-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsaveInvoiceProcess.php
More file actions
37 lines (25 loc) · 997 Bytes
/
saveInvoiceProcess.php
File metadata and controls
37 lines (25 loc) · 997 Bytes
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
35
36
37
<?php
session_start();
include "connection.php";
if(isset($_SESSION["u"])){
$order_id = $_POST["o"];
$product_id = $_POST["p"];
$email = $_POST["e"];
$amount = $_POST["a"];
$qty = $_POST["q"];
$product_rs = Database::search("SELECT * FROM `product` WHERE `id` = '".$product_id."' ");
$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` = '".$product_id."' ");
$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` , `invoice_qty` , `status` , `product_id` , `users_email`)
VALUES ('".$order_id."' , '".$date."' , '".$amount."' , '".$qty."' , '0' , '".$product_id."' , '".$email."')");
echo("success");
}else{
echo("Please login to your account");
}
?>