Exemplo n.º 1
0
function ModifyBranch($BranchDetails, $user, $password)
{
    $Errors = array();
    $db = db($user, $password);
    if (gettype($db) == 'integer') {
        $Errors[0] = NoAuthorisation;
        return $Errors;
    }
    foreach ($BranchDetails as $key => $value) {
        $BranchDetails[$key] = DB_escape_string($value);
    }
    $Errors = VerifyBranchNoExists($BranchDetails['debtorno'], $BranchDetails['branchcode'], sizeof($Errors), $Errors, $db);
    $Errors = VerifyBranchName($BranchDetails['brname'], sizeof($Errors), $Errors, $db);
    if (isset($BranchDetails['address1'])) {
        $Errors = VerifyBranchAddressLine($BranchDetails['address1'], 40, sizeof($Errors), $Errors, $db);
    }
    if (isset($BranchDetails['address2'])) {
        $Errors = VerifyBranchAddressLine($BranchDetails['address2'], 40, sizeof($Errors), $Errors, $db);
    }
    if (isset($BranchDetails['address3'])) {
        $Errors = VerifyBranchAddressLine($BranchDetails['address3'], 40, sizeof($Errors), $Errors, $db);
    }
    if (isset($BranchDetails['address4'])) {
        $Errors = VerifyBranchAddressLine($BranchDetails['address4'], 50, sizeof($Errors), $Errors, $db);
    }
    if (isset($BranchDetails['address5'])) {
        $Errors = VerifyBranchAddressLine($BranchDetails['address5'], 20, sizeof($Errors), $Errors, $db);
    }
    if (isset($BranchDetails['address6'])) {
        $Errors = VerifyBranchAddressLine($BranchDetails['address6'], 15, sizeof($Errors), $Errors, $db);
    }
    if (isset($BranchDetails['lat'])) {
        $Errors = VerifyLatitude($BranchDetails['lat'], sizeof($Errors), $Errors);
    }
    if (isset($BranchDetails['lng'])) {
        $Errors = VerifyLongitude($BranchDetails['lng'], sizeof($Errors), $Errors);
    }
    if (isset($BranchDetails['estdeliverydays'])) {
        $Errors = VerifyEstDeliveryDays($BranchDetails['estdeliverydays'], sizeof($Errors), $Errors);
    }
    if (isset($BranchDetails['area'])) {
        $Errors = VerifyAreaCode($BranchDetails['area'], sizeof($Errors), $Errors, $db);
    }
    if (isset($BranchDetails['salesman'])) {
        $Errors = VerifySalesmanCode($BranchDetails['salesman'], sizeof($Errors), $Errors, $db);
    }
    if (isset($BranchDetails['fwddate'])) {
        $Errors = VerifyFwdDate($BranchDetails['fwddate'], sizeof($Errors), $Errors);
    }
    if (isset($BranchDetails['phoneno'])) {
        $Errors = VerifyPhoneNumber($BranchDetails['phoneno'], sizeof($Errors), $Errors);
    }
    if (isset($BranchDetails['faxno'])) {
        $Errors = VerifyFaxNumber($BranchDetails['faxno'], sizeof($Errors), $Errors);
    }
    if (isset($BranchDetails['contactname'])) {
        $Errors = VerifyContactName($BranchDetails['contactname'], sizeof($Errors), $Errors);
    }
    if (isset($BranchDetails['email'])) {
        $Errors = VerifyEmailAddress($BranchDetails['email'], sizeof($Errors), $Errors);
    }
    if (isset($BranchDetails['defaultlocation'])) {
        $Errors = VerifyDefaultLocation($BranchDetails['defaultlocation'], sizeof($Errors), $Errors, $db);
    }
    if (isset($BranchDetails['taxgroupid'])) {
        $Errors = VerifyTaxGroupId($BranchDetails['taxgroupid'], sizeof($Errors), $Errors, $db);
    }
    if (isset($BranchDetails['defaultshipvia'])) {
        $Errors = VerifyDefaultShipVia($BranchDetails['defaultshipvia'], sizeof($Errors), $Errors, $db);
    }
    if (isset($BranchDetails['deliverblind'])) {
        $Errors = VerifyDeliverBlind($BranchDetails['deliverblind'], sizeof($Errors), $Errors);
    }
    if (isset($BranchDetails['disabletrans'])) {
        $Errors = VerifyDisableTrans($BranchDetails['disabletrans'], sizeof($Errors), $Errors);
    }
    if (isset($BranchDetails['brpostaddr1'])) {
        $Errors = VerifyBranchAddressLine($BranchDetails['brpostaddr1'], 40, sizeof($Errors), $Errors, $db);
    }
    if (isset($BranchDetails['brpostaddr2'])) {
        $Errors = VerifyBranchAddressLine($BranchDetails['brpostaddr2'], 40, sizeof($Errors), $Errors, $db);
    }
    if (isset($BranchDetails['brpostaddr3'])) {
        $Errors = VerifyBranchAddressLine($BranchDetails['brpostaddr3'], 30, sizeof($Errors), $Errors, $db);
    }
    if (isset($BranchDetails['brpostaddr4'])) {
        $Errors = VerifyBranchAddressLine($BranchDetails['brpostaddr4'], 20, sizeof($Errors), $Errors, $db);
    }
    if (isset($BranchDetails['brpostaddr5'])) {
        $Errors = VerifyBranchAddressLine($BranchDetails['brpostaddr5'], 20, sizeof($Errors), $Errors, $db);
    }
    if (isset($BranchDetails['brpostaddr6'])) {
        $Errors = VerifyBranchAddressLine($BranchDetails['brpostaddr6'], 15, sizeof($Errors), $Errors, $db);
    }
    if (isset($BranchDetails['specialinstructions'])) {
        $Errors = VerifySpecialInstructions($BranchDetails['specialinstructions'], sizeof($Errors), $Errors);
    }
    if (isset($BranchDetails['custbranchcode'])) {
        $Errors = VerifyCustBranchCode($BranchDetails['custbranchcode'], sizeof($Errors), $Errors);
    }
    $FieldNames = '';
    $FieldValues = '';
    foreach ($BranchDetails as $key => $value) {
        $FieldNames .= $key . ', ';
        $FieldValues .= '"' . $value . '", ';
    }
    $sql = 'UPDATE custbranch SET ';
    foreach ($BranchDetails as $key => $value) {
        $sql .= $key . '="' . $value . '", ';
    }
    $sql = mb_substr($sql, 0, -2) . " WHERE debtorno='" . $BranchDetails['debtorno'] . "'\n                                   AND branchcode='" . $BranchDetails['branchcode'] . "'";
    if (sizeof($Errors) == 0) {
        $result = DB_Query($sql, $db);
        if (DB_error_no() != 0) {
            $Errors[0] = DatabaseUpdateFailed;
        } else {
            $Errors[0] = 0;
        }
    }
    return $Errors;
}
Exemplo n.º 2
0
function ModifySupplier($SupplierDetails, $user, $password)
{
    $Errors = array();
    $db = db($user, $password);
    if (gettype($db) == 'integer') {
        $Errors[0] = NoAuthorisation;
        return $Errors;
    }
    foreach ($SupplierDetails as $key => $value) {
        $SupplierDetails[$key] = DB_escape_string($value);
    }
    $Errors = VerifySupplierNoExists($SupplierDetails['supplierid'], sizeof($Errors), $Errors, $db);
    $Errors = VerifySupplierName($SupplierDetails['suppname'], sizeof($Errors), $Errors);
    if (isset($SupplierDetails['address1'])) {
        $Errors = VerifyAddressLine($SupplierDetails['address1'], 40, sizeof($Errors), $Errors);
    }
    if (isset($SupplierDetails['address2'])) {
        $Errors = VerifyAddressLine($SupplierDetails['address2'], 40, sizeof($Errors), $Errors);
    }
    if (isset($SupplierDetails['address3'])) {
        $Errors = VerifyAddressLine($SupplierDetails['address3'], 40, sizeof($Errors), $Errors);
    }
    if (isset($SupplierDetails['address4'])) {
        $Errors = VerifyAddressLine($SupplierDetails['address4'], 50, sizeof($Errors), $Errors);
    }
    if (isset($SupplierDetails['address5'])) {
        $Errors = VerifyAddressLine($SupplierDetails['address5'], 20, sizeof($Errors), $Errors);
    }
    if (isset($SupplierDetails['address6'])) {
        $Errors = VerifyAddressLine($SupplierDetails['address6'], 15, sizeof($Errors), $Errors);
    }
    if (isset($SupplierDetails['lat'])) {
        $Errors = VerifyLatitude($SupplierDetails['lat'], sizeof($Errors), $Errors);
    }
    if (isset($SupplierDetails['lng'])) {
        $Errors = VerifyLongitude($SupplierDetails['lng'], sizeof($Errors), $Errors);
    }
    if (isset($SupplierDetails['currcode'])) {
        $Errors = VerifyCurrencyCode($SupplierDetails['currcode'], sizeof($Errors), $Errors, $db);
    }
    if (isset($SupplierDetails['suppliersince'])) {
        $Errors = VerifySupplierSince($SupplierDetails['suppliersince'], sizeof($Errors), $Errors, $db);
    }
    if (isset($SupplierDetails['paymentterms'])) {
        $Errors = VerifyPaymentTerms($SupplierDetails['paymentterms'], sizeof($Errors), $Errors, $db);
    }
    if (isset($SupplierDetails['lastpaid'])) {
        $Errors = VerifyLastPaid($SupplierDetails['lastpaid'], sizeof($Errors), $Errors);
    }
    if (isset($SupplierDetails['lastpaiddate'])) {
        $Errors = VerifyLastPaidDate($SupplierDetails['lastpaiddate'], sizeof($Errors), $Errors);
    }
    if (isset($SupplierDetails['bankact'])) {
        $Errors = VerifyBankAccount($SupplierDetails['bankact'], sizeof($Errors), $Errors);
    }
    if (isset($SupplierDetails['bankref'])) {
        $Errors = VerifyBankRef($SupplierDetails['bankref'], sizeof($Errors), $Errors);
    }
    if (isset($SupplierDetails['bankpartics'])) {
        $Errors = VerifyBankPartics($SupplierDetails['bankpartics'], sizeof($Errors), $Errors);
    }
    if (isset($SupplierDetails['remittance'])) {
        $Errors = VerifyRemittance($SupplierDetails['remittance'], sizeof($Errors), $Errors);
    }
    if (isset($SupplierDetails['taxgroupid'])) {
        $Errors = VerifyTaxGroupId($SupplierDetails['taxgroupid'], sizeof($Errors), $Errors, $db);
    }
    if (isset($SupplierDetails['factorcompanyid'])) {
        $Errors = VerifyFactorCompany($SupplierDetails['factorcompanyid'], sizeof($Errors), $Errors, $db);
    }
    if (isset($CustomerDetails['taxref'])) {
        $Errors = VerifyTaxRef($CustomerDetails['taxref'], sizeof($Errors), $Errors);
    }
    $sql = 'UPDATE suppliers SET ';
    foreach ($SupplierDetails as $key => $value) {
        $sql .= $key . '="' . $value . '", ';
    }
    $sql = mb_substr($sql, 0, -2) . " WHERE supplierid='" . $SupplierDetails['supplierid'] . "'";
    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;
}