本文整理汇总了PHP中CRM_Utils_Weight::addOrder方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Weight::addOrder方法的具体用法?PHP CRM_Utils_Weight::addOrder怎么用?PHP CRM_Utils_Weight::addOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Weight
的用法示例。
在下文中一共展示了CRM_Utils_Weight::addOrder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: browse
/**
* Browse all price fields.
*
* @return void
*/
public function browse()
{
$customOption = array();
CRM_Price_BAO_PriceFieldValue::getValues($this->_fid, $customOption);
// CRM-15378 - check if these price options are in an Event price set
$isEvent = FALSE;
$extendComponentId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_sid, 'extends', 'id');
$allComponents = explode(CRM_Core_DAO::VALUE_SEPARATOR, $extendComponentId);
$eventComponentId = CRM_Core_Component::getComponentID('CiviEvent');
if (in_array($eventComponentId, $allComponents)) {
$isEvent = TRUE;
}
$config = CRM_Core_Config::singleton();
$financialType = CRM_Contribute_PseudoConstant::financialType();
$taxRate = CRM_Core_PseudoConstant::getTaxRates();
// display taxTerm for priceFields
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
$taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
$getTaxDetails = FALSE;
foreach ($customOption as $id => $values) {
$action = array_sum(array_keys($this->actionLinks()));
// Adding the required fields in the array
if (isset($taxRate[$values['financial_type_id']])) {
$customOption[$id]['tax_rate'] = $taxRate[$values['financial_type_id']];
if ($invoicing && isset($customOption[$id]['tax_rate'])) {
$getTaxDetails = TRUE;
}
$taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($customOption[$id]['amount'], $customOption[$id]['tax_rate']);
$customOption[$id]['tax_amount'] = $taxAmount['tax_amount'];
}
if (!empty($values['financial_type_id'])) {
$customOption[$id]['financial_type_id'] = $financialType[$values['financial_type_id']];
}
// update enable/disable links depending on price_field properties.
if ($this->_isSetReserved) {
$action -= CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE + CRM_Core_Action::DISABLE + CRM_Core_Action::ENABLE;
} else {
if ($values['is_active']) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
}
if (!empty($customOption[$id]['is_default'])) {
$customOption[$id]['is_default'] = '<img src="' . $config->resourceBase . 'i/check.gif" />';
} else {
$customOption[$id]['is_default'] = '';
}
$customOption[$id]['order'] = $customOption[$id]['weight'];
$customOption[$id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('oid' => $id, 'fid' => $this->_fid, 'sid' => $this->_sid), ts('more'), FALSE, 'priceFieldValue.row.actions', 'PriceFieldValue', $id);
}
// Add order changing widget to selector
$returnURL = CRM_Utils_System::url('civicrm/admin/price/field/option', "action=browse&reset=1&fid={$this->_fid}&sid={$this->_sid}");
$filter = "price_field_id = {$this->_fid}";
CRM_Utils_Weight::addOrder($customOption, 'CRM_Price_DAO_PriceFieldValue', 'id', $returnURL, $filter);
$this->assign('taxTerm', $taxTerm);
$this->assign('getTaxDetails', $getTaxDetails);
$this->assign('customOption', $customOption);
$this->assign('sid', $this->_sid);
$this->assign('isEvent', $isEvent);
}
示例2: browse
/**
* Browse all membership types.
*
*
* @return void
*/
public function browse()
{
// get all membership types sorted by weight
$membershipType = array();
$dao = new CRM_Member_DAO_MembershipType();
$dao->orderBy('weight');
$dao->find();
while ($dao->fetch()) {
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !CRM_Core_Permission::check('view contributions of type ' . CRM_Contribute_PseudoConstant::financialType($dao->financial_type_id))) {
continue;
}
$links = self::links();
$membershipType[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $membershipType[$dao->id]);
$membershipType[$dao->id]['period_type'] = CRM_Utils_Array::value($dao->period_type, CRM_Core_SelectValues::periodType(), '');
$membershipType[$dao->id]['visibility'] = CRM_Utils_Array::value($dao->visibility, CRM_Core_SelectValues::memberVisibility(), '');
//adding column for relationship type label. CRM-4178.
if ($dao->relationship_type_id) {
//If membership associated with 2 or more relationship then display all relationship with comma separated
$relTypeIds = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->relationship_type_id);
$relTypeNames = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->relationship_direction);
$membershipType[$dao->id]['relationshipTypeName'] = NULL;
foreach ($relTypeIds as $key => $value) {
$relationshipName = 'label_' . $relTypeNames[$key];
if ($membershipType[$dao->id]['relationshipTypeName']) {
$membershipType[$dao->id]['relationshipTypeName'] .= ", ";
}
$membershipType[$dao->id]['relationshipTypeName'] .= CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $value, $relationshipName);
}
$membershipType[$dao->id]['maxRelated'] = CRM_Utils_Array::value('max_related', $membershipType[$dao->id]);
}
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !CRM_Core_Permission::check('edit contributions of type ' . CRM_Contribute_PseudoConstant::financialType($dao->financial_type_id))) {
unset($links[CRM_Core_Action::UPDATE], $links[CRM_Core_Action::ENABLE], $links[CRM_Core_Action::DISABLE]);
}
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($dao->financial_type_id))) {
unset($links[CRM_Core_Action::DELETE]);
}
// form all action links
$action = array_sum(array_keys($this->links()));
// update enable/disable links depending on if it is is_reserved or is_active
if (!isset($dao->is_reserved)) {
if ($dao->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
$membershipType[$dao->id]['order'] = $membershipType[$dao->id]['weight'];
$membershipType[$dao->id]['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $dao->id), ts('more'), FALSE, 'membershipType.manage.action', 'MembershipType', $dao->id);
}
}
$returnURL = CRM_Utils_System::url('civicrm/admin/member/membershipType', "reset=1&action=browse");
CRM_Utils_Weight::addOrder($membershipType, 'CRM_Member_DAO_MembershipType', 'id', $returnURL);
CRM_Member_BAO_MembershipType::convertDayFormat($membershipType);
$this->assign('rows', $membershipType);
}
示例3: browse
/**
* Browse all price fields.
*
* @param null
*
* @return void
* @access public
*/
function browse()
{
$customOption = array();
CRM_Price_BAO_PriceFieldValue::getValues($this->_fid, $customOption);
$config = CRM_Core_Config::singleton();
$financialType = CRM_Contribute_PseudoConstant::financialType();
foreach ($customOption as $id => $values) {
$action = array_sum(array_keys($this->actionLinks()));
if (CRM_Utils_Array::value('financial_type_id', $values)) {
$customOption[$id]['financial_type_id'] = $financialType[$values['financial_type_id']];
}
// update enable/disable links depending on price_field properties.
if ($this->_isSetReserved) {
$action -= CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE + CRM_Core_Action::DISABLE + CRM_Core_Action::ENABLE;
} else {
if ($values['is_active']) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
}
if (CRM_Utils_Array::value('is_default', $customOption[$id])) {
$customOption[$id]['is_default'] = '<img src="' . $config->resourceBase . 'i/check.gif" />';
} else {
$customOption[$id]['is_default'] = '';
}
$customOption[$id]['order'] = $customOption[$id]['weight'];
$customOption[$id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('oid' => $id, 'fid' => $this->_fid, 'sid' => $this->_sid));
}
// Add order changing widget to selector
$returnURL = CRM_Utils_System::url('civicrm/admin/price/field/option', "action=browse&reset=1&fid={$this->_fid}&sid={$this->_sid}");
$filter = "price_field_id = {$this->_fid}";
CRM_Utils_Weight::addOrder($customOption, 'CRM_Price_DAO_PriceFieldValue', 'id', $returnURL, $filter);
$this->assign('customOption', $customOption);
$this->assign('sid', $this->_sid);
}
示例4: browse
/**
*
* @return void
* @access public
* @static
*/
function browse()
{
// get all custom groups sorted by weight
$premiums = array();
require_once 'CRM/Contribute/DAO/Product.php';
$pageID = CRM_Utils_Request::retrieve('id', 'Positive', $this, false, 0);
$dao =& new CRM_Contribute_DAO_Premium();
$dao->entity_table = 'civicrm_contribution_page';
$dao->entity_id = $pageID;
$dao->find(true);
$premiumID = $dao->id;
$this->assign('products', false);
if (!$premiumID) {
return;
}
require_once 'CRM/Contribute/DAO/PremiumsProduct.php';
$dao =& new CRM_Contribute_DAO_PremiumsProduct();
$dao->premiums_id = $premiumID;
$dao->orderBy('weight');
$dao->find();
while ($dao->fetch()) {
$productDAO =& new CRM_Contribute_DAO_Product();
$productDAO->id = $dao->product_id;
$productDAO->is_active = 1;
if ($productDAO->find(true)) {
$premiums[$productDAO->id] = array();
$premiums[$productDAO->id]['weight'] = $dao->weight;
CRM_Core_DAO::storeValues($productDAO, $premiums[$productDAO->id]);
$action = array_sum(array_keys($this->links()));
$premiums[$dao->product_id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $pageID, 'pid' => $dao->id));
}
}
require_once 'CRM/Contribute/PseudoConstant.php';
if (count(CRM_Contribute_PseudoConstant::products($pageID)) == 0) {
$this->assign('products', false);
} else {
$this->assign('products', true);
}
// Add order changing widget to selector
$returnURL = CRM_Utils_System::url('civicrm/admin/contribute', "reset=1&action=update&id={$pageID}&subPage=Premium");
$filter = "premiums_id = {$premiumID}";
require_once 'CRM/Utils/Weight.php';
CRM_Utils_Weight::addOrder($premiums, 'CRM_Contribute_DAO_PremiumsProduct', 'id', $returnURL, $filter);
$this->assign('rows', $premiums);
}
示例5: addOrder
/**
* Add ordering fields to Page Format list.
*
* @param array (reference) $list List of PDF Page Formats
* @param string $returnURL
* URL of page calling this function.
*
* @return void
*/
public static function addOrder(&$list, $returnURL)
{
$filter = "option_group_id = " . self::_getGid();
CRM_Utils_Weight::addOrder($list, 'CRM_Core_DAO_OptionValue', 'id', $returnURL, $filter);
}
示例6: browse
/**
* Browse all options
*
*
* @return void
* @access public
* @static
*/
function browse()
{
$campaingCompId = CRM_Core_Component::getComponentID('CiviCampaign');
$groupParams = array('name' => $this->_gName);
$optionValues = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'component_id,weight');
foreach ($optionValues as $key => $optionValue) {
if (CRM_Utils_Array::value('component_id', $optionValue) != $campaingCompId) {
unset($optionValues[$key]);
}
}
$returnURL = CRM_Utils_System::url("civicrm/admin/campaign/surveyType", "reset=1");
$filter = "option_group_id = " . $this->_gid;
CRM_Utils_Weight::addOrder($optionValues, 'CRM_Core_DAO_OptionValue', 'id', $returnURL, $filter);
$this->assign('rows', $optionValues);
}
示例7: browse
/**
* Browse all CiviCRM Profile group fields.
*
* @return void
*/
public function browse()
{
$resourceManager = CRM_Core_Resources::singleton();
if (!empty($_GET['new']) && $resourceManager->ajaxPopupsEnabled) {
$resourceManager->addScriptFile('civicrm', 'js/crm.addNew.js', 999, 'html-header');
}
$ufField = array();
$ufFieldBAO = new CRM_Core_BAO_UFField();
// fkey is gid
$ufFieldBAO->uf_group_id = $this->_gid;
$ufFieldBAO->orderBy('weight', 'field_name');
$ufFieldBAO->find();
$otherModules = CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_gid);
$this->assign('otherModules', $otherModules);
$isGroupReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'is_reserved');
$this->assign('isGroupReserved', $isGroupReserved);
$profileType = CRM_Core_BAO_UFField::getProfileType($this->_gid);
if ($profileType == 'Contribution' || $profileType == 'Membership' || $profileType == 'Activity' || $profileType == 'Participant') {
$this->assign('skipCreate', TRUE);
}
$locationType = array();
$locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
$fields = CRM_Contact_BAO_Contact::exportableFields('All', FALSE, TRUE);
$fields = array_merge(CRM_Contribute_BAO_Contribution::getContributionFields(), $fields);
$select = array();
foreach ($fields as $name => $field) {
if ($name) {
$select[$name] = $field['title'];
}
}
$select['group'] = ts('Group(s)');
$select['tag'] = ts('Tag(s)');
$visibility = CRM_Core_SelectValues::ufVisibility();
while ($ufFieldBAO->fetch()) {
$ufField[$ufFieldBAO->id] = array();
$phoneType = $locType = '';
CRM_Core_DAO::storeValues($ufFieldBAO, $ufField[$ufFieldBAO->id]);
$ufField[$ufFieldBAO->id]['visibility_display'] = $visibility[$ufFieldBAO->visibility];
$ufField[$ufFieldBAO->id]['label'] = $ufFieldBAO->label;
$action = array_sum(array_keys($this->actionLinks()));
if ($ufFieldBAO->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
if ($ufFieldBAO->is_reserved) {
$action -= CRM_Core_Action::UPDATE;
$action -= CRM_Core_Action::DISABLE;
$action -= CRM_Core_Action::DELETE;
}
$ufField[$ufFieldBAO->id]['order'] = $ufField[$ufFieldBAO->id]['weight'];
$ufField[$ufFieldBAO->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $ufFieldBAO->id, 'gid' => $this->_gid), ts('more'), FALSE, 'ufField.row.actions', 'UFField', $ufFieldBAO->id);
}
$returnURL = CRM_Utils_System::url('civicrm/admin/uf/group/field', "reset=1&action=browse&gid={$this->_gid}");
$filter = "uf_group_id = {$this->_gid}";
CRM_Utils_Weight::addOrder($ufField, 'CRM_Core_DAO_UFField', 'id', $returnURL, $filter);
$this->assign('ufField', $ufField);
// retrieve showBestResult from session
$session = CRM_Core_Session::singleton();
$showBestResult = $session->get('showBestResult');
$this->assign('showBestResult', $showBestResult);
$session->set('showBestResult', 0);
}
示例8: browse
/**
* Browse all custom data groups.
*
*
* @return void
* @access public
* @static
*/
function browse()
{
// get all custom groups sorted by weight
$membershipStatus = array();
require_once 'CRM/Member/DAO/MembershipStatus.php';
$dao =& new CRM_Member_DAO_MembershipStatus();
$dao->orderBy('weight');
$dao->find();
while ($dao->fetch()) {
$membershipStatus[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $membershipStatus[$dao->id]);
// form all action links
$action = array_sum(array_keys($this->links()));
// update enable/disable links depending on if it is is_reserved or is_active
if (!$dao->is_reserved) {
if ($dao->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
$membershipStatus[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id));
}
$membershipStatus[$dao->id]['start_event'] = str_replace("_", " ", CRM_Utils_Array::value('start_event', $membershipStatus[$dao->id]));
if (isset($membershipStatus[$dao->id]['end_event'])) {
$membershipStatus[$dao->id]['end_event'] = str_replace("_", " ", CRM_Utils_Array::value('end_event', $membershipStatus[$dao->id]));
}
}
// Add order changing widget to selector
$returnURL = CRM_Utils_System::url('civicrm/admin/member/membershipStatus', "reset=1&action=browse");
require_once 'CRM/Utils/Weight.php';
CRM_Utils_Weight::addOrder($membershipStatus, 'CRM_Member_DAO_MembershipStatus', 'id', $returnURL);
$this->assign('rows', $membershipStatus);
}
示例9: browse
/**
* Browse all price set fields.
*
* @param null
*
* @return void
* @access public
*/
function browse()
{
require_once 'CRM/Price/BAO/Field.php';
$priceField = array();
$priceFieldBAO =& new CRM_Price_BAO_Field();
// fkey is sid
$priceFieldBAO->price_set_id = $this->_sid;
$priceFieldBAO->orderBy('weight, label');
$priceFieldBAO->find();
while ($priceFieldBAO->fetch()) {
$priceField[$priceFieldBAO->id] = array();
CRM_Core_DAO::storeValues($priceFieldBAO, $priceField[$priceFieldBAO->id]);
// get price if it's a text field
if ($priceFieldBAO->html_type == 'Text') {
$optionValues = array();
$params = array('name' => "civicrm_price_field.amount.{$priceFieldBAO->id}");
require_once 'CRM/Core/OptionValue.php';
CRM_Core_OptionValue::getValues($params, $optionValues);
$priceField[$priceFieldBAO->id]['price'] = CRM_Utils_Array::value('value', array_pop($optionValues));
}
$action = array_sum(array_keys($this->actionLinks()));
if ($priceFieldBAO->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
if ($priceFieldBAO->active_on == '0000-00-00 00:00:00') {
$priceField[$priceFieldBAO->id]['active_on'] = '';
}
if ($priceFieldBAO->expire_on == '0000-00-00 00:00:00') {
$priceField[$priceFieldBAO->id]['expire_on'] = '';
}
// need to translate html types from the db
require_once 'CRM/Price/BAO/Field.php';
$htmlTypes = CRM_Price_BAO_Field::htmlTypes();
$priceField[$priceFieldBAO->id]['html_type'] = $htmlTypes[$priceField[$priceFieldBAO->id]['html_type']];
$priceField[$priceFieldBAO->id]['order'] = $priceField[$priceFieldBAO->id]['weight'];
$priceField[$priceFieldBAO->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('fid' => $priceFieldBAO->id, 'sid' => $this->_sid));
}
$returnURL = CRM_Utils_System::url('civicrm/admin/price/field', "reset=1&action=browse&sid={$this->_sid}");
$filter = "price_set_id = {$this->_sid}";
require_once 'CRM/Utils/Weight.php';
CRM_Utils_Weight::addOrder($priceField, 'CRM_Price_DAO_Field', 'id', $returnURL, $filter);
$this->assign('priceField', $priceField);
}
示例10: browse
/**
* Browse all custom group fields.
*
* @param null
*
* @return void
* @access public
*/
function browse()
{
require_once 'CRM/Core/BAO/CustomField.php';
$customField = array();
$customFieldBAO =& new CRM_Core_BAO_CustomField();
// fkey is gid
$customFieldBAO->custom_group_id = $this->_gid;
$customFieldBAO->orderBy('weight, label');
$customFieldBAO->find();
while ($customFieldBAO->fetch()) {
$customField[$customFieldBAO->id] = array();
CRM_Core_DAO::storeValues($customFieldBAO, $customField[$customFieldBAO->id]);
$action = array_sum(array_keys($this->actionLinks()));
if ($customFieldBAO->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
switch ($customFieldBAO->data_type) {
case "String":
case "Int":
case "Float":
case "Money":
// if Multi Select field is selected in custom field
if ($customFieldBAO->html_type == 'Text') {
$action -= CRM_Core_Action::BROWSE;
}
break;
case "ContactReference":
case "Memo":
case "Date":
case "Boolean":
case "StateProvince":
case "Country":
case "File":
case "Link":
$action -= CRM_Core_Action::BROWSE;
break;
}
$customFieldDataType = CRM_Core_BAO_CustomField::dataType();
$customField[$customFieldBAO->id]['data_type'] = $customFieldDataType[$customField[$customFieldBAO->id]['data_type']];
$customField[$customFieldBAO->id]['order'] = $customField[$customFieldBAO->id]['weight'];
$customField[$customFieldBAO->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $customFieldBAO->id, 'gid' => $this->_gid));
}
$returnURL = CRM_Utils_System::url('civicrm/admin/custom/group/field', "reset=1&action=browse&gid={$this->_gid}");
$filter = "custom_group_id = {$this->_gid}";
require_once 'CRM/Utils/Weight.php';
CRM_Utils_Weight::addOrder($customField, 'CRM_Core_DAO_CustomField', 'id', $returnURL, $filter);
$this->assign('customField', $customField);
}
示例11: browse
/**
* Browse all options
*
*
* @return void
* @access public
* @static
*/
function browse()
{
if (!self::$_gName) {
return parent::browse();
}
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
$groupParams = array('name' => self::$_gName);
$optionValue = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'component_id,weight');
$gName = self::$_gName;
$returnURL = CRM_Utils_System::url("civicrm/admin/options/{$gName}", "reset=1&group={$gName}");
$filter = "option_group_id = " . self::$_gId;
CRM_Utils_Weight::addOrder($optionValue, 'CRM_Core_DAO_OptionValue', 'id', $returnURL, $filter);
// retrieve financial account name for the payment instrument page
if ($gName = "payment_instrument") {
foreach ($optionValue as $key => $option) {
$optionValue[$key]['financial_account'] = CRM_Financial_BAO_FinancialTypeAccount::getFinancialAccount($key, 'civicrm_option_value');
}
}
$this->assign('includeWysiwygEditor', TRUE);
$this->assign('rows', $optionValue);
}
示例12: browse
/**
* Browse all price fields.
*
* @param null
*
* @return void
* @access public
*/
function browse()
{
$customOption = array();
$groupParams = array('name' => "civicrm_price_field.amount.{$this->_fid}");
require_once 'CRM/Core/OptionValue.php';
CRM_Core_OptionValue::getValues($groupParams, $customOption);
$config =& CRM_Core_Config::singleton();
foreach ($customOption as $id => $values) {
$action = array_sum(array_keys($this->actionLinks()));
// update enable/disable links depending on price_field properties.
if ($values['is_active']) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
if (CRM_Utils_Array::value('is_default', $customOption[$id])) {
$customOption[$id]['is_default'] = '<img src="' . $config->resourceBase . 'i/check.gif" />';
} else {
$customOption[$id]['is_default'] = '';
}
$customOption[$id]['order'] = $customOption[$id]['weight'];
$customOption[$id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('oid' => $id, 'fid' => $this->_fid, 'sid' => $this->_sid));
}
// Add order changing widget to selector
$returnURL = CRM_Utils_System::url('civicrm/admin/price/field/option', "action=browse&reset=1&fid={$this->_fid}&sid={$this->_sid}");
$filter = "option_group_id = (SELECT id FROM civicrm_option_group WHERE name = 'civicrm_price_field.amount.{$this->_fid}')";
require_once 'CRM/Utils/Weight.php';
CRM_Utils_Weight::addOrder($customOption, 'CRM_Core_DAO_OptionValue', 'id', $returnURL, $filter);
$this->assign('customOption', $customOption);
}
示例13: browse
/**
* Browse all options.
*
*
* @return void
*/
public function browse()
{
if (!self::$_gName) {
return parent::browse();
}
$groupParams = array('name' => self::$_gName);
$optionValue = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'component_id,weight');
$gName = self::$_gName;
$returnURL = CRM_Utils_System::url("civicrm/admin/options/{$gName}", "reset=1&group={$gName}");
$filter = "option_group_id = " . self::$_gId;
CRM_Utils_Weight::addOrder($optionValue, 'CRM_Core_DAO_OptionValue', 'id', $returnURL, $filter);
// retrieve financial account name for the payment method page
if ($gName = "payment_instrument") {
foreach ($optionValue as $key => $option) {
$optionValue[$key]['financial_account'] = CRM_Financial_BAO_FinancialTypeAccount::getFinancialAccount($key, 'civicrm_option_value');
}
}
$this->assign('rows', $optionValue);
}
示例14: browse
/**
* Browse all custom group fields.
*
* @param null
*
* @return void
* @access public
*/
function browse()
{
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
//get the default value from custom fields
$customFieldBAO = new CRM_Core_BAO_CustomField();
$customFieldBAO->id = $this->_fid;
if ($customFieldBAO->find(TRUE)) {
$defaultValue = $customFieldBAO->default_value;
$fieldHtmlType = $customFieldBAO->html_type;
} else {
CRM_Core_Error::fatal();
}
$defVal = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($defaultValue, 1, -1));
// get the option group id
$optionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $this->_fid, 'option_group_id');
$query = "\nSELECT id, label\nFROM civicrm_custom_field\nWHERE option_group_id = %1";
$params = array(1 => array($optionGroupID, 'Integer'), 2 => array($this->_fid, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
$reusedNames = array();
if ($dao->N > 1) {
while ($dao->fetch()) {
$reusedNames[] = $dao->label;
}
$reusedNames = implode(', ', $reusedNames);
$newTitle = ts('%1 - Multiple Choice Options', array(1 => $reusedNames));
CRM_Utils_System::setTitle($newTitle);
$this->assign('reusedNames', $reusedNames);
}
$query = "\nSELECT *\n FROM civicrm_option_value\n WHERE option_group_id = %1\nORDER BY weight, label\n";
$params = array(1 => array($optionGroupID, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
$customOption = array();
$fields = array('label', 'value', 'is_active', 'weight');
$config = CRM_Core_Config::singleton();
while ($dao->fetch()) {
$customOption[$dao->id] = array();
foreach ($fields as $field) {
$customOption[$dao->id][$field] = $dao->{$field};
}
$action = array_sum(array_keys($this->actionLinks()));
// update enable/disable links depending on custom_field properties.
if ($dao->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
if ($fieldHtmlType == 'CheckBox' || $fieldHtmlType == 'AdvMulti-Select' || $fieldHtmlType == 'Multi-Select') {
if (in_array($dao->value, $defVal)) {
$customOption[$dao->id]['default_value'] = '<img src="' . $config->resourceBase . 'i/check.gif" />';
} else {
$customOption[$dao->id]['default_value'] = '';
}
} else {
if ($defaultValue == $dao->value) {
$customOption[$dao->id]['default_value'] = '<img src="' . $config->resourceBase . 'i/check.gif" />';
} else {
$customOption[$dao->id]['default_value'] = '';
}
}
$customOption[$dao->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $dao->id, 'fid' => $this->_fid, 'gid' => $this->_gid), ts('more'), FALSE, 'customOption.row.actions', 'customOption', $dao->id);
}
// Add order changing widget to selector
$returnURL = CRM_Utils_System::url('civicrm/admin/custom/group/field/option', "reset=1&action=browse&gid={$this->_gid}&fid={$this->_fid}");
$filter = "option_group_id = {$optionGroupID}";
CRM_Utils_Weight::addOrder($customOption, 'CRM_Core_DAO_OptionValue', 'id', $returnURL, $filter);
$this->assign('customOption', $customOption);
}
示例15: browse
/**
* Browse all custom group fields.
*
* @return void
*/
public function browse()
{
$resourceManager = CRM_Core_Resources::singleton();
if (!empty($_GET['new']) && $resourceManager->ajaxPopupsEnabled) {
$resourceManager->addScriptFile('civicrm', 'js/crm.addNew.js', 999, 'html-header');
}
$customField = array();
$customFieldBAO = new CRM_Core_BAO_CustomField();
// fkey is gid
$customFieldBAO->custom_group_id = $this->_gid;
$customFieldBAO->orderBy('weight, label');
$customFieldBAO->find();
while ($customFieldBAO->fetch()) {
$customField[$customFieldBAO->id] = array();
CRM_Core_DAO::storeValues($customFieldBAO, $customField[$customFieldBAO->id]);
$action = array_sum(array_keys($this->actionLinks()));
if ($customFieldBAO->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
switch ($customFieldBAO->data_type) {
case "String":
case "Int":
case "Float":
case "Money":
// if Multi Select field is selected in custom field
if ($customFieldBAO->html_type == 'Text') {
$action -= CRM_Core_Action::BROWSE;
}
break;
case "ContactReference":
case "Memo":
case "Date":
case "Boolean":
case "StateProvince":
case "Country":
case "File":
case "Link":
$action -= CRM_Core_Action::BROWSE;
break;
}
$customFieldDataType = CRM_Core_BAO_CustomField::dataType();
$customField[$customFieldBAO->id]['data_type'] = $customFieldDataType[$customField[$customFieldBAO->id]['data_type']];
$customField[$customFieldBAO->id]['order'] = $customField[$customFieldBAO->id]['weight'];
$customField[$customFieldBAO->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $customFieldBAO->id, 'gid' => $this->_gid), ts('more'), FALSE, 'customField.row.actions', 'CustomField', $customFieldBAO->id);
}
$returnURL = CRM_Utils_System::url('civicrm/admin/custom/group/field', "reset=1&action=browse&gid={$this->_gid}");
$filter = "custom_group_id = {$this->_gid}";
CRM_Utils_Weight::addOrder($customField, 'CRM_Core_DAO_CustomField', 'id', $returnURL, $filter);
$this->assign('customField', $customField);
}