


<?php 
    session_start();
    include 'header.php'; 

    $kdj = $_GET['kdj'];

    $tgl_ini=$_GET['tgl'];
    $tgl_ini2 = date('Y-m-d', strtotime($tgl_ini));
    
    $oleh=$_SESSION['id_kar'];
    $kdc=$_SESSION['kdc'];
    
    $nawal = mysqli_query($koneksi,"select * from nawal where noperk='$kdj'");
        $n = mysqli_fetch_assoc($nawal);    
    $perk = str_replace('Pend. ', '', $n['perk']);    
?>            
<div class="container">

  <div class="my-4 border-bottom">
    <h4 class="fw-semibold fs-4">Daftar Transaksi <?php echo $perk; ?>
    </h4>  
  </div>
  <section class="content">
    <div class="row">
      <section class="col-lg-14">
        <div class="box box-info">
          <div class="box-header">
          <div class="box-body">
            <form method="get" action="">

            </form>
          </div>
        </div>
        
        <div class="box box-info">
          <div class="box-header">
            <h6 class="box-title"></h6>
          </div>
          <div class="box-body">
            <?php 
                $tgl_d    = $tgl_ini;
              ?>

              <div class="row">
                <div class="col-lg-10">
                  <table class="table table-bordered">
                    <tr>
                      <th width="30%">TANGGAL</th>
                      <th width="1%">:</th>
                      <td><?php echo date('d-m-Y', strtotime($tgl_d)); ?></td>
                    </tr>

                    <tr>
                      <th>Lanjutan </th>
                      <th>:</th>
                      <td>
                          <button onclick="window.history.back()" class="btn btn-primary btn-sm pull-right"><i class="bi bi-reply"></i>&nbsp; Kembali</button>  
                          <a href="index.php" class="btn btn-secondary btn-sm pull-right"><i class="bi bi-bank"></i> &nbsp; Home</a> 
                      </td>
                    </tr>                       
                  </table>
                </div>
              </div>




      <!-- Modal -->
      <form action="tugas_tambah_trans_act.php" method="post">
        <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <h1 class="modal-title fs-5" id="exampleModalLabel">Tambah Transaksi</h1>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
              </div>
              <div class="modal-body">

<div style="background-color: <?php echo$_SESSION['warna_bag']; ?>; padding: 15px; border-radius: 15px; box-shadow: 0 0 15px <?php echo$_SESSION['warna_bag']; ?>;">                  

                	        <div class="form-group" style="width:100%">
                	            <label class="form-label">Nama Donatur <font color='#ff00ff'><i>(pilih Nama)</i></font color></label>
                                <?php
                                $query = mysqli_query($koneksi, "SELECT * FROM anggota Where hapus<>'HAPUS' order by nama ASC");
                        
                                // Membuat array untuk menyimpan data
                                $datay = array();
                                while ($row = mysqli_fetch_assoc($query)) {
                                    $datay[] = $row;
                                    }
                                ?>
                                <input class="form-control" type="text" name="tangg_no" list="options">
                                <datalist id="options">
                                    <?php foreach ($datay as $row) { ?>
                                    <option value="<?php echo $row['angg_no']; ?> - <?php echo $row['nama']; ?>"><?php echo $row['angg_no']; ?> - <?php echo $row['nama']; ?></option>
                                    <?php } ?>
                                </datalist>
	                        </div>               
                            <div class="form-group" style="width:100%">
                              <label>Jumlah </label>
                                <input type="hidden" name="tkdc" required="required" class="form-control" value=<?php echo $kdc; ?> readonly required >
                                <input type="hidden" name="tkdj" required="required" class="form-control" value=<?php echo $kdj; ?> readonly required >
                                <input type="hidden" name="toleh" required="required" class="form-control" value=<?php echo $oleh; ?> readonly required > 
                                <input type="hidden" name="ttanggal" required="required" class="form-control" value=<?php echo $tgl_ini2; ?> readonly required > 
                              <input type="text" class="form-control nilai rupiah" id="nilai" name="tjumlah" required="required" placeholder="Masukkan nominal ..">
                            </div>   	                        
              </div>  
                </div>              
              <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
                <button type="submit" class="btn btn-primary">Simpan</button>
              </div>
            </div>
          </div>
        </div>
        
        
        
        </div>
              <div class="table-responsive">
                <table class="table table-bordered table-striped" id="table-datatable">
          <thead>
            <tr>
              <th width="1%" class="text-center" style="text-align:Center; font-size: 10pt; font-weight:normal;">Urt</th>
              <th width="1%" class="text-center" style="text-align:Center; font-size: 10pt; font-weight:normal;">Nama</th>
              <th width="1%" class="text-center" style="text-align:Center; font-size: 10pt; font-weight:normal;">Alamat</th>
              <th width="1%" class="text-center"></th>
              <th width="1%" class="text-center" style="text-align:Center; font-size: 10pt; font-weight:normal;">Jumlah</th>              
            </tr>
          </thead>
          <tbody>
            <?php 
            $no=1;
            $data = mysqli_query($koneksi,"SELECT * FROM anggota_trans_ao WHERE kdj='$kdj' and tanggal='$tgl_ini2' and ao='$oleh' and hapus<>'HAPUS' order by id DESC");
            while($t = mysqli_fetch_array($data)){
                $noang  =$t['angg_no'] ;
                $anggota = mysqli_query($koneksi,"select * from anggota where angg_no='$noang'");
                $a = mysqli_fetch_assoc($anggota);
                //target="_blank"
              ?>
              <tr>
                <td  style="text-align:center; font-size: 9pt; font-weight:normal;"><?php echo $no++; ?></td>
                <td style="text-align:left; font-size: 10pt; font-weight:normal;"><?php echo $a['nama']; ?></td>
                <td style="text-align:left; font-size: 9pt; font-weight:normal;"><?php echo $a['alamat']; ?> <?php echo $a['rt']; ?> <?php echo $a['rw']; ?></td>
                <td>
                    <a data-toggle='tooltip' data-placement='top' title='Cetak kuitansi <?php echo $t['notrans'] ?> a/n <?php echo $a['nama']; ?>' style='margin-right:3px' class="btn btn-success btn-sm" href="tugas_trans_kuitansi.php?tid=<?php echo $t['id'] ?>&angg_no=<?php echo $noang ?>" ><i class="bi bi-printer-fill"></i></a>                    
                </td>
                <td style="text-align:right; font-size: 10pt; font-weight:normal;"><?php echo "" . number_format("$t[masuk]", 0, ",", "."); ?></td>
              </tr>
              <?php 
            }
            ?>
          </tbody>
                <?php 
                  if ($kdj<>'ALL') { ;
                    $sql_2 = mysqli_query($koneksi, "SELECT sum(masuk-keluar) AS tsaldo2 FROM anggota_trans_ao WHERE kdj='$kdj' and tanggal='$tgl_ini2' and ao='$oleh' and hapus<>'HAPUS' ");
                    list($tsaldo2) = mysqli_fetch_array($sql_2);
                  } else { ;
                    $sql_2 = mysqli_query($koneksi, "SELECT sum(masuk-keluar) AS tsaldo2 FROM anggota_trans_ao WHERE tanggal='$tgl_ini2' and ao='$oleh' and hapus<>'HAPUS' ");
                    list($tsaldo2) = mysqli_fetch_array($sql_2);                  
                  } ;
            	?>	
							<tr>
						    	<td colspan="4" style="font-weight: bold;text-align: center;">Total <?php echo $perk; ?> </td>																																									
								<td align='right'><style="font-weight: bold;">
								    <?php echo "" . number_format("$tsaldo2", 0, ",", "."); ?>
								</td>
							</tr>         
        </table>
              </div>
          </div>
        </div>
      </section>
    </div>
  </section>

</div>
<?php include 'footer.php'; ?>