
<!DOCTYPE html>
<html>
   
   
    <head>
        <script src="ambildata.js"></script>
        <script src="efekscrol.js"></script>
        <title>Halaman OPD</title>

     
    </head>
    <body>
   
    <div class="content-wrapper">
   
            
        <div class ="wrapper">
        <div class="panel-body"  style ="overflow-x :auto ; overflow-y :auto ">
            
      
<?php
include '../../../config/koneksi.php';
?>
<table width="100%"  id="example1" class="table table-bordered table-striped">
<thead>
       <tr style="text-align:center ; background-color:lightgrey" >
       <th style="text-align:center"  >No</th>
       <th hidden="hidden" style="text-align:center"  >Id</th>
       <th hidden="hidden" style="text-align:center"  >Id</th>
       <th style="text-align:center"  >User</th>
       <th hidden="hidden" style="text-align:center"  >Password</th>
       <th style="text-align:center"  >Halaman</th>
       <th style="text-align:center"  >OPD</th>
       <th style="text-align:center">Aksi</th>
       </tr>
       </thead>
       <tbody>
<?php


$no=0;
$id_opdi=$_GET['id_opdi'];
$sql = "SELECT a.id_admin,a.user1, a.password1,a.halaman,a.id_opd,b.opd from admin as a inner join opd as b on 
a.id_opd=b.id_opd  where a.id_opd='$id_opdi' and a.halaman!='opd'
";
$result = mysqli_query($koneksi, $sql);

if (mysqli_num_rows($result) > 0) {
    // output data of each row
  
    while($row = mysqli_fetch_assoc($result)) {
        
        ?>
      
      <tr style="background-color:white">
      <td style="width:1%"><?php echo $no=$no+1 ;?></td>
      <td hidden="hidden" style="width:5%"> <?php echo $row["id_admin"];?></td>
      <td hidden="hidden" style="width:5%"> <?php echo $row["id_opd"];?></td>
      <td style="width:10%"> <?php echo  $row["user1"];?></td>
      <td hidden="hidden" style="width:5%"> <?php echo ($row["password1"]);?></td>
      <td style="width:5%"> <?php echo  $row["halaman"];?></td>
      <td style="width:5%"> <?php echo  $row["opd"];?></td>

      
  
       <td style="text-align:center ; vertical-align: middle; width:10%">  
<div class="row">
     
               <button id="myButton" type="button" class=" btnubah  btn btn-warning fa fa-edit " data-toggle="modal" data-target="#modal-ubah">
                Ubah
              </button>
              |
               <button id="myButton" type="button" class=" btnhapus  btn btn-danger fa fa-edit " data-toggle="modal" data-target="#modal-hapus">
                Hapus
              </button>
          </div>

          </td>
      </tr>
     

     
 <?php 
    }
} 


mysqli_close($koneksi);
?> 
 </tbody>
  </table>
  
          <script>
              $(document).ready(function () {
                 $(".btnubah").on('click', function () {
                    
                    var currentRow = $(this).closest("tr");
              
                      var col0 = currentRow.find("td:eq(0)").html();
                      var col1 = currentRow.find("td:eq(1)").html();
                      var col2 = currentRow.find("td:eq(2)").html();
                      var col3 = currentRow.find("td:eq(3)").html();
                      var col4 = currentRow.find("td:eq(4)").html();
                      var col5 = currentRow.find("td:eq(5)").html();
                   
                      col1 = col1.replace(/^\s+|\s+$/g, '');
                      col2 = col2.replace(/^\s+|\s+$/g, '');
                      col3 = col3.replace(/^\s+|\s+$/g, '');
                      col4 = col4.replace(/^\s+|\s+$/g, '');
                      col5 = col5.replace(/^\s+|\s+$/g, '');
                    
                      
                    
                      $("#id_adminu").val(col1);
                      $("#id_opdu").val(col2);
                      $("#user1u").val(col3);
                      $("#password1").val(col4);
                      $("#halamanu").val(col5);
                      $('#id_opdu').select2();


                  });
                
                  $(".btnhapus").on('click', function () {
                    var currentRow = $(this).closest("tr");
                       var col0 = currentRow.find("td:eq(0)").html();
                      var col1 = currentRow.find("td:eq(1)").html();
                      var col2 = currentRow.find("td:eq(2)").html();
                      var col3 = currentRow.find("td:eq(3)").html();
                      var col4 = currentRow.find("td:eq(4)").html();
                      var col5 = currentRow.find("td:eq(5)").html();
                   
                      col1 = col1.replace(/^\s+|\s+$/g, '');
                      col2 = col2.replace(/^\s+|\s+$/g, '');
                      col3 = col3.replace(/^\s+|\s+$/g, '');
                      col4 = col4.replace(/^\s+|\s+$/g, '');
                      col5 = col5.replace(/^\s+|\s+$/g, '');
                    
                     
                      $("#id_adminh").val(col1);
                      $("#user1h").val(col3);
                      $("#password").val(col4);
                      $("#halamanh").val(col5);
                  });
                  
                 });
</script>

<script type="text/javascript">
      function loadul(){
    
      
         location.reload();

       
   
 }
</script>
        <script>

  $(function () {
    // Summernote
    $('#summernote1').summernote(
        {
            placeholder:'input data anda',
            height:200,
        });

   
   

   
    CodeMirror.fromTextArea(document.getElementById("beritai"), {
      mode: "htmlmixed",
      theme: "monokai"
    });
  })
</script>
          
         <script>
            $(function () {
                $("#example1").DataTable({
                    "responsive": true,
                    "lengthChange": true,
                    "autoWidth": true,
                    "buttons": ["copy", "csv", "excel", "pdf", "print"]
                }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
                $('#example2').DataTable({
                    "paging": true,
                    "lengthChange": false,
                    "searching": false,
                    "ordering": true,
                    "info": true,
                    "autoWidth": false,
                    "responsive": true,
                });
            });
</script>
 
</body>
</html>