/
label-stock-print.php
executable file
·159 lines (143 loc) · 3.89 KB
/
label-stock-print.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
<?
#This program is copyright by Andre Coetzee email: ac@main.me
#and is licensed under the GPL v3
#
#
#
#
#Please add yourself to: http://www.accounting-123.com
#Developers, Software Vendors, Support, Accountants, Users
#
#
#The full software license can be found here:
#http://www.accounting-123.com/a.php?a=153/GPLv3
#
#
#
#
#
#
#
#
#
#
#
require ("settings.php");
require ("core-settings.php");
$OUTPUT = print_labels ($_POST);
require ("tmpl-print.php");
function print_labels ($_POST)
{
extract ($_POST);
if (!isset($stock_cat))
$stock_cat = "";
if (!isset($stock_class))
$stock_class = "";
if (!isset($price_from))
$price_from = "";
if (!isset($price_to))
$price_to = "";
db_connect ();
#get cats ...
$cat_drop = "<select name='stock_cat'>";
$sql = "SELECT * FROM stockcat WHERE div = '".USER_DIV."' ORDER BY cat ASC";
$catRslt = db_exec($sql);
if(pg_numrows($catRslt) < 1){
return "<li>There are no stock categories in Cubit.</li>";
}else{
$cat_drop .= "<option value='0'>All Categories</option>";
while($cat = pg_fetch_array($catRslt)){
if($cat['catid'] == $stock_cat){
$sel = "selected";
}else{
$sel = "";
}
$cat_drop .= "<option value='$cat[catid]' $sel>$cat[cat]</option>";
}
}
$cat_drop .= "</select>";
#get classes ...
$class_drop = "<select name='stock_class'>";
$sql = "SELECT * FROM stockclass WHERE div = '".USER_DIV."' ORDER BY classname ASC";
$clasRslt = db_exec($sql);
if(pg_numrows($clasRslt) < 1){
return "<li>There are no stock Classifications in Cubit.</li>";
}else{
$class_drop .= "<option value='0'>All Classifications</option>";
while($clas = pg_fetch_array($clasRslt)){
if($clas['clasid'] == $stock_class){
$sel = "selected";
}else{
$sel = "";
}
$class_drop .= "<option value='$clas[clasid]' $sel>$clas[classname]</option>";
}
}
$class_drop .= "</select>";
if ((strlen($stock_cat) > 0) OR (strlen($stock_class) > 0) OR (strlen($price_from) > 0 AND strlen($price_to) > 0)){
$show_filters = "";
$filter = "";
if (strlen($stock_cat) > 0 AND $stock_cat != '0')
$filter .= " AND catid = '$stock_cat'";
if (strlen($stock_class) > 0 AND $stock_class != '0')
$filter .= " AND prdcls = '$stock_class'";
if (strlen($price_from) > 0 AND strlen($price_to) > 0)
$filter .= " AND selamt >= '$price_from' AND selamt <= '$price_to'";
}else {
$filter = " AND stkid = '0'";
$show_filters = "
<tr>
<th>Category</th>
<th>Classification</th>
<th>Retail Price Range</th>
</tr>
<tr>
<td>$cat_drop</td>
<td>$class_drop</td>
<td><input type='text' size='6' name='price_from'> to <input type='text' size='6' name='price_to'></td>
</tr>
<tr>
<td colspan='3' align='right'><input type='submit' value='Filter'></td>
</tr>
<tr><td><br></td></tr>";
}
#get list of customers
$get_stock = "SELECT * FROM stock WHERE div = '".USER_DIV."' $filter";
$run_stock = db_exec($get_stock) or errDie("Unable to get stock information");
if(pg_numrows($run_stock) < 1){
$listing = "No stock was found.<br><br><input type='button' onClick=\"document.location='label-stock-print.php'\" value='Back'>";
}else {
$listing = "";
while ($arr = pg_fetch_array($run_stock)){
$listing .= "
<table class='thkborder' width='150'>
<tr>
<td nowrap><font size='3'><b>$arr[stkcod]</b></font></td>
<td nowrap align='right'><font align='right'>".CUR." ".money($arr["selamt"])."</font></td>
</tr>
<tr>
<td colspan='2' align='center'><img src='".getBarcode($arr["bar"])."' width='185' height='70'></td>
</tr>
<tr>
<td colspan='2' align='left'><font size='2'>".nl2br($arr['stkdes'])."</font></td>
</tr>
</table>
<br>
";
}
}
$display = "
<table ".TMPL_tblDflts.">
<form action='".SELF."' method='POST'>
$show_filters
</form>
</table>
<table ".TMPL_tblDflts.">
<tr>
<td>$listing</td>
</tr>
</table>
";
return $display;
}
?>