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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * | |
31 | * @package CRM | |
06b69b18 | 32 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
33 | * $Id$ |
34 | * | |
35 | */ | |
36 | ||
37 | /** | |
38 | * This class generates form components for processing Event | |
39 | * | |
40 | */ | |
41 | class CRM_Event_Form_Registration_ThankYou extends CRM_Event_Form_Registration { | |
42 | ||
43 | /** | |
66f9e52b | 44 | * Set variables up before form is built. |
6a488035 TO |
45 | * |
46 | * @return void | |
6a488035 | 47 | */ |
00be9182 | 48 | public function preProcess() { |
6a488035 | 49 | parent::preProcess(); |
353ffa53 TO |
50 | $this->_params = $this->get('params'); |
51 | $this->_lineItem = $this->get('lineItem'); | |
52 | $this->_part = $this->get('part'); | |
6a488035 TO |
53 | $this->_totalAmount = $this->get('totalAmount'); |
54 | $this->_receiveDate = $this->get('receiveDate'); | |
353ffa53 TO |
55 | $this->_trxnId = $this->get('trxnId'); |
56 | $finalAmount = $this->get('finalAmount'); | |
6a488035 TO |
57 | $this->assign('finalAmount', $finalAmount); |
58 | $participantInfo = $this->get('participantInfo'); | |
59 | $this->assign('part', $this->_part); | |
60 | $this->assign('participantInfo', $participantInfo); | |
61 | $customGroup = $this->get('customProfile'); | |
62 | $this->assign('customProfile', $customGroup); | |
63 | ||
5bdcb00b | 64 | CRM_Event_Form_Registration_Confirm::assignProfiles($this); |
6a488035 TO |
65 | |
66 | CRM_Utils_System::setTitle(CRM_Utils_Array::value('thankyou_title', $this->_values['event'])); | |
67 | } | |
68 | ||
69 | /** | |
100fef9d | 70 | * Overwrite action, since we are only showing elements in frozen mode |
6a488035 TO |
71 | * no help display needed |
72 | * | |
73 | * @return int | |
6a488035 | 74 | */ |
00be9182 | 75 | public function getAction() { |
6a488035 TO |
76 | if ($this->_action & CRM_Core_Action::PREVIEW) { |
77 | return CRM_Core_Action::VIEW | CRM_Core_Action::PREVIEW; | |
78 | } | |
79 | else { | |
80 | return CRM_Core_Action::VIEW; | |
81 | } | |
82 | } | |
83 | ||
84 | /** | |
66f9e52b | 85 | * Build the form object. |
6a488035 | 86 | * |
355ba699 | 87 | * @return void |
6a488035 TO |
88 | */ |
89 | public function buildQuickForm() { | |
90 | // Assign the email address from a contact id lookup as in CRM_Event_BAO_Event->sendMail() | |
91 | $primaryContactId = $this->get('primaryContactId'); | |
92 | if ($primaryContactId) { | |
93 | list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($primaryContactId); | |
94 | $this->assign('email', $email); | |
95 | } | |
96 | $this->assignToTemplate(); | |
03e04002 | 97 | |
353ffa53 | 98 | $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings'); |
d9e4ebe7 PB |
99 | $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings); |
100 | $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); | |
101 | $getTaxDetails = FALSE; | |
a32709be | 102 | $taxAmount = 0; |
9da8dc8c | 103 | if ($this->_priceSetId && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) { |
6a488035 TO |
104 | $lineItemForTemplate = array(); |
105 | foreach ($this->_lineItem as $key => $value) { | |
106 | if (!empty($value)) { | |
107 | $lineItemForTemplate[$key] = $value; | |
03b412ae PB |
108 | if ($invoicing) { |
109 | foreach ($value as $v) { | |
110 | if (isset($v['tax_amount']) || isset($v['tax_rate'])) { | |
111 | $taxAmount += $v['tax_amount']; | |
d9e4ebe7 | 112 | $getTaxDetails = TRUE; |
03b412ae | 113 | } |
a32709be PB |
114 | } |
115 | } | |
6a488035 TO |
116 | } |
117 | } | |
118 | if (!empty($lineItemForTemplate)) { | |
119 | $this->assign('lineItem', $lineItemForTemplate); | |
120 | } | |
121 | } | |
a32709be | 122 | else { |
03b412ae PB |
123 | if ($invoicing) { |
124 | foreach ($this->_lineItem as $lineItemKey => $lineItemValue) { | |
125 | foreach ($lineItemValue as $v) { | |
126 | if (isset($v['tax_amount']) || isset($v['tax_rate'])) { | |
127 | $taxAmount += $v['tax_amount']; | |
d9e4ebe7 | 128 | $getTaxDetails = TRUE; |
03b412ae | 129 | } |
a32709be PB |
130 | } |
131 | } | |
132 | } | |
133 | } | |
6a488035 | 134 | |
03b412ae PB |
135 | if ($invoicing) { |
136 | $this->assign('getTaxDetails', $getTaxDetails); | |
137 | $this->assign('totalTaxAmount', $taxAmount); | |
d9e4ebe7 | 138 | $this->assign('taxTerm', $taxTerm); |
03b412ae | 139 | } |
6a488035 | 140 | $this->assign('totalAmount', $this->_totalAmount); |
d75f2f47 | 141 | |
6a488035 TO |
142 | $hookDiscount = $this->get('hookDiscount'); |
143 | if ($hookDiscount) { | |
144 | $this->assign('hookDiscount', $hookDiscount); | |
145 | } | |
146 | ||
147 | $this->assign('receive_date', $this->_receiveDate); | |
148 | $this->assign('trxn_id', $this->_trxnId); | |
149 | ||
150 | //cosider total amount. | |
151 | $this->assign('isAmountzero', ($this->_totalAmount <= 0) ? TRUE : FALSE); | |
152 | ||
153 | $this->assign('defaultRole', FALSE); | |
154 | if (CRM_Utils_Array::value('defaultRole', $this->_params[0]) == 1) { | |
155 | $this->assign('defaultRole', TRUE); | |
156 | } | |
157 | $defaults = array(); | |
158 | $fields = array(); | |
159 | if (!empty($this->_fields)) { | |
160 | foreach ($this->_fields as $name => $dontCare) { | |
161 | $fields[$name] = 1; | |
162 | } | |
163 | } | |
164 | $fields['state_province'] = $fields['country'] = $fields['email'] = 1; | |
165 | foreach ($fields as $name => $dontCare) { | |
166 | if (isset($this->_params[0][$name])) { | |
167 | $defaults[$name] = $this->_params[0][$name]; | |
168 | if (substr($name, 0, 7) == 'custom_') { | |
169 | $timeField = "{$name}_time"; | |
170 | if (isset($this->_params[0][$timeField])) { | |
171 | $defaults[$timeField] = $this->_params[0][$timeField]; | |
172 | } | |
173 | } | |
174 | elseif (in_array($name, CRM_Contact_BAO_Contact::$_greetingTypes) | |
175 | && !empty($this->_params[0][$name . '_custom']) | |
176 | ) { | |
177 | $defaults[$name . '_custom'] = $this->_params[0][$name . '_custom']; | |
178 | } | |
179 | } | |
180 | } | |
181 | ||
182 | $this->_submitValues = array_merge($this->_submitValues, $defaults); | |
183 | ||
184 | $this->setDefaults($defaults); | |
185 | ||
6a488035 TO |
186 | $params['entity_id'] = $this->_eventId; |
187 | $params['entity_table'] = 'civicrm_event'; | |
188 | $data = array(); | |
189 | CRM_Friend_BAO_Friend::retrieve($params, $data); | |
a7488080 | 190 | if (!empty($data['is_active'])) { |
6a488035 TO |
191 | $friendText = $data['title']; |
192 | $this->assign('friendText', $friendText); | |
193 | if ($this->_action & CRM_Core_Action::PREVIEW) { | |
194 | $url = CRM_Utils_System::url('civicrm/friend', | |
195 | "eid={$this->_eventId}&reset=1&action=preview&pcomponent=event" | |
196 | ); | |
197 | } | |
198 | else { | |
199 | $url = CRM_Utils_System::url('civicrm/friend', | |
200 | "eid={$this->_eventId}&reset=1&pcomponent=event" | |
201 | ); | |
202 | } | |
203 | $this->assign('friendURL', $url); | |
204 | } | |
205 | ||
206 | $this->freeze(); | |
207 | ||
208 | //lets give meaningful status message, CRM-4320. | |
209 | $isOnWaitlist = $isRequireApproval = FALSE; | |
210 | if ($this->_allowWaitlist && !$this->_allowConfirmation) { | |
211 | $isOnWaitlist = TRUE; | |
212 | } | |
213 | if ($this->_requireApproval && !$this->_allowConfirmation) { | |
214 | $isRequireApproval = TRUE; | |
215 | } | |
216 | $this->assign('isOnWaitlist', $isOnWaitlist); | |
217 | $this->assign('isRequireApproval', $isRequireApproval); | |
218 | ||
219 | // find pcp info | |
353ffa53 | 220 | $dao = new CRM_PCP_DAO_PCPBlock(); |
6a488035 | 221 | $dao->entity_table = 'civicrm_event'; |
353ffa53 TO |
222 | $dao->entity_id = $this->_eventId; |
223 | $dao->is_active = 1; | |
6a488035 TO |
224 | $dao->find(TRUE); |
225 | ||
226 | if ($dao->id) { | |
af72b8c7 | 227 | $this->assign('pcpLink', CRM_Utils_System::url('civicrm/contribute/campaign', 'action=add&reset=1&pageId=' . $this->_eventId . '&component=event')); |
6a488035 TO |
228 | $this->assign('pcpLinkText', $dao->link_text); |
229 | } | |
230 | ||
231 | // Assign Participant Count to Lineitem Table | |
9da8dc8c | 232 | $this->assign('pricesetFieldsCount', CRM_Price_BAO_PriceSet::getPricesetCount($this->_priceSetId)); |
6a488035 TO |
233 | |
234 | // can we blow away the session now to prevent hackery | |
235 | $this->controller->reset(); | |
236 | } | |
237 | ||
238 | /** | |
66f9e52b | 239 | * Process the form submission. |
6a488035 | 240 | * |
6a488035 | 241 | * |
355ba699 | 242 | * @return void |
6a488035 | 243 | */ |
6ea503d4 TO |
244 | public function postProcess() { |
245 | } | |
6a488035 TO |
246 | |
247 | /** | |
248 | * Return a descriptive name for the page, used in wizard header | |
249 | * | |
250 | * @return string | |
6a488035 TO |
251 | */ |
252 | public function getTitle() { | |
253 | return ts('Thank You Page'); | |
254 | } | |
96025800 | 255 | |
6a488035 | 256 | } |