1 |
www |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace LeadersLinked\Helper;
|
|
|
6 |
|
|
|
7 |
use Laminas\View\Helper\AbstractHelper;
|
|
|
8 |
use Laminas\Db\Adapter\AdapterInterface;
|
|
|
9 |
use LeadersLinked\Mapper\QueryMapper;
|
|
|
10 |
use LeadersLinked\Mapper\JobMapper;
|
|
|
11 |
use LeadersLinked\Mapper\LocationMapper;
|
|
|
12 |
|
|
|
13 |
class JobSuggestionHelper extends AbstractHelper
|
|
|
14 |
{
|
|
|
15 |
/**
|
|
|
16 |
*
|
|
|
17 |
* @var AdapterInterface
|
|
|
18 |
*/
|
|
|
19 |
private $adapter;
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
*
|
|
|
24 |
* @param AdapterInterface $adapter
|
|
|
25 |
*/
|
|
|
26 |
public function __construct($adapter)
|
|
|
27 |
{
|
|
|
28 |
$this->adapter = $adapter;
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
public function invoke($job_id)
|
|
|
32 |
{
|
|
|
33 |
$items = [];
|
|
|
34 |
|
|
|
35 |
$jobMapper = JobMapper::getInstance($this->adapter);
|
|
|
36 |
$job = $jobMapper->fetchOne($job_id);
|
|
|
37 |
|
|
|
38 |
if($job) {
|
|
|
39 |
|
|
|
40 |
$location = null;
|
|
|
41 |
if($job->location_id) {
|
|
|
42 |
$locationMapper = LocationMapper::getInstance($this->adapter);
|
|
|
43 |
$location = $locationMapper->fetchOne($job->location_id);
|
|
|
44 |
}
|
|
|
45 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
|
|
46 |
|
|
|
47 |
$select = $queryMapper->getSql()->select();
|
|
|
48 |
$select->columns(['id', 'title', 'job_category_id', 'employment_type', 'last_date_of_application']);
|
|
|
49 |
$select->from(['t' => JobMapper::_TABLE]);
|
|
|
50 |
$select->join(['l' => LocationMapper::_TABLE], 'j.location_id = l.id', ['state', 'country']);
|
|
|
51 |
$select->where->lessThan('last_date_of_application', date('Y-m-d'));
|
|
|
52 |
$select->where->equalTo('job_category_id', $job->job_category_id);
|
|
|
53 |
$select->where->equalTo('employment_type', $job->employment_type);
|
|
|
54 |
$select->where->equalTo('state', $location ? $location->state : '');
|
|
|
55 |
$select->where->equalTo('country', $location ? $location->country : '');
|
|
|
56 |
$select->limit(20);
|
|
|
57 |
$select->order(['last_date_of_application', 'title']);
|
|
|
58 |
|
|
|
59 |
$items = $queryMapper->fetchAll($select);
|
|
|
60 |
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
return $this->getView()->render('helpers/job-suggestions.phtml', ['items' => $items]);
|
|
|
64 |
}
|
|
|
65 |
}
|
|
|
66 |
|