Voicemail - Messages: Implement paging.

This commit is contained in:
fusionate 2024-06-07 15:18:14 -06:00
parent cb2b1b4132
commit a33975dc29
No known key found for this signature in database
2 changed files with 36 additions and 3 deletions

View File

@ -37,6 +37,7 @@
public $voicemail_message_uuid;
public $order_by;
public $order;
public $offset;
public $type;
/**
@ -253,6 +254,12 @@
else {
$sql .= "order by v.voicemail_id, m.".$this->order_by." ".$this->order." ";
}
//if paging offset defined, apply it along with rows per page
if (isset($this->offset)) {
$rows_per_page = $_SESSION['domain']['paging']['numeric'] != '' ? $_SESSION['domain']['paging']['numeric'] : 50;
$offset = isset($this->offset) && is_numeric($this->offset) ? $this->offset : 0;
$sql .= limit_offset($rows_per_page, $offset);
}
$parameters['domain_uuid'] = $this->domain_uuid;
$parameters['time_zone'] = $time_zone;
$database = new database;
@ -1057,4 +1064,4 @@ foreach ($_SESSION['user']['extension'] as $value) {
}
*/
?>
?>

View File

@ -229,7 +229,7 @@
$order_by = $_GET["order_by"] ?? '';
$order = $_GET["order"] ?? '';
//get the voicemail
//prepare to page the results
$vm = new voicemail;
$vm->domain_uuid = $_SESSION['domain_uuid'];
if (!empty($voicemail_uuid) && is_uuid($voicemail_uuid)) {
@ -238,8 +238,30 @@
else if (!empty($voicemail_id) && is_numeric($voicemail_id)) {
$vm->voicemail_id = $voicemail_id;
}
$voicemails = $vm->messages();
$num_rows = 0;
if (!empty($voicemails) && is_array($voicemails)) {
foreach ($voicemails as $voicemail) {
if (!empty($voicemail['messages']) && is_array($voicemail['messages'])) {
$num_rows += @sizeof($voicemail['messages']);
}
}
}
$total_rows = $num_rows;
//prepare to page the results
$rows_per_page = $_SESSION['domain']['paging']['numeric'] != '' ? $_SESSION['domain']['paging']['numeric'] : 50;
$page = empty($_GET['page']) ? 0 : $_GET['page'];
$param = 'id='.urlencode($_REQUEST['id']).'&back='.$_SESSION['back'][$_SERVER['PHP_SELF']];
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true);
$offset = $rows_per_page * $page;
unset($num_rows);
//get the voicemail
$vm->order_by = $order_by;
$vm->order = $order;
$vm->offset = $offset;
$voicemails = $vm->messages();
//count messages and detect if any transcriptions available
@ -271,7 +293,7 @@
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-voicemail_messages']." (".$num_rows.")</b></div>\n";
echo " <div class='heading'><b>".$text['title-voicemail_messages']." (".$total_rows.")</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','link'=>$_SESSION['back'][$_SERVER['PHP_SELF']]]);
$margin_left = false;
@ -286,6 +308,9 @@
if (permission_exists('voicemail_message_delete') && $num_rows) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','collapse'=>'hide-xs','style'=>'display: none;'.(!$margin_left ? 'margin-left: 15px;' : null),'onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
if (!empty($paging_controls_mini)) {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
}
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
@ -421,6 +446,7 @@
}
echo "</table>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";