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.
90 lines
3.3 KiB
PHP
90 lines
3.3 KiB
PHP
<?php
|
|
include "../func_lib.php";
|
|
session_start();
|
|
if($_SESSION['validAssko'] !== TRUE && $_SESSION['validAdmin'] !== TRUE && $_SESSION['validPemko'] !== 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>";
|
|
|
|
$idToko = $_POST['idToko'];
|
|
$bulan = $_POST['bulan'];
|
|
$tahun = $_POST['tahun'];
|
|
|
|
if(bukaKoneksi() AND bukaKoneksiPA()){
|
|
global $conn;
|
|
global $connPA;
|
|
|
|
$query = "SELECT * FROM tmp_lapdetailjual";
|
|
|
|
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,$tunai,$omset,$andil);
|
|
|
|
echo "<h2><a href=\"../home.php\">[Home]</a></h2>";
|
|
print("<table border=\"1\" class=\"tbl\">");
|
|
print("<tr class=\"header\"><td>Total Tunai</td><td>Total Omset</td><td>Andil Tunai</td></tr>");
|
|
|
|
while(mysqli_stmt_fetch($stmt)){
|
|
|
|
print("<tr class=\"isi\"><td align=\"right\">".number_format($tunai,0,',','.')."</td><td align=\"right\">".number_format($omset,0,',','.')."</td>
|
|
<td align=\"right\">".number_format($andil,2,'.',',')."</td></tr>");
|
|
|
|
$query_server = "SELECT tahun,bulan,toko FROM andil_tunai
|
|
WHERE tahun = '$tahun'
|
|
AND bulan = '$bulan'
|
|
AND toko = '$idToko'";
|
|
if($stmt2 = mysqli_prepare($connPA,$query_server)){
|
|
mysqli_stmt_execute($stmt2);
|
|
mysqli_stmt_store_result($stmt2);
|
|
$cek2 = mysqli_stmt_num_rows($stmt2);
|
|
if($cek2 > 0){
|
|
//cek di pusat,jika ada data yg sama,maka di update
|
|
while(mysqli_stmt_fetch($stmt2)){
|
|
$queryUpdate = "UPDATE andil_tunai SET total_tunai = $tunai, total_omset = $omset, andil = $andil
|
|
WHERE tahun = '$tahun'
|
|
AND bulan = '$bulan'
|
|
AND toko = '$idToko'";
|
|
runQueryPA($queryUpdate);
|
|
}
|
|
}else{
|
|
// jika tdk ada data yg sama,masukkan data yang baru.
|
|
$queryins = "INSERT INTO andil_tunai(tahun,bulan,toko,total_tunai,total_omset,andil)
|
|
VALUES ('$tahun', '$bulan', '$idToko', $tunai, $omset, $andil)";
|
|
runQueryPA($queryins);
|
|
}
|
|
}
|
|
}
|
|
print("</table><br/>");
|
|
|
|
echo "<table>";
|
|
echo "<tr>";
|
|
echo "<td align=\"center\">";
|
|
echo "Data berhasil dikirim.";
|
|
echo "</td>";
|
|
echo "</tr>";
|
|
echo "</table>";
|
|
}else{
|
|
echo "Data tidak ada!";
|
|
}
|
|
$queryclear1= "DROP TABLE IF EXISTS tmp_lapdetailjual";
|
|
runQuery($queryclear1);
|
|
|
|
}
|
|
}
|
|
?>
|