"; echo "div#divprint{width:950px; border:1px solid #000; padding:20px 0; margin-bottom:25px;}"; echo "table.tbl {width:800px;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:30px;}"; echo ".header{font-weight:bold;text-align:center;}"; echo ".isi{text-align:left;}"; echo ""; $startDate = decTgl($_POST['jtTempo']); 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(); $ttJumlahTotalBon = 0; $ttJumlahSaldoTitip = 0; $ttJumlahNetSaldo = 0; $ttJumlahBonLimit = 0; print("
"); print("

Laporan Rekap Saldo Bon



"); print("
TOKO ".$_SESSION['namatoko']."
"); print("Jatuh Tempo Tanggal : ".encTgl($startDate)."
"); 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 m.status = 'B' and (p2.upline = '$kdcust' or p2.kd_customer = '$kdcust') 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')"; 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; $ttJumlah['nota'] = 0; while(mysqli_stmt_fetch($stmt3)){ $ttJumlah['titip'] += $titip; $ttJumlah['nota'] += $totNota; $saldotitip = $ttJumlah['titip'] - $ttJumlah['nota']; } }else{ $saldotitip = 0; } } $query4 = "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 m.status = 'B' and (p2.upline = '$kdcust' or p2.kd_customer = '$kdcust') and date(m.tgl_bon) <= '$startDate' group by p2.kd_customer"; if($stmt4 = mysqli_prepare($conn,$query4)){ mysqli_stmt_execute($stmt4); mysqli_stmt_store_result($stmt4); $cek4 = mysqli_stmt_num_rows($stmt4); if($cek4 > 0){ mysqli_stmt_bind_result($stmt4,$total4); $ttJumlah['bonlimit'] = 0; while(mysqli_stmt_fetch($stmt4)){ $ttJumlah['bonlimit'] += $total4; } }else{ $ttJumlah['bonlimit'] = 0; } } $netsaldo = $ttJumlah['totalbon']-$saldotitip; if ($netsaldo != 0){ $urut ++; print(""); $ttJumlahTotalBon += $ttJumlah['totalbon']; $ttJumlahSaldoTitip += $saldotitip; $ttJumlahNetSaldo += $netsaldo; $ttJumlahBonLimit += $ttJumlah['bonlimit']; } } print(""); print("
No.Kode PlgNamaAlamatUplineTotal BonTotal TitipSaldo Net BonSaldo Jth Tempo
$urut$kdcust$nama$alamat$upline ".number_format($ttJumlah['totalbon'], 0, ",", ".")." ".number_format($saldotitip, 0, ",", ".")." ".number_format($netsaldo, 0, ",", ".")." ".number_format($ttJumlah['bonlimit'], 0, ",", ".")."
".number_format($ttJumlahTotalBon, 0, ",", ".")." ".number_format($ttJumlahSaldoTitip, 0, ",", ".")." ".number_format($ttJumlahNetSaldo, 0, ",", ".")." ".number_format($ttJumlahBonLimit, 0, ",", ".")."

"); print("
"); }else{ echo "Data tidak ditemukan!"; } } } ?>