예제 #1
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     if ($this->_mode) {
         $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, TRUE, array('onChange' => "buildAutoRenew( null, this.value, '{$this->_mode}');"));
         CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE);
     }
     // Build the form for auto renew. This is displayed when in credit card mode or update mode.
     // The reason for showing it in update mode is not that clear.
     if ($this->_mode || $this->_action & CRM_Core_Action::UPDATE) {
         if (!empty($this->_recurPaymentProcessors)) {
             $this->assign('allowAutoRenew', TRUE);
         }
         $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($this->_recurPaymentProcessors));
         $this->addElement('checkbox', 'auto_renew', ts('Membership renewed automatically'));
         $this->assignPaymentRelatedVariables();
     }
     $this->assign('autoRenewOptions', json_encode($this->membershipTypeRenewalStatus));
     if ($this->_action & CRM_Core_Action::RENEW) {
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Renew'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     } elseif ($this->_action & CRM_Core_Action::DELETE) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     } else {
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
     }
 }
예제 #2
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     // FIXME: This probably needs to be done in preprocess
     if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && $this->_action & CRM_Core_Action::UPDATE && CRM_Utils_Array::value('financial_type_id', $this->_values)) {
         $financialTypeID = CRM_Contribute_PseudoConstant::financialType($this->_values['financial_type_id']);
         CRM_Financial_BAO_FinancialType::checkPermissionedLineItems($this->_id, 'edit');
         if (!CRM_Core_Permission::check('edit contributions of type ' . $financialTypeID)) {
             CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
         }
     }
     $allPanes = array();
     $recurJs = NULL;
     //tax rate from financialType
     $this->assign('taxRates', json_encode(CRM_Core_PseudoConstant::getTaxRates()));
     $this->assign('currencies', json_encode(CRM_Core_OptionGroup::values('currencies_enabled')));
     // build price set form.
     $buildPriceSet = FALSE;
     $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
     $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
     $this->assign('invoicing', $invoicing);
     // display tax amount on edit contribution page
     if ($invoicing && $this->_action & CRM_Core_Action::UPDATE && isset($this->_values['tax_amount'])) {
         $this->assign('totalTaxAmount', $this->_values['tax_amount']);
     }
     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);
     $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';
     }
     if ($this->_mode) {
         if (CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE) == TRUE) {
             if (!empty($this->_recurPaymentProcessors)) {
                 $buildRecurBlock = TRUE;
                 if ($this->_ppID) {
                     // ppID denotes a pledge payment.
                     foreach ($this->_paymentProcessors as $processor) {
                         if (!empty($processor['is_recur']) && !empty($processor['object']) && $processor['object']->supports('recurContributionsForPledges')) {
                             $buildRecurBlock = TRUE;
                             break;
                         }
                         $buildRecurBlock = FALSE;
                     }
                 }
                 if ($buildRecurBlock) {
                     CRM_Contribute_Form_Contribution_Main::buildRecur($this);
                     $this->setDefaults(array('is_recur' => 0));
                     $this->assign('buildRecurBlock', TRUE);
                     $recurJs = array('onChange' => "buildRecurBlock( this.value ); return false;");
                 }
             }
         }
     }
     foreach ($paneNames as $name => $type) {
         $allPanes[$name] = $this->generatePane($type, $defaults);
     }
     $qfKey = $this->controller->_key;
     $this->assign('qfKey', $qfKey);
     $this->assign('allPanes', $allPanes);
     $this->addFormRule(array('CRM_Contribute_Form_Contribution', 'formRule'), $this);
     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');
     // Check permissions for financial type first
     CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, $this->_action);
     if (empty($financialTypes)) {
         CRM_Core_Error::statusBounce(ts('You do not have all the permissions needed for this page.'));
     }
     $financialType = $this->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + $financialTypes, TRUE, array('onChange' => "CRM.buildCustomData( 'Contribution', this.value );"));
     $paymentInstrument = FALSE;
     if (!$this->_mode) {
         $paymentInstrument = $this->add('select', 'payment_instrument_id', ts('Payment Method'), 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']);
     $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;
             // CRM-16451: set financial type of 'Price Set' in back office contribution
             // instead of selecting manually
             $financialTypeIds = CRM_Price_BAO_PriceSet::getAssoc(FALSE, 'CiviContribute', 'financial_type_id');
             $element = $this->add('select', 'price_set_id', ts('Choose price set'), array('' => ts('Choose price set')) + $priceSets, NULL, array('onchange' => "buildAmount( this.value, " . json_encode($financialTypeIds) . ");"));
             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 = Civi::settings()->get('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();
     }
     // if contribution is related to membership or participant freeze Financial Type, Amount
     if ($this->_id && isset($this->_values['tax_amount'])) {
         $componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
         if (CRM_Utils_Array::value('membership', $componentDetails) || CRM_Utils_Array::value('participant', $componentDetails)) {
             if ($totalAmount) {
                 $totalAmount->freeze();
             }
             $financialType->freeze();
             $this->assign('freezeFinancialType', TRUE);
         }
     }
     if ($this->_action & CRM_Core_Action::VIEW) {
         $this->freeze();
     }
 }
예제 #3
0
 /**
  * Build the form object.
  *
  * @param CRM_Core_Form $form
  *
  * @return void
  */
 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();
         $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
         $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
         $totalTaxAmount = 0;
         if (!CRM_Utils_System::isNull(CRM_Utils_Array::value('line_items', $form->_values))) {
             $lineItem[] = $form->_values['line_items'];
             foreach ($form->_values['line_items'] as $key => $value) {
                 $totalTaxAmount = $value['tax_amount'] + $totalTaxAmount;
             }
         }
         if ($invoicing) {
             $form->assign('totalTaxAmount', $totalTaxAmount);
         }
         $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('class' => "crm-select2"));
             if ($form->_online) {
                 $element->freeze();
             }
         }
         if ($form->_mode) {
             CRM_Core_Payment_Form::buildPaymentForm($form, $form->_paymentProcessor, FALSE);
         } 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);
 }
예제 #4
0
 public function buildQuickForm()
 {
     if ($this->_view == 'transaction' && $this->_action & CRM_Core_Action::BROWSE) {
         $this->addButtons(array(array('type' => 'cancel', 'name' => ts('Done'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE)));
         return;
     }
     $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);
             CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, 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);
     $label = $this->_refund ? ts('Refund Amount') : ts('Payment Amount');
     $this->addMoney('total_amount', $label, FALSE, $attributes['total_amount'], TRUE, 'currency', NULL);
     $this->add('select', 'payment_instrument_id', ts('Payment Method'), 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']);
     $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['from_email_id']);
     $this->add('textarea', 'receipt_text', ts('Confirmation Message'));
     // add various dates
     $dateLabel = $this->_refund ? ts('Refund Date') : ts('Date Received');
     $this->addDateTime('trxn_date', $dateLabel, 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 = Civi::settings()->get('mailing_backend');
     $this->assign('outBound_option', $mailingInfo['outBound_option']);
     $this->addFormRule(array('CRM_Contribute_Form_AdditionalPayment', 'formRule'), $this);
 }
예제 #5
0
파일: Form.php 프로젝트: kidaa30/yes
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     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::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE);
     }
     if ($this->_action & CRM_Core_Action::RENEW) {
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Renew'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     } elseif ($this->_action & CRM_Core_Action::DELETE) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     } else {
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
     }
 }
예제 #6
0
 public 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::buildPaymentForm($this, $this->_paymentProcessor, FALSE, FALSE);
     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);
     }
 }
예제 #7
0
 /**
  * Build the payment processor form.
  *
  * @param CRM_Core_Form $form
  */
 public static function buildQuickform(&$form)
 {
     //@todo document why this addHidden is here
     //CRM-15743 - we should not set/create hidden element for pay later
     // because payment processor is not selected
     $processorId = $form->getVar('_paymentProcessorID');
     $billing_profile_id = CRM_Utils_Request::retrieve('billing_profile_id', 'String');
     if (!empty($form->_values) && !empty($form->_values['is_billing_required'])) {
         $billing_profile_id = 'billing';
     }
     if (!empty($processorId)) {
         $form->addElement('hidden', 'hidden_processor', 1);
     }
     CRM_Core_Payment_Form::buildPaymentForm($form, $form->_paymentProcessor, $billing_profile_id, FALSE);
 }
예제 #8
0
 /**
  * Build the form object.
  *
  * @return void
  */
 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::buildPaymentForm($this, $this->_paymentProcessor, TRUE, TRUE);
     $this->addFormRule(array('CRM_Contribute_Form_UpdateBilling', 'formRule'), $this);
 }
 /**
  * @param $form
  */
 public static function buildQuickform(&$form)
 {
     //@todo document why this addHidden is here
     //CRM-15743 - we should not set/create hidden element for pay later
     // because payment processor is not selected
     if (!empty($form->_paymentProcessorID)) {
         $form->addElement('hidden', 'hidden_processor', 1);
     }
     CRM_Core_Payment_Form::buildPaymentForm($form, $form->_paymentProcessor, empty($form->_isBillingAddressRequiredForPayLater), FALSE);
 }
예제 #10
0
    /**
     * Build the form object.
     */
    public function buildQuickForm()
    {
        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::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE);
        }
        // Build the form for auto renew. This is displayed when in credit card mode or update mode.
        // The reason for showing it in update mode is not that clear.
        $autoRenew = array();
        $recurProcessor = array();
        if ($this->_mode || $this->_action & CRM_Core_Action::UPDATE) {
            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};
                        }
                    }
                }
                if ($this->_mode) {
                    if (!empty($this->_recurPaymentProcessors)) {
                        $this->assign('allowAutoRenew', TRUE);
                    }
                }
                $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));
        if ($this->_mode || $this->_action & CRM_Core_Action::UPDATE) {
            $this->addElement('checkbox', 'auto_renew', ts('Membership renewed automatically'), NULL, array('onclick' => "buildReceiptANDNotice( );"));
            $this->assignPaymentRelatedVariables();
        }
        $this->assign('autoRenewOptions', json_encode($autoRenew));
        if ($this->_action & CRM_Core_Action::RENEW) {
            $this->addButtons(array(array('type' => 'upload', 'name' => ts('Renew'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
        } elseif ($this->_action & CRM_Core_Action::DELETE) {
            $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
        } else {
            $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
        }
    }