You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
6.3 KiB
PHP
139 lines
6.3 KiB
PHP
<?php
|
|
include "../func_lib.php";
|
|
|
|
session_start();
|
|
if($_SESSION['validUser'] !== TRUE)
|
|
{
|
|
header("location: ./index.php");
|
|
exit();
|
|
}
|
|
|
|
echo "<style type='text/css'>";
|
|
echo "div#divprint{width:850px; 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:150px;}";
|
|
echo ".header{font-weight:bold;text-align:center;}";
|
|
echo ".isi{text-align:left;}";
|
|
echo "</style>";
|
|
|
|
$startDate = decTgl($_POST['startDate']);
|
|
$endDate = decTgl($_POST['endDate']);
|
|
$th1 = substr($startDate,0,4) - 1;
|
|
$bulan1 = substr($startDate,5,2);
|
|
$tgl1 = substr($startDate,8,2);
|
|
$th2 = substr($endDate,0,4) - 1;
|
|
$bulan2 = substr($endDate,5,2);
|
|
$tgl2 = substr($endDate,8,2);
|
|
|
|
$startlalu = $th1."-".$bulan1."-".$tgl1;
|
|
$endlalu = $th2."-".$bulan2."-".$tgl2;
|
|
|
|
|
|
if(bukaKoneksi()){
|
|
global $conn;
|
|
$query = "select tempskrg.tanggal,tempskrg.Skrg bulanIni,templalu.Lalu bulanLalu
|
|
from
|
|
|
|
(select tanggal,sum(vskrg.total) Skrg
|
|
from (select date(m.tgl_nota) tanggal,sum(m.jumlah_total) TOTAL
|
|
FROM m_nota_tunai m
|
|
where m.status_bayar = 'T'
|
|
and m.status_nota = 'S'
|
|
and m.no_nota_retur = ''
|
|
and date(m.tgl_nota) BETWEEN '$startDate' and '$endDate'
|
|
group by date(m.tgl_nota)
|
|
UNION ALL
|
|
select date(m.tgl_nota) tanggal,sum(jumlah_total-jumlah_total_retur) TOTAL
|
|
from m_nota_tunai m
|
|
where m.status_bayar = 'T'
|
|
and m.no_nota_retur != ''
|
|
and m.status_nota = 'S'
|
|
and date(m.tgl_nota) BETWEEN '$startDate' and '$endDate'
|
|
group by date(m.tgl_nota)
|
|
UNION ALL
|
|
select date(m.tgl_nota) tanggal,sum(-1*m.jumlah_total) TOTAL
|
|
from m_nota_retur m
|
|
where m.status_nota = 'D'
|
|
and date(m.tgl_nota) BETWEEN '$startDate' and '$endDate'
|
|
group by date(m.tgl_nota)
|
|
UNION ALL
|
|
select date(t.tgl_byr) tanggal,sum(t.bayar_bon) total
|
|
from bayar_bon t
|
|
where date(t.tgl_byr) between '$startDate' and '$endDate'
|
|
group by date(t.tgl_byr)
|
|
)vskrg group by tanggal)tempskrg
|
|
LEFT JOIN
|
|
(select tanggal,sum(vskrg.total) Lalu
|
|
from (select date(m.tgl_nota) tanggal,sum(m.jumlah_total) TOTAL
|
|
FROM m_nota_tunai m
|
|
where m.status_bayar = 'T'
|
|
and m.status_nota = 'S'
|
|
and m.no_nota_retur = ''
|
|
and date(m.tgl_nota) BETWEEN '$startlalu' and '$endlalu'
|
|
group by date(m.tgl_nota)
|
|
UNION ALL
|
|
select date(m.tgl_nota) tanggal,sum(jumlah_total-jumlah_total_retur) TOTAL
|
|
from m_nota_tunai m
|
|
where m.status_bayar = 'T'
|
|
and m.no_nota_retur != ''
|
|
and m.status_nota = 'S'
|
|
and date(m.tgl_nota) BETWEEN '$startlalu' and '$endlalu'
|
|
group by date(m.tgl_nota)
|
|
UNION ALL
|
|
select date(m.tgl_nota) tanggal,sum(-1*m.jumlah_total) TOTAL
|
|
from m_nota_retur m
|
|
where m.status_nota = 'D'
|
|
and date(m.tgl_nota) BETWEEN '$startlalu' and '$endlalu'
|
|
group by date(m.tgl_nota)
|
|
UNION ALL
|
|
select date(t.tgl_byr) tanggal,sum(t.bayar_bon) total
|
|
from bayar_bon t
|
|
where date(t.tgl_byr) between '$startlalu' and '$endlalu'
|
|
group by date(t.tgl_byr)
|
|
)vskrg group by tanggal)templalu
|
|
on day(tempskrg.tanggal)=day(templalu.tanggal)";
|
|
|
|
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,$sekarang,$lalu);
|
|
$ttJumlah = array();
|
|
$ttJumlah['jml1'] = 0;
|
|
$ttJumlah['jml2'] = 0;
|
|
|
|
print("<center><div id=\"divprint\" >");
|
|
print("<h2>Rekap Transaksi Penjualan Perbandingan Tahun Lalu</h2><br/><br/>");
|
|
print("<div class=\"luar\">TOKO ".$_SESSION['namatoko']."<br/>");
|
|
print("PERIODE : ".encTgl($startDate) ." s/d ".encTgl($endDate)."<br/>");
|
|
print("DICETAK TANGGAL : ".date('d-m-Y [H:i]')."</div><br/><br/>");
|
|
print("<table border=\"1\" class=\"tbl\">");
|
|
print("<tr class=\"header\"><td>Tanggal</td><td align=\"center\">Lalu</td><td align=\"center\">Sekarang</td><td align=\"center\">Peningkatan (%)</td></tr>");
|
|
|
|
while(mysqli_stmt_fetch($stmt)){
|
|
$ttJumlah['jml1'] += $sekarang;
|
|
$ttJumlah['jml2'] += $lalu;
|
|
if ($lalu == 0) {
|
|
$peningkatan = 100;
|
|
}else{
|
|
$peningkatan = ($sekarang - $lalu)/$lalu*100;
|
|
}
|
|
print("<tr class=\"isi\"><td align=\"center\">".encTgl($tgl)."</td><td align=\"right\">".number_format($lalu,0,',','.')."</td><td align=\"right\">".number_format($sekarang,0,',','.')."</td><td align=\"right\" width='20%'>".number_format($peningkatan,2)."</td></tr>");
|
|
}
|
|
|
|
print("</table><br/>");
|
|
print("<div class=\"luar\"><table border=\"0\">");
|
|
print("<tr><td>Total Penjualan Periode Tahun Lalu</td><td> : ".number_format($ttJumlah['jml2'],0,',','.')."</td></tr>");
|
|
print("<tr><td>Total Penjualan Periode Tahun Sekarang</td><td> : ".number_format($ttJumlah['jml1'],0,',','.')."</td></tr>");
|
|
print("</table></div></div></center>");
|
|
}else{
|
|
echo "Belum ada data transaksi untuk tanggal tersebut!";
|
|
}
|
|
}
|
|
}
|
|
?>
|