3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
32 * @copyright CiviCRM LLC (c) 2004-2014
38 * This class generates form components for processing Event
41 class CRM_Event_Form_Registration_ParticipantConfirm
extends CRM_Event_Form_Registration
{
42 // optional credit card return status code
44 protected $_cc = NULL;
47 * Set variables up before form is built
51 public function preProcess() {
52 $this->_participantId
= CRM_Utils_Request
::retrieve('participantId', 'Positive', $this);
54 $this->_cc
= CRM_Utils_Request
::retrieve('cc', 'String', $this);
56 //get the contact and event id and assing to session.
59 if ($this->_participantId
) {
60 $params = array('id' => $this->_participantId
);
61 CRM_Core_DAO
::commonRetrieve('CRM_Event_DAO_Participant', $params, $values,
62 array('contact_id', 'event_id', 'status_id')
66 $this->_participantStatusId
= CRM_Utils_Array
::value('status_id', $values);
67 $this->_eventId
= CRM_Utils_Array
::value('event_id', $values);
68 $csContactId = CRM_Utils_Array
::value('contact_id', $values);
70 // make sure we have right permission to edit this user
71 $this->_csContactID
= NULL;
72 if ($csContactId && $this->_eventId
) {
73 $session = CRM_Core_Session
::singleton();
74 if ($csContactId == $session->get('userID')) {
75 $this->_csContactID
= $csContactId;
78 if (CRM_Contact_BAO_Contact_Permission
::validateChecksumContact($csContactId, $this)) {
79 //since we have landing page so get this contact
80 //id in session if user really want to walk wizard.
81 $this->_csContactID
= $csContactId;
86 if (!$this->_csContactID
) {
87 $config = CRM_Core_Config
::singleton();
88 CRM_Core_Error
::statusBounce(ts('You do not have permission to access this event registration. Contact the site administrator if you need assistance.'), $config->userFrameworkBaseURL
);
93 * Build the form object
97 public function buildQuickForm() {
98 $params = array('id' => $this->_eventId
);
100 CRM_Core_DAO
::commonRetrieve('CRM_Event_DAO_Event', $params, $values,
105 // only pending status class family able to confirm.
108 if (array_key_exists($this->_participantStatusId
,
109 CRM_Event_PseudoConstant
::participantStatus(NULL, "class = 'Pending'")
112 //need to confirm that though participant confirming
113 //registration - but is there enough space to confirm.
114 $emptySeats = CRM_Event_BAO_Participant
::pendingToConfirmSpaces($this->_eventId
);
115 $additonalIds = CRM_Event_BAO_Participant
::getAdditionalParticipantIds($this->_participantId
);
116 $requireSpace = 1 +
count($additonalIds);
117 if ($emptySeats !== NULL && ($requireSpace > $emptySeats)) {
118 $statusMsg = ts("Oops, it looks like there are currently no available spaces for the %1 event.", array(1 => $values['title']));
121 if ($this->_cc
== 'fail') {
122 $statusMsg = '<div class="bold">' . ts('Your Credit Card transaction was not successful. No money has yet been charged to your card.') . '</div><div><br />' . ts('Click the "Confirm Registration" button to complete your registration in %1, or click "Cancel Registration" if you are no longer interested in attending this event.', array(
123 1 => $values['title'],
127 $statusMsg = '<div class="bold">' . ts('Confirm your registration for %1.', array(
128 1 => $values['title'],
129 )) . '</div><div><br />' . ts('Click the "Confirm Registration" button to begin, or click "Cancel Registration" if you are no longer interested in attending this event.') . '</div>';
131 $buttons = array_merge($buttons, array(
134 'name' => ts('Confirm Registration'),
135 'spacing' => ' ',
142 // status class other than Negative should be able to cancel registration.
143 if (array_key_exists($this->_participantStatusId
,
144 CRM_Event_PseudoConstant
::participantStatus(NULL, "class != 'Negative'")
146 $cancelConfirm = ts('Are you sure you want to cancel your registration for this event?');
147 $buttons = array_merge($buttons, array(
150 'name' => ts('Cancel Registration'),
151 'spacing' => ' ',
152 'js' => array('onclick' => 'return confirm(\'' . $cancelConfirm . '\');'),
156 $statusMsg = ts('You can cancel your registration for %1 by clicking "Cancel Registration".', array(1 => $values['title']));
160 $statusMsg = ts("Oops, it looks like your registration for %1 has already been cancelled.",
161 array(1 => $values['title'])
164 $this->assign('statusMsg', $statusMsg);
166 $this->addButtons($buttons);
170 * Process the form submission
175 public function postProcess() {
177 $buttonName = $this->controller
->getButtonName();
178 $participantId = $this->_participantId
;
180 if ($buttonName == '_qf_ParticipantConfirm_next') {
181 //lets get contact id in session.
182 $session = CRM_Core_Session
::singleton();
183 $session->set('userID', $this->_csContactID
);
185 $this->postProcessHook();
187 //check user registration status is from pending class
188 $url = CRM_Utils_System
::url('civicrm/event/register',
189 "reset=1&id={$this->_eventId}&participantId={$participantId}"
191 CRM_Utils_System
::redirect($url);
193 elseif ($buttonName == '_qf_ParticipantConfirm_submit') {
194 //need to registration status to 'cancelled'.
196 $cancelledId = array_search('Cancelled', CRM_Event_PseudoConstant
::participantStatus(NULL, "class = 'Negative'"));
197 $additionalParticipantIds = CRM_Event_BAO_Participant
::getAdditionalParticipantIds($participantId);
199 $participantIds = array_merge(array($participantId), $additionalParticipantIds);
200 $results = CRM_Event_BAO_Participant
::transitionParticipants($participantIds, $cancelledId, NULL, TRUE);
202 if (count($participantIds) > 1) {
203 $statusMessage = ts("%1 Event registration(s) have been cancelled.", array(1 => count($participantIds)));
206 $statusMessage = ts("Your Event Registration has been cancelled.");
209 if (!empty($results['mailedParticipants'])) {
210 foreach ($results['mailedParticipants'] as $key => $displayName) {
211 $statusMessage .= "<br />" . ts("Email has been sent to : %1", array(1 => $displayName));
215 $this->postProcessHook();
217 CRM_Core_Error
::statusBounce($statusMessage,
218 CRM_Utils_System
::url('civicrm/event/info',
219 "reset=1&id={$this->_eventId}&noFullMsg=1",
220 FALSE, NULL, FALSE, TRUE