diff --git a/Classes/Controller/Ajax/JoblistController.php b/Classes/Controller/Ajax/JoblistController.php index 3207037e400f591be658ea77c2ea00d8a1c5ec3d..20448bdaa43e7a490250f0408a5633c61b439c6c 100644 --- a/Classes/Controller/Ajax/JoblistController.php +++ b/Classes/Controller/Ajax/JoblistController.php @@ -55,8 +55,7 @@ class JoblistController extends AbstractAjaxController { * @throws \InvalidArgumentException */ public function filterAction() { - $recordPageId = $_POST['recordPageId']; - + $recordPageId = (int) $_POST['recordPageId']; $filters = [ 'country' => $_POST['parameters']['country'], 'location' => $_POST['parameters']['location'], @@ -93,6 +92,7 @@ class JoblistController extends AbstractAjaxController { $this->view->assign('selectedArea', $filters['area']); $this->view->assign('selectedFunction', $filters['function']); $this->view->assign('limit', $jobLimit); + $this->view->assign('recordPageId', $recordPageId); } /** diff --git a/Classes/Controller/JoblistController.php b/Classes/Controller/JoblistController.php index 390c05e32b5e332426fa18fccd459ad93bbffffd..97e5793a1b90b8e880cd7b77bc9c1a80e0ad2564 100644 --- a/Classes/Controller/JoblistController.php +++ b/Classes/Controller/JoblistController.php @@ -80,7 +80,7 @@ class JoblistController extends ActionController { $jobs = $this->jobRepository->findJobs($storagePid, [], FALSE, $jobLimit, $offset); // get all jobs for the current page - $jobsCount = \count($this->jobRepository->findJobs($storagePid, [], FALSE, 0, $offset)); + $jobsCount = \count($this->jobRepository->findJobs($storagePid)); $numberOfPages = ($jobLimit <= 0 ? 0 : ceil($jobsCount / $jobLimit)); $this->view->assign('jobs', $jobs); diff --git a/Classes/Service/FrontendFilterService.php b/Classes/Service/FrontendFilterService.php index 8caa43a4684a3f83e207c57c47d15ae4799d8b3f..39c12a319e432d5ba8818ca25bd489f4f38a68cd 100644 --- a/Classes/Service/FrontendFilterService.php +++ b/Classes/Service/FrontendFilterService.php @@ -36,255 +36,6 @@ use TYPO3\CMS\Extbase\Object\ObjectManager; */ class FrontendFilterService { - /** - * Get all the locations based on the given filters - * - * @param array $filters - * @param int $recordPageId - * @return array - * @throws \InvalidArgumentException - */ - public static function getLocations(array $filters = [], $recordPageId): array { - $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable( - 'tx_sgjobs_domain_model_company' - ); - $statement = $queryBuilder->select('city') - ->from('tx_sgjobs_domain_model_company'); - - if ($filters['country'] !== '0' && $filters['country'] !== NULL) { - $statement->andWhere( - $queryBuilder->expr()->eq( - 'country', $queryBuilder->createNamedParameter($filters['country']) - ) - ); - } - - if ($filters['location'] !== '0') { - $statement->andWhere( - $queryBuilder->expr()->eq( - 'city', $queryBuilder->createNamedParameter($filters['location']) - ) - ); - } - - if ($filters['company'] !== '0') { - $statement->andWhere( - $queryBuilder->expr()->eq( - 'name', $queryBuilder->createNamedParameter($filters['company']) - ) - ); - } - - $statement->andWhere( - $queryBuilder->expr()->eq( - 'pid', $queryBuilder->createNamedParameter($recordPageId) - ) - ); - - $locations = $statement->execute()->fetchAll(); - $result = []; - $result[0] = ''; - foreach ($locations as $location) { - $result[$location['city']] = $location['city']; - } - - return $result; - } - - /** - * Get all the companies based on the given filters - * - * @param array $filters - * @param int $recordPageId - * @return array - * @throws \InvalidArgumentException - */ - public static function getCompanies(array $filters = [], $recordPageId): array { - $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable( - 'tx_sgjobs_domain_model_company' - ); - $statement = $queryBuilder->select('name') - ->from('tx_sgjobs_domain_model_company'); - - if ($filters['location'] !== '0' && $filters['location'] !== NULL) { - $queryBuilder->where( - $queryBuilder->expr()->eq( - 'city', $queryBuilder->createNamedParameter($filters['location']) - ) - ); - } - - if ($filters['country'] !== '0' && $filters['country'] !== NULL) { - $statement->andWhere( - $queryBuilder->expr()->eq( - 'country', $queryBuilder->createNamedParameter($filters['country']) - ) - ); - } - - if ($filters['country'] !== '0' && $filters['country'] !== NULL) { - $statement->andWhere( - $queryBuilder->expr()->eq( - 'country', $queryBuilder->createNamedParameter($filters['country']) - ) - ); - } - - if ($filters['company'] !== '0' && $filters['company'] !== NULL) { - $statement->andWhere( - $queryBuilder->expr()->eq( - 'name', $queryBuilder->createNamedParameter($filters['company']) - ) - ); - } - - $statement->andWhere( - $queryBuilder->expr()->eq( - 'pid', $queryBuilder->createNamedParameter($recordPageId) - ) - ); - - $companies = $statement->execute()->fetchAll(); - - $result = []; - $result[0] = ''; - foreach ($companies as $company) { - $result[$company['name']] = $company['name']; - } - - return $result; - } - - /** - * Get all the areas based on the given filters - * - * @param array $filters - * @param int $recordPageId - * @return array - * @throws \InvalidArgumentException - */ - public static function getAreas(array $filters = [], $recordPageId): array { - $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable( - 'tx_sgjobs_domain_model_company' - ); - - $statement = $queryBuilder->select('a.area') - ->from('tx_sgjobs_domain_model_job', 'a') - ->join( - 'a', 'tx_sgjobs_domain_model_company', 'b' - , $queryBuilder->expr()->eq('a.company', 'b.uid') - ); - - if ($filters['country'] !== '0' && $filters['country'] !== NULL) { - $statement->andWhere( - $queryBuilder->expr()->eq( - 'b.country', $queryBuilder->createNamedParameter($filters['country']) - ) - ); - } - - if ($filters['location'] !== '0' && $filters['location'] !== NULL) { - $statement->andWhere( - $queryBuilder->expr()->eq( - 'b.city', $queryBuilder->createNamedParameter($filters['location']) - ) - ); - } - - if ($filters['company'] !== '0' && $filters['company'] !== NULL) { - $statement->andWhere( - $queryBuilder->expr()->eq( - 'b.name', $queryBuilder->createNamedParameter($filters['company']) - ) - ); - } - - $statement->andWhere( - $queryBuilder->expr()->eq( - 'b.pid', $queryBuilder->createNamedParameter($recordPageId) - ) - ); - - $areas = $statement->execute()->fetchAll(); - - $result = []; - $result[0] = ''; - foreach ($areas as $area) { - $result[$area['area']] = $area['area']; - } - - return $result; - } - - /** - * Get all the functions based on the given filters - * - * @param array $filters - * @param int $recordPageId - * @return array - * @throws \InvalidArgumentException - */ - public static function getFunctions(array $filters = [], $recordPageId): array { - $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable( - 'tx_sgjobs_domain_model_company' - ); - - $statement = $queryBuilder->select('a.job_function') - ->from('tx_sgjobs_domain_model_job', 'a') - ->join( - 'a', 'tx_sgjobs_domain_model_company', 'b' - , $queryBuilder->expr()->eq('a.company', 'b.uid') - ); - - if ($filters['country'] !== '0' && $filters['country'] !== NULL) { - $statement->andWhere( - $queryBuilder->expr()->eq( - 'b.country', $queryBuilder->createNamedParameter($filters['country']) - ) - ); - } - - if ($filters['location'] !== '0' && $filters['location'] !== NULL) { - $statement->andWhere( - $queryBuilder->expr()->eq( - 'b.city', $queryBuilder->createNamedParameter($filters['location']) - ) - ); - } - - if ($filters['company'] !== '0' && $filters['company'] !== NULL) { - $statement->andWhere( - $queryBuilder->expr()->eq( - 'b.name', $queryBuilder->createNamedParameter($filters['company']) - ) - ); - } - - if ($filters['area'] !== '0' && $filters['area'] !== NULL) { - $statement->andWhere( - $queryBuilder->expr()->eq( - 'b.name', $queryBuilder->createNamedParameter($filters['area']) - ) - ); - } - - $statement->andWhere( - $queryBuilder->expr()->eq( - 'b.pid', $queryBuilder->createNamedParameter($recordPageId) - ) - ); - - $jobFunctions = $statement->execute()->fetchAll(); - - $result = []; - $result[0] = ''; - foreach ($jobFunctions as $jobFunction) { - $result[$jobFunction['function']] = $jobFunction['function']; - } - - return $result; - } - /** * Get all the jobs based on the given filters * @@ -335,7 +86,15 @@ class FrontendFilterService { if ($filters['area'] !== '0' && $filters['area'] !== NULL) { $statement->andWhere( $queryBuilder->expr()->eq( - 'b.name', $queryBuilder->createNamedParameter($filters['area']) + 'a.area', $queryBuilder->createNamedParameter($filters['area']) + ) + ); + } + + if ($filters['function'] !== '0' && $filters['function'] !== NULL) { + $statement->andWhere( + $queryBuilder->expr()->eq( + 'a.job_function', $queryBuilder->createNamedParameter($filters['function']) ) ); } diff --git a/README.md b/README.md index b7ba84b2f73b4088560a2eeccd464c2579c6889f..55e0b2682ccd541998b66482c8e3dbc58297d967 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,10 @@ The Backend module is found in the **WEB** section under the name **Job Offers** You can create a new job offer by clicking on the **New Job Offer** button. +## Setting the record page id for the Joblist plugin +You need to set the id of the page (or sys folder) where you store all your job offers, contacts and locations. +To do this you can select the page/folder as Record Storage Page in the plugin settings. + ## Job form page When inserting the joblist plugin on a page, make sure to select the page which contains the application form from diff --git a/Resources/Private/Partials/Filter.html b/Resources/Private/Partials/Filter.html index 29b9424ece620f4c0f8ba93722c407ab9f426708..d3fa429a9fa62b64b65e3a67220366c378c904fe 100644 --- a/Resources/Private/Partials/Filter.html +++ b/Resources/Private/Partials/Filter.html @@ -5,4 +5,5 @@ <f:form.select class="sgjobs-select form-control" multiple="0" size="1" value="{selectedArea}" property="filterArea" optionValueField="value" options="{areas}" id="filter-areas" /> <f:form.select class="sgjobs-select form-control" multiple="0" size="1" value="{selectedFunction}" property="filterFunction" optionValueField="value" options="{functions}" id="filter-functions" /> <f:form.hidden value="{limit}" id="filter-limit" /> + <f:form.hidden id="filter-recordPageId" name="recordPageId" value="{recordPageId}" /> </f:form> diff --git a/Resources/Private/Partials/Job.html b/Resources/Private/Partials/Job.html index 466dffa252cd1d3f33e0aa96674b8b2a1a2e319e..0913ab5cddc06dc2773d909f36772830ad6861fe 100644 --- a/Resources/Private/Partials/Job.html +++ b/Resources/Private/Partials/Job.html @@ -28,8 +28,7 @@ <f:translate key="frontend.job_function" /> </td> <td> - {job.function} - </td> + {job.jobFunction} </tr> <tr> <td> diff --git a/Resources/Private/Templates/Ajax/Joblist/Filter.html b/Resources/Private/Templates/Ajax/Joblist/Filter.html index 5fdeffc60cd5119e0577e19f191c2acab074a094..fe1ee7434d690aa401872ad90720547b05a12248 100644 --- a/Resources/Private/Templates/Ajax/Joblist/Filter.html +++ b/Resources/Private/Templates/Ajax/Joblist/Filter.html @@ -1,6 +1,7 @@ +{namespace sg=SGalinski\SgJobs\ViewHelpers} <f:render partial="Filter" - arguments="{filters: filters, countries: countries, cities: cities, companies: companies, areas: areas, + arguments="{recordPageId: recordPageId, filters: filters, countries: countries, cities: cities, companies: companies, areas: areas, functions: functions, selectedCountry: selectedCountry, selectedCompany: selectedCompany, selectedLocation: selectedLocation, selectedArea: selectedArea, selectedFunction: selectedFunction, limit: limit}" /> @@ -8,3 +9,10 @@ <f:for each="{jobs}" as="job"> <f:render partial="Job" arguments="{job: job}" /> </f:for> + + +<div id="sgjobs-pagination"> + <f:format.raw> + <sg:pageBrowser numberOfPages="{numberOfPages}" /> + </f:format.raw> +</div> diff --git a/Resources/Private/Templates/Joblist/Index.html b/Resources/Private/Templates/Joblist/Index.html index ee1921d53a517923f67e28e469068d018c4ba528..6678920883c46b44cb83ca9ba83dfb8961dccc91 100644 --- a/Resources/Private/Templates/Joblist/Index.html +++ b/Resources/Private/Templates/Joblist/Index.html @@ -5,7 +5,7 @@ <div id="sgjobs-joblist"> <f:render partial="Filter" - arguments="{filters: filters, countries: countries, cities: cities, companies: companies, areas: areas, functions: functions, limit: limit}" + arguments="{recordPageId: recordPageId, filters: filters, countries: countries, cities: cities, companies: companies, areas: areas, functions: functions, limit: limit}" /> <f:for each="{jobs}" as="job"> @@ -13,11 +13,11 @@ <hr> </f:for> - </div> - <div id="sgjobs-pagination"> - <f:format.raw> - <sg:pageBrowser numberOfPages="{numberOfPages}" /> - </f:format.raw> + <div id="sgjobs-pagination"> + <f:format.raw> + <sg:pageBrowser numberOfPages="{numberOfPages}" /> + </f:format.raw> + </div> </div> <div id="sgjobs-apply-nojob"> <f:form action="applyForm" controller="Joblist" pluginName="JobApplication" pageUid="{settings.applyPage}" objectName="jobData"> diff --git a/Resources/Public/JavaScript/sgJobs.js b/Resources/Public/JavaScript/sgJobs.js index 369061a23fd1f01f17a380644275ecab1f0b3f5b..6f425fe46d1396977050c69a424585ae60ef28ba 100644 --- a/Resources/Public/JavaScript/sgJobs.js +++ b/Resources/Public/JavaScript/sgJobs.js @@ -45,7 +45,7 @@ export default class SgJobs { $.post( '?eID=sgAjax&extensionName=SgJobs&controller=Ajax%5CJoblist&action=filter&format=html', { - recordPageId: $('#recordPageId').val(), + recordPageId: $('#filter-recordPageId').val(), parameters: { country: $('#filter-countries').val(), location: $('#filter-locations').val(),