コード例 #1
0
ファイル: api_customers.php プロジェクト: patmark/weberp-elct
function ModifyCustomer($CustomerDetails, $user, $password)
{
    $Errors = array();
    $db = db($user, $password);
    if (gettype($db) == 'integer') {
        $Errors[0] = NoAuthorisation;
        return $Errors;
    }
    foreach ($CustomerDetails as $key => $value) {
        $CustomerDetails[$key] = DB_escape_string($value);
    }
    if (!isset($CustomerDetails['debtorno'])) {
        $Errors[sizeof($Errors)] = NoDebtorNumber;
        return $Errors;
    }
    $Errors = VerifyDebtorExists($CustomerDetails['debtorno'], sizeof($Errors), $Errors, $db);
    if (in_array(DebtorDoesntExist, $Errors)) {
        return $Errors;
    }
    if (isset($CustomerDetails['name'])) {
        $Errors = VerifyDebtorName($CustomerDetails['name'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['address1'])) {
        $Errors = VerifyAddressLine($CustomerDetails['address1'], 40, sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['address2'])) {
        $Errors = VerifyAddressLine($CustomerDetails['address2'], 40, sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['address3'])) {
        $Errors = VerifyAddressLine($CustomerDetails['address3'], 40, sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['address4'])) {
        $Errors = VerifyAddressLine($CustomerDetails['address4'], 50, sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['address5'])) {
        $Errors = VerifyAddressLine($CustomerDetails['address5'], 20, sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['address6'])) {
        $Errors = VerifyAddressLine($CustomerDetails['address6'], 15, sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['currcode'])) {
        $Errors = VerifyCurrencyCode($CustomerDetails['currcode'], sizeof($Errors), $Errors, $db);
    }
    if (isset($CustomerDetails['salestype'])) {
        $Errors = VerifySalesType($CustomerDetails['salestype'], sizeof($Errors), $Errors, $db);
    }
    if (isset($CustomerDetails['clientsince'])) {
        $Errors = VerifyClientSince($CustomerDetails['clientsince'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['holdreason'])) {
        $Errors = VerifyHoldReason($CustomerDetails['holdreason'], sizeof($Errors), $Errors, $db);
    }
    if (isset($CustomerDetails['paymentterms'])) {
        $Errors = VerifyPaymentTerms($CustomerDetails['paymentterms'], sizeof($Errors), $Errors, $db);
    }
    if (isset($CustomerDetails['discount'])) {
        $Errors = VerifyDiscount($CustomerDetails['discount'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['pymtdiscount'])) {
        $Errors = VerifyPymtDiscount($CustomerDetails['pymtdiscount'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['lastpaid'])) {
        $Errors = VerifyLastPaid($CustomerDetails['lastpaid'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['lastpaiddate'])) {
        $Errors = VerifyLastPaidDate($CustomerDetails['lastpaiddate'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['creditlimit'])) {
        $Errors = VerifyCreditLimit($CustomerDetails['creditlimit'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['invaddrbranch'])) {
        $Errors = VerifyInvAddrBranch($CustomerDetails['invaddrbranch'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['discountcode'])) {
        $Errors = VerifyDiscountCode($CustomerDetails['discountcode'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['ediinvoices'])) {
        $Errors = VerifyEDIInvoices($CustomerDetails['ediinvoices'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['ediorders'])) {
        $Errors = VerifyEDIOrders($CustomerDetails['ediorders'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['edireference'])) {
        $Errors = VerifyEDIReference($CustomerDetails['edireference'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['editransport'])) {
        $Errors = VerifyEDITransport($CustomerDetails['editransport'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['ediserveruser'])) {
        $Errors = VerifyEDIServerUser($CustomerDetails['ediserveruser'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['ediserverpwd'])) {
        $Errors = VerifyEDIServerPassword($CustomerDetails['ediserverpwd'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['taxref'])) {
        $Errors = VerifyTaxRef($CustomerDetails['taxref'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['customerpoline'])) {
        $Errors = VerifyCustomerPOLine($CustomerDetails['customerpoline'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['typeid'])) {
        $Errors = VerifyCustomerType($CustomerDetails['typeid'], sizeof($Errors), $Errors, $db);
    }
    $sql = "UPDATE debtorsmaster SET ";
    foreach ($CustomerDetails as $key => $value) {
        $sql .= $key . '="' . $value . '", ';
    }
    $sql = mb_substr($sql, 0, -2) . " WHERE debtorno='" . $CustomerDetails['debtorno'] . "'";
    if (sizeof($Errors) == 0) {
        $result = DB_Query($sql, $db);
        if (DB_error_no($db) != 0) {
            $Errors[0] = DatabaseUpdateFailed;
        } else {
            $Errors[0] = 0;
        }
    }
    return $Errors;
}
コード例 #2
0
ファイル: api_suppliers.php プロジェクト: rrsc/KwaMoja
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;
}