2014-03-29 21:39:56 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
App::uses('AppController', 'Controller');
|
|
|
|
|
|
|
|
class SearchController extends AppController {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This controller use User Model
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
|
2014-04-16 18:24:34 +02:00
|
|
|
public $uses = array('DreamjobWorker','DreamjobJobOpening','DreamjobCompany',
|
2014-04-15 21:43:23 +02:00
|
|
|
'DreamjobListBranch','DreamjobListCity','DreamjobListKindofjob','DreamjobListGraducation');
|
2014-03-29 21:39:56 +01:00
|
|
|
public $components = array('MiconwareSession');
|
|
|
|
|
2014-04-17 11:10:14 +02:00
|
|
|
private static $TYPE_id = array('education'=>5,'academy'=>6,'internship'=>4);
|
|
|
|
|
|
|
|
|
2014-03-29 21:39:56 +01:00
|
|
|
/**
|
|
|
|
* Displays a view
|
|
|
|
*
|
|
|
|
* @param mixed What page to display
|
|
|
|
* @return void
|
|
|
|
* @throws NotFoundException When the view file could not be found
|
|
|
|
* or MissingViewException in debug mode.
|
|
|
|
*/
|
2014-04-16 15:34:02 +02:00
|
|
|
public function beforeFilter(){
|
2014-04-16 18:24:34 +02:00
|
|
|
$this->Security->unlockedActions[]="opening";
|
|
|
|
$this->Security->unlockedActions[]="company";
|
|
|
|
$this->Security->unlockedActions[]="auto";
|
|
|
|
$this->Security->unlockedActions[]="education";
|
|
|
|
$this->Security->unlockedActions[]="academy";
|
|
|
|
$this->Security->unlockedActions[]="internship";
|
2014-04-16 15:34:02 +02:00
|
|
|
parent::beforeFilter();
|
|
|
|
}
|
2014-04-16 18:24:34 +02:00
|
|
|
|
|
|
|
public function choose() {
|
|
|
|
$this->MiconwareSession->init($this);
|
|
|
|
|
|
|
|
$profil = $this->MiconwareSession->getCompany();
|
|
|
|
if(!empty($profil) and count($profil) > 0){
|
|
|
|
$this->worker();
|
|
|
|
}else{
|
|
|
|
$this->opening();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function spezial($type) {
|
|
|
|
$this->MiconwareSession->init($this);
|
|
|
|
$this->MiconwareSession->initWeb($this);
|
|
|
|
$profil = $this->MiconwareSession->getWorker();
|
2014-04-17 11:10:14 +02:00
|
|
|
if(!empty($profil) and count($profil) > 0 and isset(self::$TYPE_id[$type])){
|
2014-04-16 18:24:34 +02:00
|
|
|
$con = $this->MiconwareSession->getOpeningCondition();
|
2014-04-17 11:10:14 +02:00
|
|
|
$con['DreamjobJobOpening.kindofjob_id'] = self::$TYPE_id[$type];
|
2014-04-16 18:24:34 +02:00
|
|
|
|
2014-04-17 12:03:14 +02:00
|
|
|
if(!empty($this->request->data['DreamjobJobOpening']['branch_id']))
|
|
|
|
$con['DreamjobJobOpening.branch_id']=$this->request->data['DreamjobJobOpening']['branch_id'];
|
|
|
|
|
2014-04-17 12:55:09 +02:00
|
|
|
|
2014-04-17 12:03:14 +02:00
|
|
|
if(!empty($this->request->data['DreamjobJobOpening']['title']))
|
|
|
|
$con['DreamjobJobOpening.title LIKE'] = '%'.$this->request->data['DreamjobJobOpening']['title'].'%';
|
|
|
|
|
|
|
|
|
2014-04-16 18:24:34 +02:00
|
|
|
|
|
|
|
$openings = $this->DreamjobJobOpening->find('all',array('conditions' => $con));
|
|
|
|
$this->set("branches",$this->DreamjobListBranch->find('list'));
|
|
|
|
$this->set("cities",$this->DreamjobListCity->find('list'));
|
|
|
|
$this->set("openings",$openings);
|
|
|
|
$this->render('/Search/'.$type);
|
|
|
|
}else{
|
|
|
|
$this->set('error', 'dreamjob.error.noPermision');
|
|
|
|
$this->render('/Home/error');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function opening() {
|
2014-04-15 21:43:23 +02:00
|
|
|
$this->MiconwareSession->init($this);
|
|
|
|
|
|
|
|
$this->MiconwareSession->initWeb($this);
|
|
|
|
$con = $this->MiconwareSession->getOpeningCondition();
|
|
|
|
|
2014-04-17 12:03:14 +02:00
|
|
|
if(!empty($this->request->data['DreamjobJobOpening']['branch_id']))
|
|
|
|
$con['DreamjobJobOpening.graducation_id']=$this->request->data['DreamjobJobOpening']['branch_id'];
|
|
|
|
|
|
|
|
if(!empty($this->request->data['DreamjobJobOpening']['graducation_id']))
|
|
|
|
$con['DreamjobJobOpening.graducation_id']=$this->request->data['DreamjobJobOpening']['graducation_id'];
|
|
|
|
|
|
|
|
if(!empty($this->request->data['DreamjobJobOpening']['kindofjob_id']))
|
|
|
|
$con['DreamjobJobOpening.kindofjob_id']=$this->request->data['DreamjobJobOpening']['kindofjob_id'];
|
|
|
|
|
2014-04-17 12:55:09 +02:00
|
|
|
if(!empty($this->request->data['DreamjobJobOpening']['city']) and $this->request->data['DreamjobJobOpening']['city'] != 48){
|
|
|
|
$con['DreamjobJobOpening.city LIKE']=$this->DreamjobListCity->find('first',array('conditions' => array('id'=>$this->request->data['DreamjobJobOpening']['city'])));
|
|
|
|
$con['DreamjobJobOpening.city LIKE']='%'.$con['DreamjobJobOpening.city LIKE']['DreamjobListCity']['name'].'%';
|
|
|
|
}
|
2014-04-17 12:03:14 +02:00
|
|
|
if(!empty($this->request->data['DreamjobJobOpening']['postcode']))
|
|
|
|
$con['DreamjobJobOpening.postcode LIKE'] = '%'.$this->request->data['DreamjobJobOpening']['postcode'].'%';
|
|
|
|
|
|
|
|
if(!empty($this->request->data['DreamjobJobOpening']['title']))
|
|
|
|
$con['DreamjobJobOpening.title LIKE'] = '%'.$this->request->data['DreamjobJobOpening']['title'].'%';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$openings = $this->DreamjobJobOpening->find('all',array('conditions' => $con));
|
2014-04-15 21:43:23 +02:00
|
|
|
$this->set("branches",$this->DreamjobListBranch->find('list'));
|
|
|
|
$this->set("cities",$this->DreamjobListCity->find('list'));
|
|
|
|
$this->set("graducations",$this->DreamjobListGraducation->find('list'));
|
|
|
|
$this->set("kindofjobs",$this->DreamjobListKindofjob->find('list'));
|
|
|
|
|
|
|
|
$this->set("openings",$openings);
|
2014-04-16 18:24:34 +02:00
|
|
|
$this->render('/Search/opening');
|
2014-04-15 21:43:23 +02:00
|
|
|
|
|
|
|
}
|
2014-04-16 18:24:34 +02:00
|
|
|
public function company() {
|
|
|
|
$this->MiconwareSession->init($this);
|
|
|
|
|
|
|
|
$this->MiconwareSession->initWeb($this);
|
|
|
|
|
2014-04-17 12:03:14 +02:00
|
|
|
$con=array();
|
|
|
|
if(!empty($this->request->data['DreamjobCompany']['branch_id']))
|
|
|
|
$con['DreamjobCompany.branch_id']=$this->request->data['DreamjobCompany']['branch_id'];
|
2014-04-17 11:10:14 +02:00
|
|
|
|
2014-04-17 12:55:09 +02:00
|
|
|
if(!empty($this->request->data['DreamjobUser']['city']) and $this->request->data['DreamjobUser']['city'] != 48){
|
|
|
|
$con['DreamjobUser.city']=$this->DreamjobListCity->find('first',array('conditions' => array('id'=>$this->request->data['DreamjobUser']['city'])));
|
|
|
|
$con['DreamjobUser.city']=$con['DreamjobUser.city']['DreamjobListCity']['name'];
|
|
|
|
}
|
2014-04-17 12:03:14 +02:00
|
|
|
if(!empty($this->request->data['AppUser']['nickname']))
|
|
|
|
$con['AppUser.nickname LIKE'] = '%'.$this->request->data['AppUser']['nickname'].'%';
|
|
|
|
|
|
|
|
$companies = $this->DreamjobCompany->find('all',array('conditions' => $con));
|
2014-04-16 18:24:34 +02:00
|
|
|
|
|
|
|
$this->set("branches",$this->DreamjobListBranch->find('list'));
|
|
|
|
$this->set("cities",$this->DreamjobListCity->find('list'));
|
|
|
|
|
|
|
|
$this->set("companies",$companies);
|
|
|
|
$this->render('/Search/company');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function auto() {
|
|
|
|
$this->MiconwareSession->init($this);
|
|
|
|
|
|
|
|
$this->MiconwareSession->initWeb($this);
|
|
|
|
$profil = $this->MiconwareSession->getWorker();
|
|
|
|
if(!empty($profil) and count($profil) > 0){
|
|
|
|
$con = $this->MiconwareSession->getOpeningCondition();
|
2014-04-17 12:03:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-16 18:24:34 +02:00
|
|
|
$openings = $this->DreamjobJobOpening->find('all',array('conditions' => $con));
|
|
|
|
$this->set("openings",$openings);
|
|
|
|
$this->render('/Search/auto');
|
|
|
|
}else{
|
|
|
|
$this->set('error', 'dreamjob.error.noPermision');
|
|
|
|
$this->render('/Home/error');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function worker(){
|
2014-03-29 21:39:56 +01:00
|
|
|
$this->MiconwareSession->init($this);
|
|
|
|
|
|
|
|
$this->MiconwareSession->initWeb($this);
|
|
|
|
$profil = $this->MiconwareSession->getCompany();
|
|
|
|
if(!empty($profil) and count($profil) > 0){
|
|
|
|
$workers = $this->DreamjobWorker->find('all',array('conditions' => array('DreamjobWorker.searchhidden'=>false)));
|
|
|
|
$this->set("workers",$workers);
|
2014-04-16 18:24:34 +02:00
|
|
|
$this->render('/Search/worker');
|
2014-03-29 21:39:56 +01:00
|
|
|
}else{
|
2014-04-16 18:24:34 +02:00
|
|
|
$this->set('error', 'dreamjob.error.noPermision');
|
|
|
|
$this->render('/Home/error');
|
2014-03-29 21:39:56 +01:00
|
|
|
}
|
2014-04-16 18:24:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function education() {
|
|
|
|
$this->spezial('education');
|
|
|
|
|
|
|
|
}
|
|
|
|
public function academy() {
|
|
|
|
$this->spezial('academy');
|
|
|
|
|
|
|
|
}
|
|
|
|
public function internship() {
|
|
|
|
$this->spezial('internship');
|
|
|
|
|
|
|
|
}
|
2014-03-29 21:39:56 +01:00
|
|
|
}
|