<!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">
</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');
//
if(isset($_POST["myInput"]))
{
$object->query = "SELECT * FROM tanda_tangan INNER JOIN akun_user, jabatan WHERE id_pejabat=akun_user.id_user AND akun_user.id_jabatan = jabatan.id_jabatan ";
$result = $object->get_result();
$kode_ttd='';
?>
<!-- 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>Edit Tanda Tangan</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="../tables/tanda_tangan.php">Home</a></li>
              <li class="breadcrumb-item active">Edit Tanda Tangan</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/tanda_tangan.php" method="post">
                <div class="card-body">
                <div class="form-group">
                  <label>Jabatan Penanda Tangan</label>
                  <select class="form-control select2" name="penandatangan" style="width: 100%;" required>
                    <option value="">Pilih Penandatangan</option>
                    <?php foreach($result as $row)
                      {
                        if ($row["id_ttd"]==$_POST["myInput"]) {
                          $kode_ttd = $row["kode_ttd"];
                          echo '<option value="'.$row["id_user"].'" selected="selected">'.$row["nama"].' '.$row["nama_jabatan"].'</option>';
                        }else  echo '<option value="'.$row["id_user"].'">'.$row["nama"].' '.$row["nama_jabatan"].'</option>';
                      }
                    ?>
                  </select>
                </div>
                <div class="form-group">
                  <label>Kode Tanda Tangan</label>
                  <input type="text" name="kodettd" required class="form-control" id="kodettd" value="<?=$kode_ttd ?>">
                </div>
                </div>
                <!-- /.card-body -->
                <div class="card-footer">
                  <input type="hidden" name="hidden_id" id="hidden_id" value="<?=$_POST["myInput"]?>" />
                  <input type="hidden" name="action" id="action" value="edit_ttd" />
                  <button type="submit" class="btn btn-primary">Submit</button>
                </div>
              </form>
            </div>
        <!-- /.row -->
      </div>
      <!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
<?php
  } else{
//
  $object->query = "SELECT * FROM akun_user INNER JOIN  jabatan WHERE akun_user.id_jabatan = jabatan.id_jabatan ";
  $result = $object->get_result();
  $tanda_tangan='';
  $nama_jabatan='';
//
?>

  <!-- 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>Tambah Tanda Tangan</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="../tables/tanda_tangan.php">Home</a></li>
              <li class="breadcrumb-item active">Tambah Tanda Tangan</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/tanda_tangan.php" method="post">
                <div class="card-body">

                <div class="form-group">
                  <label>Jabatan Penanda Tangan</label>
                  <select class="form-control select2" name="penandatangan" style="width: 100%;" required>
                    <option value="">Pilih Penandatangan</option>
                    <?php foreach($result as $row)
                      {
                        echo '<option value="'.$row["id_user"].'">'.$row["nama"].' '.$row["nama_jabatan"].'</option>';
                      }
                    ?>
                  </select>
                </div>
                <div class="form-group">
                  <label>Kode Tanda Tangan</label>
                  <input type="text" name="kodettd" required class="form-control" id="kodettd" placeholder="Masukkan Kode Tanda Tangan">
                </div>
                </div>
                <!-- /.card-body -->
                <div class="card-footer">
                  <input type="hidden" name="action" id="action" value="add_ttd" />
                  <button type="submit" class="btn btn-primary">Submit</button>
                </div>
              </form>
            </div>
        <!-- /.row -->
      </div>
      <!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
<?php 
}
?>

  <!-- /.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 -->

<!-- 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>
<!-- 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()

  })
  // BS-Stepper Init
  document.addEventListener('DOMContentLoaded', function () {
    window.stepper = new Stepper(document.querySelector('.bs-stepper'))
  })
</script>
</body>
</html>
