Skip to content
Snippets Groups Projects
Commit 877c20e3 authored by Sergiu-Lucian Petrica's avatar Sergiu-Lucian Petrica
Browse files

Merge branch 'master' of gitlab.sgalinski.de:typo3/sg_jobs

parents ff8dff63 d3845c31
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
/**
......
......@@ -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);
......
......@@ -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'])
)
);
}
......
......@@ -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
......
......@@ -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>
......@@ -28,8 +28,7 @@
<f:translate key="frontend.job_function" />
</td>
<td>
{job.function}
</td>
{job.jobFunction}
</tr>
<tr>
<td>
......
{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>
......@@ -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">
......
......@@ -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(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment