3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2015
37 * form for thank-you / success page - 3rd step of online contribution process
39 class CRM_Contribute_Form_Contribution_ThankYou
extends CRM_Contribute_Form_ContributionBase
{
42 * Membership price set status.
44 public $_useForMember;
47 * Set variables up before form is built.
51 public function preProcess() {
54 $this->_params
= $this->get('params');
55 $this->_lineItem
= $this->get('lineItem');
56 $is_deductible = $this->get('is_deductible');
57 $this->assign('is_deductible', $is_deductible);
58 $this->assign('thankyou_title', CRM_Utils_Array
::value('thankyou_title', $this->_values
));
59 $this->assign('thankyou_text', CRM_Utils_Array
::value('thankyou_text', $this->_values
));
60 $this->assign('thankyou_footer', CRM_Utils_Array
::value('thankyou_footer', $this->_values
));
61 $this->assign('max_reminders', CRM_Utils_Array
::value('max_reminders', $this->_values
));
62 $this->assign('initial_reminder_day', CRM_Utils_Array
::value('initial_reminder_day', $this->_values
));
63 CRM_Utils_System
::setTitle(CRM_Utils_Array
::value('thankyou_title', $this->_values
));
64 // Make the contributionPageID available to the template
65 $this->assign('contributionPageID', $this->_id
);
66 $this->assign('isShare', $this->_values
['is_share']);
68 $this->_params
['is_pay_later'] = $this->get('is_pay_later');
69 $this->assign('is_pay_later', $this->_params
['is_pay_later']);
70 if ($this->_params
['is_pay_later']) {
71 $this->assign('pay_later_receipt', $this->_values
['pay_later_receipt']);
76 * Overwrite action, since we are only showing elements in frozen mode
77 * no help display needed
81 public function getAction() {
82 if ($this->_action
& CRM_Core_Action
::PREVIEW
) {
83 return CRM_Core_Action
::VIEW | CRM_Core_Action
::PREVIEW
;
86 return CRM_Core_Action
::VIEW
;
91 * Build the form object.
95 public function buildQuickForm() {
96 $this->assignToTemplate();
97 $productID = $this->get('productID');
98 $option = $this->get('option');
99 $membershipTypeID = $this->get('membershipTypeID');
100 $this->assign('receiptFromEmail', CRM_Utils_Array
::value('receipt_from_email', $this->_values
));
103 CRM_Contribute_BAO_Premium
::buildPremiumBlock($this, $this->_id
, FALSE, $productID, $option);
105 if ($this->_priceSetId
&& !CRM_Core_DAO
::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId
, 'is_quick_config')) {
106 $this->assign('lineItem', $this->_lineItem
);
109 if (is_array($membershipTypeID)) {
110 $membershipTypeID = current($membershipTypeID);
112 $this->assign('is_quick_config', 1);
113 $this->_params
['is_quick_config'] = 1;
115 $this->assign('priceSetID', $this->_priceSetId
);
116 $this->assign('useForMember', $this->get('useForMember'));
118 $params = $this->_params
;
119 $invoiceSettings = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::CONTRIBUTE_PREFERENCES_NAME
, 'contribution_invoice_settings');
120 $invoicing = CRM_Utils_Array
::value('invoicing', $invoiceSettings);
122 $getTaxDetails = FALSE;
123 $taxTerm = CRM_Utils_Array
::value('tax_term', $invoiceSettings);
124 foreach ($this->_lineItem
as $key => $value) {
125 foreach ($value as $v) {
126 if (isset($v['tax_rate'])) {
127 if ($v['tax_rate'] != '') {
128 $getTaxDetails = TRUE;
133 $this->assign('getTaxDetails', $getTaxDetails);
134 $this->assign('taxTerm', $taxTerm);
135 $this->assign('totalTaxAmount', $params['tax_amount']);
137 if ($this->_honor_block_is_active
&& !empty($params['soft_credit_type_id'])) {
139 $softCreditTypes = CRM_Core_OptionGroup
::values("soft_credit_type", FALSE);
141 $this->assign('honor_block_is_active', $this->_honor_block_is_active
);
142 $this->assign('soft_credit_type', $softCreditTypes[$params['soft_credit_type_id']]);
143 CRM_Contribute_BAO_ContributionSoft
::formatHonoreeProfileFields($this, $params['honor'], $params['honoree_profile_id']);
145 $fieldTypes = array('Contact');
146 $fieldTypes[] = CRM_Core_BAO_UFGroup
::getContactType($params['honoree_profile_id']);
147 $this->buildCustom($params['honoree_profile_id'], 'honoreeProfileFields', TRUE, 'honor', $fieldTypes);
150 $qParams = "reset=1&id={$this->_id}";
153 $qParams .= "&pcpId={$this->_pcpId}";
154 $this->assign('pcpBlock', TRUE);
156 'pcp_display_in_roll',
161 if (!empty($this->_params
[$val])) {
162 $this->assign($val, $this->_params
[$val]);
167 $this->assign('qParams', $qParams);
169 if ($membershipTypeID) {
170 $transactionID = $this->get('membership_trx_id');
171 $membershipAmount = $this->get('membership_amount');
172 $renewalMode = $this->get('renewal_mode');
173 $this->assign('membership_trx_id', $transactionID);
174 $this->assign('membership_amount', $membershipAmount);
175 $this->assign('renewal_mode', $renewalMode);
177 CRM_Member_BAO_Membership
::buildMembershipBlock($this,
179 $this->_membershipContactID
,
186 if (!empty($params['auto_renew'])) {
187 $this->assign('auto_renew', TRUE);
191 $this->_separateMembershipPayment
= $this->get('separateMembershipPayment');
192 $this->assign("is_separate_payment", $this->_separateMembershipPayment
);
194 $this->buildCustom($this->_values
['custom_pre_id'], 'customPre', TRUE);
195 $this->buildCustom($this->_values
['custom_post_id'], 'customPost', TRUE);
196 if (!empty($params['hidden_onbehalf_profile'])) {
197 $ufJoinParams = array(
198 'module' => 'onBehalf',
199 'entity_table' => 'civicrm_contribution_page',
200 'entity_id' => $this->_id
,
202 $OnBehalfProfile = CRM_Core_BAO_UFJoin
::getUFGroupIds($ufJoinParams);
203 $profileId = $OnBehalfProfile[0];
205 $fieldTypes = array('Contact', 'Organization');
206 $contactSubType = CRM_Contact_BAO_ContactType
::subTypes('Organization');
207 $fieldTypes = array_merge($fieldTypes, $contactSubType);
208 if (is_array($this->_membershipBlock
) && !empty($this->_membershipBlock
)) {
209 $fieldTypes = array_merge($fieldTypes, array('Membership'));
212 $fieldTypes = array_merge($fieldTypes, array('Contribution'));
215 $this->buildCustom($profileId, 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes);
218 $this->assign('trxn_id',
219 CRM_Utils_Array
::value('trxn_id',
223 $this->assign('receive_date',
224 CRM_Utils_Date
::mysqlToIso(CRM_Utils_Array
::value('receive_date', $this->_params
))
229 foreach ($this->_fields
as $name => $dontCare) {
230 if ($name != 'onbehalf' ||
$name != 'honor') {
234 $fields['state_province'] = $fields['country'] = $fields['email'] = 1;
235 $contact = $this->_params
= $this->controller
->exportValues('Main');
237 foreach ($fields as $name => $dontCare) {
238 if (isset($contact[$name])) {
239 $defaults[$name] = $contact[$name];
240 if (substr($name, 0, 7) == 'custom_') {
241 $timeField = "{$name}_time";
242 if (isset($contact[$timeField])) {
243 $defaults[$timeField] = $contact[$timeField];
246 elseif (in_array($name, array(
250 )) && !empty($contact[$name . '_custom'])
252 $defaults[$name . '_custom'] = $contact[$name . '_custom'];
257 $this->_submitValues
= array_merge($this->_submitValues
, $defaults);
258 $this->setDefaults($defaults);
260 $values['entity_id'] = $this->_id
;
261 $values['entity_table'] = 'civicrm_contribution_page';
263 CRM_Friend_BAO_Friend
::retrieve($values, $data);
264 $tellAFriend = FALSE;
266 if ($this->_pcpBlock
['is_tellfriend_enabled']) {
267 $this->assign('friendText', ts('Tell a Friend'));
268 $subUrl = "eid={$this->_pcpId}&blockId={$this->_pcpBlock['id']}&pcomponent=pcp";
272 elseif (!empty($data['is_active'])) {
273 $friendText = $data['title'];
274 $this->assign('friendText', $friendText);
275 $subUrl = "eid={$this->_id}&pcomponent=contribute";
280 if ($this->_action
& CRM_Core_Action
::PREVIEW
) {
281 $url = CRM_Utils_System
::url("civicrm/friend",
282 "reset=1&action=preview&{$subUrl}"
286 $url = CRM_Utils_System
::url("civicrm/friend",
290 $this->assign('friendURL', $url);
295 // can we blow away the session now to prevent hackery
297 $this->controller
->reset();