X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FEvent%2FForm%2FEventFees.php;h=192e54008e2e0dc187c3b3c4ab110f3a386c6867;hb=c21afdf769a2dec4e6539ce9a1fdebd404dab247;hp=c279f95a0189b427d9bf34737e387e542c4b7666;hpb=4f374bbf9544a6bf98ac0419f0b63f0ad6afc914;p=civicrm-core.git diff --git a/CRM/Event/Form/EventFees.php b/CRM/Event/Form/EventFees.php index c279f95a01..192e54008e 100644 --- a/CRM/Event/Form/EventFees.php +++ b/CRM/Event/Form/EventFees.php @@ -1,27 +1,11 @@ _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, ['id' => 'hidden_eventFullMsg']); - } - } - - if ($form->_pId) { - if (CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', - $form->_pId, 'contribution_id', 'participant_id' - ) - ) { - $form->_online = !$form->isBackOffice; - } - } - - if ($form->_isPaidEvent) { - $params = ['id' => $form->_eventId]; - CRM_Event_BAO_Event::retrieve($params, $event); - - //retrieve custom information - $form->_values = []; - CRM_Event_Form_Registration::initEventFee($form, $event['id']); - CRM_Event_Form_Registration_Register::buildAmount($form, TRUE, $form->_discountId); - $lineItem = []; - $invoiceSettings = Civi::settings()->get('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 = []; - 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'), - [ - 0 => ts('- select -'), - ] + $discounts, - FALSE, - ['class' => "crm-select2"] - ); - - if ($form->_online) { - $element->freeze(); - } - } - if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() - && !CRM_Utils_Array::value('fee', $form->_values) - && CRM_Utils_Array::value('snippet', $_REQUEST) == CRM_Core_Smarty::PRINT_NOFORM - ) { - CRM_Core_Session::setStatus(ts('You do not have all the permissions needed for this page.'), 'Permission Denied', 'error'); - return FALSE; - } - - CRM_Core_Payment_Form::buildPaymentForm($form, $form->_paymentProcessor, FALSE, TRUE, self::getDefaultPaymentInstrumentId()); - if (!$form->_mode) { - $form->addElement('checkbox', 'record_contribution', ts('Record Payment?'), NULL, - ['onclick' => "return showHideByValue('record_contribution','','payment_information','table-row','radio',false);"] - ); - // Check permissions for financial type first - if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) { - CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, $form->_action); - } - else { - $financialTypes = CRM_Contribute_PseudoConstant::financialType(); - } - - $form->add('select', 'financial_type_id', - ts('Financial Type'), - ['' => ts('- select -')] + $financialTypes - ); - - $form->add('datepicker', 'receive_date', ts('Received'), [], FALSE, ['time' => TRUE]); - - $form->add('select', 'payment_instrument_id', - ts('Payment Method'), - ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::paymentInstrument(), - FALSE, ['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', ['CRM_Contribute_DAO_Contribution', $form->_eventId, 'trxn_id'] - ); - $form->assign('showTransactionId', TRUE); - } - - $form->add('select', 'contribution_status_id', - ts('Payment Status'), CRM_Contribute_BAO_Contribution_Utils::getContributionStatuses('participant') - ); - - $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, - ['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 = Civi::settings()->get('mailing_backend'); - $form->assign('outBound_option', $mailingInfo['outBound_option']); - $form->assign('hasPayment', $form->_paymentId); - } - /** * Get the default payment instrument id. *