From: <tim...@us...> - 2010-01-25 16:50:39
|
Revision: 3325 http://web-erp.svn.sourceforge.net/web-erp/?rev=3325&view=rev Author: tim_schofield Date: 2010-01-25 16:50:32 +0000 (Mon, 25 Jan 2010) Log Message: ----------- Paul Thursby: Simplify and shorten the code for wildcard selection criteria Modified Paths: -------------- trunk/BOMInquiry.php trunk/BOMs.php trunk/CustomerReceipt.php trunk/MRPDemands.php trunk/PO_Header.php trunk/PO_Items.php trunk/PO_SelectOSPurchOrder.php trunk/PO_SelectPurchOrder.php trunk/PurchData.php trunk/SelectCompletedOrder.php trunk/SelectCreditItems.php trunk/SelectCustomer.php trunk/SelectGLAccount.php trunk/SelectOrderItems.php trunk/SelectProduct.php trunk/SelectSalesOrder.php trunk/SelectSupplier.php trunk/SelectWorkOrder.php trunk/Shipt_Select.php trunk/WorkOrderEntry.php trunk/WorkOrderIssue.php trunk/doc/Change.log.html Modified: trunk/BOMInquiry.php =================================================================== --- trunk/BOMInquiry.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/BOMInquiry.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -39,17 +39,8 @@ } else { if (strlen($_POST['Keywords'])>0) { //insert wildcard characters in spaces + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; - $i=0; - $SearchString = '%'; - while (strpos($_POST['Keywords'], ' ', $i)) { - $wrdlen=strpos($_POST['Keywords'],' ',$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . '%'; - $i=strpos($_POST['Keywords'],' ',$i) +1; - } - $SearchString = $SearchString. substr($_POST['Keywords'],$i).'%'; - - $sql = "SELECT stockmaster.stockid, stockmaster.description, stockmaster.units, Modified: trunk/BOMs.php =================================================================== --- trunk/BOMs.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/BOMs.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -741,17 +741,8 @@ } else { If (strlen($_POST['Keywords'])>0) { //insert wildcard characters in spaces + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; - $i=0; - $SearchString = '%'; - while (strpos($_POST['Keywords'], ' ', $i)) { - $wrdlen=strpos($_POST['Keywords'],' ',$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . '%'; - $i=strpos($_POST['Keywords'],' ',$i) +1; - } - $SearchString = $SearchString. substr($_POST['Keywords'],$i).'%'; - - $sql = "SELECT stockmaster.stockid, stockmaster.description, stockmaster.units, Modified: trunk/CustomerReceipt.php =================================================================== --- trunk/CustomerReceipt.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/CustomerReceipt.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -514,15 +514,8 @@ } else { if (strlen($_POST['Keywords'])>0) { //insert wildcard characters in spaces - - $i=0; - $SearchString = "%"; - while (strpos($_POST['Keywords'], " ", $i)) { - $wrdlen=strpos($_POST['Keywords']," ",$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . "%"; - $i=strpos($_POST['Keywords']," ",$i) +1; - } - $SearchString = $SearchString . substr($_POST['Keywords'],$i)."%"; + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; + $SQL = "SELECT debtorsmaster.debtorno, debtorsmaster.name FROM debtorsmaster Modified: trunk/MRPDemands.php =================================================================== --- trunk/MRPDemands.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/MRPDemands.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -58,16 +58,8 @@ } else { if (strlen($_POST['Keywords'])>0) { //insert wildcard characters in spaces - - $i=0; - $SearchString = '%'; - while (strpos($_POST['Keywords'], ' ', $i)) { - $wrdlen=strpos($_POST['Keywords'],' ',$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . '%'; - $i=strpos($_POST['Keywords'],' ',$i) +1; - } - $SearchString = $SearchString. substr($_POST['Keywords'],$i).'%'; - + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; + $sql = "SELECT stockmaster.stockid, stockmaster.description FROM stockmaster Modified: trunk/PO_Header.php =================================================================== --- trunk/PO_Header.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/PO_Header.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -414,15 +414,8 @@ } else { if (strlen($_POST['Keywords'])>0) { //insert wildcard characters in spaces - - $i=0; - $SearchString = '%'; - while (strpos($_POST['Keywords'], ' ', $i)) { - $wrdlen=strpos($_POST['Keywords'],' ',$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . '%'; - $i=strpos($_POST['Keywords'],' ',$i) +1; - } - $SearchString = $SearchString. substr($_POST['Keywords'],$i).'%'; + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; + $SQL = "SELECT suppliers.supplierid, suppliers.suppname, suppliers.address1, Modified: trunk/PO_Items.php =================================================================== --- trunk/PO_Items.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/PO_Items.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -412,16 +412,8 @@ } If ($_POST['Keywords']) { //insert wildcard characters in spaces - - $i=0; - $SearchString = '%'; - while (strpos($_POST['Keywords'], ' ', $i)) { - $wrdlen=strpos($_POST['Keywords'],' ',$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . '%'; - $i=strpos($_POST['Keywords'],' ',$i) +1; - } - $SearchString = $SearchString. substr($_POST['Keywords'],$i).'%'; - + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; + if ($_POST['StockCat']=='All'){ $sql = "SELECT stockmaster.stockid, stockmaster.description, Modified: trunk/PO_SelectOSPurchOrder.php =================================================================== --- trunk/PO_SelectOSPurchOrder.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/PO_SelectOSPurchOrder.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -63,15 +63,7 @@ } If ($_POST['Keywords']) { //insert wildcard characters in spaces -// $completed = "purchorderdetails.completed=0 AND "; - $i=0; - $SearchString = '%'; - while (strpos($_POST['Keywords'], ' ', $i)) { - $wrdlen=strpos($_POST['Keywords'],' ',$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . '%'; - $i=strpos($_POST['Keywords'],' ',$i) +1; - } - $SearchString = $SearchString. substr($_POST['Keywords'],$i).'%'; + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; $SQL = "SELECT stockmaster.stockid, stockmaster.description, Modified: trunk/PO_SelectPurchOrder.php =================================================================== --- trunk/PO_SelectPurchOrder.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/PO_SelectPurchOrder.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -59,14 +59,7 @@ } If ($_POST['Keywords']) { //insert wildcard characters in spaces - $i=0; - $SearchString = "%"; - while (strpos($_POST['Keywords'], " ", $i)) { - $wrdlen=strpos($_POST['Keywords']," ",$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . "%"; - $i=strpos($_POST['Keywords']," ",$i) +1; - } - $SearchString = $SearchString. substr($_POST['Keywords'],$i)."%"; + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; $SQL = "SELECT stockmaster.stockid, stockmaster.description, Modified: trunk/PurchData.php =================================================================== --- trunk/PurchData.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/PurchData.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -241,15 +241,9 @@ } if (strlen($_POST['Keywords']) > 0) { //insert wildcard characters in spaces - $i = 0; - $SearchString = '%'; - while (strpos($_POST['Keywords'], ' ', $i)) { - $wrdlen = strpos($_POST['Keywords'], ' ', $i) -$i; - $SearchString = $SearchString . substr($_POST['Keywords'], $i, $wrdlen) . '%'; - $i = strpos($_POST['Keywords'], ' ', $i) +1; - } - $SearchString = $SearchString . substr($_POST['Keywords'], $i) . '%'; - $SQL = "SELECT suppliers.supplierid, + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; + + $SQL = "SELECT suppliers.supplierid, suppliers.suppname, suppliers.currcode, suppliers.address1, Modified: trunk/SelectCompletedOrder.php =================================================================== --- trunk/SelectCompletedOrder.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/SelectCompletedOrder.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -84,15 +84,7 @@ } if ($_POST['Keywords']!='') { //insert wildcard characters in spaces - - $i=0; - $SearchString = '%'; - while (strpos($_POST['Keywords'], ' ', $i)) { - $wrdlen=strpos($_POST['Keywords'],' ',$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . '%'; - $i=strpos($_POST['Keywords'],' ',$i) +1; - } - $SearchString = $SearchString. substr($_POST['Keywords'],$i).'%'; + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; if (isset($_POST['completed'])) { $SQL = "SELECT stockmaster.stockid, Modified: trunk/SelectCreditItems.php =================================================================== --- trunk/SelectCreditItems.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/SelectCreditItems.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -70,17 +70,9 @@ } else { If (strlen($_POST['Keywords'])>0) { //insert wildcard characters in spaces - $msg=''; - $i=0; - $SearchString = '%'; - while (strpos($_POST['Keywords'], ' ', $i)) { - $wrdlen=strpos($_POST['Keywords'],' ',$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . '%'; - $i=strpos($_POST['Keywords'],' ',$i) +1; - } - $SearchString = $SearchString. substr($_POST['Keywords'],$i).'%'; + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; + $msg=''; - $SQL = 'SELECT custbranch.debtorno, custbranch.brname, @@ -288,16 +280,8 @@ If ($_POST['Keywords']!="") { //insert wildcard characters in spaces - - $i=0; - $SearchString = '%'; - while (strpos($_POST['Keywords'], ' ', $i)) { - $wrdlen=strpos($_POST['Keywords'],' ',$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . '%'; - $i=strpos($_POST['Keywords'],' ',$i) +1; - } - $SearchString = $SearchString. substr($_POST['Keywords'],$i).'%'; - + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; + if ($_POST['StockCat']=='All'){ $SQL = "SELECT stockmaster.stockid, stockmaster.description, Modified: trunk/SelectCustomer.php =================================================================== --- trunk/SelectCustomer.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/SelectCustomer.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -130,17 +130,8 @@ $_POST['Keywords'] = strtoupper(trim($_POST['Keywords'])); //insert wildcard characters in spaces - - $i=0; - $SearchString = "%"; - - while (strpos($_POST['Keywords'], " ", $i)) { - $wrdlen=strpos($_POST['Keywords']," ",$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . "%"; - $i=strpos($_POST['Keywords']," ",$i) +1; - } - $SearchString = $SearchString . substr($_POST['Keywords'],$i)."%"; - + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; + $SQL = "SELECT debtorsmaster.debtorno, debtorsmaster.name, debtorsmaster.address1, Modified: trunk/SelectGLAccount.php =================================================================== --- trunk/SelectGLAccount.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/SelectGLAccount.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -36,16 +36,8 @@ } else { If (strlen($_POST['Keywords'])>0) { //insert wildcard characters in spaces - - $i=0; - $SearchString = '%'; - while (strpos($_POST['Keywords'], ' ', $i)) { - $wrdlen=strpos($_POST['Keywords'],' ',$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . '%'; - $i=strpos($_POST['Keywords'],' ',$i) +1; - } - $SearchString = $SearchString. substr($_POST['Keywords'],$i) . '%'; - + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; + $SQL = "SELECT chartmaster.accountcode, chartmaster.accountname, chartmaster.group_, Modified: trunk/SelectOrderItems.php =================================================================== --- trunk/SelectOrderItems.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/SelectOrderItems.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -307,14 +307,7 @@ if (strlen($_POST['CustKeywords'])>0) { //insert wildcard characters in spaces $_POST['CustKeywords'] = strtoupper(trim($_POST['CustKeywords'])); - $i=0; - $SearchString = '%'; - while (strpos($_POST['CustKeywords'], ' ', $i)) { - $wrdlen=strpos($_POST['CustKeywords'],' ',$i) - $i; - $SearchString=$SearchString . substr($_POST['CustKeywords'],$i,$wrdlen) . '%'; - $i=strpos($_POST['CustKeywords'],' ',$i) +1; - } - $SearchString = $SearchString. substr($_POST['CustKeywords'],$i).'%'; + $SearchString = '%' . str_replace(' ', '%', $_POST['CustKeywords']) . '%'; $SQL = "SELECT custbranch.brname, custbranch.contactname, @@ -758,16 +751,8 @@ if (isset($_POST['Keywords']) AND strlen($_POST['Keywords'])>0) { //insert wildcard characters in spaces $_POST['Keywords'] = strtoupper($_POST['Keywords']); - - $i=0; - $SearchString = '%'; - while (strpos($_POST['Keywords'], ' ', $i)) { - $wrdlen=strpos($_POST['Keywords'],' ',$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . '%'; - $i=strpos($_POST['Keywords'],' ',$i) +1; - } - $SearchString = $SearchString. substr($_POST['Keywords'],$i).'%'; - + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; + if ($_POST['StockCat']=='All'){ $SQL = "SELECT stockmaster.stockid, stockmaster.description, Modified: trunk/SelectProduct.php =================================================================== --- trunk/SelectProduct.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/SelectProduct.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -118,14 +118,7 @@ if ($_POST['Keywords']) { //insert wildcard characters in spaces $_POST['Keywords'] = strtoupper($_POST['Keywords']); - $i = 0; - $SearchString = '%'; - while (strpos($_POST['Keywords'], ' ', $i)) { - $wrdlen = strpos($_POST['Keywords'], ' ', $i) - $i; - $SearchString = $SearchString . substr($_POST['Keywords'], $i, $wrdlen) . '%'; - $i = strpos($_POST['Keywords'], ' ', $i) + 1; - } - $SearchString = $SearchString. substr($_POST['Keywords'], $i) . '%'; + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; if ($_POST['StockCat'] == 'All'){ $SQL = "SELECT stockmaster.stockid, Modified: trunk/SelectSalesOrder.php =================================================================== --- trunk/SelectSalesOrder.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/SelectSalesOrder.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -46,14 +46,7 @@ } if ($_POST['Keywords']) { //insert wildcard characters in spaces - $i=0; - $SearchString = '%'; - while (strpos($_POST['Keywords'], ' ', $i)) { - $wrdlen=strpos($_POST['Keywords'],' ',$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . '%'; - $i=strpos($_POST['Keywords'],' ',$i) +1; - } - $SearchString = $SearchString . substr($_POST['Keywords'],$i).'%'; + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; $SQL = "SELECT stockmaster.stockid, stockmaster.description, Modified: trunk/SelectSupplier.php =================================================================== --- trunk/SelectSupplier.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/SelectSupplier.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -112,16 +112,8 @@ $_POST['Keywords'] = strtoupper($_POST['Keywords']); //insert wildcard characters in spaces - - $i=0; - $SearchString = '%'; - while (strpos($_POST['Keywords'], ' ', $i)) { - $wrdlen=strpos($_POST['Keywords'],' ',$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . '%'; - $i=strpos($_POST['Keywords'],' ',$i) +1; - } - $SearchString = $SearchString. substr($_POST['Keywords'],$i).'%'; - + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; + $SQL = "SELECT supplierid, suppname, currcode, Modified: trunk/SelectWorkOrder.php =================================================================== --- trunk/SelectWorkOrder.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/SelectWorkOrder.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -39,14 +39,7 @@ } If ($_POST['Keywords']) { //insert wildcard characters in spaces - $i=0; - $SearchString = '%'; - while (strpos($_POST['Keywords'], ' ', $i)) { - $wrdlen=strpos($_POST['Keywords'],' ',$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . '%'; - $i=strpos($_POST['Keywords'],' ',$i) +1; - } - $SearchString = $SearchString . substr($_POST['Keywords'],$i).'%'; + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; $SQL = "SELECT stockmaster.stockid, stockmaster.description, Modified: trunk/Shipt_Select.php =================================================================== --- trunk/Shipt_Select.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/Shipt_Select.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -70,14 +70,7 @@ If ($_POST['Keywords']) { //insert wildcard characters in spaces - $i=0; - $SearchString = '%'; - while (strpos($_POST['Keywords'], ' ', $i)) { - $wrdlen=strpos($_POST['Keywords'],' ',$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . '%'; - $i=strpos($_POST['Keywords'],' ',$i) +1; - } - $SearchString = $SearchString. substr($_POST['Keywords'],$i).'%'; + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; $SQL .= " WHERE purchorderdetails.shiptref IS NOT NULL AND purchorderdetails.shiptref<>0 Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/WorkOrderEntry.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -43,16 +43,8 @@ If (strlen($_POST['Keywords'])>0) { //insert wildcard characters in spaces $_POST['Keywords'] = strtoupper($_POST['Keywords']); - - $i=0; - $SearchString = '%'; - while (strpos($_POST['Keywords'], ' ', $i)) { - $wrdlen=strpos($_POST['Keywords'],' ',$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . '%'; - $i=strpos($_POST['Keywords'],' ',$i) +1; - } - $SearchString = $SearchString. substr($_POST['Keywords'],$i).'%'; - + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; + if ($_POST['StockCat']=='All'){ $SQL = "SELECT stockmaster.stockid, stockmaster.description, Modified: trunk/WorkOrderIssue.php =================================================================== --- trunk/WorkOrderIssue.php 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/WorkOrderIssue.php 2010-01-25 16:50:32 UTC (rev 3325) @@ -372,16 +372,8 @@ If (strlen($_POST['Keywords'])>0) { //insert wildcard characters in spaces $_POST['Keywords'] = strtoupper($_POST['Keywords']); - - $i=0; - $SearchString = '%'; - while (strpos($_POST['Keywords'], ' ', $i)) { - $wrdlen=strpos($_POST['Keywords'],' ',$i) - $i; - $SearchString=$SearchString . substr($_POST['Keywords'],$i,$wrdlen) . '%'; - $i=strpos($_POST['Keywords'],' ',$i) +1; - } - $SearchString = $SearchString. substr($_POST['Keywords'],$i).'%'; - + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; + if ($_POST['StockCat']=='All'){ $SQL = "SELECT stockmaster.stockid, stockmaster.description, Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-01-25 10:41:16 UTC (rev 3324) +++ trunk/doc/Change.log.html 2010-01-25 16:50:32 UTC (rev 3325) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>25/01/10 Paul Thursby: Simplify and shorten the code for wildcard selection criteria</p> <p>25/01/10 Lindsay: api_xml-rpc.php - API now in 2 styles: name/password not required after login</p> <p>24/01/10 Harald: api_xml-rpc.php - Typo correction in string</p> <p>24/01/10 Harald: api_xml-rpc.php - Typo correction in string</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |