From: <dai...@us...> - 2011-09-03 11:08:04
|
Revision: 4675 http://web-erp.svn.sourceforge.net/web-erp/?rev=4675&view=rev Author: daintree Date: 2011-09-03 11:07:57 +0000 (Sat, 03 Sep 2011) Log Message: ----------- 3/9/11 Ricard: Changed SelectProduct.php to show just current prices 3/9/11 Phil: Changed SelectCustomer to use %% around each parameter to use just a single SQL statement rather than several which ignored other inputs - as suggested by Marcos Skambraks Modified Paths: -------------- trunk/AccountGroups.php trunk/GLTransInquiry.php trunk/SelectCustomer.php trunk/SelectProduct.php trunk/Stocks.php trunk/doc/Change.log trunk/includes/LanguageSetup.php trunk/includes/MiscFunctions.php trunk/includes/SQL_CommonFunctions.inc trunk/javascripts/MiscFunctions.js Modified: trunk/AccountGroups.php =================================================================== --- trunk/AccountGroups.php 2011-09-02 10:38:54 UTC (rev 4674) +++ trunk/AccountGroups.php 2011-09-03 11:07:57 UTC (rev 4675) @@ -18,7 +18,9 @@ $DbgMsg = _('The SQL that was used to retrieve the account groups of the parent account group and that failed in the process was'); do { - $sql = "SELECT parentgroupname FROM accountgroups WHERE groupname='" . $GroupName ."'"; + $sql = "SELECT parentgroupname + FROM accountgroups + WHERE groupname='" . $GroupName ."'"; $result = DB_query($sql,$db,$ErrMsg,$DbgMsg); $myrow = DB_fetch_row($result); Modified: trunk/GLTransInquiry.php =================================================================== --- trunk/GLTransInquiry.php 2011-09-02 10:38:54 UTC (rev 4674) +++ trunk/GLTransInquiry.php 2011-09-03 11:07:57 UTC (rev 4675) @@ -55,12 +55,11 @@ gltrans.posted, chartmaster.accountname, periods.lastdate_in_period - FROM gltrans, - chartmaster, - periods - WHERE gltrans.account = chartmaster.accountcode - AND periods.periodno=gltrans.periodno - AND gltrans.type= '" . $_GET['TypeID'] . "' + FROM gltrans INNER JOIN chartmaster + ON gltrans.account = chartmaster.accountcode + INNER JOIN periods + ON periods.periodno=gltrans.periodno + WHERE gltrans.type= '" . $_GET['TypeID'] . "' AND gltrans.typeno = '" . $_GET['TransNo'] . "' ORDER BY gltrans.counterindex"; $TransResult = DB_query($SQL,$db); @@ -142,21 +141,21 @@ if ($DetailResult) { while ( $DetailRow = DB_fetch_row($DetailResult) ) { if ( $TransRow['amount'] > 0){ - if ($TransRow['account'] == $_SESSION['CompanyRecord']['debtorsact']) { - $Debit = locale_number_format(($DetailRow[1] + $DetailRow[2]) / $DetailRow[3],$_SESSION['CompanyRecord']['decimalplaces']); - $Credit = ' '; - } else { - $Debit = locale_number_format((-$DetailRow[1] - $DetailRow[2]) / $DetailRow[3],$_SESSION['CompanyRecord']['decimalplaces']); - $Credit = ' '; - } + if ($TransRow['account'] == $_SESSION['CompanyRecord']['debtorsact']) { + $Debit = locale_number_format(($DetailRow[1] + $DetailRow[2]) / $DetailRow[3],$_SESSION['CompanyRecord']['decimalplaces']); + $Credit = ' '; + } else { + $Debit = locale_number_format((-$DetailRow[1] - $DetailRow[2]) / $DetailRow[3],$_SESSION['CompanyRecord']['decimalplaces']); + $Credit = ' '; + } } else { - if ($TransRow['account'] == $_SESSION['CompanyRecord']['debtorsact']) { - $Credit = locale_number_format(-($DetailRow[1] + $DetailRow[2]) / $DetailRow[3],$_SESSION['CompanyRecord']['decimalplaces']); - $Debit = ' '; - } else { - $Credit = locale_number_format(($DetailRow[1] + $DetailRow[2]) / $DetailRow[3],$_SESSION['CompanyRecord']['decimalplaces']); - $Debit = ' '; - } + if ($TransRow['account'] == $_SESSION['CompanyRecord']['debtorsact']) { + $Credit = locale_number_format(-($DetailRow[1] + $DetailRow[2]) / $DetailRow[3],$_SESSION['CompanyRecord']['decimalplaces']); + $Debit = ' '; + } else { + $Credit = locale_number_format(($DetailRow[1] + $DetailRow[2]) / $DetailRow[3],$_SESSION['CompanyRecord']['decimalplaces']); + $Debit = ' '; + } } if ($j==1) { Modified: trunk/SelectCustomer.php =================================================================== --- trunk/SelectCustomer.php 2011-09-02 10:38:54 UTC (rev 4674) +++ trunk/SelectCustomer.php 2011-09-03 11:07:57 UTC (rev 4675) @@ -86,24 +86,12 @@ } } if (isset($_POST['Search']) OR isset($_POST['CSV']) OR isset($_POST['Go']) OR isset($_POST['Next']) OR isset($_POST['Previous'])) { + unset($_POST['JustSelectedACustomer']); if (isset($_POST['Search'])) { $_POST['PageOffset'] = 1; } - if (mb_strlen($_POST['Keywords'])>0) { - $msg = _('Search Result: Customer Name has been used in search') . '<br />'; - $_POST['Keywords'] = mb_strtoupper($_POST['Keywords']); - } elseif (mb_strlen($_POST['CustCode'])>0) { - $msg = _('Search Result: Customer Code has been used in search') . '<br />'; - } elseif (mb_strlen($_POST['CustPhone'])>0) { - $msg = _('Search Result: Customer Phone has been used in search') . '<br />'; - }elseif (($_POST['CustAdd'])) { - $msg = _('Search Result: Customer Address has been used in search') . '<br />'; - } elseif (isset($_POST['CustType']) AND $_POST['CustType']!='ALL') { - $msg = _('Search Result: Customer Type has been used in search') . '<br />'; - } elseif (isset($_POST['Area']) AND $_POST['Area']!='ALL') { - $msg = _('Search Result: Customer branch area has been used in search') . '<br />'; - } - if (($_POST['Keywords'] == '') AND ($_POST['CustCode'] == '') AND ($_POST['CustPhone'] == '') AND ($_POST['CustType'] == 'ALL') AND ($_POST['Area'] == 'ALL') AND ($_POST['CustAdd'] == '')) { + + if (($_POST['Keywords'] == '') AND ($_POST['CustCode'] == '') AND ($_POST['CustPhone'] == '') AND ( $_POST['CustType'] == 'ALL') AND ($_POST['Area'] == 'ALL') AND ($_POST['CustAdd'] == '')) { //no criteria set then default to all customers $SQL = "SELECT debtorsmaster.debtorno, debtorsmaster.name, @@ -122,12 +110,11 @@ INNER JOIN debtortype ON debtorsmaster.typeid = debtortype.typeid"; } else { - if (mb_strlen($_POST['Keywords']) > 0) { - //using the customer name - $_POST['Keywords'] = mb_strtoupper(trim($_POST['Keywords'])); - //insert wildcard characters in spaces - $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; - $SQL = "SELECT debtorsmaster.debtorno, + $SearchKeywords = mb_strtoupper(trim(str_replace(' ', '%', $_POST['Keywords']))); + $_POST['CustCode'] = mb_strtoupper(trim($_POST['CustCode'])); + $_POST['CustPhone'] = trim($_POST['CustPhone']); + $_POST['CustAdd'] = trim($_POST['CustAdd']); + $SQL = "SELECT debtorsmaster.debtorno, debtorsmaster.name, debtorsmaster.address1, debtorsmaster.address2, @@ -139,103 +126,23 @@ debtortype.typename, custbranch.phoneno, custbranch.faxno - FROM debtorsmaster LEFT JOIN custbranch - ON debtorsmaster.debtorno = custbranch.debtorno, debtortype - WHERE debtorsmaster.name " . LIKE . " '" . $SearchString . "' - AND debtorsmaster.typeid = debtortype.typeid"; - } elseif (mb_strlen($_POST['CustCode']) > 0) { - $_POST['CustCode'] = mb_strtoupper(trim($_POST['CustCode'])); - $SQL = "SELECT debtorsmaster.debtorno, - debtorsmaster.name, - debtorsmaster.address1, - debtorsmaster.address2, - debtorsmaster.address3, - debtorsmaster.address4, - custbranch.branchcode, - custbranch.brname, - custbranch.contactname, - debtortype.typename, - custbranch.phoneno, - custbranch.faxno - FROM debtorsmaster LEFT JOIN custbranch - ON debtorsmaster.debtorno = custbranch.debtorno, debtortype - WHERE debtorsmaster.debtorno " . LIKE . " '%" . $_POST['CustCode'] . "%' - AND debtorsmaster.typeid = debtortype.typeid"; - } elseif (mb_strlen($_POST['CustPhone']) > 0) { - $SQL = "SELECT debtorsmaster.debtorno, - debtorsmaster.name, - debtorsmaster.address1, - debtorsmaster.address2, - debtorsmaster.address3, - debtorsmaster.address4, - custbranch.branchcode, - custbranch.brname, - custbranch.contactname, - debtortype.typename, - custbranch.phoneno, - custbranch.faxno - FROM debtorsmaster LEFT JOIN custbranch - ON debtorsmaster.debtorno = custbranch.debtorno, debtortype - WHERE custbranch.phoneno " . LIKE . " '%" . $_POST['CustPhone'] . "%' - AND debtorsmaster.typeid = debtortype.typeid"; - // Added an option to search by address. I tried having it search address1, address2, address3, and address4, but my knowledge of MYSQL is limited. This will work okay if you select the CSV Format then you can search though the address1 field. I would like to extend this to all 4 address fields. Gilles Deacur - - } elseif (mb_strlen($_POST['CustAdd']) > 0) { - $SQL = "SELECT debtorsmaster.debtorno, - debtorsmaster.name, - debtorsmaster.address1, - debtorsmaster.address2, - debtorsmaster.address3, - debtorsmaster.address4, - custbranch.branchcode, - custbranch.brname, - custbranch.contactname, - debtortype.typename, - custbranch.phoneno, - custbranch.faxno - FROM debtorsmaster LEFT JOIN custbranch - ON debtorsmaster.debtorno = custbranch.debtorno, debtortype - WHERE debtorsmaster.address1 " . LIKE . " '%" . $_POST['CustAdd'] . "%' + FROM debtorsmaster INNER JOIN debtortype + ON debtorsmaster.typeid = debtortype.typeid + LEFT JOIN custbranch + ON debtorsmaster.debtorno = custbranch.debtorno + WHERE debtorsmaster.name " . LIKE . " '%" . $SearchKeywords . "%' + AND debtorsmaster.debtorno " . LIKE . " '%" . $_POST['CustCode'] . "%' + AND custbranch.phoneno " . LIKE . " '%" . $_POST['CustPhone'] . "%' + AND (debtorsmaster.address1 " . LIKE . " '%" . $_POST['CustAdd'] . "%' OR debtorsmaster.address2 " . LIKE . " '%" . $_POST['CustAdd'] . "%' OR debtorsmaster.address3 " . LIKE . " '%" . $_POST['CustAdd'] . "%' - OR debtorsmaster.address4 " . LIKE . " '%" . $_POST['CustAdd'] . "%' - AND debtorsmaster.typeid = debtortype.typeid"; - // End added search feature. Gilles Deacur - - } elseif (mb_strlen($_POST['CustType']) > 0 AND $_POST['CustType']!='ALL') { - $SQL = "SELECT debtorsmaster.debtorno, - debtorsmaster.name, - debtorsmaster.address1, - debtorsmaster.address2, - debtorsmaster.address3, - debtorsmaster.address4, - custbranch.branchcode, - custbranch.brname, - custbranch.contactname, - debtortype.typename, - custbranch.phoneno, - custbranch.faxno - FROM debtorsmaster LEFT JOIN custbranch - ON debtorsmaster.debtorno = custbranch.debtorno, debtortype - WHERE debtorsmaster.typeid LIKE debtortype.typeid - AND debtortype.typename = '" . $_POST['CustType'] . "'"; - } elseif (mb_strlen($_POST['Area']) > 0 AND $_POST['Area']!='ALL') { - $SQL = "SELECT debtorsmaster.debtorno, - debtorsmaster.name, - debtorsmaster.address1, - debtorsmaster.address2, - debtorsmaster.address3, - debtorsmaster.address4, - custbranch.branchcode, - custbranch.brname, - custbranch.contactname, - debtortype.typename, - custbranch.phoneno, - custbranch.faxno - FROM debtorsmaster LEFT JOIN custbranch - ON debtorsmaster.debtorno = custbranch.debtorno, debtortype - WHERE debtorsmaster.typeid LIKE debtortype.typeid - AND custbranch.area = '" . $_POST['Area'] . "'"; + OR debtorsmaster.address4 " . LIKE . " '%" . $_POST['CustAdd'] . "%')"; + + if (mb_strlen($_POST['CustType']) > 0 AND $_POST['CustType']!='ALL') { + $SQL .= " AND debtortype.typename = '" . $_POST['CustType'] . "'"; + } + if (mb_strlen($_POST['Area']) > 0 AND $_POST['Area']!='ALL') { + $SQL .= " AND custbranch.area = '" . $_POST['Area'] . "'"; } } //one of keywords or custcode or custphone was more than a zero length string if ($_SESSION['SalesmanLogin'] != '') { @@ -251,6 +158,7 @@ $_SESSION['CustomerID'] = $myrow['debtorno']; $_SESSION['BranchCode'] = $myrow['branchcode']; unset($result); + unset($_POST['Search']); } elseif (DB_num_rows($result) == 0) { prnMsg(_('No customer records contain the selected text') . ' - ' . _('please alter your search criteria and try again'), 'info'); echo '<br />'; @@ -515,8 +423,8 @@ $k = 1; } echo '<td><font size="1"><input type="submit" name="SubmitCustomerSelection' . $i .'" value="' . htmlentities($myrow['debtorno'].' '.$myrow['branchcode'],ENT_QUOTES,'UTF-8') . '" /></font></td> - <input type="hidden" name="SelectedCustomer' . $i .'" value="'.$myrow['debtorno'].'"> - <input type="hidden" name="SelectedBranch' . $i .'" value="'. $myrow['branchcode'].'" /> + <input type="hidden" name="SelectedCustomer' . $i . '" value="'.$myrow['debtorno'].'"> + <input type="hidden" name="SelectedBranch' . $i . '" value="'. $myrow['branchcode'].'" /> <td><font size=1>' . $myrow['name'] . '</font></td> <td><font size=1>' . $myrow['brname'] . '</font></td> <td><font size=1>' . $myrow['contactname'] . '</font></td> @@ -578,10 +486,11 @@ // Extended Customer Info only if selected in Configuration if ($_SESSION['Extended_CustomerInfo'] == 1) { if ($_SESSION['CustomerID'] != '') { - $sql = "SELECT debtortype.typeid, debtortype.typename - FROM debtorsmaster, debtortype - WHERE debtorsmaster.typeid = debtortype.typeid - AND debtorsmaster.debtorno = '" . $_SESSION['CustomerID'] . "'"; + $sql = "SELECT debtortype.typeid, + debtortype.typename + FROM debtorsmaster INNER JOIN debtortype + ON debtorsmaster.typeid = debtortype.typeid + WHERE debtorsmaster.debtorno = '" . $_SESSION['CustomerID'] . "'"; $ErrMsg = _('An error occurred in retrieving the information'); $result = DB_query($sql, $db, $ErrMsg); $myrow = DB_fetch_array($result); Modified: trunk/SelectProduct.php =================================================================== --- trunk/SelectProduct.php 2011-09-02 10:38:54 UTC (rev 4674) +++ trunk/SelectProduct.php 2011-09-03 11:07:57 UTC (rev 4675) @@ -129,7 +129,8 @@ WHERE currabrev ='" . $_SESSION['CompanyRecord']['currencydefault'] . "' AND typeabbrev = '" . $_SESSION['DefaultPriceList'] . "' AND debtorno='' - AND branchcode='' + AND branchcode='' + AND startdate <= '". Date('Y-m-d') ."' AND ( enddate >= '" . Date('Y-m-d') . "' OR enddate = '0000-00-00') AND stockid='" . $StockID . "'", $db); if ($myrow['mbflag'] == 'K' OR $myrow['mbflag'] == 'A') { $CostResult = DB_query("SELECT SUM(bom.quantity * (stockmaster.materialcost+stockmaster.labourcost+stockmaster.overheadcost)) AS cost Modified: trunk/Stocks.php =================================================================== --- trunk/Stocks.php 2011-09-02 10:38:54 UTC (rev 4674) +++ trunk/Stocks.php 2011-09-03 11:07:57 UTC (rev 4675) @@ -1171,7 +1171,7 @@ echo '<input type="submit" name="UpdateCategories" style="visibility:hidden;width:1px" value="' . _('Categories') . '" />'; echo '<p>'; prnMsg( _('Only click the Delete button if you are sure you wish to delete the item!') . _('Checks will be made to ensure that there are no stock movements, sales analysis records, sales order items or purchase order items for the item') . '. ' . _('No deletions will be allowed if they exist'), 'warn', _('WARNING')); - echo '<p><input type="Submit" name="delete" value="' . _('Delete This Item') . '" onclick="return confirm(\'' . _('Are You Sure?') . '\');">'; + echo '<p><input type="submit" name="delete" value="' . _('Delete This Item') . '" onclick="return confirm(\'' . _('Are You Sure?') . '\');">'; } echo '</form></div>'; Modified: trunk/doc/Change.log =================================================================== --- trunk/doc/Change.log 2011-09-02 10:38:54 UTC (rev 4674) +++ trunk/doc/Change.log 2011-09-03 11:07:57 UTC (rev 4675) @@ -1,5 +1,7 @@ webERP Change Log +3/9/11 Ricard: Changed SelectProduct.php to show just current prices +3/9/11 Phil: Changed SelectCustomer to use %% around each parameter to use just a single SQL statement rather than several which ignored other inputs - as suggested by Marcos Skambraks 2/9/11 Phil: Made locale_number_format() as per Tim's instruction that displays numbers in the format of the locale in includes/LanguageSetup.php and replaced all occurrences of number_format() with locale_number_format() 2/9/11 Warren Olds: scaling of image in GetStockImage.php 31/8/11 Ricard: StockAdjustments.php now sends an email to the inventory manager on the creation of manual stock adjustments. The inventory manager email is defined in SystemParameters.php - leaving the email address blank will stop any emails from being created. Modified: trunk/includes/LanguageSetup.php =================================================================== --- trunk/includes/LanguageSetup.php 2011-09-02 10:38:54 UTC (rev 4674) +++ trunk/includes/LanguageSetup.php 2011-09-03 11:07:57 UTC (rev 4675) @@ -37,7 +37,7 @@ if ($_SESSION['Language']=='tr_TR.utf8') { $Locale = setlocale(LC_CTYPE, 'C'); } - + $Locale = setlocale (LC_NUMERIC, 'en_US'); //currently need all decimal points etc to be as expected on webserver // possibly even if locale fails the language will still switch by using Language instead of locale variable @@ -81,7 +81,6 @@ return $text; } } -} - +} ?> \ No newline at end of file Modified: trunk/includes/MiscFunctions.php =================================================================== --- trunk/includes/MiscFunctions.php 2011-09-02 10:38:54 UTC (rev 4674) +++ trunk/includes/MiscFunctions.php 2011-09-03 11:07:57 UTC (rev 4675) @@ -313,7 +313,7 @@ } function locale_number_format($Number, $DecimalPlaces) { - $LocaleInfo = localeconv(); + $LocaleInfo = localeconv(); return number_format($Number, $DecimalPlaces, $LocaleInfo['decimal_point'], $LocaleInfo['thousands_sep']); } Modified: trunk/includes/SQL_CommonFunctions.inc =================================================================== --- trunk/includes/SQL_CommonFunctions.inc 2011-09-02 10:38:54 UTC (rev 4674) +++ trunk/includes/SQL_CommonFunctions.inc 2011-09-03 11:07:57 UTC (rev 4675) @@ -13,7 +13,8 @@ 10 sales invoice 11 sales credit note 12 sales receipt - +etc +* */ DB_query("LOCK TABLES systypes WRITE",$db); Modified: trunk/javascripts/MiscFunctions.js =================================================================== --- trunk/javascripts/MiscFunctions.js 2011-09-02 10:38:54 UTC (rev 4674) +++ trunk/javascripts/MiscFunctions.js 2011-09-03 11:07:57 UTC (rev 4675) @@ -11,7 +11,7 @@ else return true; kC=String.fromCharCode(k); if ((k==null) || (k==0) || (k==8) || (k==9) || (k==13) || (k==27)) return true; - else if ((("0123456789.-").indexOf(kC)>-1)) return true; + else if ((("0123456789.,-").indexOf(kC)>-1)) return true; else return false; } function assignComboToInput(c,i){ @@ -107,8 +107,8 @@ xTR="</tr>"; TD="<td class='dpTD' onMouseOut='this.className=\"dpTD\";' onMouseOver='this.className=\"dpTDHover\";'"; xTD="</td>"; - html="<table class='dpTbl'>"+TR+"<th colspan=3>"+months[tD.getMonth()]+" "+tD.getFullYear()+"</th>"+"<td colspan=2>"+ - getButtonCode(md,tD,-1,"<",dF)+xTD+"<td colspan=2>"+getButtonCode(md,tD,1,">",dF)+xTD+xTR+TR; + html="<table class='dpTbl'>"+TR+"<th colspan=\"3\">"+months[tD.getMonth()]+" "+tD.getFullYear()+"</th>"+"<td colspan=\"2\">"+ + getButtonCode(md,tD,-1,"<",dF)+xTD+"<td colspan=\"2\">"+getButtonCode(md,tD,1,">",dF)+xTD+xTR+TR; for(i=0;i<days.length;i++) html+="<th>"+days[i]+"</th>"; html+=xTR+TR; for (i=0;i<tD.getDay();i++) html+=TD+" "+xTD; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |