diff --git a/Layout/default/ConstructionConsent/Consentform.pdf.php b/Layout/default/ConstructionConsent/Consentform.pdf.php
index 8bbcd4f1e..3d8b68c47 100644
--- a/Layout/default/ConstructionConsent/Consentform.pdf.php
+++ b/Layout/default/ConstructionConsent/Consentform.pdf.php
@@ -269,6 +269,8 @@
@@ -410,7 +412,7 @@
Übersichtsplan / Planskizze
- file): ?>
+ file && $consent->file->file_id && $consent->file->file->fileExists()): ?>
diff --git a/Layout/default/ConstructionConsent/Form.php b/Layout/default/ConstructionConsent/Form.php
index 8acc6dfb5..93c7b43ce 100644
--- a/Layout/default/ConstructionConsent/Form.php
+++ b/Layout/default/ConstructionConsent/Form.php
@@ -201,18 +201,10 @@
-
+
-
![]()
file) ? "src=".$item->file->file->asDataUrl()."" : "" ?> />
-
-
+
![]()
file && $item->file->file && $item->file->file->fileExists()) ? "src=".$item->file->file->asDataUrl()."" : "" ?> />
@@ -369,6 +361,7 @@
var [file] = $("#consent_plan_image").prop("files");
if(file) {
$("#plan_preview").attr("src", URL.createObjectURL(file));
+ $("#delete-rimo-plan").show();
}
});
@@ -377,11 +370,19 @@
$("#adb_strasse_id").val("").change();
});
- function deleteRimoPlan() {
- $('#plan_adb_hausnummer_id').val("");
- $("#submit_plan_file_id").val();
+ function deletePlan() {
+ $('#plan_adb_hausnummer_id').val("").change();
+ $("#submit_plan_file_id").val("");
$("#plan_preview").attr("src", "");
$("#delete-rimo-plan").hide();
+ $("#consent_plan_image").val("");
+
+ id): ?>
+ $.post("=self::getUrl("ConstructionConsent", "api")?>", {
+ do: "deleteRimoPlan",
+ id: =$item->id?>
+ });
+
}
diff --git a/application/ConstructionConsent/ConstructionConsentController.php b/application/ConstructionConsent/ConstructionConsentController.php
index 339afd66d..c07fb68ab 100644
--- a/application/ConstructionConsent/ConstructionConsentController.php
+++ b/application/ConstructionConsent/ConstructionConsentController.php
@@ -489,6 +489,9 @@ class ConstructionConsentController extends mfBaseController {
case "saveCheckbox":
$return = $this->saveCheckboxApi();
break;
+ case "deleteRimoPlan":
+ $return = $this->deleteRimoPlanApi();
+ break;
default:
$this->log->warn(__METHOD__ . ": Called API function '$do' does not exist");
$return = false;
@@ -889,9 +892,17 @@ class ConstructionConsentController extends mfBaseController {
}
- private function saveRimoPlanPreviewApi() {
- $adb_hausnummer_id = $this->request->building_id;
- $consent_id = $this->request->constructionconsent_id;
+ private function deleteRimoPlanApi() {
+ $consent_id = $this->request->id;
+
+ $consent = new ConstructionConsent($consent_id);
+ if(!$consent->id) return false;
+
+ if($consent->file && $consent->file->file_id) {
+ $consent->file->delete();
+ }
+
+ return ["message" => "Plan deleted successfully"];
}
private function saveCheckboxApi() {
diff --git a/lib/Mapbox/StaticImageApi.php b/lib/Mapbox/StaticImageApi.php
index 45fafe998..3cfd28261 100644
--- a/lib/Mapbox/StaticImageApi.php
+++ b/lib/Mapbox/StaticImageApi.php
@@ -29,6 +29,8 @@ class Mapbox_StaticImageApi {
$pin_part .= "+$pin_color($pin_gps_long,$pin_gps_lat)";
}
+ $initial_path_count = 0;
+ $path_count = 0;
$path_parts = [];
if(is_array($paths) && count($paths)) {
$path_stroke_width = $paths["line_width"];
@@ -37,8 +39,8 @@ class Mapbox_StaticImageApi {
$path_fill_color = $paths["line_fill_color"];
$path_fill_opacity = $paths["line_fill_opacity"];
- $path_count = 0;
- $initial_path_count = 0;
+
+
foreach($paths["coords"] as $path) {
$initial_path_count++;
//mfLoghandler::singleton()->debug(print_r($paths, true));
@@ -101,7 +103,7 @@ class Mapbox_StaticImageApi {
}
}
- if(is_array($url_opt_parts)) {
+ if(is_array($url_opt_parts) && count($url_opt_parts)) {
$url .= "/".implode(",", $url_opt_parts);
}