/
nons-purch-int-det-ret.php
executable file
·204 lines (182 loc) · 5.04 KB
/
nons-purch-int-det-ret.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
<?
#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
#
#
#
#
#
#
#
#
#
#
#
# get settings
require("settings.php");
require("core-settings.php");
require("libs/ext.lib.php");
# decide what to do
if (isset($_GET["rpurid"]) && isset($_GET["prd"])) {
$OUTPUT = details($_GET);
} else {
$OUTPUT = "<li class=err>Invalid use of module.</li>";
}
# get templete
require("template.php");
# details
function details($_GET)
{
# get vars
extract ($_GET);
# validate input
require_lib("validate");
$v = new validate ();
$v->isOk ($rpurid, "num", 1, 20, "Invalid purchase number.");
$v->isOk ($prd, "num", 1, 20, "Invalid period Database number.");
# display errors, if any
if ($v->isError ()) {
$err = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$err .= "<li class='err'>".$e["msg"]."</li>";
}
return $confirm;
}
db_conn($prd);
$sql = "SELECT * FROM rnons_purch_int WHERE purid='$rpurid'";
$purRslt = db_exec($sql) or errDie("Unable to retrieve purchase information from Cubit.");
$pur = pg_fetch_array($purRslt);
/* --- Start Products Display --- */
# Products layout
$products = "
<table ".TMPL_tblDflts." width=100%>
<tr>
<th>ITEM NUMBER</th>
<th>DESCRIPTION</th>
<th>QTY</th>
<th>UNIT PRICE</th>
<th>AMOUNT</th>
<tr>";
# get selected stock in this purchase
db_conn($prd);
$sql = "SELECT * FROM rnons_purint_items WHERE purid='$rpurid'";
$stkdRslt = db_exec($sql);
while($stkd = pg_fetch_array($stkdRslt)){
$amt = sprint($stkd['unitcost'] * $stkd['qty']);
# put in product
$products .= "
<tr class='".bg_class()."'>
<td>$stkd[cod]</td>
<td>$stkd[des]</td>
<td align='right'>$stkd[qty]</td>
<td align='right' nowrap>".CUR." $stkd[unitcost]</td>
<td align='right' nowrap>".CUR." $amt</td>
</tr>";
}
$products .= "</table>";
/* --- Start Some calculations --- */
# Get subtotal
$SUBTOT = sprint($pur['subtot']);
/* --- End Some calculations --- */
# format date
list($ryear, $rmon, $rday) = explode("-", $pur['rdate']);
/* -- Final Layout -- */
$details = "
<center>
<h3>Returned International Non Stock Purchase Details</h3>
<table ".TMPL_tblDflts." width='95%'>
<tr>
<td valign='top'>
<table ".TMPL_tblDflts.">
<tr>
<th colspan='2'> Supplier Details </th>
</tr>
<tr class='".bg_class()."'>
<td>Supplier</td>
<td valign='center'>$pur[supplier]</td>
</tr>
<tr class='".bg_class()."'>
<td valign='top'>Supplier Address</td>
<td valign='center'>".nl2br($pur['supaddr'])."</td>
</tr>
</table>
</td>
<td valign='top' align='right'>
<table ".TMPL_tblDflts.">
<tr>
<th colspan='2'> Purchase Details </th>
</tr>
<tr class='".bg_class()."'>
<td>Purchase No.</td>
<td valign='center'>$pur[purnum]</td>
</tr>
<tr class='".bg_class()."'>
<td>Delivery Ref No.</td>
<td valign='center'>$pur[refno]</td>
</tr>
<tr class='".bg_class()."'>
<td>Terms</td>
<td valign='center'>$pur[terms] Days</td>
</tr>
<tr class='".bg_class()."'>
<td>Date</td>
<td valign='center'>$rday-$rmon-$ryear</td>
</tr>
</table>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td colspan='2'>$products</td>
</tr>
<tr>
<td>
<table ".TMPL_tblDflts.">
<tr>
<th width='50%'>Quick Links</th>
<th width='45%'>Remarks</th>
<td rowspan='5' valign='top' width='15%'><br></td>
</tr>
<tr>
<td class='".bg_class()."'>
<a href='purch-int-new.php'>New International Purchase</a>
</td>
<td class='".bg_class()."' rowspan='4' align='center' valign='top'>
".nl2br($pur['remarks'])."
</td>
</tr>
<tr class='".bg_class()."'>
<td><a href='purch-int-view-prd.php'>View Received International Purchases</a></td>
</tr>
<script>document.write(getQuicklinkSpecial());</script>
<tr class='".bg_class()."'>
<td><a href='main.php'>Main Menu</a></td>
</tr>
</table>
</td>
<td align='right'>
<table ".TMPL_tblDflts." width='80%'>
<tr class='".bg_class()."'>
<th>Total Cost Returned</th>
<td align='right' nowrap>$pur[curr] $SUBTOT</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</center>";
return $details;
}
?>