";
echo "div#divprint{width:900px; border:1px solid #000; padding:20px 0; margin-bottom:25px;}";
echo "table.tbl {width:750px;border-width:0 0 1px 1px;border-spacing:0;border-collapse:collapse;font-size:9pt;text-align:center;}";
echo "table.tbl,table.tbl td {border-color:#000;border-style:solid;}";
echo "table.tbl td {margin:0;padding:2px;border-width:1px 1px 0 0;}";
echo "body {font-size:9pt;}";
echo "div.luar{text-align:left;margin-left:50px;}";
echo ".header{font-weight:bold;text-align:center;}";
echo ".isi{text-align:left;}";
echo "";
$startDate = decTgl($_POST['startDate']);
$endDate = decTgl($_POST['endDate']);
if(bukaKoneksi()){
global $conn;
$query = "select p.kd_customer,p.nama,p.alamat,p.upline from pelanggan p where p.upline = '#'";
if($stmt = mysqli_prepare($conn,$query)){
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
$cek = mysqli_stmt_num_rows($stmt);
if($cek > 0){
mysqli_stmt_bind_result($stmt,$kdcust,$nama,$alamat,$upline);
$ttJumlah = array();
print("
");
print("
Laporan Rekap Saldo Bon Per Periode
");
print("
TOKO ".$_SESSION['namatoko']."
");
print("Periode Bon Tanggal : ".encTgl($startDate)." s/d ".encTgl($endDate)."
");
print("DICETAK TANGGAL : ".date('d-m-Y [H:i]')."
");
print("
");
print("");
while(mysqli_stmt_fetch($stmt)){
$query2 = "select sum(m.jumlah_total)
from pelanggan p2 force index (primary,upline), m_bon m force index (kd_plg)
where p2.kd_customer = m.kode_plg and
(p2.upline = '$kdcust' or p2.kd_customer = '$kdcust')
and date(m.tgl_bon) BETWEEN '$startDate' and '$endDate'
group by p2.kd_customer";
if($stmt2 = mysqli_prepare($conn,$query2)){
mysqli_stmt_execute($stmt2);
mysqli_stmt_store_result($stmt2);
$cek2 = mysqli_stmt_num_rows($stmt2);
if($cek2 > 0){
mysqli_stmt_bind_result($stmt2,$total);
$ttJumlah['totalbon'] = 0;
while(mysqli_stmt_fetch($stmt2)){
$ttJumlah['totalbon'] += $total;
}
}else{
$ttJumlah['totalbon'] = 0;
}
}
$query3 = "select m.jumlah_total,t.bayar_bon
from pelanggan p force index (primary,upline),bayar_bon t left join m_bon m on (t.no_bon = m.no_bon)
where t.kd_plg = p.kd_customer
and (t.kd_plg = '$kdcust' or p.upline = '$kdcust')
and date(t.tgl_byr) between '$startDate' and '$endDate'";
if($stmt3 = mysqli_prepare($conn,$query3)){
mysqli_stmt_execute($stmt3);
mysqli_stmt_store_result($stmt3);
$cek3 = mysqli_stmt_num_rows($stmt3);
if($cek3 > 0){
mysqli_stmt_bind_result($stmt3,$totNota,$titip);
$ttJumlah['titip'] = 0;
while(mysqli_stmt_fetch($stmt3)){
$ttJumlah['titip'] += $titip;
}
}else{
$ttJumlah['titip'] = 0;
}
}
if ($ttJumlah['totalbon'] != 0){
print("| $kdcust | $nama | $alamat | $upline | ".number_format($ttJumlah['totalbon'], 0, ",", ".")." | ".number_format($ttJumlah['titip'], 0, ",", ".")." |
");
}
}
print("
");
print("
");
}else{
echo "Data tidak ditemukan!";
}
}
}
?>