$status = array();
$summary = array();
$summary['total_grants'] = NULL;
- $status = CRM_Grant_PseudoConstant::grantStatus();
+ $status = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id');
foreach ($status as $id => $name) {
$stats[$id] = array(
"action=view&reset=1&id={$grant->id}&cid={$grant->contact_id}&context=home"
);
- $grantTypes = CRM_Grant_PseudoConstant::grantType();
+ $grantTypes = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id');
if (!CRM_Utils_Array::value('skipRecentView', $params)) {
if(!isset($grant->contact_id) || !isset($grant->grant_type_id)){
$grant->find(TRUE);
$values = array();
$params['id'] = $this->_id;
CRM_Grant_BAO_Grant::retrieve($params, $values);
- $grantType = CRM_Grant_PseudoConstant::grantType();
- $grantStatus = CRM_Grant_PseudoConstant::grantStatus();
+ $grantType = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id');
+ $grantStatus = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id');
$this->assign('grantType', $grantType[$values['grant_type_id']]);
$this->assign('grantStatus', $grantStatus[$values['status_id']]);
$grantTokens = array(
* @return void
*/
function buildQuickForm() {
- $grantStatus = CRM_Grant_PseudoConstant::grantStatus();
+ $grantStatus = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id');
$this->addElement('select', 'status_id', ts('Grant Status'), array('' => '') + $grantStatus);
$this->addElement('text', 'amount_granted', ts('Amount Granted'));
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
-*/
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
- * $Id$
- *
- */
-
-/**
- * This class holds all the Pseudo constants that are specific to Grant. This avoids
- * polluting the core class and isolates the Grant
- */
-class CRM_Grant_PseudoConstant extends CRM_Core_PseudoConstant {
-
- /**
- * Grant Status
- *
- * @var array
- * @static
- */
- private static $grantStatus;
-
- /**
- * grant Type
- *
- * @var array
- * @static
- */
- private static $grantType;
-
- /**
- * Get all the n grant statuses
- *
- * @access public
- *
- * @return array - array reference of all grant statuses if any
- * @static
- */
- public static function &grantStatus($id = NULL) {
- if (!self::$grantStatus) {
- self::$grantStatus = array();
- self::$grantStatus = CRM_Core_OptionGroup::values('grant_status');
- }
-
- if ($id) {
- return self::$grantStatus[$id];
- }
-
- return self::$grantStatus;
- }
-
- /**
- * Get all the n grant types
- *
- * @access public
- *
- * @return array - array reference of all grant types if any
- * @static
- */
- public static function &grantType($id = NULL) {
- if (!self::$grantType) {
- self::$grantType = array();
- self::$grantType = CRM_Core_OptionGroup::values('grant_type');
- }
-
- If ($id) {
- return self::$grantType[$id];
- }
-
- return self::$grantType;
- }
-
- /**
- * Flush given pseudoconstant so it can be reread from db
- * nex time it's requested.
- *
- * @access public
- * @static
- *
- * @param boolean $name pseudoconstant to be flushed
- *
- */
- public static function flush($name = 'cache') {
- if (isset(self::$$name)) {
- self::$$name = NULL;
- }
- }
-}
-
'name' => 'grant_type_id',
'title' => ts('Grant Type'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
- 'options' => CRM_Grant_PseudoConstant::grantType(),
+ 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id'),
),
'status_id' =>
array(
'name' => 'status_id',
'title' => ts('Grant Status'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
- 'options' => CRM_Grant_PseudoConstant::grantStatus(),
+ 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id'),
),
'amount_granted' =>
array(
if (array_key_exists('civicrm_grant_grant_type_id', $row)) {
if ($value = $row['civicrm_grant_grant_type_id']) {
- $rows[$rowNum]['civicrm_grant_grant_type_id'] = CRM_Grant_PseudoConstant::grantType($value);
+ $rows[$rowNum]['civicrm_grant_grant_type_id'] = CRM_Core_PseudoConstant::getValue('CRM_Grant_DAO_Grant', 'grant_type_id', $value);
}
$entryFound = TRUE;
}
if (array_key_exists('civicrm_grant_status_id', $row)) {
if ($value = $row['civicrm_grant_status_id']) {
- $rows[$rowNum]['civicrm_grant_status_id'] = CRM_Grant_PseudoConstant::grantStatus($value);
+ $rows[$rowNum]['civicrm_grant_status_id'] = CRM_Core_PseudoConstant::getValue('CRM_Grant_DAO_Grant', 'status_id', $value);
}
$entryFound = TRUE;
}
'name' => 'grant_type_id',
'title' => ts('Grant Type'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
- 'options' => CRM_Grant_PseudoConstant::grantType(),
+ 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id'),
),
'status_id' =>
array(
'name' => 'status_id',
'title' => ts('Grant Status'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
- 'options' => CRM_Grant_PseudoConstant::grantStatus(),
+ 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id'),
),
'amount_requested' =>
array(
}
function where() {
- $approved = array_search( 'Approved', CRM_Grant_PseudoConstant::grantStatus( ) );
+ $approved = CRM_Core_PseudoConstant::getKey('CRM_Grant_DAO_Grant', 'status_id', 'Approved', array('labelColumn' => 'name'));
$whereClause = "
WHERE {$this->_aliases['civicrm_grant']}.amount_total IS NOT NULL
AND {$this->_aliases['civicrm_grant']}.amount_total > 0";
$awardedGrantsAmount = $grantsReceived = $totalAmount = $awardedGrants = $grantReportsReceived = 0;
$grantStatistics = array();
- $grantTypes = CRM_Grant_PseudoConstant::grantType();
+ $grantTypes = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id');
$countries = CRM_Core_PseudoConstant::country();
$gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
'sample' => 'Approved',
),
),
+ 'CRM_Grant_DAO_Grant' => array(
+ array(
+ 'fieldName' => 'status_id',
+ 'sample' => 'Approved',
+ ),
+ array(
+ 'fieldName' => 'grant_type_id',
+ 'sample' => 'Emergency',
+ ),
+ ),
);
foreach ($fields as $daoName => $daoFields) {
*/
require_once 'CRM/Report/Form.php';
-require_once 'CRM/Grant/PseudoConstant.php';
class org_civicrm_report_grant extends CRM_Report_Form {
protected $_addressField = FALSE; function __construct() {
'name' => 'grant_type_id',
'title' => ts('Grant Type'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
- 'options' => CRM_Grant_PseudoConstant::grantType(),
+ 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id'),
),
'status_id' =>
array(
'name' => 'status_id',
'title' => ts('Grant Status'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
- 'options' => CRM_Grant_PseudoConstant::grantStatus(),
+ 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id'),
),
'amount_granted' =>
array(
foreach ($rows as $rowNum => $row) {
if (array_key_exists('civicrm_grant_grant_type_id', $row)) {
if ($value = $row['civicrm_grant_grant_type_id']) {
- $rows[$rowNum]['civicrm_grant_grant_type_id'] = CRM_Grant_PseudoConstant::grantType($value);
+ $rows[$rowNum]['civicrm_grant_grant_type_id'] = CRM_Core_PseudoConstant::getValue('CRM_Grant_DAO_Grant', 'grant_type_id', $value);
}
$entryFound = TRUE;
}
if (array_key_exists('civicrm_grant_status_id', $row)) {
if ($value = $row['civicrm_grant_status_id']) {
- $rows[$rowNum]['civicrm_grant_status_id'] = CRM_Grant_PseudoConstant::grantStatus($value);
+ $rows[$rowNum]['civicrm_grant_status_id'] = CRM_Core_PseudoConstant::getValue('CRM_Grant_DAO_Grant', 'status_id', $value);
}
$entryFound = TRUE;
}
<index>
<name>index_grant_type_id</name>
<fieldName>grant_type_id</fieldName>
+ <pseudoconstant>
+ <optionGroupName>grant_type</optionGroupName>
+ </pseudoconstant>
<add>1.8</add>
</index>
<field>
<import>true</import>
<export>false</export>
<comment>Id of Grant status.</comment>
+ <pseudoconstant>
+ <optionGroupName>grant_status</optionGroupName>
+ </pseudoconstant>
<add>1.8</add>
</field>
<index>