feat: Handle status 20 as cancelled
Treat orders with status 20 as effectively cancelled. This change ensures that these orders are excluded from active workflows and views: - Prevent workorder creation. - Hide from the default order view and overview counts. - Orders remain findable only via filtering.
This commit is contained in:
@@ -521,8 +521,12 @@
|
||||
</table>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php else: ?>
|
||||
<?php elseif($preorder->status->code != "20"): ?>
|
||||
<button type="button" class="btn btn-outline-primary create-workorder" onclick="createWorkorder(<?=$preorder->id?>)"><i class="fas fa-fw fa-plus"></i> <i class="fas fa-r"></i><i class="fas fa-fw fa-gears"></i> Wokorder erstellen</button>
|
||||
<?php elseif($preorder->status->code == "20"): ?>
|
||||
<div class="alert alert-info mt-2" role="alert">
|
||||
<i class="fas fa-info-circle"></i> Diese Preorder ist auf Hold gesetzt. Es kann keine Workorder erstellt werden.
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
@@ -542,8 +546,10 @@
|
||||
<td class="text-monospace"><?=$preorder->adb_wohneinheit->ftu_data["id"]?>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h3>FCP</h3>
|
||||
<div class="col row">
|
||||
<h3 >FCP</h3>
|
||||
<?php
|
||||
if($preorder->fcp): ?>
|
||||
<table class="table table-sm table-striped">
|
||||
@@ -566,9 +572,12 @@
|
||||
</tr>
|
||||
</table>
|
||||
<?php else: ?>
|
||||
<p>Kein FCP zugewiesen</p>
|
||||
<div class="col-12 p-0">
|
||||
<div class="alert alert-info mt-2" role="alert">
|
||||
<i class="fas fa-info-circle"></i> Kein FCP zugewiesen/importert.
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ class PreorderModel
|
||||
LEFT JOIN `" . FRONKDB_DBNAME . "`.Preorderstatus tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id)
|
||||
LEFT JOIN `" . ADDRESSDB_DBNAME . "`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
LEFT JOIN `" . ADDRESSDB_DBNAME . "`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_wohneinheit_id = adb_wohneinheit.id)
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name, MAX(rimo_team_name) as rimo_team_name, MAX(rimo_team_id) as rimo_team_id FROM `" . FRONKDB_DBNAME . "`.RimoWorkorder WHERE rimo_status NOT IN ('deleted') GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name, MAX(rimo_team_name) as rimo_team_name, MAX(rimo_team_id) as rimo_team_id FROM `" . FRONKDB_DBNAME . "`.RimoWorkorder WHERE rimo_status NOT IN ('deleted', 'cancelled') GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id
|
||||
WHERE $where
|
||||
ORDER BY $orderBy
|
||||
LIMIT 1";
|
||||
@@ -305,7 +305,7 @@ class PreorderModel
|
||||
LEFT JOIN `" . FRONKDB_DBNAME . "`.Preorderstatus tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id)
|
||||
LEFT JOIN `" . ADDRESSDB_DBNAME . "`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
LEFT JOIN `" . ADDRESSDB_DBNAME . "`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_wohneinheit_id = adb_wohneinheit.id)
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name, MAX(rimo_team_name) as rimo_team_name, MAX(rimo_team_id) as rimo_team_id FROM `" . FRONKDB_DBNAME . "`.RimoWorkorder WHERE rimo_status NOT IN ('deleted') GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name, MAX(rimo_team_name) as rimo_team_name, MAX(rimo_team_id) as rimo_team_id FROM `" . FRONKDB_DBNAME . "`.RimoWorkorder WHERE rimo_status NOT IN ('deleted', 'cancelled') GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id
|
||||
LEFT JOIN Preorderlogistics ON (Preorderlogistics.preorder_id = tt_preorder.id)
|
||||
WHERE $where
|
||||
";
|
||||
@@ -331,7 +331,7 @@ class PreorderModel
|
||||
LEFT JOIN `" . FRONKDB_DBNAME . "`.Preorderstatus tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id)
|
||||
LEFT JOIN `" . ADDRESSDB_DBNAME . "`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
LEFT JOIN `" . ADDRESSDB_DBNAME . "`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_wohneinheit_id = adb_wohneinheit.id)
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name, MAX(rimo_team_name) as rimo_team_name, MAX(rimo_team_id) as rimo_team_id FROM `" . FRONKDB_DBNAME . "`.RimoWorkorder WHERE rimo_status NOT IN ('deleted') GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name, MAX(rimo_team_name) as rimo_team_name, MAX(rimo_team_id) as rimo_team_id FROM `" . FRONKDB_DBNAME . "`.RimoWorkorder WHERE rimo_status NOT IN ('deleted', 'cancelled') GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id
|
||||
LEFT JOIN Preorderlogistics ON (Preorderlogistics.preorder_id = tt_preorder.id)
|
||||
WHERE $where
|
||||
ORDER BY lastname, firstname
|
||||
@@ -385,7 +385,7 @@ class PreorderModel
|
||||
LEFT JOIN `" . FRONKDB_DBNAME . "`.Preorderstatus as tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id)
|
||||
LEFT JOIN `" . ADDRESSDB_DBNAME . "`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
LEFT JOIN `" . ADDRESSDB_DBNAME . "`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_wohneinheit_id = adb_wohneinheit.id)
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name, MAX(rimo_team_name) as rimo_team_name, MAX(rimo_team_id) as rimo_team_id FROM `" . FRONKDB_DBNAME . "`.RimoWorkorder WHERE rimo_status NOT IN ('deleted') GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id,
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name, MAX(rimo_team_name) as rimo_team_name, MAX(rimo_team_id) as rimo_team_id FROM `" . FRONKDB_DBNAME . "`.RimoWorkorder WHERE rimo_status NOT IN ('deleted', 'cancelled') GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id,
|
||||
JSON_TABLE(tt_preorder.addon_services,
|
||||
'$[*]' COLUMNS (
|
||||
ordered VARCHAR(64) PATH '$.ordered'
|
||||
@@ -426,7 +426,7 @@ class PreorderModel
|
||||
LEFT JOIN `" . FRONKDB_DBNAME . "`.Preorderstatus as tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id)
|
||||
LEFT JOIN `" . ADDRESSDB_DBNAME . "`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
LEFT JOIN `" . ADDRESSDB_DBNAME . "`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_wohneinheit_id = adb_wohneinheit.id)
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name, MAX(rimo_team_name) as rimo_team_name, MAX(rimo_team_id) as rimo_team_id FROM `" . FRONKDB_DBNAME . "`.RimoWorkorder WHERE rimo_status NOT IN ('deleted') GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id,
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name, MAX(rimo_team_name) as rimo_team_name, MAX(rimo_team_id) as rimo_team_id FROM `" . FRONKDB_DBNAME . "`.RimoWorkorder WHERE rimo_status NOT IN ('deleted', 'cancelled') GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id,
|
||||
JSON_TABLE(tt_preorder.addon_services,
|
||||
'$[*]' COLUMNS (
|
||||
ordered VARCHAR(64) PATH '$.ordered'
|
||||
@@ -469,6 +469,7 @@ class PreorderModel
|
||||
if (!array_key_exists("<status_code", $filter) && !array_key_exists(">status_code", $filter) && !array_key_exists("status_code", $filter)
|
||||
&& !array_key_exists("<status_id", $filter) && !array_key_exists(">status_id", $filter) && !array_key_exists("status_id", $filter)) {
|
||||
$filter["<status_code"] = 899;
|
||||
$filter["!status_code"] = 20;
|
||||
}
|
||||
return self::count($filter);
|
||||
}
|
||||
@@ -484,6 +485,7 @@ class PreorderModel
|
||||
if (!array_key_exists("<status_code", $filter) && !array_key_exists(">status_code", $filter) && !array_key_exists("status_code", $filter)
|
||||
&& !array_key_exists("<status_id", $filter) && !array_key_exists(">status_id", $filter) && !array_key_exists("status_id", $filter)) {
|
||||
$filter["<status_code"] = 899;
|
||||
$filter["!status_code"] = 20;
|
||||
}
|
||||
|
||||
return self::search($filter, $limit, $returnDBRessource, $returnArray);
|
||||
@@ -498,7 +500,7 @@ class PreorderModel
|
||||
LEFT JOIN `" . FRONKDB_DBNAME . "`.Preorderstatus tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id)
|
||||
LEFT JOIN `" . ADDRESSDB_DBNAME . "`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
LEFT JOIN `" . ADDRESSDB_DBNAME . "`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_wohneinheit_id = adb_wohneinheit.id)
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name, MAX(rimo_team_name) as rimo_team_name, MAX(rimo_team_id) as rimo_team_id FROM `" . FRONKDB_DBNAME . "`.RimoWorkorder WHERE rimo_status NOT IN ('deleted') GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name, MAX(rimo_team_name) as rimo_team_name, MAX(rimo_team_id) as rimo_team_id FROM `" . FRONKDB_DBNAME . "`.RimoWorkorder WHERE rimo_status NOT IN ('deleted', 'cancelled') GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id
|
||||
WHERE $where
|
||||
";
|
||||
|
||||
@@ -525,7 +527,7 @@ class PreorderModel
|
||||
LEFT JOIN `" . ADDRESSDB_DBNAME . "`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
LEFT JOIN `" . ADDRESSDB_DBNAME . "`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_wohneinheit_id = adb_wohneinheit.id)
|
||||
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name, MAX(rimo_team_name) as rimo_team_name, MAX(rimo_team_id) as rimo_team_id FROM `" . FRONKDB_DBNAME . "`.RimoWorkorder WHERE rimo_status NOT IN ('deleted') GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name, MAX(rimo_team_name) as rimo_team_name, MAX(rimo_team_id) as rimo_team_id FROM `" . FRONKDB_DBNAME . "`.RimoWorkorder WHERE rimo_status NOT IN ('deleted', 'cancelled') GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id
|
||||
WHERE $where
|
||||
ORDER BY lastname, firstname
|
||||
";
|
||||
@@ -542,7 +544,9 @@ class PreorderModel
|
||||
$sql .= " LIMIT " . $limit['count'];
|
||||
}
|
||||
}
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
|
||||
@@ -706,6 +710,15 @@ class PreorderModel
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists("!status_code", $filter)) {
|
||||
$status_code = $filter['!status_code'];
|
||||
if (is_numeric($status_code)) {
|
||||
$where .= " AND tt_preorderstatus.code != $status_code";
|
||||
} elseif (is_array($status_code)) {
|
||||
$where .= " AND tt_preorderstatus.code NOT IN (" . implode(",", $status_code) . ")";
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists("<=status_code", $filter)) {
|
||||
$status_code = $filter['<=status_code'];
|
||||
if (is_numeric($status_code)) {
|
||||
@@ -727,7 +740,7 @@ class PreorderModel
|
||||
$where .= " AND tt_preorder.borderpoint_status='$borderpoint_status'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (array_key_exists("preordercampaign_id", $filter)) {
|
||||
$preordercampaign_id = $filter['preordercampaign_id'];
|
||||
@@ -924,16 +937,10 @@ class PreorderModel
|
||||
|
||||
if (array_key_exists("rimo_workorder_status", $filter)) {
|
||||
$rimo_workorder_status = $filter['rimo_workorder_status'];
|
||||
|
||||
if (is_array($rimo_workorder_status) && count($rimo_workorder_status)) {
|
||||
$rimo_workorder_status = array_map(function ($value) {
|
||||
return FronkDB::singleton()->escape($value);
|
||||
}, $filter['rimo_workorder_status']);
|
||||
|
||||
if (is_array($rimo_workorder_status) && in_array('Canceled', $rimo_workorder_status) && !in_array('Cancelled', $rimo_workorder_status)) {
|
||||
$rimo_workorder_status = array_merge($rimo_workorder_status, ['Cancelled']);
|
||||
}
|
||||
|
||||
$where .= " AND workorder.rimo_status IN ('" . implode("','", $rimo_workorder_status) . "')";
|
||||
} else if ($rimo_workorder_status) {
|
||||
$rimo_workorder_status = FronkDB::singleton()->escape($rimo_workorder_status);
|
||||
@@ -1198,7 +1205,7 @@ class PreorderModel
|
||||
`".FRONKDB_DBNAME."`.Preorder p
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.Hausnummer h ON p.adb_hausnummer_id = h.id
|
||||
LEFT JOIN `".FRONKDB_DBNAME."`.Preorderstatus tt_preorderstatus ON p.status_id = tt_preorderstatus.id
|
||||
WHERE p.deleted = 0 AND tt_preorderstatus.code < 899";
|
||||
WHERE p.deleted = 0 AND tt_preorderstatus.code NOT IN (20) AND tt_preorderstatus.code < 899" . $where;
|
||||
|
||||
$queryStart = microtime(true);
|
||||
$res = $db->query($sql . $where);
|
||||
@@ -1268,9 +1275,9 @@ class PreorderModel
|
||||
}
|
||||
|
||||
public static function countHistoryStatus($filter = [], $status_code = null) {
|
||||
if ($status_code === null) {
|
||||
die("Please select a status code");
|
||||
}
|
||||
if ($status_code === null) {
|
||||
die("Please select a status code");
|
||||
}
|
||||
|
||||
if (!is_array($filter)) return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user