*/
protected $_batchStatusId;
+ /**
+ * Batch status name.
+ * @string
+ */
+ protected $_batchStatus;
+
public function preProcess() {
// This reuses some styles from search forms
CRM_Core_Resources::singleton()->addStyleFile('civicrm', 'css/searchForm.css', 1, 'html-header');
$this->assign('entityID', self::$_entityID);
if (isset(self::$_entityID)) {
$this->_batchStatusId = CRM_Core_DAO::getFieldValue('CRM_Batch_BAO_Batch', self::$_entityID, 'status_id');
+ $batchStatuses = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', array('labelColumn' => 'name', 'condition' => " v.value={$this->_batchStatusId}"));
+ $this->_batchStatus = $batchStatuses[$this->_batchStatusId];
$this->assign('statusID', $this->_batchStatusId);
+ $this->assign('batchStatus', $this->_batchStatus);
+ $this->assign('validStatus', FALSE);
+ if (in_array($this->_batchStatus, array('Open', 'Reopened'))) {
+ $this->assign('validStatus', TRUE);
+ }
$batchTitle = CRM_Core_DAO::getFieldValue('CRM_Batch_BAO_Batch', self::$_entityID, 'title');
CRM_Utils_System::setTitle(ts('Accounting Batch - %1', array(1 => $batchTitle)));
* Build the form object.
*/
public function buildQuickForm() {
- if ($this->_batchStatusId == 2) {
+ if ($this->_batchStatus == 'Closed') {
$this->add('submit', 'export_batch', ts('Export Batch'));
}
- // do not build rest of form unless it is open batch
- if ($this->_batchStatusId != 1) {
+ // do not build rest of form unless it is open/reopened batch
+ if (!in_array($this->_batchStatus, array('Open', 'Reopened'))) {
return;
}
}
public function setDefaultValues() {
- // do not setdefault unless it is open batch
- if ($this->_batchStatusId != 1) {
+ // do not setdefault unless it is open/reopened batch
+ if (!in_array($this->_batchStatus, array('Open', 'Reopened'))) {
return;
}
if (isset(self::$_entityID)) {
+--------------------------------------------------------------------+
*}
{* this template is used for batch transaction screen, assign/remove transactions to batch *}
-{if $statusID eq 1}
+{if in_array($batchStatus, array('Open', 'Reopened'))}
<div class="crm-form-block crm-search-form-block">
<div class="crm-accordion-wrapper crm-batch_transaction_search-accordion collapsed">
<div class="crm-accordion-header crm-master-accordion-header">
{/if}
{include file="CRM/Contribute/Form/Search/Common.tpl"}
</table>
- <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="botttom"}</div>
+ <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
</div>
</div>
</div>
</div>
-{if $statusID eq 1}
+{if in_array($batchStatus, array('Open', 'Reopened'))}
<div class="form-layout-compressed">{$form.trans_assign.html} {$form.submit.html}</div><br/>
{/if}
<div id="ltype">
<table id="crm-transaction-selector-assign-{$entityID}" cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
- <th class="crm-transaction-checkbox">{if $statusID eq 1}{$form.toggleSelect.html}{/if}</th>
+ <th class="crm-transaction-checkbox">{if in_array($batchStatus, array('Open', 'Reopened'))}{$form.toggleSelect.html}{/if}</th>
<th class="crm-contact-type"></th>
<th class="crm-contact-name">{ts}Name{/ts}</th>
<th class="crm-amount">{ts}Amount{/ts}</th>
CRM.$('.crm-batch_transaction_search-accordion:not(.collapsed)').crmAccordionToggle();
});
var batchStatus = {/literal}{$statusID}{literal};
- // build transaction listing only for open batches
- if (batchStatus == 1) {
+ {/literal}{if $validStatus}{literal}
+ // build transaction listing only for open/reopened batches
var paymentInstrumentID = {/literal}{if $paymentInstrumentID neq null}{$paymentInstrumentID}{else}'null'{/if}{literal};
if (paymentInstrumentID != 'null') {
buildTransactionSelectorAssign( true );
CRM.$("#crm-transaction-selector-remove-{/literal}{$entityID}{literal} input[id^='mark_y_']").prop('checked',false);
}
});
- }
- else {
+ {/literal}{else}{literal}
buildTransactionSelectorRemove();
- }
+ {/literal}{/if}{literal}
});
function enableActions( type ) {
</tbody>
</table>
-<div class="crm-submit-buttons">{if $statusID eq 1}{$form.close_batch.html}{/if} {$form.export_batch.html}</div>
+<div class="crm-submit-buttons">{if in_array($batchStatus, array('Open', 'Reopened'))}{$form.close_batch.html}{/if} {$form.export_batch.html}</div>
-{if $statusID eq 1} {* Add / remove transactions only allowed for Open batches *}
+{if in_array($batchStatus, array('Open', 'Reopened'))} {* Add / remove transactions only allowed for Open/Reopened batches *}
<br /><div class="form-layout-compressed">{$form.trans_remove.html} {$form.rSubmit.html}</div><br/>
{/if}
<table id="crm-transaction-selector-remove-{$entityID}" cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
- <th class="crm-transaction-checkbox">{if $statusID eq 1}{$form.toggleSelects.html}{/if}</th>
+ <th class="crm-transaction-checkbox">{if in_array($batchStatus, array('Open', 'Reopened'))}{$form.toggleSelects.html}{/if}</th>
<th class="crm-contact-type"></th>
<th class="crm-contact-name">{ts}Name{/ts}</th>
<th class="crm-amount">{ts}Amount{/ts}</th>