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

@@ -148,10 +148,10 @@
</div>
<ul class="nav nav-tabs ml-1 border-0" role="tablist">
<li class="nav-item" role="presentation">
<li class="nav-item">
<a class="nav-link <?=(!$showLonelies) ? "active" : ""?>" href="<?=self::getUrl("Order", "Index", ["filter" => $filter])?>">Bestellungen mit Anschluss<?php if(is_array($lonelyOrders)): ?> <span class="counter"><?=$pagination['maxItems']?></span><?php endif; ?></a>
</li>
<li class="nav-item" role="presentation">
<li class="nav-item">
<a class="nav-link <?=($showLonelies) ? "active" : ""?>" href="<?=self::getUrl("Order", "Index", ["noTermProducts" => 1, "filter" => $filter])?>">
<?php if(is_array($lonelyOrders)): ?>
Bestellungen ohne Anschluss <span class="counter"><?=count($lonelyOrders)?></span>
@@ -160,9 +160,31 @@
<?php endif; ?>
</a>
</li>
<li class="nav-item">
<a class="nav-link <?=($showVoice) ? "active" : ""?>" href="<?=self::getUrl("Order", "Index", ["voiceProductsOnly" => 1, "filter" => $filter])?>">
<?php if(is_array($voice_orders)): ?>
Nur Voice <span class="counter"><?=count($voice_orders)?></span>
<?php else: ?>
Nur Voice
<?php endif; ?>
</a>
</li>
<li class="nav-item">
<a class="nav-link <?=($showSpecial) ? "active" : ""?>" href="<?=self::getUrl("Order", "Index", ["specialProductsOnly" => 1, "filter" => $filter])?>">
<?php if(is_array($special_orders)): ?>
Nur Spezialprodukte <span class="counter"><?=count($special_orders)?></span>
<?php else: ?>
Nur Spezialprodukte
<?php endif; ?>
</a>
</li>
</ul>
<?php if($showLonelies): ?>
<?php if($showSpecial) $lonelyOrders = $special_orders ?>
<?php if($showVoice) $lonelyOrders = $voice_orders ?>
<?php if($showLonelies || $showSpecial || $showVoice): ?>
<div class="card">
<div class="card-body mb-3">
@@ -180,6 +202,9 @@
<th></th>
</tr>
<?php $order_count = 0; ?>
<?php foreach($lonelyOrders as $order): ?>
<tr class="order-list-tr pb-0 <?=($order_count % 2 == 0) ? "table-bg-even" : ""?>" id="order-<?=$order->id?>">
<td onclick="toggleOrder(<?=$order->id?>)">

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);
}