Example #1
0
function ModifyPurchData($PurchDataDetails, $user, $password)
{
    $Errors = array();
    $db = db($user, $password);
    if (gettype($db) == 'integer') {
        $Errors[0] = NoAuthorisation;
        return $Errors;
    }
    foreach ($PurchDataDetails as $key => $value) {
        $PurchDataDetails[$key] = DB_escape_string($value);
    }
    $Errors = VerifyPurchDataLineExists($PurchDataDetails['supplierno'], $PurchDataDetails['stockid'], sizeof($Errors), $Errors, $db);
    $Errors = VerifyStockCodeExists($PurchDataDetails['stockid'], sizeof($Errors), $Errors, $db);
    $Errors = VerifySupplierNoExists($PurchDataDetails['supplierno'], sizeof($Errors), $Errors, $db);
    if (isset($StockItemDetails['price'])) {
        $Errors = VerifyUnitPrice($PurchDataDetails['price'], sizeof($Errors), $Errors);
    }
    if (isset($StockItemDetails['suppliersuom'])) {
        $Errors = VerifySuppliersUOM($PurchDataDetails['suppliersuom'], sizeof($Errors), $Errors);
    }
    if (isset($StockItemDetails['conversionfactor'])) {
        $Errors = VerifyConversionFactor($PurchDataDetails['conversionfactor'], sizeof($Errors), $Errors);
    }
    if (isset($StockItemDetails['supplierdescription'])) {
        $Errors = VerifySupplierDescription($PurchDataDetails['supplierdescription'], sizeof($Errors), $Errors);
    }
    if (isset($StockItemDetails['leadtime'])) {
        $Errors = VerifyLeadTime($PurchDataDetails['leadtime'], sizeof($Errors), $Errors);
    }
    if (isset($StockItemDetails['preferred'])) {
        $Errors = VerifyPreferredFlag($PurchDataDetails['preferred'], sizeof($Errors), $Errors);
    }
    $sql = "UPDATE purchdata SET ";
    foreach ($PurchDataDetails as $key => $value) {
        $sql .= $key . "='" . $value . "', ";
    }
    $sql = mb_substr($sql, 0, -2) . " WHERE stockid='" . $PurchDataDetails['stockid'] . "'\n\t\t\t\t\t\t\t\tAND supplierno='" . $PurchDataDetails['supplierno'] . "'";
    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;
}
Example #2
0
function GetSupplier($SupplierID, $user, $password)
{
    $Errors = array();
    $db = db($user, $password);
    if (gettype($db) == 'integer') {
        $Errors[0] = NoAuthorisation;
        return $Errors;
    }
    $Errors = VerifySupplierNoExists($SupplierID, sizeof($Errors), $Errors, $db);
    if (sizeof($Errors) != 0) {
        return $Errors;
    }
    $sql = "SELECT * FROM suppliers WHERE supplierid='" . $SupplierID . "'";
    $result = DB_Query($sql, $db);
    if (sizeof($Errors) == 0) {
        return DB_fetch_array($result);
    } else {
        return $Errors;
    }
}