Improved 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 = "Adressen";
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
@@ -153,34 +158,8 @@
|
||||
<a class="btn btn-primary" href="<?=self::getUrl("Address", "add")?>"><i class="fas fa-plus"></i> Neue Person/Firma anlegen</a>
|
||||
</div>
|
||||
|
||||
<?php if($pagination['maxItems'] > $pagination['count']): ?>
|
||||
<nav>
|
||||
<ul class="pagination justify-content-center mb-1">
|
||||
<li class="page-item <?=($pagination['start'] - $pagination['count'] < 0) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod, "Index", ["filter" => $filter])?>" tabindex="-1">Erste</a>
|
||||
</li>
|
||||
<li class="page-item <?=($pagination['start'] - $pagination['count'] < 0) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $pagination['start'] - $pagination['count'], "filter" => $filter])?>" tabindex="-1">Zurück</a>
|
||||
</li>
|
||||
<?php for($i = 0; $i < ($pagination['maxItems'] / $pagination['count']); $i++): ?>
|
||||
<li class="page-item <?=($pagination['start'] == $i*$pagination['count']) ? "disabled font-weight-bold" : ""?>"><a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $i*$pagination['count'], "filter" => $filter])?>"><?=$i+1?></a></li>
|
||||
<?php endfor; ?>
|
||||
<li class="page-item <?=($pagination['maxItems'] / ($pagination['start'] + $pagination['count']) < 1) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $pagination['start'] + $pagination['count'], "filter" => $filter])?>">Vor</a>
|
||||
</li>
|
||||
<li class="page-item <?=($pagination['maxItems'] / ($pagination['start'] + $pagination['count']) < 1) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => ($pagination['maxItems'] - $pagination['maxItems'] % $pagination['count']), "filter" => $filter])?>">Letzte</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
<div class="pagination justify-content-center">
|
||||
<?php if($pagination['maxItems']): ?>
|
||||
Adressen <?=$pagination['start']+1?> bis <?=($pagination['start'] + $pagination['count'] > $pagination['maxItems']) ? $pagination['maxItems'] : $pagination['start'] + $pagination['count']?> von <?=$pagination['maxItems']?>
|
||||
<?php else: ?>
|
||||
Keine Adressen gefunden
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?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>
|
||||
@@ -228,34 +207,8 @@
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
<?php if($pagination['maxItems'] > $pagination['count']): ?>
|
||||
<nav>
|
||||
<ul class="pagination justify-content-center mb-1">
|
||||
<li class="page-item <?=($pagination['start'] - $pagination['count'] < 0) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod, "Index", ["filter" => $filter])?>" tabindex="-1">Erste</a>
|
||||
</li>
|
||||
<li class="page-item <?=($pagination['start'] - $pagination['count'] < 0) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $pagination['start'] - $pagination['count'], "filter" => $filter])?>" tabindex="-1">Zurück</a>
|
||||
</li>
|
||||
<?php for($i = 0; $i < ($pagination['maxItems'] / $pagination['count']); $i++): ?>
|
||||
<li class="page-item <?=($pagination['start'] == $i*$pagination['count']) ? "disabled font-weight-bold" : ""?>"><a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $i*$pagination['count'], "filter" => $filter])?>"><?=$i+1?></a></li>
|
||||
<?php endfor; ?>
|
||||
<li class="page-item <?=($pagination['maxItems'] / ($pagination['start'] + $pagination['count']) < 1) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $pagination['start'] + $pagination['count'], "filter" => $filter])?>">Vor</a>
|
||||
</li>
|
||||
<li class="page-item <?=($pagination['maxItems'] / ($pagination['start'] + $pagination['count']) < 1) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => ($pagination['maxItems'] - $pagination['maxItems'] % $pagination['count']), "filter" => $filter])?>">Letzte</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
<div class="pagination justify-content-center">
|
||||
<?php if($pagination['maxItems']): ?>
|
||||
Adressen <?=$pagination['start']+1?> bis <?=($pagination['start'] + $pagination['count'] > $pagination['maxItems']) ? $pagination['maxItems'] : $pagination['start'] + $pagination['count']?> von <?=$pagination['maxItems']?>
|
||||
<?php else: ?>
|
||||
Keine Adressen gefunden
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -106,6 +106,9 @@
|
||||
</div>
|
||||
<div class="row hidden" id="map-row">
|
||||
<div id="building-map" style="height:50vh; width: 100%"></div>
|
||||
<div class="mt-1">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="centerMap()"><i class="far fa-dot-circle"></i> Zentrieren</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -444,13 +447,17 @@
|
||||
|
||||
console.log(all_coords);
|
||||
// calculate center position
|
||||
var center_pos = GetCenterFromDegrees(all_coords);
|
||||
console.log(center_pos);
|
||||
buildingMap.setView(center_pos, 12);
|
||||
mapCenterPos = GetCenterFromDegrees(all_coords);
|
||||
console.log(mapCenterPos);
|
||||
buildingMap.setView(mapCenterPos, 12);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function centerMap() {
|
||||
buildingMap.setView(mapCenterPos, 12);
|
||||
}
|
||||
|
||||
// gets buildings and calls renderMap()
|
||||
function getMapdata() {
|
||||
filter = getFilter();
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<?php
|
||||
|
||||
$pagination_baseurl = $this->getUrl($Mod,"Index");
|
||||
$pagination_baseurl_params = ["filter" => $filter];
|
||||
$pagination_entity_name = "Bestellungen";
|
||||
//var_dump($mynetworks);
|
||||
|
||||
$sorted_networks = [];
|
||||
@@ -102,7 +106,7 @@
|
||||
<label class="form-label" for="filter_finish_date">Bestellstatus</label>
|
||||
<select name="filter[finish_date]" id="filter_finish_date" class="form-control">
|
||||
<option></option>
|
||||
<option value="0" <?=( (!array_key_exists("finish_date", $filter) || $filter["finish_date"] != "1") ? 'selected="selected"' : "")?>>Offen</option>
|
||||
<option value="0" <?=( (!is_array($filter) || (!array_key_exists("finish_date", $filter) || $filter["finish_date"] != "1")) ? 'selected="selected"' : "")?>>Offen</option>
|
||||
<option value="1" <?=($filter["finish_date"] == "1" ? 'selected="selected"' : "")?>>Fertiggestellt</option>
|
||||
<option value="waiting" <?=($filter["finish_date"] == "waiting") ? 'selected="selected"' : ""?>>Wartend / ausgeblendet</option>
|
||||
</select>
|
||||
@@ -521,34 +525,8 @@
|
||||
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Order", "add")?>"><i class="fas fa-plus"></i> Neue Bestellung anlegen</a>
|
||||
</div>
|
||||
|
||||
<?php if($pagination['maxItems'] > $pagination['count']): ?>
|
||||
<nav>
|
||||
<ul class="pagination justify-content-center mb-1">
|
||||
<li class="page-item <?=($pagination['start'] - $pagination['count'] < 0) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod, "Index", ["filter" => $filter])?>" tabindex="-1">Erste</a>
|
||||
</li>
|
||||
<li class="page-item <?=($pagination['start'] - $pagination['count'] < 0) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $pagination['start'] - $pagination['count'], "filter" => $filter])?>" tabindex="-1">Zurück</a>
|
||||
</li>
|
||||
<?php for($i = 0; $i < ($pagination['maxItems'] / $pagination['count']); $i++): ?>
|
||||
<li class="page-item <?=($pagination['start'] == $i*$pagination['count']) ? "disabled font-weight-bold" : ""?>"><a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $i*$pagination['count'], "filter" => $filter])?>"><?=$i+1?></a></li>
|
||||
<?php endfor; ?>
|
||||
<li class="page-item <?=($pagination['maxItems'] / ($pagination['start'] + $pagination['count']) < 1) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $pagination['start'] + $pagination['count'], "filter" => $filter])?>">Vor</a>
|
||||
</li>
|
||||
<li class="page-item <?=($pagination['maxItems'] / ($pagination['start'] + $pagination['count']) < 1) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => ($pagination['maxItems'] - $pagination['maxItems'] % $pagination['count']), "filter" => $filter])?>">Letzte</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
<div class="pagination justify-content-center">
|
||||
<?php if($pagination['maxItems']): ?>
|
||||
Bestellungen <?=$pagination['start']+1?> bis <?=($pagination['start'] + $pagination['count'] > $pagination['maxItems']) ? $pagination['maxItems'] : $pagination['start'] + $pagination['count']?> von <?=$pagination['maxItems']?>
|
||||
<?php else: ?>
|
||||
Keine Bestellungen gefunden
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
|
||||
<table class="table">
|
||||
<tr>
|
||||
@@ -966,34 +944,8 @@
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
<?php if($pagination['maxItems'] > $pagination['count']): ?>
|
||||
<nav>
|
||||
<ul class="pagination justify-content-center mb-1">
|
||||
<li class="page-item <?=($pagination['start'] - $pagination['count'] < 0) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod, "Index", ["filter" => $filter])?>" tabindex="-1">Erste</a>
|
||||
</li>
|
||||
<li class="page-item <?=($pagination['start'] - $pagination['count'] < 0) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $pagination['start'] - $pagination['count'], "filter" => $filter])?>" tabindex="-1">Zurück</a>
|
||||
</li>
|
||||
<?php for($i = 0; $i < ($pagination['maxItems'] / $pagination['count']); $i++): ?>
|
||||
<li class="page-item <?=($pagination['start'] == $i*$pagination['count']) ? "disabled font-weight-bold" : ""?>"><a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $i*$pagination['count'], "filter" => $filter])?>"><?=$i+1?></a></li>
|
||||
<?php endfor; ?>
|
||||
<li class="page-item <?=($pagination['maxItems'] / ($pagination['start'] + $pagination['count']) < 1) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $pagination['start'] + $pagination['count'], "filter" => $filter])?>">Vor</a>
|
||||
</li>
|
||||
<li class="page-item <?=($pagination['maxItems'] / ($pagination['start'] + $pagination['count']) < 1) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => ($pagination['maxItems'] - $pagination['maxItems'] % $pagination['count']), "filter" => $filter])?>">Letzte</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
<div class="pagination justify-content-center">
|
||||
<?php if($pagination['maxItems']): ?>
|
||||
Bestellungen <?=$pagination['start']+1?> bis <?=($pagination['start'] + $pagination['count'] > $pagination['maxItems']) ? $pagination['maxItems'] : $pagination['start'] + $pagination['count']?> von <?=$pagination['maxItems']?>
|
||||
<?php else: ?>
|
||||
Keine Bestellungen gefunden
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
62
Layout/default/Preorder/Index.php
Normal file
62
Layout/default/Preorder/Index.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>">the-tool</a></li>
|
||||
<li class="breadcrumb-item active">Vorbestellung</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Vorbestellkampagnen</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<div class="float-left">
|
||||
<h4 class="header-title">Liste aller Vorbestellkampagnen</h4>
|
||||
</div>
|
||||
<div class="float-right">
|
||||
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Product", "add")?>"><i class="fas fa-plus"></i> Neue Vorbestellkampagne anlegen</a>
|
||||
</div>
|
||||
|
||||
<table class="table table-striped table-hover">
|
||||
<tr>
|
||||
<th>Netzgebiete</th>
|
||||
<th>Name</th>
|
||||
<th>Gebiet</th>
|
||||
<th>Vorbestellungen</th>
|
||||
<th>Start</th>
|
||||
<th>Ende</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($campaigns as $cam): ?>
|
||||
<tr>
|
||||
<td><?=$camp->network->name?></td>
|
||||
<td><?=$camp->name?></td>
|
||||
<td><?=$camp->area?></td>
|
||||
<td><?=count($camp->preorders)?></td>
|
||||
<td><?=date('d.m.Y',$camp->start)?></td>
|
||||
<td><?=date('d.m.Y',$camp->end)?></td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<a href="<?=self::getUrl("Preorder", "edit", ["id" => $camp->id])?>"><i class="far fa-edit" title="Vorbestellkampagne Bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Preorder", "delete", ["id" => $camp->id])?>" class="text-danger" onclick="if(!confirm('Vorbestellkampagne wirklich löschen?')) return false;" title="Vorbestellkampagne Löschen"><i class="fas fa-trash"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?>
|
||||
@@ -83,6 +83,7 @@
|
||||
<i class="fas fa-shopping-basket"></i>Verkauf <div class="arrow-down"></div>
|
||||
</a>
|
||||
<ul class="submenu">
|
||||
<li><a href="<?=self::getUrl("Preorder")?>"><i class="fas fa-shopping-basket"></i> Vorbestellung</a></li>
|
||||
<li><a href="<?=self::getUrl("Order")?>"><i class="fas fa-file-contract"></i> Bestellungen</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
7
Layout/default/tpl/pagination-summary.php
Normal file
7
Layout/default/tpl/pagination-summary.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<div class="pagination justify-content-center">
|
||||
<?php if($pagination['maxItems']): ?>
|
||||
<?=$pagination_entity_name?> <?=$pagination['start']+1?> bis <?=($pagination['start'] + $pagination['count'] > $pagination['maxItems']) ? $pagination['maxItems'] : $pagination['start'] + $pagination['count']?> von <?=$pagination['maxItems']?>
|
||||
<?php else: ?>
|
||||
Keine <?=$pagination_entity_name?> gefunden
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
88
Layout/default/tpl/pagination.php
Normal file
88
Layout/default/tpl/pagination.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php if($pagination['maxItems'] > $pagination['count']): ?>
|
||||
|
||||
<?php
|
||||
$mfPagination_pagecount = intval($pagination['maxItems'] / $pagination['count']);
|
||||
$mfPagination_currentpage = $pagination['start'] / $pagination['count'];
|
||||
$mfPagination_pages = [];
|
||||
$mfPagination_baseurl_params = $pagination_baseurl_params;
|
||||
|
||||
$log = mfLoghandler::singleton();
|
||||
|
||||
if($mfPagination_pagecount < 12) {
|
||||
for($i = 0; $i < $mfPagination_pagecount+1; $i++) {
|
||||
$mfPagination_baseurl_params['s'] = $i * $pagination['count'];
|
||||
$page = [
|
||||
's' => $i * $pagination['count'],
|
||||
'url' => $pagination_baseurl."?".http_build_query($mfPagination_baseurl_params),
|
||||
'current' => ($pagination['start'] == $i*$pagination['count']),
|
||||
];
|
||||
$mfPagination_pages[$i] = $page;
|
||||
}
|
||||
} else {
|
||||
$show_from = $mfPagination_currentpage - 4;
|
||||
$show_to = $mfPagination_currentpage + 4;
|
||||
|
||||
if($show_from < 1) {
|
||||
$show_from = 1;
|
||||
}
|
||||
if($show_to > $mfPagination_pagecount) {
|
||||
$show_to = $mfPagination_pagecount+1;
|
||||
}
|
||||
|
||||
for($i = 0; $i < $mfPagination_pagecount+1; $i++) {
|
||||
if($show_from > 1 && $i == $show_from) {
|
||||
$mfPagination_pages[$i] = "separator_before";
|
||||
continue;
|
||||
}
|
||||
if($i == $show_to && $show_to < $mfPagination_pagecount) {
|
||||
$mfPagination_pages[$i] = "separator_after";
|
||||
continue;
|
||||
}
|
||||
|
||||
$mfPagination_baseurl_params['s'] = $i * $pagination['count'];
|
||||
|
||||
if(($i == 0 || $i == $mfPagination_pagecount) || ($i >= $show_from && $i <= $show_to)) {
|
||||
$log->debug("show_from: $show_from, show_to: $show_to");
|
||||
|
||||
$page = [
|
||||
's' => $i * $pagination['count'],
|
||||
'url' => $pagination_baseurl."?".http_build_query($mfPagination_baseurl_params),
|
||||
'current' => ($pagination['start'] == $i*$pagination['count']),
|
||||
];
|
||||
$mfPagination_pages[$i] = $page;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="alert alert-warning">
|
||||
pagecount: <?php var_dump($mfPagination_pagecount); ?>
|
||||
currentpage: <?php var_dump($mfPagination_currentpage); ?>
|
||||
<?php var_dump($mfPagination_pages); ?>
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
<ul class="pagination justify-content-center mb-1">
|
||||
<li class="page-item <?=($pagination['start'] - $pagination['count'] < 0) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod, "Index", ["filter" => $filter])?>" tabindex="-1">Erste</a>
|
||||
</li>
|
||||
<li class="page-item <?=($pagination['start'] - $pagination['count'] < 0) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $pagination['start'] - $pagination['count'], "filter" => $filter])?>" tabindex="-1">Zurück</a>
|
||||
</li>
|
||||
<?php foreach($mfPagination_pages as $mfPageIndex => $mfPage):?>
|
||||
<?php if($mfPage == "separator_before" || $mfPage == "separator_after"): ?>
|
||||
<li class="page-item disabled font-weight-bold text-secondary"><a class="page-link">...</a></li>
|
||||
<?php continue; endif; ?>
|
||||
<li class="page-item <?=($mfPage['current']) ? "disabled font-weight-bold text-secondary" : ""?>"><a class="page-link" href="<?=$mfPage['url']?>"><?=$mfPageIndex+1?></a></li>
|
||||
<?php endforeach; ?>
|
||||
<li class="page-item <?=($pagination['maxItems'] / ($pagination['start'] + $pagination['count']) < 1) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => $pagination['start'] + $pagination['count'], "filter" => $filter])?>">Weiter</a>
|
||||
</li>
|
||||
<li class="page-item <?=($pagination['maxItems'] / ($pagination['start'] + $pagination['count']) < 1) ? "disabled" : ""?>">
|
||||
<a class="page-link" href="<?=$this->getUrl($Mod,"Index",['s' => ($pagination['maxItems'] - $pagination['maxItems'] % $pagination['count']), "filter" => $filter])?>">Letzte</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
54
application/Preorder/Preorder.php
Normal file
54
application/Preorder/Preorder.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
class Preorder extends mfBaseModel {
|
||||
private $network;
|
||||
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "creator") {
|
||||
$user = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
||||
if($user) {
|
||||
$this->creator = $user;
|
||||
return $this->creator;
|
||||
}
|
||||
$this->creator = new User($this->create_by);
|
||||
if($this->creator->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator);
|
||||
}
|
||||
return $this->creator;
|
||||
}
|
||||
|
||||
if($name == "editor") {
|
||||
$user = mfValuecache::singleton()->get("Worker-id-".$this->edit_by);
|
||||
if($user) {
|
||||
$this->editor = $user;
|
||||
return $this->editor;
|
||||
}
|
||||
$this->editor = new User($this->edit_by);
|
||||
if($this->editor->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor);
|
||||
}
|
||||
return $this->editor;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
|
||||
if(!$this->$name) {
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
}
|
||||
|
||||
if($this->$name->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
}
|
||||
24
application/Preorder/PreorderController.php
Normal file
24
application/Preorder/PreorderController.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
class PreorderController extends mfBaseController {
|
||||
|
||||
protected function init() {
|
||||
$this->needlogin=true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
if(!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function indexAction() {
|
||||
$this->layout()->setTemplate("Preorder/Index");
|
||||
|
||||
$campaigns = PreorderModel::getAll();
|
||||
$this->layout()->set("campaigns", $campaigns);
|
||||
|
||||
}
|
||||
}
|
||||
107
application/Preorder/PreorderModel.php
Normal file
107
application/Preorder/PreorderModel.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
class PreorderModel {
|
||||
public $name = null;
|
||||
public $network_id = null;
|
||||
public $gps_lat = null;
|
||||
public $gps_long = null;
|
||||
public $location = null;
|
||||
public $vlan_public = null;
|
||||
public $vlan_nat = null;
|
||||
public $vlan_ipv6 = null;
|
||||
|
||||
public $note = null;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new Preorder();
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
if(property_exists(get_called_class(), $field)) {
|
||||
$model->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$me = mfValuecache::singleton()->get("me");
|
||||
if(!$me) {
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
mfValuecache::singleton()->set("me", $me);
|
||||
}
|
||||
|
||||
if($model->create_by === null) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
if($model->edit_by === null) {
|
||||
$model->edit_by = $me->id;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("Preorder", "*", "ORDER BY `create`");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Preorder($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Preorder", "*", "$where ORDER BY `create`");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Preorder($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function search($filter) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Preorder", "*", "$where ORDER BY `create`");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Preorder($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
//var_dump($filter);exit;
|
||||
if(array_key_exists("network_id", $filter)) {
|
||||
$networkid = $filter['network_id'];
|
||||
if(is_numeric($networkid)) {
|
||||
$where .= " AND network_id=$networkid";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user