1<?php
2
3/*	Please note that addTextWrap() prints a font-size-height further down than
4	addText() and other functions. Use addText() instead of addTextWrap() to
5	print left aligned elements.*/
6
7if (!$FirstPage){ /* only initiate a new page if its not the first */
8	$pdf->newPage();
9}
10
11$YPos = $Page_Height-$Top_Margin;
12
13$pdf->addJpegFromFile($_SESSION['LogoFile'],$Page_Width/2 -120,$YPos-40,0,60);
14$FontSize =15;
15if ($InvOrCredit=='Invoice') {
16
17        $pdf->addText($Page_Width - 200, $YPos, $FontSize, _('TAX INVOICE') . ' ');
18} else {
19	$pdf->addText($Page_Width - 200, $YPos, $FontSize, _('CREDIT NOTE') . ' ');
20}
21
22$FontSize = 10;
23$pdf->addTextWrap($Page_Width-$Left_Margin-42, $YPos+5, 72, $FontSize, _('Page') . ' ' . $PageNumber);
24
25$XPos = $Page_Width - 265;
26$YPos -= 111;
27/*draw a nice curved corner box around the billing details */
28/*from the top right */
29$pdf->partEllipse($XPos+225,$YPos+100,0,90,10,10);
30/*line to the top left */
31$pdf->line($XPos+225, $YPos+110,$XPos, $YPos+110);
32/*Dow top left corner */
33$pdf->partEllipse($XPos, $YPos+100,90,180,10,10);
34/*Do a line to the bottom left corner */
35$pdf->line($XPos-10, $YPos+100,$XPos-10, $YPos+5);
36/*Now do the bottom left corner 180 - 270 coming back west*/
37$pdf->partEllipse($XPos, $YPos+5,180,270,10,10);
38/*Now a line to the bottom right */
39$pdf->line($XPos, $YPos-5,$XPos+225, $YPos-5);
40/*Now do the bottom right corner */
41$pdf->partEllipse($XPos+225, $YPos+5,270,360,10,10);
42/*Finally join up to the top right corner where started */
43$pdf->line($XPos+235, $YPos+5,$XPos+235, $YPos+100);
44
45$YPos = $Page_Height - $Top_Margin - 10;
46
47$pdf->addText($Page_Width-268, $YPos-13, $FontSize, _('Number'));
48$pdf->addText($Page_Width-180, $YPos-13, $FontSize, $FromTransNo);
49$pdf->addText($Page_Width-268, $YPos-26, $FontSize, _('Customer Code'));
50$pdf->addText($Page_Width-180, $YPos-26, $FontSize, $myrow['debtorno'] . ' ' . _('Branch') . ' ' . $myrow['branchcode']);
51$pdf->addText($Page_Width-268, $YPos-39, $FontSize, _('Date'));
52$pdf->addText($Page_Width-180, $YPos-39, $FontSize, ConvertSQLDate($myrow['trandate']));
53
54
55if ($InvOrCredit=='Invoice') {
56
57	$pdf->addText($Page_Width-268, $YPos-52, $FontSize, _('Order No'));
58	$pdf->addText($Page_Width-180, $YPos-52, $FontSize, $myrow['orderno']);
59	$pdf->addText($Page_Width-268, $YPos-65, $FontSize, _('Order Date'));
60	$pdf->addText($Page_Width-180, $YPos-65, $FontSize, ConvertSQLDate($myrow['orddate']));
61	$pdf->addText($Page_Width-268, $YPos-78, $FontSize, _('Dispatch Detail'));
62	$pdf->addText($Page_Width-180, $YPos-78, $FontSize, $myrow['shippername'] . '-' . $myrow['consignment']);
63	$pdf->addText($Page_Width-268, $YPos-91, $FontSize, _('Dispatched From'));
64	$pdf->addText($Page_Width-180, $YPos-91, $FontSize, $myrow['locationname']);
65}
66
67
68/*End of the text in the right side box */
69
70/*Now print out the company name and address in the middle under the logo */
71$XPos = $Page_Width/2 -90;
72$YPos = $Page_Height - $Top_Margin-60;
73$pdf->addText($XPos, $YPos, $FontSize, $_SESSION['CompanyRecord']['coyname']);
74
75$FontSize=8;
76$pdf->addText($XPos, $YPos-10, $FontSize, $_SESSION['TaxAuthorityReferenceName'] . ': ' . $_SESSION['CompanyRecord']['gstno']);
77$pdf->addText($XPos, $YPos-19,$FontSize, $_SESSION['CompanyRecord']['regoffice1']);
78$pdf->addText($XPos, $YPos-28,$FontSize, $_SESSION['CompanyRecord']['regoffice2']);
79$pdf->addText($XPos, $YPos-37,$FontSize, $_SESSION['CompanyRecord']['regoffice3'] . '  ' . $_SESSION['CompanyRecord']['regoffice4'] . '  ' . $_SESSION['CompanyRecord']['regoffice5']);
80$pdf->addText($XPos, $YPos-46, $FontSize, $_SESSION['CompanyRecord']['regoffice6']);
81$pdf->addText($XPos, $YPos-54, $FontSize, _('Phone') . ':' . $_SESSION['CompanyRecord']['telephone'] . ' ' . _('Fax') . ': ' . $_SESSION['CompanyRecord']['fax']);
82$pdf->addText($XPos, $YPos-63, $FontSize, _('Email') . ': ' . $_SESSION['CompanyRecord']['email']);
83
84/*Now the customer charged to details top left */
85
86$XPos = $Left_Margin;
87$YPos = $Page_Height - $Top_Margin;
88
89$FontSize=10;
90
91$pdf->addText($XPos, $YPos, $FontSize, _('Sold To') . ':');
92$XPos +=80;
93
94if ($myrow['invaddrbranch']==0){
95	$pdf->addText($XPos, $YPos, $FontSize, html_entity_decode($myrow['name']));
96	$pdf->addText($XPos, $YPos-14, $FontSize, html_entity_decode($myrow['address1']));
97	$pdf->addText($XPos, $YPos-28, $FontSize, html_entity_decode($myrow['address2']));
98	$pdf->addText($XPos, $YPos-42, $FontSize, html_entity_decode($myrow['address3']) . '  ' . html_entity_decode($myrow['address4']) . '  ' . html_entity_decode($myrow['address5']) . '  ' . html_entity_decode($myrow['address6']));
99} else {
100	$pdf->addText($XPos, $YPos, $FontSize, html_entity_decode($myrow['name']));
101	$pdf->addText($XPos, $YPos-14, $FontSize, html_entity_decode($myrow['brpostaddr1']));
102	$pdf->addText($XPos, $YPos-28, $FontSize, html_entity_decode($myrow['brpostaddr2']));
103	$pdf->addText($XPos, $YPos-42, $FontSize, html_entity_decode($myrow['brpostaddr3']) . '  ' . html_entity_decode($myrow['brpostaddr4']) . '  ' . html_entity_decode($myrow['brpostaddr5']) . '  ' . html_entity_decode($myrow['brpostaddr6']));
104}
105
106
107$XPos -=80;
108$YPos -=($line_height*4);
109
110if ($InvOrCredit=='Invoice') {
111
112	$pdf->addText($XPos, $YPos, $FontSize, _('Delivered To') . ':');
113	$XPos +=80;
114// Before trying to call htmlspecialchars_decode, check that its supported, if not substitute a compatible version
115if (!function_exists('htmlspecialchars_decode')) {
116        function htmlspecialchars_decode($str) {
117                $trans = get_html_translation_table(HTML_SPECIALCHARS);
118
119                $decode = ARRAY();
120                foreach ($trans AS $char=>$entity) {
121                        $decode[$entity] = $char;
122                }
123
124                $str = strtr($str, $decode);
125
126                return $str;
127        }
128}
129	$pdf->addText($XPos, $YPos, $FontSize, html_entity_decode($myrow['deliverto']));
130	$pdf->addText($XPos, $YPos-14, $FontSize, html_entity_decode($myrow['deladd1']));
131	$pdf->addText($XPos, $YPos-28, $FontSize, html_entity_decode($myrow['deladd2']));
132	$pdf->addText($XPos, $YPos-42, $FontSize, html_entity_decode($myrow['deladd3']) . '  ' . html_entity_decode($myrow['deladd4']) . '  ' . html_entity_decode($myrow['deladd5']) . '  ' . html_entity_decode($myrow['deladd6']));
133	$XPos -=80;
134}
135if ($InvOrCredit=='Credit'){
136/* then its a credit note */
137
138	$pdf->addText($XPos, $YPos, $FontSize, _('Charge Branch') . ':');
139	$XPos +=80;
140	$pdf->addText($XPos, $YPos, $FontSize, html_entity_decode($myrow['brname']));
141	$pdf->addText($XPos, $YPos-14, $FontSize, html_entity_decode($myrow['braddress1']));
142	$pdf->addText($XPos, $YPos-28, $FontSize, html_entity_decode($myrow['braddress2']));
143	$pdf->addText($XPos, $YPos-42, $FontSize, html_entity_decode($myrow['braddress3']) . '  ' . html_entity_decode($myrow['braddress4']) . '  ' . html_entity_decode($myrow['braddress5']) . '  ' . html_entity_decode($myrow['braddress6']));
144	$XPos -=80;
145}
146
147$XPos = $Left_Margin;
148
149$YPos = $Page_Height - $Top_Margin - 80;
150/*draw a line under the company address and charge to address
151$pdf->line($XPos, $YPos,$Right_Margin, $YPos); */
152
153$XPos = $Page_Width/2;
154
155$XPos = $Left_Margin;
156$YPos -= ($line_height*2);
157
158include($PathPrefix . 'includes/CurrenciesArray.php'); // To get the currency name from the currency code.
159$pdf->addText($Left_Margin, $YPos-8, $FontSize, _('All amounts stated in') . ': ' . $myrow['currcode'] . ' ' . $CurrencyName[$myrow['currcode']]);
160
161if ($InvOrCredit=='Invoice') {
162	$pdf->addText($Page_Width-$Left_Margin-88, $YPos-8, $FontSize, _('Due Date') . ': ' . $DisplayDueDate);
163}
164
165/*draw a box with nice round corner for entering line items */
166/*90 degree arc at top right of box 0 degrees starts a bottom */
167$pdf->partEllipse($Page_Width-$Right_Margin-10, $Bottom_Margin+390,0,90,10,10);
168/*line to the top left */
169$pdf->line($Page_Width-$Right_Margin-10, $Bottom_Margin+400,$Left_Margin+10, $Bottom_Margin+400);
170/*Dow top left corner */
171$pdf->partEllipse($Left_Margin+10, $Bottom_Margin+390,90,180,10,10);
172/*Do a line to the bottom left corner */
173$pdf->line($Left_Margin, $Bottom_Margin+390,$Left_Margin, $Bottom_Margin+10);
174/*Now do the bottom left corner 180 - 270 coming back west*/
175$pdf->partEllipse($Left_Margin+10, $Bottom_Margin+10,180,270,10,10);
176/*Now a line to the bottom right */
177$pdf->line($Left_Margin+10, $Bottom_Margin,$Page_Width-$Right_Margin-10, $Bottom_Margin);
178/*Now do the bottom right corner */
179$pdf->partEllipse($Page_Width-$Right_Margin-10, $Bottom_Margin+10,270,360,10,10);
180/*Finally join up to the top right corner where started */
181$pdf->line($Page_Width-$Right_Margin, $Bottom_Margin+10,$Page_Width-$Right_Margin, $Bottom_Margin+390);
182
183
184$YPos -= ($line_height*2);
185/*Set up headings */
186$FontSize=10;
187$pdf->addText($Left_Margin + 2, $YPos, $FontSize, _('Customer Tax Ref') . ':');
188$pdf->addText($Left_Margin+100, $YPos, $FontSize, $myrow['taxref']);
189
190
191/*Print a vertical line */
192$pdf->line($Left_Margin+248, $YPos-10+$line_height+3,$Left_Margin+248, $YPos - 18);
193if ($InvOrCredit=='Invoice'){
194	$pdf->addText($Left_Margin + 252, $YPos, $FontSize, _('Customer Order Ref.') . ':');
195	$pdf->addText($Left_Margin+370, $YPos, $FontSize, $myrow['customerref']);
196}
197/*Print a vertical line */
198$pdf->line($Left_Margin+450, $YPos+$line_height-7,$Left_Margin+450,$YPos-18);
199
200$pdf->addText($Left_Margin+453, $YPos, $FontSize, _('Sales Person') . ':');
201$pdf->addText($Left_Margin+510, $YPos, $FontSize, $myrow['salesmanname']);
202
203$YPos -= 8;
204/*draw a line */
205$pdf->line($XPos, $YPos-10,$Page_Width-$Right_Margin, $YPos-10);
206
207$YPos -= 12;
208
209$TopOfColHeadings = $YPos-10;
210
211$pdf->addText($Left_Margin+5, $YPos, $FontSize, _('Item Code'));
212$pdf->addText($Left_Margin+100, $YPos, $FontSize, _('Description'));
213$pdf->addText($Left_Margin+382, $YPos, $FontSize, _('Unit Price'));
214$pdf->addText($Left_Margin+485, $YPos, $FontSize, _('Quantity'));
215$pdf->addText($Left_Margin+555, $YPos, $FontSize, _('UOM'));
216$pdf->addText($Left_Margin+595, $YPos, $FontSize, _('Discount'));
217$pdf->addText($Left_Margin+690, $YPos, $FontSize, _('Extended Price'));
218
219$YPos-=8;
220
221/*draw a line */
222$pdf->line($XPos, $YPos-5,$Page_Width-$Right_Margin, $YPos-5);
223
224$YPos -= ($line_height);
225
226?>
227