Portions created by the Initial Developer are Copyright (C) 2008-2012 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ //includes include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; //check permissions 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 = $_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 = $_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"; require_once "resources/paging.php"; $document['title'] = $text['title-time_conditions']; //set the alternating styles $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; //get the number of rows in the dialplan $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 .= " 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 lower(dialplan_enabled) like :search "; $sql .= " or lower(dialplan_description) like :search "; $sql .= ") "; $parameters['search'] = '%'.strtolower($search).'%'; } $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; } $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; //get the data $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 "\n"; echo "\n"; echo " \n"; 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 "
\n"; echo " "; if (is_uuid($app_uuid)) { echo " "; } if (strlen($order_by) > 0) { echo " "; echo " "; } echo " "; echo "
\n"; echo "
\n"; echo " \n"; echo $text['description-time_conditions']; echo " \n"; echo "
"; echo "
"; //show the content echo "
\n"; echo "\n"; echo "\n"; echo "\n"; if (permission_exists('time_condition_delete') && is_array($dialplans)) { 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)); if (permission_exists('time_condition_context')) { 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 (is_array($dialplans)) { foreach($dialplans as $row) { $app_uuid = $row['app_uuid']; $tr_link = "href='".PROJECT_PATH."/app/time_conditions/time_condition_edit.php?id=".escape($row['dialplan_uuid']).(($app_uuid != '') ? "&app_uuid=".escape($app_uuid) : null)."'"; echo "\n"; if (permission_exists("time_condition_delete")) { echo " \n"; $dialplan_ids[] = 'checkbox_'.escape($row['dialplan_uuid']); } echo " \n"; echo " \n"; if (permission_exists('time_condition_context')) { echo " \n"; } echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; $c = $c ? 0 : 1; } } unset($dialplans, $row); 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 "".escape($row['dialplan_name']).""; } else { echo escape($row['dialplan_name']); } echo " ".((strlen($row['dialplan_number']) > 0) ? $row['dialplan_number'] : " ")."".escape($row['dialplan_context'])."".escape($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"; ?>