2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2019 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
27 <div id="enableDisableStatusMsg" class="crm-container" style="display:none;"></div>
28 <table id="batch-summary" cellpadding="0" cellspacing="0" border="0" class="report crm-batch_summary">
29 <thead class="sticky">
31 {foreach from=$columnHeaders item=head}
38 {foreach from=$columnHeaders item=head key=rowKey}
39 <td id="row_{$rowKey}" class="even-row"></td>
45 <div class="crm-submit-buttons">{if in_array($batchStatus, array('Open', 'Reopened'))}{$form.close_batch.html}{/if} {$form.export_batch.html}</div>
47 {if in_array($batchStatus, array('Open', 'Reopened'))} {* Add / remove transactions only allowed for Open/Reopened batches *}
48 <br /><div class="form-layout-compressed">{$form.trans_remove.html} {$form.rSubmit.html}</div><br/>
53 <div class="form-item">
55 <table id="crm-transaction-selector-remove-{$entityID}" cellpadding="0" cellspacing="0" border="0">
58 <th class="crm-transaction-checkbox">{if in_array($batchStatus, array('Open', 'Reopened'))}{$form.toggleSelects.html}{/if}</th>
59 <th class="crm-contact-type"></th>
60 <th class="crm-contact-name">{ts}Name{/ts}</th>
61 <th class="crm-amount">{ts}Amount{/ts}</th>
62 <th class="crm-trxnID">{ts}Trxn ID{/ts}</th>
63 <th class="crm-trxn_date">{ts}Payment/Transaction Date{/ts}</th>
64 <th class="crm-received">{ts}Contribution Date{/ts}</th>
65 <th class="crm-payment-method">{ts}Pay Method{/ts}</th>
66 <th class="crm-status">{ts}Status{/ts}</th>
67 <th class="crm-type">{ts}Type{/ts}</th>
68 <th class="crm-transaction-links"></th>
76 {include file="CRM/Financial/Form/BatchTransaction.tpl"}
79 <script type="text/javascript">
81 var entityID = {/literal}{$entityID}{literal};
82 batchSummary(entityID);
83 CRM.$('#close_batch').click( function() {
84 assignRemove(entityID, 'close');
87 CRM.$('#export_batch').click( function() {
88 assignRemove(entityID, 'export');
92 function assignRemove(recordID, op) {
93 var recordBAO = 'CRM_Batch_BAO_Batch';
94 if (op == 'assign' || op == 'remove') {
95 recordBAO = 'CRM_Batch_BAO_EntityBatch';
97 var entityID = {/literal}"{$entityID}"{literal};
98 if (op == 'close' || op == 'export') {
99 var mismatch = checkMismatch();
102 CRM.$('#mark_x_' + recordID).closest('tr').block({message: {/literal}'{ts escape="js"}Updating{/ts}'{literal}});
104 if (op == 'close' || (op == 'export' && mismatch.length)) {
105 CRM.$("#enableDisableStatusMsg").dialog({
106 title: {/literal}'{ts escape="js"}Close Batch{/ts}'{literal},
110 var msg = {/literal}'{ts escape="js"}Are you sure you want to close this batch?{/ts}'{literal};
113 var msg = {/literal}'{ts escape="js"}Are you sure you want to close and export this batch?{/ts}'{literal};
115 CRM.$('#enableDisableStatusMsg').show().html(msg + mismatch);
118 {/literal}"{ts escape='js'}Cancel{/ts}"{literal}: function() {
119 CRM.$(this).dialog("close");
121 {/literal}"{ts escape='js'}OK{/ts}"{literal}: function() {
122 CRM.$(this).dialog("close");
123 saveRecord(recordID, op, recordBAO, entityID);
129 saveRecord(recordID, op, recordBAO, entityID);
133 function noServerResponse() {
134 CRM.alert({/literal}'{ts escape="js"}No response from the server. Check your internet connection and try reloading the page.{/ts}', '{ts escape="js"}Network Error{/ts}'{literal}, 'error');
137 function saveRecord(recordID, op, recordBAO, entityID) {
138 if (op == 'export') {
139 window.location.href = CRM.url('civicrm/financial/batch/export', {reset: 1, id: recordID, status: 1});
142 var postUrl = {/literal}"{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Financial_Page_AJAX&fnName=assignRemove'}"{literal};
143 //post request and get response
144 CRM.$.post( postUrl, { records: [recordID], recordBAO: recordBAO, op:op, entityID:entityID, key: {/literal}"{crmKey name='civicrm/ajax/ar'}"{literal} }, function( html ){
145 //this is custom status set when record update success.
146 if (html.status == 'record-updated-success') {
148 window.location.href = CRM.url('civicrm/financial/financialbatches', 'reset=1&batchStatus=2');
151 buildTransactionSelectorAssign( true );
152 buildTransactionSelectorRemove();
153 batchSummary(entityID);
157 CRM.alert(html.status);
160 'json').error(noServerResponse);
163 function batchSummary(entityID) {
164 var postUrl = {/literal}"{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Financial_Page_AJAX&fnName=getBatchSummary'}"{literal};
165 //post request and get response
166 CRM.$.post( postUrl, {batchID: entityID}, function(html) {
167 CRM.$.each(html, function(i, val) {
168 CRM.$("#row_" + i).html(val);
174 function checkMismatch() {
176 var enteredItem = CRM.$("#row_item_count").text();
177 var assignedItem = CRM.$("#row_assigned_item_count").text();
178 var enteredTotal = CRM.$("#row_total").text();
179 var assignedTotal = CRM.$("#row_assigned_total").text();
180 if (enteredItem != "" && enteredItem != assignedItem) {
181 txt = '{/literal}<div class="messages crm-error"><strong>Item Count mismatch:</strong><br/>{ts escape="js"}Expected{/ts}:' + enteredItem +'<br/>{ts escape="js"}Current Total{/ts}:' + assignedItem + '</div>{literal}';
183 if (enteredTotal != "" && enteredTotal != assignedTotal) {
184 txt += '{/literal}<div class="messages crm-error"><strong>Total Amount mismatch</strong><br/>{ts escape="js"}Expected{/ts}:' + enteredTotal +'<br/>{ts escape="js"}Current Total{/ts}:' + assignedTotal + '</div>{literal}';
187 txt += {/literal}'<div class="messages status">{ts escape="js"}Click OK to override and update expected values.{/ts}</div>'{literal}