Skip to content

Commit

Permalink
career controller change type
Browse files Browse the repository at this point in the history
  • Loading branch information
rserry committed Oct 22, 2023
1 parent 3e1dc84 commit 041d9a8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
5 changes: 3 additions & 2 deletions module/BrBundle/Controller/Career/VacancyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function overviewAction()

$query = $this->getEntityManager()
->getRepository('BrBundle\Entity\Company\Job')
->findAllActiveByTypeByDateQuery('vacancy');
->findAllActiveByDateQuery();

if ($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
Expand All @@ -30,12 +30,13 @@ public function overviewAction()
$repository = $this->getEntityManager()
->getRepository('BrBundle\Entity\Company\Job');

$jobType = $formData['jobType'] == 'all' ? null : $formData['sector'];
$sector = $formData['sector'] == 'all' ? null : $formData['sector'];
$location = $formData['location'] == 'all' ? null : $formData['location'];
$master = $formData['master'] == 'all' ? null : $formData['master'];

if ($formData['searchType'] == 'company') {
$query = $repository->findAllActiveByTypeQuery('vacancy', $sector, $location, $master);
$query = $repository->findAllActiveByTypeQuery($jobType, $sector, $location, $master);
} elseif ($formData['searchType'] == 'vacancy') {
$query = $repository->findAllActiveByTypeSortedByJobNameQuery('vacancy', $sector, $location, $master);
} elseif ($formData['searchType'] == 'mostRecent') {
Expand Down
11 changes: 11 additions & 0 deletions module/BrBundle/Form/Career/Search/Vacancy.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ public function init()
)
);

$this->add(
array(
'type' => 'select',
'name' => 'jobType',
'required' => true,
'attributes' => array(
'options' => array_merge(array('all' => 'All'), Company\Job::$possibleTypes),
),
)
);

$this->add(
array(
'type' => 'select',
Expand Down
22 changes: 22 additions & 0 deletions module/BrBundle/Repository/Company/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,28 @@ public function findAllActiveByTypeByDateQuery($type)
->getQuery();
}

/**
* @return \Doctrine\ORM\Query
*/
public function findAllActiveByDateQuery()
{
$query = $this->getEntityManager()->createQueryBuilder();
return $query->select('v, c')
->from('BrBundle\Entity\Company\Job', 'v')
->innerJoin('v.company', 'c')
->where(
$query->expr()->andx(
$query->expr()->gt('v.endDate', ':now'),
$query->expr()->eq('c.active', 'true'),
$query->expr()->eq('v.removed', 'FALSE'),
$query->expr()->eq('v.approved', 'TRUE')
)
)
->setParameter('now', new DateTime())
->orderBy('v.dateUpdated', 'DESC')
->getQuery();
}

/**
* @param CompanyEntity $company
* @param string $type
Expand Down

0 comments on commit 041d9a8

Please sign in to comment.