2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2018 |
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 +--------------------------------------------------------------------+
26 {* this template is used for batch transaction screen, assign/remove transactions to batch *}
27 {if in_array($batchStatus, array('Open', 'Reopened'))}
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}
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">
38 <td class="font-size12pt" colspan="2">
39 {$form.sort_name.label}<br>
40 {$form.sort_name.html|crmAddClass:'twenty'}
44 {if $form.contact_tags}
46 <label>{ts}Contributor Tag(s){/ts}</label><br>
47 {$form.contact_tags.html}
53 <td><label>{ts}Contributor Group(s){/ts}</label><br>
60 {include file="CRM/Contribute/Form/Search/Common.tpl"}
62 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
67 {if in_array($batchStatus, array('Open', 'Reopened'))}
68 <div class="form-layout-compressed">{$form.trans_assign.html} {$form.submit.html}</div><br/>
72 <div class="form-item">
74 <table id="crm-transaction-selector-assign-{$entityID}" cellpadding="0" cellspacing="0" border="0">
77 <th class="crm-transaction-checkbox">{if in_array($batchStatus, array('Open', 'Reopened'))}{$form.toggleSelect.html}{/if}</th>
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>
81 <th class="crm-trxnID">{ts}Trxn ID{/ts}</th>
82 <th class="crm-trxn_date">{ts}Payment/Transaction Date{/ts}</th>
83 <th class="crm-received">{ts}Contribution Date{/ts}</th>
84 <th class="crm-payment-method">{ts}Pay Method{/ts}</th>
85 <th class="crm-status">{ts}Status{/ts}</th>
86 <th class="crm-type">{ts}Financial Type{/ts}</th>
87 <th class="crm-transaction-links"></th>
97 <script type="text/javascript">
99 CRM.$('#_qf_BatchTransaction_submit-top, #_qf_BatchTransaction_submit-bottom').click(function() {
100 CRM.$('.crm-batch_transaction_search-accordion:not(.collapsed)').crmAccordionToggle();
102 var batchStatus = {/literal}{$statusID}{literal};
103 {/literal}{if $validStatus}{literal}
104 // build transaction listing only for open/reopened batches
105 var paymentInstrumentID = {/literal}{if $paymentInstrumentID neq null}{$paymentInstrumentID}{else}'null'{/if}{literal};
106 if (paymentInstrumentID != 'null') {
107 buildTransactionSelectorAssign( true );
110 buildTransactionSelectorAssign( false );
112 buildTransactionSelectorRemove();
113 CRM.$('#_qf_BatchTransaction_submit-bottom, #_qf_BatchTransaction_submit-top').click( function() {
114 buildTransactionSelectorAssign( true );
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() {
123 CRM.$('#crm-transaction-selector-remove-{/literal}{$entityID}{literal} #toggleSelects').click( function() {
126 CRM.$('#Go').click( function() {
127 return selectAction("trans_assign","toggleSelect", "crm-transaction-selector-assign-{/literal}{$entityID}{literal} input[id^='mark_x_']");
129 CRM.$('#GoRemove').click( function() {
130 return selectAction("trans_remove","toggleSelects", "crm-transaction-selector-remove-{/literal}{$entityID}{literal} input[id^='mark_y_']");
132 CRM.$('#Go').click( function() {
133 if (CRM.$("#trans_assign" ).val() != "" && CRM.$("input[id^='mark_x_']").is(':checked')) {
134 bulkAssignRemove('Assign');
138 CRM.$('#GoRemove').click( function() {
139 if (CRM.$("#trans_remove" ).val() != "" && CRM.$("input[id^='mark_y_']").is(':checked')) {
140 bulkAssignRemove('Remove');
144 CRM.$("#crm-transaction-selector-assign-{/literal}{$entityID}{literal} input[id^='mark_x_']").click( function() {
147 CRM.$("#crm-transaction-selector-remove-{/literal}{$entityID}{literal} input[id^='mark_y_']").click( function() {
151 CRM.$("#crm-transaction-selector-assign-{/literal}{$entityID}{literal} #toggleSelect").click( function() {
152 toggleFinancialSelections('#toggleSelect', 'assign');
154 CRM.$("#crm-transaction-selector-remove-{/literal}{$entityID}{literal} #toggleSelects").click( function() {
155 toggleFinancialSelections('#toggleSelects', 'remove');
157 {/literal}{else}{literal}
158 buildTransactionSelectorRemove();
159 {/literal}{/if}{literal}
162 function enableActions( type ) {
164 CRM.$("#trans_assign").prop('disabled',false);
167 CRM.$("#trans_remove").prop('disabled',false);
171 function toggleFinancialSelections(toggleID, toggleClass) {
173 if (toggleClass == 'remove') {
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);
180 CRM.$("#crm-transaction-selector-" + toggleClass + "-{/literal}{$entityID}{literal} input[id^='mark_" + mark + "_']").prop('checked',false);
184 function buildTransactionSelectorAssign(filterSearch) {
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";
189 var ZeroRecordText = '<div class="status messages">{/literal}{ts escape="js"}None found.{/ts}{literal}</li></ul></div>';
192 crmBatchSelector1 = CRM.$('#crm-transaction-selector-assign-{/literal}{$entityID}{literal}').dataTable({
195 "bAutoWidth" : false,
196 "lengthMenu": [ 10, 25, 50, 100, 250, 500, 1000, 2000 ],
197 "aaSorting" : [[5, 'desc']],
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'},
204 {sClass:'crm-trxn_date'},
205 {sClass:'crm-received'},
206 {sClass:'crm-payment-method'},
207 {sClass:'crm-status'},
209 {sClass:'crm-transaction-links', bSortable:false}
212 "asStripClasses" : [ "odd-row", "even-row" ],
213 "sPaginationType": "full_numbers",
214 "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
217 "sAjaxSource": sourceUrl,
218 "iDisplayLength": 25,
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},
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}
234 "fnServerData": function ( sSource, aoData, fnCallback ) {
235 if ( filterSearch ) {
236 CRM.$('#searchForm :input').each(function() {
237 if (CRM.$(this).val()) {
239 {name:CRM.$(this).attr('id'), value: CRM.$(this).val()}
241 CRM.$(':radio, :checkbox').each(function() {
242 if (CRM.$(this).is(':checked')) {
243 aoData.push( { name: CRM.$(this).attr('name'), value: CRM.$(this).val() } );
254 "success": function(b) {
256 toggleFinancialSelections('#toggleSelect', 'assign');
264 function buildTransactionSelectorRemove( ) {
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};
268 crmBatchSelector = CRM.$('#crm-transaction-selector-remove-{/literal}{$entityID}{literal}').dataTable({
271 "bAutoWidth" : false,
272 "aaSorting" : [[5, 'desc']],
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'},
279 {sClass:'crm-trxn_date'},
280 {sClass:'crm-received'},
281 {sClass:'crm-payment-method'},
282 {sClass:'crm-status'},
284 {sClass:'crm-transaction-links', bSortable:false}
287 "asStripClasses" : [ "odd-row", "even-row" ],
288 "sPaginationType": "full_numbers",
289 "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
292 "sAjaxSource": sourceUrl,
293 "iDisplayLength": 25,
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},
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}
308 "fnServerData": function (sSource, aoData, fnCallback) {
314 "success": function(b) {
316 toggleFinancialSelections('#toggleSelects', 'remove');
323 function selectAction( id, toggleSelectId, checkId ) {
324 if (CRM.$("#"+ id ).is(':disabled')) {
327 else if (!CRM.$("#" + toggleSelectId).is(':checked') && !CRM.$("#" + checkId).is(':checked') && CRM.$("#" + id).val() != "") {
328 CRM.alert ({/literal}'{ts escape="js"}Please select one or more contributions for this action.{/ts}'{literal});
331 else if (CRM.$("#" + id).val() == "") {
332 CRM.alert ({/literal}'{ts escape="js"}Please select an action from the drop-down menu.{/ts}'{literal});
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};
340 if (action == 'Assign') {
341 CRM.$("input[id^='mark_x_']:checked").each( function () {
342 var a = CRM.$(this).attr('id');
346 if (action == 'Remove') {
347 CRM.$("input[id^='mark_y_']:checked").each( function () {
348 var a = CRM.$(this).attr('id');
352 CRM.$.post(postUrl, { ID: fids, action:action }, function(data) {
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});
360 CRM.alert(data.status);