added page and function
This commit is contained in:
parent
1e50c06c5b
commit
0c4fe4ccd6
@ -3,7 +3,54 @@
|
||||
class CRM_Grant_BAO_GrantBudget extends CRM_Grant_DAO_GrantBudget {
|
||||
|
||||
public static function getFiscalyear() {
|
||||
return [2018=>2018];
|
||||
return [2018 => 2018];
|
||||
}
|
||||
|
||||
public static function getGrantBudget($params) {
|
||||
$fiscalYear = $params['fiscal_year'];
|
||||
if (empty($fiscalYear)) {
|
||||
$fiscalYear = date('Y');
|
||||
}
|
||||
$grantBudget = [];
|
||||
$paidStatusID = 4;
|
||||
// TODO fix hardcoded values
|
||||
$qParams = [
|
||||
1 => [$fiscalYear, 'String'],
|
||||
2 => ['2018-01-01', 'String'],
|
||||
3 => ['2018-12-31', 'String'],
|
||||
4 => [$paidStatusID, 'Integer'],
|
||||
];
|
||||
|
||||
$where = '';
|
||||
if (!empty($params['financial_type_id'])) {
|
||||
$where = 'WHERE cft.id = %5';
|
||||
$qParams[5] = [$params['financial_type_id'], 'Integer'];
|
||||
}
|
||||
$grantBudgetTableName = CRM_Grant_DAO_GrantBudget::getTableName();
|
||||
$sql = "SELECT gs.id, cft.name, IFNULL(cgb.budget, 0) AS budget,
|
||||
SUM(IFNULL(cg.amount_granted, 0)) as total_amount_granted
|
||||
FROM civicrm_financial_type cft
|
||||
INNER JOIN " . GRANT_SCHOLARSHIP_CUSTOM_TABLE_NAME . " gs
|
||||
ON gs.entity_id = cft.id AND gs." . GRANT_SCHOLARSHIP_CUSTOM_FIELD . " = 1
|
||||
LEFT JOIN " . $grantBudgetTableName . " cgb
|
||||
ON cgb.financial_type_id = cft.id AND cgb.fiscal_year = %1
|
||||
LEFT JOIN civicrm_grant cg
|
||||
ON cg.financial_type_id = cft.id AND cg.status_id IN (%4)
|
||||
AND cg.decision_date >= %2 AND cg.decision_date <= %3
|
||||
$where
|
||||
GROUP BY cft.id
|
||||
ORDER BY cft.name";
|
||||
$result = CRM_Core_DAO::executeQuery($sql, $qParams);
|
||||
|
||||
while ($result->fetch()) {
|
||||
$grantBudget[$result->id] = [
|
||||
'name' => $result->name,
|
||||
'budget' => $result->budget,
|
||||
'total_amount_granted' => $result->total_amount_granted,
|
||||
'balance_amount' => ($result->budget - $result->total_amount_granted),
|
||||
];
|
||||
}
|
||||
return $grantBudget;
|
||||
}
|
||||
|
||||
}
|
||||
|
58
CRM/Grant/Page/AnnualBudgets.php
Normal file
58
CRM/Grant/Page/AnnualBudgets.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
class CRM_Grant_Page_AnnualBudgets extends CRM_Core_Page_Basic {
|
||||
|
||||
/**
|
||||
* Get BAO Name.
|
||||
*
|
||||
* @return string
|
||||
* Classname of BAO.
|
||||
*/
|
||||
public function getBAOName() {
|
||||
return 'CRM_Grant_BAO_GrantBudget';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action Links.
|
||||
*
|
||||
* @return array
|
||||
* (reference) of action links
|
||||
*/
|
||||
public function &links() {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse all Grant Budget.
|
||||
*/
|
||||
public function browse() {
|
||||
$fiscalYear = NULL;
|
||||
if (empty($fiscalYear)) {
|
||||
$fiscalYear = date('Y');
|
||||
}
|
||||
$this->assign('fiscalYear', $fiscalYear);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get edit form name.
|
||||
*
|
||||
* @return string
|
||||
* name of this page.
|
||||
*/
|
||||
public function editName() {
|
||||
return ts('Annual Grant Budget');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user context.
|
||||
*
|
||||
* @param null $mode
|
||||
*
|
||||
* @return string
|
||||
* user context.
|
||||
*/
|
||||
public function userContext($mode = NULL) {
|
||||
return 'civicrm/grant/annual/budgets';
|
||||
}
|
||||
|
||||
}
|
3
templates/CRM/Grant/Page/AnnualBudgets.tpl
Normal file
3
templates/CRM/Grant/Page/AnnualBudgets.tpl
Normal file
@ -0,0 +1,3 @@
|
||||
<div class="crm-content-block crm-block">
|
||||
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user