Added parents_only filter to Address/Index

This commit is contained in:
Frank Schubert
2021-06-17 22:46:44 +02:00
parent 8ba7793a66
commit 16d7831d23
6 changed files with 45 additions and 16 deletions
+2 -2
View File
@@ -19,7 +19,7 @@
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
@@ -30,7 +30,7 @@
<form class="form-horizontal" method="post" action="<?=self::getUrl("Address", "save")?>">
<div class="card">
<div class="card-body">
<input type="hidden" name="id" value="<?=$address->id?>" />
<div class="form-group row">
+22 -8
View File
@@ -9,14 +9,16 @@
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="javascript: void(0);">the-tool</a></li>
<li class="breadcrumb-item"><a href="javascript: void(0);">Personen & Firmen</a></li>
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>">the-tool</a></li>
<?php if(is_array($filter['addresstype']) && count($filter['addresstype'])): ?>
<li class="breadcrumb-item"><a href="<?=self::getUrl("Address")?>">Personen & Firmen</a></li>
<li class="breadcrumb-item active">
<?php if(is_array($filter['addresstype']) && count($filter['addresstype'])): ?>
<?php foreach($filter['addresstype'] as $type) { $types[] = __($type); } ?>
<?=implode(", ", $types)?>
<?php endif; ?>
<?php foreach($filter['addresstype'] as $type) { $types[] = __($type); } ?>
<?=implode(", ", $types)?>
</li>
<?php else: ?>
<li class="breadcrumb-item active">Personen & Firmen</li>
<?php endif; ?>
</ol>
</div>
<h4 class="page-title">Personen & Firmen</h4>
@@ -29,10 +31,22 @@
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<div class="card-body mb-3">
<div class="float-left">
<h4 class="header-title">Liste aller Personen & Firmen</h4>
<p class="sub-header">Gefiltert nach Typ: <?=implode(", ", $types)?></p>
<?php if(is_array($filter) && count($filter)): ?>
<p class="sub-header">
<?php if(array_key_exists("parents_only", $filter) && $filter['parents_only'] == 1): ?>
Zeige nur Personen und Firmen ohne Zugehörigkeit an. <a href="<?=self::getUrl("Address", "Index", ['filter' => array_merge($filter, ["parents_only" => 0])])?>">Alle anzeigen</a><br />
<?php else: ?>
Zeige alle Personen und Firmen<br />
<?php endif; ?>
<?php if(is_array($filter['addresstype']) && count($filter['addresstype'])): ?>
Gefiltert nach Rolle: <?=implode(", ", $types)?><br />
<?php endif; ?>
</p>
<?php endif; ?>
</div>
<div class="float-right">
<a class="btn btn-primary" href="<?=self::getUrl("Address", "add")?>"><i class="fas fa-plus"></i> Neue Person/Firma anlegen</a>
+2 -2
View File
@@ -3,7 +3,7 @@
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
2018 - 2019 &copy; Simulor theme by <a href="">Coderthemes</a>
&copy; 2021 <a href="https://www.xinon.at">Xinon GmbH</a> - Made by fronk - Simulor Theme by Coderthemes
</div>
<div class="col-md-6">
<div class="text-md-right footer-links d-none d-sm-block">
@@ -17,7 +17,7 @@
</footer>
<!-- end Footer -->
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/vendor.min.js"></script>
</body>
</html>
+8 -1
View File
@@ -4,7 +4,14 @@ class AddressController extends mfBaseController {
private $filter;
protected function indexAction() {
$filter = $this->request->filter;
//var_dump($this->request->filter);
$default_filter = ['parents_only' => 1];
if(is_array($this->request->filter) && count($this->request->filter)) {
$filter = array_merge($default_filter, $this->request->filter);
} else {
$filter = $default_filter;
}
//var_dump($filter);exit;
$addresses = AddressModel::search($filter);
$this->layout()->set("addresses", $addresses);
+8 -3
View File
@@ -121,16 +121,21 @@ class AddressModel {
}
//var_dump($filter);exit;
if(array_key_exists("parent_id", $filter)) {
$parentid = $filter['parent_id'];
if($parentid === null) {
if($parentid === null || $parent_id == "null") {
$where .= " AND parent_id IS NULL";
} elseif(is_numeric($parentid)) {
$where .= " AND parent_id=$parentid";
}
}
if(array_key_exists("parents_only", $filter)) {
$po = $filter['parents_only'];
if($po == 1) {
$where .= " AND parent_id IS NULL";
}
}
//var_dump($filter, $where);exit;
return $where;
}
+3
View File
@@ -20,4 +20,7 @@ class Layout extends mfLayout {
return str_replace(".", ",", $num);
}
public function arrayToUrl(Array $array) {
}
}