<?php 
$user_name = "root";
$password = "";
$database = "komitedb";
$host_name = "localhost";
$connect_db=mysql_connect($host_name, $user_name, $password);
$find_db=mysql_select_db($database);
if ($find_db) {
?>

<?php
$nama_dokumen='PDF With MPDF'; 
define('_MPDF_PATH','mpdf/');
require (_MPDF_PATH."mpdf.php");
$mpdf=new mPDF('utf-8', 'f4',0,30,20,10,5); 
ob_start(); 
?>



<?php
include_once "library/inc.sesadmin.php";
include_once "library/inc.library.php";

$tglStart = $_GET['mulai'];
$tglEnd = $_GET['sampai'];


# Set Tanggal skrg
$tglsekarang 	= isset($_POST['cmbTanggal']) ? $_POST['cmbTanggal'] : date('d-m-Y');

# Jika Nomor Page (halaman) diklik
if($_GET) {
	if (isset($_POST['btnShow'])) {
		$SqlPeriode = "AND ( transaksi.tgl_transaksi BETWEEN '".InggrisTgl($_POST['cmbTglStart'])."' AND '".InggrisTgl($_POST['cmbTglEnd'])."')";
	}
	else {
		$startTgl 	= isset($_GET['mulai']) ? $_GET['mulai'] : $tglStart;
		$endTgl 	= isset($_GET['sampai']) ? $_GET['sampai'] : $tglEnd; 
		$SqlPeriode = " AND ( transaksi.tgl_transaksi BETWEEN '".InggrisTgl($startTgl)."' AND '".InggrisTgl($endTgl)."')";
	}
}


?>

<html>
<a href="index.php?page=Rekap-Transaksi" style="border:2px;">_</a>
<form action="?page=Rekap-Transaksi" method="post" name="form1" target="_self" id="form1">
  <table width="850" border="0"  class="table-list">
    <tr>
      <td colspan="3" align="center" Style="font-size:25px;">REKAP TRANSAKSI HARIAN </td>
    </tr>
	<tr>
      <td colspan="3" align="center" Style="font-size:20px;">KOMITE MADRASAH ALIYAH NEGERI 4 BOGOR </td>
    </tr>
    <tr>
      <td width="520" align="right" Style="font-size:17px;"><strong>Dari Tanggal </strong></td>
      <td width="25" align="center" Style="font-size:17px;"><strong>:</strong></td>
      <td width="380" Style="font-size:17px;"><?php echo ($startTgl); ?> </td>
	  
    </tr>
	<tr>
      <td width="300" align="right" Style="font-size:17px;"><strong>Sampai Tanggal </strong></td>
      <td align="center" Style="font-size:17px;"><strong>:</strong></td>
	  <td width="500" Style="font-size:17px;"><?php echo ($endTgl); ?></td>
    </tr>
  </table>
</form>
<table class="table-list" width="850" border="1" cellspacing="0" cellpadding="3">
  <tr>
    <td width="20" align="center" bgcolor="#CCCCCC"><b>NO</b></td>
    <td width="40" align="center" bgcolor="#CCCCCC"><strong>TANGGAL</strong></td>
    <td width="40" align="center" bgcolor="#CCCCCC"><b>NIS</b></td>
    <td width="140" align="center" bgcolor="#CCCCCC"><b>NAMA</b></td>  
    <td width="125" align="center" bgcolor="#CCCCCC"><b>PEMBAYARAN</b></td>
    <td width="80" align="center" bgcolor="#CCCCCC"><b>BANYAK</b></td>
    <td width="50" align="center" bgcolor="#CCCCCC"><b>PENERIMA</b></td>
  </tr>
	<?php
	# Query utama. Query ini sama dg yg dipakai Paging di atas
	$dataSql = "SELECT transaksi.tgl_transaksi, transaksi.userid, transaksi_item.*, siswa.nama_siswa, bulan.keterangan 	
			 FROM transaksi, transaksi_item, siswa, bulan
			 WHERE transaksi.no_transaksi = transaksi_item.no_transaksi AND transaksi_item.kode_bayar=bulan.kode
			 AND transaksi_item.nis 	 = siswa.nis 	$SqlPeriode 
				ORDER BY transaksi.tgl_transaksi, siswa.nis, transaksi_item.kode_bayar ASC";
	$dataQry = mysql_query($dataSql, $koneksidb) or die ("Error Query".mysql_error());
	$nomor = 0; $totalBayar = 0;
	while ($dataRow = mysql_fetch_array($dataQry)) {
		$totalBayar = $totalBayar + intval($dataRow['banyak']);
		$nomor++;
	?>
  <tr>
    <td align="center"><?php echo $nomor; ?></td>
    <td align="center"><?php echo IndonesiaTgl($dataRow['tgl_transaksi']); ?></td>
    <td align="center"><?php echo $dataRow['nis']; ?></td>
    <td align="left"><?php echo $dataRow['nama_siswa']; ?></td>
    <td align="left"><?php echo $dataRow['keterangan']; ?></td>
    <td align="right"><?php echo format_angka ($dataRow['banyak']); ?></td>
    <td align="center"><?php echo $dataRow['userid']; ?></td>
  </tr>
  
  <?php } ?>
  
  <tr>
    <td colspan="5" align="right"><b>JUMLAH PEMASUKAN     :</b> </td>
	<td align="right"><?php echo format_angka($totalBayar); ?></td>
  </tr>
</table>
<table width="850" border="0">
	<tr>
		<td width="90" > </td>
		<td width="350" > </td>
		<td width="50" > Cigombong, <?php echo ($tglsekarang); ?> </td>
	</tr>
	<tr>
		<td>  </td>
		<td> Bendahara </td>
		<td> Penyetor </td>
	</tr>
	<tr>
		<td> &nbsp;</td>	
	</tr>
	<tr>
		<td> &nbsp;</td>	
	</tr>
	<tr>
		<td> &nbsp;</td>	
	</tr>
	<tr>
		<td  >  </td>
		<td> Nita Syaban Nurwarni</td>
		<td> Meta Sari Said </td>
	</tr>
</table>
</html>





<?php
$html = ob_get_contents(); 
ob_end_clean();
$mpdf->WriteHTML(utf8_encode($html));
$mpdf->Output($nama_dokumen.".pdf" ,'I');
exit;
?>
<?php
mysql_close($connect_db);
}else {
  echo "Database Tidak Ada";
  mysql_close($connect_db);
}
?>