Merge pull request #15326 from totten/master-headfoot-2
[civicrm-core.git] / CRM / Event / Badge / NameTent.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12
13 /*
14 * Copyright (C) 2010 Tech To The People
15 * Licensed to CiviCRM under the Academic Free License version 3.0.
16 *
17 */
18
19 /**
20 *
21 * @package CRM
22 *
23 */
24 class CRM_Event_Badge_NameTent extends CRM_Event_Badge {
25
26 /**
27 */
28 public function __construct() {
29 parent::__construct();
30 // A4
31 $pw = 297;
32 $ph = 210;
33 $this->lMargin = 10;
34 $this->tMargin = 0;
35 $w = $pw - 2 * $this->lMargin;
36 $h = $ph - 2 * $this->tMargin;
37 $this->format = [
38 'name' => 'A4 horiz',
39 'paper-size' => 'A4',
40 'metric' => 'mm',
41 'lMargin' => 0,
42 'tMargin' => 0,
43 'NX' => 1,
44 'NY' => 1,
45 'SpaceX' => 0,
46 'SpaceY' => 0,
47 'width' => $w,
48 'height' => $h,
49 'font-size' => 36,
50 ];
51 // $this->setDebug ();
52 }
53
54 public function pdfExtraFormat() {
55 $this->pdf->setPageFormat('A4', 'L');
56 }
57
58 /**
59 * @param $participant
60 */
61 protected function writeOneSide(&$participant) {
62 $this->pdf->SetXY(0, $this->pdf->height / 2);
63 $this->printBackground(TRUE);
64 $txt = $participant['display_name'];
65 $this->pdf->SetXY(0, $this->pdf->height / 2 + 20);
66 $this->pdf->SetFontSize(54);
67 $this->pdf->Write(0, $txt, NULL, NULL, 'C');
68 $this->pdf->SetXY(0, $this->pdf->height / 2 + 50);
69 $this->pdf->SetFontSize(36);
70 $this->pdf->Write(0, $participant['current_employer'], NULL, NULL, 'C');
71 }
72
73 /**
74 * @param $participant
75 */
76 public function generateLabel($participant) {
77 $this->writeOneSide($participant);
78 $this->pdf->StartTransform();
79 $this->pdf->Rotate(180, $this->pdf->width / 2 + $this->pdf->marginLeft, $this->pdf->height / 2);
80 $this->writeOneSide($participant);
81 $this->pdf->StopTransform();
82 }
83
84 }