From b2080a61a97a787af8ea85e20eb006595a518087 Mon Sep 17 00:00:00 2001 From: PaulT Date: Thu, 1 Mar 2018 17:29:44 -0500 Subject: [PATCH] Update StockLocMovements.php Replacing full file content. Had a bad commit with another file previously. --- StockLocMovements.php | 784 ++++-------------------------------------- 1 file changed, 76 insertions(+), 708 deletions(-) diff --git a/StockLocMovements.php b/StockLocMovements.php index f17a25313..800ed0285 100644 --- a/StockLocMovements.php +++ b/StockLocMovements.php @@ -1,413 +1,58 @@ >>>>>> parent of 01188779... Update StockLocMovements.php -======= ->>>>>>> parent of 01188779... Update StockLocMovements.php +/* $Id: StockLocMovements.php 7957 2018-02-12 21:53:28Z turbopt $*/ include('includes/session.php'); -$Title = _('Search Pick Lists '); + +$Title = _('All Stock Movements By Location'); + include('includes/header.php'); echo '

- ', ' ', _('Pick Lists'), ' + ', ' ', $Title, '

'; -if (isset($_GET['SelectedStockItem'])) { - $SelectedStockItem = $_GET['SelectedStockItem']; -} elseif (isset($_POST['SelectedStockItem'])) { - $SelectedStockItem = $_POST['SelectedStockItem']; -} else { - $SelectedStockItem = ''; -} - -if (isset($_GET['OrderNumber'])) { - $OrderNumber = $_GET['OrderNumber']; -} elseif (isset($_POST['OrderNumber'])) { - $OrderNumber = $_POST['OrderNumber']; -} else { - $OrderNumber = ''; -} - -if (isset($_GET['PickList'])) { - $PickList = $_GET['PickList']; -} elseif (isset($_POST['PickList'])) { - $PickList = $_POST['PickList']; -} else { - $PickList = ''; -} - -if (!isset($_POST['Status'])) { - $_POST['Status'] = 'New'; -} - echo '
- '; - -if (isset($_POST['ResetPart'])) { - unset($SelectedStockItem); -} -<<<<<<< HEAD - -if (isset($OrderNumber) and $OrderNumber != '') { - if (!is_numeric($OrderNumber)) { - prnMsg(_('The Order Number entered') . ' ' . _('MUST') . ' ' . _('be numeric'), 'error'); - unset($OrderNumber); - } else { - echo _('Order Number') . ' - ' . $OrderNumber; - } -} - -if (isset($PickList) and $PickList != '') { - if (!is_numeric($PickList)) { - prnMsg(_('The Pick List entered') . ' ' . _('MUST') . ' ' . _('be numeric'), 'error'); - unset($PickList); - } else { - echo _('Pick List') . ' - ' . $PickList; - } -} - -<<<<<<< HEAD -$resultStkLocs = DB_query($sql); -======= -if (isset($_POST['SearchParts'])) { - if ($_POST['Keywords'] and $_POST['StockCode']) { - prnMsg(_('Stock description keywords have been used in preference to the Stock code extract entered'), 'info'); - } - if ($_POST['Keywords']) { - //insert wildcard characters in spaces - $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; - $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.decimalplaces, - SUM(locstock.quantity) as qoh, - stockmaster.units, - (SELECT SUM(qtypicked) - FROM pickreqdetails - INNER JOIN pickreq ON pickreq.prid = pickreqdetails.prid - INNER JOIN locationusers ON locationusers.loccode = pickreq.loccode - AND locationusers.userid='" . $_SESSION['UserID'] . "' - AND locationusers.canview =1 - WHERE pickreq.closed=0 - AND stockmaster.stockid = pickreqdetails.stockid) AS qpicked - FROM stockmaster INNER JOIN locstock - ON stockmaster.stockid = locstock.stockid - INNER JOIN locationusers ON locationusers.loccode = locstock.loccode - AND locationusers.userid='" . $_SESSION['UserID'] . "' - AND locationusers.canview=1 - WHERE stockmaster.description " . LIKE . " '" . $SearchString . "' - AND stockmaster.categoryid='" . $_POST['StockCat'] . "' - GROUP BY stockmaster.stockid, - stockmaster.description, - stockmaster.decimalplaces, - stockmaster.units - ORDER BY stockmaster.stockid"; - } elseif ($_POST['StockCode']) { - $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.decimalplaces, - SUM(locstock.quantity) AS qoh, - (SELECT SUM(qtypicked) - FROM pickreqdetails - INNER JOIN pickreq - ON pickreq.prid = pickreqdetails.prid - INNER JOIN locationusers - ON locationusers.loccode = pickreq.loccode - AND locationusers.userid='" . $_SESSION['UserID'] . "' - AND locationusers.canview =1 - WHERE pickreq.closed=0 - AND stockmaster.stockid = pickreqdetails.stockid) AS qpicked, - stockmaster.units - FROM stockmaster - INNER JOIN locstock - ON stockmaster.stockid = locstock.stockid - INNER JOIN locationusers - ON locationusers.loccode = locstock.loccode - AND locationusers.userid='" . $_SESSION['UserID'] . "' - AND locationusers.canview=1 - WHERE stockmaster.stockid " . LIKE . " '%" . $_POST['StockCode'] . "%' - AND stockmaster.categoryid='" . $_POST['StockCat'] . "' - GROUP BY stockmaster.stockid, - stockmaster.description, - stockmaster.decimalplaces, - stockmaster.units - ORDER BY stockmaster.stockid"; - } elseif (!$_POST['StockCode'] and !$_POST['Keywords']) { - $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.decimalplaces, - SUM(locstock.quantity) AS qoh, - stockmaster.units, - (SELECT SUM(qtypicked) - FROM pickreqdetails - INNER JOIN pickreq - ON pickreq.prid = pickreqdetails.prid - INNER JOIN locationusers - ON locationusers.loccode = pickreq.loccode - AND locationusers.userid='" . $_SESSION['UserID'] . "' - AND locationusers.canview =1 - WHERE pickreq.closed=0 - AND stockmaster.stockid = pickreqdetails.stockid) AS qpicked - FROM stockmaster - INNER JOIN locstock - ON stockmaster.stockid = locstock.stockid - INNER JOIN locationusers - ON locationusers.loccode = locstock.loccode - AND locationusers.userid='" . $_SESSION['UserID'] . "' - AND locationusers.canview =1 - WHERE stockmaster.categoryid='" . $_POST['StockCat'] . "' - GROUP BY stockmaster.stockid, - stockmaster.description, - stockmaster.decimalplaces, - stockmaster.units - ORDER BY stockmaster.stockid"; - } - - $ErrMsg = _('No stock items were returned by the SQL because'); - $DbgMsg = _('The SQL used to retrieve the searched parts was'); - $StockItemsResult = DB_query($SQL, $ErrMsg, $DbgMsg); -} - -======= + + + + +
', _('From Stock Location'), ': - '; - if (isset($SelectedStockItem) and $SelectedStockItem != '') { - echo ''; - } -<<<<<<< HEAD ->>>>>>> parent of 01188779... Update StockLocMovements.php -======= ->>>>>>> parent of 01188779... Update StockLocMovements.php - - echo ''; - echo ''; - - $SQL = "SELECT locations.loccode, - locationname - FROM locations - INNER JOIN locationusers - ON locationusers.loccode=locations.loccode - AND locationusers.userid='" . $_SESSION['UserID'] . "' - AND locationusers.canview=1"; - $ResultStkLocs = DB_query($SQL); - echo ' - - -
', _('For the part'), ': ', $SelectedStockItem, '', ' ', _('and'), '', _('Sales Order'), ':', _('Pick List'), ':', _('Into Stock Location'), ':', _('Pick List Status'), ':
'; } -$SQL = "SELECT categoryid, - categorydescription - FROM stockcategory - ORDER BY categorydescription"; -$Result1 = DB_query($SQL); -echo ' - - - '; -echo ' - - -
-

', _('To search for Pick Lists for a specific part use the part selection facilities below'), '

-
', _('Select a stock category'), ':'; -<<<<<<< HEAD -<<<<<<< HEAD if (!isset($_POST['BeforeDate']) or !Is_date($_POST['BeforeDate'])) { - $_POST['BeforeDate'] = Date($_SESSION['DefaultDateFormat']); + $_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'))); @@ -415,12 +60,12 @@ echo ' ', _('Show Movements before'), ': ', ' ', _('But after'), ': ', '
+
-
-
'; + +
'; if ($_POST['StockLocation'] == 'All') { $_POST['StockLocation'] = '%%'; @@ -429,32 +74,32 @@ $SQLBeforeDate = FormatDateForSQL($_POST['BeforeDate']); $SQLAfterDate = FormatDateForSQL($_POST['AfterDate']); -$sql = "SELECT stockmoves.stockid, +$SQL = "SELECT stockmoves.stockid, stockmoves.stkmoveno, - systypes.typename, - stockmoves.type, - stockmoves.transno, - stockmoves.trandate, - stockmoves.debtorno, - stockmoves.branchcode, - stockmoves.qty, - stockmoves.reference, - stockmoves.price, - stockmoves.discountpercent, - stockmoves.newqoh, + systypes.typename, + stockmoves.type, + stockmoves.transno, + stockmoves.trandate, + stockmoves.debtorno, + stockmoves.branchcode, + stockmoves.qty, + stockmoves.reference, + stockmoves.price, + stockmoves.discountpercent, + stockmoves.newqoh, stockmaster.controlled, stockmaster.serialised, stockmaster.decimalplaces - FROM stockmoves + FROM stockmoves 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"; + 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); @@ -472,320 +117,43 @@ ', _('Discount'), ' ', _('Quantity on Hand'), ' ', _('Serial No.'), ' - '; -======= -while ($MyRow1 = DB_fetch_array($Result1)) { - if (isset($_POST['StockCat']) and $MyRow1['categoryid'] == $_POST['StockCat']) { - echo ''; - } else { - echo ''; - } -} - -======= -while ($MyRow1 = DB_fetch_array($Result1)) { - if (isset($_POST['StockCat']) and $MyRow1['categoryid'] == $_POST['StockCat']) { - echo ''; - } else { - echo ''; - } -} - ->>>>>>> parent of 01188779... Update StockLocMovements.php -echo ' - ', _('Enter text extracts in the'), ' ', _('description'), ': - - - -   - ', _('OR'), ' ', _('Enter extract of the'), ' ', _('Stock Code'), ': - - - - -
- - -
- - - '; - -if (isset($StockItemsResult)) { - echo ' - - - - - - - - - '; - echo ''; - - while ($MyRow = DB_fetch_array($StockItemsResult)) { - echo ' - - - - '; - }//end of while loop - echo ''; - echo '
', _('Code'), '', _('Description'), '', _('On Hand'), '', _('Picked'), '', _('Units'), '
- ', $MyRow['description'], '', locale_number_format($MyRow['qoh'], $MyRow['decimalplaces']), '', locale_number_format($MyRow['qpicked'], $MyRow['decimalplaces']), '', $MyRow['units'], '
'; -}//end if stock search results to show -else { - //figure out the SQL required from the inputs available + while ($MyRow = DB_fetch_array($MovtsResult)) { - if (!isset($_POST['Status']) or $_POST['Status'] == 'All') { - $StatusCriteria = " AND (pickreq.status='New' OR pickreq.status='Picked' OR pickreq.status='Cancelled' OR pickreq.status='Shipped') "; - } elseif ($_POST['Status'] == 'Picked') { - $StatusCriteria = " AND (pickreq.status='Picked' OR pickreq.status='Printed')"; - } elseif ($_POST['Status'] == 'New') { - $StatusCriteria = " AND pickreq.status='New' "; - } elseif ($_POST['Status'] == 'Cancelled') { - $StatusCriteria = " AND pickreq.status='Cancelled' "; - } elseif ($_POST['Status'] == 'Shipped') { - $StatusCriteria = " AND pickreq.status='Shipped' "; - } elseif ($_POST['Status'] == 'Invoiced') { - $StatusCriteria = " AND pickreq.status='Invoiced' "; - } + $DisplayTranDate = ConvertSQLDate($MyRow['trandate']); - if (isset($OrderNumber) and $OrderNumber != '') { - $SQL = "SELECT pickreq.orderno, - pickreq.prid, - pickreq.initdate, - pickreq.requestdate, - pickreq.initiator, - pickreq.shipdate, - pickreq.shippedby, - pickreq.status, - salesorders.printedpackingslip, - debtorsmaster.name - FROM pickreq - INNER JOIN salesorders - ON salesorders.orderno=pickreq.orderno - INNER JOIN debtorsmaster - ON salesorders.debtorno = debtorsmaster.debtorno - WHERE pickreq.orderno='" . filter_number_format($OrderNumber) . "' - GROUP BY pickreq.orderno - ORDER BY pickreq.requestdate, pickreq.prid"; - } elseif (isset($PickList) and $PickList != '') { - $SQL = "SELECT pickreq.orderno, - pickreq.prid, - pickreq.initdate, - pickreq.requestdate, - pickreq.initiator, - pickreq.shipdate, - pickreq.shippedby, - pickreq.status, - salesorders.printedpackingslip, - debtorsmaster.name - FROM pickreq - INNER JOIN salesorders - ON salesorders.orderno=pickreq.orderno - INNER JOIN debtorsmaster - ON salesorders.debtorno = debtorsmaster.debtorno - WHERE pickreq.prid='" . filter_number_format($PickList) . "' - GROUP BY pickreq.prid - ORDER BY pickreq.requestdate, pickreq.prid"; - } else { - if (empty($_POST['StockLocation'])) { - $_POST['StockLocation'] = $_SESSION['UserStockLocation']; - } - if (isset($SelectedDebtor)) { - //future functionality - search by customer - } else { //no customer selected - if (isset($SelectedStockItem)) { - $SQL = "SELECT pickreq.orderno, - pickreq.prid, - pickreq.initdate, - pickreq.requestdate, - pickreq.initiator, - pickreq.shipdate, - pickreq.shippedby, - pickreq.status, - salesorders.printedpackingslip, - debtorsmaster.name - FROM pickreq - INNER JOIN pickreqdetails - ON pickreq.prid = pickreqdetails.prid - INNER JOIN locationusers - ON locationusers.loccode=pickreq.loccode - AND locationusers.userid='" . $_SESSION['UserID'] . "' - AND locationusers.canview=1 - INNER JOIN salesorders - ON salesorders.orderno=pickreq.orderno - INNER JOIN debtorsmaster - ON salesorders.debtorno = debtorsmaster.debtorno - WHERE pickreqdetails.stockid='" . $SelectedStockItem . "' - AND pickreq.loccode = '" . $_POST['StockLocation'] . "' - " . $StatusCriteria . " - GROUP BY pickreq.prid - ORDER BY pickreq.requestdate, pickreq.prid"; - } else { - $SQL = "SELECT pickreq.orderno, - pickreq.prid, - pickreq.initdate, - pickreq.requestdate, - pickreq.initiator, - pickreq.shipdate, - pickreq.shippedby, - pickreq.status, - salesorders.printedpackingslip, - debtorsmaster.name - FROM pickreq - INNER JOIN pickreqdetails - ON pickreq.prid = pickreqdetails.prid - INNER JOIN locationusers - ON locationusers.loccode=pickreq.loccode - AND locationusers.userid='" . $_SESSION['UserID'] . "' - AND locationusers.canview=1 - INNER JOIN salesorders - ON salesorders.orderno=pickreq.orderno - INNER JOIN debtorsmaster - ON salesorders.debtorno = debtorsmaster.debtorno - WHERE pickreq.loccode = '" . $_POST['StockLocation'] . "' - " . $StatusCriteria . " - GROUP BY pickreq.prid - ORDER BY pickreq.requestdate, pickreq.prid"; - } //no stock item selected - } //no customer selected -<<<<<<< HEAD + $SerialSQL = "SELECT serialno, moveqty FROM stockserialmoves WHERE stockmoveno='" . $MyRow['stkmoveno'] . "'"; + $SerialResult = DB_query($SerialSQL); - } //end not order number selected - $ErrMsg = _('No pick lists were returned by the SQL because'); - $PickReqResult = DB_query($SQL, $ErrMsg); ->>>>>>> parent of 01188779... Update StockLocMovements.php - - if (DB_num_rows($PickReqResult) > 0) { - /*show a table of the pick lists returned by the SQL */ - echo ' - - - - - - - - - - - - - - - '; - -<<<<<<< HEAD - $DisplayTranDate = ConvertSQLDate($myrow['trandate']); -======= - echo ''; ->>>>>>> parent of 01188779... Update StockLocMovements.php - - while ($MyRow = DB_fetch_array($PickReqResult)) { - -======= - - } //end not order number selected - $ErrMsg = _('No pick lists were returned by the SQL because'); - $PickReqResult = DB_query($SQL, $ErrMsg); - - if (DB_num_rows($PickReqResult) > 0) { - /*show a table of the pick lists returned by the SQL */ - echo '
', _('Modify'), '', _('Picking List'), '', _('Packing List'), '', _('Labels'), '', _('Order'), '', _('Customer'), '', _('Request Date'), '', _('Ship Date'), '', _('Shipped By'), '', _('Initiated On'), '', _('Initiated By'), '
- - - - - - - - - - - - - - - '; - - echo ''; - - while ($MyRow = DB_fetch_array($PickReqResult)) { - ->>>>>>> parent of 01188779... Update StockLocMovements.php - $ModifyPickList = $RootPath . '/PickingLists.php?Prid=' . $MyRow['prid']; - $PrintPickList = $RootPath . '/GeneratePickingList.php?TransNo=' . $MyRow['orderno']; - - if ($_SESSION['PackNoteFormat'] == 1) { - /*Laser printed A4 default */ - $PrintDispatchNote = $RootPath . '/PrintCustOrder_generic.php?TransNo=' . $MyRow['orderno']; + $SerialText = ''; + while ($SerialRow = DB_fetch_array($SerialResult)) { + if ($MyRow['serialised'] == 1) { + $SerialText .= $SerialRow['serialno'] . '
'; } else { - /*pre-printed stationery default */ - $PrintDispatchNote = $RootPath . '/PrintCustOrder.php?TransNo=' . $MyRow['orderno']; + $SerialText .= $SerialRow['serialno'] . ' Qty- ' . $SerialRow['moveqty'] . '
'; } -<<<<<<< HEAD -<<<<<<< HEAD - } -======= ->>>>>>> parent of 01188779... Update StockLocMovements.php -======= ->>>>>>> parent of 01188779... Update StockLocMovements.php - - if ($MyRow['printedpackingslip'] == 0) { - $PrintText = _('Print'); - } else { - $PrintText = _('Reprint'); - $PrintDispatchNote .= '&Reprint=OK'; - } - - $PrintLabels = $RootPath . '/PDFShipLabel.php?Type=Sales&ORD=' . $MyRow['orderno']; - $FormatedRequestDate = ConvertSQLDate($MyRow['requestdate']); - $FormatedInitDate = ConvertSQLDate($MyRow['initdate']); - $FormatedShipDate = ConvertSQLDate($MyRow['shipdate']); - $Confirm_Invoice = ''; - - if ($MyRow['status'] == "Shipped") { - $Confirm_Invoice = ''; - } - - echo ' - - - - - - - - - - - - ', $Confirm_Invoice, ' - '; - } //end of while loop + } - echo ''; - echo '
', _('Modify'), '', _('Picking List'), '', _('Packing List'), '', _('Labels'), '', _('Order'), '', _('Customer'), '', _('Request Date'), '', _('Ship Date'), '', _('Shipped By'), '', _('Initiated On'), '', _('Initiated By'), '
' . _('Invoice Order') . '
', str_pad($MyRow['prid'], 10, '0', STR_PAD_LEFT), 'Print ', $PrintText, ' ' . _('Labels') . '', $MyRow['orderno'], '', $MyRow['name'], '', $FormatedRequestDate, '', $FormatedShipDate, '', $MyRow['shippedby'], '', $FormatedInitDate, '', $MyRow['initiator'], '
'; - } // end if Pick Lists to show + 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, ' + '; + } + //end of while loop + echo ''; } echo '
'; -if ($_POST['Status'] == 'New') { - //office is gnerating picks. Warehouse needs to see latest "To Do" list so refresh every 5 minutes - echo ''; -} +include ('includes/footer.php'); -<<<<<<< HEAD -<<<<<<< HEAD -?> -======= -======= ->>>>>>> parent of 01188779... Update StockLocMovements.php -include('includes/footer.php'); ?> ->>>>>>> parent of 01188779... Update StockLocMovements.php