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"]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,14 +70,14 @@ class ConstructionConsentHistory extends mfBaseModel {
|
||||
return "Nutzung Schacht/Verteiler/Abschluss";
|
||||
case "usage_owner":
|
||||
return "Nutzung Eigenvers. GE";
|
||||
|
||||
case "approve_override":
|
||||
return "Genehmigung überschreiben";
|
||||
case "rimo_plan":
|
||||
return "Plan/Skizze aus Rimo";
|
||||
case "plan_upload":
|
||||
return "Plan/Skizze Upload";
|
||||
case "constructionconsentproject_id":
|
||||
return "Projekt";
|
||||
|
||||
case "inspection_planner":
|
||||
return "Status Begehung mit Planer";
|
||||
case "inspection_electrician";
|
||||
|
||||
@@ -20,14 +20,16 @@ class ConstructionConsentOwnerController extends mfBaseController
|
||||
|
||||
protected function uploadDocumentAction() {
|
||||
$owner_id = $this->request->owner_id;
|
||||
$filename = trim($this->request->name);
|
||||
|
||||
$owner = new ConstructionConsentOwner($owner_id);
|
||||
if(!$owner->id) {
|
||||
$this->layout()->setFlash("Besitzer nicht gefunden!", "error");
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
$constructionConsent = new ConstructionConsent($owner->constructionconsent_id);
|
||||
$filename = "ZU_KG" . $constructionConsent->kg . "_EZ" . $constructionConsent->ez . "_GST" . $constructionConsent->gst . "_" . $constructionConsent->name . "_" . $owner->lastname . ".pdf";
|
||||
$_FILES['consentOwnerUpload']['name'] = $filename;
|
||||
|
||||
if(is_array($_FILES) && array_key_exists("consentOwnerUpload", $_FILES) && !$_FILES['consentOwnerUpload']['error']) {
|
||||
try {
|
||||
// returns File object or throws Exception on error
|
||||
@@ -221,4 +223,23 @@ class ConstructionConsentOwnerController extends mfBaseController
|
||||
return ["message" => "Result saved successfully", "update" => ["id" => $owner->id, "result" => $owner->result, "result_text" => __($owner->result, "consent")]];
|
||||
|
||||
}
|
||||
|
||||
protected function searchOwnerAction() {
|
||||
$search = $this->request->search;
|
||||
|
||||
$results = PreorderModel::search(['add-where' => " AND firstname LIKE '%$search%' OR lastname LIKE '%$search%'"]);
|
||||
self::returnJson(array_map(function($result) {
|
||||
return [
|
||||
'id' => $result->id,
|
||||
'firstname' => $result->firstname,
|
||||
'lastname' => $result->lastname,
|
||||
'street' => $result->street,
|
||||
'zip' => $result->zip,
|
||||
'city' => $result->city,
|
||||
'phone' => $result->phone,
|
||||
'email' => $result->email,
|
||||
'text' => $result->firstname . " " . $result->lastname . " (" . $result->street . ", " . $result->zip . " " . $result->city . ") [" . $result->phone . " | " . $result->email . "]"
|
||||
];
|
||||
}, $results));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user