aded Preordercampaign pagination
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
<?php
|
||||
$pagination_baseurl = $this->getUrl($Mod,"Index");
|
||||
$pagination_baseurl_params = ["filter" => $filter];
|
||||
$pagination_entity_name = "Vorbestellkampagnen";
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
@@ -82,6 +87,13 @@
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table table-striped table-hover">
|
||||
<tr>
|
||||
<th></th>
|
||||
@@ -134,6 +146,10 @@
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -98,8 +98,10 @@ class PreordercampaignController extends mfBaseController {
|
||||
}
|
||||
|
||||
|
||||
$pagination['maxItems'] = PreordercampaignModel::count($filter);
|
||||
$campaigns = PreordercampaignModel::search($filter, $pagination);
|
||||
|
||||
$campaigns = PreordercampaignModel::search($filter);
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
$this->layout()->set("campaigns", $campaigns);
|
||||
|
||||
|
||||
|
||||
@@ -82,7 +82,26 @@ class PreordercampaignModel {
|
||||
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 Preordercampaign
|
||||
LEFT JOIN Network on (Preordercampaign.network_id = Network.id)
|
||||
WHERE $where ORDER BY `Preordercampaign`.name,Preordercampaign.`create`
|
||||
";
|
||||
|
||||
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();
|
||||
|
||||
@@ -90,10 +109,19 @@ class PreordercampaignModel {
|
||||
|
||||
$sql = "SELECT Preordercampaign.* FROM Preordercampaign
|
||||
LEFT JOIN Network on (Preordercampaign.network_id = Network.id)
|
||||
WHERE $where ORDER BY `Preordercampaign`.name,`create`
|
||||
WHERE $where ORDER BY `Preordercampaign`.name,Preordercampaign.`create`
|
||||
";
|
||||
|
||||
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->select("Preordercampaign", "*", "$where ORDER BY name,`create`");
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Preordercampaign($data);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
class PreorderstatusModel {
|
||||
public $code;
|
||||
public $name;
|
||||
public $connection_type;
|
||||
|
||||
public $create_by;
|
||||
public $edit_by;
|
||||
@@ -122,7 +123,7 @@ class PreorderstatusModel {
|
||||
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
|
||||
//var_dump($filter);exit;
|
||||
|
||||
if(array_key_exists("code", $filter)) {
|
||||
@@ -132,6 +133,13 @@ class PreorderstatusModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("connection_type", $filter)) {
|
||||
$connection_type = FronkDB::singleton()->escape($filter['connection_type']);
|
||||
if($connection_type) {
|
||||
$where .= " AND connection_type='$connection_type'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
|
||||
Reference in New Issue
Block a user