Portions created by the Initial Developer are Copyright (C) 2008-2012 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('dialplan_view')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support require_once "app_languages.php"; foreach($text as $key => $value) { $text[$key] = $value[$_SESSION['domain']['language']['code']]; } //set the http values as php variables $order_by = check_str($_GET["order_by"]); $order = check_str($_GET["order"]); $dialplan_context = check_str($_GET["dialplan_context"]); $app_uuid = check_str($_GET["app_uuid"]); //custom table header order by to accomodate the app_uuid function th_order_by($field_name, $columntitle, $order_by, $order, $app_uuid) { if (strlen($app_uuid) > 0) { $app_uuid = "app_uuid=".$app_uuid; } $html = "    "; if (strlen($order_by)==0) { $html .= "$columntitle"; } else { if ($order=="asc") { $html .= "$columntitle"; } else { $html .= "$columntitle"; } } $html .= "    "; return $html; } //includes require_once "resources/header.php"; require_once "resources/paging.php"; if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") { $page["title"] = $text['title-inbound_routes']; } elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") { $page["title"] = $text['title-outbound_routes']; } elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7") { $page["title"] = $text['title-queues']; } elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") { $page["title"] = $text['title-time_conditions']; } else { $page["title"] = $text['title-dialplan_manager']; } //show the content echo "
"; echo "\n"; echo "\n"; echo ""; echo ""; echo "
\n"; echo "
"; echo " \n"; echo " \n"; echo " \n"; //echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " \n"; if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") { echo " ".$text['header-inbound_routes']."\n"; } elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") { echo " ".$text['header-outbound_routes']."\n"; } elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7") { echo " ".$text['header-queues']."\n"; } elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") { echo " ".$text['header-time_conditions']."\n"; } else { echo " ".$text['header-dialplan_manager']."\n"; } echo " \n"; echo " \n"; //if (permission_exists('dialplan_advanced_view') && strlen($app_uuid) == 0) { // echo " \n"; //} //else { // echo " \n"; //} //echo "
\n"; echo " \n"; if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") { echo $text['description-inbound_routes']; } elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") { echo $text['description-outbound_routes']; } elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7") { echo $text['description-queues']; } elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") { echo $text['description-time_conditions']; } else { if (if_group("superadmin")) { echo $text['description-dialplan_manager-superadmin']; } else { echo $text['description-dialplan_manager']; } } echo " \n"; echo "
"; echo "
"; //get the number of rows in the dialplan $sql = "select count(*) as num_rows from v_dialplans "; $sql .= "where domain_uuid = '$domain_uuid' "; if (strlen($app_uuid) == 0) { //hide inbound routes $sql .= "and app_uuid <> 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' "; //hide outbound routes $sql .= "and app_uuid <> '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' "; } else { $sql .= "and app_uuid = '".$app_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) { $num_rows = $row['num_rows']; } else { $num_rows = '0'; } } unset($prep_statement, $result); $rows_per_page = 150; $param = ""; if (strlen($app_uuid) > 0) { $param = "&app_uuid=".$app_uuid; } $page = $_GET['page']; if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); $offset = $rows_per_page * $page; $sql = "select * from v_dialplans "; $sql .= "where domain_uuid = '$domain_uuid' "; if (strlen($app_uuid) == 0) { //hide inbound routes $sql .= "and app_uuid <> 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' "; //hide outbound routes $sql .= "and app_uuid <> '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' "; } else { $sql .= "and app_uuid = '".$app_uuid."' "; } 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(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result_count = count($result); unset ($prep_statement, $sql); $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; echo "
\n"; echo "\n"; echo "\n"; echo th_order_by('dialplan_name', $text['label-name'], $order_by, $order, $app_uuid); echo th_order_by('dialplan_number', $text['label-number'], $order_by, $order, $app_uuid); echo th_order_by('dialplan_context', $text['label-context'], $order_by, $order, $app_uuid); echo th_order_by('dialplan_order', $text['label-order'], $order_by, $order, $app_uuid); echo th_order_by('dialplan_enabled', $text['label-enabled'], $order_by, $order, $app_uuid); echo th_order_by('dialplan_description', $text['label-description'], $order_by, $order, $app_uuid); echo "\n"; echo "\n"; if ($result_count > 0) { foreach($result as $row) { $app_uuid = $row['app_uuid']; if (strlen($row['dialplan_number']) == 0) { $sql = "select * from v_dialplan_details "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and dialplan_uuid = '".$row['dialplan_uuid']."' "; $sql .= "and dialplan_detail_type = 'destination_number' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $tmp_result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($tmp_result as &$tmp) { //prepare the extension number preg_match_all('/[\|0-9\*]/',$tmp["dialplan_detail_data"], $tmp_match); $dialplan_number = implode("",$tmp_match[0]); $dialplan_number = str_replace("|", " ", $dialplan_number); $row['dialplan_number'] = $dialplan_number; //update the extension number $sql = "update v_dialplans set "; $sql .= "dialplan_number = '$dialplan_number' "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and dialplan_uuid = '".$row['dialplan_uuid']."'"; $db->exec($sql); unset($sql); break; //limit to 1 row } unset ($prep_statement); } echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; if ($c==0) { $c=1; } else { $c=0; } } //end foreach unset($sql, $result, $row_count); } //end if results echo "\n"; echo "\n"; echo "\n"; if ($v_path_show) { echo "\n"; echo " \n"; echo "\n"; } echo "
"; if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") { if (permission_exists('inbound_route_add')) { echo "$v_link_label_add"; } } elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") { if (permission_exists('outbound_route_add')) { echo "$v_link_label_add"; } } elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7") { if (permission_exists('fifo_add')) { echo "$v_link_label_add"; } } elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") { if (permission_exists('time_condition_add')) { echo "$v_link_label_add"; } } else { if (permission_exists('dialplan_add')) { echo "$v_link_label_add"; } } echo "
  ".$row['dialplan_name']."  ".$row['dialplan_number']."  ".$row['dialplan_context']."  ".$row['dialplan_order']."  ".$row['dialplan_enabled']."".$row['dialplan_description']." \n"; if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") { if (permission_exists('inbound_route_edit')) { echo "$v_link_label_edit"; } if (permission_exists('inbound_route_delete')) { echo "$v_link_label_delete"; } } elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") { if (permission_exists('outbound_route_edit')) { echo "$v_link_label_edit"; } if (permission_exists('outbound_route_delete')) { echo "$v_link_label_delete"; } } elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7") { if (permission_exists('fifo_edit')) { echo "$v_link_label_edit"; } if (permission_exists('fifo_delete')) { echo "$v_link_label_delete"; } } elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") { if (permission_exists('time_condition_edit')) { echo "$v_link_label_edit"; } if (permission_exists('time_condition_delete')) { echo "$v_link_label_delete"; } } else { if (permission_exists('dialplan_edit')) { echo "$v_link_label_edit"; } if (permission_exists('dialplan_delete')) { echo "$v_link_label_delete"; } } echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
 ".$paging_controls.""; if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") { if (permission_exists('inbound_route_add')) { echo "$v_link_label_add"; } } elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") { if (permission_exists('outbound_route_add')) { echo "$v_link_label_add"; } } elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7") { if (permission_exists('fifo_add')) { echo "$v_link_label_add"; } } elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") { if (permission_exists('time_condition_add')) { echo "$v_link_label_add"; } } else { if (permission_exists('dialplan_add')) { echo "$v_link_label_add"; } } echo "
\n"; echo "
\n"; echo "
\n"; echo " ".$_SESSION['switch']['dialplan']['dir']; echo "
"; echo "
"; echo "

"; echo "

"; echo "
"; echo "
"; echo "

"; //include the footer require_once "resources/footer.php"; //unset the variables unset ($result_count); unset ($result); unset ($key); unset ($val); unset ($c); ?>