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