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('time_condition_view')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $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); $_SESSION["message"] = $text['message-update']; } //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"]); //includes require_once "resources/header.php"; require_once "resources/paging.php"; $document['title'] = $text['title-time_conditions']; //show the content echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "
\n"; echo " \n"; echo " ".$text['header-time_conditions']."\n"; echo " \n"; echo "

\n"; echo " \n"; echo $text['description-time_conditions']; echo " \n"; echo "
\n"; echo "
\n"; echo " "; if (strlen($app_uuid) > 0) { echo " "; } if (strlen($order_by) > 0) { echo " "; echo " "; } echo " "; 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' 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 .= ") "; } $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' 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(); $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 "\n"; if (permission_exists('dialplan_delete') && $result_count > 0) { echo ""; } echo th_order_by('dialplan_name', $text['label-name'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".$search : null)); echo th_order_by('dialplan_number', $text['label-number'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".$search : null)); echo th_order_by('dialplan_context', $text['label-context'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".$search : null)); echo th_order_by('dialplan_order', $text['label-order'], $order_by, $order, $app_uuid, "style='text-align: center;'", (($search != '') ? "search=".$search : null)); echo th_order_by('dialplan_enabled', $text['label-enabled'], $order_by, $order, $app_uuid, "style='text-align: center;'", (($search != '') ? "search=".$search : null)); echo th_order_by('dialplan_description', $text['label-description'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".$search : null)); echo "\n"; echo "\n"; if ($result_count > 0) { foreach($result as $row) { $app_uuid = $row['app_uuid']; $tr_link = "href='".PROJECT_PATH."/app/time_conditions/time_condition_edit.php?id=".$row['dialplan_uuid'].(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)."'"; echo "\n"; if (permission_exists("time_condition_delete")) { echo " \n"; $dialplan_ids[] = 'checkbox_'.$row['dialplan_uuid']; } 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"; echo "
"; if (permission_exists('time_condition_add')) { echo "$v_link_label_add"; } if (permission_exists('time_condition_delete') && $result_count > 0) { echo "".$v_link_label_delete.""; } echo "
"; if (permission_exists('time_condition_edit')) { echo "".$row['dialplan_name'].""; } else { echo $row['dialplan_name']; } echo " ".((strlen($row['dialplan_number']) > 0) ? $row['dialplan_number'] : " ")."".$row['dialplan_context']."".$row['dialplan_order']."".((strlen($row['dialplan_description']) > 0) ? $row['dialplan_description'] : " ")."\n"; if (permission_exists('time_condition_edit')) { echo "$v_link_label_edit"; } if (permission_exists('time_condition_delete')) { echo "$v_link_label_delete"; } echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
 ".$paging_controls.""; if (permission_exists('time_condition_add')) { echo "$v_link_label_add"; } if (permission_exists('time_condition_delete') && $result_count > 0) { echo "".$v_link_label_delete.""; } echo "
\n"; echo "
"; echo "

"; echo "
"; if (sizeof($dialplan_ids) > 0) { echo "\n"; } //include the footer require_once "resources/footer.php"; ?>