From 6b178a30c4604b630245ba9c9bb3bb853662f324 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Wed, 13 Dec 2023 16:43:53 -0700 Subject: [PATCH] Adding time zone handling for call block --- app/call_block/app_defaults.php | 4 +++- app/call_block/call_block.php | 27 +++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/app/call_block/app_defaults.php b/app/call_block/app_defaults.php index a5ea0a330a..75a714d6d8 100644 --- a/app/call_block/app_defaults.php +++ b/app/call_block/app_defaults.php @@ -31,7 +31,8 @@ if ($domains_processed == 1) { $database->execute("DROP VIEW view_call_block;", null); $sql = "CREATE VIEW view_call_block AS ( \n"; $sql .= " select c.domain_uuid, call_block_uuid, c.call_block_direction, c.extension_uuid, c.call_block_name, c.call_block_country_code, \n"; - $sql .= " c.call_block_number, e.extension, e.number_alias, c.call_block_count, c.call_block_app, c.call_block_data, c.date_added, c.call_block_enabled, c.call_block_description \n"; + $sql .= " c.call_block_number, e.extension, e.number_alias, c.call_block_count, c.call_block_app, c.call_block_data, c.date_added, \n"; + $sql .= " c.call_block_enabled, c.call_block_description, c.insert_date, c.insert_user, c.update_date, c.update_user \n"; $sql .= " from v_call_block as c \n"; $sql .= " left join v_extensions as e \n"; $sql .= " on c.extension_uuid = e.extension_uuid \n"; @@ -49,3 +50,4 @@ if ($domains_processed == 1) { } ?> + diff --git a/app/call_block/call_block.php b/app/call_block/call_block.php index 44e6e6eaf6..84c3d5c7a4 100644 --- a/app/call_block/call_block.php +++ b/app/call_block/call_block.php @@ -23,7 +23,7 @@ Contributor(s): Mark J Crane - The original Call Block was written by Gerrit Visser + The original Call Block was written by Gerrit Visser All of it has been rewritten over years. */ @@ -91,6 +91,14 @@ $search = strtolower($_GET["search"]); } +//set the time zone + if (isset($_SESSION['domain']['time_zone']['name'])) { + $time_zone = $_SESSION['domain']['time_zone']['name']; + } + else { + $time_zone = date_default_timezone_get(); + } + //prepare to page the results $sql = "select count(*) from view_call_block "; $sql .= "where true "; @@ -146,8 +154,19 @@ $offset = $rows_per_page * $page; //get the list - $sql = "select * from view_call_block "; + $sql = "select domain_uuid, call_block_uuid, call_block_direction, extension_uuid, call_block_name, "; + $sql .= " call_block_country_code, call_block_number, extension, number_alias, call_block_count, "; + $sql .= " to_char(timezone(:time_zone, insert_date), 'DD Mon YYYY') as date_formatted, \n"; + if (date(!empty($_SESSION['domain']['time_format']['text']) == '12h')) { + $sql .= " to_char(timezone(:time_zone, insert_date), 'HH12:MI:SS am') as time_formatted, \n"; + } + else { + $sql .= " to_char(timezone(:time_zone, insert_date), 'HH24:MI:SS am') as time_formatted, \n"; + } + $sql .= " call_block_enabled, call_block_description, insert_date, insert_user, update_date, update_user "; + $sql .= "from view_call_block "; $sql .= "where true "; + $parameters['time_zone'] = $time_zone; if ($show == "all" && permission_exists('call_block_all')) { //$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; //$parameters['domain_uuid'] = $_SESSION['domain_uuid']; @@ -279,7 +298,7 @@ echo th_order_by('call_block_count', $text['label-count'], $order_by, $order, '', "class='center hide-sm-dn'"); echo th_order_by('call_block_action', $text['label-action'], $order_by, $order); echo th_order_by('call_block_enabled', $text['label-enabled'], $order_by, $order, null, "class='center'"); - echo th_order_by('date_added', $text['label-date-added'], $order_by, $order, null, "class='shrink no-wrap'"); + echo th_order_by('insert_date', $text['label-date-added'], $order_by, $order, null, "class='shrink no-wrap'"); echo "".$text['label-description']."\n"; if (permission_exists('call_block_edit') && $list_row_edit_button == 'true') { echo "  \n"; @@ -359,7 +378,7 @@ echo $text['label-'.$row['call_block_enabled']]; } echo " \n"; - echo " ".date('j M Y', $row['date_added'])." ".date((!empty($_SESSION['domain']['time_format']['text']) == '12h' ? 'h:i:s a' : 'H:i:s'), $row['date_added'])."\n"; + echo " ".$row['date_formatted']." ".$row['time_formatted']."\n"; echo " ".escape($row['call_block_description'])."\n"; if (permission_exists('call_block_edit') && $list_row_edit_button == 'true') { echo " ";