Added Prepatching
This commit is contained in:
@@ -54,8 +54,9 @@
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_patched">Patchstatus</label>
|
||||
<select name="filter[patched]" id="filter_patched" class="form-control">
|
||||
<option value="0" <?=($filter['patched'] != 0) ? "selected='selected'" : ""?>>Nicht gepatched</option>
|
||||
<option value="0" <?=($filter['patched'] < 1) ? "selected='selected'" : ""?>>Nicht gepatched</option>
|
||||
<option value="1" <?=($filter['patched'] == 1) ? "selected='selected'" : ""?>>Gepatched</option>
|
||||
<option value="2" <?=($filter['patched'] == 2) ? "selected='selected'" : ""?>>Vorpatchen</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -323,6 +323,28 @@ class LineworkController extends mfBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump(strlen($termination->workflowitems['pop_id']->value->value_string));exit;
|
||||
|
||||
// set patching enabled for termination
|
||||
if(
|
||||
(strlen($termination->workflowitems['pop_id']->value->value_string) || strlen($termination->workflowitems['ist_pop_id']->value->value_string)) &&
|
||||
(strlen($termination->workflowitems['schrank']->value->value_string) || strlen($termination->workflowitems['ist_schrank']->value->value_string)) &&
|
||||
(strlen($termination->workflowitems['baugruppe']->value->value_string) || strlen($termination->workflowitems['ist_baugruppe']->value->value_string)) &&
|
||||
(strlen($termination->workflowitems['modul']->value->value_string) || strlen($termination->workflowitems['ist_modul']->value->value_string)) &&
|
||||
(strlen($termination->workflowitems['ports']->value->value_string) || strlen($termination->workflowitems['ist_ports']->value->value_string))
|
||||
) {
|
||||
$this->log->debug("Linework::save: All items needed for patching set");
|
||||
if($termination->patching_enabled != 1) {
|
||||
$termination->patching_enabled = 1;
|
||||
$termination->save();
|
||||
}
|
||||
} else {
|
||||
$this->log->debug("Linework::save: Not all items needed for patching set");
|
||||
if($termination->patching_enabled == 1) {
|
||||
$termination->patching_enabled = 0;
|
||||
$termination->save();
|
||||
}
|
||||
}
|
||||
|
||||
// file upload
|
||||
//var_dump($_FILES);exit;
|
||||
|
||||
@@ -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