/**
  * 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);
 }
Example #2
0
 /**
  * Handle Payment Processor switching for contribution and event registration forms.
  *
  * @param CRM_Contribute_Form_Contribution_Main|CRM_Event_Form_Registration_Register $form
  * @param bool $noFees
  */
 public static function preProcessPaymentOptions(&$form, $noFees = FALSE)
 {
     $form->_snippet = CRM_Utils_Array::value('snippet', $_GET);
     $form->_paymentProcessors = $noFees ? array() : $form->get('paymentProcessors');
     $form->_paymentProcessorID = NULL;
     if ($form->_paymentProcessors) {
         if (!empty($form->_submitValues)) {
             $form->_paymentProcessorID = CRM_Utils_Array::value('payment_processor_id', $form->_submitValues);
             $form->_paymentProcessor = CRM_Utils_Array::value($form->_paymentProcessorID, $form->_paymentProcessors);
             $form->set('type', $form->_paymentProcessorID);
             $form->set('mode', $form->_mode);
             $form->set('paymentProcessor', $form->_paymentProcessor);
         } else {
             foreach ($form->_paymentProcessors as $values) {
                 if (!empty($values['is_default']) || count($form->_paymentProcessors) == 1) {
                     $form->_paymentProcessorID = $values['id'];
                     break;
                 }
             }
         }
         if ($form->_paymentProcessorID) {
             CRM_Core_Payment_ProcessorForm::preProcess($form);
         } else {
             $form->_paymentProcessor = array();
         }
         CRM_Financial_Form_Payment::addCreditCardJs();
     }
     $form->assign('paymentProcessorID', $form->_paymentProcessorID);
 }
 /**
  * Process the form submission.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     //get the button name.
     $button = substr($this->controller->getButtonName(), -4);
     //take the participant instance.
     $addParticipantNum = substr($this->_name, 12);
     //user submitted params.
     $params = $this->controller->exportValues($this->_name);
     if (!$this->_allowConfirmation) {
         // check if the participant is already registered
         $params['contact_id'] = CRM_Event_Form_Registration_Register::checkRegistration($params, $this, TRUE, TRUE);
     }
     //carry campaign to partcipants.
     if (array_key_exists('participant_campaign_id', $params)) {
         $params['campaign_id'] = $params['participant_campaign_id'];
     } else {
         $params['campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values['event']);
     }
     // if waiting is enabled
     if (!$this->_allowConfirmation && is_numeric($this->_availableRegistrations)) {
         $this->_allowWaitlist = FALSE;
         //get the current page count.
         $currentCount = self::getParticipantCount($this, $params);
         if ($button == 'skip') {
             $currentCount = 'skip';
         }
         //get the total count.
         $previousCount = self::getParticipantCount($this, $this->_params, TRUE);
         $totalParticipants = $previousCount;
         if (is_numeric($currentCount)) {
             $totalParticipants += $currentCount;
         }
         if (!empty($this->_values['event']['has_waitlist']) && $totalParticipants > $this->_availableRegistrations) {
             $this->_allowWaitlist = TRUE;
         }
         $this->set('allowWaitlist', $this->_allowWaitlist);
         $this->_lineItemParticipantsCount[$addParticipantNum] = $currentCount;
     }
     if ($button == 'skip') {
         //hack for free/zero amount event.
         if ($this->_resetAllowWaitlist) {
             $this->_allowWaitlist = FALSE;
             $this->set('allowWaitlist', FALSE);
             if ($this->_requireApproval) {
                 $status = ts("You have skipped last participant and which result into event having enough spaces, but your registration require 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.");
             } else {
                 $status = ts("You have skipped last participant and which result into event having enough spaces, hence your group become as register participants though you selected on wait list.");
             }
             CRM_Core_Session::setStatus($status);
         }
         $this->_params[$addParticipantNum] = 'skip';
         if (isset($this->_lineItem)) {
             $this->_lineItem[$addParticipantNum] = 'skip';
             $this->_lineItemParticipantsCount[$addParticipantNum] = 'skip';
         }
     } else {
         $config = CRM_Core_Config::singleton();
         $params['currencyID'] = $config->defaultCurrency;
         if ($this->_values['event']['is_monetary']) {
             //added for discount
             $discountId = CRM_Core_BAO_Discount::findSet($this->_eventId, 'civicrm_event');
             if (!empty($this->_values['discount'][$discountId])) {
                 $params['discount_id'] = $discountId;
                 $params['amount_level'] = $this->_values['discount'][$discountId][$params['amount']]['label'];
                 $params['amount'] = $this->_values['discount'][$discountId][$params['amount']]['value'];
             } elseif (empty($params['priceSetId'])) {
                 $params['amount_level'] = $this->_values['fee'][$params['amount']]['label'];
                 $params['amount'] = $this->_values['fee'][$params['amount']]['value'];
             } else {
                 $lineItem = array();
                 CRM_Price_BAO_PriceSet::processAmount($this->_values['fee'], $params, $lineItem);
                 //build line item array..
                 //if requireApproval/waitlist is enabled we hide fees for primary participant
                 // (and not for additional participant which might be is a bug)
                 //lineItem are not correctly build for primary participant
                 //this results in redundancy since now lineItems for additional participant will be build against primary participantNum
                 //therefore lineItems must always be build against current participant No
                 $this->_lineItem[$addParticipantNum] = $lineItem;
             }
         }
         if (array_key_exists('participant_role', $params)) {
             $params['participant_role_id'] = $params['participant_role'];
         }
         if (empty($params['participant_role_id']) && $this->_values['event']['default_role_id']) {
             $params['participant_role_id'] = $this->_values['event']['default_role_id'];
         }
         if (!empty($this->_params[0]['is_pay_later'])) {
             $params['is_pay_later'] = 1;
         }
         //carry additional participant id, contact id if pre-registered.
         if ($this->_allowConfirmation && $this->_additionalParticipantId) {
             $params['contact_id'] = $this->_contactId;
             $params['participant_id'] = $this->_additionalParticipantId;
         }
         //build the params array.
         $this->_params[$addParticipantNum] = $params;
     }
     //finally set the params.
     $this->set('params', $this->_params);
     //set the line item.
     if ($this->_lineItem) {
         $this->set('lineItem', $this->_lineItem);
         $this->set('lineItemParticipantsCount', $this->_lineItemParticipantsCount);
     }
     $participantNo = count($this->_params);
     if ($button != 'skip') {
         $statusMsg = ts('Registration information for participant %1 has been saved.', array(1 => $participantNo));
         CRM_Core_Session::setStatus($statusMsg, ts('Registration Saved'), 'success');
     }
     // Check whether to process the registration now, calling processRegistration()
     if (!$this->_values['event']['is_confirm_enabled'] && !$this->_values['event']['is_monetary'] && CRM_Utils_Array::value('additional_participants', $this->_params[0]) && $this->isLastParticipant()) {
         CRM_Event_Form_Registration_Register::processRegistration($this->_params, NULL);
     }
 }
 public function buildQuickForm()
 {
     $statuses = CRM_Event_PseudoConstant::participantStatus();
     $this->assign('partiallyPaid', array_search('Partially paid', $statuses));
     $this->assign('pendingRefund', array_search('Pending refund', $statuses));
     $this->assign('participantStatus', $this->_participantStatus);
     $config = CRM_Core_Config::singleton();
     $this->assign('currencySymbol', $config->defaultCurrencySymbol);
     // line items block
     $lineItem = $event = array();
     $params = array('id' => $this->_eventId);
     CRM_Event_BAO_Event::retrieve($params, $event);
     //retrieve custom information
     $this->_values = array();
     CRM_Event_Form_Registration::initEventFee($this, $event['id']);
     CRM_Event_Form_Registration_Register::buildAmount($this, TRUE);
     if (!CRM_Utils_System::isNull(CRM_Utils_Array::value('line_items', $this->_values))) {
         $lineItem[] = $this->_values['line_items'];
     }
     $this->assign('lineItem', empty($lineItem) ? FALSE : $lineItem);
     $event = CRM_Event_BAO_Event::getEvents(0, $this->_eventId);
     $this->assign('eventName', $event[$this->_eventId]);
     $statusOptions = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label');
     $this->add('select', 'status_id', ts('Participant Status'), array('' => ts('- select -')) + $statusOptions, TRUE);
     $this->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);"));
     $this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails['from_email_id']);
     $this->add('textarea', 'receipt_text', ts('Confirmation Message'));
     $noteAttributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note');
     $this->add('textarea', 'note', ts('Notes'), $noteAttributes['note']);
     $buttons[] = array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE);
     if (CRM_Event_BAO_Participant::isPrimaryParticipant($this->_participantId)) {
         $buttons[] = array('type' => 'upload', 'name' => ts('Save and Record Payment'), 'subName' => 'new');
     }
     $buttons[] = array('type' => 'cancel', 'name' => ts('Cancel'));
     $this->addButtons($buttons);
     $this->addFormRule(array('CRM_Event_Form_ParticipantFeeSelection', 'formRule'), $this);
 }
Example #5
0
 /**
  * Apply form rule.
  *
  * @param array $fields
  * @param array $files
  * @param CRM_Core_Form $self
  *
  * @return array|bool
  */
 public static function formRule($fields, $files, $self)
 {
     $errors = array();
     $eventFull = CRM_Event_BAO_Participant::eventFull($self->_eventId, FALSE, CRM_Utils_Array::value('has_waitlist', $self->_values['event']));
     if ($eventFull && empty($self->_allowConfirmation)) {
         if (empty($self->_allowWaitlist)) {
             CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/register', "reset=1&id={$self->_eventId}", FALSE, NULL, FALSE, TRUE));
         }
     }
     $self->_feeBlock = $self->_values['fee'];
     CRM_Event_Form_Registration_Register::formatFieldsForOptionFull($self);
     if (!empty($self->_priceSetId) && !$self->_requireApproval && !$self->_allowWaitlist) {
         $priceSetErrors = self::validatePriceSet($self, $self->_params);
         if (!empty($priceSetErrors)) {
             CRM_Core_Session::setStatus(ts('You have been returned to the start of the registration process and any sold out events have been removed from your selections. You will not be able to continue until you review your booking and select different events if you wish.'), ts('Unfortunately some of your options have now sold out for one or more participants.'), 'error');
             CRM_Core_Session::setStatus(ts('Please note that the options which are marked or selected are sold out for participant being viewed.'), ts('Sold out:'), 'error');
             CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/register', "_qf_Register_display=true&qfKey={$fields['qfKey']}"));
         }
     }
     return empty($priceSetErrors) ? TRUE : $priceSetErrors;
 }
Example #6
0
 /**
  * Method to check if the user is already registered for the event.
  * and if result found redirect to the event info page
  *
  * @param array $fields
  *   The input form values(anonymous user).
  * @param CRM_Event_Form_Registration_Register $self
  *   Event data.
  * @param bool $isAdditional
  *   Treat isAdditional participants a bit differently.
  * @param bool $returnContactId
  *   Just find and return the contactID match to use.
  * @param bool $useDedupeRules
  *   Force usage of dedupe rules.
  *
  * @return int
  */
 public static function checkRegistration($fields, &$self, $isAdditional = FALSE, $returnContactId = FALSE, $useDedupeRules = FALSE)
 {
     // CRM-3907, skip check for preview registrations
     // CRM-4320 participant need to walk wizard
     if (!$returnContactId && ($self->_mode == 'test' || $self->_allowConfirmation)) {
         return FALSE;
     }
     $contactID = NULL;
     $session = CRM_Core_Session::singleton();
     if (!$isAdditional) {
         $contactID = $self->getContactID();
     }
     if (!$contactID && is_array($fields) && $fields) {
         //CRM-14134 use Unsupervised rule for everyone
         $dedupeParams = CRM_Dedupe_Finder::formatParams($fields, 'Individual');
         // disable permission based on cache since event registration is public page/feature.
         $dedupeParams['check_permission'] = FALSE;
         // find event dedupe rule
         if (CRM_Utils_Array::value('dedupe_rule_group_id', $self->_values['event'], 0) > 0) {
             $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual', 'Unsupervised', array(), $self->_values['event']['dedupe_rule_group_id']);
         } else {
             $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual', 'Unsupervised');
         }
         $contactID = CRM_Utils_Array::value(0, $ids);
     }
     if ($returnContactId) {
         // CRM-7377
         // return contactID if contact already exists
         return $contactID;
     }
     if ($contactID) {
         $participant = new CRM_Event_BAO_Participant();
         $participant->contact_id = $contactID;
         $participant->event_id = $self->_values['event']['id'];
         if (!empty($fields['participant_role']) && is_numeric($fields['participant_role'])) {
             $participant->role_id = $fields['participant_role'];
         } else {
             $participant->role_id = $self->_values['event']['default_role_id'];
         }
         $participant->is_test = 0;
         $participant->find();
         $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
         while ($participant->fetch()) {
             if (array_key_exists($participant->status_id, $statusTypes)) {
                 if (!$isAdditional && !$self->_values['event']['allow_same_participant_emails']) {
                     $registerUrl = CRM_Utils_System::url('civicrm/event/register', "reset=1&id={$self->_values['event']['id']}&cid=0");
                     if ($self->_pcpId) {
                         $registerUrl .= '&pcpId=' . $self->_pcpId;
                     }
                     $status = ts("It looks like you are already registered for this event. If you want to change your registration, or you feel that you've gotten this message in error, please contact the site administrator.") . ' ' . ts('You can also <a href="%1">register another participant</a>.', array(1 => $registerUrl));
                     $session->setStatus($status, ts('Oops.'), 'alert');
                     $url = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$self->_values['event']['id']}&noFullMsg=true");
                     if ($self->_action & CRM_Core_Action::PREVIEW) {
                         $url .= '&action=preview';
                     }
                     if ($self->_pcpId) {
                         $url .= '&pcpId=' . $self->_pcpId;
                     }
                     CRM_Utils_System::redirect($url);
                 }
                 if ($isAdditional) {
                     $status = ts("It looks like this participant is already registered for this event. If you want to change your registration, or you feel that you've gotten this message in error, please contact the site administrator.");
                     $session->setStatus($status, ts('Oops.'), 'alert');
                     return $participant->id;
                 }
             }
         }
     }
 }
Example #7
0
 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     //get the button name.
     $button = substr($this->controller->getButtonName(), -4);
     //take the participant instance.
     $addParticipantNum = substr($this->_name, 12);
     if ($button == 'skip') {
         //hack for free/zero amount event.
         if ($this->_resetAllowWaitlist) {
             $this->_allowWaitlist = false;
             $this->set('allowWaitlist', false);
             if ($this->_requireApproval) {
                 $status = ts("You have skipped last participant and which result into event having enough spaces, but your registration require 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.");
             } else {
                 $status = ts("You have skipped last participant and which result into event having enough spaces, hence your group become as register participants though you selected on wait list.");
             }
             CRM_Core_Session::setStatus($status);
         }
         $this->_params[$addParticipantNum] = 'skip';
         if (isset($this->_lineItem)) {
             $this->_lineItem[$addParticipantNum] = 'skip';
         }
     } else {
         $params = $this->controller->exportValues($this->_name);
         if ($this->_values['event']['is_monetary']) {
             //added for discount
             require_once 'CRM/Core/BAO/Discount.php';
             $discountId = CRM_Core_BAO_Discount::findSet($this->_eventId, 'civicrm_event');
             if (!empty($this->_values['discount'][$discountId])) {
                 $params['discount_id'] = $discountId;
                 $params['amount_level'] = $this->_values['discount'][$discountId][$params['amount']]['label'];
                 $params['amount'] = $this->_values['discount'][$discountId][$params['amount']]['value'];
             } else {
                 if (empty($params['priceSetId'])) {
                     $params['amount_level'] = $this->_values['fee'][$params['amount']]['label'];
                     $params['amount'] = $this->_values['fee'][$params['amount']]['value'];
                 } else {
                     $lineItem = array();
                     require_once 'CRM/Price/BAO/Set.php';
                     CRM_Price_BAO_Set::processAmount($this->_values['fee']['fields'], $params, $lineItem);
                     //build the line item..
                     if (array_key_exists($addParticipantNum, $this->_lineItem)) {
                         $this->_lineItem[$addParticipantNum] = $lineItem;
                     } else {
                         $this->_lineItem[] = $lineItem;
                     }
                 }
             }
         }
         if (!CRM_Utils_Array::value('participant_role_id', $params) && $this->_values['event']['default_role_id']) {
             $params['participant_role_id'] = $this->_values['event']['default_role_id'];
         }
         if (CRM_Utils_Array::value('is_pay_later', $this->_params[0])) {
             $params['is_pay_later'] = 1;
         }
         //carry additional participant id, contact id if pre-registered.
         if ($this->_allowConfirmation && $this->_additionalParticipantId) {
             $params['contact_id'] = $this->_contactID;
             $params['participant_id'] = $this->_additionalParticipantId;
         }
         //build the params array.
         if (array_key_exists($addParticipantNum, $this->_params)) {
             $this->_params[$addParticipantNum] = $params;
         } else {
             $this->_params[] = $params;
         }
     }
     //finally set the params.
     $this->set('params', $this->_params);
     //set the line item.
     if ($this->_lineItem) {
         $this->set('lineItem', $this->_lineItem);
     }
     $participantNo = count($this->_params);
     if ($button != 'skip') {
         require_once "CRM/Core/Session.php";
         $statusMsg = ts('Registration information for participant %1 has been saved.', array(1 => $participantNo));
         CRM_Core_Session::setStatus("{$statusMsg}");
     }
     //to check whether call processRegistration()
     if (!$this->_values['event']['is_monetary'] && CRM_Utils_Array::value('additional_participants', $this->_params[0]) && $this->isLastParticipant()) {
         require_once 'CRM/Event/Form/Registration/Register.php';
         CRM_Event_Form_Registration_Register::processRegistration($this->_params, null);
     }
 }
Example #8
0
 /**
  * Handle Payment Processor switching for contribution and event registration forms.
  *
  * @param CRM_Contribute_Form_Contribution_Main|CRM_Event_Form_Registration_Register $form
  * @param bool $noFees
  */
 public static function preProcessPaymentOptions(&$form, $noFees = FALSE)
 {
     $form->_snippet = CRM_Utils_Array::value('snippet', $_GET);
     $form->_paymentProcessors = $noFees ? array() : $form->get('paymentProcessors');
     $form->_paymentProcessorID = NULL;
     if ($form->_paymentProcessors) {
         // Fetch type during ajax request
         if (isset($_GET['type']) && $form->_snippet) {
             $form->_paymentProcessorID = CRM_Utils_Request::retrieve('type', 'Integer', CRM_Core_DAO::$_nullObject, FALSE, 0);
         } elseif (!empty($form->_submitValues)) {
             $form->_paymentProcessorID = CRM_Utils_Array::value('payment_processor', $form->_submitValues);
             $form->_paymentProcessor = CRM_Utils_Array::value($form->_paymentProcessorID, $form->_paymentProcessors);
             $form->set('type', $form->_paymentProcessorID);
             $form->set('mode', $form->_mode);
             $form->set('paymentProcessor', $form->_paymentProcessor);
         } else {
             foreach ($form->_paymentProcessors as $values) {
                 if (!empty($values['is_default']) || count($form->_paymentProcessors) == 1) {
                     $form->_paymentProcessorID = $values['id'];
                     break;
                 }
             }
         }
         if ($form->_paymentProcessorID) {
             CRM_Core_Payment_ProcessorForm::preProcess($form);
         } else {
             $form->_paymentProcessor = array();
         }
         //get payPal express id and make it available to template
         foreach ($form->_paymentProcessors as $ppId => $values) {
             $payPalExpressId = $values['payment_processor_type'] == 'PayPal_Express' ? $values['id'] : 0;
             $form->assign('payPalExpressId', $payPalExpressId);
             if ($payPalExpressId) {
                 break;
             }
         }
         if (!$form->_snippet) {
             // Add JS to show icons for the accepted credit cards
             $creditCardTypes = CRM_Core_Payment_Form::getCreditCardCSSNames();
             CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Core/BillingBlock.js', 10)->addScript('CRM.config.creditCardTypes = ' . json_encode($creditCardTypes) . ';');
         }
     }
     $form->assign('paymentProcessorID', $form->_paymentProcessorID);
 }
Example #9
0
 /** 
  * 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']);
 }
/**
 * 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'));
}