/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } // build price set form. $buildPriceSet = FALSE; if ($this->_priceSetId || CRM_Utils_Array::value('price_set_id', $_POST)) { if (CRM_Utils_Array::value('price_set_id', $_POST)) { $buildPriceSet = TRUE; } $getOnlyPriceSetElements = TRUE; if (!$this->_priceSetId) { $this->_priceSetId = $_POST['price_set_id']; $getOnlyPriceSetElements = FALSE; } $this->set('priceSetId', $this->_priceSetId); CRM_Price_BAO_Set::buildPriceSet($this); $optionsMembershipTypes = array(); foreach ($this->_priceSet['fields'] as $pField) { if (empty($pField['options'])) { continue; } foreach ($pField['options'] as $opId => $opValues) { $optionsMembershipTypes[$opId] = CRM_Utils_Array::value('membership_type_id', $opValues, 0); } } $this->assign('autoRenewOption', CRM_Price_BAO_Set::checkAutoRenewForPriceSet($this->_priceSetId)); $this->assign('optionsMembershipTypes', $optionsMembershipTypes); $this->assign('contributionType', CRM_Utils_Array::value('contribution_type_id', $this->_priceSet)); // get only price set form elements. if ($getOnlyPriceSetElements) { return; } } // use to build form during form rule. $this->assign('buildPriceSet', $buildPriceSet); if ($this->_action & CRM_Core_Action::ADD) { $buildPriceSet = FALSE; $priceSets = CRM_Price_BAO_Set::getAssoc(FALSE, 'CiviMember'); if (!empty($priceSets)) { $buildPriceSet = TRUE; } if ($buildPriceSet) { $this->add('select', 'price_set_id', ts('Choose price set'), array('' => ts('Choose price set')) + $priceSets, NULL, array('onchange' => "buildAmount( this.value );")); } $this->assign('hasPriceSets', $buildPriceSet); } //need to assign custom data type and subtype to the template $this->assign('customDataType', 'Membership'); $this->assign('customDataSubType', $this->_memType); $this->assign('entityID', $this->_id); if ($this->_action & CRM_Core_Action::DELETE) { $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } if ($this->_context == 'standalone') { CRM_Contact_Form_NewContact::buildQuickForm($this); } $selOrgMemType[0][0] = $selMemTypeOrg[0] = ts('- select -'); $dao = new CRM_Member_DAO_MembershipType(); $dao->domain_id = CRM_Core_Config::domainID(); $dao->find(); // retrieve all memberships $allMemberships = CRM_Member_BAO_Membership::buildMembershipTypeValues($this); $allMembershipInfo = $membershipType = array(); foreach ($allMemberships as $key => $values) { if (CRM_Utils_Array::value('is_active', $values)) { $membershipType[$key] = CRM_Utils_Array::value('name', $values); if ($this->_mode && !CRM_Utils_Array::value('minimum_fee', $values)) { continue; } else { $memberOfContactId = CRM_Utils_Array::value('member_of_contact_id', $values); if (!CRM_Utils_Array::value($memberOfContactId, $selMemTypeOrg)) { $selMemTypeOrg[$memberOfContactId] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $memberOfContactId, 'display_name', 'id'); $selOrgMemType[$memberOfContactId][0] = ts('- select -'); } if (!CRM_Utils_Array::value($key, $selOrgMemType[$memberOfContactId])) { $selOrgMemType[$memberOfContactId][$key] = CRM_Utils_Array::value('name', $values); } } // build membership info array, which is used to set the payment information block when // membership type is selected. $allMembershipInfo[$key] = array('contribution_type_id' => CRM_Utils_Array::value('contribution_type_id', $values), 'total_amount' => CRM_Utils_Money::format($values['minimum_fee'], NULL, '%a'), 'auto_renew' => CRM_Utils_Array::value('auto_renew', $values)); } } $this->assign('allMembershipInfo', json_encode($allMembershipInfo)); // show organization by default, if only one organization in // the list if (count($selMemTypeOrg) == 2) { unset($selMemTypeOrg[0], $selOrgMemType[0][0]); } //sort membership organization and type, CRM-6099 natcasesort($selMemTypeOrg); foreach ($selOrgMemType as $index => $orgMembershipType) { natcasesort($orgMembershipType); $selOrgMemType[$index] = $orgMembershipType; } $memTypeJs = array('onChange' => "buildCustomData( 'Membership', this.value );"); //build the form for auto renew. $recurProcessor = $autoRenew = array(); if ($this->_mode || $this->_action & CRM_Core_Action::UPDATE) { $autoRenewElement = $this->addElement('checkbox', 'auto_renew', ts('Membership renewed automatically'), NULL, array('onclick' => "buildReceiptANDNotice( );")); if ($this->_mode) { //get the valid recurring processors. $recurring = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, 'is_recur = 1'); $recurProcessor = array_intersect_assoc($this->_processors, $recurring); $autoRenew = array(); if (!empty($recurProcessor)) { if (!empty($membershipType)) { $sql = ' SELECT id, auto_renew, duration_unit, duration_interval FROM civicrm_membership_type WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; $recurMembershipTypes = CRM_Core_DAO::executeQuery($sql); while ($recurMembershipTypes->fetch()) { $autoRenew[$recurMembershipTypes->id] = $recurMembershipTypes->auto_renew; foreach (array('id', 'auto_renew', 'duration_unit', 'duration_interval') as $fld) { $this->_recurMembershipTypes[$recurMembershipTypes->id][$fld] = $recurMembershipTypes->{$fld}; } } } $memTypeJs = array('onChange' => "buildCustomData( 'Membership', this.value ); buildAutoRenew(this.value, null );"); } } } $allowAutoRenew = FALSE; if ($this->_mode && !empty($recurProcessor)) { $allowAutoRenew = TRUE; } $this->assign('allowAutoRenew', $allowAutoRenew); $this->assign('autoRenewOptions', json_encode($autoRenew)); $this->assign('recurProcessor', json_encode($recurProcessor)); $sel =& $this->addElement('hierselect', 'membership_type_id', ts('Membership Organization and Type'), $memTypeJs); $sel->setOptions(array($selMemTypeOrg, $selOrgMemType)); $elements = array(); if ($sel) { $elements[] = $sel; } $this->applyFilter('__ALL__', 'trim'); $this->addDate('join_date', ts('Member Since'), FALSE, array('formatType' => 'activityDate')); $this->addDate('start_date', ts('Start Date'), FALSE, array('formatType' => 'activityDate')); $endDate = $this->addDate('end_date', ts('End Date'), FALSE, array('formatType' => 'activityDate')); if ($endDate) { $elements[] = $endDate; } $this->add('text', 'source', ts('Source'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_Membership', 'source')); //CRM-7362 --add campaigns. $campaignId = NULL; if ($this->_id) { $campaignId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id, 'campaign_id'); } CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId); if (!$this->_mode) { $this->add('select', 'status_id', ts('Membership Status'), array('' => ts('- select -')) + CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label')); $statusOverride = $this->addElement('checkbox', 'is_override', ts('Status Override?'), NULL, array('onClick' => 'showHideMemberStatus()')); if ($statusOverride) { $elements[] = $statusOverride; } $this->addElement('checkbox', 'record_contribution', ts('Record Membership Payment?')); $this->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType()); $this->add('text', 'total_amount', ts('Amount')); $this->addRule('total_amount', ts('Please enter a valid amount.'), 'money'); $this->addDate('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDate')); $this->add('select', 'payment_instrument_id', ts('Paid By'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), FALSE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")); $this->add('text', 'trxn_id', ts('Transaction ID')); $this->addRule('trxn_id', ts('Transaction ID already exists in Database.'), 'objectExists', array('CRM_Contribute_DAO_Contribution', $this->_id, 'trxn_id')); $allowStatuses = array(); $statuses = CRM_Contribute_PseudoConstant::contributionStatus(); if ($this->_onlinePendingContributionId) { $statusNames = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); foreach ($statusNames as $val => $name) { if (in_array($name, array('In Progress', 'Overdue'))) { continue; } $allowStatuses[$val] = $statuses[$val]; } } else { $allowStatuses = $statuses; } $this->add('select', 'contribution_status_id', ts('Payment Status'), $allowStatuses); $this->add('text', 'check_number', ts('Check Number'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'check_number')); } else { //add field for amount to allow an amount to be entered that differs from minimum $this->add('text', 'total_amount', ts('Amount')); } if ($this->_context != 'standalone') { //CRM-10223 - allow contribution to be recorded against different contact // causes a conflict in standalone mode so skip in standalone for now $this->addElement('checkbox', 'is_different_contribution_contact', ts('Record Payment from a Different Contact?')); $this->add('select', 'honor_type_id', ts('Membership payment is : '), array('' => ts('-')) + CRM_Core_PseudoConstant::honor()); CRM_Contact_Form_NewContact::buildQuickForm($this, 1, null, false, 'contribution_'); } $this->addElement('checkbox', 'send_receipt', ts('Send Confirmation and Receipt?'), NULL, array('onclick' => "showHideByValue( 'send_receipt', '', 'notice', 'table-row', 'radio', false); showHideByValue( 'send_receipt', '', 'fromEmail', 'table-row', 'radio', false);")); $this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails); $this->add('textarea', 'receipt_text_signup', ts('Receipt Message')); if ($this->_mode) { $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, TRUE, array('onChange' => "buildAutoRenew( null, this.value );")); CRM_Core_Payment_Form::buildCreditCard($this, TRUE); } // Retrieve the name and email of the contact - this will be the TO for receipt email if ($this->_contactID) { list($this->_memberDisplayName, $this->_memberEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID); $this->assign('emailExists', $this->_memberEmail); $this->assign('displayName', $this->_memberDisplayName); } $isRecur = FALSE; if ($this->_action & CRM_Core_Action::UPDATE) { $recurContributionId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id, 'contribution_recur_id'); if ($recurContributionId && !CRM_Member_BAO_Membership::isSubscriptionCancelled($this->_id)) { $isRecur = TRUE; if (CRM_Member_BAO_Membership::isCancelSubscriptionSupported($this->_id)) { $this->assign('cancelAutoRenew', CRM_Utils_System::url('civicrm/contribute/unsubscribe', "reset=1&mid={$this->_id}")); } foreach ($elements as $elem) { $elem->freeze(); } } } $this->assign('isRecur', $isRecur); $this->addFormRule(array('CRM_Member_Form_Membership', 'formRule'), $this); $mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend'); $this->assign('outBound_option', $mailingInfo['outBound_option']); parent::buildQuickForm(); }
/** * Function to actually build the form * * @return void * @access public */ public function buildQuickForm() { require_once 'CRM/Utils/Money.php'; // do u want to allow a free form text field for amount $this->addElement('checkbox', 'is_allow_other_amount', ts('Allow other amounts'), null, array('onclick' => "minMax(this);showHideAmountBlock( this, 'is_allow_other_amount' );")); $this->add('text', 'min_amount', ts('Minimum Amount'), array('size' => 8, 'maxlength' => 8)); $this->addRule('min_amount', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money'); $this->add('text', 'max_amount', ts('Maximum Amount'), array('size' => 8, 'maxlength' => 8)); $this->addRule('max_amount', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money'); $default = array(); for ($i = 1; $i <= self::NUM_OPTION; $i++) { // label $this->add('text', "label[{$i}]", ts('Label'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'label')); // value $this->add('text', "value[{$i}]", ts('Value'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value')); $this->addRule("value[{$i}]", ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money'); // default $default[] = $this->createElement('radio', null, null, null, $i); } $this->addGroup($default, 'default'); $this->addElement('checkbox', 'amount_block_is_active', ts('Contribution Amounts section enabled'), null, array('onclick' => "showHideAmountBlock( this, 'amount_block_is_active' );")); $this->addElement('checkbox', 'is_monetary', ts('Execute real-time monetary transactions')); $paymentProcessor =& CRM_Core_PseudoConstant::paymentProcessor(); $recurringPaymentProcessor = array(); if (!empty($paymentProcessor)) { $paymentProcessorIds = implode(',', array_keys($paymentProcessor)); $query = "\nSELECT id\n FROM civicrm_payment_processor\n WHERE id IN ({$paymentProcessorIds})\n AND is_recur = 1"; $dao =& CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { $recurringPaymentProcessor[] = $dao->id; } } $this->assign('recurringPaymentProcessor', $recurringPaymentProcessor); if (count($paymentProcessor)) { $this->assign('paymentProcessor', $paymentProcessor); } $this->add('select', 'payment_processor_id', ts('Payment Processor'), array('' => ts('- select -')) + $paymentProcessor, null, array('onchange' => "showRecurring( this.value );")); require_once "CRM/Contribute/BAO/ContributionPage.php"; //check if selected payment processor supports recurring payment if (!empty($recurringPaymentProcessor)) { $this->addElement('checkbox', 'is_recur', ts('Recurring contributions'), null, array('onclick' => "showHideByValue('is_recur',true,'recurFields','table-row','radio',false); showRecurInterval( );")); require_once 'CRM/Core/OptionGroup.php'; $this->addCheckBox('recur_frequency_unit', ts('Supported recurring units'), CRM_Core_OptionGroup::values('recur_frequency_units', false, false, false, null, 'name'), null, null, null, null, array(' ', ' ', ' ', '<br/>')); $this->addElement('checkbox', 'is_recur_interval', ts('Support recurring intervals')); } // add pay later options $this->addElement('checkbox', 'is_pay_later', ts('Pay later option'), null, array('onclick' => "payLater(this);")); $this->addElement('textarea', 'pay_later_text', ts('Pay later label'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'pay_later_text'), false); $this->addElement('textarea', 'pay_later_receipt', ts('Pay later instructions'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'pay_later_receipt'), false); // add price set fields require_once 'CRM/Price/BAO/Set.php'; $price = CRM_Price_BAO_Set::getAssoc(false, 'CiviContribute'); if (CRM_Utils_System::isNull($price)) { $this->assign('price', false); } else { $this->assign('price', true); } $this->add('select', 'price_set_id', ts('Price Set'), array('' => ts('- none -')) + $price, null, array('onchange' => "showHideAmountBlock( this.value, 'price_set_id' );")); //CiviPledge fields. $config = CRM_Core_Config::singleton(); if (in_array('CiviPledge', $config->enableComponents)) { $this->assign('civiPledge', true); require_once 'CRM/Core/OptionGroup.php'; $this->addElement('checkbox', 'is_pledge_active', ts('Pledges'), null, array('onclick' => "showHideAmountBlock( this, 'is_pledge_active' ); return showHideByValue('is_pledge_active',true,'pledgeFields','table-row','radio',false);")); $this->addCheckBox('pledge_frequency_unit', ts('Supported pledge frequencies'), CRM_Core_OptionGroup::values("recur_frequency_units", false, false, false, null, 'name'), null, null, null, null, array(' ', ' ', ' ', '<br/>')); $this->addElement('checkbox', 'is_pledge_interval', ts('Allow frequency intervals')); $this->addElement('text', 'initial_reminder_day', ts('Send payment reminder'), array('size' => 3)); $this->addElement('text', 'max_reminders', ts('Send up to'), array('size' => 3)); $this->addElement('text', 'additional_reminder_day', ts('Send additional reminders'), array('size' => 3)); } //add currency element. $this->addCurrency('currency', ts('Currency')); $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Amount', 'formRule'), $this); parent::buildQuickForm(); }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { require_once 'CRM/Utils/Money.php'; $this->addYesNo('is_monetary', ts('Paid Event'), null, null, array('onclick' => "return showHideByValue('is_monetary','0','event-fees','block','radio',false);")); require_once 'CRM/Contribute/PseudoConstant.php'; $paymentProcessor =& CRM_Core_PseudoConstant::paymentProcessor(); $this->assign('paymentProcessor', $paymentProcessor); $this->add('select', 'payment_processor_id', ts('Payment Processor'), array('' => ts('- select -')) + $paymentProcessor); $this->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType()); // add pay later options $this->addElement('checkbox', 'is_pay_later', ts('Enable Pay Later option?'), null, array('onclick' => "return showHideByValue('is_pay_later','','payLaterOptions','block','radio',false);")); $this->addElement('textarea', 'pay_later_text', ts('Pay Later Label'), CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'pay_later_text'), false); $this->addElement('textarea', 'pay_later_receipt', ts('Pay Later Instructions'), CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'pay_later_receipt'), false); $this->add('text', 'fee_label', ts('Fee Label')); require_once 'CRM/Price/BAO/Set.php'; $this->add('select', 'price_set_id', ts('Price Set'), array('' => ts('- none -')) + CRM_Price_BAO_Set::getAssoc(false, 'Event'), null, array('onchange' => "return showHideByValue('price_set_id', '', 'map-field', 'block', 'select', false);")); $default = array(); for ($i = 1; $i <= self::NUM_OPTION; $i++) { // label $this->add('text', "label[{$i}]", ts('Label'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'label')); // value $this->add('text', "value[{$i}]", ts('Value'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value')); $this->addRule("value[{$i}]", ts('Please enter a valid money value for this field (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money'); // default $default[] = $this->createElement('radio', null, null, null, $i); } $this->addGroup($default, 'default'); $this->addElement('checkbox', 'is_discount', ts('Discounts by Signup Date?'), null, array('onclick' => "warnDiscountDel(); return showHideByValue('is_discount','','discount','block','radio',false);")); $discountSection = $this->get('discountSection'); $this->assign('discountSection', $discountSection); require_once 'CRM/Core/ShowHideBlocks.php'; // form fields of Discount sets $defaultOption = array(); $_showHide =& new CRM_Core_ShowHideBlocks('', ''); for ($i = 1; $i <= self::NUM_DISCOUNT; $i++) { //the show hide blocks $showBlocks = 'discount_' . $i; if ($i > 2) { $_showHide->addHide($showBlocks); } else { $_showHide->addShow($showBlocks); } //Increment by 1 of start date of previous end date. if (is_array($this->_submitValues) && !empty($this->_submitValues['discount_name'][$i]) && !empty($this->_submitValues['discount_name'][$i + 1]) && isset($this->_submitValues['discount_end_date']) && isset($this->_submitValues['discount_end_date'][$i]) && array_values($this->_submitValues['discount_end_date'][$i]) && $i < self::NUM_DISCOUNT - 1) { $end_date = CRM_Utils_Date::format($this->_submitValues['discount_end_date'][$i], '-'); if (!empty($this->_submitValues['discount_end_date'][$i + 1]['M']) && empty($this->_submitValues['discount_start_date'][$i + 1]['M'])) { $this->_submitValues['discount_start_date'][$i + 1] = CRM_Utils_Date::unformat(date('Y-m-d', strtotime("+1 days {$end_date}"))); } } //Decrement by 1 of end date from next start date. if ($i > 1 && is_array($this->_submitValues) && !empty($this->_submitValues['discount_name'][$i]) && !empty($this->_submitValues['discount_name'][$i - 1]) && isset($this->_submitValues['discount_start_date']) && isset($this->_submitValues['discount_start_date'][$i]) && array_values($this->_submitValues['discount_start_date'][$i])) { $start_date = CRM_Utils_Date::format($this->_submitValues['discount_start_date'][$i], '-'); if (!empty($this->_submitValues['discount_start_date'][$i]['M']) && empty($this->_submitValues['discount_end_date'][$i - 1]['M'])) { $this->_submitValues['discount_end_date'][$i - 1] = CRM_Utils_Date::unformat(date('Y-m-d', strtotime("-1 days {$start_date}"))); } } //discount name $this->add('text', 'discount_name[' . $i . ']', ts('Discount Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'label')); //discount start date $this->add('date', 'discount_start_date[' . $i . ']', ts('Discount Start Date'), CRM_Core_SelectValues::date('activityDate')); //discount end date $this->add('date', 'discount_end_date[' . $i . ']', ts('Discount End Date'), CRM_Core_SelectValues::date('activityDate')); } $_showHide->addToTemplate(); $this->addElement('submit', $this->getButtonName('submit'), ts('Add Discount Set to Fee Table'), array('class' => 'form-submit')); $this->buildAmountLabel(); parent::buildQuickForm(); }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } // build price set form. $buildPriceSet = false; if (empty($this->_lineItems) && ($this->_priceSetId || CRM_Utils_Array::value('price_set_id', $_POST))) { $buildPriceSet = true; $getOnlyPriceSetElements = true; if (!$this->_priceSetId) { $this->_priceSetId = $_POST['price_set_id']; $getOnlyPriceSetElements = false; } $this->set('priceSetId', $this->_priceSetId); require_once 'CRM/Price/BAO/Set.php'; CRM_Price_BAO_Set::buildPriceSet($this); // get only price set form elements. if ($getOnlyPriceSetElements) { return; } } // use to build form during form rule. $this->assign('buildPriceSet', $buildPriceSet); $showAdditionalInfo = false; require_once 'CRM/Contribute/Form/AdditionalInfo.php'; $defaults = $this->_values; $additionalDetailFields = array('note', 'thankyou_date', 'invoice_id', 'non_deductible_amount', 'fee_amount', 'net_amount'); foreach ($additionalDetailFields as $key) { if (!empty($defaults[$key])) { $defaults['hidden_AdditionalDetail'] = 1; break; } } $honorFields = array('honor_type_id', 'honor_prefix_id', 'honor_first_name', 'honor_lastname', 'honor_email'); foreach ($honorFields as $key) { if (!empty($defaults[$key])) { $defaults['hidden_Honoree'] = 1; break; } } //check for honoree pane. if ($this->_ppID && CRM_Utils_Array::value('honor_contact_id', $this->_pledgeValues)) { $defaults['hidden_Honoree'] = 1; } if ($this->_productDAO) { if ($this->_productDAO->product_id) { $defaults['hidden_Premium'] = 1; } } if ($this->_noteID && isset($this->_values['note'])) { $defaults['hidden_AdditionalDetail'] = 1; } $paneNames = array('Additional Details' => 'AdditionalDetail', 'Honoree Information' => 'Honoree'); //Add Premium pane only if Premium is exists. require_once 'CRM/Contribute/DAO/Product.php'; $dao =& new CRM_Contribute_DAO_Product(); $dao->is_active = 1; if ($dao->find(true)) { $paneNames['Premium Information'] = 'Premium'; } $ccPane = null; if ($this->_mode) { if ($this->_processors['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) { $ccPane = array(ts('Direct Debit Information') => 'DirectDebit'); } else { $ccPane = array('Credit Card Information' => 'CreditCard'); } } if (is_array($ccPane)) { $paneNames = array_merge($ccPane, $paneNames); } foreach ($paneNames as $name => $type) { $urlParams = "snippet=4&formType={$type}"; if ($this->_mode) { $urlParams .= "&mode={$this->_mode}"; } $open = 'false'; if ($type == 'CreditCard' || $type == 'DirectDebit') { $open = 'true'; } $allPanes[$name] = array('url' => CRM_Utils_System::url('civicrm/contact/view/contribution', $urlParams), 'open' => $open, 'id' => $type); // see if we need to include this paneName in the current form if ($this->_formType == $type || CRM_Utils_Array::value("hidden_{$type}", $_POST) || CRM_Utils_Array::value("hidden_{$type}", $defaults)) { $showAdditionalInfo = true; $allPanes[$name]['open'] = 'true'; } if ($type == 'CreditCard') { $this->add('hidden', 'hidden_CreditCard', 1); CRM_Core_Payment_Form::buildCreditCard($this, true); } else { if ($type == 'DirectDebit') { $this->add('hidden', 'hidden_DirectDebit', 1); CRM_Core_Payment_Form::buildDirectDebit($this, true); } else { eval('CRM_Contribute_Form_AdditionalInfo::build' . $type . '( $this );'); } } } $this->assign('allPanes', $allPanes); $this->assign('showAdditionalInfo', $showAdditionalInfo); if ($this->_formType) { $this->assign('formType', $this->_formType); return; } $this->applyFilter('__ALL__', 'trim'); if ($this->_action & CRM_Core_Action::DELETE) { $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } //need to assign custom data type and subtype to the template $this->assign('customDataType', 'Contribution'); $this->assign('customDataSubType', $this->_contributionType); $this->assign('entityID', $this->_id); if ($this->_context == 'standalone') { require_once 'CRM/Contact/Form/NewContact.php'; CRM_Contact_Form_NewContact::buildQuickForm($this); } $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution'); $element =& $this->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType(), true, array('onChange' => "buildCustomData( 'Contribution', this.value );")); if ($this->_online) { $element->freeze(); } if (!$this->_mode) { $element =& $this->add('select', 'payment_instrument_id', ts('Paid By'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), false, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")); if ($this->_online) { $element->freeze(); } } $element =& $this->add('text', 'trxn_id', ts('Transaction ID'), $attributes['trxn_id']); if ($this->_online) { $element->freeze(); } else { $this->addRule('trxn_id', ts('This Transaction ID already exists in the database. Include the account number for checks.'), 'objectExists', array('CRM_Contribute_DAO_Contribution', $this->_id, 'trxn_id')); } //add receipt for offline contribution $this->addElement('checkbox', 'is_email_receipt', ts('Send Receipt?'), null, array('onclick' => "return showHideByValue('is_email_receipt','','receiptDate','table-row','radio',true);")); $status = CRM_Contribute_PseudoConstant::contributionStatus(); // supressing contribution statuses that are NOT relevant to pledges (CRM-5169) if ($this->_ppID) { foreach (array('Cancelled', 'Failed', 'In Progress') as $supress) { unset($status[CRM_Utils_Array::key($supress, $status)]); } } $this->add('select', 'contribution_status_id', ts('Contribution Status'), $status, false, array('onClick' => "if (this.value != 3) status(); else return false", 'onChange' => "return showHideByValue('contribution_status_id','3','cancelInfo','table-row','select',false);")); // add various dates $this->addDate('receive_date', ts('Received'), false, array('formatType' => 'activityDate')); if ($this->_online) { $this->assign("hideCalender", true); } $element =& $this->add('text', 'check_number', ts('Check Number'), $attributes['check_number']); if ($this->_online) { $element->freeze(); } $this->addDate('receipt_date', ts('Receipt Date'), false, array('formatType' => 'activityDate')); $this->addDate('cancel_date', ts('Cancelled Date'), false, array('formatType' => 'activityDate')); $this->add('textarea', 'cancel_reason', ts('Cancellation Reason'), $attributes['cancel_reason']); $element =& $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors); if ($this->_online) { $element->freeze(); } if (empty($this->_lineItems)) { require_once 'CRM/Price/BAO/Set.php'; $priceSets = CRM_Price_BAO_Set::getAssoc(false, 'Contribution'); $hasPriceSets = false; if (!empty($priceSets) && !$this->_ppID) { $hasPriceSets = true; $element =& $this->add('select', 'price_set_id', ts('Choose price set'), array('' => ts('Choose price set')) + $priceSets, null, array('onchange' => "buildAmount( this.value );")); if ($this->_online) { $element->freeze(); } } $this->assign('hasPriceSets', $hasPriceSets); $element =& $this->add('text', 'total_amount', ts('Total Amount'), $attributes['total_amount'], $hasPriceSets ? false : true); $this->addRule('total_amount', ts('Please enter a valid amount.'), 'money'); if ($this->_online || $this->_ppID) { $element->freeze(); } } $element =& $this->add('text', 'source', ts('Source'), CRM_Utils_Array::value('source', $attributes)); if ($this->_online) { $element->freeze(); } $dataUrl = CRM_Utils_System::url("civicrm/ajax/contactlist", "reset=1&context=softcredit&id={$this->_id}", false, null, false); $this->assign('dataUrl', $dataUrl); $this->addElement('text', 'soft_credit_to', ts('Soft Credit To')); $this->addElement('hidden', 'soft_contact_id', '', array('id' => 'soft_contact_id')); if (CRM_Utils_Array::value('pcp_made_through_id', $defaults) && $this->_action & CRM_Core_Action::UPDATE) { $ele = $this->addElement('select', 'pcp_made_through_id', ts('Personal Campaign Page'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::pcPage()); $ele->freeze(); $this->addElement('checkbox', 'pcp_display_in_roll', ts('Honor Roll?'), null, array('onclick' => "return showHideByValue('pcp_display_in_roll','','softCreditInfo','table-row','radio',false);")); $this->addElement('text', 'pcp_roll_nickname', ts('Nickname')); $this->addElement('textarea', 'pcp_personal_note', ts('Personal Note')); } $js = null; if (!$this->_mode) { $js = array('onclick' => "return verify( );"); } require_once "CRM/Core/BAO/Preferences.php"; $mailingInfo =& CRM_Core_BAO_Preferences::mailingPreferences(); $this->assign('outBound_option', $mailingInfo['outBound_option']); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'js' => $js, 'isDefault' => true), array('type' => 'upload', 'name' => ts('Save and New'), 'js' => $js, 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel')))); $this->addFormRule(array('CRM_Contribute_Form_Contribution', 'formRule'), $this); if ($this->_action & CRM_Core_Action::VIEW) { $this->freeze(); } }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { $this->addYesNo('is_monetary', ts('Paid Event'), NULL, NULL, array('onclick' => "return showHideByValue('is_monetary','0','event-fees','block','radio',false);")); //add currency element. $this->addCurrency('currency', ts('Currency'), FALSE); $paymentProcessor = CRM_Core_PseudoConstant::paymentProcessor(); $this->assign('paymentProcessor', $paymentProcessor); $this->addCheckBox('payment_processor', ts('Payment Processor'), array_flip($paymentProcessor), NULL, NULL, NULL, NULL, array(' ', ' ', ' ', '<br/>')); $this->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType()); // add pay later options $this->addElement('checkbox', 'is_pay_later', ts('Enable Pay Later option?'), NULL, array('onclick' => "return showHideByValue('is_pay_later','','payLaterOptions','block','radio',false);")); $this->addElement('textarea', 'pay_later_text', ts('Pay Later Label'), CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'pay_later_text'), FALSE); $this->addElement('textarea', 'pay_later_receipt', ts('Pay Later Instructions'), CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'pay_later_receipt'), FALSE); $this->add('text', 'fee_label', ts('Fee Label')); $price = CRM_Price_BAO_Set::getAssoc(FALSE, 'CiviEvent'); if (CRM_Utils_System::isNull($price)) { $this->assign('price', FALSE); } else { $this->assign('price', TRUE); } $this->add('select', 'price_set_id', ts('Price Set'), array('' => ts('- none -')) + $price, NULL, array('onchange' => "return showHideByValue('price_set_id', '', 'map-field', 'block', 'select', false);")); $default = array(); $this->add('hidden', "price_field_id", '', array('id' => "price_field_id")); for ($i = 1; $i <= self::NUM_OPTION; $i++) { // label $this->add('text', "label[{$i}]", ts('Label'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'label')); $this->add('hidden', "price_field_value[{$i}]", '', array('id' => "price_field_value[{$i}]")); // value $this->add('text', "value[{$i}]", ts('Value'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value')); $this->addRule("value[{$i}]", ts('Please enter a valid money value for this field (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money'); // default $default[] = $this->createElement('radio', NULL, NULL, NULL, $i); } $this->addGroup($default, 'default'); $this->addElement('checkbox', 'is_discount', ts('Discounts by Signup Date?'), NULL, array('onclick' => "warnDiscountDel(); return showHideByValue('is_discount','','discount','block','radio',false);")); $discountSection = $this->get('discountSection'); $this->assign('discountSection', $discountSection); // form fields of Discount sets $defaultOption = array(); $_showHide = new CRM_Core_ShowHideBlocks('', ''); for ($i = 1; $i <= self::NUM_DISCOUNT; $i++) { //the show hide blocks $showBlocks = 'discount_' . $i; if ($i > 2) { $_showHide->addHide($showBlocks); } else { $_showHide->addShow($showBlocks); } //Increment by 1 of start date of previous end date. if (is_array($this->_submitValues) && !empty($this->_submitValues['discount_name'][$i]) && !empty($this->_submitValues['discount_name'][$i + 1]) && isset($this->_submitValues['discount_end_date']) && isset($this->_submitValues['discount_end_date'][$i]) && $i < self::NUM_DISCOUNT - 1) { $end_date = CRM_Utils_Date::processDate($this->_submitValues['discount_end_date'][$i]); if (!empty($this->_submitValues['discount_end_date'][$i + 1]) && empty($this->_submitValues['discount_start_date'][$i + 1])) { list($this->_submitValues['discount_start_date'][$i + 1]) = CRM_Utils_Date::setDateDefaults(date('Y-m-d', strtotime("+1 days {$end_date}"))); } } //Decrement by 1 of end date from next start date. if ($i > 1 && is_array($this->_submitValues) && !empty($this->_submitValues['discount_name'][$i]) && !empty($this->_submitValues['discount_name'][$i - 1]) && isset($this->_submitValues['discount_start_date']) && isset($this->_submitValues['discount_start_date'][$i])) { $start_date = CRM_Utils_Date::processDate($this->_submitValues['discount_start_date'][$i]); if (!empty($this->_submitValues['discount_start_date'][$i]) && empty($this->_submitValues['discount_end_date'][$i - 1])) { list($this->_submitValues['discount_end_date'][$i - 1]) = CRM_Utils_Date::setDateDefaults(date('Y-m-d', strtotime("-1 days {$start_date}"))); } } //discount name $this->add('text', 'discount_name[' . $i . ']', ts('Discount Name'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_Set', 'title')); $this->add('hidden', "discount_price_set[{$i}]", '', array('id' => "discount_price_set[{$i}]")); // add a rule to ensure that discount name is not more than 24 characters to prevent overflow // in option group name, CRM-7915 // 24 characters will make the option group name less than 64 characters $this->addRule("discount_name[{$i}]", ts('Discount Name cannot be more than 24 characters'), 'maxlength', 24); //discount start date $this->addDate('discount_start_date[' . $i . ']', ts('Discount Start Date'), FALSE, array('formatType' => 'activityDate')); //discount end date $this->addDate('discount_end_date[' . $i . ']', ts('Discount End Date'), FALSE, array('formatType' => 'activityDate')); } $_showHide->addToTemplate(); $this->addElement('submit', $this->getButtonName('submit'), ts('Add Discount Set to Fee Table'), array('class' => 'form-submit')); $this->buildAmountLabel(); parent::buildQuickForm(); }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } // build price set form. $buildPriceSet = FALSE; if (empty($this->_lineItems) && ($this->_priceSetId || CRM_Utils_Array::value('price_set_id', $_POST))) { $buildPriceSet = TRUE; $getOnlyPriceSetElements = TRUE; if (!$this->_priceSetId) { $this->_priceSetId = $_POST['price_set_id']; $getOnlyPriceSetElements = FALSE; } $this->set('priceSetId', $this->_priceSetId); CRM_Price_BAO_Set::buildPriceSet($this); // get only price set form elements. if ($getOnlyPriceSetElements) { return; } } // use to build form during form rule. $this->assign('buildPriceSet', $buildPriceSet); $showAdditionalInfo = FALSE; $defaults = $this->_values; $additionalDetailFields = array('note', 'thankyou_date', 'invoice_id', 'non_deductible_amount', 'fee_amount', 'net_amount'); foreach ($additionalDetailFields as $key) { if (!empty($defaults[$key])) { $defaults['hidden_AdditionalDetail'] = 1; break; } } $honorFields = array('honor_type_id', 'honor_prefix_id', 'honor_first_name', 'honor_lastname', 'honor_email'); foreach ($honorFields as $key) { if (!empty($defaults[$key])) { $defaults['hidden_Honoree'] = 1; break; } } //check for honoree pane. if ($this->_ppID && CRM_Utils_Array::value('honor_contact_id', $this->_pledgeValues)) { $defaults['hidden_Honoree'] = 1; } if ($this->_productDAO) { if ($this->_productDAO->product_id) { $defaults['hidden_Premium'] = 1; } } if ($this->_noteID && isset($this->_values['note'])) { $defaults['hidden_AdditionalDetail'] = 1; } $paneNames = array(ts('Additional Details') => 'AdditionalDetail', ts('Honoree Information') => 'Honoree'); //Add Premium pane only if Premium is exists. $dao = new CRM_Contribute_DAO_Product(); $dao->is_active = 1; if ($dao->find(TRUE)) { $paneNames[ts('Premium Information')] = 'Premium'; } $ccPane = NULL; if ($this->_mode) { if (CRM_Utils_Array::value('payment_type', $this->_processors) & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) { $ccPane = array(ts('Direct Debit Information') => 'DirectDebit'); } else { $ccPane = array(ts('Credit Card Information') => 'CreditCard'); } } if (is_array($ccPane)) { $paneNames = array_merge($ccPane, $paneNames); } $buildRecurBlock = FALSE; foreach ($paneNames as $name => $type) { $urlParams = "snippet=4&formType={$type}"; if ($this->_mode) { $urlParams .= "&mode={$this->_mode}"; } $open = 'false'; if ($type == 'CreditCard' || $type == 'DirectDebit') { $open = 'true'; } $allPanes[$name] = array('url' => CRM_Utils_System::url('civicrm/contact/view/contribution', $urlParams), 'open' => $open, 'id' => $type); // see if we need to include this paneName in the current form if ($this->_formType == $type || CRM_Utils_Array::value("hidden_{$type}", $_POST) || CRM_Utils_Array::value("hidden_{$type}", $defaults)) { $showAdditionalInfo = TRUE; $allPanes[$name]['open'] = 'true'; } if ($type == 'CreditCard') { $buildRecurBlock = TRUE; $this->add('hidden', 'hidden_CreditCard', 1); CRM_Core_Payment_Form::buildCreditCard($this, TRUE); } elseif ($type == 'DirectDebit') { $buildRecurBlock = TRUE; $this->add('hidden', 'hidden_DirectDebit', 1); CRM_Core_Payment_Form::buildDirectDebit($this, TRUE); } else { eval('CRM_Contribute_Form_AdditionalInfo::build' . $type . '( $this );'); } } if (empty($this->_recurPaymentProcessors)) { $buildRecurBlock = FALSE; } if ($buildRecurBlock) { CRM_Contribute_Form_Contribution_Main::buildRecur($this); $this->setDefaults(array('is_recur' => 0)); } $this->assign('buildRecurBlock', $buildRecurBlock); $qfKey = $this->controller->_key; $this->assign('qfKey', $qfKey); $this->assign('allPanes', $allPanes); $this->assign('showAdditionalInfo', $showAdditionalInfo); if ($this->_formType) { $this->assign('formType', $this->_formType); return; } $this->applyFilter('__ALL__', 'trim'); if ($this->_action & CRM_Core_Action::DELETE) { $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } //need to assign custom data type and subtype to the template $this->assign('customDataType', 'Contribution'); $this->assign('customDataSubType', $this->_contributionType); $this->assign('entityID', $this->_id); if ($this->_context == 'standalone') { CRM_Contact_Form_NewContact::buildQuickForm($this); } $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution'); $element = $this->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType(), TRUE, array('onChange' => "buildCustomData( 'Contribution', this.value );")); if ($this->_online) { $element->freeze(); } if (!$this->_mode) { $element = $this->add('select', 'payment_instrument_id', ts('Paid By'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), FALSE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")); if ($this->_online) { $element->freeze(); } } $element = $this->add('text', 'trxn_id', ts('Transaction ID'), $attributes['trxn_id']); if ($this->_online) { $element->freeze(); } else { $this->addRule('trxn_id', ts('This Transaction ID already exists in the database. Include the account number for checks.'), 'objectExists', array('CRM_Contribute_DAO_Contribution', $this->_id, 'trxn_id')); } //add receipt for offline contribution $this->addElement('checkbox', 'is_email_receipt', ts('Send Receipt?')); $this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails); $status = CRM_Contribute_PseudoConstant::contributionStatus(); // supressing contribution statuses that are NOT relevant to pledges (CRM-5169) if ($this->_ppID) { $statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); foreach (array('Cancelled', 'Failed', 'In Progress') as $supress) { unset($status[CRM_Utils_Array::key($supress, $statusName)]); } } $this->add('select', 'contribution_status_id', ts('Contribution Status'), $status, FALSE, array('onClick' => "if (this.value != 3) { status();} else return false", 'onChange' => "return showHideByValue('contribution_status_id','3','cancelInfo','table-row','select',false);")); // add various dates $this->addDateTime('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime')); if ($this->_online) { $this->assign('hideCalender', TRUE); } $element = $this->add('text', 'check_number', ts('Check Number'), $attributes['check_number']); if ($this->_online) { $element->freeze(); } $this->addDateTime('receipt_date', ts('Receipt Date'), FALSE, array('formatType' => 'activityDateTime')); $this->addDateTime('cancel_date', ts('Cancelled Date'), FALSE, array('formatType' => 'activityDateTime')); $this->add('textarea', 'cancel_reason', ts('Cancellation Reason'), $attributes['cancel_reason']); $recurJs = NULL; if ($buildRecurBlock) { $recurJs = array('onChange' => "buildRecurBlock( this.value ); return false;"); } $element = $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, NULL, $recurJs); if ($this->_online) { $element->freeze(); } if (empty($this->_lineItems)) { $buildPriceSet = FALSE; $priceSets = CRM_Price_BAO_Set::getAssoc(FALSE, 'CiviContribute'); if (!empty($priceSets) && !$this->_ppID) { $buildPriceSet = TRUE; } // don't allow price set for contribution if it is related to participant, or if it is a pledge payment // and if we already have line items for that participant. CRM-5095 if ($buildPriceSet && $this->_id) { $componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id); $pledgePaymentId = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $this->_id, 'id', 'contribution_id'); if ($pledgePaymentId) { $buildPriceSet = FALSE; } if ($participantID = CRM_Utils_Array::value('participant', $componentDetails)) { $participantLI = CRM_Price_BAO_LineItem::getLineItems($participantID); if (!CRM_Utils_System::isNull($participantLI)) { $buildPriceSet = FALSE; } } } $hasPriceSets = FALSE; if ($buildPriceSet) { $hasPriceSets = TRUE; $element = $this->add('select', 'price_set_id', ts('Choose price set'), array('' => ts('Choose price set')) + $priceSets, NULL, array('onchange' => "buildAmount( this.value );")); if ($this->_online) { $element->freeze(); } } $this->assign('hasPriceSets', $hasPriceSets); $currencyFreeze = FALSE; if ($this->_online || $this->_ppID) { $attributes['total_amount'] = array_merge($attributes['total_amount'], array('READONLY' => TRUE, 'style' => "background-color:#EBECE4")); $optionTypes = array('1' => ts('Adjust Pledge Payment Schedule?'), '2' => ts('Adjust Total Pledge Amount?')); $element = $this->addRadio('option_type', NULL, $optionTypes, array(), '<br/>'); $currencyFreeze = TRUE; } $element = $this->addMoney('total_amount', ts('Total Amount'), $hasPriceSets ? FALSE : TRUE, $attributes['total_amount'], TRUE, 'currency', NULL, $currencyFreeze); } $element = $this->add('text', 'source', ts('Source'), CRM_Utils_Array::value('source', $attributes)); //CRM-7362 --add campaigns. CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values)); // CRM-7368 allow user to set or edit PCP link for contributions $siteHasPCPs = CRM_Contribute_PseudoConstant::pcPage(); if (!CRM_Utils_Array::crmIsEmptyArray($siteHasPCPs)) { $this->assign('siteHasPCPs', 1); $pcpDataUrl = CRM_Utils_System::url('civicrm/ajax/rest', "className=CRM_Contact_Page_AJAX&fnName=getPCPList&json=1&context=contact&reset=1", FALSE, NULL, FALSE); $this->assign('pcpDataUrl', $pcpDataUrl); $this->addElement('text', 'pcp_made_through', ts('Credit to a Personal Campaign Page')); $this->addElement('hidden', 'pcp_made_through_id', '', array('id' => 'pcp_made_through_id')); $this->addElement('checkbox', 'pcp_display_in_roll', ts('Display in Honor Roll?'), NULL); $this->addElement('text', 'pcp_roll_nickname', ts('Name (for Honor Roll)')); $this->addElement('textarea', 'pcp_personal_note', ts('Personal Note (for Honor Roll)')); } $dataUrl = CRM_Utils_System::url('civicrm/ajax/rest', "className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=contact&reset=1&context=softcredit&id={$this->_id}", FALSE, NULL, FALSE); $this->assign('dataUrl', $dataUrl); $this->addElement('text', 'soft_credit_to', ts('Soft Credit To')); // Tell tpl to hide Soft Credit field if contribution is linked directly to a PCP Page if (CRM_Utils_Array::value('pcp_made_through_id', $this->_values)) { $this->assign('pcpLinked', 1); } $this->addElement('hidden', 'soft_contact_id', '', array('id' => 'soft_contact_id')); $js = NULL; if (!$this->_mode) { $js = array('onclick' => "return verify( );"); } $mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend'); $this->assign('outBound_option', $mailingInfo['outBound_option']); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'js' => $js, 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save and New'), 'js' => $js, 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel')))); $this->addFormRule(array('CRM_Contribute_Form_Contribution', 'formRule'), $this); if ($this->_action & CRM_Core_Action::VIEW) { $this->freeze(); } }
/** * Function to actually build the form * * @return void * @access public */ public function buildQuickForm() { $membershipTypes = CRM_Member_BAO_MembershipType::getMembershipTypes(); if (!empty($membershipTypes)) { $this->addElement('checkbox', 'member_is_active', ts('Membership Section Enabled?')); $this->addElement('text', 'new_title', ts('Title - New Membership'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'new_title')); $this->addWysiwyg('new_text', ts('Introductory Message - New Memberships'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'new_text')); $this->addElement('text', 'renewal_title', ts('Title - Renewals'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'renewal_title')); $this->addWysiwyg('renewal_text', ts('Introductory Message - Renewals'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'renewal_text')); $this->addElement('checkbox', 'is_required', ts('Require Membership Signup')); $this->addElement('checkbox', 'display_min_fee', ts('Display Membership Fee')); $this->addElement('checkbox', 'is_separate_payment', ts('Separate Membership Payment')); $paymentProcessor = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, 'is_recur = 1'); $paymentProcessorIds = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'payment_processor'); $paymentProcessorId = explode(CRM_Core_DAO::VALUE_SEPARATOR, $paymentProcessorIds); $isRecur = TRUE; foreach ($paymentProcessorId as $dontCare => $id) { if (!array_key_exists($id, $paymentProcessor)) { $isRecur = FALSE; continue; } } $membership = $membershipDefault = array(); foreach ($membershipTypes as $k => $v) { $membership[] = $this->createElement('advcheckbox', $k, NULL, $v); $membershipDefault[] = $this->createElement('radio', NULL, NULL, NULL, $k); if ($isRecur) { $autoRenew = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $k, 'auto_renew'); $autoRenewOptions = array(); if ($autoRenew) { $autoRenewOptions = array(ts('Not offered'), ts('Give option'), ts('Required')); $this->addElement('select', "auto_renew_{$k}", ts('Auto-renew'), $autoRenewOptions); $this->_renewOption[$k] = $autoRenew; } } } $this->add('hidden', "mem_price_field_id", '', array('id' => "mem_price_field_id")); $this->assign('is_recur', $isRecur); if (isset($this->_renewOption)) { $this->assign('auto_renew', $this->_renewOption); } $this->addGroup($membership, 'membership_type', ts('Membership Types')); $this->addGroup($membershipDefault, 'membership_type_default', ts('Membership Types Default')); $this->addFormRule(array('CRM_Member_Form_MembershipBlock', 'formRule'), $this->_id); } $price = CRM_Price_BAO_Set::getAssoc(FALSE, 'CiviMember'); if (CRM_Utils_System::isNull($price)) { $this->assign('price', FALSE); } else { $this->assign('price', TRUE); } $this->add('select', 'member_price_set_id', ts('Membership Price Set'), array('' => ts('- none -')) + $price); $session = CRM_Core_Session::singleton(); $single = $session->get('singleForm'); if ($single) { $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); } else { parent::buildQuickForm(); } }