Skip to content
Snippets Groups Projects
Commit f84b6123 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by David Siegfried
Browse files

duplicate pagination on consultation pages, fixes #3774

Closes #3774

Merge request studip/studip!2648
parent f004dc9a
No related branches found
No related tags found
No related merge requests found
......@@ -69,10 +69,10 @@ class Consultation_AdminController extends ConsultationController
public function index_action($page = 0)
{
$this->count = ConsultationSlot::countByRange($this->range);
$this->limit = Config::get()->ENTRIES_PER_PAGE;
$count = ConsultationSlot::countByRange($this->range);
$limit = Config::get()->ENTRIES_PER_PAGE;
if ($page >= ceil($this->count / $this->limit)) {
if ($page >= ceil($count / $limit)) {
$page = 0;
}
......@@ -81,7 +81,7 @@ class Consultation_AdminController extends ConsultationController
if ($GLOBALS['user']->cfg->CONSULTATION_SHOW_GROUPED) {
$this->blocks = $this->groupSlots(ConsultationSlot::findByRange(
$this->range,
"ORDER BY start ASC LIMIT " . ($this->page * $this->limit) . ", {$this->limit}"
"ORDER BY start ASC LIMIT " . ($this->page * $limit) . ", {$limit}"
));
} else {
$this->blocks = ConsultationBlock::findByRange(
......@@ -90,20 +90,22 @@ class Consultation_AdminController extends ConsultationController
);
$this->slots = ConsultationSlot::findByRange(
$this->range,
"ORDER BY start ASC LIMIT " . ($this->page * $this->limit) . ", {$this->limit}"
"ORDER BY start ASC LIMIT " . ($this->page * $limit) . ", {$limit}"
);
}
$this->pagination = Pagination::create($count, $this->page, $limit);
$action = $GLOBALS['user']->cfg->CONSULTATION_SHOW_GROUPED ? 'index' : 'ungrouped';
$this->render_action($action);
}
public function expired_action($page = 0)
{
$this->count = ConsultationSlot::countByRange($this->range, true);
$this->limit = Config::get()->ENTRIES_PER_PAGE;
$count = ConsultationSlot::countByRange($this->range, true);
$limit = Config::get()->ENTRIES_PER_PAGE;
if ($page >= ceil($this->count / $this->limit)) {
if ($page >= ceil($count / $limit)) {
$page = 0;
}
......@@ -112,7 +114,7 @@ class Consultation_AdminController extends ConsultationController
if ($GLOBALS['user']->cfg->CONSULTATION_SHOW_GROUPED) {
$this->blocks = $this->groupSlots(ConsultationSlot::findByRange(
$this->range,
"ORDER BY start DESC LIMIT " . ($this->page * $this->limit) . ", {$this->limit}",
"ORDER BY start DESC LIMIT " . ($this->page * $limit) . ", {$limit}",
true
));
} else {
......@@ -123,11 +125,13 @@ class Consultation_AdminController extends ConsultationController
);
$this->slots = ConsultationSlot::findByRange(
$this->range,
"ORDER BY start DESC LIMIT " . ($this->page * $this->limit) . ", {$this->limit}",
"ORDER BY start DESC LIMIT " . ($this->page * $limit) . ", {$limit}",
true
);
}
$this->pagination = Pagination::create($count, $this->page, $limit);
$action = $GLOBALS['user']->cfg->CONSULTATION_SHOW_GROUPED ? 'index' : 'ungrouped';
$this->render_action($action);
}
......
......@@ -2,10 +2,9 @@
/**
* @var Consultation_AdminController $controller
* @var int $page
* @var int $count
* @var int $limit
* @var string $current_action
* @var array<int, array{block: ConsultationBlock, slots: ConsultationSlot[]> $blocks
* @var Pagination $pagination
*/
?>
<? if (count($blocks) === 0): ?>
......@@ -40,8 +39,16 @@
</th>
<th><?= _('Uhrzeit') ?></th>
<th><?= _('Status') ?></th>
<th><?= _('Informationen') ?></th>
<th></th>
<th colspan="2">
<div style="display: flex; justify-content: space-between">
<span><?= _('Informationen') ?></span>
<span>
<?= $pagination->asLinks(function ($page) use ($controller, $current_action) {
return $controller->action_link($current_action, $page);
}) ?>
</span>
</div>
</th>
</tr>
</thead>
<? foreach ($blocks as $block): ?>
......@@ -186,7 +193,7 @@
]) ?>
<div class="actions">
<?= Pagination::create($count, $page, $limit)->asLinks(function ($page) use ($controller, $current_action) {
<?= $pagination->asLinks(function ($page) use ($controller, $current_action) {
return $controller->action_link($current_action, $page);
}) ?>
</div>
......
......@@ -2,11 +2,10 @@
/**
* @var Consultation_AdminController $controller
* @var int $page
* @var int $count
* @var int $limit
* @var string $current_action
* @var ConsultationBlock[] $blocks
* @var ConsultationSlot[] $slots
* @var Pagination $pagination
*/
?>
<? if (count($blocks) === 0): ?>
......@@ -132,7 +131,16 @@
</table>
<table class="default consultation-overview slot-overview">
<caption><?= _('Termine') ?></caption>
<caption>
<div class="caption-container">
<div class="caption-content"><?= _('Termine') ?></div>
<div class="caption-actions">
<?= $pagination->asLinks(function ($page) use ($controller, $current_action) {
return $controller->action_link($current_action, $page);
}) ?>
</div>
</div>
</caption>
<colgroup>
<col width="24px">
<col width="15%">
......@@ -272,7 +280,7 @@
]) ?>
<div class="actions">
<?= Pagination::create($count, $page, $limit)->asLinks(function ($page) use ($controller, $current_action) {
<?= $pagination->asLinks(function ($page) use ($controller, $current_action) {
return $controller->action_link($current_action, $page);
}) ?>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment