From a88d57e9e0208b200eb0483e47a20e642910cb91 Mon Sep 17 00:00:00 2001 From: Paul Becker Date: Tue, 27 Feb 2018 09:40:39 +0000 Subject: [PATCH] Paul Becker (PaulT commit): InternalStockRequestFulfill.php: Add controlled stock handling within this script. (Reported in forums: http://www.weberp.org/forum/showthread.php?tid=8086) Signed-off-by: Paul Thursby --- InternalStockRequestFulfill.php | 50 +++++++++++++++++++++++++++++---- doc/Change.log | 1 + 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/InternalStockRequestFulfill.php b/InternalStockRequestFulfill.php index 6cd59f044..c2f0ffe20 100644 --- a/InternalStockRequestFulfill.php +++ b/InternalStockRequestFulfill.php @@ -24,6 +24,8 @@ $Department = $_POST[$RequestID.'Department'.$LineID]; $Tag = $_POST[$RequestID.'Tag'.$LineID]; $RequestedQuantity = filter_number_format($_POST[$RequestID.'RequestedQuantity'.$LineID]); + $Controlled = $_POST[$RequestID.'Controlled'.$LineID]; + $SerialNo = $_POST[$RequestID.'Ser'.$LineID]; if (isset($_POST[$RequestID.'Completed'.$LineID])) { $Completed=True; } else { @@ -93,6 +95,36 @@ /*Get the ID of the StockMove... */ $StkMoveNo = DB_Last_Insert_ID('stockmoves','stkmoveno'); + + if ($Controlled == 1) { + /*We need to add the StockSerialItem record and the StockSerialMoves as well */ + + $SQL = "UPDATE stockserialitems SET quantity= quantity - " . $Quantity . " + WHERE stockid='" . $StockID . "' + AND loccode='" . $Location . "' + AND serialno='" . $SerialNo . "'"; + + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The serial stock item record could not be updated because'); + $DbgMsg = _('The following SQL to update the serial stock item record was used'); + $Result = DB_query($SQL, $ErrMsg, $DbgMsg, true); + + /* now insert the serial stock movement */ + + $SQL = "INSERT INTO stockserialmoves (stockmoveno, + stockid, + serialno, + moveqty) + VALUES ('" . $StkMoveNo . "', + '" . $StockID . "', + '" . $SerialNo . "', + '" . -$Quantity . "')"; + + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The serial stock movement record could not be inserted because'); + $DbgMsg = _('The following SQL to insert the serial stock movement records was used'); + $Result = DB_query($SQL, $ErrMsg, $DbgMsg, true); + } /*end if the orderline is a controlled item */ + + $SQL="UPDATE stockrequestitems SET qtydelivered=qtydelivered+" . $Quantity . " WHERE dispatchid='" . $RequestID . "' @@ -296,7 +328,7 @@ ' . $myrow['dispatchid'] . ' ' . $myrow['description'] . ' ' . $myrow['locationname'] . ' - ' . ConvertSQLDate($myrow['despatchdate']) . ' + ' . ConvertSQLDate($myrow['despatchdate']) . ' ' . $myrow['narrative'] . ' '; $LineSQL="SELECT stockrequestitems.dispatchitemsid, @@ -306,7 +338,8 @@ stockrequestitems.uom, stockmaster.description, stockrequestitems.quantity, - stockrequestitems.qtydelivered + stockrequestitems.qtydelivered, + stockmaster.controlled FROM stockrequestitems LEFT JOIN stockmaster ON stockmaster.stockid=stockrequestitems.stockid @@ -323,6 +356,7 @@ ' . _('Quantity') . '
' . _('Required') . ' ' . _('Quantity') . '
' . _('Delivered') . ' ' . _('Units') . ' + ' . _('Lot/Batch/Serial') . ' ' . _('Completed') . ' ' . _('Tag') . ' '; @@ -331,9 +365,14 @@ echo ' ' . $LineRow['description'] . ' ' . locale_number_format($LineRow['quantity']-$LineRow['qtydelivered'],$LineRow['decimalplaces']) . ' - - ' . $LineRow['uom'] . ' - + + ' . $LineRow['uom'] . ''; + if ($LineRow['controlled'] == 1) { + echo ''; + } else { + echo '' . _('Stock item is not controlled') . ''; + } + echo ' '; echo ''; echo ''; + echo ''; } // end while order line detail echo ''; } //end while header loop diff --git a/doc/Change.log b/doc/Change.log index 8ac71f6df..1b10b7dfe 100644 --- a/doc/Change.log +++ b/doc/Change.log @@ -1,5 +1,6 @@ webERP Change Log +9/2/18 Paul Becker (PaulT commit): InternalStockRequestFulfill.php: Add controlled stock handling within this script. (Reported in forums: http://www.weberp.org/forum/showthread.php?tid=8086) 9/2/18 Tim/PaulT: MRPPlannedPurchaseOrders.php, MRPPlannedWorkOrders.php: Fix conversion factor matter noted by Tim, use DB_table_exists() from commit 7943 to replace table check query, and minor rework to 'missing cell' handling from commit 7939. 9/2/18 PaulT: Replace old method of table row alternating color handing with improved CSS. Also, this change removes some empty/unused properties from a few css file and removes old URL 'SID' references in files already modified for this commit. Due to SVN issues with TestPlanResults.php, this one file will be committed later. 9/2/18 Tim (PaulT commit): ConnectDB_xxxx.inc files: Add function DB_table_exists() function to all DB support files, by Tim suggestion. Note that this function will be used in other files in a future commit.