forked from CiviWare/org.agbu.annualgrantbudgets
removed hardcoded values
This commit is contained in:
@ -3,7 +3,9 @@
|
||||
class CRM_Grant_BAO_GrantBudget extends CRM_Grant_DAO_GrantBudget {
|
||||
|
||||
public static function getFiscalyear() {
|
||||
return [2018 => 2018];
|
||||
$from = date("Y", strtotime(date('Y') . ' - ' . GRANT_SCHOLARSHIP_YEAR_DIFF . ' years'));
|
||||
$to = date("Y", strtotime(date('Y') . ' + ' . GRANT_SCHOLARSHIP_YEAR_DIFF . ' years'));
|
||||
return array_combine(range($to, $from), range($to, $from));
|
||||
}
|
||||
|
||||
public static function getGrantBudget($params) {
|
||||
@ -12,12 +14,21 @@ class CRM_Grant_BAO_GrantBudget extends CRM_Grant_DAO_GrantBudget {
|
||||
$fiscalYear = date('Y');
|
||||
}
|
||||
$grantBudget = [];
|
||||
$paidStatusID = 4;
|
||||
// TODO fix hardcoded values
|
||||
$paidStatusID = CRM_Core_PseudoConstant::getKey(
|
||||
'CRM_Grant_DAO_Grant',
|
||||
'status_id',
|
||||
'Paid'
|
||||
);
|
||||
|
||||
$config = CRM_Core_Config::singleton();
|
||||
$mkTime = mktime(0, 0, 0, $config->fiscalYearStart['M'], $config->fiscalYearStart['d'], $fiscalYear);
|
||||
$fiscalStartDate = date('Y-m-d', $mkTime);
|
||||
$fiscalEndDate = date('Y-m-d', strtotime($startDate . '+ 1 year'));
|
||||
|
||||
$qParams = [
|
||||
1 => [$fiscalYear, 'String'],
|
||||
2 => ['2018-01-01', 'String'],
|
||||
3 => ['2018-12-31', 'String'],
|
||||
2 => [$fiscalStartDate, 'String'],
|
||||
3 => [$fiscalEndDate, 'String'],
|
||||
4 => [$paidStatusID, 'Integer'],
|
||||
];
|
||||
|
||||
@ -36,7 +47,7 @@ class CRM_Grant_BAO_GrantBudget extends CRM_Grant_DAO_GrantBudget {
|
||||
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
|
||||
AND cg.decision_date >= %2 AND cg.decision_date < %3
|
||||
{$where}
|
||||
GROUP BY cft.id
|
||||
ORDER BY cft.name";
|
||||
|
Reference in New Issue
Block a user