Skip to content

Commit

Permalink
Merge pull request #35 from TurboPT/master
Browse files Browse the repository at this point in the history
Merges from head fork. (see comment for details)
  • Loading branch information
TurboPT committed Apr 12, 2018
2 parents 2a0d54b + cf2113c commit 6c62691
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 107 deletions.
12 changes: 6 additions & 6 deletions SelectOrderItems.php
Expand Up @@ -1579,7 +1579,7 @@
<td class="number">%s</td>
<td class="number">%s</td>
<td class="number">%s</td>
<td><input class="number" ' . ($i==0 ? 'autofocus="autofocus"':'') . ' type="text" required="required" size="6" name="OrderQty%s" value="0" />
<td><input class="number" ' . ($j==0 ? 'autofocus="autofocus"':'') . ' type="text" required="required" size="6" name="OrderQty%s" value="0" />
<input name="StockID%s" type="hidden" value="%s" />
</td>
</tr>',
Expand All @@ -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
}
Expand Down Expand Up @@ -1676,7 +1677,6 @@
echo '<br />';
echo '<div class="page_help_text">' . _('Select an item by entering the quantity required. Click Order when ready.') . '</div>';
echo '<br />';
$j = 1;

echo '<div>';
echo '<input name="FormID" type="hidden" value="' . $_SESSION['FormID'] . '" />';
Expand Down Expand Up @@ -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++;
Expand Down
217 changes: 116 additions & 101 deletions StockQuantityByDate.php
@@ -1,172 +1,187 @@
<?php


include('includes/session.php');
include ('includes/session.php');
$Title = _('Stock On Hand By Date');
include('includes/header.php');
include ('includes/header.php');

echo '<p class="page_title_text">
<img src="'.$RootPath.'/css/'.$Theme.'/images/inventory.png" title="' . _('Inventory') .
'" alt="" /><b>' . $Title. '</b>
echo '<p class="page_title_text" >
<img src="' . $RootPath . '/css/' . $_SESSION['Theme'] . '/images/inventory.png" title="' . _('Inventory') . '" alt="" /><b>' . $Title . '</b>
</p>';

echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post">';
echo '<div>';
echo '<form action="' . htmlspecialchars(basename(__FILE__), ENT_QUOTES, 'UTF-8') . '" method="post">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';

$sql = "SELECT categoryid, categorydescription FROM stockcategory";
$resultStkLocs = DB_query($sql);
$SQL = "SELECT categoryid, categorydescription FROM stockcategory";
$ResultStkLocs = DB_query($SQL);

echo '<table class="selection">
echo '<table>
<tr>
<td>' . _('For Stock Category') . ':</td>
<td><select name="StockCategory">
<option value="All">' . _('All') . '</option>';

while ($myrow=DB_fetch_array($resultStkLocs)){
if (isset($_POST['StockCategory']) AND $_POST['StockCategory']!='All'){
if ($myrow['categoryid'] == $_POST['StockCategory']){
echo '<option selected="selected" value="' . $myrow['categoryid'] . '">' . $myrow['categorydescription'] . '</option>';
<td>
<select required="required" name="StockCategory">
<option value="All">' . _('All') . '</option>';

while ($MyRow = DB_fetch_array($ResultStkLocs)) {
if (isset($_POST['StockCategory']) and $_POST['StockCategory'] != 'All') {
if ($MyRow['categoryid'] == $_POST['StockCategory']) {
echo '<option selected="selected" value="' . $MyRow['categoryid'] . '">' . $MyRow['categorydescription'] . '</option>';
} else {
echo '<option value="' . $myrow['categoryid'] . '">' . $myrow['categorydescription'] . '</option>';
echo '<option value="' . $MyRow['categoryid'] . '">' . $MyRow['categorydescription'] . '</option>';
}
}else {
echo '<option value="' . $myrow['categoryid'] . '">' . $myrow['categorydescription'] . '</option>';
} else {
echo '<option value="' . $MyRow['categoryid'] . '">' . $MyRow['categorydescription'] . '</option>';
}
}
echo '</select></td>';

$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 '<td>' . _('For Stock Location') . ':</td>
<td><select name="StockLocation"> ';
<td><select required="required" name="StockLocation"> ';

while ($myrow=DB_fetch_array($resultStkLocs)){
if (isset($_POST['StockLocation']) AND $_POST['StockLocation']!='All'){
if ($myrow['loccode'] == $_POST['StockLocation']){
echo '<option selected="selected" value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>';
while ($MyRow = DB_fetch_array($ResultStkLocs)) {
if (isset($_POST['StockLocation']) and $_POST['StockLocation'] != 'All') {
if ($MyRow['loccode'] == $_POST['StockLocation']) {
echo '<option selected="selected" value="' . $MyRow['loccode'] . '">' . $MyRow['locationname'] . '</option>';
} else {
echo '<option value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>';
echo '<option value="' . $MyRow['loccode'] . '">' . $MyRow['locationname'] . '</option>';
}
} elseif ($myrow['loccode']==$_SESSION['UserStockLocation']){
echo '<option selected="selected" value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>';
$_POST['StockLocation']=$myrow['loccode'];
} elseif ($MyRow['loccode'] == $_SESSION['UserStockLocation']) {
echo '<option selected="selected" value="' . $MyRow['loccode'] . '">' . $MyRow['locationname'] . '</option>';
$_POST['StockLocation'] = $MyRow['loccode'];
} else {
echo '<option value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>';
echo '<option value="' . $MyRow['loccode'] . '">' . $MyRow['locationname'] . '</option>';
}
}
echo '</select></td>';

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 '<td>' . _('On-Hand On Date') . ':</td>
<td><input type="text" class="date" name="OnHandDate" size="11" maxlength="10" value="' . $_POST['OnHandDate'] . '" /></td></tr>';
<td><input type="text" class="date" name="OnHandDate" size="12" required="required" maxlength="10" value="' . $_POST['OnHandDate'] . '" /></td>';

if (isset($_POST['ShowZeroStocks'])) {
$Checked = 'checked="checked"';
} else {
$Checked = '';
}

echo '<td>
<td>', ('Include zero stocks'), '</td>
<td><input type="checkbox" name="ShowZeroStocks" value="" ', $Checked, ' /></td>
</td>
</tr>';

echo '<tr>
<td colspan="6">
<td colspan="8">
<div class="centre">
<input type="submit" name="ShowStatus" value="' . _('Show Stock Status') .'" />
<input type="submit" name="ShowStatus" value="' . _('Show Stock Status') . '" />
</div></td>
</tr>
</table>
</div>
</form>';

$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 '<br />
<table class="selection">';

$tableheader = '<tr>
<th>' . _('Item Code') . '</th>
<th>' . _('Description') . '</th>
<th>' . _('Quantity On Hand') . '</th>
</tr>';
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 '<table>
<tr>
<th>' . _('Item Code') . '</th>
<th>' . _('Description') . '</th>
<th>' . _('Quantity On Hand') . '</th>
<th>' . _('Controlled') . '</th>
</tr>';

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('<tr class="striped_row">
<td><a target="_blank" href="' . $RootPath . '/StockStatus.php?%s">%s</a></td>
<td>%s</td>
<td class="number">%s</td>
</tr>',
'StockID=' . mb_strtoupper($myrows['stockid']),
mb_strtoupper($myrows['stockid']),
$myrows['description'],
0);
<td class="number">%s</td></tr>', 'StockID=' . mb_strtoupper($MyRow['stockid']), mb_strtoupper($MyRow['stockid']), $MyRow['description'], 0);
} else {
printf('<tr class="striped_row">
<td><a target="_blank" href="' . $RootPath . '/StockStatus.php?%s">%s</a></td>
<td>%s</td>
<td class="number">%s</td>
</tr>',
'StockID=' . mb_strtoupper($myrows['stockid']),
mb_strtoupper($myrows['stockid']),
$myrows['description'],
locale_number_format($LocQtyRow['newqoh'],$myrows['decimalplaces']));
<td class="number">%s</td></tr>', '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 '<tr>
<td>' . _('Total Quantity') . ': ' . $TotalQuantity . '</td>
</tr>
</table>';
}

include('includes/footer.php');
include ('includes/footer.php');
?>

0 comments on commit 6c62691

Please sign in to comment.