Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
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 | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | */ |
17 | ||
18 | /** | |
6dd9d5c2 | 19 | * This class helps to print the labels for contacts. |
6a488035 TO |
20 | */ |
21 | class CRM_Event_Form_Task_Badge extends CRM_Event_Form_Task { | |
22 | ||
23 | /** | |
24 | * Are we operating in "single mode", i.e. sending email to one | |
25 | * specific contact? | |
26 | * | |
d51c6add | 27 | * @var bool |
6a488035 TO |
28 | */ |
29 | public $_single = FALSE; | |
30 | ||
6d4a64c8 | 31 | /** |
eceb18cc | 32 | * Component clause. |
90b461f1 | 33 | * @var string |
6d4a64c8 KJ |
34 | */ |
35 | public $_componentClause; | |
36 | ||
6a488035 | 37 | /** |
eceb18cc | 38 | * Build all the data structures needed to build the form. |
6a488035 TO |
39 | * |
40 | * @param | |
41 | * | |
42 | * @return void | |
6d4a64c8 | 43 | */ |
00be9182 | 44 | public function preProcess() { |
edc80cda | 45 | $this->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this); |
6a488035 TO |
46 | if ($this->_context == 'view') { |
47 | $this->_single = TRUE; | |
48 | ||
49 | $participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); | |
50 | $contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE); | |
be2fb01f | 51 | $this->_participantIds = [$participantID]; |
6a488035 TO |
52 | $this->_componentClause = " civicrm_participant.id = $participantID "; |
53 | $this->assign('totalSelectedParticipants', 1); | |
54 | ||
55 | // also set the user context to send back to view page | |
56 | $session = CRM_Core_Session::singleton(); | |
57 | $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view/participant', | |
353ffa53 TO |
58 | "reset=1&action=view&id={$participantID}&cid={$contactID}" |
59 | )); | |
6a488035 TO |
60 | } |
61 | else { | |
62 | parent::preProcess(); | |
63 | } | |
64 | } | |
65 | ||
66 | /** | |
eceb18cc | 67 | * Build the form object. |
6a488035 | 68 | */ |
00be9182 | 69 | public function buildQuickForm() { |
6a488035 TO |
70 | CRM_Utils_System::setTitle(ts('Make Name Badges')); |
71 | ||
22029f77 CW |
72 | // Ajax submit would interfere with file download |
73 | $this->preventAjaxSubmit(); | |
74 | ||
6a488035 | 75 | //add select for label |
8c7f8a8b | 76 | $label = CRM_Badge_BAO_Layout::getList(); |
6a488035 TO |
77 | |
78 | $this->add('select', | |
79 | 'badge_id', | |
80 | ts('Name Badge Format'), | |
be2fb01f | 81 | [ |
e7483cbe | 82 | '' => ts('- select -'), |
be2fb01f | 83 | ] + $label, TRUE |
6a488035 TO |
84 | ); |
85 | ||
86 | $next = 'next'; | |
87 | $back = $this->_single ? 'cancel' : 'back'; | |
88 | $this->addDefaultButtons(ts('Make Name Badges'), $next, $back); | |
89 | } | |
90 | ||
91 | /** | |
eceb18cc | 92 | * Process the form after the input has been submitted and validated. |
6a488035 TO |
93 | */ |
94 | public function postProcess() { | |
95 | $params = $this->controller->exportValues($this->_name); | |
6d4a64c8 | 96 | CRM_Badge_BAO_Badge::buildBadges($params, $this); |
6a488035 | 97 | } |
96025800 | 98 | |
6a488035 | 99 | } |