function ModifySalesOrderHeader($OrderHeader, $user, $password) { $Errors = array(); $db = db($user, $password); if (gettype($db) == 'integer') { $Errors[0] = NoAuthorisation; return $Errors; } foreach ($OrderHeader as $key => $value) { $OrderHeader[$key] = DB_escape_string($value); } $Errors = VerifyOrderHeaderExists($OrderHeader['orderno'], sizeof($Errors), $Errors, $db); $Errors = VerifyDebtorExists($OrderHeader['debtorno'], sizeof($Errors), $Errors, $db); $Errors = VerifyBranchNoExists($OrderHeader['debtorno'], $OrderHeader['branchcode'], sizeof($Errors), $Errors, $db); if (isset($OrderHeader['customerref'])) { $Errors = VerifyCustomerRef($OrderHeader['customerref'], sizeof($Errors), $Errors); } if (isset($OrderHeader['buyername'])) { $Errors = VerifyBuyerName($OrderHeader['buyername'], sizeof($Errors), $Errors); } if (isset($OrderHeader['comments'])) { $Errors = VerifyComments($OrderHeader['comments'], sizeof($Errors), $Errors); } if (isset($OrderHeader['orddate'])) { $Errors = VerifyOrderDate($OrderHeader['orddate'], sizeof($Errors), $Errors, $db); } if (isset($OrderHeader['ordertype'])) { $Errors = VerifyOrderType($OrderHeader['ordertype'], sizeof($Errors), $Errors, $db); } if (isset($OrderHeader['shipvia'])) { $Errors = VerifyShipVia($OrderHeader['shipvia'], sizeof($Errors), $Errors, $db); } if (isset($OrderHeader['deladd1'])) { $Errors = VerifyAddressLine($OrderHeader['deladd1'], 40, sizeof($Errors), $Errors); } if (isset($OrderHeader['deladd2'])) { $Errors = VerifyAddressLine($OrderHeader['deladd2'], 40, sizeof($Errors), $Errors); } if (isset($OrderHeader['deladd3'])) { $Errors = VerifyAddressLine($OrderHeader['deladd3'], 40, sizeof($Errors), $Errors); } if (isset($OrderHeader['deladd4'])) { $Errors = VerifyAddressLine($OrderHeader['deladd4'], 40, sizeof($Errors), $Errors); } if (isset($OrderHeader['deladd5'])) { $Errors = VerifyAddressLine($OrderHeader['deladd5'], 20, sizeof($Errors), $Errors); } if (isset($OrderHeader['deladd6'])) { $Errors = VerifyAddressLine($OrderHeader['deladd6'], 15, sizeof($Errors), $Errors); } if (isset($OrderHeader['contactphone'])) { $Errors = VerifyPhoneNumber($OrderHeader['contactphone'], sizeof($Errors), $Errors); } if (isset($OrderHeader['contactemail'])) { $Errors = VerifyEmailAddress($OrderHeader['contactemail'], sizeof($Errors), $Errors); } if (isset($OrderHeader['deliverto'])) { $Errors = VerifyDeliverTo($OrderHeader['deliverto'], sizeof($Errors), $Errors); } if (isset($OrderHeader['deliverblind'])) { $Errors = VerifyDeliverBlind($OrderHeader['deliverblind'], sizeof($Errors), $Errors); } if (isset($OrderHeader['freightcost'])) { $Errors = VerifyFreightCost($OrderHeader['freightcost'], sizeof($Errors), $Errors); } if (isset($OrderHeader['fromstkloc'])) { $Errors = VerifyFromStockLocation($OrderHeader['fromstkloc'], sizeof($Errors), $Errors, $db); } if (isset($OrderHeader['deliverydate'])) { $Errors = VerifyDeliveryDate($OrderHeader['deliverydate'], sizeof($Errors), $Errors, $db); } if (isset($OrderHeader['quotation'])) { $Errors = VerifyQuotation($OrderHeader['quotation'], sizeof($Errors), $Errors); } global $SOH_DateFields; $sql = 'UPDATE salesorders SET '; foreach ($OrderHeader as $key => $value) { if (in_array($key, $SOH_DateFields)) { $value = FormatDateforSQL($value); } // Fix dates $sql .= $key . '="' . $value . '", '; } $sql = substr($sql, 0, -2) . ' WHERE orderno="' . $OrderHeader['orderno'] . '"'; if (sizeof($Errors) == 0) { $result = api_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 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; }
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; }
function ModifyLocation($Location, $user, $password) { $Errors = array(); $db = db($user, $password); if (gettype($db) == 'integer') { $Errors[0] = NoAuthorisation; return $Errors; } foreach ($Location as $key => $value) { $Location[$key] = DB_escape_string($value); } $Errors = VerifyLocationExists($Location['loccode'], sizeof($Errors), $Errors, $db); $Errors = VerifyLocationName($Location['locationname'], sizeof($Errors), $Errors, $db); $Errors = VerifyTaxProvinceId($Location['taxprovinceid'], sizeof($Errors), $Errors, $db); if (isset($Location['deladd1'])) { $Errors = VerifyAddressLine($Location['deladd1'], 40, sizeof($Errors), $Errors); } if (isset($Location['deladd2'])) { $Errors = VerifyAddressLine($Location['deladd2'], 40, sizeof($Errors), $Errors); } if (isset($Location['deladd3'])) { $Errors = VerifyAddressLine($Location['deladd3'], 40, sizeof($Errors), $Errors); } if (isset($Location['deladd4'])) { $Errors = VerifyAddressLine($Location['deladd4'], 40, sizeof($Errors), $Errors); } if (isset($Location['deladd5'])) { $Errors = VerifyAddressLine($Location['deladd5'], 20, sizeof($Errors), $Errors); } if (isset($Location['deladd6'])) { $Errors = VerifyAddressLine($Location['deladd6'], 15, sizeof($Errors), $Errors); } if (isset($Location['tel'])) { $Errors = VerifyPhoneNumber($Location['tel'], sizeof($Errors), $Errors); } if (isset($Location['fax'])) { $Errors = VerifyFaxNumber($Location['fax'], sizeof($Errors), $Errors); } if (isset($Location['email'])) { $Errors = VerifyEmailAddress($Location['email'], sizeof($Errors), $Errors); } if (isset($Location['contact'])) { $Errors = VerifyContactName($Location['contact'], sizeof($Errors), $Errors); } $sql = 'UPDATE locations SET '; foreach ($Location as $key => $value) { $sql .= $key . '="' . $value . '", '; } $sql = substr($sql, 0, -2) . ' WHERE loccode="' . $Location['loccode'] . '"'; if (sizeof($Errors) == 0) { $result = DB_Query($sql, $db); if (DB_error_no($db) != 0) { $Errors[0] = DatabaseUpdateFailed; } else { $Errors[0] = 0; } } return $Errors; }