public $financial_type_id;
public $description;
public $line_items;
- public $_fields = array();
+ public $_fields = [];
public $_paymentProcessor;
public $total;
public $sub_total;
// handle register date CRM-4320
$registerDate = date('YmdHis');
- $participantParams = array(
+ $participantParams = [
'id' => $participant->id,
'event_id' => $event->id,
'register_date' => $registerDate,
//XXX why is this a ref to participant and not contact?:
//'registered_by_id' => $this->payer_contact_id,
'fee_currency' => CRM_Utils_Array::value('currencyID', $params),
- );
+ ];
if ($participant->must_wait) {
$participant_status = 'On waitlist';
if (self::is_administrator()) {
if (!empty($params['note'])) {
- $note_params = array(
+ $note_params = [
'participant_id' => $participant->id,
'contact_id' => self::getContactID(),
'note' => $params['note'],
- );
+ ];
CRM_Event_BAO_Participant::update_note($note_params);
}
}
$participant->save();
if (!empty($params['contributionID'])) {
- $payment_params = array(
+ $payment_params = [
'participant_id' => $participant->id,
'contribution_id' => $params['contributionID'],
- );
+ ];
CRM_Event_BAO_ParticipantPayment::create($payment_params);
}
$transaction->commit();
- $event_values = array();
+ $event_values = [];
CRM_Core_DAO::storeValues($event, $event_values);
- $location = array();
+ $location = [];
if (CRM_Utils_Array::value('is_show_location', $event_values) == 1) {
- $locationParams = array(
+ $locationParams = [
'entity_id' => $participant->event_id,
'entity_table' => 'civicrm_event',
- );
+ ];
$location = CRM_Core_BAO_Location::getValues($locationParams, TRUE);
CRM_Core_BAO_Address::fixAddress($location['address'][1]);
}
list($pre_id, $post_id) = CRM_Event_Cart_Form_MerParticipant::get_profile_groups($participant->event_id);
- $payer_values = array(
+ $payer_values = [
'email' => '',
'name' => '',
- );
+ ];
if ($this->payer_contact_id) {
$payer_contact_details = CRM_Contact_BAO_Contact::getContactDetails($this->payer_contact_id);
- $payer_values = array(
+ $payer_values = [
'email' => $payer_contact_details[1],
'name' => $payer_contact_details[0],
- );
+ ];
}
- $values = array(
- 'params' => array($participant->id => $participantParams),
+ $values = [
+ 'params' => [$participant->id => $participantParams],
'event' => $event_values,
'location' => $location,
'custom_pre_id' => $pre_id,
'custom_post_id' => $post_id,
'payer' => $payer_values,
- );
+ ];
CRM_Event_BAO_Event::sendMail($participant->contact_id, $values, $participant->id);
return $participant;
);
$this->assign('pay_later_instructions', $this->pay_later_receipt);
}
+
+ // Event Cart does not support multiple payment processors
+ // so we cannot call $this->preProcessPaymentOptions();
+ CRM_Financial_Form_Payment::addCreditCardJs($this->_paymentProcessor['id']);
}
/**
*/
public function buildQuickForm() {
- $this->line_items = array();
+ $this->line_items = [];
$this->sub_total = 0;
$this->_price_values = $this->getValuesForPage('ParticipantsAndPrices');
$this->assign('line_items', $this->line_items);
$this->assign('sub_total', $this->sub_total);
$this->assign('total', $this->total);
- $buttons = array();
- $buttons[] = array(
+ $buttons = [];
+ $buttons[] = [
'name' => ts('Go Back'),
'spacing' => '  ',
'type' => 'back',
- );
- $buttons[] = array(
+ ];
+ $buttons[] = [
'isDefault' => TRUE,
'name' => ts('Complete Transaction'),
'spacing' => ' ',
'type' => 'next',
- );
+ ];
if ($this->total) {
$this->add('text', 'billing_contact_email', 'Billing Email', '', TRUE);
}
if (self::is_administrator()) {
$this->add('textarea', 'note', 'Note');
- $this->add('text', 'source', 'Source', array('size' => 80));
- $instruments = array();
+ $this->add('text', 'source', 'Source', ['size' => 80]);
+ $instruments = [];
CRM_Core_OptionGroup::getAssoc('payment_instrument', $instruments, TRUE);
- $options = array();
+ $options = [];
foreach ($instruments as $type) {
$options[] = $this->createElement('radio', NULL, '', $type['label'], $type['value']);
}
$this->addGroup($options, 'payment_type', ts("Alternative Payment Type"));
- $this->add('text', 'check_number', ts('Check No.'), array('size' => 20));
+ $this->add('text', 'check_number', ts('Check No.'), ['size' => 20]);
$this->addElement('checkbox', 'is_pending', ts('Create a pending registration'));
$this->assign('administrator', TRUE);
}
$this->addButtons($buttons);
- $this->addFormRule(array('CRM_Event_Cart_Form_Checkout_Payment', 'formRule'), $this);
+ $this->addFormRule(['CRM_Event_Cart_Form_Checkout_Payment', 'formRule'], $this);
if ($this->payment_required) {
$this->buildPaymentFields();
$price_set_id = CRM_Price_BAO_PriceSet::getFor("civicrm_event", $event_in_cart->event_id);
$amount_level = NULL;
if ($price_set_id) {
- $event_price_values = array();
+ $event_price_values = [];
foreach ($this->_price_values as $key => $value) {
if (preg_match("/event_{$event_in_cart->event_id}_(price.*)/", $key, $matches)) {
$event_price_values[$matches[1]] = $value;
}
$price_sets = CRM_Price_BAO_PriceSet::getSetDetail($price_set_id, TRUE);
$price_set = $price_sets[$price_set_id];
- $price_set_amount = array();
+ $price_set_amount = [];
CRM_Price_BAO_PriceSet::processAmount($price_set['fields'], $event_price_values, $price_set_amount);
$discountCode = $this->_price_values['discountcode'];
if (!empty($discountCode)) {
public function add_line_item($event_in_cart, $class = NULL) {
$amount = 0;
$cost = 0;
- $not_waiting_participants = array();
+ $not_waiting_participants = [];
foreach ($event_in_cart->not_waiting_participants() as $participant) {
$amount += $participant->cost;
$cost = max($cost, $participant->cost);
- $not_waiting_participants[] = array(
+ $not_waiting_participants[] = [
'display_name' => CRM_Contact_BAO_Contact::displayName($participant->contact_id),
- );
+ ];
}
- $waiting_participants = array();
+ $waiting_participants = [];
foreach ($event_in_cart->waiting_participants() as $participant) {
- $waiting_participants[] = array(
+ $waiting_participants[] = [
'display_name' => CRM_Contact_BAO_Contact::displayName($participant->contact_id),
- );
+ ];
}
- $this->line_items[] = array(
+ $this->line_items[] = [
'amount' => $amount,
'cost' => $cost,
'event' => $event_in_cart->event,
'num_waiting_participants' => count($waiting_participants),
'waiting_participants' => $waiting_participants,
'class' => $class,
- );
+ ];
$this->sub_total += $amount;
}
$country->find();
$country->fetch();
foreach ($this->line_items as & $line_item) {
- $location_params = array('entity_id' => $line_item['event']->id, 'entity_table' => 'civicrm_event');
+ $location_params = ['entity_id' => $line_item['event']->id, 'entity_table' => 'civicrm_event'];
$line_item['location'] = CRM_Core_BAO_Location::getValues($location_params, TRUE);
CRM_Core_BAO_Address::fixAddress($line_item['location']['address'][1]);
}
- $send_template_params = array(
+ $send_template_params = [
'table' => 'civicrm_msg_template',
'contactId' => $this->payer_contact_id,
- 'from' => CRM_Core_BAO_Domain::getNameAndEmail(TRUE, TRUE),
+ 'from' => current(CRM_Core_BAO_Domain::getNameAndEmail(TRUE, TRUE)),
'groupName' => 'msg_tpl_workflow_event',
'isTest' => FALSE,
'toEmail' => $contact_details[1],
'toName' => $contact_details[0],
- 'tplParams' => array(
+ 'tplParams' => [
'billing_name' => "{$params['billing_first_name']} {$params['billing_last_name']}",
'billing_city' => $params["billing_city-{$this->_bltID}"],
'billing_country' => $country->name,
'transaction_date' => $params['trxn_date'],
'is_pay_later' => $this->is_pay_later,
'pay_later_receipt' => $this->pay_later_receipt,
- ),
+ ],
'valueName' => 'event_registration_receipt',
'PDFFilename' => ts('confirmation') . '.pdf',
- );
- $template_params_to_copy = array(
+ ];
+ $template_params_to_copy = [
'billing_name',
'billing_city',
'billing_country',
'credit_card_exp_date',
'credit_card_type',
'credit_card_number',
- );
+ ];
foreach ($template_params_to_copy as $template_param_to_copy) {
$this->set($template_param_to_copy, $send_template_params['tplParams'][$template_param_to_copy]);
}
* @return array|bool
*/
public static function formRule($fields, $files, $self) {
- $errors = array();
+ $errors = [];
if ($self->payment_required && empty($self->_submitValues['is_pay_later'])) {
CRM_Core_Form::validateMandatoryFields($self->_fields, $fields, $errors);
$main_participants = $this->cart->get_main_event_participants();
foreach ($main_participants as $participant) {
- $defaults = array();
- $ids = array('contact_id' => $participant->contact_id);
+ $defaults = [];
+ $ids = ['contact_id' => $participant->contact_id];
$contact = CRM_Contact_BAO_Contact::retrieve($ids, $defaults);
$contact->is_deleted = 0;
$contact->save();
$trxn_prefix = 'VR';
if (array_key_exists('billing_contact_email', $params)) {
- $this->payer_contact_id = self::find_or_create_contact($this->getContactID(), array(
+ $this->payer_contact_id = self::find_or_create_contact($this->getContactID(), [
'email' => $params['billing_contact_email'],
'first_name' => $params['billing_first_name'],
'last_name' => $params['billing_last_name'],
'is_deleted' => FALSE,
- ));
+ ]);
$ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',
$this->payer_contact_id,
'contact_type'
);
- $billing_fields = array(
+ $billing_fields = [
"billing_first_name" => 1,
"billing_middle_name" => 1,
"billing_last_name" => 1,
"billing_country_id-{$this->_bltID}" => 1,
"address_name-{$this->_bltID}" => 1,
"email-{$this->_bltID}" => 1,
- );
+ ];
$params["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . CRM_Utils_Array::value('billing_last_name', $params);
$ctype,
TRUE
);
+
+ $params['contact_id'] = $this->payer_contact_id;
}
$params['now'] = date('YmdHis');
// n.b. we need to process the subparticipants before main event
// participants so that session attendance can be included in the email
$main_participants = $this->cart->get_main_event_participants();
- $this->all_participants = array();
+ $this->all_participants = [];
foreach ($main_participants as $main_participant) {
$this->all_participants = array_merge($this->all_participants, $this->cart->get_subparticipants($main_participant));
}
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/cart_checkout', "_qf_Payment_display=1&qfKey={$this->controller->_key}", TRUE, NULL, FALSE));
}
- $trxnDetails = array(
+ $trxnDetails = [
'trxn_id' => $result['trxn_id'],
'trxn_date' => $result['now'],
'currency' => CRM_Utils_Array::value('currencyID', $result),
- );
+ ];
return $trxnDetails;
}
$payer = $params['participant_contact_id'];
}
- $contribParams = array(
+ $contribParams = [
'contact_id' => $payer,
'financial_type_id' => $params['financial_type_id'],
'receive_date' => $params['now'],
'payment_instrument_id' => $params['payment_instrument_id'],
'check_number' => CRM_Utils_Array::value('check_number', $params),
'skipLineItem' => 1,
- );
+ ];
if (is_array($this->_paymentProcessor)) {
$contribParams['payment_processor'] = $this->_paymentProcessor['id'];
* Save data to session.
*/
public function saveDataToSession() {
- $session_line_items = array();
+ $session_line_items = [];
foreach ($this->line_items as $line_item) {
- $session_line_item = array();
+ $session_line_item = [];
$session_line_item['amount'] = $line_item['amount'];
$session_line_item['cost'] = $line_item['cost'];
$session_line_item['event_id'] = $line_item['event']->id;
$defaults["billing_country_id-{$this->_bltID}"] = $default_country->id;
if (self::getContactID() && !self::is_administrator()) {
- $params = array('id' => self::getContactID());
+ $params = ['id' => self::getContactID()];
$contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults);
foreach ($contact->email as $email) {
*/
protected function apply_discount($discountCode, &$price_set_amount, &$cost, $event_id) {
//need better way to determine if cividiscount installed
- $autoDiscount = array();
+ $autoDiscount = [];
$sql = "select is_active from civicrm_extension where name like 'CiviDiscount%'";
$dao = CRM_Core_DAO::executeQuery($sql, '');
while ($dao->fetch()) {