emprit

datepicker_fail

Jun 20th, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.02 KB | None | 0 0
  1. <?php
  2.     include "js/indo_tgl.php";
  3. ?>
  4.  
  5. <script type="text/javascript" src="js/jquery.min.js"></script>
  6. <link href="css/bootstrap.min.css" rel="stylesheet">
  7. <script src="js/bootstrap.min.js" type="text/javascript"></script>
  8. <link href="css/all.css" rel="stylesheet" type="text/css" />
  9. <script src="js/bootstrap-modal.js"></script>
  10. <link rel="stylesheet" href="css/jquery-ui.css" />
  11. <script type="text/javascript" src="js/jquery.main.js"></script>
  12. <script src="js/jquery-ui.js"></script>
  13. <script src="js/json2.js"></script>
  14.  
  15. <script type="text/javascript">
  16. $(function(){
  17.  
  18.     $("#inputmsk").on('click',function () {
  19.         $("#msk").load('form_masuk.php');
  20.     });
  21.  
  22.     $(".datepicker").datepicker({dateFormat: 'yy-mm-dd'});
  23.  
  24.     $.fn.values = function(data) {
  25.         var els = $(this).find(':input').get();
  26.  
  27.         if(typeof data != 'object') {
  28.             // return all data
  29.             data = {};
  30.  
  31.             $.each(els, function() {
  32.                 if (this.name && !this.disabled && (this.checked
  33.                                 || /select|textarea/i.test(this.nodeName)
  34.                                 || /text|hidden|password/i.test(this.type))) {
  35.                     data[this.name] = $(this).val();
  36.                 }
  37.             });
  38.             return data;
  39.         } else {
  40.             $.each(els, function() {
  41.                 if (this.name && data[this.name]) {
  42.                     if(this.type == 'checkbox' || this.type == 'radio') {
  43.                         $(this).attr("checked", (data[this.name] == $(this).val()));
  44.                     } else {
  45.                         $(this).val(data[this.name]);
  46.                     }
  47.                 }
  48.             });
  49.             return $(this);
  50.         }
  51.     }
  52.  
  53.         $('.delete').click(function(){
  54.             var data_urll = $(this).attr('href');
  55.             var element_delete = $(this).parent().parent();
  56.             var conff = confirm('Yakin ingin menghapus Data ini?');
  57.            
  58.                 if(conff == true){
  59.                     $.getJSON(data_urll,function(respons){
  60.                             if(respons.successs == 1)
  61.                             {
  62.                                 $(".notif").show().html("Data Terhapus");
  63.                                 element_delete.remove();
  64.                             }
  65.                             else{
  66.                                 $(".notif").show().html("Gagal Menghapus");
  67.                             }
  68.                         }) 
  69.                 }else{
  70.                     return false;
  71.                 }
  72.             return false;
  73.         });
  74. });
  75. </script>
  76.  
  77. <div id="msk">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  78.     <button type="submit" class="btn btn-primary" id="inputmsk">Input Surat Masuk</button>
  79.  
  80.     <div class='notif' style='display:none; color:#468847;background-color:#dff0d8;border-color:#d6e9c6;padding:8px 35px 8px 14px;margin-bottom:20px;text-shadow:0 1px 0 rgba(255,255,255,0.5);border:1px solid #fbeed5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;font-size: 30px;text-align:center' ></div>
  81.  
  82.     <table class="table table-striped" width="50px">
  83.         <thead>
  84.             <tr>
  85.                 <th>No.</th>
  86.                 <th>No. Surat</th>
  87.                 <th>Tanggal Surat</th>
  88.                 <th>Perihal</th>
  89.                 <th>Tujuan</th>
  90.                 <th>Penginput</th>
  91.                 <th>Aksi</th>
  92.             </tr>
  93.         </thead>   
  94.         <tbody>
  95.  
  96.             <?php
  97.                 include "../koneksi.php";
  98.                 $queryyy = mysql_query("SELECT * FROM surat_masuk")or die(mysql_error());
  99.                
  100.                 $no=1;
  101.                 while($userr=mysql_fetch_array($queryyy)){
  102.                     $aa = mysql_query("SELECT nama FROM pegawai WHERE kode_peg='$userr[kode_peg]'");
  103.                     $ee = mysql_fetch_array($aa);
  104.             ?>
  105.  
  106.             <tr title="aksi data">
  107.                 <td><?php echo $no;?></td>
  108.                 <td><?php echo $userr['no_masuk'];?></td>
  109.                 <td><?php echo tgl_indo($userr['tgl_masuk']);?></td>
  110.                 <td><?php echo $userr['perihal'];?></td>
  111.                 <td><?php echo $userr['tujuan'];?></td>
  112.                 <td><?php echo $ee['nama'];?></td>
  113.                
  114.                 <?php
  115.                     $obj = new stdClass();
  116.                     $obj->no = $userr['no_masuk'];
  117.                     $obj->id = $userr['id_masuk'];
  118.                     $obj->tanggal  = $userr['tgl_masuk'];
  119.                     $obj->perihal = $userr['perihal'];
  120.                     $obj->tujuan = $userr['tujuan'];
  121.                     $obj->nama =  $ee['nama'];
  122.  
  123.                     $json = json_encode($obj);                                             
  124.                 ?>
  125.  
  126.                 <td data-role = '<?php echo $json;?>'>
  127.                     <?php echo "<a href='#' class='edit_modal'>Edit</a> | <a href='hapusmasuk.php?id=".$userr['id_masuk']."' class='delete'>Hapus</a>";?>
  128.                 </td>                              
  129.             </tr>
  130.  
  131.                 <?php $no++; } ?>
  132.         </tbody>
  133.     </table>
  134. </div>
  135.  
  136.  
  137.  
  138. <div id="example" class="modal hide fade in" style="display: none; ">  
  139.     <script src="js/jquery.form.js"></script>
  140.     <script>
  141.     $(function() {
  142.  
  143.         var bar = $('.bar');
  144.         var percent = $('.percent');
  145.         var status = $('#pesankk');
  146.  
  147.         $('#form').ajaxForm({
  148.             beforeSend: function() {
  149.                 status.empty();
  150.                 var percentVal = '0%';
  151.                 bar.width(percentVal)
  152.                 percent.html(percentVal);
  153.             },
  154.             uploadProgress: function(event, position, total, percentComplete) {
  155.                 var percentVal = percentComplete + '%';
  156.                 bar.width(percentVal)
  157.                 percent.html(percentVal);
  158.                         //console.log(percentVal, position, total);
  159.             },
  160.                 complete: function(xhr) {
  161.                         status.html(xhr.responseText);
  162.                         $('input').val('');
  163.                 }
  164.         });
  165.         });      
  166.     </script>
  167.     </script>
  168.     <div class="modal-header">  
  169.         <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  170.         <h3>Form Edit Data</h3>
  171.     </div>
  172.     <div id="pesan"></div>
  173.         <form class="form-horizontal" method="POST" id="form" action="update_masuk.php" enctype='multipart/form-data'>
  174.             <div class="control-group">
  175.                 <label class="control-label" for="inputEmail">Nomer Surat</label> &nbsp;&nbsp;&nbsp;
  176.                 <input type="text" placeholder="Nomer Surat" name="no" id='no'>
  177.                 <input type="hidden" name="id">
  178.             </div>     
  179.             <div class="control-group">
  180.                 <label class="control-label" for="inputPassword">Tanggal Surat</label> &nbsp;&nbsp;&nbsp;
  181.                 <input type="text" class="datepicker" placeholder="Tanggal" name="tanggal" id="tanggal">
  182.             </div>
  183.             <div class="control-group">
  184.                 <label class="control-label" for="inputEmail">Perihal</label> &nbsp;&nbsp;&nbsp;
  185.                 <input type="text" placeholder="Perihal" name="perihal" id='hal'>
  186.             </div>
  187.             <div class="control-group">
  188.                 <label class="control-label" for="inputPassword">Tujuan</label> &nbsp;&nbsp;&nbsp;
  189.                 <input type="text" placeholder="Tujuan" name="tujuan" id='tujuan'>
  190.             </div>
  191.             <div class="control-group">
  192.                 <label class="control-label" for="inputPassword">Scan Surat</label> &nbsp;&nbsp;&nbsp;
  193.                 <input type="file" name="file">
  194.             </div>
  195.             <div class="modal-footer">
  196.                 <label class="control-label" for="inputPassword"></label>
  197.                 <button type="submit" class="btn btn-primary" id="btn">Input Data</button>
  198.                 <button type="button" data-dismiss="modal" aria-hidden="true" class="btn">Cancel</button>
  199.             </div>
  200.         </form>
  201. </div>                         
  202.  
  203. <script type="text/javascript">
  204.     $(function(){
  205.         $('.edit_modal').click(function(){
  206.             var _data = $(this).closest('td').attr('data-role');
  207.             $('#example').modal('show');           
  208.             var obj = JSON.parse(_data);
  209.             $('#example form').values(obj);
  210.         });
  211.     });
  212. </script>
Advertisement
Add Comment
Please, Sign In to add comment