diff --git a/InternalStockRequest.php b/InternalStockRequest.php index 45bd54539..11b685d0e 100644 --- a/InternalStockRequest.php +++ b/InternalStockRequest.php @@ -1,6 +1,6 @@ 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 '
' . _('Create another request') . '
'; + echo '
', _('Create another request'), '
'; include('includes/footer.php'); unset($_SESSION['Request']); exit; @@ -140,42 +138,42 @@ prnMsg(_('There are no items added to this request'),'error'); } -echo '

' . ' ' . $Title . '

'; +echo '

', ' ', $Title, '

'; if (isset($_GET['Edit'])) { - echo '
'; + echo ''; echo '
'; - echo ''; + echo ''; echo ''; echo ' - + '; echo ' - - + + - - + + - - + + - - + + - - + + '; - echo ''; + echo ''; echo '

' . _('Edit the Request Line') . '

', _('Edit the Request Line'), '

' . _('Line number') . '' . $_SESSION['Request']->LineItems[$_GET['Edit']]->LineNumber . '', _('Line number'), '', $_SESSION['Request']->LineItems[$_GET['Edit']]->LineNumber, '
' . _('Stock Code') . '' . $_SESSION['Request']->LineItems[$_GET['Edit']]->StockID . '', _('Stock Code'), '', $_SESSION['Request']->LineItems[$_GET['Edit']]->StockID, '
' . _('Item Description') . '' . $_SESSION['Request']->LineItems[$_GET['Edit']]->ItemDescription . '', _('Item Description'), '', $_SESSION['Request']->LineItems[$_GET['Edit']]->ItemDescription, '
' . _('Unit of Measure') . '' . $_SESSION['Request']->LineItems[$_GET['Edit']]->UOM . '', _('Unit of Measure'), '', $_SESSION['Request']->LineItems[$_GET['Edit']]->UOM, '
' . _('Quantity Requested') . '', _('Quantity Requested'), '

'; echo '
- +
'; @@ -183,13 +181,12 @@ exit; } -echo '
'; -echo '
'; -echo ''; - -echo ''; -echo ' - +echo ' +
+ +

' . _('Internal Stock Request Details') . '

+ + '; @@ -211,9 +208,9 @@ echo ' @@ -229,30 +226,28 @@ $result=DB_query($sql); echo ' - '; -echo ' - '; - -echo ' - - + + + + + +

', _('Internal Stock Request Details'), '

' . _('Department') . ':
' . _('Date when required') . ':
' . _('Narrative') . ':', _('Date when required'), ':
', _('Narrative'), ':
-
'; - -echo '
- +
+
+
'; @@ -262,33 +257,32 @@ exit; } -$i = 0; //Line Item Array pointer -echo '
'; -echo '
'; -echo ''; -echo '
+echo ' +
+ +
- + - - - - - + + + + + '; if (isset($_SESSION['Request']->LineItems)) { foreach ($_SESSION['Request']->LineItems as $LineItems) { echo ' - - - - - - - + + + + + + + '; } } @@ -296,77 +290,88 @@ echo '

' . _('Details of Items Requested') . '

', _('Details of Items Requested'), '

' . _('Line Number') . '' . _('Item Code') . '' . _('Item Description'). '' . _('Quantity Required'). '' . _('UOM'). '', _('Line Number'), '', _('Item Code'), '', _('Item Description'), '', _('Quantity Required'), '', _('UOM'), '
' . $LineItems->LineNumber . '' . $LineItems->StockID . '' . $LineItems->ItemDescription . '' . locale_number_format($LineItems->Quantity, $LineItems->DecimalPlaces) . '' . $LineItems->UOM . '' . _('Edit') . '' . _('Delete') . '', $LineItems->LineNumber, '', $LineItems->StockID, '', $LineItems->ItemDescription, '', locale_number_format($LineItems->Quantity, $LineItems->DecimalPlaces), '', $LineItems->UOM, '', _('Edit'), '', _('Delete'), '

- +

'; -echo '
'; -echo '
'; -echo ''; +echo '

+ ', ' ', _('Search for Inventory Items'), + '

+ +
+ '; -echo '

' . ' ' . _('Search for Inventory Items'). '

'; $SQL = "SELECT stockcategory.categoryid, stockcategory.categorydescription - FROM stockcategory, internalstockcatrole - WHERE stockcategory.categoryid = internalstockcatrole.categoryid - AND internalstockcatrole.secroleid= " . $_SESSION['AccessLevel'] . " + 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 '

' . _('Problem Report') . ':
' . _('There are no stock categories currently defined please use the link below to set them up') . '

'; - echo '
- ' . _('Define Stock Categories') . ''; + echo '

', _('Problem Report'), ':
', _('There are no stock categories currently defined please use the link below to set them up'), '

+
+ ', _('Define Stock Categories'), ''; exit; } + echo ' - '; + '; + if (isset($_POST['Keywords'])) { - echo ''; + echo ''; } else { echo ''; } + echo ' - '; + '; if (isset($_POST['StockCode'])) { - echo ''; + echo ''; } else { echo ''; } + echo '
' . _('In Stock Category') . ':' . _('Enter partial') . ' ' . _('Description') . ':', _('Enter partial'), ' ', _('Description'), ':

' . _('OR') . ' ' . '

' . _('Enter partial') . ' ' . _('Stock Code') . ':

', _('OR'), ' ', '

', _('Enter partial'), ' ', _('Stock Code'), ':

- +

'; -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,29 +391,29 @@ 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, stockmaster.description, stockmaster.units as stockunits, stockmaster.decimalplaces - FROM stockmaster, - stockcategory, - internalstockcatrole - WHERE stockmaster.categoryid=stockcategory.categoryid - AND stockcategory.categoryid = internalstockcatrole.categoryid - AND internalstockcatrole.secroleid= " . $_SESSION['AccessLevel'] . " - AND stockmaster.mbflag <>'G' + 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.description " . LIKE . " '" . $SearchString . "' AND stockmaster.categoryid='" . $_POST['StockCat'] . "' ORDER BY stockmaster.stockid"; @@ -423,30 +429,30 @@ 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, 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,28 +463,28 @@ stockmaster.description, stockmaster.units as stockunits, stockmaster.decimalplaces - FROM stockmaster, - stockcategory, - internalstockcatrole - WHERE stockmaster.categoryid=stockcategory.categoryid - AND stockcategory.categoryid = internalstockcatrole.categoryid - AND internalstockcatrole.secroleid= " . $_SESSION['AccessLevel'] . " - AND stockmaster.mbflag <>'G' + 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'] . " ORDER BY stockmaster.stockid"; } else { $SQL = "SELECT stockmaster.stockid, stockmaster.description, stockmaster.units as stockunits, stockmaster.decimalplaces - FROM stockmaster, - stockcategory, - internalstockcatrole - WHERE stockmaster.categoryid=stockcategory.categoryid - AND stockcategory.categoryid = internalstockcatrole.categoryid - AND internalstockcatrole.secroleid= " . $_SESSION['AccessLevel'] . " - AND stockmaster.mbflag <>'G' + 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.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,129 +513,49 @@ } } //end of if search -/* display list if there is more than one record */ -if (isset($searchresult) AND !isset($_POST['Select'])) { - echo '
'; - echo '
'; - echo ''; - $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 '

  ' . $_POST['PageOffset'] . ' ' . _('of') . ' ' . $ListPageMax . ' ' . _('pages') . '. ' . _('Go to Page') . ': '; - echo ' - - - - - - -
-
'; - } - echo ''; - echo ' - - - - - - '; - $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 = '

' . _('Obsolete') . '

'; - } else { - $ItemStatus =''; - } - - echo ' - - - - - - - '; - //end of page full new headings if - } - //end of while loop - echo '
' . _('Code') . '' . _('Description') . '' . _('Total Qty On Hand') . '' . _('Units') . '' . _('Stock Status') . '
' . $myrow['description'] . '' . $qoh . '' . $myrow['units'] . '' . _('View') . '' . $ItemStatus . '
-
-
-
'; - } -} -/* end display list if there is more than one record */ if (isset($SearchResult)) { $j = 1; echo '
-
' . _('Select an item by entering the quantity required. Click Order when ready.') . '
+
', _('Select an item by entering the quantity required. Click Order when ready.'), '

-
+
- + + + + + + + + + - - - - - - - - + + + + + + + + '; $ImageSource = _('No Image'); $i=0; 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'] . "'"; @@ -642,15 +568,16 @@ $QOHSQL = "SELECT sum(locstock.quantity) AS qoh FROM locstock - WHERE locstock.stockid='" .$myrow['stockid'] . "' AND - loccode = '" . $_SESSION['Request']->Location . "'"; + 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 + FROM salesorderdetails + INNER JOIN salesorders ON salesorders.orderno = salesorderdetails.orderno WHERE salesorders.fromstkloc='" . $_SESSION['Request']->Location . "' AND salesorderdetails.completed=0 @@ -666,68 +593,41 @@ $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'] . "'"; - - $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; - } + $PurchQty = GetQuantityOnOrderDueToPurchaseOrders($MyRow['stockid'], ''); + $WoQty = GetQuantityOnOrderDueToWorkOrders($MyRow['stockid'], ''); $OnOrder = $PurchQty + $WoQty; $Available = $QOH - $DemandQty + $OnOrder; + echo ' - - - - - - - - + + + + + + + - '; - echo ''; - echo ''; - echo ''; + + + + '; $i++; } #end of while loop - echo ' - + echo ' + + + - \ - + + + +
- - - - -
' . _('Code') . '' . _('Description') . '' . _('Units') . '' . _('On Hand') . '' . _('On Demand') . '' . _('On Order') . '' . _('Available') . '' . _('Quantity') . '', _('Code'), '', _('Description'), '', _('Units'), '', _('On Hand'), '', _('On Demand'), '', _('On Order'), '', _('Available'), '', _('Quantity'), '
' . $myrow['stockid'] . '' . $myrow['description'] . '' . $myrow['stockunits'] . '' . locale_number_format($QOH,$DecimalPlaces) . '' . locale_number_format($DemandQty,$DecimalPlaces) . '' . locale_number_format($OnOrder, $DecimalPlaces) . '' . locale_number_format($Available,$DecimalPlaces) . ' - + ', $MyRow['stockid'], '', $MyRow['description'], '', $MyRow['stockunits'], '', locale_number_format($QOH,$DecimalPlaces), '', locale_number_format($DemandQty,$DecimalPlaces), '', locale_number_format($OnOrder, $DecimalPlaces), '', locale_number_format($Available,$DecimalPlaces), ' +
-
+ - -
+
'; diff --git a/doc/Change.log b/doc/Change.log index debab61da..2f07c08c2 100644 --- a/doc/Change.log +++ b/doc/Change.log @@ -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.