forked from CiviWare/org.agbu.annualgrantbudgets
convert to using a civix-generated entity
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class CRM_Grant_BAO_GrantBudget extends CRM_Grant_DAO_GrantBudget {
|
||||
class CRM_AnnualGrantBudgets_BAO_GrantBudget extends CRM_AnnualGrantBudgets_DAO_GrantBudget {
|
||||
|
||||
/**
|
||||
* Build Fiscal year option list.
|
||||
@ -28,9 +28,7 @@ class CRM_Grant_BAO_GrantBudget extends CRM_Grant_DAO_GrantBudget {
|
||||
}
|
||||
$grantBudget = [];
|
||||
$paidStatusID = CRM_Core_PseudoConstant::getKey(
|
||||
'CRM_Grant_DAO_Grant',
|
||||
'status_id',
|
||||
'Paid'
|
||||
'CRM_Grant_DAO_Grant', 'status_id', 'Paid'
|
||||
);
|
||||
$accountRelationshipId = civicrm_api3('OptionValue', 'getvalue', [
|
||||
'return' => "value",
|
||||
@ -56,7 +54,7 @@ class CRM_Grant_BAO_GrantBudget extends CRM_Grant_DAO_GrantBudget {
|
||||
$qParams[6] = [$params['financial_type_id'], 'Integer'];
|
||||
}
|
||||
|
||||
$grantBudgetTableName = CRM_Grant_DAO_GrantBudget::getTableName();
|
||||
$grantBudgetTableName = CRM_AnnualGrantBudgets_DAO_GrantBudget::getTableName();
|
||||
$sql = "SELECT cgb.id, cft.name, IFNULL(cgb.budget, 0) AS budget,
|
||||
SUM(CASE WHEN cg.id IS NULL THEN 0 ELSE IFNULL(trxn.total_amount, 0) END) as total_amount_granted,
|
||||
cft.id AS financial_type_id
|
@ -1,67 +1,69 @@
|
||||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| 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-2017
|
||||
* @copyright CiviCRM LLC (c) 2004-2019
|
||||
*
|
||||
* Generated from /home/jon/local/agbud8/htdocs/web/sites/all/civicrm/extensions/org.agbu.annualgrantbudgets/xml/schema/CRM/AnnualGrantBudgets/GrantBudget.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:e21dfb56b654dd78e0ead9af1ba5bf77)
|
||||
* (GenCodeChecksum:7aad27e2f51ebfb640dd921e054f55c9)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
|
||||
/**
|
||||
* CRM_Grant_BAO_GrantBudget constructor.
|
||||
* Database access object for the GrantBudget entity.
|
||||
*/
|
||||
class CRM_Grant_DAO_GrantBudget extends CRM_Core_DAO {
|
||||
class CRM_AnnualGrantBudgets_DAO_GrantBudget extends CRM_Core_DAO {
|
||||
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_grant_budget';
|
||||
public static $_tableName = 'civicrm_grant_budget';
|
||||
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
static $_log = TRUE;
|
||||
public static $_log = TRUE;
|
||||
|
||||
/**
|
||||
* Unique GrantBudget ID
|
||||
*
|
||||
* @var int unsigned
|
||||
* @var int
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* FK to Financial Type
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $financial_type_id;
|
||||
|
||||
/**
|
||||
* Fiscal year
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $fiscal_year;
|
||||
|
||||
/**
|
||||
* Grant Annual Budget
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
public $budget;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->__table = 'civicrm_grant_budget';
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
@ -70,12 +72,13 @@ class CRM_Grant_DAO_GrantBudget extends CRM_Core_DAO {
|
||||
*/
|
||||
public static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financialtypeid', 'civicrm_financial_type', 'id');
|
||||
Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
@ -87,25 +90,27 @@ class CRM_Grant_DAO_GrantBudget extends CRM_Core_DAO {
|
||||
'id' => [
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'description' => CRM_AnnualGrantBudgets_ExtensionUtil::ts('Unique GrantBudget ID'),
|
||||
'required' => TRUE,
|
||||
'where' => 'civicrm_grant_budget.id',
|
||||
'table_name' => 'civicrm_grant_budget',
|
||||
'entity' => 'GrantBudget',
|
||||
'bao' => 'CRM_Grant_BAO_GrantBudget',
|
||||
'localizable' => 0,
|
||||
'bao' => 'CRM_AnnualGrantBudgets_DAO_GrantBudget',
|
||||
'localizable' => 1,
|
||||
],
|
||||
'financial_type_id' => [
|
||||
'name' => 'financial_type_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Financial Type Id'),
|
||||
'description' => 'FK to Financial Type',
|
||||
'title' => CRM_AnnualGrantBudgets_ExtensionUtil::ts('Financial Type Id'),
|
||||
'description' => CRM_AnnualGrantBudgets_ExtensionUtil::ts('FK to Financial Type'),
|
||||
'required' => TRUE,
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_grant_budget.financial_type_id',
|
||||
'export' => FALSE,
|
||||
'table_name' => 'civicrm_grant_budget',
|
||||
'entity' => 'GrantBudget',
|
||||
'bao' => 'CRM_Grant_BAO_GrantBudget',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Financial_DAO_FinancialType',
|
||||
'bao' => 'CRM_AnnualGrantBudgets_DAO_GrantBudget',
|
||||
'localizable' => 1,
|
||||
'html' => [
|
||||
'type' => 'Select',
|
||||
],
|
||||
@ -113,43 +118,46 @@ class CRM_Grant_DAO_GrantBudget extends CRM_Core_DAO {
|
||||
'table' => 'civicrm_financial_type',
|
||||
'keyColumn' => 'id',
|
||||
'labelColumn' => 'name',
|
||||
]
|
||||
],
|
||||
],
|
||||
'fiscal_year' => [
|
||||
'name' => 'fiscal_year',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Fiscal year'),
|
||||
'description' => 'Fiscal year',
|
||||
'title' => CRM_AnnualGrantBudgets_ExtensionUtil::ts('Fiscal Year'),
|
||||
'description' => CRM_AnnualGrantBudgets_ExtensionUtil::ts('Fiscal year'),
|
||||
'required' => TRUE,
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_grant_budget.fiscal_year',
|
||||
'export' => FALSE,
|
||||
'table_name' => 'civicrm_grant_budget',
|
||||
'entity' => 'GrantBudget',
|
||||
'bao' => 'CRM_Grant_BAO_GrantBudget',
|
||||
'localizable' => 0,
|
||||
'bao' => 'CRM_AnnualGrantBudgets_DAO_GrantBudget',
|
||||
'localizable' => 1,
|
||||
'html' => [
|
||||
'type' => 'Select',
|
||||
],
|
||||
'pseudoconstant' => [
|
||||
'callback' => 'CRM_Grant_BAO_GrantBudget::getFiscalyear',
|
||||
]
|
||||
],
|
||||
],
|
||||
'budget' => [
|
||||
'name' => 'budget',
|
||||
'type' => CRM_Utils_Type::T_MONEY,
|
||||
'title' => ts('Grant Annual Budget'),
|
||||
'description' => 'Grant Annual Budget.',
|
||||
'title' => CRM_AnnualGrantBudgets_ExtensionUtil::ts('Grant Annual Budget'),
|
||||
'description' => CRM_AnnualGrantBudgets_ExtensionUtil::ts('Grant Annual Budget'),
|
||||
'required' => TRUE,
|
||||
'precision' => [
|
||||
20,
|
||||
2
|
||||
2,
|
||||
],
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_grant_budget.budget',
|
||||
'export' => TRUE,
|
||||
'default' => '0.00',
|
||||
'table_name' => 'civicrm_grant_budget',
|
||||
'entity' => 'GrantBudget',
|
||||
'bao' => 'CRM_Grant_BAO_GrantBudget',
|
||||
'localizable' => 0,
|
||||
'bao' => 'CRM_AnnualGrantBudgets_DAO_GrantBudget',
|
||||
'localizable' => 1,
|
||||
'html' => [
|
||||
'type' => 'Text',
|
||||
],
|
||||
@ -159,6 +167,7 @@ class CRM_Grant_DAO_GrantBudget extends CRM_Core_DAO {
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
@ -171,14 +180,16 @@ class CRM_Grant_DAO_GrantBudget extends CRM_Core_DAO {
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getTableName() {
|
||||
return self::$_tableName;
|
||||
return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
@ -187,6 +198,7 @@ class CRM_Grant_DAO_GrantBudget extends CRM_Core_DAO {
|
||||
public function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
@ -198,6 +210,7 @@ class CRM_Grant_DAO_GrantBudget extends CRM_Core_DAO {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'grant_budget', $prefix, []);
|
||||
return $r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
@ -209,8 +222,13 @@ class CRM_Grant_DAO_GrantBudget extends CRM_Core_DAO {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'grant_budget', $prefix, []);
|
||||
return $r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*
|
||||
* @param bool $localize
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = [];
|
@ -9,7 +9,7 @@ class CRM_Grant_Page_AnnualBudgets extends CRM_Core_Page_Basic {
|
||||
* Classname of BAO.
|
||||
*/
|
||||
public function getBAOName() {
|
||||
return 'CRM_Grant_BAO_GrantBudget';
|
||||
return 'CRM_AnnualGrantBudgets_BAO_GrantBudget';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,7 +40,7 @@ class CRM_Grant_Page_AnnualBudgets extends CRM_Core_Page_Basic {
|
||||
$fiscalYear = date('Y');
|
||||
}
|
||||
$fiscalYearOptions = '';
|
||||
foreach (CRM_Grant_BAO_GrantBudget::getFiscalyear() as $key => $value) {
|
||||
foreach (CRM_AnnualGrantBudgets_BAO_GrantBudget::getFiscalyear() as $key => $value) {
|
||||
$extra = '';
|
||||
if ($key == $fiscalYear) {
|
||||
$extra = 'selected="selected"';
|
||||
|
Reference in New Issue
Block a user