diff --git a/app/destinations/destination_edit.php b/app/destinations/destination_edit.php index 89b68016cd..941c6a2c3e 100644 --- a/app/destinations/destination_edit.php +++ b/app/destinations/destination_edit.php @@ -127,6 +127,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { //remove the array from the HTTP POST unset($_POST["dialplan_details"]); + //add the domain_uuid $_POST["domain_uuid"] = $_SESSION['domain_uuid']; @@ -220,6 +221,70 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { } } + //add fax detection + if (strlen($fax_uuid) > 0) { + //get the fax information + $sql = "select * from v_fax "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and fax_uuid = '".$fax_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $fax_extension = $row["fax_extension"]; + $fax_destination_number = $row["fax_destination_number"]; + $fax_name = $row["fax_name"]; + $fax_email = $row["fax_email"]; + $fax_pin_number = $row["fax_pin_number"]; + $fax_caller_id_name = $row["fax_caller_id_name"]; + $fax_caller_id_number = $row["fax_caller_id_number"]; + $fax_forward_number = $row["fax_forward_number"]; + $fax_description = $row["fax_description"]; + } + unset ($prep_statement); + + //add set tone detect_hits=1 + $dialplan["dialplan_details"][$y]["domain_uuid"] = $_SESSION['domain_uuid']; + $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; + $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set"; + $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "tone_detect_hits=1"; + $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order; + $y++; + + //increment the dialplan detail order + $dialplan_detail_order = $dialplan_detail_order + 10; + + // execute on tone detect + $dialplan["dialplan_details"][$y]["domain_uuid"] = $_SESSION['domain_uuid']; + $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; + $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set"; + $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "execute_on_tone_detect=transfer ".$fax_extension." XML ".$_SESSION["context"]; + $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order; + $y++; + + //increment the dialplan detail order + $dialplan_detail_order = $dialplan_detail_order + 10; + + //add tone_detect fax 1100 r +5000 + $dialplan["dialplan_details"][$y]["domain_uuid"] = $_SESSION['domain_uuid']; + $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; + $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "tone_detect"; + $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "fax 1100 r +5000"; + $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order; + $y++; + + //increment the dialplan detail order + $dialplan_detail_order = $dialplan_detail_order + 10; + + // execute on tone detect + $dialplan["dialplan_details"][$y]["domain_uuid"] = $_SESSION['domain_uuid']; + $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; + $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "sleep"; + $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "3000"]; + $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order; + $y++; + } + //save the dialplan if (strlen($dialplan_details[0][dialplan_detail_data]) > 2) { $orm = new orm; diff --git a/resources/install/scripts/app/dialplan/resources/outbound/100_is_local.lua b/resources/install/scripts/app/dialplan/resources/outbound/100_is_local.lua index 31970e8505..dfe97f7b17 100644 --- a/resources/install/scripts/app/dialplan/resources/outbound/100_is_local.lua +++ b/resources/install/scripts/app/dialplan/resources/outbound/100_is_local.lua @@ -45,12 +45,15 @@ --freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n"); assert(dbh:query(sql, function(row) + --set the outbound caller id if (outbound_caller_id_name ~= nil) then session:execute("export", "caller_id_name="..outbound_caller_id_name); + session:execute("export", "effective_caller_id_name="..outbound_caller_id_name); end if (outbound_caller_id_number ~= nil) then session:execute("export", "caller_id_number="..outbound_caller_id_number); + session:execute("export", "effective_caller_id_number="..outbound_caller_id_number); end --set the local variables @@ -88,9 +91,19 @@ var[key] = value; end + --set the outbound caller id + if (outbound_caller_id_name ~= nil) then + session:execute("export", "caller_id_name="..outbound_caller_id_name); + session:execute("export", "effective_caller_id_name="..outbound_caller_id_name); + end + if (outbound_caller_id_number ~= nil) then + session:execute("export", "caller_id_number="..outbound_caller_id_number); + session:execute("export", "effective_caller_id_number="..outbound_caller_id_number); + end + --send to the console freeswitch.consoleLog("notice", "[app:dialplan:outbound:is_local] " .. cache .. " source: memcache\n"); --transfer the call session:transfer(var["destination_number"], "XML", var["destination_context"]); - end \ No newline at end of file + end