[Weberp-svn] SF.net SVN: weberp:[9453] trunk
Brought to you by:
sotandeka,
tim_schofield
From: <tim...@us...> - 2012-07-28 18:11:37
|
Revision: 9453 http://weberp.svn.sourceforge.net/weberp/?rev=9453&view=rev Author: tim_schofield Date: 2012-07-28 18:11:31 +0000 (Sat, 28 Jul 2012) Log Message: ----------- New product search facility Modified Paths: -------------- trunk/SelectSupplier.php Added Paths: ----------- trunk/includes/SupplierSearch.php Modified: trunk/SelectSupplier.php =================================================================== --- trunk/SelectSupplier.php 2012-07-28 18:11:13 UTC (rev 9452) +++ trunk/SelectSupplier.php 2012-07-28 18:11:31 UTC (rev 9453) @@ -11,6 +11,7 @@ if (isset($_GET['SupplierID'])) { $_SESSION['SupplierID']=$_GET['SupplierID']; } + // only get geocode information if integration is on, and supplier has been selected if ($_SESSION['geocode_integration'] == 1 AND isset($_SESSION['SupplierID'])) { $sql = "SELECT geocode_key, @@ -60,16 +61,8 @@ </script> <body onload="load()" onunload="GUnload()" >'; } - -if (!isset($_POST['PageOffset'])) { - $_POST['PageOffset'] = 1; -} else { - if ($_POST['PageOffset'] == 0) { - $_POST['PageOffset'] = 1; - } -} -if (isset($_POST['Select'])) { /*User has hit the button selecting a supplier */ - $_SESSION['SupplierID'] = $_POST['Select']; +if (isset($_POST['ChooseSupplier'])) { /*User has hit the button selecting a supplier */ + $_SESSION['SupplierID'] = $_POST['ChooseSupplier']; unset($_POST['Select']); unset($_POST['Keywords']); unset($_POST['SupplierCode']); @@ -78,60 +71,6 @@ unset($_POST['Next']); unset($_POST['Previous']); } -if (isset($_POST['Search']) OR isset($_POST['Go']) OR isset($_POST['Next']) OR isset($_POST['Previous'])) { - if (mb_strlen($_POST['Keywords']) > 0 AND mb_strlen($_POST['SupplierCode']) > 0) { - prnMsg( '<br />' . _('Supplier name keywords have been used in preference to the Supplier code extract entered'), 'info' ); - } - if ($_POST['Keywords'] == '' AND $_POST['SupplierCode'] == '') { - $SQL = "SELECT supplierid, - suppname, - currcode, - address1, - address2, - address3, - address4 - FROM suppliers - ORDER BY suppname"; - } else { - if (mb_strlen($_POST['Keywords']) > 0) { - $_POST['Keywords'] = mb_strtoupper($_POST['Keywords']); - //insert wildcard characters in spaces - $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; - $SQL = "SELECT supplierid, - suppname, - currcode, - address1, - address2, - address3, - address4 - FROM suppliers - WHERE suppname " . LIKE . " '$SearchString' - ORDER BY suppname"; - } elseif (mb_strlen($_POST['SupplierCode']) > 0) { - $_POST['SupplierCode'] = mb_strtoupper($_POST['SupplierCode']); - $SQL = "SELECT supplierid, - suppname, - currcode, - address1, - address2, - address3, - address4 - FROM suppliers - WHERE supplierid " . LIKE . " '%" . $_POST['SupplierCode'] . "%' - ORDER BY supplierid"; - } - } //one of keywords or SupplierCode was more than a zero length string - $result = DB_query($SQL, $db); - if (DB_num_rows($result) == 1) { - $myrow = DB_fetch_array($result); - $SingleSupplierReturned = $myrow['supplierid']; - } -} //end of if search -if (isset($SingleSupplierReturned)) { /*there was only one supplier returned */ - $_SESSION['SupplierID'] = $SingleSupplierReturned; - unset($_POST['Keywords']); - unset($_POST['SupplierCode']); -} if (isset($_SESSION['SupplierID'])) { $SupplierName = ''; $SQL = "SELECT suppliers.suppname @@ -142,39 +81,44 @@ $myrow = DB_fetch_array($SupplierNameResult); $SupplierName = $myrow['suppname']; } - echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/supplier.png" title="' . _('Supplier') . '" alt="" />' . ' ' . _('Supplier') . ' : <b>' . stripslashes($_SESSION['SupplierID']) . - ' - ' . $SupplierName . '</b> ' . _('has been selected') . '.</p>'; - echo '<div class="page_help_text">' . _('Select a menu option to operate using this supplier.') . '</div>'; echo '<br /><table width=90% cellpadding="4" class="selection">'; echo '<tr> - <th width="33%" class="header">' . _('Supplier Inquiries') . '</th> - <th width="33%" class="header">' . _('Supplier Transactions') . '</th> - <th width="33%" class="header">' . _('Supplier Maintenance') . '</th> + <th colspan="3" class="header"> + <img src="' . $rootpath . '/css/' . $theme . '/images/supplier.png" title="' . _('Supplier') . '" alt="" />' . ' ' . _('Supplier') . ' : <b>' . stripslashes($_SESSION['SupplierID']) . ' - ' . $SupplierName . '</b> ' . _('has been selected') . '. + </th> + </tr>'; + echo '<tr> + <th width="33%" class="header">' . _('Supplier Inquiries') . ' + <img src="' . $rootpath . '/css/' . $theme . '/images/inquiry.png" title="' . _('Supplier') . '" alt="" /> + </th> + <th width="33%" class="header">' . _('Supplier Transactions') . ' + <img src="' . $rootpath . '/css/' . $theme . '/images/transactions.png" title="' . _('Supplier') . '" alt="" /> + </th> + <th width="33%" class="header">' . _('Supplier Maintenance') . ' + <img src="' . $rootpath . '/css/' . $theme . '/images/maintenance.png" title="' . _('Supplier') . '" alt="" /> + </th> </tr>'; echo '<tr><td valign="top" class="select">'; /* Inquiry Options */ - echo '<a href="' . $rootpath . '/SupplierInquiry.php?SupplierID=' . stripslashes($_SESSION['SupplierID']) . '">' . _('Supplier Account Inquiry') . '</a><br />'; - echo '<br />'; - echo '<br /><a href="'.$rootpath.'/PO_SelectOSPurchOrder.php?SelectedSupplier=' . stripslashes($_SESSION['SupplierID']) . '">' . _('Add / Receive / View Outstanding Purchase Orders') . '</a>'; - echo '<br /><a href="'.$rootpath.'/PO_SelectPurchOrder.php?SelectedSupplier=' . stripslashes($_SESSION['SupplierID']) . '">' . _('View All Purchase Orders') . '</a><br />'; + echo InternalLink('', 'SupplierInquiry.php?SupplierID=' . stripslashes($_SESSION['SupplierID']) , _('Supplier Account Inquiry')); + echo '<br />' . InternalLink('', 'PO_SelectOSPurchOrder.php?SelectedSupplier=' . stripslashes($_SESSION['SupplierID']), _('Add / Receive / View Outstanding Purchase Orders')); + echo '<br />' . InternalLink('', 'PO_SelectPurchOrder.php?SelectedSupplier=' . stripslashes($_SESSION['SupplierID']), _('View All Purchase Orders')); wikiLink('Supplier', stripslashes($_SESSION['SupplierID'])); - echo '<br /><a href="'.$rootpath.'/ShiptsList.php?SupplierID=' . stripslashes($_SESSION['SupplierID']) . '&SupplierName='.urlencode($SupplierName).'">' . _('List all open shipments for') .' '.$SupplierName. '</a>'; - echo '<br /><a href="' . $rootpath . '/Shipt_Select.php?SelectedSupplier=' . stripslashes($_SESSION['SupplierID']) . '">' . _('Search / Modify / Close Shipments') . '</a>'; - echo '<br /><a href="' . $rootpath . '/SuppPriceList.php?SelectedSupplier=' . stripslashes($_SESSION['SupplierID']) . '">' . _('Supplier Price List') . '</a>'; + echo '<br />' . InternalLink('', 'ShiptsList.php?SupplierID=' . stripslashes($_SESSION['SupplierID']) . '&SupplierName='.urlencode($SupplierName), _('List all open shipments for') .' '.$SupplierName); + echo '<br />' . InternalLink('', 'Shipt_Select.php?SelectedSupplier=' . stripslashes($_SESSION['SupplierID']), _('Search / Modify / Close Shipments')); + echo '<br />' . InternalLink('', 'SuppPriceList.php?SelectedSupplier=' . stripslashes($_SESSION['SupplierID']), _('Supplier Price List')); echo '</td><td valign=top class="select">'; /* Supplier Transactions */ - echo '<a href="' . $rootpath . '/PO_Header.php?NewOrder=Yes&SupplierID=' . stripslashes($_SESSION['SupplierID']) . '">' . _('Enter a Purchase Order for This Supplier') . '</a><br />'; - echo '<a href="' . $rootpath . '/SupplierInvoice.php?SupplierID=' . stripslashes($_SESSION['SupplierID']) . '">' . _('Enter a Suppliers Invoice') . '</a><br />'; - echo '<a href="' . $rootpath . '/SupplierCredit.php?New=true&SupplierID=' . stripslashes($_SESSION['SupplierID']) . '">' . _('Enter a Suppliers Credit Note') . '</a><br />'; - echo '<a href="' . $rootpath . '/Payments.php?SupplierID=' . stripslashes($_SESSION['SupplierID']) . '">' . _('Enter a Payment to, or Receipt from the Supplier') . '</a><br />'; - echo '<br />'; - echo '<br /><a href="'.$rootpath.'/ReverseGRN.php?&SupplierID=' . stripslashes($_SESSION['SupplierID']) . '">' . _('Reverse an Outstanding Goods Received Note (GRN)') . '</a>'; + echo '<br />' . InternalLink('', 'PO_Header.php?NewOrder=Yes&SupplierID=' . stripslashes($_SESSION['SupplierID']), _('Enter a Purchase Order for This Supplier')); + echo '<br />' . InternalLink('', 'SupplierInvoice.php?SupplierID=' . stripslashes($_SESSION['SupplierID']), _('Enter a Suppliers Invoice')); + echo '<br />' . InternalLink('', 'SupplierCredit.php?New=true&SupplierID=' . stripslashes($_SESSION['SupplierID']), _('Enter a Suppliers Credit Note')); + echo '<br />' . InternalLink('', 'Payments.php?SupplierID=' . stripslashes($_SESSION['SupplierID']), _('Enter a Payment to, or Receipt from the Supplier')); + echo '<br />' . InternalLink('', 'ReverseGRN.php?&SupplierID=' . stripslashes($_SESSION['SupplierID']), _('Reverse an Outstanding Goods Received Note (GRN)')); echo '</td><td valign=top class="select">'; /* Supplier Maintenance */ - echo '<a href="' . $rootpath . '/Suppliers.php?">' . _('Add a New Supplier') . '</a><br />'; - echo '<a href="' . $rootpath . '/Suppliers.php?SupplierID=' . urlencode(stripslashes($_SESSION['SupplierID'])) . '">' . _('Modify Or Delete Supplier Details') . '</a>'; - echo '<br /><a href="' . $rootpath . '/SupplierContacts.php?&SupplierID=' . stripslashes($_SESSION['SupplierID']) . '">' . _('Add/Modify/Delete Supplier Contacts') . '</a>'; - echo '<br /><a href="' . $rootpath . '/SupplierPriceList.php?&SupplierID=' . stripslashes($_SESSION['SupplierID']) . '">' . _('Add or Modify Supplier Price List') . '</a>'; - echo '<br />'; - echo '<br /><a href="'.$rootpath.'/Shipments.php?NewShipment=Yes">' . _('Set Up A New Shipment') . '</a>'; - echo '<br /><a href="'.$rootpath.'/SuppLoginSetup.php">' . _('Supplier Login Configuration') . '</a>'; + echo '<br />' . InternalLink('', 'Suppliers.php?"', _('Add a New Supplier')); + echo '<br />' . InternalLink('', 'Suppliers.php?SupplierID=' . urlencode(stripslashes($_SESSION['SupplierID'])), _('Modify Or Delete Supplier Details')); + echo '<br />' . InternalLink('', 'SupplierContacts.php?&SupplierID=' . stripslashes($_SESSION['SupplierID']), _('Add/Modify/Delete Supplier Contacts')); + echo '<br />' . InternalLink('', 'SupplierPriceList.php?&SupplierID=' . stripslashes($_SESSION['SupplierID']), _('Add or Modify Supplier Price List')); + echo '<br />' . InternalLink('', 'Shipments.php?NewShipment=Yes', _('Set Up A New Shipment')); + echo '<br />' . InternalLink('', 'SuppLoginSetup.php', _('Supplier Login Configuration')); echo '</td></tr></table>'; } else { // Supplier is not selected yet @@ -191,114 +135,19 @@ echo '<a href="' . $rootpath . '/Suppliers.php?">' . _('Add a New Supplier') . '</a><br />'; echo '</td></tr></table>'; } -echo '<form onsubmit="return SubmitForm(this)" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">'; -echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; -echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . _('Search') . '" alt="" />' . ' ' . _('Search for Suppliers') . '</p> - <table cellpadding="3" class="selection"><tr><td>' . _('Enter a partial Name') . ':</font></td><td>'; -if (isset($_POST['Keywords'])) { - echo '<input type="text" name="Keywords" value="' . $_POST['Keywords'] . '" size="20" maxlength="25" />'; -} else { - echo '<input type="text" name="Keywords" size="20" maxlength="25" />'; -} -echo '</td><td><b>' . _('OR') . '</b></font></td><td>' . _('Enter a partial Code') . ':</font></td><td>'; -if (isset($_POST['SupplierCode'])) { - echo '<input type="text" name="SupplierCode" value="' . $_POST['SupplierCode'] . '" size="15" maxlength="18" />'; -} else { - echo '<input type="text" name="SupplierCode" size="15" maxlength="18" />'; -} -echo '</td></tr></table><br /><div class="centre"><button type="submit" name="Search">' . _('Search Now') . '</button></div>'; -//if (isset($result) AND !isset($SingleSupplierReturned)) { -if (isset($_POST['Search'])) { - $ListCount = DB_num_rows($result); - $ListPageMax = ceil($ListCount / $_SESSION['DisplayRecordsMax']); - if (isset($_POST['Next'])) { - if ($_POST['PageOffset'] < $ListPageMax) { - $_POST['PageOffset'] = $_POST['PageOffset'] + 1; - } - } - if (isset($_POST['Previous'])) { - if ($_POST['PageOffset'] > 1) { - $_POST['PageOffset'] = $_POST['PageOffset'] - 1; - } - } - if ($ListPageMax > 1) { - echo '<br /> ' . $_POST['PageOffset'] . ' ' . _('of') . ' ' . $ListPageMax . ' ' . _('pages') . '. ' . _('Go to Page') . ': '; - echo '<select name="PageOffset">'; - $ListPage = 1; - while ($ListPage <= $ListPageMax) { - if ($ListPage == $_POST['PageOffset']) { - echo '<option value=' . $ListPage . ' selected>' . $ListPage . '</option>'; - } else { - echo '<option value=' . $ListPage . '>' . $ListPage . '</option>'; - } - $ListPage++; - } - echo '</select> - <button type="submit" name="Go">' . _('Go') . '</button> - <button type="submit" name="Previous">' . _('Previous') . '</button> - <button type="submit" name="Next">' . _('Next') . '</button>'; - echo '<br />'; - } - echo '<input type="hidden" name="Search" value="' . _('Search Now') . '" />'; - echo '<br /><br />'; - echo '<br /><table cellpadding="2" class="selection">'; - $tableheader = '<tr> - <th>' . _('Code') . '</th> - <th>' . _('Supplier Name') . '</th> - <th>' . _('Currency') . '</th> - <th>' . _('Address 1') . '</th> - <th>' . _('Address 2') . '</th> - <th>' . _('Address 3') . '</th> - <th>' . _('Address 4') . '</th> - </tr>'; - echo $tableheader; - $j = 1; - $k = 0; //row counter to determine background colour - $RowIndex = 0; - if (DB_num_rows($result) <> 0) { - DB_data_seek($result, ($_POST['PageOffset'] - 1) * $_SESSION['DisplayRecordsMax']); - } - while (($myrow = DB_fetch_array($result)) AND ($RowIndex <> $_SESSION['DisplayRecordsMax'])) { - if ($k == 1) { - echo '<tr class="EvenTableRows">'; - $k = 0; - } else { - echo '<tr class="OddTableRows">'; - $k = 1; - } - echo '<td><button type="submit" name="Select" value="'.DB_escape_string($myrow['supplierid']).'">'.DB_escape_string($myrow['supplierid']).'</button></td> - <td>'.$myrow['suppname'].'</td> - <td>'.$myrow['currcode'].'</td> - <td>'.$myrow['address1'].'</td> - <td>'.$myrow['address2'].'</td> - <td>'.$myrow['address3'].'</td> - <td>'.$myrow['address4'].'</td> - </tr>'; - $RowIndex = $RowIndex + 1; - //end of page full new headings if - } - //end of while loop - echo '</table>'; -} -//end if results to show -if (isset($ListPageMax) and $ListPageMax > 1) { - echo '<br /> ' . $_POST['PageOffset'] . ' ' . _('of') . ' ' . $ListPageMax . ' ' . _('pages') . '. ' . _('Go to Page') . ': '; - echo '<select name="PageOffset">'; - $ListPage = 1; - while ($ListPage <= $ListPageMax) { - if ($ListPage == $_POST['PageOffset']) { - echo '<option value=' . $ListPage . ' selected>' . $ListPage . '</option>'; - } else { - echo '<option value=' . $ListPage . '>' . $ListPage . '</option>'; - } - $ListPage++; - } - echo '</select> - <button type="submit" name="Go">' . _('Go') . '</button> - <button type="submit" name="Previous">' . _('Previous') . '</button> - <button type="submit" name="Next">' . _('Next') . '</button>'; - echo '<br />'; -} + +$URLArray=explode('/', $_SERVER['PHP_SELF']); +echo '<div class="centre"> + <button type="submit" name="Search" onclick="return OpenSearchWindow(\'includes/SupplierSearch.php\', \'' . htmlspecialchars(array_pop($URLArray), ENT_QUOTES, 'UTF-8') . '\')"> + <img src="'.$rootpath.'/css/'.$theme.'/images/magnifier.png" title="' . _('Click To Search For Suppliers') . '" alt="" /> + ' . _('Search For Suppliers') . ' + </button> + </div>'; + +echo '<div id="SearchMask"></div>'; +echo '<div id="SearchWindow">'; +echo '</div>'; +- echo '</form>'; // Only display the geocode map if the integration is turned on, and there is a latitude/longitude to display if (isset($_SESSION['SupplierID']) and $_SESSION['SupplierID'] != '') { Added: trunk/includes/SupplierSearch.php =================================================================== --- trunk/includes/SupplierSearch.php (rev 0) +++ trunk/includes/SupplierSearch.php 2012-07-28 18:11:31 UTC (rev 9453) @@ -0,0 +1,105 @@ +<?php + +$PageSecurity=1; + +if (!isset($PathPrefix)) { + $PathPrefix=$_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF']) . '/../'; + $rootpath = dirname(htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8')); +} + +include($PathPrefix . 'config.php'); +require_once($PathPrefix . 'includes/session.inc'); + +if (!isset($_POST['PartialID']) and !isset($_POST['PartialDescription'])) { + $_POST['PartialID']=''; + $_POST['PartialName']=''; + $_POST['PartialAddress']=''; + $_POST['PartialTelephone']=''; + echo '<form name="search" onkeyup="return SubmitSearchForm(this,\'includes/SupplierSearch.php?CallingURL='.$_GET['CallingURL'].'\');" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">'; + echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; + echo '<div class="manual_title_bar">' . _('Search Suppliers') . '</div>'; + + echo '<table class="background_table" width="98%"> + <tr> + <td class="background_td" width="33%">'; + echo '<table style="border: solid #000000 1px;width:100%;border-radius: 5px"> + <tr> + <th colspan="2" class="dialog_header">' . _('Selection Criteria') . '</th> + </tr>'; + echo '<tr> + <td>' . _('Partial ID') . '</td> + <td><input type="text" name="PartialID" class="SearchInput" /></td> + </tr>'; + echo '<tr> + <td>' . _('Partial Name') . '</td> + <td><input type="text" name="PartialName" class="SearchInput" /></td> + </tr>'; + echo '<tr> + <td>' . _('Partial Address') . '</td> + <td><input type="text" name="PartialAddress" class="SearchInput" /></td> + </tr>'; + echo '<tr> + <td>' . _('Partial Telephone Number') . '</td> + <td><input type="text" name="PartialTelephone" class="SearchInput" /></td> + </tr>'; + echo '</table></form>'; + echo '</td>'; + echo '<td class="background_td" width="66%" id="SearchResults">'; +} + +echo '<form onkeyup="return SubmitSearchForm(this);" name="SearchForm" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">'; +echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; + +echo '<table style="border: solid #000000 1px;width:100%;border-radius: 5px;"> + <tr> + <th class="dialog_header" colspan="5">' . _('Suppliers') . '</th> + </tr>'; + + +$SearchResult = SupplierSearchSQL($db); +while ($myrow=DB_fetch_array($SearchResult)) { + $address=$myrow['address1'].','.$myrow['address2'].','.$myrow['address3'].','.$myrow['address4']; + echo '<tr> + <td>' . $myrow['supplierid'] . '</td> + <td>' . $myrow['suppname'] . '</td> + <td>' . $address . '</td> + <td class="number"><input name="SupplierID" value="' . $myrow['supplierid'] . '" type="radio" onclick="OnSelectClick(this, ChooseSupplier)" /></td> + </tr>'; +} +echo '<tr> + <th class="dialog_header" style="background:transparent" colspan="5"> + <button class="dialog_button" type="submit" name="ChooseSupplier" id="ChooseSupplier" value="submit" onclick="return SubmitForm(SearchForm,\''.$_GET['CallingURL'].'\')"> + <img src="css/'.$theme.'/images/tick.png" title="' . _('Save') . '" alt="" class="ButtonIcon" /> ' . _('Select') . ' + </button> + <button class="dialog_button" type="cancel" id="CancelSearch" value="submit" onclick="CloseSearchWindow()"> + <img src="css/'.$theme.'/images/cross.png" title="' . _('Save') . '" alt="" class="ButtonIcon" /> ' . _('Cancel') . ' + </button> + </th> + </tr>'; +echo '</table>'; + +echo '</td> + </tr> + </table></form>'; + +function SupplierSearchSQL($db) { + $SQL = "SELECT suppliers.supplierid, + suppliers.suppname, + suppliers.address1, + suppliers.address2, + suppliers.address3, + suppliers.address4 + FROM suppliers + WHERE suppliers.suppname " . LIKE . " '%" . $_POST['PartialName'] . "%' + AND suppliers.supplierid " . LIKE . " '%" . $_POST['PartialID'] . "%' + AND suppliers.telephone " . LIKE . " '%" . $_POST['PartialTelephone'] . "%' + AND (suppliers.address1 " . LIKE . " '%" . $_POST['PartialAddress'] . "%' + OR suppliers.address2 " . LIKE . " '%" . $_POST['PartialAddress'] . "%' + OR suppliers.address3 " . LIKE . " '%" . $_POST['PartialAddress'] . "%' + OR suppliers.address4 " . LIKE . " '%" . $_POST['PartialAddress'] . "%') + LIMIT 15"; + $result=DB_query($SQL, $db); + return $result; +} + +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |