/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { if ($this->_ppType) { return CRM_Core_Payment_ProcessorForm::buildQuickForm($this); } $config = CRM_Core_Config::singleton(); if (CRM_Utils_Array::value('is_for_organization', $this->_values) == 2) { $this->assign('onBehalfRequired', TRUE); $this->_onBehalfRequired = 1; } if ($this->_onbehalf) { $this->assign('onbehalf', TRUE); return CRM_Contribute_Form_Contribution_OnBehalfOf::buildQuickForm($this); } $this->applyFilter('__ALL__', 'trim'); $this->add('text', "email-{$this->_bltID}", ts('Email Address'), array('size' => 30, 'maxlength' => 60), TRUE); $this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email'); $this->_paymentProcessors = $this->get('paymentProcessors'); $pps = array(); if (!empty($this->_paymentProcessors)) { $pps = $this->_paymentProcessors; foreach ($pps as $key => &$name) { $pps[$key] = $name['name']; } } if (CRM_Utils_Array::value('is_pay_later', $this->_values)) { $pps[0] = $this->_values['pay_later_text']; } if (count($pps) > 1) { $this->addRadio('payment_processor', ts('Payment Method'), $pps, NULL, " ", TRUE); } elseif (!empty($pps)) { $key = array_pop(array_keys($pps)); $this->addElement('hidden', 'payment_processor', $key); if ($key === 0) { $this->assign('is_pay_later', $this->_values['is_pay_later']); $this->assign('pay_later_text', $this->_values['pay_later_text']); } } //build pledge block. $this->_useForMember = 0; //don't build membership block when pledge_id is passed if (!CRM_Utils_Array::value('pledge_id', $this->_values)) { $this->_separateMembershipPayment = FALSE; if (in_array('CiviMember', $config->enableComponents)) { $isTest = 0; if ($this->_action & CRM_Core_Action::PREVIEW) { $isTest = 1; } if ($this->_priceSetId && CRM_Core_Component::getComponentID('CiviMember') == CRM_Utils_Array::value('extends', $this->_priceSet)) { $this->_useForMember = 1; $this->set('useForMember', $this->_useForMember); } $this->_separateMembershipPayment = CRM_Member_BAO_Membership::buildMembershipBlock($this, $this->_id, TRUE, NULL, FALSE, $isTest, $this->_membershipContactID); } $this->set('separateMembershipPayment', $this->_separateMembershipPayment); } $this->assign('useForMember', $this->_useForMember); // If we configured price set for contribution page // we are not allow membership signup as well as any // other contribution amount field, CRM-5095 if (isset($this->_priceSetId) && $this->_priceSetId) { $this->add('hidden', 'priceSetId', $this->_priceSetId); // build price set form. $this->set('priceSetId', $this->_priceSetId); CRM_Price_BAO_Set::buildPriceSet($this); if ($this->_values['is_monetary'] && $this->_values['is_recur'] && !CRM_Utils_Array::value('pledge_id', $this->_values)) { self::buildRecur($this); } } elseif (CRM_Utils_Array::value('amount_block_is_active', $this->_values) && !CRM_Utils_Array::value('pledge_id', $this->_values)) { $this->buildAmount($this->_separateMembershipPayment); } if ($this->_priceSetId) { $is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $this->_priceSetId, 'is_quick_config'); if ($is_quick_config) { $this->_useForMember = 0; $this->set('useForMember', $this->_useForMember); } } if ($this->_values['is_for_organization']) { $this->buildOnBehalfOrganization(); } //we allow premium for pledge during pledge creation only. if (!CRM_Utils_Array::value('pledge_id', $this->_values)) { CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, TRUE); } if ($this->_values['honor_block_is_active']) { $this->buildHonorBlock(); } //don't build pledge block when mid is passed if (!$this->_mid) { $config = CRM_Core_Config::singleton(); if (in_array('CiviPledge', $config->enableComponents) && CRM_Utils_Array::value('pledge_block_id', $this->_values)) { CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this); } } $this->buildCustom($this->_values['custom_pre_id'], 'customPre'); $this->buildCustom($this->_values['custom_post_id'], 'customPost'); if (!empty($this->_fields)) { $profileAddressFields = array(); foreach ($this->_fields as $key => $value) { CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields); } $this->set('profileAddressFields', $profileAddressFields); } //to create an cms user if (!$this->_userID) { $createCMSUser = FALSE; if ($this->_values['custom_pre_id']) { $profileID = $this->_values['custom_pre_id']; $createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user'); } if (!$createCMSUser && $this->_values['custom_post_id']) { if (!is_array($this->_values['custom_post_id'])) { $profileIDs = array($this->_values['custom_post_id']); } else { $profileIDs = $this->_values['custom_post_id']; } foreach ($profileIDs as $pid) { if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $pid, 'is_cms_user')) { $profileID = $pid; $createCMSUser = TRUE; break; } } } if ($createCMSUser) { CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE); } } if ($this->_pcpId) { if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($this->_pcpId)) { $this->assign('pcpSupporterText', ts('This contribution is being made thanks to effort of <strong>%1</strong>, who supports our campaign. You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!', array(1 => $pcpSupporter))); } $this->assign('pcp', TRUE); $this->add('checkbox', 'pcp_display_in_roll', ts('Show my contribution in the public honor roll'), NULL, NULL, array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );")); $extraOption = array('onclick' => "return pcpAnonymous( );"); $elements = array(); $elements[] =& $this->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption); $elements[] =& $this->createElement('radio', NULL, '', ts('List my contribution anonymously'), 1, $extraOption); $this->addGroup($elements, 'pcp_is_anonymous', NULL, ' '); $this->_defaults['pcp_is_anonymous'] = 0; $this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30)); $this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;')); } //we have to load confirm contribution button in template //when multiple payment processor as the user //can toggle with payment processor selection $billingModePaymentProcessors = 0; if (!empty($this->_paymentProcessors)) { foreach ($this->_paymentProcessors as $key => $values) { if ($values['billing_mode'] == CRM_Core_Payment::BILLING_MODE_BUTTON) { $billingModePaymentProcessors++; } } } if ($billingModePaymentProcessors && count($this->_paymentProcessors) == $billingModePaymentProcessors) { $allAreBillingModeProcessors = TRUE; } else { $allAreBillingModeProcessors = FALSE; } if (!($allAreBillingModeProcessors && !$this->_values['is_pay_later'])) { $this->addButtons(array(array('type' => 'upload', 'name' => ts('Confirm Contribution'), 'spacing' => ' ', 'isDefault' => TRUE))); } $this->addFormRule(array('CRM_Contribute_Form_Contribution_Main', 'formRule'), $this); }
/** * Build the form object. */ public function buildQuickForm() { // build profiles first so that we can determine address fields etc // and then show copy address checkbox if (empty($this->_ccid)) { $this->buildCustom($this->_values['custom_pre_id'], 'customPre'); $this->buildCustom($this->_values['custom_post_id'], 'customPost'); // CRM-18399: used by template to pass pre profile id as a url arg $this->assign('custom_pre_id', $this->_values['custom_pre_id']); $this->buildComponentForm($this->_id, $this); } // Build payment processor form CRM_Core_Payment_ProcessorForm::buildQuickForm($this); $config = CRM_Core_Config::singleton(); $contactID = $this->getContactID(); if ($contactID) { $this->assign('contact_id', $contactID); $this->assign('display_name', CRM_Contact_BAO_Contact::displayName($contactID)); } $this->applyFilter('__ALL__', 'trim'); if (empty($this->_ccid)) { $this->add('text', "email-{$this->_bltID}", ts('Email Address'), array('size' => 30, 'maxlength' => 60, 'class' => 'email'), TRUE); $this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email'); } else { $this->addElement('hidden', "email-{$this->_bltID}", 1); $this->add('text', 'total_amount', ts('Total Amount'), array('readonly' => TRUE), FALSE); } $pps = array(); //@todo - this should be replaced by a check as to whether billing fields are set $onlinePaymentProcessorEnabled = FALSE; if (!empty($this->_paymentProcessors)) { foreach ($this->_paymentProcessors as $key => $name) { if ($name['billing_mode'] == 1) { $onlinePaymentProcessorEnabled = TRUE; } $pps[$key] = $name['name']; } } if (!empty($this->_values['is_pay_later'])) { $pps[0] = $this->_values['pay_later_text']; } if (count($pps) > 1) { $this->addRadio('payment_processor_id', ts('Payment Method'), $pps, NULL, " "); } elseif (!empty($pps)) { $key = array_keys($pps); $key = array_pop($key); $this->addElement('hidden', 'payment_processor_id', $key); if ($key === 0) { $this->assign('is_pay_later', $this->_values['is_pay_later']); $this->assign('pay_later_text', $this->_values['pay_later_text']); } } $contactID = $this->getContactID(); if ($this->getContactID() === 0) { $this->addCidZeroOptions($onlinePaymentProcessorEnabled); } //build pledge block. $this->_useForMember = 0; //don't build membership block when pledge_id is passed if (empty($this->_values['pledge_id']) && empty($this->_ccid)) { $this->_separateMembershipPayment = FALSE; if (in_array('CiviMember', $config->enableComponents)) { $isTest = 0; if ($this->_action & CRM_Core_Action::PREVIEW) { $isTest = 1; } if ($this->_priceSetId && CRM_Core_Component::getComponentID('CiviMember') == CRM_Utils_Array::value('extends', $this->_priceSet)) { $this->_useForMember = 1; $this->set('useForMember', $this->_useForMember); } $this->_separateMembershipPayment = $this->buildMembershipBlock($this->_membershipContactID, TRUE, NULL, FALSE, $isTest); } $this->set('separateMembershipPayment', $this->_separateMembershipPayment); } $this->assign('useForMember', $this->_useForMember); // If we configured price set for contribution page // we are not allow membership signup as well as any // other contribution amount field, CRM-5095 if (isset($this->_priceSetId) && $this->_priceSetId) { $this->add('hidden', 'priceSetId', $this->_priceSetId); // build price set form. $this->set('priceSetId', $this->_priceSetId); if (empty($this->_ccid)) { CRM_Price_BAO_PriceSet::buildPriceSet($this); } if ($this->_values['is_monetary'] && $this->_values['is_recur'] && empty($this->_values['pledge_id'])) { self::buildRecur($this); } } if ($this->_priceSetId && empty($this->_ccid)) { $is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config'); if ($is_quick_config) { $this->_useForMember = 0; $this->set('useForMember', $this->_useForMember); } } //we allow premium for pledge during pledge creation only. if (empty($this->_values['pledge_id']) && empty($this->_ccid)) { CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, TRUE); } //don't build pledge block when mid is passed if (!$this->_mid && empty($this->_ccid)) { $config = CRM_Core_Config::singleton(); if (in_array('CiviPledge', $config->enableComponents) && !empty($this->_values['pledge_block_id'])) { CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this); } } //to create an cms user if (!$this->_contactID && empty($this->_ccid)) { $createCMSUser = FALSE; if ($this->_values['custom_pre_id']) { $profileID = $this->_values['custom_pre_id']; $createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user'); } if (!$createCMSUser && $this->_values['custom_post_id']) { if (!is_array($this->_values['custom_post_id'])) { $profileIDs = array($this->_values['custom_post_id']); } else { $profileIDs = $this->_values['custom_post_id']; } foreach ($profileIDs as $pid) { if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $pid, 'is_cms_user')) { $profileID = $pid; $createCMSUser = TRUE; break; } } } if ($createCMSUser) { CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE); } } if ($this->_pcpId && empty($this->_ccid)) { if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($this->_pcpId)) { $pcp_supporter_text = ts('This contribution is being made thanks to the effort of <strong>%1</strong>, who supports our campaign.', array(1 => $pcpSupporter)); // Only tell people that can also create a PCP if the contribution page has a non-empty value in the "Create Personal Campaign Page link" field. $text = CRM_PCP_BAO_PCP::getPcpBlockStatus($this->_id, 'contribute'); if (!empty($text)) { $pcp_supporter_text .= ts("You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!"); } $this->assign('pcpSupporterText', $pcp_supporter_text); } $prms = array('id' => $this->_pcpId); CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo); if ($pcpInfo['is_honor_roll']) { $this->assign('isHonor', TRUE); $this->add('checkbox', 'pcp_display_in_roll', ts('Show my contribution in the public honor roll'), NULL, NULL, array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );")); $extraOption = array('onclick' => "return pcpAnonymous( );"); $elements = array(); $elements[] =& $this->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption); $elements[] =& $this->createElement('radio', NULL, '', ts('List my contribution anonymously'), 1, $extraOption); $this->addGroup($elements, 'pcp_is_anonymous', NULL, ' '); $this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30)); $this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;')); } } if (empty($this->_values['fee']) && empty($this->_ccid)) { CRM_Core_Error::fatal(ts('This page does not have any price fields configured or you may not have permission for them. Please contact the site administrator for more details.')); } //we have to load confirm contribution button in template //when multiple payment processor as the user //can toggle with payment processor selection $billingModePaymentProcessors = 0; if (!empty($this->_paymentProcessors)) { foreach ($this->_paymentProcessors as $key => $values) { if ($values['billing_mode'] == CRM_Core_Payment::BILLING_MODE_BUTTON) { $billingModePaymentProcessors++; } } } if ($billingModePaymentProcessors && count($this->_paymentProcessors) == $billingModePaymentProcessors) { $allAreBillingModeProcessors = TRUE; } else { $allAreBillingModeProcessors = FALSE; } if (!($allAreBillingModeProcessors && !$this->_values['is_pay_later'])) { $submitButton = array('type' => 'upload', 'name' => CRM_Utils_Array::value('is_confirm_enabled', $this->_values) ? ts('Confirm Contribution') : ts('Contribute'), 'spacing' => ' ', 'isDefault' => TRUE); // Add submit-once behavior when confirm page disabled if (empty($this->_values['is_confirm_enabled'])) { $submitButton['js'] = array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"); } //change button name for updating contribution if (!empty($this->_ccid)) { $submitButton['name'] = ts('Confirm Payment'); } $this->addButtons(array($submitButton)); } $this->addFormRule(array('CRM_Contribute_Form_Contribution_Main', 'formRule'), $this); }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { $config = CRM_Core_Config::singleton(); if ($this->_values['is_for_organization'] == 2) { $this->assign('onBehalfRequired', true); } if ($this->_onbehalf) { $this->assign('onbehalf', true); return CRM_Contribute_Form_Contribution_OnBehalfOf::buildQuickForm($this); } $this->applyFilter('__ALL__', 'trim'); $this->add('text', "email-{$this->_bltID}", ts('Email Address'), array('size' => 30, 'maxlength' => 60), true); $this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email'); //build pledge block. $this->_useForMember = 0; //don't build membership block when pledge_id is passed if (!CRM_Utils_Array::value('pledge_id', $this->_values)) { $this->_separateMembershipPayment = false; if (in_array('CiviMember', $config->enableComponents)) { $isTest = 0; if ($this->_action & CRM_Core_Action::PREVIEW) { $isTest = 1; } if ($this->_priceSetId && CRM_Core_Component::getComponentID('CiviMember') == CRM_Utils_Array::value('extends', $this->_priceSet)) { $this->_useForMember = 1; $this->set('useForMember', $this->_useForMember); } require_once 'CRM/Member/BAO/Membership.php'; $this->_separateMembershipPayment = CRM_Member_BAO_Membership::buildMembershipBlock($this, $this->_id, true, null, false, $isTest, $this->_membershipContactID); } $this->set('separateMembershipPayment', $this->_separateMembershipPayment); } $this->assign('useForMember', $this->_useForMember); // If we configured price set for contribution page // we are not allow membership signup as well as any // other contribution amount field, CRM-5095 if (isset($this->_priceSetId) && $this->_priceSetId) { $this->add('hidden', 'priceSetId', $this->_priceSetId); // build price set form. $this->set('priceSetId', $this->_priceSetId); require_once 'CRM/Price/BAO/Set.php'; CRM_Price_BAO_Set::buildPriceSet($this); } else { if (CRM_Utils_Array::value('amount_block_is_active', $this->_values) && !CRM_Utils_Array::value('pledge_id', $this->_values)) { $this->buildAmount($this->_separateMembershipPayment); if ($this->_values['is_monetary'] && $this->_values['is_recur'] && $this->_paymentProcessor['is_recur']) { self::buildRecur($this); } } } if (CRM_Utils_Array::value('is_pay_later', $this->_values)) { $this->buildPayLater(); } if ($this->_values['is_for_organization']) { $this->buildOnBehalfOrganization(); } //we allow premium for pledge during pledge creation only. if (!CRM_Utils_Array::value('pledge_id', $this->_values)) { require_once 'CRM/Contribute/BAO/Premium.php'; CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, true); } if ($this->_values['honor_block_is_active']) { $this->buildHonorBlock(); } //don't build pledge block when mid is passed if (!$this->_mid) { $config = CRM_Core_Config::singleton(); if (in_array('CiviPledge', $config->enableComponents) && CRM_Utils_Array::value('pledge_block_id', $this->_values)) { require_once 'CRM/Pledge/BAO/PledgeBlock.php'; CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this); } } $this->buildCustom($this->_values['custom_pre_id'], 'customPre'); $this->buildCustom($this->_values['custom_post_id'], 'customPost'); // doing this later since the express button type depends if there is an upload or not if ($this->_values['is_monetary']) { require_once 'CRM/Core/Payment/Form.php'; if ($this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) { CRM_Core_Payment_Form::buildDirectDebit($this); } else { CRM_Core_Payment_Form::buildCreditCard($this); } } //to create an cms user if (!$this->_userID) { $createCMSUser = false; if ($this->_values['custom_pre_id']) { $profileID = $this->_values['custom_pre_id']; $createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user'); } if (!$createCMSUser && $this->_values['custom_post_id']) { $profileID = $this->_values['custom_post_id']; $createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user'); } if ($createCMSUser) { require_once 'CRM/Core/BAO/CMSUser.php'; CRM_Core_BAO_CMSUser::buildForm($this, $profileID, true); } } if ($this->_pcpId) { require_once 'CRM/Contribute/BAO/PCP.php'; if ($pcpSupporter = CRM_Contribute_BAO_PCP::displayName($this->_pcpId)) { $this->assign('pcpSupporterText', ts('This contribution is being made thanks to effort of <strong>%1</strong>, who supports our campaign. You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!', array(1 => $pcpSupporter))); } $this->assign('pcp', true); $this->add('checkbox', 'pcp_display_in_roll', ts('Show my contribution in the public honor roll'), null, null, array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );")); $extraOption = array('onclick' => "return pcpAnonymous( );"); $elements = array(); $elements[] =& $this->createElement('radio', null, '', ts('Include my name and message'), 0, $extraOption); $elements[] =& $this->createElement('radio', null, '', ts('List my contribution anonymously'), 1, $extraOption); $this->addGroup($elements, 'pcp_is_anonymous', null, ' '); $this->_defaults['pcp_is_anonymous'] = 0; $this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30)); $this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;')); } if (!($this->_paymentProcessor['billing_mode'] == CRM_Core_Payment::BILLING_MODE_BUTTON && !$this->_values['is_pay_later'])) { $this->addButtons(array(array('type' => 'upload', 'name' => ts('Confirm Contribution'), 'spacing' => ' ', 'isDefault' => true))); } $this->addFormRule(array('CRM_Contribute_Form_Contribution_Main', 'formRule'), $this); }