Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06b69b18 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
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 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | /** | |
29 | * | |
30 | * @package CRM | |
06b69b18 | 31 | * @copyright CiviCRM LLC (c) 2004-2014 |
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 | /** |
100fef9d | 51 | * Component clause |
6d4a64c8 KJ |
52 | */ |
53 | public $_componentClause; | |
54 | ||
6a488035 | 55 | /** |
100fef9d | 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 | /** | |
c490a46a | 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 | ||
93 | //add select for label | |
8c7f8a8b | 94 | $label = CRM_Badge_BAO_Layout::getList(); |
6a488035 TO |
95 | |
96 | $this->add('select', | |
97 | 'badge_id', | |
98 | ts('Name Badge Format'), | |
99 | array( | |
e7483cbe | 100 | '' => ts('- select -'), |
353ffa53 | 101 | ) + $label, TRUE |
6a488035 TO |
102 | ); |
103 | ||
104 | $next = 'next'; | |
105 | $back = $this->_single ? 'cancel' : 'back'; | |
106 | $this->addDefaultButtons(ts('Make Name Badges'), $next, $back); | |
107 | } | |
108 | ||
109 | /** | |
100fef9d | 110 | * Process the form after the input has been submitted and validated |
6a488035 | 111 | * |
6a488035 TO |
112 | * |
113 | * @return void | |
114 | */ | |
115 | public function postProcess() { | |
116 | $params = $this->controller->exportValues($this->_name); | |
6d4a64c8 | 117 | CRM_Badge_BAO_Badge::buildBadges($params, $this); |
6a488035 TO |
118 | } |
119 | } |