diff --git a/app/voicemails/resources/classes/voicemail.php b/app/voicemails/resources/classes/voicemail.php index a140e25b80..f7cf99d1ce 100644 --- a/app/voicemails/resources/classes/voicemail.php +++ b/app/voicemails/resources/classes/voicemail.php @@ -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) { } */ -?> +?> \ No newline at end of file diff --git a/app/voicemails/voicemail_messages.php b/app/voicemails/voicemail_messages.php index 3075163b35..a06caea906 100644 --- a/app/voicemails/voicemail_messages.php +++ b/app/voicemails/voicemail_messages.php @@ -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 "
\n"; @@ -421,6 +446,7 @@ } echo "\n"; echo "