mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Initial attempt at allowing the destination button button
to dynamically change This sets the UUID as the ID in the options list. The we use the javascript onclick listener to get the id(uuid) of the selected option and open the link to the edit page.
This commit is contained in:
@@ -476,10 +476,11 @@ if (!class_exists('destinations')) {
|
||||
$language2 = new text;
|
||||
|
||||
//build the destination select list in html
|
||||
$response .= " <select class='formfld' style='".$select_style."' onchange=\"get_destinations('".$destination_id."', '".$destination_type."', this.value);\">\n";
|
||||
$response .= " <select id='{destination_id}_type' class='formfld' style='".$select_style."' onchange=\"get_destinations('".$destination_id."', '".$destination_type."', this.value);\">\n";
|
||||
$response .= " <option value=''></option>\n";
|
||||
foreach($_SESSION['destinations']['array'][$destination_type] as $key => $value) {
|
||||
if (permission_exists($destination->singular($key)."_destinations")) {
|
||||
$singular = $this->singular($key);
|
||||
if (permission_exists("{$singular}_destinations")) {
|
||||
//determine if selected
|
||||
$selected = ($key == $destination_key) ? "selected='selected'" : '';
|
||||
|
||||
@@ -493,7 +494,7 @@ if (!class_exists('destinations')) {
|
||||
$text2 = $language2->get($_SESSION['domain']['language']['code'], 'app/dialplans');
|
||||
}
|
||||
//add the application to the select list
|
||||
$response .= " <option value='".$key."' $selected>".$text2['title-'.$key]."</option>\n";
|
||||
$response .= " <option id='{$singular}' class='{$key}' value='".$key."' $selected>".$text2['title-'.$key]."</option>\n";
|
||||
}
|
||||
}
|
||||
$response .= " </select>\n";
|
||||
@@ -502,22 +503,18 @@ if (!class_exists('destinations')) {
|
||||
if ($key == $destination_key) {
|
||||
foreach($value as $k => $row) {
|
||||
$selected = ($row['destination'] == $destination_value) ? "selected='selected'" : '';
|
||||
$response .= " <option value='".$row['destination']."' $selected>".$row['label']."</option>\n";
|
||||
if ($row['destination'] == $destination_value) {
|
||||
$response_button = button::create([
|
||||
'type'=>'button',
|
||||
'icon'=>'external-link-alt',
|
||||
'id'=>'btn_dest_go',
|
||||
'title'=>$row['label'],
|
||||
//'style'=>'margin-left: 15px;',
|
||||
'link'=>'/app/'.$key.'/'.$this->singular($key).'_edit.php?id='.$row[$this->singular($key).'_uuid']
|
||||
])."\n";
|
||||
}
|
||||
$response .= " <option id='{$row[$this->singular($key).'_uuid']}' value='".$row['destination']."' $selected>".$row['label']."</option>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$response .= " </select>".$response_button."\n";
|
||||
|
||||
$response .= " </select>";
|
||||
$response .= button::create([
|
||||
'type'=>'button',
|
||||
'icon'=>'external-link-alt',
|
||||
'id'=>'btn_dest_go',
|
||||
'title'=>$text['label-edit'],
|
||||
'onclick'=>"let types = document.getElementById('{destination_id}_type').options; let opts = document.getElementById('{$destination_id}').options; window.location.assign('/app/'+types[types.selectedIndex].className+'/'+types[types.selectedIndex].id+'_edit.php?id='+opts[opts.selectedIndex].id);"
|
||||
])."\n";
|
||||
|
||||
//debug information
|
||||
//echo $response;
|
||||
|
||||
@@ -30,7 +30,8 @@
|
||||
echo " <select name='subaction' id='action' class='formfld' style='".$select_style."'>\n";
|
||||
echo " <option value=''></option>\n";
|
||||
foreach($destinations as $key => $rows) {
|
||||
if ($key == $action && permission_exists($destination->singular($key)."_destinations")) {
|
||||
$singular = $destination->singular($key);
|
||||
if ($key == $action && permission_exists("{$singular}_destinations")) {
|
||||
if (is_array($rows)) {
|
||||
foreach($rows as $row) {
|
||||
|
||||
@@ -50,7 +51,7 @@
|
||||
$select_label = str_replace('email-icon', '✉', $select_label);
|
||||
|
||||
//add the select option
|
||||
echo " <option value='".$select_value."'>".$select_label."</option>\n";
|
||||
echo " <option id='{$row[$singular.'_uuid']}' value='".$select_value."'>".$select_label."</option>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user