From: <ex...@us...> - 2013-12-11 07:27:10
|
Revision: 6490 http://sourceforge.net/p/web-erp/reponame/6490 Author: exsonqu Date: 2013-12-11 07:27:08 +0000 (Wed, 11 Dec 2013) Log Message: ----------- 11/12/13 Thumb: fixed bug that using limit without offsetting in PO_Items.php,WorkOrderEntry.php and make users' DisplayRecordsMax effective in SelectOrderItems.php.And fixed typo in SelectCreditItems.php. Modified Paths: -------------- trunk/PO_Items.php trunk/SelectCreditItems.php trunk/SelectOrderItems.php trunk/WorkOrderEntry.php Modified: trunk/PO_Items.php =================================================================== --- trunk/PO_Items.php 2013-12-10 19:40:50 UTC (rev 6489) +++ trunk/PO_Items.php 2013-12-11 07:27:08 UTC (rev 6490) @@ -851,7 +851,7 @@ } /* Now show the stock item selection search stuff below */ -if (isset($_POST['Search'])){ /*ie seach for stock items */ +if (isset($_POST['Search'])||isset($_POST['Prev'])||isset($_POST['Next'])){ /*ie seach for stock items */ if ($_POST['Keywords'] AND $_POST['StockCode']) { prnMsg( _('Stock description keywords have been used in preference to the Stock code extract entered'), 'info' ); @@ -877,7 +877,7 @@ AND purchdata.supplierno='" . $_SESSION['PO'.$identifier]->SupplierID . "' AND stockmaster.description " . LIKE . " '" . $SearchString ."' ORDER BY stockmaster.stockid - LIMIT " .$_SESSION['DefaultDisplayRecordsMax']; + "; } else { // not just supplier purchdata items $sql = "SELECT stockmaster.stockid, @@ -892,7 +892,7 @@ AND stockmaster.discontinued<>1 AND stockmaster.description " . LIKE . " '" . $SearchString ."' ORDER BY stockmaster.stockid - LIMIT " .$_SESSION['DefaultDisplayRecordsMax']; + "; } } else { //for a specific stock category if ($_POST['SupplierItemsOnly']=='on'){ @@ -912,7 +912,7 @@ AND stockmaster.description " . LIKE . " '". $SearchString ."' AND stockmaster.categoryid='" . $_POST['StockCat'] . "' ORDER BY stockmaster.stockid - LIMIT ".$_SESSION['DefaultDisplayRecordsMax']; + "; } else { $sql = "SELECT stockmaster.stockid, stockmaster.description, @@ -927,7 +927,7 @@ AND stockmaster.description " . LIKE . " '". $SearchString ."' AND stockmaster.categoryid='" . $_POST['StockCat'] . "' ORDER BY stockmaster.stockid - LIMIT ".$_SESSION['DefaultDisplayRecordsMax']; + "; } } @@ -952,7 +952,7 @@ AND stockmaster.discontinued<>1 AND stockmaster.stockid " . LIKE . " '" . $_POST['StockCode'] . "' ORDER BY stockmaster.stockid - LIMIT ".$_SESSION['DefaultDisplayRecordsMax']; + "; } else { $sql = "SELECT stockmaster.stockid, stockmaster.description, @@ -966,7 +966,7 @@ AND stockmaster.discontinued<>1 AND stockmaster.stockid " . LIKE . " '" . $_POST['StockCode'] . "' ORDER BY stockmaster.stockid - LIMIT ".$_SESSION['DefaultDisplayRecordsMax']; + "; } } else { //for a specific stock category and LIKE stock code if ($_POST['SupplierItemsOnly']=='on'){ @@ -986,7 +986,7 @@ AND stockmaster.stockid " . LIKE . " '" . $_POST['StockCode'] . "' AND stockmaster.categoryid='" . $_POST['StockCat'] . "' ORDER BY stockmaster.stockid - LIMIT ".$_SESSION['DefaultDisplayRecordsMax']; + "; } else { $sql = "SELECT stockmaster.stockid, stockmaster.description, @@ -1001,7 +1001,7 @@ AND stockmaster.stockid " . LIKE . " '" . $_POST['StockCode'] . "' AND stockmaster.categoryid='" . $_POST['StockCat'] . "' ORDER BY stockmaster.stockid - LIMIT ".$_SESSION['DefaultDisplayRecordsMax']; + "; } } @@ -1022,7 +1022,7 @@ AND purchdata.supplierno='" . $_SESSION['PO'.$identifier]->SupplierID . "' AND stockmaster.discontinued<>1 ORDER BY stockmaster.stockid - LIMIT " . $_SESSION['DefaultDisplayRecordsMax']; + "; } else { $sql = "SELECT stockmaster.stockid, stockmaster.description, @@ -1035,7 +1035,7 @@ AND stockmaster.mbflag<>'G' AND stockmaster.discontinued<>1 ORDER BY stockmaster.stockid - LIMIT " . $_SESSION['DefaultDisplayRecordsMax']; + "; } } else { // for a specific stock category if ($_POST['SupplierItemsOnly']=='on'){ @@ -1054,7 +1054,7 @@ AND stockmaster.discontinued<>1 AND stockmaster.categoryid='" . $_POST['StockCat'] . "' ORDER BY stockmaster.stockid - LIMIT " . $_SESSION['DefaultDisplayRecordsMax']; + "; } else { $sql = "SELECT stockmaster.stockid, stockmaster.description, @@ -1068,11 +1068,37 @@ AND stockmaster.discontinued<>1 AND stockmaster.categoryid='" . $_POST['StockCat'] . "' ORDER BY stockmaster.stockid - LIMIT " . $_SESSION['DefaultDisplayRecordsMax']; + "; } } } + + $sqlcount = substr($sql,strpos($sql, "FROM")); + $sqlcount = substr($sqlcount,0, strpos($sqlcount, "ORDER")); + $sqlcount = 'SELECT COUNT(*) '.$sqlcount; + $SearchResult = DB_query($sqlcount,$db,$ErrMsg,$DbgMsg); + $myrow=DB_fetch_array($SearchResult); + DB_free_result($SearchResult); + unset($SearchResult); + $ListCount = $myrow[0]; + $ListPageMax = ceil($ListCount / $_SESSION['DisplayRecordsMax'])-1; + + if (isset($_POST['Next'])) { + $Offset = $_POST['currpage']+1; + } + if (isset($_POST['Prev'])) { + $Offset = $_POST['currpage']-1; + } + if (!isset($Offset)) { + $Offset=0; + } + if($Offset<0)$Offset=0; + if($Offset>$ListPageMax)$Offset=$ListPageMax; + + $sql = $sql . "LIMIT " . $_SESSION['DisplayRecordsMax']." OFFSET " . strval($_SESSION['DisplayRecordsMax']*$Offset); + + $ErrMsg = _('There is a problem selecting the part records to display because'); $DbgMsg = _('The SQL statement that failed was'); $SearchResult = DB_query($sql,$db,$ErrMsg,$DbgMsg); @@ -1152,9 +1178,22 @@ } if (isset($SearchResult)) { + $PageBar = '<tr><td><input type="hidden" name="currpage" value="'.$Offset.'">'; + if($Offset>0) + $PageBar .= '<input type="submit" name="Prev" value="'._('Prev').'" />'; + else + $PageBar .= '<input type="submit" name="Prev" value="'._('Prev').'" disabled="disabled"/>'; + $PageBar .= '</td><td style="text-align:center" colspan="4"><input type="submit" value="'._('Order some').'" name="NewItem"/></td><td>'; + if($Offset<$ListPageMax) + $PageBar .= '<input type="submit" name="Next" value="'._('Next').'" />'; + else + $PageBar .= '<input type="submit" name="Next" value="'._('Next').'" disabled="disabled"/>'; + $PageBar .= '</td></tr>'; + + echo '<table cellpadding="1" class="selection">'; - + echo $PageBar; $TableHeader = '<tr> <th class="ascending">' . _('Code') . '</th> <th class="ascending">' . _('Description') . '</th> @@ -1215,6 +1254,7 @@ $PartsDisplayed++; #end of page full new headings if } + echo $PageBar; #end of while loop echo '</table>'; echo '<input type="hidden" name="PO_ItemsResubmitFormValue" value="' . $_SESSION['PO_ItemsResubmitForm' . $identifier] . '" />'; Modified: trunk/SelectCreditItems.php =================================================================== --- trunk/SelectCreditItems.php 2013-12-10 19:40:50 UTC (rev 6489) +++ trunk/SelectCreditItems.php 2013-12-11 07:27:08 UTC (rev 6490) @@ -1488,7 +1488,7 @@ '" . $AssParts['quantity'] * $CreditLine->Quantity . "', '" . $AssParts['standard'] . "', 0, - '" . $QtyOnHandPrior + ($AssParts['quantity'] * $CreditLine->Quantity) . "' + '" . ($QtyOnHandPrior + ($AssParts['quantity'] * $CreditLine->Quantity)) . "' )"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Stock movement records for the assembly components of') . ' ' . $CreditLine->StockID . ' ' . _('could not be inserted because'); Modified: trunk/SelectOrderItems.php =================================================================== --- trunk/SelectOrderItems.php 2013-12-10 19:40:50 UTC (rev 6489) +++ trunk/SelectOrderItems.php 2013-12-11 07:27:08 UTC (rev 6490) @@ -855,8 +855,9 @@ if (!isset($Offset) OR $Offset < 0) { $Offset=0; } - $SQL = $SQL . " LIMIT " . $_SESSION['DefaultDisplayRecordsMax'] . " OFFSET " . strval($_SESSION['DefaultDisplayRecordsMax'] * $Offset); + $SQL = $SQL . " LIMIT " . $_SESSION['DisplayRecordsMax'] . " OFFSET " . strval($_SESSION['DisplayRecordsMax'] * $Offset); + $ErrMsg = _('There is a problem selecting the part records to display because'); $DbgMsg = _('The SQL used to get the part selection was'); Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2013-12-10 19:40:50 UTC (rev 6489) +++ trunk/WorkOrderEntry.php 2013-12-11 07:27:08 UTC (rev 6490) @@ -80,7 +80,7 @@ } -if (isset($_POST['Search'])){ +if (isset($_POST['Search']) OR isset($_POST['Prev']) OR isset($_POST['Next'])){ If ($_POST['Keywords'] AND $_POST['StockCode']) { prnMsg(_('Stock description keywords have been used in preference to the Stock code extract entered'),'warn'); @@ -175,9 +175,35 @@ ORDER BY stockmaster.stockid"; } } + $sql=$SQL; + + $sqlcount = substr($sql,strpos($sql, "FROM")); + $sqlcount = substr($sqlcount,0, strpos($sqlcount, "ORDER")); + $sqlcount = 'SELECT COUNT(*) '.$sqlcount; + $SearchResult = DB_query($sqlcount,$db,$ErrMsg,$DbgMsg); + $myrow=DB_fetch_array($SearchResult); + DB_free_result($SearchResult); + unset($SearchResult); + $ListCount = $myrow[0]; + $ListPageMax = ceil($ListCount / $_SESSION['DisplayRecordsMax'])-1; + + if (isset($_POST['Next'])) { + $Offset = $_POST['currpage']+1; + } + if (isset($_POST['Prev'])) { + $Offset = $_POST['currpage']-1; + } + if (!isset($Offset)) { + $Offset=0; + } + if($Offset<0)$Offset=0; + if($Offset>$ListPageMax)$Offset=$ListPageMax; + $sql = $sql . ' LIMIT ' . $_SESSION['DisplayRecordsMax'].' OFFSET ' . strval($_SESSION['DisplayRecordsMax']*$Offset); - $SQL = $SQL . ' LIMIT ' . $_SESSION['DisplayRecordsMax']; + $SQL=$sql; + + $ErrMsg = _('There is a problem selecting the part records to display because'); $DbgMsg = _('The SQL used to get the part selection was'); $SearchResult = DB_query($SQL,$db,$ErrMsg, $DbgMsg); @@ -642,8 +668,21 @@ if (DB_num_rows($SearchResult)>1){ - echo '<br /><table cellpadding="2" class="selection"> - <tr> + $PageBar = '<tr><td><input type="hidden" name="currpage" value="'.$Offset.'">'; + if($Offset>0) + $PageBar .= '<input type="submit" name="Prev" value="'._('Prev').'" />'; + else + $PageBar .= '<input type="submit" name="Prev" value="'._('Prev').'" disabled="disabled"/>'; + $PageBar .= '</td><td>'; + if($Offset<$ListPageMax) + $PageBar .= '<input type="submit" name="Next" value="'._('Next').'" />'; + else + $PageBar .= '<input type="submit" name="Next" value="'._('Next').'" disabled="disabled"/>'; + $PageBar .= '</td></tr>'; + + echo '<br /><table cellpadding="2" class="selection">'; + echo $PageBar; + echo '<tr> <th class="ascending">' . _('Code') . '</th> <th class="ascending">' . _('Description') . '</th> <th>' . _('Units') . '</th></tr>'; |