Advertisement
Guest User

Untitled

a guest
Sep 15th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.48 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <title>Master RW</title>
  4. <meta name="viewport" content="width=device-width, initial-scale=1">
  5. <link rel="stylesheet" href="css/w3.css">
  6. <!--<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway">-->
  7. <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">
  8.  
  9. <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
  10. <link href="//cdnjs.cloudflare.com/ajax/libs/octicons/3.5.0/octicons.min.css" rel="stylesheet">
  11. <link href="../colorpicker/dist/css/bootstrap-colorpicker.min.css" rel="stylesheet">
  12. <link href="../colorpicker/docs/assets/main.css" rel="stylesheet">
  13.  
  14. <script src="//code.jquery.com/jquery-2.2.2.min.js"></script>
  15. <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  16. <script src="../colorpicker/dist/js/bootstrap-colorpicker.js"></script>
  17. <!--
  18. <link rel="stylesheet" href="css/bootstrap/css/bootstrap.min.css">
  19. <script src="css/jquery-1.12.2.min.js"></script>
  20. <script src="css/bootstrap/js/bootstrap.min.js"></script>
  21. -->
  22. <script src="css/bootstrapvalidator.min.js"></script>
  23. <script src="modal/bootstrap.js" type="text/javascript"></script>
  24. <script src="css/jscolor.js"></script>
  25. <style>
  26. .modal-header, h4, .close {
  27. background-color: #5cb85c;
  28. color:white !important;
  29. text-align: center;
  30. font-size: 30px;
  31. }
  32. .modal-footer {
  33. background-color: #f9f9f9;
  34. }
  35. #trtabel {
  36. background-color: #5cb85c;
  37. color:white !important;
  38. text-align: center;
  39. }
  40. #modalhapus,{
  41. background-color: #0099FF;
  42. color:white !important;
  43. text-align: center;
  44. font-size: 30px;
  45. }
  46. #logout {
  47. color: white;
  48.  
  49. }
  50. td {
  51. background: white;
  52. }
  53. .square {
  54. position: absolute;
  55. width: 20px;
  56. height: 20px;
  57. }
  58. </style>
  59. <style>
  60. html,body,h1,h2,h3,h4,h5 {font-family: "Raleway", sans-serif}
  61. </style>
  62. <body class="w3-light-grey">
  63.  
  64. <!-- Top container -->
  65. <div class="w3-container w3-top w3-green w3-large w3-padding" style="z-index:4">
  66. <button class="w3-btn w3-hide-large w3-padding-0 w3-hover-text-grey" onclick="w3_open();"><i class="fa fa-bars"></i>  Menu</button>
  67. <span class="w3-Left">Halaman Admin</span>
  68. <a href="logout.php"><span id="logout" class="w3-right glyphicon glyphicon-log-out"> Logout</span></a>
  69. </div>
  70.  
  71. <!-- Sidenav/menu -->
  72. <nav class="w3-sidenav w3-collapse w3-white w3-animate-left" style="z-index:3;width:300px;" id="mySidenav"><br>
  73. <div class="w3-container w3-row">
  74. <div class="w3-col s3">
  75. <img src="css/img_avatar3.png" class="w3-circle w3-margin-right" style="width:46px">
  76. </div>
  77. <?php
  78. session_start();
  79. /**
  80. * Jika Tidak login atau sudah login tapi bukan sebagai admin
  81. * maka akan dibawa kembali kehalaman login atau menuju halaman yang seharusnya.
  82. */
  83. if ( !isset($_SESSION['user_login']) ||
  84. ( isset($_SESSION['user_login']) && $_SESSION['user_login'] != 'admin' ) ) {
  85.  
  86. header('location:./login.php');
  87. exit();
  88. }
  89. ?>
  90. <div class="w3-col s9">
  91. <span>Admin, <strong><?=$_SESSION['nama'];?></strong></span><br>
  92.  
  93. </div>
  94. </div>
  95. <hr>
  96. <div class="w3-container" >
  97. <h5>Menu</h5>
  98. </div>
  99. <a href="#" class="w3-padding-16 w3-hide-large w3-dark-grey w3-hover-black" onclick="w3_close()" title="close menu"><i class="fa fa-remove fa-fw"></i>  Close Menu</a>
  100. <a href="#" class="w3-padding "><span class="glyphicon glyphicon-dashboard"></span> Dashboard</a>
  101. <a href="" class="w3-padding w3-grey"><i class="glyphicon glyphicon-menu-right"></i> Data Master</a>
  102. <a href="tampil_kelurahan.php" class="w3-padding "><i class="glyphicon glyphicon-th-list"></i> Master Kelurahan</a>
  103. <a href="tampil_rw.php" class="w3-padding w3-green"><i class="glyphicon glyphicon-th-list"></i> Master RW</a>
  104. <a href="tampil_kk.php" class="w3-padding"><i class="glyphicon glyphicon-th-list"></i> Master KK</a>
  105. <a href="tampil_penduduk.php" class="w3-padding"><i class="glyphicon glyphicon-th-list"></i> Master Penduduk</a>
  106. <a href="" class="w3-padding w3-grey"><i class="glyphicon glyphicon-menu-right"></i> Kategori Warna Pemetaan</a>
  107. <a href="status/index.php" class="w3-padding"><i class="glyphicon glyphicon-map-marker"></i> Status Jumlah Penduduk</a>
  108. <a href="status_jmlkk/index.php" class="w3-padding "><i class="glyphicon glyphicon-map-marker"></i> Status Jumlah KK</a>
  109. <a href="status_kk/index.php" class="w3-padding"><i class="glyphicon glyphicon-map-marker"></i> Status Jumlah Penduduk Miskin</a>
  110.  
  111. </nav>
  112.  
  113.  
  114. <!-- Overlay effect when opening sidenav on small screens -->
  115. <div class="w3-overlay w3-hide-large w3-animate-opacity" onclick="w3_close()" style="cursor:pointer" title="close side menu" id="myOverlay"></div>
  116.  
  117. <!-- !PAGE CONTENT! -->
  118. <div class="w3-main" style="margin-left:300px;margin-top:43px;">
  119. <?php
  120. include "koneksi.php";
  121. ?>
  122. <div class="row" >
  123. <div class="col-sm-1"></div>
  124.  
  125. <div class="col-sm-10" id="konten" style="margin-top:20px;">
  126. <h3>Master RW</h3>
  127. <table border="1" class="table table-striped w3-card-4">
  128. <tr id="trtabel">
  129. <th>Id RW</th>
  130. <th>Id Kelurahan</th>
  131. <th>Nama RW</th>
  132. <th>Alamat</th>
  133. <th>Polygon</th>
  134. <th colspan="2" >Opsi</th>
  135. </tr>
  136. <?php
  137. $batas = 5;
  138. $pg = isset( $_GET['pg'] ) ? $_GET['pg'] : "";
  139.  
  140. if ( empty( $pg ) ) {
  141. $posisi = 0;
  142. $pg = 1;
  143. } else {
  144. $posisi = ( $pg - 1 ) * $batas;
  145. }
  146.  
  147. $query = "select * from tb_rw limit $posisi, $batas";
  148. $result = mysqli_query($sambung, $query);
  149. //$no = 0;
  150. while ($buff = mysqli_fetch_array($result)){
  151. //$no++;
  152. ?>
  153. <tr>
  154. <td><?php echo $buff['id_rw']; ?></td>
  155. <td><?php echo $buff['id_kelurahan']; ?></td>
  156. <td><?php echo "RW ".$buff['nama_rw']; ?></td>
  157. <td><?php echo $buff['alamat']; ?></td>
  158. <td><?php echo $buff['polygon']; ?></td>
  159. <td>
  160. <div class="button-toolbar">
  161. <a href="ubah_rw.php?id_rw=<?php echo $buff ['id_rw']; ?>" class="btn btn-warning glyphicon glyphicon-pencil" role="button" data-toggle="tooltip" title="Edit" data-placement="bottom"></a>
  162.  
  163. <a href="#" onclick="confirm_modal('hapus_rw.php?id_rw=<?php echo $buff['id_rw']; ?>');" class="btn btn-danger glyphicon glyphicon-trash" data-toggle="tooltip" title="Hapus" data-placement="bottom"></a></div></td>
  164. <!-- Trigger the modal with a button -->
  165.  
  166.  
  167. </tr>
  168.  
  169. <?php
  170. };
  171.  
  172. //hitung jumlah data
  173. $jml_data = mysqli_num_rows(mysqli_query($sambung,"select * from tb_rw"));
  174. //Jumlah halaman
  175. $JmlHalaman = ceil($jml_data/$batas); //ceil digunakan untuk pembulatan keatas
  176.  
  177.  
  178.  
  179. mysqli_close($sambung);
  180. ?>
  181.  
  182. </table>
  183.  
  184. </div>
  185.  
  186.  
  187. </div>
  188. <div class="row" >
  189. <div class="col-sm-1"></div>
  190.  
  191.  
  192. <!--TAMBAH DATA-->
  193.  
  194. <!-- Trigger the modal with a button -->
  195. <div class="col-sm-5">
  196. <button type="button" class="btn btn-success btn-lg" id="myBtn">Tambah</button></div>
  197. <div class="col-sm-6">
  198. <?php
  199. //Navigasi ke sebelumnya
  200. if ( $pg > 1 ) {
  201. $link = $pg-1;
  202. $prev = "<a href='?pg=$link'>Sebelumnya </a>";
  203. } else {
  204. $prev = "Sebelumnya ";
  205. }
  206.  
  207. //Navigasi nomor
  208. $nmr = '';
  209. for ( $i = 1; $i<= $JmlHalaman; $i++ ){
  210.  
  211. if ( $i == $pg ) {
  212. $nmr .= $i . " ";
  213. } else {
  214. $nmr .= "<a href='?pg=$i'>$i</a> ";
  215. }
  216. }
  217.  
  218. //Navigasi ke selanjutnya
  219. if ( $pg < $JmlHalaman ) {
  220. $link = $pg + 1;
  221. $next = " <a href='?pg=$link'>Selanjutnya</a>";
  222. } else {
  223. $next = " Selanjutnya";
  224. }
  225.  
  226. //Tampilkan navigasi
  227. echo $prev . $nmr . $next;
  228.  
  229. ?>
  230. </div>
  231. <!-- Modal -->
  232. <div class="modal fade" id="myModal" role="dialog">
  233. <div class="modal-dialog">
  234.  
  235. <!-- Modal content-->
  236. <div class="modal-content">
  237. <div class="modal-header" style="padding:35px 50px;">
  238. <button type="button" class="close" data-dismiss="modal">&times;</button>
  239. <h4><span class="glyphicon glyphicon-lock"></span>Tambah Data RW</h4>
  240. </div>
  241. <div class="modal-body" style="padding:40px 50px;">
  242. <form role="form" class="form-horizontal" name="form1" action="entry_rw.php" method="POST" id="contact_form">
  243. <?php require('koneksi.php'); ?>
  244. <!--menampilkan id otomatis-->
  245. <?php
  246.  
  247. $hostname = 'localhost'; // server mysql
  248. $username = 'root'; // user mysql
  249. $password = ''; // pasword mysql
  250. $database = 'solo'; // nama database
  251. try
  252. {
  253. $dbh = new PDO("mysql:host=$hostname;dbname=$database", $username, $password);
  254.  
  255. }
  256. catch(PDOException $e)
  257. {
  258. echo $e->getMessage();
  259. }
  260. $query = $dbh->query('SELECT MAX(id_rw) as kodex FROM tb_rw');
  261. $data = $query->fetch();
  262. $kode = $data['kodex'];
  263. $nourut = ($kode);
  264. $nourut++; ?>
  265. <div class="form-group">
  266. <label for="psw"><span class="glyphicon glyphicon-user"></span> ID RW : </label>
  267. <input type="text" class="form-control" id="id_rw" name="id_rw" placeholder="ID RW" value="<?php echo $nourut; ?>">
  268. </div>
  269. <div class="form-group ">
  270. <label for="id" ><span class="glyphicon glyphicon-home"></span> Kelurahan:</label>
  271. <select name="id_kelurahan" id="id_kelurahan" class="form-control">
  272. <option value="">--Daftar Kelurahan--</option>
  273. <?php
  274. $sql = mysqli_query($sambung,"SELECT * FROM `tb_kelurahan`");
  275. while($val = mysqli_fetch_array($sql)) {
  276. echo '<option value="'.$val['id_kelurahan'].'">'.$val['nama_kelurahan'].'</option>';
  277. }
  278. ?>
  279. </select>
  280. </div>
  281. <div class="form-group">
  282. <label for="psw"><span class="glyphicon glyphicon-home"></span> Nama RW : </label>
  283. <input type="text" class="form-control" id="nama_rw" name="nama_rw" placeholder="Masukan Nama RW">
  284. </div>
  285.  
  286. <div class="form-group">
  287. <label for="psw"><span class="glyphicon glyphicon-globe"></span> Alamat : </label>
  288. <input type="text" class="form-control" id="alamat" name="alamat" placeholder="alamat">
  289. </div>
  290. <div class="form-group">
  291. <button type="button" class="btn btn-success btn-sm glyphicon glyphicon-map-marker" id="myBtn2" data-toggle="tooltip" title="Pencari Koordinate Polygon"></button>
  292. <label for="psw"><span class="glyphicon glyphicon-map-marker"></span> Polygon : </label>
  293. <textarea type="text" class="form-control" id="polygon" name="polygon" placeholder="polygon">
  294. </textarea>
  295. </div>
  296. <button type="submit" class="btn btn-success btn-block"><span class="glyphicon glyphicon-floppy-disk"></span> SIMPAN</button>
  297. </form>
  298. </div>
  299. <div class="modal-footer">
  300. <button type="submit" class="btn btn-danger btn-default pull-left" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span>BATAL</button>
  301. </div>
  302. </div>
  303.  
  304. </div>
  305. </div>
  306. <!-- Modal Polygon-->
  307. <div class="modal fade" id="myModal2" role="dialog">
  308. <div class="modal-dialog">
  309.  
  310. <!-- Modal content-->
  311. <div class="modal-content">
  312. <div class="modal-header" >
  313. <button type="button" class="close" data-dismiss="modal">&times;</button>
  314. <h4><span class="glyphicon glyphicon-map-marker"></span>Pencari Koordinat Polygon</h4>
  315. </div>
  316.  
  317. <div class="modal-body" style="padding:40px 50px;">
  318. <iframe src="gcltool/index.html" style="width:515px; height: 600px" >
  319. <p>Your browser does not support iframes.</p>
  320. </iframe>
  321. </div>
  322.  
  323. </div>
  324.  
  325. </div>
  326. </div>
  327.  
  328. <!-- Modal Popup untuk delete-->
  329. <div class="modal fade" id="modalhapus">
  330. <div class="modal-dialog">
  331. <div class="modal-content" style="margin-top:100px;">
  332. <div class="modal-header">
  333. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  334. <h4 class="modal-title" style="text-align:center;"><span class="glyphicon glyphicon-trash"></span> Apakah Anda Yakin Ingin Menghapus Data Ini ?</h4>
  335. </div>
  336.  
  337. <div class="modal-footer" style="margin:0px; border-top:0px; text-align:center;">
  338. <a href="#" class="btn btn-danger" id="hapus">Hapus</a>
  339. <button type="button" class="btn btn-success" data-dismiss="modal">Batal</button>
  340. </div>
  341. </div>
  342. </div>
  343. </div>
  344.  
  345. <!-- End page content -->
  346. </div>
  347. <script type="text/javascript">
  348. function confirm_modal(delete_url)
  349. {
  350. $('#modalhapus').modal('show', {backdrop: 'static'});
  351. document.getElementById('hapus').setAttribute('href' , delete_url);
  352. }
  353. </script>
  354. <script>
  355. // Get the Sidenav
  356. var mySidenav = document.getElementById("mySidenav");
  357.  
  358. // Get the DIV with overlay effect
  359. var overlayBg = document.getElementById("myOverlay");
  360.  
  361. // Toggle between showing and hiding the sidenav, and add overlay effect
  362. function w3_open() {
  363. if (mySidenav.style.display === 'block') {
  364. mySidenav.style.display = 'none';
  365. overlayBg.style.display = "none";
  366. } else {
  367. mySidenav.style.display = 'block';
  368. overlayBg.style.display = "block";
  369. }
  370. }
  371.  
  372. // Close the sidenav with the close button
  373. function w3_close() {
  374. mySidenav.style.display = "none";
  375. overlayBg.style.display = "none";
  376. }
  377. </script>
  378. <script>
  379. $(document).ready(function(){
  380. $("#myBtn").click(function(){
  381. $("#myModal").modal();
  382. });
  383. });
  384.  
  385. </script>
  386. <script>
  387. $(document).ready(function(){
  388. $("#myBtn2").click(function(){
  389. $("#myModal2").modal();
  390. });
  391. });
  392.  
  393. </script>
  394.  
  395. <script type="text/javascript">
  396. $(document).ready(function() {
  397. $('#contact_form').bootstrapValidator({
  398. // To use feedback icons, ensure that you use Bootstrap v3.1.0 or later
  399. feedbackIcons: {
  400. valid: 'glyphicon glyphicon-ok',
  401. invalid: 'glyphicon glyphicon-remove',
  402. validating: 'glyphicon glyphicon-refresh'
  403. },
  404. fields: {
  405. id_rw: {
  406. validators: {
  407. integer: {
  408. min: 1,
  409. },
  410. notEmpty: {
  411. message: 'Masukan Id'
  412. }
  413. }
  414. },
  415. id_kelurahan: {
  416. validators: {
  417. integer: {
  418. min: 1,
  419. },
  420. notEmpty: {
  421. message: 'Pilih Kelurahan'
  422. }
  423. }
  424. },
  425. nama_rw: {
  426. validators: {
  427. integer: {
  428. min: 1,
  429. },
  430. notEmpty: {
  431. message: 'Masukan Nama RW'
  432. }
  433. }
  434. },
  435. alamat: {
  436. validators: {
  437.  
  438. stringLength: {
  439. min: 7,
  440. },
  441. notEmpty: {
  442. message: 'Masukan Alamat'
  443. }
  444. }
  445. },
  446. jmlpend: {
  447. validators: {
  448. integer: {
  449. min: 1,
  450. },
  451. notEmpty: {
  452. message: 'Masukan Jumlah Penduduk'
  453. }
  454. }
  455. },
  456. jmlkk: {
  457. validators: {
  458. integer: {
  459. min: 1,
  460. },
  461. notEmpty: {
  462. message: 'Masukan Jumlah KK'
  463. }
  464. }
  465. },
  466. pmiskin: {
  467. validators: {
  468. integer: {
  469. min: 1,
  470. },
  471. notEmpty: {
  472. message: 'Masukan Jumlah Penduduk Miskin'
  473. }
  474. }
  475. },
  476. polygon: {
  477. validators: {
  478.  
  479. stringLength: {
  480. min: 10,
  481. },
  482. notEmpty: {
  483. message: 'Masukan Polygon'
  484. }
  485. }
  486. },
  487.  
  488. }
  489. })
  490. .on('err.field.fv', function(e, data) {
  491. // $(e.target) --> The field element
  492. // data.fv --> The FormValidation instance
  493. // data.field --> The field name
  494. // data.element --> The field element
  495.  
  496. data.fv.disableSubmitButtons(false);
  497. })
  498. .on('success.field.fv', function(e, data) {
  499. // e, data parameters are the same as in err.field.fv event handler
  500. // Despite that the field is valid, by default, the submit button will be disabled if all the following conditions meet
  501. // - The submit button is clicked
  502. // - The form is invalid
  503. data.fv.disableSubmitButtons(false);
  504. });
  505. });
  506.  
  507. </script>
  508.  
  509. <script>
  510. $(document).ready(function(){
  511. $('[data-toggle="tooltip"]').tooltip();
  512. });
  513. </script>
  514. <script>
  515. $(function () {
  516. $('#cp2').colorpicker();
  517. });
  518. </script>
  519.  
  520. </body>
  521. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement