diff --git a/Layout/default/Voicenumberblock/Form.php b/Layout/default/Voicenumberblock/Form.php new file mode 100644 index 000000000..f663a5635 --- /dev/null +++ b/Layout/default/Voicenumberblock/Form.php @@ -0,0 +1,92 @@ + + +
+
+
+
+ +
+

Objekte

+
+
+
+ + +
+
+ +
+
+

id) ? "Rufnummernblock bearbeiten" : "Neuer Rufnummernblock"?>

+ +
"> +
+
+ + + +
+ +
+ + 43 +
+
+ +
+ +
+ + 3115 +
+
+ +
+ +
+ + 4080010 +
+
+ +
+ +
+ + 4080099 +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+ + + +
+
+
+ +
+
+ + + \ No newline at end of file diff --git a/Layout/default/Voicenumberblock/Index.php b/Layout/default/Voicenumberblock/Index.php new file mode 100644 index 000000000..e64139303 --- /dev/null +++ b/Layout/default/Voicenumberblock/Index.php @@ -0,0 +1,171 @@ + + + +
+
+
+
+ +
+

Rufnummernblöcke

+
+
+
+ + +
+
+ +
+
+

Filter

+ +
"> +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+
+ + ">Filter zurücksetzen +
+
+
+ +
+
+ + +
+
+
+

Rufnummernblöcke

+
+ + + $pagination['count']): ?> + + + + + + + + + + + + + + + + + + + + + + + + + +
IDCountry CodeArea CodeAnfangEndeKommentar
id?>countrycode?>areacode?>first?>last?>comment?> + $block->id])?>"> + $block->id])?>" onclick="if(!confirm('Rufnummernblock wirklich löschen?')) return false;" class="text-danger" title="Löschen"> +
+ + $pagination['count']): ?> + + + + + +
+
+ +
+
+ + \ No newline at end of file diff --git a/Layout/default/menu.php b/Layout/default/menu.php index 37ed3ddda..4cccb6d02 100644 --- a/Layout/default/menu.php +++ b/Layout/default/menu.php @@ -15,16 +15,16 @@ @@ -36,10 +36,10 @@ Netzbau
@@ -47,11 +47,11 @@ is(["Admin"])): ?>
  • - Netzbetrieb
    + Netzbetrieb
  • @@ -62,7 +62,18 @@ Verkauf
    + + + + is(["Admin"])): ?> +
  • + + Telefonie
    +
    +
  • diff --git a/application/Building/BuildingController.php b/application/Building/BuildingController.php index 26268cde2..00db862d3 100644 --- a/application/Building/BuildingController.php +++ b/application/Building/BuildingController.php @@ -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)) { diff --git a/application/Voicenumberblock/Voicenumberblock.php b/application/Voicenumberblock/Voicenumberblock.php new file mode 100644 index 000000000..b6ceb3a57 --- /dev/null +++ b/application/Voicenumberblock/Voicenumberblock.php @@ -0,0 +1,55 @@ +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; + } +} \ No newline at end of file diff --git a/application/Voicenumberblock/VoicenumberblockController.php b/application/Voicenumberblock/VoicenumberblockController.php new file mode 100644 index 000000000..33bc1b99e --- /dev/null +++ b/application/Voicenumberblock/VoicenumberblockController.php @@ -0,0 +1,122 @@ +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"); + + } +} \ No newline at end of file diff --git a/application/Voicenumberblock/VoicenumberblockModel.php b/application/Voicenumberblock/VoicenumberblockModel.php new file mode 100644 index 000000000..b1776abd6 --- /dev/null +++ b/application/Voicenumberblock/VoicenumberblockModel.php @@ -0,0 +1,156 @@ + $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; + } + +} \ No newline at end of file