<?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 Penerimaan Pinjaman</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_penerimaan_pinjaman'])){
            $id = $_POST['warkat_penerimaan_pinjaman'];
            if($_POST['warkat_penerimaan_pinjaman']=='Pilih')
              $where=" WHERE a.rekening = '".$id."' OR a.no_bukti= '".$id."' ";
            else
              $where=" WHERE a.rekening = '".$id."' OR a.no_bukti= '".$id."' ";

          }else{
            
            $id="";

            $where="where a.rekening='$id' ";
           
          }
          ?>
          <form role="form" id="quickForm" action="home.php?home=<?php echo md5("cetakpenerimaanpinjaman");?>" method="post">
            <div class="form-group row">
              <label for="nama" class="col-2 m-3">Rekening</label>
              <input type="text" name="warkat_penerimaan_pinjaman" id="warkat_penerimaan_pinjaman"  class="form-control col-sm-5" placeholder="Rekening" value="<?php if(isset($_POST['warkat_penerimaan_pinjaman'])){ echo $_POST['warkat_penerimaan_pinjaman'];}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 a.rekening AS rekening,a.no_bukti AS no_bukti,a.tgl AS tgl,a.taksasi,a.keterangan AS keterangan,b.nama AS nama,a.barang AS barang,a.jaminan AS jaminan,a.plafond AS plafond,a.noseri AS noseri,a.jtempo AS jatuhtempo FROM pinjaman a LEFT JOIN registrasi b ON b.id=SUBSTR(a.rekening,1,10)  $where   ";
                $queryc  =mysqli_query($koneksi,$querycw);
                if(mysqli_num_rows($queryc)){
                while ($data = mysqli_fetch_assoc($queryc)) {
                  extract($data);
                   }}
                 
                  ?>
                    <tr>                      
                    <td width="20%"><b>DATA PEMOHON GADAI</b></td>
                    </tr>
                    <tr>
                    <td width="20%">Tanggal</td><td width="1%">:</td>
                    <td width="31%"><?php echo $tgl; ?></td>
                    <td width="4%"></td>
                    <td width="20%">Nilai Pinjaman</td><td width="1%">:</td>
                    <td width="40%"><?php echo number_format($plafond); ?></td>
                  </tr>
                    <tr>
                    <td width="20%">No Kwitansi</td><td width="1%">:</td>
                    <td width="31%"><?php echo $no_bukti; ?></td>
                    <td width="4%"></td>
                    <td width="20%">Administrasi</td><td width="1%">:</td>
                    <td width="40%"><?php echo ""; ?></td>
                  </tr>
                  <tr>
                  <td width="20%">No Rek</td><td width="1%">:</td>
                    <td width="31%"><?php echo $rekening; ?></td>
                    <td width="4%"></td>
                    <td width="20%">Asuransi</td><td width="1%">:</td>
                    <td width="40%"><?php echo ""; ?></td>
                  </tr>
                  <tr>
                  <td width="20%">Nama</td><td width="1%">:</td>
                    <td width="20%"><?php echo $nama; ?></td>
                    <td width="4%"></td>
                    <td width="20%">Rekening Tujuan</td><td width="1%">:</td>
                    <td width="40%"><?php echo ""; ?></td>
                  </tr>
                  <tr>
                  <td width="20%">Nama Barang</td><td width="1%">:</td>
                    <td width="31%"><?php echo $barang; ?></td>
                    <td width="4%"></td>
                    <td width="20%">Tgl Jatuh Tempo</td><td width="1%">:</td>
                    <td width="40%"><?php echo date('d-F-Y', strtotime($jatuhtempo)); ?></td>
                  </tr>
                
                    <tr>
                    <td width="20%">No Seri</td><td width="1%">:</td>
                    <td width="31%"><?php echo $noseri;?></td>
                    <td width="4%"></td>
                    <td width="20%"></td><td width="1%">:</td>
                    <td width="40%"><?php echo ""; ?></td>
                  </tr>
                  
                  

              </tbody>

              </table>
              <p class="s2" style="margin-left:30px;margin-top: 40px;">
<?php echo "Apabila sampai dengan tanggal jatuh tempo nasabah tidak melunasi atau melakukan perpanjagan, maka nasabah memberikan kuasa kepada Pihak PT Gadai untuk menjual barang jaminan "."<br>"."\n\n" ?>
</p>


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

                ?>
                <a href="pdf/cetak_nobukti_pinjaman_pdf.php?no_bukti=<?php echo $_POST['warkat_penerimaan_pinjaman'];?>&rekening=<?php echo $_POST['rekening'];?>" 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 -->


