diff --git a/Layout/default/Preorder/include/preorder-detail.php b/Layout/default/Preorder/include/preorder-detail.php index b89670c7f..6b8a53efa 100644 --- a/Layout/default/Preorder/include/preorder-detail.php +++ b/Layout/default/Preorder/include/preorder-detail.php @@ -313,21 +313,25 @@

Workorder

- - - - - - - - - - - - - - -
Nameadb_wohneinheit->rimo_workorder->rimo_name?>
External IDadb_wohneinheit->rimo_workorder->rimo_id?>
Statusadb_wohneinheit->rimo_workorder->rimo_status?>
Erstelltadb_wohneinheit->rimo_workorder->id) ? date("d.m.Y H:i:s", $preorder->adb_wohneinheit->rimo_workorder->create) : ""?>
+ adb_wohneinheit->rimo_workorder) && $preorder->adb_wohneinheit->rimo_workorder->id): ?> + Workorder löschen + + + + + + + + + + + + + + +
Nameadb_wohneinheit->rimo_workorder->rimo_name?>
External IDadb_wohneinheit->rimo_workorder->rimo_id?>
Statusadb_wohneinheit->rimo_workorder->rimo_status?>
Erstelltadb_wohneinheit->rimo_workorder)) ? date("d.m.Y H:i:s", $preorder->adb_wohneinheit->rimo_workorder->create) : ""?>
+ +
@@ -402,4 +406,29 @@ }, 'json'); } + + function deleteWorkorder(pid) { + console.log("in delete workorder"); + if(!Number.isInteger(pid) || pid < 1) { + return false; + } + + $.post("", + { + 'do': "deleteWorkorder", + id: pid, + }, + function(success) { + if(success.status == "OK") { + $("#preorder-detail-" + success.result.id + "-workorder td").each(function() { + $(this).html("--gelöscht--"); + }); + + $("#preorder-detail-" + success.result.id + "-workorder-del").remove(); + } + }, + 'json'); + + return false; + } \ No newline at end of file diff --git a/application/ADBWohneinheit/ADBWohneinheit.php b/application/ADBWohneinheit/ADBWohneinheit.php index 8fa0fcf93..c65271c64 100644 --- a/application/ADBWohneinheit/ADBWohneinheit.php +++ b/application/ADBWohneinheit/ADBWohneinheit.php @@ -168,7 +168,10 @@ class ADBWohneinheit extends mfBaseModel { } if($name == "rimo_workorder") { - $this->rimo_workorder = RimoWorkorderModel::getFirst(['adb_wohneinheit_id' => $this->id]); + $this->rimo_workorder = new RimoWorkorder(); + if($this->id) { + $this->rimo_workorder = RimoWorkorderModel::getFirst(['adb_wohneinheit_id' => $this->id]); + } return $this->rimo_workorder; } diff --git a/application/ADBWohneinheit/ADBWohneinheitModel.php b/application/ADBWohneinheit/ADBWohneinheitModel.php index 211ab60d2..e2eb033b7 100644 --- a/application/ADBWohneinheit/ADBWohneinheitModel.php +++ b/application/ADBWohneinheit/ADBWohneinheitModel.php @@ -54,7 +54,7 @@ class ADBWohneinheitModel { ORDER BY hausnummer_id,block,stiege,LENGTH(stock),stock,LENGTH(tuer),tuer,num LIMIT 1"; - mfLoghandler::singleton()->debug($sql); + //mfLoghandler::singleton()->debug($sql); $res = $db->query($sql); if($db->num_rows($res)) { $data = $db->fetch_object($res); @@ -96,7 +96,7 @@ class ADBWohneinheitModel { ) as tbl "; - mfLoghandler::singleton()->debug($sql); + //mfLoghandler::singleton()->debug($sql); $res = $db->query($sql); if($db->num_rows($res)) { $data = $db->fetch_object($res); diff --git a/application/OpenAccessId/OpenAccessIdModel.php b/application/OpenAccessId/OpenAccessIdModel.php index 1149c4b3e..fb170fba1 100644 --- a/application/OpenAccessId/OpenAccessIdModel.php +++ b/application/OpenAccessId/OpenAccessIdModel.php @@ -82,7 +82,7 @@ class OpenAccessIdModel { if(!$oaid) return null; $where = self::getSqlFilter(["oaid" => $oaid]); - mfLoghandler::singleton()->debug($where); + //mfLoghandler::singleton()->debug($where); $res = $db->select("OpenAccessId", "*", "$where ORDER BY id"); if($db->num_rows($res)) { $data = $db->fetch_object($res); diff --git a/application/Preorder/Preorder.php b/application/Preorder/Preorder.php index 8b06eb9f8..7ba96d362 100644 --- a/application/Preorder/Preorder.php +++ b/application/Preorder/Preorder.php @@ -359,7 +359,11 @@ class Preorder extends mfBaseModel { $a['cifurl'] = $this->cifurl; $a['oaid'] = $this->oaid; $a['extref'] = $this->extref; + $a['orderDate'] = ($this->order_date) ? date("Y-m-d",$this->order_date) : null; $a['status'] = $this->getProperty("status")->getApiArray(); + $a['ciftoken'] = ($this->ciftoken) ? $this->ciftoken : null; + $a['cifurl'] = ($this->cifurl) ? $this->cifurl : null; + $a['installationDate'] = ($this->installation_date) ? date("c", $this->installation_date) : null; $a['connectionType'] = $this->connection_type; $a['connectionCount'] = ($this->connection_count) ? (int)$this->connection_count : 1; $a['isAdditionalOrder'] = ($this->is_additional_order) ? true : false; diff --git a/application/Preorder/PreorderController.php b/application/Preorder/PreorderController.php index edb2c4640..09547595f 100644 --- a/application/Preorder/PreorderController.php +++ b/application/Preorder/PreorderController.php @@ -797,6 +797,9 @@ class PreorderController extends mfBaseController { case "updateStatus": $return = $this->updateStatusApi(); break; + case "deleteWorkorder": + $return = $this->deleteWorkorderApi(); + break; default: $return = false; } @@ -997,4 +1000,33 @@ class PreorderController extends mfBaseController { return ["message" => "Status saved successfully", "id" => $preorder_id, "update" => $update]; } + private function deleteWorkorderApi() { + if(!$this->me->is("Admin")) { + return false; + } + + $preorder_id = $this->request->id; + + if(!is_numeric($preorder_id) || $preorder_id < 1) { + return false; + } + + $preorder = new Preorder($preorder_id); + if(!$preorder->id) { + return false; + } + + if(!$preorder->adb_wohneinheit_id) { + return false; + } + + $workorder = RimoWorkorderModel::getFirst(["adb_wohneinheit_id" => $preorder->adb_wohneinheit_id]); + if(!$workorder) { + return false; + } + + $workorder->delete(); + return ["Message" => "Workorder deleted successfully", "id" => $preorder->id]; + } + } \ No newline at end of file diff --git a/application/RimoWorkorder/RimoWorkorderModel.php b/application/RimoWorkorder/RimoWorkorderModel.php index 3ab2ec151..4ed8ca453 100644 --- a/application/RimoWorkorder/RimoWorkorderModel.php +++ b/application/RimoWorkorder/RimoWorkorderModel.php @@ -54,7 +54,7 @@ class RimoWorkorderModel { $db = FronkDB::singleton(); $where = self::getSqlFilter($filter); - mfLoghandler::singleton()->debug($where); + //mfLoghandler::singleton()->debug($where); $res = $db->select("RimoWorkorder", "*", "$where ORDER BY `create`"); if($db->num_rows($res)) { $data = $db->fetch_object($res); diff --git a/db/migrations/20231109131925_preorder_add_installation_and_order_dates.php b/db/migrations/20231109131925_preorder_add_installation_and_order_dates.php new file mode 100644 index 000000000..4e3959860 --- /dev/null +++ b/db/migrations/20231109131925_preorder_add_installation_and_order_dates.php @@ -0,0 +1,33 @@ +getEnvironment() == "thetool") { + $table = $this->table("Preorder"); + $table->addColumn("installation_date", "integer", ["null" => true, "default" => null, "after" => "submit_request"]); + $table->addColumn("order_date", "integer", ["null" => true, "default" => null, "after" => "note"]); + $table->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + $this->table("Preorder")->removeColumn("installation_date")->save(); + $this->table("Preorder")->removeColumn("order_date")->save(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } +} diff --git a/public/docs/preorder-api.yaml b/public/docs/preorder-api.yaml index 73f647739..c974e034a 100644 --- a/public/docs/preorder-api.yaml +++ b/public/docs/preorder-api.yaml @@ -760,7 +760,7 @@ paths: description: Unauthorized '404': description: Vorbestellung nicht gefunden - /preorder/{id}/inhouseInstallationFinished: + /preorder/{id}/serviceActivated: post: tags: - preorder @@ -1137,6 +1137,11 @@ components: extref: type: string description: Providereigener Identifikationsstring. Wird unverändert gespeichert und kann statt `code` in `GET /preorder` und `DELETE /preorder` angegeben werden. **Darf nicht mit Dateiendung wie z.B. `.json`, `.csv` enden, da diese als Ausgabeformat interpretiert werden können** + orderDate: + type: string + format: date + description: Bestell- oder Vertragsdatum ISO 8601 Format + example: "2023-02-01" preorderType: type: string enum: [interest, provision, order] @@ -1402,6 +1407,11 @@ components: extref: type: string description: Providereigener Identifikationsstring. Wird unverändert gespeichert und kann statt `code` in `GET /preorder` und `DELETE /preorder` angegeben werden. **Darf nicht mit Dateiendung wie z.B. `.json`, `.csv` enden, da diese als Ausgabeformat interpretiert werden können** + orderDate: + type: string + format: date + description: Bestell- oder Vertragsdatum ISO 8601 Format + example: "2023-02-01" status: type: object properties: @@ -1421,6 +1431,11 @@ components: type: string description: Customer Installation Feedback Url example: "https://pro.ichwillglasfaser.at/ClientSubmit/finishedInstallationWork?c=XArjnWQXGq4a8JWF" + installationDate: + type: string + format: date-time + description: Installationstermin in ISO 8601 Format + example: "2023-02-01T00:00:00+01:00" connectionType: type: string enum: [single-dwelling, multi-dwelling, apartment-building, apartment, business]