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