changes to sql and params
This commit is contained in:
parent
8d7149bc2f
commit
1b4aa80f24
@ -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;
|
||||
|
@ -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');
|
||||
}
|
||||
|
@ -8,7 +8,12 @@
|
||||
</thead>
|
||||
{crmAPI var='result' entity='GrantBudget' action='getbudget' fiscal_year=$fiscalYear}
|
||||
{foreach from=$result.values item=row}
|
||||
<tr id="GrantBudget-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"}">
|
||||
{if $row.id}
|
||||
{assign var='rowId' value=$row.id}
|
||||
{else}
|
||||
{capture assign=rowId}{$row.financial_type_id}_{$fiscalYear}{/capture}
|
||||
{/if}
|
||||
<tr id="GrantBudget-{$rowId}" class="crm-entity {cycle values="odd-row,even-row"}">
|
||||
<td>{$row.name}</td>
|
||||
<td class="crm-editable" data-field="budget" data-type="text">{$row.budget}</td>
|
||||
<td>{$row.total_amount_granted}</td>
|
||||
|
Loading…
Reference in New Issue
Block a user