showing disabled products in existing orders if needed

This commit is contained in:
Frank Schubert
2023-02-27 19:17:50 +01:00
parent 4be8e91508
commit 3d679732a8
2 changed files with 23 additions and 3 deletions

View File

@@ -364,9 +364,11 @@ class OrderController extends mfBaseController {
// TODO: filter by network permissions
$this->layout()->setTemplate("Order/Form");
$products = [];
if($this->me->is("Admin")) {
//$this->layout()->set("addresses", AddressModel::search(['parents_only' => 1]));
$this->layout()->set("products", ProductModel::getActive());
//$this->layout()->set("products", ProductModel::getActive());
$products = ProductModel::getActive();
$this->layout()->set("terminations", TerminationModel::getAll());
} else {
// get all salespartner addresses of my networks
@@ -397,13 +399,24 @@ class OrderController extends mfBaseController {
$products = [];
foreach(ProductNetworkModel::search(["network_id" => $network_ids]) as $pn) {
if(!$pn->product->active) continue;
if(!array_key_exists($pn->product_id, $products))
if(!array_key_exists($pn->product_id, $products)) {
$products[$pn->product_id] = $pn->product;
}
}
$this->layout()->set("products", $products);
}
$order = $this->layout()->get("order");
if($order) {
foreach($order->products as $op) {
if(!$op->product->active) {
$products[$op->product_id] = $op->product;
}
}
}
$this->layout()->set("products", $products);
if($this->request->filter) {
$this->layout()->set("filter", $this->request->filter);
}