[Weberp-svn] SF.net SVN: weberp:[8976] trunk
Brought to you by:
sotandeka,
tim_schofield
From: <tim...@us...> - 2012-05-30 21:10:50
|
Revision: 8976 http://weberp.svn.sourceforge.net/weberp/?rev=8976&view=rev Author: tim_schofield Date: 2012-05-30 21:10:44 +0000 (Wed, 30 May 2012) Log Message: ----------- Generalisation of stock item search functionality Modified Paths: -------------- trunk/CounterSales.php trunk/includes/ItemSearch.php trunk/includes/ItemShowSearch.php Modified: trunk/CounterSales.php =================================================================== --- trunk/CounterSales.php 2012-05-30 19:22:17 UTC (rev 8975) +++ trunk/CounterSales.php 2012-05-30 21:10:44 UTC (rev 8976) @@ -1911,7 +1911,7 @@ /* Now show the stock item selection search stuff below */ if (isset($_POST['PartSearch'])){ - ShowItemSearchFields($rootpath, $theme, $db, $identifier); + ShowItemSearchFields($rootpath, $theme, $db, $identifier, array('A', 'K', 'M', 'B', 'D'), array('F', 'D'), 'Search'); } echo '<br /></form>'; Modified: trunk/includes/ItemSearch.php =================================================================== --- trunk/includes/ItemSearch.php 2012-05-30 19:22:17 UTC (rev 8975) +++ trunk/includes/ItemSearch.php 2012-05-30 21:10:44 UTC (rev 8976) @@ -2,7 +2,7 @@ echo '<script type="text/javascript" src = "'.$rootpath.'/javascripts/ItemSearch.js"></script>'; -function ShowItemSearchFields($rootpath, $theme, $db, $identifier) { +function ShowItemSearchFields($rootpath, $theme, $db, $identifier, $MBFlags, $StockTypes, $SearchOrSelect) { $PathPrefix=$_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF']) . '/'; echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/magnifier.png" title="' . _('Search') . '" alt="" />' . ' ' . _('Search for Items') . '</p>'; @@ -15,7 +15,7 @@ echo '<table class="selection" width="98%"> <tr> <td><b>' . _('Select a Stock Category') . ': </b></td> - <td><select tabindex="1" name="StockCat" onchange="ShowItems(this.value, StockCode.value, Keywords.value, MaxItems.value,' . $identifier . ')">'; + <td><select tabindex="1" name="StockCat" onchange="ShowItems(\'' . $SearchOrSelect . '\', this.value, StockCode.value, Keywords.value, MaxItems.value,' . $identifier . ')">'; if (!isset($_POST['Keywords'])) { $_POST['Keywords']=''; @@ -47,16 +47,16 @@ echo '</select></td></tr> <tr> <td><b>' . _('Enter partial Description') . ':</b></td> - <td><input tabindex="2" type="text" name="Keywords" size="20" maxlength="25" value="' . $_POST['Keywords'] . '" onkeyup="ShowItems(StockCat.value, StockCode.value, Keywords.value, MaxItems.value,' . $identifier . ')" /></td> + <td><input tabindex="2" type="text" name="Keywords" size="20" maxlength="25" value="' . $_POST['Keywords'] . '" onkeyup="ShowItems(\'' . $SearchOrSelect . '\', StockCat.value, StockCode.value, Keywords.value, MaxItems.value,' . $identifier . ')" /></td> </tr> <tr> <td><b>' . _('OR') . ' ' . _('Enter extract of the Stock Code') . ':</b></td> - <td><input tabindex="3" type="text" name="StockCode" size="15" maxlength="18" value="' . $_POST['StockCode'] . '" onkeyup="ShowItems(StockCat.value, StockCode.value, Keywords.value, MaxItems.value,' . $identifier . ')" /></td> + <td><input tabindex="3" type="text" name="StockCode" size="15" maxlength="18" value="' . $_POST['StockCode'] . '" onkeyup="ShowItems(\'' . $SearchOrSelect . '\', StockCat.value, StockCode.value, Keywords.value, MaxItems.value,' . $identifier . ')" /></td> </tr> <tr> <td><b>' . _('Maximum number of Items to Show') . ':</b></td> <td> - <select name="MaxItems" onchange="ShowItems(StockCat.value, StockCode.value, Keywords.value, MaxItems.value,' . $identifier . ')"> + <select name="MaxItems" onchange="ShowItems(\'' . $SearchOrSelect . '\', StockCat.value, StockCode.value, Keywords.value, MaxItems.value,' . $identifier . ')"> <option value="10">10</option> <option value="20">20</option> <option value="30">30</option> @@ -79,7 +79,26 @@ /* Search Results*/ echo '<td width="67%" valign="top">'; - include('includes/ItemShowSearch.php'); + + unset($_SESSION['MBFlagSQL']); + unset($_SESSION['StockTypesSQL']); + $MBFlagSQL=" AND ("; + foreach ($MBFlags as $MBFlag) { + $MBFlagSQL .= "stockmaster.mbflag='".$MBFlag."' OR "; + } + $_SESSION['MBFlagSQL']=mb_substr($MBFlagSQL, 0, mb_strlen($MBFlagSQL)-3).")"; + + $StockTypesSQL=" ("; + foreach ($StockTypes as $StockType) { + $StockTypesSQL .= "stockcategory.stocktype='".$StockType."' OR "; + } + $_SESSION['StockTypesSQL']=mb_substr($StockTypesSQL, 0, mb_strlen($StockTypesSQL)-3).") "; + + if ($SearchOrSelect=='Search') { + include('includes/ItemShowSearch.php'); + } else { + include('includes/ItemShowSelect.php'); + } echo '</td> </tr> </table>'; Modified: trunk/includes/ItemShowSearch.php =================================================================== --- trunk/includes/ItemShowSearch.php 2012-05-30 19:22:17 UTC (rev 8975) +++ trunk/includes/ItemShowSearch.php 2012-05-30 21:10:44 UTC (rev 8976) @@ -48,8 +48,8 @@ FROM stockmaster INNER JOIN stockcategory ON stockmaster.categoryid=stockcategory.categoryid - WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') - AND stockmaster.mbflag <>'G' + WHERE ".$_SESSION['StockTypesSQL']." + ".$_SESSION['MBFlagSQL']." AND stockmaster.discontinued=0 AND stockmaster.categoryid like '".$Category."' AND stockmaster.description like '%".$Description."%' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |