Added AddressDB bulk update + address update in rimo
This commit is contained in:
@@ -318,6 +318,14 @@
|
||||
<td><?=$address->rollout?></td>
|
||||
<td><?=$address->rollout_info?></td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<?php if($me->is("Admin")): ?>
|
||||
<a href="<?=self::getUrl("AddressDB", "syncAddressToRimo", ["id" => $address->id])?>" title="Adressdaten nach Rimo exportieren">
|
||||
<sup><span class="" style="margin-right: -16px;"><i class="fas fa-cloud-arrow-up text-success"></i></span></sup><i class="fal fa-r"></i>
|
||||
</a>
|
||||
<!--a href="<?=self::getUrl("AddressDB", "syncAddressFromRimo", ["id" => $address->id])?>" title="Adressdaten von Rimo holen">
|
||||
<sup><span class="" style="margin-right: -16px;"><i class="fas fa-cloud-arrow-down text-danger"></i></span></sup><i class="fal fa-r"></i>
|
||||
</a-->
|
||||
<?php endif; ?>
|
||||
<a href="<?=self::getUrl("AddressDB", "view", ["id" => $address->id])?>"><i class="far fa-fw fa-eye" title="Adresse Anzeigen"></i></a>
|
||||
<a href="<?=self::getUrl("AddressDB", "edit", ["id" => $address->id])?>" class="pl-1"><i class="far fa-fw fa-edit" title="Adresse Bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("AddressDB", "delete", ["id" => $address->id])?>" onclick="if(!confirm('Addresse und alle Wohneinheiten wirklich löschen?')) return false;"><i class="far fa-fw fa-trash-alt text-danger" title="Adresse Löschen"></i></a>
|
||||
|
||||
@@ -57,7 +57,7 @@ class ADBHausnummer extends mfBaseModel {
|
||||
return true;
|
||||
}
|
||||
|
||||
private function updateAddressInRimo() {
|
||||
public function updateAddressInRimo() {
|
||||
if(!$this->rimo_id) return false;
|
||||
$creds = $this->getNetownerRimoApiCredentials();
|
||||
if(!$creds) {
|
||||
@@ -66,7 +66,7 @@ class ADBHausnummer extends mfBaseModel {
|
||||
|
||||
$update_data = [];
|
||||
if($this->strasse_id && $this->getProperty("strasse")->name) $update_data["address"] = $this->getProperty("strasse")->name;
|
||||
if($this->ortschaft_id && $this->getProperty("ort")->name) $update_data["city"] = $this->getProperty("ort")->name;
|
||||
if($this->ortschaft_id && $this->getProperty("ortschaft")->name) $update_data["city"] = $this->getProperty("ortschaft")->name;
|
||||
if($this->plz_id && $this->getProperty("plz")->plz) $update_data["zipCode"] = $this->getProperty("plz")->plz;
|
||||
if($this->strasse_id && $this->getProperty("strasse")->gemeinde_id && $this->getProperty("strasse")->gemeinde->name) $update_data["district"] = $this->getProperty("strasse")->gemeinde->name;
|
||||
|
||||
|
||||
@@ -783,6 +783,32 @@ class AddressDBController extends mfBaseController {
|
||||
}
|
||||
}*/
|
||||
|
||||
protected function syncAddressToRimoAction() {
|
||||
if(!$this->me->is("Admin")) {
|
||||
$this->redirect("AddressDB");
|
||||
}
|
||||
|
||||
$hausnummer_id = $this->request->id;
|
||||
if(!$hausnummer_id) {
|
||||
$this->layout()->setFlash("Adresse nicht gefunden", "error");
|
||||
$this->redirect("AddressDB");
|
||||
}
|
||||
|
||||
$hausnummer = new ADBHausnummer($hausnummer_id);
|
||||
if(!$hausnummer->id) {
|
||||
$this->layout()->setFlash("Adresse nicht gefunden", "error");
|
||||
}
|
||||
|
||||
if(!$hausnummer->updateAddressInRimo()) {
|
||||
$this->layout()->setFlash("Fehler beim updaten der Adresse in Rimo", "error");
|
||||
$this->redirect("AddressDB");
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Adresse erfolgreich nach Rimo synchronisiert", "success");
|
||||
$this->redirect("AddressDB");
|
||||
|
||||
}
|
||||
|
||||
protected function saveBulkupdateAction() {
|
||||
if(!$this->me->is("Admin")) {
|
||||
$this->redirect("AddressDB");
|
||||
@@ -811,7 +837,7 @@ class AddressDBController extends mfBaseController {
|
||||
$u = 0;
|
||||
|
||||
if(ADBHausnummerModel::count($filter, true) > 1000) {
|
||||
$this->layout()->setFlas("Bissi viel auf einmal");
|
||||
$this->layout()->setFlash("Bissi viel auf einmal");
|
||||
}
|
||||
|
||||
$cache = [];
|
||||
@@ -908,7 +934,7 @@ class AddressDBController extends mfBaseController {
|
||||
$hausnummer->strasse_id = $strasse->id;
|
||||
$updated = true;
|
||||
}
|
||||
if($plz_search && $hausnummer->plz != $plz->id) {
|
||||
if($plz_search && $hausnummer->plz_id != $plz->id) {
|
||||
$hausnummer->plz_id = $plz->id;
|
||||
$updated = true;
|
||||
}
|
||||
|
||||
@@ -36,14 +36,16 @@ class Rimoapi {
|
||||
$createOrderEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_CHANGE_BUILDING_ADDRESS;
|
||||
$put_url = $createOrderEp."?".$qs;
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$log->debug(__METHOD__.": Creating OAID in Rimo: $put_url");
|
||||
$log->debug(__METHOD__.": Address Change in Rimo: $put_url");
|
||||
$response = file_get_contents($put_url, false, $ctx);
|
||||
//var_dump($response);exit;
|
||||
$log->debug(__METHOD__.": response: ".print_r($response,true));
|
||||
if($response === false) {
|
||||
$log->error("Fehler beim Update der Adresse in RIMO ".$building_external_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$resp_data = json_decode($response);
|
||||
if(!$resp_data->id) return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user