/** * Browse all price sets * * @param string $action the action to be invoked * * @return void * @access public */ function browse($action = null) { // get all price sets $priceSet = array(); require_once 'CRM/Core/Component.php'; $comps = array('CiviEvent' => ts('Event'), 'CiviContribute' => ts('Contribution')); $dao = new CRM_Price_DAO_Set(); if (defined('CIVICRM_EVENT_PRICE_SET_DOMAIN_ID') && CIVICRM_EVENT_PRICE_SET_DOMAIN_ID) { $dao->domain_id = CRM_Core_Config::domainID(); } $dao->find(); while ($dao->fetch()) { $priceSet[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $priceSet[$dao->id]); $compIds = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('extends', $priceSet[$dao->id])); $extends = array(); foreach ($compIds as $compId) { $extends[] = $comps[CRM_Core_Component::getComponentName($compId)]; } $priceSet[$dao->id]['extends'] = implode(', ', $extends); // form all action links $action = array_sum(array_keys($this->actionLinks())); // update enable/disable links depending on price_set properties. if ($dao->is_active) { $action -= CRM_Core_Action::ENABLE; } else { $action -= CRM_Core_Action::DISABLE; } $priceSet[$dao->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('sid' => $dao->id)); } $this->assign('rows', $priceSet); }
/** * returns the list of fields that can be exported * * @access public * return array * @static */ static function &export($prefix = false) { if (!self::$_export) { self::$_export = array(); $fields = self::fields(); foreach ($fields as $name => $field) { if (CRM_Utils_Array::value('export', $field)) { if ($prefix) { self::$_export['price_set'] =& $fields[$name]; } else { self::$_export[$name] =& $fields[$name]; } } } } return self::$_export; }
/** * class constructor */ function __construct() { parent::__construct(); }
/** * Link the price set with the specified table and id * * @param string $entityTable * @param integer $entityId * @param integer $priceSetId * * @return bool */ public static function addTo($entityTable, $entityId, $priceSetId) { // verify that the price set exists $dao = new CRM_Price_DAO_Set(); $dao->id = $priceSetId; if (!$dao->find()) { return FALSE; } unset($dao); $dao = new CRM_Price_DAO_SetEntity(); // find if this already exists $dao->entity_id = $entityId; $dao->entity_table = $entityTable; $dao->find(TRUE); // add or update price_set_id $dao->price_set_id = $priceSetId; return $dao->save(); }
/** * Browse all price sets * * @param string $action the action to be invoked * * @return void * @access public */ function browse($action = NULL) { // get all price sets $priceSet = array(); $comps = array('CiviEvent' => ts('Event'), 'CiviContribute' => ts('Contribution'), 'CiviMember' => ts('Membership')); $dao = new CRM_Price_DAO_Set(); if (CRM_Price_BAO_Set::eventPriceSetDomainID()) { $dao->domain_id = CRM_Core_Config::domainID(); } $dao->is_quick_config = 0; $dao->find(); while ($dao->fetch()) { $priceSet[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $priceSet[$dao->id]); $compIds = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('extends', $priceSet[$dao->id])); $extends = array(); foreach ($compIds as $compId) { $extends[] = $comps[CRM_Core_Component::getComponentName($compId)]; } $priceSet[$dao->id]['extends'] = implode(', ', $extends); // form all action links $action = array_sum(array_keys($this->actionLinks())); // update enable/disable links depending on price_set properties. if ($dao->is_reserved) { $action -= CRM_Core_Action::UPDATE + CRM_Core_Action::DISABLE + CRM_Core_Action::ENABLE + CRM_Core_Action::DELETE + CRM_Core_Action::COPY; } else { if ($dao->is_active) { $action -= CRM_Core_Action::ENABLE; } else { $action -= CRM_Core_Action::DISABLE; } } $actionLinks = self::actionLinks(); //CRM-10117 if ($dao->is_reserved) { $actionLinks[CRM_Core_Action::BROWSE]['name'] = 'View Price Fields'; } $priceSet[$dao->id]['action'] = CRM_Core_Action::formLink($actionLinks, $action, array('sid' => $dao->id)); } $this->assign('rows', $priceSet); }
/** * Link the price set with the specified table and id * * @param string $entityTable * @param integer $entityId * @param integer $priceSetId * @return bool */ public static function addTo($entityTable, $entityId, $priceSetId) { // verify that the price set exists $dao = new CRM_Price_DAO_Set(); $dao->id = $priceSetId; if (!$dao->find()) { return false; } unset($dao); require_once 'CRM/Price/DAO/SetEntity.php'; $dao = new CRM_Price_DAO_SetEntity(); // find if this already exists $dao->entity_id = $entityId; $dao->entity_table = $entityTable; $dao->find(true); // add or update price_set_id $dao->price_set_id = $priceSetId; return $dao->save(); }