added new features

This commit is contained in:
Luca Haid
2025-03-25 13:49:16 +01:00
parent c94d7de181
commit af6a4e02f5
7 changed files with 199 additions and 33 deletions

View File

@@ -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));
}
}