From: <tu...@us...> - 2018-02-13 00:20:47
|
Revision: 7958 http://sourceforge.net/p/web-erp/reponame/7958 Author: turbopt Date: 2018-02-13 00:20:44 +0000 (Tue, 13 Feb 2018) Log Message: ----------- PaulT: InternalStockRequest.php: Address a few issues reported by Paul B: Fix Previous/Next handling, table sorting, wrong on-order quantities, and apply the user's display records max. Change also removes unused code and other minor improvements. (Reported in forums: http://www.weberp.org/forum/showthread.php?tid=8089) Modified Paths: -------------- trunk/InternalStockRequest.php trunk/doc/Change.log Property Changed: ---------------- trunk/InternalStockRequest.php Modified: trunk/InternalStockRequest.php =================================================================== --- trunk/InternalStockRequest.php 2018-02-12 21:53:28 UTC (rev 7957) +++ trunk/InternalStockRequest.php 2018-02-13 00:20:44 UTC (rev 7958) @@ -1,6 +1,6 @@ <?php -/* $Id: InternalStockRequest.php 4576 2011-05-27 10:59:20Z daintree $*/ +/* $Id$*/ include('includes/DefineStockRequestClass.php'); @@ -117,8 +117,8 @@ if ($myEmail=DB_fetch_array($EmailResult)){ $ConfirmationText = _('An internal stock request has been created and is waiting for your authoritation'); $EmailSubject = _('Internal Stock Request needs your authoritation'); - if($_SESSION['SmtpSetting']==0){ - mail($myEmail['email'],$EmailSubject,$ConfirmationText); + if($_SESSION['SmtpSetting']==0){ + mail($myEmail['email'],$EmailSubject,$ConfirmationText); }else{ include('includes/htmlMimeMail.php'); $mail = new htmlMimeMail(); @@ -126,13 +126,11 @@ $mail->setText($ConfirmationText); $result = SendmailBySmtp($mail,array($myEmail['email'])); } - } - } DB_Txn_Commit(); prnMsg( _('The internal stock request has been entered and now needs to be authorised'), 'success'); - echo '<br /><div class="centre"><a href="'. htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '?New=Yes">' . _('Create another request') . '</a></div>'; + echo '<br /><div class="centre"><a href="', htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8'), '?New=Yes">', _('Create another request'), '</a></div>'; include('includes/footer.php'); unset($_SESSION['Request']); exit; @@ -140,80 +138,79 @@ prnMsg(_('There are no items added to this request'),'error'); } -echo '<p class="page_title_text"><img src="'.$RootPath.'/css/'.$Theme.'/images/supplier.png" title="' . _('Dispatch') . - '" alt="" />' . ' ' . $Title . '</p>'; +echo '<p class="page_title_text"><img src="', $RootPath, '/css/', $Theme, '/images/supplier.png" title="', _('Dispatch'), + '" alt="" />', ' ', $Title, '</p>'; if (isset($_GET['Edit'])) { - echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">'; - echo '<div>'; - echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; + echo '<form action="', htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8'), '" method="post">'; + echo '<div>'; + echo '<input type="hidden" name="FormID" value="', $_SESSION['FormID'], '" />'; echo '<table class="selection">'; echo '<tr> - <th colspan="2"><h4>' . _('Edit the Request Line') . '</h4></th> + <th colspan="2"><h4>', _('Edit the Request Line'), '</h4></th> </tr>'; echo '<tr> - <td>' . _('Line number') . '</td> - <td>' . $_SESSION['Request']->LineItems[$_GET['Edit']]->LineNumber . '</td> + <td>', _('Line number'), '</td> + <td>', $_SESSION['Request']->LineItems[$_GET['Edit']]->LineNumber, '</td> </tr> <tr> - <td>' . _('Stock Code') . '</td> - <td>' . $_SESSION['Request']->LineItems[$_GET['Edit']]->StockID . '</td> + <td>', _('Stock Code'), '</td> + <td>', $_SESSION['Request']->LineItems[$_GET['Edit']]->StockID, '</td> </tr> <tr> - <td>' . _('Item Description') . '</td> - <td>' . $_SESSION['Request']->LineItems[$_GET['Edit']]->ItemDescription . '</td> + <td>', _('Item Description'), '</td> + <td>', $_SESSION['Request']->LineItems[$_GET['Edit']]->ItemDescription, '</td> </tr> <tr> - <td>' . _('Unit of Measure') . '</td> - <td>' . $_SESSION['Request']->LineItems[$_GET['Edit']]->UOM . '</td> + <td>', _('Unit of Measure'), '</td> + <td>', $_SESSION['Request']->LineItems[$_GET['Edit']]->UOM, '</td> </tr> <tr> - <td>' . _('Quantity Requested') . '</td> - <td><input type="text" class="number" name="Quantity" value="' . locale_number_format($_SESSION['Request']->LineItems[$_GET['Edit']]->Quantity, $_SESSION['Request']->LineItems[$_GET['Edit']]->DecimalPlaces) . '" /></td> + <td>', _('Quantity Requested'), '</td> + <td><input type="text" class="number" name="Quantity" value="', locale_number_format($_SESSION['Request']->LineItems[$_GET['Edit']]->Quantity, $_SESSION['Request']->LineItems[$_GET['Edit']]->DecimalPlaces), '" /></td> </tr>'; - echo '<input type="hidden" name="LineNumber" value="' . $_SESSION['Request']->LineItems[$_GET['Edit']]->LineNumber . '" />'; + echo '<input type="hidden" name="LineNumber" value="', $_SESSION['Request']->LineItems[$_GET['Edit']]->LineNumber, '" />'; echo '</table> <br />'; echo '<div class="centre"> - <input type="submit" name="Edit" value="' . _('Update Line') . '" /> + <input type="submit" name="Edit" value="', _('Update Line'), '" /> </div> - </div> + </div> </form>'; include('includes/footer.php'); exit; } -echo '<form action="'. htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">'; -echo '<div>'; -echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - -echo '<table class="selection">'; -echo '<tr> - <th colspan="2"><h4>' . _('Internal Stock Request Details') . '</h4></th> +echo '<form action="', htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8'), '" method="post"> + <div> + <input type="hidden" name="FormID" value="', $_SESSION['FormID'], '" /> + <table class="selection"> + <tr> + <th colspan="2"><h4>', _('Internal Stock Request Details'), '</h4></th> </tr> <tr> <td>' . _('Department') . ':</td>'; if($_SESSION['AllowedDepartment'] == 0){ // any internal department allowed - $sql="SELECT departmentid, + $SQL="SELECT departmentid, description FROM departments ORDER BY description"; }else{ // just 1 internal department allowed - $sql="SELECT departmentid, + $SQL="SELECT departmentid, description FROM departments WHERE departmentid = '". $_SESSION['AllowedDepartment'] ."' ORDER BY description"; } -$result=DB_query($sql); +$Result=DB_query($SQL); echo '<td><select name="Department">'; -while ($myrow=DB_fetch_array($result)){ - if (isset($_SESSION['Request']->Department) AND $_SESSION['Request']->Department==$myrow['departmentid']){ - echo '<option selected="True" value="' . $myrow['departmentid'] . '">' . htmlspecialchars($myrow['description'], ENT_QUOTES,'UTF-8') . '</option>'; +while ($MyRow=DB_fetch_array($Result)){ + if (isset($_SESSION['Request']->Department) AND $_SESSION['Request']->Department==$MyRow['departmentid']){ + echo '<option selected value="', $MyRow['departmentid'], '">', htmlspecialchars($MyRow['description'], ENT_QUOTES,'UTF-8'), '</option>'; } else { - echo '<option value="' . $myrow['departmentid'] . '">' . htmlspecialchars($myrow['description'], ENT_QUOTES,'UTF-8') . '</option>'; + echo '<option value="', $MyRow['departmentid'], '">', htmlspecialchars($MyRow['description'], ENT_QUOTES,'UTF-8'), '</option>'; } } echo '</select></td> @@ -220,7 +217,7 @@ </tr> <tr> <td>' . _('Location from which to request stock') . ':</td>'; -$sql="SELECT locations.loccode, +$SQL="SELECT locations.loccode, locationname FROM locations INNER JOIN locationusers ON locationusers.loccode=locations.loccode AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canupd=1 @@ -227,34 +224,32 @@ WHERE internalrequest = 1 ORDER BY locationname"; -$result=DB_query($sql); +$Result=DB_query($SQL); echo '<td><select name="Location"> - <option value="">' . _('Select a Location') . '</option>'; -while ($myrow=DB_fetch_array($result)){ - if (isset($_SESSION['Request']->Location) AND $_SESSION['Request']->Location==$myrow['loccode']){ - echo '<option selected="True" value="' . $myrow['loccode'] . '">' . $myrow['loccode'].' - ' .htmlspecialchars($myrow['locationname'], ENT_QUOTES,'UTF-8') . '</option>'; + <option value="">', _('Select a Location'), '</option>'; +while ($MyRow=DB_fetch_array($Result)){ + if (isset($_SESSION['Request']->Location) AND $_SESSION['Request']->Location==$MyRow['loccode']){ + echo '<option selected value="', $MyRow['loccode'], '">', $MyRow['loccode'], ' - ', htmlspecialchars($MyRow['locationname'], ENT_QUOTES,'UTF-8'), '</option>'; } else { - echo '<option value="' . $myrow['loccode'] . '">' . $myrow['loccode'].' - ' .htmlspecialchars($myrow['locationname'], ENT_QUOTES,'UTF-8') . '</option>'; + echo '<option value="', $MyRow['loccode'], '">', $MyRow['loccode'], ' - ', htmlspecialchars($MyRow['locationname'], ENT_QUOTES,'UTF-8'), '</option>'; } } echo '</select></td> </tr> <tr> - <td>' . _('Date when required') . ':</td>'; -echo '<td><input type="text" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" name="DispatchDate" maxlength="10" size="11" value="' . $_SESSION['Request']->DispatchDate . '" /></td> - </tr>'; - -echo '<tr> - <td>' . _('Narrative') . ':</td> - <td><textarea name="Narrative" cols="30" rows="5">' . $_SESSION['Request']->Narrative . '</textarea></td> + <td>', _('Date when required'), ':</td> + <td><input type="text" class="date" alt="', $_SESSION['DefaultDateFormat'], '" name="DispatchDate" maxlength="10" size="11" value="', $_SESSION['Request']->DispatchDate, '" /></td> </tr> + <tr> + <td>', _('Narrative'), ':</td> + <td><textarea name="Narrative" cols="30" rows="5">', $_SESSION['Request']->Narrative, '</textarea></td> + </tr> </table> - <br />'; - -echo '<div class="centre"> - <input type="submit" name="Update" value="' . _('Update') . '" /> + <br /> + <div class="centre"> + <input type="submit" name="Update" value="', _('Update'), '" /> </div> - </div> + </div> </form>'; if (!isset($_SESSION['Request']->Location)) { @@ -262,33 +257,32 @@ exit; } -$i = 0; //Line Item Array pointer -echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">'; -echo '<div>'; -echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; -echo '<br /> +echo '<form action="', htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8'), '" method="post"> + <div> + <input type="hidden" name="FormID" value="', $_SESSION['FormID'], '" /> + <br /> <table class="selection"> <tr> - <th colspan="7"><h4>' . _('Details of Items Requested') . '</h4></th> + <th colspan="7"><h4>', _('Details of Items Requested'), '</h4></th> </tr> <tr> - <th>' . _('Line Number') . '</th> - <th class="ascending">' . _('Item Code') . '</th> - <th class="ascending">' . _('Item Description'). '</th> - <th class="ascending">' . _('Quantity Required'). '</th> - <th>' . _('UOM'). '</th> + <th>', _('Line Number'), '</th> + <th class="ascending">', _('Item Code'), '</th> + <th class="ascending">', _('Item Description'), '</th> + <th class="ascending">', _('Quantity Required'), '</th> + <th>', _('UOM'), '</th> </tr>'; if (isset($_SESSION['Request']->LineItems)) { foreach ($_SESSION['Request']->LineItems as $LineItems) { echo '<tr class="striped_row"> - <td>' . $LineItems->LineNumber . '</td> - <td>' . $LineItems->StockID . '</td> - <td>' . $LineItems->ItemDescription . '</td> - <td class="number">' . locale_number_format($LineItems->Quantity, $LineItems->DecimalPlaces) . '</td> - <td>' . $LineItems->UOM . '</td> - <td><a href="'. htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '?Edit='.$LineItems->LineNumber.'">' . _('Edit') . '</a></td> - <td><a href="'. htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '?Delete='.$LineItems->LineNumber.'">' . _('Delete') . '</a></td> + <td>', $LineItems->LineNumber, '</td> + <td>', $LineItems->StockID, '</td> + <td>', $LineItems->ItemDescription, '</td> + <td class="number">', locale_number_format($LineItems->Quantity, $LineItems->DecimalPlaces), '</td> + <td>', $LineItems->UOM, '</td> + <td><a href="', htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8'), '?Edit=', urlencode($LineItems->LineNumber), '">', _('Edit'), '</a></td> + <td><a href="', htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8'), '?Delete=', urlencode($LineItems->LineNumber), '">', _('Delete'), '</a></td> </tr>'; } } @@ -296,77 +290,88 @@ echo '</table> <br /> <div class="centre"> - <input type="submit" name="Submit" value="' . _('Submit') . '" /> + <input type="submit" name="Submit" value="', _('Submit'), '" /> </div> <br /> - </div> - </form>'; + </div> + </form>'; -echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">'; -echo '<div>'; -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 Inventory Items'), + '</p> + <form action="', htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8'), '" method="post"> + <div> + <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 Inventory Items'). '</p>'; $SQL = "SELECT stockcategory.categoryid, stockcategory.categorydescription - FROM stockcategory, internalstockcatrole - WHERE stockcategory.categoryid = internalstockcatrole.categoryid - AND internalstockcatrole.secroleid= " . $_SESSION['AccessLevel'] . " - ORDER BY stockcategory.categorydescription"; -$result1 = DB_query($SQL); -if (DB_num_rows($result1) == 0) { - echo '<p class="bad">' . _('Problem Report') . ':<br />' . _('There are no stock categories currently defined please use the link below to set them up') . '</p>'; - echo '<br /> - <a href="' . $RootPath . '/StockCategories.php">' . _('Define Stock Categories') . '</a>'; + FROM stockcategory + INNER JOIN internalstockcatrole + ON stockcategory.categoryid = internalstockcatrole.categoryid + WHERE internalstockcatrole.secroleid= " . $_SESSION['AccessLevel'] . " + ORDER BY stockcategory.categorydescription"; + +$Result1 = DB_query($SQL); +if (DB_num_rows($Result1) == 0) { + echo '<p class="bad">', _('Problem Report'), ':<br />', _('There are no stock categories currently defined please use the link below to set them up'), '</p> + <br /> + <a href="', $RootPath, '/StockCategories.php">', _('Define Stock Categories'), '</a>'; exit; } + echo '<table class="selection"> <tr> <td>' . _('In Stock Category') . ':<select name="StockCat">'; if (!isset($_POST['StockCat'])) { - $_POST['StockCat'] = ''; + $_POST['StockCat'] = 'All'; } + if ($_POST['StockCat'] == 'All') { - echo '<option selected="True" value="All">' . _('All Authorized') . '</option>'; + echo '<option selected value="All">' . _('All Authorized') . '</option>'; } else { echo '<option value="All">' . _('All Authorized') . '</option>'; } -while ($myrow1 = DB_fetch_array($result1)) { - if ($myrow1['categoryid'] == $_POST['StockCat']) { - echo '<option selected="True" value="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>'; + +while ($MyRow1 = DB_fetch_array($Result1)) { + if ($MyRow1['categoryid'] == $_POST['StockCat']) { + echo '<option selected value="', $MyRow1['categoryid'], '">', $MyRow1['categorydescription'], '</option>'; } else { - echo '<option value="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>'; + echo '<option value="', $MyRow1['categoryid'], '">', $MyRow1['categorydescription'], '</option>'; } } + echo '</select></td> - <td>' . _('Enter partial') . '<b> ' . _('Description') . '</b>:</td>'; + <td>', _('Enter partial'), '<b> ', _('Description'), '</b>:</td>'; + if (isset($_POST['Keywords'])) { - echo '<td><input type="text" name="Keywords" value="' . $_POST['Keywords'] . '" size="20" maxlength="25" /></td>'; + echo '<td><input type="text" name="Keywords" value="', $_POST['Keywords'], '" size="20" maxlength="25" /></td>'; } else { echo '<td><input type="text" name="Keywords" size="20" maxlength="25" /></td>'; } + echo '</tr> <tr> <td></td> - <td><h3>' . _('OR') . ' ' . '</h3>' . _('Enter partial') . ' <b>' . _('Stock Code') . '</b>:</td>'; + <td><h3>', _('OR'), ' ', '</h3>', _('Enter partial'), ' <b>', _('Stock Code'), '</b>:</td>'; if (isset($_POST['StockCode'])) { - echo '<td><input type="text" autofocus="autofocus" name="StockCode" value="' . $_POST['StockCode'] . '" size="15" maxlength="18" /></td>'; + echo '<td><input type="text" autofocus="autofocus" name="StockCode" value="', $_POST['StockCode'], '" size="15" maxlength="18" /></td>'; } else { echo '<td><input type="text" name="StockCode" size="15" maxlength="18" /></td>'; } + echo '</tr> </table> <br /> <div class="centre"> - <input type="submit" name="Search" value="' . _('Search Now') . '" /> + <input type="submit" name="Search" value="', _('Search Now'), '" /> </div> <br /> </div> </form>'; -if (isset($_POST['Search']) or isset($_POST['Next']) or isset($_POST['Prev'])){ +if (isset($_POST['Search']) or isset($_POST['Next']) or isset($_POST['Previous'])){ if ($_POST['Keywords']!='' AND $_POST['StockCode']=='') { prnMsg ( _('Order Item description has been used in search'), 'warn' ); @@ -375,6 +380,7 @@ } elseif ($_POST['Keywords']=='' AND $_POST['StockCode']=='') { prnMsg ( _('Stock Category has been used in search'), 'warn' ); } + if (isset($_POST['Keywords']) AND mb_strlen($_POST['Keywords'])>0) { //insert wildcard characters in spaces $_POST['Keywords'] = mb_strtoupper($_POST['Keywords']); @@ -385,15 +391,15 @@ stockmaster.description, stockmaster.units as stockunits, stockmaster.decimalplaces - FROM stockmaster, - stockcategory, - internalstockcatrole - WHERE stockmaster.categoryid=stockcategory.categoryid - AND stockcategory.categoryid = internalstockcatrole.categoryid + FROM stockmaster + INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + INNER JOIN internalstockcatrole + ON stockcategory.categoryid = internalstockcatrole.categoryid + WHERE stockmaster.mbflag <>'G' + AND stockmaster.discontinued=0 AND internalstockcatrole.secroleid= " . $_SESSION['AccessLevel'] . " - AND stockmaster.mbflag <>'G' AND stockmaster.description " . LIKE . " '" . $SearchString . "' - AND stockmaster.discontinued=0 ORDER BY stockmaster.stockid"; } else { $SQL = "SELECT stockmaster.stockid, @@ -400,14 +406,14 @@ stockmaster.description, stockmaster.units as stockunits, stockmaster.decimalplaces - FROM stockmaster, - stockcategory, - internalstockcatrole - WHERE stockmaster.categoryid=stockcategory.categoryid - AND stockcategory.categoryid = internalstockcatrole.categoryid + FROM stockmaster + INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + INNER JOIN internalstockcatrole + ON stockcategory.categoryid = internalstockcatrole.categoryid + WHERE stockmaster.mbflag <>'G' + AND stockmaster.discontinued=0 AND internalstockcatrole.secroleid= " . $_SESSION['AccessLevel'] . " - AND stockmaster.mbflag <>'G' - AND stockmaster.discontinued=0 AND stockmaster.description " . LIKE . " '" . $SearchString . "' AND stockmaster.categoryid='" . $_POST['StockCat'] . "' ORDER BY stockmaster.stockid"; @@ -423,15 +429,15 @@ stockmaster.description, stockmaster.units as stockunits, stockmaster.decimalplaces - FROM stockmaster, - stockcategory, - internalstockcatrole - WHERE stockmaster.categoryid=stockcategory.categoryid - AND stockcategory.categoryid = internalstockcatrole.categoryid + FROM stockmaster + INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + INNER JOIN internalstockcatrole + ON stockcategory.categoryid = internalstockcatrole.categoryid + WHERE stockmaster.mbflag <>'G' + AND stockmaster.discontinued=0 AND internalstockcatrole.secroleid= " . $_SESSION['AccessLevel'] . " AND stockmaster.stockid " . LIKE . " '" . $SearchString . "' - AND stockmaster.mbflag <>'G' - AND stockmaster.discontinued=0 ORDER BY stockmaster.stockid"; } else { $SQL = "SELECT stockmaster.stockid, @@ -438,15 +444,15 @@ stockmaster.description, stockmaster.units as stockunits, stockmaster.decimalplaces - FROM stockmaster, - stockcategory, - internalstockcatrole - WHERE stockmaster.categoryid=stockcategory.categoryid - AND stockcategory.categoryid = internalstockcatrole.categoryid + FROM stockmaster + INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + INNER JOIN internalstockcatrole + ON stockcategory.categoryid = internalstockcatrole.categoryid + WHERE stockmaster.mbflag <>'G' + AND stockmaster.discontinued=0 AND internalstockcatrole.secroleid= " . $_SESSION['AccessLevel'] . " AND stockmaster.stockid " . LIKE . " '" . $SearchString . "' - AND stockmaster.mbflag <>'G' - AND stockmaster.discontinued=0 AND stockmaster.categoryid='" . $_POST['StockCat'] . "' ORDER BY stockmaster.stockid"; } @@ -457,14 +463,14 @@ stockmaster.description, stockmaster.units as stockunits, stockmaster.decimalplaces - FROM stockmaster, - stockcategory, - internalstockcatrole - WHERE stockmaster.categoryid=stockcategory.categoryid - AND stockcategory.categoryid = internalstockcatrole.categoryid + FROM stockmaster + INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + INNER JOIN internalstockcatrole + ON stockcategory.categoryid = internalstockcatrole.categoryid + WHERE stockmaster.mbflag <>'G' + AND stockmaster.discontinued=0 AND internalstockcatrole.secroleid= " . $_SESSION['AccessLevel'] . " - AND stockmaster.mbflag <>'G' - AND stockmaster.discontinued=0 ORDER BY stockmaster.stockid"; } else { $SQL = "SELECT stockmaster.stockid, @@ -471,14 +477,14 @@ stockmaster.description, stockmaster.units as stockunits, stockmaster.decimalplaces - FROM stockmaster, - stockcategory, - internalstockcatrole - WHERE stockmaster.categoryid=stockcategory.categoryid - AND stockcategory.categoryid = internalstockcatrole.categoryid + FROM stockmaster + INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + INNER JOIN internalstockcatrole + ON stockcategory.categoryid = internalstockcatrole.categoryid + WHERE stockmaster.mbflag <>'G' + AND stockmaster.discontinued=0 AND internalstockcatrole.secroleid= " . $_SESSION['AccessLevel'] . " - AND stockmaster.mbflag <>'G' - AND stockmaster.discontinued=0 AND stockmaster.categoryid='" . $_POST['StockCat'] . "' ORDER BY stockmaster.stockid"; } @@ -487,13 +493,13 @@ if (isset($_POST['Next'])) { $Offset = $_POST['NextList']; } - if (isset($_POST['Prev'])) { - $Offset = $_POST['Previous']; + if (isset($_POST['Previous'])) { + $Offset = $_POST['PreviousList']; } if (!isset($Offset) or $Offset<0) { $Offset=0; } - $SQL = $SQL . ' LIMIT ' . $_SESSION['DefaultDisplayRecordsMax'] . ' OFFSET ' . ($_SESSION['DefaultDisplayRecordsMax']*$Offset); + $SQL = $SQL . ' LIMIT ' . $_SESSION['DisplayRecordsMax'] . ' OFFSET ' . ($_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'); @@ -507,157 +513,78 @@ } } //end of if search -/* display list if there is more than one record */ -if (isset($searchresult) AND !isset($_POST['Select'])) { - echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">'; - echo '<div>'; - echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - $ListCount = DB_num_rows($searchresult); - if ($ListCount > 0) { - // If the user hit the search button and there is more than one item to show - $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 ($_POST['PageOffset'] > $ListPageMax) { - $_POST['PageOffset'] = $ListPageMax; - } - if ($ListPageMax > 1) { - echo '<div class="centre"><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> - <input type="submit" name="Go" value="' . _('Go') . '" /> - <input type="submit" name="Previous" value="' . _('Previous') . '" /> - <input type="submit" name="Next" value="' . _('Next') . '" /> - <input type="hidden" name=Keywords value="'.$_POST['Keywords'].'" /> - <input type="hidden" name=StockCat value="'.$_POST['StockCat'].'" /> - <input type="hidden" name=StockCode value="'.$_POST['StockCode'].'" /> - <br /> - </div>'; - } - echo '<table cellpadding="2">'; - echo '<tr> - <th>' . _('Code') . '</th> - <th>' . _('Description') . '</th> - <th>' . _('Total Qty On Hand') . '</th> - <th>' . _('Units') . '</th> - <th>' . _('Stock Status') . '</th> - </tr>'; - $j = 1; - $RowIndex = 0; - if (DB_num_rows($searchresult) <> 0) { - DB_data_seek($searchresult, ($_POST['PageOffset'] - 1) * $_SESSION['DisplayRecordsMax']); - } - while (($myrow = DB_fetch_array($searchresult)) AND ($RowIndex <> $_SESSION['DisplayRecordsMax'])) { - if ($myrow['mbflag'] == 'D') { - $qoh = _('N/A'); - } else { - $qoh = locale_number_format($myrow['qoh'], $myrow['decimalplaces']); - } - if ($myrow['discontinued']==1){ - $ItemStatus = '<p class="bad">' . _('Obsolete') . '</p>'; - } else { - $ItemStatus =''; - } - echo '<tr class="striped_row"> - <td><input type="submit" name="Select" value="' . $myrow['stockid'] . '" /></td> - <td>' . $myrow['description'] . '</td> - <td class="number">' . $qoh . '</td> - <td>' . $myrow['units'] . '</td> - <td><a target="_blank" href="' . $RootPath . '/StockStatus.php?StockID=' . $myrow['stockid'].'">' . _('View') . '</a></td> - <td>' . $ItemStatus . '</td> - </tr>'; - //end of page full new headings if - } - //end of while loop - echo '</table> - </div> - </form> - <br />'; - } -} -/* end display list if there is more than one record */ - if (isset($SearchResult)) { $j = 1; echo '<br /> - <div class="page_help_text">' . _('Select an item by entering the quantity required. Click Order when ready.') . '</div> + <div class="page_help_text">', _('Select an item by entering the quantity required. Click Order when ready.'), '</div> <br /> - <form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post" id="orderform"> + <form action="', htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8'), '" method="post" id="orderform"> <div> - <input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" /> + <input type="hidden" name="FormID" value="', $_SESSION['FormID'], '" /> <table class="table1"> - <tr> - <td> - <input type="hidden" name="Previous" value="'.($Offset-1).'" /> - <input tabindex="'.($j+8).'" type="submit" name="Prev" value="'._('Prev').'" /></td> + <thead> + <tr> + <td> + <input type="hidden" name="PreviousList" value="', ($Offset - 1), '" /> + <input tabindex="', ($j+8), '" type="submit" name="Previous" value="', _('Previous'), '" /></td> <td class="centre" colspan="6"> - <input type="hidden" name="order_items" value="1" /> - <input tabindex="'.($j+9).'" type="submit" value="'._('Add to Requisition').'" /></td> - <td> - <input type="hidden" name="NextList" value="'.($Offset+1).'" /> - <input tabindex="'.($j+10).'" type="submit" name="Next" value="'._('Next').'" /></td> + <input type="hidden" name="order_items" value="1" /> + <input tabindex="', ($j+9), '" type="submit" value="', _('Add to Requisition'), '" /></td> + <td> + <input type="hidden" name="NextList" value="', ($Offset + 1), '" /> + <input tabindex="', ($j+10), '" type="submit" name="Next" value="', _('Next'), '" /></td> </tr> + </thead> + <tbody> <tr> - <th class="ascending">' . _('Code') . '</th> - <th class="ascending">' . _('Description') . '</th> - <th>' . _('Units') . '</th> - <th class="ascending">' . _('On Hand') . '</th> - <th class="ascending">' . _('On Demand') . '</th> - <th class="ascending">' . _('On Order') . '</th> - <th class="ascending">' . _('Available') . '</th> - <th class="ascending">' . _('Quantity') . '</th> + <th class="ascending">', _('Code'), '</th> + <th class="ascending">', _('Description'), '</th> + <th>', _('Units'), '</th> + <th class="ascending">', _('On Hand'), '</th> + <th class="ascending">', _('On Demand'), '</th> + <th class="ascending">', _('On Order'), '</th> + <th class="ascending">', _('Available'), '</th> + <th class="ascending">', _('Quantity'), '</th> </tr>'; $ImageSource = _('No Image'); $i=0; - while ($myrow=DB_fetch_array($SearchResult)) { - if ($myrow['decimalplaces']=='') { + while ($MyRow=DB_fetch_array($SearchResult)) { + if ($MyRow['decimalplaces']=='') { + /* This REALLY seems to be a redundant (unnecessary) re-query? + * The default on stockmaster is 0, so an empty string should never + * be true, as decimalplaces is in all queries from lines 382-482. + */ $DecimalPlacesSQL="SELECT decimalplaces FROM stockmaster - WHERE stockid='" .$myrow['stockid'] . "'"; + WHERE stockid='" .$MyRow['stockid'] . "'"; $DecimalPlacesResult = DB_query($DecimalPlacesSQL); $DecimalPlacesRow = DB_fetch_array($DecimalPlacesResult); $DecimalPlaces = $DecimalPlacesRow['decimalplaces']; } else { - $DecimalPlaces=$myrow['decimalplaces']; + $DecimalPlaces=$MyRow['decimalplaces']; } $QOHSQL = "SELECT sum(locstock.quantity) AS qoh - FROM locstock - WHERE locstock.stockid='" .$myrow['stockid'] . "' AND - loccode = '" . $_SESSION['Request']->Location . "'"; + FROM locstock + WHERE locstock.stockid='" .$MyRow['stockid'] . "' + AND loccode = '" . $_SESSION['Request']->Location . "'"; $QOHResult = DB_query($QOHSQL); $QOHRow = DB_fetch_array($QOHResult); $QOH = $QOHRow['qoh']; // Find the quantity on outstanding sales orders - $sql = "SELECT SUM(salesorderdetails.quantity-salesorderdetails.qtyinvoiced) AS dem - FROM salesorderdetails INNER JOIN salesorders - ON salesorders.orderno = salesorderdetails.orderno - WHERE salesorders.fromstkloc='" . $_SESSION['Request']->Location . "' - AND salesorderdetails.completed=0 - AND salesorders.quotation=0 - AND salesorderdetails.stkcode='" . $myrow['stockid'] . "'"; + $SQL = "SELECT SUM(salesorderdetails.quantity-salesorderdetails.qtyinvoiced) AS dem + FROM salesorderdetails + INNER JOIN salesorders + ON salesorders.orderno = salesorderdetails.orderno + WHERE salesorders.fromstkloc='" . $_SESSION['Request']->Location . "' + AND salesorderdetails.completed=0 + AND salesorders.quotation=0 + AND salesorderdetails.stkcode='" . $MyRow['stockid'] . "'"; $ErrMsg = _('The demand for this product from') . ' ' . $_SESSION['Request']->Location . ' ' . _('cannot be retrieved because'); - $DemandResult = DB_query($sql,$ErrMsg); + $DemandResult = DB_query($SQL,$ErrMsg); $DemandRow = DB_fetch_row($DemandResult); if ($DemandRow[0] != null){ @@ -666,71 +593,44 @@ $DemandQty = 0; } - // Find the quantity on purchase orders - $sql = "SELECT SUM(purchorderdetails.quantityord-purchorderdetails.quantityrecd)*purchorderdetails.conversionfactor AS dem - FROM purchorderdetails LEFT JOIN purchorders - ON purchorderdetails.orderno=purchorders.orderno - WHERE purchorderdetails.completed=0 - AND purchorders.status<>'Cancelled' - AND purchorders.status<>'Rejected' - AND purchorders.status<>'Completed' - AND purchorderdetails.itemcode='" . $myrow['stockid'] . "'"; + $PurchQty = GetQuantityOnOrderDueToPurchaseOrders($MyRow['stockid'], ''); + $WoQty = GetQuantityOnOrderDueToWorkOrders($MyRow['stockid'], ''); - $ErrMsg = _('The order details for this product cannot be retrieved because'); - $PurchResult = DB_query($sql,$ErrMsg); - - $PurchRow = DB_fetch_row($PurchResult); - if ($PurchRow[0]!=null){ - $PurchQty = $PurchRow[0]; - } else { - $PurchQty = 0; - } - - // Find the quantity on works orders - $sql = "SELECT SUM(woitems.qtyreqd - woitems.qtyrecd) AS dedm - FROM woitems - WHERE stockid='" . $myrow['stockid'] ."'"; - $ErrMsg = _('The order details for this product cannot be retrieved because'); - $WoResult = DB_query($sql,$ErrMsg); - - $WoRow = DB_fetch_row($WoResult); - if ($WoRow[0]!=null){ - $WoQty = $WoRow[0]; - } else { - $WoQty = 0; - } - $OnOrder = $PurchQty + $WoQty; $Available = $QOH - $DemandQty + $OnOrder; + echo '<tr class="striped_row"> - <td>' . $myrow['stockid'] . '</td> - <td>' . $myrow['description'] . '</td> - <td>' . $myrow['stockunits'] . '</td> - <td class="number">' . locale_number_format($QOH,$DecimalPlaces) . '</td> - <td class="number">' . locale_number_format($DemandQty,$DecimalPlaces) . '</td> - <td class="number">' . locale_number_format($OnOrder, $DecimalPlaces) . '</td> - <td class="number">' . locale_number_format($Available,$DecimalPlaces) . '</td> - <td><input class="number" ' . ($i==0 ? 'autofocus="autofocus"':'') . ' tabindex="'.($j+7).'" type="text" size="6" name="Quantity'.$i.'" value="0" /> - <input type="hidden" name="StockID'.$i.'" value="'.$myrow['stockid'].'" /> + <td>', $MyRow['stockid'], '</td> + <td>', $MyRow['description'], '</td> + <td>', $MyRow['stockunits'], '</td> + <td class="number">', locale_number_format($QOH,$DecimalPlaces), '</td> + <td class="number">', locale_number_format($DemandQty,$DecimalPlaces), '</td> + <td class="number">', locale_number_format($OnOrder, $DecimalPlaces), '</td> + <td class="number">', locale_number_format($Available,$DecimalPlaces), '</td> + <td><input class="number" ', ($i==0 ? 'autofocus="autofocus"':''), ' tabindex="', ($j+7), '" type="text" size="6" name="Quantity', $i, '" value="0" /> + <input type="hidden" name="StockID', $i, '" value="', $MyRow['stockid'], '" /> </td> - </tr>'; - echo '<input type="hidden" name="DecimalPlaces'.$i.'" value="' . $myrow['decimalplaces'] . '" />'; - echo '<input type="hidden" name="ItemDescription'.$i.'" value="' . $myrow['description'] . '" />'; - echo '<input type="hidden" name="Units'.$i.'" value="' . $myrow['stockunits'] . '" />'; + </tr> + <input type="hidden" name="DecimalPlaces', $i, '" value="', $MyRow['decimalplaces'], '" /> + <input type="hidden" name="ItemDescription', $i, '" value="', $MyRow['description'], '" /> + <input type="hidden" name="Units', $i, '" value="', $MyRow['stockunits'], '" />'; $i++; } #end of while loop - echo '<tr> - <td><input type="hidden" name="Previous" value="'.($Offset-1).'" /> - <input tabindex="'.($j+7).'" type="submit" name="Prev" value="'._('Prev').'" /></td> - <td class="centre" colspan="6"><input type="hidden" name="order_items" value="1" /> - <input tabindex="'.($j+8).'" type="submit" value="'._('Add to Requisition').'" /></td> - <td><input type="hidden" name="NextList" value="'.($Offset+1).'" /> - <input tabindex="'.($j+9).'" type="submit" name="Next" value="'._('Next').'" /></td>\ - <tr/> + echo '</tbody> + <tfoot> + <tr> + <td><input type="hidden" name="PreviousList" value="', ($Offset - 1), '" /> + <input tabindex="', ($j+7), '" type="submit" name="Previous" value="', _('Previous'), '" /></td> + <td class="centre" colspan="6"><input type="hidden" name="order_items" value="1" /> + <input tabindex="', ($j+8), '" type="submit" value="', _('Add to Requisition'), '" /></td> + <td><input type="hidden" name="NextList" value="', ($Offset + 1), '" /> + <input tabindex="', ($j+9), '" type="submit" name="Next" value="', _('Next'), '" /></td> + </tr> + </tfoot> </table> - </div> - </form>'; + </div> + </form>'; }#end if SearchResults to show //********************************************************************************************************* Property changes on: trunk/InternalStockRequest.php ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Modified: trunk/doc/Change.log =================================================================== --- trunk/doc/Change.log 2018-02-12 21:53:28 UTC (rev 7957) +++ trunk/doc/Change.log 2018-02-13 00:20:44 UTC (rev 7958) @@ -1,5 +1,6 @@ webERP Change Log +12/2/18 PaulT: InternalStockRequest.php: Address a few issues reported by Paul B: Fix Previous/Next handling, table sorting, wrong on-order quantities, and apply the user's display records max. Change also removes unused code and other minor improvements. (Reported in forums: http://www.weberp.org/forum/showthread.php?tid=8089) 12/2/18 Tim (PaulT commit): StockMovements.php, StockLocMovements.php: Correct stock movements that have more than one serial number as part of it, then the item will appear multiple times in the movements script with the total quantity in each line. For example, if I enter a quantity adjustment for a controlled item, and assign 3 serial numbers to this movement and then run the inquiries, there will be 3 separate lines with a quantity of 3 against each one. 11/2/18 PaulT: SellThroughSupport.php: Remove (another) redundant hidden FormID input. (there were two, overlooked the 2nd one earlier) 11/2/18 PaulT: SellThroughSupport.php: Remove redundant hidden FormID input. |