added new features
This commit is contained in:
@@ -386,22 +386,46 @@ class ConstructionConsent extends mfBaseModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT
|
||||
ConstructionConsent.*,
|
||||
COALESCE(SUM(cwo.result = 'denied'), 0) AS denied_count,
|
||||
COALESCE(SUM(cwo.result = 'unresolvable'), 0) AS unresolvable_count,
|
||||
COALESCE(SUM(cwo.result = 'moved'), 0) AS moved_count,
|
||||
COALESCE(SUM(cwo.result = 'accepted'), 0) AS accepted_count,
|
||||
COUNT(cwo.id) AS total_owners,
|
||||
CASE
|
||||
WHEN COALESCE(SUM(cwo.result = 'denied'), 0) > 0 THEN 'red'
|
||||
WHEN COALESCE(SUM(cwo.result = 'unresolvable'), 0) > 0
|
||||
OR COALESCE(SUM(cwo.result = 'moved'), 0) > 0 THEN 'yellow'
|
||||
WHEN COALESCE(SUM(cwo.result = 'accepted'), 0) = COUNT(cwo.id)
|
||||
AND COUNT(cwo.id) > 0 THEN 'green'
|
||||
ELSE 'blue'
|
||||
END AS status_light
|
||||
FROM ConstructionConsent
|
||||
$sql = "SELECT ConstructionConsent.*,
|
||||
COALESCE(SUM(CASE
|
||||
WHEN ConstructionConsent.approve_override = 1 THEN 0
|
||||
ELSE (cwo.result = 'denied')
|
||||
END), 0) AS denied_count,
|
||||
COALESCE(SUM(CASE
|
||||
WHEN ConstructionConsent.approve_override = 1 THEN 0
|
||||
ELSE (cwo.result = 'unresolvable')
|
||||
END), 0) AS unresolvable_count,
|
||||
COALESCE(SUM(CASE
|
||||
WHEN ConstructionConsent.approve_override = 1 THEN 0
|
||||
ELSE (cwo.result = 'moved')
|
||||
END), 0) AS moved_count,
|
||||
COALESCE(SUM(CASE
|
||||
WHEN ConstructionConsent.approve_override = 1 THEN 1
|
||||
ELSE (cwo.result = 'accepted')
|
||||
END), 0) AS accepted_count,
|
||||
COUNT(cwo.id) AS total_owners,
|
||||
CASE
|
||||
WHEN ConstructionConsent.approve_override = 1 THEN 'green'
|
||||
WHEN COALESCE(SUM(CASE
|
||||
WHEN approve_override = 1 THEN 0
|
||||
ELSE (cwo.result = 'denied')
|
||||
END), 0) > 0 THEN 'red'
|
||||
WHEN COALESCE(SUM(CASE
|
||||
WHEN approve_override = 1 THEN 0
|
||||
ELSE (cwo.result = 'unresolvable')
|
||||
END), 0) > 0
|
||||
OR COALESCE(SUM(CASE
|
||||
WHEN approve_override = 1 THEN 0
|
||||
ELSE (cwo.result = 'moved')
|
||||
END), 0) > 0 THEN 'yellow'
|
||||
WHEN COALESCE(SUM(CASE
|
||||
WHEN approve_override = 1 THEN 1
|
||||
ELSE (cwo.result = 'accepted')
|
||||
END), 0) = COUNT(cwo.id)
|
||||
AND COUNT(cwo.id) > 0 THEN 'green'
|
||||
ELSE 'blue'
|
||||
END AS status_light
|
||||
FROM ConstructionConsent
|
||||
LEFT JOIN ConstructionConsentOwner cwo ON ConstructionConsent.id = cwo.constructionconsent_id
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer vh ON ConstructionConsent.adb_hausnummer_id = vh.hausnummer_id
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.Strasse vs ON ConstructionConsent.adb_strasse_id = vs.id
|
||||
|
||||
@@ -111,6 +111,7 @@ class ConstructionConsentController extends mfBaseController {
|
||||
|
||||
protected function viewAction() : void {
|
||||
$this->layout()->setTemplate("ConstructionConsent/View");
|
||||
$this->layout()->set("is_admin", $this->me->isAdmin());
|
||||
|
||||
$id = $this->request->id;
|
||||
if(!is_numeric($id) || $id < 1) {
|
||||
@@ -1027,4 +1028,20 @@ class ConstructionConsentController extends mfBaseController {
|
||||
"status_light_green" => getFilteredCount("status_light", "green", $baseFilter)
|
||||
];
|
||||
}
|
||||
|
||||
protected function approveOverrideAction() {
|
||||
$consent_id = $this->request->consent_id;
|
||||
$checked = $this->request->checked;
|
||||
|
||||
$consent = new ConstructionConsent($consent_id);
|
||||
if(!$consent->id) {
|
||||
$this->returnJson(["status" => "error"]);
|
||||
}
|
||||
|
||||
$consent->update(["approve_override" => $checked]);
|
||||
$consent->save();
|
||||
|
||||
$this->returnJson(["status" => "OK"]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user