diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 6ed1c82..b8d37e5 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -8,12 +8,18 @@ // https://github.com/chan-sccp/chan-sccp/wiki/Conferencing // https://github.com/chan-sccp/chan-sccp/wiki/Frequently-Asked-Questions // http://chan-sccp-b.sourceforge.net/doc/_howto.xhtml#nf_adhoc_plar -/* +// https://www.cisco.com/c/en/us/td/docs/voice_ip_comm/cuipph/all_models/xsi/9-1-1/CUIP_BK_P82B3B16_00_phones-services-application-development-notes/CUIP_BK_P82B3B16_00_phones-services-application-development-notes_chapter_011.html +// https://www.cisco.com/c/en/us/td/docs/voice_ip_comm/cuipph/7960g_7940g/sip/4_4/english/administration/guide/ver4_4/sipins44.html +/* * ToDo: * + Cisco Format Mac * + Model Information * + Device Right Menu - * - WiFi Config + * + Dial Templates + Configuration + * + Dial Templates in Global Configuration ( Enabled / Disabled ; default templet ) + * ? Dial Templates - Hoto IT Include in XML.Config ??????? + * - Dial Templates in device Configuration ( Enabled / inheret / Disabled ; templet ) + * - WiFi Config (Bulk Deployment Utility for Cisco 7921, 7925, 7926)????? * - suport kvstore ????? * - Shared Line ???? * - bug Fix @@ -32,7 +38,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { // const General - default.xml = '10'; // const General - system_path = '2'; // const General - don't store = '99'; - + private $SCCP_LANG_DICTIONARY = 'SCCP-dictionary.xml'; // CISCO LANG file search in /tftp-path private $pagedata = null; private $tftpLang = array(); @@ -117,9 +123,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $this->FreePBX = $freepbx; $this->db = $freepbx->Database; $this->cnf_wr = \FreePBX::WriteConfig(); - $this->cnf_read =\FreePBX::LoadConfig(); - - + $this->cnf_read = \FreePBX::LoadConfig(); + + $this->v = new \Respect\Validation\Validator(); $this->getSccpSettingsDB(false); // Overwrite Exist @@ -127,7 +133,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $this->init_sccp_path(); $this->initVarfromDefs(); $this->initTftpLang(); - + // Load Advanced Form Constuctor Data if (file_exists(__DIR__ . '/views/sccpgeneral.xml')) { @@ -201,7 +207,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } } - if ($child['type'] == 'IS' || $child['type'] == 'IED' ) { + if ($child['type'] == 'IS' || $child['type'] == 'IED') { if (empty($child->value)) { $datav = (string) $child->default; } else { @@ -212,7 +218,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { // $this->sccpvalues[] = array('keyword' => (string)$child->name, 'data' =>(string)$child-> default,'type'=>'0'); } } - if ($child['type'] == 'SLD' || $child['type'] == 'SLS' || $child['type'] == 'SLT' || $child['type'] == 'SL' || $child['type'] == 'SLM' || $child['type'] == 'SLZ' || $child['type'] == 'SLZN') { + if ($child['type'] == 'SLD' || $child['type'] == 'SLS' || $child['type'] == 'SLT' || $child['type'] == 'SL' || $child['type'] == 'SLM' || $child['type'] == 'SLZ' || $child['type'] == 'SLZN' || $child['type'] == 'SLA') { if (empty($child->value)) { $datav = (string) $child->default; } else { @@ -251,6 +257,31 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { public function getActionBar($request) { $buttons = array(); switch ($request['display']) { + case 'sccp_adv': + if (empty($request['tech_hardware'])) { + break; + } + $buttons = array( + 'submit' => array( + 'name' => 'ajaxsubmit', + 'id' => 'ajaxsubmit', + 'value' => _("Save") + ), + 'Save' => array( + 'name' => 'ajaxsubmit2', + 'id' => 'ajaxsubmit2', + 'stayonpage' => 'yes', + 'value' => _("Save + Continue") + ), + 'cancel' => array( + 'name' => 'cancel', + 'id' => 'ajaxcancel', + 'data-search' => '?display=sccp_adv', + 'data-hash' => 'sccpdialplan', + 'value' => _("Cancel") + ), + ); + break; case 'sccp_phone': if (empty($request['tech_hardware'])) { break; @@ -326,14 +357,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { "name" => _("SCCP Codec"), "page" => 'views/server.codec.php' ), - "sccpkeyset" => array( - "name" => _("SCCP Device Keyset"), - "page" => 'views/server.keyset.php' - ), - "sccpmodels" => array( - "name" => _("SCCP Model information"), - "page" => 'views/server.model.php' - ) ); foreach ($this->pagedata as &$page) { @@ -347,6 +370,50 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $this->pagedata; } + public function AdvServerShowPage() { + $request = $_REQUEST; + $action = !empty($request['action']) ? $request['action'] : ''; + $inputform = !empty($request['tech_hardware']) ? $request['tech_hardware'] : ''; + +// print_r($inputform); + if (empty($this->pagedata)) { + switch ($inputform) { + case dialplan: + $this->pagedata = array( + "general" => array( + "name" => _("SCCP Dial Plan information"), + "page" => 'views/form.dptemplet.php' + ) + ); + break; + default: + $this->pagedata = array( + "general" => array( + "name" => _("SCCP Model information"), + "page" => 'views/server.model.php' + ), + "sccpkeyset" => array( + "name" => _("SCCP Device Keyset"), + "page" => 'views/server.keyset.php' + ), +// "sccpdialplan" => array( +// "name" => _("SCCP Dial Plan information"), +// "page" => 'views/server.dialtemplet.php' +// ) + ); + break; + } + foreach ($this->pagedata as &$page) { + ob_start(); + include($page['page']); + $page['content'] = ob_get_contents(); + ob_end_clean(); + } + } + + return $this->pagedata; + } + public function PhoneShowPage() { $request = $_REQUEST; $action = !empty($request['action']) ? $request['action'] : ''; @@ -427,22 +494,25 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $this->pagedata; } + public function getRightNav($request) { - if(isset($request['tech_hardware']) && ($request['tech_hardware'] == 'cisco')) { - return load_view(__DIR__."/views/hardware.rnav.php",array('request' => $request)); - } + if (isset($request['tech_hardware']) && ($request['tech_hardware'] == 'cisco')) { + return load_view(__DIR__ . "/views/hardware.rnav.php", array('request' => $request)); + } } - + public function ajaxRequest($req, &$setting) { switch ($req) { case 'savesettings': case "save_hardware": + case "save_dp_templet": case "delete_hardware": case "getPhoneGrid": case "getExtensionGrid": case "getDeviceModel": case "getUserGrid": case "getSoftKey": + case "getDialTemplete": case "create_hw_tftp": case "reset_dev": case "model_enabled": @@ -452,6 +522,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { case "model_delete": case "updateSoftKey": case "deleteSoftKey": + case "delete_dialplan": return true; break; } @@ -481,6 +552,23 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $this->save_hw_phone($request); + break; + case "save_dp_templet": + $res = $this->save_DialPlant($request); + if (empty($res)) { + return array('status' => true, 'search' => '?display=sccp_adv', 'hash' => 'sccpdialplan'); + } else { + return array('status' => false, 'message' => print_r($res)); + } + break; + case "delete_dialplan": + if (!empty($request['dialplan'])) { + $get_file = $request['dialplan']; + $res = $this->del_DialPlant($get_file); + return array('status' => true, 'message' => 'Dial Templet is Delete ! ', 'table_reload'=>true); + } else { + return array('status' => false, 'message' => print_r($res)); + } break; case 'delete_hardware': if (!empty($request['idn'])) { @@ -659,6 +747,15 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } return $result; break; + + case "getDialTemplete": + $result = $this->get_DP_list(); + if (empty($result)) { + $result = array(); + } + return $result; + break; + } } @@ -673,16 +770,15 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { * * Save Hardware Device Information to Db + ???? Create / update XML Profile * */ - function save_hw_phone($get_settings, $validateonly = false) { $hdr_prefix = 'sccp_hw_'; $save_buttons = array(); $save_settings = array(); $save_codec = array(); - $def_feature = array('parkinglot' => array('name'=>'P.slot','value' => 'default'), - 'devstate' => array('name'=> 'Coffee', 'value' => 'coffee'), - 'monitor' => array('name'=>'Record Calls', 'value'=>'') - ); + $def_feature = array('parkinglot' => array('name' => 'P.slot', 'value' => 'default'), + 'devstate' => array('name' => 'Coffee', 'value' => 'coffee'), + 'monitor' => array('name' => 'Record Calls', 'value' => '') + ); $name_dev = ''; $db_field = $this->get_db_SccpTableData("get_colums_sccpdevice"); $hw_id = (empty($get_settings['sccp_deviceid'])) ? 'new' : $get_settings['sccp_deviceid']; @@ -696,9 +792,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $value = $get_settings[$hdr_prefix . $key . '_net'] . '/' . $get_settings[$hdr_prefix . $key . '_mask']; break; case 'name': - if (!empty($get_settings[$hdr_prefix . 'mac'])) { + if (!empty($get_settings[$hdr_prefix . 'mac'])) { $value = $get_settings[$hdr_prefix . 'mac']; - $value = 'SEP' . strtoupper(str_replace(array('.','-',':'),'',$value)); // Delete mac Seporated from string + $value = 'SEP' . strtoupper(str_replace(array('.', '-', ':'), '', $value)); // Delete mac Seporated from string $name_dev = $value; } break; @@ -753,18 +849,18 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $btn_opt = $btn_f; if (!empty($def_feature[$btn_f]['value'])) { if (empty($get_settings['button' . $it . '_fvalue'])) { - $btn_opt .= ','.$def_feature[$btn_f]['value']; + $btn_opt .= ',' . $def_feature[$btn_f]['value']; } else { - $btn_opt .= ','.$get_settings['button' . $it . '_fvalue']; + $btn_opt .= ',' . $get_settings['button' . $it . '_fvalue']; } - } + } break; case 'monitor': $btn_t = 'speeddial'; $btn_opt = (string) $get_settings['button' . $it . '_line']; - $db_res = $this->get_db_SccpTableData('SccpExtension',array('id'=>$btn_opt)); + $db_res = $this->get_db_SccpTableData('SccpExtension', array('id' => $btn_opt)); $btn_n = $db_res[0]['label']; - $btn_opt .= ',' . $btn_opt. $this->hint_context; + $btn_opt .= ',' . $btn_opt . $this->hint_context; break; case 'speeddial': if (!empty($get_settings['button' . $it . '_input'])) { @@ -814,7 +910,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $this->sccp_create_device_XML($name_dev); // sccp restart // $this->sccp_core_comands(array('cmd'=>'reset_phone', 'name' => $name_dev)); - $this->sccp_core_comands(array('cmd'=>'reload_phone', 'name' => $name_dev)); + $this->sccp_core_comands(array('cmd' => 'reload_phone', 'name' => $name_dev)); // die(); return $save_settings; } @@ -844,21 +940,20 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $arr_data = ''; if (!empty($this->sccpvalues[$key1])) { foreach ($value as $vkey => $vval) { - $tmp_data =''; + $tmp_data = ''; foreach ($vval as $vkey => $vval) { - $tmp_data .= $vval. '/'; - } - if (strlen($tmp_data)>2){ - $arr_data .= substr($tmp_data,0,-1).';'; + $tmp_data .= $vval . '/'; + } + if (strlen($tmp_data) > 2) { + $arr_data .= substr($tmp_data, 0, -1) . ';'; } } - $arr_data = substr($arr_data,0,-1); + $arr_data = substr($arr_data, 0, -1); if (!($this->sccpvalues[$key1]['data'] == $arr_data)) { $save_settings[] = array('keyword' => $this->sccpvalues[$key1]['keyword'], 'data' => $arr_data, 'seq' => $this->sccpvalues[$key1]['seq'], 'type' => $this->sccpvalues[$key1]['type']); } } - } switch ($key) { case 'voicecodecs': @@ -1014,17 +1109,17 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $line_arr = explode(' ', $line); $it = 1; do { - if (strpos($line_arr[$it + 1],'SEP') === false) { - $line_arr[0] .= ' '.$line_arr[$it]; + if (strpos($line_arr[$it + 1], 'SEP') === false) { + $line_arr[0] .= ' ' . $line_arr[$it]; unset($line_arr[$it]); } else { break; } - $it++; - } while ((count($line_arr)> 3) and ($it 3) and ( $it < count($line_arr))); + explode(";|", implode(";|", $line_arr)); + list ($descr, $adress, $devname, $status, $junk) = explode(";|", implode(";|", $line_arr)); + // list ($descr, $adress, $devname, $status, $junk) = $line_arr; if (isset($ast_key[$devname])) { @@ -1401,6 +1496,15 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } } + if (!empty($this->sccppath["tftp_path"])) { + $this->sccppath["tftp_DP"] = $this->sccppath["tftp_path"] . '/Dialplan'; + if (!file_exists($this->sccppath["tftp_DP"])) { + if (!mkdir($this->sccppath["tftp_DP"], 0777, true)) { + die('Error create DialPlan templet dir'); + } + } + } + if (empty($_SERVER['DOCUMENT_ROOT'])) { return; } @@ -1425,10 +1529,99 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } $this->sccp_conf_init = $this->cnf_read->getConfig('sccp.conf'); - + // $this->sccp_conf_init = @parse_ini_file($this->sccppath["sccp_conf"], true); } + /* + * + * + */ + + + function get_DP_list() { + $dir = $this->sccppath["tftp_DP"].'/*.xml'; + $base_len = strlen($this->sccppath["tftp_DP"])+ 1; + $res = glob($dir); + $dp_list = array(); + foreach ($res as $key => $value) { + $res[$key] = array('id'=> substr($value,$base_len,-4), 'file' => substr($value,$base_len)); + } + + return $res; + } + + function get_DialPlant($get_file) { + $file = $this->sccppath["tftp_DP"].'/'.$get_file.'.xml'; + if (file_exists($file)) { +// $load_xml_data = simplexml_load_file($file); + + $fileContents= file_get_contents($file); + $fileContents = str_replace(array("\n", "\r", "\t"), '', $fileContents); + $fileContents = trim(str_replace('"', "'", $fileContents)); + $fileContents = strtolower($fileContents); + $res = (array) simplexml_load_string($fileContents); + } + return $res; + } + + function del_DialPlant($get_file) { + if (!empty($get_file)) { + $file = $this->sccppath["tftp_DP"].'/'.$get_file.'.xml'; + if (file_exists($file)) { + $res = unlink($file); + } + } + return $res; + } + + + function save_DialPlant($get_settings) { + $xmlstr = "\n"; + $dialFelds = array('match','timeout','rewrite','tone'); //str -to lo ! + + $hdr_prefix = 'sccp_dial_'; + $hdr_arprefix = 'sccp_dial-ar_'; + $save_data = array(); + $integer_msg = _("%s must be a non-negative integer"); + $errors = array(); + foreach ($get_settings[$hdr_arprefix.'dialtemplete'] as $key => $value) { + $xmlstr .= 'sccppath["tftp_DP"].'/'.$put_file.'.xml'; + file_put_contents($file, $xmlstr); + } + + return $errors; + } + /* * Save Config Value to mysql DB * sccp_db_save_setting(empty) - Save All settings from $sccpvalues @@ -1719,18 +1912,18 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $xml_work->$key = $var_hw_config["loadimage"]; if (!empty($var_hw_config['addon'])) { $hw_addon = explode(',', $var_hw_config['addon']); - $xnode = $xml_work -> addChild('addOnModules'); + $xnode = $xml_work->addChild('addOnModules'); $ti = 1; - foreach ($hw_addon as $key ) { - $hw_inf = $this-> getSccp_model_information('byid',false, "all",array('model'=>$key )); - $xnode_obj = $xnode -> addChild('addOnModule'); + foreach ($hw_addon as $key) { + $hw_inf = $this->getSccp_model_information('byid', false, "all", array('model' => $key)); + $xnode_obj = $xnode->addChild('addOnModule'); // if $hw_inf['loadimage'] - $xnode_obj -> addAttribute('idx', $ti); - $xnode_obj -> addChild('loadInformation',$hw_inf[0]['loadimage']); + $xnode_obj->addAttribute('idx', $ti); + $xnode_obj->addChild('loadInformation', $hw_inf[0]['loadimage']); $ti ++; } // $this->appendSimpleXmlNode($xml_work , $xnode_obj); - } + } break; case 'userLocale': case 'networkLocaleInfo': @@ -1739,14 +1932,14 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { if (!empty($var_hw_config["hwlang"])) { $hwlang = explode(':', $var_hw_config["hwlang"]); } - if (($key == 'networkLocaleInfo') || ($key == 'networkLocale') ){ + if (($key == 'networkLocaleInfo') || ($key == 'networkLocale')) { // $lang=$this->sccpvalues['netlang']['data']; $lang = (empty($hwlang[0])) ? $this->sccpvalues['netlang']['data'] : $hwlang[0]; } else { $lang = (empty($hwlang[1])) ? $this->sccpvalues['devlang']['data'] : $hwlang[1]; // $lang=$this->sccpvalues['devlang']['data']; } - if ($key == 'networkLocale'){ + if ($key == 'networkLocale') { $xml_work->$key = $lang; } else { $xml_node->name = $this->sccp_lang[$lang]['locale']; @@ -1794,7 +1987,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { case "tftp_path": break; default: - $this->sccp_conf_init['general'][$key] = $value['data']; + $this->sccp_conf_init['general'][$key] = $value['data']; } } } @@ -1820,8 +2013,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $sql = "SELECT * FROM `sccpline` ORDER BY `id`"; $raw_settings = sql($sql, "getAll", DB_FETCHMODE_ASSOC); } else { - $sql = "SELECT * FROM `sccpline` WHERE `id`=".$data['id']; - $raw_settings = sql($sql, "getAll", DB_FETCHMODE_ASSOC); + $sql = "SELECT * FROM `sccpline` WHERE `id`=" . $data['id']; + $raw_settings = sql($sql, "getAll", DB_FETCHMODE_ASSOC); } break; case "SccpDevice": @@ -1877,7 +2070,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { function getSccp_model_information($get = "all", $validate = false, $format_list = "all", $filter = array()) { global $db; - $file_ext = array('.loads','.LOADS','.sbn','.SBN','.bin','.BIN'); + $file_ext = array('.loads', '.LOADS', '.sbn', '.SBN', '.bin', '.BIN'); $dir = $this->sccppath["tftp_path"]; $dir_tepl = $this->sccppath["tftp_templets"]; @@ -1898,7 +2091,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { case "byid": if (!empty($filter)) { if (!empty($filter['model'])) { - $sql = "SELECT " . $sel_inf . " FROM sccpdevmodel WHERE (`model` =".$filter['model'].") ORDER BY model "; + $sql = "SELECT " . $sel_inf . " FROM sccpdevmodel WHERE (`model` =" . $filter['model'] . ") ORDER BY model "; } else { // $sql = "SELECT ".$filter['model']; $sql = "SELECT " . $sel_inf . " FROM sccpdevmodel ORDER BY model "; @@ -1907,7 +2100,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } break; case "extension": - $sql = "SELECT " . $sel_inf . " FROM sccpdevmodel WHERE (dns = 0)ORDER BY model "; + $sql = "SELECT " . $sel_inf . " FROM sccpdevmodel WHERE (dns = 0)ORDER BY model "; break; case "enabled": case "phones": @@ -1926,15 +2119,15 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $raw_settings[$i]['validate'] = '-;-'; if (!empty($raw_settings[$i]['loadimage'])) { $file = $dir . '/' . $raw_settings[$i]['loadimage']; - if (is_dir($file)){ + if (is_dir($file)) { $file .= '/' . $raw_settings[$i]['loadimage']; } $raw_settings[$i]['validate'] = 'no;'; - if (strtolower($raw_settings[$i]['vendor']) == 'cisco') { + if (strtolower($raw_settings[$i]['vendor']) == 'cisco') { foreach ($file_ext as $value) { - if (file_exists($file.$value)) { + if (file_exists($file . $value)) { $raw_settings[$i]['validate'] = 'yes;'; - break; + break; } } } else { @@ -1955,7 +2148,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } else { $raw_settings[$i]['validate'] .= '-'; } - } } return $raw_settings; diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 30e6108..67a55ba 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -33,6 +33,10 @@ $(document).ready(function () { if ($('.fpbx-submit').data('id') == "hw_edit") { snd_command = 'save_hardware'; } + if ($('.fpbx-submit').data('id') == "dial_templet") { + snd_command = 'save_dp_templet'; + } + $.ajax({ type: 'POST', url: 'ajax.php?module=sccp_manager&command=' + snd_command, @@ -64,6 +68,9 @@ $(document).ready(function () { if ($('.fpbx-submit').data('id') == "hw_edit") { snd_command = 'save_hardware'; } + if ($('.fpbx-submit').data('id') == "dial_templet") { + snd_command = 'save_dp_templet'; + } $.ajax({ type: 'POST', url: 'ajax.php?module=sccp_manager&command=' + snd_command, @@ -107,6 +114,73 @@ $(document).ready(function () { add_dynamic_input($(this),$(this).data('for'),"",""); }); + $(".table").on('click','.table-js-add', function (e) { + add_dynamic_table($(this),$(this).data('for'),"",""); + }); + + $(".table").on('click','.table-js-del', function (e) { + del_dynamic_table($(this),$(this).data('for')); + }); + + + $(".table").on('click','.btn-item-delete', function (e) { + var dev_cmd = ''; + var dev_id = $(this).data('id'); + var dev_for = $(this).data('for'); + var ext_data = ''; + if (dev_for =='softkeys') { + dev_cmd = 'deleteSoftKey'; + ext_data = "softkey=" + dev_id; + } + if (dev_for =='model') { + dev_cmd = 'model_delete'; + ext_data = "model=" + dev_id; + } + if (dev_for =='dialplan') { + dev_cmd = 'delete_dialplan'; + ext_data = "dialplan=" + dev_id; + } + if (dev_for =='hardware') { + dev_cmd = 'delete_hardware'; + ext_data = "idn[0]=" + dev_id; + } +// console.log("delete : " + data); + if (dev_cmd != '') { + if (confirm(_('Are you sure you wish to delete "' + dev_id.toString().toUpperCase() + '" inormation ?'))) { + $.ajax({ + type: 'POST', + url: 'ajax.php?module=sccp_manager&command=' + dev_cmd, + command: dev_cmd, + data: ext_data, + success: function (data) { +// console.log(data); + if (data.status === true) { + if (data.message) { + alert(data.message); + } + if (data.table_reload === true) { + $('table').bootstrapTable('refresh'); + } + if (data.reload === true) { + location.reload(); + } + } else { + if (Array.isArray(data.message)) { + data.message.forEach(function (entry) { + fpbxToast(entry, 'error', 'error'); + }); + } + } + } + + }); + } + } + + }); + + + // ----------------------- Server.model.Button.Select---------------- $('.dropdown-menu a.dropitem').on("click", function (e) { @@ -448,11 +522,13 @@ $("table").on('uncheck-all.bs.table', function (rows) { }); // +// On table Click !!!!!! $("table").on("post-body.bs.table", function () { // console.log('Table '); +// delete extension $(this).find(".clickable.delete").click(function () { var id = $(this).data("id"); -// console.log(id); + if (confirm(_("Are you sure you wish to delete this extension?"))) { $.post("ajax.php", {command: "delete", module: "core", extensions: [id], type: "extensions"}, function (data) { if (data.status) { @@ -469,6 +545,7 @@ $("table").on("post-body.bs.table", function () { } }); }); + function load_oncliсk(e, data) { // console.log('load_oncliсk'); @@ -526,51 +603,7 @@ function load_oncliсk(e, data) { } } -function delete_oncliсk(e, data) { - var dev_cmd = ''; - var datas = ''; - if (e.href.indexOf('#delete_softkeys') > 0) { - dev_cmd = 'deleteSoftKey'; - datas = "softkey=" + data; - } - if (e.href.indexOf('#delete_model') > 0) { - dev_cmd = 'model_delete'; - datas = "model=" + data; - } - if (e.href.indexOf('#delete_hardware') > 0) { - dev_cmd = 'delete_hardware'; - datas = "idn[0]=" + data; - } -// console.log("delete : " + data); - if (confirm(_('Are you sure you wish to delete "' + data.toUpperCase() + '" inormation ?'))) { - $.ajax({ - type: 'POST', - url: 'ajax.php?module=sccp_manager&command=' + dev_cmd, - data: datas, - success: function (data) { -// console.log(data); - if (data.status === true) { - if (data.message) { - alert(data.message); - } - if (data.table_reload === true) { - $('table').bootstrapTable('refresh'); - } - if (data.reload === true) { - location.reload(); - } - } else { - if (Array.isArray(data.message)) { - data.message.forEach(function (entry) { - fpbxToast(entry, 'error', 'error'); - }); - } - } - } - }); - } -} function add_dynamic_input(pe, pclass, vdefault) { // We'd like a new one, please. pcls = pe.data('for'); @@ -594,6 +627,80 @@ function add_dynamic_input(pe, pclass, vdefault) { last.after(html); } +function del_dynamic_table(pe, pclass, vdefault) { + pcls = pe.data('for'); + pname = pe.data('id'); + +// pe.preventDefault(); + var rowCount = $('#dp-table-'+pcls+'>tbody >tr').length; + curRow =$('#'+pcls+'-row-'+ pname); + var curRow = pe.closest('tr'); + if(rowCount > 1){ + curRow.fadeOut("slow", function(){ + $(this).remove(); + }); + }else{ + curRow.find('input:text').each(function(){$(this).val('')}); + } +} + +function add_dynamic_table(pe, pclass, vdefault) { + // We'd like a new one, please. + pcls = pe.data('for'); + pname = pe.data('id'); + jdata = JSON.parse(hex2bin(pe.data('json'))); + + var last = $("."+pcls+":last"), + ourid = last.data('nextid'), + nextid = ourid + 1; + var html = ""; + for (var key in jdata) { + html_opt = ''; + res_ni = pcls + '_' + nextid + '_' + key; + res_n = pcls + '[' + nextid + '][' + key + ']'; + for (var skey in jdata[key]['options']) { + html_opt += ' ' + skey+'="' + jdata[key]['options'][skey] +'"'; + } + var html_rs = '
' + jdata[key]['display_prefix'] + ''; + var html_re = '' + jdata[key]['display_sufix'] + '
'; + + html += ''; + switch (jdata[key]['type']) { + case "title": + break; + case "label": + html +=''; + break; + case "input": + html += html_rs + '' +html_re ; + break; + case "number": + html += html_rs + '' +html_re ; + break; + case "date": + html += html_rs + '' +html_re ; + break; + case "select": + html += html_rs + ''+ html_re; + break; + } + html += ''; + } + html += ''; + html += ''; + +// html += ''; + + html += "\n"; + + last.after(html); +} + var theForm = document.editIax; /* Insert a iax_setting/iax_value pair of text boxes */ (function ($) { diff --git a/module.xml b/module.xml index cb592c6..561425a 100644 --- a/module.xml +++ b/module.xml @@ -7,8 +7,9 @@ Alex GP SCCP Phone and Extention Manager - SCCP Server Config - SCCP Phones Manager + Server Config + System Parameters + Phones Manager * Version 13.0.0.1 * - Alfa Release tested on freepbx v.13.0.192.16, v.14.0.1.5 diff --git a/page.sccp_adv.php b/page.sccp_adv.php new file mode 100644 index 0000000..4d5e4aa --- /dev/null +++ b/page.sccp_adv.php @@ -0,0 +1,49 @@ +Sccp_manager; +$display_page = $spage->AdvServerShowPage(); +$display_info = _("SCCP Advance Server Configuration"); + +?> + +
+

+
+
+
+
+ +
+ $page) { ?> +
+ +
+ +
+
+
+
+
+
\ No newline at end of file diff --git a/views/form.dptemplet.php b/views/form.dptemplet.php new file mode 100644 index 0000000..e5984e9 --- /dev/null +++ b/views/form.dptemplet.php @@ -0,0 +1,80 @@ +get_DialPlant('dialplan'); +//print_r($list_data); +//$dialFelds = array('match','timeout','line','rewrite','tone'); +//$dialFelds = array('match','timeout','User','rewrite','tone'); +$dialFelds = array('match','timeout','rewrite','tone'); +$dev_id = '*new*'; +if (!empty($_REQUEST['extdisplay'])) { + $dev_id = $_REQUEST['extdisplay']; +} +if ($dev_id != '*new*') { + $list_data= $this->get_DialPlant($dev_id ); + $data_s= ''; + foreach ($list_data['template'] as $key => $value) { + foreach ($dialFelds as $fld) { + if (isset($value[$fld])) { + $data_s .=(string)$value[$fld]; + } + $data_s .= '/'; + } + $data_s = substr($data_s, 0, -1); + $data_s .= ';'; + } + $data_s = substr($data_s, 0, -1); + $def_val['dialtemplete'] = array("keyword" => 'dialtemplete', "data" => $data_s, "seq" => "99"); +} + +?> + + +
+ + + + ShowGroup('sccp_dp_new_templet',0,'sccp_dial',$def_val); + } + ?> + +
+
+ +
+
+

+

+ + + + + + + + + + + + + + + + +
0 1 2 3 4 5 6 7 8 9
.
*
\*
,
0 1 2 3 4 5 6 7 8 9
%0
%1 %2 %3 %4 %5
%%
.
+
+
+ + +ShowGroup('sccp_dp_new_templet',0,'sccp_dial',$def_val); + echo $this->ShowGroup('sccp_dp_templet',0,'sccp_dial',$def_val); +?> +
diff --git a/views/formShow.php b/views/formShow.php index 6c1c9b4..61e8486 100644 --- a/views/formShow.php +++ b/views/formShow.php @@ -2,8 +2,10 @@ /* * IE - Text Input * IED - Text Input Dynamic + * ITED- Input Dynamic Table * IS - Radio box * SL - Select element + * SLA - Select element (from - data ) * Input element Select SLD - Date format * SLZ - Time Zone * SLZN - Time Zone List @@ -157,7 +159,6 @@ foreach ($items as $child) { echo ''; ?> -
@@ -345,7 +346,7 @@ foreach ($items as $child) { * Input element Select SLS - System Language */ - if ($child['type'] == 'SLS' || $child['type'] == 'SLT') { + if ($child['type'] == 'SLS' || $child['type'] == 'SLT' || $child['type'] == 'SLA') { // $value = $child -> select; $res_n = (string)$child ->name; $res_id = $npref.$res_n; @@ -356,6 +357,21 @@ foreach ($items as $child) { if ($child['type'] == 'SLT') { $select_opt= $tftp_lang; } + + if ($child['type'] == 'SLA') { + $select_opt =''; + if (!empty($fvalues[$res_n])) { + if (!empty($fvalues[$res_n]['data'])) { + $res_value = explode(';', $fvalues[$res_n]['data']); + } + if (empty($res_value)) { + $res_value = array((string) $child->default); + } + foreach ($res_value as $key) { + $select_opt[$key]= $key; + } + } + } if (empty($child->class)) { $child->class = 'form-control'; @@ -410,7 +426,6 @@ foreach ($items as $child) { echo ''; ?> -
@@ -445,7 +460,6 @@ foreach ($items as $child) { help);?>
- label.' -->'; } @@ -517,6 +531,112 @@ foreach ($items as $child) { echo ''; } + if ($child['type'] == 'ITED') { + $res_input = ''; + $res_name = ''; + $res_na = (string)$child->name; + +// $res_value + $lnhtm = ''; + $res_id = $napref.$child->name; + $i = 0; + + if (!empty($fvalues[$res_na])) { + if (!empty($fvalues[$res_na]['data'])) { + $res_value = explode(';', $fvalues[$res_na]['data']); + } + } + if (empty($res_value)) { + $res_value = array((string) $child->default); +// $res_value = explode('/', (string) $child->default); + } + + echo ''; + ?> + + + '; + if (!empty($child->label)) { + echo ''; + } + + $res_vf = explode('/', $dat_v); + $i2 = 0; + + foreach ($child->xpath('element') as $value) { + $fields_id = (string)strtolower($value['field']); + $res_n = $res_id.'['.$i.']['.$fields_id.']'; + $res_ni = $res_id.'_'.$i.'_'.$fields_id; + + $opt_at[$fields_id]['display_prefix']=(string)$value['display_prefix']; + $opt_at[$fields_id]['display_sufix']=(string)$value['display_sufix']; + + if (empty($value->options->class)) { + $opt_at[$fields_id]['options']['class']='form-control'; + } + $opt_at[$fields_id]['type']=(string)$value['type']; + $res_opt['addon'] =''; + if (isset($value->options)){ + foreach ($value->options ->attributes() as $optkey =>$optval){ + $opt_at[$fields_id]['options'][$optkey]=(string)$optval; + $res_opt['addon'] .=' '.$optkey.'="'.$optval.'"'; + } + } + + echo ''; + $i2 ++; + + } + echo ''; + $i++; + } + echo '
'.$child->label.'
'; + $res_opt['inp_st'] = '
'.$opt_at[$fields_id]['display_prefix'].''; + $res_opt['inp_end'] = ''.$opt_at[$fields_id]['display_sufix'].'
'; + switch ($value['type']){ + case 'date': + echo $res_opt['inp_st'].''.$res_opt['inp_end']; + break; + case 'number': + echo $res_opt['inp_st'].''.$res_opt['inp_end']; + break; + case 'input': + echo $res_opt['inp_st'].''.$res_opt['inp_end']; + break; + case 'title': + if ($i > 0 ) { + break; + } + case 'label': + $opt_at[$fields_id]['data'] = (string)$value; + echo ''; + break; + case 'select': + echo $res_opt['inp_st'].''.$res_opt['inp_end']; + break; + } + echo '
'; + if ($i > 0 ) { + echo ''; + } + + echo '
'; + echo ''; + + } + } ?> diff --git a/views/hardware.phone.php b/views/hardware.phone.php index f1cb060..7f87438 100644 --- a/views/hardware.phone.php +++ b/views/hardware.phone.php @@ -48,9 +48,9 @@ function DispayDeviceActionsKeyFormatter(value, row, index) { var exp_model = ''; exp_model += '    \n'; - exp_model += ''; + exp_model += '  '; return exp_model; - } +} function LineFormatter(value, row, index) { var data = value.split(";"); diff --git a/views/sccpgeneral.xml b/views/sccpgeneral.xml index f057dae..69c4787 100644 --- a/views/sccpgeneral.xml +++ b/views/sccpgeneral.xml @@ -453,7 +453,16 @@ and open the template in the editor. form-control Music Class: Available MOH Classes. These are the MOH classes listed in your current server. - autoselectline_enabled + + dial_templet + none + + sccp-custom + Help. + + + autoselectline_enabled + no @@ -842,5 +851,58 @@ and open the template in the editor. - + + + + dialtemplete_name + + form-control + + Help. + + + + + + + dialtemplete + */10/* + title + + + text1 + + + + empty + Bellcore-Alerting + Bellcore-Inside + Bellcore-Outside + Bellcore-Busy + Bellcore-BusyVerify + Bellcore-Reorder + Bellcore-CallWaiting + Bellcore-Hold + Bellcore-Reminder + Bellcore-Confirmation + Bellcore-Stutter + Bellcore-Permanent + Bellcore-None + Cisco-Zip + Cisco-ZipZip + Cisco-BeepBonk + Bellcore-dr1 + Bellcore-dr2 + Bellcore-dr3 + Bellcore-dr4 + Bellcore-dr5 + Bellcore-dr6 + CallWaiting-2 + CallWaiting-3 + CallWaiting-4 + + Alow network settings. Blank fields will be ignored used Network 0.0.0.0. + + + diff --git a/views/server.device.php b/views/server.device.php index e163cf0..d71dba3 100644 --- a/views/server.device.php +++ b/views/server.device.php @@ -5,6 +5,14 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ +$data = 'none;'; +foreach ($this->get_DP_list() as $value) { + $data .= $value['id'].';'; +} +if (strlen($data) >0 ){ + $data = substr ($data,0,-1); +} + $this->sccpvalues['dial_templet'] = array('keyword' => 'dial_templet', 'data' => $data, 'type' => '10', 'seq' => '90'); ?>
@@ -14,6 +22,5 @@ echo $this->ShowGroup('sccp_dev_config',1); echo $this->ShowGroup('sccp_dev_url',1); echo $this->ShowGroup('sccp_hotline_config',1); - ?>
diff --git a/views/server.dialtemplet.php b/views/server.dialtemplet.php new file mode 100644 index 0000000..e73bcba --- /dev/null +++ b/views/server.dialtemplet.php @@ -0,0 +1,42 @@ +get_DP_list()); +//print_r($this->get_DialPlant('dialplan')); +?> +
+
+
+
+

+
+   + +
+ + + + + + + + +
+
+
+
+
+ \ No newline at end of file diff --git a/views/server.keyset.php b/views/server.keyset.php index 6eb4269..2be5cea 100644 --- a/views/server.keyset.php +++ b/views/server.keyset.php @@ -164,10 +164,8 @@ $keynamearray = array('onhook' => array(sname => 'ONHOOK', name =>'Display On function DispayActionsKeyFormatter(value, row, index) { var exp_model = ''; if (row['softkeys'] !== 'default') { -// exp_model += ''; -// exp_model += ''; exp_model += ' '; - exp_model += ''; + exp_model += '  '; } return exp_model; } diff --git a/views/server.model.php b/views/server.model.php index 8221adf..55c157f 100644 --- a/views/server.model.php +++ b/views/server.model.php @@ -218,9 +218,8 @@ function DispayActionsModelFormatter(value, row, index) { var exp_model = ''; // exp_model += ''; -// exp_model += ''; exp_model += '  '; - exp_model += ''; + exp_model += '  '; return exp_model; }