Cleanup extra spaces around HTML id attributes
[civicrm-core.git] / templates / CRM / Financial / Page / BatchTransaction.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.3 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
8 | |
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. |
12 | |
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. |
17 | |
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 +--------------------------------------------------------------------+
25 *}
26
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">
30 <tr>
31 {foreach from=$columnHeaders item=head}
32 <th>{$head}</th>
33 {/foreach}
34 </tr>
35 </thead>
36 <tbody>
37 <tr>
38 {foreach from=$columnHeaders item=head key=rowKey}
39 <td id="row_{$rowKey}" class="even-row"></td>
40 {/foreach}
41 </tr>
42 </tbody>
43 </table>
44
45 <div class="crm-submit-buttons">{if $statusID eq 1}{$form.close_batch.html}{/if} {$form.export_batch.html}</div>
46
47 {if $statusID eq 1} {* Add / remove transactions only allowed for Open batches *}
48 <br /><div class="form-layout-compressed">{$form.trans_remove.html}&nbsp;{$form.rSubmit.html}</div><br/>
49 {/if}
50
51 <div id="ltype">
52 <p></p>
53 <div class="form-item">
54 {strip}
55 <table id="crm-transaction-selector-remove" cellpadding="0" cellspacing="0" border="0">
56 <thead>
57 <tr>
58 <th class="crm-transaction-checkbox">{if $statusID eq 1}{$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-received">{ts}Received{/ts}</th>
64 <th class="crm-payment-method">{ts}Pay Method{/ts}</th>
65 <th class="crm-status">{ts}Status{/ts}</th>
66 <th class="crm-type">{ts}Type{/ts}</th>
67 <th class="crm-transaction-links"></th>
68 </tr>
69 </thead>
70 </table>
71 {/strip}
72 </div>
73 </div>
74 <br/>
75 {include file="CRM/Financial/Form/BatchTransaction.tpl"}
76
77 {literal}
78 <script type="text/javascript">
79 cj( function() {
80 var entityID = {/literal}{$entityID}{literal};
81 batchSummary(entityID);
82 cj('#close_batch').click( function() {
83 assignRemove(entityID, 'close');
84 return false;
85 });
86 cj('#export_batch').click( function() {
87 assignRemove(entityID, 'export');
88 return false;
89 });
90 });
91 function assignRemove(recordID, op) {
92 var recordBAO = 'CRM_Batch_BAO_Batch';
93 var entityID = {/literal}"{$entityID}"{literal};
94 if (op == 'close' || op == 'export') {
95 var mismatch = checkMismatch();
96 }
97 else {
98 cj('#mark_x_' + recordID).closest('tr').block({message: {/literal}'{ts escape="js"}Updating{/ts}'{literal}});
99 }
100 if (op == 'close' || (op == 'export' && mismatch.length)) {
101 cj("#enableDisableStatusMsg").dialog({
102 title: {/literal}'{ts escape="js"}Close Batch{/ts}'{literal},
103 modal: true,
104 bgiframe: true,
105 overlay: {
106 opacity: 0.5,
107 background: "black"
108 },
109 open:function() {
110 if (op == 'close') {
111 var msg = {/literal}'{ts escape="js"}Are you sure you want to close this batch?{/ts}'{literal};
112 }
113 else {
114 var msg = {/literal}'{ts escape="js"}Are you sure you want to close and export this batch?{/ts}'{literal};
115 }
116 cj('#enableDisableStatusMsg').show().html(msg + mismatch);
117 },
118 buttons: {
119 {/literal}"{ts escape='js'}Cancel{/ts}"{literal}: function() {
120 cj(this).dialog("close");
121 },
122 {/literal}"{ts escape='js'}OK{/ts}"{literal}: function() {
123 cj(this).dialog("close");
124 saveRecord(recordID, op, recordBAO, entityID);
125 }
126 }
127 });
128 }
129 else {
130 saveRecord(recordID, op, recordBAO, entityID);
131 }
132 }
133
134 function noServerResponse() {
135 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');
136 }
137
138 function saveRecord(recordID, op, recordBAO, entityID) {
139 if (op == 'export') {
140 window.location.href = CRM.url('civicrm/financial/batch/export', {reset: 1, id: recordID, status: 1});
141 return;
142 }
143 var postUrl = {/literal}"{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Financial_Page_AJAX&fnName=assignRemove'}"{literal};
144 //post request and get response
145 cj.post( postUrl, { records: [recordID], recordBAO: recordBAO, op:op, entityID:entityID, key: {/literal}"{crmKey name='civicrm/ajax/ar'}"{literal} }, function( html ){
146 //this is custom status set when record update success.
147 if (html.status == 'record-updated-success') {
148 if (op == 'close') {
149 window.location.href = CRM.url('civicrm/financial/financialbatches', 'reset=1&batchStatus=2');
150 }
151 else {
152 buildTransactionSelectorAssign( true );
153 buildTransactionSelectorRemove();
154 batchSummary(entityID);
155 }
156 }
157 else {
158 CRM.alert(html.status);
159 }
160 },
161 'json').error(noServerResponse);
162 }
163
164 function batchSummary(entityID) {
165 var postUrl = {/literal}"{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Financial_Page_AJAX&fnName=getBatchSummary'}"{literal};
166 //post request and get response
167 cj.post( postUrl, {batchID: entityID}, function(html) {
168 cj.each(html, function(i, val) {
169 cj("#row_" + i).html(val);
170 });
171 },
172 'json');
173 }
174
175 function checkMismatch() {
176 var txt = '';
177 var enteredItem = cj("#row_item_count").text();
178 var assignedItem = cj("#row_assigned_item_count").text();
179 var enteredTotal = cj("#row_total").text();
180 var assignedTotal = cj("#row_assigned_total").text();
181 if (enteredItem != "" && enteredItem != assignedItem) {
182 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 }
184 if (enteredTotal != "" && enteredTotal != assignedTotal) {
185 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}';
186 }
187 if (txt.length) {
188 txt += {/literal}'<div class="messages status">{ts escape="js"}Click OK to override and update expected values.{/ts}</div>'{literal}
189 }
190 return txt;
191 }
192 </script>
193 {/literal}