diff --git a/Layout/default/Preorder/Index.php b/Layout/default/Preorder/Index.php
index aa8189f53..27f36e86a 100644
--- a/Layout/default/Preorder/Index.php
+++ b/Layout/default/Preorder/Index.php
@@ -599,8 +599,14 @@ $pagination_entity_name = "Vorbestellungen";
=$preorder->oaid?>
- =($preorder->company) ? $preorder->company : $preorder->firstname." ".$preorder->lastname?>
- =$preorder->street?>=($preorder->housenumber) ? " ".$preorder->housenumber : ""?>
+ =($preorder->company) ? $preorder->company." " : ""?>
+ =($preorder->firstname || $preorder->lastname ) ? $preorder->firstname." ".$preorder->lastname." " : ""?>
+ =$preorder->street?>=($preorder->housenumber) ? " ".$preorder->housenumber : ""?>
+ =($preorder->block) ? "Block ".$preorder->block : ""?>
+ =($preorder->stiege) ? "Stiege ".$preorder->stiege : ""?>
+ =($preorder->stock) ? "Stock ".$preorder->stock : ""?>
+ =($preorder->tuer) ? "Tür ".$preorder->tuer : ""?>
+
=$preorder->zip?> =$preorder->city?>
|
diff --git a/application/Api/v1/PreorderApicontroller.php b/application/Api/v1/PreorderApicontroller.php
index 21db2fd55..d1e5f4b24 100644
--- a/application/Api/v1/PreorderApicontroller.php
+++ b/application/Api/v1/PreorderApicontroller.php
@@ -53,6 +53,7 @@ class PreorderApicontroller extends mfBaseApicontroller {
$this->addRoute("/preorder/:code/clientInstallationFinished", [$modules["Cif"], "providerSetCif"], "POST");
$this->addRoute("/preorder/:code/serviceActivated", [$modules["Activation"], "setServiceActive"], "POST");
$this->addRoute("/preorder/:code", "getPreorder", "GET");
+ $this->addRoute("/preorder/:code", "updatePreorder", "PUT");
$this->addRoute("/preorder/:code", "cancelPreorder", "DELETE");
@@ -331,6 +332,67 @@ class PreorderApicontroller extends mfBaseApicontroller {
}
+ protected function updatePreorder($code) {
+ $code = trim($code);
+ if(!$code) {
+ return mfResponse::NotFound(["message" => "Preorder not found"]);
+ }
+
+ $preorder = PreorderModel::getFirst(['ucode' => strtoupper($code), 'partner_id' => $this->me->address_id]);
+ if(!$preorder) {
+ // try as extref
+ $preorder = PreorderModel::getFirst(['extref' => $code, 'partner_id' => $this->me->address_id]);
+ }
+ if(!$preorder) {
+ // try oan id
+ $preorder = PreorderModel::getFirst(['oaid' => strtolower($code), 'partner_id' => $this->me->address_id], "`create` DESC");
+ }
+
+ if(!$preorder) {
+ return mfResponse::NotFound(["message" => "Preorder not found"]);
+ }
+
+
+ if($preorder->partner_id != $this->me->address_id) {
+ return mfResponse::NotFound(["message" => "Preorder not found"]);
+ }
+
+ $updates = [];
+ foreach(["contact_type","company","uid","firstname","lastname","street","housenumber","block","stock","stiege","tuer","unit_string","zip","city","phone","email"] as $type) {
+ if(array_key_exists($type, $this->post)) {
+ $updates[$type] = trim($this->post[$type]);
+ }
+ }
+
+ if(!count($updates)) {
+ return mfResponse::BadRequest(["message" => "No updates provided"]);
+ }
+
+ if(array_key_exists("contact_type", $updates)) {
+ if($updates["contact_type"] != "tenant" && $updates["contact_type"] != "owner") {
+ return mfResponse::BadRequest(["message" => "Invalid contact type. Must be 'owner' or 'tenant'"]);
+ }
+ }
+
+ $updates["edit_by"] = $this->me->id;
+ $preorder->update($updates);
+
+ // sanity checks
+ if(!$preorder->company && (!$preorder->firstname || !$preorder->lastname)) {
+ return mfResponse::BadRequest(["message" => "Cannot leave company or first- and lastname empty"]);
+ }
+ if(!$preorder->email) {
+ return mfResponse::BadRequest(["message" => "Cannot leave email empty"]);
+ }
+
+ if(!$preorder->save()) {
+ return mfResponse::InternalServerError();
+ }
+
+ return mfResponse::Ok(["message" => "Contact successfully updated"]);
+
+ }
+
protected function cancelPreorder($code) {
if($this->me->is("Preorderreadonly")) return \mfResponse::Forbidden();
/*
diff --git a/lib/mvcfronk/mfBase/mfBaseApicontroller.php b/lib/mvcfronk/mfBase/mfBaseApicontroller.php
index d264367dc..b896c8d75 100644
--- a/lib/mvcfronk/mfBase/mfBaseApicontroller.php
+++ b/lib/mvcfronk/mfBase/mfBaseApicontroller.php
@@ -185,7 +185,7 @@ class mfBaseApicontroller {
// POST Request
$post = [];
- if($this->http_method == "POST") {
+ if($this->http_method == "POST" || $this->http_method == "PUT") {
$post = $this->getPostRequest();
if($post === false) {
$post = [];
@@ -234,6 +234,11 @@ class mfBaseApicontroller {
return $request_body;
}
+ if($this->http_method == "PUT") {
+ // PUT requests in application/x-www-form-urlencoded format need special handling
+ parse_str(file_get_contents("php://input"), $_POST);
+ }
+
// Request body is urlencoded or multipart-formdata
if(array_key_exists("CONTENT_TYPE", $_SERVER) && preg_match('#charset\s*=\s*["\']?([^ "\']+)["\']?\s*;?#i', $_SERVER["CONTENT_TYPE"], $m)) {
$request_charset = strtolower($m[1]);
diff --git a/public/docs/preorder-api.yaml b/public/docs/preorder-api.yaml
index 488d973b2..5b8f3af57 100644
--- a/public/docs/preorder-api.yaml
+++ b/public/docs/preorder-api.yaml
@@ -820,6 +820,192 @@ paths:
description: Unauthorized
'404':
description: Vorbestellung nicht gefunden
+ put:
+ tags:
+ - preorder
+ summary: Kontaktdaten bearbeiten
+ description: Zum Bearbeiten der Kontaktdaten einer Bestellung. Ein oder mehrere Parameter benötigt.
+ operationId: updatePreorderContact
+ parameters:
+ - name: id
+ in: path
+ description: Automatisch generierter **code** der Vorbestellung, **OAID** der Wohneinheit oder providereigene ID (**extref**)
+ required: true
+ schema:
+ type: string
+ requestBody:
+ description: zu ändernde Kontaktdaten
+ required: true
+ content:
+ 'application/json':
+ schema:
+ type: object
+ description: Vertragsinhaber
+ properties:
+ type:
+ type: string
+ enum: [ "owner","tenant" ]
+ description: |
+ Ist diese Adresse Besitzer oder Bewohner der Wohneinheit. Optional, aber kann je nach Kampagne ein Pflichtfeld sein.
+
+ | type | Description |
+ |--------|-------------|
+ | owner | Ist Besitzer |
+ | tenant | Ist Bewohner|
+ company:
+ type: string
+ description: Firmenname Kunde
+ example:
+ uid:
+ type: string
+ description: UID (wenn Firmenkunde)
+ example:
+ firstname:
+ type: string
+ description: Vorname Kunde
+ example: Vor
+ lastname:
+ type: string
+ description: Nachname Kunde
+ example: Nachname
+ street:
+ type: string
+ description: Straße Kunde
+ example: Beispielstraße
+ housenumber:
+ type: string
+ description: Hausnummer Kunde
+ example: 42
+ zip:
+ type: string
+ description: PLZ Kunde
+ example: 9999
+ city:
+ type: string
+ description: Ort Kunde
+ example: Beispielhausen
+ block:
+ type: string
+ description: Adresszusatz
+ example: null
+ stiege:
+ type: string
+ description: Adresszusatz
+ example: null
+ stock:
+ type: string
+ description: Adresszusatz
+ example: null
+ tuer:
+ type: string
+ description: Adresszusatz
+ example: null
+ phone:
+ type: string
+ description: Telefonnummer Kunde
+ example: "01 1234 567 89"
+ email:
+ type: string
+ description: Emailadresse Kunde
+ example: this.email@does-not.exist
+ 'application/x-www-form-urlencoded':
+ schema:
+ type: object
+ description: Vertragsinhaber
+ properties:
+ type:
+ type: string
+ enum: [ "owner","tenant" ]
+ description: |
+ Ist diese Adresse Besitzer oder Bewohner der Wohneinheit. Optional, aber kann je nach Kampagne ein Pflichtfeld sein.
+
+ | type | Description |
+ |--------|-------------|
+ | owner | Ist Besitzer |
+ | tenant | Ist Bewohner|
+ company:
+ type: string
+ description: Firmenname Kunde
+ example:
+ uid:
+ type: string
+ description: UID (wenn Firmenkunde)
+ example:
+ firstname:
+ type: string
+ description: Vorname Kunde
+ example: Vor
+ lastname:
+ type: string
+ description: Nachname Kunde
+ example: Nachname
+ street:
+ type: string
+ description: Straße Kunde
+ example: Beispielstraße
+ housenumber:
+ type: string
+ description: Hausnummer Kunde
+ example: 42
+ zip:
+ type: string
+ description: PLZ Kunde
+ example: 9999
+ city:
+ type: string
+ description: Ort Kunde
+ example: Beispielhausen
+ block:
+ type: string
+ description: Adresszusatz
+ example: null
+ stiege:
+ type: string
+ description: Adresszusatz
+ example: null
+ stock:
+ type: string
+ description: Adresszusatz
+ example: null
+ tuer:
+ type: string
+ description: Adresszusatz
+ example: null
+ phone:
+ type: string
+ description: Telefonnummer Kunde
+ example: "01 1234 567 89"
+ email:
+ type: string
+ description: Emailadresse Kunde
+ example: this.email@does-not.exist
+ responses:
+ '200':
+ description: Successful operation
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ status:
+ type: string
+ description: Status string
+ example: OK
+ result:
+ type: object
+ properties:
+ message:
+ type: string
+ description: Statustext
+ example: Contact successfully updated
+ '400':
+ description: Fehler in Eingabedaten
+ '401':
+ description: Api key fehlt oder ungültig
+ '403':
+ description: Keine Berechtigung
+ '404':
+ description: Bestellung nicht gefunden oder bereits storniert
delete:
tags:
- preorder
|