From: Kurund Jalmi Date: Thu, 4 Jul 2013 20:18:55 +0000 (+0530) Subject: CRM-12966, added missing files X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=42c62ec1d9dd8e34cb53a9afe4d912c87fede8a5;p=civicrm-core.git CRM-12966, added missing files --- diff --git a/CRM/Badge/Format/Avery5395.php b/CRM/Badge/Format/Avery5395.php new file mode 100644 index 0000000000..1c6453ff7e --- /dev/null +++ b/CRM/Badge/Format/Avery5395.php @@ -0,0 +1,61 @@ +lMarginLogo = 20; + $this->tMarginName = 20; + + $x = $this->pdf->GetAbsX(); + $y = $this->pdf->GetY(); + + $this->printImage($participant['image_1']); + + $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, $participant['token'][1]['value'], $this->border, "L", 0, 1, $x + $this->lMarginLogo, $y); + + $this->pdf->SetFontSize(20); + $this->pdf->MultiCell($this->pdf->width, 10, $participant['token'][2]['value'], $this->border, "C", 0, 1, $x, $y + $this->tMarginName); + $this->pdf->SetFontSize(15); + $this->pdf->MultiCell($this->pdf->width, 0, $participant['token'][3]['value'], $this->border, "C", 0, 1, $x, $this->pdf->getY()); + + $this->pdf->SetFontSize(9); + $this->pdf->SetXY($x, $y + $this->pdf->height - 5); + $date = CRM_Utils_Date::customFormat($participant['token'][4]['value'], "%e %b"); + $this->pdf->Cell($this->pdf->width, 0, $date, $this->border, 2, "R"); + } +} diff --git a/CRM/Badge/Format/Badge.php b/CRM/Badge/Format/Badge.php new file mode 100644 index 0000000000..47d482426a --- /dev/null +++ b/CRM/Badge/Format/Badge.php @@ -0,0 +1,121 @@ +pdf->GetAbsX(); + $y = $this->pdf->GetY(); + + $this->imgRes = 300; + + if ($img) { + $imgsize = getimagesize($img); + // mm + $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->SetXY($x, $y); + } + + /** + * This function is called to create name label pdf + * + * @param array $participants associated array with participant info + * @param array $layoutInfo associated array which contains meta data about format/layout + * + * @return void + * @access public + */ + function createLabels(&$participants, &$layoutInfo) { + $this->pdf = new CRM_Utils_PDF_Label($layoutInfo['format'], 'mm'); + $this->pdf->Open(); + $this->pdf->setPrintHeader(FALSE); + $this->pdf->setPrintFooter(FALSE); + $this->pdf->AddPage(); + $this->pdf->AddFont('DejaVu Sans', '', 'DejaVuSans.php'); + $this->pdf->SetFont('DejaVu Sans'); + $this->pdf->SetGenerator($this, "generateLabel"); + + foreach ($participants as $participant) { + $formattedRow = self::formatLabel($participant, $layoutInfo); + $this->pdf->AddPdfLabel($formattedRow); + } + + $this->pdf->Output(CRM_Utils_String::munge($layoutInfo['title'], '_', 64) . '.pdf', 'D'); + CRM_Utils_System::civiExit(1); + } + + /** + * Funtion to create structure and add meta data according to layout + * + * @param array $row row element that needs to be formatted + * @param array $layout layout meta data + * + * @return array $formattedRow row with meta data + */ + static function formatLabel(&$row, &$layout) { + $formattedRow = array(); + if (CRM_Utils_Array::value('rowElements', $layout['data'])) { + foreach($layout['data']['rowElements'] as $key => $element) { + $formattedRow['token'][$key] = array( + 'value' => $row[$element], + 'font_name' => $layout['data']['font_name'][$key], + 'font_size' => $layout['data']['font_size'][$key], + 'text_alignment' => $layout['data']['text_alignment'][$key], + ); + } + } + + if (CRM_Utils_Array::value('image_1', $layout['data'])) { + $formattedRow['image_1'] = $layout['data']['image_1']; + } + + if (CRM_Utils_Array::value('image_2', $layout['data'])) { + $formattedRow['image_2'] = $layout['data']['image_2']; + } + + if (CRM_Utils_Array::value('add_barcode', $layout['data'])) { + $formattedRow['barcode'] = $layout['data']['barcode_alignment']; + } + + return $formattedRow; + } +} +