<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>SIDINAR</title>

  <!-- Google Font: Source Sans Pro -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="../../plugins/fontawesome-free/css/all.min.css">
  <!-- daterange picker -->
  <link rel="stylesheet" href="../../plugins/daterangepicker/daterangepicker.css">
  <!-- iCheck for checkboxes and radio inputs -->
  <link rel="stylesheet" href="../../plugins/icheck-bootstrap/icheck-bootstrap.min.css">
  <!-- Bootstrap Color Picker -->
  <link rel="stylesheet" href="../../plugins/bootstrap-colorpicker/css/bootstrap-colorpicker.min.css">
  <!-- Tempusdominus Bootstrap 4 -->
  <link rel="stylesheet" href="../../plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css">
  <!-- Select2 -->
  <link rel="stylesheet" href="../../plugins/select2/css/select2.min.css">
  <link rel="stylesheet" href="../../plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css">
  <!-- Bootstrap4 Duallistbox -->
  <link rel="stylesheet" href="../../plugins/bootstrap4-duallistbox/bootstrap-duallistbox.min.css">
  <!-- BS Stepper -->
  <link rel="stylesheet" href="../../plugins/bs-stepper/css/bs-stepper.min.css">
  <!-- dropzonejs -->
  <link rel="stylesheet" href="../../plugins/dropzone/min/dropzone.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="../../dist/css/adminlte.min.css">
  <!-- summernote -->
  <link rel="stylesheet" href="../../plugins/summernote/summernote-bs4.min.css">
</head>
<body class="hold-transition sidebar-mini">
<?php
//
include('../../class/Database.php');
$object = new Database;
if(!$object->is_login())
{
    header("location:".$object->base_url);
}
include('menu.php');
//

$object->query = "SELECT * FROM jenis_naskah WHERE status='enable'";
$result = $object->get_result();
$object->query = "SELECT * FROM kode_klasifikasi ";
$result2 = $object->get_result();
$object->query = "SELECT * FROM tanda_tangan INNER JOIN akun_user, jabatan WHERE tanda_tangan.id_pejabat = akun_user.id_user AND akun_user.id_jabatan = jabatan.id_jabatan";
$result3 = $object->get_result();
$object->query = "SELECT * FROM verifikator INNER JOIN akun_user, jabatan WHERE verifikator.id_pejabat=akun_user.id_user AND akun_user.id_jabatan = jabatan.id_jabatan ";
$result4 = $object->get_result();
$object->query = "SELECT * FROM tujuan INNER JOIN akun_user,jabatan WHERE akun_user.id_user = tujuan.id_user_tujuan AND akun_user.id_jabatan = jabatan.id_jabatan ";
$result5 = $object->get_result();

if(isset($_POST["myInput"]))
  {
    //
    $kode_klasifikasi='';
    $kode_ttd='';
    $jenis_naskah='';
    $perihal='';
    $tanggal='';
    $template='';
    $id_verifikator='';
    $nomor_urut='';
    $id_user = $_SESSION['id_akun'];
    $object->query = "SELECT surat_keluar.id_surat,no_urut,kode_naskah,jenis_naskah.jenis_naskah,nomor,perihal,tujuan,klasifikasi,surat_keluar.tanggal,template,surat_keluar.status,id_verifikator,nama,nama_jabatan FROM surat_keluar INNER JOIN jenis_naskah,verifikator_detail,akun_user, jabatan WHERE surat_keluar.jenis_naskah=jenis_naskah.kode_naskah AND verifikator_detail.id_surat=surat_keluar.no_urut AND akun_user.id_user=surat_keluar.ttd AND jabatan.id_jabatan=akun_user.id_jabatan AND id_verifikator=".$id_user." AND surat_keluar.id_surat=".$_POST["myInput"]." ";
    $result6 = $object->get_result();
    foreach($result6 as $row)
    {
        $jenis_naskah=$row["jenis_naskah"];
        $kode_klasifikasi=$row["klasifikasi"];
        $kode_ttd=$row["nama"].' - '.$row["nama_jabatan"];
        $perihal=$row["perihal"];
        $tanggal=$row["tanggal"];
        $template=$row["template"];
        $nomor_urut=$row["no_urut"];
        $id_verifikator = $row["id_verifikator"];
    }

  }
  //echo '<script>alert( "Form successful submitted! '.($jenis_naskah).' '.($kode_klasifikasi).' '.($kode_ttd).' '.($perihal).' '.($tanggal).'");</script>';
?>
  <!-- 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>Verifikasi Surat Keluar</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="../tables/verifikasi_surat.php">Home</a></li>
              <li class="breadcrumb-item active">Verifikasi Surat Keluar</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">

          <div class="card card-primary">
              <!--div class="card-header">
                <h3 class="card-title">Surat Keluar</h3>
              </div-->
              <!-- /.card-header -->
              <!-- form start -->
              <form id="quickForm" action="../tables/surat_keluar.php" method="post">
                <div class="card-body">
                <div class="row">
                <div class="col-md-6">
                  <div class="form-group">
                  <label>Jenis Naskah</label>
                  <input type="text" name="jenis_naskah" readonly class="form-control" value="<?=$jenis_naskah.' - ' .$id_user?>">
                </div>
              </div>
              <div class="col-md-6">
                <div class="form-group">
                  <label>Kode Klasifikasi</label>
                  <input type="text" name="kode_klasifikasi" readonly class="form-control" value="<?=$kode_klasifikasi?>">
                </div>
              </div>
            </div>
              <div class="row">
              <div class="col-md-6">
                <div class="form-group">
                  <label>Tanggal</label>
                    <input type="text" name="tanggal" id="tanggal" class="form-control datepicker" value="<?=$tanggal?>" readonly />
                </div>
              </div>
              <div class="col-md-6">
                <div class="form-group">
                  <label>Penanda Tangan</label>
                  <input type="text" name="tanda_tangan" readonly class="form-control" value="<?=$kode_ttd?>">
                  
                </div>
              </div>
            </div>
              <div class="form-group" >
                <iframe src='https://view.officeapps.live.com/op/embed.aspx?src=https://arsiparisbnn.my.id/adminlte/pages/forms/<?=$template?>' width='100%' height='423px' frameborder='0'></iframe>
              </div>
              <div class="form-group">
                <table id="example1" class="table table-bordered table-hover">
                  <thead>
                  <tr>
                    <th>Nama Verifikator</th>
                    <th>Jabatan</th>
                    <th></th>
                  </tr>
                  </thead>
                  <tbody>
                  <?php
                    $object->query = "SELECT surat_keluar.id_surat,id_verifikator,nama,nama_jabatan,verifikator_detail.status FROM surat_keluar INNER JOIN jenis_naskah,verifikator_detail,akun_user, jabatan WHERE surat_keluar.jenis_naskah=jenis_naskah.kode_naskah AND verifikator_detail.id_surat=surat_keluar.no_urut AND akun_user.id_user=verifikator_detail.id_verifikator AND jabatan.id_jabatan=akun_user.id_jabatan AND surat_keluar.id_surat=".$_POST["myInput"]." ORDER BY id_detail ASC";
                    $result7 = $object->get_result();
                    $x=0;
                    foreach($result7 as $row)
                    {
                        
                      echo '<tr><td>'.$row["nama"].'</td>';
                      echo '<td>'.$row["nama_jabatan"].'</td>';
                      //
                      if($row["status"]==0){
                          if($row["id_verifikator"]==$id_user & $x==0){
                            echo '<td><div align="center"><button type="button" name="edit_button" class="btn btn-warning btn-circle btn-sm edit_button" data-id="'.$row["id_surat"].'" ><i class="fas fa-edit"></i></button></div></td></tr>';
                          }
                          $x=1;
                      }
                      else{
                        echo '<td></td></tr>';
                      }
                    }
                  ?>
                  </tbody>
                </table>
              </div>
              <!-- /.card-body -->
            </div>
                  </div>
                </div>
              </div>
                <!-- /.card-body -->
                <div class="card-footer">
                  <input type="hidden" name="action" id="action" value="add_surat" />
                  <button type="submit" class="btn btn-primary">Submit</button>
                </div>
              </form>
            </div>
        <!-- /.row -->
      </div>
      <!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>

  <!-- /.content-wrapper -->
  <footer class="main-footer">
    <div class="float-right d-none d-sm-block">
      <b>Version</b> 3.2.0
    </div>
    <strong>Copyright &copy; 2014-2021 <a href="https://adminlte.io">AdminLTE.io</a>.</strong> All rights reserved.
  </footer>

  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
  </aside>
  <!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->
<div class="modal fade" id="modal-default">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <h4 class="modal-title">Verifikasi</h4>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body">
              <form id="quickForm" method="post" action="../tables/verifikasi_surat.php">
            <div class="modal-footer justify-content-between">
                  <div class="form-group">
                    <div class="form-check">
                          <input class="form-check-input" type="radio" name="radio_setuju" value="1">
                          <label class="form-check-label">Setuju</label>
                    </div>
                    <div class="form-check">
                          <input class="form-check-input" type="radio" name="radio_setuju"  value="0">
                          <label class="form-check-label">Tolak</label>
                    </div>
                  </div>
              <textarea id="inputDescription" name="alasan" class="form-control" rows="4" >
              </textarea>
              <input type="hidden" name="id_verifikator" id="id_verifikator" value="<?=$id_verifikator?>" />
              <input type="hidden" name="id_surat" id="id_surat" value="<?=$nomor_urut?>" />
              <input type="hidden" name="action" id="action" value="ubah_verif" />
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
              <button type="submit" class="btn btn-success edit_button2" name="edit_button2">Save changes</button>
            </div>
              </form>
            </div>
            
          </div>
          <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
</div>
<!-- jQuery -->
<script src="../../plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="../../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Select2 -->
<script src="../../plugins/select2/js/select2.full.min.js"></script>
<!-- Bootstrap4 Duallistbox -->
<script src="../../plugins/bootstrap4-duallistbox/jquery.bootstrap-duallistbox.min.js"></script>
<!-- InputMask -->
<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/bootstrap-colorpicker/js/bootstrap-colorpicker.min.js"></script>
<!-- Tempusdominus Bootstrap 4 -->
<script src="../../plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
<!-- Bootstrap Switch -->
<script src="../../plugins/bootstrap-switch/js/bootstrap-switch.min.js"></script>
<!-- BS-Stepper -->
<script src="../../plugins/bs-stepper/js/bs-stepper.min.js"></script>
<!-- dropzonejs -->
<script src="../../plugins/dropzone/min/dropzone.min.js"></script>
<!-- AdminLTE App -->
<script src="../../dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../../dist/js/demo.js"></script>
<!-- Summernote -->
<script src="../../plugins/summernote/summernote-bs4.min.js"></script>
<!-- Page specific script -->
<script>
  $(function () {

    //Initialize Select2 Elements
    $('.select2').select2()

    //Initialize Select2 Elements
    $('.select2bs4').select2({
      theme: 'bootstrap4'
    })

    //Datemask dd/mm/yyyy
    $('#datemask').inputmask('dd/mm/yyyy', { 'placeholder': 'dd/mm/yyyy' })
    //Datemask2 mm/dd/yyyy
    $('#datemask2').inputmask('mm/dd/yyyy', { 'placeholder': 'mm/dd/yyyy' })
    //Money Euro
    $('[data-mask]').inputmask()

    //Date picker
    $('#reservationdate').datetimepicker({
        format: 'L'
    });

    $('#tanggal').datepicker({
        format: "yyyy-mm-dd",
        autoclose: true
    });

  })
  // BS-Stepper Init
  document.addEventListener('DOMContentLoaded', function () {
    window.stepper = new Stepper(document.querySelector('.bs-stepper'))
  })
</script>
<script type="text/javascript" language="javascript" >
 $(document).ready(function(){
        //
    $('.edit_button').click(function() {
      var no_urut = $(this).data('id');
      var id_user = $(this).data('status');
      $.ajax({        
        success: function (response) {
          //alert("Kasih nomor "+no_urut+" "+id_user);
          $('#modal-default').modal({backdrop: 'static', keyboard: false}) ;
          $('#modal-default').modal('show');
        }
      });
    });

    $('.edit_button2').click(function() {
      $.ajax({        
        success: function (response) {
          //alert("tessss");
        }
      });
    });
  });
</script>
</body>
</html>
