From 1b4aa80f248c736716a111eb99351a4bc9f2431b Mon Sep 17 00:00:00 2001 From: Civiware Solutions Date: Sun, 12 Aug 2018 01:07:33 +0530 Subject: [PATCH] changes to sql and params --- CRM/Grant/BAO/GrantBudget.php | 10 ++++++---- CRM/Grant/Page/AnnualBudgets.php | 2 +- templates/CRM/Grant/Page/AnnualBudgets.tpl | 7 ++++++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CRM/Grant/BAO/GrantBudget.php b/CRM/Grant/BAO/GrantBudget.php index 78770a5..0f424e8 100644 --- a/CRM/Grant/BAO/GrantBudget.php +++ b/CRM/Grant/BAO/GrantBudget.php @@ -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; diff --git a/CRM/Grant/Page/AnnualBudgets.php b/CRM/Grant/Page/AnnualBudgets.php index 4d14390..258a222 100644 --- a/CRM/Grant/Page/AnnualBudgets.php +++ b/CRM/Grant/Page/AnnualBudgets.php @@ -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'); } diff --git a/templates/CRM/Grant/Page/AnnualBudgets.tpl b/templates/CRM/Grant/Page/AnnualBudgets.tpl index efcf02e..3226060 100644 --- a/templates/CRM/Grant/Page/AnnualBudgets.tpl +++ b/templates/CRM/Grant/Page/AnnualBudgets.tpl @@ -8,7 +8,12 @@ {crmAPI var='result' entity='GrantBudget' action='getbudget' fiscal_year=$fiscalYear} {foreach from=$result.values item=row} - + {if $row.id} + {assign var='rowId' value=$row.id} + {else} + {capture assign=rowId}{$row.financial_type_id}_{$fiscalYear}{/capture} + {/if} + {$row.name} {$row.budget} {$row.total_amount_granted}