From d17f7c88ad95862b97560b331d7db09f903cf87d Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Fri, 14 Sep 2012 22:45:26 +0000 Subject: [PATCH] Add call flow name and the beginning of the dialplan structure. --- app/call_flows/app_config.php | 4 + app/call_flows/call_flow_edit.php | 213 +++++++++++++++++++++--------- 2 files changed, 155 insertions(+), 62 deletions(-) diff --git a/app/call_flows/app_config.php b/app/call_flows/app_config.php index 44f719ef26..702b34c043 100644 --- a/app/call_flows/app_config.php +++ b/app/call_flows/app_config.php @@ -62,6 +62,10 @@ $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_dialplans'; $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'dialplan_uuid'; $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = 'call_flow_name'; + $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; + $apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'Enter the name.'; + $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = 'call_flow_extension'; $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; $apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'Enter the extension number.'; diff --git a/app/call_flows/call_flow_edit.php b/app/call_flows/call_flow_edit.php index d7c2ae93cd..b6697ce388 100644 --- a/app/call_flows/call_flow_edit.php +++ b/app/call_flows/call_flow_edit.php @@ -22,6 +22,7 @@ else { //get http post variables and set them to php variables if (count($_POST)>0) { //set the variables from the http values + $call_flow_name = check_str($_POST["call_flow_name"]); $call_flow_extension = check_str($_POST["call_flow_extension"]); $call_flow_feature_code = check_str($_POST["call_flow_feature_code"]); $call_flow_status = check_str($_POST["call_flow_status"]); @@ -49,7 +50,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { } //check for all required data - //if (strlen($call_flow_extension) == 0) { $msg .= "Please provide: Extension
\n"; } + if (strlen($call_flow_name) == 0) { $msg .= "Please provide: Name
\n"; } + if (strlen($call_flow_extension) == 0) { $msg .= "Please provide: Extension
\n"; } //if (strlen($call_flow_feature_code) == 0) { $msg .= "Please provide: Feature Code
\n"; } //if (strlen($call_flow_status) == 0) { $msg .= "Please provide: Status
\n"; } //if (strlen($call_flow_app) == 0) { $msg .= "Please provide: Application
\n"; } @@ -74,71 +76,146 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { //add or update the database if ($_POST["persistformvar"] != "true") { if ($action == "add" && permission_exists('call_flow_add')) { - $sql = "insert into v_call_flows "; - $sql .= "("; - $sql .= "domain_uuid, "; - $sql .= "call_flow_uuid, "; - $sql .= "call_flow_extension, "; - $sql .= "call_flow_feature_code, "; - $sql .= "call_flow_status, "; - $sql .= "call_flow_app, "; - $sql .= "call_flow_pin_number, "; - $sql .= "call_flow_data, "; - $sql .= "call_flow_anti_app, "; - $sql .= "call_flow_anti_data, "; - $sql .= "call_flow_description "; - $sql .= ")"; - $sql .= "values "; - $sql .= "("; - $sql .= "'$domain_uuid', "; - $sql .= "'".uuid()."', "; - $sql .= "'$call_flow_extension', "; - $sql .= "'$call_flow_feature_code', "; - $sql .= "'$call_flow_status', "; - $sql .= "'$call_flow_app', "; - $sql .= "'$call_flow_pin_number', "; - $sql .= "'$call_flow_data', "; - $sql .= "'$call_flow_anti_app', "; - $sql .= "'$call_flow_anti_data', "; - $sql .= "'$call_flow_description' "; - $sql .= ")"; - $db->exec(check_sql($sql)); - unset($sql); - - require_once "includes/header.php"; - echo "\n"; - echo "
\n"; - echo "Add Complete\n"; - echo "
\n"; - require_once "includes/footer.php"; - return; + //prepare the uuids + $call_flow_uuid = uuid(); + $dialplan_uuid = uuid(); + //add the call flow + $sql = "insert into v_call_flows "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "call_flow_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "call_flow_name, "; + $sql .= "call_flow_extension, "; + $sql .= "call_flow_feature_code, "; + $sql .= "call_flow_status, "; + $sql .= "call_flow_app, "; + $sql .= "call_flow_pin_number, "; + $sql .= "call_flow_data, "; + $sql .= "call_flow_anti_app, "; + $sql .= "call_flow_anti_data, "; + $sql .= "call_flow_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'".$call_flow_uuid."', "; + $sql .= "'".$dialplan_uuid."', "; + $sql .= "'$call_flow_name', "; + $sql .= "'$call_flow_extension', "; + $sql .= "'$call_flow_feature_code', "; + $sql .= "'$call_flow_status', "; + $sql .= "'$call_flow_app', "; + $sql .= "'$call_flow_pin_number', "; + $sql .= "'$call_flow_data', "; + $sql .= "'$call_flow_anti_app', "; + $sql .= "'$call_flow_anti_data', "; + $sql .= "'$call_flow_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); } //if ($action == "add") if ($action == "update" && permission_exists('call_flow_edit')) { - $sql = "update v_call_flows set "; - $sql .= "call_flow_extension = '$call_flow_extension', "; - $sql .= "call_flow_feature_code = '$call_flow_feature_code', "; - $sql .= "call_flow_status = '$call_flow_status', "; - - $sql .= "call_flow_pin_number = '$call_flow_pin_number', "; - $sql .= "call_flow_app = '$call_flow_app', "; - $sql .= "call_flow_data = '$call_flow_data', "; - $sql .= "call_flow_anti_app = '$call_flow_anti_app', "; - $sql .= "call_flow_anti_data = '$call_flow_anti_data', "; - $sql .= "call_flow_description = '$call_flow_description' "; - $sql .= "where domain_uuid = '$domain_uuid' "; - $sql .= "and call_flow_uuid = '$call_flow_uuid'"; - $db->exec(check_sql($sql)); - unset($sql); - - require_once "includes/header.php"; - echo "\n"; - echo "
\n"; - echo "Update Complete\n"; - echo "
\n"; - require_once "includes/footer.php"; - return; + //prepare the uuids + if (strlen($dialplan_uuid) == 0) { + $dialplan_uuid = uuid(); + } + //add the call flow + $sql = "update v_call_flows set "; + $sql .= "dialplan_uuid = '$dialplan_uuid', "; + $sql .= "call_flow_name = '$call_flow_name', "; + $sql .= "call_flow_extension = '$call_flow_extension', "; + $sql .= "call_flow_feature_code = '$call_flow_feature_code', "; + $sql .= "call_flow_status = '$call_flow_status', "; + $sql .= "call_flow_pin_number = '$call_flow_pin_number', "; + $sql .= "call_flow_app = '$call_flow_app', "; + $sql .= "call_flow_data = '$call_flow_data', "; + $sql .= "call_flow_anti_app = '$call_flow_anti_app', "; + $sql .= "call_flow_anti_data = '$call_flow_anti_data', "; + $sql .= "call_flow_description = '$call_flow_description' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and call_flow_uuid = '$call_flow_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); } //if ($action == "update") + + if ($action == "add" || $action == "update") { +/* + //if it does not exist in the dialplan then add it + $sql = "select count(*) as num_rows from v_dialplans "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '".$dialplan_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] == 0) { + //create the dialplan entry for fax + $dialplan_name = $call_flow_name; + $dialplan_order ='333'; + $dialplan_context = $call_flow_context; + $dialplan_enabled = 'true'; + $dialplan_description = $call_flow_description; + $app_uuid = 'b1b70f85-6b42-429b-8c5a-60c8b02b7d14'; + dialplan_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_name, $dialplan_order, $dialplan_context, $dialplan_enabled, $dialplan_description, $app_uuid); + + // + $dialplan_detail_tag = 'condition'; //condition, action, antiaction + $dialplan_detail_type = 'destination_number'; + $dialplan_detail_data = '^'.$call_flow_extension.'$'; + $dialplan_detail_order = '000'; + $dialplan_detail_group = '1'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + // + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = 'call_flow_uuid='.$call_flow_uuid; + $dialplan_detail_order = '010'; + $dialplan_detail_group = '1'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + // + //$dialplan_detail_tag = 'action'; //condition, action, antiaction + //$dialplan_detail_type = 'set'; + //$dialplan_detail_data = 'ringback=${us-ring}'; + //$dialplan_detail_order = '020'; + //$dialplan_detail_group = '1'; + //dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + // + $dialplan_detail_tag = 'action'; //condition, action, antiaction + //$dialplan_detail_type = 'transfer'; + //$dialplan_detail_data = $ring_group_extension . ' LUA call_flow.lua'; + $dialplan_detail_type = 'lua'; + $dialplan_detail_data = 'call_flow.lua'; + $dialplan_detail_order = '030'; + $dialplan_detail_group = '1'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + //save the xml + save_dialplan_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + } + } +*/ + //redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + if ($action == "add") { + echo "Add Complete\n"; + } + if ($action == "update") { + echo "Update Complete\n"; + } + echo "
\n"; + require_once "includes/footer.php"; + return; + } } //if ($_POST["persistformvar"] != "true") } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) @@ -153,6 +230,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $result = $prep_statement->fetchAll(); foreach ($result as &$row) { //set the php variables + $call_flow_name = $row["call_flow_name"]; $call_flow_extension = $row["call_flow_extension"]; $call_flow_feature_code = $row["call_flow_feature_code"]; $call_flow_status = $row["call_flow_status"]; @@ -200,6 +278,17 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; + echo "\n"; + echo "\n"; + echo " Name:\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the name.\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo " Extension:\n";