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();
|
$config = CRM_Core_Config::singleton();
|
||||||
$mkTime = mktime(0, 0, 0, $config->fiscalYearStart['M'], $config->fiscalYearStart['d'], $fiscalYear);
|
$mkTime = mktime(0, 0, 0, $config->fiscalYearStart['M'], $config->fiscalYearStart['d'], $fiscalYear);
|
||||||
$fiscalStartDate = date('Y-m-d', $mkTime);
|
$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 = [
|
$qParams = [
|
||||||
1 => [$fiscalYear, 'String'],
|
1 => [$fiscalYear, 'String'],
|
||||||
@ -38,8 +38,9 @@ class CRM_Grant_BAO_GrantBudget extends CRM_Grant_DAO_GrantBudget {
|
|||||||
$qParams[5] = [$params['financial_type_id'], 'Integer'];
|
$qParams[5] = [$params['financial_type_id'], 'Integer'];
|
||||||
}
|
}
|
||||||
$grantBudgetTableName = CRM_Grant_DAO_GrantBudget::getTableName();
|
$grantBudgetTableName = CRM_Grant_DAO_GrantBudget::getTableName();
|
||||||
$sql = "SELECT gs.id, cft.name, IFNULL(cgb.budget, 0) AS budget,
|
$sql = "SELECT cgb.id, cft.name, IFNULL(cgb.budget, 0) AS budget,
|
||||||
SUM(IFNULL(cg.amount_granted, 0)) as total_amount_granted
|
SUM(IFNULL(cg.amount_granted, 0)) as total_amount_granted,
|
||||||
|
cft.id AS financial_type_id
|
||||||
FROM civicrm_financial_type cft
|
FROM civicrm_financial_type cft
|
||||||
INNER JOIN " . GRANT_SCHOLARSHIP_CUSTOM_TABLE_NAME . " gs
|
INNER JOIN " . GRANT_SCHOLARSHIP_CUSTOM_TABLE_NAME . " gs
|
||||||
ON gs.entity_id = cft.id AND gs." . GRANT_SCHOLARSHIP_CUSTOM_FIELD . " = 1
|
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);
|
$result = CRM_Core_DAO::executeQuery($sql, $qParams);
|
||||||
|
|
||||||
while ($result->fetch()) {
|
while ($result->fetch()) {
|
||||||
$grantBudget[$result->id] = [
|
$grantBudget[] = [
|
||||||
'id' => $result->id,
|
'id' => $result->id,
|
||||||
'name' => $result->name,
|
'name' => $result->name,
|
||||||
'budget' => CRM_Utils_Money::format($result->budget),
|
'budget' => CRM_Utils_Money::format($result->budget),
|
||||||
'total_amount_granted' => CRM_Utils_Money::format($result->total_amount_granted),
|
'total_amount_granted' => CRM_Utils_Money::format($result->total_amount_granted),
|
||||||
'balance_amount' => CRM_Utils_Money::format(($result->budget - $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;
|
return $grantBudget;
|
||||||
|
@ -35,7 +35,7 @@ class CRM_Grant_Page_AnnualBudgets extends CRM_Core_Page_Basic {
|
|||||||
)) {
|
)) {
|
||||||
return CRM_Utils_System::permissionDenied();
|
return CRM_Utils_System::permissionDenied();
|
||||||
}
|
}
|
||||||
$fiscalYear = CRM_Utils_Request::retrieve('fiscalYears', 'Positive');
|
$fiscalYear = CRM_Utils_Request::retrieve('fiscalYear', 'Positive');
|
||||||
if (empty($fiscalYear)) {
|
if (empty($fiscalYear)) {
|
||||||
$fiscalYear = date('Y');
|
$fiscalYear = date('Y');
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,12 @@
|
|||||||
</thead>
|
</thead>
|
||||||
{crmAPI var='result' entity='GrantBudget' action='getbudget' fiscal_year=$fiscalYear}
|
{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"}">
|
{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>{$row.name}</td>
|
||||||
<td class="crm-editable" data-field="budget" data-type="text">{$row.budget}</td>
|
<td class="crm-editable" data-field="budget" data-type="text">{$row.budget}</td>
|
||||||
<td>{$row.total_amount_granted}</td>
|
<td>{$row.total_amount_granted}</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user