forked from webERP-team/webERP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
StockSerialItems.php
176 lines (153 loc) · 5.65 KB
/
StockSerialItems.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
include('includes/session.php');
$Title = _('Stock Of Controlled Items');
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>';
if (isset($_GET['StockID'])){
if (ContainsIllegalCharacters ($_GET['StockID'])){
prnMsg(_('The stock code sent to this page appears to be invalid'),'error');
include('includes/footer.php');
exit;
}
$StockID = trim(mb_strtoupper($_GET['StockID']));
} else {
prnMsg( _('This page must be called with parameters specifying the item to show the serial references and quantities') . '. ' . _('It cannot be displayed without the proper parameters being passed'),'error');
include('includes/footer.php');
exit;
}
$result = DB_query("SELECT description,
units,
mbflag,
decimalplaces,
serialised,
controlled,
perishable
FROM stockmaster
WHERE stockid='".$StockID."'",
_('Could not retrieve the requested item because'));
$myrow = DB_fetch_array($result);
$Description = $myrow['description'];
$UOM = $myrow['units'];
$DecimalPlaces = $myrow['decimalplaces'];
$Serialised = $myrow['serialised'];
$Controlled = $myrow['controlled'];
$Perishable = $myrow['perishable'];
if ($myrow['mbflag']=='K' OR $myrow['mbflag']=='A' OR $myrow['mbflag']=='D'){
prnMsg(_('This item is either a kitset or assembly or a dummy part and cannot have a stock holding') . '. ' . _('This page cannot be displayed') . '. ' . _('Only serialised or controlled items can be displayed in this page'),'error');
include('includes/footer.php');
exit;
}
$result = DB_query("SELECT locationname
FROM locations
INNER JOIN locationusers ON locationusers.loccode=locations.loccode AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canview=1
WHERE locations.loccode='" . $_GET['Location'] . "'",
_('Could not retrieve the stock location of the item because'),
_('The SQL used to lookup the location was'));
$myrow = DB_fetch_row($result);
$sql = "SELECT serialno,
quantity,
expirationdate
FROM stockserialitems
INNER JOIN locationusers ON locationusers.loccode=stockserialitems.loccode AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canview=1
WHERE stockserialitems.loccode='" . $_GET['Location'] . "'
AND stockid = '" . $StockID . "'
AND quantity <>0";
$ErrMsg = _('The serial numbers/batches held cannot be retrieved because');
$LocStockResult = DB_query($sql, $ErrMsg);
echo '<table class="selection">';
if ($Serialised==1){
echo '<tr><th colspan="5"><font color="navy" size="2">' . _('Serialised items in') . ' ';
} else {
echo '<tr><th colspan="11"><font color="navy" size="2">' . _('Controlled items in') . ' ';
}
echo $myrow[0]. '</font></th></tr>';
echo '<tr>
<th colspan="11"><font color="navy" size="2">' . $StockID .'-'. $Description . '</b> (' . _('In units of') . ' ' . $UOM . ')</font></th>
</tr>';
if ($Serialised == 1 and $Perishable==0){
$tableheader = '<tr>
<th>' . _('Serial Number') . '</th>
<th></th>
<th>' . _('Serial Number') . '</th>
<th></th>
<th>' . _('Serial Number') . '</th>
</tr>';
} else if ($Serialised == 1 and $Perishable==1){
$tableheader = '<tr>
<th>' . _('Serial Number') . '</th>
<th>' . _('Expiry Date') . '</th>
<th>' . _('Serial Number') . '</th>
<th>' . _('Expiry Date') . '</th>
<th>' . _('Serial Number') . '</th>
<th>' . _('Expiry Date') . '</th>
</tr>';
} else if ($Serialised == 0 and $Perishable==0){
$tableheader = '<tr>
<th>' . _('Batch/Bundle Ref') . '</th>
<th>' . _('Quantity On Hand') . '</th>
<th></th>
<th>' . _('Batch/Bundle Ref') . '</th>
<th>' . _('Quantity On Hand') . '</th>
<th></th>
<th>' . _('Batch/Bundle Ref') . '</th>
<th>' . _('Quantity On Hand') . '</th>
</tr>';
} else if ($Serialised == 0 and $Perishable==1){
$tableheader = '<tr>
<th>' . _('Batch/Bundle Ref') . '</th>
<th>' . _('Quantity On Hand') . '</th>
<th>' . _('Expiry Date') . '</th>
<th></th>
<th>' . _('Batch/Bundle Ref') . '</th>
<th>' . _('Quantity On Hand') . '</th>
<th>' . _('Expiry Date') . '</th>
<th></th>
<th>' . _('Batch/Bundle Ref') . '</th>
<th>' . _('Quantity On Hand') . '</th>
<th>' . _('Expiry Date') . '</th>
</tr>';
}
echo $tableheader;
$TotalQuantity =0;
$j = 1;
$Col =0;
while ($myrow=DB_fetch_array($LocStockResult)) {
echo '<tr class="striped_row">';
$TotalQuantity += $myrow['quantity'];
if ($Serialised == 1 and $Perishable==0){
echo '<td>' . $myrow['serialno'] . '</td>';
echo '<th></th>';
} else if ($Serialised == 1 and $Perishable==1) {
echo '<td>' . $myrow['serialno'] . '</td>
<td>' . ConvertSQLDate($myrow['expirationdate']). '</td>';
} else if ($Serialised == 0 and $Perishable==0) {
echo '<td>' . $myrow['serialno'] . '</td>
<td class="number">' . locale_number_format($myrow['quantity'],$DecimalPlaces) . '</td>';
echo '<th></th>';
} else if ($Serialised == 0 and $Perishable==1){
echo '<td>' . $myrow['serialno'] . '</td>
<td class="number">' . locale_number_format($myrow['quantity'],$DecimalPlaces). '</td>
<td>' . ConvertSQLDate($myrow['expirationdate']). '</td>
<th></th>';
}
$j++;
If ($j == 36){
$j=1;
echo $tableheader;
}
//end of page full new headings if
$Col++;
if ($Col==3){
echo '</tr>';
$Col=0;
}
}
//end of while loop
echo '</table><br />';
echo '<div class="centre"><br /><b>' . _('Total quantity') . ': ' . locale_number_format($TotalQuantity, $DecimalPlaces) . '<br /></div>';
echo '</form>';
include('includes/footer.php');
?>