Time Conditions: Database class integration.
This commit is contained in:
parent
889306af83
commit
033fa2e960
|
|
@ -40,56 +40,54 @@ else {
|
|||
|
||||
//set the dialplan uuid
|
||||
$dialplan_uuids = $_REQUEST["id"];
|
||||
$app_uuid = check_str($_REQUEST['app_uuid']);
|
||||
|
||||
//delete the dialplans
|
||||
if (sizeof($dialplan_uuids) > 0) {
|
||||
if (is_array($dialplan_uuids) && @sizeof($dialplan_uuids) != 0) {
|
||||
|
||||
//get dialplan contexts
|
||||
//get dialplan contexts for each
|
||||
foreach ($dialplan_uuids as $dialplan_uuid) {
|
||||
//check each
|
||||
$dialplan_uuid = check_str($dialplan_uuid);
|
||||
|
||||
//get the dialplan data
|
||||
if (is_uuid($dialplan_uuid)) {
|
||||
$sql = "select dialplan_context from v_dialplans ";
|
||||
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$dialplan_contexts[] = $row["dialplan_context"];
|
||||
}
|
||||
unset($prep_statement);
|
||||
$sql .= "where dialplan_uuid = :dialplan_uuid ";
|
||||
$parameters['dialplan_uuid'] = $dialplan_uuid;
|
||||
$database = new database;
|
||||
$dialplan_contexts[] = $database->select($sql, $parameters, 'column');
|
||||
unset($sql, $parameters);
|
||||
}
|
||||
}
|
||||
|
||||
//start the atomic transaction
|
||||
$db->beginTransaction();
|
||||
|
||||
//delete dialplan and details
|
||||
$dialplans_deleted = 0;
|
||||
foreach ($dialplan_uuids as $dialplan_uuid) {
|
||||
//delete child data
|
||||
$sql = "delete from v_dialplan_details ";
|
||||
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
|
||||
$sql .= "and domain_uuid = '".$domain_uuid."'; ";
|
||||
$db->query($sql);
|
||||
unset($sql);
|
||||
foreach ($dialplan_uuids as $x => $dialplan_uuid) {
|
||||
//build delete array of child data
|
||||
$array['dialplan_details'][$x]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplan_details'][$x]['domain_uuid'] = $domain_uuid;
|
||||
|
||||
//delete parent data
|
||||
$sql = "delete from v_dialplans ";
|
||||
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
|
||||
$sql .= "and domain_uuid = '".$domain_uuid."' ";
|
||||
$sql .= "and app_uuid = '4b821450-926b-175a-af93-a03c441818b1'; ";
|
||||
$db->query($sql);
|
||||
unset($sql);
|
||||
//build delete array of parent data
|
||||
$array['dialplans'][$x]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplans'][$x]['domain_uuid'] = $domain_uuid;
|
||||
$array['dialplans'][$x]['app_uuid'] = '4b821450-926b-175a-af93-a03c441818b1';
|
||||
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('dialplan_detail_delete', 'temp');
|
||||
$p->add('dialplan_delete', 'temp');
|
||||
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = 'time_conditions';
|
||||
$database->app_uuid = '4b821450-926b-175a-af93-a03c441818b1';
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
|
||||
//revoke temporary permissions
|
||||
$p->delete('dialplan_detail_delete', 'temp');
|
||||
$p->delete('dialplan_delete', 'temp');
|
||||
|
||||
//count the time conditions that were deleted
|
||||
$dialplans_deleted++;
|
||||
}
|
||||
|
||||
//commit the atomic transaction
|
||||
$db->commit();
|
||||
|
||||
//synchronize the xml config
|
||||
save_dialplan_xml();
|
||||
|
||||
|
|
@ -103,10 +101,13 @@ else {
|
|||
$cache->delete("dialplan:".$dialplan_context);
|
||||
}
|
||||
}
|
||||
|
||||
//set message
|
||||
message::add($text['message-delete'].($dialplans_deleted > 1 ? ": ".$dialplans_deleted : null));
|
||||
|
||||
}
|
||||
|
||||
//redirect the browser
|
||||
$_SESSION["message"] = $text['message-delete'].(($dialplans_deleted > 1) ? ": ".$dialplans_deleted : null);
|
||||
header("Location: ".PROJECT_PATH."/app/time_conditions/time_conditions.php");
|
||||
header("Location: time_conditions.php");
|
||||
|
||||
?>
|
||||
|
|
@ -55,9 +55,9 @@
|
|||
unset($preset_region);
|
||||
|
||||
//set the action as an add or an update
|
||||
if (isset($_REQUEST["id"])) {
|
||||
if (is_uuid($_REQUEST["id"])) {
|
||||
$action = "update";
|
||||
$dialplan_uuid = check_str($_REQUEST["id"]);
|
||||
$dialplan_uuid = $_REQUEST["id"];
|
||||
}
|
||||
else {
|
||||
$action = "add";
|
||||
|
|
@ -65,20 +65,20 @@
|
|||
|
||||
//get the post variables
|
||||
if (count($_POST) > 0) {
|
||||
$domain_uuid = check_str($_POST["domain_uuid"]);
|
||||
$dialplan_name = check_str($_POST["dialplan_name"]);
|
||||
$dialplan_number = check_str($_POST["dialplan_number"]);
|
||||
$dialplan_order = check_str($_POST["dialplan_order"]);
|
||||
$domain_uuid = $_POST["domain_uuid"];
|
||||
$dialplan_name = $_POST["dialplan_name"];
|
||||
$dialplan_number = $_POST["dialplan_number"];
|
||||
$dialplan_order = $_POST["dialplan_order"];
|
||||
|
||||
$dialplan_anti_action = check_str($_POST["dialplan_anti_action"]);
|
||||
$dialplan_anti_action = $_POST["dialplan_anti_action"];
|
||||
$dialplan_anti_action_array = explode(":", $dialplan_anti_action);
|
||||
$dialplan_anti_action_app = array_shift($dialplan_anti_action_array);
|
||||
$dialplan_anti_action_data = join(':', $dialplan_anti_action_array);
|
||||
if (permission_exists('time_condition_context')) {
|
||||
$dialplan_context = check_str($_POST["dialplan_context"]);
|
||||
$dialplan_context = $_POST["dialplan_context"];
|
||||
}
|
||||
$dialplan_enabled = check_str($_POST["dialplan_enabled"]);
|
||||
$dialplan_description = check_str($_POST["dialplan_description"]);
|
||||
$dialplan_enabled = $_POST["dialplan_enabled"];
|
||||
$dialplan_description = $_POST["dialplan_description"];
|
||||
|
||||
if (!permission_exists('time_condition_domain')) {
|
||||
$domain_uuid = $_SESSION['domain_uuid'];
|
||||
|
|
@ -86,6 +86,7 @@
|
|||
}
|
||||
|
||||
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
|
||||
//check for all required data
|
||||
//if (strlen($domain_uuid) == 0) { $msg .= $text['label-required-domain_uuid']."<br>\n"; }
|
||||
if (strlen($dialplan_name) == 0) { $msg .= $text['label-required-dialplan_name']."<br>\n"; }
|
||||
|
|
@ -110,7 +111,7 @@
|
|||
|
||||
//set the context for users that do not have the permission
|
||||
if (permission_exists('time_condition_context')) {
|
||||
$dialplan_context = check_str($_POST["dialplan_context"]);
|
||||
$dialplan_context = $_POST["dialplan_context"];
|
||||
}
|
||||
else {
|
||||
if ($action == 'add') {
|
||||
|
|
@ -118,77 +119,68 @@
|
|||
}
|
||||
}
|
||||
|
||||
//start the atomic transaction
|
||||
$count = $db->exec("BEGIN;"); //returns affected rows
|
||||
|
||||
//process main dialplan entry
|
||||
if ($action == "add") {
|
||||
|
||||
//add main dialplan entry
|
||||
//build insert array
|
||||
$dialplan_uuid = uuid();
|
||||
$sql = "insert into v_dialplans ";
|
||||
$sql .= "(";
|
||||
$sql .= "domain_uuid, ";
|
||||
$sql .= "dialplan_uuid, ";
|
||||
$sql .= "app_uuid, ";
|
||||
$sql .= "dialplan_name, ";
|
||||
$sql .= "dialplan_number, ";
|
||||
$sql .= "dialplan_order, ";
|
||||
$sql .= "dialplan_continue, ";
|
||||
$sql .= "dialplan_context, ";
|
||||
$sql .= "dialplan_enabled, ";
|
||||
$sql .= "dialplan_description ";
|
||||
$sql .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
if (strlen($domain_uuid) == 0) {
|
||||
$sql .= "null, ";
|
||||
}
|
||||
else {
|
||||
$sql .= "'".$domain_uuid."', ";
|
||||
}
|
||||
$sql .= "'".$dialplan_uuid."', ";
|
||||
$sql .= "'4b821450-926b-175a-af93-a03c441818b1', ";
|
||||
$sql .= "'".$dialplan_name."', ";
|
||||
$sql .= "'".$dialplan_number."', ";
|
||||
$sql .= "'".$dialplan_order."', ";
|
||||
$sql .= "'false', ";
|
||||
$sql .= "'".$dialplan_context."', ";
|
||||
$sql .= "'".$dialplan_enabled."', ";
|
||||
$sql .= "'".$dialplan_description."' ";
|
||||
$sql .= ")";
|
||||
$array['dialplans'][0]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplans'][0]['app_uuid'] = '4b821450-926b-175a-af93-a03c441818b1';
|
||||
$array['dialplans'][0]['dialplan_continue'] = 'false';
|
||||
$array['dialplans'][0]['dialplan_context'] = $dialplan_context;
|
||||
|
||||
//execute query
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('dialplan_add', 'temp');
|
||||
}
|
||||
else if ($action == "update") {
|
||||
//update main dialplan entry
|
||||
$sql = "update v_dialplans set ";
|
||||
if (strlen($domain_uuid) == 0) {
|
||||
$sql .= "domain_uuid = null, ";
|
||||
}
|
||||
else {
|
||||
$sql .= "domain_uuid = '".$domain_uuid."', ";
|
||||
}
|
||||
$sql .= "dialplan_name = '".$dialplan_name."', ";
|
||||
$sql .= "dialplan_number = '".$dialplan_number."', ";
|
||||
$sql .= "dialplan_order = '".$dialplan_order."', ";
|
||||
$sql .= "dialplan_continue = 'true', ";
|
||||
if (strlen($dialplan_context) > 0) {
|
||||
$sql .= "dialplan_context = '".$dialplan_context."', ";
|
||||
}
|
||||
$sql .= "dialplan_enabled = '".$dialplan_enabled."', ";
|
||||
$sql .= "dialplan_description = '".$dialplan_description."' ";
|
||||
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
//build delete array
|
||||
$array['dialplan_details'][0]['dialplan_uuid'] = $dialplan_uuid;
|
||||
|
||||
//delete existing dialplan details
|
||||
$sql = "delete from v_dialplan_details ";
|
||||
$sql .= "where dialplan_uuid = '".$dialplan_uuid."'; ";
|
||||
$db->query($sql);
|
||||
unset($sql);
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('dialplan_detail_delete', 'temp');
|
||||
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = 'time_conditions';
|
||||
$database->app_uuid = '4b821450-926b-175a-af93-a03c441818b1';
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
|
||||
//revoke temporary permissions
|
||||
$p->delete('dialplan_detail_delete', 'temp');
|
||||
|
||||
//build update array
|
||||
$array['dialplans'][0]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplans'][0]['dialplan_continue'] = 'true';
|
||||
if (strlen($dialplan_context) > 0) {
|
||||
$array['dialplans'][0]['dialplan_context'] = $dialplan_context;
|
||||
}
|
||||
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('dialplan_edit', 'temp');
|
||||
}
|
||||
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//add common fields to insert/update array
|
||||
$array['dialplans'][0]['domain_uuid'] = is_uuid($domain_uuid) ? $domain_uuid : null;
|
||||
$array['dialplans'][0]['dialplan_name'] = $dialplan_name;
|
||||
$array['dialplans'][0]['dialplan_number'] = $dialplan_number;
|
||||
$array['dialplans'][0]['dialplan_order'] = $dialplan_order;
|
||||
$array['dialplans'][0]['dialplan_enabled'] = $dialplan_enabled;
|
||||
$array['dialplans'][0]['dialplan_description'] = $dialplan_description;
|
||||
|
||||
//execute insert/update
|
||||
$database = new database;
|
||||
$database->app_name = 'time_conditions';
|
||||
$database->app_uuid = '4b821450-926b-175a-af93-a03c441818b1';
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
//revoke temporary permissions
|
||||
$p->delete('dialplan_add', 'temp');
|
||||
$p->delete('dialplan_edit', 'temp');
|
||||
}
|
||||
|
||||
//initialize dialplan detail group and order numbers
|
||||
|
|
@ -271,192 +263,155 @@
|
|||
}
|
||||
}
|
||||
|
||||
//process conditions
|
||||
$conditions_exist = false;
|
||||
//add conditions to insert array for custom and preset conditions
|
||||
if (is_array($_REQUEST['variable'])) {
|
||||
$x = 0;
|
||||
foreach ($_REQUEST['variable'] as $group_id => $conditions) {
|
||||
|
||||
//begin insert query for custom and preset conditions
|
||||
$sql = "insert into v_dialplan_details ";
|
||||
$sql .= "( ";
|
||||
$sql .= "domain_uuid, ";
|
||||
$sql .= "dialplan_uuid, ";
|
||||
$sql .= "dialplan_detail_uuid, ";
|
||||
$sql .= "dialplan_detail_tag, ";
|
||||
$sql .= "dialplan_detail_type, ";
|
||||
$sql .= "dialplan_detail_data, ";
|
||||
$sql .= "dialplan_detail_break, ";
|
||||
$sql .= "dialplan_detail_inline, ";
|
||||
$sql .= "dialplan_detail_group, ";
|
||||
$sql .= "dialplan_detail_order ";
|
||||
$sql .= ") ";
|
||||
$sql .= "values ";
|
||||
$group_conditions_exist[$group_id] = false;
|
||||
|
||||
//add conditions
|
||||
if (is_array($_REQUEST['variable'])) foreach ($_REQUEST['variable'] as $group_id => $conditions) {
|
||||
//determine if preset
|
||||
$is_preset = (in_array($group_id, $_REQUEST['preset'])) ? true : false;
|
||||
|
||||
$group_conditions_exist[$group_id] = false;
|
||||
|
||||
//determine if preset
|
||||
$is_preset = (in_array($group_id, $_REQUEST['preset'])) ? true : false;
|
||||
|
||||
//set group and order number
|
||||
$dialplan_detail_group_user = check_str($_POST["group_$group_id"]);
|
||||
if($dialplan_detail_group_user!='') {
|
||||
$dialplan_detail_group = $dialplan_detail_group_user;
|
||||
} else {
|
||||
$dialplan_detail_group = $group_id;
|
||||
}
|
||||
|
||||
$dialplan_detail_order = 0;
|
||||
|
||||
if (is_array($conditions)) foreach ($conditions as $cond_num => $cond_var) {
|
||||
if ($cond_var != '') {
|
||||
$cond_start = $_REQUEST['value'][$group_id][$cond_num]['start'];
|
||||
$cond_stop = $_REQUEST['value'][$group_id][$cond_num]['stop'];
|
||||
|
||||
//convert time-of-day to minute-of-day (due to inconsistencies with time-of-day on some systems)
|
||||
if ($cond_var == 'time-of-day') {
|
||||
$cond_var = 'minute-of-day';
|
||||
$array_cond_start = explode(':', $cond_start);
|
||||
$cond_start = ($array_cond_start[0] * 60) + $array_cond_start[1];
|
||||
if ($cond_stop != '') {
|
||||
$array_cond_stop = explode(':', $cond_stop);
|
||||
$cond_stop = ($array_cond_stop[0] * 60) + $array_cond_stop[1];
|
||||
}
|
||||
}
|
||||
|
||||
$cond_value = $cond_start;
|
||||
if ($cond_stop != '') {
|
||||
$range_indicator = ($cond_var == 'date-time') ? '~' : '-';
|
||||
$cond_value .= $range_indicator.$cond_stop;
|
||||
}
|
||||
|
||||
if (!$group_conditions_exist[$group_id]) {
|
||||
//add destination number condition
|
||||
$dialplan_detail_order += 10;
|
||||
$sql .= ($conditions_exist) ? ", ( " : "( ";
|
||||
if (strlen($domain_uuid) == 0) {
|
||||
$sql .= "null, ";
|
||||
}
|
||||
else {
|
||||
$sql .= "'".$domain_uuid."', ";
|
||||
}
|
||||
$sql .= "'".$dialplan_uuid."', ";
|
||||
$sql .= "'".uuid()."', ";
|
||||
$sql .= "'condition', ";
|
||||
$sql .= "'destination_number', ";
|
||||
$sql .= "'^".$dialplan_number."$', ";
|
||||
$sql .= "null, ";
|
||||
$sql .= "null, ";
|
||||
$sql .= "'".$dialplan_detail_group."', ";
|
||||
$sql .= "'".$dialplan_detail_order."' ";
|
||||
$sql .= ") ";
|
||||
}
|
||||
|
||||
//add condition to query string
|
||||
$dialplan_detail_order += 10;
|
||||
$sql .= ", ( ";
|
||||
if (strlen($domain_uuid) == 0) {
|
||||
$sql .= "null, ";
|
||||
}
|
||||
else {
|
||||
$sql .= "'".$domain_uuid."', ";
|
||||
}
|
||||
$sql .= "'".$dialplan_uuid."', ";
|
||||
$sql .= "'".uuid()."', ";
|
||||
$sql .= "'condition', ";
|
||||
$sql .= "'".$cond_var."', ";
|
||||
$sql .= "'".$cond_value."', ";
|
||||
$sql .= "'never', ";
|
||||
$sql .= "null, ";
|
||||
$sql .= "'".$dialplan_detail_group."', ";
|
||||
$sql .= "'".$dialplan_detail_order."' ";
|
||||
$sql .= ") ";
|
||||
|
||||
$conditions_exist = true;
|
||||
$group_conditions_exist[$group_id] = true;
|
||||
} //if
|
||||
} //for each
|
||||
|
||||
//continue adding to query only if conditions exist in current group
|
||||
if ($group_conditions_exist[$group_id]) {
|
||||
|
||||
//determine group action app and data
|
||||
$dialplan_action = check_str($_REQUEST["dialplan_action"][$group_id]);
|
||||
if ($dialplan_action == '') {
|
||||
if ($is_preset) {
|
||||
if (check_str($_REQUEST['default_preset_action']) != '') {
|
||||
$dialplan_action = check_str($_REQUEST['default_preset_action']);
|
||||
}
|
||||
else if (check_str($_REQUEST['dialplan_anti_action']) != '') {
|
||||
$dialplan_action = check_str($_REQUEST['dialplan_anti_action']);
|
||||
}
|
||||
}
|
||||
//set group and order number
|
||||
$dialplan_detail_group_user = $_POST["group_$group_id"];
|
||||
if ($dialplan_detail_group_user != '') {
|
||||
$dialplan_detail_group = $dialplan_detail_group_user;
|
||||
}
|
||||
else {
|
||||
$dialplan_detail_group = $group_id;
|
||||
}
|
||||
|
||||
if ($dialplan_action != '') {
|
||||
//if preset, set log variable
|
||||
if ($is_preset && is_array($_REQUEST['preset'])) {
|
||||
foreach ($_REQUEST['preset'] as $preset_number => $preset_group_id) {
|
||||
if ($group_id == $preset_group_id) {
|
||||
if (is_array($available_presets[$preset_number])) {
|
||||
foreach ($available_presets[$preset_number] as $available_preset_name => $meh) {
|
||||
$dialplan_detail_order += 10;
|
||||
$sql .= ", ( ";
|
||||
if (strlen($domain_uuid) == 0) {
|
||||
$sql .= "null, ";
|
||||
}
|
||||
else {
|
||||
$sql .= "'".$domain_uuid."', ";
|
||||
}
|
||||
$sql .= "'".$dialplan_uuid."', ";
|
||||
$sql .= "'".uuid()."', ";
|
||||
$sql .= "'action', ";
|
||||
$sql .= "'set', ";
|
||||
$sql .= "'preset=".$available_preset_name."', ";
|
||||
$sql .= "null, ";
|
||||
$sql .= "'true', ";
|
||||
$sql .= "'".$dialplan_detail_group."', ";
|
||||
$sql .= "'".$dialplan_detail_order."' ";
|
||||
$sql .= ") ";
|
||||
}
|
||||
$dialplan_detail_order = 0;
|
||||
|
||||
if (is_array($conditions)) {
|
||||
foreach ($conditions as $cond_num => $cond_var) {
|
||||
if ($cond_var != '') {
|
||||
$cond_start = $_REQUEST['value'][$group_id][$cond_num]['start'];
|
||||
$cond_stop = $_REQUEST['value'][$group_id][$cond_num]['stop'];
|
||||
|
||||
//convert time-of-day to minute-of-day (due to inconsistencies with time-of-day on some systems)
|
||||
if ($cond_var == 'time-of-day') {
|
||||
$cond_var = 'minute-of-day';
|
||||
$array_cond_start = explode(':', $cond_start);
|
||||
$cond_start = ($array_cond_start[0] * 60) + $array_cond_start[1];
|
||||
if ($cond_stop != '') {
|
||||
$array_cond_stop = explode(':', $cond_stop);
|
||||
$cond_stop = ($array_cond_stop[0] * 60) + $array_cond_stop[1];
|
||||
}
|
||||
}
|
||||
|
||||
$cond_value = $cond_start;
|
||||
if ($cond_stop != '') {
|
||||
$range_indicator = ($cond_var == 'date-time') ? '~' : '-';
|
||||
$cond_value .= $range_indicator.$cond_stop;
|
||||
}
|
||||
|
||||
if (!$group_conditions_exist[$group_id]) {
|
||||
//add destination number condition
|
||||
$dialplan_detail_order += 10;
|
||||
$array['dialplan_details'][$x]['domain_uuid'] = is_uuid($domain_uuid) ? $domain_uuid : null;
|
||||
$array['dialplan_details'][$x]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_uuid'] = uuid();
|
||||
$array['dialplan_details'][$x]['dialplan_detail_tag'] = 'condition';
|
||||
$array['dialplan_details'][$x]['dialplan_detail_type'] = 'destination_number';
|
||||
$array['dialplan_details'][$x]['dialplan_detail_data'] = '^'.$dialplan_number.'$';
|
||||
$array['dialplan_details'][$x]['dialplan_detail_break'] = null;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_inline'] = null;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_group'] = $dialplan_detail_group;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_order'] = $dialplan_detail_order;
|
||||
$x++;
|
||||
}
|
||||
|
||||
//add condition to query string
|
||||
$dialplan_detail_order += 10;
|
||||
$array['dialplan_details'][$x]['domain_uuid'] = is_uuid($domain_uuid) ? $domain_uuid : null;
|
||||
$array['dialplan_details'][$x]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_uuid'] = uuid();
|
||||
$array['dialplan_details'][$x]['dialplan_detail_tag'] = 'condition';
|
||||
$array['dialplan_details'][$x]['dialplan_detail_type'] = $cond_var;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_data'] = $cond_value;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_break'] = 'never';
|
||||
$array['dialplan_details'][$x]['dialplan_detail_inline'] = null;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_group'] = $dialplan_detail_group;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_order'] = $dialplan_detail_order;
|
||||
$x++;
|
||||
|
||||
$group_conditions_exist[$group_id] = true;
|
||||
} //if
|
||||
} //foreach
|
||||
} //if
|
||||
|
||||
//continue adding to query only if conditions exist in current group
|
||||
if ($group_conditions_exist[$group_id]) {
|
||||
|
||||
//determine group action app and data
|
||||
$dialplan_action = $_REQUEST["dialplan_action"][$group_id];
|
||||
if ($dialplan_action == '') {
|
||||
if ($is_preset) {
|
||||
if ($_REQUEST['default_preset_action'] != '') {
|
||||
$dialplan_action = $_REQUEST['default_preset_action'];
|
||||
}
|
||||
else if ($_REQUEST['dialplan_anti_action'] != '') {
|
||||
$dialplan_action = $_REQUEST['dialplan_anti_action'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//parse group app and data
|
||||
if (substr_count($dialplan_action, ":") > 0) {
|
||||
$dialplan_action_array = explode(":", $dialplan_action);
|
||||
$dialplan_action_app = array_shift($dialplan_action_array);
|
||||
$dialplan_action_data = join(':', $dialplan_action_array);
|
||||
}
|
||||
else {
|
||||
$dialplan_action_app = $dialplan_action;
|
||||
$dialplan_action_data = '';
|
||||
}
|
||||
if ($dialplan_action != '') {
|
||||
//if preset, set log variable
|
||||
if ($is_preset && is_array($_REQUEST['preset'])) {
|
||||
foreach ($_REQUEST['preset'] as $preset_number => $preset_group_id) {
|
||||
if ($group_id == $preset_group_id) {
|
||||
if (is_array($available_presets[$preset_number])) {
|
||||
foreach ($available_presets[$preset_number] as $available_preset_name => $meh) {
|
||||
$dialplan_detail_order += 10;
|
||||
$array['dialplan_details'][$x]['domain_uuid'] = is_uuid($domain_uuid) ? $domain_uuid : null;
|
||||
$array['dialplan_details'][$x]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_uuid'] = uuid();
|
||||
$array['dialplan_details'][$x]['dialplan_detail_tag'] = 'action';
|
||||
$array['dialplan_details'][$x]['dialplan_detail_type'] = 'set';
|
||||
$array['dialplan_details'][$x]['dialplan_detail_data'] = 'preset='.$available_preset_name;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_break'] = null;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_inline'] = 'true';
|
||||
$array['dialplan_details'][$x]['dialplan_detail_group'] = $dialplan_detail_group;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_order'] = $dialplan_detail_order;
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//add group action to query
|
||||
$dialplan_detail_order += 10;
|
||||
$sql .= ", ( ";
|
||||
if (strlen($domain_uuid) == 0) {
|
||||
$sql .= "null, ";
|
||||
//parse group app and data
|
||||
if (substr_count($dialplan_action, ":") > 0) {
|
||||
$dialplan_action_array = explode(":", $dialplan_action);
|
||||
$dialplan_action_app = array_shift($dialplan_action_array);
|
||||
$dialplan_action_data = join(':', $dialplan_action_array);
|
||||
}
|
||||
else {
|
||||
$dialplan_action_app = $dialplan_action;
|
||||
$dialplan_action_data = '';
|
||||
}
|
||||
|
||||
//add group action to query
|
||||
$dialplan_detail_order += 10;
|
||||
$array['dialplan_details'][$x]['domain_uuid'] = is_uuid($domain_uuid) ? $domain_uuid : null;
|
||||
$array['dialplan_details'][$x]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_uuid'] = uuid();
|
||||
$array['dialplan_details'][$x]['dialplan_detail_tag'] = 'action';
|
||||
$array['dialplan_details'][$x]['dialplan_detail_type'] = $dialplan_action_app;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_data'] = $dialplan_action_data;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_break'] = null;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_inline'] = null;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_group'] = $dialplan_detail_group;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_order'] = $dialplan_detail_order;
|
||||
$x++;
|
||||
}
|
||||
else {
|
||||
$sql .= "'".$domain_uuid."', ";
|
||||
}
|
||||
$sql .= "'".$dialplan_uuid."', ";
|
||||
$sql .= "'".uuid()."', ";
|
||||
$sql .= "'action', ";
|
||||
$sql .= "'".$dialplan_action_app."', ";
|
||||
$sql .= "'".$dialplan_action_data."', ";
|
||||
$sql .= "null, ";
|
||||
$sql .= "null, ";
|
||||
$sql .= "'".$dialplan_detail_group."', ";
|
||||
$sql .= "'".$dialplan_detail_order."' ";
|
||||
$sql .= ") ";
|
||||
}
|
||||
}
|
||||
} //for each
|
||||
|
||||
} //foreach
|
||||
} //if
|
||||
|
||||
//add to query for default anti-action (if defined)
|
||||
if (strlen($dialplan_anti_action_app) > 0) {
|
||||
|
|
@ -467,53 +422,49 @@
|
|||
|
||||
//add destination number condition
|
||||
$dialplan_detail_order += 10;
|
||||
$sql .= ", ( ";
|
||||
if (strlen($domain_uuid) == 0) {
|
||||
$sql .= "null, ";
|
||||
}
|
||||
else {
|
||||
$sql .= "'".$domain_uuid."', ";
|
||||
}
|
||||
$sql .= "'".$dialplan_uuid."', ";
|
||||
$sql .= "'".uuid()."', ";
|
||||
$sql .= "'condition', ";
|
||||
$sql .= "'destination_number', ";
|
||||
$sql .= "'^".$dialplan_number."$', ";
|
||||
$sql .= "null, ";
|
||||
$sql .= "null, ";
|
||||
$sql .= "'".$dialplan_detail_group."', ";
|
||||
$sql .= "'".$dialplan_detail_order."' ";
|
||||
$sql .= ") ";
|
||||
$array['dialplan_details'][$x]['domain_uuid'] = is_uuid($domain_uuid) ? $domain_uuid : null;
|
||||
$array['dialplan_details'][$x]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_uuid'] = uuid();
|
||||
$array['dialplan_details'][$x]['dialplan_detail_tag'] = 'condition';
|
||||
$array['dialplan_details'][$x]['dialplan_detail_type'] = 'destination_number';
|
||||
$array['dialplan_details'][$x]['dialplan_detail_data'] = '^'.$dialplan_number.'$';
|
||||
$array['dialplan_details'][$x]['dialplan_detail_break'] = null;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_inline'] = null;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_group'] = $dialplan_detail_group;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_order'] = $dialplan_detail_order;
|
||||
$x++;
|
||||
|
||||
//add anti-action
|
||||
$dialplan_detail_order += 10;
|
||||
$sql .= ", ( ";
|
||||
if (strlen($domain_uuid) == 0) {
|
||||
$sql .= "null, ";
|
||||
}
|
||||
else {
|
||||
$sql .= "'".$domain_uuid."', ";
|
||||
}
|
||||
$sql .= "'".$dialplan_uuid."', ";
|
||||
$sql .= "'".uuid()."', ";
|
||||
$sql .= "'action', ";
|
||||
$sql .= "'".$dialplan_anti_action_app."', ";
|
||||
$sql .= "'".$dialplan_anti_action_data."', ";
|
||||
$sql .= "null, ";
|
||||
$sql .= "null, ";
|
||||
$sql .= "'".$dialplan_detail_group."', ";
|
||||
$sql .= "'".$dialplan_detail_order."' ";
|
||||
$sql .= ") ";
|
||||
$array['dialplan_details'][$x]['domain_uuid'] = is_uuid($domain_uuid) ? $domain_uuid : null;
|
||||
$array['dialplan_details'][$x]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_uuid'] = uuid();
|
||||
$array['dialplan_details'][$x]['dialplan_detail_tag'] = 'action';
|
||||
$array['dialplan_details'][$x]['dialplan_detail_type'] = $dialplan_anti_action_app;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_data'] = $dialplan_anti_action_data;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_break'] = null;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_inline'] = null;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_group'] = $dialplan_detail_group;
|
||||
$array['dialplan_details'][$x]['dialplan_detail_order'] = $dialplan_detail_order;
|
||||
$x++;
|
||||
}
|
||||
|
||||
//execute query
|
||||
if ($conditions_exist) {
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
}
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('dialplan_detail_add', 'temp');
|
||||
|
||||
//commit the atomic transaction
|
||||
$count = $db->exec("COMMIT;");
|
||||
//execute insert
|
||||
$database = new database;
|
||||
$database->app_name = 'time_conditions';
|
||||
$database->app_uuid = '4b821450-926b-175a-af93-a03c441818b1';
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
//revoke temporary permissions
|
||||
$p->delete('dialplan_detail_add', 'temp');
|
||||
}
|
||||
|
||||
//update the dialplan xml
|
||||
$dialplans = new dialplan;
|
||||
|
|
@ -536,51 +487,37 @@
|
|||
else if ($action == "update") {
|
||||
message::add($text['message-update']);
|
||||
}
|
||||
header("Location: time_condition_edit.php?id=".$dialplan_uuid.(($app_uuid != '') ? "&app_uuid=".$app_uuid : null));
|
||||
return;
|
||||
header("Location: time_condition_edit.php?id=".$dialplan_uuid.($app_uuid != '' ? "&app_uuid=".$app_uuid : null));
|
||||
exit;
|
||||
|
||||
} //end if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
|
||||
}
|
||||
|
||||
//get existing data to pre-populate form
|
||||
if ($dialplan_uuid != '' && $_POST["persistformvar"] != "true") {
|
||||
|
||||
//add the dialplan permission
|
||||
$p = new permissions;
|
||||
$p->add("dialplan_add", 'temp');
|
||||
$p->add("dialplan_detail_add", 'temp');
|
||||
$p->add("dialplan_edit", 'temp');
|
||||
$p->add("dialplan_detail_edit", 'temp');
|
||||
if (is_uuid($dialplan_uuid) && $_POST["persistformvar"] != "true") {
|
||||
|
||||
//get main dialplan entry
|
||||
$sql = "select * from v_dialplans ";
|
||||
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$dialplans = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
if (is_array($dialplans)) {
|
||||
foreach ($dialplans as &$row) {
|
||||
$domain_uuid = $row["domain_uuid"];
|
||||
//$app_uuid = $row["app_uuid"];
|
||||
$dialplan_name = $row["dialplan_name"];
|
||||
$dialplan_number = $row["dialplan_number"];
|
||||
$dialplan_order = $row["dialplan_order"];
|
||||
$dialplan_continue = $row["dialplan_continue"];
|
||||
$dialplan_context = $row["dialplan_context"];
|
||||
$dialplan_enabled = $row["dialplan_enabled"];
|
||||
$dialplan_description = $row["dialplan_description"];
|
||||
}
|
||||
$sql .= "where dialplan_uuid = :dialplan_uuid ";
|
||||
$parameters['dialplan_uuid'] = $dialplan_uuid;
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
if (is_array($row) && @sizeof($row) != 0) {
|
||||
$domain_uuid = $row["domain_uuid"];
|
||||
//$app_uuid = $row["app_uuid"];
|
||||
$dialplan_name = $row["dialplan_name"];
|
||||
$dialplan_number = $row["dialplan_number"];
|
||||
$dialplan_order = $row["dialplan_order"];
|
||||
$dialplan_continue = $row["dialplan_continue"];
|
||||
$dialplan_context = $row["dialplan_context"];
|
||||
$dialplan_enabled = $row["dialplan_enabled"];
|
||||
$dialplan_description = $row["dialplan_description"];
|
||||
}
|
||||
unset ($prep_statement);
|
||||
|
||||
//remove the temporary permission
|
||||
$p->delete("dialplan_add", 'temp');
|
||||
$p->delete("dialplan_detail_add", 'temp');
|
||||
$p->delete("dialplan_edit", 'temp');
|
||||
$p->delete("dialplan_detail_edit", 'temp');
|
||||
unset($sql, $parameters, $row);
|
||||
|
||||
//get dialplan detail conditions
|
||||
$sql = "select dialplan_detail_group, dialplan_detail_tag, dialplan_detail_type, dialplan_detail_data from v_dialplan_details ";
|
||||
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
|
||||
$sql = "select dialplan_detail_group, dialplan_detail_tag, dialplan_detail_type, dialplan_detail_data ";
|
||||
$sql .= "from v_dialplan_details ";
|
||||
$sql .= "where dialplan_uuid = :dialplan_uuid ";
|
||||
$sql .= "and ";
|
||||
$sql .= "( ";
|
||||
$sql .= " ( ";
|
||||
|
|
@ -593,10 +530,10 @@
|
|||
$sql .= " ) ";
|
||||
$sql .= ") ";
|
||||
$sql .= "order by dialplan_detail_group asc, dialplan_detail_order asc";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$dialplan_details = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
unset ($prep_statement, $sql);
|
||||
$parameters['dialplan_uuid'] = $dialplan_uuid;
|
||||
$database = new database;
|
||||
$dialplan_details = $database->select($sql, $parameters, 'all');
|
||||
unset($sql, $parameters);
|
||||
|
||||
//load current conditions into array (combined by group), and retrieve action and anti-action
|
||||
$c = 0;
|
||||
|
|
@ -619,20 +556,22 @@
|
|||
//loop through available presets (if any)
|
||||
if (is_array($available_presets)) {
|
||||
foreach ($available_presets as $preset_number => $preset) {
|
||||
if (is_array($preset)) foreach ($preset as $preset_name => $preset_variables) {
|
||||
//loop through each condition group
|
||||
if (is_array($current_conditions)) {
|
||||
foreach ($current_conditions as $group_id => $condition_variables) {
|
||||
$matches = 0;
|
||||
if (is_array($condition_variables)) {
|
||||
foreach ($condition_variables as $condition_variable_name => $condition_variable_value) {
|
||||
//count matching variable values
|
||||
if ($preset_variables[$condition_variable_name] == $condition_variable_value) { $matches++; }
|
||||
if (is_array($preset)) {
|
||||
foreach ($preset as $preset_name => $preset_variables) {
|
||||
//loop through each condition group
|
||||
if (is_array($current_conditions)) {
|
||||
foreach ($current_conditions as $group_id => $condition_variables) {
|
||||
$matches = 0;
|
||||
if (is_array($condition_variables)) {
|
||||
foreach ($condition_variables as $condition_variable_name => $condition_variable_value) {
|
||||
//count matching variable values
|
||||
if ($preset_variables[$condition_variable_name] == $condition_variable_value) { $matches++; }
|
||||
}
|
||||
}
|
||||
//if all preset variables found, then condition is a preset
|
||||
if ($matches == sizeof($preset_variables)) {
|
||||
$current_presets[$preset_number] = $group_id;
|
||||
}
|
||||
}
|
||||
//if all preset variables found, then condition is a preset
|
||||
if ($matches == sizeof($preset_variables)) {
|
||||
$current_presets[$preset_number] = $group_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -854,13 +793,18 @@
|
|||
|
||||
function alternate_destination_required() {
|
||||
require_default_or_alt_destination = false;
|
||||
<?php if (is_array($available_presets)) foreach ($available_presets as $preset_number => $meh) { ?>
|
||||
if (document.getElementById('preset_<?php echo $preset_number; ?>').checked) {
|
||||
preset_group_id = document.getElementById('preset_<?php echo $preset_number; ?>').value;
|
||||
preset_destination = $('#dialplan_action_' + preset_group_id).val();
|
||||
if (preset_destination == '') { require_default_or_alt_destination = true; }
|
||||
<?php
|
||||
if (is_array($available_presets)) {
|
||||
foreach ($available_presets as $preset_number => $meh) { ?>
|
||||
if (document.getElementById('preset_<?php echo $preset_number; ?>').checked) {
|
||||
preset_group_id = document.getElementById('preset_<?php echo $preset_number; ?>').value;
|
||||
preset_destination = $('#dialplan_action_' + preset_group_id).val();
|
||||
if (preset_destination == '') { require_default_or_alt_destination = true; }
|
||||
}
|
||||
<?php
|
||||
}
|
||||
<?php } ?>
|
||||
}
|
||||
?>
|
||||
|
||||
if (require_default_or_alt_destination && $('#default_preset_action').val() == '') {
|
||||
$('#td_alt_dest').attr('class', 'vncellreq');
|
||||
|
|
@ -1268,4 +1212,4 @@ if ($action == 'update') {
|
|||
//include the footer
|
||||
require_once "resources/footer.php";
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
@ -43,24 +43,37 @@
|
|||
$text = $language->get();
|
||||
|
||||
//handle enable toggle
|
||||
$dialplan_uuid = check_str($_REQUEST['id']);
|
||||
$dialplan_enabled = check_str($_REQUEST['enabled']);
|
||||
if ($dialplan_uuid != '' && $dialplan_enabled != '') {
|
||||
$sql = "update v_dialplans set ";
|
||||
$sql .= "dialplan_enabled = '".$dialplan_enabled."' ";
|
||||
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
|
||||
$sql .= "and app_uuid = '4b821450-926b-175a-af93-a03c441818b1' ";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
message::add($text['message-update']);
|
||||
$dialplan_uuid = $_REQUEST['id'];
|
||||
$dialplan_enabled = $_REQUEST['enabled'];
|
||||
if (is_uuid($dialplan_uuid) && $dialplan_enabled != '') {
|
||||
//build array
|
||||
$array['dialplans'][0]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplans'][0]['dialplan_enabled'] = $dialplan_enabled;
|
||||
$array['dialplans'][0]['app_uuid'] = '4b821450-926b-175a-af93-a03c441818b1';
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('dialplan_edit', 'temp');
|
||||
//execute update
|
||||
$database = new database;
|
||||
$database->app_name = 'time_conditions';
|
||||
$database->app_uuid = '4b821450-926b-175a-af93-a03c441818b1';
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
//revoke temporary permissions
|
||||
$p->delete('dialplan_edit', 'temp');
|
||||
//set message
|
||||
message::add($text['message-update']);
|
||||
//redirect
|
||||
header('Location: time_conditions.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
//set the http values as php variables
|
||||
$search = check_str($_REQUEST["search"]);
|
||||
$order_by = check_str($_REQUEST["order_by"]);
|
||||
$order = check_str($_REQUEST["order"]);
|
||||
$dialplan_context = check_str($_REQUEST["dialplan_context"]);
|
||||
$app_uuid = check_str($_REQUEST["app_uuid"]);
|
||||
$search = $_REQUEST["search"];
|
||||
$order_by = $_REQUEST["order_by"];
|
||||
$order = $_REQUEST["order"];
|
||||
$dialplan_context = $_REQUEST["dialplan_context"];
|
||||
$app_uuid = $_REQUEST["app_uuid"];
|
||||
|
||||
//includes
|
||||
require_once "resources/header.php";
|
||||
|
|
@ -73,35 +86,28 @@
|
|||
$row_style["1"] = "row_style1";
|
||||
|
||||
//get the number of rows in the dialplan
|
||||
$sql = "select count(*) as num_rows from v_dialplans ";
|
||||
$sql .= "where (domain_uuid = '$domain_uuid' or domain_uuid is null) ";
|
||||
$sql = "select count(*) from v_dialplans ";
|
||||
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$sql .= "and app_uuid = '4b821450-926b-175a-af93-a03c441818b1' ";
|
||||
if (strlen($search) > 0) {
|
||||
$sql .= "and (";
|
||||
$sql .= " dialplan_context like '%".$search."%' ";
|
||||
$sql .= " or dialplan_name like '%".$search."%' ";
|
||||
$sql .= " or dialplan_number like '%".$search."%' ";
|
||||
$sql .= " or dialplan_continue like '%".$search."%' ";
|
||||
$sql .= " lower(dialplan_context) like :search ";
|
||||
$sql .= " or lower(dialplan_name) like :search ";
|
||||
$sql .= " or lower(dialplan_number) like :search ";
|
||||
$sql .= " or lower(dialplan_continue) like :search ";
|
||||
if (is_numeric($search)) {
|
||||
$sql .= " or dialplan_order = '".$search."' ";
|
||||
$sql .= " or dialplan_order = :search ";
|
||||
}
|
||||
$sql .= " or dialplan_enabled like '%".$search."%' ";
|
||||
$sql .= " or dialplan_description like '%".$search."%' ";
|
||||
$sql .= " or lower(dialplan_enabled) like :search ";
|
||||
$sql .= " or lower(dialplan_description) like :search ";
|
||||
$sql .= ") ";
|
||||
$parameters['search'] = '%'.strtolower($search).'%';
|
||||
}
|
||||
$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) {
|
||||
$num_rows = $row['num_rows'];
|
||||
}
|
||||
else {
|
||||
$num_rows = '0';
|
||||
}
|
||||
}
|
||||
unset($prep_statement, $result);
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
$database = new database;
|
||||
$num_rows = $database->select($sql, $parameters, 'column');
|
||||
|
||||
//prepare to page data
|
||||
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
|
||||
$param = "";
|
||||
if (strlen($app_uuid) > 0) { $param = "&app_uuid=".$app_uuid; }
|
||||
|
|
@ -111,28 +117,12 @@
|
|||
$offset = $rows_per_page * $page;
|
||||
|
||||
//get the data
|
||||
$sql = "select * from v_dialplans ";
|
||||
$sql .= "where (domain_uuid = '$domain_uuid' or domain_uuid is null) ";
|
||||
$sql .= "and app_uuid = '4b821450-926b-175a-af93-a03c441818b1' ";
|
||||
if (strlen($search) > 0) {
|
||||
$sql .= "and (";
|
||||
$sql .= " dialplan_context like '%".$search."%' ";
|
||||
$sql .= " or dialplan_name like '%".$search."%' ";
|
||||
$sql .= " or dialplan_number like '%".$search."%' ";
|
||||
$sql .= " or dialplan_continue like '%".$search."%' ";
|
||||
if (is_numeric($search)) {
|
||||
$sql .= " or dialplan_order = '".$search."' ";
|
||||
}
|
||||
$sql .= " or dialplan_enabled like '%".$search."%' ";
|
||||
$sql .= " or dialplan_description like '%".$search."%' ";
|
||||
$sql .= ") ";
|
||||
}
|
||||
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } else { $sql .= "order by dialplan_order asc, dialplan_name asc "; }
|
||||
$sql .= " limit $rows_per_page offset $offset ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$dialplans = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
unset ($prep_statement, $sql);
|
||||
$sql = str_replace('count(*)', '*', $sql);
|
||||
$sql .= $order_by != '' ? order_by($order_by, $order) : " order by dialplan_order asc, dialplan_name asc ";
|
||||
$sql .= limit_offset($rows_per_page, $offset);
|
||||
$database = new database;
|
||||
$dialplans = $database->select($sql, $parameters, 'all');
|
||||
unset($sql, $parameters);
|
||||
|
||||
//show the content
|
||||
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
|
|
@ -146,7 +136,7 @@
|
|||
echo " <td align='right' valign='top' nowrap='nowrap' style='padding-left: 50px;'>\n";
|
||||
echo " <form name='frm_search' method='get' action=''>\n";
|
||||
echo " <input type='text' class='txt' style='width: 150px' name='search' value='".escape($search)."'>";
|
||||
if (strlen($app_uuid) > 0) {
|
||||
if (is_uuid($app_uuid)) {
|
||||
echo " <input type='hidden' class='txt' name='app_uuid' value='".escape($app_uuid)."'>";
|
||||
}
|
||||
if (strlen($order_by) > 0) {
|
||||
|
|
@ -230,10 +220,10 @@
|
|||
}
|
||||
echo " </td>\n";
|
||||
echo "</tr>\n";
|
||||
if ($c==0) { $c=1; } else { $c=0; }
|
||||
} //end foreach
|
||||
unset($sql, $result, $row_count);
|
||||
} //end if results
|
||||
$c = $c ? 0 : 1;
|
||||
}
|
||||
}
|
||||
unset($dialplans, $row);
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td colspan='8'>\n";
|
||||
|
|
@ -271,4 +261,4 @@
|
|||
//include the footer
|
||||
require_once "resources/footer.php";
|
||||
|
||||
?>
|
||||
?>
|
||||
Loading…
Reference in New Issue