PageRenderTime 89ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/chronique/includes/PDFTransPageHeaderPortrait.inc

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