/** * 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); }
/** * 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); }
/** * 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); }
/** * * @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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * Browse all options. */ public function browse() { $groupParams = array('name' => self::$_gName); $optionValue = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'weight'); $gName = self::$_gName; $returnURL = CRM_Utils_System::url("civicrm/admin/report/options/{$gName}", "reset=1"); $filter = "option_group_id = " . self::$_gId; $session = new CRM_Core_Session(); $session->replaceUserContext($returnURL); CRM_Utils_Weight::addOrder($optionValue, 'CRM_Core_DAO_OptionValue', 'id', $returnURL, $filter); $this->assign('rows', $optionValue); }
/** * Browse all options * * * @return void * @access public * @static */ function browse() { require_once 'CRM/Core/OptionValue.php'; $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; require_once 'CRM/Utils/Weight.php'; CRM_Utils_Weight::addOrder($optionValue, 'CRM_Core_DAO_OptionValue', 'id', $returnURL, $filter); $this->assign('rows', $optionValue); }
/** * Browse all price set fields. * * @param null * * @return void * @access public */ function browse() { $resourceManager = CRM_Core_Resources::singleton(); if (!empty($_GET['new']) && $resourceManager->ajaxPopupsEnabled) { $resourceManager->addScriptFile('civicrm', 'js/crm.addNew.js', 999); } $priceField = array(); $priceFieldBAO = new CRM_Price_BAO_PriceField(); // 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('price_field_id' => $priceFieldBAO->id); CRM_Price_BAO_PriceFieldValue::retrieve($params, $optionValues); $priceField[$priceFieldBAO->id]['price'] = CRM_Utils_Array::value('amount', $optionValues); } $action = array_sum(array_keys($this->actionLinks())); if ($this->_isSetReserved) { $action -= CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE + CRM_Core_Action::ENABLE + CRM_Core_Action::DISABLE; } else { 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 $htmlTypes = CRM_Price_BAO_PriceField::htmlTypes(); $priceField[$priceFieldBAO->id]['html_type_display'] = $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), ts('more'), FALSE, 'priceField.row.actions', 'PriceField', $priceFieldBAO->id); } $returnURL = CRM_Utils_System::url('civicrm/admin/price/field', "reset=1&action=browse&sid={$this->_sid}"); $filter = "price_set_id = {$this->_sid}"; CRM_Utils_Weight::addOrder($priceField, 'CRM_Price_DAO_PriceField', 'id', $returnURL, $filter); $this->assign('priceField', $priceField); }
/** * Browse all CiviCRM Profile group fields. * * @return void * @access public * @static */ function browse() { $ufField = array(); $ufFieldBAO = new CRM_Core_BAO_UFField(); // fkey is gid $ufFieldBAO->uf_group_id = $this->_gid; $ufFieldBAO->orderBy('weight', 'field_name'); $ufFieldBAO->find(); require_once "CRM/Core/BAO/UFField.php"; $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::locationType(); require_once 'CRM/Contact/BAO/Contact.php'; $fields =& CRM_Contact_BAO_Contact::exportableFields('All', false, true); require_once "CRM/Contribute/BAO/Contribution.php"; $fields = array_merge(CRM_Contribute_BAO_Contribution::getContributionFields(), $fields); if (CRM_Core_Permission::access('Quest')) { require_once 'CRM/Quest/BAO/Student.php'; $fields = array_merge(CRM_Quest_BAO_Student::exportableFields(), $fields); } $select = array(); foreach ($fields as $name => $field) { if ($name) { $select[$name] = $field['title']; } } $select['group'] = ts('Group(s)'); $select['tag'] = ts('Tag(s)'); while ($ufFieldBAO->fetch()) { $ufField[$ufFieldBAO->id] = array(); $phoneType = $locType = ''; CRM_Core_DAO::storeValues($ufFieldBAO, $ufField[$ufFieldBAO->id]); CRM_Core_DAO_UFField::addDisplayEnums($ufField[$ufFieldBAO->id]); $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)); } $returnURL = CRM_Utils_System::url('civicrm/admin/uf/group/field', "reset=1&action=browse&gid={$this->_gid}"); $filter = "uf_group_id = {$this->_gid}"; require_once 'CRM/Utils/Weight.php'; 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); }
/** * Browse function. */ public function browse() { // get all custom groups sorted by weight $premiums = array(); $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); $this->assign('id', $pageID); if (!$premiumID) { return; } $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), ts('more'), FALSE, 'premium.contributionpage.row', 'Premium', $dao->id); //Financial Type if (!empty($dao->financial_type_id)) { $premiums[$productDAO->id]['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $dao->financial_type_id, 'name'); } } } 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/premium', "reset=1&action=update&id={$pageID}"); $filter = "premiums_id = {$premiumID}"; CRM_Utils_Weight::addOrder($premiums, 'CRM_Contribute_DAO_PremiumsProduct', 'id', $returnURL, $filter); $this->assign('rows', $premiums); }
/** * Browse all price set 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'); } $priceField = array(); $priceFieldBAO = new CRM_Price_BAO_PriceField(); // fkey is sid $priceFieldBAO->price_set_id = $this->_sid; $priceFieldBAO->orderBy('weight, label'); $priceFieldBAO->find(); // 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; $taxRate = CRM_Core_PseudoConstant::getTaxRates(); CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes); 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('price_field_id' => $priceFieldBAO->id); CRM_Price_BAO_PriceFieldValue::retrieve($params, $optionValues); $financialTypeId = $optionValues['financial_type_id']; if (!array_key_exists($financialTypeId, $financialTypes)) { unset($priceField[$priceFieldBAO->id]); continue; } $priceField[$priceFieldBAO->id]['price'] = CRM_Utils_Array::value('amount', $optionValues); if ($invoicing && isset($taxRate[$financialTypeId])) { $priceField[$priceFieldBAO->id]['tax_rate'] = $taxRate[$financialTypeId]; $getTaxDetails = TRUE; } if (isset($priceField[$priceFieldBAO->id]['tax_rate'])) { $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($priceField[$priceFieldBAO->id]['price'], $priceField[$priceFieldBAO->id]['tax_rate']); $priceField[$priceFieldBAO->id]['tax_amount'] = $taxAmount['tax_amount']; } } $action = array_sum(array_keys(self::actionLinks())); if ($this->_isSetReserved) { $action -= CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE + CRM_Core_Action::ENABLE + CRM_Core_Action::DISABLE; } else { 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 $htmlTypes = CRM_Price_BAO_PriceField::htmlTypes(); $priceField[$priceFieldBAO->id]['html_type_display'] = $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), ts('more'), FALSE, 'priceField.row.actions', 'PriceField', $priceFieldBAO->id); $this->assign('taxTerm', $taxTerm); $this->assign('getTaxDetails', $getTaxDetails); } $returnURL = CRM_Utils_System::url('civicrm/admin/price/field', "reset=1&action=browse&sid={$this->_sid}"); $filter = "price_set_id = {$this->_sid}"; CRM_Utils_Weight::addOrder($priceField, 'CRM_Price_DAO_PriceField', 'id', $returnURL, $filter); $this->assign('priceField', $priceField); }
/** * Browse all custom data groups. * * @param string $action the action to be invoked * * @return void * @access public */ function browse($action = NULL) { // get all custom groups sorted by weight $customGroup = array(); $dao = new CRM_Core_DAO_CustomGroup(); $dao->orderBy('weight, title'); $dao->find(); while ($dao->fetch()) { $customGroup[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $customGroup[$dao->id]); // form all action links $action = array_sum(array_keys($this->actionLinks())); // update enable/disable links depending on custom_group properties. if ($dao->is_active) { $action -= CRM_Core_Action::ENABLE; } else { $action -= CRM_Core_Action::DISABLE; } $customGroup[$dao->id]['order'] = $customGroup[$dao->id]['weight']; $customGroup[$dao->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $dao->id)); } $customGroupExtends = CRM_Core_SelectValues::customGroupExtends(); foreach ($customGroup as $key => $array) { CRM_Core_DAO_CustomGroup::addDisplayEnums($customGroup[$key]); $customGroup[$key]['extends_display'] = $customGroupExtends[$customGroup[$key]['extends']]; } //fix for Displaying subTypes $subTypes = array(); $subTypes['Activity'] = CRM_Core_PseudoConstant::activityType(FALSE, TRUE, FALSE, 'label', TRUE); $subTypes['Contribution'] = CRM_Contribute_PseudoConstant::contributionType(); $subTypes['Membership'] = CRM_Member_BAO_MembershipType::getMembershipTypes(FALSE); $subTypes['Event'] = CRM_Core_OptionGroup::values('event_type'); $subTypes['Grant'] = CRM_Core_OptionGroup::values('grant_type'); $subTypes['Campaign'] = CRM_Campaign_PseudoConstant::campaignType(); $subTypes['Participant'] = array(); $subTypes['ParticipantRole'] = CRM_Core_OptionGroup::values('participant_role'); $subTypes['ParticipantEventName'] = CRM_Event_PseudoConstant::event(); $subTypes['ParticipantEventType'] = CRM_Core_OptionGroup::values('event_type'); $subTypes['Individual'] = CRM_Contact_BAO_ContactType::subTypePairs('Individual', FALSE, NULL); $subTypes['Household'] = CRM_Contact_BAO_ContactType::subTypePairs('Household', FALSE, NULL); $subTypes['Organization'] = CRM_Contact_BAO_ContactType::subTypePairs('Organization', FALSE, NULL); $relTypeInd = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Individual'); $relTypeOrg = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Organization'); $relTypeHou = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Household'); $allRelationshipType = array(); $allRelationshipType = array_merge($relTypeInd, $relTypeOrg); $allRelationshipType = array_merge($allRelationshipType, $relTypeHou); //adding subtype specific relationships CRM-5256 $relSubType = CRM_Contact_BAO_ContactType::subTypeInfo(); foreach ($relSubType as $subType => $val) { $subTypeRelationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $val['parent'], FALSE, 'label', TRUE, $subType); $allRelationshipType = array_merge($allRelationshipType, $subTypeRelationshipTypes); } $subTypes['Relationship'] = $allRelationshipType; $cSubTypes = CRM_Core_Component::contactSubTypes(); $contactSubTypes = array(); foreach ($cSubTypes as $key => $value) { $contactSubTypes[$key] = $key; } $subTypes['Contact'] = $contactSubTypes; CRM_Core_BAO_CustomGroup::getExtendedObjectTypes($subTypes); foreach ($customGroup as $key => $values) { $subValue = CRM_Utils_Array::value('extends_entity_column_value', $customGroup[$key]); $subName = CRM_Utils_Array::value('extends_entity_column_id', $customGroup[$key]); $type = CRM_Utils_Array::value('extends', $customGroup[$key]); if ($subValue) { $subValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($subValue, 1, -1)); $colValue = NULL; foreach ($subValue as $sub) { if ($sub) { if ($type == 'Participant') { if ($subName == 1) { $colValue = $colValue ? $colValue . ', ' . $subTypes['ParticipantRole'][$sub] : $subTypes['ParticipantRole'][$sub]; } elseif ($subName == 2) { $colValue = $colValue ? $colValue . ', ' . $subTypes['ParticipantEventName'][$sub] : $subTypes['ParticipantEventName'][$sub]; } elseif ($subName == 3) { $colValue = $colValue ? $colValue . ', ' . $subTypes['ParticipantEventType'][$sub] : $subTypes['ParticipantEventType'][$sub]; } } elseif ($type == 'Relationship') { $colValue = $colValue ? $colValue . ', ' . $subTypes[$type][$sub . '_a_b'] : $subTypes[$type][$sub . '_a_b']; if (isset($subTypes[$type][$sub . '_b_a'])) { $colValue = $colValue ? $colValue . ', ' . $subTypes[$type][$sub . '_b_a'] : $subTypes[$type][$sub . '_b_a']; } } else { $colValue = $colValue ? $colValue . (isset($subTypes[$type][$sub]) ? ', ' . $subTypes[$type][$sub] : '') : (isset($subTypes[$type][$sub]) ? $subTypes[$type][$sub] : ''); } } } $customGroup[$key]["extends_entity_column_value"] = $colValue; } else { if (is_array(CRM_Utils_Array::value($type, $subTypes))) { $customGroup[$key]["extends_entity_column_value"] = ts("Any"); } } } $returnURL = CRM_Utils_System::url('civicrm/admin/custom/group', "reset=1&action=browse"); CRM_Utils_Weight::addOrder($customGroup, 'CRM_Core_DAO_CustomGroup', 'id', $returnURL); $this->assign('rows', $customGroup); }
/** * Browse all membership types. * * * @return void * @access public * @static */ function browse() { CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); // get all membership types sorted by weight $membershipType = array(); $dao = new CRM_Member_DAO_MembershipType(); $dao->orderBy('weight'); $dao->find(); while ($dao->fetch()) { $membershipType[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $membershipType[$dao->id]); //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]); } // 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(self::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); }
/** * Browse all membership types. * * * @return void * @access public * @static */ function browse() { // get all membership types sorted by weight $membershipType = array(); require_once 'CRM/Member/DAO/MembershipType.php'; $dao =& new CRM_Member_DAO_MembershipType(); $dao->orderBy('weight'); $dao->find(); require_once 'CRM/Utils/Money.php'; while ($dao->fetch()) { $membershipType[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $membershipType[$dao->id]); // fix the display of the monetary value, CRM-4038 if (CRM_Utils_Array::value('minimum_fee', $membershipType[$dao->id])) { $membershipType[$dao->id]['minimum_fee'] = CRM_Utils_Money::format($membershipType[$dao->id]['minimum_fee'], null, '%a'); } //adding column for relationship type label. CRM-4178. if ($dao->relationship_type_id) { $relationshipName = 'label_' . $dao->relationship_direction; $membershipType[$dao->id]['relationshipTypeName'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $dao->relationship_type_id, $relationshipName); } // 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(self::links(), $action, array('id' => $dao->id)); } } $returnURL = CRM_Utils_System::url('civicrm/admin/member/membershipType', "reset=1&action=browse"); require_once 'CRM/Utils/Weight.php'; CRM_Utils_Weight::addOrder($membershipType, 'CRM_Member_DAO_MembershipType', 'id', $returnURL); CRM_Member_BAO_MembershipType::convertDayFormat($membershipType); $this->assign('rows', $membershipType); }
/** * Browse all custom data groups. * * * @return void * @access public * @static */ function browse() { CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); // get all custom groups sorted by weight $membershipStatus = array(); $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), ts('more'), FALSE, 'membershipStatus.manage.action', 'MembershipStatus', $dao->id); } if ($startEvent = CRM_Utils_Array::value('start_event', $membershipStatus[$dao->id])) { $membershipStatus[$dao->id]['start_event'] = $startEvent == 'join_date' ? 'member since' : str_replace("_", " ", $startEvent); } if ($endEvent = CRM_Utils_Array::value('end_event', $membershipStatus[$dao->id])) { $membershipStatus[$dao->id]['end_event'] = $endEvent == 'join_date' ? 'member since' : str_replace("_", " ", $endEvent); } } // Add order changing widget to selector $returnURL = CRM_Utils_System::url('civicrm/admin/member/membershipStatus', "reset=1&action=browse"); CRM_Utils_Weight::addOrder($membershipStatus, 'CRM_Member_DAO_MembershipStatus', 'id', $returnURL); $this->assign('rows', $membershipStatus); }