diff --git a/application/Order/OrderController.php b/application/Order/OrderController.php index 0eea90c44..f3356cb4c 100644 --- a/application/Order/OrderController.php +++ b/application/Order/OrderController.php @@ -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); diff --git a/application/Order/OrderModel.php b/application/Order/OrderModel.php index 21cfc37bd..9d2badc6a 100644 --- a/application/Order/OrderModel.php +++ b/application/Order/OrderModel.php @@ -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);