<?php
/*
error_reporting(E_ALL^(E_NOTICE|E_WARNING));
ini_set('display_errors',1);
error_reporting(0);*/
?>

<!-- Content Header (Page header) -->
<div class="content-header">
  <div class="container-fluid">
    <div class="row mb-1">
      <div class="col-sm-12">
        <!-- <h1 class="m-0 text-dark">Laporan Neraca []</h1> -->
      </div><!-- /.col -->
    </div><!-- /.row -->
  </div><!-- /.container-fluid -->
</div>
<!-- /.content-header -->

<!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-12">
            <!-- Default box -->
            <div class="card">
              <div class="card-header bg-info">
                <h3 class="card-title ">Posting Akhir Tahun</h3>
                <div class="card-tools">
                  <button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
                    <i class="fas fa-minus"></i>
                  </button>
                  <button type="button" class="btn btn-tool" data-card-widget="remove" title="Remove">
                    <i class="fas fa-times"></i>
                  </button>
                </div>
              </div>

              <!-- /.card-header -->
        <div class="card-body">
          <?php
          
          
          /*$username=$_SESSION['username'];*/
          if(isset($_POST['par2'])){
           
            $par2=date('Y',strtotime($_POST['par2']));
             $tgl=date('Y-m-d',strtotime($_POST['par2']));
            $kode=$_SESSION['kode'];
           
            if($_POST['par2']=='semua')
              $where="where  YEAR(tanggal)='$par2' AND kode_akun >='4' AND kode_akun <'5' GROUP BY kode_akun";
            else
              $where="where YEAR(tanggal)='$par2' AND kode_akun >='4' GROUP BY kode_akun";
            
          }else{
            
            $kode="";

            $where="where kode_akun='$kode'";
           
          }
          ?>
          <form role="form" id="quickForm" action="" method="POST">
            <div class="row">
              <div class="col-sm-10">
            <div class="form-group row">
              <label  for="nama" class="col-2 m-2">Tanggal</label>
              <input type="date" name="par2" id="par2" required="par2" class="form-control col-3" value="<?=@$tgl?>">
                <button type="submit" class="  btn btn-info"  ><i class="fas fa-search"></i></button>
                </div>
              </div>
                <?php if(isset($_POST['par2'])){ ?>

                  <div class="form-group col-2">
                  
              </div>
            </div>
                
               
              
                     
          </form>                   
          <hr>

          <form action="simpan/simpan_posting.php" method="POST">
            <!-- <table id="sortTable" width="100%" class="table table-bordered table-hover">
            <thead>
               <tr>
                <th>No</th>
                <th>Tgl</th>
                <th>Rekening</th>                
                <th>Debet</th>
            </thead>
            <tbody> -->
              <?php
              if(isset($_POST['par2'])){
                $tglm=$_POST['par2'];
             include 'koneksi.php';             

              $queryt = "SELECT kode_akun,keterangan,kode,id_jurnal, SUM(debet-kredit)AS debet from bukubesar  $where";
                $querya       =mysqli_query($koneksi,$queryt);
                if(mysqli_num_rows($querya)){
                $no=0;                
                while ($data = mysqli_fetch_assoc($querya)) {
                  extract($data);
                  
                 $no++;
                 /*<td align='center'> $id_jurnal </td>              
                    <td>$tgl</td>
                    <td>$kode_akun</td>                   
                    <td align='right'>$debet</td>*/
                  echo "                                  
                    <tr>
                    
                      <td><input type='hidden' name='id_jurnal[]'value ='$id_jurnal'checked </td>
                      <td><input type='hidden' name='tgl' value = '$tgl' </td> 
                       <td><input type='hidden' name='kode_akun[]'value ='$kode_akun'checked </td> 
                      <td><input type='hidden' name='debet[]' value='$debet'</td>
                                      
                  </tr>";
                   }}
                   ?>
                  
                  
              <!-- </tbody> -->
               <?php }?>
              </table>
              
            <input type="submit" name="Proses" value="Proses">
             </form>
             <?php } ?>
            <script type="text/javascript" charset="utf8" src="./assets/jquery.dataTables.js"></script>
              <link rel="stylesheet" type="text/css" href="./assets/jquery.dataTables.css">
                  <script>
              $('#sortTable').DataTable(); //https://www.sahretech.com/2020/04/cara-membuat-pencarian-sorting-dan.html?m=1/ cara buat sorter table
              </script>
              
            </div>
            <!-- /.card-body -->
          </div>
          <!-- /.card -->
        </div>
        <!-- /.col -->
      </div>

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


