-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsaveInvoice.php
34 lines (23 loc) · 872 Bytes
/
saveInvoice.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
session_start();
require "connection.php";
if(isset($_SESSION["u"])){
$order_id = $_POST["o"];
$pid = $_POST["i"];
$mail = $_POST["m"];
$amount = $_POST["a"];
$qty = $_POST["q"];
$product_rs = Database::search("SELECT * FROM `product` WHERE `id`='".$pid."'");
$product_data = $product_rs->fetch_assoc();
$current_qty = $product_data["qty"];
$new_qty = $current_qty - $qty;
Database::iud("UPDATE `product` SET `qty`='".$new_qty."' WHERE `id`='".$pid."'");
$d = new DateTime();
$tz = new DateTimeZone("Asia/Colombo");
$d->setTimezone($tz);
$date = $d->format("Y-m-d H:i:s");
Database::iud("INSERT INTO `invoice`(`order_id`,`date`,`total`,`qty`,`status`,`product_id`,`user_email`) VALUES
('".$order_id."','".$date."','".$amount."','".$qty."','0','".$pid."','".$mail."')");
echo ("1");
}
?>