<?php
session_start();
if(isset($_SESSION['halaman']) && !empty($_SESSION['halaman'])) {
}
if(($_SESSION['halaman']=="admin"))
{
}
else
{
  header("location: ../../../login");  
}
include("../header.php");
include '../../../config/koneksi.php';

 ?>
                
<!DOCTYPE html>
<html>
    <head>
        <title></title>

               
            <script type="text/javascript">

                function tampilsurat() {
                    $.ajax({
                        type: 'GET',
                        url: 'tampil.php',
                        data: {
                          id_opdi: $("#id_opdi").val()
                            
                        },
                        success: function (data) {
                            $('#tampil_data').html(data);
                          
                        }
                    });
                };

 </script>  
        
          <script type="text/javascript">
              $(document).ready(function () {
                  $("#btnsimpan").click(function () {
                        $.ajax({
                              type: "POST",
                              url: "input.php",
                              data: {
                                id_admini: $("#id_admini").val(),
                                user1i: $("#user1i").val(),
                                password1i: $("#password1i").val(),
                                halamani: $("#halamani").val(),
                                id_opdi: $("#id_opdi").val(),

                                 
                                      },
                              success: function () {
                                  
                              tampilsurat(),
                              $("#user1i").val(''),
                              $("#password1i").val(''),
                              oksimp()
                                 
                              }
                          })
                      }
                  );


    function okubahok() {
        var Toast = Swal.mixin({
            toast: true,
            position: 'center-midlle',
            showConfirmButton: false,
            timer: 2500
        });

       
    }

                  $("#btnubah").click(function () {
                    var Toast = Swal.mixin({
            toast: true,
            position: 'center-midlle',
            showConfirmButton: false,
            timer: 2500
        });
                      $.ajax({
                          type: "POST",
                          url: "edit.php",
                          data: {
                                 id_adminu: $("#id_adminu").val(),
                                user1u: $("#user1u").val(),
                                password1v: $("#password1v").val(),
                                password1u: $("#password1u").val(),
                                halamanu: $("#halamanu").val(),
                                id_opdu: $("#id_opdu").val(),


                                },
                          success: function (msg) {
                            
                              tampilsurat(),
                               
                              $("#user1u").val(''),
                              $("#password1u").val(''),
                              $("#password1v").val(''),

                            Toast.fire({
                            icon: '',
                            title: msg
                                        })

                          }
                      })
                  });
                   $("#btndefault").click(function () {
                      var Toast = Swal.mixin({
                       toast: true,
                      position: 'center-midlle',
                      showConfirmButton: false,
                      timer: 2500
                                            });
                      $.ajax({
                          type: "POST",
                          url: "editdefault.php",
                          data: {
                                 id_adminu: $("#id_adminu").val(),
                                
                                },
                          success: function (msg) {
                              tampilsurat(),
                              $("#password1u").val(''),
                              Toast.fire({
                            icon: '',
                            title: msg
                                        })
                          }
                      })
                  });
                  $("#btnhapus").click(function () {
                      $.ajax({
                          type: "POST",
                          url: "delete.php",
                          data: {
                             id_adminh: $("#id_adminh").val(),
                          },
                          success: function () {
                              tampilsurat(),
                                 $("#id_adminh").val(''),
                                 okhapus()
                          }
                      })
                  });

              });

</script>
       
       
    </head>
    <body onload="tampilsurat(),tgladd()">
     <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 id="stat"></h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item active"></li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>
        <section class="content">
      <div class="container-fluid">
       <div > 
       <br>
             

<div class="card">
  <div class="card-header bg-blue">
    <h3 class="card-title">Data Admin OPD</h3>
    <div class="card-tools">
      <!-- Collapse Button -->
      <button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fas fa-minus"></i></button>
    </div>
    <!-- /.card-tools -->
  </div>
  <!-- /.card-header -->
  <div class="card-body">
     
       <div id="form_input" class ="card-body">
        <p><label>OPD</label>
        <select id="id_opdi"  style="width:45%" onchange="tampilsurat()">
          <option value="">Pilih OPD</option>
        <?php
$sqlopd  = mysqli_query($koneksi, "SELECT 
    distinct id_opd,opd from opd
    ");
foreach ($sqlopd as $rowopd) {?>
          <option value="<?php echo $rowopd["id_opd"] ;?>"><?php echo $rowopd["opd"] ;?></option>
          <?php  }?>

        </select>
      </p>
              
            <button id="myButton"  type="button" class=" btnSelect  btn btn-info fa fa-edit " data-toggle="modal" data-target="#modal-simpan">
                Input Admin
              </button>
            
         </div>

          <div id="tampil_data" ></div>
        
  </div>
  <!-- /.card-body -->
</div>
<!-- /.card -->

<div class="modal fade" id="modal-simpan" >
        <div class="modal-dialog modal-xl"  style ="width:99%">
          <div class="modal-content" >
            <div class="modal-header">
              <h4 class="modal-title"><i class ="fa fa-bar">Input</i></h4>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body" >
          <div id="form_hapus" class ="card-body">
               
            <div class="row">
        <div class="col-md-12">
          <div class="card card-outline card-info">
            <div class="card-header">
              <h3 class="card-title">
                 
              </h3>
              
            </div>
            <!-- /.card-header -->
            <div class="card-body" style="overflow: auto;">
              <p>User<input type="text" id="user1i" class=" form-control "/></p>
              <p hidden="hidden">Password<input type="text" id="password1i" class=" form-control "/></p>
              <p>Halaman
                <select  id="halamani" class="form-control">
                  <option value="admin">Admin</option>
                   <option value="opd">OPD</option>
                   <option value="bidang">Bidang</option>
                </select>
              </p>
               
            </div>
            
          </div>
        </div>
        <!-- /.col-->
      </div>
             </div>

            </div>
            <div class="modal-footer justify-content-between">
              
             
             <button style="float:right" class="btn btn-success" data-dismiss="modal">Batal</button>
             <button id="btnsimpan"  style="float:left" class="btn btn-success " data-dismiss="modal">Simpan</button>
            </div>
          </div>
          <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
      </div>
      <!-- /.modal -->

      <div class="modal fade" id="modal-ubah" >
        <div class="modal-dialog modal-xl"  style ="width:99%">
          <div class="modal-content" >
            <div class="modal-header">
              <h4 class="modal-title"><i class ="fa fa-bar">Ubah</i></h4>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body" >
          <div id="form_hapus" class ="card-body">
               
            <div class="row">
        <div class="col-md-12">
          <div class="card card-outline card-info">
            <div class="card-header">
              <h3 class="card-title">
                 
              </h3>
            </div>
            <!-- /.card-header -->
            <div class="card-body">
              <p><label>OPD</label>
        <select id="id_opdu" class="select2" style="width:100%">
          <option value="">Pilih OPD</option>
          <?php foreach ($sql as $row) {?>
          <option value="<?php echo $row["id_opd"] ;?>"><?php echo $row["opd"] ;?></option>
          <?php  }?>

        </select>
      </p>
              <p hidden="hidden">ID<input type="text" id="id_adminu" class=" form-control "/></p>
              <p>User<input type="text" id="user1u" class=" form-control " readonly="readonly" /></p>
              <p>Password Lama<input type="text" id="password1v" class=" form-control "/></p>
              <p>Password Baru<input type="text" id="password1u" class=" form-control "/></p>
              <p>Halaman
                <select  id="halamanu" class="form-control">
                  <option value="admin">Admin</option>
                  <option value="opd">OPD</option>
                  <option value="bidang">Bidang</option>
                </select>
              </p>
              </div>
            
          </div>
        </div>
        <!-- /.col-->
      </div>
             </div>

            </div>
            <div class="modal-footer justify-content-between">
              
             
             <button style="float:right" class="btn btn-success" data-dismiss="modal">Batal</button>
             <button id="btnubah"  style="float:left" class="btn btn-success " data-dismiss="modal">Simpan</button>
             <button id="btndefault"  style="float:left" class="btn btn-success " data-dismiss="modal">Reset Password</button>
            </div>
          </div>
          <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
      </div>
      <!-- /.modal -->



                   <div class="modal fade" id="modal-hapus" >
        <div class="modal-dialog modal-xl"  style ="width:99%">
          <div class="modal-content" >
            <div class="modal-header">
              <h4 class="modal-title"><i class ="fa fa-bar">Hapus</i></h4>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body" >
          <p>ID<input type="text" id="id_adminh" class=" form-control "/></p>
              <p>User<input type="text" id="user1h" class=" form-control "/></p>
              <p>Password<input type="text" id="password1h" class=" form-control "/></p>
              <p>Halaman
                <select  id="halamanh" class="form-control">
                  <option value="admin">Admin</option>
                   <option value="opd">OPD</option>
                   <option value="bidang">Bidang</option>
                </select>
              </p>

            </div>
            <div class="modal-footer justify-content-between">
              
             <button   style="float:left" class="btn btn-success" data-dismiss="modal">Batal</button>
             <button id="btnhapus"  style="float:right" class="btn btn-danger" data-dismiss="modal">Hapus</button>
            </div>
          </div>
          <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
      </div>
      <!-- /.modal -->
     
               
                

        
       
           </div>
        
        </div>
       
   
     
    </section>
  

  <!-- Control Sidebar -->
 
</div>
<!-- ./wrapper -->
         <footer class="main-footer">
    <strong></strong>
    BADAN PERENCANAAN PEMBANGUNAN DAERAH
    <div class="float-right d-none d-sm-inline-block">
      <b>By </b> eky
    </div>
  </footer>

  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
 <?php 
 include("../samping.php");
 ?>
  </aside>
  <!-- /.control-sidebar -->

        <!-- DataTables  & Plugins -->
<script src="../../../plugins/datatables/jquery.dataTables.min.js"></script>
<script src="../../../plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="../../../plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="../../../plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="../../../plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="../../../plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="../../../plugins/jszip/jszip.min.js"></script>
<script src="../../../plugins/pdfmake/pdfmake.min.js"></script>
<script src="../../../plugins/pdfmake/vfs_fonts.js"></script>
<script src="../../../plugins/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="../../../plugins/datatables-buttons/js/buttons.print.min.js"></script>
<script src="../../../plugins/datatables-buttons/js/buttons.colVis.min.js"></script>
   
<!-- SweetAlert2 -->
<script src="../../../plugins/sweetalert2/sweetalert2.min.js"></script>
<!-- Toastr -->
<script src="../../../plugins/toastr/toastr.min.js"></script>
<!-- AdminLTE App -->
<!-- Select2 -->
<script src="../../../plugins/select2/js/select2.full.min.js"></script>
<script src="../../../plugins/daterangepicker/daterangepicker.js"></script>


<script src="../../../plugins/moment/moment.min.js"></script>
<script src="../../../plugins/inputmask/jquery.inputmask.min.js"></script>
<!-- date-range-picker -->
<script src="../../../plugins/daterangepicker/daterangepicker.js"></script>
<!-- bootstrap color picker -->
<script src="../../../plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>

        <!-- Bootstrap 4 -->

<script src="../../../plugins/summernote/summernote-bs4.min.js"></script>
<!-- SweetAlert2 -->
     

<script type="text/javascript">
  function tgladd(){
    $('id_opdi').select2();
     $('#tgl_beritai').datetimepicker({
                        format: 'yyyy-MM-DD',
                        autoclose: true,
                    });
  }
</script>

        <script>
            $(function () {
                 $('#id_opdi').select2();
                
                  $('#tgl_beritai').datetimepicker({
                        format: 'yyyy-MM-DD',
                        autoclose: true,
                    });
                   $('#tgl_beritau').datetimepicker({
                        format: 'yyyy-MM-DD',
                        autoclose: true,
                    });
       })
            // DropzoneJS Demo Code End
</script>


    </body>
</html>
