changes to sql and params

This commit is contained in:
2018-08-12 01:07:33 +05:30
parent 8d7149bc2f
commit 1b4aa80f24
3 changed files with 13 additions and 6 deletions

View File

@ -23,7 +23,7 @@ class CRM_Grant_BAO_GrantBudget extends CRM_Grant_DAO_GrantBudget {
$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'));
$fiscalEndDate = date('Y-m-d', strtotime($fiscalStartDate . '+ 1 year'));
$qParams = [
1 => [$fiscalYear, 'String'],
@ -38,8 +38,9 @@ class CRM_Grant_BAO_GrantBudget extends CRM_Grant_DAO_GrantBudget {
$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
$sql = "SELECT cgb.id, cft.name, IFNULL(cgb.budget, 0) AS budget,
SUM(IFNULL(cg.amount_granted, 0)) as total_amount_granted,
cft.id AS financial_type_id
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
@ -54,12 +55,13 @@ class CRM_Grant_BAO_GrantBudget extends CRM_Grant_DAO_GrantBudget {
$result = CRM_Core_DAO::executeQuery($sql, $qParams);
while ($result->fetch()) {
$grantBudget[$result->id] = [
$grantBudget[] = [
'id' => $result->id,
'name' => $result->name,
'budget' => CRM_Utils_Money::format($result->budget),
'total_amount_granted' => CRM_Utils_Money::format($result->total_amount_granted),
'balance_amount' => CRM_Utils_Money::format(($result->budget - $result->total_amount_granted)),
'financial_type_id' => $result->financial_type_id,
];
}
return $grantBudget;

View File

@ -35,7 +35,7 @@ class CRM_Grant_Page_AnnualBudgets extends CRM_Core_Page_Basic {
)) {
return CRM_Utils_System::permissionDenied();
}
$fiscalYear = CRM_Utils_Request::retrieve('fiscalYears', 'Positive');
$fiscalYear = CRM_Utils_Request::retrieve('fiscalYear', 'Positive');
if (empty($fiscalYear)) {
$fiscalYear = date('Y');
}