";
echo "table.tbl {width:80%;border-width:1px 1px 1px 1px;border-spacing:0;border-collapse:collapse;font-size:9pt;text-align:center;}";
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:150px;}";
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 vX.tgl,A,totA,B,totB,C,totC,D,totD,E,totE,F,totF,G,totG,H,totH
from
(SELECT date(tgl_nota) tgl,count(*) x,sum(jumlah_total) totx
FROM m_nota_tunai m
WHERE
date(tgl_nota) between '$startDate' AND '$endDate'
group by tgl)vX
LEFT OUTER JOIN
(SELECT date(tgl_nota) tgl,count(*) A,sum(jumlah_total) totA
FROM m_nota_tunai m
WHERE
m.status_nota = 'S'
and m.jumlah_total <= 100000
and date(tgl_nota) between '$startDate' AND '$endDate'
group by tgl)vA
ON vX.tgl = vA.tgl
LEFT OUTER JOIN
(SELECT date(tgl_nota) tgl,count(*) B,sum(jumlah_total) totB
FROM m_nota_tunai m
WHERE
m.status_nota = 'S'
and m.jumlah_total >= 100001 and m.jumlah_total <= 200000
and date(tgl_nota) between '$startDate' AND '$endDate'
group by tgl)vB
ON vX.tgl = vB.tgl
LEFT OUTER JOIN
(SELECT date(tgl_nota) tgl,count(*) C,sum(jumlah_total) totC
FROM m_nota_tunai m
WHERE
m.status_nota = 'S'
and m.jumlah_total >= 200001 and m.jumlah_total <= 300000
and date(tgl_nota) between '$startDate' AND '$endDate'
group by tgl)vC
ON vX.tgl = vC.tgl
LEFT OUTER JOIN
(SELECT date(tgl_nota) tgl,count(*) D,sum(jumlah_total) totD
FROM m_nota_tunai m
WHERE
m.status_nota = 'S'
and m.jumlah_total >= 300001 and m.jumlah_total <= 400000
and date(tgl_nota) between '$startDate' AND '$endDate'
group by tgl)vD
ON vX.tgl = vD.tgl
LEFT OUTER JOIN
(SELECT date(tgl_nota) tgl,count(*) E,sum(jumlah_total) totE
FROM m_nota_tunai m
WHERE
m.status_nota = 'S'
and m.jumlah_total >= 400001 and m.jumlah_total <= 500000
and date(tgl_nota) between '$startDate' AND '$endDate'
group by tgl)vE
ON vX.tgl = vE.tgl
LEFT OUTER JOIN
(SELECT date(tgl_nota) tgl,count(*) F,sum(jumlah_total) totF
FROM m_nota_tunai m
WHERE
m.status_nota = 'S'
and m.jumlah_total >= 500001 and m.jumlah_total <= 600000
and date(tgl_nota) between '$startDate' AND '$endDate'
group by tgl)vF
ON vX.tgl = vF.tgl
LEFT OUTER JOIN
(SELECT date(tgl_nota) tgl,count(*) G,sum(jumlah_total) totG
FROM m_nota_tunai m
WHERE
m.status_nota = 'S'
and m.jumlah_total >= 600001 and m.jumlah_total <= 1250000
and date(tgl_nota) between '$startDate' AND '$endDate'
group by tgl)vG
ON vX.tgl = vG.tgl
LEFT OUTER JOIN
(SELECT date(tgl_nota) tgl,count(*) H,sum(jumlah_total) totH
FROM m_nota_tunai m
WHERE
m.status_nota = 'S'
and m.jumlah_total >= 1250001
and date(tgl_nota) between '$startDate' AND '$endDate'
group by tgl)vH
ON vX.tgl = vH.tgl";
$query2 = "select vX.tgl,A,totA,B,totB,C,totC,D,totD,E,totE,F,totF,G,totG,H,totH
from
(SELECT date(tgl_bon) tgl,count(*) x,sum(jumlah_total) totx
FROM m_bon m
WHERE
date(tgl_bon) between '$startDate' AND '$endDate'
group by tgl)vX
LEFT OUTER JOIN
(SELECT date(tgl_bon) tgl,count(*) A,sum(jumlah_total) totA
FROM m_bon m
WHERE
m.jumlah_total <= 100000
and date(tgl_bon) between '$startDate' AND '$endDate'
group by tgl)vA
ON vX.tgl = vA.tgl
LEFT OUTER JOIN
(SELECT date(tgl_bon) tgl,count(*) B,sum(jumlah_total) totB
FROM m_bon m
WHERE
m.jumlah_total >= 100001 and m.jumlah_total <= 200000
and date(tgl_bon) between '$startDate' AND '$endDate'
group by tgl)vB
ON vX.tgl = vB.tgl
LEFT OUTER JOIN
(SELECT date(tgl_bon) tgl,count(*) C,sum(jumlah_total) totC
FROM m_bon m
WHERE
m.jumlah_total >= 200001 and m.jumlah_total <= 300000
and date(tgl_bon) between '$startDate' AND '$endDate'
group by tgl)vC
ON vX.tgl = vC.tgl
LEFT OUTER JOIN
(SELECT date(tgl_bon) tgl,count(*) D,sum(jumlah_total) totD
FROM m_bon m
WHERE
m.jumlah_total >= 300001 and m.jumlah_total <= 400000
and date(tgl_bon) between '$startDate' AND '$endDate'
group by tgl)vD
ON vX.tgl = vD.tgl
LEFT OUTER JOIN
(SELECT date(tgl_bon) tgl,count(*) E,sum(jumlah_total) totE
FROM m_bon m
WHERE
m.jumlah_total >= 400001 and m.jumlah_total <= 500000
and date(tgl_bon) between '$startDate' AND '$endDate'
group by tgl)vE
ON vX.tgl = vE.tgl
LEFT OUTER JOIN
(SELECT date(tgl_bon) tgl,count(*) F,sum(jumlah_total) totF
FROM m_bon m
WHERE
m.jumlah_total >= 500001 and m.jumlah_total <= 600000
and date(tgl_bon) between '$startDate' AND '$endDate'
group by tgl)vF
ON vX.tgl = vF.tgl
LEFT OUTER JOIN
(SELECT date(tgl_bon) tgl,count(*) G,sum(jumlah_total) totG
FROM m_bon m
WHERE
m.jumlah_total >= 600001 and m.jumlah_total <= 1250000
and date(tgl_bon) between '$startDate' AND '$endDate'
group by tgl)vG
ON vX.tgl = vG.tgl
LEFT OUTER JOIN
(SELECT date(tgl_bon) tgl,count(*) H,sum(jumlah_total) totH
FROM m_bon m
WHERE
m.jumlah_total >= 1250001
and date(tgl_bon) between '$startDate' AND '$endDate'
group by tgl)vH
ON vX.tgl = vH.tgl";
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,$tgl,$A,$totA,$B,$totB,$C,$totC,$D,$totD,$E,$totE,$F,$totF,$G,$totG,$H,$totH);
$ttJumlah = array();
$ttJumlah['jmltunai'] = 0;
$ttJumlah['rptunai'] = 0;
print("
");
print("
Rekap Transaksi Per Komposisi Penjualan Tunai
");
print("
TOKO ".$_SESSION['namatoko']."
");
print("PERIODE : ".encTgl($startDate) ." s/d ".encTgl($endDate)."
");
print("DICETAK TANGGAL : ".date('d-m-Y [H:i]')."
");
print("
");
print("");
while(mysqli_stmt_fetch($stmt)){
$ttJumlah['jmltunai'] += $A+$B+$C+$D+$E+$F+$G+$H;
$ttJumlah['rptunai'] += $totA+$totB+$totC+$totD+$totE+$totF+$totG+$totH;
print("| ".encTgl($tgl)." | $A | ".number_format($totA,0,',','.')." | $B | ".number_format($totB,0,',','.')." | $C | ".number_format($totC,0,',','.')." | $D | ".number_format($totD,0,',','.')." | $E | ".number_format($totE,0,',','.')." | $F | ".number_format($totF,0,',','.')." | $G | ".number_format($totG,0,',','.')." | $H | ".number_format($totH,0,',','.')." |
");
}
print("
");
print("
");
print("| Total Jumlah Transaksi : | ".number_format($ttJumlah['jmltunai'],0,',','.')." |
");
print("| Total Rupiah Transaksi : | ".number_format($ttJumlah['rptunai'],0,',','.')." |
");
print("
");
}else{
echo "Belum ada data transaksi tunai untuk tanggal tersebut!";
}
}
$jmltunai = $ttJumlah['jmltunai'];
$rptunai = $ttJumlah['rptunai'];
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,$tgl,$A,$totA,$B,$totB,$C,$totC,$D,$totD,$E,$totE,$F,$totF,$G,$totG,$H,$totH);
$ttJumlah = array();
$ttJumlah['jmlbon'] = 0;
$ttJumlah['rpbon'] = 0;
print("");
print("
Rekap Transaksi Per Komposisi Penjualan Bon
");
print("
TOKO ".$_SESSION['namatoko']."
");
print("PERIODE : ".encTgl($startDate) ." s/d ".encTgl($endDate)."
");
print("DICETAK TANGGAL : ".date('d-m-Y [H:i]')."
");
print("
");
print("");
while(mysqli_stmt_fetch($stmt2)){
$ttJumlah['jmlbon'] += $A+$B+$C+$D+$E+$F+$G+$H;
$ttJumlah['rpbon'] += $totA+$totB+$totC+$totD+$totE+$totF+$totG+$totH;
print("| ".encTgl($tgl)." | $A | ".number_format($totA,0,',','.')." | $B | ".number_format($totB,0,',','.')." | $C | ".number_format($totC,0,',','.')." | $D | ".number_format($totD,0,',','.')." | $E | ".number_format($totE,0,',','.')." | $F | ".number_format($totF,0,',','.')." | $G | ".number_format($totG,0,',','.')." | $H | ".number_format($totH,0,',','.')." |
");
}
print("
");
print("
");
print("| Total Jumlah Transaksi Bon: | ".number_format($ttJumlah['jmlbon'],0,',','.')." |
");
print("| Total Rupiah Transaksi Bon: | ".number_format($ttJumlah['rpbon'],0,',','.')." |
");
print("
");
}else{
echo "Belum ada data transaksi bon untuk tanggal tersebut!";
}
}
$jmlbon = $ttJumlah['jmlbon'];
$rpbon = $ttJumlah['rpbon'];
$totaljml = $jmltunai + $jmlbon;
$totalrp = $rptunai + $rpbon;
print("");
print("_______________________________________________");
print("| Total jumlah transaksi : ".number_format($totaljml,0,',','.')." |
");
print("| Total rupiah transaksi : ".number_format($totalrp,0,',','.')." |
");
print("
");
print("
");
$query3 = "SELECT vX.kd_customer,vX.nama,A,totA,B,totB,C,totC,D,totD,E,totE,F,totF
FROM
(SELECT p.kd_customer,p.nama
FROM pelanggan p, m_nota_tunai m
WHERE
m.status_nota = 'S'
and p.kd_customer = m.kd_customer
and date(tgl_nota) between '$startDate' AND '$endDate'
group by p.kd_customer)vX
LEFT OUTER JOIN
(SELECT m.kd_customer,count(*) A,sum(jumlah_total) totA
FROM m_nota_tunai m
WHERE
m.status_nota = 'S'
and m.jumlah_total >= 200000 and m.jumlah_total <= 350000
and date(tgl_nota) between '$startDate' AND '$endDate'
group by kd_customer)vA
ON vX.kd_customer = vA.kd_customer
LEFT OUTER JOIN
(SELECT m.kd_customer,count(*) B,sum(jumlah_total) totB
FROM m_nota_tunai m
WHERE
m.status_nota = 'S'
and m.jumlah_total > 350000 and m.jumlah_total <= 500000
and date(tgl_nota) between '$startDate' AND '$endDate'
group by kd_customer)vB
ON vX.kd_customer = vB.kd_customer
LEFT OUTER JOIN
(SELECT m.kd_customer,count(*) C,sum(jumlah_total) totC
FROM m_nota_tunai m
WHERE
m.status_nota = 'S'
and m.jumlah_total > 500000 and m.jumlah_total <= 650000
and date(tgl_nota) between '$startDate' AND '$endDate'
group by kd_customer)vC
ON vX.kd_customer = vC.kd_customer
LEFT OUTER JOIN
(SELECT m.kd_customer,count(*) D,sum(jumlah_total) totD
FROM m_nota_tunai m
WHERE
m.status_nota = 'S'
and m.jumlah_total > 650000 and m.jumlah_total <= 800000
and date(tgl_nota) between '$startDate' AND '$endDate'
group by kd_customer)vD
ON vX.kd_customer = vD.kd_customer
LEFT OUTER JOIN
(SELECT m.kd_customer,count(*) E,sum(jumlah_total) totE
FROM m_nota_tunai m
WHERE
m.status_nota = 'S'
and m.jumlah_total > 800000 and m.jumlah_total <= 950000
and date(tgl_nota) between '$startDate' AND '$endDate'
group by kd_customer)vE
ON vX.kd_customer = vE.kd_customer
LEFT OUTER JOIN
(SELECT m.kd_customer,count(*) F,sum(jumlah_total) totF
FROM m_nota_tunai m
WHERE
m.status_nota = 'S'
and m.jumlah_total > 950000
and date(tgl_nota) between '$startDate' AND '$endDate'
group by kd_customer)vF
ON vX.kd_customer = vF.kd_customer
WHERE A is not NULL OR B is not NULL OR C is not NULL OR D is not NULL OR E is not NULL OR F is not NULL";
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,$kd_customer,$nama,$A,$totA,$B,$totB,$C,$totC,$D,$totD,$E,$totE,$F,$totF);
$ttJumlah = array();
$ttJumlah['jmlbon'] = 0;
$ttJumlah['rpbon'] = 0;
print("");
print("
Rekap POINT PELANGGAN
");
print("
TOKO ".$_SESSION['namatoko']."
");
print("PERIODE : ".encTgl($startDate) ." s/d ".encTgl($endDate)."
");
print("DICETAK TANGGAL : ".date('d-m-Y [H:i]')."
");
print("
");
print("");
while(mysqli_stmt_fetch($stmt3)){
$ttJumlah['jumlah'] += $A+$B+$C+$D+$E+$F;
$ttJumlah['rupiah'] += $totA+$totB+$totC+$totD+$totE+$totF;
$pointA = $A*2;
$pointB = $B*4;
$pointC = $C*7;
$pointD = $D*10;
$pointE = $E*15;
$pointF = $F*25;
$ttJumlahPoint = $pointA+$pointB+$pointC+$pointD+$pointE+$pointF;
print("| $kd_customer | $nama |
$A | ".number_format($totA,0,',','.')." | $pointA |
$B | ".number_format($totB,0,',','.')." | $pointB |
$C | ".number_format($totC,0,',','.')." | $pointC |
$D | ".number_format($totD,0,',','.')." | $pointD |
$E | ".number_format($totE,0,',','.')." | $pointE |
$F | ".number_format($totF,0,',','.')." | $pointF |
$ttJumlahPoint |
");
}
print("
");
print("
");
print("| Total Jumlah Transaksi: | ".number_format($ttJumlah['jumlah'],0,',','.')." |
");
print("| Total Rupiah Transaksi: | ".number_format($ttJumlah['rupiah'],0,',','.')." |
");
print("
");
}else{
echo "Belum ada data transaksi untuk tanggal tersebut!";
}
}
}
?>