Added more Pagination
This commit is contained in:
@@ -106,6 +106,35 @@
|
||||
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Building", "add")?>"><i class="fas fa-plus"></i> Neues Objekt 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']): ?>
|
||||
Objekte <?=$pagination['start']+1?> bis <?=($pagination['start'] + $pagination['count'] > $pagination['maxItems']) ? $pagination['maxItems'] : $pagination['start'] + $pagination['count']?> von <?=$pagination['maxItems']?>
|
||||
<?php else: ?>
|
||||
Keine Objekte gefunden
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<table class="table table-striped table-hover">
|
||||
<tr>
|
||||
<th>Netzgebiet</th>
|
||||
@@ -263,6 +292,37 @@
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
<div class="pagination justify-content-center">
|
||||
<?php if($pagination['maxItems']): ?>
|
||||
Objekte <?=$pagination['start']+1?> bis <?=($pagination['start'] + $pagination['count'] > $pagination['maxItems']) ? $pagination['maxItems'] : $pagination['start'] + $pagination['count']?> von <?=$pagination['maxItems']?>
|
||||
<?php else: ?>
|
||||
Keine Objekte gefunden
|
||||
<?php endif; ?>
|
||||
</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>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
<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("Linework")?>" tabindex="-1">Erste</a>
|
||||
<a class="page-link" href="<?=$this->getUrl("Linework", "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("Linework","Index",['s' => $pagination['start'] - $pagination['count'], "filter" => $filter])?>" tabindex="-1">Zurück</a>
|
||||
@@ -176,13 +176,13 @@
|
||||
<?php $i = 0; foreach($term->workflowitems as $item): ?>
|
||||
<?php if($i==0): ?>
|
||||
<?php if($item->type == "delimiter"): ?>
|
||||
<tr class="workflow-header"><th colspan='<?=$termination_wf_colspan?>'><?=$item->label?></th></tr><tr>
|
||||
<tr class="workflow-header"><th colspan='<?=$wfColspan?>'><?=$item->label?></th></tr><tr>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<?php if($item->type == "delimiter"): ?>
|
||||
</tr><tr class="workflow-header"><th colspan='<?=$termination_wf_colspan?>'><?=$item->label?></th></tr><tr>
|
||||
</tr><tr class="workflow-header"><th colspan='<?=$wfColspan?>'><?=$item->label?></th></tr><tr>
|
||||
<?php else: ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/Workflow/form.php"); ?>
|
||||
<?php endif; ?>
|
||||
@@ -194,7 +194,7 @@
|
||||
<td colspan="3">
|
||||
<label class="form-label">Kommentar</label> <textarea class="form-control" style="height:100%" form="wf-termination-<?=$term->id?>" name="workflow_comment" id="workflow_comment_<?=$term->id?>"><?=$term->workflow_comment?></textarea>
|
||||
</td>
|
||||
<td colspan="<?=$termination_wf_colspan - 3?>">
|
||||
<td colspan="<?=$wfColspan - 3?>">
|
||||
<h5>Dokumente</h5>
|
||||
<table class="table table-sm">
|
||||
<?php if(is_array($term->files) && count($term->files)): $i=0; foreach($term->files as $file): ?>
|
||||
|
||||
@@ -86,6 +86,50 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if(is_array($lonelyOrders) && count($lonelyOrders)): ?>
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<div class="float-left">
|
||||
<h4 class="header-title">Bestellungen ohne Produkte</h4>
|
||||
</div>
|
||||
|
||||
<table class="table table-striped table-hover">
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Kunde</th>
|
||||
<th>Adresse</th>
|
||||
<th>Bestelldatum</th>
|
||||
<th>Zuletzt bearbeitet</th>
|
||||
<th>Bearbeitet von</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($lonelyOrders as $order): ?>
|
||||
<tr>
|
||||
<td><?=$order->id?></td>
|
||||
<td>
|
||||
<?=nl2br($order->owner->getCompanyOrName())?>
|
||||
<?=($order->owner->spin) ? "<br /><span class='text-pink'>".$order->owner->spin."</span>" : ""?>
|
||||
</td>
|
||||
<td>
|
||||
<?=$order->owner->street?><br />
|
||||
<?=$order->owner->zip?> <?=$order->owner->city?>
|
||||
</td>
|
||||
|
||||
<td class="text-monospace"><?=date("d.m.Y", $order->order_date)?></td>
|
||||
<td class="text-monospace"><?=date("d.m.Y", $order->edit)?></td>
|
||||
<td class="text-monospace"><?=$order->editor->name?></td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<a href="<?=self::getUrl("Order", "downloadServicePin", ["id" => $order->id])?>"><i class="fas fa-file-alt" title="Service PIN als PDF herunterladen"></i></a>
|
||||
<a href="<?=self::getUrl("Order", "sendServicePin", ["id" => $order->id])?>" onclick="if(!confirm('Soll der Service-PIN an den Vertragsinhaber gesendet werden?')) return false;"><i class="fas fa-paper-plane" title="Service PIN als PDF per Email an Vertragsinhaber"></i></a>
|
||||
<a href="<?=self::getUrl("Order", "edit", ["id" => $order->id])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Order", "delete", ["id" => $order->id])?>" onclick="if(!confirm('Bestellung wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
@@ -96,6 +140,35 @@
|
||||
<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>
|
||||
|
||||
<table class="table table-striped table-hover">
|
||||
<tr>
|
||||
<th></th>
|
||||
@@ -177,6 +250,35 @@
|
||||
</tr>
|
||||
<?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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -98,13 +98,13 @@
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<h4 class="header-title mb-3">Auftragsliste nach Netzgebiet</h4>
|
||||
<h4 class="header-title">Auftragsliste nach Netzgebiet</h4>
|
||||
|
||||
<?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)?>" tabindex="-1">Erste</a>
|
||||
<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>
|
||||
@@ -123,9 +123,9 @@
|
||||
<?php endif; ?>
|
||||
<div class="pagination justify-content-center">
|
||||
<?php if($pagination['maxItems']): ?>
|
||||
Leitungsbauaufträge <?=$pagination['start']+1?> bis <?=($pagination['start'] + $pagination['count'] > $pagination['maxItems']) ? $pagination['maxItems'] : $pagination['start'] + $pagination['count']?> von <?=$pagination['maxItems']?>
|
||||
Tiefbauaufträge <?=$pagination['start']+1?> bis <?=($pagination['start'] + $pagination['count'] > $pagination['maxItems']) ? $pagination['maxItems'] : $pagination['start'] + $pagination['count']?> von <?=$pagination['maxItems']?>
|
||||
<?php else: ?>
|
||||
Keine Leitungsbauaufträge gefunden
|
||||
Keine Tiefbauaufträge gefunden
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
@@ -163,7 +163,7 @@
|
||||
</td>
|
||||
<td>
|
||||
<form method="post" name="wf-building-<?=$building->id?>" id="wf-building-<?=$building->id?>" action="<?=self::getUrl("Pipework","save", ["filter" => $filter])?>" enctype="multipart/form-data" >
|
||||
<input type="hidden" name="id" value="<?=$building->id?>" />
|
||||
<input type="hidden" name="id" value="<?=$building->id?>" />
|
||||
<table class="table workflow-table">
|
||||
<?php $i = 0; foreach($building->workflowitems as $item): ?>
|
||||
<?php if($i==0): ?>
|
||||
@@ -236,6 +236,37 @@
|
||||
<?php $bcount++; endforeach; ?>
|
||||
</table>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if($pagination['maxItems'] > $pagination['count']): ?>
|
||||
<div class="pagination justify-content-center">
|
||||
<?php if($pagination['maxItems']): ?>
|
||||
Tiefbauaufträge <?=$pagination['start']+1?> bis <?=($pagination['start'] + $pagination['count'] > $pagination['maxItems']) ? $pagination['maxItems'] : $pagination['start'] + $pagination['count']?> von <?=$pagination['maxItems']?>
|
||||
<?php else: ?>
|
||||
Keine Tiefbauaufträge gefunden
|
||||
<?php endif; ?>
|
||||
</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)?>" 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; ?>
|
||||
|
||||
|
||||
<?php else: ?>
|
||||
<i>Keine Bauaufträge gefunden</i>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -23,6 +23,16 @@ class BuildingController extends mfBaseController {
|
||||
$filter = $this->getPreparedFilter($this->request->filter);
|
||||
}
|
||||
|
||||
// pagination defaults
|
||||
$pagination = [];
|
||||
$pagination['start'] = 0;
|
||||
$pagination['count'] = 5;
|
||||
$pagination['maxItems'] = 0;
|
||||
|
||||
if(is_numeric($this->request->s)) {
|
||||
$pagination['start'] = intval($this->request->s);
|
||||
}
|
||||
|
||||
$my_networks = [];
|
||||
|
||||
if($this->me->is("Admin")) {
|
||||
@@ -54,43 +64,33 @@ class BuildingController extends mfBaseController {
|
||||
unset($filter['network_id']);
|
||||
|
||||
// get Buildings in networks
|
||||
$my_network_ids = [];
|
||||
$buildings = [];
|
||||
foreach($my_networks as $network) {
|
||||
$building_search = [
|
||||
"network_id" => $network->id,
|
||||
"workflow_finished" => 0
|
||||
];
|
||||
|
||||
if(is_array($filter) && count($filter)) {
|
||||
foreach($filter as $name => $value) {
|
||||
$building_search[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(BuildingModel::search($building_search) as $b) {
|
||||
if(!array_key_exists($b->id, $buildings)) {
|
||||
$buildings[$b->id] = $b;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
$buildings = [];
|
||||
foreach($this->me->my_networks as $network) {
|
||||
foreach(BuildingModel::search(["network_id" => $network->id]) as $b) {
|
||||
if(!array_key_exists($b->id, $buildings)) {
|
||||
$buildings[$b->id] = $b;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
//var_dump($buildings);exit;
|
||||
$this->layout()->set("buildings", $buildings);
|
||||
$my_network_ids[] = $network->id;
|
||||
}
|
||||
|
||||
|
||||
$building_search = [
|
||||
"network_id" => $my_network_ids,
|
||||
"workflow_finished" => 0
|
||||
];
|
||||
|
||||
if(is_array($filter) && count($filter)) {
|
||||
foreach($filter as $name => $value) {
|
||||
$building_search[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$pagination['maxItems'] = BuildingModel::count($building_search);
|
||||
foreach(BuildingModel::search($building_search, $pagination) as $b) {
|
||||
if(!array_key_exists($b->id, $buildings)) {
|
||||
$buildings[$b->id] = $b;
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($buildings);exit;
|
||||
$this->layout()->set("buildings", $buildings);
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
}
|
||||
|
||||
private function getPreparedFilter($filter) {
|
||||
|
||||
@@ -23,16 +23,27 @@ class OrderController extends mfBaseController {
|
||||
if($this->request->filter) {
|
||||
$filter = $this->getPreparedFilter($this->request->filter);
|
||||
}
|
||||
|
||||
// pagination defaults
|
||||
$pagination = [];
|
||||
$pagination['start'] = 0;
|
||||
$pagination['count'] = 5;
|
||||
$pagination['maxItems'] = 0;
|
||||
|
||||
if(is_numeric($this->request->s)) {
|
||||
$pagination['start'] = intval($this->request->s);
|
||||
}
|
||||
|
||||
$my_networks = [];
|
||||
|
||||
if($this->me->is("Admin")) {
|
||||
$my_networks = NetworkModel::getAll();
|
||||
$this->layout()->set("mynetworks", $my_networks);
|
||||
|
||||
/*
|
||||
if(!count($filter)) {
|
||||
$this->layout()->set("orders", OrderModel::getAll());
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
if($filter['network_id']) {
|
||||
//$this->layout()->set("orders", OrderModel::search(['network_id' => $filter['network_id']]));
|
||||
@@ -63,35 +74,48 @@ class OrderController extends mfBaseController {
|
||||
|
||||
// get Orders in my networks
|
||||
|
||||
$my_network_ids = [];
|
||||
$orders = [];
|
||||
//var_dump($this->me->my_networks);exit;
|
||||
foreach($my_networks as $network) {
|
||||
$order_search = [
|
||||
'network_id' => $network->id
|
||||
];
|
||||
$my_network_ids[] = $network->id;
|
||||
|
||||
if(is_array($filter) && count($filter)) {
|
||||
foreach($filter as $name => $value) {
|
||||
$order_search[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(OrderModel::search($order_search) as $order) {
|
||||
if(!array_key_exists($order->id, $orders)) {
|
||||
$orders[$order->id] = $order;
|
||||
}
|
||||
}
|
||||
$order_search = [
|
||||
'network_id' => $my_network_ids
|
||||
];
|
||||
|
||||
if(is_array($filter) && count($filter)) {
|
||||
foreach($filter as $name => $value) {
|
||||
$order_search[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$pagination['maxItems'] = OrderModel::count($order_search);
|
||||
foreach(OrderModel::search($order_search, $pagination) as $order) {
|
||||
if(!array_key_exists($order->id, $orders)) {
|
||||
$orders[$order->id] = $order;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$lonelyOrders = [];
|
||||
if(!count($filter)) {
|
||||
foreach(OrderModel::search(['create_by' => $this->me->id]) as $order) {
|
||||
if($this->me->isAdmin()) {
|
||||
$lonelies = OrderModel::search(['product_id' => null]);
|
||||
} else {
|
||||
$lonelies = OrderModel::search(['product_id' => null, 'create_by' => $this->me->id]);
|
||||
}
|
||||
foreach($lonelies as $order) {
|
||||
if(!array_key_exists($order->id, $orders)) {
|
||||
$orders[$order->id] = $order;
|
||||
$lonelyOrders[$order->id] = $order;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->layout()->set("orders", $orders);
|
||||
$this->layout()->set("lonelyOrders", $lonelyOrders);
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -131,8 +131,37 @@ class OrderModel {
|
||||
return $orders;
|
||||
}
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
/*$sql = "SELECT COUNT(*) as cnt FROM `Order`
|
||||
LEFT JOIN OrderProduct ON (OrderProduct.order_id = `Order`.id)
|
||||
LEFT JOIN Product ON (Product.id = OrderProduct.product_id)
|
||||
LEFT JOIN Termination ON (Termination.id = OrderProduct.termination_id)
|
||||
LEFT JOIN Building ON (Building.id = Termination.building_id)
|
||||
WHERE $where
|
||||
GROUP BY `Order`.id";*/
|
||||
|
||||
$sql = "SELECT COUNT(*) as cnt FROM
|
||||
(SELECT `Order`.id FROM `Order`
|
||||
LEFT JOIN OrderProduct ON (OrderProduct.order_id = `Order`.id)
|
||||
LEFT JOIN Product ON (Product.id = OrderProduct.product_id)
|
||||
LEFT JOIN Termination ON (Termination.id = OrderProduct.termination_id)
|
||||
LEFT JOIN Building ON (Building.id = Termination.building_id)
|
||||
WHERE $where
|
||||
GROUP BY `Order`.id)
|
||||
as o";
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function search($filter) {
|
||||
public static function search($filter, $limit=false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
@@ -149,8 +178,17 @@ class OrderModel {
|
||||
LEFT JOIN Termination ON (Termination.id = OrderProduct.termination_id)
|
||||
LEFT JOIN Building ON (Building.id = Termination.building_id)
|
||||
WHERE $where
|
||||
GROUP BY `Order`.id";
|
||||
|
||||
GROUP BY `Order`.id
|
||||
ORDER BY `Order`.order_date ASC";
|
||||
|
||||
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'];
|
||||
}
|
||||
}
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
@@ -187,6 +225,15 @@ class OrderModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("product_id", $filter)) {
|
||||
$product_id = $filter['product_id'];
|
||||
if(is_numeric($product_id)) {
|
||||
$where .= " AND OrderProduct.product_id=$product_id";
|
||||
} elseif($product_id === null) {
|
||||
$where .= " AND OrderProduct.product_id IS NULL";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("productgroup_id", $filter)) {
|
||||
$productgroup_id = $filter['productgroup_id'];
|
||||
if(is_numeric($productgroup_id)) {
|
||||
@@ -205,6 +252,8 @@ class OrderModel {
|
||||
$network_id = $filter['network_id'];
|
||||
if(is_numeric($network_id)) {
|
||||
$where .= " AND Building.network_id=$network_id";
|
||||
} elseif(is_array($network_id)) {
|
||||
$where .= " AND Building.network_id IN (". implode(",", $network_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user