[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/vtlib/Vtiger/PDF/inventory/ -> HeaderViewer.php (source)

   1  <?php
   2  /*+**********************************************************************************
   3   * The contents of this file are subject to the vtiger CRM Public License Version 1.0
   4   * ("License"); You may not use this file except in compliance with the License
   5   * The Original Code is:  vtiger CRM Open Source
   6   * The Initial Developer of the Original Code is vtiger.
   7   * Portions created by vtiger are Copyright (C) vtiger.
   8   * All Rights Reserved.
   9   ************************************************************************************/
  10  include_once dirname(__FILE__) . '/../viewers/HeaderViewer.php';
  11  
  12  class Vtiger_PDF_InventoryHeaderViewer extends Vtiger_PDF_HeaderViewer {
  13  
  14  	function totalHeight($parent) {
  15          $height = 100;
  16          
  17          if($this->onEveryPage) return $height;
  18          if($this->onFirstPage && $parent->onFirstPage()) $height;
  19          return 0;
  20      }
  21      
  22  	function display($parent) {
  23          $pdf = $parent->getPDF();
  24          $headerFrame = $parent->getHeaderFrame();
  25          if($this->model) {
  26              $headerColumnWidth = $headerFrame->w/3.0;
  27              
  28              $modelColumns = $this->model->get('columns');
  29              
  30              // Column 1
  31              $offsetX = 5;
  32              
  33              $modelColumn0 = $modelColumns[0];
  34  
  35              list($imageWidth, $imageHeight, $imageType, $imageAttr) = $parent->getimagesize(
  36                      $modelColumn0['logo']);
  37              //division because of mm to px conversion
  38              $w = $imageWidth/3;
  39              if($w > 60) {
  40                  $w=60;
  41              }
  42              $h = $imageHeight/3;
  43              if($h > 30) {
  44                  $h = 30;
  45              }
  46              $pdf->Image($modelColumn0['logo'], $headerFrame->x, $headerFrame->y, $w, $h);
  47              $imageHeightInMM = 30;
  48              
  49              $pdf->SetFont('freeserif', 'B');
  50              $contentHeight = $pdf->GetStringHeight( $modelColumn0['summary'], $headerColumnWidth);
  51              $pdf->MultiCell($headerColumnWidth, $contentHeight, $modelColumn0['summary'], 0, 'L', 0, 1, 
  52                  $headerFrame->x, $headerFrame->y+$imageHeightInMM+2);
  53              
  54              $pdf->SetFont('freeserif', '');
  55              $contentHeight = $pdf->GetStringHeight( $modelColumn0['content'], $headerColumnWidth);            
  56              $pdf->MultiCell($headerColumnWidth, $contentHeight, $modelColumn0['content'], 0, 'L', 0, 1, 
  57                  $headerFrame->x, $pdf->GetY());
  58                  
  59              // Column 2
  60              $offsetX = 5;
  61              $pdf->SetY($headerFrame->y);
  62  
  63              $modelColumn1 = $modelColumns[1];
  64              
  65              $offsetY = 8;
  66              foreach($modelColumn1 as $label => $value) {
  67  
  68                  if(!empty($value)) {
  69                      $pdf->SetFont('freeserif', 'B');
  70                      $pdf->SetFillColor(205,201,201);
  71                      $pdf->MultiCell($headerColumnWidth-$offsetX, 7, $label, 1, 'C', 1, 1, $headerFrame->x+$headerColumnWidth+$offsetX, $pdf->GetY()+$offsetY);
  72  
  73                      $pdf->SetFont('freeserif', '');
  74                      $pdf->MultiCell($headerColumnWidth-$offsetX, 7, $value, 1, 'C', 0, 1, $headerFrame->x+$headerColumnWidth+$offsetX, $pdf->GetY());
  75                      $offsetY = 2;
  76                  }
  77              }
  78              
  79              // Column 3
  80              $offsetX = 10;
  81              
  82              $modelColumn2 = $modelColumns[2];
  83              
  84              $contentWidth = $pdf->GetStringWidth($this->model->get('title'));
  85              $contentHeight = $pdf->GetStringHeight($this->model->get('title'), $contentWidth);
  86              
  87              $roundedRectX = $headerFrame->w+$headerFrame->x-$contentWidth*2.0;
  88              $roundedRectW = $contentWidth*2.0;
  89              
  90              $pdf->RoundedRect($roundedRectX, 10, $roundedRectW, 10, 3, '1111', 'DF', array(), array(205,201,201));
  91              
  92              $contentX = $roundedRectX + (($roundedRectW - $contentWidth)/2.0);
  93              $pdf->SetFont('freeserif', 'B');
  94              $pdf->MultiCell($contentWidth*2.0, $contentHeight, $this->model->get('title'), 0, 'R', 0, 1, $contentX-$contentWidth,
  95                   $headerFrame->y+2);
  96  
  97              $offsetY = 4;
  98  
  99              foreach($modelColumn2 as $label => $value) {
 100                  if(is_array($value)) {
 101                      $pdf->SetFont('freeserif', '');
 102                      foreach($value as $l => $v) {
 103                          $pdf->MultiCell($headerColumnWidth-$offsetX, 7, sprintf('%s: %s', $l, $v), 1, 'C', 0, 1, 
 104                              $headerFrame->x+$headerColumnWidth*2.0+$offsetX, $pdf->GetY()+$offsetY);
 105                          $offsetY = 0;
 106                      }
 107                  } else {
 108                      $offsetY = 1;
 109                      
 110                  $pdf->SetFont('freeserif', 'B');
 111                  $pdf->SetFillColor(205,201,201);
 112                                  if($label=='Shipping Address'){ 
 113                                      $width=$pdf->GetStringWidth($value); 
 114                                      $height=$pdf->GetStringHeight($value,$width);
 115                                      $pdf->MultiCell($headerColumnWidth-$offsetX, 7, $label, 1, 'L', 1, 1, $headerFrame->x+$headerColumnWidth*2.0+$offsetX,
 116                                              $pdf->GetY()+$offsetY-$height-$offsetX-4.0); 
 117  
 118                                      $pdf->SetFont('freeserif', '');
 119                                      $pdf->MultiCell($headerColumnWidth-$offsetX, 7, $value, 1, 'L', 0, 1, $headerFrame->x+$headerColumnWidth*2.0+$offsetX, 
 120                      $pdf->GetY());
 121                  } else{ 
 122                                      $pdf->MultiCell($headerColumnWidth-$offsetX, 7, $label, 1, 'L', 1, 1, $headerFrame->x+$headerColumnWidth, 
 123                                              $pdf->GetY()+$offsetY); 
 124  
 125                                      $pdf->SetFont('freeserif', ''); 
 126                                      $pdf->MultiCell($headerColumnWidth-$offsetX, 7, $value, 1, 'L', 0, 1, $headerFrame->x+$headerColumnWidth,  
 127                                              $pdf->GetY()); 
 128                                      } 
 129                                  } 
 130                              } 
 131              $pdf->setFont('freeserif', '');
 132  
 133              // Add the border cell at the end
 134              // This is required to reset Y position for next write
 135              $pdf->MultiCell($headerFrame->w, $headerFrame->h-$headerFrame->y, "", 0, 'L', 0, 1, $headerFrame->x, $headerFrame->y);
 136          }    
 137          
 138      }
 139      
 140  }


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1