Contractjournal finished & Started Contractconfig Hooks for Provisioning Workflow
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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]);
|
||||
|
||||
|
||||
35
application/Contractconfig/hooks/Contractconfig_Hook.php
Normal file
35
application/Contractconfig/hooks/Contractconfig_Hook.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
abstract class Contractconfig_Hook {
|
||||
protected $contract;
|
||||
protected $items;
|
||||
|
||||
public function __construct(Contract $contract) {
|
||||
|
||||
if(method_exists($this, "init")) {
|
||||
$this->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();
|
||||
|
||||
}
|
||||
42
application/Contractconfig/hooks/Voip.php
Normal file
42
application/Contractconfig/hooks/Voip.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
class Contractconfig_Hook_Voip extends Contractconfig_Hook {
|
||||
private $my_product_attributes = ["needs_number"];
|
||||
|
||||
/*
|
||||
* Checks to determine if class needs to work on contract.
|
||||
*/
|
||||
public function isResponsible(Contract $contract) {
|
||||
|
||||
/*
|
||||
* Test for standard checks
|
||||
* (Only Producttech attributes for now)
|
||||
*/
|
||||
if(!parent::isResponsible()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// do additional checks
|
||||
|
||||
}
|
||||
|
||||
public function init() {
|
||||
|
||||
}
|
||||
|
||||
public function beforeSave() {
|
||||
|
||||
}
|
||||
|
||||
public function afterSave() {
|
||||
|
||||
}
|
||||
|
||||
public function beforeDelete() {
|
||||
|
||||
}
|
||||
|
||||
public function afterDelete() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ class ContractconfigItemController extends mfBaseController {
|
||||
}
|
||||
|
||||
$item_data['contractconfiggroup_id'] = $r->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;
|
||||
|
||||
86
application/Contractjournal/ContractjournalController.php
Normal file
86
application/Contractjournal/ContractjournalController.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
class ContractjournalController extends mfBaseController {
|
||||
|
||||
protected function init() {
|
||||
$this->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]);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user