function delete_store_item($id) { try { $sql = "DELETE FROM item WHERE itemID=?"; $stmt = dataBase::getInstance()->prepare($sql); $stmt->execute(array($id)); return "success"; } catch (PDOException $e) { return $e->getMessage(); } }
function push_po_items($voucherID, $qty, $price, $eprice, $itemID) { try { $sql = "INSERT INTO voucher_item (voucherID, qty, price, eprice, itemID) VALUES(?,?,?,?,?)"; $stmt = dataBase::getInstance()->prepare($sql); $stmt->execute(array($voucherID, $qty, $price, $eprice, $itemID)); return "success"; } catch (PDOException $e) { return $e->getMessage(); } }
function push_item($itemName, $itemType, $deptID, $vendorID, $itemDes, $attribute, $size, $itemNo, $receiptNo, $UPC, $orderCost, $alternateLookup, $reorderPointByStore, $companyReorderPoint, $usualSellUnit, $usualOrderUnit, $baseUnit, $itemUnit2, $itemUnit3, $itemUnit4, $onHandQuantity, $storeReorderPoint, $regularPrice, $orderCost) { try { $store_sql = "SELECT * FROM store"; $item_sql = "INSERT INTO item \n\t\t\t\t\t(storeID, itemType, deptID, vendorID, itemName, itemDes, attribute, size, itemNo, receiptNo, UPC, \n\t\t\t\t\t\torderCost, alternateLookup, reorderPointByStore, companyReorderPoint, usualSellUnit, usualOrderUnit, \n\t\t\t\t\t\tbaseUnit, itemUnit2, itemUnit3, itemUnit4) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; $store_item_sql = "INSERT INTO store_item (itemID, storeID, onHandQuantity, storeReorderPoint, regularPrice, \n\t\t\t\t\torderCost) VALUES (?,?,?,?,?,?)"; $store = dataBase::getInstance()->prepare($store_sql); $store->execute(); foreach ($store as $key => $value) { $item = dataBase::getInstance()->prepare($item_sql); $item->execute(array($value["storeID"], $itemType, $deptID, $vendorID, $itemName, $itemDes, $attribute, $size, $itemNo, $receiptNo, $UPC, $orderCost, $alternateLookup, $reorderPointByStore, $companyReorderPoint, $usualSellUnit, $usualOrderUnit, $baseUnit, $itemUnit2, $itemUnit3, $itemUnit4)); $last_id = dataBase::getInstance()->prepare("SELECT * FROM item WHERE itemID =(SELECT max(itemID) FROM item)"); $last_id->execute(); $id_result = ""; foreach ($last_id as $key => $id_data) { $id_result = $id_data["itemID"]; } $store_item = dataBase::getInstance()->prepare($store_item_sql); $store_item->execute(array($id_result, $value["storeID"], $onHandQuantity, $storeReorderPoint, $regularPrice, $orderCost)); } return "success"; } catch (PDOException $e) { return $e->getMessage(); } }