more fixes CRM-12966
authorKurund Jalmi <kurund@civicrm.org>
Thu, 4 Jul 2013 21:30:47 +0000 (03:00 +0530)
committerKurund Jalmi <kurund@civicrm.org>
Thu, 4 Jul 2013 21:30:47 +0000 (03:00 +0530)
CRM/Badge/BAO/Badge.php
CRM/Core/BAO/LabelFormat.php

index 1932bf26f20b406e81020a3484b8a823e9cf1229..a2ffe9ad07de899f0f8101f3960b677657709452 100644 (file)
@@ -46,7 +46,7 @@ class CRM_Badge_BAO_Badge {
    * @return  void
    * @access  public
    */
-   public function createLabels(&$participants, &$layoutInfo) {
+  public function createLabels(&$participants, &$layoutInfo) {
     $this->pdf = new CRM_Utils_PDF_Label($layoutInfo['format'], 'mm');
     $this->pdf->Open();
     $this->pdf->setPrintHeader(FALSE);
@@ -56,6 +56,12 @@ class CRM_Badge_BAO_Badge {
     $this->pdf->SetFont('DejaVu Sans');
     $this->pdf->SetGenerator($this, "generateLabel");
 
+    // this is very useful for debugging, by default set to FALSE
+    $this->debug = TRUE;
+    if ($this->debug) {
+      $this->border = "LTRB";
+    }
+
     foreach ($participants as $participant) {
       $formattedRow = self::formatLabel($participant, $layoutInfo);
       $this->pdf->AddPdfLabel($formattedRow);
@@ -104,7 +110,7 @@ class CRM_Badge_BAO_Badge {
 
   public function generateLabel($formattedRow) {
     switch ($formattedRow['labelFormat']) {
-      case 'Avery5395':
+      case 'Avery 5395':
         self::labelAvery5395($formattedRow);
         break;
     }
@@ -118,21 +124,27 @@ class CRM_Badge_BAO_Badge {
     $y = $this->pdf->GetY();
 
     $this->printImage($formattedRow['image_1']);
+    //$this->printImage($formattedRow['image_2']);
 
     $this->pdf->SetLineStyle(array('width' => 0.1, 'cap' => 'round', 'join' => 'round', 'dash' => '2,2', 'color' => array(0, 0, 200)));
 
-    $this->pdf->SetFontSize(9);
-    $this->pdf->MultiCell($this->pdf->width - $this->lMarginLogo, 0, $formattedRow['token'][1]['value'], $this->border, "L", 0, 1, $x + $this->lMarginLogo, $y);
+    $this->pdf->SetFontSize($formattedRow['token'][1]['font_size']);
+    //$this->pdf->MultiCell($this->pdf->width - $this->lMarginLogo, 0, $formattedRow['token'][1]['value'], $this->border, "L", 0, 1, $x + $this->lMarginLogo, $y);
+    $this->pdf->MultiCell($this->pdf->width - $this->lMarginLogo, 0, $formattedRow['token'][1]['value'],
+      $this->border, $formattedRow['token'][1]['text_alignment'], 0, 1, $x + $this->lMarginLogo, $y);
 
-    $this->pdf->SetFontSize(20);
-    $this->pdf->MultiCell($this->pdf->width, 10, $formattedRow['token'][2]['value'], $this->border, "C", 0, 1, $x, $y + $this->tMarginName);
-    $this->pdf->SetFontSize(15);
-    $this->pdf->MultiCell($this->pdf->width, 0, $formattedRow['token'][3]['value'], $this->border, "C", 0, 1, $x, $this->pdf->getY());
+    $this->pdf->SetFontSize($formattedRow['token'][2]['font_size']);
+    $this->pdf->MultiCell($this->pdf->width, 10, $formattedRow['token'][2]['value'],
+      $this->border, $formattedRow['token'][2]['text_alignment'], 0, 1, $x, $y + $this->tMarginName);
 
-    $this->pdf->SetFontSize(9);
+    $this->pdf->SetFontSize($formattedRow['token'][3]['font_size']);
+    $this->pdf->MultiCell($this->pdf->width, 0, $formattedRow['token'][3]['value'],
+      $this->border, $formattedRow['token'][3]['text_alignment'], 0, 1, $x, $this->pdf->getY());
+
+    $this->pdf->SetFontSize($formattedRow['token'][4]['font_size']);
     $this->pdf->SetXY($x, $y + $this->pdf->height - 5);
     $date = CRM_Utils_Date::customFormat($formattedRow['token'][4]['value'], "%e %b");
-    $this->pdf->Cell($this->pdf->width, 0, $date, $this->border, 2, "R");
+    $this->pdf->Cell($this->pdf->width, 0, $date, $this->border, 2, $formattedRow['token'][4]['text_alignment']);
   }
 
   /**
@@ -142,9 +154,14 @@ class CRM_Badge_BAO_Badge {
    * @return void
    * @access public
    */
-  function printImage($img) {
-    $x = $this->pdf->GetAbsX();
-    $y = $this->pdf->GetY();
+  function printImage($img, $x='', $y='') {
+    if (!$x) {
+      $x = $this->pdf->GetAbsX();
+    }
+
+    if (!$y) {
+      $y = $this->pdf->GetY();
+    }
 
     $this->imgRes = 300;
 
@@ -154,7 +171,8 @@ class CRM_Badge_BAO_Badge {
       $f = $this->imgRes / 25.4;
       $w = $imgsize[0] / $f;
       $h = $imgsize[1] / $f;
-      $this->pdf->Image($img, $this->pdf->GetAbsX(), $this->pdf->GetY(), $w, $h, '', '', '', FALSE, 72, '', FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
+      $this->pdf->Image($img, $x, $y, $w, $h, '', '', '', FALSE, 72, '', FALSE,
+        FALSE, $this->debug, FALSE, FALSE, FALSE);
     }
     $this->pdf->SetXY($x, $y);
   }
index 3b16781c2aa0cac49513d45904db8c271ebd80dd..e3637420ab02f53acc97f1127432ea7e198f87a3 100644 (file)
@@ -205,6 +205,15 @@ class CRM_Core_BAO_LabelFormat extends CRM_Core_DAO_OptionValue {
       13 => ts('13 pt'),
       14 => ts('14 pt'),
       15 => ts('15 pt'),
+      16 => ts('16 pt'),
+      17 => ts('17 pt'),
+      18 => ts('18 pt'),
+      19 => ts('19 pt'),
+      20 => ts('20 pt'),
+      21 => ts('21 pt'),
+      22 => ts('22 pt'),
+      23 => ts('23 pt'),
+      24 => ts('24 pt'),
     );
   }
 
@@ -239,7 +248,7 @@ class CRM_Core_BAO_LabelFormat extends CRM_Core_DAO_OptionValue {
     return array(
       'R' => ts('Right'),
       'L' => ts('Left'),
-      'J' => ts('Justify'),
+      'C' => ts('Center'),
     );
   }