diff --git a/SelectOrderItems.php b/SelectOrderItems.php index 06b166c8f..b3486fea3 100644 --- a/SelectOrderItems.php +++ b/SelectOrderItems.php @@ -1579,7 +1579,7 @@ %s %s %s - + ', @@ -1591,9 +1591,10 @@ locale_number_format($DemandQty, $QOHRow['decimalplaces']), locale_number_format($OnOrder, $QOHRow['decimalplaces']), locale_number_format($Available, $QOHRow['decimalplaces']), - strval($j+7), - $i, + $j, + $j, $myrow['stockid']); + $j++; $i++; #end of page full new headings if } @@ -1676,7 +1677,6 @@ echo '
'; echo '
' . _('Select an item by entering the quantity required. Click Order when ready.') . '
'; echo '
'; - $j = 1; echo '
'; echo ''; @@ -1765,8 +1765,8 @@ locale_number_format($DemandQty,$QOHRow['decimalplaces']), locale_number_format($OnOrder,$QOHRow['decimalplaces']), locale_number_format($Available,$QOHRow['decimalplaces']), - strval($j+7), - $i, + $j, + $j, $myrow['stockid'] ); $i++; $j++; diff --git a/StockQuantityByDate.php b/StockQuantityByDate.php index dca800ffc..67b27ae25 100644 --- a/StockQuantityByDate.php +++ b/StockQuantityByDate.php @@ -1,172 +1,187 @@ - ' . $Title. ' +echo '

+ ' . $Title . '

'; -echo '
'; -echo '
'; +echo ''; echo ''; -$sql = "SELECT categoryid, categorydescription FROM stockcategory"; -$resultStkLocs = DB_query($sql); +$SQL = "SELECT categoryid, categorydescription FROM stockcategory"; +$ResultStkLocs = DB_query($SQL); -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); +$SQL = "SELECT locationname, + locations.loccode + FROM locations + INNER JOIN locationusers + ON locationusers.loccode=locations.loccode + AND locationusers.userid='" . $_SESSION['UserID'] . "' + AND locationusers.canview=1"; + +$ResultStkLocs = DB_query($SQL); echo ' - '; -if (!isset($_POST['OnHandDate'])){ - $_POST['OnHandDate'] = Date($_SESSION['DefaultDateFormat'], Mktime(0,0,0,Date('m'),0,Date('y'))); +if (!isset($_POST['OnHandDate'])) { + $_POST['OnHandDate'] = Date($_SESSION['DefaultDateFormat'], Mktime(0, 0, 0, Date('m'), 0, Date('y'))); } echo ' - '; + '; + +if (isset($_POST['ShowZeroStocks'])) { + $Checked = 'checked="checked"'; +} else { + $Checked = ''; +} + +echo ' + + +'; + echo ' -
' . _('For Stock Category') . ': + ' . _('For Stock Location') . ':' . _('On-Hand On Date') . ':
+ ', ('Include zero stocks'), '
+
- +
-
'; $TotalQuantity = 0; -if(isset($_POST['ShowStatus']) AND Is_Date($_POST['OnHandDate'])) { - if ($_POST['StockCategory']=='All') { - $sql = "SELECT stockid, - description, - decimalplaces - FROM stockmaster - WHERE (mbflag='M' OR mbflag='B')"; - } else { - $sql = "SELECT stockid, - description, - decimalplaces - FROM stockmaster - WHERE categoryid = '" . $_POST['StockCategory'] . "' - AND (mbflag='M' OR mbflag='B')"; - } +if (isset($_POST['ShowStatus']) and is_date($_POST['OnHandDate'])) { + if ($_POST['StockCategory'] == 'All') { + $SQL = "SELECT stockid, + description, + decimalplaces + FROM stockmaster + WHERE (mbflag='M' OR mbflag='B')"; + } else { + $SQL = "SELECT stockid, + description, + decimalplaces + FROM stockmaster + WHERE categoryid = '" . $_POST['StockCategory'] . "' + AND (mbflag='M' OR mbflag='B')"; + } $ErrMsg = _('The stock items in the category selected cannot be retrieved because'); $DbgMsg = _('The SQL that failed was'); - $StockResult = DB_query($sql, $ErrMsg, $DbgMsg); + $StockResult = DB_query($SQL, $ErrMsg, $DbgMsg); $SQLOnHandDate = FormatDateForSQL($_POST['OnHandDate']); - echo '
- '; - - $tableheader = ' - - - - '; - echo $tableheader; - - while ($myrows=DB_fetch_array($StockResult)) { - - $sql = "SELECT stockid, - newqoh - FROM stockmoves - WHERE stockmoves.trandate <= '". $SQLOnHandDate . "' - AND stockid = '" . $myrows['stockid'] . "' - AND loccode = '" . $_POST['StockLocation'] ."' - ORDER BY stkmoveno DESC LIMIT 1"; + echo '
' . _('Item Code') . '' . _('Description') . '' . _('Quantity On Hand') . '
+ + + + + + '; + + while ($MyRow = DB_fetch_array($StockResult)) { + + if (isset($_POST['ShowZeroStocks'])) { + $SQL = "SELECT stockid, + newqoh + FROM stockmoves + WHERE stockmoves.trandate <= '" . $SQLOnHandDate . "' + AND stockid = '" . $MyRow['stockid'] . "' + AND loccode = '" . $_POST['StockLocation'] . "' + ORDER BY stkmoveno DESC LIMIT 1"; + } else { + $SQL = "SELECT stockid, + newqoh + FROM stockmoves + WHERE stockmoves.trandate <= '" . $SQLOnHandDate . "' + AND stockid = '" . $MyRow['stockid'] . "' + AND loccode = '" . $_POST['StockLocation'] . "' + AND newqoh > 0 + ORDER BY stkmoveno DESC LIMIT 1"; + } - $ErrMsg = _('The stock held as at') . ' ' . $_POST['OnHandDate'] . ' ' . _('could not be retrieved because'); + $ErrMsg = _('The stock held as at') . ' ' . $_POST['OnHandDate'] . ' ' . _('could not be retrieved because'); - $LocStockResult = DB_query($sql, $ErrMsg); + $LocStockResult = DB_query($SQL, $ErrMsg); $NumRows = DB_num_rows($LocStockResult); - $j = 1; + while ($LocQtyRow = DB_fetch_array($LocStockResult)) { - while ($LocQtyRow=DB_fetch_array($LocStockResult)) { + if ($MyRows['controlled'] == 1) { + $Controlled = _('Yes'); + } else { + $Controlled = _('No'); + } - if($NumRows == 0){ + if ($NumRows == 0) { printf(' - - ', - 'StockID=' . mb_strtoupper($myrows['stockid']), - mb_strtoupper($myrows['stockid']), - $myrows['description'], - 0); + ', 'StockID=' . mb_strtoupper($MyRow['stockid']), mb_strtoupper($MyRow['stockid']), $MyRow['description'], 0); } else { printf(' - ', - 'StockID=' . mb_strtoupper($myrows['stockid']), - mb_strtoupper($myrows['stockid']), - $myrows['description'], - locale_number_format($LocQtyRow['newqoh'],$myrows['decimalplaces'])); + ', 'StockID=' . mb_strtoupper($MyRow['stockid']), mb_strtoupper($MyRow['stockid']), $MyRow['description'], locale_number_format($LocQtyRow['newqoh'], $MyRow['decimalplaces']), $Controlled); - $TotalQuantity += $LocQtyRow['newqoh']; - } - $j++; - if ($j == 12){ - $j=1; - echo $tableheader; + $TotalQuantity+= $LocQtyRow['newqoh']; } - //end of page full new headings if + //end of page full new headings if + } - }//end of while loop + } //end of while loop echo '
' . _('Item Code') . '' . _('Description') . '' . _('Quantity On Hand') . '' . _('Controlled') . '
%s %s%s
%s
%s %s %s
%s
' . _('Total Quantity') . ': ' . $TotalQuantity . '
'; } -include('includes/footer.php'); +include ('includes/footer.php'); ?> \ No newline at end of file