Added Voicenumberblock
This commit is contained in:
92
Layout/default/Voicenumberblock/Form.php
Normal file
92
Layout/default/Voicenumberblock/Form.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?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"><a href="<?=self::getUrl("Voicenumberblock")?>">Rufnummernblöcke</a></li>
|
||||
<li class="breadcrumb-item active"><?=($block->id) ? "bearbeiten" : "Neu" ?></li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Objekte</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title mb-2"><?=($block->id) ? "Rufnummernblock bearbeiten" : "Neuer Rufnummernblock"?></h4>
|
||||
|
||||
<form class="form-horizontal" method="post" action="<?=self::getUrl("Voicenumberblock", "save")?>">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<input type="hidden" name="id" value="<?=$block->id?>" />
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="countrycode">Country Code *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="countrycode" class="form-control" name="countrycode" id="countrycode" value="<?=$block->countrycode?>" />
|
||||
<small>43</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="areacode">Area Code *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="areacode" id="areacode" value="<?=$block->areacode?>" />
|
||||
<small>3115</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="first">Erste Nummer *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="first" id="first" value="<?=$block->first?>" />
|
||||
<small>4080010</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="last">Letzte Nummer *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="last" id="last" value="<?=$block->last?>" />
|
||||
<small>4080099</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="comment">Kommentar</label>
|
||||
<div class="col-lg-10">
|
||||
<textarea id="note" class="form-control" name="comment" rows="5"><?=$block->comment?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2"></label>
|
||||
<div class="col-lg-10">
|
||||
<button type="submit" class="btn btn-primary">Speichern</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?>
|
||||
171
Layout/default/Voicenumberblock/Index.php
Normal file
171
Layout/default/Voicenumberblock/Index.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?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">Rufnummernblöcke</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Rufnummernblöcke</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<h4 class="header-title mb-3">Filter</h4>
|
||||
|
||||
<form method="get" action="<?=self::getUrl("Voicenumberblock")?>">
|
||||
<div class="row">
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_countrycode">Countrycode</label>
|
||||
<input type="text" class="form-control" name="filter[countrycode]" id="filter_countrycode" value="<?=$filter['countrycode']?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_areacode">Areacode</label>
|
||||
<input type="text" class="form-control" name="filter[areacode]" id="filter_areacode" value="<?=$filter['areacode']?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_first">Anfang</label>
|
||||
<input type="text" class="form-control" name="filter[first]" id="filter_first" value="<?=$filter['first']?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_last">Ende</label>
|
||||
<input type="text" class="form-control" name="filter[last]" id="filter_last" value="<?=$filter['last']?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_number">Nummer</label>
|
||||
<input type="text" class="form-control" name="filter[number]" id="filter_number" value="<?=$filter['number']?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_comment">Kommentar</label>
|
||||
<input type="text" class="form-control" name="filter[comment]" id="filter_comment" value="<?=$filter['comment']?>" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row mt-2">
|
||||
<div class="col">
|
||||
<button type="submit" class="btn btn-primary">Filter anwenden</button>
|
||||
<a class="btn btn-secondary" href="<?=self::getUrl("Voicenumberblock")?>">Filter zurücksetzen</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<div class="float-left">
|
||||
<h4 class="header-title">Rufnummernblöcke</h4>
|
||||
</div>
|
||||
<div class="float-right">
|
||||
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Voicenumberblock", "add")?>"><i class="fas fa-plus"></i> Neuen Rufnummernblock 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']): ?>
|
||||
Rufnummernblöcke <?=$pagination['start']+1?> bis <?=($pagination['start'] + $pagination['count'] > $pagination['maxItems']) ? $pagination['maxItems'] : $pagination['start'] + $pagination['count']?> von <?=$pagination['maxItems']?>
|
||||
<?php else: ?>
|
||||
Keine Rufnummernblöcke gefunden
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<table class="table table-striped table-hover">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Country Code</th>
|
||||
<th>Area Code</th>
|
||||
<th>Anfang</th>
|
||||
<th>Ende</th>
|
||||
<th>Kommentar</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($blocks as $block): ?>
|
||||
<tr>
|
||||
<td><?=$block->id?></td>
|
||||
<td><?=$block->countrycode?></td>
|
||||
<td><?=$block->areacode?></td>
|
||||
<td><?=$block->first?></td>
|
||||
<td><?=$block->last?></td>
|
||||
<td><?=$block->comment?></td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<a href="<?=self::getUrl("Voicenumberblock", "edit", ["id" => $block->id])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Voicenumberblock", "delete", ["id" => $block->id])?>" onclick="if(!confirm('Rufnummernblock wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
|
||||
</td>
|
||||
</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']): ?>
|
||||
Rufnummernblöcke <?=$pagination['start']+1?> bis <?=($pagination['start'] + $pagination['count'] > $pagination['maxItems']) ? $pagination['maxItems'] : $pagination['start'] + $pagination['count']?> von <?=$pagination['maxItems']?>
|
||||
<?php else: ?>
|
||||
Keine Rufnummernblöcke gefunden
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?>
|
||||
@@ -15,16 +15,16 @@
|
||||
</a>
|
||||
<ul class="submenu">
|
||||
<li class="has-sub-submenu">
|
||||
<a href="<?=self::getUrl("Address")?>">Personen & Firmen</a>
|
||||
<ul class="sub-submenu">
|
||||
<li><a href="<?=self::getUrl("Address", "Index" , ["filter" => ["addresstype" => ["employee"]]])?>">Mitarbeiter</a></li>
|
||||
<li><a href="<?=self::getUrl("Address", "Index" , ["filter" => ["addresstype" => ["supplier"]]])?>">Lieferanten</a></li>
|
||||
</ul>
|
||||
<a href="<?=self::getUrl("Address")?>"><i class="fas fa-user"></i> Personen & Firmen</a>
|
||||
<!--<ul class="sub-submenu">
|
||||
<li><a href="<?=self::getUrl("Address", "Index" , ["filter" => ["addresstype" => ["employee"]]])?>"><i class="fas fa-"></i> Mitarbeiter</a></li>
|
||||
<li><a href="<?=self::getUrl("Address", "Index" , ["filter" => ["addresstype" => ["supplier"]]])?>"><i class="fas fa-"></i> Lieferanten</a></li>
|
||||
</ul>-->
|
||||
</li>
|
||||
<li><a href="<?=self::getUrl("Product")?>">Produkte</a></li>
|
||||
<li><a href="<?=self::getUrl("Producttech")?>">Technologien</a></li>
|
||||
<li><a href="<?=self::getUrl("User")?>">Benutzer</a></li>
|
||||
<li><a href="<?=self::getUrl("Network")?>">Netzgebiete</a></li>
|
||||
<li><a href="<?=self::getUrl("Product")?>"><i class="fab fa-product-hunt"></i> Produkte</a></li>
|
||||
<li><a href="<?=self::getUrl("Producttech")?>"><i class="fas fa-microchip"></i> Technologien</a></li>
|
||||
<li><a href="<?=self::getUrl("User")?>"><i class="fas fa-users"></i> Benutzer</a></li>
|
||||
<li><a href="<?=self::getUrl("Network")?>"><i class="fas fa-network-wired"></i> Netzgebiete</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
@@ -36,10 +36,10 @@
|
||||
<i class="fas fa-hard-hat"></i>Netzbau <div class="arrow-down"></div>
|
||||
</a>
|
||||
<ul class="submenu">
|
||||
<?php if($me->is(["Admin","netowner","pipeplanner"])): ?><li><a href="<?=self::getUrl("Building")?>">Objekte & Anschlüsse</a></li><?php endif; ?>
|
||||
<?php if($me->is(["Admin","netowner","pipeplanner","pipeworker","lineplanner","lineworker"])): ?><li><a href="<?=self::getUrl("Pipework")?>">Tiefbau</a></li><?php endif; ?>
|
||||
<?php if($me->is(["Admin","netowner","lineplanner","lineworker"])): ?><li><a href="<?=self::getUrl("Linework")?>">Leitungsbau</a></li><?php endif; ?>
|
||||
<?php if($me->is(["Admin", "netowner", "netoperator", "lineworker"])): ?><li><a href="<?=self::getUrl("Patching")?>">Patchungen</a></li><?php endif; ?>
|
||||
<?php if($me->is(["Admin","netowner","pipeplanner"])): ?><li><a href="<?=self::getUrl("Building")?>"><i class="fas fa-city"></i> Objekte & Anschlüsse</a></li><?php endif; ?>
|
||||
<?php if($me->is(["Admin","netowner","pipeplanner","pipeworker","lineplanner","lineworker"])): ?><li><a href="<?=self::getUrl("Pipework")?>"><i class="fas fa-wrench"></i> Tiefbau</a></li><?php endif; ?>
|
||||
<?php if($me->is(["Admin","netowner","lineplanner","lineworker"])): ?><li><a href="<?=self::getUrl("Linework")?>"><i class="fas fa-ethernet"></i> Leitungsbau</a></li><?php endif; ?>
|
||||
<?php if($me->is(["Admin", "netowner", "netoperator", "lineworker"])): ?><li><a href="<?=self::getUrl("Patching")?>"><i class="fas fa-plug"></i> Patchungen</a></li><?php endif; ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
@@ -47,11 +47,11 @@
|
||||
<?php if($me->is(["Admin"])): ?>
|
||||
<li class="has-submenu">
|
||||
<a href="#">
|
||||
<i class="fas fa-hard-hat"></i>Netzbetrieb <div class="arrow-down"></div>
|
||||
<i class="fas fa-running"></i>Netzbetrieb <div class="arrow-down"></div>
|
||||
</a>
|
||||
<ul class="submenu">
|
||||
<li><a href="<?=self::getUrl("Cpeprovisioning")?>">CPE Provisioning</a></li>
|
||||
<li><a href="<?=self::getUrl("Cpeshipping")?>">CPE Versand</a></li>
|
||||
<li><a href="<?=self::getUrl("Cpeprovisioning")?>"><i class="fas fa-hdd"></i> CPE Provisioning</a></li>
|
||||
<li><a href="<?=self::getUrl("Cpeshipping")?>"><i class="fas fa-shipping-fast"></i> CPE Versand</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
@@ -62,7 +62,18 @@
|
||||
<i class="fas fa-shopping-basket"></i>Verkauf <div class="arrow-down"></div>
|
||||
</a>
|
||||
<ul class="submenu">
|
||||
<li><a href="<?=self::getUrl("Order")?>">Bestellungen</a></li>
|
||||
<li><a href="<?=self::getUrl("Order")?>"><i class="fas fa-file-contract"></i> Bestellungen</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($me->is(["Admin"])): ?>
|
||||
<li class="has-submenu">
|
||||
<a href="#">
|
||||
<i class="fas fa-phone"></i>Telefonie <div class="arrow-down"></div>
|
||||
</a>
|
||||
<ul class="submenu">
|
||||
<li><a href="<?=self::getUrl("Order")?>"><i class="fas fa-blender-phone"></i> Rufnummernblöcke</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -80,7 +80,7 @@ class BuildingController extends mfBaseController {
|
||||
$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)) {
|
||||
|
||||
55
application/Voicenumberblock/Voicenumberblock.php
Normal file
55
application/Voicenumberblock/Voicenumberblock.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
class Voicenumberblock extends mfBaseModel {
|
||||
protected $forcestr = ['comment'];
|
||||
private $number_first;
|
||||
private $number_last;
|
||||
private $files;
|
||||
private $numbers;
|
||||
|
||||
private function getFullNumber($last = false) {
|
||||
if($last) {
|
||||
$number = $this->countrycode.$this->areacode.$this->last;
|
||||
} else {
|
||||
$number = $this->countrycode.$this->areacode.$this->first;
|
||||
}
|
||||
|
||||
return $number;
|
||||
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "files") {
|
||||
$this->files = VoiceblocknumberFileModel::search(["voicenumberblock_id" => $this->id]);
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
if($name == "numbers") {
|
||||
$this->numbers = VoicenumberModel::search(["voicenumberblock_id" => $this->id]);
|
||||
return $this->numbers;
|
||||
}
|
||||
|
||||
if($name == "number_first") {
|
||||
return $this->getFullNumber();
|
||||
}
|
||||
|
||||
if($name == "number_last") {
|
||||
return $this->getFullNumber(true);
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
}
|
||||
122
application/Voicenumberblock/VoicenumberblockController.php
Normal file
122
application/Voicenumberblock/VoicenumberblockController.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
class VoicenumberblockController extends mfBaseController {
|
||||
|
||||
protected function init() {
|
||||
$this->needlogin=true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
if(!$me->isAdmin()) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function indexAction() {
|
||||
$this->layout()->setTemplate("Voicenumberblock/Index");
|
||||
|
||||
$filter = [];
|
||||
if(is_array($this->request->filter)) {
|
||||
$filter = $this->request->filter;
|
||||
}
|
||||
|
||||
$this->layout->set("filter", $filter);
|
||||
|
||||
if($filter) {
|
||||
$filter = $this->getPreparedFilter($filter);
|
||||
}
|
||||
|
||||
// pagination defaults
|
||||
$pagination = [];
|
||||
$pagination['start'] = 0;
|
||||
$pagination['count'] = 20;
|
||||
$pagination['maxItems'] = 0;
|
||||
|
||||
if(is_numeric($this->request->s)) {
|
||||
$pagination['start'] = intval($this->request->s);
|
||||
}
|
||||
|
||||
$pagination['maxItems'] = VoicenumberblockModel::count($filter);
|
||||
$blocks = VoicenumberblockModel::search($filter, $pagination);
|
||||
|
||||
|
||||
$this->layout()->set("blocks", $blocks);
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
|
||||
}
|
||||
|
||||
private function getPreparedFilter($filter) {
|
||||
return $filter;
|
||||
}
|
||||
|
||||
protected function addAction() {
|
||||
$this->layout()->setTemplate("Voicenumberblock/Form");
|
||||
}
|
||||
|
||||
protected function editAction() {
|
||||
$id = $this->request->id;
|
||||
if(!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("Rufnummernblock nicht gefunden", "error");
|
||||
$this->redirect("Voicenumberblock");
|
||||
}
|
||||
|
||||
$block = new Voicenumberblock($id);
|
||||
if($block->id != $id) {
|
||||
$this->layout()->setFlash("Rufnummernblock nicht gefunden", "error");
|
||||
$this->redirect("Voicenumberblock");
|
||||
}
|
||||
|
||||
$this->layout()->set("block", $block);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
//var_dump($r);exit;
|
||||
if(is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$block = new Voicenumberblock($id);
|
||||
if(!$block->id) {
|
||||
$this->layout()->setFlash("Rufnummernblock nicht gefunden", "error");
|
||||
$this->redirect("Voicenumberblock");
|
||||
}
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
if(!$r->countrycode ||!$r->areacode || !$r->first || !$r->last) {
|
||||
$this->layout()->setFlash("Bitte alle benötigten Felder ausfüllen!", "error");
|
||||
$this->layout()->set("block", $r);
|
||||
return $this->add();
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['countrycode'] = $r->countrycode;
|
||||
$data['areacode'] = $r->areacode;
|
||||
$data['first'] = $r->first;
|
||||
$data['last'] = $r->last;
|
||||
$data['comment'] = $r->comment;
|
||||
$data['edit_by'] = $this->me->id;
|
||||
|
||||
if($mode == "add") {
|
||||
$data['create_by'] = 1;
|
||||
$block = VoicenumberblockModel::create($data);
|
||||
} else {
|
||||
$block->update($data);
|
||||
}
|
||||
|
||||
$new_id = $block->save();
|
||||
if(!$new_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern", "error");
|
||||
$this->layout()->set("block", $block);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Rufnummernblock erfolgreich gespeichert.", "success");
|
||||
$this->redirect("Voicenumberblock");
|
||||
|
||||
}
|
||||
}
|
||||
156
application/Voicenumberblock/VoicenumberblockModel.php
Normal file
156
application/Voicenumberblock/VoicenumberblockModel.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
class VoicenumberblockModel {
|
||||
public $countrycode;
|
||||
public $areacode;
|
||||
public $first;
|
||||
public $last;
|
||||
public $comment;
|
||||
|
||||
public $create_by;
|
||||
public $edit_by;
|
||||
public $create;
|
||||
public $edit;
|
||||
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new Voicenumberblock();
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
if(property_exists(get_called_class(), $field)) {
|
||||
$model->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
|
||||
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("Voicenumberblock", "*");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Voicenumberblock($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Voicenumberblock", "*", "$where ORDER BY countrycode, areacode, first, last");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Voicenumberblock($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as cnt FROM Voicenumberblock
|
||||
WHERE $where
|
||||
";
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function search($filter) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
//mfLoghandler::singleton()->log->debug($where);
|
||||
$res = $db->select("Voicenumberblock", "*", "$where ORDER BY countrycode, areacode, first, last");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Voicenumberblock($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private function getSqlFilter($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
$where = "1=1 ";
|
||||
|
||||
if(!is_array($filter)) {
|
||||
return $where;
|
||||
}
|
||||
|
||||
//var_dump($filter);exit;
|
||||
if(array_key_exists("countrycode", $filter)) {
|
||||
$countrycode = $filter['countrycode'];
|
||||
if(is_numeric($countrycode)) {
|
||||
$where .= " AND countrycode=$countrycode";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("areacode", $filter)) {
|
||||
$areacode = $filter['areacode'];
|
||||
if(is_numeric($areacode)) {
|
||||
$where .= " AND areacode=$areacode";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("first", $filter)) {
|
||||
$first = $filter['first'];
|
||||
if(is_numeric($first)) {
|
||||
$where .= " AND first=$first";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("last", $filter)) {
|
||||
$last = $filter['last'];
|
||||
if(is_numeric($last)) {
|
||||
$where .= " AND last=$last";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("number", $filter)) {
|
||||
$number = $filter['number'];
|
||||
if(is_numeric($number)) {
|
||||
$where .= " AND first <= $number AND last >= $number";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("comment", $filter)) {
|
||||
$comment = $db->escape($filter['comment']);
|
||||
if($comment) {
|
||||
$where .= " AND comment like '%$comment%'";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user