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