Use the database to format the date time with the time zone

This commit is contained in:
markjcrane
2023-05-17 20:41:52 -06:00
parent f1ac3d92dd
commit 5c7dfe339b
2 changed files with 17 additions and 13 deletions

View File

@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
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) {

View File

@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
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])." <span class='hide-xs' title=\"".escape($array[3].' '.$array[4])."\">".escape($array[3].' '.$array[4])."</span>";
}
//playback progress bar
echo "<tr class='list-row' id='recording_progress_bar_".escape($row['voicemail_message_uuid'])."' style='display: none;'><td class='playback_progress_bar_background' style='padding: 0; border: none;' colspan='".$col_count."'><span class='playback_progress_bar' id='recording_progress_".escape($row['voicemail_message_uuid'])."'></span></td></tr>\n";
@@ -312,7 +304,7 @@
echo " <input type='hidden' name='voicemail_messages[$x][uuid]' value='".escape($row['voicemail_message_uuid'])."' />\n";
echo " <input type='hidden' name='voicemail_messages[$x][voicemail_uuid]' value='".escape($row['voicemail_uuid'])."' />\n";
echo " </td>\n";
echo " <td class='no-wrap' style='".$bold."'>".$created_date."</td>\n";
echo " <td class='no-wrap' style='".$bold."'>".escape($row['created_date_formatted'])." ".escape($row['created_time_formatted'])."</td>\n";
echo " <td class='overflow' style='".$bold."'>".escape($row['caller_id_name'])."&nbsp;</td>\n";
echo " <td class='hide-xs' style='".$bold."'>".escape($row['caller_id_number'])."&nbsp;</td>\n";
echo " <td class='button center no-link no-wrap'>";