diff --git a/app/voicemails/voicemails.php b/app/voicemails/voicemails.php index a5ddceae2f..3b630793f0 100644 --- a/app/voicemails/voicemails.php +++ b/app/voicemails/voicemails.php @@ -136,6 +136,22 @@ $voicemails = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); +//get vm count for each mailbox + if (permission_exists('voicemail_message_view')) { + $sql = "select voicemail_uuid, count(*) as voicemail_count "; + $sql .= "from v_voicemail_messages where domain_uuid = :domain_uuid"; + $sql .= " group by voicemail_uuid"; + $parameters['domain_uuid'] = $domain_uuid; + $database = new database; + $voicemails_count_tmp = $database->select($sql, $parameters, 'all'); + + $voicemails_count = array(); + foreach ($voicemails_count_tmp as &$row) { + $voicemails_count[$row['voicemail_uuid']] = $row['voicemail_count']; + } + unset($sql, $parameters, $voicemails_count_tmp); + } + //create token $object = new token; $token = $object->create($_SERVER['PHP_SELF']); @@ -193,7 +209,12 @@ if (is_array($_SESSION['voicemail']['transcribe_enabled']) && $_SESSION['voicemail']['transcribe_enabled']['boolean'] == 'true') { echo th_order_by('voicemail_transcription_enabled', $text['label-voicemail_transcribe_enabled'], $order_by, $order); } - echo "".$text['label-tools']."\n"; + if (permission_exists('voicemail_message_view') || permission_exists('voicemail_greeting_view')) { + echo "".$text['label-tools']."\n"; + } + if (permission_exists('voicemail_message_view') && permission_exists('voicemail_greeting_view')) { + echo "\n"; + } echo th_order_by('voicemail_enabled', $text['label-voicemail_enabled'], $order_by, $order, null, "class='center'"); echo th_order_by('voicemail_description', $text['label-voicemail_description'], $order_by, $order, null, "class='hide-sm-dn'"); if (permission_exists('voicemail_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { @@ -229,14 +250,17 @@ if (is_array($_SESSION['voicemail']['transcribe_enabled']) && $_SESSION['voicemail']['transcribe_enabled']['boolean'] == 'true') { echo " ".ucwords(escape($row['voicemail_transcription_enabled']))." \n"; } - echo " \n"; if (permission_exists('voicemail_message_view')) { - echo " ".$text['label-messages']."  \n"; + echo " \n"; + $tmp_voicemail_string = (array_key_exists($row['voicemail_uuid'], $voicemails_count)) ? " (" . $voicemails_count[$row['voicemail_uuid']] . ")" : " (0)"; + echo " ".$text['label-messages'].$tmp_voicemail_string."\n"; + echo " \n"; } if (permission_exists('voicemail_greeting_view')) { + echo " \n"; echo " ".$text['label-greetings']."\n"; + echo " \n"; } - echo " \n"; if (permission_exists('voicemail_edit')) { echo " \n"; echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['voicemail_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);