removed hardcoded values
This commit is contained in:
parent
b5c998846e
commit
04a78b6e3b
@ -3,7 +3,9 @@
|
|||||||
class CRM_Grant_BAO_GrantBudget extends CRM_Grant_DAO_GrantBudget {
|
class CRM_Grant_BAO_GrantBudget extends CRM_Grant_DAO_GrantBudget {
|
||||||
|
|
||||||
public static function getFiscalyear() {
|
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) {
|
public static function getGrantBudget($params) {
|
||||||
@ -12,12 +14,21 @@ class CRM_Grant_BAO_GrantBudget extends CRM_Grant_DAO_GrantBudget {
|
|||||||
$fiscalYear = date('Y');
|
$fiscalYear = date('Y');
|
||||||
}
|
}
|
||||||
$grantBudget = [];
|
$grantBudget = [];
|
||||||
$paidStatusID = 4;
|
$paidStatusID = CRM_Core_PseudoConstant::getKey(
|
||||||
// TODO fix hardcoded values
|
'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 = [
|
$qParams = [
|
||||||
1 => [$fiscalYear, 'String'],
|
1 => [$fiscalYear, 'String'],
|
||||||
2 => ['2018-01-01', 'String'],
|
2 => [$fiscalStartDate, 'String'],
|
||||||
3 => ['2018-12-31', 'String'],
|
3 => [$fiscalEndDate, 'String'],
|
||||||
4 => [$paidStatusID, 'Integer'],
|
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
|
ON cgb.financial_type_id = cft.id AND cgb.fiscal_year = %1
|
||||||
LEFT JOIN civicrm_grant cg
|
LEFT JOIN civicrm_grant cg
|
||||||
ON cg.financial_type_id = cft.id AND cg.status_id IN (%4)
|
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}
|
{$where}
|
||||||
GROUP BY cft.id
|
GROUP BY cft.id
|
||||||
ORDER BY cft.name";
|
ORDER BY cft.name";
|
||||||
|
@ -26,7 +26,7 @@ class CRM_Grant_Page_AnnualBudgets extends CRM_Core_Page_Basic {
|
|||||||
* Browse all Grant Budget.
|
* Browse all Grant Budget.
|
||||||
*/
|
*/
|
||||||
public function browse() {
|
public function browse() {
|
||||||
$fiscalYear = NULL;
|
$fiscalYear = CRM_Utils_Request::retrieve('fiscalYears', 'Positive');
|
||||||
if (empty($fiscalYear)) {
|
if (empty($fiscalYear)) {
|
||||||
$fiscalYear = date('Y');
|
$fiscalYear = date('Y');
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ use CRM_Annualgrantbudgets_ExtensionUtil as E;
|
|||||||
define('GRANT_SCHOLARSHIP_CUSTOM_GROUP', 'grant_scholarship');
|
define('GRANT_SCHOLARSHIP_CUSTOM_GROUP', 'grant_scholarship');
|
||||||
define('GRANT_SCHOLARSHIP_CUSTOM_FIELD', 'is_grant_scholarship');
|
define('GRANT_SCHOLARSHIP_CUSTOM_FIELD', 'is_grant_scholarship');
|
||||||
define('GRANT_SCHOLARSHIP_CUSTOM_TABLE_NAME', 'civicrm_value_grant_scholarship');
|
define('GRANT_SCHOLARSHIP_CUSTOM_TABLE_NAME', 'civicrm_value_grant_scholarship');
|
||||||
|
define('GRANT_SCHOLARSHIP_YEAR_DIFF', 10);
|
||||||
/**
|
/**
|
||||||
* Implements hook_civicrm_config().
|
* Implements hook_civicrm_config().
|
||||||
*
|
*
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<th>{ts}Amount Awarded{/ts}</th>
|
<th>{ts}Amount Awarded{/ts}</th>
|
||||||
<th>{ts}Amound Remaining{/ts}</th>
|
<th>{ts}Amound Remaining{/ts}</th>
|
||||||
</thead>
|
</thead>
|
||||||
{crmAPI var='result' entity='GrantBudget' action='getbudget' fiscal_year=2018}
|
{crmAPI var='result' entity='GrantBudget' action='getbudget' fiscal_year=$fiscalYear}
|
||||||
{foreach from=$result.values item=row}
|
{foreach from=$result.values item=row}
|
||||||
<tr id="GrantBudget-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"}">
|
<tr id="GrantBudget-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"}">
|
||||||
<td>{$row.name}</td>
|
<td>{$row.name}</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user