D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home3
/
encodto1
/
salvation.incrediblebengal.com
/
admin
/
Filename :
get_tableDetails.php
back
Copy
<?php include "config.php"; include "function.php"; error_reporting(); $ip_add = getUserIP(); $order_date = getOrderDate(); // Insert into Table order list and dine order tables if(isset($_POST['entryId']) && $_POST['entryId'] == 1){ $entry = $_POST['entryId']; $cust_phone = $_POST['custPhone']; $cust_name = $_POST['custName']; $cust_address = $_POST['custAddress']; $totalPrice = $_POST['total_price']; $tableId = $_POST['tableId']; print_r($_POST); // $totalPrice = 0; $order_status = "running"; $waiter_name = $_SESSION['restroUser']; echo $sql = "SELECT * FROM dinein_order WHERE customer_phone = $cust_phone AND order_date = '$order_date' AND table_id = $tableId"; $res = mysqli_query($conn, $sql) or die("query failed to check"); // echo $res; // $cust_arr = array(); if (mysqli_num_rows($res) > 0) { echo '<script>alert("Order Already in Process.")</script>'; } else{ $insrt_order = "INSERT INTO dinein_order (order_id, table_id, customer_phone, total_payment, order_status, order_date, waiter_name, customer_ip) VALUES ('', $tableId, $cust_phone, $totalPrice, '$order_status', '$order_date', '$waiter_name', '$ip_add')"; $run_order= mysqli_query($conn, $insrt_order) or die("Data Entry Failed."); "<script>alert('Data inserted into Dine Order.')</script>"; } $check_cust = "SELECT * FROM customer_details WHERE customer_phone = '$cust_phone' AND customer_name = '$cust_name'"; $run_cust_query = mysqli_query($conn,$check_cust) or die("not checking customer data."); if (mysqli_num_rows($run_cust_query) > 0) { echo '<script>alert("Already previous Customer .")</script>'; // echo '<script>window.location="table-order.php"</script>'; } else{ echo $insert_cust = "INSERT INTO customer_details (customer_id, customer_name, customer_phone, customer_address) VALUES ('', '$cust_name', $cust_phone, '$cust_address')"; echo $run_cust = mysqli_query($conn, $insert_cust) or die("Data Entry Failed."); if (!$run_cust) { echo "Customer Data not inserted."; } } $show_num = mysqli_query($conn, "SELECT * FROM dinein_order WHERE table_id = $tableId AND order_date = '$order_date' AND order_status = 'running' AND customer_phone = $cust_phone"); $row = mysqli_fetch_assoc($show_num); echo $order_id = $row['order_id']; echo $edit_tableItems = "UPDATE table_cart SET customer_phone = $cust_phone, order_id = $order_id WHERE table_id = $tableId AND order_date = '$order_date'"; $run_editItems = mysqli_query($conn, $edit_tableItems) or die("Update Failed."); if (!$run_editItems) { echo "Data not updated."; } $move_orderlist = mysqli_query($conn, "INSERT INTO table_orderlist(order_id, table_id, food_id, food_name, food_qty, food_price, food_subtotal, order_date, customer_phone) SELECT order_id, table_id, food_id, food_name, food_qty, food_price, food_subtotal, order_date, customer_phone FROM table_cart ;") or die($conn); mysqli_query($conn, "UPDATE `restro_tables` SET `table_status`= 1 WHERE `table_id`= $tableId"); header("location: print-pdf/table_kot.php?tableId=$tableId&customer_phone= $cust_phone&dbTable=table_orderlist"); } // Update Table order list and dine order tables if (isset($_GET['editId']) && $_GET['editId'] == 2) { // print_r($_GET); echo "<br><br>"; $tableId = $_GET['tableId']; $customer_phone = $_GET['customer_phone']; $order_id = $_GET['order_id']; echo $view_cart = "SELECT * FROM table_cart WHERE table_id = '$tableId' "; echo "<br>"; $run_cart = mysqli_query($conn, $view_cart); while($rec = mysqli_fetch_assoc($run_cart)){ print_r($rec); $foodId = $rec['food_id']; $foodName = $rec['food_name']; $foodPrice = $rec['food_price']; $foodQty = $rec['food_qty']; $foodSub = $rec['food_subtotal']; echo "<br><br>"; echo $show_total_price = "SELECT total_payment FROM dinein_order WHERE table_id = $tableId AND customer_phone = $customer_phone"; $run_total_price = mysqli_query($conn, $show_total_price) or die($conn); $total = mysqli_fetch_assoc($run_total_price); echo $total['total_payment']; echo $total = $total['total_payment'] + $foodSub; echo $edit_ordr = "UPDATE dinein_order SET total_payment = $total WHERE table_id = '$tableId' AND order_id = '$order_id' AND customer_phone = '$customer_phone'"; $ordr_edit = mysqli_query($conn, $edit_ordr); if (!$ordr_edit) { echo "<br>order update not succeed.."; } echo "<br><br>"; echo $edit_item = "UPDATE table_cart SET customer_phone = '$customer_phone', order_id = '$order_id' WHERE table_id = '$tableId' AND order_date = '$order_date' AND food_id = '$foodId'"; $run_edit = mysqli_query($conn, $edit_item); if (!$run_edit) { echo "<br>items list update not succeed.."; } } echo $move_orderlist = mysqli_query($conn, "INSERT INTO table_orderlist(order_id, table_id, food_id, food_name, food_qty, food_price, food_subtotal, order_date, customer_phone) SELECT order_id, table_id, food_id, food_name, food_qty, food_price, food_subtotal, order_date, customer_phone FROM table_cart ;") or die($conn); header("location: print-pdf/table_kot.php?tableId=$tableId&customer_phone= $customer_phone&dbTable=table_cart"); } ?>