Bug 22811: Add button to clear DataTables filtering
[koha.git] / koha-tmpl / intranet-tmpl / prog / js / datatables.js
1 // These default options are for translation but can be used
2 // for any other datatables settings
3 // MSG_DT_* variables comes from datatables.inc
4 // To use it, write:
5 //  $("#table_id").dataTable($.extend(true, {}, dataTableDefaults, {
6 //      // other settings
7 //  } ) );
8 var dataTablesDefaults = {
9     "oLanguage": {
10         "oPaginate": {
11             "sFirst"    : window.MSG_DT_FIRST || "First",
12             "sLast"     : window.MSG_DT_LAST || "Last",
13             "sNext"     : window.MSG_DT_NEXT || "Next",
14             "sPrevious" : window.MSG_DT_PREVIOUS || "Previous"
15         },
16         "sEmptyTable"       : window.MSG_DT_EMPTY_TABLE || "No data available in table",
17         "sInfo"             : window.MSG_DT_INFO || "Showing _START_ to _END_ of _TOTAL_ entries",
18         "sInfoEmpty"        : window.MSG_DT_INFO_EMPTY || "No entries to show",
19         "sInfoFiltered"     : window.MSG_DT_INFO_FILTERED || "(filtered from _MAX_ total entries)",
20         "sLengthMenu"       : window.MSG_DT_LENGTH_MENU || "Show _MENU_ entries",
21         "sLoadingRecords"   : window.MSG_DT_LOADING_RECORDS || "Loading...",
22         "sProcessing"       : window.MSG_DT_PROCESSING || "Processing...",
23         "sSearch"           : window.MSG_DT_SEARCH || "Search:",
24         "sZeroRecords"      : window.MSG_DT_ZERO_RECORDS || "No matching records found",
25         buttons: {
26             "copyTitle"     : window.MSG_DT_COPY_TITLE || "Copy to clipboard",
27             "copyKeys"      : window.MSG_DT_COPY_KEYS || "Press <i>ctrl</i> or <i>⌘</i> + <i>C</i> to copy the table data<br>to your system clipboard.<br><br>To cancel, click this message or press escape.",
28             "copySuccess": {
29                 _: window.MSG_DT_COPY_SUCCESS_X || "Copied %d rows to clipboard",
30                 1: window.MSG_DT_COPY_SUCCESS_ONE || "Copied one row to clipboard"
31             }
32         }
33     },
34     "dom": '<"top pager"ilpfB>tr<"bottom pager"ip>',
35     "buttons": [{
36         fade: 100,
37         className: "dt_button_clear_filter",
38         titleAttr: _("Clear filter"),
39         enabled: false,
40         text: '<i class="fa fa-lg fa-remove"></i> <span class="dt-button-text">' + _("Clear filter") + '</span>',
41         available: function ( dt ) {
42             // The "clear filter" button is made available if this test returns true
43             if( dt.settings()[0].aanFeatures.f ){ // aanFeatures.f is null if there is no search form
44                 return true;
45             }
46         },
47         action: function ( e, dt, node ) {
48             dt.search( "" ).draw("page");
49             node.addClass("disabled");
50         }
51     }],
52     "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, window.MSG_DT_ALL || "All"]],
53     "iDisplayLength": 20,
54     initComplete: function( settings) {
55         var tableId = settings.nTable.id
56         // When the DataTables search function is triggered,
57         // enable or disable the "Clear filter" button based on
58         // the presence of a search string
59         $("#" + tableId ).on( 'search.dt', function ( e, settings ) {
60             if( settings.oPreviousSearch.sSearch == "" ){
61                 $("#" + tableId + "_wrapper").find(".dt_button_clear_filter").addClass("disabled");
62             } else {
63                 $("#" + tableId + "_wrapper").find(".dt_button_clear_filter").removeClass("disabled");
64             }
65         });
66     }
67 };
68
69
70 // Return an array of string containing the values of a particular column
71 $.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) {
72     // check that we have a column id
73     if ( typeof iColumn == "undefined" ) return new Array();
74     // by default we only wany unique data
75     if ( typeof bUnique == "undefined" ) bUnique = true;
76     // by default we do want to only look at filtered data
77     if ( typeof bFiltered == "undefined" ) bFiltered = true;
78     // by default we do not wany to include empty values
79     if ( typeof bIgnoreEmpty == "undefined" ) bIgnoreEmpty = true;
80     // list of rows which we're going to loop through
81     var aiRows;
82     // use only filtered rows
83     if (bFiltered == true) aiRows = oSettings.aiDisplay;
84     // use all rows
85     else aiRows = oSettings.aiDisplayMaster; // all row numbers
86
87     // set up data array
88     var asResultData = new Array();
89     for (var i=0,c=aiRows.length; i<c; i++) {
90         iRow = aiRows[i];
91         var aData = this.fnGetData(iRow);
92         var sValue = aData[iColumn];
93         // ignore empty values?
94         if (bIgnoreEmpty == true && sValue.length == 0) continue;
95         // ignore unique values?
96         else if (bUnique == true && jQuery.inArray(sValue, asResultData) > -1) continue;
97         // else push the value onto the result data array
98         else asResultData.push(sValue);
99     }
100     return asResultData;
101 }
102
103 // List of unbind keys (Ctrl, Alt, Direction keys, etc.)
104 // These keys must not launch filtering
105 var blacklist_keys = new Array(0, 16, 17, 18, 37, 38, 39, 40);
106
107 // Set a filtering delay for global search field
108 jQuery.fn.dataTableExt.oApi.fnSetFilteringDelay = function ( oSettings, iDelay ) {
109     /*
110      * Inputs:      object:oSettings - dataTables settings object - automatically given
111      *              integer:iDelay - delay in milliseconds
112      * Usage:       $('#example').dataTable().fnSetFilteringDelay(250);
113      * Author:      Zygimantas Berziunas (www.zygimantas.com) and Allan Jardine
114      * License:     GPL v2 or BSD 3 point style
115      * Contact:     zygimantas.berziunas /AT\ hotmail.com
116      */
117     var
118         _that = this,
119         iDelay = (typeof iDelay == 'undefined') ? 250 : iDelay;
120
121     this.each( function ( i ) {
122         $.fn.dataTableExt.iApiIndex = i;
123         var
124             $this = this,
125             oTimerId = null,
126             sPreviousSearch = null,
127             anControl = $( 'input', _that.fnSettings().aanFeatures.f );
128
129         anControl.unbind( 'keyup.DT' ).bind( 'keyup.DT', function(event) {
130             var $$this = $this;
131             if (blacklist_keys.indexOf(event.keyCode) != -1) {
132                 return this;
133             }else if ( event.keyCode == '13' ) {
134                 $.fn.dataTableExt.iApiIndex = i;
135                 _that.fnFilter( $(this).val() );
136             } else {
137                 if (sPreviousSearch === null || sPreviousSearch != anControl.val()) {
138                     window.clearTimeout(oTimerId);
139                     sPreviousSearch = anControl.val();
140                     oTimerId = window.setTimeout(function() {
141                         $.fn.dataTableExt.iApiIndex = i;
142                         _that.fnFilter( anControl.val() );
143                     }, iDelay);
144                 }
145             }
146         });
147
148         return this;
149     } );
150     return this;
151 }
152
153 // Add a filtering delay on general search and on all input (with a class 'filter')
154 jQuery.fn.dataTableExt.oApi.fnAddFilters = function ( oSettings, sClass, iDelay ) {
155     var table = this;
156     this.fnSetFilteringDelay(iDelay);
157     var filterTimerId = null;
158     $(table).find("input."+sClass).keyup(function(event) {
159       if (blacklist_keys.indexOf(event.keyCode) != -1) {
160         return this;
161       }else if ( event.keyCode == '13' ) {
162         table.fnFilter( $(this).val(), $(this).attr('data-column_num') );
163       } else {
164         window.clearTimeout(filterTimerId);
165         var input = this;
166         filterTimerId = window.setTimeout(function() {
167           table.fnFilter($(input).val(), $(input).attr('data-column_num'));
168         }, iDelay);
169       }
170     });
171     $(table).find("select."+sClass).on('change', function() {
172         table.fnFilter($(this).val(), $(this).attr('data-column_num'));
173     });
174 }
175
176 // Sorting on html contains
177 // <a href="foo.pl">bar</a> sort on 'bar'
178 function dt_overwrite_html_sorting_localeCompare() {
179     jQuery.fn.dataTableExt.oSort['html-asc']  = function(a,b) {
180         a = a.replace(/<.*?>/g, "").replace(/\s+/g, " ");
181         b = b.replace(/<.*?>/g, "").replace(/\s+/g, " ");
182         if (typeof(a.localeCompare == "function")) {
183            return a.localeCompare(b);
184         } else {
185            return (a > b) ? 1 : ((a < b) ? -1 : 0);
186         }
187     };
188
189     jQuery.fn.dataTableExt.oSort['html-desc'] = function(a,b) {
190         a = a.replace(/<.*?>/g, "").replace(/\s+/g, " ");
191         b = b.replace(/<.*?>/g, "").replace(/\s+/g, " ");
192         if(typeof(b.localeCompare == "function")) {
193             return b.localeCompare(a);
194         } else {
195             return (b > a) ? 1 : ((b < a) ? -1 : 0);
196         }
197     };
198
199     jQuery.fn.dataTableExt.oSort['num-html-asc']  = function(a,b) {
200         var x = a.replace( /<.*?>/g, "" );
201         var y = b.replace( /<.*?>/g, "" );
202         x = parseFloat( x );
203         y = parseFloat( y );
204         return ((x < y) ? -1 : ((x > y) ?  1 : 0));
205     };
206
207     jQuery.fn.dataTableExt.oSort['num-html-desc'] = function(a,b) {
208         var x = a.replace( /<.*?>/g, "" );
209         var y = b.replace( /<.*?>/g, "" );
210         x = parseFloat( x );
211         y = parseFloat( y );
212         return ((x < y) ?  1 : ((x > y) ? -1 : 0));
213     };
214 }
215
216 $.fn.dataTableExt.oPagination.four_button = {
217     /*
218      * Function: oPagination.four_button.fnInit
219      * Purpose:  Initalise dom elements required for pagination with a list of the pages
220      * Returns:  -
221      * Inputs:   object:oSettings - dataTables settings object
222      *           node:nPaging - the DIV which contains this pagination control
223      *           function:fnCallbackDraw - draw function which must be called on update
224      */
225     "fnInit": function ( oSettings, nPaging, fnCallbackDraw )
226     {
227         nFirst = document.createElement( 'span' );
228         nPrevious = document.createElement( 'span' );
229         nNext = document.createElement( 'span' );
230         nLast = document.createElement( 'span' );
231
232         nFirst.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sFirst ) );
233         nPrevious.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sPrevious ) );
234         nNext.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sNext ) );
235         nLast.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sLast ) );
236
237         nFirst.className = "paginate_button first";
238         nPrevious.className = "paginate_button previous";
239         nNext.className="paginate_button next";
240         nLast.className = "paginate_button last";
241
242         nPaging.appendChild( nFirst );
243         nPaging.appendChild( nPrevious );
244         nPaging.appendChild( nNext );
245         nPaging.appendChild( nLast );
246
247         $(nFirst).click( function () {
248             oSettings.oApi._fnPageChange( oSettings, "first" );
249             fnCallbackDraw( oSettings );
250         } );
251
252         $(nPrevious).click( function() {
253             oSettings.oApi._fnPageChange( oSettings, "previous" );
254             fnCallbackDraw( oSettings );
255         } );
256
257         $(nNext).click( function() {
258             oSettings.oApi._fnPageChange( oSettings, "next" );
259             fnCallbackDraw( oSettings );
260         } );
261
262         $(nLast).click( function() {
263             oSettings.oApi._fnPageChange( oSettings, "last" );
264             fnCallbackDraw( oSettings );
265         } );
266
267         /* Disallow text selection */
268         $(nFirst).bind( 'selectstart', function () { return false; } );
269         $(nPrevious).bind( 'selectstart', function () { return false; } );
270         $(nNext).bind( 'selectstart', function () { return false; } );
271         $(nLast).bind( 'selectstart', function () { return false; } );
272     },
273
274     /*
275      * Function: oPagination.four_button.fnUpdate
276      * Purpose:  Update the list of page buttons shows
277      * Returns:  -
278      * Inputs:   object:oSettings - dataTables settings object
279      *           function:fnCallbackDraw - draw function which must be called on update
280      */
281     "fnUpdate": function ( oSettings, fnCallbackDraw )
282     {
283         if ( !oSettings.aanFeatures.p )
284         {
285             return;
286         }
287
288         /* Loop over each instance of the pager */
289         var an = oSettings.aanFeatures.p;
290         for ( var i=0, iLen=an.length ; i<iLen ; i++ )
291         {
292             var buttons = an[i].getElementsByTagName('span');
293             if ( oSettings._iDisplayStart === 0 )
294             {
295                 buttons[0].className = "paginate_disabled_first";
296                 buttons[1].className = "paginate_disabled_previous";
297             }
298             else
299             {
300                 buttons[0].className = "paginate_enabled_first";
301                 buttons[1].className = "paginate_enabled_previous";
302             }
303
304             if ( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() )
305             {
306                 buttons[2].className = "paginate_disabled_next";
307                 buttons[3].className = "paginate_disabled_last";
308             }
309             else
310             {
311                 buttons[2].className = "paginate_enabled_next";
312                 buttons[3].className = "paginate_enabled_last";
313             }
314         }
315     }
316 };
317
318 $.fn.dataTableExt.oSort['num-html-asc']  = function(a,b) {
319     var x = a.replace( /<.*?>/g, "" );
320     var y = b.replace( /<.*?>/g, "" );
321     x = parseFloat( x );
322     y = parseFloat( y );
323     return ((x < y) ? -1 : ((x > y) ?  1 : 0));
324 };
325
326 $.fn.dataTableExt.oSort['num-html-desc'] = function(a,b) {
327     var x = a.replace( /<.*?>/g, "" );
328     var y = b.replace( /<.*?>/g, "" );
329     x = parseFloat( x );
330     y = parseFloat( y );
331     return ((x < y) ?  1 : ((x > y) ? -1 : 0));
332 };
333
334 (function() {
335
336 /*
337  * Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license
338  * Author: Jim Palmer (based on chunking idea from Dave Koelle)
339  * Contributors: Mike Grier (mgrier.com), Clint Priest, Kyle Adams, guillermo
340  * See: http://js-naturalsort.googlecode.com/svn/trunk/naturalSort.js
341  */
342 function naturalSort (a, b) {
343     var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,
344         sre = /(^[ ]*|[ ]*$)/g,
345         dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,
346         hre = /^0x[0-9a-f]+$/i,
347         ore = /^0/,
348         // convert all to strings and trim()
349         x = a.toString().replace(sre, '') || '',
350         y = b.toString().replace(sre, '') || '',
351         // chunk/tokenize
352         xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
353         yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
354         // numeric, hex or date detection
355         xD = parseInt(x.match(hre), 10) || (xN.length != 1 && x.match(dre) && Date.parse(x)),
356         yD = parseInt(y.match(hre), 10) || xD && y.match(dre) && Date.parse(y) || null;
357     // first try and sort Hex codes or Dates
358     if (yD)
359         if ( xD < yD ) return -1;
360         else if ( xD > yD )  return 1;
361     // natural sorting through split numeric strings and default strings
362     for(var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc++) {
363         // find floats not starting with '0', string or 0 if not defined (Clint Priest)
364         var oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
365         var oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
366         // handle numeric vs string comparison - number < string - (Kyle Adams)
367         if (isNaN(oFxNcL) !== isNaN(oFyNcL)) return (isNaN(oFxNcL)) ? 1 : -1;
368         // rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
369         else if (typeof oFxNcL !== typeof oFyNcL) {
370             oFxNcL += '';
371             oFyNcL += '';
372         }
373         if (oFxNcL < oFyNcL) return -1;
374         if (oFxNcL > oFyNcL) return 1;
375     }
376     return 0;
377 }
378
379 jQuery.extend( jQuery.fn.dataTableExt.oSort, {
380     "natural-asc": function ( a, b ) {
381         return naturalSort(a,b);
382     },
383
384     "natural-desc": function ( a, b ) {
385         return naturalSort(a,b) * -1;
386     }
387 } );
388
389 }());
390
391 /* Plugin to allow sorting on data stored in a span's title attribute
392  *
393  * Ex: <td><span title="[% ISO_date %]">[% formatted_date %]</span></td>
394  *
395  * In DataTables config:
396  *     "aoColumns": [
397  *        { "sType": "title-string" },
398  *      ]
399  * http://datatables.net/plug-ins/sorting#hidden_title_string
400  */
401 jQuery.extend( jQuery.fn.dataTableExt.oSort, {
402     "title-string-pre": function ( a ) {
403         var m = a.match(/title="(.*?)"/);
404         if ( null !== m && m.length ) {
405             return m[1].toLowerCase();
406         }
407         return "";
408     },
409
410     "title-string-asc": function ( a, b ) {
411         return ((a < b) ? -1 : ((a > b) ? 1 : 0));
412     },
413
414     "title-string-desc": function ( a, b ) {
415         return ((a < b) ? 1 : ((a > b) ? -1 : 0));
416     }
417 } );
418
419 /* Plugin to allow sorting on numeric data stored in a span's title attribute
420  *
421  * Ex: <td><span title="[% decimal_number_that_JS_parseFloat_accepts %]">
422  *              [% formatted currency %]
423  *     </span></td>
424  *
425  * In DataTables config:
426  *     "aoColumns": [
427  *        { "sType": "title-numeric" },
428  *      ]
429  * http://datatables.net/plug-ins/sorting#hidden_title
430  */
431 jQuery.extend( jQuery.fn.dataTableExt.oSort, {
432     "title-numeric-pre": function ( a ) {
433         var x = a.match(/title="*(-?[0-9\.]+)/)[1];
434         return parseFloat( x );
435     },
436
437     "title-numeric-asc": function ( a, b ) {
438         return ((a < b) ? -1 : ((a > b) ? 1 : 0));
439     },
440
441     "title-numeric-desc": function ( a, b ) {
442         return ((a < b) ? 1 : ((a > b) ? -1 : 0));
443     }
444 } );
445
446 (function() {
447
448     /* Plugin to allow text sorting to ignore articles
449      *
450      * In DataTables config:
451      *     "aoColumns": [
452      *        { "sType": "anti-the" },
453      *      ]
454      * Based on the plugin found here:
455      * http://datatables.net/plug-ins/sorting#anti_the
456      * Modified to exclude HTML tags from sorting
457      * Extended to accept a string of space-separated articles
458      * from a configuration file (in English, "a," "an," and "the")
459      */
460
461     if(CONFIG_EXCLUDE_ARTICLES_FROM_SORT){
462         var articles = CONFIG_EXCLUDE_ARTICLES_FROM_SORT.split(" ");
463         var rpattern = "";
464         for(i=0;i<articles.length;i++){
465             rpattern += "^" + articles[i] + " ";
466             if(i < articles.length - 1){ rpattern += "|"; }
467         }
468         var re = new RegExp(rpattern, "i");
469     }
470
471     jQuery.extend( jQuery.fn.dataTableExt.oSort, {
472         "anti-the-pre": function ( a ) {
473             var x = String(a).replace( /<[\s\S]*?>/g, "" );
474             var y = x.trim();
475             var z = y.replace(re, "").toLowerCase();
476             return z;
477         },
478
479         "anti-the-asc": function ( a, b ) {
480             return ((a < b) ? -1 : ((a > b) ? 1 : 0));
481         },
482
483         "anti-the-desc": function ( a, b ) {
484             return ((a < b) ? 1 : ((a > b) ? -1 : 0));
485         }
486     });
487
488 }());
489
490 // Remove string between NSB NSB characters
491 $.fn.dataTableExt.oSort['nsb-nse-asc'] = function(a,b) {
492     var pattern = new RegExp("\x88.*\x89");
493     a = a.replace(pattern, "");
494     b = b.replace(pattern, "");
495     return (a > b) ? 1 : ((a < b) ? -1 : 0);
496 }
497 $.fn.dataTableExt.oSort['nsb-nse-desc'] = function(a,b) {
498     var pattern = new RegExp("\x88.*\x89");
499     a = a.replace(pattern, "");
500     b = b.replace(pattern, "");
501     return (b > a) ? 1 : ((b < a) ? -1 : 0);
502 }
503
504 /* Define two custom functions (asc and desc) for basket callnumber sorting */
505 jQuery.fn.dataTableExt.oSort['callnumbers-asc']  = function(x,y) {
506         var x_array = x.split("<div>");
507         var y_array = y.split("<div>");
508
509         /* Pop the first elements, they are empty strings */
510         x_array.shift();
511         y_array.shift();
512
513         x_array = jQuery.map( x_array, function( a ) {
514             return parse_callnumber( a );
515         });
516         y_array = jQuery.map( y_array, function( a ) {
517             return parse_callnumber( a );
518         });
519
520         x_array.sort();
521         y_array.sort();
522
523         x = x_array.shift();
524         y = y_array.shift();
525
526         if ( !x ) { x = ""; }
527         if ( !y ) { y = ""; }
528
529         return ((x < y) ? -1 : ((x > y) ?  1 : 0));
530 };
531
532 jQuery.fn.dataTableExt.oSort['callnumbers-desc'] = function(x,y) {
533         var x_array = x.split("<div>");
534         var y_array = y.split("<div>");
535
536         /* Pop the first elements, they are empty strings */
537         x_array.shift();
538         y_array.shift();
539
540         x_array = jQuery.map( x_array, function( a ) {
541             return parse_callnumber( a );
542         });
543         y_array = jQuery.map( y_array, function( a ) {
544             return parse_callnumber( a );
545         });
546
547         x_array.sort();
548         y_array.sort();
549
550         x = x_array.pop();
551         y = y_array.pop();
552
553         if ( !x ) { x = ""; }
554         if ( !y ) { y = ""; }
555
556         return ((x < y) ?  1 : ((x > y) ? -1 : 0));
557 };
558
559 function parse_callnumber ( html ) {
560     var array = html.split('<span class="callnumber">');
561     if ( array[1] ) {
562         array = array[1].split('</span>');
563         return array[0];
564     } else {
565         return "";
566     }
567 }
568
569 // see http://www.datatables.net/examples/advanced_init/footer_callback.html
570 function footer_column_sum( api, column_numbers ) {
571     // Remove the formatting to get integer data for summation
572     var intVal = function ( i ) {
573         if ( typeof i === 'number' ) {
574             if ( isNaN(i) ) return 0;
575             return i;
576         } else if ( typeof i === 'string' ) {
577             var value = i.replace(/[a-zA-Z ,.]/g, '')*1;
578             if ( isNaN(value) ) return 0;
579             return value;
580         }
581         return 0;
582     };
583
584
585     for ( var indice = 0 ; indice < column_numbers.length ; indice++ ) {
586         var column_number = column_numbers[indice];
587
588         var total = 0;
589         var cells = api.column( column_number, { page: 'current' } ).nodes().to$().find("span.total_amount");
590         $(cells).each(function(){
591             total += intVal( $(this).html() );
592         });
593         total /= 100; // Hard-coded decimal precision
594
595         // Update footer
596         $( api.column( column_number ).footer() ).html(total.format_price());
597     };
598 }
599
600 function filterDataTable( table, column, term ){
601     if( column ){
602         table.column( column ).search( term ).draw("page");
603     } else {
604         table.search( term ).draw("page");
605     }
606 }