From 43bdf4a484c08996480f686ee21f20e282470101 Mon Sep 17 00:00:00 2001
From: Stefan Galinski <stefan@sgalinski.de>
Date: Mon, 27 Mar 2023 20:32:35 +0200
Subject: [PATCH] [BUGFIX] Fix missing company in the application data

---
 Classes/Controller/JoblistController.php | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/Classes/Controller/JoblistController.php b/Classes/Controller/JoblistController.php
index 5732f175..ba8bb33f 100644
--- a/Classes/Controller/JoblistController.php
+++ b/Classes/Controller/JoblistController.php
@@ -423,7 +423,7 @@ class JoblistController extends ActionController {
 			. '-' . $applicationData->getLastName();
 		$storage = $resourceFactory->getStorageObject(1);
 		$applicationFilePath = Environment::getPublicPath() . '/' . $storage->getConfiguration(
-		)['basePath'] . 'JobApplication/' . $folderName .
+			)['basePath'] . 'JobApplication/' . $folderName .
 			'/' . $newName . '.csv';
 		$this->writeApplicationFile($applicationData, $applicationFilePath);
 	}
@@ -469,6 +469,13 @@ class JoblistController extends ActionController {
 					/** @var Company $company */
 					$applyData->setCompany($company);
 				}
+			} elseif (!$applyData->getCompany()) {
+				$company = $this->companyRepository->findByUid(
+					(int) $_POST['tx_sgjobs_jobapplication']['applyData']['company']
+				);
+				if ($company) {
+					$applyData->setCompany($company);
+				}
 			}
 
 			$applyData->setPid($GLOBALS['TSFE']->id);
@@ -589,7 +596,9 @@ class JoblistController extends ActionController {
 		$departments = $this->departmentRepository->findAllByFilter($filters['filterByDepartment'] ?? []);
 		$this->view->assign('departments', $departments);
 
-		$experienceLevels = $this->experienceLevelRepository->findAllByFilter($filters['filterByExperienceLevel'] ?? []);
+		$experienceLevels = $this->experienceLevelRepository->findAllByFilter(
+			$filters['filterByExperienceLevel'] ?? []
+		);
 		$this->view->assign('experienceLevels', $experienceLevels);
 	}
 
-- 
GitLab