Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
6b83d5bd | 6 | | Copyright CiviCRM LLC (c) 2004-2019 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
6b83d5bd | 31 | * @copyright CiviCRM LLC (c) 2004-2019 |
6a488035 TO |
32 | */ |
33 | ||
34 | /** | |
6dd9d5c2 | 35 | * This class helps to print the labels for contacts. |
6a488035 TO |
36 | */ |
37 | class CRM_Event_Form_Task_Badge extends CRM_Event_Form_Task { | |
38 | ||
39 | /** | |
40 | * Are we operating in "single mode", i.e. sending email to one | |
41 | * specific contact? | |
42 | * | |
43 | * @var boolean | |
44 | */ | |
45 | public $_single = FALSE; | |
46 | ||
6d4a64c8 | 47 | /** |
eceb18cc | 48 | * Component clause. |
6d4a64c8 KJ |
49 | */ |
50 | public $_componentClause; | |
51 | ||
6a488035 | 52 | /** |
eceb18cc | 53 | * Build all the data structures needed to build the form. |
6a488035 TO |
54 | * |
55 | * @param | |
56 | * | |
57 | * @return void | |
6d4a64c8 | 58 | */ |
00be9182 | 59 | public function preProcess() { |
edc80cda | 60 | $this->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this); |
6a488035 TO |
61 | if ($this->_context == 'view') { |
62 | $this->_single = TRUE; | |
63 | ||
64 | $participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); | |
65 | $contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE); | |
66 | $this->_participantIds = array($participantID); | |
67 | $this->_componentClause = " civicrm_participant.id = $participantID "; | |
68 | $this->assign('totalSelectedParticipants', 1); | |
69 | ||
70 | // also set the user context to send back to view page | |
71 | $session = CRM_Core_Session::singleton(); | |
72 | $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view/participant', | |
353ffa53 TO |
73 | "reset=1&action=view&id={$participantID}&cid={$contactID}" |
74 | )); | |
6a488035 TO |
75 | } |
76 | else { | |
77 | parent::preProcess(); | |
78 | } | |
79 | } | |
80 | ||
81 | /** | |
eceb18cc | 82 | * Build the form object. |
6a488035 | 83 | */ |
00be9182 | 84 | public function buildQuickForm() { |
6a488035 TO |
85 | CRM_Utils_System::setTitle(ts('Make Name Badges')); |
86 | ||
22029f77 CW |
87 | // Ajax submit would interfere with file download |
88 | $this->preventAjaxSubmit(); | |
89 | ||
6a488035 | 90 | //add select for label |
8c7f8a8b | 91 | $label = CRM_Badge_BAO_Layout::getList(); |
6a488035 TO |
92 | |
93 | $this->add('select', | |
94 | 'badge_id', | |
95 | ts('Name Badge Format'), | |
96 | array( | |
e7483cbe | 97 | '' => ts('- select -'), |
353ffa53 | 98 | ) + $label, TRUE |
6a488035 TO |
99 | ); |
100 | ||
101 | $next = 'next'; | |
102 | $back = $this->_single ? 'cancel' : 'back'; | |
103 | $this->addDefaultButtons(ts('Make Name Badges'), $next, $back); | |
104 | } | |
105 | ||
106 | /** | |
eceb18cc | 107 | * Process the form after the input has been submitted and validated. |
6a488035 TO |
108 | */ |
109 | public function postProcess() { | |
110 | $params = $this->controller->exportValues($this->_name); | |
6d4a64c8 | 111 | CRM_Badge_BAO_Badge::buildBadges($params, $this); |
6a488035 | 112 | } |
96025800 | 113 | |
6a488035 | 114 | } |