forked from CiviWare/org.agbu.annualgrantbudgets
		
	implement the is_reserved lock
This commit is contained in:
		@@ -57,7 +57,7 @@ class CRM_AnnualGrantBudgets_BAO_GrantBudget extends CRM_AnnualGrantBudgets_DAO_
 | 
				
			|||||||
    $grantBudgetTableName = CRM_AnnualGrantBudgets_DAO_GrantBudget::getTableName();
 | 
					    $grantBudgetTableName = CRM_AnnualGrantBudgets_DAO_GrantBudget::getTableName();
 | 
				
			||||||
    $sql = "SELECT cgb.id, cft.name, IFNULL(cgb.budget, 0) AS budget,
 | 
					    $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,
 | 
					        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
 | 
					      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
 | 
					          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),
 | 
					        '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,
 | 
					        'financial_type_id' => $result->financial_type_id,
 | 
				
			||||||
 | 
					        'note' => $result->note,
 | 
				
			||||||
 | 
					        'is_reserved' => $result->is_reserved,
 | 
				
			||||||
      ];
 | 
					      ];
 | 
				
			||||||
      if ($returnTotals) {
 | 
					      if ($returnTotals) {
 | 
				
			||||||
        $totals['budget'] += $result->budget;
 | 
					        $totals['budget'] += $result->budget;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,9 @@
 | 
				
			|||||||
<div class="crm-content-block crm-block">
 | 
					<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>
 | 
					  <label>{ts}Fiscal Year: {/ts}</label>
 | 
				
			||||||
  <select name="fiscal_year" type="text" id="fiscal_year" class="crm-form-select required crm-select2 six">
 | 
					  <select name="fiscal_year" type="text" id="fiscal_year" class="crm-form-select required crm-select2 six">
 | 
				
			||||||
    {$fiscal_year_options}
 | 
					    {$fiscal_year_options}
 | 
				
			||||||
@@ -24,14 +29,19 @@
 | 
				
			|||||||
    {foreach from=$result.values item=row}
 | 
					    {foreach from=$result.values item=row}
 | 
				
			||||||
      {if $row.id}
 | 
					      {if $row.id}
 | 
				
			||||||
        {assign var='rowId' value=$row.id}
 | 
					        {assign var='rowId' value=$row.id}
 | 
				
			||||||
 | 
					        {if !$row.is_reserved}
 | 
				
			||||||
 | 
					          {assign var='canEdit' value='crm-editable'}
 | 
				
			||||||
 | 
					        {/if}
 | 
				
			||||||
      {else}
 | 
					      {else}
 | 
				
			||||||
        {capture assign=rowId}{$row.financial_type_id}_{$fiscalYear}{/capture}
 | 
					        {capture assign=rowId}{$row.financial_type_id}_{$fiscalYear}{/capture}
 | 
				
			||||||
      {/if}
 | 
					      {/if}
 | 
				
			||||||
      <tr id="GrantBudget-{$rowId}" class="crm-entity {cycle values="odd-row,even-row"}">
 | 
					      <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="{$canEdit}" data-field="budget" data-type="text">{$row.budget}</td>
 | 
				
			||||||
        <td>{$row.total_amount_granted}</td>
 | 
					        <td>{$row.total_amount_granted}</td>
 | 
				
			||||||
        <td>{$row.balance_amount}</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>
 | 
					      </tr>
 | 
				
			||||||
    {/foreach}
 | 
					    {/foreach}
 | 
				
			||||||
    <tr id="GrantBudget-totals" class="crm-entity">
 | 
					    <tr id="GrantBudget-totals" class="crm-entity">
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user