Skip to content

Commit

Permalink
PaulT: Remove unused $db parameter from many functions within the /ap…
Browse files Browse the repository at this point in the history
…i area.
  • Loading branch information
TurboPT authored and timschofield committed Feb 27, 2018
1 parent 5935b1e commit 634c3f9
Show file tree
Hide file tree
Showing 15 changed files with 268 additions and 267 deletions.
96 changes: 48 additions & 48 deletions api/api_branches.php
Expand Up @@ -2,7 +2,7 @@
/* $Id$*/

/* Check that the debtor number exists*/
function VerifyBranchDebtorExists($DebtorNumber, $i, $Errors, $db) {
function VerifyBranchDebtorExists($DebtorNumber, $i, $Errors) {
$Searchsql = "SELECT count(debtorno)
FROM debtorsmaster
WHERE debtorno='".$DebtorNumber."'";
Expand All @@ -16,7 +16,7 @@ function VerifyBranchDebtorExists($DebtorNumber, $i, $Errors, $db) {

/* Verify that the branch number is valid, and doesn't already
exist.*/
function VerifyBranchNo($DebtorNumber, $BranchNumber, $i, $Errors, $db) {
function VerifyBranchNo($DebtorNumber, $BranchNumber, $i, $Errors) {
if ((mb_strlen($BranchNumber)<1) or (mb_strlen($BranchNumber)>10)) {
$Errors[$i] = IncorrectBranchNumberLength;
}
Expand All @@ -33,7 +33,7 @@ function VerifyBranchNo($DebtorNumber, $BranchNumber, $i, $Errors, $db) {
}

/* Verify that the branch number exists.*/
function VerifyBranchNoExists($DebtorNumber, $BranchNumber, $i, $Errors, $db) {
function VerifyBranchNoExists($DebtorNumber, $BranchNumber, $i, $Errors) {
if ((mb_strlen($BranchNumber)<1) or (mb_strlen($BranchNumber)>10)) {
$Errors[$i] = IncorrectBranchNumberLength;
}
Expand Down Expand Up @@ -91,7 +91,7 @@ function VerifyEstDeliveryDays($EstDeliveryDays, $i, $Errors) {
}

/* Check that the area code is set up in the weberp database */
function VerifyAreaCode($AreaCode , $i, $Errors, $db) {
function VerifyAreaCode($AreaCode , $i, $Errors) {
$Searchsql = "SELECT COUNT(areacode)
FROM areas
WHERE areacode='".$AreaCode."'";
Expand All @@ -104,7 +104,7 @@ function VerifyAreaCode($AreaCode , $i, $Errors, $db) {
}

/* Check that the salesman is set up in the weberp database */
function VerifySalesmanCode($SalesmanCode , $i, $Errors, $db) {
function VerifySalesmanCode($SalesmanCode , $i, $Errors) {
$Searchsql = "SELECT COUNT(salesmancode)
FROM salesman
WHERE salesmancode='".$SalesmanCode."'";
Expand Down Expand Up @@ -165,7 +165,7 @@ function VerifyEmailAddress($EmailAddress, $i, $Errors) {
}

/* Check that the default location is set up in the weberp database */
function VerifyDefaultLocation($DefaultLocation , $i, $Errors, $db) {
function VerifyDefaultLocation($DefaultLocation , $i, $Errors) {
$Searchsql = "SELECT COUNT(loccode)
FROM locations
WHERE loccode='".$DefaultLocation."'";
Expand All @@ -178,7 +178,7 @@ function VerifyDefaultLocation($DefaultLocation , $i, $Errors, $db) {
}

/* Check that the tax group id is set up in the weberp database */
function VerifyTaxGroupId($TaxGroupId , $i, $Errors, $db) {
function VerifyTaxGroupId($TaxGroupId , $i, $Errors) {
$Searchsql = "SELECT COUNT(taxgroupid)
FROM taxgroups
WHERE taxgroupid='".$TaxGroupId."'";
Expand All @@ -191,7 +191,7 @@ function VerifyTaxGroupId($TaxGroupId , $i, $Errors, $db) {
}

/* Check that the default shipper is set up in the weberp database */
function VerifyDefaultShipVia($DefaultShipVia , $i, $Errors, $db) {
function VerifyDefaultShipVia($DefaultShipVia , $i, $Errors) {
$Searchsql = "SELECT COUNT(shipper_id)
FROM shippers
WHERE shipper_id='".$DefaultShipVia."'";
Expand Down Expand Up @@ -245,26 +245,26 @@ function InsertBranch($BranchDetails, $user, $password) {
foreach ($BranchDetails as $key => $value) {
$BranchDetails[$key] = DB_escape_string($value);
}
$Errors=VerifyBranchDebtorExists($BranchDetails['debtorno'], sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchNo($BranchDetails['debtorno'], $BranchDetails['branchcode'], sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchName($BranchDetails['brname'], sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchDebtorExists($BranchDetails['debtorno'], sizeof($Errors), $Errors);
$Errors=VerifyBranchNo($BranchDetails['debtorno'], $BranchDetails['branchcode'], sizeof($Errors), $Errors);
$Errors=VerifyBranchName($BranchDetails['brname'], sizeof($Errors), $Errors);
if (isset($BranchDetails['address1'])){
$Errors=VerifyBranchAddressLine($BranchDetails['address1'], 40, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['address1'], 40, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['address2'])){
$Errors=VerifyBranchAddressLine($BranchDetails['address2'], 40, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['address2'], 40, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['address3'])){
$Errors=VerifyBranchAddressLine($BranchDetails['address3'], 40, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['address3'], 40, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['address4'])){
$Errors=VerifyBranchAddressLine($BranchDetails['address4'], 50, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['address4'], 50, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['address5'])){
$Errors=VerifyBranchAddressLine($BranchDetails['address5'], 20, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['address5'], 20, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['address6'])){
$Errors=VerifyBranchAddressLine($BranchDetails['address6'], 15, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['address6'], 15, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['lat'])){
$Errors=VerifyLatitude($BranchDetails['lat'], sizeof($Errors), $Errors);
Expand All @@ -276,10 +276,10 @@ function InsertBranch($BranchDetails, $user, $password) {
$Errors=VerifyEstDeliveryDays($BranchDetails['estdeliverydays'], sizeof($Errors), $Errors);
}
if (isset($BranchDetails['area'])){
$Errors=VerifyAreaCode($BranchDetails['area'], sizeof($Errors), $Errors, $db);
$Errors=VerifyAreaCode($BranchDetails['area'], sizeof($Errors), $Errors);
}
if (isset($BranchDetails['salesman'])){
$Errors=VerifySalesmanCode($BranchDetails['salesman'], sizeof($Errors), $Errors, $db);
$Errors=VerifySalesmanCode($BranchDetails['salesman'], sizeof($Errors), $Errors);
}
if (isset($BranchDetails['fwddate'])){
$Errors=VerifyFwdDate($BranchDetails['fwddate'], sizeof($Errors), $Errors);
Expand All @@ -297,13 +297,13 @@ function InsertBranch($BranchDetails, $user, $password) {
$Errors=VerifyEmailAddress($BranchDetails['email'], sizeof($Errors), $Errors);
}
if (isset($BranchDetails['defaultlocation'])){
$Errors=VerifyDefaultLocation($BranchDetails['defaultlocation'], sizeof($Errors), $Errors, $db);
$Errors=VerifyDefaultLocation($BranchDetails['defaultlocation'], sizeof($Errors), $Errors);
}
if (isset($BranchDetails['taxgroupid'])){
$Errors=VerifyTaxGroupId($BranchDetails['taxgroupid'], sizeof($Errors), $Errors, $db);
$Errors=VerifyTaxGroupId($BranchDetails['taxgroupid'], sizeof($Errors), $Errors);
}
if (isset($BranchDetails['defaultshipvia'])){
$Errors=VerifyDefaultShipVia($BranchDetails['defaultshipvia'], sizeof($Errors), $Errors, $db);
$Errors=VerifyDefaultShipVia($BranchDetails['defaultshipvia'], sizeof($Errors), $Errors);
}
if (isset($BranchDetails['deliverblind'])){
$Errors=VerifyDeliverBlind($BranchDetails['deliverblind'], sizeof($Errors), $Errors);
Expand All @@ -312,22 +312,22 @@ function InsertBranch($BranchDetails, $user, $password) {
$Errors=VerifyDisableTrans($BranchDetails['disabletrans'], sizeof($Errors), $Errors);
}
if (isset($BranchDetails['brpostaddr1'])){
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr1'], 40, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr1'], 40, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['brpostaddr2'])){
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr2'], 40, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr2'], 40, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['brpostaddr3'])){
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr3'], 30, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr3'], 30, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['brpostaddr4'])){
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr4'], 20, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr4'], 20, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['brpostaddr5'])){
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr5'], 20, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr5'], 20, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['brpostaddr6'])){
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr6'], 15, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr6'], 15, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['specialinstructions'])){
$Errors=VerifySpecialInstructions($BranchDetails['specialinstructions'], sizeof($Errors), $Errors);
Expand Down Expand Up @@ -369,25 +369,25 @@ function ModifyBranch($BranchDetails, $user, $password) {
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);
$Errors=VerifyBranchNoExists($BranchDetails['debtorno'], $BranchDetails['branchcode'], sizeof($Errors), $Errors);
$Errors=VerifyBranchName($BranchDetails['brname'], sizeof($Errors), $Errors);
if (isset($BranchDetails['address1'])){
$Errors=VerifyBranchAddressLine($BranchDetails['address1'], 40, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['address1'], 40, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['address2'])){
$Errors=VerifyBranchAddressLine($BranchDetails['address2'], 40, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['address2'], 40, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['address3'])){
$Errors=VerifyBranchAddressLine($BranchDetails['address3'], 40, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['address3'], 40, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['address4'])){
$Errors=VerifyBranchAddressLine($BranchDetails['address4'], 50, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['address4'], 50, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['address5'])){
$Errors=VerifyBranchAddressLine($BranchDetails['address5'], 20, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['address5'], 20, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['address6'])){
$Errors=VerifyBranchAddressLine($BranchDetails['address6'], 15, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['address6'], 15, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['lat'])){
$Errors=VerifyLatitude($BranchDetails['lat'], sizeof($Errors), $Errors);
Expand All @@ -399,10 +399,10 @@ function ModifyBranch($BranchDetails, $user, $password) {
$Errors=VerifyEstDeliveryDays($BranchDetails['estdeliverydays'], sizeof($Errors), $Errors);
}
if (isset($BranchDetails['area'])){
$Errors=VerifyAreaCode($BranchDetails['area'], sizeof($Errors), $Errors, $db);
$Errors=VerifyAreaCode($BranchDetails['area'], sizeof($Errors), $Errors);
}
if (isset($BranchDetails['salesman'])){
$Errors=VerifySalesmanCode($BranchDetails['salesman'], sizeof($Errors), $Errors, $db);
$Errors=VerifySalesmanCode($BranchDetails['salesman'], sizeof($Errors), $Errors);
}
if (isset($BranchDetails['fwddate'])){
$Errors=VerifyFwdDate($BranchDetails['fwddate'], sizeof($Errors), $Errors);
Expand All @@ -420,13 +420,13 @@ function ModifyBranch($BranchDetails, $user, $password) {
$Errors=VerifyEmailAddress($BranchDetails['email'], sizeof($Errors), $Errors);
}
if (isset($BranchDetails['defaultlocation'])){
$Errors=VerifyDefaultLocation($BranchDetails['defaultlocation'], sizeof($Errors), $Errors, $db);
$Errors=VerifyDefaultLocation($BranchDetails['defaultlocation'], sizeof($Errors), $Errors);
}
if (isset($BranchDetails['taxgroupid'])){
$Errors=VerifyTaxGroupId($BranchDetails['taxgroupid'], sizeof($Errors), $Errors, $db);
$Errors=VerifyTaxGroupId($BranchDetails['taxgroupid'], sizeof($Errors), $Errors);
}
if (isset($BranchDetails['defaultshipvia'])){
$Errors=VerifyDefaultShipVia($BranchDetails['defaultshipvia'], sizeof($Errors), $Errors, $db);
$Errors=VerifyDefaultShipVia($BranchDetails['defaultshipvia'], sizeof($Errors), $Errors);
}
if (isset($BranchDetails['deliverblind'])){
$Errors=VerifyDeliverBlind($BranchDetails['deliverblind'], sizeof($Errors), $Errors);
Expand All @@ -435,22 +435,22 @@ function ModifyBranch($BranchDetails, $user, $password) {
$Errors=VerifyDisableTrans($BranchDetails['disabletrans'], sizeof($Errors), $Errors);
}
if (isset($BranchDetails['brpostaddr1'])){
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr1'], 40, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr1'], 40, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['brpostaddr2'])){
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr2'], 40, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr2'], 40, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['brpostaddr3'])){
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr3'], 30, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr3'], 30, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['brpostaddr4'])){
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr4'], 20, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr4'], 20, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['brpostaddr5'])){
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr5'], 20, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr5'], 20, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['brpostaddr6'])){
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr6'], 15, sizeof($Errors), $Errors, $db);
$Errors=VerifyBranchAddressLine($BranchDetails['brpostaddr6'], 15, sizeof($Errors), $Errors);
}
if (isset($BranchDetails['specialinstructions'])){
$Errors=VerifySpecialInstructions($BranchDetails['specialinstructions'], sizeof($Errors), $Errors);
Expand Down Expand Up @@ -520,7 +520,7 @@ function GetCustomerBranch($DebtorNumber, $BranchCode, $user, $password) {
$Errors[0]=NoAuthorisation;
return $Errors;
}
$Errors = VerifyBranchNoExists($DebtorNumber, $BranchCode, sizeof($Errors), $Errors, $db);
$Errors = VerifyBranchNoExists($DebtorNumber, $BranchCode, sizeof($Errors), $Errors);
if (sizeof($Errors)!=0) {
return $Errors;
}
Expand Down

0 comments on commit 634c3f9

Please sign in to comment.