Write the call center dialplan with the new call center class.

This commit is contained in:
Mark Crane
2015-06-25 08:25:00 +00:00
parent 88ef7714b5
commit fc3974f557
3 changed files with 277 additions and 228 deletions

View File

@@ -736,6 +736,7 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
}
//fifo queues
/*
if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/fifo/app_config.php")) {
if ($select_type == "dialplan" || $select_type == "ivr") {
$sql = "select * from v_dialplan_details ";
@@ -792,6 +793,7 @@ function switch_select_destination($select_type, $select_label, $select_name, $s
unset ($prep_statement);
}
}
*/
//gateways
if (if_group("superadmin")) {
@@ -2236,239 +2238,19 @@ if (!function_exists('save_call_center_xml')) {
global $db, $domain_uuid;
if (strlen($_SESSION['switch']['call_center']['dir']) > 0) {
//include the classes
include "app/dialplan/resources/classes/dialplan.php";
//get the call center queue array
$sql = "select * from v_call_center_queues ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
$result_count = count($result);
$call_center_queues = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
$result_count = count($call_center_queues);
unset ($prep_statement, $sql);
if ($result_count > 0) {
foreach($result as $row) {
//set the variables
$call_center_queue_uuid = $row["call_center_queue_uuid"];
$domain_uuid = $row["domain_uuid"];
$dialplan_uuid = $row["dialplan_uuid"];
$queue_name = check_str($row["queue_name"]);
$queue_extension = $row["queue_extension"];
$queue_strategy = $row["queue_strategy"];
$queue_moh_sound = $row["queue_moh_sound"];
$queue_record_template = $row["queue_record_template"];
$queue_time_base_score = $row["queue_time_base_score"];
$queue_max_wait_time = $row["queue_max_wait_time"];
$queue_max_wait_time_with_no_agent = $row["queue_max_wait_time_with_no_agent"];
$queue_tier_rules_apply = $row["queue_tier_rules_apply"];
$queue_tier_rule_wait_second = $row["queue_tier_rule_wait_second"];
$queue_tier_rule_wait_multiply_level = $row["queue_tier_rule_wait_multiply_level"];
$queue_tier_rule_no_agent_no_wait = $row["queue_tier_rule_no_agent_no_wait"];
$queue_timeout_action = $row["queue_timeout_action"];
$queue_discard_abandoned_after = $row["queue_discard_abandoned_after"];
$queue_abandoned_resume_allowed = $row["queue_abandoned_resume_allowed"];
$queue_cid_prefix = $row["queue_cid_prefix"];
$queue_announce_sound = $row["queue_announce_sound"];
$queue_announce_frequency = $row["queue_announce_frequency"];
$queue_description = check_str($row["queue_description"]);
//replace space with an underscore
$queue_name = str_replace(" ", "_", $queue_name);
//add each Queue to the dialplan
if (strlen($row['call_center_queue_uuid']) > 0) {
$action = 'add'; //set default action to add
$i = 0;
//determine the action add or update
if (strlen($dialplan_uuid) > 0) {
$sql = "select * from v_dialplans ";
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
$prep_statement_2 = $db->prepare($sql);
$prep_statement_2->execute();
while($row2 = $prep_statement_2->fetch(PDO::FETCH_ASSOC)) {
$action = 'update';
}
unset ($sql, $prep_statement_2);
}
if ($action == 'add') {
//create queue entry in the dialplan
$dialplan_name = $queue_name;
$dialplan_order ='210';
$dialplan_context = $_SESSION['context'];
$dialplan_enabled = 'true';
$dialplan_description = $queue_description;
$app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
$dialplan_uuid = uuid();
dialplan_add($domain_uuid, $dialplan_uuid, $dialplan_name, $dialplan_order, $dialplan_context, $dialplan_enabled, $dialplan_description, $app_uuid);
//add the dialplan_uuid to the call center table
$sql = "update v_call_center_queues set ";
$sql .= "dialplan_uuid = '$dialplan_uuid' ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and call_center_queue_uuid = '".$row['call_center_queue_uuid']."' ";
$db->exec(check_sql($sql));
unset($sql);
}
if ($action == 'update') {
//add the dialplan_uuid to the call center table
$sql = "update v_dialplans set ";
$sql .= "dialplan_name = '".$queue_name."', ";
$sql .= "dialplan_description = '".$queue_description."' ";
$sql .= "where domain_uuid = '".$domain_uuid."' ";
$sql .= "and dialplan_uuid = '".$dialplan_uuid."' ";
$db->exec(check_sql($sql));
unset($sql);
//add the dialplan_uuid to the call center table
$sql = "delete from v_dialplan_details ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and dialplan_uuid = '$dialplan_uuid' ";
$db->exec(check_sql($sql));
unset($sql);
}
//group 1
$dialplan = new dialplan;
$dialplan->domain_uuid = $domain_uuid;
$dialplan->dialplan_uuid = $dialplan_uuid;
$dialplan->dialplan_detail_tag = 'condition'; //condition, action, antiaction
$dialplan->dialplan_detail_type = '${caller_id_name}';
$dialplan->dialplan_detail_data = '^([^#]+#)(.*)$';
$dialplan->dialplan_detail_break = 'never';
$dialplan->dialplan_detail_inline = '';
$dialplan->dialplan_detail_group = '1';
$dialplan->dialplan_detail_order = '010';
$dialplan->dialplan_detail_add();
unset($dialplan);
$dialplan = new dialplan;
$dialplan->domain_uuid = $domain_uuid;
$dialplan->dialplan_uuid = $dialplan_uuid;
$dialplan->dialplan_detail_tag = 'action'; //condition, action, antiaction
$dialplan->dialplan_detail_type = 'set';
$dialplan->dialplan_detail_data = 'caller_id_name=$2';
$dialplan->dialplan_detail_break = '';
$dialplan->dialplan_detail_inline = '';
$dialplan->dialplan_detail_group = '1';
$dialplan->dialplan_detail_order = '020';
$dialplan->dialplan_detail_add();
unset($dialplan);
//group 2
$dialplan = new dialplan;
$dialplan->domain_uuid = $domain_uuid;
$dialplan->dialplan_uuid = $dialplan_uuid;
$dialplan->dialplan_detail_tag = 'condition'; //condition, action, antiaction
$dialplan->dialplan_detail_type = 'destination_number';
$dialplan->dialplan_detail_data = '^'.$row['queue_extension'].'$';
$dialplan->dialplan_detail_break = '';
$dialplan->dialplan_detail_inline = '';
$dialplan->dialplan_detail_group = '2';
$dialplan->dialplan_detail_order = '010';
$dialplan->dialplan_detail_add();
unset($dialplan);
$dialplan = new dialplan;
$dialplan->domain_uuid = $domain_uuid;
$dialplan->dialplan_uuid = $dialplan_uuid;
$dialplan->dialplan_detail_tag = 'action'; //condition, action, antiaction
$dialplan->dialplan_detail_type = 'answer';
$dialplan->dialplan_detail_data = '';
$dialplan->dialplan_detail_break = '';
$dialplan->dialplan_detail_inline = '';
$dialplan->dialplan_detail_group = '2';
$dialplan->dialplan_detail_order = '020';
$dialplan->dialplan_detail_add();
unset($dialplan);
$dialplan = new dialplan;
$dialplan->domain_uuid = $domain_uuid;
$dialplan->dialplan_uuid = $dialplan_uuid;
$dialplan->dialplan_detail_tag = 'action'; //condition, action, antiaction
$dialplan->dialplan_detail_type = 'set';
$dialplan->dialplan_detail_data = 'hangup_after_bridge=true';
$dialplan->dialplan_detail_break = '';
$dialplan->dialplan_detail_inline = '';
$dialplan->dialplan_detail_group = '2';
$dialplan->dialplan_detail_order = '030';
$dialplan->dialplan_detail_add();
unset($dialplan);
if (strlen($queue_cid_prefix) > 0) {
$dialplan = new dialplan;
$dialplan->domain_uuid = $domain_uuid;
$dialplan->dialplan_uuid = $dialplan_uuid;
$dialplan->dialplan_detail_tag = 'action'; //condition, action, antiaction
$dialplan->dialplan_detail_type = 'set';
$dialplan->dialplan_detail_data = "effective_caller_id_name=".$queue_cid_prefix."-\${caller_id_name}";
$dialplan->dialplan_detail_break = '';
$dialplan->dialplan_detail_inline = '';
$dialplan->dialplan_detail_group = '2';
$dialplan->dialplan_detail_order = '040';
$dialplan->dialplan_detail_add();
unset($dialplan);
}
$dialplan = new dialplan;
$dialplan->domain_uuid = $domain_uuid;
$dialplan->dialplan_uuid = $dialplan_uuid;
$dialplan->dialplan_detail_tag = 'action'; //condition, action, antiaction
$dialplan->dialplan_detail_type = 'callcenter';
$dialplan->dialplan_detail_data = $queue_name."@".$_SESSION['domains'][$domain_uuid]['domain_name'];
$dialplan->dialplan_detail_break = '';
$dialplan->dialplan_detail_inline = '';
$dialplan->dialplan_detail_group = '2';
$dialplan->dialplan_detail_order = '050';
$dialplan->dialplan_detail_add();
unset($dialplan);
if (strlen($queue_timeout_action) > 0) {
$action_array = explode(":",$queue_timeout_action);
$dialplan = new dialplan;
$dialplan->domain_uuid = $domain_uuid;
$dialplan->dialplan_uuid = $dialplan_uuid;
$dialplan->dialplan_detail_tag = 'action'; //condition, action, antiaction
$dialplan->dialplan_detail_type = $action_array[0];
$dialplan->dialplan_detail_data = substr($queue_timeout_action, strlen($action_array[0])+1, strlen($queue_timeout_action));
$dialplan->dialplan_detail_break = '';
$dialplan->dialplan_detail_inline = '';
$dialplan->dialplan_detail_group = '2';
$dialplan->dialplan_detail_order = '060';
$dialplan->dialplan_detail_add();
unset($dialplan);
}
$dialplan = new dialplan;
$dialplan->domain_uuid = $domain_uuid;
$dialplan->dialplan_uuid = $dialplan_uuid;
$dialplan->dialplan_detail_tag = 'action'; //condition, action, antiaction
$dialplan->dialplan_detail_type = 'hangup';
$dialplan->dialplan_detail_data = '';
$dialplan->dialplan_detail_break = '';
$dialplan->dialplan_detail_inline = '';
$dialplan->dialplan_detail_group = '2';
$dialplan->dialplan_detail_order = '070';
$dialplan->dialplan_detail_add();
unset($dialplan);
//synchronize the xml config
save_dialplan_xml();
//unset variables
unset($action);
} //end if strlen call_center_queue_uuid; add the call center queue to the dialplan
}
//prepare Queue XML string
$v_queues = '';
$sql = "select * from v_call_center_queues ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
$x=0;
foreach ($result as &$row) {
foreach ($call_center_queues as &$row) {
$queue_name = $row["queue_name"];
$queue_extension = $row["queue_extension"];
$queue_strategy = $row["queue_strategy"];
@@ -2486,6 +2268,10 @@ if (!function_exists('save_call_center_xml')) {
$queue_announce_sound = $row["queue_announce_sound"];
$queue_announce_frequency = $row ["queue_announce_frequency"];
$queue_description = $row["queue_description"];
//replace space with an underscore
$queue_name = str_replace(" ", "_", $queue_name);
if ($x > 0) {
$v_queues .= "\n";
$v_queues .= " ";
@@ -2859,4 +2645,4 @@ if (!function_exists('save_switch_xml')) {
}
}
?>
?>