7
7
8
8
include ('includes/header.php ' );
9
9
10
- echo '<form action=" ' . htmlspecialchars ($ _SERVER ['PHP_SELF ' ],ENT_QUOTES ,'UTF-8 ' ) . '" method="post"> ' ;
11
- echo '<div> ' ;
12
- echo '<input type="hidden" name="FormID" value=" ' . $ _SESSION ['FormID ' ] . '" /> ' ;
13
-
14
- echo '<p class="page_title_text"><img src=" ' . $ RootPath . '/css/ ' . $ Theme . '/images/magnifier.png" title=" ' . _ ('Search ' ) .
15
- '" alt="" /> ' . ' ' . $ Title . '</p> ' ;
16
-
17
- echo '<table class="selection">
18
- <tr>
19
- <td> ' . _ ('From Stock Location ' ) . ':<select name="StockLocation"> ' ;
10
+ echo '<p class="page_title_text">
11
+ <img src=" ' , $ RootPath , '/css/ ' , $ _SESSION ['Theme ' ], '/images/magnifier.png" title=" ' , _ ('Search ' ), '" alt="" /> ' , ' ' , $ Title , '
12
+ </p> ' ;
13
+
14
+ echo '<form action=" ' , htmlspecialchars ($ _SERVER ['PHP_SELF ' ], ENT_QUOTES , 'UTF-8 ' ), '" method="post">
15
+ <input type="hidden" name="FormID" value=" ' , $ _SESSION ['FormID ' ], '" />
16
+ <table>
17
+ <tr>
18
+ <td> ' , _ ('From Stock Location ' ), ':<select required="required" name="StockLocation"> ' ;
19
+
20
+ $ SQL = "SELECT locationname,
21
+ locations.loccode
22
+ FROM locations
23
+ INNER JOIN locationusers
24
+ ON locationusers.loccode=locations.loccode
25
+ AND locationusers.userid=' " . $ _SESSION ['UserID ' ] . "'
26
+ AND locationusers.canview=1
27
+ ORDER BY locationname " ;
28
+
29
+ echo '<option selected="selected" value="All"> ' , _ ('All Locations ' ), '</option> ' ;
30
+
31
+ if (!isset ($ _POST ['StockLocation ' ])) {
32
+ $ _POST ['StockLocation ' ] = 'All ' ;
33
+ }
20
34
21
- $ sql = "SELECT locations.loccode, locationname FROM locations
22
- INNER JOIN locationusers ON locationusers.loccode=locations.loccode AND locationusers.userid=' " . $ _SESSION ['UserID ' ] . "' AND locationusers.canview=1 " ;
23
35
$ resultStkLocs = DB_query ($ sql );
24
- while ($ myrow =DB_fetch_array ($ resultStkLocs )){
25
- if (isset ($ _POST ['StockLocation ' ]) AND $ _POST ['StockLocation ' ]!='All ' ){
26
- if ($ myrow ['loccode ' ] == $ _POST ['StockLocation ' ]){
27
- echo '<option selected="selected" value=" ' . $ myrow ['loccode ' ] . '"> ' . $ myrow ['locationname ' ] . '</option> ' ;
36
+
37
+ while ($ MyRow = DB_fetch_array ($ ResultStkLocs )) {
38
+ if (isset ($ _POST ['StockLocation ' ]) and $ _POST ['StockLocation ' ] != 'All ' ) {
39
+ if ($ MyRow ['loccode ' ] == $ _POST ['StockLocation ' ]) {
40
+ echo '<option selected="selected" value=" ' , $ MyRow ['loccode ' ], '"> ' , $ MyRow ['locationname ' ], '</option> ' ;
28
41
} else {
29
- echo '<option value=" ' . $ myrow ['loccode ' ] . '"> ' . $ myrow ['locationname ' ] . '</option> ' ;
42
+ echo '<option value=" ' , $ MyRow ['loccode ' ], '"> ' , $ MyRow ['locationname ' ], '</option> ' ;
30
43
}
31
- } elseif ($ myrow ['loccode ' ]== $ _SESSION ['UserStockLocation ' ]){
44
+ } elseif ($ MyRow ['loccode ' ] == $ _SESSION ['UserStockLocation ' ]) {
32
45
echo '<option selected="selected" value=" ' . $ myrow ['loccode ' ] . '"> ' . $ myrow ['locationname ' ] . '</option> ' ;
33
46
$ _POST ['StockLocation ' ]=$ myrow ['loccode ' ];
34
47
} else {
35
- echo '<option value=" ' . $ myrow ['loccode ' ] . '"> ' . $ myrow ['locationname ' ] . '</option> ' ;
48
+ echo '<option value=" ' , $ MyRow ['loccode ' ], '"> ' , $ MyRow ['locationname ' ], '</option> ' ;
36
49
}
37
50
}
38
51
39
52
echo '</select> ' ;
40
53
41
- if (!isset ($ _POST ['BeforeDate ' ]) OR ! Is_Date ($ _POST ['BeforeDate ' ])){
54
+ if (!isset ($ _POST ['BeforeDate ' ]) or ! Is_date ($ _POST ['BeforeDate ' ])) {
42
55
$ _POST ['BeforeDate ' ] = Date ($ _SESSION ['DefaultDateFormat ' ]);
43
56
}
44
- if (!isset ($ _POST ['AfterDate ' ]) OR ! Is_Date ($ _POST ['AfterDate ' ])){
45
- $ _POST ['AfterDate ' ] = Date ($ _SESSION ['DefaultDateFormat ' ], Mktime (0 ,0 , 0 , Date ('m ' )- 1 , Date ('d ' ),Date ('y ' )));
57
+ if (!isset ($ _POST ['AfterDate ' ]) or ! Is_date ($ _POST ['AfterDate ' ])) {
58
+ $ _POST ['AfterDate ' ] = Date ($ _SESSION ['DefaultDateFormat ' ], Mktime (0 , 0 , 0 , Date ('m ' ) - 1 , Date ('d ' ), Date ('y ' )));
46
59
}
47
- echo ' ' . _ ('Show Movements before ' ) . ': <input type="text" name="BeforeDate" size="12" maxlength="12" value=" ' . $ _POST ['BeforeDate ' ] . '" /> ' ;
48
- echo ' ' . _ ('But after ' ) . ': <input type="text" name="AfterDate" size="12" maxlength="12" value=" ' . $ _POST ['AfterDate ' ] . '" /> ' ;
49
- echo '</td>
60
+ echo ' ' , _ ('Show Movements before ' ), ': <input type="text" class="date" alt=" ' , $ _SESSION [ ' DefaultDateFormat ' ], ' " name="BeforeDate" size="12" required="required" maxlength="12" value=" ', $ _POST ['BeforeDate ' ], '" /> ' ,
61
+ ' ' , _ ('But after ' ), ': <input type="text" class="date" alt=" ' , $ _SESSION [ ' DefaultDateFormat ' ], ' " name="AfterDate" size="12" required="required" maxlength="12" value=" ', $ _POST ['AfterDate ' ], '" /> ' ,
62
+ '</td>
50
63
</tr>
51
64
</table>
52
- <br /> ' ;
53
- echo '<div class="centre">
54
- <input type="submit" name="ShowMoves" value=" ' . _ ('Show Stock Movements ' ) . '" />
65
+ <div class="centre">
66
+ <input type="submit" name="ShowMoves" value=" ' , _ ('Show Stock Movements ' ), '" />
55
67
</div>
56
68
<br /> ' ;
57
69
70
+ if ($ _POST ['StockLocation ' ] == 'All ' ) {
71
+ $ _POST ['StockLocation ' ] = '%% ' ;
72
+ }
58
73
59
74
$ SQLBeforeDate = FormatDateForSQL ($ _POST ['BeforeDate ' ]);
60
75
$ SQLAfterDate = FormatDateForSQL ($ _POST ['AfterDate ' ]);
61
76
62
77
$ sql = "SELECT stockmoves.stockid,
78
+ stockmoves.stkmoveno,
63
79
systypes.typename,
64
80
stockmoves.type,
65
81
stockmoves.transno,
71
87
stockmoves.price,
72
88
stockmoves.discountpercent,
73
89
stockmoves.newqoh,
74
- stockmaster.decimalplaces,
75
- stockserialmoves.serialno
90
+ stockmaster.controlled,
91
+ stockmaster.serialised,
92
+ stockmaster.decimalplaces
76
93
FROM stockmoves
77
- INNER JOIN systypes ON stockmoves.type=systypes.typeid
78
- INNER JOIN stockmaster ON stockmoves.stockid=stockmaster.stockid
79
- LEFT JOIN stockserialmoves ON stockmoves.stkmoveno=stockserialmoves.stockmoveno
80
- WHERE stockmoves.loccode=' " . $ _POST ['StockLocation ' ] . "'
81
- AND stockmoves.trandate >= ' " . $ SQLAfterDate . "'
94
+ INNER JOIN systypes
95
+ ON stockmoves.type=systypes.typeid
96
+ INNER JOIN stockmaster
97
+ ON stockmoves.stockid=stockmaster.stockid
98
+ WHERE stockmoves.loccode " . LIKE . " ' " . $ _POST ['StockLocation ' ] . "'
99
+ AND stockmoves.trandate >= ' " . $ SQLAfterDate . "'
82
100
AND stockmoves.trandate <= ' " . $ SQLBeforeDate . "'
83
101
AND hidemovt=0
84
102
ORDER BY stkmoveno DESC " ;
85
-
86
103
$ ErrMsg = _ ('The stock movements for the selected criteria could not be retrieved because ' );
87
- $ MovtsResult = DB_query ($ sql ,$ ErrMsg );
88
-
89
- echo '<table cellpadding="5" cellspacing="4 "class="selection"> ' ;
90
- $ tableheader = '<tr>
91
- <th> ' . _ ('Item Code ' ) . '</th>
92
- <th> ' . _ ('Type ' ) . '</th>
93
- <th> ' . _ ('Trans No ' ) . '</th>
94
- <th> ' . _ ('Date ' ) . '</th>
95
- <th> ' . _ ('Customer ' ) . '</th>
96
- <th> ' . _ ('Quantity ' ) . '</th>
97
- <th> ' . _ ('Reference ' ) . '</th>
98
- <th> ' . _ ('Price ' ) . '</th>
99
- <th> ' . _ ('Discount ' ) . '</th>
100
- <th> ' . _ ('Quantity on Hand ' ) . '</th>
101
- <th> ' . _ ('Serial No. ' ) . '</th>
104
+ $ MovtsResult = DB_query ($ SQL , $ ErrMsg );
105
+
106
+ if (DB_num_rows ($ MovtsResult ) > 0 ) {
107
+ echo '<table cellpadding="5" cellspacing="4" class="selection">
108
+ <tr>
109
+ <th> ' , _ ('Item Code ' ), '</th>
110
+ <th> ' , _ ('Type ' ), '</th>
111
+ <th> ' , _ ('Trans No ' ), '</th>
112
+ <th> ' , _ ('Date ' ), '</th>
113
+ <th> ' , _ ('Customer ' ), '</th>
114
+ <th> ' , _ ('Quantity ' ), '</th>
115
+ <th> ' , _ ('Reference ' ), '</th>
116
+ <th> ' , _ ('Price ' ), '</th>
117
+ <th> ' , _ ('Discount ' ), '</th>
118
+ <th> ' , _ ('Quantity on Hand ' ), '</th>
119
+ <th> ' , _ ('Serial No. ' ), '</th>
102
120
</tr> ' ;
103
- echo $ tableheader ;
104
-
105
- $ j = 1 ;
106
121
107
- while ($ myrow = DB_fetch_array ($ MovtsResult )) {
122
+ while ($ MyRow = DB_fetch_array ($ MovtsResult )) {
108
123
109
124
$ DisplayTranDate = ConvertSQLDate ($ myrow ['trandate ' ]);
110
125
111
- printf ('<tr class="striped_row">
112
- <td><a target="_blank" href=" ' . $ RootPath . '/StockStatus.php?StockID=%s">%s</a></td>
113
- <td>%s</td>
114
- <td>%s</td>
115
- <td>%s</td>
116
- <td>%s</td>
117
- <td class="number">%s</td>
118
- <td>%s</td>
119
- <td class="number">%s</td>
120
- <td class="number">%s</td>
121
- <td class="number">%s</td>
122
- <td class="number">%s</td>
123
- </tr> ' ,
124
- mb_strtoupper ($ myrow ['stockid ' ]),
125
- mb_strtoupper ($ myrow ['stockid ' ]),
126
- $ myrow ['typename ' ],
127
- $ myrow ['transno ' ],
128
- $ DisplayTranDate ,
129
- $ myrow ['debtorno ' ],
130
- locale_number_format ($ myrow ['qty ' ],
131
- $ myrow ['decimalplaces ' ]),
132
- $ myrow ['reference ' ],
133
- locale_number_format ($ myrow ['price ' ],$ _SESSION ['CompanyRecord ' ]['decimalplaces ' ]),
134
- locale_number_format ($ myrow ['discountpercent ' ]*100 ,2 ),
135
- locale_number_format ($ myrow ['newqoh ' ],$ myrow ['decimalplaces ' ]),
136
- $ myrow ['serialno ' ]);
137
- $ j ++;
138
- If ($ j == 16 ){
139
- $ j =1 ;
140
- echo $ tableheader ;
126
+ $ SerialSQL = "SELECT serialno, moveqty FROM stockserialmoves WHERE stockmoveno=' " . $ MyRow ['stkmoveno ' ] . "' " ;
127
+ $ SerialResult = DB_query ($ SerialSQL );
128
+
129
+ $ SerialText = '' ;
130
+ while ($ SerialRow = DB_fetch_array ($ SerialResult )) {
131
+ if ($ MyRow ['serialised ' ] == 1 ) {
132
+ $ SerialText .= $ SerialRow ['serialno ' ] . '<br /> ' ;
133
+ } else {
134
+ $ SerialText .= $ SerialRow ['serialno ' ] . ' Qty- ' . $ SerialRow ['moveqty ' ] . '<br /> ' ;
135
+ }
141
136
}
142
- //end of page full new headings if
143
- }
144
- //end of while loop
145
137
146
- echo '</table> ' ;
147
- echo '</div>
148
- </form> ' ;
138
+ echo '<tr class="striped_row">
139
+ <td><a target="_blank" href=" ' , $ RootPath , '/StockStatus.php?StockID= ' , mb_strtoupper (urlencode ($ MyRow ['stockid ' ])), '"> ' , mb_strtoupper ($ MyRow ['stockid ' ]), '</a></td>
140
+ <td> ' , $ MyRow ['typename ' ], '</td>
141
+ <td> ' , $ MyRow ['transno ' ], '</td>
142
+ <td> ' , $ DisplayTranDate , '</td>
143
+ <td> ' , $ MyRow ['debtorno ' ], '</td>
144
+ <td class="number"> ' , locale_number_format ($ MyRow ['qty ' ], $ MyRow ['decimalplaces ' ]), '</td>
145
+ <td> ' , $ MyRow ['reference ' ], '</td>
146
+ <td class="number"> ' , locale_number_format ($ MyRow ['price ' ], $ _SESSION ['CompanyRecord ' ]['decimalplaces ' ]), '</td>
147
+ <td class="number"> ' , locale_number_format ($ MyRow ['discountpercent ' ] * 100 , 2 ), '%</td>
148
+ <td class="number"> ' , locale_number_format ($ MyRow ['newqoh ' ], $ MyRow ['decimalplaces ' ]), '</td>
149
+ <td> ' , $ SerialText , '</td>
150
+ </tr> ' ;
151
+ }
152
+ //end of while loop
153
+ echo '</table> ' ;
154
+ }
155
+ echo '</form> ' ;
149
156
150
- include ('includes/footer.php ' );
157
+ include ('includes/footer.php ' );
151
158
152
159
?>
0 commit comments