function ModifyStockItem($StockItemDetails, $user, $password) { $Errors = array(); $db = db($user, $password); if (gettype($db) == 'integer') { $Errors[0] = NoAuthorisation; return $Errors; } foreach ($StockItemDetails as $key => $value) { $StockItemDetails[$key] = DB_escape_string($value); } $Errors = VerifyStockCodeExists($StockItemDetails['stockid'], sizeof($Errors), $Errors, $db); if (in_array(StockCodeDoesntExist, $Errors)) { return $Errors; } if (isset($StockItemDetails['description'])) { $Errors = VerifyStockDescription($StockItemDetails['decription'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['longdescription'])) { $Errors = VerifyStockLongDescription($StockItemDetails['longdescription'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['categoryid'])) { $Errors = VerifyStockCategoryExists($StockItemDetails['categoryid'], sizeof($Errors), $Errors, $db); } if (isset($StockItemDetails['units'])) { $Errors = VerifyUnits($StockItemDetails['units'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['mbflag'])) { $Errors = VerifyMBFlag($StockItemDetails['mbflag'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['lastcurcostdate'])) { $Errors = VerifyLastCurCostDate($StockItemDetails['lascurcostdate'], sizeof($Errors), $Errors, $db); } if (isset($StockItemDetails['actualcost'])) { $Errors = VerifyActualCost($StockItemDetails['actualcost'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['lastcost'])) { $Errors = VerifyLastCost($StockItemDetails['lastcost'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['materialcost'])) { $Errors = VerifyMaterialCost($StockItemDetails['materialcost'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['labourcost'])) { $Errors = VerifyLabourCost($StockItemDetails['labourcost'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['overheadcost'])) { $Errors = VerifyOverheadCost($StockItemDetails['overheadcost'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['lowestlevel'])) { $Errors = VerifyLowestLevel($StockItemDetails['lowestlevel'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['discontinued'])) { $Errors = VerifyDiscontinued($StockItemDetails['discontinued'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['controlled'])) { $Errors = VerifyControlled($StockItemDetails['controlled'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['eoq'])) { $Errors = VerifyEOQ($StockItemDetails['eoq'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['volume'])) { $Errors = VerifyVolume($StockItemDetails['volume'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['grossweight'])) { $Errors = VerifyKgs($StockItemDetails['grossweight'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['barcode'])) { $Errors = VerifyBarCode($StockItemDetails['barcode'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['discountcategory'])) { $Errors = VerifyDiscountCategory($StockItemDetails['discountcategory'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['taxcatid'])) { $Errors = VerifyTaxCatExists($StockItemDetails['taxcatid'], sizeof($Errors), $Errors, $db); } if (isset($StockItemDetails['serialised'])) { $Errors = VerifySerialised($StockItemDetails['serialised'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['appendfile'])) { $Errors = VerifyApendFile($StockItemDetails['apendfile'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['perishable'])) { $Errors = VerifyPerishable($StockItemDetails['perishable'], sizeof($Errors), $Errors); } if (isset($StockItemDetails['decimalplaces'])) { $Errors = VerifyDecimalPlaces($StockItemDetails['decimalplaces'], sizeof($Errors), $Errors); } $sql = 'UPDATE stockmaster SET '; foreach ($StockItemDetails as $key => $value) { $sql .= $key . '="' . $value . '", '; } $sql = mb_substr($sql, 0, -2) . " WHERE stockid='" . $StockItemDetails['stockid'] . "'"; if (sizeof($Errors) == 0) { $result = DB_Query($sql, $db); echo DB_error_no($db); if (DB_error_no($db) != 0) { $Errors[0] = DatabaseUpdateFailed; } else { $Errors[0] = 0; } } return $Errors; }
function GetStockCategory($Categoryid, $user, $password) { $Errors = array(); $db = db($user, $password); if (gettype($db) == 'integer') { $Errors[0] = NoAuthorisation; return $Errors; } $Errors = VerifyStockCategoryExists($Categoryid, sizeof($Errors), $Errors, $db); if (sizeof($Errors) != 0) { return $Errors; } $sql = "SELECT * FROM stockcategory WHERE categoryid='" . $Categoryid . "'"; $result = DB_Query($sql, $db); if (sizeof($Errors) == 0) { return DB_fetch_array($result); } else { return $Errors; } }