From: <dai...@us...> - 2010-06-04 11:10:59
|
Revision: 3478 http://web-erp.svn.sourceforge.net/web-erp/?rev=3478&view=rev Author: daintree Date: 2010-06-04 11:10:53 +0000 (Fri, 04 Jun 2010) Log Message: ----------- Otandeka changes to CounterSales.php and Locations.php to use explode to parse the debtorno-branchcode from the new field in locations. Also changed to remove spaces requirements in the format of entry of this field. Phil: added error checking to CounterSales.php and more useful message if defaultcashsales not entered for the users location Modified Paths: -------------- trunk/CounterSales.php trunk/Locations.php trunk/doc/Change.log.html trunk/sql/mysql/weberp-demo.sql Modified: trunk/CounterSales.php =================================================================== --- trunk/CounterSales.php 2010-05-30 05:53:40 UTC (rev 3477) +++ trunk/CounterSales.php 2010-06-04 11:10:53 UTC (rev 3478) @@ -65,21 +65,30 @@ $_SESSION['Items'.$identifier] = new cart; $_SESSION['PrintedPackingSlip'] = 0; /*Of course 'cos the order ain't even started !!*/ /*Get the default customer-branch combo from the user's default location record */ - $result = DB_query("SELECT cashsalecustomer, + $sql = "SELECT cashsalecustomer, locationname, taxprovinceid FROM locations - WHERE loccode='" . $_SESSION['UserStockLocation'] . "'",$db); + WHERE loccode='" . $_SESSION['UserStockLocation'] ."'"; + $result = DB_query($sql,$db); if (DB_num_rows($result)==0) { prnMsg(_('Your user account does not have a valid default inventory location set up. Please see the system administrator to modify your user account.'),'error'); include('includes/footer.inc'); exit; } else { $myrow = DB_fetch_array($result); //get the only row returned - $_SESSION['Items'.$identifier]->Branch = substr($myrow['cashsalecustomer'],strpos($myrow['cashsalecustomer'],' - ')+3); - - $_SESSION['Items'.$identifier]->DebtorNo = substr($myrow['cashsalecustomer'],0,strpos($myrow['cashsalecustomer'],' - ')); - $_SESSION['Items'.$identifier]->LocationName = $myrow['locationname']; + + if ($myrow['cashsalecustomer']==''){ + prnMsg(_('To use this script it is first necessary to define a cash sales customer for the location that is your default location. The default cash sale customer is defined under set up ->Inventory Locations Maintenance. The customer should be entered using the customer code a hypen then the branch code of the customer to use.'),'error'); + include('includes/footer.inc'); + exit; + } + + $CashSaleCustomer = explode('-',$myrow['cashsalecustomer']); + + $_SESSION['Items'.$identifier]->Branch = $CashSaleCustomer[0]; + $_SESSION['Items'.$identifier]->DebtorNo = $CashSaleCustomer[1]; + $_SESSION['Items'.$identifier]->LocationName = $myrow['locationname']; $_SESSION['Items'.$identifier]->Location = $_SESSION['UserStockLocation']; $_SESSION['Items'.$identifier]->DispatchTaxProvince = $myrow['taxprovinceid']; @@ -102,6 +111,7 @@ $ErrMsg = _('The details of the customer selected') . ': ' . $_SESSION['Items'.$identifier]->DebtorNo . ' ' . _('cannot be retrieved because'); $DbgMsg = _('The SQL used to retrieve the customer details and failed was') . ':'; + // echo $sql; $result =DB_query($sql,$db,$ErrMsg,$DbgMsg); $myrow = DB_fetch_row($result); @@ -2251,8 +2261,8 @@ /* Do not display colum unless customer requires po line number by sales order line*/ echo '<td><input type="text" name="part_' . $i . '" size=21 maxlength=20></td> <td><input type="text" name="qty_' . $i . '" size=6 maxlength=6></td> - <td><input type="hidden" class="date" name="itemdue_' . $i . '" - value="' . $DefaultDeliveryDate . '"></td></tr>'; + <input type="hidden" class="date" name="itemdue_' . $i . '" + value="' . $DefaultDeliveryDate . '"></tr>'; } echo '<script type="text/javascript">if (document.SelectParts) {defaultControl(document.SelectParts.part_1);}</script>'; @@ -2266,4 +2276,4 @@ } echo '</form>'; include('includes/footer.inc'); -?> \ No newline at end of file +?> Modified: trunk/Locations.php =================================================================== --- trunk/Locations.php 2010-05-30 05:53:40 UTC (rev 3477) +++ trunk/Locations.php 2010-06-04 11:10:53 UTC (rev 3478) @@ -31,15 +31,20 @@ prnMsg( _('The location code may not be empty'), 'error'); } if ($_POST['CashSaleCustomer']!=''){ - if (!strstr($_POST['CashSaleCustomer'],' - ')){ + if (!strstr($_POST['CashSaleCustomer'],'-')){ $InputError =1; - prnMsg(_('The cash sale customer account must be a valid customer account separated by " - " then the branch code of the customer entered'), 'error'); + prnMsg(_('The cash sale customers '.$_POST['CashSaleCustomer'].' account must be a valid customer account separated by " - " then the branch code of the customer entered'), 'error'); } else { - $Branch = substr($_POST['CashSaleCustomer'],strpos($_POST['CashSaleCustomer'],' - ')+3); - $DebtorNo = substr($_POST['CashSaleCustomer'],0,strpos($_POST['CashSaleCustomer'],' - ')); + // $Branch = substr($_POST['CashSaleCustomer'],strpos($_POST['CashSaleCustomer'],' - ')+3); + // $DebtorNo = substr($_POST['CashSaleCustomer'],0,strpos($_POST['CashSaleCustomer'],' - ')); + $arr = explode('-',$_POST['CashSaleCustomer']); + $DebtorNo = $arr[0]; + $Branch = $arr[1]; + $sql = "SELECT * FROM custbranch WHERE debtorno='" . $DebtorNo . "' - AND branchcode='" . $Branch . "'"; - + AND branchcode='" . $Branch . "'"; + + // echo $sql; $result = DB_query($sql,$db); if (DB_num_rows($result)==0){ $InputError = 1; @@ -556,4 +561,4 @@ <?php } //end if record deleted no point displaying form to add record include('includes/footer.inc'); -?> \ No newline at end of file +?> Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-30 05:53:40 UTC (rev 3477) +++ trunk/doc/Change.log.html 2010-06-04 11:10:53 UTC (rev 3478) @@ -1,5 +1,8 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>03/06/10 Phil: Added a bit of error trapping to ensure customer/branch set up when going into CounterSales.php +<p>03/06/10 Otandeka: Locations.php used explode function rather than substr function to split the cashsalecustomer to get Branch and Debtorno codes - also changed format to just a hypen between debtorno and branchcode</p> +<p>03/06/10 Otandeka: CounterSales php changed to use explode to get branch and debtorno from cashsalecustomer - and changed format to debtorno-branchcode and rather than debtorno - branchcode (spaces removed)</p> <p>31/5/10 Phil: BankMatching script took out double quotes reformated indenting - a hard one to read - my bad!</p> <p>31/5/10 Phil: New script CounterSales.php to allow entry of sale and payment over the counter as a half way step to POS - the customer account is defaulted based on the users default stock location. The locations table now has a default cash sales account - see below</p> <p>28/5/10 Phil: New field in locations table to allow a default cash sales account to be setup by location -modifications to Locations.php to allow it to be entered and error-trapping for debtor - branch format required for specification. This will be used in a new CounterSales.php script I am working on</p> Modified: trunk/sql/mysql/weberp-demo.sql =================================================================== --- trunk/sql/mysql/weberp-demo.sql 2010-05-30 05:53:40 UTC (rev 3477) +++ trunk/sql/mysql/weberp-demo.sql 2010-06-04 11:10:53 UTC (rev 3478) @@ -1,5 +1,5 @@ -CREATE DATABASE IF NOT EXISTS weberpdemo DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; -USE weberpdemo; +CREATE DATABASE IF NOT EXISTS weberp DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; +USE weberp; SET FOREIGN_KEY_CHECKS=0; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |