Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2011
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.99 KB | None | 0 0
  1. <?php
  2.  
  3. $pdf->SetAutoPageBreak(TRUE,20);
  4.  
  5. # Logo
  6. $pdf->Image(ROOTDIR.'/images/logo.jpg',20,5);
  7.  
  8. # Company Details
  9. $pdf->SetFont('freesans','',13);
  10. $pdf->Cell(0,6,trim($companyaddress[0]),0,1,'R');
  11. $pdf->SetFont('freesans','',9);
  12. for ( $i = 1; $i <= count($companyaddress); $i += 1) {
  13. $pdf->Cell(0,4,trim($companyaddress[$i]),0,1,'R');
  14. }
  15. $pdf->Ln(5);
  16.  
  17. # Header Bar
  18. $invoiceprefix = $_LANG["invoicenumber"];
  19. /*
  20. ** This code should be uncommented for EU companies using the sequential invoice numbering so that when unpaid it is shown as a proforma invoice **
  21. if ($status!="Paid") {
  22. $invoiceprefix = $_LANG["proformainvoicenumber"];
  23. }
  24. */
  25. $pdf->SetFont('freesans','B',15);
  26. $pdf->SetFillColor(239);
  27. $pdf->Cell(0,8,$invoiceprefix.$invoicenum,0,1,'L','1');
  28. $pdf->SetFont('freesans','',10);
  29. $pdf->Cell(0,6,$_LANG["invoicesdatecreated"].': '.$datecreated.'',0,1,'L','1');
  30. $pdf->Cell(0,6,$_LANG["invoicesdatedue"].': '.$duedate.'',0,1,'L','1');
  31. $pdf->Ln(10);
  32.  
  33. $startpage = $pdf->GetPage();
  34.  
  35. # Clients Details
  36. $pdf->SetFont('freesans','B',10);
  37. $pdf->Cell(0,4,$_LANG["invoicesinvoicedto"],0,1);
  38. $pdf->SetFont('freesans','',9);
  39. if ($clientsdetails["companyname"]) {
  40. $pdf->Cell(0,4,$clientsdetails["companyname"],0,1,'L');
  41. $pdf->Cell(0,4,$_LANG["invoicesattn"].": ".$clientsdetails["firstname"]." ".$clientsdetails["lastname"],0,1,'L');
  42. } else {
  43. $pdf->Cell(0,4,$clientsdetails["firstname"]." ".$clientsdetails["lastname"],0,1,'L');
  44. }
  45. $pdf->Cell(0,4,$clientsdetails["address1"],0,1,'L');
  46. if ($clientsdetails["address2"]) {
  47. $pdf->Cell(0,4,$clientsdetails["address2"],0,1,'L');
  48. }
  49. $pdf->Cell(0,4,$clientsdetails["city"].", ".$clientsdetails["state"].", ".$clientsdetails["postcode"],0,1,'L');
  50. $pdf->Cell(0,4,$clientsdetails["country"],0,1,'L');
  51. if ($customfields) {
  52. $pdf->Ln();
  53. foreach ($customfields AS $customfield) {
  54. $pdf->Cell(0,4,$customfield['fieldname'].': '.$customfield['value'],0,1,'L');
  55. }
  56. }
  57. $pdf->Ln(10);
  58.  
  59. $pdf->SetDrawColor(200);
  60.  
  61. $pdf->SetFont('freesans','B',10);
  62. $pdf->SetFillColor(239);
  63. $pdf->Cell(140,7,$_LANG["invoicesdescription"],1,0,'C','1');
  64. $pdf->Cell(40,7,$_LANG["invoicesamount"],1,0,'C','1');
  65. $pdf->Ln();
  66.  
  67. $pdf->SetFont('freesans','',10);
  68.  
  69. foreach ($invoiceitems AS $item) {
  70.  
  71. $rowcount = $pdf->getNumLines($item['description'], 140)+1;
  72.  
  73. if ($pdf->GetY()+($rowcount*5)>260) $pdf->AddPage();
  74.  
  75. $pdf->MultiCell(140,$rowcount * 5,$item['description'],1,'L',0,0);
  76. $pdf->MultiCell(40,$rowcount * 5,$item['amount'],1,'C',0,0);
  77.  
  78. $pdf->Ln();
  79. }
  80.  
  81. $pdf->SetFont('freesans','B',10);
  82.  
  83. $pdf->Cell(140,7,$_LANG["invoicessubtotal"],1,0,'R','1');
  84. $pdf->Cell(40,7,$subtotal,1,0,'C','1');
  85. $pdf->Ln();
  86.  
  87. if ($taxname) {
  88. $pdf->Cell(140,7,$taxrate."% ".$taxname,1,0,'R','1');
  89. $pdf->Cell(40,7,$tax,1,0,'C','1');
  90. $pdf->Ln();
  91. }
  92.  
  93. if ($taxname2) {
  94. $pdf->Cell(140,7,$taxrate2."% ".$taxname2,1,0,'R','1');
  95. $pdf->Cell(40,7,$tax2,1,0,'C','1');
  96. $pdf->Ln();
  97. }
  98.  
  99. $pdf->Cell(140,7,$_LANG["invoicescredit"],1,0,'R','1');
  100. $pdf->Cell(40,7,$credit,1,0,'C','1');
  101. $pdf->Ln();
  102.  
  103. $pdf->Cell(140,7,$_LANG["invoicestotal"],1,0,'R','1');
  104. $pdf->Cell(40,7,$total,1,0,'C','1');
  105. $pdf->Ln();
  106.  
  107. $pdf->Ln();
  108.  
  109. if ($notes) {
  110. $pdf->SetFont('freesans','',8);
  111. $pdf->MultiCell(170,5,$_LANG["invoicesnotes"].": $notes");
  112. }
  113.  
  114. $endpage = $pdf->GetPage();
  115.  
  116. $pdf->setPage($startpage);
  117. $pdf->SetXY(70,90);
  118. if ($status=="Cancelled") {
  119. $statustext = $_LANG["invoicescancelled"];
  120. $pdf->SetTextColor(245,245,245);
  121. } elseif ($status=="Unpaid") {
  122. $statustext = $_LANG["invoicesunpaid"];
  123. $pdf->SetTextColor(204,0,0);
  124. } elseif ($status=="Paid") {
  125. $statustext = $_LANG["invoicespaid"];
  126. $pdf->SetTextColor(153,204,0);
  127. } elseif ($status=="Refunded") {
  128. $statustext = $_LANG["invoicesrefunded"];
  129. $pdf->SetTextColor(34,68,136);
  130. } elseif ($status=="Collections") {
  131. $statustext = $_LANG["invoicescollections"];
  132. $pdf->SetTextColor(255,204,0);
  133. }
  134. $pdf->SetFont('freesans','B',40);
  135. $pdf->Cell(120,20,strtoupper($statustext),0,0,'C');
  136. $pdf->setPage($endpage);
  137.  
  138. ?>
  139.  
  140.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement