Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
7e9e8871 | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
0f03f337 | 6 | | Copyright CiviCRM LLC (c) 2004-2017 | |
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 | |
0f03f337 | 31 | * @copyright CiviCRM LLC (c) 2004-2017 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * This class helps to print the labels for contacts | |
38 | * | |
39 | */ | |
40 | class CRM_Event_Form_Task_Badge extends CRM_Event_Form_Task { | |
41 | ||
42 | /** | |
43 | * Are we operating in "single mode", i.e. sending email to one | |
44 | * specific contact? | |
45 | * | |
46 | * @var boolean | |
47 | */ | |
48 | public $_single = FALSE; | |
49 | ||
6d4a64c8 | 50 | /** |
eceb18cc | 51 | * Component clause. |
6d4a64c8 KJ |
52 | */ |
53 | public $_componentClause; | |
54 | ||
6a488035 | 55 | /** |
eceb18cc | 56 | * Build all the data structures needed to build the form. |
6a488035 TO |
57 | * |
58 | * @param | |
59 | * | |
60 | * @return void | |
6d4a64c8 | 61 | */ |
00be9182 | 62 | public function preProcess() { |
6a488035 TO |
63 | $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); |
64 | if ($this->_context == 'view') { | |
65 | $this->_single = TRUE; | |
66 | ||
67 | $participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); | |
68 | $contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE); | |
69 | $this->_participantIds = array($participantID); | |
70 | $this->_componentClause = " civicrm_participant.id = $participantID "; | |
71 | $this->assign('totalSelectedParticipants', 1); | |
72 | ||
73 | // also set the user context to send back to view page | |
74 | $session = CRM_Core_Session::singleton(); | |
75 | $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view/participant', | |
353ffa53 TO |
76 | "reset=1&action=view&id={$participantID}&cid={$contactID}" |
77 | )); | |
6a488035 TO |
78 | } |
79 | else { | |
80 | parent::preProcess(); | |
81 | } | |
82 | } | |
83 | ||
84 | /** | |
eceb18cc | 85 | * Build the form object. |
6a488035 | 86 | * |
6a488035 TO |
87 | * |
88 | * @return void | |
89 | */ | |
00be9182 | 90 | public function buildQuickForm() { |
6a488035 TO |
91 | CRM_Utils_System::setTitle(ts('Make Name Badges')); |
92 | ||
22029f77 CW |
93 | // Ajax submit would interfere with file download |
94 | $this->preventAjaxSubmit(); | |
95 | ||
6a488035 | 96 | //add select for label |
8c7f8a8b | 97 | $label = CRM_Badge_BAO_Layout::getList(); |
6a488035 TO |
98 | |
99 | $this->add('select', | |
100 | 'badge_id', | |
101 | ts('Name Badge Format'), | |
102 | array( | |
e7483cbe | 103 | '' => ts('- select -'), |
353ffa53 | 104 | ) + $label, TRUE |
6a488035 TO |
105 | ); |
106 | ||
107 | $next = 'next'; | |
108 | $back = $this->_single ? 'cancel' : 'back'; | |
109 | $this->addDefaultButtons(ts('Make Name Badges'), $next, $back); | |
110 | } | |
111 | ||
112 | /** | |
eceb18cc | 113 | * Process the form after the input has been submitted and validated. |
6a488035 | 114 | * |
6a488035 TO |
115 | * |
116 | * @return void | |
117 | */ | |
118 | public function postProcess() { | |
119 | $params = $this->controller->exportValues($this->_name); | |
6d4a64c8 | 120 | CRM_Badge_BAO_Badge::buildBadges($params, $this); |
6a488035 | 121 | } |
96025800 | 122 | |
6a488035 | 123 | } |