add Patching::Save

This commit is contained in:
Frank Schubert
2021-09-23 20:42:04 +02:00
parent d80cf387e6
commit ba1c96c3f5
4 changed files with 293 additions and 14 deletions

View File

@@ -83,6 +83,41 @@ class PatchingModel {
return null;
}
public static function searchByTerminationCount($filter = false) {
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT COUNT(Termination.id) as cnd 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 Building ON (Building.id = Termination.building_id)
LEFT JOIN Terminationstatus ON (Terminationstatus.id = Termination.status_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 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 LIMIT 1";
//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 searchByTermination($filter = false) {
$items = [];
$db = FronkDB::singleton();
@@ -102,11 +137,12 @@ class PatchingModel {
WHERE Workflowitem.name = 'customer_passive_finished'
AND Workflowvalue.object_id = OrderProduct.termination_id
AND Workflowvalue.value_int = 1
AND (Patching.termination_id IS NULL OR Patching.patched = 0)
AND $where
GROUP BY Termination.id
ORDER BY Termination.id ASC";
//mfLoghandler::singleton()->debug($sql);
// 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'])) {
@@ -155,7 +191,39 @@ class PatchingModel {
}
}
if(array_key_exists("patched", $filter)) {
$patched = $filter["patched"];
if($patched) {
$where .= " AND Patching.patched=1";
} else {
$where .= " AND (Patching.patched IS NULL OR Patching.patched = 0)";
}
} else {
$where .= " AND (Patching.patched IS NULL OR Patching.patched = 0)";
}
if(array_key_exists("network_id", $filter)) {
$network_id = $filter['network_id'];
if(is_numeric($network_id)) {
$where .= " AND Building.network_id=$network_id";
} elseif(is_array($network_id) && count($network_id)) {
$where .= " AND Building.network_id IN (". implode(",", $network_id).")";
}
}
if(array_key_exists("code", $filter)) {
$code = FronkDB::singleton()->escape($filter['code']);
if($code) {
$where .= " AND Building.`code` like '%$code%'";
}
}
if(array_key_exists("street", $filter)) {
$street = FronkDB::singleton()->escape($filter["street"]);
if($street) {
$where .= " AND Building.street like '%$street%'";
}
}
//var_dump($filter, $where);exit;
return $where;