diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 6e8669d..db1837d 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -1011,11 +1011,13 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $modelList; } // Here so want to see if FW and template files exist on TFTP server. + // only look in relevant column indexed by model so that returned value is ne 0 + // will be boolean false if not found - $needToCheckFw = array_search('no', array_column($modelList, 'fwfound'), true); - $needToCheckTemp = array_search('no', array_column($modelList, 'templatefound'), true); + $needToCheckFw = array_search('no', array_column($modelList, 'fwfound', 'model'), true); + $needToCheckTemp = array_search('no', array_column($modelList, 'templatefound', 'model'), true); - if (!$needToCheckFw && !$needToCheckTemp) { + if ($needToCheckFw === false && $needToCheckTemp === false) { // in modellist, all firmware shows as being available (no not found for either) return $modelList; } diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index e910db1..373d103 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -180,16 +180,7 @@ $(document).ready(function () { -// ----------------------- Server.model.Button.Select---------------- - $('.dropdown-menu a.dropitem').on("click", function (e) { - - $(this).parents('div.btn-group').find('.dropdown_capture').text($(this).text()); - //console.log($(this).data('id')); - ref_url = "ajax.php?module=sccp_manager&command=getDeviceModel&type=" + $(this).data('id'); - $('#table-models').bootstrapTable('refresh', {url: ref_url}); - }); -// --------------------------------------- // Set location.hash when changing tabs so that can return to same tab after reload. $(".change-tab").click(function(){ @@ -526,12 +517,24 @@ $(document).ready(function () { }); + // -----------------------adserver.model view Select models by status---------------- + $('.dropdown-menu a.dropitem').on("click", function (e) { + + $(this).parents('div.btn-group').find('.dropdown_capture').text($(this).text()); + //console.log($(this).data('id')); + ref_url = "ajax.php?module=sccp_manager&command=getDeviceModel&type=" + $(this).data('id'); + $('#table-models').bootstrapTable('refresh', {url: ref_url}); + $('#table-models').bootstrapTable('uncheckAll'); + $("#buttonDeviceEnable").attr('disabled', true); + $("#buttonDeviceDisable").attr('disabled', true); + }); + // --------------------------------------- $('.sccp_update').on('click', function (e) { // console.log($(this).data('id')); -// ----------------------- Server.keyset form ---------------- +// ----------------------- advserver.keyset view ---------------- // if ($(this).data('id') === 'keyset_add') { var dev_cmd = 'updateSoftKey'; @@ -558,7 +561,8 @@ $(document).ready(function () { ; } -// ----------------------- Server.model form ---------------- +// ----------------------- advserver.model view ---------------- + if ($(this).data('id') === 'model_add') { var dev_cmd = 'model_add'; // var dev_fld = ["model","vendor","dns","buttons","loadimage","loadinformationid","validate","enabled"]; @@ -608,8 +612,9 @@ $(document).ready(function () { i++; }); } - console.log(datas); + // console.log(datas); } + // Delete action button if ($(this).data('id') === 'delete_hardware') { var dev_cmd = $(this).data('id'); var datas = ''; @@ -667,16 +672,16 @@ $(document).ready(function () { url: 'ajax.php?module=sccp_manager&command=' + dev_cmd, data: datas, success: function (data) { - if (data.status === true) { if (data.table_reload === true) { - $('table').bootstrapTable('refresh'); + $('#table-models').bootstrapTable('refresh'); } if (data.message) { - fpbxToast(data.message,_('Operation Result'), 'success'); + fpbxToast(data.message,'', 'success'); if (data.reload === true) { //Need setTimout or reload will kill Toast setTimeout(function(){location.reload();},500); + $('#table-models').bootstrapTable("resetSearch",""); } } } else { @@ -782,31 +787,42 @@ $(document).ready(function () { // console.log($('#update-sccp-phone').find(':selected').data('val')); }); - +// End DOCUMENT READY ************************************************** }); - - -//$("table").on('click-cell.bs.table', function (field, value, row, $element) { -// var id_fld=$element['model']; Работает ! -// console.log('Table test: '+ id_fld); -// $('#bt'+id_fld).removeAttr('hidden'); -//}); - - // Bootstrap table Enable / Disable buttons ( class="btn-tab-select") $("table").on('check-all.bs.table', function (rows) { var id_fld = $(this).data('id'); - $(".btn-tab-select").each(function () { - $(this).removeAttr('disabled'); - }); -// console.log('Table unselect all' + id_fld); + + if (id_fld === 'model') { + var firstRow = $('#table-models').bootstrapTable('getData')[0]; + if (firstRow['enabled'] === "1") { + $("#buttonDeviceDisable").removeAttr('disabled'); + } else { + $("#buttonDeviceEnable").removeAttr('disabled'); + } + } else { + $(".btn-tab-select").each(function () { + $(this).removeAttr('disabled'); + }); + } + //console.log('Table unselect all' + id_fld); }); $("table").on('check.bs.table', function (e, row) { var id_fld = $(this).data('id'); - $(".btn-tab-select").each(function () { - $(this).removeAttr('disabled'); - }); + + if (id_fld === 'model') { + if (row['enabled'] === "1") { + $("#buttonDeviceDisable").removeAttr('disabled'); + } else if (row['enabled'] === "0") { + $("#buttonDeviceEnable").removeAttr('disabled'); + + } + } else { + $(".btn-tab-select").each(function () { + $(this).removeAttr('disabled'); + }); + } // console.log('Table select ' + id_fld); }); $("table").on('uncheck.bs.table', function (e, row) { @@ -819,7 +835,7 @@ $("table").on('uncheck.bs.table', function (e, row) { $(this).attr('disabled', true); }); } -// console.log('Table unselect ' + id_count); +// console.log('Table unselect ' + id_fld + id_count); }); $("table").on('uncheck-all.bs.table', function (rows) { var id_fld = $(this).data('id'); diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index e847bf1..0c564da 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -228,7 +228,7 @@ class dbinterface $stmtU->execute(); return $stmtU->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE); break; - case 'extension': + case 'expansion': $stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel WHERE (dns = 0) and (enabled = 1) ORDER BY model"); break; case 'enabled': @@ -237,6 +237,9 @@ class dbinterface case 'phones': $stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel WHERE (dns != 0) and (enabled = 1) ORDER BY model"); break; + case 'disabled': + $stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel WHERE (dns != 0) and (enabled = 0) ORDER BY model"); + break; case 'ciscophones': $stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) AND RIGHT(vendor,4) != '-sip' ORDER BY model"); break; diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index e6ba24d..e7a7f7f 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -207,7 +207,7 @@ trait ajaxHelper { $this->dbinterface->write('sccpdevmodel', array('model' => $idv, 'enabled' => $model_set), 'update', "model"); } } - return array('status' => true, 'table_reload' => true); + return array('status' => true, 'reload' => true , 'message' => ($model_set) ? "Devices Enabled" : "Devices Disabled"); break; case 'model_delete': if (!empty($request['model'])) { @@ -217,8 +217,8 @@ trait ajaxHelper { break; case 'getDeviceModel': switch ($request['type']) { - case 'all': - case 'extension': + case 'disabled': + case 'expansion': case 'enabled': $devices = $this->getSccpModelInformation($request['type'], $validate = true); break; diff --git a/sccpManTraits/bmoFunctions.php b/sccpManTraits/bmoFunctions.php index d2f7b49..c9a6486 100644 --- a/sccpManTraits/bmoFunctions.php +++ b/sccpManTraits/bmoFunctions.php @@ -72,10 +72,10 @@ trait bmoFunctions { } $dev_schema = $this->getSccpModelInformation('byciscoid', false, "all", array('model' => $dev_data['SCCP_Vendor']['model_id'])); if (empty($dev_schema)) { - $dev_schema[0]['model'] = "Model ${dev_data['SCCP_Vendor']['model_id']} not found in model Database"; - } else if ( $dev_schema[0]['enabled' == 0]) { + $dev_schema[0]['model'] = "Model {$dev_data['SCCP_Vendor']['model_id']} not found in model Database"; + } else if ( $dev_schema[0]['enabled'] == 0) { // Need to enable this model in phone types - $this->dbinterface->write('sccpdevmodel', array('model'=> $dev_data['SCCP_Vendor']['model_id'], 'enabled = 1'), 'update' , 'model'); + $this->dbinterface->write('sccpdevmodel', array('model'=> $dev_data['SCCP_Vendor']['model_id'], 'enabled' => 1), 'update' , 'model'); } $dbDevices[] = array( diff --git a/views/advserver.keyset.php b/views/advserver.keyset.php index 862146a..7d1f701 100644 --- a/views/advserver.keyset.php +++ b/views/advserver.keyset.php @@ -84,7 +84,9 @@ $keynamearray = array('onhook' => array('sname' => 'ONHOOK', 'name' =>'Displa