From 5c7dfe339be6938f3a1199d6309d8913551e23ba Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 17 May 2023 20:41:52 -0600 Subject: [PATCH] Use the database to format the date time with the time zone --- app/voicemails/resources/classes/voicemail.php | 18 +++++++++++++++--- app/voicemails/voicemail_messages.php | 12 ++---------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/voicemails/resources/classes/voicemail.php b/app/voicemails/resources/classes/voicemail.php index bc16531401..bef26980f9 100644 --- a/app/voicemails/resources/classes/voicemail.php +++ b/app/voicemails/resources/classes/voicemail.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-2019 + Portions created by the Initial Developer are Copyright (C) 2008-2023 the Initial Developer. All Rights Reserved. Contributor(s): @@ -203,8 +203,19 @@ return false; } + //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(); + } + //get the message from the database - $sql = "select * from v_voicemail_messages as m, v_voicemails as v "; + $sql = "select *, "; + $sql .= "to_char(timezone(:time_zone, to_timestamp(m.created_epoch)), 'DD Mon YYYY') as created_date_formatted, \n"; + $sql .= "to_char(timezone(:time_zone, to_timestamp(m.created_epoch)), 'HH12:MI:SS am') as created_time_formatted \n"; + $sql .= "from v_voicemail_messages as m, v_voicemails as v "; $sql .= "where m.domain_uuid = :domain_uuid "; $sql .= "and m.voicemail_uuid = v.voicemail_uuid "; if (is_array($this->voicemail_id) && @sizeof($this->voicemail_id) != 0) { @@ -230,10 +241,11 @@ $sql .= "order by v.voicemail_id, m.".$this->order_by." ".$this->order." "; } $parameters['domain_uuid'] = $this->domain_uuid; + $parameters['time_zone'] = $time_zone; $database = new database; $result = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); - + //update the array with additional information if (is_array($result)) { foreach($result as &$row) { diff --git a/app/voicemails/voicemail_messages.php b/app/voicemails/voicemail_messages.php index 92b7635a59..9e0b09321f 100644 --- a/app/voicemails/voicemail_messages.php +++ b/app/voicemails/voicemail_messages.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-2023 the Initial Developer. All Rights Reserved. Contributor(s): @@ -291,14 +291,6 @@ if (is_array($field['messages']) && @sizeof($field['messages']) > 0) { foreach ($field['messages'] as $row) { - //responsive date - $array = explode(' ', $row['created_date']); - if ($array[0].' '.$array[1].' '.$array[2] == date('j M Y')) { //today - $created_date = escape($array[3].' '.$array[4]); //only show time - } - else { - $created_date = escape($array[0].' '.$array[1].' '.$array[2])." ".escape($array[3].' '.$array[4]).""; - } //playback progress bar echo "\n"; @@ -312,7 +304,7 @@ echo " \n"; echo " \n"; echo " \n"; - echo " ".$created_date."\n"; + echo " ".escape($row['created_date_formatted'])." ".escape($row['created_time_formatted'])."\n"; echo " ".escape($row['caller_id_name'])." \n"; echo " ".escape($row['caller_id_number'])." \n"; echo " ";