Add select_mode

This commit is contained in:
FusionPBX 2020-11-19 09:54:32 -07:00 committed by GitHub
parent cb14ed7a77
commit 6fd52ec721
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 324 additions and 229 deletions

View File

@ -155,6 +155,7 @@ if (!class_exists('destinations')) {
}
/**
* Build the destination select list
* @var string $destination_type can be ivr, dialplan, call_center_contact or bridge
@ -173,6 +174,8 @@ if (!class_exists('destinations')) {
$database = new database;
$this->domain_name = $database->select($sql, $parameters, 'column');
//create a single destination select list
if ($_SESSION['destinations']['select_mode']['text'] == 'default') {
//get the destinations
if (!is_array($this->destinations)) {
@ -420,6 +423,97 @@ if (!class_exists('destinations')) {
if (if_group("superadmin")) {
$response .= "<input type='button' id='btn_select_to_input_".$destination_id."' class='btn' name='' alt='back' onclick='changeToInput".$destination_id."(document.getElementById(\"".$destination_id."\"));this.style.visibility = \"hidden\";' value='&#9665;'>";
}
}
//create a dynamic destination select list
if ($_SESSION['destinations']['select_mode']['text'] == 'dynamic') {
//remove special characters from the name
$destination_id = str_replace("]", "", $destination_name);
$destination_id = str_replace("[", "_", $destination_id);
//$destination_id = preg_replace('/[^a-zA-Z_,.]/', '', $destination_name);
?>
<script type="text/javascript">
function get_destinations(id, destination_type, action, search) {
//alert(action);
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById(id).innerHTML = this.responseText;
}
};
if (action) {
xhttp.open("GET", "/app/destinations/resources/destinations.php?destination_type="+destination_type+"&action="+action, true);
}
else {
xhttp.open("GET", "/app/destinations/resources/destinations.php?destination_type="+destination_type, true);
}
xhttp.send();
}
</script>
<?php
//get the destinations
$destination = new destinations;
if (!isset($_SESSION['destinations'][$destination_type])) {
unset($_SESSION['destinations'][$destination_type]);
$_SESSION['destinations'][$destination_type] = $destination->get($destination_type);
}
//get the destination label
foreach($_SESSION['destinations'][$destination_type] as $key => $value) {
foreach($value as $k => $row) {
if ($destination_value == $row['destination']) {
$destination_key = $key;
$destination_label = $row['label'];
break;
}
}
}
//add the language object
$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 .= " <option value=''></option>\n";
foreach($_SESSION['destinations'][$destination_type] as $key => $value) {
if (permission_exists($destination->singular($key)."_destinations")) {
//determine if selected
$selected = ($key == $destination_key) ? "selected='selected'" : '';
//add multi-lingual support
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/".$key."/app_languages.php")) {
$text2 = $language2->get($_SESSION['domain']['language']['code'], 'app/'.$key);
}
//add the application to the select list
$response .= " <option value='".$key."' $selected>".$text2['title-'.$key]." </option>\n";
}
}
$response .= " </select>\n";
$response .= " <select id='".$destination_id."' name='".$destination_name."' class='formfld' style='".$select_style."'>\n";
foreach($_SESSION['destinations'][$destination_type] as $key => $value) {
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";
}
}
}
$response .= " </select>\n";
//debug information
//echo $response;
//echo "destination_key $destination_key\n";
//echo "destination_id $destination_id\n";
//echo "destination_type $destination_type\n";
//echo "destination_name $destination_name\n";
//echo "destination_value $destination_value\n";
//exit;
}
//return the formatted destinations
return $response;
@ -523,7 +617,7 @@ if (!class_exists('destinations')) {
$this->destinations[$x]['select_value']['dialplan'] = "transfer:\${destination}";
$this->destinations[$x]['select_value']['ivr'] = "menu-exec-app:transfer \${destination}";
$this->destinations[$x]['select_label'] = "\${name}";
$y = 0;
$y=0;
$this->destinations[$x]['result']['data'][$y]['label'] = 'check_voicemail';
$this->destinations[$x]['result']['data'][$y]['name'] = '*98';
$this->destinations[$x]['result']['data'][$y]['destination'] = '*98 XML ${context}';
@ -843,6 +937,7 @@ if (!class_exists('destinations')) {
$i++;
}
$i = 0;
unset($text);
}