本文整理汇总了PHP中CRM_Core_PseudoConstant::countryIsoCode方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_PseudoConstant::countryIsoCode方法的具体用法?PHP CRM_Core_PseudoConstant::countryIsoCode怎么用?PHP CRM_Core_PseudoConstant::countryIsoCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_PseudoConstant
的用法示例。
在下文中一共展示了CRM_Core_PseudoConstant::countryIsoCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: civicrm_pseudoconstant_countryIsoCode
function civicrm_pseudoconstant_countryIsoCode($params) {
$countries = CRM_Core_PseudoConstant::countryIsoCode();
$return = array('countries' => $countries);
return $return;
}
示例4: 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();
}
示例5: 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;
}
示例6: fixParams
/**
* Function to fix civicrm setting variables
*
* @params array $params associated array of civicrm variables
*
* @return null
* @static
*/
static function fixParams(&$params)
{
// in our old civicrm.settings.php we were using ISO code for country and
// province limit, now we have changed it to use ids
$countryIsoCodes = CRM_Core_PseudoConstant::countryIsoCode();
$specialArray = array('countryLimit', 'provinceLimit');
foreach ($params as $key => $value) {
if (in_array($key, $specialArray) && is_array($value)) {
foreach ($value as $k => $val) {
if (!is_numeric($val)) {
$params[$key][$k] = array_search($val, $countryIsoCodes);
}
}
} else {
if ($key == 'defaultContactCountry') {
if (!is_numeric($value)) {
$params[$key] = array_search($value, $countryIsoCodes);
}
}
}
}
}
示例7: findChapterForContact
public function findChapterForContact($contact_id)
{
$config = CRM_Chapters_AutomatchConfig::singelton();
try {
$primary_address = civicrm_api3('Address', 'getsingle', array('contact_id' => $contact_id, 'is_primary' => '1'));
$country_iso_codes = CRM_Core_PseudoConstant::countryIsoCode();
$us_country_id = false;
foreach ($country_iso_codes as $country_id => $iso_code) {
if ($iso_code == 'US') {
$us_country_id = $country_id;
}
}
if (!empty($primary_address['country_id'])) {
$country_sql = "SELECT entity_id FROM `" . $config->getCustomGroup('table_name') . "` WHERE `" . $config->getMatchTypeField('column_name') . "` = 'country' AND `" . $config->getCountryField('column_name') . "` = %1";
$country_params[1] = array($primary_address['country_id'], 'Integer');
$dao = CRM_Core_DAO::executeQuery($country_sql, $country_params);
if ($dao->fetch()) {
return $dao->entity_id;
}
}
if (!empty($primary_address['country_id']) && $us_country_id && $primary_address['country_id'] == $us_country_id && !empty($primary_address['postal_code'])) {
$zipcode = substr($primary_address['postal_code'], 0, 5);
if (is_numeric($zipcode)) {
$zipcode_sql = "SELECT entity_id FROM `" . $config->getCustomGroup('table_name') . "` WHERE `" . $config->getMatchTypeField('column_name') . "` = 'zipcode' AND `" . $config->getZipCodeRangeFromField('column_name') . "` <= %1 AND `" . $config->getZipCodeRangeToField('column_name') . "` >= %1";
$zipcode_params[1] = array($zipcode, 'Integer');
$dao = CRM_Core_DAO::executeQuery($zipcode_sql, $zipcode_params);
if ($dao->fetch()) {
return $dao->entity_id;
}
}
}
} catch (Exception $e) {
//do nothing
}
return false;
}
示例8: defaultContactCountry
/**
* Provide cached default contact country.
*
* @return string
*/
public static function defaultContactCountry()
{
static $cachedContactCountry = NULL;
$defaultContactCountry = Civi::settings()->get('defaultContactCountry');
if (!empty($defaultContactCountry) && !$cachedContactCountry) {
$countryIsoCodes = CRM_Core_PseudoConstant::countryIsoCode();
$cachedContactCountry = CRM_Utils_Array::value($defaultContactCountry, $countryIsoCodes);
}
return $cachedContactCountry;
}
示例9: resolveDefaults
/**
* Get the values for pseudoconstants for name->value and reverse.
*
* @param array $defaults
* (reference) the default values, some of which need to be resolved.
* @param bool $reverse
* True if we want to resolve the values in the reverse direction (value -> name).
*/
public static function resolveDefaults(&$defaults, $reverse = FALSE)
{
// Hack for birth_date.
if (!empty($defaults['birth_date'])) {
if (is_array($defaults['birth_date'])) {
$defaults['birth_date'] = CRM_Utils_Date::format($defaults['birth_date'], '-');
}
}
CRM_Utils_Array::lookupValue($defaults, 'prefix', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'), $reverse);
CRM_Utils_Array::lookupValue($defaults, 'suffix', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'), $reverse);
CRM_Utils_Array::lookupValue($defaults, 'gender', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), $reverse);
CRM_Utils_Array::lookupValue($defaults, 'communication_style', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id'), $reverse);
//lookup value of email/postal greeting, addressee, CRM-4575
foreach (self::$_greetingTypes as $greeting) {
$filterCondition = array('contact_type' => CRM_Utils_Array::value('contact_type', $defaults), 'greeting_type' => $greeting);
CRM_Utils_Array::lookupValue($defaults, $greeting, CRM_Core_PseudoConstant::greeting($filterCondition), $reverse);
}
$blocks = array('address', 'im', 'phone');
foreach ($blocks as $name) {
if (!array_key_exists($name, $defaults) || !is_array($defaults[$name])) {
continue;
}
foreach ($defaults[$name] as $count => &$values) {
//get location type id.
CRM_Utils_Array::lookupValue($values, 'location_type', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'), $reverse);
if ($name == 'address') {
// FIXME: lookupValue doesn't work for vcard_name
if (!empty($values['location_type_id'])) {
$vcardNames = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'vcard_name'));
$values['vcard_name'] = $vcardNames[$values['location_type_id']];
}
if (!CRM_Utils_Array::lookupValue($values, 'country', CRM_Core_PseudoConstant::country(), $reverse) && $reverse) {
CRM_Utils_Array::lookupValue($values, 'country', CRM_Core_PseudoConstant::countryIsoCode(), $reverse);
}
// CRM-7597
// if we find a country id above, we need to restrict it to that country
// rather than the list of all countries
if (!empty($values['country_id'])) {
$stateProvinceList = CRM_Core_PseudoConstant::stateProvinceForCountry($values['country_id']);
} else {
$stateProvinceList = CRM_Core_PseudoConstant::stateProvince();
}
if (!CRM_Utils_Array::lookupValue($values, 'state_province', $stateProvinceList, $reverse) && $reverse) {
if (!empty($values['country_id'])) {
$stateProvinceList = CRM_Core_PseudoConstant::stateProvinceForCountry($values['country_id'], 'abbreviation');
} else {
$stateProvinceList = CRM_Core_PseudoConstant::stateProvinceAbbreviation();
}
CRM_Utils_Array::lookupValue($values, 'state_province', $stateProvinceList, $reverse);
}
if (!empty($values['state_province_id'])) {
$countyList = CRM_Core_PseudoConstant::countyForState($values['state_province_id']);
} else {
$countyList = CRM_Core_PseudoConstant::county();
}
CRM_Utils_Array::lookupValue($values, 'county', $countyList, $reverse);
}
if ($name == 'im') {
CRM_Utils_Array::lookupValue($values, 'provider', CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), $reverse);
}
if ($name == 'phone') {
CRM_Utils_Array::lookupValue($values, 'phone_type', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'), $reverse);
}
// Kill the reference.
unset($values);
}
}
}
示例10: create
/**
* @param array $customParams
*
* @throws Exception
*/
public static function create(&$customParams)
{
if (empty($customParams) || !is_array($customParams)) {
return;
}
foreach ($customParams as $tableName => $tables) {
foreach ($tables as $index => $fields) {
$sqlOP = NULL;
$hookID = NULL;
$hookOP = NULL;
$entityID = NULL;
$isMultiple = FALSE;
$set = array();
$params = array();
$count = 1;
foreach ($fields as $field) {
if (!$sqlOP) {
$entityID = $field['entity_id'];
$hookID = $field['custom_group_id'];
$isMultiple = $field['is_multiple'];
if (array_key_exists('id', $field)) {
$sqlOP = "UPDATE {$tableName} ";
$where = " WHERE id = %{$count}";
$params[$count] = array($field['id'], 'Integer');
$count++;
$hookOP = 'edit';
} else {
$sqlOP = "INSERT INTO {$tableName} ";
$where = NULL;
$hookOP = 'create';
}
}
// fix the value before we store it
$value = $field['value'];
$type = $field['type'];
switch ($type) {
case 'StateProvince':
$type = 'Integer';
if (is_array($value)) {
$value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $value) . CRM_Core_DAO::VALUE_SEPARATOR;
$type = 'String';
} elseif (!is_numeric($value) && !strstr($value, CRM_Core_DAO::VALUE_SEPARATOR)) {
//fix for multi select state, CRM-3437
$mulValues = explode(',', $value);
$validStates = array();
foreach ($mulValues as $key => $stateVal) {
$states = array();
$states['state_province'] = trim($stateVal);
CRM_Utils_Array::lookupValue($states, 'state_province', CRM_Core_PseudoConstant::stateProvince(), TRUE);
if (empty($states['state_province_id'])) {
CRM_Utils_Array::lookupValue($states, 'state_province', CRM_Core_PseudoConstant::stateProvinceAbbreviation(), TRUE);
}
$validStates[] = CRM_Utils_Array::value('state_province_id', $states);
}
$value = implode(CRM_Core_DAO::VALUE_SEPARATOR, $validStates);
$type = 'String';
} elseif (!$value) {
// CRM-3415
// using type of timestamp allows us to sneak in a null into db
// gross but effective hack
$value = NULL;
$type = 'Timestamp';
} else {
$type = 'String';
}
break;
case 'Country':
$type = 'Integer';
$mulValues = explode(',', $value);
if (is_array($value)) {
$value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $value) . CRM_Core_DAO::VALUE_SEPARATOR;
$type = 'String';
} elseif (!is_numeric($value) && !strstr($value, CRM_Core_DAO::VALUE_SEPARATOR)) {
//fix for multi select country, CRM-3437
$mulValues = explode(',', $value);
$validCountries = array();
foreach ($mulValues as $key => $countryVal) {
$countries = array();
$countries['country'] = trim($countryVal);
CRM_Utils_Array::lookupValue($countries, 'country', CRM_Core_PseudoConstant::country(), TRUE);
if (empty($countries['country_id'])) {
CRM_Utils_Array::lookupValue($countries, 'country', CRM_Core_PseudoConstant::countryIsoCode(), TRUE);
}
$validCountries[] = CRM_Utils_Array::value('country_id', $countries);
}
$value = implode(CRM_Core_DAO::VALUE_SEPARATOR, $validCountries);
$type = 'String';
} elseif (!$value) {
// CRM-3415
// using type of timestamp allows us to sneak in a null into db
// gross but effective hack
$value = NULL;
$type = 'Timestamp';
} else {
$type = 'String';
//.........这里部分代码省略.........
示例11: postProcess
/**
* Process the renewal form.
*
*
* @return void
*/
public function postProcess()
{
$ids = array();
$config = CRM_Core_Config::singleton();
// get the submitted form values.
$this->_params = $formValues = $this->controller->exportValues($this->_name);
$this->storeContactFields($formValues);
// use values from screen
if ($formValues['membership_type_id'][1] != 0) {
$defaults['receipt_text_renewal'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $formValues['membership_type_id'][1], 'receipt_text_renewal');
}
$now = CRM_Utils_Date::getToday(NULL, 'YmdHis');
$this->convertDateFieldsToMySQL($formValues);
$this->assign('receive_date', $formValues['receive_date']);
if (!empty($this->_params['send_receipt'])) {
$formValues['receipt_date'] = $now;
$this->assign('receipt_date', CRM_Utils_Date::mysqlToIso($formValues['receipt_date']));
} else {
$formValues['receipt_date'] = NULL;
}
if ($this->_mode) {
$formValues['total_amount'] = CRM_Utils_Array::value('total_amount', $this->_params, CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'minimum_fee'));
if (empty($formValues['financial_type_id'])) {
$formValues['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'financial_type_id');
}
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($formValues['payment_processor_id'], $this->_mode);
$fields = array();
// set email for primary location.
$fields['email-Primary'] = 1;
$formValues['email-5'] = $formValues['email-Primary'] = $this->_contributorEmail;
$formValues['register_date'] = $now;
// now set the values for the billing location.
foreach ($this->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
// also add location name to the array
$formValues["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_middle_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_last_name', $formValues);
$formValues["address_name-{$this->_bltID}"] = trim($formValues["address_name-{$this->_bltID}"]);
$fields["address_name-{$this->_bltID}"] = 1;
$fields["email-{$this->_bltID}"] = 1;
$ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactID, 'contact_type');
$nameFields = array('first_name', 'middle_name', 'last_name');
foreach ($nameFields as $name) {
$fields[$name] = 1;
if (array_key_exists("billing_{$name}", $formValues)) {
$formValues[$name] = $formValues["billing_{$name}"];
$formValues['preserveDBName'] = TRUE;
}
}
//here we are setting up the billing contact - if different from the member they are already created
// but they will get billing details assigned
CRM_Contact_BAO_Contact::createProfileContact($formValues, $fields, $this->_contributorContactID, NULL, NULL, $ctype);
// add all the additional payment params we need
$this->_params["state_province-{$this->_bltID}"] = $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
$this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
$this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params);
$this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params);
$this->_params['description'] = ts('Office Credit Card Membership Renewal Contribution');
$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$this->_params['amount'] = $formValues['total_amount'];
$this->_params['currencyID'] = $config->defaultCurrency;
$this->_params['payment_action'] = 'Sale';
$paymentParams['invoiceID'] = $this->_params['invoiceID'] = md5(uniqid(rand(), TRUE));
// at this point we've created a contact and stored its address etc
// all the payment processors expect the name and address to be in the passed params
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
if (!empty($this->_params['send_receipt'])) {
$paymentParams['email'] = $this->_contributorEmail;
}
$paymentParams['contactID'] = $this->_contributorContactID;
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, TRUE);
$payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
if (!empty($paymentParams['auto_renew'])) {
$contributionRecurParams = $this->processRecurringContribution($paymentParams);
$this->_params['contributionRecurID'] = $contributionRecurParams['contributionRecurID'];
$paymentParams = array_merge($paymentParams, $contributionRecurParams);
}
$result = $payment->doDirectPayment($paymentParams);
if (is_a($result, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$this->_id}&context=membership&mode={$this->_mode}"));
}
if ($result) {
$this->_params = array_merge($this->_params, $result);
}
$formValues['contribution_status_id'] = 1;
$formValues['invoice_id'] = $this->_params['invoiceID'];
$formValues['trxn_id'] = $result['trxn_id'];
$formValues['payment_instrument_id'] = 1;
$formValues['is_test'] = $this->_mode == 'live' ? 0 : 1;
$this->set('params', $this->_params);
$this->assign('trxn_id', $result['trxn_id']);
}
//.........这里部分代码省略.........
示例12: postProcess
//.........这里部分代码省略.........
$now = date('YmdHis');
$fields = array();
// set email for primary location.
$fields['email-Primary'] = 1;
$formValues['email-5'] = $formValues['email-Primary'] = $this->_memberEmail;
$params['register_date'] = $now;
// now set the values for the billing location.
foreach ($this->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
// also add location name to the array
$formValues["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_middle_name', $formValues) . ' ' . CRM_Utils_Array::value('billing_last_name', $formValues);
$formValues["address_name-{$this->_bltID}"] = trim($formValues["address_name-{$this->_bltID}"]);
$fields["address_name-{$this->_bltID}"] = 1;
//ensure we don't over-write the payer's email with the member's email
if ($this->_contributorContactID == $this->_contactID) {
$fields["email-{$this->_bltID}"] = 1;
}
$ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactID, 'contact_type');
$nameFields = array('first_name', 'middle_name', 'last_name');
foreach ($nameFields as $name) {
$fields[$name] = 1;
if (array_key_exists("billing_{$name}", $formValues)) {
$formValues[$name] = $formValues["billing_{$name}"];
$formValues['preserveDBName'] = TRUE;
}
}
if ($this->_contributorContactID == $this->_contactID) {
//see CRM-12869 for discussion of why we don't do this for separate payee payments
CRM_Contact_BAO_Contact::createProfileContact($formValues, $fields, $this->_contributorContactID, NULL, NULL, $ctype);
}
// add all the additional payment params we need
$this->_params["state_province-{$this->_bltID}"] = $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
$this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
$this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params);
$this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params);
$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$this->_params['amount'] = $params['total_amount'];
$this->_params['currencyID'] = $config->defaultCurrency;
$this->_params['description'] = ts('Office Credit Card Membership Signup Contribution');
$this->_params['payment_action'] = 'Sale';
$this->_params['invoiceID'] = md5(uniqid(rand(), TRUE));
$this->_params['financial_type_id'] = $params['financial_type_id'];
// at this point we've created a contact and stored its address etc
// all the payment processors expect the name and address to be in the
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
$paymentParams['contactID'] = $this->_contributorContactID;
//CRM-10377 if payment is by an alternate contact then we need to set that person
// as the contact in the payment params
if ($this->_contributorContactID != $this->_contactID) {
if (!empty($this->_params['soft_credit_type_id'])) {
$softParams['contact_id'] = $params['contact_id'];
$softParams['soft_credit_type_id'] = $this->_params['soft_credit_type_id'];
}
}
if (!empty($this->_params['send_receipt'])) {
$paymentParams['email'] = $this->_contributorEmail;
}
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, TRUE);
// CRM-7137 -for recurring membership,
// we do need contribution and recuring records.
$result = NULL;
if (!empty($paymentParams['is_recur'])) {
$contributionType = new CRM_Financial_DAO_FinancialType();
$contributionType->id = $params['financial_type_id'];
示例13: postProcess
//.........这里部分代码省略.........
$params["address_name-{$this->_bltID}"] = trim($params["address_name-{$this->_bltID}"]);
$fields["address_name-{$this->_bltID}"] = 1;
$fields["email-{$this->_bltID}"] = 1;
$ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'contact_type');
$nameFields = array('first_name', 'middle_name', 'last_name');
foreach ($nameFields as $name) {
$fields[$name] = 1;
if (array_key_exists("billing_{$name}", $params)) {
$params[$name] = $params["billing_{$name}"];
$params['preserveDBName'] = TRUE;
}
}
$contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $this->_contactId, NULL, NULL, $ctype);
}
if (!empty($this->_params['participant_role_id'])) {
$customFieldsRole = array();
foreach ($this->_params['participant_role_id'] as $roleKey) {
$customFieldsRole = CRM_Utils_Array::crmArrayMerge(CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, $roleKey, $this->_roleCustomDataTypeID), $customFieldsRole);
}
$customFieldsEvent = CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, CRM_Utils_Array::value('event_id', $params), $this->_eventNameCustomDataTypeID);
$customFieldsEventType = CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, $this->_eventTypeId, $this->_eventTypeCustomDataTypeID);
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsRole, CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, NULL, NULL, TRUE));
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsEvent, $customFields);
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsEventType, $customFields);
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $this->_id, 'Participant');
}
//do cleanup line items if participant edit the Event Fee.
if (($this->_lineItem || !isset($params['proceSetId'])) && !$this->_paymentId && $this->_id) {
CRM_Price_BAO_LineItem::deleteLineItems($this->_id, 'civicrm_participant');
}
if ($this->_mode) {
// add all the additional payment params we need
$this->_params["state_province-{$this->_bltID}"] = $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
$this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
$this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params);
$this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params);
$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$this->_params['amount'] = $params['fee_amount'];
$this->_params['amount_level'] = $params['amount_level'];
$this->_params['currencyID'] = $config->defaultCurrency;
$this->_params['invoiceID'] = md5(uniqid(rand(), TRUE));
// at this point we've created a contact and stored its address etc
// all the payment processors expect the name and address to be in the
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
if (!empty($this->_params['send_receipt'])) {
$paymentParams['email'] = $this->_contributorEmail;
}
// The only reason for merging in the 'contact_id' rather than ensuring it is set
// is that this patch is being done around the time of the stable release
// so more conservative approach is called for.
// In fact the use of $params and $this->_params & $this->_contactId vs $contactID
// needs rationalising.
$mapParams = array_merge(array('contact_id' => $contactID), $this->_params);
CRM_Core_Payment_Form::mapParams($this->_bltID, $mapParams, $paymentParams, TRUE);
$payment = $this->_paymentProcessor['object'];
// CRM-15622: fix for incorrect contribution.fee_amount
$paymentParams['fee_amount'] = NULL;
$result = $payment->doPayment($paymentParams);
if (is_a($result, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/participant', "reset=1&action=add&cid={$this->_contactId}&context=participant&mode={$this->_mode}"));
}
if ($result) {
$this->_params = array_merge($this->_params, $result);
}
示例14: preProcess
/**
* Set variables up before form is built.
*/
public function preProcess()
{
$config = CRM_Core_Config::singleton();
parent::preProcess();
// lineItem isn't set until Register postProcess
$this->_lineItem = $this->get('lineItem');
$this->_paymentProcessor = $this->get('paymentProcessor');
$this->_params = $this->controller->exportValues('Main');
$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$this->_params['amount'] = $this->get('amount');
if (isset($this->_params['amount'])) {
$this->setFormAmountFields($this->_params['priceSetId']);
}
$this->_params['tax_amount'] = $this->get('tax_amount');
$this->_useForMember = $this->get('useForMember');
if (isset($this->_params['credit_card_exp_date'])) {
$this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params);
$this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params);
}
$this->_params['currencyID'] = $config->defaultCurrency;
if (!empty($this->_membershipBlock)) {
$this->_params['selectMembership'] = $this->get('selectMembership');
}
if (!empty($this->_paymentProcessor) && $this->_paymentProcessor['object']->supports('preApproval')) {
$preApprovalParams = $this->_paymentProcessor['object']->getPreApprovalDetails($this->get('pre_approval_parameters'));
$this->_params = array_merge($this->_params, $preApprovalParams);
}
// We may have fetched some billing details from the getPreApprovalDetails function so we
// want to ensure we set this after that function has been called.
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $this->_params, FALSE);
$this->_params['is_pay_later'] = $this->get('is_pay_later');
$this->assign('is_pay_later', $this->_params['is_pay_later']);
if ($this->_params['is_pay_later']) {
$this->assign('pay_later_receipt', $this->_values['pay_later_receipt']);
}
// if onbehalf-of-organization
if (!empty($this->_values['onbehalf_profile_id']) && !empty($this->_params['onbehalf']['organization_name'])) {
// CRM-15182
$this->_params['organization_id'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_params['onbehalf']['organization_name'], 'id', 'display_name');
$this->_params['organization_name'] = $this->_params['onbehalf']['organization_name'];
$addressBlocks = array('street_address', 'city', 'state_province', 'postal_code', 'country', 'supplemental_address_1', 'supplemental_address_2', 'supplemental_address_3', 'postal_code_suffix', 'geo_code_1', 'geo_code_2', 'address_name');
$blocks = array('email', 'phone', 'im', 'url', 'openid');
foreach ($this->_params['onbehalf'] as $loc => $value) {
$field = $typeId = NULL;
if (strstr($loc, '-')) {
list($field, $locType) = explode('-', $loc);
}
if (in_array($field, $addressBlocks)) {
if ($locType == 'Primary') {
$defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
$locType = $defaultLocationType->id;
}
if ($field == 'country') {
$value = CRM_Core_PseudoConstant::countryIsoCode($value);
} elseif ($field == 'state_province') {
$value = CRM_Core_PseudoConstant::stateProvinceAbbreviation($value);
}
$isPrimary = 1;
if (isset($this->_params['onbehalf_location']['address']) && count($this->_params['onbehalf_location']['address']) > 0) {
$isPrimary = 0;
}
$this->_params['onbehalf_location']['address'][$locType][$field] = $value;
if (empty($this->_params['onbehalf_location']['address'][$locType]['is_primary'])) {
$this->_params['onbehalf_location']['address'][$locType]['is_primary'] = $isPrimary;
}
$this->_params['onbehalf_location']['address'][$locType]['location_type_id'] = $locType;
} elseif (in_array($field, $blocks)) {
if (!$typeId || is_numeric($typeId)) {
$blockName = $fieldName = $field;
$locationType = 'location_type_id';
if ($locType == 'Primary') {
$defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
$locationValue = $defaultLocationType->id;
} else {
$locationValue = $locType;
}
$locTypeId = '';
$phoneExtField = array();
if ($field == 'url') {
$blockName = 'website';
$locationType = 'website_type_id';
list($field, $locationValue) = explode('-', $loc);
} elseif ($field == 'im') {
$fieldName = 'name';
$locTypeId = 'provider_id';
$typeId = $this->_params['onbehalf']["{$loc}-provider_id"];
} elseif ($field == 'phone') {
list($field, $locType, $typeId) = explode('-', $loc);
$locTypeId = 'phone_type_id';
//check if extension field exists
$extField = str_replace('phone', 'phone_ext', $loc);
if (isset($this->_params['onbehalf'][$extField])) {
$phoneExtField = array('phone_ext' => $this->_params['onbehalf'][$extField]);
}
}
$isPrimary = 1;
if (isset($this->_params['onbehalf_location'][$blockName]) && count($this->_params['onbehalf_location'][$blockName]) > 0) {
//.........这里部分代码省略.........
示例15: countries
/**
* Test Function used for new hs-widget.
*/
function countries(&$config)
{
//get the country limit and restrict the combo select options
$limitCodes = $config->countryLimit();
if (!is_array($limitCodes)) {
$limitCodes = array($config->countryLimit => 1);
}
$limitCodes = array_intersect(CRM_Core_PseudoConstant::countryIsoCode(), $limitCodes);
// added for testing purpose
//$limitCodes['1101'] = 'IN';
if (count($limitCodes)) {
$whereClause = " iso_code IN ('" . implode("', '", $limitCodes) . "')";
} else {
$whereClause = " 1";
}
$elements = array();
require_once 'CRM/Utils/Type.php';
$name = NULL;
if (isset($_GET['name'])) {
$name = CRM_Utils_Type::escape($_GET['name'], 'String');
}
$countryId = NULL;
if (isset($_GET['id'])) {
$countryId = CRM_Utils_Type::escape($_GET['id'], 'Positive', FALSE);
}
//temporary fix to handle locales other than default US,
// CRM-2653
if (!$countryId && $name && $config->lcMessages != 'en_US') {
$countries = CRM_Core_PseudoConstant::country();
// get the country name in en_US, since db has this locale
$countryName = array_search($name, $countries);
if ($countryName) {
$countryId = $countryName;
}
}
$validValue = TRUE;
if (!$name && !$countryId) {
$validValue = FALSE;
}
if ($validValue) {
if (!$countryId) {
$name = str_replace('*', '%', $name);
$countryClause = " civicrm_country.name LIKE LOWER('{$name}%') ";
} else {
$countryClause = " civicrm_country.id = {$countryId} ";
}
$query = "\nSELECT id, name\n FROM civicrm_country\n WHERE {$countryClause}\n AND {$whereClause} \nORDER BY name";
$nullArray = array();
$dao = CRM_Core_DAO::executeQuery($query, $nullArray);
$count = 0;
while ($dao->fetch() && $count < 5) {
$elements[] = array('name' => ts($dao->name), 'value' => $dao->id);
$count++;
}
}
if (empty($elements)) {
if (isset($_GET['id'])) {
$name = $_GET['id'];
}
$elements[] = array('name' => trim($name, "%"), 'value' => trim($name, "%"));
}
require_once "CRM/Utils/JSON.php";
echo CRM_Utils_JSON::encode($elements, 'value');
}