-
- items) && count($group->items)): ?>
- items as $item): ?>
-
-
-
=$item->name?> - =$item->displayname?> [=$item->type?>]
-
-
-
diff --git a/Layout/default/Voicenumberblock/Index.php b/Layout/default/Voicenumberblock/Index.php
index dc2eadf2a..950a1439b 100644
--- a/Layout/default/Voicenumberblock/Index.php
+++ b/Layout/default/Voicenumberblock/Index.php
@@ -110,9 +110,9 @@
=$block->name?> |
=$block->countrycode?> |
=$block->areacode?> |
-
=$block->base?> |
-
=$block->getFirst()?> |
-
=$block->getLast()?> |
+
=$block->short_prefix?> |
+
=$block->first?> |
+
=$block->last?> |
=$block->comment?> |
$block->id])?>">
diff --git a/Layout/default/Voicenumberblock/include/block-detail.php b/Layout/default/Voicenumberblock/include/block-detail.php
index e6938a62a..2a8f1ecf8 100644
--- a/Layout/default/Voicenumberblock/include/block-detail.php
+++ b/Layout/default/Voicenumberblock/include/block-detail.php
@@ -3,7 +3,7 @@
?>
-
+
| Nummer |
@@ -14,10 +14,10 @@
Entsperrung |
|
- getFirst(), $block->getLast()) as $number): ?>
- $block_id, 'number' => ($block->number_prepend_zero) ? "0$number" : $number]) ?>
+ first, $block->last) as $number): ?>
+ $block_id, 'number' => $number]) ?>
- | =$block->countrycode?> =$block->areacode?> =($block->number_prepend_zero) ? "0" : ""?>=$number?> |
+ =$number?> |
active): ?>
diff --git a/application/Contract/ContractController.php b/application/Contract/ContractController.php
index 96ed5ae69..fb4c9f56d 100644
--- a/application/Contract/ContractController.php
+++ b/application/Contract/ContractController.php
@@ -474,6 +474,14 @@ class ContractController extends mfBaseController {
return $this->addAction();
}
+ // create journal
+ $journal = ContractjournalModel::create([
+ 'contract_id' => $contract_id,
+ 'type' => "created_from",
+ 'value' => "manual"
+ ]);
+ $journal->save();
+
$this->layout()->setFlash("Vertrag erfolgreich gespeichert.", "success");
/*
@@ -487,7 +495,22 @@ class ContractController extends mfBaseController {
'origin_contract_id' => $origin->id,
'type' => 'link'
]);
- $link->save();
+ $link_id = $link->save();
+ if($link_id) {
+ $journal = ContractjournalModel::create([
+ 'contract_id' => $contract_id,
+ 'type' => "link",
+ 'value' => $origin->id
+ ]);
+ $journal->save();
+
+ $ojournal = ContractjournalModel::create([
+ 'contract_id' => $origin->id,
+ 'type' => "link",
+ 'value' => $contract_id
+ ]);
+ $ojournal->save();
+ }
}
}
diff --git a/application/Contractconfig/ContractconfigController.php b/application/Contractconfig/ContractconfigController.php
index be688787c..a155f2d8e 100644
--- a/application/Contractconfig/ContractconfigController.php
+++ b/application/Contractconfig/ContractconfigController.php
@@ -55,6 +55,12 @@ class ContractconfigController extends mfBaseController {
$this->redirect("Contract");
}
+ $contract = new Contract($contract_id);
+ if(!$contract->id) {
+ $this->layout()->setFlash("Contract ID nicht gefunden.","error");
+ $this->redirect("Contract");
+ }
+
if(!is_array($r->itemvalues) || !count($r->itemvalues)) {
$this->layout()->setFlash("Keine Änderungen.","info");
$this->redirect("Contract");
@@ -87,6 +93,9 @@ class ContractconfigController extends mfBaseController {
return $this->editAction();
}
+ // run custom productgroup hooks
+
+
$this->layout()->setFlash("Konfiguration gespeichert", "success");
$this->redirect("Contract", "view", ['id' => $contract_id]);
diff --git a/application/Contractconfig/hooks/Contractconfig_Hook.php b/application/Contractconfig/hooks/Contractconfig_Hook.php
new file mode 100644
index 000000000..2b31194b6
--- /dev/null
+++ b/application/Contractconfig/hooks/Contractconfig_Hook.php
@@ -0,0 +1,35 @@
+init();
+ }
+ }
+
+ public function isResponsible() {
+ if(!$this->contract) return false;
+
+ // only work on contracts with our producttech attributes
+ if(!$this->testMyProductAttributes($contract)) {
+ return false;
+ }
+
+ }
+
+ private function testMyProductAttributes(Contract $contract) {
+ $product = $contract->product;
+
+ }
+
+ abstract public function beforeSave();
+ abstract public function afterSave();
+
+ abstract public function beforeDelete();
+ abstract public function afterDelete();
+
+}
\ No newline at end of file
diff --git a/application/Contractconfig/hooks/Voip.php b/application/Contractconfig/hooks/Voip.php
new file mode 100644
index 000000000..06ba1d585
--- /dev/null
+++ b/application/Contractconfig/hooks/Voip.php
@@ -0,0 +1,42 @@
+group_id;
+ $item_data['order'] = ($r->order && is_numeric($r->order)) ? $r->order : null;
$item_data['name'] = $r->name;
$item_data['displayname'] = $r->displayname;
$item_data['description'] = $r->description;
diff --git a/application/Contractjournal/ContractjournalController.php b/application/Contractjournal/ContractjournalController.php
new file mode 100644
index 000000000..410856b3e
--- /dev/null
+++ b/application/Contractjournal/ContractjournalController.php
@@ -0,0 +1,86 @@
+needlogin=true;
+ $me = new User();
+ $me->loadMe();
+ $this->me = $me;
+ $this->layout()->set("me",$me);
+
+ if(!$me->is(["Admin"])) {
+ $this->redirect("Dashboard");
+ }
+ }
+
+ protected function saveAction() {
+ $r = $this->request;
+ //var_dump($r->get());exit;
+
+ $contract_id = $r->contract_id;
+
+ if(!is_numeric($contract_id) || $contract_id < 1) {
+ $this->layout()->setFlash("Contract nicht gefunden", "error");
+ $this->redirect("Contract");
+ }
+
+ $contract = new Contract($contract_id);
+ if(!$contract->id) {
+ $this->layout()->setFlash("Contract nicht gefunden", "error");
+ $this->redirect("Contract");
+ }
+
+ $journal_data = [];
+ $journal_data["contract_id"] = $contract_id;
+ $journal_data["text"] = ($r->text) ? $r->text : null;
+
+ $journal_data["type"] = "text";
+ if($r->type == "phone") $journal_data["type"] = "phone";
+ if($r->type == "file") $journal_data["type"] = "file";
+
+
+ if(in_array($r->type, ["text", "phone"])) {
+ if(!$journal_data['text']) {
+ $this->layout()->setFlash("Journaleintrag darf nicht leer sein", "error");
+ $this->redirect("Contract", "view", ['contract_id' => $contract_id]);
+ }
+ }
+
+ if($r->type == "file") {
+ try {
+ // returns File object or throws Exception on error
+ $file = mfUpload::handleFormUpload("journal_file");
+ } catch (Exception $ex) {
+ $this->layout()->setFlash("Fehler beim Dateiupload: ".$ex->getMessage(), "error");
+ $this->redirect("Contract", "view", ['contract_id' => $contract_id]);
+ }
+
+ $cf = ContractFileModel::create([
+ 'contract_id' => $contract_id,
+ 'file_id' => $file->id,
+ 'name' => $file->name,
+ ]);
+ $contractfile_id = $cf->save();
+ if(!$contractfile_id) {
+ $this->layout()->setFlash("Fehler beim Speichern der hochgeladenen Datei", "error");
+ $this->redirect("Contract", "view", ['contract_id' => $contract_id]);
+ }
+
+ $journal_data['type'] = "file";
+ $journal_data['value'] = $contractfile_id;
+
+ }
+
+ $journal = ContractjournalModel::create($journal_data);
+ $journal_id = $journal->save();
+ if(!$journal_id) {
+ $this->layout()->setFlash("Fehler beim Speichern des Journaleintrags", "error");
+ $this->redirect("Contract", "view", ['contract_id' => $contract_id]);
+ }
+
+ $this->layout()->setFlash("Journaleintrag erfolgreich gespeichert", "success");
+ $this->redirect("Contract", "view", ['contract_id' => $contract_id]);
+
+ }
+}
\ No newline at end of file
diff --git a/application/Voicenumber/Voicenumber.php b/application/Voicenumber/Voicenumber.php
index c056792e9..a48cd976a 100644
--- a/application/Voicenumber/Voicenumber.php
+++ b/application/Voicenumber/Voicenumber.php
@@ -7,19 +7,12 @@ class Voicenumber extends mfBaseModel {
public function loadFromBlock(Voicenumberblock $block) {
$this->voicenumberblock_id = $block->id;
- $this->countrycode = $block->countrycode;
- $this->areacode = $block->areacode;
- $this->number_prepend_zero = $block->number_prepend_zero;
+ //$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;
diff --git a/application/Voicenumber/VoicenumberController.php b/application/Voicenumber/VoicenumberController.php
index c8449a2ff..db0e93eaa 100644
--- a/application/Voicenumber/VoicenumberController.php
+++ b/application/Voicenumber/VoicenumberController.php
@@ -57,7 +57,7 @@ class VoicenumberController extends mfBaseController {
protected function saveAction() {
$r = $this->request;
- //var_dump($r);
+ var_dump($r);exit;
$block_id = $r->block_id;
if(!is_numeric($block_id) || !$block_id) {
$this->layout()->setFlash("Rufnummer nicht gefunden1", "error");
diff --git a/application/Voicenumber/VoicenumberModel.php b/application/Voicenumber/VoicenumberModel.php
index 24341b417..008e3d3d0 100644
--- a/application/Voicenumber/VoicenumberModel.php
+++ b/application/Voicenumber/VoicenumberModel.php
@@ -56,7 +56,7 @@ class VoicenumberModel {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
- mfLoghandler::singleton()->debug($where);
+ //mfLoghandler::singleton()->debug($where);
$res = $db->select("Voicenumber", "*", "$where ORDER BY voicenumberblock_id, number");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
@@ -146,21 +146,9 @@ class VoicenumberModel {
}
if(array_key_exists("number", $filter)) {
- $add_zero = false;
$number = $filter['number'];
-
- mfLoghandler::singleton()->debug($number);
-
- if(substr($number,0, 1) === "0") {
- $add_zero = true;
- $number = substr($number, 1);
- }
if(is_numeric($number)) {
$where .= " AND number = $number";
-
- if($add_zero) {
- $where .= " AND number_prepend_zero = 1";
- }
}
}
diff --git a/application/Voicenumberblock/Voicenumberblock.php b/application/Voicenumberblock/Voicenumberblock.php
index 85aeeefe8..74ed8e503 100644
--- a/application/Voicenumberblock/Voicenumberblock.php
+++ b/application/Voicenumberblock/Voicenumberblock.php
@@ -5,42 +5,12 @@ class Voicenumberblock extends mfBaseModel {
private $number_first;
private $number_last;
private $base;
+ private $short_prefix;
+ private $short_first;
+ private $short_last;
private $files;
private $numbers;
- private function getFullNumber($last = false) {
- if($last) {
- $number = $this->countrycode.$this->areacode.$this->getLast();
- } else {
- $number = $this->countrycode.$this->areacode.$this->getFirst();
- }
-
- return $number;
- }
-
- public function getFirst() {
- if($this->number_prepend_zero) {
- return "0".$this->first;
- }
- return $this->first;
- }
-
- public function getLast() {
- if($this->number_prepend_zero) {
- return "0".$this->last;
- }
- return $this->last;
- }
-
- public function getBaseNumber() {
- $base = floor($this->first / pow(10, ceil(log10($this->last - $this->first))));
-
- if($this->number_prepend_zero) {
- return "0".$base;
- }
- return $base;
- }
-
public function isNumberInBlock($number) {
return ($number >= $this->first && $number <= $this->last);
}
@@ -58,16 +28,17 @@ class Voicenumberblock extends mfBaseModel {
return $this->numbers;
}
- if($name == "number_first") {
- return $this->getFullNumber();
+ if($name == "short_prefix") {
+ $this->short_prefix = substr($this->prefix, strlen($this->countrycode.$this->areacode));
+ return $this->short_prefix;
}
-
- if($name == "number_last") {
- return $this->getFullNumber(true);
+ if($name == "short_first") {
+ $this->short_first = substr($this->first, strlen($this->countrycode.$this->areacode));
+ return $this->short_first;
}
-
- if($name == "base") {
- return $this->getBaseNumber();
+ if($name == "short_last") {
+ $this->short_last = substr($this->last, strlen($this->countrycode.$this->areacode));
+ return $this->short_last;
}
$classname = ucfirst($name);
diff --git a/application/Voicenumberblock/VoicenumberblockModel.php b/application/Voicenumberblock/VoicenumberblockModel.php
index ad13be2fd..ff2d7d3da 100644
--- a/application/Voicenumberblock/VoicenumberblockModel.php
+++ b/application/Voicenumberblock/VoicenumberblockModel.php
@@ -4,9 +4,9 @@ class VoicenumberblockModel {
public $name;
public $countrycode;
public $areacode;
+ public $prefix;
public $first;
public $last;
- public $number_prepend_zero;
public $comment;
public $create_by;
@@ -138,56 +138,24 @@ class VoicenumberblockModel {
}
if(array_key_exists("first", $filter)) {
- $add_zero = false;
$first = $filter['first'];
-
- mfLoghandler::singleton()->debug($first);
-
- if(substr($first,0, 1) === "0") {
- $add_zero = true;
- $first = substr($first, 1);
- }
-
if(is_numeric($first)) {
- $where .= " AND first like '%$first%'";
- if($add_zero) {
- $where .= " AND number_prepend_zero = 1";
- }
+ $where .= " AND first = '$first'";
}
}
if(array_key_exists("last", $filter)) {
- $add_zero = false;
$last = $filter['last'];
-
- mfLoghandler::singleton()->debug($last);
-
- if(substr($last,0, 1) === "0") {
- $add_zero = true;
- $last = substr($last, 1);
- }
-
if(is_numeric($last)) {
- $where .= " AND last like '%$last%'";
+ $where .= " AND last = '$last'";
}
}
if(array_key_exists("number", $filter)) {
- $add_zero = false;
$number = $filter['number'];
-
- mfLoghandler::singleton()->debug($number);
-
- if(substr($number,0, 1) === "0") {
- $add_zero = true;
- $number = substr($number, 1);
- }
+
if(is_numeric($number)) {
$where .= " AND first <= $number AND last >= $number";
-
- if($add_zero) {
- $where .= " AND number_prepend_zero = 1";
- }
}
}
diff --git a/lib/mvcfronk/mfUpload/mfUpload.php b/lib/mvcfronk/mfUpload/mfUpload.php
index c9814d55f..50bc98b28 100644
--- a/lib/mvcfronk/mfUpload/mfUpload.php
+++ b/lib/mvcfronk/mfUpload/mfUpload.php
@@ -46,6 +46,58 @@ class mfUpload {
}
}
+ static public function handleFormUpload($uplName, $filename = false, $subfolder = false, $savepath = MFUPLOAD_FILE_SAVE_PATH) {
+ if(!isset($_FILES) || !array_key_exists($uplName, $_FILES)) {
+ throw new Exception("Uploaded file not found");
+ }
+ if($_FILES['OrderFileUpload']['error']) {
+ throw new Exception("Error receiving file");
+ }
+
+ $upload_error = false;
+
+ $savepath = preg_replace('#/+$#', "", $savepath); // remove trailing slash
+ if($subfolder) {
+ $subfolder = preg_replace('#^/+#', "", $subfolder); // remove leading slash
+ $subfolder = preg_replace('#/+$#', "", $subfolder); // remove trailing slash
+ $savepath .= "/$subfolder";
+ }
+
+ $upload = new mfUpload($uplName);
+ $upload->setSavepath($savepath);
+
+ if(!$upload->getSize()) {
+ throw new Exception("Datei darf nicht leer sein");
+ }
+
+ if(substr(strtolower($upload->getFilename()), -3, 3) == "pdf" && !$upload->validatePDF()) {
+ throw new Exception("PDF-Validierung fehlgeschlagen");
+ }
+
+ try {
+ $upload->save();
+ } catch (Exception $ex) {
+ throw $ex;
+ }
+
+ $file_data = [];
+ $file_data['name'] = ($filename) ? $filename : $upload->getOriginalFilename();
+ $file_data['filename'] = ($filename) ? $filename : $upload->getOriginalFilename();
+ $file_data['subfolder'] = $subfolder;
+ $file_data['store_filename'] = $upload->getFilename();
+ $file_data['orig_filename'] = $upload->getOriginalFilename();
+
+ $file = FileModel::create($file_data);
+ $file_id = $file->save();
+ if(!$file_id) {
+ unlink($upload->getSavepath()."/".$upload->getFilename());
+ throw new Exception("Datei konnte nicht angelegt werden");
+ }
+
+ return $file;
+
+ }
+
public function getSavepath() {
return $this->savepath;
}
diff --git a/public/assets/css/thetool.css b/public/assets/css/thetool.css
index 3b6ec51fd..bf6dba98a 100644
--- a/public/assets/css/thetool.css
+++ b/public/assets/css/thetool.css
@@ -83,6 +83,9 @@ h1, h2, h3, h4, h5, h6 {
.card.border-top-warning {
border-top: 2px solid #f7b84b;
}
+.card.border-top-info {
+ border-top: 2px solid #4b88e4;
+}
/*
.card-header.underline-danger {
border-bottom: 2px solid #f1556c;
| |