forked from timschofield/webERP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStockLocMovements.php
169 lines (145 loc) · 5.93 KB
/
StockLocMovements.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
<?php
include('includes/session.php');
if (isset($_POST['BeforeDate'])){$_POST['BeforeDate'] = ConvertSQLDate($_POST['BeforeDate']);};
if (isset($_POST['AfterDate'])){$_POST['AfterDate'] = ConvertSQLDate($_POST['AfterDate']);};
$Title = _('All Stock Movements By Location');
$ViewTopic = 'Inventory';
$BookMark = '';
include('includes/header.php');
echo '<p class="page_title_text">
<img src="', $RootPath, '/css/', $_SESSION['Theme'], '/images/magnifier.png" title="', _('Search'), '" alt="" />', ' ', $Title, '
</p>';
echo '<form action="', htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8'), '" method="post">
<input type="hidden" name="FormID" value="', $_SESSION['FormID'], '" />
<fieldset>
<legend>', _('Inquiry Criteria'), '</legend>
<field>
<label for="StockLocation">', _('From Stock Location'), ':</label>
<select required="required" name="StockLocation">';
$SQL = "SELECT locationname,
locations.loccode
FROM locations
INNER JOIN locationusers
ON locationusers.loccode=locations.loccode
AND locationusers.userid='" . $_SESSION['UserID'] . "'
AND locationusers.canview=1
ORDER BY locationname";
echo '<option selected="selected" value="All">', _('All Locations'), '</option>';
if (!isset($_POST['StockLocation'])) {
$_POST['StockLocation'] = 'All';
}
$ResultStkLocs = DB_query($SQL);
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>';
}
} 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 '</select>
</field>';
if (!isset($_POST['BeforeDate']) or !Is_date($_POST['BeforeDate'])) {
$_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')));
}
echo '<field>
<label for="BeforeDate">', _('Show Movements before'), ':</label>
<input type="date" name="BeforeDate" size="11" required="required" maxlength="10" value="', FormatDateForSQL($_POST['BeforeDate']), '" />
</field>';
echo '<field>
<label for="AfterDate">', _('But after'), ':</label>
<input type="date" name="AfterDate" size="11" required="required" maxlength="10" value="', FormatDateForSQL($_POST['AfterDate']), '" />
</field>
</fieldset>
<div class="centre">
<input type="submit" name="ShowMoves" value="', _('Show Stock Movements'), '" />
</div>';
if ($_POST['StockLocation'] == 'All') {
$_POST['StockLocation'] = '%%';
}
$SQLBeforeDate = FormatDateForSQL($_POST['BeforeDate']);
$SQLAfterDate = FormatDateForSQL($_POST['AfterDate']);
$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,
stockmaster.controlled,
stockmaster.serialised,
stockmaster.decimalplaces
FROM stockmoves
INNER JOIN systypes
ON stockmoves.type=systypes.typeid
INNER JOIN stockmaster
ON stockmoves.stockid=stockmaster.stockid
WHERE stockmoves.loccode = '" . $_POST['StockLocation'] . "'
AND stockmoves.trandate >= '" . $SQLAfterDate . "'
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);
if (DB_num_rows($MovtsResult) > 0) {
echo '<table cellpadding="5" cellspacing="4" class="selection">
<tr>
<th>', _('Item Code'), '</th>
<th>', _('Type'), '</th>
<th>', _('Trans No'), '</th>
<th>', _('Date'), '</th>
<th>', _('Customer'), '</th>
<th>', _('Quantity'), '</th>
<th>', _('Reference'), '</th>
<th>', _('Price'), '</th>
<th>', _('Discount'), '</th>
<th>', _('Quantity on Hand'), '</th>
<th>', _('Serial No.'), '</th>
</tr>';
while ($MyRow = DB_fetch_array($MovtsResult)) {
$DisplayTranDate = ConvertSQLDate($MyRow['trandate']);
$SerialSQL = "SELECT serialno, moveqty FROM stockserialmoves WHERE stockmoveno='" . $MyRow['stkmoveno'] . "'";
$SerialResult = DB_query($SerialSQL);
$SerialText = '';
while ($SerialRow = DB_fetch_array($SerialResult)) {
if ($MyRow['serialised'] == 1) {
$SerialText .= $SerialRow['serialno'] . '<br />';
} else {
$SerialText .= $SerialRow['serialno'] . ' Qty- ' . $SerialRow['moveqty'] . '<br />';
}
}
echo '<tr class="striped_row">
<td><a target="_blank" href="', $RootPath, '/StockStatus.php?StockID=', mb_strtoupper(urlencode($MyRow['stockid'])), '">', mb_strtoupper($MyRow['stockid']), '</a></td>
<td>', $MyRow['typename'], '</td>
<td>', $MyRow['transno'], '</td>
<td>', $DisplayTranDate, '</td>
<td>', $MyRow['debtorno'], '</td>
<td class="number">', locale_number_format($MyRow['qty'], $MyRow['decimalplaces']), '</td>
<td>', $MyRow['reference'], '</td>
<td class="number">', locale_number_format($MyRow['price'], $_SESSION['CompanyRecord']['decimalplaces']), '</td>
<td class="number">', locale_number_format($MyRow['discountpercent'] * 100, 2), '%</td>
<td class="number">', locale_number_format($MyRow['newqoh'], $MyRow['decimalplaces']), '</td>
<td>', $SerialText, '</td>
</tr>';
}
//end of while loop
echo '</table>';
}
echo '</form>';
include ('includes/footer.php');
?>