dreamjob/app/Controller/SearchController.php

150 lines
4.2 KiB
PHP
Raw Normal View History

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
$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();
$openings = $this->DreamjobJobOpening->find('all',array('conditions' => $con));
$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 11:10:14 +02:00
echo var_dump($this->request->data);
2014-04-16 18:24:34 +02:00
$companies = $this->DreamjobCompany->find('all');
$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();
$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
}