262 lines
9.6 KiB
PHP
262 lines
9.6 KiB
PHP
<?php
|
|
// echo $_POST['phone'];
|
|
|
|
if (isset ($_POST['phone'])) {
|
|
// echo strlen($_POST['phone']);exit();
|
|
if (strlen($_POST['phone']) > 4)
|
|
$name = $_POST['name'];
|
|
else
|
|
$name = '0';
|
|
$link = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB);
|
|
$link->set_charset("utf8");
|
|
$started = 1;
|
|
$query = "INSERT INTO `" . SHOP_ID . "_bill` ( `status`,`cust_phone`,`cust_name`)VALUES(?,?,?)";
|
|
$stmt = $link->prepare($query);
|
|
if ($stmt) {
|
|
$stmt->bind_param("sss", $started, $_POST['phone'], $name);
|
|
//if(!$stmt->execute()) echo '<div class="alert alert-danger">' . mysqli_error($link) . '</div>';
|
|
if (!$stmt->execute())
|
|
echo '<div class="alert alert-danger">' . mysqli_error($link) . '</div>';
|
|
else {
|
|
$last_id = $link->insert_id;
|
|
echo '<div class="alert alert-success"> ' . $last_id . 'Bill Started</div> <br>
|
|
<meta http-equiv="refresh" content="0; url=create_bill?bill=' . $last_id . '">
|
|
';
|
|
}
|
|
} else
|
|
echo mysqli_error($link);
|
|
$link->close();
|
|
} elseif (isset ($_GET['bill'])) {
|
|
// echo $_GET['bill'];
|
|
//echo ' <br /> <form method="POST"> <input type="hidden" name="bill" value="'.$_GET['bill'].'"> <input type="text" name="code"> </form>';
|
|
|
|
|
|
if (isset ($_POST['code'])) {
|
|
// if(isset($url[1])) { $lnk=$url[2]; $lnk2 = explode('?', $lnk); }
|
|
$code = explode('-', $_POST['code']);
|
|
// echo $code[1];
|
|
$link = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB);
|
|
$query = "SELECT * FROM `" . SHOP_ID . "_product` WHERE `id`='" . $code[0] . "'";
|
|
$result = mysqli_query($link, $query);
|
|
if (mysqli_num_rows($result) < 1) {
|
|
echo ' <br />
|
|
<h2> Err: no Product Found </h2>
|
|
';
|
|
} else {
|
|
$row = $result->fetch_array(MYSQLI_ASSOC);
|
|
// var_dump($row);
|
|
if ($row['stock'] < 1)
|
|
echo ' <br /> <h2> Err: out of stock </h2> ';
|
|
else {
|
|
$link = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB);
|
|
$link->set_charset("utf8");
|
|
$query = "INSERT INTO `" . SHOP_ID . "_bill_product` ( `bill_id`,`product_id`,`price`,`product_name`)VALUES(?,?,?,?)";
|
|
$stmt = $link->prepare($query);
|
|
if ($stmt) {
|
|
$stmt->bind_param("ssss", $_GET['bill'], $code[1], $row['price'], $row['name']);
|
|
//if(!$stmt->execute()) echo '<div class="alert alert-danger">' . mysqli_error($link) . '</div>';
|
|
if (!$stmt->execute())
|
|
echo '<div class="alert alert-danger"> Err' . mysqli_error($link) . '</div>';
|
|
// else {
|
|
// $last_id = $link->insert_id;
|
|
// echo '<div class="alert alert-success"> '.$last_id .'Bill Started</div> <br>
|
|
// ';
|
|
// }
|
|
} else
|
|
echo mysqli_error($link);
|
|
$link->close();
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
?>
|
|
<div id="section-to-print" style="width:350px; display: flex; flex-direction: column; justify-content: center;">
|
|
<!-- <img src="/assets/ave_logo.png" alt="" style="width: 100px;" /> -->
|
|
|
|
<!-- <img src="/assets/mgm_logo.jpg" alt="" style="height: 70px;"> -->
|
|
<div style="display: flex; flex-direction: row; justify-content: center; margin-bottom: -20px;">
|
|
<p style="font-weight:bold; font-size: 25px; text-align: center;">MGM Enterprises</p>
|
|
<img src="/assets/ave_logo.png" alt="" style="width: 80px; height: 50px;" />
|
|
</div>
|
|
<span style="font-weight:bold; font-size: 15px; text-align: center;">GST: 19AJSPB8539J1ZJ</span>
|
|
|
|
<span>16/120/57, Golbazar, Ashoknagar, Habra, 743222</span>
|
|
<span style="text-align: center;"> +91 9907218172 </span>
|
|
<span style="font-weight:bold; font-size:22px; text-align: center;">Fashion Avenue</span>
|
|
<span style="text-align: center; border-bottom: 2px solid #1d1d1d;"> Bill No:
|
|
<?php
|
|
$link = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB);
|
|
$bill_id = $link->real_escape_string($_GET['bill']);
|
|
$query = "SELECT * FROM `" . SHOP_ID . "_bill` WHERE `id` = '$bill_id'";
|
|
$result = $link->query($query);
|
|
|
|
if ($result) {
|
|
if ($row = $result->fetch_assoc()) {
|
|
$billing_date = $row['time'];
|
|
$tz = 'Asia/Kolkata';
|
|
$billing_dt = new DateTime($billing_date, new DateTimeZone('UTC'));
|
|
$print_dt = new DateTime("now", new DateTimeZone($tz));
|
|
echo "<b>", $_GET['bill'], "</b>, ", $billing_dt->format('Y/m/d h:i:sa');
|
|
|
|
} else {
|
|
echo "No results found.";
|
|
}
|
|
} else {
|
|
echo "Error: " . $link->error;
|
|
}
|
|
|
|
$link->close();
|
|
?>
|
|
|
|
</span>
|
|
<hr />
|
|
<table>
|
|
<tr>
|
|
<td>SL</td>
|
|
<td>Product</td>
|
|
<!-- <td>HSN</td> -->
|
|
<td>GST</td>
|
|
<td>Price</td>
|
|
<td>Total</td>
|
|
</tr>
|
|
<?php
|
|
$sl = 0;
|
|
$total = 0;
|
|
$totalTax = 0;
|
|
$totalPrice = 0;
|
|
$totalReturn = 0;
|
|
|
|
|
|
$link = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB);
|
|
$query = "SELECT * FROM `" . SHOP_ID . "_bill_product` WHERE `bill_id`='" . $_GET['bill'] . "' ORDER BY `id` DESC";
|
|
$result = mysqli_query($link, $query);
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
$sl++;
|
|
$total = $total + $row['price'];
|
|
|
|
|
|
if ($row['price'] <= 1000) {
|
|
$GSTPercentage = 105;
|
|
}
|
|
if ($row['price'] >= 1000) {
|
|
$GSTPercentage = 112;
|
|
} else {
|
|
//Future Billing Amount Conditions
|
|
}
|
|
|
|
$GSTAmount = round($row['price'] / $GSTPercentage * 100);
|
|
$totalTax = $totalTax + $row['price'] - $GSTAmount;
|
|
$totalPrice = $totalPrice + $GSTAmount;
|
|
// echo $GSTAmount;
|
|
|
|
// $withGST = round($row['price'] + $GSTAmount);
|
|
?>
|
|
<tr>
|
|
<td>
|
|
<?php echo $sl; ?>
|
|
</td>
|
|
<td><span style="font-size:small;">
|
|
<?php echo $row['product_name'];echo ' <br/> HSN: ', $row['hsn'];
|
|
if($row['returned']=='1'){
|
|
echo '<br/> (Exchanged) ';
|
|
$totalReturn=$totalReturn+$row['price'];
|
|
}
|
|
// if ($row['mrp'] > $row['price']) { $discount = $row['mrp'] - $row['price']; }
|
|
?>
|
|
</span></td>
|
|
<td>
|
|
<?php echo $row['price'] - $GSTAmount; ?>
|
|
</td>
|
|
<td>
|
|
<?php echo $GSTAmount; ?>
|
|
</td>
|
|
<td>
|
|
<?php echo $row['price']; ?>
|
|
</td>
|
|
</tr>
|
|
<?php } ?>
|
|
</table>
|
|
<br />
|
|
|
|
<?php
|
|
$gst = 18 * $total / 100;
|
|
$indTax = $totalTax / 2;
|
|
//echo 'GST: ',$gst,'<br />' ;
|
|
|
|
// echo '<a href="print_bill.php?'.$_GET['bill'].'"> Print </a>';
|
|
?>
|
|
<div
|
|
style="display: flex; flex-direction: row; justify-content: space-between; border-top: 2px solid #1d1d1d; border-bottom: 2px solid #1d1d1d;">
|
|
<p>Total Tax:</p>
|
|
<p style="padding-left: 100px;">
|
|
<?php echo $totalTax; ?><br>
|
|
<span style="font-size: 12px; padding-right: 0px;">SGST:
|
|
<?php echo $indTax; ?>,
|
|
</span>
|
|
<span style="font-size: 12px; padding-right: 0px;">CGST:
|
|
<?php echo $indTax; ?>
|
|
</span>
|
|
</p>
|
|
<p></p>
|
|
</div>
|
|
<div
|
|
|
|
style="display: flex; flex-direction: row; justify-content: space-between; border-top: 2px solid #1d1d1d; border-bottom: 2px solid #1d1d1d;">
|
|
<table>
|
|
<tr>
|
|
<td>G. Total:</td>
|
|
<td style="width: 130px;"></td>
|
|
<td><?php echo $total; ?></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<hr />
|
|
|
|
<?php
|
|
if($totalReturn>0) echo
|
|
'<div style="display: flex; flex-direction: row; justify-content: space-between; border-top: 2px solid #1d1d1d; border-bottom: 2px solid #1d1d1d;">
|
|
<table>
|
|
<tr>
|
|
<td>Total Return:</td>
|
|
<td style="width: 130px;"></td>
|
|
<td>'.$totalReturn.'</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<hr />' ; ?>
|
|
|
|
<p style="font-weight: bold; margin-bottom: -2px; margin-top: -2px;">Conditions:</p>
|
|
<span style="text-align: justify; font-size: 15px;">• Items sold cannot be returned but exchanged within 5
|
|
days from purchase (Time 12:00 to 15:00)</span>
|
|
<span style="text-align: justify; font-size: 15px;">• To exchange, original bill and price tag must be
|
|
intact.</span>
|
|
<span style="text-align: justify; font-size: 15px;">• Accessories and undergarments cannot be
|
|
exchanged.</span><br>
|
|
<span> Thank You for shopping with us <br /> Authorised Signatory </span>
|
|
<p>Bill Print Date: <?php date_default_timezone_set('Asia/Kolkata'); $currentDateTime = new DateTime(); echo $currentDateTime->format('Y-m-d H:i:s');?><p>
|
|
|
|
<hr />
|
|
</div>
|
|
<button onclick="window.print()">Print </button>
|
|
|
|
<style>
|
|
@media print {
|
|
body * {
|
|
visibility: hidden;
|
|
}
|
|
|
|
#section-to-print,
|
|
#section-to-print * {
|
|
visibility: visible;
|
|
}
|
|
|
|
#section-to-print {
|
|
position: absolute;
|
|
left: 0;
|
|
top: 0;
|
|
}
|
|
}
|
|
</style>
|