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.
209 lines
9.6 KiB
PHP
209 lines
9.6 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:900px; border:1px solid #000; padding:20px 0; margin-bottom:25px;}";
|
|
echo "table.tbl {width:850px;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 ".warnaBarisStrip{font-weight : bold; background-color : #FFFF33;}";
|
|
echo ".warnaBarisKategori{font-weight : bold; background-color: #FFCC00;}";
|
|
echo ".master{text-align:left;}";
|
|
echo "</style>";
|
|
|
|
$startDate = decTgl($_POST['startDate']);
|
|
$endDate = decTgl($_POST['endDate']);
|
|
|
|
|
|
if(bukaKoneksi()){
|
|
global $conn;
|
|
$query = "select s.kel_jns,s.nama_strip,dlm,ked_produk,sum(juml) vol,sum(tot) totHJ,sum(hp) totHP
|
|
from (
|
|
select b.kode_strip lini,b.ked_produk dlm,k.ked_produk,sum(jumlah) juml,
|
|
sum((d.harga_jual * d.jumlah) - (d.harga_jual * d.jumlah * d.diskon / 100)) tot,
|
|
sum(d.jumlah*REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(d.harga_pokok,'B','1'),'R','2'),'A','3'),'W','4'),'N','5'),'F','6'),'O','7'),'X','8'),'E','9'),'S','0')) hp
|
|
from d_nota_tunai d,m_nota_tunai m, kedalaman_produk k, barang b
|
|
where d.no_nota = m.no_nota
|
|
and d.kd_barang = b.kode_barang
|
|
and (b.kode_strip = k.kode_strip and b.ked_produk = k.kode_ked_produk)
|
|
and d.harga_pokok IS NOT NULL
|
|
and m.status_nota = 'S'
|
|
and date(tgl_nota) between '$startDate' and '$endDate'
|
|
group by b.kode_strip,b.ked_produk
|
|
UNION ALL
|
|
select b.kode_strip lini,b.ked_produk dlm,k.ked_produk,(-1*sum(jumlah)) juml,
|
|
(-1*sum((d.harga_jual * d.jumlah) - (d.harga_jual * d.jumlah * d.diskon / 100))) tot,
|
|
(-1*sum(d.jumlah*REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(d.harga_pokok,'B','1'),'R','2'),'A','3'),'W','4'),'N','5'),'F','6'),'O','7'),'X','8'),'E','9'),'S','0'))) hp
|
|
from d_nota_retur d,m_nota_retur m, kedalaman_produk k, barang b
|
|
where d.no_nota = m.no_nota
|
|
and d.kd_barang = b.kode_barang
|
|
and (b.kode_strip = k.kode_strip and b.ked_produk = k.kode_ked_produk)
|
|
and d.harga_pokok IS NOT NULL
|
|
and date(tgl_nota) between '$startDate' and '$endDate'
|
|
group by b.kode_strip,b.ked_produk
|
|
UNION ALL
|
|
select b.kode_strip lini,b.ked_produk dlm,k.ked_produk,sum(jumlah) juml,
|
|
sum((d.hrg_satuan * d.jumlah) - (d.hrg_satuan * d.jumlah * d.diskon / 100)) tot,
|
|
sum(d.jumlah*REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(d.harga_pokok,'B','1'),'R','2'),'A','3'),'W','4'),'N','5'),'F','6'),'O','7'),'X','8'),'E','9'),'S','0')) hp
|
|
from d_bon d,m_bon m, kedalaman_produk k, barang b
|
|
where d.no_bon = m.no_bon
|
|
and d.kd_brg = b.kode_barang
|
|
and (b.kode_strip = k.kode_strip and b.ked_produk = k.kode_ked_produk)
|
|
and d.harga_pokok IS NOT NULL
|
|
and date(tgl_bon) between '$startDate' and '$endDate'
|
|
group by b.kode_strip,b.ked_produk
|
|
) vdlmpdk,strip s
|
|
where s.kd_strip = lini
|
|
group by s.kd_strip,dlm";
|
|
|
|
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,$kelJns,$strip,$kdSuppl,$nmSuppl,$jmlBeli,$rpBeli,$hrgPokok);
|
|
$ttJmlBeli = array();
|
|
$ttJmlBeli['pria']['jml'] = 0;
|
|
$ttJmlBeli['pria']['rp'] = 0;
|
|
$ttJmlBeli['pria']['hp'] = 0;
|
|
$ttJmlBeli['wanita']['jml'] = 0;
|
|
$ttJmlBeli['wanita']['rp'] = 0;
|
|
$ttJmlBeli['wanita']['hp'] = 0;
|
|
$ttJmlBeli['anak']['jml'] = 0;
|
|
$ttJmlBeli['anak']['rp'] = 0;
|
|
$ttJmlBeli['anak']['hp'] = 0;
|
|
$ttJmlBeli['sepatu']['jml'] = 0;
|
|
$ttJmlBeli['sepatu']['rp'] = 0;
|
|
$ttJmlBeli['sepatu']['hp'] = 0;
|
|
|
|
print("<center><div id=\"divprint\" >");
|
|
print("<h2>Laporan Penjualan Per Sub Group Product</h2><br/><br/>");
|
|
print("<div class=\"luar\">TOKO ".$_SESSION['namatoko']."<br/>");
|
|
print("PADA TANGGAL : ".encTgl($startDate) ." s/d ".encTgl($endDate)."<br/>");
|
|
print("DICETAK TANGGAL : ".date('d-m-Y [H:i]')."</div><br/><br/>");
|
|
$pria = 0;
|
|
$wanita = 0;
|
|
$anak = 0;
|
|
$sepatu = 0;
|
|
$str = array();
|
|
$jmlB = array();
|
|
$rpB = array();
|
|
$HP = array();
|
|
$kdSupplier = array();
|
|
$nmSupplier = array();
|
|
|
|
while(mysqli_stmt_fetch($stmt)){
|
|
if($jmlRetur == ''){
|
|
$jmlRetur = 0;
|
|
}
|
|
if($rpRetur == ''){
|
|
$rpRetur = 0;
|
|
}
|
|
if($kelJns == "P"){
|
|
$kelJns = "Pria";
|
|
$ttJmlBeli['pria']['jml'] += $jmlBeli;
|
|
$ttJmlBeli['pria']['rp'] += $rpBeli;
|
|
$ttJmlBeli['pria']['hp'] += $hrgPokok;
|
|
$str[$pria]['pria'] = $strip;
|
|
$jmlB[$pria]['pria'] = $jmlBeli;
|
|
$rpB[$pria]['pria'] = $rpBeli;
|
|
$HP[$pria]['pria'] = $hrgPokok;
|
|
$kdSupplier[$pria]['pria'] = $kdSuppl;
|
|
$nmSupplier[$pria]['pria'] = $nmSuppl;
|
|
$pria++;
|
|
}elseif($kelJns == "W"){
|
|
$kelJns = "Wanita";
|
|
$ttJmlBeli['wanita']['jml'] += $jmlBeli;
|
|
$ttJmlBeli['wanita']['rp'] += $rpBeli;
|
|
$ttJmlBeli['wanita']['hp'] += $hrgPokok;
|
|
$str[$wanita]['wanita'] = $strip;
|
|
$jmlB[$wanita]['wanita'] = $jmlBeli;
|
|
$rpB[$wanita]['wanita'] = $rpBeli;
|
|
$HP[$wanita]['wanita'] = $hrgPokok;
|
|
$kdSupplier[$wanita]['wanita'] = $kdSuppl;
|
|
$nmSupplier[$wanita]['wanita'] = $nmSuppl;
|
|
$wanita++;
|
|
}elseif($kelJns == "A"){
|
|
$kelJns = "Anak";
|
|
$ttJmlBeli['anak']['jml'] += $jmlBeli;
|
|
$ttJmlBeli['anak']['rp'] += $rpBeli;
|
|
$ttJmlBeli['anak']['hp'] += $hrgPokok;
|
|
$str[$anak]['anak'] = $strip;
|
|
$jmlB[$anak]['anak'] = $jmlBeli;
|
|
$rpB[$anak]['anak'] = $rpBeli;
|
|
$HP[$anak]['anak'] = $hrgPokok;
|
|
$kdSupplier[$anak]['anak'] = $kdSuppl;
|
|
$nmSupplier[$anak]['anak'] = $nmSuppl;
|
|
$anak++;
|
|
}else{
|
|
$kelJns = "Sepatu";
|
|
$ttJmlBeli['sepatu']['jml'] += $jmlBeli;
|
|
$ttJmlBeli['sepatu']['rp'] += $rpBeli;
|
|
$ttJmlBeli['sepatu']['hp'] += $hrgPokok;
|
|
$str[$sepatu]['sepatu'] = $strip;
|
|
$jmlB[$sepatu]['sepatu'] = $jmlBeli;
|
|
$rpB[$sepatu]['sepatu'] = $rpBeli;
|
|
$HP[$sepatu]['sepatu'] = $hrgPokok;
|
|
$kdSupplier[$sepatu]['sepatu'] = $kdSuppl;
|
|
$nmSupplier[$sepatu]['sepatu'] = $nmSuppl;
|
|
$sepatu++;
|
|
}
|
|
|
|
}
|
|
print("<table border=\"1\" class=\"tbl\">");
|
|
print("<tr class=\"header\"><td>Lini Produk</td><td>Kode Sub Group</td><td>Sub Group Product</td><td>Jumlah Jual</td><td>Total Jual</td><td>Total HP Jual</td></tr>");
|
|
print("<div class=\"luar\">");
|
|
|
|
|
|
/* SEPATU -------------------------------------------------------------------------*/
|
|
$jmlkatsepatu = $ttJmlBeli['sepatu']['jml'];
|
|
$rpkatsepatu = $ttJmlBeli['sepatu']['rp'];
|
|
$hpkatsepatu = $ttJmlBeli['sepatu']['hp'];
|
|
|
|
if($ttJmlBeli['sepatu']['jml']!=0){
|
|
print("<tr class=\"master\"><td colspan=\"6\"></td></tr>");
|
|
for($i=0;$i<$sepatu;$i++){
|
|
if ($str[$i-1]['sepatu']==$str[$i]['sepatu']){
|
|
print("<tr class=\"isi\"><td>".$str[$i]['sepatu']."</td><td>.".$kdSupplier[$i]['sepatu']."</td><td>".$nmSupplier[$i]['sepatu']."</td><td align=\"right\">".number_format($jmlB[$i]['sepatu'], 0, ",", ".")."</td><td align=\"right\">".number_format($rpB[$i]['sepatu'], 0, ",", ".")."</td><td align=\"right\">".number_format($HP[$i]['sepatu'], 0, ",", ".")."</td></tr>");
|
|
}else{
|
|
print("<tr class=\"warnaBarisStrip\"><td colspan=\"3\"></td><td align=\"right\">".number_format($tempjumlahrugi4, 0, ",", ".")."</td><td align=\"right\">".number_format($temprprugi4, 0, ",", ".")."</td><td align=\"right\">".number_format($temphprugi4, 0, ",", ".")."</td></tr>");
|
|
print("<tr class=\"isi\"><td>".$str[$i]['sepatu']."</td><td>.".$kdSupplier[$i]['sepatu']."</td><td>".$nmSupplier[$i]['sepatu']."</td><td align=\"right\">".number_format($jmlB[$i]['sepatu'], 0, ",", ".")."</td><td align=\"right\">".number_format($rpB[$i]['sepatu'], 0, ",", ".")."</td><td align=\"right\">".number_format($HP[$i]['sepatu'], 0, ",", ".")."</td></tr>");
|
|
$tempjumlahrugi4 = 0;
|
|
$temphprugi4 = 0;
|
|
$temprprugi4 = 0;
|
|
}
|
|
$tempjumlahrugi4 += $jmlB[$i]['sepatu'];
|
|
$temphprugi4 += $HP[$i]['sepatu'];
|
|
$temprprugi4 += $rpB[$i]['sepatu'];
|
|
}
|
|
print("<tr class=\"warnaBarisStrip\"><td colspan=\"3\"></td><td align=\"right\">".number_format($tempjumlahrugi4, 0, ",", ".")."</td><td align=\"right\">".number_format($temprprugi4, 0, ",", ".")."</td><td align=\"right\">".number_format($temphprugi4, 0, ",", ".")."</td></tr>");
|
|
}
|
|
|
|
$ttjml = $jmlkatpria + $jmlkatwanita + $jmlkatanak + $jmlkatsepatu;
|
|
$ttrp = $rpkatpria + $rpkatwanita + $rpkatanak + $rpkatsepatu;
|
|
$tthp = $hpkatpria + $hpkatwanita + $hpkatanak + $hpkatsepatu;
|
|
|
|
print("<tr class=\"warnaBarisKategori\"><td colspan=\"3\" align=\"center\">T O T A L : </td>
|
|
<td align=\"right\">".number_format($ttjml, 0, ",", ".")."</td>
|
|
<td align=\"right\">".number_format($ttrp, 0, ",", ".")."</td>
|
|
<td align=\"right\">".number_format($tthp, 0, ",", ".")."</td></tr>");
|
|
|
|
print("</table><br/>");
|
|
}else{
|
|
echo "Belum ada data pembelian untuk tanggal tersebut!";
|
|
}
|
|
}
|
|
}
|
|
?>
|