2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.7 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2017 |
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">{$form.sort_name.label} {$form.sort_name.html|crmAddClass:'twenty'}</td>
41 {if $form.contact_tags}
42 <td><label>{ts}Contributor Tag(s){/ts}</label>
43 {$form.contact_tags.html}
49 <td><label>{ts}Contributor Group(s){/ts}</label>
56 {include file="CRM/Contribute/Form/Search/Common.tpl"}
58 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
63 {if in_array($batchStatus, array('Open', 'Reopened'))}
64 <div class="form-layout-compressed">{$form.trans_assign.html} {$form.submit.html}</div><br/>
68 <div class="form-item">
70 <table id="crm-transaction-selector-assign-{$entityID}" cellpadding="0" cellspacing="0" border="0">
73 <th class="crm-transaction-checkbox">{if in_array($batchStatus, array('Open', 'Reopened'))}{$form.toggleSelect.html}{/if}</th>
74 <th class="crm-contact-type"></th>
75 <th class="crm-contact-name">{ts}Name{/ts}</th>
76 <th class="crm-amount">{ts}Amount{/ts}</th>
77 <th class="crm-trxnID">{ts}Trxn ID{/ts}</th>
78 <th class="crm-received">{ts}Received{/ts}</th>
79 <th class="crm-payment-method">{ts}Pay Method{/ts}</th>
80 <th class="crm-status">{ts}Status{/ts}</th>
81 <th class="crm-type">{ts}Financial Type{/ts}</th>
82 <th class="crm-transaction-links"></th>
92 <script type="text/javascript">
94 CRM.$('#_qf_BatchTransaction_submit-top, #_qf_BatchTransaction_submit-bottom').click(function() {
95 CRM.$('.crm-batch_transaction_search-accordion:not(.collapsed)').crmAccordionToggle();
97 var batchStatus = {/literal}{$statusID}{literal};
98 {/literal}{if $validStatus}{literal}
99 // build transaction listing only for open/reopened batches
100 var paymentInstrumentID = {/literal}{if $paymentInstrumentID neq null}{$paymentInstrumentID}{else}'null'{/if}{literal};
101 if (paymentInstrumentID != 'null') {
102 buildTransactionSelectorAssign( true );
105 buildTransactionSelectorAssign( false );
107 buildTransactionSelectorRemove();
108 CRM.$('#_qf_BatchTransaction_submit-bottom, #_qf_BatchTransaction_submit-top').click( function() {
109 buildTransactionSelectorAssign( true );
113 CRM.$("#trans_assign").prop('disabled',true);
114 CRM.$("#trans_remove").prop('disabled',true);
115 CRM.$('#crm-transaction-selector-assign-{/literal}{$entityID}{literal} #toggleSelect').click( function() {
118 CRM.$('#crm-transaction-selector-remove-{/literal}{$entityID}{literal} #toggleSelects').click( function() {
121 CRM.$('#Go').click( function() {
122 return selectAction("trans_assign","toggleSelect", "crm-transaction-selector-assign-{/literal}{$entityID}{literal} input[id^='mark_x_']");
124 CRM.$('#GoRemove').click( function() {
125 return selectAction("trans_remove","toggleSelects", "crm-transaction-selector-remove-{/literal}{$entityID}{literal} input[id^='mark_y_']");
127 CRM.$('#Go').click( function() {
128 if (CRM.$("#trans_assign" ).val() != "" && CRM.$("input[id^='mark_x_']").is(':checked')) {
129 bulkAssignRemove('Assign');
133 CRM.$('#GoRemove').click( function() {
134 if (CRM.$("#trans_remove" ).val() != "" && CRM.$("input[id^='mark_y_']").is(':checked')) {
135 bulkAssignRemove('Remove');
139 CRM.$("#crm-transaction-selector-assign-{/literal}{$entityID}{literal} input[id^='mark_x_']").click( function() {
142 CRM.$("#crm-transaction-selector-remove-{/literal}{$entityID}{literal} input[id^='mark_y_']").click( function() {
146 CRM.$("#crm-transaction-selector-assign-{/literal}{$entityID}{literal} #toggleSelect").click( function() {
147 toggleFinancialSelections('#toggleSelect', 'assign');
149 CRM.$("#crm-transaction-selector-remove-{/literal}{$entityID}{literal} #toggleSelects").click( function() {
150 toggleFinancialSelections('#toggleSelects', 'remove');
152 {/literal}{else}{literal}
153 buildTransactionSelectorRemove();
154 {/literal}{/if}{literal}
157 function enableActions( type ) {
159 CRM.$("#trans_assign").prop('disabled',false);
162 CRM.$("#trans_remove").prop('disabled',false);
166 function toggleFinancialSelections(toggleID, toggleClass) {
168 if (toggleClass == 'remove') {
171 if (CRM.$("#crm-transaction-selector-" + toggleClass + "-{/literal}{$entityID}{literal} " + toggleID).is(':checked')) {
172 CRM.$("#crm-transaction-selector-" + toggleClass + "-{/literal}{$entityID}{literal} input[id^='mark_" + mark + "_']").prop('checked',true);
175 CRM.$("#crm-transaction-selector-" + toggleClass + "-{/literal}{$entityID}{literal} input[id^='mark_" + mark + "_']").prop('checked',false);
179 function buildTransactionSelectorAssign(filterSearch) {
181 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};
182 if ( filterSearch ) {
183 sourceUrl = sourceUrl+"&search=1";
184 var ZeroRecordText = '<div class="status messages">{/literal}{ts escape="js"}None found.{/ts}{literal}</li></ul></div>';
187 crmBatchSelector1 = CRM.$('#crm-transaction-selector-assign-{/literal}{$entityID}{literal}').dataTable({
190 "bAutoWidth" : false,
191 "aaSorting" : [[5, 'desc']],
193 {sClass:'crm-transaction-checkbox', bSortable:false},
194 {sClass:'crm-contact-type', bSortable:false},
195 {sClass:'crm-contact-name'},
196 {sClass:'crm-amount'},
197 {sClass:'crm-trxnID'},
198 {sClass:'crm-received'},
199 {sClass:'crm-payment-method'},
200 {sClass:'crm-status'},
202 {sClass:'crm-transaction-links', bSortable:false}
205 "asStripClasses" : [ "odd-row", "even-row" ],
206 "sPaginationType": "full_numbers",
207 "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
210 "sAjaxSource": sourceUrl,
211 "iDisplayLength": 25,
213 "sZeroRecords": ZeroRecordText,
214 "sProcessing": {/literal}"{ts escape='js'}Processing...{/ts}"{literal},
215 "sLengthMenu": {/literal}"{ts escape='js'}Show _MENU_ entries{/ts}"{literal},
216 "sInfo": {/literal}"{ts escape='js'}Showing _START_ to _END_ of _TOTAL_ entries{/ts}"{literal},
217 "sInfoEmpty": {/literal}"{ts escape='js'}Showing 0 to 0 of 0 entries{/ts}"{literal},
218 "sInfoFiltered": {/literal}"{ts escape='js'}(filtered from _MAX_ total entries){/ts}"{literal},
219 "sSearch": {/literal}"{ts escape='js'}Search:{/ts}"{literal},
221 "sFirst": {/literal}"{ts escape='js'}First{/ts}"{literal},
222 "sPrevious": {/literal}"{ts escape='js'}Previous{/ts}"{literal},
223 "sNext": {/literal}"{ts escape='js'}Next{/ts}"{literal},
224 "sLast": {/literal}"{ts escape='js'}Last{/ts}"{literal}
227 "fnServerData": function ( sSource, aoData, fnCallback ) {
228 if ( filterSearch ) {
229 CRM.$('#searchForm :input').each(function() {
230 if (CRM.$(this).val()) {
232 {name:CRM.$(this).attr('id'), value: CRM.$(this).val()}
234 CRM.$(':radio, :checkbox').each(function() {
235 if (CRM.$(this).is(':checked')) {
236 aoData.push( { name: CRM.$(this).attr('name'), value: CRM.$(this).val() } );
247 "success": function(b) {
249 toggleFinancialSelections('#toggleSelect', 'assign');
257 function buildTransactionSelectorRemove( ) {
259 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};
261 crmBatchSelector = CRM.$('#crm-transaction-selector-remove-{/literal}{$entityID}{literal}').dataTable({
264 "bAutoWidth" : false,
265 "aaSorting" : [[5, 'desc']],
267 {sClass:'crm-transaction-checkbox', bSortable:false},
268 {sClass:'crm-contact-type', bSortable:false},
269 {sClass:'crm-contact-name'},
270 {sClass:'crm-amount'},
271 {sClass:'crm-trxnID'},
272 {sClass:'crm-received'},
273 {sClass:'crm-payment-method'},
274 {sClass:'crm-status'},
276 {sClass:'crm-transaction-links', bSortable:false}
279 "asStripClasses" : [ "odd-row", "even-row" ],
280 "sPaginationType": "full_numbers",
281 "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
284 "sAjaxSource": sourceUrl,
285 "iDisplayLength": 25,
287 "sProcessing": {/literal}"{ts escape='js'}Processing...{/ts}"{literal},
288 "sLengthMenu": {/literal}"{ts escape='js'}Show _MENU_ entries{/ts}"{literal},
289 "sInfo": {/literal}"{ts escape='js'}Showing _START_ to _END_ of _TOTAL_ entries{/ts}"{literal},
290 "sInfoEmpty": {/literal}"{ts escape='js'}Showing 0 to 0 of 0 entries{/ts}"{literal},
291 "sInfoFiltered": {/literal}"{ts escape='js'}(filtered from _MAX_ total entries){/ts}"{literal},
292 "sSearch": {/literal}"{ts escape='js'}Search:{/ts}"{literal},
294 "sFirst": {/literal}"{ts escape='js'}First{/ts}"{literal},
295 "sPrevious": {/literal}"{ts escape='js'}Previous{/ts}"{literal},
296 "sNext": {/literal}"{ts escape='js'}Next{/ts}"{literal},
297 "sLast": {/literal}"{ts escape='js'}Last{/ts}"{literal}
300 "fnServerData": function (sSource, aoData, fnCallback) {
306 "success": function(b) {
308 toggleFinancialSelections('#toggleSelects', 'remove');
315 function selectAction( id, toggleSelectId, checkId ) {
316 if (CRM.$("#"+ id ).is(':disabled')) {
319 else if (!CRM.$("#" + toggleSelectId).is(':checked') && !CRM.$("#" + checkId).is(':checked') && CRM.$("#" + id).val() != "") {
320 CRM.alert ({/literal}'{ts escape="js"}Please select one or more contributions for this action.{/ts}'{literal});
323 else if (CRM.$("#" + id).val() == "") {
324 CRM.alert ({/literal}'{ts escape="js"}Please select an action from the drop-down menu.{/ts}'{literal});
329 function bulkAssignRemove( action ) {
330 var postUrl = {/literal}"{crmURL p='civicrm/ajax/rest' h=0 q="className=CRM_Financial_Page_AJAX&fnName=bulkAssignRemove&entityID=$entityID" }"{literal};
332 if (action == 'Assign') {
333 CRM.$("input[id^='mark_x_']:checked").each( function () {
334 var a = CRM.$(this).attr('id');
338 if (action == 'Remove') {
339 CRM.$("input[id^='mark_y_']:checked").each( function () {
340 var a = CRM.$(this).attr('id');
344 CRM.$.post(postUrl, { ID: fids, action:action }, function(data) {
345 //this is custom status set when record update success.
346 if (data.status == 'record-updated-success') {
347 buildTransactionSelectorAssign( true );
348 buildTransactionSelectorRemove();
349 batchSummary({/literal}{$entityID}{literal});
352 CRM.alert(data.status);