/
supp-tran-rep.php
executable file
·224 lines (197 loc) · 5.79 KB
/
supp-tran-rep.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?
#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");
// Decide what to do
if (isset($_POST["key"])) {
switch ($_POST["key"]) {
default:
case "printSupp":
$OUTPUT = print_supp($_POST);
break;
}
} else {
$OUTPUT = print_supp();
}
require ("template.php");
# show stock
function print_supp ($errors="")
{
global $_POST;
extract ($_POST);
if (!isset($fdate_day)) $fdate_day = "01";
if (!isset($fdate_month)) $fdate_month = date("m");
if (!isset($fdate_year)) $fdate_year = date("Y");
if (!isset($tdate_day)) $tdate_day = date("d");
if (!isset($tdate_month)) $tdate_month = date("m");
if (!isset($tdate_year)) $tdate_year = date("Y");
$fdate = "$fdate_year-$fdate_month-$fdate_day";
$tdate = "$tdate_year-$tdate_month-$tdate_day";
# Set up table to display in
$printSupp = "
<center>
<h3>Current Supplier Transactions</h3>
<form method='POST' action='".SELF."'>
<input type='hidden' name='key' value='printSupp'>
<input type='hidden' name='search' value='true'>
<table ".TMPL_tblDflts.">
<tr>
<th colspan='5'>Date Range</th>
</tr>
<tr class='".bg_class()."'>
<td><b>From </b></td>
<td>
".mkDateSelect("fdate",$fdate_year,$fdate_month,$fdate_day)."
</td>
<td><b> To </b></td>
<td>
".mkDateSelect("tdate",$tdate_year,$tdate_month,$tdate_day)."
</td>
<td><input type='submit' value='View »'></td>
</tr>
</table>
</form>
<table ".TMPL_tblDflts." width='500'>";
# connect to database
db_connect();
# Query server
$i = 0;
$sql = "SELECT * FROM suppliers WHERE div = '".USER_DIV."' ORDER BY supid ASC";
$suppRslt = db_exec ($sql) or errDie ("Unable to retrieve Suppliers from database.");
if (pg_numrows ($suppRslt) < 1) {
return "
<li>There are no Suppliers in Cubit.</li>
<table ".TMPL_tblDflts." width='15%'>
<tr><td><br></td></tr>
<tr>
<th>".ct("Quick Links")."</th>
</tr>
<tr class='".bg_class()."'>
<td><a href='supp-view.php'>".ct("View Suppliers")."</a></td>
</tr>
<script>document.write(getQuicklinkSpecial());</script>
</table>";
}
if(!isset($search))
$search = "";
if($search)
while ($supp = pg_fetch_array ($suppRslt)) {
# get department
db_conn("exten");
$sql = "SELECT * FROM departments WHERE deptid = '$supp[deptid]' AND div = '".USER_DIV."'";
$deptRslt = db_exec($sql);
if(pg_numrows($deptRslt) < 1){
$deptname = "<li class=err>".ct("Department not Found.")."";
}else{
$dept = pg_fetch_array($deptRslt);
$deptname = $dept['deptname'];
}
if($supp['location'] == 'int'){
$cur = $supp['currency'];
$bal = "fbalance";
}else{
$cur = CUR;
$bal = "balance";
}
$printSupp .= "
<tr class='".bg_class()."'>
<td colspan='10'>$supp[supno] - $supp[supname] <b>$cur $supp[$bal]</b></td>
</tr>";
# connect to database
db_connect ();
$stmnt = "";
$totout = 0;
# Query server
$sql = "SELECT * FROM sup_stmnt WHERE supid = '$supp[supid]' AND edate >= '$fdate' AND edate <= '$tdate' AND div = '".USER_DIV."' ORDER BY edate ASC";
$stRslt = db_exec ($sql) or errDie ("Unable to retrieve invoices statement from database.");
if (pg_numrows ($stRslt) < 1) {
$stmnt .= "
<tr class='".bg_class()."'>
<td colspan='10'>".ct("No transactions found for the current date range.")."</td>
</tr>";
}else{
while ($st = pg_fetch_array ($stRslt)) {
# Accounts details
if($st['cacc'] > 0){
$accRs = get("core","*","accounts","accid",$st['cacc']);
if(pg_numrows($accRs) < 1){
$acc['accname'] = "No Account.";
$acc['topacc'] = "000";
$acc['accnum'] = "000";
}else{
$acc = pg_fetch_array($accRs);
}
}else{
$acc['accname'] = "No Account.";
$acc['topacc'] = "000";
$acc['accnum'] = "000";
}
# format date
$st['edate'] = explode("-", $st['edate']);
$st['edate'] = $st['edate'][2]."-".$st['edate'][1]."-".$st['edate'][0];
$st['amount'] = sprint($st['amount']);
$stmnt .= "
<tr class='".bg_class()."'>
<td align='center'>$st[edate]</td>
<td>$st[ref]</td>
<td>$acc[topacc]/$acc[accnum] - $acc[accname]</td>
<td>$st[descript]</td>
<td align='right' nowrap>$cur $st[amount]</td>
</tr>";
# keep track of da totals
$totout += $st['amount'];
}
}
$printSupp .= $stmnt."<tr><td><br><br></td></tr>";
}
$printSupp .= "
</table>
<form method='POST' action='xls/supp-tran-rep-xls.php'>
<input type='hidden' name='key' value='printSupp'>
<input type='hidden' name='fdate_day' value='$fdate_day'>
<input type='hidden' name='fdate_month' value='$fdate_month'>
<input type='hidden' name='fdate_year' value='$fdate_year'>
<input type='hidden' name='tdate_day' value='$tdate_day'>
<input type='hidden' name='tdate_month' value='$tdate_month'>
<input type='hidden' name='tdate_year' value='$tdate_year'>
<center><input type='submit' value='Export to Spreadsheet'></center>
<p>
<table ".TMPL_tblDflts." width='15%'>
<tr><td><br></td></tr>
<tr>
<th>".ct("Quick Links")."</th>
</tr>
<tr class='".bg_class()."'>
<td><a href='supp-view.php'>".ct("View Suppliers")."</a></td>
</tr>
<script>document.write(getQuicklinkSpecial());</script>
</table>
</center>";
return $printSupp;
}
//function ct($string)
//{
// return $string;
//}
?>