<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
class CRM_Contribute_Form_Contribution_OnBehalfOf {
/**
- * Function to set variables up before form is built
+ * Set variables up before form is built
*
- * @param $form
+ * @param CRM_Core_Form $form
*
* @return void
- * @access public
*/
- static function preProcess(&$form) {
+ public static function preProcess(&$form) {
$session = CRM_Core_Session::singleton();
$contactID = $form->_contactID;
}
$locDataURL = CRM_Utils_System::url('civicrm/ajax/permlocation', $args, FALSE, NULL, FALSE);
$form->assign('locDataURL', $locDataURL);
+
+ if (!empty($form->_submitValues['onbehalf'])) {
+ if (!empty($form->_submitValues['onbehalfof_id'])) {
+ $form->assign('submittedOnBehalf', $form->_submitValues['onbehalfof_id']);
+ }
+ $form->assign('submittedOnBehalfInfo', json_encode($form->_submitValues['onbehalf']));
+ }
}
if ($form->_values['is_for_organization'] != 2) {
}
/**
- * Function to build form for related contacts / on behalf of organization.
- *
- * @param $form object invoking Object
+ * Build form for related contacts / on behalf of organization.
*
- * @internal param string $contactType contact type
- * @internal param string $title fieldset title
+ * @param CRM_Core_Form $form
*
* @static
*/
- static function buildQuickForm(&$form) {
+ public static function buildQuickForm(&$form) {
$form->assign('fieldSetTitle', ts('Organization Details'));
$form->assign('buildOnBehalfForm', TRUE);
$fieldTypes = array_merge($fieldTypes, array('Contribution'));
}
- $stateCountryMap = array();
foreach ($profileFields as $name => $field) {
if (in_array($field['field_type'], $fieldTypes)) {
list($prefixName, $index) = CRM_Utils_System::explode('-', $name, 2);
- if (in_array($prefixName, array(
- 'state_province', 'country', 'county'))) {
- if (!array_key_exists($index, $stateCountryMap)) {
- $stateCountryMap[$index] = array();
- }
-
- $stateCountryMap[$index][$prefixName] = 'onbehalf[' . $name . ']';
-
- if (count($form->_submitValues)) {
- $locationTypeId = $field['location_type_id'];
- if (!empty($form->_submitValues['onbehalf']["country-{$locationTypeId}"]) &&
- $prefixName == "state_province") {
- $field['is_required'] = CRM_Core_Payment_Form::checkRequiredStateProvince($form, "country-{$locationTypeId}", TRUE);
- }
- }
- }
- elseif (in_array($prefixName, array(
- 'organization_name', 'email')) && empty($field['is_required'])) {
+ if (in_array($prefixName, array('organization_name', 'email')) && empty($field['is_required'])) {
$field['is_required'] = 1;
}
}
}
- if (!empty($stateCountryMap)) {
- CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
-
- // now fix all state country selectors
- CRM_Core_BAO_Address::fixAllStateSelects($form, CRM_Core_DAO::$_nullArray);
- }
-
$form->assign('onBehalfOfFields', $profileFields);
$form->addElement('hidden', 'hidden_onbehalf_profile', 1);
}
}
-