From 72dafd903d2a7346401a478c8ce9c339d6860801 Mon Sep 17 00:00:00 2001 From: Alex <40072887+alexdcrane@users.noreply.github.com> Date: Thu, 18 Dec 2025 09:52:49 -0700 Subject: [PATCH] Use the time_format default setting on more pages (#7663) * Use the time_format default setting on more pages * Update call_recordings.php * Update devices.php * Update email_queue.php * Update emergency.php * Update time formatting based on settings * Update fax_logs.php * Update fax_queue.php * Update time_condition_edit.php * Update xml_cdr_details.php * Update xml_cdr_search.php * Update xml_cdr_statistics_inc.php * Update xml_cdr_statistics.php * Update xml_cdr.php * Update contact_edit.php * Update contact_notes_view.php * Update contact_notes.php * Update contact_timer.php * Update contact_times.php * Update user_logs.php * Update footer.php * Update template.php * Update fax_files.php * Update recent_calls.php * Update missed_calls.php * Update recordings.php * Update xml_cdr_statistics_inc.php * Update xml_cdr_inc.php * Update xml_cdr_inc.php * Update recordings.php * Update missed_calls.php * Update call_block.php * Update user_logs.php * Update xml_cdr_inc.php * Update xml_cdr_details.php * Update recordings.php * Update fax_queue.php * Update fax_logs.php * Update fax_files.php * Update event_guard_logs.php * Update emergency.php * Update email_queue.php * Update devices.php * Update call_recordings.php * Update time_condition_edit.php * Update time_condition_edit.php * Update call_block.php * Update call_recordings.php * Update devices.php * Update email_queue.php * Update emergency.php * Update event_guard_logs.php * Update fax_files.php * Update fax_logs.php * Update fax_queue.php * Update recordings.php * Update xml_cdr_inc.php * Update user_logs.php * Update destination_summary.php * Update xml_cdr_extension_summary.php * Update music_on_hold.php * Update fax_send.php * Update voicemail_greetings.php * Update voicemail_greetings.php * Update xml_cdr_inc.php * Update xml_cdr_inc.php * Update xml_cdr_inc.php * Update xml_cdr_statistics_inc.php * Update xml_cdr_statistics_inc.php * Update xml_cdr_inc.php * Update xml_cdr_extension_summary.php * Update destination_summary.php * Update xml_cdr_statistics_inc.php * Update xml_cdr_inc.php * Update xml_cdr_statistics_inc.php * Update contact_edit.php * Update css.php * Update template.php * Update fax_send.php --- app/call_block/call_block.php | 27 ++++--- app/call_recordings/call_recordings.php | 20 +++-- app/destinations/destination_summary.php | 18 +++-- app/devices/devices.php | 24 ++++-- app/email_queue/email_queue.php | 18 +++-- app/emergency/emergency.php | 10 ++- app/event_guard/event_guard_logs.php | 12 ++- app/fax/fax_files.php | 13 +--- app/fax/fax_logs.php | 15 ++-- app/fax/fax_send.php | 8 +- app/fax_queue/fax_queue.php | 20 +++-- app/music_on_hold/music_on_hold.php | 15 +++- app/recordings/recordings.php | 24 +++--- app/time_conditions/time_condition_edit.php | 20 +++-- .../voicemail_greetings.php | 11 ++- .../resources/dashboard/missed_calls.php | 17 +++-- .../resources/dashboard/recent_calls.php | 17 +++-- app/xml_cdr/xml_cdr.php | 4 +- app/xml_cdr/xml_cdr_details.php | 20 +++-- app/xml_cdr/xml_cdr_extension_summary.php | 16 +++- app/xml_cdr/xml_cdr_inc.php | 75 ++++++++++++------- app/xml_cdr/xml_cdr_search.php | 12 +-- app/xml_cdr/xml_cdr_statistics.php | 15 +++- app/xml_cdr/xml_cdr_statistics_inc.php | 74 ++++++++++++------ core/contacts/contact_edit.php | 17 ++++- core/contacts/contact_notes.php | 14 +++- core/contacts/contact_notes_view.php | 15 +++- core/contacts/contact_timer.php | 9 ++- core/contacts/contact_times.php | 13 +++- core/user_logs/user_logs.php | 14 +++- resources/footer.php | 2 + themes/default/css.php | 3 +- themes/default/template.php | 22 +++++- 33 files changed, 430 insertions(+), 184 deletions(-) diff --git a/app/call_block/call_block.php b/app/call_block/call_block.php index e531aaba27..f3a27b57e4 100644 --- a/app/call_block/call_block.php +++ b/app/call_block/call_block.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2024 + Portions created by the Initial Developer are Copyright (C) 2008-2025 the Initial Developer. All Rights Reserved. Contributor(s): @@ -92,10 +92,7 @@ $search = strtolower($_GET["search"]); } -//set the time zone - $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); - -//prepare to page the results +//get the count $sql = "select count(*) from view_call_block "; $sql .= "where true "; if ($show == "all" && permission_exists('call_block_all')) { @@ -147,21 +144,26 @@ list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; +//set the time zone + $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); + +//set the time format options: 12h, 24h + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'HH24:MI:SS'; + } + else { + $time_format = 'HH12:MI:SS am'; + } + //get the list $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 .= " call_block_app, call_block_data, "; $sql .= " to_char(timezone(:time_zone, insert_date), 'DD Mon YYYY') as date_formatted, \n"; - if (date(!empty($settings->get('domain', 'time_format')) == '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 .= " to_char(timezone(:time_zone, insert_date), '".$time_format."') as time_formatted, \n"; $sql .= " cast(call_block_enabled as text), 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']; @@ -199,6 +201,7 @@ } $sql .= order_by($order_by, $order, ['domain_uuid','call_block_country_code','call_block_number']); $sql .= limit_offset($rows_per_page, $offset); + $parameters['time_zone'] = $time_zone; $result = $database->select($sql, $parameters ?? null, 'all'); unset($sql, $parameters); diff --git a/app/call_recordings/call_recordings.php b/app/call_recordings/call_recordings.php index 2db96c69df..c9610af5c8 100644 --- a/app/call_recordings/call_recordings.php +++ b/app/call_recordings/call_recordings.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2018-2024 + Portions created by the Initial Developer are Copyright (C) 2018-2025 the Initial Developer. All Rights Reserved. Contributor(s): @@ -93,22 +93,29 @@ $search = strtolower($_GET["search"]); } -//set the time zone - $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); - $parameters['time_zone'] = $time_zone; - //prepare some of the paging values $rows_per_page = $settings->get('domain', 'paging', 50); $page = $_GET['page'] ?? ''; if (empty($page)) { $page = 0; $_GET['page'] = 0; } $offset = $rows_per_page * $page; +//set the time zone + $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); + +//set the time format options: 12h, 24h + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'HH24:MI:SS'; + } + else { + $time_format = 'HH12:MI:SS am'; + } + //get the list $sql = "select r.domain_uuid, d.domain_name, r.call_recording_uuid, r.call_direction, "; $sql .= "r.call_recording_name, r.call_recording_path, r.call_recording_transcription, r.call_recording_length, "; $sql .= "r.caller_id_name, r.caller_id_number, r.caller_destination, r.destination_number, "; $sql .= "to_char(timezone(:time_zone, r.call_recording_date), 'DD Mon YYYY') as call_recording_date_formatted, \n"; - $sql .= "to_char(timezone(:time_zone, r.call_recording_date), 'HH12:MI:SS am') as call_recording_time_formatted \n"; + $sql .= "to_char(timezone(:time_zone, r.call_recording_date), '".$time_format."') as call_recording_time_formatted \n"; $sql .= "from view_call_recordings as r, v_domains as d "; //$sql .= "from v_call_recordings as r, v_domains as d "; $sql .= "where true "; @@ -131,6 +138,7 @@ } $sql .= order_by($order_by, $order, 'r.call_recording_date', 'desc'); $sql .= limit_offset($rows_per_page, $offset); + $parameters['time_zone'] = $time_zone; $call_recordings = $database->select($sql, $parameters ?? null, 'all'); unset($sql, $parameters); diff --git a/app/destinations/destination_summary.php b/app/destinations/destination_summary.php index ce27dc44a9..c6a66d14f6 100644 --- a/app/destinations/destination_summary.php +++ b/app/destinations/destination_summary.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2023-2024 + Portions created by the Initial Developer are Copyright (C) 2023-2025 the Initial Developer. All Rights Reserved. Contributor(s): @@ -52,6 +52,14 @@ $quick_select = 3; //set default } +//convert time format to 24 hour + if (!empty($start_stamp_begin)) { + $start_stamp_begin_formatted = ($settings->get('domain', 'time_format') == '24h' ? $start_stamp_begin : DateTime::createFromFormat('Y-m-d h:i a', $start_stamp_begin)->format('Y-m-d H:i')); + } + if (!empty($start_stamp_end)) { + $start_stamp_end_formatted = ($settings->get('domain', 'time_format') == '24h' ? $start_stamp_end : DateTime::createFromFormat('Y-m-d h:i a', $start_stamp_end)->format('Y-m-d H:i')); + } + //get the summary $destination = new destinations; $destination->domain_uuid = $_SESSION['domain_uuid']; @@ -59,8 +67,8 @@ $destination->quick_select = $quick_select; } else { - $destination->start_stamp_begin = $start_stamp_begin ?? ''; - $destination->start_stamp_end = $start_stamp_end ?? ''; + $destination->start_stamp_begin = $start_stamp_begin_formatted ?? ''; + $destination->start_stamp_end = $start_stamp_end_formatted ?? ''; } //$destination->include_internal = $include_internal ?? null; $summary = $destination->destination_summary(); @@ -174,7 +182,7 @@ echo " ".$text['label-start_date_time']."\n"; echo " \n"; echo "
\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo " \n"; @@ -183,7 +191,7 @@ echo " ".$text['label-end_date_time']."\n"; echo " \n"; echo "
\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo " \n"; diff --git a/app/devices/devices.php b/app/devices/devices.php index c74f09eb9a..bd54d0b01f 100644 --- a/app/devices/devices.php +++ b/app/devices/devices.php @@ -54,10 +54,6 @@ $devices = $_POST['devices']; } -//get the search - $search = strtolower($_REQUEST["search"] ?? ''); - $fields = strtolower($_REQUEST["fields"] ?? ''); - //process the http post data by action if (!empty($action) && !empty($devices) && is_array($devices) && @sizeof($devices) != 0) { switch ($action) { @@ -83,8 +79,9 @@ $order_by = $_GET["order_by"] ?? ''; $order = $_GET["order"] ?? ''; -//set the time zone - $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); +//get the search + $search = strtolower($_REQUEST["search"] ?? ''); + $fields = strtolower($_REQUEST["fields"] ?? ''); //get total devices count from the database $sql = "select count(*) from v_devices "; @@ -108,7 +105,7 @@ $device_profiles = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); -//prepare to page the results +//get the count $sql = "select count(*) from v_devices as d "; if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) { if (!empty($search)) { @@ -180,6 +177,17 @@ list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param ?? '', $rows_per_page, true); $offset = $rows_per_page * $page; +//set the time zone + $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); + +//set the time format options: 12h, 24h + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'HH24:MI:SS'; + } + else { + $time_format = 'HH12:MI:SS am'; + } + //get the list $sql = "select "; if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) { @@ -208,7 +216,7 @@ $sql .= "d.device_enabled, "; $sql .= "d2.device_label as alternate_label, "; $sql .= "to_char(timezone(:time_zone, d.device_provisioned_date), 'DD Mon YYYY') as provisioned_date_formatted, \n"; - $sql .= "to_char(timezone(:time_zone, d.device_provisioned_date), 'HH12:MI:SS am') as provisioned_time_formatted \n"; + $sql .= "to_char(timezone(:time_zone, d.device_provisioned_date), '".$time_format."') as provisioned_time_formatted \n"; $sql .= "from v_devices as d, v_devices as d2 "; if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) { $sql .= ", v_domains as d3 "; diff --git a/app/email_queue/email_queue.php b/app/email_queue/email_queue.php index afa13417d4..b1a7cd938e 100644 --- a/app/email_queue/email_queue.php +++ b/app/email_queue/email_queue.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2022-2023 + Portions created by the Initial Developer are Copyright (C) 2022-2025 the Initial Developer. All Rights Reserved. Contributor(s): @@ -91,9 +91,6 @@ exit; } -//set the time zone - $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); - //get order and order by $order_by = $_GET["order_by"] ?? null; $order = $_GET["order"] ?? null; @@ -138,11 +135,22 @@ list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; +//set the time zone + $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); + +//set the time format options: 12h, 24h + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'HH24:MI:SS'; + } + else { + $time_format = 'HH12:MI:SS am'; + } + //get the list $sql = "select "; $sql .= "email_date, "; $sql .= "to_char(timezone(:time_zone, email_date), 'DD Mon YYYY') as email_date_formatted, \n"; - $sql .= "to_char(timezone(:time_zone, email_date), 'HH12:MI:SS am') as email_time_formatted, \n"; + $sql .= "to_char(timezone(:time_zone, email_date), '".$time_format."') as email_time_formatted, \n"; $sql .= "email_queue_uuid, "; $sql .= "hostname, "; $sql .= "email_from, "; diff --git a/app/emergency/emergency.php b/app/emergency/emergency.php index 130e4a2252..3b800bd07d 100644 --- a/app/emergency/emergency.php +++ b/app/emergency/emergency.php @@ -109,13 +109,21 @@ $offset = $rows_per_page * $page; //set the time zone $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); +//set the time format options: 12h, 24h +if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'HH24:MI:SS'; +} +else { + $time_format = 'HH12:MI:SS am'; +} + //get the list $sql = "select e.emergency_log_uuid, "; $sql .= "e.domain_uuid, "; $sql .= "e.extension, "; $sql .= "e.event, "; $sql .= "to_char(timezone(:time_zone, e.insert_date), 'DD Mon YYYY') as date_formatted, "; -$sql .= "to_char(timezone(:time_zone, e.insert_date), 'HH12:MI:SS am') as time_formatted, "; +$sql .= "to_char(timezone(:time_zone, e.insert_date), '".$time_format."') as time_formatted, "; $sql .= "e.insert_date, "; $sql .= "c.status as status, "; $sql .= "concat(c.record_path, '/', c.record_name) as recording, "; //temp diff --git a/app/event_guard/event_guard_logs.php b/app/event_guard/event_guard_logs.php index bc0495d38c..81a701284d 100644 --- a/app/event_guard/event_guard_logs.php +++ b/app/event_guard/event_guard_logs.php @@ -115,7 +115,14 @@ //set the time zone $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); - $parameters['time_zone'] = $time_zone; + +//set the time format options: 12h, 24h + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'HH24:MI:SS'; + } + else { + $time_format = 'HH12:MI:SS am'; + } //get the list $sql = "select "; @@ -123,7 +130,7 @@ $sql .= "hostname, "; $sql .= "log_date, "; $sql .= "to_char(timezone(:time_zone, log_date), 'DD Mon YYYY') as log_date_formatted, \n"; - $sql .= "to_char(timezone(:time_zone, log_date), 'HH12:MI:SS am') as log_time_formatted, \n"; + $sql .= "to_char(timezone(:time_zone, log_date), '".$time_format."') as log_time_formatted, \n"; $sql .= "filter, "; $sql .= "ip_address, "; $sql .= "extension, "; @@ -148,6 +155,7 @@ } $sql .= order_by($order_by, $order, 'log_date', 'desc'); $sql .= limit_offset($rows_per_page, $offset); + $parameters['time_zone'] = $time_zone; $event_guard_logs = $database->select($sql, $parameters ?? null, 'all'); unset($sql, $parameters); diff --git a/app/fax/fax_files.php b/app/fax/fax_files.php index 660b54efcc..b12d8d94f6 100644 --- a/app/fax/fax_files.php +++ b/app/fax/fax_files.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2018-2024 + Portions created by the Initial Developer are Copyright (C) 2018-2025 the Initial Developer. All Rights Reserved. Contributor(s): @@ -244,16 +244,10 @@ //set the time zone $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); - $parameters['time_zone'] = $time_zone; //set the time format options: 12h, 24h - if (!empty($settings->get('domain', 'time_format'))) { - if ($settings->get('domain', 'time_format') == '12h') { - $time_format = 'HH12:MI:SS am'; - } - elseif ($settings->get('domain', 'time_format') == '24h') { - $time_format = 'HH24:MI:SS'; - } + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'HH24:MI:SS'; } else { $time_format = 'HH12:MI:SS am'; @@ -279,6 +273,7 @@ $parameters['domain_uuid'] = $domain_uuid; $sql .= order_by($order_by, $order, 'fax_date', 'desc'); $sql .= limit_offset($rows_per_page, $offset); + $parameters['time_zone'] = $time_zone; $fax_files = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); diff --git a/app/fax/fax_logs.php b/app/fax/fax_logs.php index 7e94d0432d..be1c6d4c2e 100644 --- a/app/fax/fax_logs.php +++ b/app/fax/fax_logs.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2024 + Portions created by the Initial Developer are Copyright (C) 2008-2025 the Initial Developer. All Rights Reserved. Contributor(s): @@ -81,7 +81,7 @@ $parameters['search'] = '%'.$search.'%'; } -//prepare to page the results +//get the count $sql = "select count(fax_log_uuid) from v_fax_logs "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and fax_uuid = :fax_uuid "; @@ -104,14 +104,19 @@ //set the time zone $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); -//set time format - $time_format = $settings->get('domain', 'time_format'); +//set the time format options: 12h, 24h + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'HH24:MI:SS'; + } + else { + $time_format = 'HH12:MI:SS am'; + } //get the list $sql = "select "; $sql .= " fax_epoch, "; $sql .= " to_char(timezone(:time_zone, to_timestamp(fax_epoch)), 'DD Mon YYYY') as fax_date_formatted, \n"; - $sql .= " to_char(timezone(:time_zone, to_timestamp(fax_epoch)), 'HH12:MI:SS am') as fax_time_formatted, \n"; + $sql .= " to_char(timezone(:time_zone, to_timestamp(fax_epoch)), '".$time_format."') as fax_time_formatted, \n"; $sql .= " fax_success, "; $sql .= " fax_result_code, "; $sql .= " fax_result_text, "; diff --git a/app/fax/fax_send.php b/app/fax/fax_send.php index 69856b71cc..4d5eb50568 100644 --- a/app/fax/fax_send.php +++ b/app/fax/fax_send.php @@ -518,7 +518,13 @@ if (!function_exists('fax_split_dtmf')) { $pdf->SetXY($x + 2.0, $y + 1.65); if (defined('STDIN') || (!empty($_REQUEST['submit']) && $_REQUEST['submit'] != 'preview')) { $date = new DateTime('now', new DateTimeZone( $settings->get('domain','time_zone', date_default_timezone_get() ) )); - $pdf->Write(0.3, $date->format('d M Y @ h:i:s A')); + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'H:i:s'; + } + else { + $time_format = 'h:i:s A'; + } + $pdf->Write(0.3, $date->format('d M Y @ '.$time_format)); } $pdf->SetXY($x + 2.0, $y + 1.95); if (!empty($fax_recipient)) { diff --git a/app/fax_queue/fax_queue.php b/app/fax_queue/fax_queue.php index 6a0549d23c..b3a0b6da64 100644 --- a/app/fax_queue/fax_queue.php +++ b/app/fax_queue/fax_queue.php @@ -93,9 +93,6 @@ exit; } -//set the time zone - $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); - //get order and order by $order_by = $_GET["order_by"] ?? null; $order = $_GET["order"] ?? null; @@ -152,6 +149,17 @@ list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; +//set the time zone + $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); + +//set the time format options: 12h, 24h + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'HH24:MI:SS'; + } + else { + $time_format = 'HH12:MI:SS am'; + } + //get the list $sql = "SELECT "; $sql .= "d.domain_name, "; @@ -160,7 +168,7 @@ $sql .= "q.fax_uuid, "; $sql .= "q.fax_date, "; $sql .= "to_char(timezone(:time_zone, q.fax_date), 'DD Mon YYYY') as fax_date_formatted, "; - $sql .= "to_char(timezone(:time_zone, q.fax_date), 'HH12:MI:SS am') as fax_time_formatted, "; + $sql .= "to_char(timezone(:time_zone, q.fax_date), '".$time_format."') as fax_time_formatted, "; $sql .= "q.hostname, "; $sql .= "q.fax_caller_id_name, "; $sql .= "q.fax_caller_id_number, "; @@ -172,10 +180,10 @@ $sql .= "q.fax_status, "; $sql .= "q.fax_retry_date, "; $sql .= "to_char(timezone(:time_zone, q.fax_retry_date), 'DD Mon YYYY') as fax_retry_date_formatted, "; - $sql .= "to_char(timezone(:time_zone, q.fax_retry_date), 'HH12:MI:SS am') as fax_retry_time_formatted, "; + $sql .= "to_char(timezone(:time_zone, q.fax_retry_date), '".$time_format."') as fax_retry_time_formatted, "; $sql .= "q.fax_notify_date, "; $sql .= "to_char(timezone(:time_zone, q.fax_notify_date), 'DD Mon YYYY') as fax_notify_date_formatted, "; - $sql .= "to_char(timezone(:time_zone, q.fax_notify_date), 'HH12:MI:SS am') as fax_notify_time_formatted, "; + $sql .= "to_char(timezone(:time_zone, q.fax_notify_date), '".$time_format."') as fax_notify_time_formatted, "; $sql .= "q.fax_retry_count, "; $sql .= "q.fax_accountcode, "; $sql .= "q.fax_command "; diff --git a/app/music_on_hold/music_on_hold.php b/app/music_on_hold/music_on_hold.php index 1fac7f418b..95470fb6d0 100644 --- a/app/music_on_hold/music_on_hold.php +++ b/app/music_on_hold/music_on_hold.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2024 + Portions created by the Initial Developer are Copyright (C) 2008-2025 the Initial Developer. All Rights Reserved. Contributor(s): @@ -547,13 +547,24 @@ echo " "; unset($stream_icons, $icons); + //set the time zone + date_default_timezone_set($settings->get('domain', 'time_zone', date_default_timezone_get())); + + //set the time format options: 12h, 24h + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'H:i:s'; + } + else { + $time_format = 'h:i:s a'; + } + //list the stream files if (!empty($stream_files)) { foreach ($stream_files as $stream_file_path) { $row_uuid = uuid(); $stream_file = pathinfo($stream_file_path, PATHINFO_BASENAME); $stream_file_size = byte_convert(filesize($stream_file_path)); - $stream_file_date = date("M d, Y H:i:s", filemtime($stream_file_path)); + $stream_file_date = date("M d, Y ".$time_format, filemtime($stream_file_path)); $stream_file_ext = pathinfo($stream_file, PATHINFO_EXTENSION); switch ($stream_file_ext) { case "wav" : $stream_file_type = "audio/wav"; break; diff --git a/app/recordings/recordings.php b/app/recordings/recordings.php index 4ea6de17f9..1b1abbc5d3 100644 --- a/app/recordings/recordings.php +++ b/app/recordings/recordings.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2024 + Portions created by the Initial Developer are Copyright (C) 2008-2025 the Initial Developer. All Rights Reserved. Contributor(s): @@ -302,7 +302,6 @@ //add the search term $search = $_REQUEST["search"] ?? ''; - //get total recordings from the database $sql = "select count(*) from v_recordings "; $sql .= "where true "; @@ -332,16 +331,6 @@ [$paging_controls_mini, $rows_per_page] = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; -//set the time zone - $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); - $parameters['time_zone'] = $time_zone; - -//set the sql time format - $sql_time_format = 'HH12:MI am'; - if (!empty($settings->get('domain', 'time_format'))) { - $sql_time_format = $settings->get('domain', 'time_format') == '12h' ? "HH12:MI am" : "HH24:MI"; - } - //get the file size if ($recording_storage_type == 'base64') { switch ($db_type) { @@ -350,12 +339,19 @@ } } +//set the time format options: 12h, 24h + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'HH24:MI:SS'; + } + else { + $time_format = 'HH12:MI:SS am'; + } + //get the recordings from the database $sql = "select recording_uuid, domain_uuid, "; if (!empty($sql_file_size)) { $sql .= $sql_file_size; } $sql .= "to_char(timezone(:time_zone, COALESCE(update_date, insert_date)), 'DD Mon YYYY') as date_formatted, \n"; - $sql .= "to_char(timezone(:time_zone, COALESCE(update_date, insert_date)), '".$sql_time_format."') as time_formatted, \n"; - + $sql .= "to_char(timezone(:time_zone, COALESCE(update_date, insert_date)), '".$time_format."') as time_formatted, \n"; $sql .= "recording_name, recording_filename, recording_description "; $sql .= "from v_recordings "; $sql .= "where true "; diff --git a/app/time_conditions/time_condition_edit.php b/app/time_conditions/time_condition_edit.php index 3d3aafce26..1b665ed69d 100644 --- a/app/time_conditions/time_condition_edit.php +++ b/app/time_conditions/time_condition_edit.php @@ -657,6 +657,14 @@ $document['title'] = $text['title-time_condition']; require_once "resources/header.php"; +//set the time format options: 12h, 24h + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'HH:mm'; + } + else { + $time_format = 'hh:mm a'; + } + //debug // echo "
\n"; // echo "".'$dialplan_details'."\n"; view_array($dialplan_details, false); @@ -807,8 +815,7 @@ case 'hour': //hours of day get('domain', 'time_format') == "24h") { - + if ($time_format == '24h') { for ($h = 0; $h <= 23; $h++) { echo "sel_start.options[sel_start.options.length] = new Option(".$h.", ".$h.");\n"; echo "sel_stop.options[sel_stop.options.length] = new Option(".$h.", ".$h.");\n"; @@ -826,8 +833,7 @@ case 'time-of-day': //time of day get('domain', 'time_format') == "24h") { - + if ($time_format == '24h') { for ($h = 0; $h <= 23; $h++) { for ($m = 0; $m <= 59; $m++) { echo "sel_start.options[sel_start.options.length] = new Option(('0'+'".$h."').slice(-2)+':'+('0'+'".$m."').slice(-2),pad('".$h."', 2) + ':' + pad(".$m.", 2));\n"; @@ -841,7 +847,7 @@ echo "sel_start.options[sel_start.options.length] = new Option(((".$h." != 0) ? ((".$h." >= 12) ? ((".$h." == 12) ? ".$h." : (".$h." - 12)) + ':' + pad(".$m.", 2) + ' PM' : ".$h." + ':' + pad(".$m.", 2) + ' AM') : '12:' + pad(".$m.", 2) + ' AM'), pad(".$h.", 2) + ':' + pad(".$m.", 2));\n"; echo "sel_stop.options[sel_stop.options.length] = new Option(((".$h." != 0) ? ((".$h." >= 12) ? ((".$h." == 12) ? ".$h." : (".$h." - 12)) + ':' + pad(".$m.", 2) + ' PM' : ".$h." + ':' + pad(".$m.", 2) + ' AM') : '12:' + pad(".$m.", 2) + ' AM'), pad(".$h.", 2) + ':' + pad(".$m.", 2));\n"; } - } + } } //h = 23; //m = 59; @@ -876,14 +882,14 @@ tb.id = obj.id; tb_id = obj.id; tb.className = 'formfld datetimepicker'; - tb.setAttribute('style', 'position: relative; width: 120px; min-width: 120px; max-width: 120px; text-align: center;'); + tb.setAttribute('style', 'position: relative; width: 130px; min-width: 130px; max-width: 130px; text-align: center;'); tb.setAttribute('data-toggle', 'datetimepicker'); tb.setAttribute('data-target', '#' + tb.id); tb.setAttribute('onblur', "$(this).datetimepicker('hide');"); obj.parentNode.insertBefore(tb, obj); obj.parentNode.removeChild(obj); $('#'+tb_id).wrap("
"); //add parent div - $('#'+tb_id).datetimepicker({ format: 'YYYY-MM-DD HH:mm', }); + $('#'+tb_id).datetimepicker({ format: 'YYYY-MM-DD ', }); } function change_to_select(obj) { diff --git a/app/voicemail_greetings/voicemail_greetings.php b/app/voicemail_greetings/voicemail_greetings.php index 8b0405c188..24e24effcb 100644 --- a/app/voicemail_greetings/voicemail_greetings.php +++ b/app/voicemail_greetings/voicemail_greetings.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2024 + Portions created by the Initial Developer are Copyright (C) 2008-2025 the Initial Developer. All Rights Reserved. Contributor(s): @@ -482,8 +482,15 @@ } else { if (file_exists($greeting_dir.'/'.$row['greeting_filename'])) { + date_default_timezone_set($settings->get('domain', 'time_zone', date_default_timezone_get())); + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'H:i:s'; + } + else { + $time_format = 'h:i:s a'; + } $file_size = byte_convert(filesize($greeting_dir.'/'.$row['greeting_filename'])); - $file_date = date("M d, Y H:i:s", filemtime($greeting_dir.'/'.$row['greeting_filename'])); + $file_date = date("M d, Y ".$time_format, filemtime($greeting_dir.'/'.$row['greeting_filename'])); } else { $file_size = 0; $file_date = ''; diff --git a/app/xml_cdr/resources/dashboard/missed_calls.php b/app/xml_cdr/resources/dashboard/missed_calls.php index 331bec48aa..68db4440bd 100644 --- a/app/xml_cdr/resources/dashboard/missed_calls.php +++ b/app/xml_cdr/resources/dashboard/missed_calls.php @@ -34,17 +34,22 @@ //if also viewing system status, show more recent calls (more room avaialble) $missed_limit = !empty($selected_blocks) && (is_array($selected_blocks) && in_array('counts', $selected_blocks)) ? 10 : 5; -//set the sql time format - $sql_time_format = 'DD Mon HH12:MI am'; - if (!empty($settings->get('domain', 'time_format'))) { - $sql_time_format = $settings->get('domain', 'time_format') == '12h' ? "DD Mon HH12:MI am" : "DD Mon HH24:MI"; +//set the time zone + $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); + +//set the time format options: 12h, 24h + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'DD Mon HH24:MI'; + } + else { + $time_format = 'DD Mon HH12:MI am'; } //get the missed calls from call detail records $sql = "select \n"; $sql .= " status, \n"; $sql .= " direction, \n"; - $sql .= " to_char(timezone(:time_zone, start_stamp), '".$sql_time_format."') as start_date_time, \n"; + $sql .= " to_char(timezone(:time_zone, start_stamp), '".$time_format."') as start_date_time, \n"; $sql .= " caller_id_name, \n"; $sql .= " caller_id_number, \n"; $sql .= " answer_stamp \n"; @@ -82,7 +87,7 @@ $sql .= "start_epoch desc \n"; $sql .= "limit :missed_limit \n"; $parameters['missed_limit'] = $missed_limit; - $parameters['time_zone'] = $settings->get('domain', 'time_zone', date_default_timezone_get()); + $parameters['time_zone'] = $time_zone; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $result = $database->select($sql, $parameters, 'all'); $num_rows = !empty($result) ? sizeof($result) : 0; diff --git a/app/xml_cdr/resources/dashboard/recent_calls.php b/app/xml_cdr/resources/dashboard/recent_calls.php index a1f35f6b64..c5c01b0d09 100644 --- a/app/xml_cdr/resources/dashboard/recent_calls.php +++ b/app/xml_cdr/resources/dashboard/recent_calls.php @@ -34,10 +34,15 @@ //if also viewing system status, show more recent calls (more room avaialble) $recent_limit = isset($selected_blocks) && is_array($selected_blocks) && in_array('counts', $selected_blocks) ? 10 : 5; -//set the sql time format - $sql_time_format = 'DD Mon HH12:MI am'; - if (!empty($settings->get('domain', 'time_format'))) { - $sql_time_format = $settings->get('domain', 'time_format') == '12h' ? "DD Mon HH12:MI am" : "DD Mon HH24:MI"; +//set the time zone + $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); + +//set the time format options: 12h, 24h + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'DD Mon HH24:MI'; + } + else { + $time_format = 'DD Mon HH12:MI am'; } //get the recent calls from call detail records @@ -46,7 +51,7 @@ status, direction, start_stamp, - to_char(timezone(:time_zone, start_stamp), '".$sql_time_format."') as start_date_time, + to_char(timezone(:time_zone, start_stamp), '".$time_format."') as start_date_time, caller_id_name, caller_id_number, destination_number, @@ -79,7 +84,7 @@ $sql .= "order by start_epoch desc "; $sql .= "limit :recent_limit "; $parameters['recent_limit'] = $recent_limit; - $parameters['time_zone'] = $settings->get('domain', 'time_zone', date_default_timezone_get()); + $parameters['time_zone'] = $time_zone; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $result = $database->select($sql, $parameters, 'all'); $num_rows = !empty($result) ? sizeof($result) : 0; diff --git a/app/xml_cdr/xml_cdr.php b/app/xml_cdr/xml_cdr.php index a8e39d2432..ccf6574912 100644 --- a/app/xml_cdr/xml_cdr.php +++ b/app/xml_cdr/xml_cdr.php @@ -425,8 +425,8 @@ echo " ".$text['label-start_range']."\n"; echo "
\n"; echo "
\n"; - echo " \n"; - echo " \n"; + echo " \n"; + echo " \n"; echo "
\n"; echo " \n"; } diff --git a/app/xml_cdr/xml_cdr_details.php b/app/xml_cdr/xml_cdr_details.php index 225e7de218..c1388c387e 100644 --- a/app/xml_cdr/xml_cdr_details.php +++ b/app/xml_cdr/xml_cdr_details.php @@ -272,9 +272,6 @@ $outbound_caller_id_name = urldecode($array["variables"]["outbound_caller_id_name"] ?? ''); $outbound_caller_id_number = urldecode($array["variables"]["outbound_caller_id_number"] ?? ''); -//set the time zone - date_default_timezone_set($settings->get('domain', 'time_zone', 'GMT')); - //create the destinations object $destinations = new destinations(); @@ -308,6 +305,19 @@ } } +//set the time zone + date_default_timezone_set($settings->get('domain', 'time_zone', date_default_timezone_get())); + +//format the date and time + if ($settings->get('domain', 'time_format') == '24h') { + $start_time = date("Y-m-d H:i:s", (int) $start_epoch); + $end_time= date("Y-m-d H:i:s", (int) $end_epoch); + } + else { + $start_time = date("Y-m-d g:i:s a", (int) $start_epoch); + $end_time = date("Y-m-d g:i:s a", (int) $end_epoch); + } + //set the year, month and date $tmp_year = date("Y", strtotime($start_stamp)); $tmp_month = date("M", strtotime($start_stamp)); @@ -520,8 +530,8 @@ } echo " \n"; echo " ".escape($destination_number)."\n"; - echo " ".escape(date("Y-m-d H:i:s", (int) $start_epoch))."\n"; - echo " ".escape(date("Y-m-d H:i:s", (int) $end_epoch))."\n"; + echo " ".escape($start_time)."\n"; + echo " ".escape($end_time)."\n"; if (permission_exists('xml_cdr_hangup_cause')) { echo " ".escape($hangup_cause)."\n"; } diff --git a/app/xml_cdr/xml_cdr_extension_summary.php b/app/xml_cdr/xml_cdr_extension_summary.php index 27478b407a..2719cbad12 100644 --- a/app/xml_cdr/xml_cdr_extension_summary.php +++ b/app/xml_cdr/xml_cdr_extension_summary.php @@ -53,12 +53,20 @@ $quick_select = 3; //set default } +//convert time format to 24 hour + if (!empty($start_stamp_begin)) { + $start_stamp_begin_formatted = ($settings->get('domain', 'time_format') == '24h' ? $start_stamp_begin : DateTime::createFromFormat('Y-m-d h:i a', $start_stamp_begin)->format('Y-m-d H:i')); + } + if (!empty($start_stamp_end)) { + $start_stamp_end_formatted = ($settings->get('domain', 'time_format') == '24h' ? $start_stamp_end : DateTime::createFromFormat('Y-m-d h:i a', $start_stamp_end)->format('Y-m-d H:i')); + } + //get the summary $cdr = new xml_cdr; $cdr->domain_uuid = $_SESSION['domain_uuid']; $cdr->quick_select = $quick_select; - $cdr->start_stamp_begin = $start_stamp_begin ?? null; - $cdr->start_stamp_end = $start_stamp_end ?? null; + $cdr->start_stamp_begin = $start_stamp_begin_formatted ?? null; + $cdr->start_stamp_end = $start_stamp_end_formatted ?? null; $cdr->include_internal = $include_internal ?? null; $summary = $cdr->user_summary(); @@ -174,14 +182,14 @@ echo " ".$text['label-start_date_time']."\n"; echo " \n"; echo "
\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-end_date_time']."\n"; echo "
\n"; echo "
\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo " \n"; diff --git a/app/xml_cdr/xml_cdr_inc.php b/app/xml_cdr/xml_cdr_inc.php index 387033d53c..456030bef4 100644 --- a/app/xml_cdr/xml_cdr_inc.php +++ b/app/xml_cdr/xml_cdr_inc.php @@ -296,12 +296,13 @@ //set the time zone $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); - $parameters['time_zone'] = $time_zone; -//set the sql time format - $sql_time_format = 'HH12:MI am'; - if (!empty($settings->get('domain', 'time_format'))) { - $sql_time_format = $settings->get('domain', 'time_format') == '12h' ? "HH12:MI am" : "HH24:MI"; +//set the time format options: 12h, 24h + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'HH24:MI'; + } + else { + $time_format = 'HH12:MI am'; } //get the results from the db @@ -313,7 +314,7 @@ $sql .= "c.start_stamp, \n"; $sql .= "c.end_stamp, \n"; $sql .= "to_char(timezone(:time_zone, start_stamp), 'DD Mon YYYY') as start_date_formatted, \n"; - $sql .= "to_char(timezone(:time_zone, start_stamp), '".$sql_time_format."') as start_time_formatted, \n"; + $sql .= "to_char(timezone(:time_zone, start_stamp), '".$time_format."') as start_time_formatted, \n"; $sql .= "c.start_epoch, \n"; $sql .= "c.hangup_cause, \n"; $sql .= "c.billsec as duration, \n"; @@ -471,50 +472,67 @@ } } } - - if (!empty($start_stamp_begin) && !empty($start_stamp_end)) { + if (!empty($start_stamp_begin)) { + $start_stamp_begin_formatted = ($settings->get('domain', 'time_format') == '24h' ? $start_stamp_begin : DateTime::createFromFormat('Y-m-d h:i a', $start_stamp_begin)->format('Y-m-d H:i')); + } + if (!empty($start_stamp_end)) { + $start_stamp_end_formatted = ($settings->get('domain', 'time_format') == '24h' ? $start_stamp_end : DateTime::createFromFormat('Y-m-d h:i a', $start_stamp_end)->format('Y-m-d H:i')); + } + if (!empty($start_stamp_begin_formatted) && !empty($start_stamp_end_formatted)) { $sql .= "and start_stamp between :start_stamp_begin::timestamptz and :start_stamp_end::timestamptz \n"; - $parameters['start_stamp_begin'] = $start_stamp_begin.':00.000 '.$time_zone; - $parameters['start_stamp_end'] = $start_stamp_end.':59.999 '.$time_zone; + $parameters['start_stamp_begin'] = $start_stamp_begin_formatted.':00.000 '.$time_zone; + $parameters['start_stamp_end'] = $start_stamp_end_formatted.':59.999 '.$time_zone; } else { - if (!empty($start_stamp_begin)) { + if (!empty($start_stamp_begin_formatted)) { $sql .= "and start_stamp >= :start_stamp_begin \n"; - $parameters['start_stamp_begin'] = $start_stamp_begin.':00.000 '.$time_zone; + $parameters['start_stamp_begin'] = $start_stamp_begin_formatted.':00.000 '.$time_zone; } - if (!empty($start_stamp_end)) { + if (!empty($start_stamp_end_formatted)) { $sql .= "and start_stamp <= :start_stamp_end \n"; - $parameters['start_stamp_end'] = $start_stamp_end.':59.999 '.$time_zone; + $parameters['start_stamp_end'] = $start_stamp_end_formatted.':59.999 '.$time_zone; } } - if (!empty($answer_stamp_begin) && !empty($answer_stamp_end)) { + if (!empty($answer_stamp_begin)) { + $answer_stamp_begin_formatted = ($settings->get('domain', 'time_format') == '24h' ? $answer_stamp_begin : DateTime::createFromFormat('Y-m-d h:i a', $answer_stamp_begin)->format('Y-m-d H:i')); + } + if (!empty($answer_stamp_end)) { + $answer_stamp_end_formatted = ($settings->get('domain', 'time_format') == '24h' ? $answer_stamp_end : DateTime::createFromFormat('Y-m-d h:i a', $answer_stamp_end)->format('Y-m-d H:i')); + } + if (!empty($answer_stamp_begin_formatted) && !empty($answer_stamp_end_formatted)) { $sql .= "and answer_stamp between :answer_stamp_begin::timestamptz and :answer_stamp_end::timestamptz \n"; - $parameters['answer_stamp_begin'] = $answer_stamp_begin.':00.000 '.$time_zone; - $parameters['answer_stamp_end'] = $answer_stamp_end.':59.999 '.$time_zone; + $parameters['answer_stamp_begin'] = $answer_stamp_begin_formatted.':00.000 '.$time_zone; + $parameters['answer_stamp_end'] = $answer_stamp_end_formatted.':59.999 '.$time_zone; } else { - if (!empty($answer_stamp_begin)) { + if (!empty($answer_stamp_begin_formatted)) { $sql .= "and answer_stamp >= :answer_stamp_begin \n"; - $parameters['answer_stamp_begin'] = $answer_stamp_begin.':00.000 '.$time_zone;; + $parameters['answer_stamp_begin'] = $answer_stamp_begin_formatted.':00.000 '.$time_zone;; } - if (!empty($answer_stamp_end)) { + if (!empty($answer_stamp_end_formatted)) { $sql .= "and answer_stamp <= :answer_stamp_end \n"; - $parameters['answer_stamp_end'] = $answer_stamp_end.':59.999 '.$time_zone; + $parameters['answer_stamp_end'] = $answer_stamp_end_formatted.':59.999 '.$time_zone; } } - if (!empty($end_stamp_begin) && !empty($end_stamp_end)) { + if (!empty($end_stamp_begin)) { + $end_stamp_begin_formatted = ($settings->get('domain', 'time_format') == '24h' ? $end_stamp_begin : DateTime::createFromFormat('Y-m-d h:i a', $end_stamp_begin)->format('Y-m-d H:i')); + } + if (!empty($end_stamp_end)) { + $end_stamp_end_formatted = ($settings->get('domain', 'time_format') == '24h' ? $end_stamp_end : DateTime::createFromFormat('Y-m-d h:i a', $end_stamp_end)->format('Y-m-d H:i')); + } + if (!empty($end_stamp_begin_formatted) && !empty($end_stamp_end_formatted)) { $sql .= "and end_stamp between :end_stamp_begin::timestamptz and :end_stamp_end::timestamptz \n"; - $parameters['end_stamp_begin'] = $end_stamp_begin.':00.000 '.$time_zone; - $parameters['end_stamp_end'] = $end_stamp_end.':59.999 '.$time_zone; + $parameters['end_stamp_begin'] = $end_stamp_begin_formatted.':00.000 '.$time_zone; + $parameters['end_stamp_end'] = $end_stamp_end_formatted.':59.999 '.$time_zone; } else { - if (!empty($end_stamp_begin)) { + if (!empty($end_stamp_begin_formatted)) { $sql .= "and end_stamp >= :end_stamp_begin \n"; - $parameters['end_stamp_begin'] = $end_stamp_begin.':00.000 '.$time_zone; + $parameters['end_stamp_begin'] = $end_stamp_begin_formatted.':00.000 '.$time_zone; } - if (!empty($end_stamp_end)) { + if (!empty($end_stamp_end_formatted)) { $sql .= "and end_stamp <= :end_stamp_end \n"; - $parameters['end_stamp'] = $end_stamp_end.':59.999 '.$time_zone; + $parameters['end_stamp'] = $end_stamp_end_formatted.':59.999 '.$time_zone; } } if (is_numeric($duration_min)) { @@ -652,6 +670,7 @@ $database->username = $settings->get('cdr', 'archive_database_username'); $database->password = $settings->get('cdr', 'archive_database_password'); } + $parameters['time_zone'] = $time_zone; $result = $database->select($sql, $parameters, 'all'); $result_count = is_array($result) ? sizeof($result) : 0; unset($sql, $parameters); diff --git a/app/xml_cdr/xml_cdr_search.php b/app/xml_cdr/xml_cdr_search.php index b2e3992e01..1f33662587 100644 --- a/app/xml_cdr/xml_cdr_search.php +++ b/app/xml_cdr/xml_cdr_search.php @@ -214,8 +214,8 @@ echo " "; echo "
\n"; echo "
"; - echo " "; - echo " "; + echo " "; + echo " "; echo "
\n"; echo "
\n"; echo " "; @@ -225,8 +225,8 @@ echo " "; echo "
\n"; echo "
"; - echo " "; - echo " "; + echo " "; + echo " "; echo "
\n"; echo "
\n"; echo " "; @@ -236,8 +236,8 @@ echo " "; echo "
\n"; echo "
"; - echo " "; - echo " "; + echo " "; + echo " "; echo "
\n"; echo "
\n"; echo " "; diff --git a/app/xml_cdr/xml_cdr_statistics.php b/app/xml_cdr/xml_cdr_statistics.php index a1439ee9c5..74b01af00e 100644 --- a/app/xml_cdr/xml_cdr_statistics.php +++ b/app/xml_cdr/xml_cdr_statistics.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2024 + Portions created by the Initial Developer are Copyright (C) 2008-2025 the Initial Developer. All Rights Reserved. Contributor(s): @@ -131,6 +131,14 @@ $search_url .= '&mos_score='.urlencode($_GET['mos_score']); } +//set the chart time format + if ($settings->get('domain', 'time_format') == '24h') { + $chart_time_format = 'H:mm'; + } + else { + $chart_time_format = 'h a'; + } + //show the content echo "
\n"; echo "
".$text['title-call-statistics']."
\n"; @@ -234,6 +242,11 @@ scales: { x: { type: "time", + time: { + displayFormats: { + hour: '', + } + }, }, y: { min: 0 diff --git a/app/xml_cdr/xml_cdr_statistics_inc.php b/app/xml_cdr/xml_cdr_statistics_inc.php index 5d3809715a..beb36b3aa3 100644 --- a/app/xml_cdr/xml_cdr_statistics_inc.php +++ b/app/xml_cdr/xml_cdr_statistics_inc.php @@ -200,45 +200,63 @@ $parameters['context'] = '%'.$context.'%'; } /* - if (!empty($start_stamp_begin) && !empty($start_stamp_end)) { + if (!empty($start_stamp_begin)) { + $start_stamp_begin_formatted = ($settings->get('domain', 'time_format') == '24h' ? $start_stamp_begin : DateTime::createFromFormat('Y-m-d h:i a', $start_stamp_begin)->format('Y-m-d H:i')); + } + if (!empty($start_stamp_end)) { + $start_stamp_end_formatted = ($settings->get('domain', 'time_format') == '24h' ? $start_stamp_end : DateTime::createFromFormat('Y-m-d h:i a', $start_stamp_end)->format('Y-m-d H:i')); + } + if (!empty($start_stamp_begin_formatted) && !empty($start_stamp_end_formatted)) { $sql_where_ands[] = "start_stamp between :start_stamp_begin and :start_stamp_end"; - $parameters['start_stamp_begin'] = $start_stamp_begin.':00.000'; - $parameters['start_stamp_end'] = $start_stamp_end.':59.999'; + $parameters['start_stamp_begin'] = $start_stamp_begin_formatted.':00.000'; + $parameters['start_stamp_end'] = $start_stamp_end_formatted.':59.999'; } - else if (!empty($start_stamp_begin)) { + else if (!empty($start_stamp_begin_formatted)) { $sql_where_ands[] = "start_stamp >= :start_stamp_begin"; - $parameters['start_stamp_begin'] = $start_stamp_begin.':00.000'; + $parameters['start_stamp_begin'] = $start_stamp_begin_formatted.':00.000'; } - else if (!empty($start_stamp_end)) { + else if (!empty($start_stamp_end_formatted)) { $sql_where_ands[] = "start_stamp <= :start_stamp_end"; - $parameters['start_stamp_end'] = $start_stamp_end.':59.999'; + $parameters['start_stamp_end'] = $start_stamp_end_formatted.':59.999'; } */ - if (!empty($answer_stamp_begin) && !empty($answer_stamp_end)) { + if (!empty($answer_stamp_begin)) { + $answer_stamp_begin_formatted = ($settings->get('domain', 'time_format') == '24h' ? $answer_stamp_begin : DateTime::createFromFormat('Y-m-d h:i a', $answer_stamp_begin)->format('Y-m-d H:i')); + } + if (!empty($answer_stamp_end)) { + $answer_stamp_end_formatted = ($settings->get('domain', 'time_format') == '24h' ? $answer_stamp_end : DateTime::createFromFormat('Y-m-d h:i a', $answer_stamp_end)->format('Y-m-d H:i')); + } + if (!empty($answer_stamp_begin_formatted) && !empty($answer_stamp_end_formatted)) { $sql_where_ands[] = "c.answer_stamp between :answer_stamp_begin and :answer_stamp_end"; - $parameters['answer_stamp_begin'] = $answer_stamp_begin.':00.000'; - $parameters['answer_stamp_end'] = $answer_stamp_end.':59.999'; + $parameters['answer_stamp_begin'] = $answer_stamp_begin_formatted.':00.000'; + $parameters['answer_stamp_end'] = $answer_stamp_end_formatted.':59.999'; } - else if (!empty($answer_stamp_begin)) { + else if (!empty($answer_stamp_begin_formatted)) { $sql_where_ands[] = "c.answer_stamp >= :answer_stamp_begin"; - $parameters['answer_stamp_begin'] = $answer_stamp_begin.':00.000'; + $parameters['answer_stamp_begin'] = $answer_stamp_begin_formatted.':00.000'; } - else if (!empty($answer_stamp_end)) { + else if (!empty($answer_stamp_end_formatted)) { $sql_where_ands[] = "c.answer_stamp <= :answer_stamp_end"; - $parameters['answer_stamp_end'] = $answer_stamp_end.':59.999'; + $parameters['answer_stamp_end'] = $answer_stamp_end_formatted.':59.999'; } - if (!empty($end_stamp_begin) && !empty($end_stamp_end)) { + if (!empty($end_stamp_begin)) { + $end_stamp_begin_formatted = ($settings->get('domain', 'time_format') == '24h' ? $end_stamp_begin : DateTime::createFromFormat('Y-m-d h:i a', $end_stamp_begin)->format('Y-m-d H:i')); + } + if (!empty($end_stamp_end)) { + $end_stamp_end_formatted = ($settings->get('domain', 'time_format') == '24h' ? $end_stamp_end : DateTime::createFromFormat('Y-m-d h:i a', $end_stamp_end)->format('Y-m-d H:i')); + } + if (!empty($end_stamp_begin_formatted) && !empty($end_stamp_end_formatted)) { $sql_where_ands[] = "c.end_stamp between :end_stamp_begin and :end_stamp_end"; - $parameters['end_stamp_begin'] = $end_stamp_begin.':00.000'; - $parameters['end_stamp_end'] = $end_stamp_end.':59.999'; + $parameters['end_stamp_begin'] = $end_stamp_begin_formatted.':00.000'; + $parameters['end_stamp_end'] = $end_stamp_end_formatted.':59.999'; } - else if (!empty($end_stamp_begin)) { + else if (!empty($end_stamp_begin_formatted)) { $sql_where_ands[] = "c.end_stamp >= :end_stamp_begin"; - $parameters['end_stamp_begin'] = $end_stamp_begin.':00.000'; + $parameters['end_stamp_begin'] = $end_stamp_begin_formatted.':00.000'; } - else if (!empty($end_stamp_end)) { + else if (!empty($end_stamp_end_formatted)) { $sql_where_ands[] = "c.end_stamp <= :end_stamp_end"; - $parameters['end_stamp_end'] = $end_stamp_end.':59.999'; + $parameters['end_stamp_end'] = $end_stamp_end_formatted.':59.999'; } if (!empty($duration)) { $sql_where_ands[] = "c.duration like :duration"; @@ -355,13 +373,20 @@ //set the time zone $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); - $parameters['time_zone'] = $time_zone; + +//set the time format options: 12h, 24h + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'HH24:MI'; + } + else { + $time_format = 'HH12:MI am'; + } //build the sql query for xml cdr statistics $sql = "select "; $sql .= "row_number() over() as hours, "; $sql .= "to_char(start_date at time zone :time_zone, 'DD Mon') as date, \n"; - $sql .= "to_char(start_date at time zone :time_zone, 'HH12:MI am') || ' - ' || to_char(end_date at time zone :time_zone, 'HH12:MI am') as time, \n"; + $sql .= "to_char(start_date at time zone :time_zone, '".$time_format."') || ' - ' || to_char(end_date at time zone :time_zone, '".$time_format."') as time, \n"; $sql .= "extract(epoch from start_date) as start_epoch, "; $sql .= "extract(epoch from end_date) as end_epoch, "; $sql .= "s_hour, start_date, end_date, volume, answered, (round(d.seconds / 60, 1)) as minutes, \n"; @@ -575,6 +600,7 @@ $sql .= " group by s.s_id, s.start_date, s.end_date, s.s_hour \n"; $sql .= " order by s.s_id asc \n"; $sql .= ") as d; \n"; + $parameters['time_zone'] = $time_zone; $stats = $database->select($sql, $parameters, 'all'); //set the hours @@ -624,4 +650,4 @@ $x++; } -?> \ No newline at end of file +?> diff --git a/core/contacts/contact_edit.php b/core/contacts/contact_edit.php index 894779e59d..f626576722 100644 --- a/core/contacts/contact_edit.php +++ b/core/contacts/contact_edit.php @@ -594,6 +594,17 @@ } } +//set the time zone + date_default_timezone_set($settings->get('domain', 'time_zone', date_default_timezone_get())); + +//set the time format options: 12h, 24h + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'H:i:s'; + } + else { + $time_format = 'h:i:s a'; + } + //pre-populate the form if (!empty($_GET) && empty($_POST["persistformvar"])) { $sql = "select * from v_contacts "; @@ -2635,14 +2646,14 @@ if (permission_exists('contact_time_view')) { echo " ".$text['label-time_start']."\n"; echo "
\n"; echo "
\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo "
\n"; echo " ".$text['label-time_stop']."\n"; echo "
\n"; echo "
\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo "
\n"; @@ -2701,7 +2712,7 @@ if (permission_exists('contact_note_view')) { echo " ".$text['label-note_user']."\n"; echo "
\n"; echo "
\n"; - echo "
".escape($row['last_mod_user']).": ".date("j M Y @ H:i:s", strtotime($row['last_mod_date']))."
\n"; + echo "
".escape($row['last_mod_user']).": ".date("j M Y @ ".$time_format, strtotime($row['last_mod_date']))."
\n"; echo "
\n"; echo "
\n"; diff --git a/core/contacts/contact_notes.php b/core/contacts/contact_notes.php index a9db5579e2..bb0c5b3d24 100644 --- a/core/contacts/contact_notes.php +++ b/core/contacts/contact_notes.php @@ -39,6 +39,17 @@ $contact_uuid = $_GET['id']; } +//set the time zone + date_default_timezone_set($settings->get('domain', 'time_zone', date_default_timezone_get())); + +//set the time format options: 12h, 24h + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'H:i:s'; + } + else { + $time_format = 'h:i:s a'; + } + //get the contact list $sql = "select * from v_contact_notes "; $sql .= "where domain_uuid = :domain_uuid "; @@ -93,7 +104,7 @@ echo " \n"; } echo " ".$contact_note."\n"; - echo " ".escape($row['last_mod_user']).": ".date("j M Y @ H:i:s", strtotime($row['last_mod_date']))."\n"; + echo " ".escape($row['last_mod_user']).": ".date("j M Y @ ".$time_format, strtotime($row['last_mod_date']))."\n"; if (permission_exists('contact_note_edit') && $list_row_edit_button == 'true') { echo " \n"; echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$settings->get('theme', 'button_icon_edit'),'link'=>$list_row_url]); @@ -112,4 +123,3 @@ } ?> - diff --git a/core/contacts/contact_notes_view.php b/core/contacts/contact_notes_view.php index 646f2b93c1..3e1aefc62d 100644 --- a/core/contacts/contact_notes_view.php +++ b/core/contacts/contact_notes_view.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2020 + Portions created by the Initial Developer are Copyright (C) 2008-2025 the Initial Developer. All Rights Reserved. Contributor(s): @@ -34,6 +34,17 @@ exit; } +//set the time zone + date_default_timezone_set($settings->get('domain', 'time_zone', date_default_timezone_get())); + +//set the time format options: 12h, 24h + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'H:i:s'; + } + else { + $time_format = 'h:i:s a'; + } + //get the contact list $sql = "select * from v_contact_notes "; $sql .= "where domain_uuid = :domain_uuid "; @@ -53,7 +64,7 @@ foreach ($contact_notes as $row) { $contact_note = str_replace("\n","
",escape($row['contact_note'])); echo "
".$contact_note."
\n"; - echo "
".escape($row['last_mod_user']).": ".date("j M Y @ H:i:s", strtotime($row['last_mod_date']))."
\n"; + echo "
".escape($row['last_mod_user']).": ".date("j M Y @ ".$time_format, strtotime($row['last_mod_date']))."
\n"; $x++; } echo "
\n"; diff --git a/core/contacts/contact_timer.php b/core/contacts/contact_timer.php index 05e183b70f..ee7f332a15 100644 --- a/core/contacts/contact_timer.php +++ b/core/contacts/contact_timer.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2015 + Portions created by the Initial Developer are Copyright (C) 2008-2025 the Initial Developer. All Rights Reserved. Contributor(s): @@ -28,6 +28,10 @@ require_once "resources/check_auth.php"; if (!permission_exists('contact_time_add')) { echo "access denied"; exit; } +//set the defaults + $contact_time_uuid = ''; + $time_description = ''; + //add multi-lingual support $language = new text; $text = $language->get(); @@ -36,6 +40,9 @@ $domain_uuid = $_REQUEST['domain_uuid']; $contact_uuid = $_REQUEST['contact_uuid']; +//set the time zone + date_default_timezone_set($settings->get('domain', 'time_zone', date_default_timezone_get())); + //get posted variables & set time status if (!empty($_POST)) { $contact_time_uuid = $_POST['contact_time_uuid']; diff --git a/core/contacts/contact_times.php b/core/contacts/contact_times.php index 1577e029aa..3233158b17 100644 --- a/core/contacts/contact_times.php +++ b/core/contacts/contact_times.php @@ -42,6 +42,17 @@ $contact_uuid = $_GET['id']; } +//set the time zone + date_default_timezone_set($settings->get('domain', 'time_zone', date_default_timezone_get())); + +//set the time format options: 12h, 24h + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'H:i:s'; + } + else { + $time_format = 'h:i:s a'; + } + //get the contact list $sql = "select ct.*, u.username, u.domain_uuid as user_domain_uuid "; $sql .= "from v_contact_times as ct, v_users as u "; @@ -86,7 +97,7 @@ if (!empty($row["time_start"]) && !empty($row['time_stop'])) { $time_start = strtotime($row["time_start"]); $time_stop = strtotime($row['time_stop']); - $time = gmdate("H:i:s", ($time_stop - $time_start)); + $time = gmdate($time_zone, ($time_stop - $time_start)); } else { unset($time); diff --git a/core/user_logs/user_logs.php b/core/user_logs/user_logs.php index deef7796a3..52d8e443b5 100644 --- a/core/user_logs/user_logs.php +++ b/core/user_logs/user_logs.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2018-2024 + Portions created by the Initial Developer are Copyright (C) 2018-2025 the Initial Developer. All Rights Reserved. */ @@ -146,7 +146,14 @@ //set the time zone $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); - $parameters['time_zone'] = $time_zone; + +//set the time format options: 12h, 24h + if ($settings->get('domain', 'time_format') == '24h') { + $time_format = 'HH24:MI:SS'; + } + else { + $time_format = 'HH12:MI:SS am'; + } //get the list $sql = "select "; @@ -155,7 +162,7 @@ $sql .= "u.domain_uuid, "; $sql .= "d.domain_name, "; $sql .= "to_char(timezone(:time_zone, timestamp), 'DD Mon YYYY') as date_formatted, "; - $sql .= "to_char(timezone(:time_zone, timestamp), 'HH12:MI:SS am') as time_formatted, "; + $sql .= "to_char(timezone(:time_zone, timestamp), '".$time_format."') as time_formatted, "; $sql .= "user_uuid, "; $sql .= "username, "; $sql .= "type, "; @@ -187,6 +194,7 @@ $sql .= "and u.domain_uuid = d.domain_uuid "; $sql .= order_by($order_by, $order, 'timestamp', 'desc'); $sql .= limit_offset($rows_per_page, $offset); + $parameters['time_zone'] = $time_zone; $user_logs = $database->select($sql, $parameters ?? null, 'all'); unset($sql, $parameters); diff --git a/resources/footer.php b/resources/footer.php index e8c983848e..b93db8cb46 100644 --- a/resources/footer.php +++ b/resources/footer.php @@ -103,6 +103,8 @@ $view->assign('project_path', PROJECT_PATH); //domain menu $view->assign('domain_menu', escape($settings->get('domain', 'menu'))); + //time format + $view->assign('time_format', escape($settings->get('domain', 'time_format'))); //domain json token $view->assign('domain_json_token_name', $domain_json_token['name']); $view->assign('domain_json_token_hash', $domain_json_token['hash']); diff --git a/themes/default/css.php b/themes/default/css.php index 39cbe6ec9d..8ae554c073 100644 --- a/themes/default/css.php +++ b/themes/default/css.php @@ -2958,7 +2958,8 @@ else { //default: white ?> } - div.card:has(.datetimepicker) { + div.card:has(.datetimepicker), + div.card:has(.datetimesecpicker) { overflow-x: visible; } diff --git a/themes/default/template.php b/themes/default/template.php index f4712cb5ee..6056b3c381 100644 --- a/themes/default/template.php +++ b/themes/default/template.php @@ -19,7 +19,7 @@ - + {*//link to custom css file *} {if !empty($settings.theme.custom_css)} @@ -567,9 +567,23 @@ }); //define formatting of individual classes $('.datepicker').datetimepicker({ format: 'YYYY-MM-DD', }); - $('.datetimepicker').datetimepicker({ format: 'YYYY-MM-DD HH:mm', }); - $('.datetimepicker-future').datetimepicker({ format: 'YYYY-MM-DD HH:mm', minDate: new Date(), }); - $('.datetimesecpicker').datetimepicker({ format: 'YYYY-MM-DD HH:mm:ss', }); + {/literal} + + {if !empty($time_format) && $time_format == '24h'} + {literal} + $(".datetimepicker").datetimepicker({ format: 'YYYY-MM-DD HH:mm', }); + $(".datetimepicker-future").datetimepicker({ format: 'YYYY-MM-DD HH:mm', minDate: new Date(), }); + $(".datetimesecpicker").datetimepicker({ format: 'YYYY-MM-DD HH:mm:ss', }); + {/literal} + {else} + {literal} + $(".datetimepicker").datetimepicker({ format: 'YYYY-MM-DD hh:mm a', }); + $(".datetimepicker-future").datetimepicker({ format: 'YYYY-MM-DD hh:mm a', minDate: new Date(), }); + $(".datetimesecpicker").datetimepicker({ format: 'YYYY-MM-DD hh:mm:ss a', }); + {/literal} + {/if} + + {literal} }); {/literal}