Added pagination to preorder
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
<?php
|
||||
$pagination_baseurl = $this->getUrl($Mod,"Index");
|
||||
$pagination_baseurl_params = ["filter" => $filter];
|
||||
$pagination_entity_name = "Vorbestellungen";
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
@@ -86,14 +91,22 @@
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<div class="float-left">
|
||||
<h4 class="header-title">Liste aller Vorbestellungen<?=($campaign) ? " - ".$campaign->name : ""?></h4>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="float-left">
|
||||
<h4 class="header-title">Liste aller Vorbestellungen<?=($campaign) ? " - ".$campaign->name : ""?></h4>
|
||||
</div>
|
||||
<?php if($filter['preordercampaign_id']): ?>
|
||||
<div class="float-right">
|
||||
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Preorder", "add", ["preordercampaign_id" => $filter['preordercampaign_id']])?>"><i class="fas fa-plus"></i> Neue Vorbestellung anlegen</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if($filter['campaign_id']): ?>
|
||||
<div class="float-right">
|
||||
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Preorder", "add", ["preordercampaign_id" => $filter['campaign_id']])?>"><i class="fas fa-plus"></i> Neue Vorbestellung anlegen</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
|
||||
<table class="table table-striped table-hover">
|
||||
<tr>
|
||||
@@ -150,6 +163,10 @@
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ class PreorderController extends mfBaseController {
|
||||
}
|
||||
//var_dump($filter);exit;
|
||||
//$pagination['maxItems'] = AddressModel::count($filter);
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
|
||||
|
||||
$campaign_filter = [];
|
||||
@@ -52,8 +51,12 @@ class PreorderController extends mfBaseController {
|
||||
}
|
||||
//var_dump($filter);exit;
|
||||
|
||||
$preorders = PreorderModel::search($filter);
|
||||
$pagination['maxItems'] = PreorderModel::count($filter);
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
|
||||
$preorders = PreorderModel::search($filter, $pagination);
|
||||
$this->layout()->set("preorders", $preorders);
|
||||
|
||||
}
|
||||
|
||||
private function getPreparedFilter($filter) {
|
||||
|
||||
@@ -108,7 +108,26 @@ class PreorderModel {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function search($filter) {
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as cnt FROM `".FRONKDB_DBNAME."`.Preorder tt_preorder
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
WHERE $where
|
||||
";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function search($filter, $limit = false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
@@ -120,6 +139,14 @@ class PreorderModel {
|
||||
ORDER BY lastname, firstname
|
||||
";
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
} elseif(is_numeric($count)) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
|
||||
Reference in New Issue
Block a user