<file_sep><section class="content-header">
  <h1>
    Disposisi
  </h1>
  <ol class="breadcrumb">
    <li>
      <a href="#">
        <i class="fa fa-dashboard"></i> Home</a>
    </li>
    <li>
      <a href="#">Disposisi</a>
    </li>
    <li class="active">Inbox</li>
  </ol>
</section>

<section class="content">
  <div class="row">
    <div class="col-xs-12">
      <div class="box">
        <div class="box-header">
          <h3 class="box-title">Inbox Disposisi Surat</h3>
        </div>
        <!-- /.box-header -->
        <div class="box-body">
          <div class="table-responsive">
            <table id="table_data" class="table table-striped table-hover">
              <thead>
                <tr>
                  <th>No</th>
                  <th>Nomor Agenda</th>
                  <th>Perihal</th>
                  <th>Isi Ringkas</th>
                  <th>Dari</th>
                  <th>Instruksi</th>
                  <th>Aksi</th>
                </tr>
              </thead>

              <tbody>
                <?php
                $no = 1;
                $query = $mysqli->query("SELECT sm.*,ssm.*,ds.* FROM tbl_disposisi_surat ds
                LEFT JOIN tbl_status_sm ssm ON ds.no_surat = ssm.no_surat
                LEFT JOIN tbl_surat_masuk sm on ssm.no_surat=sm.no_surat where ds.diteruskan_kpd LIKE '%$jabatan%' and ds.proses='belum ditindak lanjuti'");
                while($data = $query->fetch_array()){
                  ?>
                  <tr>
                    <td>
                      <?php echo ($no) ?>
                    </td>
                    <td>
                      <?php echo ($data["nomor_agenda"]) ?>
                    </td>
                    <td>
                      <?php echo ($data["perihal"]) ?>
                    </td>
                    <td>
                      <?php echo ($data["isi_ringkas"]) ?>
                    </td>
                    <td>
                      <?php echo ($data["asal_surat"]) ?>
                    </td>
                    <td>
                      <?php echo ($data["instruksi"]) ?>
                    </td>
                    <td>
                      <a href='<?php echo "?page=detail_disposisi&no_surat=$data[no_surat]"; ?>' class="btn btn-success btn-sm">Detail</a>
                      <a href='<?php echo "?page=tindak_lanjut_disposisi&no_surat=$data[no_surat]"; ?>' class="btn btn-primary btn-sm ">Proses</a>
                    </td>

                  </tr>
                  <?php $no++;
                }
                ?>
              </tbody>
            </table>
          </div>
        </div>
        <!-- /.box-body -->
      </div>
      <!-- /.box -->
    </div>
    <!-- /.col -->
  </div>
  <!-- /.row -->
</section><file_sep><?php
//Establishing Connection with Server by passing server_name, user_id and password as a parameter 
$host= '';
$username= '';
$database= '';
$password= '';

$mysqli = new mysqli($host, $username, $password, $database);

if ($mysqli->connect_errno) {
  echo  "Failed to connect to MySQL: (" .$mysqli->connect_errno .")" .$mysqli->connect_error;
}

?><file_sep><section class="content-header">
  <h1>
    Disposisi
  </h1>
  <ol class="breadcrumb">
    <li>
      <a href="#">
        <i class="fa fa-dashboard"></i> Home</a>
    </li>
    <li>
      <a href="#">Disposisi</a>
    </li>
    <li class="active">Rekap Disposisi Surat</li>
  </ol>
</section>

<section class="content">
  <div class="row">
    <div class="col-xs-12">
      <div class="box">
        <div class="box-header">
          <h3 class="box-title">Rekap Disposisi Surat</h3>
        </div>
        <!-- /.box-header -->
        <div class="box-body">
          <div class="table-responsive">
            <table id="table_data" class="table table-striped table-hover">
              <thead>
                <tr>
                  <th>No</th>
                  <th>Nomor Agenda</th>
                  <th>Perihal</th>
                  <th>Tgl Penyelesaian</th>
                  <th>Instruksi</th>
                  <th>Diteruskan Kepada</th>
                  <th>Tindak Lanjut</th>

                  <?php if ($level_user=="kpl") { ?>
                  <th>Aksi</th>
                  <?php }?>

                </tr>
              </thead>

              <tbody>
                <?php
                      $no = 1;
                      $query = $mysqli->query("SELECT sm.*,ssm.*,ds.* FROM tbl_disposisi_surat ds
                      LEFT JOIN tbl_status_sm ssm ON ds.no_surat = ssm.no_surat
                      LEFT JOIN tbl_surat_masuk sm on ssm.no_surat=sm.no_surat  ORDER BY tanggal_penyelesaian");
                      while($data = $query->fetch_array()){ ?>
                  <tr>
                    <td>
                      <?php echo ($no)?>
                    </td>
                    <td>
                      <?php echo ($data["nomor_agenda"]) ?>
                    </td>
                    <td>
                      <?php echo ($data["perihal"]) ?>
                    </td>
                    <td>
                      <?php echo ($data["tanggal_penyelesaian"]) ?>
                    </td>
                    <td>
                      <?php echo ($data["instruksi"]) ?>
                    </td>
                    <td>
                      <?php echo ($data["diteruskan_kpd"]) ?>
                    </td>

                    <?php 
                      if ($data["proses"]=="belum ditindak lanjuti"){
                        $warna = "bg-red text-center";
                      }
                      else {
                        $warna = "bg-green text-center";
                      }
                    ?>
                    <td>
                      <div class="<?php echo $warna;?>">
                        <?php echo ($data["proses"]) ?>
                      </div>
                    </td>
                    <?php if ($level_user=="kpl") { ?>
                    <td>
                      <a href='<?php echo "?page=edit_disposisi&no_surat=$data[no_surat]"; ?>' class="btn btn-success btn-sm btn-block">edit</a>
                      <!-- <a href="" class="btn btn-danger btn-sm">delete</a>  -->
                    </td>
                    <?php }?>
                  </tr>
                  <?php $no++;
                    }
                  ?>
              </tbody>
            </table>
          </div>
        </div>
        <!-- /.box-body -->
      </div>
      <!-- /.box -->
    </div>
    <!-- /.col -->
  </div>
  <!-- /.row -->
</section><file_sep><?php
$message='hide';
  if ($_POST) { 
    foreach($_POST AS $key => $value) { $_POST[$key] = $mysqli->real_escape_string($value); } 
    $sql = "INSERT INTO `tbl_pengguna` ( 
      `nip` ,  
      `password` ,  
      `nama_user` ,  
      `jabatan` ,  
      `level_user`  ) VALUES(  
      '{$_POST['nip']}' , 
      '{$_POST['password']}' ,  
      '{$_POST['nama_user']}' ,  
      '{$_POST['jabatan']}' ,  
      '{$_POST['level_user']}'  ) "; 
    $mysqli->query($sql) or die($mysqli->error);
    $message='show';
    } 
?>
<section class="content-header">
  <h1>
    User
  </h1>
  <ol class="breadcrumb">
    <li>
      <a href="#">
        <i class="fa fa-dashboard"></i> Home</a>
    </li>
    <li>
      <a href="#">User</a>
    </li>
    <li class="active">Input User</li>
  </ol>
</section>

<section class="content">
  <div class="row">
    <div class="col-xs-12">
      <div class="box box-primary">
        <div class="box-header with-border">
          <div class="alert alert-success alert-dismissible alert-message <?=$message?>">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                <h4><i class="icon fa fa-check"></i> Sukses!</h4>
                Data berhasil disimpan
          </div>
          <h3 class="box-title">Input User</h3>

        </div>
        <!-- /.box-header -->
        <form class="form-horizontal" role="form" method="POST" action="">
          <div class="box-body">
            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">NIP</label>
              <div class="col-sm-6">
                <input type="text" class="form-control" id="inputPassword3" placeholder="NIP" name="nip" required>
              </div>
            </div>

            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Nama</label>
              <div class="col-sm-6">
                <input type="text" class="form-control" id="inputPassword3" placeholder="Nama" name="nama_user" required>
              </div>
            </div>

            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Password</label>
              <div class="col-sm-6">
                <input type="text" class="form-control" id="inputPassword3" placeholder="<PASSWORD>" name="password" required>
              </div>
            </div>

            <div class="form-group">
              <label for="<PASSWORD>" class="col-sm-2 control-label">Jabatan</label>
              <div class="col-sm-6">
                <select class="form-control" data-live-search="true" id="slct2" data-size="5" name="jabatan" required>
                  <option value="Waka SDM">Waka SDM</option>
                  <option value="Waka Sarana">Waka Sarana</option>
                  <option value="Waka Kesiswaan">Waka Kesiswaan</option>
                  <option value="Waka HUBIN">Waka HUBIN</option>
                  <option value="Waka Kurikulum">Waka Kurikulum</option>
                  <option value="WMM">WMM</option>
                  <option value="Persuratan">Persuratan</option>
                  <option value="Kepala Sekolah">Kepala Sekolah</option>
                </select>
              </div>
            </div>
            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Level</label>
              <div class="col-sm-6">
                <select class="form-control" data-live-search="true" id="slct3" data-size="5" name="level_user" required>
                  <option value="wka">Wakil Kepala Sekolah</option>
                  <option value="wka">Kepala Sekolah</option>
                  <option value="wka">Persuratan</option>

                </select>
              </div>
            </div>

          </div>
          <!-- /.box-body -->
          <div class="box-footer">
            <div class="form-group">
              <div class="col-sm-offset-2 col-sm-10">
                <input type="submit" class="btn btn-primary" value="Submit">
              </div>
            </div>

          </div>
        </form>
      </div>
      <!-- /.box -->
    </div>
    <!-- /.col -->
  </div>
  <!-- /.row -->
</section><file_sep><!-- jQuery 3 -->
<script src="../assets/bower_components/jquery/dist/jquery.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="../assets/bower_components/jquery-ui/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
  $.widget.bridge('uibutton', $.ui.button);
</script>
<!-- Bootstrap 3.3.7 -->
<script src="../assets/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- Select2 -->
<script src="../assets/bower_components/select2/dist/js/select2.full.min.js"></script>
<!-- daterangepicker -->
<script src="../assets/bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
<!-- datepicker -->
<script src="../assets/bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
<!-- Bootstrap WYSIHTML5 -->
<script src="../assets/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<!-- DataTables -->
<script src="../assets/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="../assets/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>

<!-- AdminLTE App -->
<script src="../assets/dist/js/adminlte.min.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<!-- <script src="../assets/dist/js/pages/dashboard.js"></script> -->
<!-- AdminLTE for demo purposes -->
<!-- <script src="../assets/dist/js/demo.js"></script> -->

<script>

$('.textarea').wysihtml5();
$('#table_data').DataTable();
$('.select2').select2();
$('#datepicker, #datepicker2').datepicker({
  autoclose: true
});
window.setTimeout(function () {
  $(".alert-message").fadeTo(500, 0).slideUp(500, function () {
    $(this).remove();
  });
}, 2000);

$('.kode-sm').change(function(){
  var kode = $(this).val();
  var currentTime = new Date();
  var month = currentTime.getMonth() + 1;
  var year = currentTime.getFullYear();
  var roman_month = romanize(month);
  var nomor_surat =  $('.no-surat').text();

  $('.nomor_agenda').val(nomor_surat+'/'+kode+'-SMKN.14/'+roman_month+'/'+year);
})

function romanize (num) {
	if (!+num)
		return false;
	var	digits = String(+num).split(""),
		key = ["","<KEY>",
		       "","X","XX","XXX","XL","L","<KEY>",
		       "","I","II","III","IV","V","VI","VII","VIII","IX"],
		roman = "",
		i = 3;
	while (i--)
		roman = (key[+digits.pop() + (i * 10)] || "") + roman;
	return Array(+digits.join("") + 1).join("M") + roman;
}
</script>

</body>
</html><file_sep><?php
session_start();

$nip = $_SESSION['nip'];
$nama_user = $_SESSION['nama_user'];
$jabatan = $_SESSION['jabatan'];
$level_user = $_SESSION['level_user'];
$hari= date('Y-m-d');
include "../db.php";
include "header.php";

$res=$mysqli->query("SELECT count(status) as status FROM `tbl_status_sm` WHERE status ='undisposed'"); 
$row = $res->fetch_assoc();
$inboxsurat=$row['status'];

$res1=$mysqli->query("SELECT count(status) as status FROM `tbl_status_sm` s LEFT JOIN tbl_disposisi_surat ds on ds.no_surat=s.no_surat WHERE diteruskan_kpd LIKE '%$jabatan%' and ds.proses='belum ditindak lanjuti' ");
$row1 = $res1->fetch_assoc();
$inboxdisposisi=$row1['status'];


switch ($level_user) {
  case 'pst':
    $res=$mysqli->query("SELECT count(no_surat) as status FROM `tbl_surat_masuk` "); 
    $row = $res->fetch_assoc();
    $inboxsurat=$row['status'];
    break;
  case 'kpl':
    $res=$mysqli->query("SELECT count(status) as status FROM `tbl_status_sm` WHERE status ='undisposed'"); 
    $row = $res->fetch_assoc();
    $inboxsurat=$row['status'];
    break;
  case 'wka':
    $res=$mysqli->query("SELECT count(status) as status FROM `tbl_status_sm` s LEFT JOIN tbl_disposisi_surat ds on ds.no_surat=s.no_surat WHERE diteruskan_kpd LIKE '%$jabatan%' and ds.proses='belum ditindak lanjuti' ");
    $row = $res->fetch_assoc();
    $inboxsurat=$row['status'];
  default:
    # code...
    break;
}
?>
<body class="hold-transition skin-yellow sidebar-mini">
<div class="wrapper">

  <header class="main-header">
    <!-- Logo -->
    <a href="./" class="logo">
      <!-- mini logo for sidebar mini 50x50 pixels -->
      <span class="logo-mini"><img src="../assets/img/logo.png" width='40px' height='40px'></span>
      <!-- logo for regular state and mobile devices -->
      <span class="logo-lg"> <img src="../assets/img/logo.png" width='40px' height='40px'> <b>SMKN</b>14 </span>
    </a>
    <!-- Header Navbar: style can be found in header.less -->
    <nav class="navbar navbar-static-top">
      <!-- Sidebar toggle button-->
      <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
        <span class="sr-only">Toggle navigation</span>
      </a>

      <div class="navbar-custom-menu">
        <ul class="nav navbar-nav">

          <!-- User Account: style can be found in dropdown.less -->
          <li class="dropdown user user-menu">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
              <img src="../assets/dist/img/avatar.png" class="user-image" alt="User Image">
              <span class="hidden-xs"><?=$nama_user?></span>
            </a>
            <ul class="dropdown-menu">
              <!-- User image -->
              <li class="user-header">
                <img src="../assets/dist/img/avatar.png" class="img-circle" alt="User Image">

                <p>
                  <?php echo "$nama_user - $jabatan"; ?>
                  
                </p>
              </li>


              <!-- Menu Footer-->
              <li class="user-footer">
                <div class="text-center">
                  <a href="../logout.php" class="btn btn-default btn-flat">Sign out</a>
                </div>
              </li>
            </ul>
          </li>
          <!-- Control Sidebar Toggle Button -->
        </ul>
      </div>
    </nav>
  </header>
  <!-- Left side column. contains the logo and sidebar -->

  <?php include "navbar.php" ?>
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
  <?php 
  if (!empty($_GET['page'])) {
    switch ($_GET['page']) {
      case 'surat':
        include "../menu/surat_masuk.php";
        break;
      case 'input_surat':
        include "../menu/input_surat_masuk.php";
        break;
      case 'edit_surat':
        include "../menu/edit_surat_masuk.php";
        break;
      case 'rekap_surat':
        include "../menu/rekap_surat_masuk.php";
        break;        
      case 'disposisi':
        include "../menu/disposisi.php";
        break;        
      case 'input_disposisi':
        include "../menu/input_disposisi.php";
        break;        
      case 'edit_disposisi':
        include "../menu/edit_disposisi.php";
        break;        
      case 'rekap_disposisi':
        include "../menu/rekap_disposisi.php";
        break;        
      case 'detail_disposisi':
        include "../menu/detail_disposisi.php";
        break;        
      case 'tindak_lanjut_disposisi':
        include "../menu/tindak_lanjut_disposisi.php";
        break;        
      case 'user':
        include "../menu/user.php";
        break; 
      case 'input_user':
        include "../menu/input_user.php";
        break;                
      case 'edit_user':
        include "../menu/edit_user.php";
        break;                
      default:
        include "../menu/dashboard.php";  
        break;
    }
  }else {
    include "../menu/dashboard.php";
  }

  ?>
 
  </div>
  <!-- /.content-wrapper -->
  <footer class="main-footer">
    <!-- <div class="pull-right hidden-xs">
      <b>Version</b> 2.4.0
    </div>
    <strong>Copyright &copy; 2014-2016 <a href="https://adminlte.io">Almsaeed Studio</a>.</strong> All rights
    reserved. -->
  </footer>

  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->


<?php include "footer.php" ?><file_sep><?php 
if($level_user!='wka'){
  header("location: index.php");
}

$message = 'hide';
$hari= date('Y-m-d');
$id=$_REQUEST['no_surat'];
$edit = "SELECT sm. * , ssm. * , ds. *
FROM tbl_disposisi_surat ds
LEFT JOIN tbl_status_sm ssm ON ds.no_surat = ssm.no_surat
LEFT JOIN tbl_surat_masuk sm ON ssm.no_surat = sm.no_surat
WHERE ds.no_surat = '$id' ";
$hasil =  $mysqli->query($edit);
$data = $hasil->fetch_array(); 

if ($_POST) { 
foreach($_POST AS $key => $value) { $_POST[$key] = $mysqli->real_escape_string($value); } 
$sql = "UPDATE `tbl_disposisi_surat` SET  
 `tanggal_penyelesaian` =  '{$_POST['tanggal_penyelesaian']}' ,  
 `proses` =  '{$_POST['proses']}' WHERE `no_surat` = '$id' "; ; 

$mysqli->query($sql) or die($mysqli->error);
$message = 'show';

}
?>
<section class="content-header">
  <h1>
    Disposisi
  </h1>
  <ol class="breadcrumb">
    <li>
      <a href="#">
        <i class="fa fa-dashboard"></i> Home</a>
    </li>
    <li>
      <a href="#">Disposisi</a>
    </li>
    <li class="active">Tindak Lanjut Disposisi Surat</li>
  </ol>
</section>

<section class="content">
  <div class="row">
    <div class="col-xs-12">
      <div class="box box-primary">
        <div class="box-header with-border">
          <div class="alert alert-success alert-dismissible alert-message <?=$message?>">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            <h4>
              <i class="icon fa fa-check"></i> Sukses!</h4>
            Data berhasil disimpan
          </div>
          <h3 class="box-title">Tindak Lanjut Disposisi Surat</h3>
        </div>
        <!-- /.box-header -->
        <form class="form-horizontal" role="form" method="POST" action="">
          <div class="box-body">

            <div class="form-group">
              <label for="inputEmail3" class="col-sm-2 control-label">Tgl Penyelesaian </label>
              <div class="col-sm-4">
                <input type="text" class="form-control" id="datepicker" placeholder="Tanggal Penyelesaian" name="tanggal_penyelesaian" required
                  data-date-format="yyyy-mm-dd" required value="<?php echo ($hari) ?>">
              </div>
            </div>


            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Tindakan</label>
              <div class="col-sm-7">
                <textarea class="form-control textarea" id="proses" placeholder="Tindakan" name="proses" required></textarea>
              </div>
            </div>



          </div>
          <!-- /.box-body -->
          <div class="box-footer">
            <div class="form-group">
              <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary pull-right">Submit</button>
                <a href="dash.php" class="btn btn-success">Inbox Surat</a>
              </div>
            </div>
          </div>
      </div>
      </form>
    </div>
    <!-- /.box -->
  </div>
  <!-- /.col -->
  </div>
  <!-- /.row -->
</section><file_sep><?php 
$rekap_disposisi = 'show';
$input_surat = 'hide';
$input_user = 'hide';
$rekap_surat = 'hide';
$inbox_surat = 'hide';
$inbox_disposisi = 'hide';
$rekap_user = 'hide';
$status_surat = 'hide';
$status_user = 'hide';
$status_disposisi = 'hide';

  switch ($level_user) {
    case 'pst':
      $status_surat = 'show';
      $input_surat = 'show';
      $rekap_surat = 'show';
      $status_disposisi = 'show';
      break;
    case 'kpl':
      $status_surat = 'show';
      $inbox_surat = 'show';
      $status_disposisi = 'show';
      break;
    case 'wka':
      $status_disposisi = 'show';
      $inbox_disposisi = 'show';
      break;
    case 'akr':
      $status_user = 'show';
      $input_user = 'show';
      $rekap_user = 'show';
      $status_surat = 'show';
      $input_surat = 'show';
      $rekap_surat = 'show';
      $inbox_surat = 'show';
      $status_disposisi = 'show';
      $inbox_disposisi = 'show';
      break;
    default:

      break;
  }
?>

<aside class="main-sidebar">
    <!-- sidebar: style can be found in sidebar.less -->
    <section class="sidebar">
      <!-- Sidebar user panel -->
      <div class="user-panel">
        <div class="pull-left image">
          <img src="../assets/dist/img/avatar.png" class="img-circle" alt="User Image">
        </div>
        <div class="pull-left info">
          <p><?=$nama_user?></p>
          <a href="#"><i class="fa fa-circle text-success"></i> Online</a>
        </div>
      </div>


      <!-- sidebar menu: : style can be found in sidebar.less -->
      <ul class="sidebar-menu" data-widget="tree">
        <li class="header">MAIN NAVIGATION</li>

        <li class="active">
          <a href="index.php">
            <i class="fa fa-dashboard"></i> <span> Dashboard</span>
          </a>
        </li>
        <li class="treeview">
          <a href="#" class='<?=$status_surat?>'>
            <i class="fa fa-envelope"></i> <span>Surat Masuk</span>
                            <span class="pull-right-container">
                  <small class="label pull-right bg-green"><?=$inboxsurat?></small>
                </span>
          </a>
          <ul class="treeview-menu">
            <li class='<?=$inbox_surat?>'>
              <a href="index.php?page=surat">
                <i class="fa fa-circle-o"></i> Inbox 
                <span class="pull-right-container">
                  <small class="label pull-right bg-green"><?=$inboxsurat?></small>
                </span>
              </a>
            </li>
            <li class='<?=$input_surat?>'><a href="index.php?page=input_surat"><i class="fa fa-circle-o"></i> Input Surat Masuk</a></li>
            <li class='<?=$rekap_surat?>'><a href="index.php?page=rekap_surat"><i class="fa fa-circle-o"></i> Rekap Surat Masuk <small class="label pull-right bg-green"><?=$inboxsurat?></small></a></li>
          </ul>
        </li>

        <li class="treeview">
          <a href="#" class='<?=$status_disposisi?>'>
            <i class="fa fa-envelope"></i> <span>Disposisi</span>
                            <span class="pull-right-container">
                  <small class="label pull-right bg-green"></small>
                </span>
          </a>
          <ul class="treeview-menu">
            <li class="<?=$inbox_disposisi?>">
              <a href="index.php?page=disposisi">
                <i class="fa fa-circle-o"></i> Inbox 
                <span class="pull-right-container">
                  <small class="label pull-right bg-green"><?=$inboxsurat?></small>
                </span>
              </a>
            </li>
            <!-- <li><a href="index.php?page=input_disposisi"><i class="fa fa-circle-o"></i> Input Disposisi</a></li> -->
            <li class="<?=$rekap_disposisi?>"><a href="index.php?page=rekap_disposisi"><i class="fa fa-circle-o"></i> Rekap Disposisi Surat</a></li>
          </ul>
        </li>

        <li class="treeview">
          <a href="#" class='<?=$status_user?>'>
            <i class="fa fa-envelope"></i> <span>User</span>
          </a>
          <ul class="treeview-menu">
            <li class="<?=$rekap_user?>">
              <a href="index.php?page=user">
                <i class="fa fa-circle-o"></i> List User 
              </a>
            </li>
            <li class="<?=$input_user?>"><a href="index.php?page=input_user"><i class="fa fa-circle-o"></i> Input User</a></li>
          </ul>
        </li>

      </ul>
    </section>
    <!-- /.sidebar -->
  </aside><file_sep># disposisi-surat

incoming mail management on school

## Installation

- change filename from `db.example.php` to `db.php` add your configuration

- import `example.sql` to your database

- install bower component with `bower install`<file_sep><?php 
$surat = 'hide';
$disposisi = 'hide';
$user = 'hide';
$col = 'col-lg-4 col-xs-6';
$link_surat = '';
$link_disposisi = '';
  switch ($level_user) {
    case 'pst':
      $surat = 'show';
      $disposisi = 'show';
      $link_surat = '?page=rekap_surat';
      $link_disposisi ='?page=rekap_disposisi';
      break;
    case 'wka':
      $disposisi = 'show';
      $link_surat = '?page=surat';
      $link_disposisi ='?page=disposisi';
      break;
    case 'kpl':
      $surat = 'show';
      $disposisi = 'show';
      $link_surat = '?page=surat';
      $link_disposisi ='?page=rekap_disposisi';

      break;
    default:
      # code...
      break;
  }

?>



<section class="content-header">
<h1>
  Dashboard
  <small>Control panel</small>
</h1>
<ol class="breadcrumb">
  <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
  <li class="active">Dashboard</li>
</ol>
</section>

<!-- Main content -->
<section class="content">
<!-- Small boxes (Stat box) -->
<div class="row">
  <div class="<?=$col?> <?=$surat?>">
    <!-- small box -->
    <div class="small-box bg-aqua">
      <div class="inner">
        <h3><?=$inboxsurat?></h3>

        <p>Surat Masuk</p>
      </div>
      <div class="icon">
        <i class="ion ion-bag"></i>
      </div>
      <a href="<?=$link_surat?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
    </div>
  </div>
  <!-- ./col -->
  <div class="col-lg-4 col-xs-6 <?=$disposisi?>">
    <!-- small box -->
    <div class="small-box bg-green">
      <div class="inner">
        <h3><?=$inboxdisposisi?></sup></h3>
        <p>Disposisi</p>
      </div>
      <div class="icon">
        <i class="ion ion-stats-bars"></i>
      </div>
      <a href="<?=$link_disposisi?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
    </div>
  </div>
  <!-- ./col -->
  <div class="col-lg-4 col-xs-6 <?=$user?>">
    <!-- small box -->
    <div class="small-box bg-yellow">
      <div class="inner">
        <?php 
          $res = $mysqli->query("SELECT * FROM tbl_pengguna");
          $user = $res->num_rows;
        ?>
        <h3><?=$user?></h3>
        <p>User </p>
      </div>
      <div class="icon">
        <i class="ion ion-person-add"></i>
      </div>
      <a href="#" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
    </div>
  </div>
  <!-- ./col -->

</div>
<!-- /.row -->
<!-- Main row -->

</section>
<!-- /.content -->

<file_sep><?php
$message='hide';
if ($_REQUEST['edit'] ?? false) {
  $id=$_REQUEST['edit'];
  $edit = "select * from tbl_pengguna where nip='$id'";
  $hasil =  $mysqli->query($edit);
  $row = $hasil->fetch_array(); 
  if ($_POST) { 
    foreach($_POST AS $key => $value) { $_POST[$key] = $mysqli->real_escape_string($value); } 
    $sql = "UPDATE `tbl_pengguna` SET  
    `nama_user` =  '{$_POST['nama_user']}' ,  
    `password` =  '{$_POST['password']}' ,  
    `jabatan` =  '{$_POST['jabatan']}' ,  
    `level_user` =  '{$_POST['level_user']}'  
    WHERE `nip` = '$id' "; 
    $mysqli->query($sql) or die($mysqli->error);
    $message = 'show';
   }
  }
  
  if ($_REQUEST['del'] ?? false ) {
  $id=$_REQUEST['del'];

  $mysqli->query("DELETE FROM `tbl_pengguna` WHERE `nip` = '$id' ");
  echo "<meta http-equiv='refresh' content='0; url=./'>";
  }   
?>
<section class="content-header">
  <h1>
    User
  </h1>
  <ol class="breadcrumb">
    <li>
      <a href="#">
        <i class="fa fa-dashboard"></i> Home</a>
    </li>
    <li>
      <a href="#">User</a>
    </li>
    <li class="active">Input User</li>
  </ol>
</section>

<section class="content">
  <div class="row">
    <div class="col-xs-12">
      <div class="box box-primary">
        <div class="box-header with-border">
          <div class="alert alert-success alert-dismissible alert-message <?=$message?>">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                <h4><i class="icon fa fa-check"></i> Sukses!</h4>
                Data berhasil disimpan
          </div>
          <h3 class="box-title">Input User</h3>

        </div>
        <!-- /.box-header -->
        <form class="form-horizontal" role="form" method="POST" action="">
          <div class="box-body">
          <div class="form-group">
          <label for="inputPassword3" class="col-sm-2 control-label">NIP</label>
          <div class="col-sm-4">
            <input type="text" class="form-control" id="inputPassword3" placeholder="NIP" name="nip" readonly value="<?= stripslashes($row['nip']) ?>">
          </div>
        </div>
  
        <div class="form-group">
          <label for="inputPassword3" class="col-sm-2 control-label">Nama</label>
          <div class="col-sm-4">
            <input type="text" class="form-control" id="inputPassword3" placeholder="Nama" name="nama_user" required value="<?= stripslashes($row['nama_user']) ?>">
          </div>
        </div>
  
        <div class="form-group">
          <label for="inputPassword3" class="col-sm-2 control-label">Password</label>
          <div class="col-sm-4">
            <input type="text" class="form-control" id="inputPassword3" placeholder="*********" name="password" required>
          </div>
        </div>
  
        <div class="form-group">
          <label for="inputPassword3" class="col-sm-2 control-label">Jabatan</label>
          <div class="col-sm-4">
            <select class="form-control" data-live-search="true" id="slct2" data-size="5" name="jabatan" required>
              <option value="Waka SDM">Waka SDM</option>
              <option value="Waka Sarana">Waka Sarana</option>
              <option value="Waka Kesiswaan">Waka Kesiswaan</option>
              <option value="Waka HUBIN">Waka HUBIN</option>
              <option value="Waka Kurikulum">Waka Kurikulum</option>
              <option value="WMM">WMM</option>
              <option value="Persuratan">Persuratan</option>
              <option value="Kepala Sekolah">Kepala Sekolah</option>
            </select>
  
          </div>
        </div>
        <div class="form-group">
          <label for="inputPassword3" class="col-sm-2 control-label">Level</label>
          <div class="col-sm-4">
            <select class="form-control" data-live-search="true" id="slct3" data-size="5" name="level_user" required>
              <option value="wka">Wakil Kepala Sekolah</option>
              <option value="kpl">Kepala Sekolah</option>
              <option value="pst">Persuratan</option>
  
            </select>
  
          </div>
        </div>
  
        <div class="form-group">
          <div class="col-sm-offset-2 col-sm-10">

            <input type='hidden' value='1' name="edituser" />
          </div>
        </div>

          </div>
          <!-- /.box-body -->
          <div class="box-footer">
            <div class="form-group">
              <div class="col-sm-offset-2 col-sm-10">
              <input type="submit" class="btn btn-success pull-right" value="Edit">
              <a href="./" class="btn btn-primary "> Dashboard </a>
              </div>
            </div>

          </div>
        </form>
      </div>
      <!-- /.box -->
    </div>
    <!-- /.col -->
  </div>
  <!-- /.row -->
</section><file_sep><?php
session_start();//starting session
include("db.php");
$error=''; //variable to store error message
if ($_POST) {

    if (empty($_POST['username']) || empty($_POST['password'])) {
        $error = "Username atau Password salah"; 
        echo "<meta http-equiv='refresh' content='0; url=./'>";        
    } else {                                                               
        $username=$_POST['username'];  
        $password=$_POST['<PASSWORD>'];       
        
        $res = $mysqli->query("SELECT * from tbl_pengguna where password='$<PASSWORD>' AND nip='$username' ");
        $data = $res->fetch_array();
        $rows = $res->num_rows;
            if ($rows == 1) {
                /**
                 * session set
                 */
                $_SESSION['nip']=$data['nip'];
                $_SESSION['nama_user']=$data['nama_user'];
                $_SESSION['jabatan']=$data['jabatan'];
                $_SESSION['level_user']=$data['level_user'];
                echo "<meta http-equiv='refresh' content='0; url=layout/index.php'>"; 
            } else {
                $error = "User Atau Password Salah";
                echo "<meta http-equiv='refresh' content='0; url=./'>";
            }
                  
    }
}
<file_sep>-- phpMyAdmin SQL Dump
-- version 4.5.4.1deb2ubuntu2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: 01 Nov 2017 pada 20.51
-- Versi Server: 5.7.20-0ubuntu0.16.04.1
-- PHP Version: 7.1.11-1+ubuntu16.04.1+deb.sury.org+1

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";

--
-- Database: `dispose`
--

-- --------------------------------------------------------

--
-- Struktur dari tabel `tbl_disposisi_surat`
--

CREATE TABLE `tbl_disposisi_surat` (
  `no_surat` varchar(100) NOT NULL,
  `tanggal_penyelesaian` date DEFAULT NULL,
  `tanggal_penerimaan` date DEFAULT NULL,
  `instruksi` text NOT NULL,
  `diteruskan_kpd` varchar(100) NOT NULL,
  `proses` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data untuk tabel `tbl_disposisi_surat`
--

INSERT INTO `tbl_disposisi_surat` (`no_surat`, `tanggal_penyelesaian`, `tanggal_penerimaan`, `instruksi`, `diteruskan_kpd`, `proses`) VALUES
('1', '2017-11-01', NULL, 'palajari, adakan pertemuan tanggal 3 november 2017 pukul 09.00', 'Waka Kurikulum-Waka Kesiswaan-Waka Sarana', 'buatkan surat tugas untuk guru multimedia dan 10 siswa untuk mengikuti workshop tersebut.'),
('3', NULL, NULL, 'tindak lanjuti', 'Waka SDM', 'belum ditindak lanjuti');

-- --------------------------------------------------------

--
-- Struktur dari tabel `tbl_pengguna`
--

CREATE TABLE `tbl_pengguna` (
  `nip` varchar(20) NOT NULL,
  `password` varchar(50) NOT NULL,
  `nama_user` varchar(30) NOT NULL,
  `jabatan` varchar(20) NOT NULL,
  `level_user` varchar(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data untuk tabel `tbl_pengguna`
--

INSERT INTO `tbl_pengguna` (`nip`, `password`, `nama_user`, `jabatan`, `level_user`) VALUES
('000', '123', 'Super Admin', 'admin', 'akr'),
('001', '123', 'B<NAME>adi, M.Sn', 'Kepala Sekolah', 'kpl'),
('002', '123', 'Yulian T.S. Karyat, Drs.', 'Waka Kurikulum', 'wka'),
('003', '123', '<NAME>, Drs. M.Ds.', 'Waka HUBIN', 'wka'),
('004', '123', 'Drs. <NAME>, S.Pd', 'Waka Kesiswaan', 'wka'),
('005', '123', 'Nana Sutejo, Drs.', 'Waka Sarana', 'wka'),
('006', '123', '<NAME>, Drs., M.Ds.', 'WMM', 'wka'),
('007', '123', 'Drs. D<NAME>', 'Waka SDM', 'wka'),
('008', '123', '<NAME> S., Dra.', 'Persuratan', 'pst');

-- --------------------------------------------------------

--
-- Struktur dari tabel `tbl_status_sm`
--

CREATE TABLE `tbl_status_sm` (
  `no_surat` int(5) NOT NULL,
  `tujuan` varchar(100) NOT NULL,
  `status` varchar(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data untuk tabel `tbl_status_sm`
--

INSERT INTO `tbl_status_sm` (`no_surat`, `tujuan`, `status`) VALUES
(1, 'Kepala Sekolah', 'disposed'),
(2, 'Kepala Sekolah', 'undisposed'),
(3, 'Kepala Sekolah', 'disposed');

-- --------------------------------------------------------

--
-- Struktur dari tabel `tbl_surat_masuk`
--

CREATE TABLE `tbl_surat_masuk` (
  `no_surat` int(5) NOT NULL,
  `kode_sm` varchar(20) NOT NULL,
  `nomor_agenda` varchar(100) NOT NULL,
  `perihal` text NOT NULL,
  `isi_ringkas` text NOT NULL,
  `asal_surat` varchar(100) NOT NULL,
  `tgl_sm` date NOT NULL,
  `lampiran` int(5) NOT NULL,
  `tgl_diteruskan` date NOT NULL,
  `nama_file` varchar(50) NOT NULL,
  `golongan_surat` varchar(20) NOT NULL,
  `pengolah` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data untuk tabel `tbl_surat_masuk`
--

INSERT INTO `tbl_surat_masuk` (`no_surat`, `kode_sm`, `nomor_agenda`, `perihal`, `isi_ringkas`, `asal_surat`, `tgl_sm`, `lampiran`, `tgl_diteruskan`, `nama_file`, `golongan_surat`, `pengolah`) VALUES
(1, '421.7', '1/421.7-SMKN.14/XI/2017', 'Penawaran Program Workshop', 'Pelaksanaan workshop desain grafis yang difasilitasi oleh pintar grafis, dilaksanakan tanpa biaya pungutan apapun (gratis). Sekolah hanya bertanggung jawab untuk menyiapkan waktu, tempat dan peserta workshop.', 'Pintar Grafis', '2017-11-01', 1, '2017-11-01', '1509527725_pintar grafis.jpg', 'Biasa', '<NAME> S., Dra.'),
(2, '425', '2/425-SMKN.14/XI/2017', 'Penawaran Jasa Service Komputer dan Printer', 'Penawaran kerjasama maintenance komputer, printer dan pemasangan jaringan komputer', 'MSC Tarutung', '2017-11-01', 3, '2017-11-01', '1509530651_penawaran service.jpg', 'Penting', '<NAME> S., Dra.'),
(3, '800', '3/800-SMKN.14/XI/2017', 'Pengunduran Diri', 'Pengajuan pengunduran diri Supardi S.Pd per tanggal 15 November 2017.', 'Supardi S.Pd', '2017-11-01', 0, '2017-11-01', '1509531280_pengunduran diri.jpg', 'Penting', '<NAME> S., Dra.');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `tbl_disposisi_surat`
--
ALTER TABLE `tbl_disposisi_surat`
  ADD PRIMARY KEY (`no_surat`);

--
-- Indexes for table `tbl_pengguna`
--
ALTER TABLE `tbl_pengguna`
  ADD PRIMARY KEY (`nip`);

--
-- Indexes for table `tbl_status_sm`
--
ALTER TABLE `tbl_status_sm`
  ADD PRIMARY KEY (`no_surat`);

--
-- Indexes for table `tbl_surat_masuk`
--
ALTER TABLE `tbl_surat_masuk`
  ADD PRIMARY KEY (`no_surat`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `tbl_surat_masuk`
--
ALTER TABLE `tbl_surat_masuk`
  MODIFY `no_surat` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;<file_sep><?php 
$id=$_REQUEST['no_surat'];
$edit = "select * from tbl_surat_masuk where no_surat='$id'";
$hasil =  $mysqli->query($edit);
$data = $hasil->fetch_array(); 
$message = 'hide';

if(empty($level_user)){
  header("location: index.php");
}
$id=$_REQUEST['no_surat'];

if ($level_user=="kpl") {
$edit = " SELECT sm.*,ssm.* FROM tbl_surat_masuk sm LEFT JOIN tbl_status_sm ssm on ssm.no_surat=sm.no_surat where sm.no_surat = '$id' ";
}

if ($level_user=="wka") {
$edit = "SELECT sm.*,ssm.*,ds.* FROM tbl_disposisi_surat ds LEFT JOIN tbl_status_sm ssm ON ds.no_surat = ssm.no_surat LEFT JOIN tbl_surat_masuk sm on ssm.no_surat=sm.no_surat where ds.no_surat = '$id' ";
}

$hasil = $mysqli->query($edit);
$row = $hasil->fetch_array();  
?>
<section class="content-header">
  <h1>
    Surat Masuk
  </h1>
  <ol class="breadcrumb">
    <li>
      <a href="#">
        <i class="fa fa-dashboard"></i> Home</a>
    </li>
    <li>
      <a href="#">Surat Masuk</a>
    </li>
    <li class="active">Input Surat Masuk</li>
  </ol>
</section>

<section class="content">
  <div class="row">
    <div class="col-xs-12">
      <div class="box box-primary">
        <div class="box-header with-border">
          <div class="alert alert-success alert-dismissible alert-message <?=$message?>">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            <h4>
              <i class="icon fa fa-check"></i> Sukses!</h4>
            Data berhasil disimpan
          </div>
          <h3 class="box-title">Input Surat Masuk</h3>
        </div>
        <!-- /.box-header -->
        <form class="form-horizontal" role="form" method="POST" action="">
          <div class="box-body">
            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Kode Surat</label>
              <div class="col-sm-4">
                <input type="text" class="form-control" id="inputPassword3" placeholder="Kode Surat" name="kode_sm" required value="<?= stripslashes($row['kode_sm']) ?>"
                  readonly>
              </div>
            </div>

            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Golongan Surat</label>
              <div class="col-sm-4">
                <input type="text" class="form-control" id="inputPassword3" placeholder="G<NAME>at" name="golongan_surat" required value="<?= stripslashes($row['golongan_surat']) ?>"
                  readonly>
              </div>
            </div>

            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Nomor Agenda</label>
              <div class="col-sm-4">
                <input type="text" class="form-control" id="inputPassword3" placeholder="Nom<NAME>" name="nomor_agenda" required value="<?= stripslashes($row['nomor_agenda']) ?>"
                  readonly>
              </div>
            </div>

            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Perihal</label>
              <div class="col-sm-4">
                <input type="text" class="form-control" id="inputPassword3" placeholder="Perihal" name="perihal" required value="<?= stripslashes($row['perihal']) ?>"
                  readonly>
              </div>
            </div>

            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Isi Ringkas</label>
              <div class="col-sm-7">
                <textarea class="form-control " id="inputPassword3" placeholder="<NAME>" name="isi_ringkas" required rows="5" readonly><?= stripslashes($row['isi_ringkas']) ?>
                </textarea>
              </div>
            </div>
            <?php if ($level_user=="wka"): ?>


            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Instruksi</label>
              <div class="col-sm-7">
                <textarea class="form-control textarea" id="inputPassword3" placeholder="Instruksi" name="instruksi" required rows="5" readonly><?= stripslashes($row['instruksi']) ?>
                </textarea>
              </div>
            </div>

            <?php endif ?>
            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Asal Surat</label>
              <div class="col-sm-4">
                <input type="text" class="form-control" id="inputPassword3" placeholder="<NAME>" name="asal_surat" required value="<?= stripslashes($row['asal_surat']) ?>"
                  readonly>
              </div>
            </div>

            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Tanggal Diterima</label>
              <div class="col-sm-4">
                <input type="text" class="form-control" placeholder="Tanggal" autocomplete="off" name="tgl_sm" data-date-format="yyyy-mm-dd"
                  required value="<?= stripslashes($row['tgl_sm']) ?>" readonly>
              </div>
            </div>

            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Jumlah Lampiran</label>
              <div class="col-sm-4">
                <input type="text" class="form-control" id="inputPassword3" placeholder="Lampiran" name="lampiran" value="<?= stripslashes($row['lampiran']) ?>"
                  readonly>
              </div>
            </div>

            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Tanggal Diteruskan</label>
              <div class="col-sm-4">
                <input type="text" id="datepicker" class="form-control" placeholder="Tanggal Diteruskan" autocomplete="off" name="tgl_diteruskan" data-date-format="yyyy-mm-dd"
                  required value="<?= stripslashes($row['tgl_diteruskan']) ?>" readonly>
              </div>
            </div>

            <div class="form-group">
              <label for="input<PASSWORD>3" class="col-sm-2 control-label">File Permohonan</label>
              <div class="col-sm-4">
                <a href="<?php echo "../file-sm/$row[nama_file] ";?>" class="btn btn-warning example1demo">File Surat</a>
              </div>
            </div>


          </div>
          <!-- /.box-body -->
          <div class="box-footer">

                <div class="form-group">
                  <div class="col-sm-offset-2 col-sm-10">
                    <a href="?page=surat" class="btn btn-success ">Inbox Surat</a>
                    <?php  if ($level_user =="kpl") {  ?>
                    <a href= '<?php echo "?page=input_disposisit&no_surat=$row[no_surat]"; ?>' class="btn btn-primary pull-right"> Disposisi </a>
                    <?php } ?>
                    <?php  if ($level_user =="wka") {  ?>
                    <a href= '<?php echo "?page=tindak_lanjut_disposisi&no_surat=$row[no_surat]"; ?>' class="btn btn-primary pull-right"> Tindak Lanjut </a>
                    <?php } ?>
                  </div>
                </div>

          </div>
      </div>
      </form>
    </div>
    <!-- /.box -->
  </div>
  <!-- /.col -->
  </div>
  <!-- /.row -->
</section><file_sep><?php 
$id=$_REQUEST['no_surat'];
$edit = "select * from tbl_surat_masuk where no_surat='$id'";
$hasil =  $mysqli->query($edit);
$data = $hasil->fetch_array(); 
$message = 'hide';

if ($_POST) { 
  $wak=$_POST['diteruskan_kpd'];
  $imp=implode("-", $wak);
  foreach($_POST AS $key => $value) { $_POST[$key] =$value; } 
    $sql = "INSERT INTO `tbl_disposisi_surat` ( 
      `no_surat` , 
      `instruksi` , 
      `diteruskan_kpd`,
      `proses`) 
          VALUES(
      '{$_POST['no_surat']}', 
      '{$_POST['instruksi']}',  
      '$imp',
      'belum ditindak lanjuti')"; 
    $sql1 = " UPDATE `tbl_status_sm` 
         SET 
      `status`='disposed' 
       where `no_surat`='$id' ";
    $mysqli->query($sql) or die($mysqli->error);
    $mysqli->query($sql1) or die($mysqli->error);
    $message = 'show';
 }
?>
<section class="content-header">
  <h1>
    Disposisi
  </h1>
  <ol class="breadcrumb">
    <li>
      <a href="#">
        <i class="fa fa-dashboard"></i> Home</a>
    </li>
    <li>
      <a href="#">Disposisi</a>
    </li>
    <li class="active">Input Disposisi</li>
  </ol>
</section>

<section class="content">
  <div class="row">
    <div class="col-xs-12">
      <div class="box box-primary">
        <div class="box-header with-border">
          <div class="alert alert-success alert-dismissible alert-message <?=$message?>">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            <h4>
              <i class="icon fa fa-check"></i> Sukses!</h4>
            Data berhasil disimpan
          </div>
          <h3 class="box-title">Input Disposisi</h3>
        </div>
        <!-- /.box-header -->
        <form class="form-horizontal" role="form" method="POST" action="">
          <div class="box-body">
            <div class="form-group">
              <label for="inputEmail3" class="col-sm-2 control-label">No Agenda Surat </label>
              <div class="col-sm-4">
                <input type="text" class="form-control" id="inputEmail3" placeholder="No Surat" value=<?php echo ($data[ "nomor_agenda"]) ?> readonly name="no_agenda">
                <input type="hidden" class="form-control" id="inputEmail3" placeholder="No Surat" value=<?php echo ($data[ "no_surat"]) ?> readonly name="no_surat">
              </div>
            </div>


            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Instruksi</label>
              <div class="col-sm-7">
                <textarea class="form-control textarea" id="instruksi" placeholder="Instruksi" name="instruksi" required></textarea>
              </div>
            </div>

            <div class="form-group">
              <label class="col-sm-2 control-label">Diteruskan Kepada</label>
              <div class="col-sm-4">
                <select class="form-control select2" data-live-search="true" data-size="5" multiple name="diteruskan_kpd[]">
                  <?php 
                    $query = $mysqli->query("SELECT * FROM tbl_pengguna WHERE level_user='wka'");
                    while($data=$query->fetch_array()):
                  ?>                
                  <option value="<?=$data['jabatan']?>"><?=$data['jabatan']?></option>
                  <?php endwhile;?>
                </select>
              </div>
            </div>

          </div>
          <!-- /.box-body -->
          <div class="box-footer">
            <div class="form-group">
              <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary pull-right">Submit</button>
                <a href="dash.php" class="btn btn-success">Inbox Surat</a>
              </div>
            </div>
          </div>
      </div>
      </form>
    </div>
    <!-- /.box -->
  </div>

</section><file_sep><?php 
$kode_surats = array (
"0|Pilih Kode Surat",
"800|kepegawaian",
"900|keuangan",
"420|PENDIDIKAN",
"421|Sekolah",
"421.1|Pra Sekolah",
"421.2|Sekolah Dasar",
"421.3|Sekolah Menengah",
"421.4|Sekolah Tinggi",
"421.5|Sekolah Kejuruan",
"421.6|Kegiatan Sekolah, Dies Natalis Lustrum",
"421.7|Kegiatan Pelajar",
"421.71|Reuni Darmawisata",
"421.72|Pelajar Teladan",
"421.73|Resimen Mahasiswa",
"421.8|Sekolah Pendidikan Luar Biasa",
"421.9|Pendidikan Luar Sekolah / Pemberantasan Buta Huruf",
"422|Administrasi Sekolah",
"422.1|Persyaratan Masuk Sekolah, Testing, Ujian, Pendaftaran, Mapras, Perpeloncoan",
"422.2|Tahun Pelajaran",
"422.3|Hari Libur",
"422.4|Uang Sekolah, Klasifikasi Disini SPP",
"422.5|Beasiswa",
"423|Metode Belajar",
"423.1|Kuliah",
"423.2|Ceramah, Simposium",
"423.3|Diskusi",
"423.4|Kuliah Lapangan, Widyawisata, KKN, Studi Tur",
"423.5|Kurikulum",
"423.6|Karya Tulis",
"423.7|Ujian",
"424|Tenaga Pengajar, Guru, Dosen, Dekan, Rektor",
"425|Sarana Pendidikan",
"425.1|Gedung",
"425.11|Gedung Sekolah",
"425.12|Kampus",
"425.13|Pusat Kegiatan Mahasiswa",
"425.2|Buku",
"425.3|Perlengkapan Sekolah  ");

$message = 'hide';
  if ($_POST) { 

    $lokasi_file=$_FILES['nama_file']['tmp_name'];
    $nama_file=$_FILES['nama_file']['name'];
    $tipe = explode(".",$nama_file);
    $nn=time();
    $nama_baru = $nn."_".$tipe[0].".".$tipe[1];
    move_uploaded_file($lokasi_file,"../file-sm/$nama_baru");
      foreach($_POST AS $key => $value) { $_POST[$key] = $mysqli->real_escape_string($value); } 
      $sql = "INSERT INTO `tbl_surat_masuk` (
        `kode_sm` ,
        `nomor_agenda` ,
        `perihal` ,
        `isi_ringkas` , 
        `asal_surat` ,
        `tgl_sm` ,
        `lampiran` ,
        `tgl_diteruskan` ,
        `nama_file` ,
        `golongan_surat` ,
        `pengolah` 
      )
            VALUES(
        '{$_POST['kode_sm']}' ,
        '{$_POST['nomor_agenda']}' ,  
        '{$_POST['perihal']}' ,  
        '{$_POST['isi_ringkas']}' ,  
        '{$_POST['asal_surat']}' ,  
        '{$_POST['tgl_sm']}' ,  
        '{$_POST['lampiran']}' ,  
        '{$_POST['tgl_diteruskan']}', 
        '$nama_baru',  
        '{$_POST['golongan_surat']}' ,   
        '{$_POST['pengolah']}'
         ) "; 

      $sql1 = "INSERT INTO `tbl_status_sm` (
        `no_surat`,
        `tujuan`,
        `status`) 
            VALUES (
        LAST_INSERT_ID(),
        'Kepala Sekolah',
        'undisposed')";

      $mysqli->query($sql) or die($mysqli->error);
      $mysqli->query($sql1) or die($mysqli->error);
      $message = "show";

    }
?>
<section class="content-header">
  <h1>
    Surat Masuk
  </h1>
  <ol class="breadcrumb">
    <li>
      <a href="#">
        <i class="fa fa-dashboard"></i> Home</a>
    </li>
    <li>
      <a href="#">Surat Masuk</a>
    </li>
    <li class="active">Input Surat Masuk</li>
  </ol>
</section>

<section class="content">
  <div class="row">
    <div class="col-xs-12">
      <div class="box box-primary">
        <div class="box-header with-border">
          <div class="alert alert-success alert-dismissible alert-message <?=$message?>">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                <h4><i class="icon fa fa-check"></i> Sukses!</h4>
                Data berhasil disimpan
          </div>
          <?php 
              $query = $mysqli->query("SELECT * FROM tbl_surat_masuk");
              $nomor_surat = $query->num_rows+1;
            ?>        
          <h3 class="box-title">Input Surat Masuk</h3>
          <div class="no-surat hide"><?php echo $nomor_surat ?></div>
        </div>
        <!-- /.box-header -->
        <form class="form-horizontal" role="form" method="POST" action="" enctype="multipart/form-data">
          <div class="box-body">
            <div class="form-group">
              <label for="<PASSWORD>" class="col-sm-2 control-label">Kode Surat</label>
              <div class="col-sm-4">
                <select name="kode_sm"  data-size="5" class="form-control select2 kode-sm" data-live-search="true">
                <?php foreach ($kode_surats as $kode_surat) : ?>
                  <?php $kode_surat = explode('|',$kode_surat) ?>
                  <option value="<?=$kode_surat[0]?>"><?=$kode_surat[0].' - '.$kode_surat[1] ?></option>
                <?php endforeach; ?>
                </select>
              </div>
            </div>

            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Golongan Surat</label>
              <div class="col-sm-4">
                <select class="form-control" data-live-search="true" id="slct" data-size="5" name="golongan_surat" required>
                  <option value="Biasa">Biasa</option>
                  <option value="Penting">Penting</option>
                  <option value="Rahasia">Rahasia</option>
                  <option value="Sangat Rahasia">Sangat Rahasia</option>

                </select>
              </div>
            </div>

            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Nomor Agenda</label>
              <div class="col-sm-4">
                <input type="text" class="form-control nomor_agenda" id="inputPassword3" placeholder="<NAME>" name="nomor_agenda" required>
              </div>
            </div>

            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Perihal</label>
              <div class="col-sm-4">
                <input type="text" class="form-control" id="inputPassword3" placeholder="Perihal" name="perihal" required>
              </div>
            </div>

            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Isi Ringkas</label>
              <div class="col-sm-7">
                <textarea class="form-control textarea" id="inputPassword3" placeholder="<NAME>" name="isi_ringkas" required></textarea>
              </div>
            </div>

            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Asal Surat</label>
              <div class="col-sm-4">
                <input type="text" class="form-control" id="inputPassword3" placeholder="As<NAME>" name="asal_surat" required>
              </div>
            </div>

            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Tanggal Diterima</label>
              <div class="col-sm-4">

                <input type="text" class="form-control" id="datepicker" placeholder="Tanggal" autocomplete="off" name="tgl_sm" data-date-format="yyyy-mm-dd"
                  required value="<?php echo ($hari) ?>">
              </div>
            </div>

            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Jumlah Lampiran</label>
              <div class="col-sm-4 ">

                <input type="text" class="form-control" id="inputPassword3" placeholder="Jumlah Lembar" name="lampiran">

              </div>
            </div>


            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">Tanggal Diteruskan</label>
              <div class="col-sm-4">
                <input type="text" class="form-control" id="datepicker2" placeholder="Tanggal Diteruskan" autocomplete="off" name="tgl_diteruskan"
                  data-date-format="yyyy-mm-dd" required>
              </div>
            </div>

            <div class="form-group">
              <label for="inputPassword3" class="col-sm-2 control-label">File Surat Masuk</label>
              <div class="col-sm-4">
                <input type="file" class="form-control" placeholder="File Surat Masuk" name="nama_file">
              </div>
            </div>

            <div class="form-group">
              <label for="input<PASSWORD>" class="col-sm-2 control-label">Pengolah</label>
              <div class="col-sm-4">
                <input type="text" class="form-control" placeholder="Pengolah" value="<?php echo ($nama_user) ?>" readonly
                  name="pengolah">
              </div>
            </div>

          </div>
          <!-- /.box-body -->
          <div class="box-footer">
            <div class="form-group">
              <div class="col-sm-offset-2 col-sm-10">
                <input type="submit" class="btn btn-primary" value="Submit">
                <input type='hidden' value='1' name="inputsurat" />
              </div>
            </div>
          </div>
        </form>
      </div>
      <!-- /.box -->
    </div>
    <!-- /.col -->
  </div>
  <!-- /.row -->
</section><file_sep><section class="content-header">
  <h1>
    Surat Masuk
  </h1>
  <ol class="breadcrumb">
    <li>
      <a href="#">
        <i class="fa fa-dashboard"></i> Home</a>
    </li>
    <li>
      <a href="#">Surat Masuk</a>
    </li>
    <li class="active">Rekap Surat Masuk</li>
  </ol>
</section>

<section class="content">
  <div class="row">
    <div class="col-xs-12">
      <div class="box">
        <div class="box-header">
          <h3 class="box-title">Rekap Surat Masuk</h3>
        </div>
        <!-- /.box-header -->
        <div class="box-body">
          <div class="table-responsive">
            <table id="table_data" class="table table-striped table-hover">
              <thead>
                <tr>
                  <th>No</th>
                  <th>Nomor Agenda</th>
                  <th>Perihal</th>
                  <th>Isi Ringkas</th>
                  <th>Asal Surat</th>
                  <th>Status</th>
                  <th>Aksi</th>
                </tr>
              </thead>

              <tbody>
                <?php
                    $no = 1;
                    $query = $mysqli->query("SELECT * FROM tbl_surat_masuk sm LEFT JOIN tbl_status_sm ssm ON sm.`no_surat` = ssm.`no_surat` ORDER BY sm.no_surat DESC");
                    while($data = $query->fetch_array()){ ?>
                  <tr>
                    <td>
                      <?php echo ($no) ?>
                    </td>
                    <td>
                      <?php echo ($data["nomor_agenda"]) ?>
                    </td>
                    <td>
                      <?php echo ($data["perihal"]) ?>
                    </td>
                    <td>
                      <?php echo ($data["isi_ringkas"]) ?>
                    </td>
                    <td>
                      <?php echo ($data["asal_surat"]) ?>
                    </td>

                    <?php 
                          if ($data["status"]=="disposed"){
                            $warna = "bg-primary";
                          }
                          else {
                            $warna = "bg-danger";
                          }
                          ?>
                    <td>
                      <p class="<?php echo ($warna) ?> text-center">
                        <?php echo ($data["status"]) ?> </p>
                    </td>


                    <td>
                      <a href= '<?php echo "?page=edit_surat&no_surat=$data[no_surat]"; ?>' class="btn btn-success btn-sm btn-block">edit</a>
                    </td>
                  </tr>
                  <?php $no++;
                    }
                    ?>
              </tbody>
            </table>
          </div>
        </div>
        <!-- /.box-body -->
      </div>
      <!-- /.box -->
    </div>
    <!-- /.col -->
  </div>
  <!-- /.row -->
</section> 
<file_sep><?php 

 
$message = 'hide';
$id=$_REQUEST['no_surat'];
$edit = "select * from tbl_surat_masuk where no_surat='$id'";
$hasil =  $mysqli->query($edit);
$row = $hasil->fetch_array(); 

if ($_POST) { 
foreach($_POST AS $key => $value) { $_POST[$key] = $mysqli->real_escape_string($value); } 
$sql = "UPDATE `tbl_surat_masuk` SET  
`kode_sm` =  '{$_POST['kode_sm']}' ,
`nomor_agenda` =  '{$_POST['nomor_agenda']}' ,
`perihal` =  '{$_POST['perihal']}' , 
`isi_ringkas` =  '{$_POST['isi_ringkas']}' , 
`asal_surat` =  '{$_POST['asal_surat']}' ,  
`tgl_sm` =  '{$_POST['tgl_sm']}' ,  
`lampiran` =  '{$_POST['lampiran']}' ,  
`tgl_diteruskan` =  '{$_POST['tgl_diteruskan']}' , 
`golongan_surat` =  '{$_POST['golongan_surat']}' 
 WHERE `no_surat` = $id "; 

$mysqli->query($sql) or die($mysqli->error); 
$message = 'show';
}
?>
<section class="content-header">
  <h1>
    Surat Masuk
  </h1>
  <ol class="breadcrumb">
    <li>
      <a href="#">
        <i class="fa fa-dashboard"></i> Home</a>
    </li>
    <li>
      <a href="#">Surat Masuk</a>
    </li>
    <li class="active">Input Surat Masuk</li>
  </ol>
</section>

<section class="content">
  <div class="row">
    <div class="col-xs-12">
      <div class="box box-primary">
        <div class="box-header with-border">
          <div class="alert alert-success alert-dismissible alert-message <?=$message?>">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            <h4>
              <i class="icon fa fa-check"></i> Sukses!</h4>
            Data berhasil disimpan
          </div>
          <h3 class="box-title">Input Surat Masuk</h3>
        </div>
        <!-- /.box-header -->
        <form class="form-horizontal" role="form" method="POST" action="">
          <div class="box-body">
          <input type='hidden' name='no_surat' value='<?= $id ?>' /> 
          <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">Kode Surat</label>
            <div class="col-sm-4">
              <input type="text" class="form-control" id="inputPassword3" placeholder="Kode Surat" name="kode_sm" required value="<?= stripslashes($row['kode_sm']) ?>">
            </div>
          </div>

          <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">Golongan Surat</label>
            <div class="col-sm-4">
              <select class="form-control" data-live-search="true" id="slct" data-size="5" name="golongan_surat" required>
                <option value="Biasa">Biasa</option>    
                <option value="Penting">Penting</option>                  
                <option value="Rahasia">Rahasia</option>
                <option value="Sangat Rahasia">Sangat Rahasia</option>

              </select>
            </div>
          </div>

          <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">Nomor Agenda</label>
            <div class="col-sm-4">
              <input type="text" class="form-control" id="inputPassword3" placeholder="Nomor Agenda" name="nomor_agenda" required value="<?= stripslashes($row['nomor_agenda']) ?>">
            </div>
          </div>

          <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">Perihal</label>
            <div class="col-sm-4">
              <input type="text" class="form-control" id="inputPassword3" placeholder="Perihal" name="perihal" required value="<?= stripslashes($row['perihal']) ?>">
            </div>
          </div>

          <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">Isi Ringkas</label>
            <div class="col-sm-7">
              <textarea  class="form-control textarea" id="inputPassword3" placeholder="<NAME>" name="isi_ringkas" required rows="5"><?= stripslashes($row['isi_ringkas']) ?></textarea>
            </div>
          </div>

          <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">Asal Surat</label>
            <div class="col-sm-4">
              <input type="text" class="form-control" id="inputPassword3" placeholder="<NAME>" name="asal_surat" required value="<?= stripslashes($row['asal_surat']) ?>">
            </div>
          </div>

          <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">Tanggal Diterima</label>
            <div class="col-sm-4">
              <input type="text" class="form-control" id="datepicker" placeholder="Tanggal" autocomplete="off" name="tgl_sm" data-date-format="yyyy-mm-dd" required value="<?= stripslashes($row['tgl_sm']) ?>">
            </div>
          </div>

          <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">Jumlah Lampiran</label>
            <div class="col-sm-4">
              <input type="text" class="form-control" id="inputPassword3" placeholder="Lampiran" name="lampiran" value="<?= stripslashes($row['lampiran']) ?>">
            </div>
          </div>





          <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">Tanggal Diteruskan</label>
            <div class="col-sm-4">
              <input type="text" class="form-control" id="datepicker2" placeholder="Tanggal Diteruskan" autocomplete="off" name="tgl_diteruskan" data-date-format="yyyy-mm-dd" required value="<?= stripslashes($row['tgl_diteruskan']) ?>">
            </div>
          </div>

          <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">File Permohonan</label>
            <div class="col-sm-4">
              <input type="file" class="form-control" id="inputPassword3" placeholder="Password" value="<?= stripslashes($row['perihal']) ?>">
            </div>
          </div>

          <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">Pegolah</label>
            <div class="col-sm-4">
              <input type="text" class="form-control" id="inputPassword3" placeholder="Pengolah" value="<?= stripslashes($row['pengolah']) ?>" readonly name="pengolah" >
            </div>
          </div>

          </div>
          <!-- /.box-body -->
          <div class="box-footer">
            <div class="form-group">
              <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary pull-right">Submit</button>
                <a href="dash.php" class="btn btn-success">Inbox Surat</a>
              </div>
            </div>
          </div>
      </div>
      </form>
    </div>
    <!-- /.box -->
  </div>

</section><file_sep><section class="content-header">
  <h1>
    Surat Masuk
    
  </h1>
  <ol class="breadcrumb">
    <li>
      <a href="#">
        <i class="fa fa-dashboard"></i> Home</a>
    </li>
    <li>
      <a href="#">Surat Masuk</a>
    </li>
    <li class="active">Inbox</li>
  </ol>
</section>

<section class="content">
  <div class="row">
    <div class="col-xs-12">
      <div class="box">
        <div class="box-header">
          <h3 class="box-title">Inbox Surat Masuk</h3>
        </div>
        <!-- /.box-header -->
        <div class="box-body">
          <div class="table-responsive">
            <table id="table_data" class="table table-striped table-hover">
            <thead>
            <tr>
              <th>No</th>
              <th>Nomor Agenda</th>
              <th>Perihal</th>
              <th>Isi Ringkas</th>
              <th>Asal Surat</th>
              <th>Golongan Surat</th>
              <th>Aksi</th>
            </tr>
          </thead>

          <tbody>
            <?php
                $no = 1;
                $query = $mysqli->query("SELECT * FROM tbl_surat_masuk LEFT JOIN tbl_status_sm ON tbl_surat_masuk.`no_surat` = tbl_status_sm.`no_surat`where tbl_status_sm.`status` = 'undisposed'  ORDER BY tbl_surat_masuk.`tgl_sm` DESC ");
                while($data = $query->fetch_array()){ ?>
              <tr>
                <td width="2%">
                  <?php echo ($no) ?> </td>
                <td>
                  <?php echo ($data["nomor_agenda"]) ?>
                </td>
                <td>
                  <?php echo ($data["perihal"]) ?>
                </td>
                <td>
                  <?php echo ($data["isi_ringkas"]) ?>
                </td>
                <td>
                  <?php echo ($data["asal_surat"]) ?>
                </td>

                <?php if ($data["golongan_surat"]=="Biasa"){
                        $warna = "bg-primary";
                      }
                      else if ($data["golongan_surat"]=="Penting") {
                        $warna = "bg-success";
                      }
                      else if ($data["golongan_surat"]=="Rahasia") {
                        $warna = "bg-warning";
                      } 
                      else {
                        $warna ="bg-danger";
                      }

                      ?>
                <td>
                  <p class="<?php echo ($warna) ?> text-center">
                    <?php echo ($data["golongan_surat"]) ?> </p>
                </td>


                <td>
                  <a href= <?php echo "?page=detail_disposisi&no_surat=$data[no_surat]"; ?> class="btn btn-success btn-sm"> detail </a>
                  <a href= <?php echo "?page=input_disposisi&no_surat=$data[no_surat]"; ?> class="btn btn-primary btn-sm"> disposisi </a>

                </td>
              </tr>
              <?php $no++;
                }
                ?>
          </tbody>

            </table>
          </div>
        </div>
        <!-- /.box-body -->
      </div>
      <!-- /.box -->
    </div>
    <!-- /.col -->
  </div>
  <!-- /.row -->
</section>