Prevent select option groups from displaying in switch_select_destination() function if no options available.
This commit is contained in:
parent
8c740f11bb
commit
4680f40924
|
|
@ -493,9 +493,8 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
if ($select_type == "dialplan" || $select_type == "ivr") {
|
||||
if (count($result) > 0) {
|
||||
$options[] = "<optgroup label='Call Center'>";
|
||||
}
|
||||
$previous_call_center_name = "";
|
||||
foreach ($result as &$row) {
|
||||
$queue_name = $row["queue_name"];
|
||||
|
|
@ -513,7 +512,6 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
$previous_call_center_name = $queue_name;
|
||||
}
|
||||
}
|
||||
if ($select_type == "dialplan" || $select_type == "ivr") {
|
||||
$options[] = "</optgroup>";
|
||||
}
|
||||
unset ($prep_statement);
|
||||
|
|
@ -529,6 +527,7 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (count($result) > 0) {
|
||||
$options[] = "<optgroup label='Call Flows'>";
|
||||
foreach ($result as &$row) {
|
||||
$call_flow_name = $row["call_flow_name"];
|
||||
|
|
@ -544,6 +543,7 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
if ($selected) { $selection_found = true; }
|
||||
}
|
||||
$options[] = "</optgroup>";
|
||||
}
|
||||
unset ($prep_statement, $call_flow_extension);
|
||||
}
|
||||
}
|
||||
|
|
@ -559,6 +559,7 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
$prep_statement->execute();
|
||||
$x = 0;
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (count($result) > 0) {
|
||||
$previous_call_group_name = "";
|
||||
$options[] = "<optgroup label='Call Group'>";
|
||||
foreach ($result as &$row) {
|
||||
|
|
@ -581,6 +582,7 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
$x++;
|
||||
}
|
||||
$options[] = "</optgroup>";
|
||||
}
|
||||
unset ($prep_statement);
|
||||
}
|
||||
}
|
||||
|
|
@ -640,8 +642,8 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
if ($selected) { $selection_found = true; }
|
||||
}
|
||||
$options[] = "</optgroup>";
|
||||
unset ($prep_statement);
|
||||
}
|
||||
unset ($prep_statement);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -700,6 +702,7 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (count($result) > 0) {
|
||||
$options[] = "<optgroup label='Extensions'>";
|
||||
foreach ($result as &$row) {
|
||||
$extension = $row["extension"];
|
||||
|
|
@ -718,6 +721,7 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
if ($selected) { $selection_found = true; }
|
||||
}
|
||||
$options[] = "</optgroup>";
|
||||
}
|
||||
unset ($prep_statement, $extension);
|
||||
}
|
||||
}
|
||||
|
|
@ -731,6 +735,7 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (count($result) > 0) {
|
||||
$options[] = "<optgroup label='FAX'>";
|
||||
foreach ($result as &$row) {
|
||||
$fax_name = $row["fax_name"];
|
||||
|
|
@ -745,6 +750,7 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
if ($selected) { $selection_found = true; }
|
||||
}
|
||||
$options[] = "</optgroup>";
|
||||
}
|
||||
unset ($prep_statement, $extension);
|
||||
}
|
||||
}
|
||||
|
|
@ -754,15 +760,16 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
if ($select_type == "dialplan" || $select_type == "ivr") {
|
||||
$sql = "select * from v_dialplan_details ";
|
||||
$sql .= "where domain_uuid = '".$domain_uuid."' ";
|
||||
$sql .= "and dialplan_detail_type = 'fifo' ";
|
||||
$sql .= "and dialplan_detail_data not like '%@${domain_name} in%' ";
|
||||
$sql .= "order by dialplan_detail_data asc ";
|
||||
echo $sql;
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (count($result) > 0) {
|
||||
$options[] = "<optgroup label='Queues (FIFO)'>";
|
||||
foreach ($result as &$row) {
|
||||
//$dialplan_detail_tag = $row["dialplan_detail_tag"];
|
||||
if ($row["dialplan_detail_type"] == "fifo") {
|
||||
if (strpos($row["dialplan_detail_data"], '@${domain_name} in') !== false) {
|
||||
$dialplan_uuid = $row["dialplan_uuid"];
|
||||
//get the extension number using the dialplan_uuid
|
||||
$sql = "select dialplan_detail_data as extension_number ";
|
||||
|
|
@ -801,18 +808,14 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
if ($selected) { $selection_found = true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$options[] = "</optgroup>";
|
||||
}
|
||||
unset ($prep_statement);
|
||||
}
|
||||
}
|
||||
|
||||
//gateways
|
||||
if (if_group("superadmin")) {
|
||||
if ($select_type == "dialplan" || $select_type == "ivr" || $select_type == "call_center_contact" || $select_type == "bridge") {
|
||||
$options[] = "<optgroup label='Gateways'>";
|
||||
}
|
||||
$sql = "select v_gateways.gateway_uuid, v_gateways.gateway, v_domains.domain_name from v_gateways ";
|
||||
$sql .= "inner join v_domains on v_gateways.domain_uuid=v_domains.domain_uuid ";
|
||||
$sql .= "where enabled = 'true' ";
|
||||
|
|
@ -820,9 +823,11 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
$result_count = count($result);
|
||||
unset ($prep_statement, $sql);
|
||||
$tmp_selected = '';
|
||||
if (count($result) > 0) {
|
||||
if ($select_type == "dialplan" || $select_type == "ivr" || $select_type == "call_center_contact" || $select_type == "bridge") {
|
||||
$options[] = "<optgroup label='Gateways'>";
|
||||
}
|
||||
foreach($result as $row) {
|
||||
switch ($select_type) {
|
||||
case "dialplan":
|
||||
|
|
@ -858,16 +863,17 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
}
|
||||
if ($selected) { $selection_found = true; }
|
||||
}
|
||||
unset($sql, $result, $value, $default_value, $flag);
|
||||
if ($select_type == "dialplan" || $select_type == "ivr" || $select_type == "call_center_contact") {
|
||||
$options[] = "</optgroup>";
|
||||
}
|
||||
}
|
||||
unset($prep_statement, $sql, $result, $value, $default_value, $flag);
|
||||
}
|
||||
|
||||
|
||||
//xmpp
|
||||
if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/xmpp/app_config.php")) {
|
||||
if (if_group("superadmin")) {
|
||||
if (if_group("superadmin") && $select_type == "bridge") {
|
||||
$sql = "select v_xmpp.xmpp_profile_uuid, v_xmpp.profile_name, v_domains.domain_name from v_xmpp ";
|
||||
$sql .= "inner join v_domains on v_xmpp.domain_uuid=v_domains.domain_uuid ";
|
||||
$sql .= "where enabled = 'true' ";
|
||||
|
|
@ -875,20 +881,15 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
$result_count = count($result);
|
||||
unset ($prep_statement, $sql);
|
||||
$tmp_selected = '';
|
||||
if (sizeof($result) > 0 && ($select_type == "bridge" || $select_type == "dialplan" || $select_type == "ivr" || $select_type == "call_center_contact")) {
|
||||
if (count($result) > 0) {
|
||||
$options[] = "<optgroup label='XMPP Gateways'>";
|
||||
}
|
||||
foreach($result as $row) {
|
||||
$selected = ('dingaling/'.$row['profile_name'].'/' == $select_value) ? true : false;
|
||||
if ($select_type == "bridge") {
|
||||
$options[] = "<option value='dingaling/".$row['profile_name']."/' ".(($selected) ? "selected='selected'" : null).">".$row['profile_name']."@".$row['domain_name']."</option>";
|
||||
}
|
||||
if ($selected) { $selection_found = true; }
|
||||
}
|
||||
if (sizeof($result) > 0 && ($select_type == "bridge" || $select_type == "dialplan" || $select_type == "ivr" || $select_type == "call_center_contact")) {
|
||||
$options[] = "</optgroup>";
|
||||
}
|
||||
unset($sql, $result);
|
||||
|
|
@ -910,6 +911,7 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (count($result) > 0) {
|
||||
$options[] = "<optgroup label='Hunt Groups'>";
|
||||
foreach ($result as &$row) {
|
||||
$extension = $row["hunt_group_extension"];
|
||||
|
|
@ -924,6 +926,7 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
if ($selected) { $selection_found = true; }
|
||||
}
|
||||
$options[] = "</optgroup>";
|
||||
}
|
||||
unset ($prep_statement, $extension);
|
||||
}
|
||||
}
|
||||
|
|
@ -938,6 +941,7 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (count($result) > 0) {
|
||||
$options[] = "<optgroup label='IVR Menu'>";
|
||||
foreach ($result as &$row) {
|
||||
$extension = $row["ivr_menu_extension"];
|
||||
|
|
@ -962,6 +966,7 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
if ($selected) { $selection_found = true; }
|
||||
}
|
||||
$options[] = "</optgroup>";
|
||||
}
|
||||
unset ($prep_statement, $extension);
|
||||
}
|
||||
}
|
||||
|
|
@ -1003,7 +1008,7 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (sizeof($result) > 0) {
|
||||
if (count($result) > 0) {
|
||||
$options[] = "<optgroup label='Recordings'>";
|
||||
foreach ($result as &$row) {
|
||||
$name = $row["recording_name"];
|
||||
|
|
@ -1033,9 +1038,8 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
if ($select_type == "dialplan" || $select_type == "ivr") {
|
||||
if (count($result) > 0) {
|
||||
$options[] = "<optgroup label='Ring Groups'>";
|
||||
}
|
||||
foreach ($result as &$row) {
|
||||
$extension = $row["ring_group_extension"];
|
||||
$context = $row["ring_group_context"];
|
||||
|
|
@ -1049,7 +1053,6 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
}
|
||||
if ($selected) { $selection_found = true; }
|
||||
}
|
||||
if ($select_type == "dialplan" || $select_type == "ivr") {
|
||||
$options[] = "</optgroup>";
|
||||
}
|
||||
}
|
||||
|
|
@ -1064,6 +1067,7 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
$prep_statement->execute();
|
||||
$x = 0;
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as &$row) {
|
||||
switch ($row['dialplan_detail_type']) {
|
||||
case "hour":
|
||||
|
|
@ -1080,9 +1084,7 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
$time_array[$row['dialplan_uuid']] = $row['dialplan_detail_type'];
|
||||
}
|
||||
}
|
||||
if ($select_type == "dialplan" || $select_type == "ivr") {
|
||||
$options[] = "<optgroup label='Time Conditions'>";
|
||||
}
|
||||
foreach($time_array as $key=>$val) {
|
||||
$dialplan_uuid = $key;
|
||||
//get the extension number using the dialplan_uuid
|
||||
|
|
@ -1121,7 +1123,6 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
if ($selected) { $selection_found = true; }
|
||||
}
|
||||
}
|
||||
if ($select_type == "dialplan" || $select_type == "ivr") {
|
||||
$options[] = "</optgroup>";
|
||||
}
|
||||
unset ($prep_statement);
|
||||
|
|
@ -1138,6 +1139,7 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (count($result) > 0) {
|
||||
$options[] = "<optgroup label='Voicemail'>";
|
||||
foreach ($result as &$row) {
|
||||
$voicemail_id = $row["voicemail_id"];
|
||||
|
|
@ -1154,6 +1156,7 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
|
|||
$options[] = "</optgroup>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//other
|
||||
if ($select_type == "dialplan" || $select_type == "ivr") {
|
||||
|
|
|
|||
Loading…
Reference in New Issue