本文整理汇总了PHP中CRM_Core_PseudoConstant::stateProvince方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_PseudoConstant::stateProvince方法的具体用法?PHP CRM_Core_PseudoConstant::stateProvince怎么用?PHP CRM_Core_PseudoConstant::stateProvince使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_PseudoConstant
的用法示例。
在下文中一共展示了CRM_Core_PseudoConstant::stateProvince方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: evaluateToken
/**
* Evaluate the content of a single token.
*
* @param \Civi\Token\TokenRow $row
* The record for which we want token values.
* @param string $field
* The name of the token field.
* @param mixed $prefetch
* Any data that was returned by the prefetch().
* @return mixed
*/
public function evaluateToken(\Civi\Token\TokenRow $row, $entity, $field, $prefetch = NULL)
{
$actionSearchResult = $row->context['actionSearchResult'];
if ($field == 'location') {
$loc = array();
$stateProvince = \CRM_Core_PseudoConstant::stateProvince();
$loc['street_address'] = $actionSearchResult->street_address;
$loc['city'] = $actionSearchResult->city;
$loc['state_province'] = \CRM_Utils_Array::value($actionSearchResult->state_province_id, $stateProvince);
$loc['postal_code'] = $actionSearchResult->postal_code;
//$entityTokenParams[$tokenEntity][$field] = \CRM_Utils_Address::format($loc);
$row->tokens($entity, $field, \CRM_Utils_Address::format($loc));
} elseif ($field == 'info_url') {
$row->tokens($entity, $field, \CRM_Utils_System::url('civicrm/event/info', 'reset=1&id=' . $actionSearchResult->event_id, TRUE, NULL, FALSE));
} elseif ($field == 'registration_url') {
$row->tokens($entity, $field, \CRM_Utils_System::url('civicrm/event/register', 'reset=1&id=' . $actionSearchResult->event_id, TRUE, NULL, FALSE));
} elseif (in_array($field, array('start_date', 'end_date'))) {
$row->tokens($entity, $field, \CRM_Utils_Date::customFormat($actionSearchResult->{$field}));
} elseif ($field == 'balance') {
if ($actionSearchResult->entityTable == 'civicrm_contact') {
$balancePay = 'N/A';
} elseif (!empty($actionSearchResult->entityID)) {
$info = \CRM_Contribute_BAO_Contribution::getPaymentInfo($actionSearchResult->entityID, 'event');
$balancePay = \CRM_Utils_Array::value('balance', $info);
$balancePay = \CRM_Utils_Money::format($balancePay);
}
$row->tokens($entity, $field, $balancePay);
} elseif ($field == 'fee_amount') {
$row->tokens($entity, $field, \CRM_Utils_Money::format($actionSearchResult->{$field}));
} elseif (isset($actionSearchResult->{$field})) {
$row->tokens($entity, $field, $actionSearchResult->{$field});
} else {
$row->tokens($entity, $field, '');
}
}
示例2: __construct
function __construct()
{
$this->_exposeContactID = $this->_emailField = FALSE;
$this->_customGroupJoin = 'LEFT JOIN';
$this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name' => array('title' => ts('Name'), 'required' => TRUE), 'id' => array('no_display' => TRUE, 'required' => TRUE), 'gender' => array()), 'filters' => array('sort_name' => array('title' => ts('Name'), 'operator' => 'like'), 'id' => array('title' => ts('Contact ID'), 'no_display' => TRUE, 'type' => CRM_Utils_Type::T_INT), 'gender' => array()), 'order_bys' => array('sort_name' => array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC'), 'id' => array('title' => ts('Contact ID'), 'default' => '1', 'default_weight' => '1', 'default_order' => 'ASC')), 'grouping' => array('contact-fields' => ts('Personal Details'))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('default' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'fields' => array('city' => array('title' => ts('Work City')), 'postal_code' => array('title' => ts('Work Postal Code')), 'state_province_id' => array('title' => ts('Work State/Province')), 'country_id' => array('title' => ts('Work Country'))), 'filters' => array('city' => array('title' => ts('Work City')), 'postal_code' => array('title' => ts('Work Postal Code')), 'state_province_id' => array('title' => ts('Work State/Province'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince()), 'country_id' => array('title' => ts('Work Country'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country())), 'grouping' => 'contact-fields'), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_GroupContact', 'alias' => 'cgroup', 'filters' => array('gid' => array('name' => 'group_id', 'title' => ts('Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => TRUE, 'options' => CRM_Core_PseudoConstant::group(), 'type' => CRM_Utils_Type::T_INT))), 'civicrm_hrjobcontract' => array('dao' => 'CRM_Hrjobcontract_DAO_HRJobContract', 'fields' => array('is_primary' => array('title' => ts('Job Is Primary?'), 'no_repeat' => TRUE, 'dbAlias' => 'hrjobcontract_civireport.is_primary')), 'filters' => array('is_primary' => array('title' => ts('Job Is Primary?'), 'default' => 1, 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => ts('Any'), '0' => ts('No'), '1' => ts('Yes'))), 'current_employee' => array('default' => NULL, 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => ts('ANY'), '0' => ts('No'), '1' => ts('Yes')), 'no_display' => TRUE)), 'grouping' => array('job-fields' => 'Job')), 'civicrm_hrjobcontract_revision' => array('dao' => 'CRM_Hrjobcontract_DAO_HRJobContractRevision', 'fields' => array('jobcontract_revision_id' => array('title' => ts('Revision ID'), 'no_repeat' => TRUE, 'name' => 'id', 'no_display' => TRUE), 'editor_uid' => array('title' => ts('Editor UID'), 'no_repeat' => TRUE, 'name' => 'editor_uid', 'no_display' => TRUE), 'created_date' => array('title' => ts('Created date'), 'no_repeat' => TRUE, 'name' => 'created_date', 'no_display' => TRUE), 'modified_date' => array('title' => ts('Modified date'), 'no_repeat' => TRUE, 'name' => 'modified_date', 'no_display' => TRUE), 'effective_date' => array('title' => ts('Effective date'), 'no_repeat' => TRUE, 'name' => 'effective_date', 'no_display' => TRUE), 'change_reason' => array('title' => ts('Change reason'), 'no_repeat' => TRUE, 'name' => 'change_reason', 'no_display' => TRUE), 'status' => array('title' => ts('Revision status'), 'no_repeat' => TRUE, 'name' => 'status', 'no_display' => TRUE)), 'grouping' => array('job-fields' => 'Job'), 'order_bys' => array('civicrm_hrjobcontract_revision_revision_id' => array('title' => ts('Revision Id'), 'dbAlias' => 'hrjobcontract_revision_civireport.id')), 'group_bys' => array('civicrm_hrjobcontract_revision_revision_id' => array('title' => ts('Revision Id'), 'dbAlias' => 'hrjobcontract_revision_civireport.id'))), 'civicrm_hrjobcontract_details' => array('dao' => 'CRM_Hrjobcontract_DAO_HRJobDetails', 'fields' => array('hrjobcontract_details_title' => array(), 'hrjobcontract_details_contract_type' => array(), 'hrjobcontract_details_location' => array(), 'hrjobcontract_details_position' => array(), 'hrjobcontract_details_period_start_date' => array(), 'hrjobcontract_details_period_end_date' => array()), 'filters' => array('hrjobcontract_details_title' => array(), 'hrjobcontract_details_contract_type' => array(), 'hrjobcontract_details_location' => array(), 'hrjobcontract_details_position' => array(), 'hrjobcontract_details_period_start_date' => array(), 'hrjobcontract_details_period_end_date' => array()), 'grouping' => array('job-fields' => 'Job')), 'civicrm_hrjobcontract_health' => array('dao' => 'CRM_Hrjobcontract_DAO_HRJobHealth', 'fields' => array('hrjobcontract_health_health_provider_life_insurance' => array(), 'hrjobcontract_health_life_insurance_plan_type' => array(), 'hrjobcontract_health_health_provider' => array(), 'hrjobcontract_health_health_plan_type' => array()), 'filters' => array('hrjobcontract_health_life_insurance_plan_type' => array(), 'hrjobcontract_health_health_plan_type' => array()), 'grouping' => array('job-fields' => 'Job')), 'civicrm_hrjobcontract_health_provider' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('organization_name' => array('title' => ts('Job Healthcare Provider'), 'no_repeat' => TRUE, 'no_display' => TRUE, 'required' => TRUE), 'id' => array('no_display' => TRUE, 'required' => TRUE)), 'filters' => array('organization_name' => array('title' => ts('Job Healthcare Provider'), 'operatorType' => CRM_Report_Form::OP_STRING))), 'civicrm_hrjobcontract_health_life_provider' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('display_name' => array('title' => ts('Job life insurance Provider'), 'no_repeat' => TRUE, 'no_display' => TRUE, 'required' => TRUE), 'id' => array('no_display' => TRUE, 'required' => TRUE)), 'filters' => array('display_name' => array('title' => ts('Job life insurance Provider'), 'operatorType' => CRM_Report_Form::OP_STRING))), 'civicrm_hrjobcontract_hour' => array('dao' => 'CRM_Hrjobcontract_DAO_HRJobHour', 'fields' => array('hrjobcontract_hour_hours_type' => array(), 'hrjobcontract_hour_hours_amount' => array(), 'hrjobcontract_hour_hours_unit' => array(), 'hrjobcontract_hour_hours_fte' => array()), 'filters' => array('hrjobcontract_hour_hours_type' => array(), 'hrjobcontract_hour_hours_amount' => array(), 'hrjobcontract_hour_hours_unit' => array(), 'hrjobcontract_hour_hours_fte' => array()), 'grouping' => array('job-fields' => 'Job')), 'civicrm_hrjobcontract_pay' => array('dao' => 'CRM_Hrjobcontract_DAO_HRJobPay', 'fields' => array('hrjobcontract_pay_is_paid' => array(), 'hrjobcontract_pay_pay_amount' => array(), 'hrjobcontract_pay_pay_unit' => array(), 'hrjobcontract_pay_pay_currency' => array(), 'hrjobcontract_pay_pay_annualized_est' => array()), 'filters' => array('hrjobcontract_pay_is_paid' => array(), 'hrjobcontract_pay_pay_amount' => array(), 'hrjobcontract_pay_pay_unit' => array(), 'hrjobcontract_pay_pay_annualized_est' => array()), 'grouping' => array('job-fields' => 'Job')), 'civicrm_hrjobcontract_pension' => array('dao' => 'CRM_Hrjobcontract_DAO_HRJobPension', 'fields' => array('hrjobcontract_pension_is_enrolled' => array()), 'filters' => array('hrjobcontract_pension_is_enrolled' => array()), 'grouping' => array('job-fields' => 'Job')), 'civicrm_hrjobcontract_role' => array('dao' => 'CRM_Hrjobcontract_DAO_HRJobRole', 'fields' => array('hrjobcontract_role_role_department' => array(), 'hrjobcontract_role_role_level_type' => array('name' => 'level_type', 'title' => ts('Role Level Types'), 'type' => CRM_Utils_Type::T_INT, 'grouping' => array('job-fields' => 'Job')), 'manager' => array('name' => 'manager_sort_name', 'title' => ts('Role Managers'), 'dbAlias' => 'manager.sort_name'), 'hrjob_role_manager_contact_id' => array('no_display' => TRUE, 'name' => 'manager_contact_id', 'title' => ts('Role Managers'), 'type' => CRM_Utils_Type::T_INT, 'grouping' => array('job-fields' => 'Job'))), 'filters' => array('hrjobcontract_role_role_department' => array(), 'hrjobcontract_role_role_level_type' => array()), 'grouping' => array('job-fields' => 'Job'))) + $this->addAddressFields(FALSE, TRUE);
parent::__construct();
}
示例3: __construct
/**
* @param $formValues
*
* @throws Exception
*/
public function __construct(&$formValues)
{
parent::__construct($formValues);
// unset search profile and other search params if set
unset($this->_formValues['uf_group_id']);
unset($this->_formValues['component_mode']);
unset($this->_formValues['operator']);
if (!empty($this->_formValues)) {
// add the country and state
if (!empty($this->_formValues['country_id'])) {
$this->_formValues['country'] = CRM_Core_PseudoConstant::country($this->_formValues['country_id']);
}
if (!empty($this->_formValues['state_province_id'])) {
$this->_formValues['state_province'] = CRM_Core_PseudoConstant::stateProvince($this->_formValues['state_province_id']);
}
// use the address to get the latitude and longitude
CRM_Utils_Geocode_Google::format($this->_formValues);
if (!is_numeric(CRM_Utils_Array::value('geo_code_1', $this->_formValues)) || !is_numeric(CRM_Utils_Array::value('geo_code_2', $this->_formValues)) || !isset($this->_formValues['distance'])) {
CRM_Core_Error::fatal(ts('Could not geocode input'));
}
$this->_latitude = $this->_formValues['geo_code_1'];
$this->_longitude = $this->_formValues['geo_code_2'];
if ($this->_formValues['prox_distance_unit'] == "miles") {
$conversionFactor = 1609.344;
} else {
$conversionFactor = 1000;
}
$this->_distance = $this->_formValues['distance'] * $conversionFactor;
}
$this->_group = CRM_Utils_Array::value('group', $this->_formValues);
$this->_tag = CRM_Utils_Array::value('tag', $this->_formValues);
$this->_columns = array(ts('Name') => 'sort_name', ts('Street Address') => 'street_address', ts('City') => 'city', ts('Postal Code') => 'postal_code', ts('State') => 'state_province', ts('Country') => 'country');
}
示例4: civicrm_pseudoconstant_stateProvince
function civicrm_pseudoconstant_stateProvince($params) {
$stateProvince = CRM_Core_PseudoConstant::stateProvince();
$return = array('stateProvince' => $stateProvince);
return $return;
}
示例5: _setPaymentFields
/**
* create all common fields needed for a credit card or direct debit transaction
*
* @return void
* @access protected
*/
protected function _setPaymentFields(&$form)
{
$bltID = $form->_bltID;
$form->_fields['billing_first_name'] = array('htmlType' => 'text', 'name' => 'billing_first_name', 'title' => ts('Billing First Name'), 'cc_field' => true, 'attributes' => array('size' => 30, 'maxlength' => 60, 'autocomplete' => 'off'), 'is_required' => true);
$form->_fields['billing_middle_name'] = array('htmlType' => 'text', 'name' => 'billing_middle_name', 'title' => ts('Billing Middle Name'), 'cc_field' => true, 'attributes' => array('size' => 30, 'maxlength' => 60, 'autocomplete' => 'off'), 'is_required' => false);
$form->_fields['billing_last_name'] = array('htmlType' => 'text', 'name' => 'billing_last_name', 'title' => ts('Billing Last Name'), 'cc_field' => true, 'attributes' => array('size' => 30, 'maxlength' => 60, 'autocomplete' => 'off'), 'is_required' => true);
$form->_fields["billing_street_address-{$bltID}"] = array('htmlType' => 'text', 'name' => "billing_street_address-{$bltID}", 'title' => ts('Street Address'), 'cc_field' => true, 'attributes' => array('size' => 30, 'maxlength' => 60, 'autocomplete' => 'off'), 'is_required' => true);
$form->_fields["billing_city-{$bltID}"] = array('htmlType' => 'text', 'name' => "billing_city-{$bltID}", 'title' => ts('City'), 'cc_field' => true, 'attributes' => array('size' => 30, 'maxlength' => 60, 'autocomplete' => 'off'), 'is_required' => true);
$form->_fields["billing_state_province_id-{$bltID}"] = array('htmlType' => 'select', 'name' => "billing_state_province_id-{$bltID}", 'title' => ts('State / Province'), 'cc_field' => true, 'attributes' => array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvince(), 'is_required' => true);
$form->_fields["billing_postal_code-{$bltID}"] = array('htmlType' => 'text', 'name' => "billing_postal_code-{$bltID}", 'title' => ts('Postal Code'), 'cc_field' => true, 'attributes' => array('size' => 30, 'maxlength' => 60, 'autocomplete' => 'off'), 'is_required' => true);
$form->_fields["billing_country_id-{$bltID}"] = array('htmlType' => 'select', 'name' => "billing_country_id-{$bltID}", 'title' => ts('Country'), 'cc_field' => true, 'attributes' => array('' => ts('- select -')) + CRM_Core_PseudoConstant::country(), 'is_required' => true);
}
示例6: buildForm
/**
* Prepare a set of search fields
*
* @param CRM_Core_Form $form modifiable
* @return void
*/
function buildForm(&$form)
{
CRM_Utils_System::setTitle(ts('My Search Title'));
$form->add('text', 'household_name', ts('Household Name'), TRUE);
$stateProvince = array('' => ts('- any state/province -')) + CRM_Core_PseudoConstant::stateProvince();
$form->addElement('select', 'state_province_id', ts('State/Province'), $stateProvince);
// Optionally define default search values
$form->setDefaults(array('household_name' => '', 'state_province_id' => NULL));
/**
* if you are using the standard template, this array tells the template what elements
* are part of the search criteria
*/
$form->assign('elements', array('household_name', 'state_province_id'));
}
示例7: typecheck
/**
* Validate a value against a CustomField type.
*
* @param string $type
* The type of the data.
* @param string $value
* The data to be validated.
*
* @return bool
* True if the value is of the specified type
*/
public static function typecheck($type, $value)
{
switch ($type) {
case 'Memo':
return TRUE;
case 'String':
return CRM_Utils_Rule::string($value);
case 'Int':
return CRM_Utils_Rule::integer($value);
case 'Float':
case 'Money':
return CRM_Utils_Rule::numeric($value);
case 'Date':
if (is_numeric($value)) {
return CRM_Utils_Rule::dateTime($value);
} else {
return CRM_Utils_Rule::date($value);
}
case 'Boolean':
return CRM_Utils_Rule::boolean($value);
case 'ContactReference':
return CRM_Utils_Rule::validContact($value);
case 'StateProvince':
//fix for multi select state, CRM-3437
$valid = FALSE;
$mulValues = explode(',', $value);
foreach ($mulValues as $key => $state) {
$valid = array_key_exists(strtolower(trim($state)), array_change_key_case(array_flip(CRM_Core_PseudoConstant::stateProvinceAbbreviation()), CASE_LOWER)) || array_key_exists(strtolower(trim($state)), array_change_key_case(array_flip(CRM_Core_PseudoConstant::stateProvince()), CASE_LOWER));
if (!$valid) {
break;
}
}
return $valid;
case 'Country':
//fix multi select country, CRM-3437
$valid = FALSE;
$mulValues = explode(',', $value);
foreach ($mulValues as $key => $country) {
$valid = array_key_exists(strtolower(trim($country)), array_change_key_case(array_flip(CRM_Core_PseudoConstant::countryIsoCode()), CASE_LOWER)) || array_key_exists(strtolower(trim($country)), array_change_key_case(array_flip(CRM_Core_PseudoConstant::country()), CASE_LOWER));
if (!$valid) {
break;
}
}
return $valid;
case 'Link':
return CRM_Utils_Rule::url($value);
}
return FALSE;
}
示例8: buildForm
/**
* Build form.
*
* @param CRM_Core_Form $form
*/
public function buildForm(&$form)
{
$form->add('text', 'household_name', ts('Household Name'), TRUE);
$stateProvince = array('' => ts('- any state/province -')) + CRM_Core_PseudoConstant::stateProvince();
$form->addElement('select', 'state_province_id', ts('State/Province'), $stateProvince);
/**
* You can define a custom title for the search form
*/
$this->setTitle(ts('My Search Title'));
/**
* if you are using the standard template, this array tells the template what elements
* are part of the search criteria
*/
$form->assign('elements', array('household_name', 'state_province_id'));
}
示例9: buildQuickForm
/**
* Function to actually build the form
*
* @return None
* @access public
*/
function buildQuickForm()
{
$this->add('text', 'sort_name', ts('Name or email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
// select for state province
$stateProvince = array('' => ts('- any state/province -')) + CRM_Core_PseudoConstant::stateProvince();
$this->addElement('select', 'state_province', ts('State/Province'), $stateProvince);
// select for country
$country = array('' => ts('- any country -')) + CRM_Core_PseudoConstant::country();
$this->addElement('select', 'country', ts('Country'), $country);
$this->addElement('date', 'birth_date', ts('Date of birth'), CRM_Core_SelectValues::date('birth'));
$this->addElement('date', 'scheduled_date_time', ts('Date and Time'), CRM_Core_SelectValues::date('datetime'));
$group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::group();
$this->addElement('select', 'group', ts('Groups'), $group);
$this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => true)));
}
示例10: _populateOptionAndCustomGroup
public function _populateOptionAndCustomGroup()
{
$dataValues = array('integer' => array(1, 2, 3), 'number' => array(10.11, 20.22, 30.33), 'string' => array(substr(sha1(rand()), 0, 4), substr(sha1(rand()), 0, 3), substr(sha1(rand()), 0, 2)), 'country' => array_rand(CRM_Core_PseudoConstant::country(FALSE, FALSE), 3), 'state_province' => array_rand(CRM_Core_PseudoConstant::stateProvince(FALSE, FALSE), 3), 'date' => NULL, 'contact' => NULL);
foreach ($dataValues as $dataType => $values) {
$this->optionGroup[$dataType] = array('values' => $values);
if (!empty($values)) {
$result = $this->callAPISuccess('OptionGroup', 'create', array('name' => "{$dataType}_group", 'api.option_value.create' => array('label' => "{$dataType} 1", 'value' => $values[0]), 'api.option_value.create.1' => array('label' => "{$dataType} 2", 'value' => $values[1]), 'api.option_value.create.2' => array('label' => "{$dataType} 3", 'value' => $values[2])));
$this->optionGroup[$dataType]['id'] = $result['id'];
} elseif ($dataType == 'contact') {
for ($i = 0; $i < 3; $i++) {
$result = $this->callAPISuccess('Contact', 'create', array('contact_type' => 'Individual', 'email' => substr(sha1(rand()), 0, 7) . '@yahoo.com'));
$this->optionGroup[$dataType]['values'][$i] = $result['id'];
}
}
$this->ids[$dataType] = $this->entityCustomGroupWithSingleFieldCreate("{$dataType} Custom Group", 'Contacts');
}
}
示例11: buildForm
function buildForm(&$form)
{
/**
* You can define a custom title for the search form
*/
$this->setTitle('List Employers for Individual Contacts');
/**
* Define the search form fields here
*/
$form->add('text', 'sort_name', ts('Individual\'s Name (last, first)'));
$stateProvince = array('' => ts('- any state/province -')) + CRM_Core_PseudoConstant::stateProvince();
$form->addElement('select', 'state_province_id', ts('Individual\'s Home State'), $stateProvince);
/**
* If you are using the sample template, this array tells the template fields to render
* for the search form.
*/
$form->assign('elements', array('sort_name', 'state_province_id'));
}
示例12: getState
/**
* This function is to get the state name based on the search criteria
* @param string $fragment this is the search string
* @param integer $countryId country id
*
* @return state id / state name depending on search criteria
* @access public
*/
function getState($fragment = '', $countryId = 0)
{
$fraglen = strlen($fragment);
if (!$countryId) {
$states = CRM_Core_PseudoConstant::stateProvince();
} else {
$queryString = "SELECT civicrm_state_province.id as civicrm_state_province_id \n FROM civicrm_country , civicrm_state_province \n WHERE civicrm_state_province.country_id = civicrm_country.id\n AND civicrm_country.id = " . CRM_Utils_Type::escape($countryId, 'Integer') . "\n AND civicrm_state_province.name ='" . CRM_Utils_Type::escape($fragment, 'String') . "'";
$DAOobj =& new CRM_Core_DAO();
$DAOobj->query($queryString);
while ($DAOobj->fetch()) {
return $DAOobj->civicrm_state_province_id;
}
}
for ($i = $fraglen; $i > 0; $i--) {
$matches = preg_grep('/^' . substr($fragment, 0, $i) . '/i', $states);
if (count($matches) > 0) {
$id = key($matches);
$value = current($matches);
$showState[$id] = $value;
return $showState;
}
}
return '';
}
示例13: alterDisplay
function alterDisplay(&$rows)
{
// custom code to alter rows
$checkList = array();
$entryFound = false;
$display_flag = $prev_cid = $cid = 0;
$contributionTypes = CRM_Contribute_PseudoConstant::contributionType();
foreach ($rows as $rowNum => $row) {
if (!empty($this->_noRepeats) && $this->_outputMode != 'csv') {
// don't repeat contact details if its same as the previous row
if (array_key_exists('civicrm_contact_id', $row)) {
if ($cid = $row['civicrm_contact_id']) {
if ($rowNum == 0) {
$prev_cid = $cid;
} else {
if ($prev_cid == $cid) {
$display_flag = 1;
$prev_cid = $cid;
} else {
$display_flag = 0;
$prev_cid = $cid;
}
}
if ($display_flag) {
foreach ($row as $colName => $colVal) {
if (in_array($colName, $this->_noRepeats)) {
unset($rows[$rowNum][$colName]);
}
}
}
$entryFound = true;
}
}
}
// handle state province
if (array_key_exists('civicrm_address_state_province_id', $row)) {
if ($value = $row['civicrm_address_state_province_id']) {
$rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($value, false);
$url = CRM_Report_Utils_Report::getNextUrl('contribute/detail', "reset=1&force=1&" . "state_province_id_op=in&state_province_id_value={$value}", $this->_absoluteUrl, $this->_id);
$rows[$rowNum]['civicrm_address_state_province_id_link'] = $url;
$rows[$rowNum]['civicrm_address_state_province_id_hover'] = ts("List all contribution(s) for this State.");
}
$entryFound = true;
}
// handle country
if (array_key_exists('civicrm_address_country_id', $row)) {
if ($value = $row['civicrm_address_country_id']) {
$rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant::country($value, false);
$url = CRM_Report_Utils_Report::getNextUrl('contribute/detail', "reset=1&force=1&" . "country_id_op=in&country_id_value={$value}", $this->_absoluteUrl, $this->_id);
$rows[$rowNum]['civicrm_address_country_id_link'] = $url;
$rows[$rowNum]['civicrm_address_country_id_hover'] = ts("List all contribution(s) for this Country.");
}
$entryFound = true;
}
// convert display name to links
if (array_key_exists('civicrm_contact_display_name', $row) && CRM_Utils_Array::value('civicrm_contact_display_name', $rows[$rowNum]) && array_key_exists('civicrm_contact_id', $row)) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $row['civicrm_contact_id'], $this->_absoluteUrl);
$rows[$rowNum]['civicrm_contact_display_name_link'] = $url;
$rows[$rowNum]['civicrm_contact_display_name_hover'] = ts("View Contact Summary for this Contact.");
}
if ($value = CRM_Utils_Array::value('civicrm_contribution_contribution_type_id', $row)) {
$rows[$rowNum]['civicrm_contribution_contribution_type_id'] = $contributionTypes[$value];
$entryFound = true;
}
// skip looking further in rows, if first row itself doesn't
// have the column we need
if (!$entryFound) {
break;
}
$lastKey = $rowNum;
}
}
示例14: displayProfile
/**
* Function to build the array for display the profile fields
*
* @param array $params key value.
* @param int $gid profile Id
* @param array $groupTitle Profile Group Title.
* @param array $values formatted array of key value
*
* @return None
* @access public
*/
function displayProfile(&$params, $gid, &$groupTitle, &$values)
{
if ($gid) {
require_once 'CRM/Core/BAO/UFGroup.php';
require_once 'CRM/Profile/Form.php';
require_once 'CRM/Event/PseudoConstant.php';
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
if ($contactID) {
if (CRM_Core_BAO_UFGroup::filterUFGroups($gid, $contactID)) {
$fields = CRM_Core_BAO_UFGroup::getFields($gid, false, CRM_Core_Action::VIEW);
}
} else {
$fields = CRM_Core_BAO_UFGroup::getFields($gid, false, CRM_Core_Action::ADD);
}
if (is_array($fields)) {
// unset any email-* fields since we already collect it, CRM-2888
foreach (array_keys($fields) as $fieldName) {
if (substr($fieldName, 0, 6) == 'email-') {
unset($fields[$fieldName]);
}
}
}
foreach ($fields as $v) {
if (CRM_Utils_Array::value('groupTitle', $v)) {
$groupTitle['groupTitle'] = $v["groupTitle"];
break;
}
}
$config = CRM_Core_Config::singleton();
require_once 'CRM/Core/PseudoConstant.php';
$locationTypes = $imProviders = array();
$locationTypes = CRM_Core_PseudoConstant::locationType();
$imProviders = CRM_Core_PseudoConstant::IMProvider();
//start of code to set the default values
foreach ($fields as $name => $field) {
$index = $field['title'];
$customFieldName = null;
if ($name === 'organization_name') {
$values[$index] = $params[$name];
}
if ('state_province' == substr($name, 0, 14)) {
if ($params[$name]) {
$values[$index] = CRM_Core_PseudoConstant::stateProvince($params[$name]);
} else {
$values[$index] = '';
}
} else {
if ('country' == substr($name, 0, 7)) {
if ($params[$name]) {
$values[$index] = CRM_Core_PseudoConstant::country($params[$name]);
} else {
$values[$index] = '';
}
} else {
if ('county' == substr($name, 0, 6)) {
if ($params[$name]) {
$values[$index] = CRM_Core_PseudoConstant::county($params[$name]);
} else {
$values[$index] = '';
}
} else {
if ('gender' == substr($name, 0, 6)) {
$gender = CRM_Core_PseudoConstant::gender();
$values[$index] = $gender[$params[$name]];
} else {
if ('individual_prefix' == substr($name, 0, 17)) {
$prefix = CRM_Core_PseudoConstant::individualPrefix();
$values[$index] = $prefix[$params[$name]];
} else {
if ('individual_suffix' == substr($name, 0, 17)) {
$suffix = CRM_Core_PseudoConstant::individualSuffix();
$values[$index] = $suffix[$params[$name]];
} else {
if (in_array($name, array('addressee', 'email_greeting', 'postal_greeting'))) {
$filterCondition = array('greeting_type' => $name);
$greeting =& CRM_Core_PseudoConstant::greeting($filterCondition);
$values[$index] = $greeting[$params[$name]];
} else {
if ($name === 'preferred_communication_method') {
$communicationFields = CRM_Core_PseudoConstant::pcm();
$pref = array();
$compref = array();
$pref = $params[$name];
if (is_array($pref)) {
foreach ($pref as $k => $v) {
if ($v) {
$compref[] = $communicationFields[$k];
}
//.........这里部分代码省略.........
示例15: buildQuickForm
/**
* Build the form
*
* @access public
*
* @return void
*/
function buildQuickForm($form, $proxSearch)
{
// is proximity search required (2) or optional (1)?
$proxRequired = $proxSearch == 2 ? TRUE : FALSE;
$form->assign('proximity_search', TRUE);
$form->add('text', 'prox_street_address', ts('Street Address'), NULL, FALSE);
$form->add('text', 'prox_city', ts('City'), NULL, FALSE);
$form->add('text', 'prox_postal_code', ts('Postal Code'), NULL, FALSE);
$defaults = self::setDefaultValues($form);
if (CRM_Utils_Array::value('prox_country_id', $defaults)) {
$stateProvince = array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvinceForCountry($defaults['prox_country_id']);
} else {
$stateProvince = array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvince();
}
$form->add('select', 'prox_state_province_id', ts('State/Province'), $stateProvince, $proxRequired);
$country = array('' => ts('- select -')) + CRM_Core_PseudoConstant::country();
$form->add('select', 'prox_country_id', ts('Country'), $country, $proxRequired);
$form->add('text', 'prox_distance', ts('Distance'), NULL, $proxRequired);
$proxUnits = array('km' => ts('km'), 'miles' => ts('miles'));
$form->add('select', 'prox_distance_unit', ts('Units'), $proxUnits, $proxRequired);
// prox_distance_unit
// state country js, CRM-5233
$stateCountryMap = array();
$stateCountryMap[] = array('state_province' => 'prox_state_province_id', 'country' => 'prox_country_id');
CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults);
$form->addFormRule(array('CRM_Contact_Form_Task_ProximityCommon', 'formRule'), $form);
}