(function ($) { function mass_status_change(dt, status){ var oData = dt.rows('.selected').ids(); $('#mass_status_change').val(status); $('#rows_status').val(''); for (var i=0; i < oData.length ;i++){ $('#rows_status').val($('#rows_status').val() + oData[i] + ','); } $('#selectedrows_status').submit(); } function mass_usefulness_change(dt, usefulness){ var oData = dt.rows('.selected').ids(); $('#mass_usefulness_change').val(usefulness); $('#rows_usefulness').val(''); for (var i=0; i < oData.length ;i++){ $('#rows_usefulness').val($('#rows_usefulness').val() + oData[i] + ','); } $('#selectedrows_usefulness').submit(); } $(document).ready(function() { var url = "admin.php?page=ContacticPluginSubmissions&form_name=Haftungsverzicht&submit_time="; // Date range filter var minDateFilter = ""; var maxDateFilter = ""; oTable = $('#table-1764d1a03f7cb0').dataTable( { serverSide: true, stateSave: true, ajax: { url: "https://dirtforce.de/wp-admin/admin-ajax.php?action=load_contacts&form_name=Haftungsverzicht", type: "POST", data: function ( d ) { d.minDateFilter = minDateFilter; d.maxDateFilter = maxDateFilter; } }, scrollX: true, scrollY: '50vh', paging: true, dom: 'Bfrtip', pageLength: 100, buttons: [ 'pageLength', { extend: 'collection', text: 'Mass Action', buttons: [ { text: "Löschen", action: function ( e, dt, node, config ) { var oData = oTable.api().rows('.selected').ids(); if (confirm('Are you sure you want to delete the selected data for this form?')) { $('#rows_delete').val(''); for (var i=0; i < oData.length ;i++){ $('#rows_delete').val($('#rows_delete').val() + oData[i] + ','); } $('#selectedrows_delete').submit(); } } }, { text: '', className: 'dt_button_separator', }, { text: "Set Status : Todo", action: function ( e, dt, node, config ) { mass_status_change(dt, 'Todo'); } }, { text: "Set Status : Done", action: function ( e, dt, node, config ) { mass_status_change(dt, 'Done'); } }, { text: '', className: 'dt_button_separator', }, { text: "Set Usefulness : Usefull", action: function ( e, dt, node, config ) { mass_usefulness_change(dt, 'Usefull'); } }, { text: "Set Usefulness : Useless", action: function ( e, dt, node, config ) { mass_usefulness_change(dt, 'Useless'); } }, { text: "Set Usefulness : Spam", action: function ( e, dt, node, config ) { mass_usefulness_change(dt, 'Spam'); } } ] }, { extend:'colvis', columns:':gt(0)' } ], rowId: 'submit_time', columns: [ { data: null, defaultContent: '', className: 'select-checkbox', orderable: false }, { data: "Submitted", name: 'Submitted' }, { data: "Vorname", name: 'Vorname' }, { data: "Nachname", name: 'Nachname' }, { data: "Emailadresse", name: 'Emailadresse' }, { data: "Emailadresse-confirm", name: 'Emailadresse-confirm' }, { data: "Telefon", name: 'Telefon' }, { data: "Geburtstag", name: 'Geburtstag' }, { data: "Solofahrt", name: 'Solofahrt' }, { data: "Notfallkontakt", name: 'Notfallkontakt' }, { data: "Notfallnummer", name: 'Notfallnummer' }, { data: "Signatur", name: 'Signatur' }, { data: "Signatur-attachment", name: 'Signatur-attachment' }, { data: "Signatur-inline", name: 'Signatur-inline' }, { data: "akzeptieren-e-signature", name: 'akzeptieren-e-signature' }, { data: "akzeptieren", name: 'akzeptieren' }, { data: "_ctc_referer", name: '_ctc_referer' }, { data: "_ctc_usefulness", name: '_ctc_usefulness' }, { data: "_ctc_status", name: '_ctc_status' }, { data: "Submitted From", name: 'Submitted From' }, ], columnDefs: [{ orderable: false, className: 'select-checkbox', targets: 0 }, { render : function (data, type, row) { return '' + data + ''; }, targets: 1 }], select: { style: 'multi', selector: 'td:first-child' }, order: [[ 1, 'desc' ]] });
$('#selectall').click( function () { if (this.checked) { oTable.api().rows().select(); }else{ oTable.api().rows().deselect(); } });
$("#datepicker_from").datepicker({ "onSelect": function(date) { minDateFilter = new Date(date).getTime() / 1000; if (isNaN(minDateFilter)) minDateFilter = ''; oTable.fnDraw(); } }).keyup(function() { minDateFilter = new Date(this.value).getTime() / 1000; if (isNaN(minDateFilter)) minDateFilter = ''; oTable.fnDraw(); });
$("#datepicker_to").datepicker({ "onSelect": function(date) { maxDateFilter = new Date(date).getTime() / 1000; if (isNaN(maxDateFilter)) maxDateFilter = ''; oTable.fnDraw(); } }).keyup(function() { maxDateFilter = new Date(this.value).getTime() / 1000; if (isNaN(maxDateFilter)) maxDateFilter = ''; oTable.fnDraw(); });
}); })(jQuery);