From 45f169be1a508c8bc6d7279e678a15c336210a66 Mon Sep 17 00:00:00 2001 From: Tim Schofield Date: Tue, 27 Feb 2018 11:11:12 +0000 Subject: [PATCH] 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. Signed-off-by: Paul Thursby --- StockLocMovements.php | 191 ++++++++++++++++---------------- StockMovements.php | 247 +++++++++++++++++++++--------------------- doc/Change.log | 1 + 3 files changed, 226 insertions(+), 213 deletions(-) diff --git a/StockLocMovements.php b/StockLocMovements.php index 113647653..bfab7c5d4 100644 --- a/StockLocMovements.php +++ b/StockLocMovements.php @@ -7,59 +7,75 @@ include('includes/header.php'); -echo '
'; -echo '
'; -echo ''; - -echo '

' . ' ' . $Title . '

'; - -echo ' - - + + + + + + + + + + + + '; + } + //end of while loop + echo '
' . _('From Stock Location') . ': + + + +echo ' ', _('Show Movements before'), ': ', + ' ', _('But after'), ': ', + '
', _('From Stock Location'), ':'; -if (!isset($_POST['BeforeDate']) OR !Is_Date($_POST['BeforeDate'])){ +if (!isset($_POST['BeforeDate']) or !Is_date($_POST['BeforeDate'])) { $_POST['BeforeDate'] = Date($_SESSION['DefaultDateFormat']); } -if (!isset($_POST['AfterDate']) OR !Is_Date($_POST['AfterDate'])){ - $_POST['AfterDate'] = Date($_SESSION['DefaultDateFormat'], Mktime(0,0,0,Date('m')-1,Date('d'),Date('y'))); +if (!isset($_POST['AfterDate']) or !Is_date($_POST['AfterDate'])) { + $_POST['AfterDate'] = Date($_SESSION['DefaultDateFormat'], Mktime(0, 0, 0, Date('m') - 1, Date('d'), Date('y'))); } -echo ' ' . _('Show Movements before') . ': '; -echo ' ' . _('But after') . ': '; -echo '
-
'; -echo '
- +
+

'; +if ($_POST['StockLocation'] == 'All') { + $_POST['StockLocation'] = '%%'; +} $SQLBeforeDate = FormatDateForSQL($_POST['BeforeDate']); $SQLAfterDate = FormatDateForSQL($_POST['AfterDate']); $sql = "SELECT stockmoves.stockid, + stockmoves.stkmoveno, systypes.typename, stockmoves.type, stockmoves.transno, @@ -71,82 +87,73 @@ stockmoves.price, stockmoves.discountpercent, stockmoves.newqoh, - stockmaster.decimalplaces, - stockserialmoves.serialno + stockmaster.controlled, + stockmaster.serialised, + stockmaster.decimalplaces FROM stockmoves - INNER JOIN systypes ON stockmoves.type=systypes.typeid - INNER JOIN stockmaster ON stockmoves.stockid=stockmaster.stockid - LEFT JOIN stockserialmoves ON stockmoves.stkmoveno=stockserialmoves.stockmoveno - WHERE stockmoves.loccode='" . $_POST['StockLocation'] . "' - AND stockmoves.trandate >= '". $SQLAfterDate . "' + INNER JOIN systypes + ON stockmoves.type=systypes.typeid + INNER JOIN stockmaster + ON stockmoves.stockid=stockmaster.stockid + WHERE stockmoves.loccode " . LIKE . " '" . $_POST['StockLocation'] . "' + AND stockmoves.trandate >= '" . $SQLAfterDate . "' AND stockmoves.trandate <= '" . $SQLBeforeDate . "' AND hidemovt=0 ORDER BY stkmoveno DESC"; - $ErrMsg = _('The stock movements for the selected criteria could not be retrieved because'); -$MovtsResult = DB_query($sql,$ErrMsg); - -echo ''; -$tableheader = ' - - - - - - - - - - - +$MovtsResult = DB_query($SQL, $ErrMsg); + +if (DB_num_rows($MovtsResult) > 0) { + echo '
' . _('Item Code') . '' . _('Type') . '' . _('Trans No') . '' . _('Date') . '' . _('Customer') . '' . _('Quantity') . '' . _('Reference') . '' . _('Price') . '' . _('Discount') . '' . _('Quantity on Hand') . '' . _('Serial No.') . '
+ + + + + + + + + + + + '; -echo $tableheader; - -$j = 1; -while ($myrow=DB_fetch_array($MovtsResult)) { + while ($MyRow = DB_fetch_array($MovtsResult)) { $DisplayTranDate = ConvertSQLDate($myrow['trandate']); - printf(' - - - - - - - - - - - - ', - mb_strtoupper($myrow['stockid']), - mb_strtoupper($myrow['stockid']), - $myrow['typename'], - $myrow['transno'], - $DisplayTranDate, - $myrow['debtorno'], - locale_number_format($myrow['qty'], - $myrow['decimalplaces']), - $myrow['reference'], - locale_number_format($myrow['price'],$_SESSION['CompanyRecord']['decimalplaces']), - locale_number_format($myrow['discountpercent']*100,2), - locale_number_format($myrow['newqoh'],$myrow['decimalplaces']), - $myrow['serialno']); - $j++; - If ($j == 16){ - $j=1; - echo $tableheader; + $SerialSQL = "SELECT serialno, moveqty FROM stockserialmoves WHERE stockmoveno='" . $MyRow['stkmoveno'] . "'"; + $SerialResult = DB_query($SerialSQL); + + $SerialText = ''; + while ($SerialRow = DB_fetch_array($SerialResult)) { + if ($MyRow['serialised'] == 1) { + $SerialText .= $SerialRow['serialno'] . '
'; + } else { + $SerialText .= $SerialRow['serialno'] . ' Qty- ' . $SerialRow['moveqty'] . '
'; + } } -//end of page full new headings if -} -//end of while loop -echo '
', _('Item Code'), '', _('Type'), '', _('Trans No'), '', _('Date'), '', _('Customer'), '', _('Quantity'), '', _('Reference'), '', _('Price'), '', _('Discount'), '', _('Quantity on Hand'), '', _('Serial No.'), '
%s%s%s%s%s%s%s%s%s%s%s
'; -echo '
- '; + echo '
', mb_strtoupper($MyRow['stockid']), '', $MyRow['typename'], '', $MyRow['transno'], '', $DisplayTranDate, '', $MyRow['debtorno'], '', locale_number_format($MyRow['qty'], $MyRow['decimalplaces']), '', $MyRow['reference'], '', locale_number_format($MyRow['price'], $_SESSION['CompanyRecord']['decimalplaces']), '', locale_number_format($MyRow['discountpercent'] * 100, 2), '%', locale_number_format($MyRow['newqoh'], $MyRow['decimalplaces']), '', $SerialText, '
'; +} +echo ''; -include('includes/footer.php'); +include ('includes/footer.php'); ?> \ No newline at end of file diff --git a/StockMovements.php b/StockMovements.php index 419180d58..46eae63a0 100644 --- a/StockMovements.php +++ b/StockMovements.php @@ -5,8 +5,8 @@ include('includes/session.php'); $Title = _('Stock Movements'); /* webERP manual links before header.php */ -$ViewTopic= "Inventory"; -$BookMark = "InventoryMovement"; +$ViewTopic= 'Inventory'; +$BookMark = 'InventoryMovement'; include('includes/header.php'); if (isset($_GET['StockID'])){ @@ -17,13 +17,22 @@ $StockID = ''; } -$result = DB_query("SELECT description, units FROM stockmaster WHERE stockid='".$StockID."'"); -$myrow = DB_fetch_row($result); -echo '

' . ' ' . $StockID . ' - ' . $myrow['0'] . ' : ' . _('in units of') . ' : ' . $myrow[1] . '

'; +$StockInfo = ''; +if ('' != $StockID) { + $result = DB_query("SELECT description, units FROM stockmaster WHERE stockid='" . $StockID . "'"); + $myrow = DB_fetch_row($result); -echo '
'; -echo '
'; -echo ''; + $StockInfo = '
' . $StockID . ' - ' . $myrow['0'] . ' : ' . _('in units of') . ' : ' . $myrow[1] . ''; +} + +echo '

+ ', $Title, + $StockInfo, + '

'; + +echo ' +
+ '; if (!isset($_POST['BeforeDate']) OR !Is_Date($_POST['BeforeDate'])){ $_POST['BeforeDate'] = Date($_SESSION['DefaultDateFormat']); @@ -31,19 +40,23 @@ if (!isset($_POST['AfterDate']) OR !Is_Date($_POST['AfterDate'])){ $_POST['AfterDate'] = Date($_SESSION['DefaultDateFormat'], Mktime(0,0,0,Date('m')-3,Date('d'),Date('y'))); } + echo '
- '; -echo '
' . _('Stock Code') . ':'; + + + '; echo ' - + '; $SQLBeforeDate = FormatDateForSQL($_POST['BeforeDate']); @@ -72,6 +89,7 @@ $sql = "SELECT stockmoves.stockid, systypes.typename, + stockmoves.stkmoveno, stockmoves.type, stockmoves.transno, stockmoves.trandate, @@ -84,13 +102,15 @@ stockmoves.discountpercent, stockmoves.newqoh, stockmaster.decimalplaces, - stockserialmoves.serialno + stockmaster.controlled, + stockmaster.serialised FROM stockmoves - INNER JOIN systypes ON stockmoves.type=systypes.typeid - INNER JOIN stockmaster ON stockmoves.stockid=stockmaster.stockid - LEFT JOIN stockserialmoves ON stockmoves.stkmoveno=stockserialmoves.stockmoveno + INNER JOIN systypes + ON stockmoves.type=systypes.typeid + INNER JOIN stockmaster + ON stockmoves.stockid=stockmaster.stockid WHERE stockmoves.loccode='" . $_POST['StockLocation'] . "' - AND stockmoves.trandate >= '". $SQLAfterDate . "' + AND stockmoves.trandate >= '" . $SQLAfterDate . "' AND stockmoves.stockid = '" . $StockID . "' AND stockmoves.trandate <= '" . $SQLBeforeDate . "' AND hidemovt=0 @@ -101,7 +121,10 @@ $MovtsResult = DB_query($sql, $ErrMsg, $DbgMsg); -$tableheader = ' +if (DB_num_rows($MovtsResult) > 0) { + $myrow = DB_fetch_array($MovtsResult); + + echo ' @@ -112,119 +135,101 @@ - - - '; - -echo $tableheader; + '; + if ($myrow['controlled'] == 1) { + echo ''; + } + echo ''; -$j = 1; + DB_data_seek($MovtsResult, 0); -while ($myrow=DB_fetch_array($MovtsResult)) { + while ($myrow = DB_fetch_array($MovtsResult)) { $DisplayTranDate = ConvertSQLDate($myrow['trandate']); - if ($myrow['type']==10){ /*its a sales invoice allow link to show invoice it was sold on*/ - - printf(' - - - - - - - - - - - - - ', - $RootPath, - $myrow['transno'], - $myrow['typename'], - $myrow['transno'], - $DisplayTranDate, - $myrow['userid'], - $myrow['debtorno'], - $myrow['branchcode'], - locale_number_format($myrow['qty'],$myrow['decimalplaces']), - $myrow['reference'], - locale_number_format($myrow['price'],$_SESSION['CompanyRecord']['decimalplaces']), - locale_number_format($myrow['discountpercent']*100,2), - locale_number_format($myrow['newqoh'],$myrow['decimalplaces']), - $myrow['serialno']); + $SerialSQL = "SELECT serialno, moveqty FROM stockserialmoves WHERE stockmoveno='" . $myrow['stkmoveno'] . "'"; + $SerialResult = DB_query($SerialSQL); + + $SerialText = ''; + while ($SerialRow = DB_fetch_array($SerialResult)) { + if ($myrow['serialised'] == 1) { + $SerialText .= $SerialRow['serialno'] . '
'; + } else { + $SerialText .= $SerialRow['serialno'] . ' Qty- ' . $SerialRow['moveqty'] . '
'; + } + } + + if ($myrow['type']==10){ + /*its a sales invoice allow link to show invoice it was sold on*/ + + echo ' + + + + + + + + + + + '; + if ($myrow['controlled'] == 1) { + echo ''; + } + echo ''; } elseif ($myrow['type']==11){ - printf(' - - - - - - - - - - - - - ', - $RootPath, - $myrow['transno'], - $myrow['typename'], - $myrow['transno'], - $DisplayTranDate, - $myrow['userid'], - $myrow['debtorno'], - $myrow['branchcode'], - locale_number_format($myrow['qty'],$myrow['decimalplaces']), - $myrow['reference'], - locale_number_format($myrow['price'],$_SESSION['CompanyRecord']['decimalplaces']), - locale_number_format($myrow['discountpercent']*100,2), - locale_number_format($myrow['newqoh'],$myrow['decimalplaces']), - $myrow['serialno']); + echo ' + + + + + + + + + + + '; + if ($myrow['controlled'] == 1) { + echo ''; + } + echo ''; + } else { - printf(' - - - - - - - - - - - - - ', - $myrow['typename'], - $myrow['transno'], - $DisplayTranDate, - $myrow['userid'], - $myrow['debtorno'], - $myrow['branchcode'], - locale_number_format($myrow['qty'],$myrow['decimalplaces']), - $myrow['reference'], - locale_number_format($myrow['price'],$_SESSION['CompanyRecord']['decimalplaces']), - locale_number_format($myrow['discountpercent']*100,2), - locale_number_format($myrow['newqoh'],$myrow['decimalplaces']), - $myrow['serialno']); + echo ' + + + + + + + + + + + '; + if ($myrow['controlled'] == 1) { + echo ''; + } + echo ''; + + } + //end of page full new headings if } -//end of page full new headings if + //end of while loop } -//end of while loop - -echo '
', _('Stock Code'), ':'; -echo ' ' . _('From Stock Location') . ': '; -$sql = "SELECT locations.loccode, locationname FROM locations +$SQL = "SELECT locations.loccode, + locationname + FROM locations INNER JOIN locationusers ON locationusers.loccode=locations.loccode AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canview=1 - ORDER BY locationname - "; + ORDER BY locationname"; + $resultStkLocs = DB_query($sql); while ($myrow=DB_fetch_array($resultStkLocs)){ @@ -64,7 +77,11 @@ echo '
' . _('Show Movements between') . ': ' . _('and') . ': ', _('Show Movements between'), ': + ' . _('and') . ': + + +
' . _('Type') . ' ' . _('Number') . ' ' . _('Date') . '' . _('Reference') . ' ' . _('Price') . ' ' . _('Discount') . '' . _('New Qty') . '' . _('Serial No.') . '
' . _('New Qty') . '', _('Serial No.'), '
%s%s%s%s%s%s%s%s%s%s%%%s%s
', $myrow['typename'], '', $myrow['transno'], '', $DisplayTranDate, '', $myrow['userid'], '', $myrow['debtorno'], '', $myrow['branchcode'], '', locale_number_format($myrow['qty'], $myrow['decimalplaces']), '', $myrow['reference'], '', locale_number_format($myrow['price'], $_SESSION['CompanyRecord']['decimalplaces']), '', locale_number_format($myrow['discountpercent'] * 100, 2), '%%', locale_number_format($myrow['newqoh'], $myrow['decimalplaces']), '', $SerialText, '
%s%s%s%s%s%s%s%s%s%s%%%s%s
', $myrow['typename'], '', $myrow['transno'], '', $DisplayTranDate, '', $myrow['userid'], '', $myrow['debtorno'], '', $myrow['branchcode'], '', locale_number_format($myrow['qty'], $myrow['decimalplaces']), '', $myrow['reference'], '', locale_number_format($myrow['price'], $_SESSION['CompanyRecord']['decimalplaces']), '', locale_number_format($myrow['discountpercent'] * 100, 2), '%%', locale_number_format($myrow['newqoh'], $myrow['decimalplaces']), '', $SerialText, '
%s%s%s%s%s%s%s%s%s%s%%%s%s
', $myrow['typename'], '', $myrow['transno'], '', $DisplayTranDate, '', $myrow['userid'], '', $myrow['debtorno'], '', $myrow['branchcode'], '', locale_number_format($myrow['qty'], $myrow['decimalplaces']), '', $myrow['reference'], '', locale_number_format($myrow['price'], $_SESSION['CompanyRecord']['decimalplaces']), '', locale_number_format($myrow['discountpercent'] * 100, 2), '%', locale_number_format($myrow['newqoh'], $myrow['decimalplaces']), '', $SerialText, '
'; -echo ' +echo '
+
'; diff --git a/doc/Change.log b/doc/Change.log index 5ab5d805e..debab61da 100644 --- a/doc/Change.log +++ b/doc/Change.log @@ -1,5 +1,6 @@ webERP Change Log +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. 11/2/18 PaulT: Contracts.php: Move closing form tag outside of condition. Fixes view page source message "Saw a form start tag, but there was already an active form element. Nested forms are not allowed. Ignoring the tag." reported in Firefox.