diff --git a/Classes/Controller/JoblistController.php b/Classes/Controller/JoblistController.php index f7c3ff9b6873842905c80fc1cd714fa319d658b1..9439b740609b63e410a00172830e0cca41ab679e 100644 --- a/Classes/Controller/JoblistController.php +++ b/Classes/Controller/JoblistController.php @@ -27,6 +27,9 @@ namespace SGalinski\SgJobs\Controller; ***************************************************************/ use SGalinski\SgJobs\Service\BackendService; +use SGalinski\SgMail\Service\MailTemplateService; +use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException; +use TYPO3\CMS\Core\Exception; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; @@ -34,6 +37,11 @@ use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; * The joblist plugin controller */ class JoblistController extends ActionController { + /** + * @var \TYPO3\CMS\Extbase\Object\ObjectManager + * @inject + */ + protected $objectManager; /** * @var \SGalinski\SgJobs\Domain\Repository\CompanyRepository @@ -60,17 +68,51 @@ class JoblistController extends ActionController { // get all jobs for the next root page $jobs = $this->jobRepository->findJobs(BackendService::getRootUidByPageUid($pageUid)); $this->view->assign('jobs', $jobs); - - debug(BackendService::getRootUidByPageUid($pageUid)); - debug($jobs); } - public function applyFormAction() { - + /** + * @param string $jobTitle + */ + public function applyFormAction($jobTitle = '') { + $this->view->assign('jobTitle', $jobTitle); } + /** + * @param array $applyData + * @return void + */ + public function applyAction(array $applyData = []) { + // get an instance of the mail service + /** @var MailTemplateService $mailService */ + $mailService = $this->objectManager->get( + MailTemplateService::class, 'application_mail', 'sg_jobs', $this->getApplicationMailMarkers($applyData) + ); + $mailService->setIgnoreMailQueue(TRUE); + $mailService->setToAddresses('torsten@sgalinski.de'); + try { + $mailService->sendEmail(); + } catch (Exception $exception) { - public function applyAction() { + } + } + /** + * @param array $applyData + * @return array + */ + private function getApplicationMailMarkers(array $applyData = []) { + return [ + 'jobtitle' => $applyData['jobTitle'], + 'salutation' => $applyData['salutation'], + 'firstname' => $applyData['firstName'], + 'lastname' => $applyData['lastName'], + 'street' => $applyData['street'], + 'city' => $applyData['city'], + 'country' => $applyData['country'], + 'phone' => $applyData['phone'], + 'mobile' => $applyData['mobile'], + 'email' => $applyData['email'], + 'message' => $applyData['message'] + ]; } } diff --git a/Configuration/MailTemplates/ApplicationMail.php b/Configuration/MailTemplates/ApplicationMail.php index fe0c359a226e04ff62ac92e696c0fe621b39ea6b..98f85ad5fede4fdd6e8bd7e8b732132dc863d11d 100644 --- a/Configuration/MailTemplates/ApplicationMail.php +++ b/Configuration/MailTemplates/ApplicationMail.php @@ -42,6 +42,12 @@ return [ 'value' => '99999', 'description' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang.xlf:application_mail.marker.zip' ], + [ + 'marker' => 'city', + 'type' => \SGalinski\SgMail\Service\MailTemplateService::MARKER_TYPE_STRING, + 'value' => 'München', + 'description' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang.xlf:application_mail.marker.city' + ], [ 'marker' => 'country', 'type' => \SGalinski\SgMail\Service\MailTemplateService::MARKER_TYPE_STRING, diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf index b886004883fd74394fa6f44ccefd4cc141852e11..265c16651a5bacb196f371478f07ca2e61244f1c 100644 --- a/Resources/Private/Language/de.locallang.xlf +++ b/Resources/Private/Language/de.locallang.xlf @@ -9,6 +9,10 @@ <authorEmail>fabian@sgalinski.de</authorEmail> </header> <body> + <trans-unit id="application_mail.marker.city" approved="yes"> + <source>City</source> + <target>Ort</target> + </trans-unit> <trans-unit id="application_mail.marker.country" approved="yes"> <source>Country</source> <target>Land</target> @@ -162,6 +166,10 @@ <source>Street</source> <target>Strasse</target> </trans-unit> + <trans-unit id="frontend.apply.thank_you" approved="yes"> + <source>Thank you for your application!</source> + <target>Vielen Dank für Ihre Bewerbung!</target> + </trans-unit> <trans-unit id="frontend.apply.title" approved="yes"> <source>Job title</source> <target>Job-Titel</target> diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 5230763f1ca4106c80b10d7169513e85adedb9a0..522b0fd40dbcaf99a2d51faca5eb834d2d282aab 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -9,6 +9,9 @@ <authorEmail>fabian@sgalinski.de</authorEmail> </header> <body> + <trans-unit id="application_mail.marker.city"> + <source>City</source> + </trans-unit> <trans-unit id="application_mail.marker.country"> <source>Country</source> </trans-unit> @@ -123,6 +126,9 @@ <trans-unit id="frontend.apply.street"> <source>Street</source> </trans-unit> + <trans-unit id="frontend.apply.thank_you"> + <source>Thank you for your application!</source> + </trans-unit> <trans-unit id="frontend.apply.title"> <source>Job title</source> </trans-unit> diff --git a/Resources/Private/Partials/Job.html b/Resources/Private/Partials/Job.html index 4e58f3b2259b533b13544ba7f519b680280db835..8f39a327271ecdfedbef81867f5147253c5846d3 100644 --- a/Resources/Private/Partials/Job.html +++ b/Resources/Private/Partials/Job.html @@ -67,6 +67,7 @@ <div> <f:form action="applyForm" controller="Joblist"> + <f:form.hidden value="{job.title}" property="jobTitle" /> <f:form.submit value="{f:translate(key:'frontend.applyNow')}" /> </f:form> </div> diff --git a/Resources/Private/Templates/Joblist/Apply.html b/Resources/Private/Templates/Joblist/Apply.html index b926622c7df1358aaec7c6ab00d548581aee9555..4fd20e3360d7cdad15ace4a67b67a3b40fa68e8e 100644 --- a/Resources/Private/Templates/Joblist/Apply.html +++ b/Resources/Private/Templates/Joblist/Apply.html @@ -1,5 +1,7 @@ <f:layout name="Default" /> <f:section name="main"> - + <p> + <f:translate key="frontend.apply.thank_you" /> + </p> </f:section> diff --git a/Resources/Private/Templates/Joblist/ApplyForm.html b/Resources/Private/Templates/Joblist/ApplyForm.html index d8c6876948e03c4ad1d7e900a5ddfac927d81838..11a5e399a5c4f93d4ff3a68b71eecce6b683fdde 100644 --- a/Resources/Private/Templates/Joblist/ApplyForm.html +++ b/Resources/Private/Templates/Joblist/ApplyForm.html @@ -3,7 +3,7 @@ <f:section name="main"> <f:form action="apply" controller="Joblist" method="post" objectName="applyData" object="{applyData}" enctype="multipart/form-data"> <label for="apply-jobTitle"><f:translate key="frontend.apply.title" /></label> - <f:form.textfield property="jobTitle" id="apply-jobTitle" data="{}" class="" /> + <f:form.textfield property="jobTitle" id="apply-jobTitle" data="{}" class="" value="{jobTitle}"/> <br /> <label for="apply-salutation"><f:translate key="frontend.apply.salutation" /></label> <f:form.textfield property="salutation" id="apply-salutation" data="{}" class="" />