Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. <?php
  2. global $org_options;
  3. if(getCountryZoneId($org_options['organization_country']) == '2'){
  4. $currency_sign = 'EUR ';
  5. }else{
  6. $currency_sign = html_entity_decode( $org_options[ 'currency_symbol' ], ENT_QUOTES, 'ISO-8859-15' );
  7. }
  8. class Espresso_PDF extends Espresso_FPDF{
  9. //Page header
  10. function Header(){
  11. global $org_options;
  12. $invoice_payment_settings = get_option('event_espresso_invoice_payment_settings');
  13. //Logo
  14. if (isset($invoice_payment_settings['image_url'])&&trim($invoice_payment_settings['image_url']) !=''){
  15. $this->Image($invoice_payment_settings['image_url'],10,8,90);//Set the logo if it is available
  16. }else{
  17. $this->SetFont('Arial','B',15);
  18. $this->Cell(10,10,pdftext($org_options['organization']),0,0,'L');//If no logo, then display the organizatin name
  19. }
  20.  
  21. //Arial bold 15
  22. $this->SetFont('Arial','B',15);
  23. //Move to the right
  24. $this->Cell(80);
  25. //Title
  26. if(isset($invoice_payment_settings['pdf_title']))
  27. $this->MultiCell(100,10,pdftext($invoice_payment_settings['pdf_title']),0,'R');//Set the right header
  28. else
  29. $this->MultiCell(100,10,pdftext(''),0,'R');//Set the right header
  30. //Line break
  31. $this->Ln(20);
  32. }
  33.  
  34. function LoadData($file){
  35. $lines=$file;
  36. $data=array();
  37. foreach($lines as $line)
  38. $data[]=explode(';',chop($line));
  39. return $data;
  40. }
  41.  
  42. //Better table
  43. function ImprovedTable($header,$event_data,$w=array(100,35,40)){
  44. global $org_options, $currency_sign;
  45.  
  46. //Column widths
  47. //Header
  48. for($i=0;$i<count($header);$i++)
  49. $this->Cell($w[$i],7,$header[$i],1,0,'C');
  50. $this->Ln();
  51. $x = $this->GetX();
  52. $y = $this->GetY();
  53. //Data
  54. $counter = 0;
  55. foreach($event_data as $data){
  56. $counter++;
  57. if($counter == 24) {
  58. $this->AddPage();
  59. $counter = 0;
  60. }
  61. foreach($data as $row){
  62. $y1 = $this->GetY();
  63. $this->MultiCell($w[0],6,$row[0],'LBR');
  64. $y2 = $this->GetY();
  65. $yH = $y2 - $y1;
  66. $this->SetXY($x + $w[0], $this->GetY() - $yH);
  67. $this->Cell($w[1],$yH,$row[1],'LBR',0,'C');
  68. $this->Cell($w[2],$yH,$row[2],'LBR',0,'C');
  69. if( isset( $row[3] ) ){
  70. $this->Cell($w[3],$yH, $currency_sign.number_format($row[3],2, '.', ''),'LBR',0,'C');
  71. }
  72. if( isset( $row[4] ) ){
  73. $this->Cell($w[4],$yH, $currency_sign.number_format($row[4],2, '.', ''),'LBR',0,'C');
  74. }
  75. $this->Ln();
  76. }
  77. }
  78. $this->Cell(array_sum($w),0,'','T');
  79. }
  80.  
  81. function InvoiceTotals($text,$total_cost,$left_cell = 125, $right_cell = 35){
  82. global $org_options, $currency_sign;
  83. $this->SetFillColor(192,192,192);
  84. $this->Cell($left_cell, 10, $text, 0, 0, 'R');
  85. $minus = '';
  86. if ( $total_cost < 0 ){
  87. $minus = '-';
  88. $total_cost = (-1)*$total_cost;
  89. }
  90. $this->Cell($right_cell, 10, $minus.$currency_sign.number_format($total_cost,2, '.', ''), 0, 1, 'C');
  91. }
  92. //Page footer
  93. function Footer(){
  94. //Position at 1.5 cm from bottom
  95. $this->SetY(-15);
  96. //Arial italic 8
  97. $this->SetFont('Arial','I',8);
  98. //Page number
  99. $this->Cell(0,10, __('Page','event_espresso').$this->PageNo().'/{nb}',0,0,'C');
  100. }
  101. }
  102.  
  103. //Build the PDF
  104. function pdftext($val){
  105. return iconv("UTF-8", "ISO-8859-1",stripslashes_deep($val));
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement