$items[] = array("iditem" => $_POST["hidItem" . $i], "idvendor" => $_POST["cmbVendor" . $i], "quantity" => $_POST["txtRealPurchaseQty" . $i], "price" => $_POST["txtPrice" . $i]); } } } $response = $porder->saveItems($items, $date1, $date2); $msg = ""; if ($response) { $msg = "The items where succesfully saved"; } else { $msg = "Couldn't save the data"; } header("Location: ../view/purchaseOrders.php?msg={$msg}"); break; case "generatePurchaseOrders": $porder = new PurchaseOrder(); $max = $_POST["max"]; $items = array(); for ($i = 0; $i < $max; $i++) { if (isset($_POST["hidItem" . $i])) { $items[] = array("iditem" => $_POST["hidItem" . $i], "idvendor" => $_POST["hidVendor" . $i], "quantity" => $_POST["txtRealPurchaseQty" . $i], "price" => $_POST["txtPrice" . $i], "order" => $_POST["txtOrder" . $i]); } } $msg = $porder->generatePurchaseOrders($items); header("Location: ../view/genPurchaseOrders.php?msg={$msg}"); callGenerateDispatchReport(); break; } function callGenerateDispatchReport() { include_once "../view/dispatchReportMail.php"; }