
<?php 
    include 'header.php'; 
    $id = $_GET['id'];

    $jor = mysqli_query($koneksi,"select * from jor where notrans='$id'");
    $j = mysqli_fetch_assoc($jor);  

    $kas = mysqli_query($koneksi,"select * from kas where notrans='$id'");
    $k = mysqli_fetch_assoc($kas);
    $oleh=$k['oleh'];
    
    $n_kode_1 = mysqli_query($koneksi,"select * from karyawan where id='$oleh'");
    $x = mysqli_fetch_assoc($n_kode_1); 
?>              

<div class="container">
  <div class="my-2 border-bottom">
        <h6 class="fw-semibold fs-6"></h6>
  </div>
  <div class="row justify-content-center">
    <div class="col-lg-6">
       <div class="card">
    <div class="card-header d-flex justify-content-between">
      <span class="card-title fw-semibold align-self-start mb">KARTU JORNAL TRANSAKSI PER NOTRANS</span>
      <button type="button" class="btn btn-primary btn-sm align-self-end" data-bs-toggle="modal" data-bs-target="#exampleModal">
        <a href="javascript:history.go(-1)" class="btn btn-primary btn-sm"><i class="bi bi-reply-all"></i> &nbsp Kembali</a> 
      </button>
    </div>
          <div class="box-body">
            <form method="get" action="">
              <div class="row">
                <div class="col-lg-12">
                  <table class="table table-bordered">
                    <tr>
                      <th width="35%">Uraian</th>
                      <th width="1%">:</th>
                      <td><?php echo $j['keterangan'] ?></td>
                    </tr>
                    <tr>
                      <th>Tanggal / NoTrans / Klp </th>
                      <th>:</th>
                      <td><?php echo date('d/m/Y', strtotime($j['tanggal'])); ?> / <?php echo $j['notrans'] ?> / <?php echo $j['unit'] ?> </td>
                    </tr>
                    <tr>
                      <th>Petugas Input </th>
                      <th>:</th>
                      <td><?php echo $x['nama'] ?></td>
                    </tr>
                  </table>
<!-- ////////////////////////// Jor //////////////// -->          

    <div class="card-body">
      <div class="table-responsive">
        <table class="table table-bordered table-striped" id="table-datatable1">
          <thead>
            <tr>
            <tr>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">No</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Akunt</th>
              <th width="50%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">N a m a</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Debet</th>
              <th width="1%" class="text-center" style="text-align:left; font-size: 10pt; font-weight:normal;">Kredit</th>
            </tr>
            </tr>
          </thead>
          <tbody>
            <?php 
              $no   = 1;
              $awal = 0;
              $debet  = 0;
              $kredit  = 0;
            $jor = mysqli_query($koneksi,"SELECT * FROM jor WHERE notrans=$id ORDER BY id ASC");
            while($p = mysqli_fetch_array($jor)){
                $noperk=$p['noperk'] ;
                
                
                $nawal = mysqli_query($koneksi,"select * from nawal where noperk='$p[noperk]'");
                    $n = mysqli_fetch_assoc($nawal);  
              ?>
              <tr>
                <td><?php echo $no++; ?></td>
                <td style="text-align:left; font-size: 10pt; font-weight:normal;"><?php echo $p['noperk'] ?></td>
                <td style="text-align:left; font-size: 10pt; font-weight:normal;"><?php echo $n['perk'] ?></td>
                <td style="text-align:right; font-size: 10pt; font-weight:normal;"><?php echo "" . number_format("$p[debet]", 0, ",", "."); ?></td>
                <td style="text-align:right; font-size: 10pt; font-weight:normal;"><?php echo "" . number_format("$p[kredit]", 0, ",", "."); ?></td>
              </tr>   
  
                  </form>                      
              <?php } ?>
          </tbody>

                        <?php 
                $sql1 = mysqli_query($koneksi, "SELECT sum(debet) AS tdebet,sum(kredit) AS tkredit FROM jor WHERE notrans=$id ");
                list($tdebet,$tkredit) = mysqli_fetch_array($sql1);
            	        ?>						
							<tr>
						    	<td colspan="3" style="font-weight: bold;text-align: center;">Total </td>																																									
								<td align='right'><style="font-weight: bold;"><?php echo "" . number_format("$tdebet", 0, ",", "."); ?></td>
								<td align='right'><style="font-weight: bold;"><?php echo "" . number_format("$tkredit", 0, ",", "."); ?></td>
							</tr>          
							
        </table>
       </div> 
    </div>    

<!-- ////////////////////////// SELESAI PERMOHONAN  //////////////// --> 
                </div>
              </div>
              </div>
            </form>
          </div>
      </div>
    </div>
  </div>
</div>
<?php include 'footer.php'; ?>