<?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 Pelunasan</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."' ORDER BY c.no DESC LIMIT 1 ";

          }else{
            
            $id="";

            $where="where b.rekening='$id' ";
           
          }
          ?>
          <form role="form" id="quickForm" action="home.php?home=<?php echo md5("warkatpelunasan");?>" 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 border="0" width="100%" style="margin-left:22px" >
            
            <tbody>
              <?php
              include 'koneksi.php';
              $querycw = "SELECT b.rekening AS rekening,a.id AS id,a.nik AS nik,a.nama AS nama,a.alamat AS alamat,b.taksasi AS taksasi,b.barang AS barang,b.kelengkapan AS kelengkapan,b.noseri AS noseri,b.kondisi AS kondisi,a.rtrw AS rtrw, a.nohp AS nohp,b.plafond AS plafond,DATE_ADD(b.tgl, INTERVAL b.jangkawaktu MONTH) AS jatuh_tempo,c.tgl AS tgl,c.pokok AS pokok,c.margin AS margin,b.jaminan AS jaminan,c.keterangan AS keterangan,c.username AS usersystem  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);
                   }}
                 
                  ?> 
                                    
                    <tr>
                    <td width="8%">No KTP</td>
                    <td width="1%">:</td>
                    <td width="19%" style="text-align: left;"><?php echo $nik;?></td>
                    <td width="8%">Tanggal</td>
                    <td width="1%">:</td>
                    <td width="19%"><?php echo date('d-m-Y',strtotime($tgl));?></td>              
                  </tr>

                  <tr>
                    <td width="8%">Nama</td>
                    <td width="1%">:</td>
                    <td width="19%"><?php echo ucwords(strtolower($nama));?></td>
                    <td width="8%">Pokok Pinjaman</td><td style="width:2px;">:</td>
                    <td width="19%"><?php echo number_format($pokok,0);?></td>     
                  </tr>
                  <tr>
                    <td width="8%">No Telepon</td>
                    <td width="1%">:</td>
                    <td width="19%"><?php echo $nohp;?></td>
                    <td width="8%">Biaya Titip</td><td style="width:2px;">:</td>
                    <td width="19%"><?php echo number_format($margin,0);?></td>     
                  </tr>
                  <tr>
                    <td width="8%">Alamat</td>
                    <td width="1%">:</td>
                    <td width="19%"><?php echo $alamat;?></td>
                    <td width="8%">Jumlah</td><td style="width:2px;">:</td>
                    <td width="19%"><?php echo number_format($pokok+$margin,0);?></td>     
                  </tr>
                  
                 </table>

                 <table border="1" width="80%" style="margin-left:22px;margin-top:10px" >
                  <tr>
                  <td style="text-align: center;">Nama Barang</td>
                  <td style="text-align: center;">Kondisi</td>
                    <td style="text-align: center;">No Seri</td>
                    <td style="text-align: center;">Kelengkapan</td>
                  </tr>
                  <tr>
                    <td width="22%" style="text-align: center;"><?php echo $barang;?></td>
                    <td width="22%" style="text-align: center;"><?php echo $kondisi;?></td>
                    <td width="22%" style="text-align: center;"><?php echo $noseri;?></td>
                    <td width="35%" style="text-align: center;"><?php echo $kelengkapan;?></td>
                  </tr>
              </table>

      <table border="0" width="90%" style="margin-top:22px;margin-left:22px;">
        <tr>
            <td style="text-align: center;">Dibayar Oleh</td>
            <td style="width: 20%;"></td>
            <td style="text-align: center;">Diterima Oleh</td>
          </tr>
          <tr style="height: 170px;">
            <td style="text-align: center;"><?php echo ucwords(strtolower($nama));?></td>
            <td style="width: 20%;"></td>
            <td style="text-align: center;"><?php echo ucwords(strtolower($usersystem));?></td>
          </tr>
          <tr>
            <td colspan="3">
            <?php 
          
          echo wordwrap("1. Cek kembali barang dan uang anda sebelum "."&nbsp;"."meninggal kan outlet"."<br>\n");
          
          echo wordwrap("2. Segala bentuk kerusakan dan kekurangan pada barang atau uang  menjadi tanggung jawab nasabah setelah meninggalkan outlet". "<br>\n");
          echo wordwrap("3. Barang gadai yg telah melewati batas maksimal masa gadai" ."(45 hari)"." tidak dapat mengklaim garansi"."<br>\n");
            ?>                      
            </td>
          </tr>
      </table>
        
              </tbody>
              </br>
              <?php if(isset($_POST['warkat_pencairan'])){
                $_SESSION['warkatp']['kode']['sql']=$querycw;
                $_SESSION['warkatp']['akun']=$_POST['warkat_pencairan'];

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

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

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

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


