/** * Function to build the form * * @return void * @access public */ public function buildQuickForm() { if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } parent::buildQuickForm(); $defaults = array(); $defaults = parent::setDefaultValues(); $this->_memType = $defaults['membership_type_id']; $this->assign('customDataType', 'Membership'); $this->assign('customDataSubType', $this->_memType); $this->assign('entityID', $this->_id); $selOrgMemType[0][0] = $selMemTypeOrg[0] = ts('- select -'); $allMemberships = CRM_Member_BAO_Membership::buildMembershipTypeValues($this); $allMembershipInfo = $membershipType = array(); // auto renew options if enabled for the membership $options = array(ts('No auto-renew option'), ts('Give option, but not required'), ts('Auto-renew required ')); foreach ($allMemberships as $key => $values) { if (!empty($values['is_active'])) { $membershipType[$key] = CRM_Utils_Array::value('name', $values); if ($this->_mode && empty($values['minimum_fee'])) { continue; } else { $memberOfContactId = CRM_Utils_Array::value('member_of_contact_id', $values); if (empty($selMemTypeOrg[$memberOfContactId])) { $selMemTypeOrg[$memberOfContactId] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $memberOfContactId, 'display_name', 'id'); $selOrgMemType[$memberOfContactId][0] = ts('- select -'); } if (empty($selOrgMemType[$memberOfContactId][$key])) { $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('financial_type_id' => CRM_Utils_Array::value('financial_type_id', $values), 'total_amount' => CRM_Utils_Money::format($values['minimum_fee'], NULL, '%a'), 'total_amount_numeric' => CRM_Utils_Array::value('minimum_fee', $values)); if (!empty($values['auto_renew'])) { $allMembershipInfo[$key]['auto_renew'] = $options[$values['auto_renew']]; } } } $this->assign('allMembershipInfo', json_encode($allMembershipInfo)); if ($this->_memType) { $this->assign('orgName', $selMemTypeOrg[$allMemberships[$this->_memType]['member_of_contact_id']]); $this->assign('memType', $allMemberships[$this->_memType]['name']); } // force select of 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; } $js = array('onChange' => "setPaymentBlock( ); CRM.buildCustomData( 'Membership', this.value );"); //build the form for auto renew. $recurProcessor = array(); if ($this->_mode || $this->_action & CRM_Core_Action::UPDATE) { //get the valid recurring processors. $recurring = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, 'is_recur = 1'); $recurProcessor = array_intersect_assoc($this->_processors, $recurring); if (!empty($recurProcessor)) { $autoRenew = array(); 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}; } } } $js = array('onChange' => "setPaymentBlock(); CRM.buildCustomData( 'Membership', this.value );"); $this->assign('autoRenew', json_encode($autoRenew)); } $autoRenewElement = $this->addElement('checkbox', 'auto_renew', ts('Membership renewed automatically'), NULL, array('onclick' => "showHideByValue('auto_renew','','send-receipt','table-row','radio',true); showHideNotice( );")); if ($this->_action & CRM_Core_Action::UPDATE) { $autoRenewElement->freeze(); } } $this->assign('recurProcessor', json_encode($recurProcessor)); $sel =& $this->addElement('hierselect', 'membership_type_id', ts('Renewal Membership Organization and Type'), $js); $sel->setOptions(array($selMemTypeOrg, $selOrgMemType)); $elements = array(); if ($sel) { $elements[] = $sel; } $this->applyFilter('__ALL__', 'trim'); $this->addDate('renewal_date', ts('Date Renewal Entered'), FALSE, array('formatType' => 'activityDate')); $this->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType()); if (CRM_Core_Permission::access('CiviContribute') && !$this->_mode) { $this->addElement('checkbox', 'record_contribution', ts('Record Renewal Payment?'), NULL, array('onclick' => "checkPayment();")); $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' => 'activityDateTime')); $this->add('text', 'num_terms', ts('Extend Membership by'), array('onchange' => "setPaymentBlock();"), TRUE); $this->addRule('num_terms', ts('Please enter a whole number for how many periods to renew.'), 'integer'); $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')); $this->add('select', 'contribution_status_id', ts('Payment Status'), CRM_Contribute_PseudoConstant::contributionStatus()); $this->add('text', 'check_number', ts('Check Number'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'check_number')); } else { $this->add('text', 'total_amount', ts('Amount')); $this->addRule('total_amount', ts('Please enter a valid amount.'), 'money'); } $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_renewal', ts('Renewal Message')); if ($this->_mode) { $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, TRUE); CRM_Core_Payment_Form::buildCreditCard($this, TRUE); } // Retrieve the name and email of the contact - this will be the TO for receipt email list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID); $this->assign('email', $this->_contributorEmail); $mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend'); $this->assign('outBound_option', $mailingInfo['outBound_option']); if (CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id, 'contribution_recur_id')) { if (CRM_Member_BAO_Membership::isCancelSubscriptionSupported($this->_id)) { $this->assign('cancelAutoRenew', CRM_Utils_System::url('civicrm/contribute/unsubscribe', "reset=1&mid={$this->_id}")); } } $this->addFormRule(array('CRM_Member_Form_MembershipRenewal', 'formRule')); 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', 'contribution_contact', ts('Record Payment from a Different Contact?')); $this->add('select', 'soft_credit_type_id', ts('Membership payment is : '), array('' => ts('- Select - ')) + CRM_Core_OptionGroup::values("soft_credit_type", FALSE)); require_once 'CRM/Contact/Form/NewContact.php'; CRM_Contact_Form_NewContact::buildQuickForm($this, 1, null, false, 'contribution_'); } }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { parent::buildQuickForm(); $this->applyFilter('__ALL__', 'trim'); $this->addDate('renewal_date', ts('Date Renewal Entered'), false, array('formatType' => 'activityDate')); if (!$this->_mode) { $this->addElement('checkbox', 'record_contribution', ts('Record Renewal Payment?'), null, array('onclick' => "checkPayment();")); require_once 'CRM/Contribute/PseudoConstant.php'; $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->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')); $this->add('select', 'contribution_status_id', ts('Payment Status'), CRM_Contribute_PseudoConstant::contributionStatus()); $this->add('text', 'check_number', ts('Check Number'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'check_number')); } $this->addElement('checkbox', 'send_receipt', ts('Send Confirmation and Receipt?'), null, array('onclick' => "return showHideByValue('send_receipt','','notice','table-row','radio',false);")); $this->add('textarea', 'receipt_text_renewal', ts('Renewal Message')); if ($this->_mode) { $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, true); require_once 'CRM/Core/Payment/Form.php'; CRM_Core_Payment_Form::buildCreditCard($this, true); } require_once 'CRM/Contact/BAO/Contact/Location.php'; // Retrieve the name and email of the contact - this will be the TO for receipt email list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID); $this->assign('email', $this->_contributorEmail); require_once "CRM/Core/BAO/Preferences.php"; $mailingInfo =& CRM_Core_BAO_Preferences::mailingPreferences(); $this->assign('outBound_option', $mailingInfo['outBound_option']); $this->addFormRule(array('CRM_Member_Form_MembershipRenewal', 'formRule')); }
public function buildQuickForm() { $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'); } $defaults = $this->_values; $showAdditionalInfo = FALSE; foreach ($ccPane as $name => $type) { if ($this->_formType == $type || !empty($_POST["hidden_{$type}"]) || CRM_Utils_Array::value("hidden_{$type}", $defaults)) { $showAdditionalInfo = TRUE; $allPanes[$name]['open'] = 'true'; } $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/payment/add', $urlParams), 'open' => $open, 'id' => $type); if ($type == 'CreditCard') { $this->add('hidden', 'hidden_CreditCard', 1); CRM_Core_Payment_Form::buildCreditCard($this, TRUE); } elseif ($type == 'DirectDebit') { $this->add('hidden', 'hidden_DirectDebit', 1); CRM_Core_Payment_Form::buildDirectDebit($this, TRUE); } $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; } } } $attributes = CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialTrxn'); $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, NULL); $this->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(), TRUE); $label = $this->_refund ? 'Refund Amount' : 'Payment Amount'; $this->addMoney('total_amount', ts('%1', array(1 => $label)), FALSE, $attributes['total_amount'], TRUE, 'currency', NULL); if (!$this->_mode) { $this->add('select', 'payment_instrument_id', ts('Paid By'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), TRUE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")); } $this->add('text', 'check_number', ts('Check Number'), $attributes['financial_trxn_check_number']); $trxnId = $this->add('text', 'trxn_id', ts('Transaction ID'), $attributes['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['from_email_id']); $this->add('textarea', 'receipt_text', ts('Confirmation Message')); // add various dates $this->addDateTime('trxn_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime')); if ($this->_contactId && $this->_id) { if ($this->_component == 'event') { $eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'event_id', 'id'); $event = CRM_Event_BAO_Event::getEvents(0, $eventId); $this->assign('eventName', $event[$eventId]); } } $this->assign('displayName', $this->_contributorDisplayName); $this->assign('component', $this->_component); $this->assign('email', $this->_contributorEmail); $this->add('text', 'fee_amount', ts('Fee Amount'), $attributes['fee_amount']); $this->addRule('fee_amount', ts('Please enter a valid monetary value for Fee Amount.'), 'money'); $this->add('text', 'net_amount', ts('Net Amount'), $attributes['net_amount']); $this->addRule('net_amount', ts('Please enter a valid monetary value for Net Amount.'), 'money'); $js = NULL; if (!$this->_mode) { $js = array('onclick' => "return verify( );"); } $buttonName = $this->_refund ? 'Record Refund' : 'Record Payment'; $this->addButtons(array(array('type' => 'upload', 'name' => ts('%1', array(1 => $buttonName)), 'js' => $js, 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); $mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend'); $this->assign('outBound_option', $mailingInfo['outBound_option']); $this->addFormRule(array('CRM_Contribute_Form_AdditionalPayment', 'formRule'), $this); }
/** * Function to build the form * * @return void * @access public */ public function buildQuickForm() { $type = 'next'; if ($this->_selfService) { $type = 'submit'; } $this->addButtons(array(array('type' => $type, 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); CRM_Core_Payment_Form::buildCreditCard($this); $this->addFormRule(array('CRM_Contribute_Form_UpdateBilling', 'formRule'), $this); }
/** * Function to build the form * * @return void * @access public */ public function buildQuickForm() { if ($this->_cdType) { CRM_Custom_Form_CustomData::buildQuickForm($this); return; } $allPanes = array(); // build price set form. $buildPriceSet = FALSE; if (empty($this->_lineItems) && ($this->_priceSetId || !empty($_POST['price_set_id']))) { $buildPriceSet = TRUE; $getOnlyPriceSetElements = TRUE; if (!$this->_priceSetId) { $this->_priceSetId = $_POST['price_set_id']; $getOnlyPriceSetElements = FALSE; } $this->set('priceSetId', $this->_priceSetId); CRM_Price_BAO_PriceSet::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; } } 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'); //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 || !empty($_POST["hidden_{$type}"]) || 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 { $additionalInfoFormFunction = 'build' . $type; CRM_Contribute_Form_AdditionalInfo::$additionalInfoFormFunction($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') { $this->addEntityRef('contact_id', ts('Contact'), array('create' => TRUE, 'api' => array('extra' => array('email'))), TRUE); } $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution'); $financialType = $this->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(), TRUE, array('onChange' => "CRM.buildCustomData( 'Contribution', this.value );")); $paymentInstrument = FALSE; if (!$this->_mode) { $paymentInstrument = $this->add('select', 'payment_instrument_id', ts('Paid By'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), TRUE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")); } $trxnId = $this->add('text', 'trxn_id', ts('Transaction ID'), array('class' => 'twelve') + $attributes['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(); // suppressing contribution statuses that are NOT relevant to pledges (CRM-5169) $statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); if ($this->_ppID) { foreach (array('Cancelled', 'Failed', 'In Progress') as $suppress) { unset($status[CRM_Utils_Array::key($suppress, $statusName)]); } } elseif (!$this->_ppID && $this->_id || !$this->_id) { $suppressFlag = FALSE; if ($this->_id) { $componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id); if (CRM_Utils_Array::value('membership', $componentDetails) || CRM_Utils_Array::value('participant', $componentDetails)) { $suppressFlag = TRUE; } } if (!$suppressFlag) { foreach (array('Overdue', 'In Progress') as $suppress) { unset($status[CRM_Utils_Array::key($suppress, $statusName)]); } } else { unset($status[CRM_Utils_Array::key('Overdue', $statusName)]); } } if ($this->_id) { $contributionStatus = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $this->_id, 'contribution_status_id'); $name = CRM_Utils_Array::value($contributionStatus, $statusName); switch ($name) { case 'Completed': case 'Cancelled': case 'Refunded': unset($status[CRM_Utils_Array::key('In Progress', $statusName)]); unset($status[CRM_Utils_Array::key('Pending', $statusName)]); unset($status[CRM_Utils_Array::key('Failed', $statusName)]); break; case 'Pending': case 'In Progress': unset($status[CRM_Utils_Array::key('Refunded', $statusName)]); break; case 'Failed': foreach (array('Pending', 'Refunded', 'Completed', 'In Progress', 'Cancelled') as $suppress) { unset($status[CRM_Utils_Array::key($suppress, $statusName)]); } break; } } else { unset($status[CRM_Utils_Array::key('Refunded', $statusName)]); } $this->add('select', 'contribution_status_id', ts('Contribution Status'), $status, FALSE); // add various dates $this->addDateTime('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime')); if ($this->_online) { $this->assign('hideCalender', TRUE); } $checkNumber = $this->add('text', 'check_number', ts('Check Number'), $attributes['check_number']); $this->addDateTime('receipt_date', ts('Receipt Date'), FALSE, array('formatType' => 'activityDateTime')); $this->addDateTime('cancel_date', ts('Cancelled / Refunded Date'), FALSE, array('formatType' => 'activityDateTime')); $this->add('textarea', 'cancel_reason', ts('Cancellation / Refund 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(); } $totalAmount = NULL; if (empty($this->_lineItems)) { $buildPriceSet = FALSE; $priceSets = CRM_Price_BAO_PriceSet::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 && !($this->_action & CRM_Core_Action::UPDATE)) { $element->freeze(); } } $this->assign('hasPriceSets', $hasPriceSets); $currencyFreeze = FALSE; if (!($this->_action & CRM_Core_Action::UPDATE)) { 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?')); $this->addRadio('option_type', NULL, $optionTypes, array(), '<br/>'); $currencyFreeze = TRUE; } } $totalAmount = $this->addMoney('total_amount', ts('Total Amount'), $hasPriceSets ? FALSE : TRUE, $attributes['total_amount'], TRUE, 'currency', NULL, $currencyFreeze); } $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_Contribute_Form_SoftCredit::buildQuickForm($this); $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')))); // if status is Cancelled freeze Amount, Payment Instrument, Check #, Financial Type, // Net and Fee Amounts are frozen in AdditionalInfo::buildAdditionalDetail if ($this->_id && $this->_values['contribution_status_id'] == array_search('Cancelled', $statusName)) { if ($totalAmount) { $totalAmount->freeze(); } $checkNumber->freeze(); $paymentInstrument->freeze(); $trxnId->freeze(); $financialType->freeze(); } $this->addFormRule(array('CRM_Contribute_Form_Contribution', 'formRule'), $this); if ($this->_action & CRM_Core_Action::VIEW) { $this->freeze(); } }
/** * Function to build the form * * @param $form * * @return void * @access public */ static function buildQuickForm(&$form) { if ($form->_eventId) { $form->_isPaidEvent = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $form->_eventId, 'is_monetary'); if ($form->_isPaidEvent) { $form->addElement('hidden', 'hidden_feeblock', 1); } // make sure this is for backoffice registration. if ($form->getName() == 'Participant') { $eventfullMsg = CRM_Event_BAO_Participant::eventFullMessage($form->_eventId, $form->_pId); $form->addElement('hidden', 'hidden_eventFullMsg', $eventfullMsg, array('id' => 'hidden_eventFullMsg')); } } if ($form->_pId) { if (CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $form->_pId, 'contribution_id', 'participant_id')) { $form->_online = TRUE; } } if ($form->_isPaidEvent) { $params = array('id' => $form->_eventId); CRM_Event_BAO_Event::retrieve($params, $event); //retrieve custom information $form->_values = array(); CRM_Event_Form_Registration::initEventFee($form, $event['id']); CRM_Event_Form_Registration_Register::buildAmount($form, TRUE, $form->_discountId); $lineItem = array(); if (!CRM_Utils_System::isNull(CRM_Utils_Array::value('line_items', $form->_values))) { $lineItem[] = $form->_values['line_items']; } $form->assign('lineItem', empty($lineItem) ? FALSE : $lineItem); $discounts = array(); if (!empty($form->_values['discount'])) { foreach ($form->_values['discount'] as $key => $value) { $value = current($value); $discounts[$key] = $value['name']; } $element = $form->add('select', 'discount_id', ts('Discount Set'), array(0 => ts('- select -')) + $discounts, FALSE, array('onchange' => "buildFeeBlock( {$form->_eventId}, this.value );")); if ($form->_online) { $element->freeze(); } } if ($form->_mode) { CRM_Core_Payment_Form::buildCreditCard($form, TRUE); } elseif (!$form->_mode) { $form->addElement('checkbox', 'record_contribution', ts('Record Payment?'), NULL, array('onclick' => "return showHideByValue('record_contribution','','payment_information','table-row','radio',false);")); $form->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType()); $form->addDate('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDate')); $form->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);")); // don't show transaction id in batch update mode $path = CRM_Utils_System::currentPath(); $form->assign('showTransactionId', FALSE); if ($path != 'civicrm/contact/search/basic') { $form->add('text', 'trxn_id', ts('Transaction ID')); $form->addRule('trxn_id', ts('Transaction ID already exists in Database.'), 'objectExists', array('CRM_Contribute_DAO_Contribution', $form->_eventId, 'trxn_id')); $form->assign('showTransactionId', TRUE); } $status = CRM_Contribute_PseudoConstant::contributionStatus(); // CRM-14417 suppressing contribution statuses that are NOT relevant to new participant registrations $statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); foreach (array('Cancelled', 'Failed', 'In Progress', 'Overdue', 'Refunded', 'Pending refund') as $suppress) { unset($status[CRM_Utils_Array::key($suppress, $statusName)]); } $form->add('select', 'contribution_status_id', ts('Payment Status'), $status); $form->add('text', 'check_number', ts('Check Number'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'check_number')); $form->add('text', 'total_amount', ts('Amount'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'total_amount')); } } else { $form->add('text', 'amount', ts('Event Fee(s)')); } $form->assign('onlinePendingContributionId', $form->get('onlinePendingContributionId')); $form->assign('paid', $form->_isPaidEvent); $form->addElement('checkbox', 'send_receipt', ts('Send Confirmation?'), NULL, array('onclick' => "showHideByValue('send_receipt','','notice','table-row','radio',false); showHideByValue('send_receipt','','from-email','table-row','radio',false);")); $form->add('select', 'from_email_address', ts('Receipt From'), $form->_fromEmails['from_email_id']); $form->add('textarea', 'receipt_text', ts('Confirmation Message')); // Retrieve the name and email of the contact - form will be the TO for receipt email ( only if context is not standalone) if ($form->_context != 'standalone') { if ($form->_contactId) { list($form->_contributorDisplayName, $form->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($form->_contactId); $form->assign('email', $form->_contributorEmail); } else { //show email block for batch update for event $form->assign('batchEmail', TRUE); } } $mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend'); $form->assign('outBound_option', $mailingInfo['outBound_option']); $form->assign('hasPayment', $form->_paymentId); }
/** * Function to build the form * * @return None * @access public */ static function buildQuickForm(&$form) { if ($form->_eventId) { $form->_isPaidEvent = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $form->_eventId, 'is_monetary'); if ($form->_isPaidEvent) { $form->addElement('hidden', 'hidden_feeblock', 1); } // make sure this is for backoffice registration. if ($form->getName() == 'Participant') { require_once "CRM/Event/BAO/Participant.php"; $eventfullMsg = CRM_Event_BAO_Participant::eventFullMessage($form->_eventId, $form->_pId); $form->addElement('hidden', 'hidden_eventFullMsg', $eventfullMsg, array('id' => 'hidden_eventFullMsg')); } } if ($form->_pId) { if (CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $form->_pId, 'contribution_id', 'participant_id')) { $form->_online = true; } } if ($form->_isPaidEvent) { require_once "CRM/Event/BAO/Event.php"; $params = array('id' => $form->_eventId); CRM_Event_BAO_Event::retrieve($params, $event); //retrieve custom information $form->_values = array(); require_once "CRM/Event/Form/Registration/Register.php"; CRM_Event_Form_Registration::initPriceSet($form, $event['id']); CRM_Event_Form_Registration_Register::buildAmount($form, true, $form->_discountId); $lineItem = array(); if (!CRM_Utils_System::isNull(CRM_Utils_Array::value('line_items', $form->_values))) { $lineItem[] = $form->_values['line_items']; } $form->assign('lineItem', empty($lineItem) ? false : $lineItem); $discounts = array(); if (!empty($form->_values['discount'])) { foreach ($form->_values['discount'] as $key => $value) { $discounts[$key] = $value['name']; } $element = $form->add('select', 'discount_id', ts('Discount Set'), array(0 => ts('- select -')) + $discounts, false, array('onchange' => "buildFeeBlock( {$form->_eventId}, this.value );")); if ($form->_online) { $element->freeze(); } } if ($form->_mode) { require_once 'CRM/Core/Payment/Form.php'; CRM_Core_Payment_Form::buildCreditCard($form, true); } else { if (!$form->_mode) { $form->addElement('checkbox', 'record_contribution', ts('Record Payment?'), null, array('onclick' => "return showHideByValue('record_contribution','','payment_information','table-row','radio',false);")); require_once 'CRM/Contribute/PseudoConstant.php'; $form->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType()); $form->addDate('receive_date', ts('Received'), false, array('formatType' => 'activityDate')); $form->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);")); // don't show transaction id in batch update mode $path = CRM_Utils_System::currentPath(); $form->assign('showTransactionId', false); if ($path != 'civicrm/contact/search/basic') { $form->add('text', 'trxn_id', ts('Transaction ID')); $form->addRule('trxn_id', ts('Transaction ID already exists in Database.'), 'objectExists', array('CRM_Contribute_DAO_Contribution', $form->_eventId, 'trxn_id')); $form->assign('showTransactionId', true); } $allowStatuses = array(); $statuses = CRM_Contribute_PseudoConstant::contributionStatus(); if ($form->get('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; } $form->add('select', 'contribution_status_id', ts('Payment Status'), $allowStatuses); $form->add('text', 'check_number', ts('Check Number'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'check_number')); } } } else { $form->add('text', 'amount', ts('Event Fee(s)')); } $form->assign('onlinePendingContributionId', $form->get('onlinePendingContributionId')); $form->assign("paid", $form->_isPaidEvent); $form->addElement('checkbox', 'send_receipt', ts('Send Confirmation?'), null, array('onclick' => "return showHideByValue('send_receipt','','notice','table-row','radio',false);")); $form->add('textarea', 'receipt_text', ts('Confirmation Message')); // Retrieve the name and email of the contact - form will be the TO for receipt email ( only if context is not standalone) if ($form->_context != 'standalone') { if ($form->_contactID) { list($form->_contributorDisplayName, $form->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($form->_contactID); $form->assign('email', $form->_contributorEmail); } else { //show email block for batch update for event $form->assign('batchEmail', true); } } require_once "CRM/Core/BAO/Preferences.php"; $mailingInfo =& CRM_Core_BAO_Preferences::mailingPreferences(); $form->assign('outBound_option', $mailingInfo['outBound_option']); }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } //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') { require_once 'CRM/Contact/Form/NewContact.php'; CRM_Contact_Form_NewContact::buildQuickForm($this); } $selOrgMemType[0][0] = $selMemTypeOrg[0] = ts('- select -'); $dao =& new CRM_Member_DAO_MembershipType(); $dao->find(); while ($dao->fetch()) { if ($dao->is_active) { if ($this->_mode && !$dao->minimum_fee) { continue; } else { if (!CRM_Utils_Array::value($dao->member_of_contact_id, $selMemTypeOrg)) { $selMemTypeOrg[$dao->member_of_contact_id] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $dao->member_of_contact_id, 'display_name', 'id'); $selOrgMemType[$dao->member_of_contact_id][0] = ts('- select -'); } if (!CRM_Utils_Array::value($dao->id, $selOrgMemType[$dao->member_of_contact_id])) { $selOrgMemType[$dao->member_of_contact_id][$dao->id] = $dao->name; } } } } // show organization by default, if only one organization in // the list if (count($selMemTypeOrg) == 2) { unset($selMemTypeOrg[0], $selOrgMemType[0][0]); } $sel =& $this->addElement('hierselect', 'membership_type_id', ts('Membership Organization and Type'), array('onChange' => "buildCustomData( 'Membership', this.value ); setPaymentBlock( this.value );")); $sel->setOptions(array($selMemTypeOrg, $selOrgMemType)); $this->applyFilter('__ALL__', 'trim'); $this->addDate('join_date', ts('Join Date'), false, array('formatType' => 'activityDate')); $this->addDate('start_date', ts('Start Date'), false, array('formatType' => 'activityDate')); $this->addDate('end_date', ts('End Date'), false, array('formatType' => 'activityDate')); $this->add('text', 'source', ts('Source'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_Membership', 'source')); if (!$this->_mode) { $this->add('select', 'status_id', ts('Membership Status'), array('' => ts('- select -')) + CRM_Member_PseudoConstant::membershipStatus()); $this->addElement('checkbox', 'is_override', ts('Status Override?'), null, array('onClick' => 'showHideMemberStatus()')); $this->addElement('checkbox', 'record_contribution', ts('Record Membership Payment?'), null, array('onclick' => "return showHideByValue('record_contribution','','recordContribution','table-row','radio',false);")); require_once 'CRM/Contribute/PseudoConstant.php'; $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')); } $this->addElement('checkbox', 'send_receipt', ts('Send Confirmation and Receipt?'), null, array('onclick' => "return showHideByValue('send_receipt','','notice','table-row','radio',false);")); $this->add('textarea', 'receipt_text_signup', ts('Receipt Message')); if ($this->_mode) { $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, true); require_once 'CRM/Core/Payment/Form.php'; 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) { require_once 'CRM/Contact/BAO/Contact/Location.php'; list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID); $this->assign('emailExists', $this->_contributorEmail); } $this->addFormRule(array('CRM_Member_Form_Membership', 'formRule'), $this); require_once "CRM/Core/BAO/Preferences.php"; $mailingInfo =& CRM_Core_BAO_Preferences::mailingPreferences(); $this->assign('outBound_option', $mailingInfo['outBound_option']); parent::buildQuickForm(); }
/** * Implement buildForm hook to remove billing fields if elsewhere on the form. * * @param string $formName * @param CRM_Contribute_Form_Contribution_Main|CRM_Event_Form_Registration_Register $form */ function omnipaymultiprocessor_civicrm_buildForm($formName, &$form) { if ($formName == 'CRM_Admin_Form_PaymentProcessor') { foreach (array('signature', 'test_signature') as $fieldName) { if ($form->elementExists($fieldName)) { $label = $form->_elements[$form->_elementIndex[$fieldName]]->_label; $form->removeElement($fieldName); $form->add('textarea', $fieldName, $label, array('rows' => 4, 'cols' => 40)); } } } if (omnipaymultiprocessor__versionAtLeast(4.6)) { return; } if (!omnipaymultiprocessor_is_credit_card_form($formName) || $form->_paymentProcessor['class_name'] != 'Payment_OmnipayMultiProcessor') { return; } $paymentType = civicrm_api3('option_value', 'getsingle', array('value' => $form->_paymentProcessor['payment_type'], 'option_group_id' => 'payment_type')); $form->assign('paymentTypeName', $paymentType['name']); $paymentFields = omnipaymultiprocessor_get_valid_form_payment_fields($formName == 'CRM_Contribute_Form_Contribution_Main' ? 'contribute' : 'event', $form->_paymentProcessor, empty($form->_paymentFields) ? array() : $form->_paymentFields); if (!empty($paymentFields)) { $form->assign('paymentFields', $paymentFields); $form->assign('paymentTypeLabel', ts($paymentType['label'] . ' Information')); } else { $form->assign('paymentFields', NULL); $form->assign('paymentTypeLabel', NULL); } $billingDetailsFields = omnipaymultiprocessor_getBillingPersonalDetailsFields($form->_paymentProcessor); //we trick CiviCRM into adding the credit card form so we can remove the parts we don't want (the credit card fields) //for a transparent redirect like Cybersource $billingMode = $form->_paymentProcessor['billing_mode']; $form->_paymentProcessor['billing_mode'] = CRM_Core_Payment::BILLING_MODE_FORM; CRM_Core_Payment_Form::buildCreditCard($form); $form->_paymentProcessor['billing_mode'] = $billingMode; //CiviCRM assumes that if it is Not a credit card it MUST be a direct debit & makes those required $suppressedFields = omnipaymultiprocessor_get_suppressed_billing_fields((array) $billingDetailsFields, (array) $paymentFields, (array) $form->_paymentFields); foreach ($suppressedFields as $suppressedField) { $form->_paymentFields[$suppressedField]['is_required'] = FALSE; } $form->assign('suppressedFields', $suppressedFields); $form->assign('billingDetailsFields', $billingDetailsFields); CRM_Core_Region::instance('billing-block')->update('default', array('disabled' => TRUE)); CRM_Core_Region::instance('billing-block')->add(array('template' => 'SubstituteBillingBlock.tpl')); }
static function buildQuickform(&$form) { $form->addElement('hidden', 'hidden_processor', 1); if ($form->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) { CRM_Core_Payment_Form::buildDirectDebit($form); } elseif ($form->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_CREDIT_CARD) { CRM_Core_Payment_Form::buildCreditCard($form); } }
/** * 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() { $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); }
/** * 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 buildPaymentFields() { $payment_processor_id = NULL; $can_pay_later = TRUE; $pay_later_text = ""; $this->pay_later_receipt = ""; foreach ($this->cart->get_main_events_in_carts() as $event_in_cart) { if ($payment_processor_id == NULL && $event_in_cart->event->payment_processor != NULL) { $payment_processor_id = $event_in_cart->event->payment_processor; $this->financial_type_id = $event_in_cart->event->financial_type_id; } else { if ($event_in_cart->event->payment_processor != NULL && $event_in_cart->event->payment_processor != $payment_processor_id) { CRM_Core_Error::statusBounce(ts('When registering for multiple events all events must use the same payment processor. ')); } } if (!$event_in_cart->event->is_pay_later) { $can_pay_later = FALSE; } else { //XXX $pay_later_text = $event_in_cart->event->pay_later_text; $this->pay_later_receipt = $event_in_cart->event->pay_later_receipt; } } if ($payment_processor_id == NULL) { CRM_Core_Error::statusBounce(ts('A payment processor must be selected for this event registration page, or the event must be configured to give users the option to pay later (contact the site administrator for assistance).')); } $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($payment_processor_id, $this->_mode); $this->assign('paymentProcessor', $this->_paymentProcessor); CRM_Core_Payment_Form::setCreditCardFields($this); CRM_Core_Payment_Form::buildCreditCard($this); if ($can_pay_later || self::is_administrator()) { $this->addElement('checkbox', 'is_pay_later', $pay_later_text); $this->addElement('checkbox', 'payment_completed', ts('Payment Completed')); $this->assign('pay_later_instructions', $this->pay_later_receipt); } }
/** * @param $form */ static function buildQuickform(&$form) { $form->addElement('hidden', 'hidden_processor', 1); $profileAddressFields = $form->get('profileAddressFields'); if (!empty($profileAddressFields)) { $form->assign('profileAddressFields', $profileAddressFields); } // before we do this lets see if the payment processor has implemented a buildForm method if (method_exists($form->_paymentProcessor['instance'], 'buildForm') && is_callable(array($form->_paymentProcessor['instance'], 'buildForm'))) { // the payment processor implements the buildForm function, let the payment // processor do the work $form->_paymentProcessor['instance']->buildForm($form); return; } if ($form->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) { CRM_Core_Payment_Form::buildDirectDebit($form); } elseif ($form->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_CREDIT_CARD) { CRM_Core_Payment_Form::buildCreditCard($form); } }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { $contactID = parent::getContactID(); if ($contactID) { require_once "CRM/Contact/BAO/Contact.php"; $name = CRM_Contact_BAO_Contact::displayName($contactID); $this->assign('display_name', $name); $this->assign('contact_id', $contactID); } $config = CRM_Core_Config::singleton(); $this->add('hidden', 'scriptFee', null); $this->add('hidden', 'scriptArray', null); $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'); $bypassPayment = $allowGroupOnWaitlist = $isAdditionalParticipants = false; if ($this->_values['event']['is_multiple_registrations']) { // don't allow to add additional during confirmation if not preregistered. if (!$this->_allowConfirmation || $this->_additionalParticipantIds) { // Hardcode maximum number of additional participants here for now. May need to make this configurable per event. // Label is value + 1, since the code sees this is ADDITIONAL participants (in addition to "self") $additionalOptions = array('' => ts('1'), 1 => ts('2'), 2 => ts('3'), 3 => ts('4'), 4 => ts('5'), 5 => ts('6'), 6 => ts('7'), 7 => ts('8'), 8 => ts('9'), 9 => ts('10')); $element = $this->add('select', 'additional_participants', ts('How many people are you registering?'), $additionalOptions, null, array('onChange' => "allowParticipant()")); $isAdditionalParticipants = true; } } //hack to allow group to register w/ waiting if ((CRM_Utils_Array::value('is_multiple_registrations', $this->_values['event']) || $this->_priceSetId) && !$this->_allowConfirmation && is_numeric($this->_availableRegistrations) && CRM_Utils_Array::value('has_waitlist', $this->_values['event'])) { $bypassPayment = true; //case might be group become as a part of waitlist. //If not waitlist then they require admin approve. $allowGroupOnWaitlist = true; $this->_waitlistMsg = ts("This event has only %1 space(s) left. If you continue and register more than %1 people (including yourself ), the whole group will be wait listed. Or, you can reduce the number of people you are registering to %1 to avoid being put on the waiting list.", array(1 => $this->_availableRegistrations)); if ($this->_requireApproval) { $this->_requireApprovalMsg = CRM_Utils_Array::value('approval_req_text', $this->_values['event'], ts('Registration for this event requires approval. Once your registration(s) have been reviewed, you will receive an email with a link to a web page where you can complete the registration process.')); } } //case where only approval needed - no waitlist. if ($this->_requireApproval && !$this->_allowWaitlist && !$bypassPayment) { $this->_requireApprovalMsg = CRM_Utils_Array::value('approval_req_text', $this->_values['event'], ts('Registration for this event requires approval. Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.')); } //lets display status to primary page only. $this->assign('waitlistMsg', $this->_waitlistMsg); $this->assign('requireApprovalMsg', $this->_requireApprovalMsg); $this->assign('allowGroupOnWaitlist', $allowGroupOnWaitlist); $this->assign('isAdditionalParticipants', $isAdditionalParticipants); $this->buildCustom($this->_values['custom_pre_id'], 'customPre'); $this->buildCustom($this->_values['custom_post_id'], 'customPost'); //lets get js on two different qf elements. $buildExpressPayBlock = false; $showHidePayfieldName = null; $showHidePaymentInformation = false; if ($this->_values['event']['is_monetary']) { self::buildAmount($this); $attributes = null; $freezePayLater = true; if (is_array($this->_paymentProcessor)) { $freezePayLater = false; if (!in_array($this->_paymentProcessor['billing_mode'], array(2, 4))) { $showHidePayfieldName = 'payment_information'; $attributes = array('onclick' => "showHidePaymentInfo( );"); } if ($this->_paymentProcessor['payment_processor_type'] == 'PayPal_Express') { $showHidePayfieldName = 'PayPalExpress'; $attributes = array('onclick' => "showHidePayPalExpressOption();"); } } //lets build only when there is no waiting and no required approval. if ($this->_allowConfirmation || !$this->_requireApproval && !$this->_allowWaitlist) { if ($this->_values['event']['is_pay_later']) { $element = $this->addElement('checkbox', 'is_pay_later', $this->_values['event']['pay_later_text'], null, $attributes); //if payment processor is not available then freeze //the paylater checkbox with default checked. if ($freezePayLater) { $element->freeze(); } } require_once 'CRM/Core/Payment/Form.php'; CRM_Core_Payment_Form::buildCreditCard($this); if ($showHidePayfieldName == 'payment_information') { $showHidePaymentInformation = true; } if ($showHidePayfieldName == 'PayPalExpress') { $buildExpressPayBlock = true; } } } //lets add some qf element to bypass payment validations, CRM-4320 if ($bypassPayment) { $attributes = null; if ($showHidePayfieldName == 'payment_information' && $showHidePaymentInformation) { $attributes = array('onclick' => "showHidePaymentInfo();"); } if ($showHidePayfieldName == 'PayPalExpress') { $attributes = array('onclick' => "showHidePayPalExpressOption();"); } $this->addElement('hidden', 'bypass_payment', null, array('id' => 'bypass_payment')); } $this->assign('bypassPayment', $bypassPayment); $this->assign('buildExpressPayBlock', $buildExpressPayBlock); $this->assign('showHidePaymentInformation', $showHidePaymentInformation); $userID = parent::getContactID(); if (!$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->_paymentProcessor['billing_mode'] != CRM_Core_Payment::BILLING_MODE_BUTTON || CRM_Utils_Array::value('is_pay_later', $this->_values['event']) || $bypassPayment || !$buildExpressPayBlock) { //freeze button to avoid multiple calls. $js = null; if (!CRM_Utils_Array::value('is_monetary', $this->_values['event'])) { $js = array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"); } $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => true, 'js' => $js))); } $this->addFormRule(array('CRM_Event_Form_Registration_Register', 'formRule'), $this); }
/** * 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_PriceSet::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_PriceSet::checkAutoRenewForPriceSet($this->_priceSetId)); $this->assign('optionsMembershipTypes', $optionsMembershipTypes); $this->assign('contributionType', CRM_Utils_Array::value('financial_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_PriceSet::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 when membership type is selected to: // - set the payment information block // - set the max related block $allMembershipInfo[$key] = array('financial_type_id' => CRM_Utils_Array::value('financial_type_id', $values), 'total_amount' => CRM_Utils_Money::format($values['minimum_fee'], NULL, '%a'), 'total_amount_numeric' => CRM_Utils_Array::value('minimum_fee', $values), 'auto_renew' => CRM_Utils_Array::value('auto_renew', $values), 'has_related' => isset($values['relationship_type_id']), 'max_related' => CRM_Utils_Array::value('max_related', $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' => "CRM.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' => "CRM.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)); // for max_related: a little JS to show/hide & set default value $memTypeJs['onChange'] = "buildMaxRelated(this.value,true); " . $memTypeJs['onChange']; $this->add('text', 'max_related', ts('Max related'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_Membership', 'max_related')); $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'); if ($this->_action & CRM_Core_Action::ADD) { $this->add('text', 'num_terms', ts('Number of Terms'), array('size' => 6)); } $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('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' => 'activityDateTime')); $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')); } $this->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType()); 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::get('CRM_Contribute_DAO_Contribution', 'honor_type_id')); 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 build the form * * @return None * @access public */ public function buildQuickForm() { if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } //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') { require_once 'CRM/Contact/Form/NewContact.php'; 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(); $membershipType = array(); while ($dao->fetch()) { if ($dao->is_active) { $membershipType[$dao->id] = $dao->name; if ($this->_mode && !$dao->minimum_fee) { continue; } else { if (!CRM_Utils_Array::value($dao->member_of_contact_id, $selMemTypeOrg)) { $selMemTypeOrg[$dao->member_of_contact_id] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $dao->member_of_contact_id, 'display_name', 'id'); $selOrgMemType[$dao->member_of_contact_id][0] = ts('- select -'); } if (!CRM_Utils_Array::value($dao->id, $selOrgMemType[$dao->member_of_contact_id])) { $selOrgMemType[$dao->member_of_contact_id][$dao->id] = $dao->name; } } } } // 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')); 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?')); require_once 'CRM/Contribute/PseudoConstant.php'; $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')); } $this->addElement('checkbox', 'send_receipt', ts('Send Confirmation and Receipt?'), null, array('onclick' => "return showHideByValue('send_receipt','','notice','table-row','radio',false);")); $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 );")); require_once 'CRM/Core/Payment/Form.php'; 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) { require_once 'CRM/Contact/BAO/Contact/Location.php'; 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) { $isRecur = true; require_once 'CRM/Member/BAO/Membership.php'; 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); require_once "CRM/Core/BAO/Preferences.php"; $mailingInfo =& CRM_Core_BAO_Preferences::mailingPreferences(); $this->assign('outBound_option', $mailingInfo['outBound_option']); parent::buildQuickForm(); }