<?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 ">Cetak Warkat Pencairan</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
     
          if(isset($_POST['warkat_pencairan'])){
            $id = $_POST['warkat_pencairan'];
            if($_POST['warkat_pencairan']=='Pilih')
              $where="where b.rekening = '".$id."' ";
            else
              $where="where b.rekening = '".$id."' ";

          }else{
            
            $id="";

            $where="where b.rekening='$id' ";
           
          }
          ?>
          <form role="form" id="quickForm" action="home.php?home=<?php echo md5("warkatpencairan");?>" method="post">
            <div class="form-group row">
              <label for="nama" class="col-2 m-3">Rekening</label>
              <input type="text" name="warkat_pencairan" id="warkat_pencairan"  class="form-control col-sm-5" placeholder="Rekening" value="<?php if(isset($_POST['warkat_pencairan'])){ echo $_POST['warkat_pencairan'];}else{echo "";} ?>">
              <div class="form-group row">
                <button type="submit" class="  btn btn-info"  ><i class="fas fa-search"></i></button>
               </div>
              
                     
          </form>                   
          <hr>

          <!-- <table id="example3" class="table table-bordered table-hover" width="148%"> -->
          <table border="0" width="148%" style="margin-left:22px" >
            
            <tbody>
              <?php
              include 'koneksi.php';
              $querycw = "SELECT b.tgl as tgl,b.rekening as rekening,a.id as id,a.nik as nik,a.nama as nama,a.alamat as alamat,a.rtrw as rtrw, a.nohp as nohp,b.plafond as plafond,c.plafond-SUM(c.pokok) AS bakidebet,b.barang as barang,b.jenisbarang as jenisbarang,b.kelengkapan as kelengkapan,b.kondisi as kondisi,b.noseri as noseri,b.plafond*b.margin/100 as margin,DATE_ADD(b.tgl, INTERVAL b.jangkawaktu MONTH)as jatuh_tempo  from registrasi a left join pinjaman b ON a.id=b.register LEFT JOIN angsuran c ON b.rekening=c.rekening $where  ";
                $queryc       =mysqli_query($koneksi,$querycw);
                if(mysqli_num_rows($queryc)){
                while ($data = mysqli_fetch_assoc($queryc)) {
                  extract($data);
                   }}
                 
                  /*https://www.niagahoster.co.id/blog/undefined-index-php/
                  cara mengatasi Undefined variable  php terbaru*/
                  ?> 
                    <!-- <td><?php echo date('d-m-Y',strtotime($tanggal)); ?></td> -->
                    <tr>                      
                    <td width="20%"><b>DATA PEMOHON GADAI</b></td>
                    </tr>
                    <tr>
                    <td width="20%">No. Rekening</td><td width="1%">:</td>
                    <td width="19%"><?php echo $rekening; ?></td>
                    <td width="12%"></td>
                    <td width="19%">Tgl Realisasi</td><td width="1%">:</td>
                    <td width="40%"><?php echo date('d-m-Y',strtotime($tgl)); ?></td>
                  </tr>
                    <td width="20%">No. KTP</td><td width="1%">:</td>
                    <td width="19%"><?php echo $nik; ?></td>
                    <td width="12%"></td>
                    <td width="19%">Plafond</td><td width="1%">:</td>
                    <td width="40%"><?php echo number_format($plafond); ?></td>
                  </tr>
                  <tr>
                  <td width="20%">Nama</td><td width="1%">:</td>
                    <td width="19%"><?php echo $nama; ?></td>
                    <td width="12%"></td>
                    <td width="19%">Bakidebet</td><td width="1%">:</td>
                    <td width="40%"><?php echo number_format($bakidebet); ?></td>
                  </tr>
                  <tr>
                  <td width="20%">No.Tlp</td><td width="1%">:</td>
                    <td width="19%"><?php echo $nohp; ?></td>
                    <td width="12%"></td>
                    <td width="19%">Biaya Penitipan</td><td width="1%">:</td>
                    <td width="40%"><?php echo number_format($margin); ?></td>
                  </tr>
                  <tr>
                  <td width="20%">Alamat</td><td width="1%">:</td>
                    <td width="19%"><?php echo $alamat; ?></td>
                    <td width="12%"></td>
                    <td width="19%">Tgl Jatuh Tempo</td><td width="1%">:</td>
                    <td width="40%"><?php echo  date('Y-m-d', strtotime('+15 days', strtotime($tgl)));  ?></td>
                  </tr>
                
                <tr>                      
                    <td width="20%"><b>DATA BARANG GADAI</b></td>
                    </tr>
                    <tr>
                    <td width="20%">Nama Barang</td><td width="1%">:</td>
                    <td width="19%"><?php echo $barang;?></td>
                    <td width="12%"></td>
                    <td width="19%">Perpanjangan ke-1</td><td width="1%">:</td>
                    <td width="40%"><?php echo date('Y-m-d', strtotime('+15 days', strtotime($tgl))); ?></td>
                  </tr>
                  <tr>
                  <td width="20%">Jenis Barang</td><td width="1%">:</td>
                    <td width="19%"><?php echo $jenisbarang; ?></td>
                    <td width="12%"></td>
                    <td width="19%">Perpanjangan ke-2</td><td width="1%">:</td>
                    <td width="40%"><?php echo date('Y-m-d', strtotime('+30 days', strtotime($tgl))); ?></td>
                  </tr>
                  <tr>
                  <td width="20%">Kelengkapan</td><td width="1%">:</td>
                    <td width="19%"><?php echo $kelengkapan; ?></td>
                    <td width="12%"></td>
                    <td width="19%">Pelunasan</td><td width="1%">:</td>
                    <td width="40%"><?php  ?></td>
                  </tr>
                  <tr>
                  <td width="20%">Kondisi</td><td width="1%">:</td>
                    <td width="19%"><?php echo $kondisi; ?></td>
                    <td width="12%"></td>
                    <td width="19%">Tgl Pelunasan</td><td width="1%">:</td>
                    <td width="40%"><?php echo date('d-m-Y', strtotime('+45 days', strtotime($tgl)));  ?></td>
                  </tr>
                  <tr>
                  <td width="20%">No.Seri</td><td width="1%"></td>
                    <td width="19%"><?php echo $noseri; ?></td>
                    <td width="12%"></td>
                    <td width="19%"></td><td width="1%"></td>
                    <td width="40%"><?php  ?></td>
                  </tr>
                  

              </tbody>
              </table>

              <?php if(isset($_POST['warkat_pencairan'])){
               
                $_SESSION['warkatp']['kode']['sql']=$querycw;
                $_SESSION['warkatp']['akun']=$_POST['warkat_pencairan'];

                ?>
                <a href="pdf/cetak_warkat_pencairan_pdf.php" target="_blank" style="float: right;margin-top: 10px;" class="btn btn-success"><i class="far fa-file-pdf"></i> PDF</a>

                <a href="faktur/cetak_faktur_warkat.php" target="_blank" style="float: right;margin-top: 10px;" class="btn btn-warning"><i class="fa fa-print"></i> Print</a>

              <?php } ?>
            </div>
            <!-- /.card-body -->
          </div>
          <!-- /.card -->
        </div>
        <!-- /.col -->
      </div>

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


