-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinvoice.php
231 lines (228 loc) · 10.2 KB
/
invoice.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
225
226
227
228
229
230
231
<?php
/************************************************************************/
/* PHP InvoiceIt v1.0 */
/* =========================== */
/* */
/* Written by Steve Dawson - http://www.stevedawson.com */
/* Freelance Web Developer - PHP, MySQL, HTML programming */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* but please leave this header intact, thanks */
/************************************************************************/
## Include the Config file because without we can't do anything!
include "config.php";
## The processing function thingy ma jig.
function processform() {
global $HeaderDistance;
global $BorderColour;
global $TableBGcolour;
global $PageTitle;
global $CurrencyUnit;
global $InvoiceSignature;
global $DisplayVat;
global $TaxName;
global $VatRate;
global $vat_at;
global $customer_id;
global $customer_address;
global $customer_name;
global $date;
global $order;
global $price;
global $notes;
?>
<HTML>
<HEAD>
<TITLE>PHP InvoiceIt - Invoice Created</TITLE>
<LINK REL="STYLESHEET" HREF="invoice.css">
</HEAD>
<BODY>
<img src="blank.gif" width="1" height="<?php print $HeaderDistance; ?>">
<DIV align="center">
<TABLE border="0" width="600">
<tr>
<TD valign="top" colspan="2"> <table>
<tr>
<td align="left"> To:<br> <?php print $customer_name; ?><br> <?php print str_replace("\n", "<br>", $customer_address); ?>
</td>
</tr>
<tr>
<td align="right"> <b>Date:</b> <?php print "$date"; ?>
</td>
</tr>
<tr>
<td align="right"> <b>Ref:</b> <?php print "$customer_id"; ?>
</td>
</tr>
<tr>
<td> <br><br><table width="100%" CELLPADDING="2" CELLSPACING="0" border="1" bordercolor="<?PHP print "$BorderColour"; ?>">
<tr bgcolor="<?PHP print "$TableBGcolour"; ?>">
<th>Product</th>
<th>Cost</th>
<th><?PHP print "$TaxName"; ?></th>
<th>Total</th>
</tr>
<tr>
<td><img src="blank.gif" width="450" height="14"></td>
<td><img src="blank.gif" width="60" height="14"></td>
<td><img src="blank.gif" width="60" height="14"></td>
<td><img src="blank.gif" width="60" height="14"></td>
</tr>
<?php
$tot_cost = "0";
$tot_vat = "0";
$tot_price = "0";
for($l=0; $l<sizeof($order); $l++){
if(!strlen($order[$l]) && $l == (sizeof($order)-1)) { continue; }
?>
<tr>
<td><?php print $order[$l]; ?></td>
<td align="right"><?php print "$CurrencyUnit"; ?><?php print number_format($price[$l]/($vat_at+100)*100, 2); ?></td>
<td align="right"><?php print "$CurrencyUnit"; ?><?php print number_format($price[$l]-($price[$l]/($vat_at+100)*100), 2); ?></td>
<td align="right" width="50"><?php print "$CurrencyUnit"; ?><?php print number_format($price[$l],2); ?></td>
</tr>
<?php
$tot_cost += $price[$l]/($vat_at+100)*100;
$tot_vat += $price[$l]-($price[$l]/($vat_at+100)*100);
$tot_price += $price[$l];
}
?>
<tr>
<td colspan="4"><?php if($DisplayVat == "Y") { print "<i>$TaxName charged at a rate of $vat_at%</i>"; } else print "<img src=\"blank.gif\" width=\"1\" height=\"14\">";?></td>
</tr>
</table>
<br> <table align="right" width="0" CELLPADDING="2" CELLSPACING="1" border="1" bordercolor="<?PHP print "$BorderColour"; ?>">
<tr>
<td width="60" align="right"><b><?php print "$CurrencyUnit"; ?><?php print number_format($tot_cost,2); ?></b></td>
<td align="right" width="60"><b><?php print "$CurrencyUnit"; ?><?php print number_format($tot_vat,2); ?></b></td>
<td align="right" width="60"><b><?php print "$CurrencyUnit"; ?><?php print number_format($tot_price,2); ?></b></td>
</tr>
</table> <br> <br><br><br><?php print tag($notes); ?>
<br> <br> <?php print "$InvoiceSignature"; ?> </td>
</tr></table></TD></TR></TABLE>
</DIV>
</BODY>
</HTML>
<?php
}
function mainform() {
global $HeaderDistance;
global $BorderColour;
global $TableBGcolour;
global $PageTitle;
global $CurrencyUnit;
global $DisplayVat;
global $TaxName;
global $VatRate;
global $InvoiceSignature;
global $n_order;
global $n_price;
global $vat_at;
global $customer_id;
global $customer_address;
global $customer_name;
global $date;
global $order;
global $price;
global $notes;
?>
<HTML>
<HEAD>
<TITLE>PHP InvoiceIt - Create the Invoice</TITLE>
<LINK REL="STYLESHEET" HREF="invoice.css">
</HEAD>
<BODY><img src="blank.gif" width="1" height="<?php print $HeaderDistance; ?>">
<DIV align="center">
<TABLE WIDTH="90%" BORDER="0" CELLPADDING="2" CELLSPACING="2" ALIGN="CENTER">
<TR>
<TD valign="top" colspan="2"><H4 align="center"><?PHP print $PageTitle; ?></H4>
<br> <FORM method="post">
<table>
<tr>
<td align="left"> To:<br>
<input type="text" name="customer_name" size="38" value="<?php if($customer_name) { print tag($customer_name); } else { print "Insert Customer Name"; } ?>">
<br> <textarea name="customer_address" rows="5" cols="40"><?php if($customer_address) { print $customer_address; } else { print "Insert Customer Address"; } ?></textarea>
</td>
</tr>
<tr>
<td align="right"> <b>Date:</b>
<input type="text" name="date" size="15" value="<?php if($date){ print tag($date); } else { print date("d/m/Y"); } ?>">
</td>
</tr>
<tr>
<td align="right"> <b>Ref Number:</b>
<input type="text" name="customer_id" size="15" value="<?php if($customer_id){ print tag($customer_id); } else { print "Customer Ref"; } ?>">
</td>
</tr>
<tr>
<td> <table width="100%" CELLPADDING="2" CELLSPACING="0" border="1" bordercolor="<?PHP print "$BorderColour"; ?>">
<tr bgcolor="<?PHP print "$TableBGcolour"; ?>">
<th>Product</th>
<th>Cost</th>
<th><?PHP print "$TaxName"; ?></th>
<th>Total</th>
</tr>
<tr>
<td><img src="blank.gif" width="450" height="14"></td>
<td><img src="blank.gif" width="60" height="14"></td>
<td><img src="blank.gif" width="60" height="14"></td>
<td><img src="blank.gif" width="60" height="14"></td>
</tr>
<?php
$tot_cost = 0;
$tot_vat = 0;
$tot_price = 0;
for($l=0; $l<sizeof($order); $l++){
?>
<input type="hidden" name="order[<?php print $l; ?>]" value="<?php print tag($order[$l]); ?>">
<input type="hidden" name="price[<?php print $l; ?>]" value="<?php print tag($price[$l]); ?>">
<tr>
<td><?php print $order[$l]; ?></td>
<td align="right"><?php print "$CurrencyUnit"; ?><?php print number_format($price[$l]/($vat_at+100)*100, 2); ?></td>
<td align="right"><?php print "$CurrencyUnit"; ?><?php print number_format($price[$l]-($price[$l]/($vat_at+100)*100),2); ?></td>
<td align="right"><?php print "$CurrencyUnit"; ?><?php print number_format($price[$l],2); ?></td>
</tr>
<?php
$tot_cost += $price[$l]/($vat_at+100)*100;
$tot_vat += $price[$l]-($price[$l]/($vat_at+100)*100);
$tot_price += $price[$l];
}
?>
<tr>
<td>
<input type="text" name="order[<?php print sizeof($order); ?>]" size="70"></td>
<td align="right"><img src="blank.gif" width="60" height="14"></td>
<td align="right"><img src="blank.gif" width="60" height="14"></td>
<td align="right"><?php print "$CurrencyUnit"; ?> <input type="text" name="price[<?php print sizeof($price); ?>]" size="5"></td>
</tr> <tr>
<td colspan=4><?php if($DisplayVat == "Y") {
print "<input type=\"hidden\" name=\"vat_at\" value=\"$VatRate\" size=\"4\">
<i>$TaxName charged at a rate of $VatRate%</i>"; } else print "<img src=\"blank.gif\" width=\"1\" height=\"14\">"; ?></td>
</tr>
</table> <table align="right" width="0" CELLPADDING="2" CELLSPACING="1" border="1" bordercolor="<?PHP print "$BorderColour"; ?>">
<br>
<tr>
<td width="60" align="right"><b><?php print "$CurrencyUnit"; ?><?php print number_format($tot_cost,2); ?></b></td>
<td align="right" width="60"><b><?php print "$CurrencyUnit"; ?><?php print number_format($tot_vat,2); ?></b></td>
<td align="right" width="60"><b><?php print "$CurrencyUnit"; ?><?php print number_format($tot_price,2); ?></b></td>
</tr>
</table><br>
<br>
<br>Enter any additional notes:<br>
<textarea name="notes" cols="100%" rows="5"><?php print "$notes"; ?></textarea> <br> <br><br>
<?php print "$InvoiceSignature"; ?><br></td>
</tr>
<tr>
<td><br> <br> <p align="center"><input name="action" type="submit" value="Update Invoice" class="button">
<input name="action" type="submit" value="Process Invoice" class="button"></p></td>
</tr></table>
</FORM> </TD>
</TR>
</TABLE>
</DIV>
</BODY>
</HTML>
<?php
}
if($action == "Process Invoice"){ processform();} else {mainform();}
?>