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