/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { $this->assignToTemplate(); if ($this->_params[0]['amount'] || $this->_params[0]['amount'] == 0) { $this->_amount = array(); foreach ($this->_params as $k => $v) { if (is_array($v)) { if (CRM_Utils_Array::value("email-{$this->_bltID}", $v)) { $append = $v["email-{$this->_bltID}"]; } else { $append = $v['first_name'] . ' ' . $v['last_name']; } $this->_amount[$k]['amount'] = $v['amount']; if (CRM_Utils_Array::value('discountAmount', $v)) { $this->_amount[$k]['amount'] -= $v['discountAmount']; } $this->_amount[$k]['label'] = $v['amount_level'] . ' - ' . $append; $this->_totalAmount = $this->_totalAmount + $this->_amount[$k]['amount']; if (CRM_Utils_Array::value('is_primary', $v)) { $this->set('primaryParticipantAmount', $this->_amount[$k]['amount']); } } } $this->assign('amount', $this->_amount); $this->assign('totalAmount', $this->_totalAmount); $this->set('totalAmount', $this->_totalAmount); } $config =& CRM_Core_Config::singleton(); $this->buildCustom($this->_values['custom_pre_id'], 'customPre', true); $this->buildCustom($this->_values['custom_post_id'], 'customPost', true); $this->assign('lineItem', $this->_lineItem); //display additional participants profile. require_once 'CRM/Event/BAO/Event.php'; $participantParams = $this->_params; $formattedValues = array(); $count = 1; foreach ($participantParams as $participantNum => $participantValue) { if ($participantNum && $participantValue != 'skip') { //get the customPre profile info if (CRM_Utils_Array::value('additional_custom_pre_id', $this->_values)) { $values = array(); $groupName = array(); CRM_Event_BAO_Event::displayProfile($participantValue, $this->_values['additional_custom_pre_id'], $groupName, $values); if (count($values)) { $formattedValues[$count]['additionalCustomPre'] = $values; } $formattedValues[$count]['additionalCustomPreGroupTitle'] = CRM_Utils_Array::value('groupTitle', $groupName); } //get the customPost profile info if (CRM_Utils_Array::value('additional_custom_post_id', $this->_values)) { $values = array(); $groupName = array(); CRM_Event_BAO_Event::displayProfile($participantValue, $this->_values['additional_custom_post_id'], $groupName, $values); if (count($values)) { $formattedValues[$count]['additionalCustomPost'] = $values; } $formattedValues[$count]['additionalCustomPostGroupTitle'] = CRM_Utils_Array::value('groupTitle', $groupName); } $count++; } } if (!empty($formattedValues) && $count > 1) { $this->assign('addParticipantProfile', $formattedValues); } if ($this->_params[0]['amount'] == 0) { $this->assign('isAmountzero', 1); } if ($this->_paymentProcessor['payment_processor_type'] == 'Google_Checkout' && !CRM_Utils_Array::value('is_pay_later', $this->_params[0]) && !($this->_params[0]['amount'] == 0) && !$this->_allowWaitlist && !$this->_requireApproval) { $this->_checkoutButtonName = $this->getButtonName('next', 'checkout'); $this->add('image', $this->_checkoutButtonName, $this->_paymentProcessor['url_button'], array('class' => 'form-submit')); $this->addButtons(array(array('type' => 'back', 'name' => ts('<< Go Back')))); } else { $contribButton = ts('Continue >>'); $this->addButtons(array(array('type' => 'back', 'spacing' => ' ', 'name' => ts('<< Go Back')), array('type' => 'next', 'name' => $contribButton, 'isDefault' => true, 'js' => array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');")))); } $defaults = array(); $fields = array(); if (!empty($this->_fields)) { foreach ($this->_fields as $name => $dontCare) { $fields[$name] = 1; } } $fields["billing_state_province-{$this->_bltID}"] = $fields["billing_country-{$this->_bltID}"] = $fields["email-{$this->_bltID}"] = 1; foreach ($fields as $name => $dontCare) { if (isset($this->_params[0][$name])) { $defaults[$name] = $this->_params[0][$name]; if (substr($name, 0, 7) == 'custom_') { $timeField = "{$name}_time"; if (isset($this->_params[0][$timeField])) { $defaults[$timeField] = $this->_params[0][$timeField]; } } else { if (in_array($name, array('addressee', 'email_greeting', 'postal_greeting')) && CRM_Utils_Array::value($name . '_custom', $this->_params[0])) { $defaults[$name . '_custom'] = $this->_params[0][$name . '_custom']; } } } } // now fix all state country selectors require_once 'CRM/Core/BAO/Address.php'; CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults); $this->setDefaults($defaults); $this->freeze(); //lets give meaningful status message, CRM-4320. $this->assign('isOnWaitlist', $this->_allowWaitlist); $this->assign('isRequireApproval', $this->_requireApproval); }
/** * Assign Profiles. * * @param CRM_Core_Form $form */ public static function assignProfiles(&$form) { $participantParams = $form->_params; $formattedValues = $profileFields = array(); $count = 1; foreach ($participantParams as $participantNum => $participantValue) { if ($participantNum) { $prefix1 = 'additional'; $prefix2 = 'additional_'; } else { $prefix1 = ''; $prefix2 = ''; } if ($participantValue != 'skip') { //get the customPre profile info if (!empty($form->_values[$prefix2 . 'custom_pre_id'])) { $values = $groupName = array(); CRM_Event_BAO_Event::displayProfile($participantValue, $form->_values[$prefix2 . 'custom_pre_id'], $groupName, $values, $profileFields); if (count($values)) { $formattedValues[$count][$prefix1 . 'CustomPre'] = $values; } $formattedValues[$count][$prefix1 . 'CustomPreGroupTitle'] = CRM_Utils_Array::value('groupTitle', $groupName); } //get the customPost profile info if (!empty($form->_values[$prefix2 . 'custom_post_id'])) { $values = $groupName = array(); foreach ($form->_values[$prefix2 . 'custom_post_id'] as $gids) { $val = array(); CRM_Event_BAO_Event::displayProfile($participantValue, $gids, $group, $val, $profileFields); $values[$gids] = $val; $groupName[$gids] = $group; } if (count($values)) { $formattedValues[$count][$prefix1 . 'CustomPost'] = $values; } if (isset($formattedValues[$count][$prefix1 . 'CustomPre'])) { $formattedValues[$count][$prefix1 . 'CustomPost'] = array_diff_assoc($formattedValues[$count][$prefix1 . 'CustomPost'], $formattedValues[$count][$prefix1 . 'CustomPre']); } $formattedValues[$count][$prefix1 . 'CustomPostGroupTitle'] = $groupName; } $count++; } $form->_fields = $profileFields; } if (!empty($formattedValues)) { $form->assign('primaryParticipantProfile', $formattedValues[1]); $form->set('primaryParticipantProfile', $formattedValues[1]); if ($count > 2) { unset($formattedValues[1]); $form->assign('addParticipantProfile', $formattedValues); $form->set('addParticipantProfile', $formattedValues); } } }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { $this->assignToTemplate(); if ($this->_params[0]['amount'] || $this->_params[0]['amount'] == 0) { $this->_amount = array(); foreach ($this->_params as $k => $v) { if (is_array($v)) { foreach (array('first_name', 'last_name') as $name) { if (isset($v['billing_' . $name]) && !isset($v[$name])) { $v[$name] = $v['billing_' . $name]; } } if (CRM_Utils_Array::value('first_name', $v) && CRM_Utils_Array::value('last_name', $v)) { $append = $v['first_name'] . ' ' . $v['last_name']; } else { //use an email if we have one foreach ($v as $v_key => $v_val) { if (substr($v_key, 0, 6) == 'email-') { $append = $v[$v_key]; } } } $this->_amount[$k]['amount'] = $v['amount']; if (CRM_Utils_Array::value('discountAmount', $v)) { $this->_amount[$k]['amount'] -= $v['discountAmount']; } $this->_amount[$k]['label'] = preg_replace('//', '', $v['amount_level']) . ' - ' . $append; $this->_part[$k]['info'] = CRM_Utils_Array::value('first_name', $v) . ' ' . CRM_Utils_Array::value('last_name', $v); if (!CRM_Utils_Array::value('first_name', $v)) { $this->_part[$k]['info'] = $append; } $this->_totalAmount = $this->_totalAmount + $this->_amount[$k]['amount']; if (CRM_Utils_Array::value('is_primary', $v)) { $this->set('primaryParticipantAmount', $this->_amount[$k]['amount']); } } } $this->assign('part', $this->_part); $this->set('part', $this->_part); $this->assign('amounts', $this->_amount); $this->assign('totalAmount', $this->_totalAmount); $this->set('totalAmount', $this->_totalAmount); } $config = CRM_Core_Config::singleton(); $this->buildCustom($this->_values['custom_pre_id'], 'customPre', TRUE); $this->buildCustom($this->_values['custom_post_id'], 'customPost', TRUE); if ($this->_priceSetId && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $this->_priceSetId, 'is_quick_config')) { $this->assign('lineItem', $this->_lineItem); } //display additional participants profile. $participantParams = $this->_params; $formattedValues = array(); $count = 1; foreach ($participantParams as $participantNum => $participantValue) { if ($participantNum && $participantValue != 'skip') { //get the customPre profile info if (CRM_Utils_Array::value('additional_custom_pre_id', $this->_values)) { $values = $groupName = array(); CRM_Event_BAO_Event::displayProfile($participantValue, $this->_values['additional_custom_pre_id'], $groupName, $values); if (count($values)) { $formattedValues[$count]['additionalCustomPre'] = $values; } $formattedValues[$count]['additionalCustomPreGroupTitle'] = CRM_Utils_Array::value('groupTitle', $groupName); } //get the customPost profile info if (CRM_Utils_Array::value('additional_custom_post_id', $this->_values)) { $values = $groupName = array(); foreach ($this->_values['additional_custom_post_id'] as $gids) { $val = array(); CRM_Event_BAO_Event::displayProfile($participantValue, $gids, $group, $val); $values[$gids] = $val; $groupName[$gids] = $group; } if (count($values)) { $formattedValues[$count]['additionalCustomPost'] = $values; } if (isset($formattedValues[$count]['additionalCustomPre'])) { $formattedValues[$count]['additionalCustomPost'] = array_diff_assoc($formattedValues[$count]['additionalCustomPost'], $formattedValues[$count]['additionalCustomPre']); } $formattedValues[$count]['additionalCustomPostGroupTitle'] = $groupName; } $count++; } } if (!empty($formattedValues) && $count > 1) { $this->assign('addParticipantProfile', $formattedValues); $this->set('addParticipantProfile', $formattedValues); } //cosider total amount. $this->assign('isAmountzero', $this->_totalAmount <= 0 ? TRUE : FALSE); if ($this->_paymentProcessor['payment_processor_type'] == 'Google_Checkout' && !CRM_Utils_Array::value('is_pay_later', $this->_params[0]) && !($this->_params[0]['amount'] == 0) && !$this->_allowWaitlist && !$this->_requireApproval) { $this->_checkoutButtonName = $this->getButtonName('next', 'checkout'); $this->add('image', $this->_checkoutButtonName, $this->_paymentProcessor['url_button'], array('class' => 'form-submit')); $this->addButtons(array(array('type' => 'back', 'name' => ts('<< Go Back')))); } else { $contribButton = ts('Continue'); $this->addButtons(array(array('type' => 'next', 'name' => $contribButton, 'isDefault' => TRUE, 'js' => array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');")), array('type' => 'back', 'spacing' => ' ', 'name' => ts('Go Back')))); } $defaults = array(); $fields = array(); if (!empty($this->_fields)) { foreach ($this->_fields as $name => $dontCare) { $fields[$name] = 1; } } $fields["billing_state_province-{$this->_bltID}"] = $fields["billing_country-{$this->_bltID}"] = $fields["email-{$this->_bltID}"] = 1; foreach ($fields as $name => $dontCare) { if (isset($this->_params[0][$name])) { $defaults[$name] = $this->_params[0][$name]; if (substr($name, 0, 7) == 'custom_') { $timeField = "{$name}_time"; if (isset($this->_params[0][$timeField])) { $defaults[$timeField] = $this->_params[0][$timeField]; } if (isset($this->_params[0]["{$name}_id"])) { $defaults["{$name}_id"] = $this->_params[0]["{$name}_id"]; } } elseif (in_array($name, CRM_Contact_BAO_Contact::$_greetingTypes) && !empty($this->_params[0][$name . '_custom'])) { $defaults[$name . '_custom'] = $this->_params[0][$name . '_custom']; } } } // now fix all state country selectors CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults); $this->setDefaults($defaults); $this->freeze(); //lets give meaningful status message, CRM-4320. $this->assign('isOnWaitlist', $this->_allowWaitlist); $this->assign('isRequireApproval', $this->_requireApproval); // Assign Participant Count to Lineitem Table $this->assign('pricesetFieldsCount', CRM_Price_BAO_Set::getPricesetCount($this->_priceSetId)); }