本文整理汇总了PHP中CRM_Core_PseudoConstant::country方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_PseudoConstant::country方法的具体用法?PHP CRM_Core_PseudoConstant::country怎么用?PHP CRM_Core_PseudoConstant::country使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_PseudoConstant
的用法示例。
在下文中一共展示了CRM_Core_PseudoConstant::country方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run()
{
$countries = CRM_Bic_Parser_Parser::getParserList();
$stats = civicrm_api3('Bic', 'stats');
$total_count = 0;
foreach ($countries as $country) {
if (isset($stats['values'][$country])) {
$total_count += $stats['values'][$country];
} else {
$stats['values'][$country] = 0;
}
}
// gather the names
$country_names = array();
$config = CRM_Core_Config::singleton();
$id2code = CRM_Core_PseudoConstant::countryIsoCode();
$default_country = $id2code[$config->defaultContactCountry];
$code2id = array_flip($id2code);
$id2country = CRM_Core_PseudoConstant::country(FALSE, FALSE);
foreach ($countries as $code) {
$country_id = $code2id[$code];
$country_name = $id2country[$country_id];
$country_names[$code] = $country_name;
}
$this->assign('countries', $countries);
$this->assign('country_names', $country_names);
$this->assign('default_country', $default_country);
$this->assign('stats', $stats['values']);
$this->assign('total_count', $total_count);
parent::run();
}
示例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: run
function run()
{
// Prepares variables for being sent to Smarty
//Only show countries with attached information
$countries = null;
$stats = civicrm_api3('Bic', 'stats');
foreach ($stats['values'] as $country => $count) {
$countries[] = $country;
}
// Get country names
$country_names = null;
if ($countries) {
$config = CRM_Core_Config::singleton();
$country_names = array();
$id2code = CRM_Core_PseudoConstant::countryIsoCode();
$default_country = $id2code[$config->defaultContactCountry];
$code2id = array_flip($id2code);
$id2country = CRM_Core_PseudoConstant::country(false, false);
foreach ($countries as $code) {
$country_id = $code2id[$code];
$country_name = $id2country[$country_id];
$country_names[$code] = $country_name;
}
}
// Sends variables to Smarty
$this->assign('countries', $countries);
$this->assign('country_names', $country_names);
$this->assign('default_country', $default_country);
$this->assign('show_message', true);
parent::run();
}
示例4: __construct
function __construct()
{
$this->_autoIncludeIndexedFieldsAsOrderBys = 1;
$this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name' => array('title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE), 'first_name' => array('title' => ts('First Name')), 'last_name' => array('title' => ts('Last Name')), 'id' => array('no_display' => TRUE, 'required' => TRUE), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact SubType')), 'birth_date' => array('title' => ts('Birth Date'))), 'filters' => array('sort_name' => array('title' => ts('Contact Name')), 'source' => array('title' => ts('Contact Source'), 'type' => CRM_Utils_Type::T_STRING), 'id' => array('title' => ts('Contact ID'), 'no_display' => TRUE), 'birth_date' => array('title' => ts('Birth Date'), 'operatorType' => CRM_Report_Form::OP_DATE)), 'grouping' => 'contact-fields', 'order_bys' => array('sort_name' => array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC'))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Email'), 'no_repeat' => TRUE)), 'grouping' => 'contact-fields', 'order_bys' => array('email' => array('title' => ts('Email')))), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'grouping' => 'contact-fields', 'fields' => array('street_address' => array('default' => TRUE), 'city' => array('default' => TRUE), 'postal_code' => NULL, 'state_province_id' => array('title' => ts('State/Province'))), 'filters' => array('country_id' => array('title' => ts('Country'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country()), 'state_province_id' => array('title' => ts('State / Province'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince())), 'order_bys' => array('state_province_id' => array('title' => 'State/Province'), 'city' => array('title' => 'City'), 'postal_code' => array('title' => 'Postal Code'))), 'civicrm_country' => array('dao' => 'CRM_Core_DAO_Country', 'fields' => array('name' => array('title' => 'Country', 'default' => TRUE)), 'order_bys' => array('name' => array('title' => 'Country')), 'grouping' => 'contact-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => NULL, 'phone_ext' => array('title' => ts('Phone Extension'))), 'grouping' => 'contact-fields'), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_Group', '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()))));
$this->_tagFilter = TRUE;
parent::__construct();
}
示例5: run
public function run()
{
CRM_Utils_System::setTitle(ts('Household Finder'));
// determine result count
if (!empty($_REQUEST['count'])) {
if ($_REQUEST['count'] == 'all') {
$result_count = 'all';
} else {
$result_count = (int) $_REQUEST['count'];
if ($result_count <= 0) {
$result_count = 25;
}
}
} else {
$result_count = 25;
}
// first run the scanner
$scanner = new CRM_Householdmerge_Logic_Scanner();
$proposals = $scanner->findNewHouseholds($result_count);
// set the country names
$countries = CRM_Core_PseudoConstant::country();
foreach ($proposals as $pid => $proposal) {
foreach ($proposal['contacts'] as $contact_id => $contact) {
if (!empty($contact['country_id'])) {
$proposals[$pid]['contacts'][$contact_id]['country'] = $countries[$contact['country_id']];
}
}
}
$this->assign('proposals', $proposals);
$this->assign('proposals_json', json_encode($proposals));
$this->assign('result_count', $result_count);
parent::run();
}
示例6: civicrm_pseudoconstant_country
function civicrm_pseudoconstant_country($params) {
$countries = CRM_Core_PseudoConstant::country();
$return = array('countries' => $countries);
return $return;
}
示例7: buildQuickForm
function buildQuickForm()
{
$contact_id = 0;
$bank_accounts = array();
if (isset($_REQUEST['cid'])) {
$contact_id = (int) $_REQUEST['cid'];
$bank_account = new CRM_Banking_BAO_BankAccount();
$bank_account->contact_id = $contact_id;
$bank_account->find();
while ($bank_account->fetch()) {
$bank_account_data = $bank_account->toArray();
$bank_account_data['references'] = $bank_account->getReferences();
$bank_account_data['data_parsed'] = json_decode($bank_account->data_parsed, true);
$bank_accounts[$bank_account->id] = $bank_account_data;
}
}
$this->assign('bank_accounts', $bank_accounts);
$this->assign('bank_accounts_json', json_encode($bank_accounts));
$this->assign('contact_id', $contact_id);
// load all account types
$option_group = civicrm_api3('OptionGroup', 'getsingle', array('name' => 'civicrm_banking.reference_types'));
$reference_types = civicrm_api3('OptionValue', 'get', array('option_group_id' => $option_group['id'], 'is_reserved' => 0));
$this->assign('reference_types_json', json_encode($reference_types['values']));
$reference_type_list = array();
$this->assign('reference_types', $reference_types['values']);
foreach ($reference_types['values'] as $reference_type_id => $reference_type) {
$reference_type_list[$reference_type_id] = "{$reference_type['label']} ({$reference_type['name']})";
}
// load countries
$country_id2iso = CRM_Core_PseudoConstant::countryIsoCode();
$country_iso2id = array_flip($country_id2iso);
$country_id2name = CRM_Core_PseudoConstant::country();
$countries = array('' => ts("Unknown"));
foreach ($country_iso2id as $iso => $id) {
if (!empty($country_id2name[$id])) {
$countries[$iso] = $country_id2name[$id];
}
}
// load settings
$this->assign('reference_normalisation', (int) CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_normalisation'));
$this->assign('reference_validation', (int) CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_validation'));
// ACCOUNT REFRENCE ITEMS
$this->add('hidden', 'contact_id', $contact_id, true);
$this->add('hidden', 'reference_id');
$reference_type = $this->add('select', 'reference_type', ts("Bank Account Type"), $reference_type_list, true);
// set last value
$reference_type->setSelected(CRM_Core_BAO_Setting::getItem('CiviBanking', 'account.default_reference_id'));
$reference_type = $this->add('text', 'reference', ts("Bank Account Number"), array('size' => 40), true);
// BANK ITEMS
$this->add('hidden', 'ba_id');
$this->addElement('text', 'bic', ts("BIC"), array('size' => 40), false);
$this->addElement('text', 'bank_name', ts("Bank Name"), array('size' => 40), false);
$country = $this->add('select', 'country', ts("Country"), $countries, false);
// set last value
$country->setSelected(CRM_Core_BAO_Setting::getItem('CiviBanking', 'account.default_country'));
$this->addButtons(array(array('type' => 'submit', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'), 'isDefault' => FALSE)));
parent::buildQuickForm();
}
示例8: optionValues
public static function optionValues(&$options, $name)
{
if ($name != 'chapter_match_country') {
return;
}
$countries = CRM_Core_PseudoConstant::country();
foreach ($countries as $country_id => $country) {
$options[$country_id] = $country;
}
}
示例9: testAddressFormat
public function testAddressFormat()
{
$contact = $this->callAPISuccess('contact', 'create', array('first_name' => 'Micky', 'last_name' => 'mouse', 'contact_type' => 'Individual'));
$address = $this->callAPISuccess('address', 'create', array('street_address' => '1 Happy Place', 'city' => 'Miami', 'state_province' => 'Flordia', 'country' => 'United States', 'postal_code' => 33101, 'contact_id' => $contact['id'], 'location_type_id' => 5, 'is_primary' => 1));
$addressDetails = $address['values'][$address['id']];
$countries = CRM_Core_PseudoConstant::country();
$addressDetails['country'] = $countries[$addressDetails['country_id']];
$formatted_address = CRM_Utils_Address::format($addressDetails, 'mailing_format', FALSE, TRUE);
$this->assertTrue((bool) strstr($formatted_address, 'UNITED STATES'));
}
示例10: _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);
}
示例11: 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)));
}
示例12: _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');
}
}
示例13: buildQuickForm
/**
* Build the form object.
*
*
* @param CRM_Core_Form $form
* @param $proxSearch
*
* @return void
*/
public 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);
$form->addChainSelect('prox_state_province_id', array('required' => $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
$form->addFormRule(array('CRM_Contact_Form_Task_ProximityCommon', 'formRule'), $form);
}
示例14: buildQuickForm
public function buildQuickForm()
{
$config =& CRM_Core_Config::singleton();
$this->add('select', 'country_id', ts('Country'), array('' => ts('- select -')) + CRM_Core_PseudoConstant::country());
$countryID = isset($_POST['country_id']) ? $_POST['country_id'] : null;
if (!$countryID) {
$countryID = isset($this->_params['country_id']) ? $this->_params['country_id'] : null;
}
if ($countryID) {
$this->add('select', 'state_province_id', ts('State'), array('' => ts('- select a state -')) + CRM_Core_PseudoConstant::stateProvinceForCountry($countryID));
} else {
$this->add('select', 'state_province_id', ts('State'), array('' => ts('- select a country first -')));
}
$stateCountryURL = CRM_Utils_System::url('civicrm/ajax/jqState');
$this->assign('stateCountryURL', $stateCountryURL);
$this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
}
示例15: 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 boolean True if the value is of the specified type
* @access public
* @static
*/
public static function typecheck($type, $value)
{
require_once 'CRM/Utils/Rule.php';
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':
return CRM_Utils_Rule::date($value);
case 'Boolean':
return CRM_Utils_Rule::boolean($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;
}