Added termination select to Product/Form
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user