implement the is_reserved lock

This commit is contained in:
Jon Goldberg 2019-08-19 18:59:03 -04:00
parent 4cf1c728e1
commit 87888691dc
No known key found for this signature in database
GPG Key ID: C2D2247364F9DB13
2 changed files with 14 additions and 2 deletions

View File

@ -57,7 +57,7 @@ class CRM_AnnualGrantBudgets_BAO_GrantBudget extends CRM_AnnualGrantBudgets_DAO_
$grantBudgetTableName = CRM_AnnualGrantBudgets_DAO_GrantBudget::getTableName();
$sql = "SELECT cgb.id, cft.name, IFNULL(cgb.budget, 0) AS budget,
SUM(CASE WHEN cg.id IS NULL THEN 0 ELSE IFNULL(trxn.total_amount, 0) END) as total_amount_granted,
cft.id AS financial_type_id
cft.id AS financial_type_id, cgb.note, cgb.is_reserved
FROM civicrm_financial_type cft
INNER JOIN " . GRANT_SCHOLARSHIP_CUSTOM_TABLE_NAME . " gs
ON gs.entity_id = cft.id
@ -85,6 +85,8 @@ class CRM_AnnualGrantBudgets_BAO_GrantBudget extends CRM_AnnualGrantBudgets_DAO_
'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,
'note' => $result->note,
'is_reserved' => $result->is_reserved,
];
if ($returnTotals) {
$totals['budget'] += $result->budget;

View File

@ -1,4 +1,9 @@
<div class="crm-content-block crm-block">
{* Check to see if this user can lock/unlock items *}
{if call_user_func(array('CRM_Core_Permission','check'), 'Administer CiviCRM')}
{assign var='canLock' value='crm-editable'}
{/if}
<label>{ts}Fiscal Year: {/ts}</label>
<select name="fiscal_year" type="text" id="fiscal_year" class="crm-form-select required crm-select2 six">
{$fiscal_year_options}
@ -24,14 +29,19 @@
{foreach from=$result.values item=row}
{if $row.id}
{assign var='rowId' value=$row.id}
{if !$row.is_reserved}
{assign var='canEdit' value='crm-editable'}
{/if}
{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 class="{$canEdit}" data-field="budget" data-type="text">{$row.budget}</td>
<td>{$row.total_amount_granted}</td>
<td>{$row.balance_amount}</td>
<td class="{$canLock}" data-field="is_reserved" data-type="boolean">{if $row.is_reserved eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
<td class="{$canEdit}" data-field="note" data-type="text">{$row.note}</td>
</tr>
{/foreach}
<tr id="GrantBudget-totals" class="crm-entity">