Merge pull request #5845 from winsock/destinations_button_js
Dynamic Destination Edit Button
This commit is contained in:
commit
fbcffbc78d
|
|
@ -476,10 +476,11 @@ if (!class_exists('destinations')) {
|
||||||
$language2 = new text;
|
$language2 = new text;
|
||||||
|
|
||||||
//build the destination select list in html
|
//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";
|
$response .= " <option value=''></option>\n";
|
||||||
foreach($_SESSION['destinations']['array'][$destination_type] as $key => $value) {
|
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
|
//determine if selected
|
||||||
$selected = ($key == $destination_key) ? "selected='selected'" : '';
|
$selected = ($key == $destination_key) ? "selected='selected'" : '';
|
||||||
|
|
||||||
|
|
@ -493,7 +494,7 @@ if (!class_exists('destinations')) {
|
||||||
$text2 = $language2->get($_SESSION['domain']['language']['code'], 'app/dialplans');
|
$text2 = $language2->get($_SESSION['domain']['language']['code'], 'app/dialplans');
|
||||||
}
|
}
|
||||||
//add the application to the select list
|
//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";
|
$response .= " </select>\n";
|
||||||
|
|
@ -501,23 +502,20 @@ if (!class_exists('destinations')) {
|
||||||
foreach($_SESSION['destinations']['array'][$destination_type] as $key => $value) {
|
foreach($_SESSION['destinations']['array'][$destination_type] as $key => $value) {
|
||||||
if ($key == $destination_key) {
|
if ($key == $destination_key) {
|
||||||
foreach($value as $k => $row) {
|
foreach($value as $k => $row) {
|
||||||
$selected = ($row['destination'] == $destination_value) ? "selected='selected'" : '';
|
$selected = ($row['destination'] == $destination_value) ? "selected='selected'" : '';
|
||||||
$response .= " <option value='".$row['destination']."' $selected>".$row['label']."</option>\n";
|
$uuid = isset($row[$this->singular($key).'_uuid']) ? $row[$this->singular($key).'_uuid'] : $row['uuid'];
|
||||||
if ($row['destination'] == $destination_value) {
|
$response .= " <option id='{$uuid}' value='".$row['destination']."' $selected>".$row['label']."</option>\n";
|
||||||
$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 .= " </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; if(opts[opts.selectedIndex].id && opts[opts.selectedIndex].id.length > 0) {window.open('/app/'+types[types.selectedIndex].className+'/'+types[types.selectedIndex].id+'_edit.php?id='+opts[opts.selectedIndex].id, '_blank');}"
|
||||||
|
])."\n";
|
||||||
|
|
||||||
//debug information
|
//debug information
|
||||||
//echo $response;
|
//echo $response;
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@
|
||||||
echo " <select name='subaction' id='action' class='formfld' style='".$select_style."'>\n";
|
echo " <select name='subaction' id='action' class='formfld' style='".$select_style."'>\n";
|
||||||
echo " <option value=''></option>\n";
|
echo " <option value=''></option>\n";
|
||||||
foreach($destinations as $key => $rows) {
|
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)) {
|
if (is_array($rows)) {
|
||||||
foreach($rows as $row) {
|
foreach($rows as $row) {
|
||||||
|
|
||||||
|
|
@ -50,7 +51,8 @@
|
||||||
$select_label = str_replace('email-icon', '✉', $select_label);
|
$select_label = str_replace('email-icon', '✉', $select_label);
|
||||||
|
|
||||||
//add the select option
|
//add the select option
|
||||||
echo " <option value='".$select_value."'>".$select_label."</option>\n";
|
$uuid = isset($row[$singular.'_uuid']) ? $row[$singular.'_uuid'] : $row['uuid'];
|
||||||
|
echo " <option id='{$uuid}' value='".$select_value."'>".$select_label."</option>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,10 @@
|
||||||
$apps[$x]['destinations'][$y]['type'] = "sql";
|
$apps[$x]['destinations'][$y]['type'] = "sql";
|
||||||
$apps[$x]['destinations'][$y]['label'] = "voicemails";
|
$apps[$x]['destinations'][$y]['label'] = "voicemails";
|
||||||
$apps[$x]['destinations'][$y]['name'] = "voicemails";
|
$apps[$x]['destinations'][$y]['name'] = "voicemails";
|
||||||
$apps[$x]['destinations'][$y]['sql'] = "select voicemail_id as destination, '*99' || voicemail_id as extension, voicemail_description as description from v_voicemails";
|
$apps[$x]['destinations'][$y]['sql'] = "select voicemail_uuid, voicemail_id as destination, '*99' || voicemail_id as extension, voicemail_description as description from v_voicemails";
|
||||||
$apps[$x]['destinations'][$y]['where'] = "where domain_uuid = '\${domain_uuid}' and voicemail_enabled = 'true' ";
|
$apps[$x]['destinations'][$y]['where'] = "where domain_uuid = '\${domain_uuid}' and voicemail_enabled = 'true' ";
|
||||||
$apps[$x]['destinations'][$y]['order_by'] = "voicemail_id asc ";
|
$apps[$x]['destinations'][$y]['order_by'] = "voicemail_id asc ";
|
||||||
|
$apps[$x]['destinations'][$y]['field']['voicemail_uuid'] = "voicemail_uuid";
|
||||||
$apps[$x]['destinations'][$y]['field']['destination'] = "voicemail_id";
|
$apps[$x]['destinations'][$y]['field']['destination'] = "voicemail_id";
|
||||||
$apps[$x]['destinations'][$y]['field']['extension'] = "voicemail_id";
|
$apps[$x]['destinations'][$y]['field']['extension'] = "voicemail_id";
|
||||||
$apps[$x]['destinations'][$y]['field']['description'] = "voicemail_description";
|
$apps[$x]['destinations'][$y]['field']['description'] = "voicemail_description";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue