diff --git a/CustomerBranches.php b/CustomerBranches.php index 2e3c2918..e0fb763d 100644 --- a/CustomerBranches.php +++ b/CustomerBranches.php @@ -7,16 +7,15 @@ $ViewTopic = 'AccountsReceivable';// Filename's id in ManualContents.php's TOC. $BookMark = 'NewCustomerBranch';// Anchor's id in the manual's html document. include('includes/header.inc'); - include('includes/CountriesArray.php'); -if(isset($_GET['DebtorNo'])) { +if (isset($_GET['DebtorNo'])) { $DebtorNo = mb_strtoupper($_GET['DebtorNo']); -} elseif(isset($_POST['DebtorNo'])) { +} else if (isset($_POST['DebtorNo'])){ $DebtorNo = mb_strtoupper($_POST['DebtorNo']); } -if(!isset($DebtorNo)) { +if (!isset($DebtorNo)) { prnMsg(_('This page must be called with the debtor code of the customer for whom you wish to edit the branches for').'.
' . _('When the pages is called from within the system this will always be the case').'
' . _('Select a customer first then select the link to add/edit/delete branches'),'warn'); @@ -24,13 +23,14 @@ exit; } -if(isset($_GET['SelectedBranch'])) { + +if (isset($_GET['SelectedBranch'])){ $SelectedBranch = mb_strtoupper($_GET['SelectedBranch']); -} elseif(isset($_POST['SelectedBranch'])) { +} else if (isset($_POST['SelectedBranch'])){ $SelectedBranch = mb_strtoupper($_POST['SelectedBranch']); } -if(isset($Errors)) { +if (isset($Errors)) { unset($Errors); } @@ -38,7 +38,7 @@ $Errors = array(); $InputError = 0; -if(isset($_POST['submit'])) { +if (isset($_POST['submit'])) { $i=1; @@ -49,53 +49,53 @@ $_POST['BranchCode'] = mb_strtoupper($_POST['BranchCode']); - if($_SESSION['SalesmanLogin'] != '') { + if ($_SESSION['SalesmanLogin'] != '') { $_POST['Salesman'] = $_SESSION['SalesmanLogin']; } - if(ContainsIllegalCharacters($_POST['BranchCode']) OR mb_strstr($_POST['BranchCode'],' ')) { + if (ContainsIllegalCharacters($_POST['BranchCode']) OR mb_strstr($_POST['BranchCode'],' ')) { $InputError = 1; prnMsg(_('The Branch code cannot contain any of the following characters')." - & \' < >",'error'); $Errors[$i] = 'BranchCode'; $i++; } - if(mb_strlen($_POST['BranchCode'])==0) { + if (mb_strlen($_POST['BranchCode'])==0) { $InputError = 1; prnMsg(_('The Branch code must be at least one character long'),'error'); $Errors[$i] = 'BranchCode'; $i++; } - if(!is_numeric($_POST['FwdDate'])) { + if (!is_numeric($_POST['FwdDate'])) { $InputError = 1; prnMsg(_('The date after which invoices are charged to the following month is expected to be a number and a recognised number has not been entered'),'error'); $Errors[$i] = 'FwdDate'; $i++; } - if($_POST['FwdDate'] >30) { + if ($_POST['FwdDate'] >30) { $InputError = 1; prnMsg(_('The date (in the month) after which invoices are charged to the following month should be a number less than 31'),'error'); $Errors[$i] = 'FwdDate'; $i++; } - if(!is_numeric(filter_number_format($_POST['EstDeliveryDays']))) { + if (!is_numeric(filter_number_format($_POST['EstDeliveryDays']))) { $InputError = 1; prnMsg(_('The estimated delivery days is expected to be a number and a recognised number has not been entered'),'error'); $Errors[$i] = 'EstDeliveryDays'; $i++; } - if(filter_number_format($_POST['EstDeliveryDays']) >60) { + if (filter_number_format($_POST['EstDeliveryDays']) >60) { $InputError = 1; prnMsg(_('The estimated delivery days should be a number of days less than 60') . '. ' . _('A package can be delivered by seafreight anywhere in the world normally in less than 60 days'),'error'); $Errors[$i] = 'EstDeliveryDays'; $i++; } - if(!isset($_POST['EstDeliveryDays'])) { + if (!isset($_POST['EstDeliveryDays'])) { $_POST['EstDeliveryDays']=1; } - if(!isset($Latitude)) { + if (!isset($Latitude)) { $Latitude=0.0; $Longitude=0.0; } - if($_SESSION['geocode_integration']==1 ) { + if ($_SESSION['geocode_integration']==1 ){ // Get the lat/long from our geocoding host $SQL = "SELECT * FROM geocode_param WHERE 1"; $ErrMsg = _('An error occurred in retrieving the information'); @@ -105,7 +105,7 @@ $map_host = $row['map_host']; define('MAPS_HOST', $map_host); define('KEY', $api_key); - if($map_host=="") { + if ($map_host=="") { // check that some sane values are setup already in geocode tables, if not skip the geocoding but add the record anyway. echo '
' . _('Warning - Geocode Integration is enabled, but no hosts are setup. Go to Geocode Setup') . '
'; } else { @@ -120,7 +120,7 @@ $Longitude = $CoordinatesSplit[0]; $Status = $xml->Response->Status->code; - if(strcmp($Status, '200') == 0) { + if (strcmp($Status, '200') == 0) { // Successful geocode $Geocode_Pending = false; $Coordinates = $xml->Response->Placemark->Point->Coordinates; @@ -136,7 +136,7 @@ } } } - if(isset($SelectedBranch) AND $InputError !=1) { + if (isset($SelectedBranch) AND $InputError !=1) { /*SelectedBranch could also exist if submit had not been clicked this code would not run in this case cos submit is false of course see the delete code below*/ @@ -171,13 +171,13 @@ deliverblind='" . $_POST['DeliverBlind'] . "' WHERE branchcode = '".$SelectedBranch."' AND debtorno='".$DebtorNo."'"; - if($_SESSION['SalesmanLogin'] != '') { + if ($_SESSION['SalesmanLogin'] != '') { $SQL .= " AND custbranch.salesman='" . $_SESSION['SalesmanLogin'] . "'"; } $msg = $_POST['BrName'] . ' '._('branch has been updated.'); - } elseif($InputError !=1) { + } else if ($InputError !=1) { /*Selected branch is null cos no item selected on first time round so must be adding a record must be submitting new entries in the new Customer Branches form */ @@ -250,11 +250,11 @@ //run the SQL from either of the above possibilites $ErrMsg = _('The branch record could not be inserted or updated because'); - if($InputError==0) { + if ($InputError==0) { $result = DB_query($SQL, $ErrMsg); } - if(DB_error_no() ==0 AND $InputError==0) { + if (DB_error_no() ==0 AND $InputError==0) { prnMsg($msg,'success'); unset($_POST['BranchCode']); unset($_POST['BrName']); @@ -286,7 +286,7 @@ unset($_POST['DeliverBlind']); unset($SelectedBranch); } -} elseif(isset($_GET['delete'])) { +} else if (isset($_GET['delete'])) { //the link to delete a selected record was clicked instead of the submit button // PREVENT DELETES IF DEPENDENT RECORDS IN 'DebtorTrans' @@ -295,7 +295,7 @@ $result = DB_query($SQL); $myrow = DB_fetch_row($result); - if($myrow[0]>0) { + if ($myrow[0]>0) { prnMsg(_('Cannot delete this branch because customer transactions have been created to this branch') . '
' . _('There are').' ' . $myrow[0] . ' '._('transactions with this Branch Code'),'error'); @@ -305,7 +305,7 @@ $result = DB_query($SQL); $myrow = DB_fetch_row($result); - if($myrow[0]>0) { + if ($myrow[0]>0) { prnMsg(_('Cannot delete this branch because sales analysis records exist for it'),'error'); echo '
' . _('There are').' ' . $myrow[0] . ' '._('sales analysis records with this Branch Code/customer'); @@ -315,7 +315,7 @@ $result = DB_query($SQL); $myrow = DB_fetch_row($result); - if($myrow[0]>0) { + if ($myrow[0]>0) { prnMsg(_('Cannot delete this branch because sales orders exist for it') . '. ' . _('Purge old sales orders first'),'warn'); echo '
' . _('There are').' ' . $myrow[0] . ' '._('sales orders for this Branch/customer'); } else { @@ -325,7 +325,7 @@ $result = DB_query($SQL); $myrow = DB_fetch_row($result); - if($myrow[0]>0) { + if ($myrow[0]>0) { prnMsg(_('Cannot delete this branch because users exist that refer to it') . '. ' . _('Purge old users first'),'warn'); echo '
' . _('There are') . ' ' . $myrow[0] . ' '._('users referring to this Branch/customer'); } else { @@ -335,7 +335,7 @@ $result = DB_query($SQL); $myrow = DB_fetch_row($result); - if($myrow[0]>0) { + if ($myrow[0]>0) { prnMsg(_('Cannot delete this branch because contract have been created that refer to it') . '. ' . _('Purge old contracts first'),'warn'); echo '
' . _('There are') . ' ' . $myrow[0] . ' '._('contracts referring to this branch/customer'); } else { @@ -345,16 +345,16 @@ $result = DB_query($SQL); $myrow = DB_fetch_row($result); - if($myrow[0]==1) { + if ($myrow[0]==1) { prnMsg(_('Cannot delete this branch because it is the only branch defined for this customer.'),'warn'); } else { $SQL="DELETE FROM custbranch WHERE branchcode='" . $SelectedBranch . "' AND debtorno='" . $DebtorNo . "'"; - if($_SESSION['SalesmanLogin'] != '') { + if ($_SESSION['SalesmanLogin'] != '') { $SQL .= " AND custbranch.salesman='" . $_SESSION['SalesmanLogin'] . "'"; } $ErrMsg = _('The branch record could not be deleted') . ' - ' . _('the SQL server returned the following message'); $result = DB_query($SQL,$ErrMsg); - if(DB_error_no()==0) { + if (DB_error_no()==0){ prnMsg(_('Branch Deleted'),'success'); } } @@ -365,7 +365,7 @@ }//end ifs to test if the branch can be deleted } -if(!isset($SelectedBranch)) { +if (!isset($SelectedBranch)){ /* It could still be the second time the page has been run and a record has been selected for modification - SelectedBranch will exist because it was sent with the new call. If its the first time the page has been displayed with no parameters then none of the above are true and the list of branches will be displayed with links to delete or edit each. These will call the same page again and allow update/input or deletion of the records*/ @@ -390,7 +390,7 @@ ON custbranch.taxgroupid=taxgroups.taxgroupid WHERE custbranch.debtorno = '".$DebtorNo."'"; - if($_SESSION['SalesmanLogin'] != '') { + if ($_SESSION['SalesmanLogin'] != '') { $SQL .= " AND custbranch.salesman='" . $_SESSION['SalesmanLogin'] . "'"; } @@ -398,7 +398,7 @@ $myrow = DB_fetch_row($result); $TotalEnable = 0; $TotalDisable = 0; - if($myrow) { + if ($myrow) { echo '

',// Icon title. @@ -419,7 +419,7 @@ $k=0; do { - if($k==1) { + if ($k==1){ echo ''; $k=0; } else { @@ -459,7 +459,7 @@ urlencode($myrow[1]), _('Delete Branch')); - if($myrow[10]) { + if ($myrow[10]){ $TotalDisable++; } else { $TotalEnable++; @@ -503,12 +503,12 @@ } } -if(!isset($_GET['delete'])) { +if (!isset($_GET['delete'])) { echo '

'; echo '
'; echo ''; - if(isset($SelectedBranch)) { + if (isset($SelectedBranch)) { //editing an existing branch $SQL = "SELECT branchcode, @@ -543,14 +543,14 @@ WHERE branchcode='".$SelectedBranch."' AND debtorno='".$DebtorNo."'"; - if($_SESSION['SalesmanLogin'] != '') { + if ($_SESSION['SalesmanLogin'] != '') { $SQL .= " AND custbranch.salesman='" . $_SESSION['SalesmanLogin'] . "'"; } $result = DB_query($SQL); $myrow = DB_fetch_array($result); - if($InputError==0) { + if ($InputError==0) { $_POST['BranchCode'] = $myrow['branchcode']; $_POST['BrName'] = $myrow['brname']; $_POST['BrAddress1'] = $myrow['braddress1']; @@ -586,7 +586,7 @@ echo '

' . ' ' . _('Change Details for Branch'). ' '. $SelectedBranch . '

'; - if(isset($SelectedBranch)) { + if (isset($SelectedBranch)) { echo ''; } echo '
@@ -606,7 +606,7 @@ /* SETUP ANY $_GET VALUES THAT ARE PASSED. This really is just used coming from the Customers.php when a new customer is created. Maybe should only do this when that page is the referrer? */ - if(isset($_GET['BranchCode'])) { + if (isset($_GET['BranchCode'])){ $SQL="SELECT name, address1, address2, @@ -628,7 +628,7 @@ $_POST['BrAddress5'] = $myrow['addrsss5']; $_POST['BrAddress6'] = $myrow['addrsss6']; } - if(!isset($_POST['BranchCode'])) { + if (!isset($_POST['BranchCode'])) { $_POST['BranchCode']=''; } echo '

' . ' ' . _('Add a Branch') . '

'; @@ -647,58 +647,58 @@ echo _('Branch Name').':'; - if(!isset($_POST['BrName'])) {$_POST['BrName']='';} + if (!isset($_POST['BrName'])) {$_POST['BrName']='';} echo ' '; echo ' ' . _('Branch Contact').':'; - if(!isset($_POST['ContactName'])) {$_POST['ContactName']='';} + if (!isset($_POST['ContactName'])) {$_POST['ContactName']='';} echo ' '; echo '' . _('Street Address 1 (Street)').':'; - if(!isset($_POST['BrAddress1'])) { + if (!isset($_POST['BrAddress1'])) { $_POST['BrAddress1']=''; } echo ' ' . _('Street Address 2 (Street)').':'; - if(!isset($_POST['BrAddress2'])) { + if (!isset($_POST['BrAddress2'])) { $_POST['BrAddress2']=''; } echo ' ' . _('Street Address 3 (Suburb/City)').':'; - if(!isset($_POST['BrAddress3'])) { + if (!isset($_POST['BrAddress3'])) { $_POST['BrAddress3']=''; } echo ' ' . _('Street Address 4 (State/Province)').':'; - if(!isset($_POST['BrAddress4'])) { + if (!isset($_POST['BrAddress4'])) { $_POST['BrAddress4']=''; } echo ' ' . _('Street Address 5 (Postal Code)').':'; - if(!isset($_POST['BrAddress5'])) { + if (!isset($_POST['BrAddress5'])) { $_POST['BrAddress5']=''; } echo ' ' . _('Country').':'; - if(!isset($_POST['BrAddress6'])) { + if (!isset($_POST['BrAddress6'])) { $_POST['BrAddress6']=''; } echo ' ' . _('Default days to deliver').':'; - if(!isset($_POST['EstDeliveryDays'])) { + if (!isset($_POST['EstDeliveryDays'])) { $_POST['EstDeliveryDays']=0; } echo ' ' . _('Forward Date After (day in month)').':'; - if(!isset($_POST['FwdDate'])) { + if (!isset($_POST['FwdDate'])) { $_POST['FwdDate']=0; } echo ' '; - if($_SESSION['SalesmanLogin'] != '') { + if ($_SESSION['SalesmanLogin'] != '') { echo ' ' . _('Salesperson').':'; echo $_SESSION['UsersRealName']; @@ -746,7 +746,7 @@ $result = DB_query($SQL); - if(DB_num_rows($result)==0) { + if (DB_num_rows($result)==0){ echo ''; prnMsg(_('There are no sales people defined as yet') . ' - ' . _('customer branches must be allocated to a sales person') . '. ' . _('Please use the link below to define at least one sales person'),'error'); echo '

' . _('Define Sales People') . ''; @@ -759,7 +759,7 @@ '; while ($myrow = DB_fetch_array($result)) { - if(isset($_POST['Area']) AND $myrow['areacode']==$_POST['Area']) { + if (isset($_POST['Area']) AND $myrow['areacode']==$_POST['Area']) { echo ' '; } else { @@ -905,7 +905,7 @@ $SQL = "SELECT shipper_id, shippername FROM shippers"; $ShipperResults = DB_query($SQL); - if(DB_num_rows($ShipperResults)==0) { + if (DB_num_rows($ShipperResults)==0){ echo ''; prnMsg(_('There are no shippers defined - these must be set up first before any branches can be set up') . '
' . _('Define Shippers') . '','error'); @@ -915,8 +915,8 @@ echo ' ' . _('Default freight/shipper method') . ': '; - if($_POST['DeliverBlind']==2) { + if ($_POST['DeliverBlind']==2){ echo ' '; } else { @@ -942,23 +942,23 @@ echo ' '; - if(!isset($_POST['BrPostAddr1'])) {// Postal address, line 1. Database: custbranch.brpostaddr1, varchar(40) + if (!isset($_POST['BrPostAddr1'])) {// Postal address, line 1. Database: custbranch.brpostaddr1, varchar(40) $_POST['BrPostAddr1']=''; } echo ' - ', _('Postal Address 1 (Street)'), ': + ' . _('Postal Address 1 (Street)') . ': '; - if(!isset($_POST['BrPostAddr2'])) {// Postal address, line 2. Database: custbranch.brpostaddr2, varchar(40) + if (!isset($_POST['BrPostAddr2'])){// Postal address, line 2. Database: custbranch.brpostaddr2, varchar(40) $_POST['BrPostAddr2']=''; } echo ' - ', _('Postal Address 2 (Suburb/City)'), ': + ' , _('Postal Address 2 (Suburb/City)'), ': '; - if(!isset($_POST['BrPostAddr3'])) {// Postal address, line 3. Database: custbranch.brpostaddr3, varchar(40) + if (!isset($_POST['BrPostAddr3'])) {// Postal address, line 3. Database: custbranch.brpostaddr3, varchar(40) $_POST['BrPostAddr3']=''; } echo ' @@ -966,7 +966,7 @@ '; - if(!isset($_POST['BrPostAddr4'])) {// Postal address, line 4. Database: custbranch.brpostaddr4, varchar(40) + if (!isset($_POST['BrPostAddr4'])) {// Postal address, line 4. Database: custbranch.brpostaddr4, varchar(40) $_POST['BrPostAddr4']=''; } echo ' @@ -974,7 +974,7 @@ '; - if(!isset($_POST['BrPostAddr5'])) {// Postal address, line 5. Database: custbranch.brpostaddr5, varchar(20) + if (!isset($_POST['BrPostAddr5'])) {// Postal address, line 5. Database: custbranch.brpostaddr5, varchar(20) $_POST['BrPostAddr5']=''; } echo ' @@ -1000,4 +1000,4 @@ }//end if record deleted no point displaying form to add record include('includes/footer.inc'); -?> \ No newline at end of file +?>