本文整理汇总了PHP中CRM_Core_OptionGroup::getAssoc方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_OptionGroup::getAssoc方法的具体用法?PHP CRM_Core_OptionGroup::getAssoc怎么用?PHP CRM_Core_OptionGroup::getAssoc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_OptionGroup
的用法示例。
在下文中一共展示了CRM_Core_OptionGroup::getAssoc方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseGroupEmailGreeting
/**
* Parse all email greeting types in array of locale and gender shortcut
*/
public function parseGroupEmailGreeting()
{
CRM_Core_OptionGroup::getAssoc('email_greeting', $group, false, 'name');
foreach ($group['description'] as $id => $description) {
$tab = $this->parseLocaleGenderShortcut($description);
if (is_array($tab) && count($tab) == 2) {
$this->emailGreetingIds[$tab['locale']][$tab['genderShortcut']] = $id;
}
}
}
示例2: setValues
static function setValues($id, &$values)
{
$params = array('id' => $id);
CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', $params, $values);
// get the amounts and the label
require_once 'CRM/Core/OptionGroup.php';
$values['amount'] = array();
CRM_Core_OptionGroup::getAssoc("civicrm_contribution_page.amount.{$id}", $values['amount'], true);
// get the profile ids
require_once 'CRM/Core/BAO/UFJoin.php';
$ufJoinParams = array('entity_table' => 'civicrm_contribution_page', 'entity_id' => $id);
list($values['custom_pre_id'], $values['custom_post_id']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
// add an accounting code also
if ($values['contribution_type_id']) {
$values['accountingCode'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionType', $values['contribution_type_id'], 'accounting_code');
}
}
示例3: setDefaultValues
/**
* This function sets the default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
* @access public
* @return void
*/
function setDefaultValues()
{
$defaults = parent::setDefaultValues();
$title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'title');
CRM_Utils_System::setTitle(ts('Contribution Amounts (%1)', array(1 => $title)));
if (!CRM_Utils_Array::value('pay_later_text', $defaults)) {
$defaults['pay_later_text'] = ts('I will send payment by check');
}
if (CRM_Utils_Array::value('amount_block_is_active', $defaults)) {
// don't allow other amount option when price set present.
$this->assign('priceSetID', $this->_priceSetID);
if ($this->_priceSetID) {
return $defaults;
}
require_once 'CRM/Core/OptionGroup.php';
CRM_Core_OptionGroup::getAssoc("civicrm_contribution_page.amount.{$this->_id}", $this->_amountBlock);
$hasAmountBlock = false;
if (!empty($this->_amountBlock)) {
$hasAmountBlock = true;
$defaults = array_merge($defaults, $this->_amountBlock);
}
if (CRM_Utils_Array::value('value', $defaults) && is_array($defaults['value'])) {
if (CRM_Utils_Array::value('default_amount_id', $defaults) && CRM_Utils_Array::value('amount_id', $defaults) && is_array($defaults['amount_id'])) {
foreach ($defaults['value'] as $i => $v) {
if ($defaults['amount_id'][$i] == $defaults['default_amount_id']) {
$defaults['default'] = $i;
break;
}
}
}
// CRM-4038: fix value display
foreach ($defaults['value'] as &$amount) {
$amount = trim(CRM_Utils_Money::format($amount, ' '));
}
}
}
// fix the display of the monetary value, CRM-4038
require_once 'CRM/Utils/Money.php';
if (isset($defaults['min_amount'])) {
$defaults['min_amount'] = CRM_Utils_Money::format($defaults['min_amount'], null, '%a');
}
if (isset($defaults['max_amount'])) {
$defaults['max_amount'] = CRM_Utils_Money::format($defaults['max_amount'], null, '%a');
}
return $defaults;
}
示例4: buildAdvancedSearchPaneForm
public function buildAdvancedSearchPaneForm(&$form, $type)
{
//if (!CRM_Core_Permission::check('access HRJobs')) { echo 'not accessible'; return; }
if ($type == 'hrjobcontract') {
$form->add('hidden', 'hidden_hrjobcontract', 1);
$form->addElement('text', 'hrjobcontract_details_position', ts('Position'), CRM_Core_DAO::getAttribute('CRM_Hrjobcontract_DAO_HRJobDetails', 'position'));
$form->addElement('text', 'hrjobcontract_details_title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Hrjobcontract_DAO_HRJobDetails', 'title'));
$form->addElement('text', 'hrjobcontract_details_funding_notes', ts('Funding Notes'), CRM_Core_DAO::getAttribute('CRM_Hrjobcontract_DAO_HRJobDetails', 'funding_notes'));
$form->addElement('text', 'hrjobcontract_details_notice_amount', ts('Notice Period from Employer (Amount)'), CRM_Core_DAO::getAttribute('CRM_Hrjobcontract_DAO_HRJobDetails', 'notice_amount'));
$form->add('select', 'hrjobcontract_details_notice_unit', ts('Notice Period from Employer (Amount)'), CRM_Hrjobcontract_SelectValues::commonUnit(), FALSE, array('id' => 'hrjobcontract_details_notice_unit', 'multiple' => true));
$form->addElement('text', 'hrjobcontract_details_notice_amount_employee', ts('Notice Period from Employee (Amount)'), CRM_Core_DAO::getAttribute('CRM_Hrjobcontract_DAO_HRJobDetails', 'notice_amount_employee'));
$form->add('select', 'hrjobcontract_details_notice_unit_employee', ts('Notice Period from Employer (Amount)'), CRM_Hrjobcontract_SelectValues::commonUnit(), FALSE, array('id' => 'hrjobcontract_details_notice_unit_employee', 'multiple' => true));
$hrjcLocation = CRM_Core_PseudoConstant::get('CRM_Hrjobcontract_DAO_HRJobDetails', 'hrjobcontract_details_location');
$form->add('select', 'hrjobcontract_details_location', ts('Normal Place of Work'), $hrjcLocation, FALSE, array('id' => 'hrjobcontract_details_location', 'multiple' => true));
$form->add('select', 'hrjobcontract_role_role_level_type', ts('Level'), CRM_Core_PseudoConstant::get('CRM_Hrjobcontract_DAO_HRJobRole', 'hrjobcontract_role_role_level_type'), FALSE, array('id' => 'hrjobcontract_role_role_level_type', 'multiple' => true));
$form->add('select', 'hrjobcontract_details_contract_type', ts('Contract Type'), CRM_Core_PseudoConstant::get('CRM_Hrjobcontract_DAO_HRJobDetails', 'hrjobcontract_details_contract_type'), FALSE, array('id' => 'hrjobcontract_details_contract_type', 'multiple' => true));
CRM_Core_Form_Date::buildDateRange($form, 'hrjobcontract_details_period_start_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE);
CRM_Core_Form_Date::buildDateRange($form, 'hrjobcontract_details_period_end_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE);
//$form->addYesNo( 'hrjobcontract_details_is_primary', ts('Is Primary?'));
$form->add('select', 'hrjobcontract_details_is_primary', ts('Is Primary'), array('' => '- select -', 0 => 'No', 1 => 'Yes'), FALSE, array('id' => 'hrjobcontract_details_is_primary', 'multiple' => false));
}
if ($type == 'hrjobcontract_health') {
$form->add('hidden', 'hidden_hrjobcontract_health', 1);
//$form->add('checkbox', 'hrjobcontract_health_is_healthcare', ts('Is healthcare provided?'));
$form->addElement('text', 'hrjobcontract_health_health_provider', ts('Healthcare Provider (Complete OR Partial Name)'), CRM_Core_DAO::getAttribute('CRM_Hrjobcontract_DAO_HRJobHealth', 'provider'));
$form->add('select', 'hrjobcontract_health_health_plan_type', ts('Healthcare Plan Type'), CRM_Hrjobcontract_SelectValues::planType(), FALSE, array('id' => 'hrjobcontract_health_health_plan_type', 'multiple' => true));
$form->addElement('text', 'hrjobcontract_health_description', ts('Description Health Insurance'), CRM_Core_DAO::getAttribute('CRM_Hrjobcontract_DAO_HRJobHealth', 'description'));
$form->addElement('text', 'hrjobcontract_health_dependents', ts('Healthcare Dependents'), CRM_Core_DAO::getAttribute('CRM_Hrjobcontract_DAO_HRJobHealth', 'dependents'));
$form->addElement('text', 'hrjobcontract_health_health_provider_life_insurance', ts('Life insurance Provider (Complete OR Partial Name)'), CRM_Core_DAO::getAttribute('CRM_Hrjobcontract_DAO_HRJobHealth', 'provider_life_insurance'));
$form->add('select', 'hrjobcontract_health_life_insurance_plan_type', ts('Life insurance Plan Type'), CRM_Hrjobcontract_SelectValues::planTypeLifeInsurance(), FALSE, array('id' => 'hrjobcontract_health_life_insurance_plan_type', 'multiple' => true));
$form->addElement('text', 'hrjobcontract_health_description_life_insurance', ts('Description Life Insurance'), CRM_Core_DAO::getAttribute('CRM_Hrjobcontract_DAO_HRJobHealth', 'description_life_insurance'));
$form->addElement('text', 'hrjobcontract_health_dependents_life_insurance', ts('Life Insurance Dependents'), CRM_Core_DAO::getAttribute('CRM_Hrjobcontract_DAO_HRJobHealth', 'dependents_life_insurance'));
}
if ($type == 'hrjobcontract_hour') {
$form->add('hidden', 'hidden_hrjobcontract_hour', 1);
$hoursLocation = new CRM_Hrjobcontract_BAO_HoursLocation();
$hoursLocation->find();
$hoursLocationOptions = array();
while ($hoursLocation->fetch()) {
$hoursLocationOptions[$hoursLocation->id] = $hoursLocation->location;
}
$form->add('select', 'hrjobcontract_hour_location_standard_hours', ts('Location/Standard hours'), $hoursLocationOptions, FALSE, array('id' => 'hrjobcontract_hour_location_standard_hours', 'multiple' => true));
$hoursType = CRM_Core_PseudoConstant::get('CRM_Hrjobcontract_DAO_HRJobHour', 'hrjobcontract_hour_hours_type');
$form->add('select', 'hrjobcontract_hour_hours_type', ts('Hours Types'), $hoursType, FALSE, array('id' => 'hrjobcontract_hour_hours_type', 'multiple' => true));
$form->add('text', 'hrjobcontract_hour_hours_amount', ts('Actual Hours (Amount)'), array('size' => 8, 'maxlength' => 8));
$form->add('select', 'hrjobcontract_hour_hours_unit', ts('Actual Hours (Unit)'), CRM_Hrjobcontract_SelectValues::commonUnit(), FALSE, array('id' => 'hrjobcontract_hour_hours_unit', 'multiple' => true));
$form->add('text', 'hrjobcontract_hour_hours_fte', ts('Full-Time Equivalence'), array('size' => 8, 'maxlength' => 8));
$form->add('text', 'hrjobcontract_hour_hours_fte_num', ts('Full-Time Numerator Equivalence'), array('size' => 8, 'maxlength' => 8));
$form->add('text', 'hrjobcontract_hour_fte_denom', ts('Full-Time Denominator Equivalence'), array('size' => 8, 'maxlength' => 8));
$form->add('text', 'hrjobcontract_hour_hours_amount_low', ts('From'), array('size' => 8, 'maxlength' => 8));
$form->addRule('hrjobcontract_hour_hours_amount_low', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money');
$form->add('text', 'hrjobcontract_hour_hours_amount_high', ts('To'), array('size' => 8, 'maxlength' => 8));
$form->addRule('hrjobcontract_hour_hours_amount_high', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
$form->add('text', 'hrjobcontract_hour_hours_fte_low', ts('From'), array('size' => 8, 'maxlength' => 8));
$form->addRule('hrjobcontract_hour_hours_fte_low', ts('Please enter a valid decimal value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money');
$form->add('text', 'hrjobcontract_hour_hours_fte_high', ts('To'), array('size' => 8, 'maxlength' => 8));
$form->addRule('hrjobcontract_hour_hours_fte_high', ts('Please enter a valid decimal value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
}
if ($type == 'hrjobcontract_leave') {
$form->add('hidden', 'hidden_hrjobcontract_leave', 1);
$leaveTypeOptions = array();
$absenceType = new CRM_HRAbsence_BAO_HRAbsenceType();
$absenceType->find();
while ($absenceType->fetch()) {
$leaveTypeOptions[$absenceType->id] = $absenceType->title;
}
$form->add('select', 'hrjobcontract_leave_leave_type', ts('Leave Type'), $leaveTypeOptions, FALSE, array('id' => 'hrjobcontract_leave_leave_type', 'multiple' => true));
}
if ($type == 'hrjobcontract_pay') {
$form->add('hidden', 'hidden_hrjobcontract_pay', 1);
$payScaleOptions = array();
$payScale = new CRM_Hrjobcontract_BAO_PayScale();
$payScale->find();
while ($payScale->fetch()) {
$payScaleOptions[$payScale->id] = $payScale->pay_scale;
if (!empty($payScale->pay_grade)) {
$payScaleOptions[$payScale->id] .= ' - ' . $payScale->pay_grade . ' - ' . $payScale->currency . ' ' . $payScale->amount . ' per ' . $payScale->periodicity;
}
}
$form->add('select', 'hrjobcontract_pay_pay_scale', ts('Pay Scale'), $payScaleOptions, FALSE, array('id' => 'hrjobcontract_pay_pay_scale', 'multiple' => true));
$form->add('select', 'hrjobcontract_pay_is_paid', ts('Paid / Unpaid'), CRM_Core_PseudoConstant::get('CRM_Hrjobcontract_DAO_HRJobPay', 'is_paid'), FALSE, array('id' => 'hrjobcontract_pay_is_paid', 'multiple' => 'multiple', 'title' => ts('- select -')));
$form->add('text', 'hrjobcontract_pay_pay_amount', ts('Pay Amount'), array('size' => 8, 'maxlength' => 8));
$form->addRule('hrjobcontract_pay_pay_amount', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money');
$form->add('text', 'hrjobcontract_pay_pay_amount_low', ts('From'), array('size' => 8, 'maxlength' => 8));
$form->addRule('hrjobcontract_pay_pay_amount_low', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money');
$form->add('text', 'hrjobcontract_pay_pay_amount_high', ts('To'), array('size' => 8, 'maxlength' => 8));
$form->addRule('hrjobcontract_pay_pay_amount_high', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
$form->add('select', 'hrjobcontract_pay_pay_unit', ts('Pay Unit'), CRM_Hrjobcontract_SelectValues::payUnit(), FALSE, array('id' => 'hrjobcontract_pay_pay_unit', 'multiple' => true));
$form->add('select', 'hrjobcontract_pay_pay_currency', ts('Pay Currency'), array_keys(CRM_Hrjobcontract_Page_JobContractTab::getCurrencyFormats()), FALSE, array('id' => 'hrjobcontract_pay_pay_currency', 'multiple' => true));
$form->add('text', 'hrjobcontract_pay_pay_annualized_est', ts('Estimated Annual Pay'), array('size' => 8, 'maxlength' => 8));
$form->addRule('hrjobcontract_pay_pay_annualized_est', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money');
$form->add('text', 'hrjobcontract_pay_pay_annualized_est_low', ts('From'), array('size' => 8, 'maxlength' => 8));
$form->addRule('hrjobcontract_pay_pay_annualized_est_low', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money');
$form->add('text', 'hrjobcontract_pay_pay_annualized_est_high', ts('To'), array('size' => 8, 'maxlength' => 8));
$form->addRule('hrjobcontract_pay_pay_annualized_est_high', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
$form->add('select', 'hrjobcontract_pay_pay_is_auto_est', ts('Estimated Auto Pay'), array('' => '- select -', 0 => 'No', 1 => 'Yes'), FALSE, array('id' => 'hrjobcontract_pay_pay_is_auto_est', 'multiple' => false));
// TODO: Annual Benefits + Annual Deductions
$payCycleOptions = array();
$payCycles = array();
CRM_Core_OptionGroup::getAssoc('hrjc_pay_cycle', $payCycles, true);
//.........这里部分代码省略.........
示例5: alterDisplay
function alterDisplay(&$rows)
{
// custom code to alter rows
$entryFound = FALSE;
$entities = array('HRJobContract', 'HRJobDetails', 'HRJobHour', 'HRJobHealth', 'HRJobLeave', 'HRJobPay', 'HRJobPension', 'HRJobRole');
$ei = CRM_Hrjobcontract_ExportImportValuesConverter::singleton();
$changeReasonOptions = array();
CRM_Core_OptionGroup::getAssoc('hrjc_revision_change_reason', $changeReasonOptions);
foreach ($rows as $rowNum => $row) {
// make count columns point to detail report
// convert sort name to links
if (!empty($row['civicrm_contact_sort_name']) && !empty($row['civicrm_hrjobcontract_contact_id'])) {
$url = CRM_Report_Utils_Report::getNextUrl('contact/detail', 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_hrjobcontract_contact_id'], $this->_absoluteUrl, $this->_id, $this->_drilldownReport);
$rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
$rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View Constituent Detail Report for this contact.");
$entryFound = TRUE;
}
// Convert revisionable HRJobContract Entities values for export
foreach ($entities as $entity) {
$tableName = _civicrm_get_table_name($entity);
$fields = $this->_columns['civicrm_hrjobcontract_' . $tableName]['fields'];
foreach ($fields as $key => $value) {
$fieldName = substr($key, strlen($tableName) + 1);
$rowKey = 'civicrm_hrjobcontract_' . $tableName . '_' . $tableName . '_' . $fieldName;
if (isset($row[$rowKey])) {
$rows[$rowNum][$rowKey] = $ei->export($tableName, $fieldName, $row[$rowKey]);
}
}
}
// Convert non-revisionable HRJobContract Entities values for export
if (!empty($row['civicrm_hrjobcontract_revision_change_reason'])) {
$rows[$rowNum]['civicrm_hrjobcontract_revision_change_reason'] = $changeReasonOptions['label'][$rows[$rowNum]['civicrm_hrjobcontract_revision_change_reason']];
$entryFound = TRUE;
}
}
}
示例6: run
/**
* Run the page.
*
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
*
* @return void
* @access public
*
*/
function run()
{
//get the event id.
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
$config =& CRM_Core_Config::singleton();
require_once 'CRM/Event/BAO/Event.php';
// ensure that the user has permission to see this page
if (!CRM_Core_Permission::event(CRM_Core_Permission::VIEW, $this->_id)) {
CRM_Core_Error::fatal(ts('You do not have permission to view this event'));
}
$action = CRM_Utils_Request::retrieve('action', 'String', $this, false);
$context = CRM_Utils_Request::retrieve('context', 'String', $this, false, 'register');
$this->assign('context', $context);
// Sometimes we want to suppress the Event Full msg
$noFullMsg = CRM_Utils_Request::retrieve('noFullMsg', 'String', $this, false, 'false');
// set breadcrumb to append to 2nd layer pages
$breadCrumbPath = CRM_Utils_System::url("civicrm/event/info", "id={$this->_id}&reset=1");
$additionalBreadCrumb = "<a href=\"{$breadCrumbPath}\">" . ts('Events') . '</a>';
//retrieve event information
$params = array('id' => $this->_id);
CRM_Event_BAO_Event::retrieve($params, $values['event']);
if (!$values['event']['is_active']) {
// form is inactive, die a fatal death
CRM_Core_Error::fatal(ts('The page you requested is currently unavailable.'));
}
$this->assign('isShowLocation', CRM_Utils_Array::value('is_show_location', $values['event']));
// show event fees.
require_once 'CRM/Price/BAO/Set.php';
if ($this->_id && CRM_Utils_Array::value('is_monetary', $values['event'])) {
// get price set options, - CRM-5209
if ($priceSetId = CRM_Price_BAO_Set::getFor('civicrm_event', $this->_id)) {
$setDetails = CRM_Price_BAO_Set::getSetDetail($priceSetId);
eval("\$priceSetFields = \$setDetails[{$priceSetId}][fields];");
if (is_array($priceSetFields)) {
$fieldCnt = 1;
foreach ($priceSetFields as $fid => $fieldValues) {
if (!is_array($fieldValues['options']) || empty($fieldValues['options'])) {
continue;
}
foreach ($fieldValues['options'] as $optionId => $optionVal) {
$values['feeBlock']['value'][$fieldCnt] = $optionVal['value'];
$values['feeBlock']['label'][$fieldCnt] = $optionVal['description'];
$fieldCnt++;
}
}
}
} else {
//retrieve event fee block.
require_once 'CRM/Core/OptionGroup.php';
require_once 'CRM/Core/BAO/Discount.php';
$discountId = CRM_Core_BAO_Discount::findSet($this->_id, 'civicrm_event');
if ($discountId) {
CRM_Core_OptionGroup::getAssoc(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $discountId, 'option_group_id'), $values['feeBlock'], false, 'id');
} else {
CRM_Core_OptionGroup::getAssoc("civicrm_event.amount.{$this->_id}", $values['feeBlock']);
}
}
}
$params = array('entity_id' => $this->_id, 'entity_table' => 'civicrm_event');
require_once 'CRM/Core/BAO/Location.php';
$values['location'] = CRM_Core_BAO_Location::getValues($params, true);
//retrieve custom field information
require_once 'CRM/Core/BAO/CustomGroup.php';
$groupTree =& CRM_Core_BAO_CustomGroup::getTree("Event", $this, $this->_id, 0, $values['event']['event_type_id']);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$this->assign('action', CRM_Core_Action::VIEW);
//To show the event location on maps directly on event info page
$locations =& CRM_Event_BAO_Event::getMapInfo($this->_id);
if (!empty($locations) && CRM_Utils_Array::value('is_map', $values['event'])) {
$this->assign('locations', $locations);
$this->assign('mapProvider', $config->mapProvider);
$this->assign('mapKey', $config->mapAPIKey);
$sumLat = $sumLng = 0;
$maxLat = $maxLng = -400;
$minLat = $minLng = +400;
foreach ($locations as $location) {
$sumLat += $location['lat'];
$sumLng += $location['lng'];
if ($location['lat'] > $maxLat) {
$maxLat = $location['lat'];
}
if ($location['lat'] < $minLat) {
$minLat = $location['lat'];
}
if ($location['lng'] > $maxLng) {
$maxLng = $location['lng'];
}
if ($location['lng'] < $minLng) {
$minLng = $location['lng'];
//.........这里部分代码省略.........
示例7: createPriceSet
/**
*
* create price sets
*/
public static function createPriceSet($daoName, $addTo, $options = array())
{
$query = "SELECT title FROM {$addTo[0]} where id =%1";
$setParams['title'] = CRM_Core_DAO::singleValueQuery($query, array(1 => array($addTo[2], 'Integer')));
$pageTitle = strtolower(CRM_Utils_String::munge($setParams['title'], '_', 245));
// an event or contrib page has been deleted but left the option group behind - (this may be fixed in later versions?)
// we should probably delete the option group - but at least early exit here as the code following it does not fatal
// CRM-10298
if (empty($pageTitle)) {
return;
}
$optionValue = array();
if (!empty($options['optionGroup'])) {
CRM_Core_OptionGroup::getAssoc($options['optionGroup'], $optionValue);
if (empty($optionValue)) {
return;
}
} elseif (empty($options['otherAmount']) && empty($options['membership'])) {
//CRM-12273
//if options group, otherAmount, membersip is empty then return, contribution should be default price set
return;
}
if (!CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set', $pageTitle, 'id', 'name', TRUE)) {
$setParams['name'] = $pageTitle;
} else {
$timeSec = explode(".", microtime(TRUE));
$setParams['name'] = $pageTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
}
$setParams['extends'] = $daoName[$addTo[0]][1];
$setParams['is_quick_config'] = 1;
$priceSet = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::create($setParams);
CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::addTo($addTo[0], $addTo[2], $priceSet->id, 1);
$fieldParams['price_set_id'] = $priceSet->id;
if (!empty($options['optionGroup'])) {
$fieldParams['html_type'] = 'Radio';
$fieldParams['is_required'] = 1;
if ($addTo[0] == 'civicrm_event') {
$query = "SELECT fee_label FROM civicrm_event where id =%1";
$fieldParams['name'] = $fieldParams['label'] = CRM_Core_DAO::singleValueQuery($query, array(1 => array($addTo[2], 'Integer')));
$defaultAmountColumn = 'default_fee_id';
} else {
$options['membership'] = 1;
$fieldParams['name'] = strtolower(CRM_Utils_String::munge("Contribution Amount", '_', 245));
$fieldParams['label'] = "Contribution Amount";
$defaultAmountColumn = 'default_amount_id';
$options['otherAmount'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $addTo[2], 'is_allow_other_amount');
if (!empty($options['otherAmount'])) {
$fieldParams['is_required'] = 0;
}
}
$fieldParams['option_label'] = $optionValue['label'];
$fieldParams['option_amount'] = $optionValue['value'];
$fieldParams['option_weight'] = $optionValue['weight'];
$fieldParams['is_quick_config'] = $setParams['is_quick_config'];
if ($defaultAmount = CRM_Core_DAO::getFieldValue($daoName[$addTo[0]][0], $addTo[2], $defaultAmountColumn)) {
$fieldParams['default_option'] = array_search($defaultAmount, $optionValue['amount_id']);
}
$priceField = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::create($fieldParams);
}
if (!empty($options['membership'])) {
$dao = new CRM_Member_DAO_MembershipBlock();
$dao->entity_table = 'civicrm_contribution_page';
$dao->entity_id = $addTo[2];
if ($dao->find(TRUE)) {
if ($dao->membership_types) {
$fieldParams = array('name' => strtolower(CRM_Utils_String::munge("Membership Amount", '_', 245)), 'label' => "Membership Amount", 'is_required' => $dao->is_required, 'is_display_amounts' => $dao->display_min_fee, 'is_active' => $dao->is_active, 'price_set_id' => $priceSet->id, 'html_type' => 'Radio', 'weight' => 1);
$membershipTypes = unserialize($dao->membership_types);
$rowcount = 0;
foreach ($membershipTypes as $membershipType => $autoRenew) {
$membershipTypeDetail = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($membershipType);
$rowcount++;
$fieldParams['option_label'][$rowcount] = $membershipTypeDetail['name'];
$fieldParams['option_amount'][$rowcount] = $membershipTypeDetail['minimum_fee'];
$fieldParams['option_weight'][$rowcount] = $rowcount;
$fieldParams['membership_type_id'][$rowcount] = $membershipType;
if ($membershipType == $dao->membership_type_default) {
$fieldParams['default_option'] = $rowcount;
}
}
$priceField = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::create($fieldParams);
$setParams = array('id' => $priceSet->id, 'extends' => CRM_Core_Component::getComponentID('CiviMember'), 'contribution_type_id' => CRM_Core_DAO::getFieldValue($daoName[$addTo[0]][0], $addTo[2], 'contribution_type_id'));
CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::create($setParams);
}
}
}
if (!empty($options['otherAmount'])) {
$fieldParams = array('name' => strtolower(CRM_Utils_String::munge("Other Amount", '_', 245)), 'label' => "Other Amount", 'is_required' => 0, 'is_display_amounts' => 0, 'is_active' => 1, 'price_set_id' => $priceSet->id, 'html_type' => 'Text', 'weight' => 3);
$fieldParams['option_label'][1] = "Other Amount";
$fieldParams['option_amount'][1] = 1;
$fieldParams['option_weight'][1] = 1;
$priceField = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::create($fieldParams);
}
}
示例8: setDefaultValues
/**
* This function sets the default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
* @param null
*
* @return array array of default values
* @access public
*/
function setDefaultValues()
{
$defaults = array();
// is it an edit operation ?
if (isset($this->_fid)) {
$params = array('id' => $this->_fid);
$this->assign('id', $this->_fid);
CRM_Price_BAO_Field::retrieve($params, $defaults);
$this->_sid = $defaults['price_set_id'];
// if text, retrieve price
if ($defaults['html_type'] == 'Text') {
$optionValues = array();
require_once 'CRM/Core/OptionGroup.php';
CRM_Core_OptionGroup::getAssoc("civicrm_price_field.amount.{$this->_fid}", $optionValues);
// fix the display of the monetary value, CRM-4038
require_once 'CRM/Utils/Money.php';
$defaults['price'] = CRM_Utils_Money::format($optionValues['value'][1], null, '%a');
}
} else {
$defaults['is_active'] = 1;
for ($i = 1; $i <= self::NUM_OPTION; $i++) {
$defaults['option_status[' . $i . ']'] = 1;
$defaults['option_weight[' . $i . ']'] = $i;
}
}
if ($this->_action & CRM_Core_Action::ADD) {
require_once 'CRM/Utils/Weight.php';
$fieldValues = array('price_set_id' => $this->_sid);
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Price_DAO_Field', $fieldValues);
$defaults['options_per_line'] = 1;
$defaults['is_display_amounts'] = 1;
}
return $defaults;
}
示例9: buildQuickForm
public function buildQuickForm()
{
$this->line_items = array();
$this->sub_total = 0;
$this->_price_values = $this->getValuesForPage('ParticipantsAndPrices');
// iterate over each event in cart
foreach ($this->cart->get_main_events_in_carts() as $event_in_cart) {
$this->process_event_line_item($event_in_cart);
foreach ($this->cart->get_events_in_carts_by_main_event_id($event_in_cart->event_id) as $subevent) {
$this->process_event_line_item($subevent, 'subevent');
}
}
$this->total = $this->sub_total;
$this->payment_required = $this->total > 0;
$this->assign('payment_required', $this->payment_required);
$this->assign('line_items', $this->line_items);
$this->assign('sub_total', $this->sub_total);
$this->assign('total', $this->total);
$buttons = array();
$buttons[] = array('name' => ts('Go Back'), 'spacing' => '  ', 'type' => 'back');
$buttons[] = array('isDefault' => TRUE, 'name' => ts('Complete Transaction'), 'spacing' => ' ', 'type' => 'next');
if ($this->total) {
$this->add('text', 'billing_contact_email', 'Billing Email', '', TRUE);
$this->assign('collect_billing_email', TRUE);
}
if (self::is_administrator()) {
$this->add('textarea', 'note', 'Note');
$this->add('text', 'source', 'Source', array('size' => 80));
$instruments = array();
CRM_Core_OptionGroup::getAssoc('payment_instrument', $instruments, TRUE);
$options = array();
foreach ($instruments as $type) {
$options[] = $this->createElement('radio', NULL, '', $type['label'], $type['value']);
}
$this->addGroup($options, 'payment_type', ts("Alternative Payment Type"));
$this->add('text', 'check_number', ts('Check No.'), array('size' => 20));
$this->addElement('checkbox', 'is_pending', ts('Create a pending registration'));
$this->assign('administrator', TRUE);
}
$this->addButtons($buttons);
$this->addFormRule(array('CRM_Event_Cart_Form_Checkout_Payment', 'formRule'), $this);
if ($this->payment_required) {
$this->buildPaymentFields();
}
}
示例10: initPriceSet
static function initPriceSet(&$form, $eventID)
{
// get price info
require_once 'CRM/Price/BAO/Set.php';
$price = CRM_Price_BAO_Set::initSet($form, $eventID, 'civicrm_event');
if ($price == false) {
require_once 'CRM/Core/OptionGroup.php';
CRM_Core_OptionGroup::getAssoc("civicrm_event.amount.{$eventID}", $form->_values['fee'], true);
require_once 'CRM/Core/BAO/Discount.php';
$discountedEvent = CRM_Core_BAO_Discount::getOptionGroup($eventID, "civicrm_event");
if (is_array($discountedEvent)) {
foreach ($discountedEvent as $key => $optionGroupId) {
$name = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $optionGroupId);
CRM_Core_OptionGroup::getAssoc($name, $form->_values['discount'][$key], true);
$form->_values['discount'][$key]["name"] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $optionGroupId, 'label');
}
}
}
return $price;
}
示例11: setDefaultValues
/**
* This function sets the default values for the form. For edit/view mode
* the default values are retrieved from the database
*
* @access public
* @return None
*/
function setDefaultValues()
{
$parentDefaults = parent::setDefaultValues();
$eventId = $this->_id;
$params = array();
$defaults = array();
if (isset($eventId)) {
$params = array('id' => $eventId);
}
CRM_Event_BAO_Event::retrieve($params, $defaults);
if (isset($eventId)) {
require_once 'CRM/Price/BAO/Set.php';
$price_set_id = CRM_Price_BAO_Set::getFor('civicrm_event', $eventId);
if ($price_set_id) {
$defaults['price_set_id'] = $price_set_id;
} else {
require_once 'CRM/Core/OptionGroup.php';
CRM_Core_OptionGroup::getAssoc("civicrm_event.amount.{$eventId}", $defaults);
}
}
//check if discounted
require_once 'CRM/Core/BAO/Discount.php';
$discountedEvent = CRM_Core_BAO_Discount::getOptionGroup($this->_id, "civicrm_event");
if (!empty($discountedEvent)) {
$defaults['is_discount'] = $i = 1;
$totalLables = $maxSize = $defaultDiscounts = array();
foreach ($discountedEvent as $optionGroupId) {
$name = $defaults["discount_name[{$i}]"] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $optionGroupId, 'label');
$defaults["discount_start_date[{$i}]"] = CRM_Utils_Date::unformat(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $optionGroupId, 'start_date', 'option_group_id'));
$defaults["discount_end_date[{$i}]"] = CRM_Utils_Date::unformat(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $optionGroupId, 'end_date', 'option_group_id'));
CRM_Core_OptionGroup::getAssoc("civicrm_event.amount.{$eventId}.discount.{$name}", $defaultDiscounts[]);
$i++;
}
//avoid moving up value of lable when some labels don't
//have a value ,fixed for CRM-3088
foreach ($defaultDiscounts as $key => $val) {
$totalLables[$key]['label'] = $val['label'];
$totalLables[$key]['value'] = $val['value'];
$totalLables[$key]['amount_id'] = $val['amount_id'];
foreach ($val['weight'] as $v) {
//take array of weight for setdefault
$discountWeight[$key][] = $v;
}
foreach ($val['value'] as $v) {
//take array of available value for particular
//discount set
$discountValue[$key][] = $v;
}
//combining the weight with amount array for set default
$discountDefualt[] = array_combine($discountWeight[$key], $discountValue[$key]);
foreach ($discountDefualt[$key] as $k => $v) {
$defaults["discounted_value"][$k][$key + 1] = $v;
}
$maxSize[$key] = sizeof($val['label']);
}
$maxKey = CRM_Utils_Array::key(max($maxSize), $maxSize);
$defaults["discounted_label"] = $totalLables[$maxKey]['label'];
$this->set('discountSection', 1);
$this->buildQuickForm();
} else {
if (!empty($defaults['label'])) {
//if Regular Fees are present in DB and event fee page is in update mode
$defaults["discounted_label"] = $defaults['label'];
} else {
if (CRM_Utils_Array::value('label', $this->_submitValues)) {
//if event is newly created, use submitted values for
//discount labels
if (is_array($this->_submitValues['label'])) {
$k = 1;
foreach ($this->_submitValues['label'] as $value) {
if ($value) {
$defaults["discounted_label"][$k] = $value;
$k++;
}
}
}
}
}
}
$defaults = array_merge($defaults, $parentDefaults);
$defaults['id'] = $eventId;
if (CRM_Utils_Array::value('value', $defaults)) {
foreach ($defaults['value'] as $i => $v) {
if ($defaults['amount_id'][$i] == $defaults['default_fee_id']) {
$defaults['default'] = $i;
break;
}
}
}
if (!empty($totalLables)) {
$maxKey = count($totalLables) - 1;
if (isset($maxKey) && CRM_Utils_Array::value('value', $totalLables[$maxKey])) {
foreach ($totalLables[$maxKey]['value'] as $i => $v) {
//.........这里部分代码省略.........
示例12: initEventFee
static function initEventFee(&$form, $eventID)
{
// get price info
require_once 'CRM/Price/BAO/Set.php';
$price = CRM_Price_BAO_Set::initSet($form, $eventID, 'civicrm_event');
if ($price == false) {
require_once 'CRM/Core/OptionGroup.php';
CRM_Core_OptionGroup::getAssoc("civicrm_event.amount.{$eventID}", $form->_values['fee'], true);
require_once 'CRM/Core/BAO/Discount.php';
$discountedEvent = CRM_Core_BAO_Discount::getOptionGroup($eventID, "civicrm_event");
if (is_array($discountedEvent)) {
foreach ($discountedEvent as $key => $optionGroupId) {
$name = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $optionGroupId);
CRM_Core_OptionGroup::getAssoc($name, $form->_values['discount'][$key], true);
$form->_values['discount'][$key]["name"] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $optionGroupId, 'label');
}
}
}
$eventFee = CRM_Utils_Array::value('fee', $form->_values);
if (!is_array($eventFee) || empty($eventFee)) {
$form->_values['fee'] = array();
}
//fix for non-upgraded price sets.CRM-4256.
if (isset($form->_isPaidEvent)) {
$isPaidEvent = $form->_isPaidEvent;
} else {
$isPaidEvent = CRM_Utils_Array::value('is_monetary', $form->_values['event']);
}
if ($isPaidEvent && empty($form->_values['fee'])) {
CRM_Core_Error::fatal(ts('No Fee Level(s) or Price Set is configured for this event.<br />Click <a href=\'%1\'>CiviEvent >> Manage Event >> Configure >> Event Fees</a> to configure the Fee Level(s) or Price Set for this event.', array(1 => CRM_Utils_System::url('civicrm/event/manage/fee', 'reset=1&action=update&id=' . $form->_eventId))));
}
}
示例13: session_start
session_start();
$settingsFile = trim(implode('', file('path.inc'))) . '/civicrm.settings.php';
define('CIVICRM_SETTINGS_PATH', $settingsFile);
$error = @(include_once $settingsFile);
if ($error == false) {
echo "Could not load the settings file at: {$settingsFile}\n";
exit;
}
// Load class loader
global $civicrm_root;
require_once $civicrm_root . '/CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
require_once 'CRM/Core/Config.php';
$config = CRM_Core_Config::singleton();
CRM_Core_OptionGroup::getAssoc('email_greeting', $group, false, 'name');
print_r($group);
$dict = new CRM_Speakcivi_Tools_Dictionary();
$dict->parseGroupEmailGreeting();
print_r($dict->emailGreetingIds);
$locales = array('fr_FR:', 'fr_FR:F', 'fr_FR:M', 'de_DE:', 'de_DE:M', 'de_DE:FG');
foreach ($locales as $loc) {
echo $loc . ' -> ' . print_r($dict->parseLocaleGenderShortcut($loc), true) . "\n";
}
echo $dict->getEmailGreetingId('fr_FR', '') . "\n";
echo $dict->getEmailGreetingId('fr_FR', 'F') . "\n";
echo $dict->getEmailGreetingId('fr_FR', 'M') . "\n";
echo $dict->getEmailGreetingId('de_DE', '') . "\n";
echo $dict->getEmailGreetingId('de_DE', 'F') . "\n";
echo $dict->getEmailGreetingId('de_DE', 'M') . "\n";
echo $dict->getEmailGreetingId('es_ES', '') . "\n";
示例14: _initialize
protected function _initialize()
{
// annual benefits options:
CRM_Core_OptionGroup::getAssoc('hrjc_benefit_name', $this->_annualOptions['benefit']['name']);
CRM_Core_OptionGroup::getAssoc('hrjc_benefit_type', $this->_annualOptions['benefit']['type']);
foreach ($this->_annualOptions['benefit']['name']['label'] as $key => $value) {
$this->_annualOptionsFlipped['benefit']['name'][$value] = $key;
}
foreach ($this->_annualOptions['benefit']['type']['label'] as $key => $value) {
$this->_annualOptionsFlipped['benefit']['type'][$value] = $key;
}
// annual deductions options:
CRM_Core_OptionGroup::getAssoc('hrjc_deduction_name', $this->_annualOptions['deduction']['name']);
CRM_Core_OptionGroup::getAssoc('hrjc_deduction_type', $this->_annualOptions['deduction']['type']);
foreach ($this->_annualOptions['deduction']['name']['label'] as $key => $value) {
$this->_annualOptionsFlipped['deduction']['name'][$value] = $key;
}
foreach ($this->_annualOptions['deduction']['type']['label'] as $key => $value) {
$this->_annualOptionsFlipped['deduction']['type'][$value] = $key;
}
// contract type options:
$contractTypeOptions = array();
CRM_Core_OptionGroup::getAssoc('hrjc_contract_type', $contractTypeOptions, true);
foreach ($contractTypeOptions as $contractType) {
$this->_contractTypeOptions[$contractType['value']] = $contractType;
$this->_contractTypeOptionsFlipped[$contractType['label']] = $contractType['value'];
}
// hours location options:
$hoursLocation = new CRM_Hrjobcontract_BAO_HoursLocation();
$hoursLocation->find();
while ($hoursLocation->fetch()) {
$this->_hoursLocationOptions[$hoursLocation->id] = (array) $hoursLocation;
}
// hours type options:
$hoursTypeOptions = array();
CRM_Core_OptionGroup::getAssoc('hrjc_hours_type', $hoursType, true);
foreach ($hoursType as $hourType) {
$this->_hoursTypeOptions[$hourType['value']] = $hourType;
$this->_hoursTypeOptionsFlipped[$hourType['label']] = $hourType['value'];
}
// leave types options:
$absenceType = new CRM_HRAbsence_BAO_HRAbsenceType();
$absenceType->find();
while ($absenceType->fetch()) {
$absenceTypeArray = (array) $absenceType;
$this->_leaveTypes[$absenceType->id] = $absenceTypeArray;
$this->_leaveTypesFlipped[$absenceTypeArray['title']] = $absenceType->id;
}
// location options:
$locationOptions = array();
CRM_Core_OptionGroup::getAssoc('hrjc_location', $locationOptions, true);
foreach ($locationOptions as $location) {
$this->_locationOptions[$location['value']] = $location;
$this->_locationOptionsFlipped[$location['label']] = $location['value'];
}
// pay cycle options:
$payCycleOptions = array();
CRM_Core_OptionGroup::getAssoc('hrjc_pay_cycle', $payCycleOptions, true);
foreach ($payCycleOptions as $payCycle) {
$this->_payCycleOptions[$payCycle['value']] = $payCycle;
$this->_payCycleOptionsFlipped[$payCycle['label']] = $payCycle['value'];
}
// pay scale options:
$payScale = new CRM_Hrjobcontract_BAO_PayScale();
$payScale->find();
while ($payScale->fetch()) {
$this->_payScaleOptions[$payScale->id] = (array) $payScale;
}
// pension type options:
$pensionTypeOptions = array();
CRM_Core_OptionGroup::getAssoc('hrjc_pension_type', $pensionTypeOptions, true);
foreach ($pensionTypeOptions as $pensionType) {
$this->_pensionTypeOptions[$pensionType['value']] = $pensionType;
$this->_pensionTypeOptionsFlipped[$pensionType['label']] = $pensionType['value'];
}
}