Skip to content

Commit

Permalink
Paul Becker (PaulT commit): InternalStockRequestFulfill.php: Add cont…
Browse files Browse the repository at this point in the history
…rolled stock handling within this script. (Reported in forums: http://www.weberp.org/forum/showthread.php?tid=8086)

Signed-off-by: Paul Thursby <pthursby2@gmail.com>
  • Loading branch information
Paul Becker authored and timschofield committed Feb 27, 2018
1 parent 21b6010 commit a88d57e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
50 changes: 45 additions & 5 deletions InternalStockRequestFulfill.php
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 . "'
Expand Down Expand Up @@ -296,7 +328,7 @@
<td>' . $myrow['dispatchid'] . '</td>
<td>' . $myrow['description'] . '</td>
<td>' . $myrow['locationname'] . '</td>
<td>' . ConvertSQLDate($myrow['despatchdate']) . '</td>
<td class="centre">' . ConvertSQLDate($myrow['despatchdate']) . '</td>
<td>' . $myrow['narrative'] . '</td>
</tr>';
$LineSQL="SELECT stockrequestitems.dispatchitemsid,
Expand All @@ -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
Expand All @@ -323,6 +356,7 @@
<th>' . _('Quantity') . '<br />' . _('Required') . '</th>
<th>' . _('Quantity') . '<br />' . _('Delivered') . '</th>
<th>' . _('Units') . '</th>
<th>' . _('Lot/Batch/Serial') . '</th>
<th>' . _('Completed') . '</th>
<th>' . _('Tag') . '</th>
</tr>';
Expand All @@ -331,9 +365,14 @@
echo '<tr>
<td>' . $LineRow['description'] . '</td>
<td class="number">' . locale_number_format($LineRow['quantity']-$LineRow['qtydelivered'],$LineRow['decimalplaces']) . '</td>
<td class="number"><input type="text" class="number" name="'. $LineRow['dispatchid'] . 'Qty'. $LineRow['dispatchitemsid'] . '" value="'.locale_number_format($LineRow['quantity']-$LineRow['qtydelivered'],$LineRow['decimalplaces']).'" /></td>
<td>' . $LineRow['uom'] . '</td>
<td><input type="checkbox" name="'. $LineRow['dispatchid'] . 'Completed'. $LineRow['dispatchitemsid'] . '" /></td>
<td class="number"><input type="text" class="number" name="'. $LineRow['dispatchid'] . 'Qty' . $LineRow['dispatchitemsid'] . '" value="'.locale_number_format($LineRow['quantity']-$LineRow['qtydelivered'],$LineRow['decimalplaces']).'" /></td>
<td>' . $LineRow['uom'] . '</td>';
if ($LineRow['controlled'] == 1) {
echo '<td class="number"><input type="text" class="number" name="'. $LineRow['dispatchid'] . 'Ser' . $LineRow['dispatchitemsid'] .'" /></td>';
} else {
echo '<td>' . _('Stock item is not controlled') . '</td>';
}
echo '<td class="centre"><input type="checkbox" name="'. $LineRow['dispatchid'] . 'Completed'. $LineRow['dispatchitemsid'] . '" /></td>
<td><select name="'. $LineRow['dispatchid'] . 'Tag'. $LineRow['dispatchitemsid'] . '">';

$SQL = "SELECT tagref,
Expand All @@ -357,6 +396,7 @@
echo '<input type="hidden" class="number" name="'. $LineRow['dispatchid'] . 'Location'. $LineRow['dispatchitemsid'] . '" value="'.$_POST['Location'].'" />';
echo '<input type="hidden" class="number" name="'. $LineRow['dispatchid'] . 'RequestedQuantity'. $LineRow['dispatchitemsid'] . '" value="'.locale_number_format($LineRow['quantity']-$LineRow['qtydelivered'],$LineRow['decimalplaces']).'" />';
echo '<input type="hidden" class="number" name="'. $LineRow['dispatchid'] . 'Department'. $LineRow['dispatchitemsid'] . '" value="'.$myrow['description'].'" />';
echo '<input type="hidden" class="number" name="'. $LineRow['dispatchid'] . 'Controlled'. $LineRow['dispatchitemsid'] . '" value="'.$LineRow['controlled'].'" />';
} // end while order line detail
echo '</table></td></tr>';
} //end while header loop
Expand Down
1 change: 1 addition & 0 deletions 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.
Expand Down

0 comments on commit a88d57e

Please sign in to comment.