Added termination select to Product/Form
This commit is contained in:
@@ -10,6 +10,20 @@ class Building extends mfBaseModel {
|
||||
private $pipeworker;
|
||||
private $terminations;
|
||||
|
||||
public function getAddress($singelLine = false) {
|
||||
if(!$this->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$address = $this->street."\n".$this->zip." ".$this->city;
|
||||
if($singelLine) {
|
||||
$address = str_replace("\n", " ", $address);
|
||||
}
|
||||
|
||||
return $address;
|
||||
}
|
||||
|
||||
|
||||
public function getNewObjectCode() {
|
||||
if(!$this->zip) {
|
||||
return false;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
class File extends mfBaseModel {
|
||||
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
public function delete() {
|
||||
if($this->id) {
|
||||
@@ -28,4 +29,36 @@ class File extends mfBaseModel {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if(!$this->id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($name == "creator") {
|
||||
$this->creator = new User($this->create_by);
|
||||
return $this->creator;
|
||||
}
|
||||
|
||||
if($name == "editor") {
|
||||
$this->editor = new User($this->edit_by);
|
||||
return $this->editor;
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,9 +21,11 @@ class OrderController extends mfBaseController {
|
||||
}
|
||||
|
||||
protected function addAction() {
|
||||
// TODO: filter by network permissions
|
||||
$this->layout()->setTemplate("Order/Form");
|
||||
$this->layout()->set("addresses", AddressModel::search(['parents_only' => 1]));
|
||||
$this->layout()->set("products", ProductModel::getAll());
|
||||
$this->layout()->set("terminations", TerminationModel::getAll());
|
||||
|
||||
|
||||
}
|
||||
@@ -264,6 +266,16 @@ class OrderController extends mfBaseController {
|
||||
if(!$product_id || !$p["product_id"]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$prod = new Product($p['product_id']);
|
||||
if(!$prod->id) {
|
||||
$this->log->warn(__CLASS__."::save() Invalid product: ".$p['product_id']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$product_data = [];
|
||||
$product_data["order_id"] = $new_id;
|
||||
$product_data["product_id"] = $p["product_id"];
|
||||
@@ -275,6 +287,17 @@ class OrderController extends mfBaseController {
|
||||
$product_data["billing_delay"] = 0;
|
||||
$product_data["billing_period"] = $p["billing_period"];
|
||||
|
||||
$require_term = false;
|
||||
if(array_key_exists(TT_ATTRIB_TERMINATION_REQUIRED_NAME, $prod->attributes) && $prod->attributes[TT_ATTRIB_TERMINATION_REQUIRED_NAME] == 1) {
|
||||
$require_term = true;
|
||||
if(!$p['termination_id']) {
|
||||
$this->layout()->setFlash("Produkt nicht gespeichert. Produkt erfordert Anschluss.", "warn");
|
||||
continue;
|
||||
}
|
||||
$product_data['termination_id'] = $p['termination_id'];
|
||||
}
|
||||
|
||||
|
||||
if($product_id == "new") {
|
||||
$product = OrderProductModel::create($product_data);
|
||||
} else {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
class OrderFile extends mfBaseModel {
|
||||
private $file;
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
@@ -63,10 +63,10 @@ class ProductController extends mfBaseController {
|
||||
$data['description'] = $r->description;
|
||||
$data['sla_id'] = $r->sla_id;
|
||||
$data['external'] = ($r->external == 1) ? "1" : "0";
|
||||
$data['price_nne'] = Layout::commaToDot($r->price_nne);
|
||||
$data['price_nbe'] = Layout::commaToDot($r->price_nbe);
|
||||
$data['price'] = Layout::commaToDot($r->price);
|
||||
$data['price_setup'] = Layout::commaToDot($r->price_setup);
|
||||
$data['price_nne'] = ($data['price_nne']) ? Layout::commaToDot($r->price_nne) : 0;
|
||||
$data['price_nbe'] = ($data['price_nbe']) ? Layout::commaToDot($r->price_nbe) : 0;
|
||||
$data['price'] = ($data['price']) ? Layout::commaToDot($r->price) : 0;
|
||||
$data['price_setup'] = ($data['price_setup']) ? Layout::commaToDot($r->price_setup) : 0;
|
||||
$data['billing_period'] = $r->billing_period;
|
||||
$data['billing_delay'] = $r->billing_delay;
|
||||
$data['ivt_id'] = ($r->ivt_id) ? $r->ivt_id : null;
|
||||
@@ -215,6 +215,15 @@ class ProductController extends mfBaseController {
|
||||
if(!$product->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(is_array($product->attributes) && count($product->attributes)) {
|
||||
$attributes = $product->attributes;
|
||||
$product->data->attributes = [];
|
||||
foreach($attributes as $attrib) {
|
||||
$product->data->attributes[$attrib->name] = $attrib->value;
|
||||
}
|
||||
}
|
||||
|
||||
return ["product" => $product->data, "form_id" => $form_id];
|
||||
}
|
||||
|
||||
@@ -10,6 +10,25 @@ class Termination extends mfBaseModel {
|
||||
private $editor;
|
||||
|
||||
|
||||
public function getAddress($singelLine = false) {
|
||||
if(!$this->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$b = $this->getProperty("building");
|
||||
|
||||
$address = $b->street;
|
||||
if($this->name) {
|
||||
$address .= " ".$this->name;
|
||||
}
|
||||
$address .= "\n".$b->zip." ".$b->city;
|
||||
if($singelLine) {
|
||||
$address = str_replace("\n", " ", $address);
|
||||
}
|
||||
|
||||
return $address;
|
||||
}
|
||||
|
||||
public function getNewObjectCode() {
|
||||
if(!$this->building_id) {
|
||||
return false;
|
||||
@@ -51,6 +70,8 @@ class Termination extends mfBaseModel {
|
||||
return $code;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user