You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

302 regels
10 KiB

2 jaren geleden
  1. <?php
  2. ini_set('session.use_only_cookies', TRUE);
  3. ini_set('session.use_trans_sid', FALSE);
  4. session_start();
  5. require_once("conn/db.php");
  6. require_once('utils/helper.php');
  7. if (!isset($_SESSION['nim'])) {
  8. header('location:login.php');
  9. } else {
  10. $nim = $_SESSION['nim'];
  11. }
  12. $queryStudent = "SELECT
  13. TOP 1
  14. a.nim,
  15. b.nim_panitia,
  16. b.role,
  17. COUNT(c.id_pemilu) AS votes
  18. FROM
  19. tb_mhs AS a
  20. LEFT JOIN
  21. tb_panitia b ON b.nim_panitia = a.nim
  22. LEFT JOIN
  23. tb_pemilu c ON c.nim_mhs = a.nim
  24. WHERE
  25. a.nim = '$nim'
  26. GROUP BY
  27. a.nim,
  28. b.nim_panitia,
  29. b.role";
  30. $execStudent = odbc_exec($koneksi, $queryStudent);
  31. $student = dbGet($execStudent)[0];
  32. // Cek dia panitia
  33. if ($student['nim_panitia'] != null) {
  34. if ((int) $student['role'] === 1) {
  35. header('location:private.php');
  36. } else {
  37. header('location:tampilanSION.php');
  38. }
  39. }
  40. // Cek dia udah vote atau belom
  41. if ((int) $student['votes'] > 0) {
  42. header('location:tampilanSION.php');
  43. } else {
  44. if (empty($_SESSION['token'])) {
  45. if (function_exists('mcrypt_create_iv')) {
  46. $_SESSION['token'] = bin2hex(mcrypt_create_iv(32, MCRYPT_DEV_URANDOM));
  47. } else {
  48. $_SESSION['token'] = bin2hex(openssl_random_pseudo_bytes(32));
  49. }
  50. }
  51. $token = $_SESSION['token'];
  52. }
  53. // Ambil profil calon
  54. $queryCandidates = "SELECT
  55. a.id_calon,
  56. a.nama_calon,
  57. a.photo,
  58. a.id_status,
  59. b.visi,
  60. b.misi
  61. FROM
  62. tb_calon AS a
  63. INNER JOIN
  64. tb_visimisi b ON b.id_calon = a.id_calon
  65. ORDER BY a.photo";
  66. $execCandidates = odbc_exec($koneksi, $queryCandidates);
  67. $candidates = dbGet($execCandidates);
  68. $sema = array_filter($candidates, function ($item) {
  69. return $item['id_status'] === 'KTU3vVnd';
  70. });
  71. $balma = array_filter($candidates, function ($item) {
  72. return $item['id_status'] === 'S9af54pY';
  73. });
  74. ?>
  75. <!doctype html>
  76. <html>
  77. <head>
  78. <meta charset="utf-8">
  79. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  80. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  81. <title>Poling Pemilu Raya <?= date('Y') ?></title>
  82. <link href="public/css/bootstrap.css" rel="stylesheet">
  83. <link href="public/css/normalize.css" rel="stylesheet">
  84. <link href="public/css/style.css" rel="stylesheet">
  85. </head>
  86. <body>
  87. <header>
  88. <div>
  89. <img class="img-responsive shd one" src="public/images/banner.png">
  90. </div>
  91. <div class="clearfix"></div>
  92. </header>
  93. <main>
  94. <form action="validate.php" method="post">
  95. <div class="text-center lists-striped" data-toggle="buttons">
  96. <h1 class="ttl" style="font-size:50px; margin-bottom:24px;">POLLING PEMILU RAYA <?= date('Y') ?><br></h1>
  97. <p class="text-warning" style="font-size:16px; margin-bottom:24px;">
  98. <em>
  99. <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> Pilih 1 calon Sema dan 1 calon Balma, kemudian klik tombol <b>Simpan</b> yang berada di paling bawah untuk menyimpan vote anda.
  100. </em>
  101. </p>
  102. <!--data-toggle="buttons"-->
  103. <input type="hidden" name="token_" value="<?= $token ?>" />
  104. <?php
  105. if (isset($_SESSION['get'])) {
  106. $get = $_GET['get'];
  107. if ($get == 1) {
  108. $msg = 'Ada Katagori yang belum di polling';
  109. } else if($get == 2) {
  110. $msg = 'Tidak bisa melakukan poling lagi';
  111. } else if($get == 3) {
  112. $msg = 'Tidak dapat melakukan poling';
  113. } else {
  114. $msg = 'Tidak dapat melakukan poling, silahkan coba kembali !';
  115. }
  116. ?>
  117. <div class="container">
  118. <div class="row">
  119. <div class="col-md-6 col-md-push-3 col-sm-10 col-sm-push-1">
  120. <div class="alert alert-danger alert-dismissible fade in" role="alert">
  121. <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  122. <span aria-hidden="true">&times;</span>
  123. </button>
  124. <strong>
  125. <span class="glyphicon glyphicon-remove-sign" aria-hidden="true"></span> <?= $msg; ?>
  126. </strong>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. <?php
  132. }
  133. unset($_SESSION['get']);
  134. ?>
  135. <!-- <div class="stripe"></div> -->
  136. <h1 class="ttl">Calon Ketua & Wakil Ketua Senat Mahasiswa</h1>
  137. <div class="lines"></div>
  138. <p class="text-warning">
  139. <em>
  140. <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> Klik salah satu foto atau nama untuk polling
  141. </em>
  142. </p>
  143. <div class="container">
  144. <div class="row">
  145. <?php
  146. $no = 1;
  147. $inputName = 'senat';
  148. foreach ($sema as $key => $item) {
  149. ?>
  150. <div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
  151. <?php include('./components/card-vote.php'); ?>
  152. </div>
  153. <?php
  154. }
  155. ?>
  156. </div>
  157. </div>
  158. <div class="clearfix" style="margin-top:10px;"></div>
  159. <!-- <div class="stripe-reverse"></div> -->
  160. </div>
  161. <!--end for senat-->
  162. <div class="clearfix"></div>
  163. <div class="shadow"></div>
  164. <!--for balma-->
  165. <div class="text-center lists" data-toggle="buttons">
  166. <!-- <div class="stripe"></div> -->
  167. <h1 class="ttl">Calon Ketua Badan Legislatif Mahasiswa</h1>
  168. <div class="lines"></div>
  169. <p class="text-warning">
  170. <em>
  171. <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> Klik salah satu foto atau nama untuk polling
  172. </em>
  173. </p>
  174. <div class="container">
  175. <div class="row">
  176. <?php
  177. $no = 1;
  178. $inputName = 'balma';
  179. foreach ($balma as $key => $item) {
  180. ?>
  181. <div class="col-lg-push-2 col-lg-4 col-md-6 col-sm-6 col-xs-12">
  182. <?php include('./components/card-vote.php'); ?>
  183. </div>
  184. <?php
  185. }
  186. ?>
  187. </div>
  188. </div>
  189. <div class="clearfix" style="margin-top: 15px;"></div>
  190. <!-- <div class="stripe-reverse"></div> -->
  191. </div>
  192. <!--end for balma-->
  193. <div class="clearfix"></div>
  194. <!--end for modal-->
  195. <div class="text-center">
  196. <button type="submit" name="formSubmit" value="Submit" class="btn btn-lg btn-success submit">Simpan <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button>
  197. </div>
  198. </form>
  199. </main>
  200. <footer>
  201. <div class="clearfix"></div>
  202. <div class="text-center">
  203. <img class="img-responsive one" src="public/images/banner2.png">
  204. <div class="lists-footer">
  205. <p style="margin:0 5px;">Copyright &copy; <?= date('Y') ?> IT Support Pemira</p>
  206. </div>
  207. </div>
  208. </footer>
  209. <!--for modal-->
  210. <div class="modal fade" id="visimisi" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
  211. <div class="modal-dialog modal-md">
  212. <div class="modal-content">
  213. <div class="modal-header">
  214. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  215. <span aria-hidden="true">&times;</span>
  216. </button>
  217. <h4 class="modal-title" style="text-align:center;"></h4>
  218. </div>
  219. <div class="modal-body">
  220. <div class="imginsert" style="text-align:center;"></div>
  221. <h2 style="text-align:center;">Visi</h2>
  222. <div class="visi"></div>
  223. <h2 style="text-align:center;">Misi</h2>
  224. <div class="misi"></div>
  225. </div>
  226. <div class="modal-footer">
  227. <button type="button" class="btn btn-default" data-dismiss="modal">Tutup</button>
  228. </div>
  229. </div>
  230. </div>
  231. </div>
  232. <script src="public/js/jquery-3.3.1.min.js"></script>
  233. <script src="public/js/bootstrap.min.js"></script>
  234. <script>
  235. $(document).ready(function() {
  236. $('#visimisi').on('show.bs.modal', function (event) {
  237. var button = $(event.relatedTarget)
  238. var recipient = button.data('kandidat')
  239. var recipient2 = button.data('visi')
  240. var recipient3 = button.data('misi')
  241. var recipient4 = button.data('img')
  242. var modal = $(this)
  243. modal.find('.modal-title').text(recipient)
  244. modal.find('.visi').html(recipient2)
  245. modal.find('.misi').html(recipient3)
  246. modal.find('.imginsert').html('<img class="img-responsive img-thumbnail" src="' + recipient4 + '" alt="asdad">')
  247. });
  248. });
  249. </script>
  250. </body>
  251. </html>