From 2041fa7798be9b592ea189137529d65db0cf3dd2 Mon Sep 17 00:00:00 2001
From: Stefan Galinski <stefan@sgalinski.de>
Date: Wed, 8 Nov 2023 14:57:15 +0100
Subject: [PATCH] [BUGFIX] Fix completely broken contact adress integration

---
 Classes/Domain/Model/Company.php              | 16 ++--
 Classes/Domain/Model/Contact.php              | 95 +++++++++++++++++++
 .../Private/Templates/Joblist/ApplyForm.html  | 39 +++++++-
 3 files changed, 138 insertions(+), 12 deletions(-)

diff --git a/Classes/Domain/Model/Company.php b/Classes/Domain/Model/Company.php
index 64c16e50..c2762141 100644
--- a/Classes/Domain/Model/Company.php
+++ b/Classes/Domain/Model/Company.php
@@ -33,24 +33,24 @@ use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
  */
 class Company extends AbstractEntity {
 	/**
-	 * @var string $zip
+	 * @var string $jobId
 	 */
-	protected $zip = '';
+	protected $jobId = '';
 
 	/**
-	 * @var string $city
+	 * @var string $name
 	 */
-	protected $city = '';
+	protected $name = '';
 
 	/**
-	 * @var string $jobId
+	 * @var string $zip
 	 */
-	protected $jobId = '';
+	protected $zip = '';
 
 	/**
-	 * @var string $name
+	 * @var string $city
 	 */
-	protected $name = '';
+	protected $city = '';
 
 	/**
 	 * @var string $street
diff --git a/Classes/Domain/Model/Contact.php b/Classes/Domain/Model/Contact.php
index 1c30a1d4..065c5de3 100644
--- a/Classes/Domain/Model/Contact.php
+++ b/Classes/Domain/Model/Contact.php
@@ -59,6 +59,31 @@ class Contact extends AbstractEntity {
 	 */
 	protected $phone = '';
 
+	/**
+	 * @var string $zip
+	 */
+	protected $zip = '';
+
+	/**
+	 * @var string $city
+	 */
+	protected $city = '';
+
+	/**
+	 * @var string $street
+	 */
+	protected $street = '';
+
+	/**
+	 * @var string $state
+	 */
+	protected $state = '';
+
+	/**
+	 * @var string $country
+	 */
+	protected $country = '';
+
 	/**
 	 * @TYPO3\CMS\Extbase\Annotation\ORM\Lazy
 	 * @var FileReference
@@ -152,4 +177,74 @@ class Contact extends AbstractEntity {
 
 		return $this->image;
 	}
+
+	/**
+	 * @return string
+	 */
+	public function getCity() {
+		return $this->city;
+	}
+
+	/**
+	 * @param string $city
+	 */
+	public function setCity(string $city) {
+		$this->city = $city;
+	}
+
+	/**
+	 * @return string
+	 */
+	public function getState() {
+		return $this->state;
+	}
+
+	/**
+	 * @param string $state
+	 */
+	public function setState(string $state) {
+		$this->state = $state;
+	}
+
+	/**
+	 * @return string
+	 */
+	public function getCountry() {
+		return $this->country;
+	}
+
+	/**
+	 * @param string $country
+	 */
+	public function setCountry(string $country) {
+		$this->country = $country;
+	}
+
+	/**
+	 * @return string
+	 */
+	public function getStreet() {
+		return $this->street;
+	}
+
+	/**
+	 * @param string $street
+	 */
+	public function setStreet(string $street) {
+		$this->street = $street;
+	}
+
+	/**
+	 * @return string
+	 */
+	public function getZip() {
+		return $this->zip;
+	}
+
+	/**
+	 * @param string $zip
+	 */
+	public function setZip($zip) {
+		$this->zip = $zip;
+	}
 }
diff --git a/Resources/Private/Templates/Joblist/ApplyForm.html b/Resources/Private/Templates/Joblist/ApplyForm.html
index 9b395b30..28163f2b 100644
--- a/Resources/Private/Templates/Joblist/ApplyForm.html
+++ b/Resources/Private/Templates/Joblist/ApplyForm.html
@@ -100,11 +100,42 @@
 											{job.company.contact.title} {job.company.contact.firstName} {job.company.contact.lastName}<br>
 										</f:else>
 									</f:if>
-									{job.company.street}<br>
-									<f:if condition="{job.company.state}">
-										{job.company.state}<br>
+									<f:if condition="{job.contact} && {job.contact.street}">
+										<f:then>
+											{job.contact.street}<br>
+											<f:if condition="{job.contact.state}">
+												{job.contact.state}<br>
+											</f:if>
+											{job.contact.zip} {job.contact.city}
+											<f:if condition="{job.contact.country}">
+												<br>{job.contact.country}
+											</f:if>
+										</f:then>
+										<f:else>
+											<f:if condition="{job.company.contact} && {job.company.contact.street}">
+												<f:then>
+													{job.company.contact.street}<br>
+													<f:if condition="{job.company.contact.state}">
+														{job.company.contact.state}<br>
+													</f:if>
+													{job.company.contact.zip} {job.company.contact.city}
+													<f:if condition="{job.company.contact.country}">
+														<br>{job.company.contact.country}
+													</f:if>
+												</f:then>
+												<f:else>
+													{job.company.street}<br>
+													<f:if condition="{job.company.state}">
+														{job.company.state}<br>
+													</f:if>
+													{job.company.zip} {job.company.city}
+													<f:if condition="{job.company.country}">
+														<br>{job.company.country}
+													</f:if>
+												</f:else>
+											</f:if>
+										</f:else>
 									</f:if>
-									{job.company.zip} {job.company.city}
 								</p>
 							</f:if>
 
-- 
GitLab