forked from timschofield/webERP
-
Notifications
You must be signed in to change notification settings - Fork 89
/
AgedControlledInventory.php
105 lines (90 loc) · 3.16 KB
/
AgedControlledInventory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
include('includes/session.php');
$PricesSecurity = 12;//don't show pricing info unless security token 12 available to user
$Today = time();
$Title = _('Aged Controlled Inventory') . ' ' . _('as-of') . ' ' . Date(($_SESSION['DefaultDateFormat']), $Today);
include('includes/header.php');
echo '<p class="page_title_text">
<img src="', $RootPath, '/css/', $Theme, '/images/inventory.png" title="', _('Inventory'), '" alt="" /><b>', $Title, '</b>
</p>';
$sql = "SELECT stockserialitems.stockid,
stockmaster.description,
stockserialitems.serialno,
stockserialitems.quantity,
stockmoves.trandate,
stockmaster.units,
stockmaster.materialcost+stockmaster.labourcost+stockmaster.overheadcost AS cost,
createdate,
decimalplaces
FROM stockserialitems
LEFT JOIN stockserialmoves
ON stockserialitems.serialno=stockserialmoves.serialno
LEFT JOIN stockmoves
ON stockserialmoves.stockmoveno=stockmoves.stkmoveno
INNER JOIN stockmaster
ON stockmaster.stockid = stockserialitems.stockid
INNER JOIN locationusers
ON locationusers.loccode=stockserialitems.loccode
AND locationusers.userid='" . $_SESSION['UserID'] . "'
AND locationusers.canview=1
WHERE quantity > 0
ORDER BY createdate, quantity";
$ErrMsg = _('The stock held could not be retrieved because');
$LocStockResult = DB_query($sql, $ErrMsg);
$NumRows = DB_num_rows($LocStockResult);
$TotalQty=0;
$TotalVal=0;
echo '<table>
<thead>
<tr>
<th class="ascending">', _('Stock'), '</th>
<th class="ascending">', _('Description'), '</th>
<th class="ascending">', _('Batch'), '</th>
<th class="ascending">', _('Quantity Remaining'), '</th>
<th class="ascending">', _('Units'), '</th>
<th class="ascending">', _('Inventory Value'), '</th>
<th class="ascending">', _('Date'), '</th>
<th class="ascending">', _('Days Old'), '</th>
</tr>
</thead>
<tbody>';
while ($LocQtyRow=DB_fetch_array($LocStockResult)) {
$DaysOld = floor(($Today - strtotime($LocQtyRow['createdate']))/(60*60*24));
$TotalQty += $LocQtyRow['quantity'];
$DispVal = '-----------';
if (in_array($PricesSecurity, $_SESSION['AllowedPageSecurityTokens']) OR !isset($PricesSecurity)) {
$DispVal = locale_number_format(($LocQtyRow['quantity']*$LocQtyRow['cost']),$LocQtyRow['decimalplaces']);
$TotalVal += ($LocQtyRow['quantity'] * $LocQtyRow['cost']);
}
printf('<tr class="striped_row">
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td class="number">%s</td>
<td>%s</td>
<td class="number">%s</td>
<td>%s</td>
<td class="number">%s</td>
</tr>',
mb_strtoupper($LocQtyRow['stockid']),
$LocQtyRow['description'],
$LocQtyRow['serialno'],
locale_number_format($LocQtyRow['quantity'],$LocQtyRow['decimalplaces']),
$LocQtyRow['units'],
$DispVal,
ConvertSQLDate($LocQtyRow['createdate']),
$DaysOld
);
} //while
echo '</tbody>
<tfoot>
<tr class="striped_row">
<td colspan="3"><b>', _('Total'), '</b></td>
<td class="number"><b>', locale_number_format($TotalQty,2), '</b></td>
<td class="number"><b>', locale_number_format($TotalVal,2), '</b></td>
<td colspan="2"></td>
</tr>
</tfoot>
</table>';
include('includes/footer.php');
?>