So, I have two tables tb_empgrocery
and tb_empgroc_master
. When I click order now, the items that I've ordered will be saved into the two tables. tb_empgrocery
saves all the items each row and tb_empgroc_master
reads the each row from the first table and counts items and summarize it.
case "Add":
$itemno = $_POST['itemno'];
$qty = $_POST['qty'];
$unitprc = $_POST['unitprc'];
$amt = $_POST['amt'];
$coopmemid = $_SESSION['kiosk']['is_coopmemID_kiosk'];
$totamt = 0;
$totitm = count($itemno);
$a_empgroid = array();
for($x=0; $x<$totitm; $x++) {
$Addquery = "INSERT INTO tb_empgrocery (coopmemID , date_ordered, item_no, qty_ordered, unit_price, amount)
VALUES ('$coopmemid',(NOW()),'$itemno[$x]','$qty[$x]','$unitprc[$x]','$amt[$x]')";
$atecCoop->query($Addquery);
$totamt+=$amt[$x];
$inserted_id = $atecCoop->insert_id;
array_push($a_empgroid,$inserted_id);
}
$Savequery = "INSERT INTO tb_empgroc_master (date_ordered, total_items, total_amount) VALUES ((NOW()), '$totitm', '$totamt')";
$atecCoop->query($Savequery);
$empgrocmstid = $atecCoop->insert_id;
$orderno = date('y-m-').str_pad($empgrocmstid, 10, "0", STR_PAD_LEFT);
$sql = "UPDATE tb_empgroc_master SET order_no='$orderno' WHERE empgrocmstID='$empgrocmstid'";
$atecCoop->query($sql);
foreach($a_empgroid as $empgrocid) {
$sql = "UPDATE tb_empgrocery SET order_no='$orderno' WHERE empgrocID='$empgrocid'";
$atecCoop->query($sql);
}
break;
I want to add the value "Pending" in my 2nd table with the row to the column of order_status
by adding it in here.
$Savequery = "INSERT INTO tb_empgroc_master (//here-order_status, date_ordered, total_items, total_amount) VALUES (//and here, (NOW()), '$totitm', '$totamt')";
Another array will be inserted i think but I don't know how to
Thanks in advance :)