fusionpbx/app/voicemails/resources/dashboard/voicemails.php

158 lines
5.9 KiB
PHP
Raw Normal View History

2021-11-10 02:42:14 +01:00
<?php
2022-10-11 00:35:14 +02:00
//includes files
Use magic constant dir (#6711) * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ to load only functions.php * replace spaces with tab character * update dirname command to use levels instead of nesting * use magic constant __DIR__ * update dirname command to use levels instead of nesting * Update access_control_edit.php * Update access_control_import.php * Update access_controls.php * Update dnd.php * Update access_controls_reload.php * Update call_center_agents.php * Update call_center_agents.php * Update fax_queue.php * Update login.php * Update pdo.php * Update pdo_vm.php * Update switch.php * Update index.php * Update css.php * Update v_mailto.php * Update fax_to_email.php --------- Co-authored-by: FusionPBX <markjcrane@gmail.com>
2023-06-15 19:28:23 +02:00
require_once dirname(__DIR__, 4) . "/resources/require.php";
2021-11-10 02:42:14 +01:00
//check permisions
require_once "resources/check_auth.php";
if (permission_exists('voicemail_view') || permission_exists('voicemail_message_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get($_SESSION['domain']['language']['code'], 'core/user_settings');
//used for missed and recent calls
$theme_image_path = $_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/";
2021-11-10 02:42:14 +01:00
//voicemail
2021-11-10 07:19:37 +01:00
echo "<div class='hud_box'>\n";
//get the voicemail
$vm = new voicemail;
$vm->domain_uuid = $_SESSION['domain_uuid'];
$vm->order_by = $order_by ?? null;
$vm->order = $order ?? null;
2021-11-10 07:19:37 +01:00
$voicemails = $vm->messages();
//sum total and new
$messages['total'] = 0;
$messages['new'] = 0;
if (!empty($voicemails) && sizeof($voicemails) > 0) {
2021-11-10 07:19:37 +01:00
foreach($voicemails as $field) {
$messages[$field['voicemail_uuid']]['ext'] = $field['voicemail_id'];
$messages[$field['voicemail_uuid']]['total'] = 0;
$messages[$field['voicemail_uuid']]['new'] = 0;
foreach ($field['messages'] as $row) {
2021-11-10 07:19:37 +01:00
if ($row['message_status'] == '') {
$messages[$field['voicemail_uuid']]['new']++;
$messages['new']++;
2021-11-10 02:42:14 +01:00
}
2021-11-10 07:19:37 +01:00
$messages[$field['voicemail_uuid']]['total']++;
$messages['total']++;
2021-11-10 02:42:14 +01:00
}
2021-11-10 07:19:37 +01:00
}
}
2021-11-10 02:42:14 +01:00
echo "<div class='hud_content' ".($dashboard_details_state == "disabled" ?: "onclick=\"$('#hud_voicemail_details').slideToggle('fast'); toggle_grid_row_end('".$dashboard_name."')\"").">\n";
echo " <span class='hud_title'><a onclick=\"document.location.href='".PROJECT_PATH."/app/voicemails/voicemail_messages.php'\">".$text['label-new_messages']."</a></span>";
2024-06-03 19:40:05 +02:00
if (isset($dashboard_chart_type) && $dashboard_chart_type == "doughnut") {
2024-04-19 01:11:05 +02:00
//add doughnut chart
?>
<div class='hud_chart'><canvas id='new_messages_chart'></canvas></div>
2021-11-12 20:55:42 +01:00
2024-04-19 01:11:05 +02:00
<script>
const new_messages_chart = new Chart(
document.getElementById('new_messages_chart').getContext('2d'),
{
type: 'doughnut',
data: {
datasets: [{
data: ['<?php echo $messages['new']; ?>', 0.00001],
backgroundColor: [
'<?php echo ($settings->get('theme', 'dashboard_missed_calls_chart_main_color') ?? '#ff9933'); ?>',
'<?php echo ($settings->get('theme', 'dashboard_missed_calls_chart_sub_color') ?? '#d4d4d4'); ?>'
2024-04-19 01:11:05 +02:00
],
borderColor: '<?php echo $settings->get('theme', 'dashboard_chart_border_color'); ?>',
borderWidth: '<?php echo $settings->get('theme', 'dashboard_chart_border_width'); ?>',
2024-04-19 01:11:05 +02:00
}]
},
options: {
plugins: {
chart_number: {
text: '<?php echo $messages['new']; ?>'
}
}
2024-04-19 01:11:05 +02:00
},
plugins: [{
id: 'chart_number',
beforeDraw(chart, args, options){
const {ctx, chartArea: {top, right, bottom, left, width, height} } = chart;
ctx.font = chart_text_size + ' ' + chart_text_font;
2024-04-19 01:11:05 +02:00
ctx.textBaseline = 'middle';
ctx.textAlign = 'center';
ctx.fillStyle = '<?php echo $dashboard_number_text_color; ?>';
ctx.fillText(options.text, width / 2, top + (height / 2));
ctx.save();
}
}]
}
);
</script>
<?php
}
//dashboard number
2024-06-03 19:40:05 +02:00
if (!isset($dashboard_chart_type) || $dashboard_chart_type == "number") {
echo " <span class='hud_stat'>".$messages['new']."</span>";
2024-04-19 01:11:05 +02:00
}
//dashboard icon
if (!isset($dashboard_chart_type) || $dashboard_chart_type == "icon") {
echo "<span class='hud_content'>\n";
echo "<div style='position: relative; display: inline-block;'>\n";
echo " <span class='hud_stat'><i class=\"fas ".$dashboard_icon." \"></i></span>\n";
echo " <span style=\"background-color: ".(!empty($dashboard_number_background_color) ? $dashboard_number_background_color : '#03c04a')."; color: ".(!empty($dashboard_number_text_color) ? $dashboard_number_text_color : '#ffffff')."; font-size: 12px; font-weight: bold; text-align: center; position: absolute; top: 23px; left: 24.5px; padding: 2px 7px 1px 7px; border-radius: 10px; white-space: nowrap;\">".$messages['new']."</span>\n";
echo " </div>\n";
echo "</span>";
}
echo "</div>\n";
2021-11-10 07:19:37 +01:00
if ($dashboard_details_state != 'disabled') {
echo "<div class='hud_details hud_box' id='hud_voicemail_details'>";
if (!empty($voicemails) && 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'])."&back=".urlencode($_SERVER["REQUEST_URI"])."'>".$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;
}
2021-11-10 02:42:14 +01:00
}
echo "</table>";
2021-11-10 07:19:37 +01:00
}
else {
echo "<br />".$text['label-no_voicemail_assigned'];
}
echo "</div>";
//$n++;
2021-11-10 07:19:37 +01:00
echo "<span class='hud_expander' onclick=\"$('#hud_voicemail_details').slideToggle('fast'); toggle_grid_row_end('".$dashboard_name."')\"><span class='fas fa-ellipsis-h'></span></span>";
2021-11-10 07:19:37 +01:00
}
2021-11-10 07:19:37 +01:00
echo "</div>\n";
2021-11-10 02:42:14 +01:00
?>