Update call_block_edit.php

This commit is contained in:
FusionPBX 2019-10-28 12:29:29 -06:00 committed by GitHub
parent 666c4a4cb3
commit 4c7b50a8ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 55 additions and 40 deletions

View File

@ -40,32 +40,6 @@
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//define the call_block_get_extensions function
function call_block_get_extensions($select_extension) {
global $text;
//list voicemail
$sql = "select extension, user_context, description from v_extensions ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and enabled = 'true' ";
$sql .= "order by extension asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$result = $database->select($sql, $parameters);
if (is_array($result) && sizeof($result) != 0) {
echo "<optgroup label='".$text['label-voicemail']."'>\n";
foreach ($result as &$row) {
$extension = $row["extension"];
$context = $row["user_context"];
$description = $row["description"];
$selected = $extension == $select_extension ? "selected='selected'" : null;
echo "<option value='Voicemail ".$context." ".$extension."' ".$selected.">".$extension." ".$description."</option>\n";
}
echo "</optgroup>\n";
}
}
//action add or update //action add or update
if (is_uuid($_REQUEST["id"])) { if (is_uuid($_REQUEST["id"])) {
$action = "update"; $action = "update";
@ -77,6 +51,7 @@
//get http post variables and set them to php variables //get http post variables and set them to php variables
if (count($_POST) > 0) { if (count($_POST) > 0) {
$extension_uuid = $_POST["extension_uuid"];
$call_block_name = $_POST["call_block_name"]; $call_block_name = $_POST["call_block_name"];
$call_block_number = $_POST["call_block_number"]; $call_block_number = $_POST["call_block_number"];
$call_block_action = $_POST["call_block_action"]; $call_block_action = $_POST["call_block_action"];
@ -85,7 +60,7 @@
} }
//handle the http post //handle the http post
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//delete the call block //delete the call block
if (permission_exists('call_block_delete')) { if (permission_exists('call_block_delete')) {
@ -163,6 +138,9 @@
if ($action == "add") { if ($action == "add") {
$array['call_block'][0]['call_block_uuid'] = uuid(); $array['call_block'][0]['call_block_uuid'] = uuid();
$array['call_block'][0]['domain_uuid'] = $_SESSION['domain_uuid']; $array['call_block'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
if (is_uuid($extension_uuid)) {
$array['call_block'][0]['extension_uuid'] = $extension_uuid;
}
$array['call_block'][0]['call_block_name'] = $call_block_name; $array['call_block'][0]['call_block_name'] = $call_block_name;
$array['call_block'][0]['call_block_number'] = $call_block_number; $array['call_block'][0]['call_block_number'] = $call_block_number;
$array['call_block'][0]['call_block_count'] = 0; $array['call_block'][0]['call_block_count'] = 0;
@ -205,6 +183,9 @@
$array['call_block'][0]['call_block_uuid'] = $call_block_uuid; $array['call_block'][0]['call_block_uuid'] = $call_block_uuid;
$array['call_block'][0]['domain_uuid'] = $_SESSION['domain_uuid']; $array['call_block'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
if (is_uuid($extension_uuid)) {
$array['call_block'][0]['extension_uuid'] = $extension_uuid;
}
$array['call_block'][0]['call_block_name'] = $call_block_name; $array['call_block'][0]['call_block_name'] = $call_block_name;
$array['call_block'][0]['call_block_number'] = $call_block_number; $array['call_block'][0]['call_block_number'] = $call_block_number;
$array['call_block'][0]['call_block_action'] = $call_block_action; $array['call_block'][0]['call_block_action'] = $call_block_action;
@ -223,9 +204,7 @@
header("Location: call_block.php"); header("Location: call_block.php");
return; return;
} }
} }
} }
//pre-populate the form //pre-populate the form
@ -239,6 +218,7 @@
$database = new database; $database = new database;
$row = $database->select($sql, $parameters, 'row'); $row = $database->select($sql, $parameters, 'row');
if (is_array($row) && sizeof($row) != 0) { if (is_array($row) && sizeof($row) != 0) {
$extension_uuid = $row["extension_uuid"];
$call_block_name = $row["call_block_name"]; $call_block_name = $row["call_block_name"];
$call_block_number = $row["call_block_number"]; $call_block_number = $row["call_block_number"];
$call_block_action = $row["call_block_action"]; $call_block_action = $row["call_block_action"];
@ -248,6 +228,15 @@
unset($sql, $parameters, $row); unset($sql, $parameters, $row);
} }
//get the extensions
$sql = "select extension_uuid, extension, number_alias, user_context, description from v_extensions ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and enabled = 'true' ";
$sql .= "order by extension asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$extensions = $database->select($sql, $parameters);
//create token //create token
$object = new token; $object = new token;
$token = $object->create($_SERVER['PHP_SELF']); $token = $object->create($_SERVER['PHP_SELF']);
@ -334,7 +323,14 @@
else { else {
echo " <option value='Hold'>".$text['label-hold']."</option>\n"; echo " <option value='Hold'>".$text['label-hold']."</option>\n";
} }
call_block_get_extensions($extension); if (is_array($extensions) && sizeof($extensions) != 0) {
echo " <optgroup label='".$text['label-voicemail']."'>\n";
foreach ($extensions as &$row) {
$selected = $extension_uuid == $row['extension_uuid'] ? "selected='selected'" : null;
echo " <option value='Voicemail ".escape($row["user_context"])." ".escape($row["extension"])."' ".$selected.">".escape($row['extension'])." ".escape($row['description'])."</option>\n";
}
echo " </optgroup>\n";
}
echo " </select>\n"; echo " </select>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-action']."\n"; echo $text['description-action']."\n";
@ -342,6 +338,26 @@
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='extension_uuid'>\n";
echo " <option value=''></option>\n";
if (is_array($extensions) && sizeof($extensions) != 0) {
foreach ($extensions as $row) {
$selected = $extension_uuid == $row['extension_uuid'] ? "selected='selected'" : null;
echo " <option value='".urlencode($row["extension_uuid"])."' ".$selected.">".escape($row['extension'])." ".escape($row['description'])."</option>\n";
}
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-enable']."\n";
echo "\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-enabled']."\n"; echo " ".$text['label-enabled']."\n";
@ -382,7 +398,6 @@
echo "<br><br>"; echo "<br><br>";
echo "</form>"; echo "</form>";
//get recent calls from the db (if not editing an existing call block record) //get recent calls from the db (if not editing an existing call block record)
if (!is_uuid($_REQUEST["id"])) { if (!is_uuid($_REQUEST["id"])) {
$sql = "select caller_id_number, caller_id_name, start_epoch, direction, hangup_cause, duration, billsec, xml_cdr_uuid "; $sql = "select caller_id_number, caller_id_name, start_epoch, direction, hangup_cause, duration, billsec, xml_cdr_uuid ";