/****************************************************************************************** Copyright (c) 2015 Christopher W. Olsen <cwolsen@ubixtechnologies.com> All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors in the documentation and/or other materials provided with the distribution. Neither the name of the uBix Cube Project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. $Id: did.js 202 2015-12-06 01:11:39Z reddawg $ *****************************************************************************************/ var DDT; var DDT_api; var DST; $(function() { var edit_dial_plan, edit_did_form; DDT = $('#dpTable').dataTable({ "order": [[ 0, 'desc' ]] }); /* $('#edit_dial_plan_data').accordion({ header: "> div > h3" }) .sortable({ axis: "y", handle: "h3", stop: function( event, ui ) { // IE doesn't register the blur when sorting // so trigger focusout handlers to remove .ui-state-focus ui.item.children( "h3" ).triggerHandler( "focusout" ); alert(ui.item.index()); // Refresh accordion to handle new order $( this ).accordion( "refresh" ); } }); */ DST = $('#dpsTable').DataTable({ rowReorder: true }); DST.on('row-reorder', function(e, diff, edit) { alert('balls'); for ( var i=0, ien=diff.length ; i<ien ; i++ ) { var rowData = DST.row( diff[i].node ).data(); var hD = rowData.find('.dps'); // var hD = diff[i].node.closest('.dps'); alert(hD.name); //result += rowData[1]+' updated to be in position 'String+ //diff[i].newData+' (was 'String+diff[i].oldData+')<br>'String; } }); DDT_api = DDT.api(); DDT.delegate(".edit_dial_plan", "click", function() { /* var dT = this.id.split(':'); _AJAX( '/user/voip/dialplan_json.php', 'data[req]=dialplan_pubList&data[account_number]=' + dT[1], function(data, code, message) { $("#ed_dstBox option").remove(); $("#ed_dstBox").append($("<option></option>").text('Unassigned').val('ua-in')); if (code == 1) { $.each(data, function(index, item) { $("#ed_dstBox").append($("<option></option>").text(item.Desc).val(item.ID)); }); } else { alert(message); } } ); _AJAX( '/user/voip/dialplan_json.php', 'data[req]=dialplan_dynDID&data[exten]=' + dT[0], function(data, code, message) { if (code == 1) { alert(data); } else { alert(message); } } ); */ edit_dial_plan.dialog("open"); /* _AJAX( '/user/voip/did_json.php', 'data[req]=did_info&data[did]=' + dT[0], function(data, code, message) { if (code == 1) { $('#ed_did').val(data.did); $('#ed_didLabel').text(data.did); $('#ed_cidOut').val(data.caller_id); $('#ed_recordCalls').val(data.rec_in).change(); $('#ed_dstBox').val(data.exten).change(); } else alert(message); } ); */ }); /* Edit DID Functions */ edit_dial_plan = $("#dialog-edit-dial_plan").dialog({ autoOpen: false, height: 750, width: 750, modal: true, buttons: { "Save": editDP, "Save & Close": editDID, Cancel: function() { edit_dial_plan.dialog("close"); } }, close: function() { edit_did_form[0].reset(); } }); edit_did_form = $("#edit_did_form" ).on("submit", function( event ) { event.preventDefault(); }); function editDID() { _AJAX( '/user/voip/did_json.php', edit_did_form.serialize(), function(data, code, message) { if (code == 1) { DDT.fnClearTable(); _AJAX( '/user/voip/did_json.php', 'data[req]=did_list', function(data, code, message) { if (code == 1) DDT.fnAddData(data); } ); edit_did.dialog("close"); } else alert(message); } ); return; } function editDP() { } }); function _start() { var data; /* Get Initial DID Data */ data = _AJAX( '/user/voip/dial_plan_json.php', 'data[req]=dial_plan_list', function(data, code, message) { if (code == 1) DDT.fnAddData(data); else alert(message); } ); }