Fixed showing orders with not required termination

This commit is contained in:
Frank Schubert
2021-10-12 20:09:32 +02:00
parent 6d41583735
commit 77f5931995
2 changed files with 42 additions and 6 deletions

View File

@@ -101,8 +101,8 @@ class OrderController extends mfBaseController {
$lonelyOrders = [];
unset($order_search["network_id"]);
//$order_search['product_id'] = null;
// all orders without a product or with products without terminations
$order_search['product_id'] = null;
// orders without a product
if($this->me->isAdmin()) {
$lonelies = OrderModel::search($order_search);
} else {
@@ -114,7 +114,31 @@ class OrderController extends mfBaseController {
$lonelyOrders[$order->id] = $order;
}
}
// orders with termination product not requiring termination_id
$order_search['product_id'] = ">0";
$order_search['termination_id'] = null;
if($this->me->isAdmin()) {
$lonelies = OrderModel::search($order_search);
} else {
$order_search['create_by'] = $this->me->id;
$lonelies = OrderModel::search($order_search);
}
foreach($lonelies as $order) {
if(!array_key_exists($order->id, $orders)) {
$o = new Order($order->id);
foreach($o->products as $p) {
//var_dump($p->product->attributes);exit;
if(array_key_exists(TT_ATTRIB_TERMINATION_REQUIRED_NAME, $p->product->attributes)) {
$this->log->debug("found additional order wher termination_required 0");
$lonelyOrders[$order->id] = $order;
break;
}
}
//$lonelyOrders[$order->id] = $order;
}
}
$this->layout()->set("orders", $orders);

View File

@@ -256,8 +256,20 @@ class OrderModel {
if(array_key_exists("product_id", $filter)) {
$product_id = $filter['product_id'];
if(is_numeric($product_id)) {
$where .= " AND OrderProduct.product_id=$product_id";
if($product_id) {
if(in_array(substr($filter['product_id'], 0, 2), ["<=", ">="])) {
$op = substr($filter['product_id'], 0, 2);
$product_id = substr($filter['product_id'], 2);
} elseif(in_array(substr($filter['product_id'], 0, 1), ["<", ">"])) {
$op = substr($filter['product_id'], 0, 1);
$product_id = substr($filter['product_id'], 1);
} else {
$op = "=";
$product_id = $filter['product_id'];
}
if(is_numeric($product_id)) {
$where .= " AND OrderProduct.product_id $op $product_id";
}
} elseif($product_id === null) {
$where .= " AND OrderProduct.product_id IS NULL";
}
@@ -313,7 +325,7 @@ class OrderModel {
$where .= " AND Building.street LIKE '%$street%'";
}
}
var_dump($filter['building_status_code']);
//var_dump($filter['building_status_code']);
if(array_key_exists("building_status_code", $filter)) {
if(in_array(substr($filter['building_status_code'], 0, 2), ["<=", ">="])) {
$op = substr($filter['building_status_code'], 0, 2);