diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php
index 5140b24..22a1465 100644
--- a/Sccp_manager.class.php
+++ b/Sccp_manager.class.php
@@ -383,6 +383,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
function getPhoneButtons($get_settings, $ref_id = '', $ref_type = 'sccpdevice') {
// get Model Buttons info
+ dbug($get_settings);
$res = array();
$def_feature = array('parkinglot' => array('name' => 'P.slot', 'value' => 'default'),
'devstate' => array('name' => 'Coffee', 'value' => 'coffee'),
@@ -489,10 +490,11 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
break;
}
if (!empty($btn_t)) {
- $res[] = array('ref' => $ref_id, 'reftype' => $ref_type, 'instance' => (string) ($it + 1), 'type' => $btn_t, 'name' => $btn_n, 'options' => $btn_opt);
+ $res[] = array('ref' => $ref_id, 'reftype' => $ref_type, 'instance' => (string) ($it + 1), 'buttontype' => $btn_t, 'name' => $btn_n, 'options' => $btn_opt);
}
}
}
+ dbug($res);
return $res;
}
@@ -796,7 +798,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
if (empty($button_list)) {
return array('Response' => ' 0 buttons found ', 'data' => '');
}
- $copy_fld = array('ref', 'reftype', 'instance', 'buttontype');
+ $copy_fld = array('ref', 'reftype', 'instance', 'buttontype', 'options');
$extList = $extList = $this->dbinterface->get_db_SccpTableByID("SccpExtension", array(), 'name');
foreach ($button_list as $value) {
$btn_opt = explode(',', $value['options']);
@@ -1068,9 +1070,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
}
function getSccpModelInformation($get = "all", $validate = false, $format_list = "all", $filter = array()) {
- // $file_ext = array('.loads', '.LOADS', '.sbn', '.SBN', '.bin', '.BIN','.zup','.ZUP');
$file_ext = array('.loads', '.sbn', '.bin', '.zup');
- // $dir = $this->sccppath["tftp_path"];
$dir = $this->sccppath['tftp_firmware_path'];
$dir_tepl = $this->sccppath['tftp_templates_path'];
diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js
index dc0ad4f..70e2473 100644
--- a/assets/js/sccp_manager.js
+++ b/assets/js/sccp_manager.js
@@ -296,6 +296,7 @@ $(document).ready(function () {
}
var btn_add = $('#sccp_hw_addon').find(':selected').data('val');
+ $('#buttonscount').attr('value',btn_dev + btn_add);
$('.line_button').each(function () {
if ($(this).data('id') < btn_dev + btn_add) {
$(this).removeClass('hidden');
@@ -307,6 +308,12 @@ $(document).ready(function () {
});
+ $('.lineSelect').change(function (e) {
+ var type_id = $('#sccp_hw_defaultLine').find(':selected').data('id');
+ $("select.lineid_0 option:selected").prop("selected",false);
+ $("select.lineid_0 option[value=" + type_id + "]").prop("selected",true);
+ });
+
$('.sccp_button_hide').each(function () {
// On page create !!
var dev_id = $(this).data('vhide');
diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433
index 01528b3..fce9f7c 100644
--- a/conf/sccpgeneral.xml.v433
+++ b/conf/sccpgeneral.xml.v433
@@ -1263,7 +1263,7 @@ and open the template in the editor. Base Version before all crash :-)
type7911
- hw_select sccp-custom
+ hw_select form-controlThe type of phone: 7911, 7940, 7960, etc. Important note: the 'G' models are handled as the base model (e.g., 7962G is handled as 7962). In the Display mode, this field is read-only because the MAC address and the model number are a pair.
@@ -1271,7 +1271,7 @@ and open the template in the editor. Base Version before all crash :-)
addonNONE
- hw_select sccp-custom
+ hw_select form-controlAddon: Addons are model specific and only work with certain base phones. This phone model is identified as being a phone that does not accept sidecars. Update devmodel if this is not correct.
@@ -1322,6 +1322,14 @@ and open the template in the editor. Base Version before all crash :-)
The information in the upper right corner of the device screen. Only English letters and digits !
+
+
+ defaultLine
+
+
+ lineSelect form-control
+ Select the default line for this device
+ softkeyset
@@ -1894,7 +1902,7 @@ and open the template in the editor. Base Version before all crash :-)
type7911
- hw_select sccp-custom
+ form-control hw_selectThe type of phone: 7911, 7940, 7960, etc. Important note: the 'G' models are handled as the base model (e.g., 7962G is handled as 7962). In the Display mode, this field is read-only because the MAC address and the model number are a pair.
@@ -1902,7 +1910,7 @@ and open the template in the editor. Base Version before all crash :-)
addonNONE
- hw_select sccp-custom
+ hw_select form-controlAddon: Addons are model specific and only work with certain base phones. This phone model is identified as being a phone that does not accept sidecars. Update devmodel if this is not correct.
diff --git a/sccpManClasses/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433
index 1ebd4b3..798057e 100644
--- a/sccpManClasses/Sccp.class.php.v433
+++ b/sccpManClasses/Sccp.class.php.v433
@@ -182,9 +182,12 @@ class Sccp extends \FreePBX\modules\Core\Driver {
}
public function delDevice($id) {
- //Required by FreePBX
- $sql = "DELETE FROM sccpline WHERE name = ?";
- $sth = $this->database->prepare($sql);
+ //Required by FreePBX.
+ // Delete associated default line buttons or will leave orphans
+ $sth = $this->database->prepare("DELETE FROM sccpbuttonconfig WHERE ref = ? AND instance = 1 AND buttontype = 'line'");
+ $sth->execute(array($id));
+
+ $sth = $this->database->prepare("DELETE FROM sccpline WHERE name = ?");
$sth->execute(array($id));
return true;
}
diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php
index a1c7b72..afaed23 100644
--- a/sccpManClasses/dbinterface.class.php
+++ b/sccpManClasses/dbinterface.class.php
@@ -49,6 +49,7 @@ class dbinterface
// $stmt is a single row fetch, $stmts is a fetchAll while stmtU is fetchAll UNIQUE
$stmt = '';
$stmts = '';
+ $stmtU = '';
if ($dataid == '') {
return false;
}
@@ -60,7 +61,7 @@ class dbinterface
break;
case 'SccpExtension':
if (empty($data['name'])) {
- $stmts = $this->db->prepare('SELECT * FROM sccpline ORDER BY name');
+ $stmtU = $this->db->prepare('SELECT name, sccpline.* FROM sccpline ORDER BY name');
} else {
$stmts = $this->db->prepare('SELECT * FROM sccpline WHERE name = :name');
$stmts->bindParam(':name', $data['name'],\PDO::PARAM_STR);
@@ -111,15 +112,6 @@ class dbinterface
$stmts = $this->db->prepare("SELECT {$fld} FROM sccpdeviceconfig ORDER BY name");
}
break;
- case 'HWSipDevice':
- $raw_settings = $this->getDb_model_info($get = "sipphones", $format_list = "model");
- break;
- case 'HWDevice':
- $raw_settings = $this->getDb_model_info($get = "ciscophones", $format_list = "model");
- break;
- case 'HWextension':
- $raw_settings = $this->getDb_model_info($get = "extension", $format_list = "model");
- break;
case 'get_columns_sccpdevice':
$stmts = $this->db->prepare('DESCRIBE sccpdevice');
break;
@@ -140,6 +132,13 @@ class dbinterface
$stmt = $this->db->prepare('SELECT * FROM sccpuser WHERE name = :name');
$stmt->bindParam(':name', $data['id'],\PDO::PARAM_STR);
break;
+ case 'getAssignedExtensions':
+ // all extensions that are designed as default lines
+ $stmtU = $this->db->prepare("SELECT DISTINCT name, name FROM sccpbuttonconfig WHERE buttontype = 'line' AND instance =1");
+ break;
+ case 'getDefaultLine':
+ $stmt = $this->db->prepare("SELECT name FROM sccpbuttonconfig WHERE ref = '{$data['id']}' and instance =1 and buttontype = 'line'");
+ break;
case 'get_sccpdevice_buttons':
$sql = '';
if (!empty($data['buttontype'])) {
@@ -162,7 +161,7 @@ class dbinterface
$raw_settings = array();
}
break;
- // No default case so will give exception of $raw_settings undefined if there
+ // No default case so will give exception of $raw_settings undefined if the
// dataid is not in the switch.
}
if (!empty($stmt)) {
@@ -323,29 +322,51 @@ class dbinterface
break;
case 'replace':
foreach ($save_value as $button_array) {
- $stmt = $this->db->prepare('UPDATE sccpbuttonconfig SET name =:name WHERE ref = :ref AND reftype =:reftype AND instance = :instance AND buttontype = :buttontype');
+ $stmt = $this->db->prepare('UPDATE sccpbuttonconfig SET name =:name WHERE ref = :ref AND reftype =:reftype AND instance = :instance AND buttontype = :buttontype AND options = :options');
$stmt->bindParam(':ref', $button_array['ref'],\PDO::PARAM_STR);
$stmt->bindParam(':reftype', $button_array['reftype'],\PDO::PARAM_STR);
$stmt->bindParam(':instance', $button_array['instance'],\PDO::PARAM_INT);
- $stmt->bindParam(':buttontype', $button_array['type'],\PDO::PARAM_STR);
+ $stmt->bindParam(':buttontype', $button_array['buttontype'],\PDO::PARAM_STR);
$stmt->bindParam(':name', $button_array['name'],\PDO::PARAM_STR);
+ $stmt->bindParam(':options', $button_array['options'],\PDO::PARAM_STR);
$result= $stmt->execute();
}
break;
+ case 'add':
+ foreach ($save_value as $button_array) {
+ $stmt = $this->db->prepare("INSERT INTO sccpbuttonconfig SET ref = :ref, reftype = :reftype, instance = :instance, buttontype = :buttontype, name = :name, options = :options
+ ON DUPLICATE KEY UPDATE ref = :refU, reftype = :reftypeU, instance = :instanceU, buttontype = :buttontypeU, name = :nameU, options = :optionsU");
+ $stmt->bindParam(':ref', $button_array['ref'],\PDO::PARAM_STR);
+ $stmt->bindParam(':reftype', $button_array['reftype'],\PDO::PARAM_STR);
+ $stmt->bindParam(':instance', $button_array['instance'],\PDO::PARAM_INT);
+ $stmt->bindParam(':buttontype', $button_array['buttontype'],\PDO::PARAM_STR);
+ $stmt->bindParam(':name', $button_array['name'],\PDO::PARAM_STR);
+ $stmt->bindParam(':options', $button_array['options'],\PDO::PARAM_STR);
+ $stmt->bindParam(':refU', $button_array['ref'],\PDO::PARAM_STR);
+ $stmt->bindParam(':reftypeU', $button_array['reftype'],\PDO::PARAM_STR);
+ $stmt->bindParam(':instanceU', $button_array['instance'],\PDO::PARAM_INT);
+ $stmt->bindParam(':buttontypeU', $button_array['buttontype'],\PDO::PARAM_STR);
+ $stmt->bindParam(':nameU', $button_array['name'],\PDO::PARAM_STR);
+ $stmt->bindParam(':optionsU', $button_array['options'],\PDO::PARAM_STR);
+ $result = $stmt->execute();
+ }
+ break;
+ /*
case 'add':
foreach ($save_value as $button_array) {
$stmt = $this->db->prepare('INSERT INTO sccpbuttonconfig (ref, reftype, instance, buttontype, name, options) VALUES (:ref, :reftype, :instance, :buttontype, :name, :options)');
$stmt->bindParam(':ref', $button_array['ref'],\PDO::PARAM_STR);
$stmt->bindParam(':reftype', $button_array['reftype'],\PDO::PARAM_STR);
$stmt->bindParam(':instance', $button_array['instance'],\PDO::PARAM_INT);
- $stmt->bindParam(':buttontype', $button_array['type'],\PDO::PARAM_STR);
+ $stmt->bindParam(':buttontype', $button_array['buttontype'],\PDO::PARAM_STR);
$stmt->bindParam(':name', $button_array['name'],\PDO::PARAM_STR);
$stmt->bindParam(':options', $button_array['options'],\PDO::PARAM_STR);
$result = $stmt->execute();
}
break;
+ */
case 'clear';
- // Clear is equivalent of delete + insert.
+ // Clear is equivalent of delete + insert. Mode is used in order to activate trigger.
$this->write('sccpbuttons', '', $mode = 'delete','', $hwid);
$this->write('sccpbuttons', $save_value, $mode = 'add','', $hwid);
break;
diff --git a/sccpManClasses/formcreate.class.php b/sccpManClasses/formcreate.class.php
index 9251361..e1ac17e 100644
--- a/sccpManClasses/formcreate.class.php
+++ b/sccpManClasses/formcreate.class.php
@@ -537,6 +537,7 @@ class formcreate
$select_opt[$key]= $key;
}
}
+
case 'SLM':
if (function_exists('music_list')) {
$moh_list = music_list();
@@ -741,15 +742,23 @@ class formcreate
}
switch ($child['type']) {
case 'SDM':
- $model_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWDevice");
+ $model_list = \FreePBX::Sccp_manager()->dbinterface->getDb_model_info('ciscophones', 'model');
$select_opt= $model_list;
break;
case 'SDMS':
- $model_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWSipDevice");
+ $model_list = \FreePBX::Sccp_manager()->dbinterface->getDb_model_info('sipphones', 'model');
$select_opt= $model_list;
break;
+ case 'SDML':
+ $assignedExts = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData('getAssignedExtensions');
+ $select_opt = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData('SccpExtension');
+ foreach ($assignedExts as $name => $nameArr ) {
+ $select_opt[$name]['label'] .= " - in use";
+ }
+ $child->default = $fvalues['defaultLine'];
+ break;
case 'SDE':
- $extension_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWextension");
+ $extension_list = \FreePBX::Sccp_manager()->dbinterface->getDb_model_info('extension', 'model');
$extension_list[]=array( 'model' => 'NONE', 'vendor' => 'CISCO', 'dns' => '0');
foreach ($extension_list as &$data) {
$d_name = explode(';', $data['model']);
@@ -771,7 +780,6 @@ class formcreate
?>