New order categories (voice, special)

This commit is contained in:
Frank Schubert
2022-06-14 14:30:23 +02:00
parent fd8049dc28
commit 40598c15c4
2 changed files with 74 additions and 6 deletions

View File

@@ -135,9 +135,17 @@ class OrderController extends mfBaseController {
$showLoneliesCount = true;
}
if($this->request->voiceProductsOnly) {
$showLoneliesCount = true;
$this->layout()->set("showVoice", true);
}
if($this->request->specialProductsOnly) {
$showLoneliesCount = true;
$this->layout()->set("showSpecial", true);
}
if($showLonelies || $showLoneliesCount) {
$userIds = $this->me->getAddressOrParent()->getUserIds();
//var_dump($userIds);exit;
if(!array_key_exists("network_linked_status", $order_search)) {
$lonelyOrders = [];
unset($order_search["network_id"]);
@@ -146,6 +154,7 @@ class OrderController extends mfBaseController {
if($this->me->isAdmin()) {
if(!$this->request->filter['network_id']) {
$lonelies = OrderModel::search($order_search);
}
} else {
$order_search['create_by'] = $userIds;
@@ -157,9 +166,10 @@ class OrderController extends mfBaseController {
$lonelyOrders[$order->id] = $order;
}
}
//var_dump($lonelyOrders);exit;
}
// orders with termination product not requiring termination_id
$order_search['product_id'] = ">0";
$order_search['termination_id'] = null;
@@ -171,7 +181,38 @@ class OrderController extends mfBaseController {
$order_search['create_by'] = $userIds;
$lonelies = OrderModel::search($order_search);
}
$special_orders = [];
$voice_orders = [];
foreach($lonelies as $order) {
// check for voice or special products only
$this->log->debug("Order id ".$order->id);
/*if($order->id == 38) {
var_dump($order);
exit;
}*/
$has_bras = false;
$has_voice = false;
foreach($order->products as $lop) {
if(array_key_exists("bras_type", $lop->product->attributes) && $lop->product->attributes['bras_type']) {
$has_bras = true;
}
if(array_key_exists("voip_chan", $lop->product->attributes) && $lop->product->attributes['voip_chan']) {
$has_voice = true;
}
}
if(!$has_bras && !$has_voice) {
$special_orders[] = $order;
continue;
}
if($has_voice && !$has_bras) {
$voice_orders[] = $order;
continue;
}
// check for termination
if(!array_key_exists($order->id, $orders)) {
$o = new Order($order->id);
$add = true;
@@ -198,6 +239,8 @@ class OrderController extends mfBaseController {
}
$this->layout()->set("lonelyOrders", $lonelyOrders);
$this->layout()->set("special_orders", $special_orders);
$this->layout()->set("voice_orders", $voice_orders);
}