Update voicemails.php (#6115)

This commit is contained in:
AlexC
2021-11-09 23:19:37 -07:00
committed by GitHub
parent a8697e1f71
commit aa9eac0684
+105 -101
View File
@@ -22,116 +22,120 @@
$theme_image_path = $_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/"; $theme_image_path = $_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/";
//voicemail //voicemail
//if (is_array($selected_blocks) && in_array('voicemail', $selected_blocks) && permission_exists('voicemail_message_view') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/voicemails/")) { echo "<div class='hud_box'>\n";
//required class
require_once "app/voicemails/resources/classes/voicemail.php"; //required class
//get the voicemail require_once "app/voicemails/resources/classes/voicemail.php";
$vm = new voicemail;
$vm->db = $db; //get the voicemail
$vm->domain_uuid = $_SESSION['domain_uuid']; $vm = new voicemail;
$vm->order_by = $order_by; $vm->db = $db;
$vm->order = $order; $vm->domain_uuid = $_SESSION['domain_uuid'];
$voicemails = $vm->messages(); $vm->order_by = $order_by;
//sum total and new $vm->order = $order;
$messages['total'] = 0; $voicemails = $vm->messages();
$messages['new'] = 0;
if (sizeof($voicemails) > 0) { //sum total and new
foreach($voicemails as $field) { $messages['total'] = 0;
$messages[$field['voicemail_uuid']]['ext'] = $field['voicemail_id']; $messages['new'] = 0;
$messages[$field['voicemail_uuid']]['total'] = 0; if (sizeof($voicemails) > 0) {
$messages[$field['voicemail_uuid']]['new'] = 0; foreach($voicemails as $field) {
foreach($field['messages'] as &$row) { $messages[$field['voicemail_uuid']]['ext'] = $field['voicemail_id'];
if ($row['message_status'] == '') { $messages[$field['voicemail_uuid']]['total'] = 0;
$messages[$field['voicemail_uuid']]['new']++; $messages[$field['voicemail_uuid']]['new'] = 0;
$messages['new']++; foreach($field['messages'] as &$row) {
} if ($row['message_status'] == '') {
$messages[$field['voicemail_uuid']]['total']++; $messages[$field['voicemail_uuid']]['new']++;
$messages['total']++; $messages['new']++;
}
} }
$messages[$field['voicemail_uuid']]['total']++;
$messages['total']++;
} }
}
}
//add doughnut chart //add doughnut chart
echo " echo "
<div style='display: flex; flex-wrap: wrap; justify-content: center; padding-bottom:10px;'> <div style='display: flex; flex-wrap: wrap; justify-content: center; padding-bottom:10px;'>
<div style='width: 175px; height: 175px;'><canvas id='new_messages_chart'></canvas></div> <div style='width: 175px; height: 175px;'><canvas id='new_messages_chart'></canvas></div>
</div> </div>
<script> <script>
var new_messages_bgc = ['#ff9933', '#d4d4d4']; var new_messages_bgc = ['#ff9933', '#d4d4d4'];
const new_messages_data = { const new_messages_data = {
datasets: [{ datasets: [{
data:[".$messages['new'].", 0.00001], data:[".$messages['new'].", 0.00001],
borderColor: 'rgba(0,0,0,0)', borderColor: 'rgba(0,0,0,0)',
backgroundColor: [new_messages_bgc[0], new_messages_bgc[1]], backgroundColor: [new_messages_bgc[0], new_messages_bgc[1]],
cutout: chart_cutout cutout: chart_cutout
}] }]
}; };
const new_messages_config = { const new_messages_config = {
type: 'doughnut', type: 'doughnut',
data: new_messages_data, data: new_messages_data,
options: { options: {
responsive: true, responsive: true,
maintainAspectRatio: false, maintainAspectRatio: false,
plugins: { plugins: {
chart_counter: { chart_counter: {
chart_text: ".$messages['new'].", chart_text: ".$messages['new'].",
},
legend: {
display: false
},
title: {
display: true,
text: '".$text['label-new_messages']."',
fontFamily: chart_font_family
}
}
}, },
plugins: [chart_counter], legend: {
}; display: false
},
const new_messages_chart = new Chart( title: {
document.getElementById('new_messages_chart'), display: true,
new_messages_config text: '".$text['label-new_messages']."',
); fontFamily: chart_font_family
</script> }
";
echo "<div class='hud_details hud_box' id='hud_voicemail_details'>";
if (sizeof($voicemails) > 0) {
echo "<table class='tr_hover' cellpadding='2' cellspacing='0' border='0' width='100%'>";
echo "<tr>";
echo " <th class='hud_heading' width='50%'>".$text['label-voicemail']."</th>";
echo " <th class='hud_heading' style='text-align: center;' width='50%'>".$text['label-new']."</th>";
echo " <th class='hud_heading' style='text-align: center;'>".$text['label-total']."</th>";
echo "</tr>";
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
foreach ($messages as $voicemail_uuid => $row) {
if (is_uuid($voicemail_uuid)) {
$tr_link = "href='".PROJECT_PATH."/app/voicemails/voicemail_messages.php?id=".(permission_exists('voicemail_view') ? $voicemail_uuid : $row['ext'])."'";
echo "<tr ".$tr_link." style='cursor: pointer;'>";
echo " <td class='".$row_style[$c]." hud_text'><a href='".PROJECT_PATH."/app/voicemails/voicemail_messages.php?id=".(permission_exists('voicemail_view') ? $voicemail_uuid : $row['ext'])."'>".$row['ext']."</a></td>";
echo " <td class='".$row_style[$c]." hud_text' style='text-align: center;'>".$row['new']."</td>";
echo " <td class='".$row_style[$c]." hud_text' style='text-align: center;'>".$row['total']."</td>";
echo "</tr>";
$c = ($c) ? 0 : 1;
} }
} },
plugins: [chart_counter],
};
echo "</table>"; const new_messages_chart = new Chart(
document.getElementById('new_messages_chart'),
new_messages_config
);
</script>
";
echo "<div class='hud_details hud_box' id='hud_voicemail_details'>";
if (sizeof($voicemails) > 0) {
echo "<table class='tr_hover' cellpadding='2' cellspacing='0' border='0' width='100%'>";
echo "<tr>";
echo " <th class='hud_heading' width='50%'>".$text['label-voicemail']."</th>";
echo " <th class='hud_heading' style='text-align: center;' width='50%'>".$text['label-new']."</th>";
echo " <th class='hud_heading' style='text-align: center;'>".$text['label-total']."</th>";
echo "</tr>";
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
foreach ($messages as $voicemail_uuid => $row) {
if (is_uuid($voicemail_uuid)) {
$tr_link = "href='".PROJECT_PATH."/app/voicemails/voicemail_messages.php?id=".(permission_exists('voicemail_view') ? $voicemail_uuid : $row['ext'])."'";
echo "<tr ".$tr_link." style='cursor: pointer;'>";
echo " <td class='".$row_style[$c]." hud_text'><a href='".PROJECT_PATH."/app/voicemails/voicemail_messages.php?id=".(permission_exists('voicemail_view') ? $voicemail_uuid : $row['ext'])."'>".$row['ext']."</a></td>";
echo " <td class='".$row_style[$c]." hud_text' style='text-align: center;'>".$row['new']."</td>";
echo " <td class='".$row_style[$c]." hud_text' style='text-align: center;'>".$row['total']."</td>";
echo "</tr>";
$c = ($c) ? 0 : 1;
} }
else { }
echo "<br />".$text['label-no_voicemail_assigned'];
} echo "</table>";
echo "</div>"; }
$n++; else {
//} echo "<br />".$text['label-no_voicemail_assigned'];
echo " <span class='hud_expander' onclick=\"$('#hud_voicemail_details').slideToggle('fast');\"><span class='fas fa-ellipsis-h'></span></span>"; }
echo "</div>";
$n++;
echo "<span class='hud_expander' onclick=\"$('#hud_voicemail_details').slideToggle('fast');\"><span class='fas fa-ellipsis-h'></span></span>";
echo "</div>\n";
?> ?>