Advertisement
kzwhkzw

Untitled

Sep 25th, 2020
1,645
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.62 KB | None | 0 0
  1. <?php
  2.  
  3. $tanggal=WKT(date("Y-m-d"));
  4. $pro="simpan";
  5. $gambar0="avatar.jpg";
  6. //$PATH="ypathcss";
  7. ?>
  8. <link type="text/css" href="<?php echo "$PATH/base/";?>ui.all.css" rel="stylesheet" />  
  9. <script type="text/javascript" src="<?php echo "$PATH/";?>jquery-1.3.2.js"></script>
  10. <script type="text/javascript" src="<?php echo "$PATH/";?>ui/ui.core.js"></script>
  11. <script type="text/javascript" src="<?php echo "$PATH/";?>ui/ui.datepicker.js"></script>
  12. <script type="text/javascript" src="<?php echo "$PATH/";?>ui/i18n/ui.datepicker-id.js"></script>
  13.    
  14.   <script type="text/javascript">
  15.       $(document).ready(function(){
  16.         $("#tanggal").datepicker({
  17.                     dateFormat  : "dd MM yy",        
  18.           changeMonth : true,
  19.           changeYear  : true                   
  20.         });
  21.       });
  22.     </script>    
  23.  
  24. <script type="text/javascript">
  25. function PRINT(){
  26. win=window.open('wisata/print.php','win','width=1000, height=400, menubar=0, scrollbars=1, resizable=0, location=0, toolbar=0, keterangan=0'); }
  27. </script>
  28. <script language="JavaScript">
  29. function buka(url) {window.open(url, 'window_baru', 'width=800,height=600,left=320,top=100,resizable=1,scrollbars=1');}
  30. </script>
  31.  
  32. <?php
  33.   $sql="select `id_wisata` from `$tbwisata` order by `id_wisata` desc";
  34.   $q=mysqli_query($conn, $sql);
  35.   $jum=mysqli_num_rows($q);
  36.   $th=date("y");
  37.   $bl=date("m")+0;if($bl<10){$bl="0".$bl;}
  38.  
  39.   $kd="WIS".$th.$bl;//KEG1610001
  40.   if($jum > 0){
  41.    $d=mysqli_fetch_array($q);
  42.    $idmax=$d["id_wisata"];
  43.    
  44.    $bul=substr($idmax,5,2);
  45.    $tah=substr($idmax,3,2);
  46.     if($bul==$bl && $tah==$th){
  47.      $urut=substr($idmax,7,3)+1;
  48.      if($urut<10){$idmax="$kd"."00".$urut;}
  49.      else if($urut<100){$idmax="$kd"."0".$urut;}
  50.      else{$idmax="$kd".$urut;}
  51.     }//==
  52.     else{
  53.      $idmax="$kd"."001";
  54.      }  
  55.    }//jum>0
  56.   else{$idmax="$kd"."001";}
  57.   $id_wisata=$idmax;
  58. ?>
  59. <?php
  60. if($_GET["pro"]=="ubah"){
  61.     $id_wisata=$_GET["kode"];
  62.     $sql="select * from `$tbwisata` where `id_wisata`='$id_wisata'";
  63.     $d=getField($conn,$sql);
  64.                 $id_wisata=$d["id_wisata"];
  65.                 $nama_wisata=$d["nama_wisata"];
  66.                 $telepon=$d["telepon"];
  67.                 $alamat=$d["alamat"];
  68.                 $latitude=$d["latitude"];
  69.                 $longitude=$d["longitude"];
  70.                 $deskripsi=$d["deskripsi"];
  71.                 $keterangan=$d["keterangan"];
  72.                 $gambar=$d["gambar"];
  73.                 $gambar0=$d["gambar"];
  74.                 $pro="ubah";       
  75. }
  76. ?>
  77.  
  78.  
  79. <?php
  80. if($_GET["pro"]=="tambah" ||$_GET["pro"]=="ubah" ){
  81.     ?>
  82.   <div STYLE=" height: 100%; width: 100%; font-size: 12px; overflow: auto;">  
  83. <form  action="" method="post" enctype="multipart/form-data">
  84. <table class="table table-striped table-bordered table-hover"  width="47%" >
  85. <tr>
  86. <th width="164"><label for="id_wisata">ID wisata</label>
  87. <th width="11">:
  88. <th colspan="2"><b><?php echo $id_wisata;?></b></tr>
  89. <tr>
  90. <td><label for="nama_wisata">Nama wisata</label>
  91. <td>:<td width="415"><input name="nama_wisata" type="text" id="nama_wisata" value="<?php echo $nama_wisata;?>" size="25" />
  92. </td>
  93.  
  94. </tr>
  95.  
  96. <tr>
  97. <td height="24"><label for="telepon">Telepon</label>
  98. <td>:<td><input name="telepon" type="text" id="telepon" value="<?php echo $telepon;?>" size="15" /></td>
  99. </tr>
  100.  
  101.  
  102. <tr>
  103. <td height="24"><label for="alamat">Alamat</label>
  104. <td>:<td><textarea name="alamat" cols="35" rows="3" id="alamat"><?php echo $alamat;?></textarea>
  105. </td>
  106. </tr>
  107.  
  108. <tr>
  109. <td height="24"><label for="latitude">Latitude</label>
  110. <td>:<td><input name="latitude" type="text" id="latitude" value="<?php echo $latitude;?>" size="20" />
  111. </td>
  112. </tr>
  113.  
  114. <tr>
  115. <td height="24"><label for="longitude">Longitude</label>
  116. <td>:<td><input name="longitude" type="longitude" id="longitude" value="<?php echo $longitude;?>" size="20" />
  117. </td>
  118. </tr>
  119.  
  120.  
  121. <tr>
  122. <td height="24"><label for="deskripsi">Deskripsi</label>
  123. <td>:<td><textarea name="deskripsi" cols="45" rows="4" id="deskripsi"><?php echo $deskripsi;?></textarea>
  124. </td>
  125. </tr>
  126.  
  127. <tr>
  128. <td><label for="keterangan">Keterangan</label>
  129. <td>:<td colspan="2">
  130. <textarea name="keterangan" cols="35" rows="3" id="keterangan"><?php echo $keterangan;?></textarea>
  131. </td></tr>
  132.  
  133. <tr>
  134.   <td height="24"><label for="gambar">Gambar</label>
  135.     <td>:<td colspan="2">
  136.         <input name="gambar" type="file" id="gambar" size="20" />
  137.       => <a href='#' onclick='buka("admin/zoom.php?id=<?php echo $kode_admin;?>")'><?php echo $gambar0;?></a></td>
  138. </tr>
  139.  
  140. <tr>
  141. <td>
  142. <td>
  143. <td colspan="2"><input name="Simpan" class="btn btn-success"  type="submit" id="Simpan" value="Simpan" />
  144.         <input name="pro" type="hidden" id="pro" value="<?php echo $pro;?>" />
  145.         <input name="gambar0" type="hidden" id="gambar0" value="<?php echo $gambar0;?>" />
  146.         <input name="id_wisata" type="hidden" id="id_wisata" value="<?php echo $id_wisata;?>" />
  147.         <input name="id_wisata0" type="hidden" id="id_wisata0" value="<?php echo $id_wisata0;?>" />
  148.         <a href="?mnu=wisata"><input name="Batal" class="btn btn-danger"  type="button" id="Batal" value="Batal" /></a>
  149. </td></tr>
  150. </table>
  151. </form>
  152. </div>
  153.  
  154. <?php }
  155. else {?>
  156. <a class="blue" href="?mnu=wisata&pro=tambah"><button type="button" class="btn btn-info"><i class="fa fa-plus-square"></i> Tambah Data </button></a>
  157.  
  158. <p>
  159. Data wisata: | <img src='ypathicon/print.png' alt='PRINT' OnClick="PRINT()"> |
  160. </p>
  161. <br>
  162.  
  163.  
  164. <table id="bootstrap-data-table-export" class="table table-striped table-bordered" width="100%" border="0">
  165. <thead>
  166.   <tr bgcolor="#cccccc">
  167.     <th width="3%">No</td>
  168.     <th width="9%">Gambar</td>
  169.     <th width="66%">Nama wisata</td>
  170.     <th width="14%">Telepon</td>
  171.     <th width="8%">Menu</td>
  172.   </tr>
  173.   </thead>
  174.     <tbody>
  175. <?php  
  176.   $sql="select * from `$tbwisata` order by `id_wisata` desc";
  177.   $jum=getJum($conn,$sql);
  178.         if($jum > 0){
  179.  
  180. $no =1;
  181. //--------------------------------------------------------------------------------------------                                 
  182.     $arr=getData($conn,$sql);
  183.         foreach($arr as $d) {                      
  184.                 $id_wisata=$d["id_wisata"];
  185.                 $nama_wisata=$d["nama_wisata"];
  186.                 $telepon=$d["telepon"];
  187.                 $alamat=$d["alamat"];
  188.                 $latitude=$d["latitude"];
  189.                 $longitude=$d["longitude"];
  190.                 $deskripsi=$d["deskripsi"];
  191.                 if(strlen($deskripsi)>250){$deskripsi=substr($deskripsi." ...",0,250);}
  192.                 $keterangan=$d["keterangan"];
  193.                 $gambar=$d["gambar"];
  194.                 $gambar0=$d["gambar"];
  195.                 $color="#dddddd";      
  196.                     if($no %2==0){$color="#eeeeee";}
  197. echo"<tr bgcolor='$color'>
  198.                 <td>$no</td>
  199.                
  200.                 <td><div align='center'>";
  201. echo"<a href='#' onclick='buka(\"wisata/zoom.php?id=$id_wisata\")'>
  202. <img src='$YPATH/$gambar' width='40' height='40' /></a></div>";
  203.                 echo"</td>
  204.                
  205.                 <td><b>$nama_wisata</b> ($id_wisata)</br>
  206.                 <b>Alamat :</b>  <i>$alamat</i><br>Lat : $latitude - Lon : $longitude</br></br>
  207.                 <b>Keterangan :</b>  $keterangan</br></br>
  208.                 <b>Deskripsi :</b>  <i>$deskripsi</i></td>
  209.                 <td>$telepon</td>
  210.                
  211.                 <td><div align='center'>
  212. <a href='?mnu=wisata&pro=ubah&kode=$id_wisata'><button type='button' class='btn-primary'><i class='fa fa-refresh'></i></button></a> <br><br>
  213. <a href='?mnu=wisata&pro=hapus&kode=$id_wisata'>
  214. <button type='button' class='btn-danger'
  215. onClick='return confirm(\"Apakah Anda benar-benar akan menghapus $nama_wisata pada data wisata ?..\")'><i class='fa fa-trash-o'></i></button></a></div></td>
  216.                 </tr>";
  217.                
  218.             $no++;
  219.             }//while
  220.         }//if
  221.         else{echo"<tr><td colspan='6'><blink>Maaf, Data wisata belum tersedia...</blink></td></tr>";}
  222. ?>
  223. </tbody>
  224. </table>
  225.  
  226.  
  227. <?php } ?>
  228.  
  229. <?php
  230. if(isset($_POST["Simpan"])){
  231.     $pro=strip_tags($_POST["pro"]);
  232.     $id_wisata=strip_tags($_POST["id_wisata"]);
  233.     $id_wisata0=strip_tags($_POST["id_wisata"]);
  234.     $nama_wisata=strip_tags($_POST["nama_wisata"]);
  235.     $telepon=strip_tags($_POST["telepon"]);
  236.     $alamat=strip_tags($_POST["alamat"]);
  237.     $latitude=strip_tags($_POST["latitude"]);
  238.     $longitude=strip_tags($_POST["longitude"]);
  239.     $deskripsi=$_POST["deskripsi"];
  240.     $keterangan=strip_tags($_POST["keterangan"]);
  241.    
  242.     $gambar0=strip_tags($_POST["gambar0"]);
  243.     if ($_FILES["gambar"] != "") {
  244.         @copy($_FILES["gambar"]["tmp_name"],"$YPATH/".$_FILES["gambar"]["name"]);
  245.         $gambar=$_FILES["gambar"]["name"];
  246.         }
  247.     else {$gambar=$gambar0;}
  248.     if(strlen($gambar)<1){$gambar=$gambar0;}
  249.    
  250.    
  251. if($pro=="simpan"){
  252. $sql=" INSERT INTO `$tbwisata` (
  253. `id_wisata` ,
  254. `nama_wisata` ,
  255. `telepon` ,
  256. `alamat` ,
  257. `latitude` ,
  258. `longitude` ,
  259. `deskripsi` ,
  260. `keterangan`  ,
  261. `gambar`  
  262. ) VALUES (
  263. '$id_wisata',
  264. '$nama_wisata',
  265. '$telepon',
  266. '$alamat',
  267. '$latitude',
  268. '$longitude',
  269. '$deskripsi',
  270. '$keterangan',
  271. '$gambar'
  272. )";
  273.    
  274. $simpan=process($conn,$sql);
  275.     if($simpan) {echo "<script>alert('Data $id_wisata berhasil disimpan !');document.location.href='?mnu=wisata';</script>";}
  276.         else{echo"<script>alert('Data $id_wisata gagal disimpan...');document.location.href='?mnu=wisata';</script>";}
  277.     }
  278.     else{
  279.     $sql="update `$tbwisata` set
  280.     `nama_wisata`='$nama_wisata',
  281.     `telepon`='$telepon',
  282.     `alamat`='$alamat' ,
  283.     `latitude`='$latitude',
  284.     `longitude`='$longitude',
  285.     `deskripsi`='$deskripsi',
  286.     `keterangan`='$keterangan',
  287.     `gambar`='$gambar'
  288.  
  289.     where `id_wisata`='$id_wisata0'";
  290.     $ubah=process($conn,$sql);
  291.         if($ubah) {echo "<script>alert('Data $id_wisata berhasil diubah !');document.location.href='?mnu=wisata';</script>";}
  292.         else{echo"<script>alert('Data $id_wisata gagal diubah...');document.location.href='?mnu=wisata';</script>";}
  293.     }//else simpan
  294. }
  295. ?>
  296.  
  297. <?php
  298. if($_GET["pro"]=="hapus"){
  299. $id_wisata=$_GET["kode"];
  300. $sql="delete from `$tbwisata` where `id_wisata`='$id_wisata'";
  301. $hapus=process($conn,$sql);
  302.     if($hapus) {echo "<script>alert('Data $id_wisata berhasil dihapus !');document.location.href='?mnu=wisata';</script>";}
  303.     else{echo"<script>alert('Data $id_wisata gagal dihapus...');document.location.href='?mnu=wisata';</script>";}
  304. }
  305. ?>
  306.  
  307.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement