Added Prepatching
This commit is contained in:
@@ -78,10 +78,20 @@ class PatchingController extends mfBaseController {
|
||||
}
|
||||
|
||||
//var_dump($terms_search);exit;
|
||||
$pagination['maxItems'] = PatchingModel::searchByTerminationCount($terms_search);
|
||||
foreach(PatchingModel::searchByTermination($terms_search, $pagination) as $t) {
|
||||
if(!array_key_exists($t->id, $terms)) {
|
||||
$terms[$t->id] = $t;
|
||||
|
||||
if($filter["prepatched"]) {
|
||||
$pagination['maxItems'] = PatchingModel::searchByEnabledPatchingCount($terms_search);
|
||||
foreach(PatchingModel::searchByEnabledPatching($terms_search, $pagination) as $t) {
|
||||
if(!array_key_exists($t->id, $terms)) {
|
||||
$terms[$t->id] = $t;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$pagination['maxItems'] = PatchingModel::searchByFinishedLineworkCount($terms_search);
|
||||
foreach(PatchingModel::searchByFinishedLinework($terms_search, $pagination) as $t) {
|
||||
if(!array_key_exists($t->id, $terms)) {
|
||||
$terms[$t->id] = $t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,16 +127,15 @@ class PatchingController extends mfBaseController {
|
||||
if($filter["patched"] == "1") {
|
||||
$new_filter["patched"] = true;
|
||||
$new_filter["hide_delayed_finish"] = false;
|
||||
} else {
|
||||
} elseif ($filter["patched"] == "2") {
|
||||
$new_filter["patched"] = false;
|
||||
$new_filter["prepatched"] = true;
|
||||
}
|
||||
unset($filter["patched"]);
|
||||
} else {
|
||||
$new_filter["patched"] = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
foreach($filter as $name => $value) {
|
||||
$new_filter[$name] = $value;
|
||||
}
|
||||
|
||||
@@ -122,12 +122,12 @@ class PatchingModel {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function searchByTerminationCount($filter = false) {
|
||||
public static function searchByFinishedLineworkCount($filter = false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getTerminationSqlFilter($filter);
|
||||
|
||||
|
||||
$sql = "SELECT COUNT(Termination.id) as cnt FROM `Order`
|
||||
LEFT JOIN OrderProduct ON (OrderProduct.order_id = `Order`.id)
|
||||
LEFT JOIN Product ON (Product.id = OrderProduct.product_id)
|
||||
@@ -152,16 +152,15 @@ class PatchingModel {
|
||||
return $data->cnt;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function searchByTermination($filter = false, $limit = false) {
|
||||
public static function searchByFinishedLinework($filter = false, $limit = false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getTerminationSqlFilter($filter);
|
||||
|
||||
// TEMP: vorpatchen
|
||||
$sql = "SELECT Termination.id as termination_id FROM `Order`
|
||||
LEFT JOIN OrderProduct ON (OrderProduct.order_id = `Order`.id)
|
||||
LEFT JOIN Product ON (Product.id = OrderProduct.product_id)
|
||||
@@ -197,6 +196,83 @@ class PatchingModel {
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
public static function searchByEnabledPatchingCount($filter = false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getTerminationSqlFilter($filter);
|
||||
|
||||
$sql = "SELECT COUNT(Termination.id) as cnt FROM `Order`
|
||||
LEFT JOIN OrderProduct ON (OrderProduct.order_id = `Order`.id)
|
||||
LEFT JOIN Product ON (Product.id = OrderProduct.product_id)
|
||||
LEFT JOIN Termination ON (Termination.id = OrderProduct.termination_id)
|
||||
LEFT JOIN Terminationstatus ON (Terminationstatus.id = Termination.status_id)
|
||||
LEFT JOIN Building ON (Building.id = Termination.building_id)
|
||||
LEFT JOIN Buildingstatus ON (Buildingstatus.id = Building.status_id)
|
||||
LEFT JOIN Patching ON (Patching.Termination_id = OrderProduct.termination_id)
|
||||
LEFT JOIN Workflowitem ON (Workflowitem.object_type = 'Termination')
|
||||
LEFT JOIN Workflowvalue ON (Workflowvalue.item_id = Workflowitem.id)
|
||||
WHERE Termination.patching_enabled = 1
|
||||
AND Workflowitem.name = 'customer_passive_finished'
|
||||
AND Workflowvalue.object_id = OrderProduct.termination_id
|
||||
AND Workflowvalue.value_int <> 1
|
||||
AND $where";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function searchByEnabledPatching($filter = false, $limit = false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getTerminationSqlFilter($filter);
|
||||
// TEMP: vorpatchen
|
||||
$sql = "SELECT Termination.id as termination_id FROM `Order`
|
||||
LEFT JOIN OrderProduct ON (OrderProduct.order_id = `Order`.id)
|
||||
LEFT JOIN Product ON (Product.id = OrderProduct.product_id)
|
||||
LEFT JOIN Termination ON (Termination.id = OrderProduct.termination_id)
|
||||
LEFT JOIN Terminationstatus ON (Terminationstatus.id = Termination.status_id)
|
||||
LEFT JOIN Building ON (Building.id = Termination.building_id)
|
||||
LEFT JOIN Buildingstatus ON (Buildingstatus.id = Building.status_id)
|
||||
LEFT JOIN Patching ON (Patching.Termination_id = OrderProduct.termination_id)
|
||||
LEFT JOIN Workflowitem ON (Workflowitem.object_type = 'Termination')
|
||||
LEFT JOIN Workflowvalue ON (Workflowvalue.item_id = Workflowitem.id)
|
||||
WHERE Termination.patching_enabled = 1
|
||||
AND Workflowitem.name = 'customer_passive_finished'
|
||||
AND Workflowvalue.object_id = OrderProduct.termination_id
|
||||
AND Workflowvalue.value_int <> 1
|
||||
AND $where
|
||||
GROUP BY Termination.id
|
||||
ORDER BY Termination.id ASC";
|
||||
|
||||
// AND (Patching.patched IS NULL OR Patching.patched = 0)
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
} elseif(is_numeric($count)) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Termination($data->termination_id);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user