Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
39de6fd5 | 3 | | CiviCRM version 4.6 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
819d0d41 | 5 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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 | {* this template is used for batch transaction screen, assign/remove transactions to batch *} | |
27 | {if $statusID eq 1} | |
28 | <div class="crm-form-block crm-search-form-block"> | |
29 | <div class="crm-accordion-wrapper crm-batch_transaction_search-accordion collapsed"> | |
30 | <div class="crm-accordion-header crm-master-accordion-header"> | |
31 | {ts}Edit Search Criteria{/ts} | |
32 | </div> | |
33 | <div class="crm-accordion-body"> | |
34 | <div id="searchForm" class="crm-block crm-form-block crm-contact-custom-search-activity-search-form-block"> | |
35 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div> | |
36 | <table class="form-layout-compressed"> | |
37 | <tr> | |
38 | <td class="font-size12pt" colspan="2">{$form.sort_name.label} {$form.sort_name.html|crmAddClass:'twenty'}</td> | |
39 | </tr> | |
40 | <tr> | |
41 | {if $form.contact_tags} | |
42 | <td><label>{ts}Contributor Tag(s){/ts}</label> | |
43 | {$form.contact_tags.html} | |
6a488035 TO |
44 | </td> |
45 | {else} | |
46 | <td> </td> | |
47 | {/if} | |
48 | {if $form.group} | |
49 | <td><label>{ts}Contributor Group(s){/ts}</label> | |
50 | {$form.group.html} | |
6a488035 TO |
51 | </td> |
52 | {else} | |
53 | <td> </td> | |
54 | {/if} | |
55 | {include file="CRM/Contribute/Form/Search/Common.tpl"} | |
56 | </table> | |
57 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="botttom"}</div> | |
58 | </div> | |
59 | </div> | |
60 | </div> | |
61 | </div> | |
62 | {if $statusID eq 1} | |
63 | <div class="form-layout-compressed">{$form.trans_assign.html} {$form.submit.html}</div><br/> | |
64 | {/if} | |
65 | <div id="ltype"> | |
66 | <p></p> | |
67 | <div class="form-item"> | |
68 | {strip} | |
24e7a504 | 69 | <table id="crm-transaction-selector-assign-{$entityID}" cellpadding="0" cellspacing="0" border="0"> |
6a488035 TO |
70 | <thead> |
71 | <tr> | |
72 | <th class="crm-transaction-checkbox">{if $statusID eq 1}{$form.toggleSelect.html}{/if}</th> | |
73 | <th class="crm-contact-type"></th> | |
74 | <th class="crm-contact-name">{ts}Name{/ts}</th> | |
75 | <th class="crm-amount">{ts}Amount{/ts}</th> | |
a48d1d9c | 76 | <th class="crm-trxnID">{ts}Trxn ID{/ts}</th> |
6a488035 TO |
77 | <th class="crm-received">{ts}Received{/ts}</th> |
78 | <th class="crm-payment-method">{ts}Pay Method{/ts}</th> | |
a48d1d9c | 79 | <th class="crm-status">{ts}Status{/ts}</th> |
6a488035 TO |
80 | <th class="crm-type">{ts}Financial Type{/ts}</th> |
81 | <th class="crm-transaction-links"></th> | |
82 | </tr> | |
83 | </thead> | |
84 | </table> | |
85 | {/strip} | |
86 | </div> | |
87 | </div> | |
88 | {/if} | |
89 | ||
90 | {literal} | |
91 | <script type="text/javascript"> | |
3cc60a06 | 92 | CRM.$(function($) { |
2c68626a DJ |
93 | CRM.$('#_qf_BatchTransaction_submit-top, #_qf_BatchTransaction_submit-botttom').click(function() { |
94 | CRM.$('.crm-batch_transaction_search-accordion:not(.collapsed)').crmAccordionToggle(); | |
6a488035 TO |
95 | }); |
96 | var batchStatus = {/literal}{$statusID}{literal}; | |
97 | // build transaction listing only for open batches | |
98 | if (batchStatus == 1) { | |
99 | var paymentInstrumentID = {/literal}{if $paymentInstrumentID neq null}{$paymentInstrumentID}{else}'null'{/if}{literal}; | |
100 | if (paymentInstrumentID != 'null') { | |
101 | buildTransactionSelectorAssign( true ); | |
102 | } | |
103 | else { | |
104 | buildTransactionSelectorAssign( false ); | |
105 | } | |
106 | buildTransactionSelectorRemove(); | |
2c68626a | 107 | CRM.$('#_qf_BatchTransaction_submit-botttom, #_qf_BatchTransaction_submit-top').click( function() { |
6a488035 TO |
108 | buildTransactionSelectorAssign( true ); |
109 | return false; | |
110 | }); | |
111 | ||
2c68626a DJ |
112 | CRM.$("#trans_assign").prop('disabled',true); |
113 | CRM.$("#trans_remove").prop('disabled',true); | |
114 | CRM.$('#crm-transaction-selector-assign-{/literal}{$entityID}{literal} #toggleSelect').click( function() { | |
6a488035 TO |
115 | enableActions('x'); |
116 | }); | |
2c68626a | 117 | CRM.$('#crm-transaction-selector-remove-{/literal}{$entityID}{literal} #toggleSelects').click( function() { |
6a488035 TO |
118 | enableActions('y'); |
119 | }); | |
2c68626a | 120 | CRM.$('#Go').click( function() { |
24e7a504 | 121 | return selectAction("trans_assign","toggleSelect", "crm-transaction-selector-assign-{/literal}{$entityID}{literal} input[id^='mark_x_']"); |
6a488035 | 122 | }); |
2c68626a | 123 | CRM.$('#GoRemove').click( function() { |
24e7a504 | 124 | return selectAction("trans_remove","toggleSelects", "crm-transaction-selector-remove-{/literal}{$entityID}{literal} input[id^='mark_y_']"); |
6a488035 | 125 | }); |
2c68626a DJ |
126 | CRM.$('#Go').click( function() { |
127 | if (CRM.$("#trans_assign" ).val() != "" && CRM.$("input[id^='mark_x_']").is(':checked')) { | |
6a488035 TO |
128 | bulkAssignRemove('Assign'); |
129 | } | |
130 | return false; | |
131 | }); | |
2c68626a DJ |
132 | CRM.$('#GoRemove').click( function() { |
133 | if (CRM.$("#trans_remove" ).val() != "" && CRM.$("input[id^='mark_y_']").is(':checked')) { | |
6a488035 TO |
134 | bulkAssignRemove('Remove'); |
135 | } | |
136 | return false; | |
137 | }); | |
2c68626a | 138 | CRM.$("#crm-transaction-selector-assign-{/literal}{$entityID}{literal} input[id^='mark_x_']").click( function() { |
6a488035 TO |
139 | enableActions('x'); |
140 | }); | |
2c68626a | 141 | CRM.$("#crm-transaction-selector-remove-{/literal}{$entityID}{literal} input[id^='mark_y_']").click( function() { |
6a488035 TO |
142 | enableActions('y'); |
143 | }); | |
144 | ||
2c68626a DJ |
145 | CRM.$("#crm-transaction-selector-assign-{/literal}{$entityID}{literal} #toggleSelect").click( function() { |
146 | if (CRM.$("#crm-transaction-selector-assign-{/literal}{$entityID}{literal} #toggleSelect").is(':checked')) { | |
147 | CRM.$("#crm-transaction-selector-assign-{/literal}{$entityID}{literal} input[id^='mark_x_']").prop('checked',true); | |
6a488035 TO |
148 | } |
149 | else { | |
2c68626a | 150 | CRM.$("#crm-transaction-selector-assign-{/literal}{$entityID}{literal} input[id^='mark_x_']").prop('checked',false); |
6a488035 TO |
151 | } |
152 | }); | |
2c68626a DJ |
153 | CRM.$("#crm-transaction-selector-remove-{/literal}{$entityID}{literal} #toggleSelects").click( function() { |
154 | if (CRM.$("#crm-transaction-selector-remove-{/literal}{$entityID}{literal} #toggleSelects").is(':checked')) { | |
155 | CRM.$("#crm-transaction-selector-remove-{/literal}{$entityID}{literal} input[id^='mark_y_']").prop('checked',true); | |
6a488035 TO |
156 | } |
157 | else { | |
2c68626a | 158 | CRM.$("#crm-transaction-selector-remove-{/literal}{$entityID}{literal} input[id^='mark_y_']").prop('checked',false); |
6a488035 TO |
159 | } |
160 | }); | |
161 | } | |
162 | else { | |
163 | buildTransactionSelectorRemove(); | |
164 | } | |
165 | }); | |
166 | ||
167 | function enableActions( type ) { | |
168 | if (type == 'x') { | |
2c68626a | 169 | CRM.$("#trans_assign").prop('disabled',false); |
6a488035 TO |
170 | } |
171 | else { | |
2c68626a | 172 | CRM.$("#trans_remove").prop('disabled',false); |
6a488035 TO |
173 | } |
174 | } | |
175 | ||
176 | function buildTransactionSelectorAssign(filterSearch) { | |
177 | var columns = ''; | |
178 | var sourceUrl = {/literal}'{crmURL p="civicrm/ajax/rest" h=0 q="className=CRM_Financial_Page_AJAX&fnName=getFinancialTransactionsList&snippet=4&context=financialBatch&entityID=$entityID¬Present=1&statusID=$statusID"}'{literal}; | |
179 | if ( filterSearch ) { | |
180 | sourceUrl = sourceUrl+"&search=1"; | |
1eba7e53 | 181 | var ZeroRecordText = '<div class="status messages">{/literal}{ts escape="js"}None found.{/ts}{literal}</li></ul></div>'; |
6a488035 TO |
182 | } |
183 | ||
2c68626a | 184 | crmBatchSelector1 = CRM.$('#crm-transaction-selector-assign-{/literal}{$entityID}{literal}').dataTable({ |
6a488035 TO |
185 | "bDestroy" : true, |
186 | "bFilter" : false, | |
187 | "bAutoWidth" : false, | |
188 | "aaSorting" : [[5, 'desc']], | |
189 | "aoColumns" : [ | |
190 | {sClass:'crm-transaction-checkbox', bSortable:false}, | |
191 | {sClass:'crm-contact-type', bSortable:false}, | |
192 | {sClass:'crm-contact-name'}, | |
193 | {sClass:'crm-amount'}, | |
194 | {sClass:'crm-trxnID'}, | |
195 | {sClass:'crm-received'}, | |
196 | {sClass:'crm-payment-method'}, | |
197 | {sClass:'crm-status'}, | |
198 | {sClass:'crm-type'}, | |
199 | {sClass:'crm-transaction-links', bSortable:false} | |
200 | ], | |
201 | "bProcessing": true, | |
202 | "asStripClasses" : [ "odd-row", "even-row" ], | |
203 | "sPaginationType": "full_numbers", | |
204 | "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>', | |
205 | "bServerSide": true, | |
206 | "bJQueryUI": true, | |
207 | "sAjaxSource": sourceUrl, | |
208 | "iDisplayLength": 25, | |
209 | "oLanguage": { | |
210 | "sZeroRecords": ZeroRecordText, | |
211 | "sProcessing": {/literal}"{ts escape='js'}Processing...{/ts}"{literal}, | |
212 | "sLengthMenu": {/literal}"{ts escape='js'}Show _MENU_ entries{/ts}"{literal}, | |
213 | "sInfo": {/literal}"{ts escape='js'}Showing _START_ to _END_ of _TOTAL_ entries{/ts}"{literal}, | |
214 | "sInfoEmpty": {/literal}"{ts escape='js'}Showing 0 to 0 of 0 entries{/ts}"{literal}, | |
215 | "sInfoFiltered": {/literal}"{ts escape='js'}(filtered from _MAX_ total entries){/ts}"{literal}, | |
216 | "sSearch": {/literal}"{ts escape='js'}Search:{/ts}"{literal}, | |
217 | "oPaginate": { | |
218 | "sFirst": {/literal}"{ts escape='js'}First{/ts}"{literal}, | |
219 | "sPrevious": {/literal}"{ts escape='js'}Previous{/ts}"{literal}, | |
220 | "sNext": {/literal}"{ts escape='js'}Next{/ts}"{literal}, | |
221 | "sLast": {/literal}"{ts escape='js'}Last{/ts}"{literal} | |
222 | } | |
223 | }, | |
224 | "fnServerData": function ( sSource, aoData, fnCallback ) { | |
225 | if ( filterSearch ) { | |
2c68626a DJ |
226 | CRM.$('#searchForm :input').each(function() { |
227 | if (CRM.$(this).val()) { | |
6a488035 | 228 | aoData.push( |
2c68626a | 229 | {name:CRM.$(this).attr('id'), value: CRM.$(this).val()} |
6a488035 | 230 | ); |
2c68626a DJ |
231 | CRM.$(':radio, :checkbox').each(function() { |
232 | if (CRM.$(this).is(':checked')) { | |
233 | aoData.push( { name: CRM.$(this).attr('name'), value: CRM.$(this).val() } ); | |
6a488035 TO |
234 | } |
235 | }); | |
236 | } | |
237 | }); | |
238 | } | |
2c68626a | 239 | CRM.$.ajax({ |
6a488035 TO |
240 | "dataType": 'json', |
241 | "type": "POST", | |
242 | "url": sSource, | |
243 | "data": aoData, | |
244 | "success": fnCallback | |
245 | }); | |
246 | } | |
247 | }); | |
248 | } | |
249 | ||
250 | function buildTransactionSelectorRemove( ) { | |
251 | var columns = ''; | |
252 | var sourceUrl = {/literal}'{crmURL p="civicrm/ajax/rest" h=0 q="className=CRM_Financial_Page_AJAX&fnName=getFinancialTransactionsList&snippet=4&context=financialBatch&entityID=$entityID&statusID=$statusID"}'{literal}; | |
253 | ||
2c68626a | 254 | crmBatchSelector = CRM.$('#crm-transaction-selector-remove-{/literal}{$entityID}{literal}').dataTable({ |
6a488035 TO |
255 | "bDestroy" : true, |
256 | "bFilter" : false, | |
257 | "bAutoWidth" : false, | |
258 | "aaSorting" : [[5, 'desc']], | |
259 | "aoColumns" : [ | |
260 | {sClass:'crm-transaction-checkbox', bSortable:false}, | |
261 | {sClass:'crm-contact-type', bSortable:false}, | |
262 | {sClass:'crm-contact-name'}, | |
263 | {sClass:'crm-amount'}, | |
264 | {sClass:'crm-trxnID'}, | |
265 | {sClass:'crm-received'}, | |
266 | {sClass:'crm-payment-method'}, | |
267 | {sClass:'crm-status'}, | |
268 | {sClass:'crm-type'}, | |
269 | {sClass:'crm-transaction-links', bSortable:false} | |
270 | ], | |
271 | "bProcessing": true, | |
272 | "asStripClasses" : [ "odd-row", "even-row" ], | |
273 | "sPaginationType": "full_numbers", | |
274 | "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>', | |
275 | "bServerSide": true, | |
276 | "bJQueryUI": true, | |
277 | "sAjaxSource": sourceUrl, | |
278 | "iDisplayLength": 25, | |
279 | "oLanguage": { | |
280 | "sProcessing": {/literal}"{ts escape='js'}Processing...{/ts}"{literal}, | |
281 | "sLengthMenu": {/literal}"{ts escape='js'}Show _MENU_ entries{/ts}"{literal}, | |
282 | "sInfo": {/literal}"{ts escape='js'}Showing _START_ to _END_ of _TOTAL_ entries{/ts}"{literal}, | |
283 | "sInfoEmpty": {/literal}"{ts escape='js'}Showing 0 to 0 of 0 entries{/ts}"{literal}, | |
284 | "sInfoFiltered": {/literal}"{ts escape='js'}(filtered from _MAX_ total entries){/ts}"{literal}, | |
285 | "sSearch": {/literal}"{ts escape='js'}Search:{/ts}"{literal}, | |
286 | "oPaginate": { | |
287 | "sFirst": {/literal}"{ts escape='js'}First{/ts}"{literal}, | |
288 | "sPrevious": {/literal}"{ts escape='js'}Previous{/ts}"{literal}, | |
289 | "sNext": {/literal}"{ts escape='js'}Next{/ts}"{literal}, | |
290 | "sLast": {/literal}"{ts escape='js'}Last{/ts}"{literal} | |
291 | } | |
292 | }, | |
293 | "fnServerData": function (sSource, aoData, fnCallback) { | |
2c68626a | 294 | CRM.$.ajax({ |
6a488035 TO |
295 | "dataType": 'json', |
296 | "type": "POST", | |
297 | "url": sSource, | |
298 | "data": aoData, | |
299 | "success": fnCallback | |
300 | }); | |
301 | } | |
302 | }); | |
303 | } | |
304 | ||
305 | function selectAction( id, toggleSelectId, checkId ) { | |
2c68626a | 306 | if (CRM.$("#"+ id ).is(':disabled')) { |
6a488035 TO |
307 | return false; |
308 | } | |
2c68626a | 309 | else if (!CRM.$("#" + toggleSelectId).is(':checked') && !CRM.$("#" + checkId).is(':checked') && CRM.$("#" + id).val() != "") { |
6a488035 TO |
310 | CRM.alert ({/literal}'{ts escape="js"}Please select one or more contributions for this action.{/ts}'{literal}); |
311 | return false; | |
312 | } | |
2c68626a | 313 | else if (CRM.$("#" + id).val() == "") { |
6a488035 TO |
314 | CRM.alert ({/literal}'{ts escape="js"}Please select an action from the drop-down menu.{/ts}'{literal}); |
315 | return false; | |
316 | } | |
317 | } | |
318 | ||
319 | function bulkAssignRemove( action ) { | |
320 | var postUrl = {/literal}"{crmURL p='civicrm/ajax/rest' h=0 q="className=CRM_Financial_Page_AJAX&fnName=bulkAssignRemove&entityID=$entityID" }"{literal}; | |
321 | var fids = []; | |
322 | if (action == 'Assign') { | |
2c68626a DJ |
323 | CRM.$("input[id^='mark_x_']:checked").each( function () { |
324 | var a = CRM.$(this).attr('id'); | |
6a488035 TO |
325 | fids.push(a); |
326 | }); | |
327 | } | |
328 | if (action == 'Remove') { | |
2c68626a DJ |
329 | CRM.$("input[id^='mark_y_']:checked").each( function () { |
330 | var a = CRM.$(this).attr('id'); | |
6a488035 TO |
331 | fids.push(a); |
332 | }); | |
333 | } | |
2c68626a | 334 | CRM.$.post(postUrl, { ID: fids, action:action }, function(data) { |
6a488035 TO |
335 | //this is custom status set when record update success. |
336 | if (data.status == 'record-updated-success') { | |
337 | buildTransactionSelectorAssign( true ); | |
338 | buildTransactionSelectorRemove(); | |
339 | batchSummary({/literal}{$entityID}{literal}); | |
340 | } | |
341 | else { | |
342 | CRM.alert(data.status); | |
a48d1d9c | 343 | } |
6a488035 TO |
344 | }, 'json'); |
345 | } | |
346 | </script> | |
347 | {/literal} |