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

Rufnummer getFullNumber()?>

+
+
+
+ + +
+
+ +
+
+ + +
"> +

Allgemein

+
+
+ + + + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +

Portierung

+
+
+ +
+ +
+ +
+
+
+ +
+ port_in_date) : ""?>" /> +
+
+ +
+ +
+ +
+
+
+ +
+ port_out_date) : ""?>" /> +
+
+ +
+
+ +

Sperre

+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ enable_on_date) : ""?>" /> +
+
+ +
+
+ +

Kommentar

+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+ + + +
+
+
+ +
+
+ + + + \ No newline at end of file diff --git a/Layout/default/Voicenumberblock/Index.php b/Layout/default/Voicenumberblock/Index.php index 95fbdfd62..ed07e67d2 100644 --- a/Layout/default/Voicenumberblock/Index.php +++ b/Layout/default/Voicenumberblock/Index.php @@ -192,5 +192,15 @@ $('#block-' + id).addClass("table-info"); } } + + + var block; + var hash = window.location.hash.substr(1); + var match = hash.match(/block=(\d+)/); + if(match && match[1]) { + block = match[1] + toggleBlock(block); + } + \ No newline at end of file diff --git a/Layout/default/Voicenumberblock/include/block-detail.php b/Layout/default/Voicenumberblock/include/block-detail.php index 4fe596fab..f8dfae462 100644 --- a/Layout/default/Voicenumberblock/include/block-detail.php +++ b/Layout/default/Voicenumberblock/include/block-detail.php @@ -12,6 +12,7 @@ Portierungsstatus Sperre Entsperrung + getFirst(), $block->getLast()) as $number): ?> $block_id, 'number' => ($block->number_prepend_zero) ? "0$number" : $number]) ?> @@ -29,13 +30,19 @@ ported_out): ?> Exportiert - (id) ? date("d.m.Y H:i:s", $num->port_out_date) : ""?>) + (id) ? date("d.m.Y", $num->port_out_date) : ""?>) + ported_in): ?> + Importiert + (id) ? date("d.m.Y", $num->port_in_date) : ""?>) Lokal disabled_reason?> id && $num->enable_on_date) ? date("d.m.Y", $num->enable_on_date) : ""?> + + $block->id, "number" => $number])?>"> + = 100) break; ?> diff --git a/application/Voicenumber/Voicenumber.php b/application/Voicenumber/Voicenumber.php index a78066748..c056792e9 100644 --- a/application/Voicenumber/Voicenumber.php +++ b/application/Voicenumber/Voicenumber.php @@ -1,5 +1,72 @@ voicenumberblock_id = $block->id; + $this->countrycode = $block->countrycode; + $this->areacode = $block->areacode; + $this->number_prepend_zero = $block->number_prepend_zero; + return true; + } + + public function getFullNumber() { + $number = $this->countrycode.$this->areacode.$this->number; + + return $number; + } + + + public function beforeSave() { + if($this->ported_from && $this->port_in_date) { + $this->ported_in = 1; + } else { + $this->ported_in = 0; + } + + if($this->ported_to && $this->port_out_date) { + $this->ported_out = 1; + } else { + $this->ported_out = 0; + } + + if($this->active == 1 && !$this->_old_data->active) { + $this->activated_date = date("U"); + } + } + + public function getProperty($name) { + if($this->$name == null) { + + if($name == "block") { + $this->block = new Voicenumberblock($this->voicenumberblock_id); + return $this->block; + } + + if($name == "orderproduct") { + $this->orderproduct = new Orderproduct($this->orderproduct_id); + return $this->orderproduct; + } + + if($name == "contract") { + $this->contract = new Contract($this->contract_id); + return $this->contract; + } + + $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/Voicenumber/VoicenumberController.php b/application/Voicenumber/VoicenumberController.php new file mode 100644 index 000000000..c8449a2ff --- /dev/null +++ b/application/Voicenumber/VoicenumberController.php @@ -0,0 +1,166 @@ +needlogin=true; + $me = new User(); + $me->loadMe(); + $this->me = $me; + $this->layout()->set("me",$me); + + if(!$me->isAdmin()) { + $this->redirect("Dashboard"); + } + } + + protected function editAction() { + $block_id = $this->request->block_id; + if(!is_numeric($block_id) || !$block_id) { + $this->layout()->setFlash("Rufnummer nicht gefunden1", "error"); + $this->redirect("Voicenumberblock"); + } + + $block = new Voicenumberblock($block_id); + if(!$block->id) { + $this->layout()->setFlash("Rufnummer nicht gefunden2", "error"); + $this->redirect("Voicenumberblock"); + } + + $num = (string)$this->request->number; + if(!strlen($num)) { + $this->layout()->setFlash("Rufnummer nicht gefunden3", "error"); + $this->redirect("Voicenumberblock", "Index", null, ["block" => $block->id]); + } + + if(!$block->isNumberInBlock($num)) { + $this->layout()->setFlash("Rufnummer nicht gefunden4", "error"); + $this->redirect("Voicenumberblock", "Index", null, ["block" => $block->id]); + } + + $number = VoicenumberModel::getFirst(["block_id" => $block_id, "number" => (string)$num]); + $mode = "edit"; + + if(!$number) { + $number = new Voicenumber(); + $number->loadFromBlock($block); + $number->number = $num; + $mode = "add"; + } + //var_dump($number);exit; + + $this->layout()->setTemplate("Voicenumber/Form"); + $this->layout()->set("number", $number); + + + } + + protected function saveAction() { + $r = $this->request; + //var_dump($r); + $block_id = $r->block_id; + if(!is_numeric($block_id) || !$block_id) { + $this->layout()->setFlash("Rufnummer nicht gefunden1", "error"); + $this->redirect("Voicenumberblock"); + } + + $block = new Voicenumberblock($block_id); + if(!$block->id) { + $this->layout()->setFlash("Rufnummer nicht gefunden2", "error"); + $this->redirect("Voicenumberblock"); + } + + $num = (string)$r->number; + if(!strlen($num)) { + $this->layout()->setFlash("Rufnummer nicht gefunden3", "error"); + $this->redirect("Voicenumberblock", "Index", null, ["block" => $block->id]); + } + + if(!$block->isNumberInBlock($num)) { + $this->layout()->setFlash("Rufnummer nicht gefunden4", "error"); + $this->redirect("Voicenumberblock", "Index", null, ["block" => $block->id]); + } + + $number = VoicenumberModel::getFirst(["block_id" => $block_id, "number" => (string)$num]); + $mode = "edit"; + + if(!$number) { + $number = new Voicenumber(); + $number->loadFromBlock($block); + $number->number = $num; + $number->create_by = $this->me->id; + $mode = "add"; + } + + //var_dump($number); + + + $number_data = []; + $number_data['contract_id'] = $r->contract_id; + if($r->active === "1") { + $number_data['active'] = 1; + } else { + $number_data['active'] = 0; + } + + switch($r->routing) { + case "sipit": + $number_data['routing'] = "sipit"; + break; + default: + $number_data['routing'] = "kolmisoft"; + } + + + $number_data['ported_from'] = $r->ported_from; + if($r->port_in_date) { + $number_data['port_in_date'] = self::dateToTimestamp($r->port_in_date); + } + + $number_data['ported_to'] = $r->ported_to; + if($r->port_out_date) { + $number_data['port_out_date'] = self::dateToTimestamp($r->port_out_date); + } + + if($r->disabled === "1") { + $number_data['disabled'] = 1; + switch($r->disabled_reason) { + case "ported_out": + $number_data['disabled_reason'] = "ported_out"; + break; + case "ported_back": + $number_data['disabled_reason'] = "ported_back"; + break; + case "legacy": + $number_data['disabled_reason'] = "legacy"; + break; + case "damaged": + $number_data['disabled_reason'] = "damaged"; + break; + default: + $number_data['disabled_reason'] = "reserved"; + } + + } + + if($r->enable_on_date) { + $number_data['enable_on_date'] = self::dateToTimestamp($r->enable_on_date); + } + $number_data['comment'] = $r->comment; + $number_data['edit_by'] = $this->me->id; + + $number->update($number_data); + $number_id = $number->save(); + + if(!$number_id) { + $this->layout()->setFlash("Fehler beim Speichern", "error"); + $this->redirect("Voicenumber", "edit", ["block_id" => $block_id, "number" => $num]); + } + + $this->layout()->setFlash("Rufnummer erfolgreich gespeichert", "success"); + $this->redirect("Voicenumberblock", "Index", null, "block=".$block->id); + + + } + +} \ No newline at end of file diff --git a/application/Voicenumber/VoicenumberModel.php b/application/Voicenumber/VoicenumberModel.php index 9dbf7d846..be01b2901 100644 --- a/application/Voicenumber/VoicenumberModel.php +++ b/application/Voicenumber/VoicenumberModel.php @@ -123,6 +123,13 @@ class VoicenumberModel { return $where; } + if(array_key_exists("block_id", $filter)) { + $block_id = $filter['block_id']; + if(is_numeric($block_id)) { + $where .= " AND voicenumberblock_id = $block_id"; + } + } + //var_dump($filter);exit; if(array_key_exists("countrycode", $filter)) { $countrycode = $filter['countrycode']; diff --git a/application/Voicenumberblock/Voicenumberblock.php b/application/Voicenumberblock/Voicenumberblock.php index 6cb3b100d..85aeeefe8 100644 --- a/application/Voicenumberblock/Voicenumberblock.php +++ b/application/Voicenumberblock/Voicenumberblock.php @@ -41,6 +41,10 @@ class Voicenumberblock extends mfBaseModel { return $base; } + public function isNumberInBlock($number) { + return ($number >= $this->first && $number <= $this->last); + } + public function getProperty($name) { if($this->$name == null) {