Products in Order Form now dynamic

This commit is contained in:
Frank Schubert
2022-06-02 17:22:19 +02:00
parent e08dda9bee
commit 66417f53b6
7 changed files with 328 additions and 47 deletions

View File

@@ -646,14 +646,17 @@ class OrderController extends mfBaseController {
//var_dump($r->products);exit;
// validate and add products
if(is_array($r->products) && count($r->products)) {
foreach($r->products as $product_id => $p) {
//var_dump($p);
if(!$product_id || !$p["product_id"]) {
foreach($r->products as $pos => $p) {
$orderproduct_id = $p["orderproduct_id"];
//var_dump($r);exit;
//var_dump($pos, $p);exit;
if(!$p["product_id"]) {
continue;
}
if($p['delete'] == 1) {
$product = new OrderProduct($product_id);
$product = new OrderProduct($orderproduct_id);
$product->delete();
continue;
}
@@ -661,6 +664,7 @@ class OrderController extends mfBaseController {
$prod = new Product($p['product_id']);
if(!$prod->id) {
$this->log->warn(__CLASS__."::save() Invalid product: ".$p['product_id']);
continue;
}
$product_data = [];
@@ -706,10 +710,10 @@ class OrderController extends mfBaseController {
}
if($product_id == "new") {
if(!$orderproduct_id) {
$product = OrderProductModel::create($product_data);
} else {
$product = new OrderProduct($product_id);
$product = new OrderProduct();
$product->update($product_data);
}
@@ -886,11 +890,18 @@ class OrderController extends mfBaseController {
if($r->filter) {
$query["filter"] = $r->filter;
}
if($r->return != "index") {
$query['id'] = $new_id;
}
$qs = http_build_query($query);
$this->layout()->setFlash("Bestellung erfolgreich gespeichert.", "success");
$this->redirect("Order", "Index", $qs, "order=$new_id-details");
if($r->return == "index") {
$this->redirect("Order", "Index", $qs, "order=$new_id-details");
} else {
$this->redirect("Order", "edit", $qs, "order=$new_id-details");
}
}

View File

@@ -389,6 +389,7 @@ class OrderModel {
$status_parts[] = "(Building.network_id = $net_id AND Terminationstatus.code >= ".TT_TERMSTATUS_CONNECTED.")";
}
if($filter['network_linked_status'][$net_id] == "building_connected") {
// sometimes terminations are of higher status when buildings are not yet finished, so we get them as well
$status_parts[] = "(Building.network_id = $net_id AND (Buildingstatus.code >= ".TT_BUILDINGSTATUS_CONNECTED." OR Terminationstatus.code >= ".TT_TERMSTATUS_ASSIGNED."))";
}
if($filter['network_linked_status'][$net_id] == "pipework_needed") {