From 315fe1ab67c1b782a1e498f615437c345afa6de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=BCller?= Date: Sun, 11 May 2014 13:36:55 +0200 Subject: [PATCH] workersuche mit isearch + subquery :( --- app/Controller/SearchController.php | 388 +++++++++++++++------------- app/View/Search/worker.ctp | 27 +- 2 files changed, 218 insertions(+), 197 deletions(-) diff --git a/app/Controller/SearchController.php b/app/Controller/SearchController.php index 6a5f645..ca674b0 100644 --- a/app/Controller/SearchController.php +++ b/app/Controller/SearchController.php @@ -4,189 +4,207 @@ App::uses('AppController', 'Controller'); class SearchController extends AppController { - /** - * This controller use User Model - * - * @var array - */ - - public $uses = array('DreamjobWorker','DreamjobJobOpening','DreamjobCompany', - 'DreamjobListBranch','DreamjobListCity','DreamjobListKindofjob','DreamjobListGraducation'); - public $components = array('MiconwareSession'); - - private static $TYPE_id = array('education'=>5,'academy'=>6,'internship'=>4); - - - /** - * 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. - */ - public function beforeFilter(){ - $this->Security->unlockedActions[]="opening"; - $this->Security->unlockedActions[]="company"; - $this->Security->unlockedActions[]="auto"; - $this->Security->unlockedActions[]="education"; - $this->Security->unlockedActions[]="academy"; - $this->Security->unlockedActions[]="internship"; - parent::beforeFilter(); - $this->set('MENU_SEARCH', true); - } - - 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(); - if(!empty($profil) and count($profil) > 0 and isset(self::$TYPE_id[$type])){ - $con = $this->MiconwareSession->getOpeningCondition(); - $con['DreamjobJobOpening.kindofjob_id'] = self::$TYPE_id[$type]; - - if(!empty($this->request->data['DreamjobJobOpening']['branch_id'])) - $con['DreamjobJobOpening.branch_id']=$this->request->data['DreamjobJobOpening']['branch_id']; - - - if(!empty($this->request->data['DreamjobJobOpening']['title'])) - $con['DreamjobJobOpening.title LIKE'] = '%'.$this->request->data['DreamjobJobOpening']['title'].'%'; - - if(!empty($this->request->data['DreamjobUser']['city']) and $this->request->data['DreamjobUser']['city'] != 48){ - $con['DreamjobUser.city_id']=$this->request->data['DreamjobUser']['city']; - } - - - $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() { - $this->MiconwareSession->init($this); - - $this->MiconwareSession->initWeb($this); - $con = $this->MiconwareSession->getOpeningCondition(); - - 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']; - - if(!empty($this->request->data['DreamjobJobOpening']['city']) and $this->request->data['DreamjobJobOpening']['city'] != 48){ - $con['DreamjobJobOpening.city_id']=$this->request->data['DreamjobJobOpening']['city']; - } - 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)); - $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); - $this->render('/Search/opening'); - - } - public function company() { - $this->MiconwareSession->init($this); - - $this->MiconwareSession->initWeb($this); - - $con=array(); - if(!empty($this->request->data['DreamjobCompany']['branch_id'])) - $con['DreamjobCompany.branch_id']=$this->request->data['DreamjobCompany']['branch_id']; - - if(!empty($this->request->data['DreamjobUser']['city']) and $this->request->data['DreamjobUser']['city'] != 48){ - $con['DreamjobUser.city_id']=$this->request->data['DreamjobUser']['city']; - } - if(!empty($this->request->data['AppUser']['nickname'])) - $con['AppUser.nickname LIKE'] = '%'.$this->request->data['AppUser']['nickname'].'%'; - - $companies = $this->DreamjobCompany->find('all',array('conditions' => $con)); - - $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(){ - $this->MiconwareSession->init($this); - - $this->MiconwareSession->initWeb($this); - $profil = $this->MiconwareSession->getCompany(); - if(!empty($profil) and count($profil) > 0){ - //TODO iam - $workers = $this->DreamjobWorker->find('all',array('conditions' => array('DreamjobWorker.searchhidden'=>false))); - $this->set("workers",$workers); - $this->render('/Search/worker'); - }else{ - $this->set('error', 'dreamjob.error.noPermision'); - $this->render('/Home/error'); - } - } - - - public function education() { - $this->spezial('education'); - - } - public function academy() { - $this->spezial('academy'); - - } - public function internship() { - $this->spezial('internship'); - - } + /** + * This controller use User Model + * + * @var array + */ + public $uses = array('DreamjobWorker', 'DreamjobJobOpening', 'DreamjobCompany','DreamjobISearch', + 'DreamjobListBranch', 'DreamjobListCity', 'DreamjobListJob', 'DreamjobListKindofjob', 'DreamjobListGraducation'); + public $components = array('MiconwareSession'); + private static $TYPE_id = array('education' => 5, 'academy' => 6, 'internship' => 4); + + /** + * 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. + */ + public function beforeFilter() { + $this->Security->unlockedActions[] = "opening"; + $this->Security->unlockedActions[] = "company"; + $this->Security->unlockedActions[] = "worker"; + $this->Security->unlockedActions[] = "auto"; + $this->Security->unlockedActions[] = "education"; + $this->Security->unlockedActions[] = "academy"; + $this->Security->unlockedActions[] = "internship"; + parent::beforeFilter(); + $this->set('MENU_SEARCH', true); + } + + 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(); + if (!empty($profil) and count($profil) > 0 and isset(self::$TYPE_id[$type])) { + $con = $this->MiconwareSession->getOpeningCondition(); + $con['DreamjobJobOpening.kindofjob_id'] = self::$TYPE_id[$type]; + + if (!empty($this->request->data['DreamjobJobOpening']['branch_id'])) + $con['DreamjobJobOpening.branch_id'] = $this->request->data['DreamjobJobOpening']['branch_id']; + + + if (!empty($this->request->data['DreamjobJobOpening']['title'])) + $con['DreamjobJobOpening.title LIKE'] = '%' . $this->request->data['DreamjobJobOpening']['title'] . '%'; + + if (!empty($this->request->data['DreamjobUser']['city']) and $this->request->data['DreamjobUser']['city'] != 48) { + $con['DreamjobUser.city_id'] = $this->request->data['DreamjobUser']['city']; + } + + + $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() { + $this->MiconwareSession->init($this); + + $this->MiconwareSession->initWeb($this); + $con = $this->MiconwareSession->getOpeningCondition(); + + 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']; + + if (!empty($this->request->data['DreamjobJobOpening']['city']) and $this->request->data['DreamjobJobOpening']['city'] != 48) { + $con['DreamjobJobOpening.city_id'] = $this->request->data['DreamjobJobOpening']['city']; + } + 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)); + $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); + $this->render('/Search/opening'); + } + + public function company() { + $this->MiconwareSession->init($this); + + $this->MiconwareSession->initWeb($this); + + $con = array(); + if (!empty($this->request->data['DreamjobCompany']['branch_id'])) + $con['DreamjobCompany.branch_id'] = $this->request->data['DreamjobCompany']['branch_id']; + + if (!empty($this->request->data['DreamjobUser']['city']) and $this->request->data['DreamjobUser']['city'] != 48) { + $con['DreamjobUser.city_id'] = $this->request->data['DreamjobUser']['city']; + } + if (!empty($this->request->data['AppUser']['nickname'])) + $con['AppUser.nickname LIKE'] = '%' . $this->request->data['AppUser']['nickname'] . '%'; + + $companies = $this->DreamjobCompany->find('all', array('conditions' => $con)); + + $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() { + $this->MiconwareSession->init($this); + + $this->MiconwareSession->initWeb($this); + $profil = $this->MiconwareSession->getCompany(); + if (!empty($profil) and count($profil) > 0) { + $con = array('DreamjobWorker.searchhidden' => false); + $con2 = array(); + + if (!empty($this->request->data['DreamjobISearch']['branch_id'])) + $con2['DreamjobISearch.branch_id'] = $this->request->data['DreamjobISearch']['branch_id']; + + if (!empty($this->request->data['DreamjobISearch']['job_id'])) + $con2['DreamjobISearch.job_id'] = $this->request->data['DreamjobISearch']['job_id']; + + if (!empty($this->request->data['DreamjobISearch']['kindofjob_id'])) + $con2['DreamjobISearch.kindofjob_id'] = $this->request->data['DreamjobISearch']['kindofjob_id']; + + if(count($con2)>0){ + $a = $this->DreamjobISearch->find('all',array('fields' => array('worker_id'),'recursive' => -1,'conditions' =>$con2)); + $c = array(); + foreach ($a as $b) + $c[] = $b['DreamjobISearch']['worker_id']; + $con['DreamjobWorker.djaccount_ptr_id'] =$c; + } + var_dump($con); + $workers = $this->DreamjobWorker->find('all', array('conditions' => $con)); + + $this->set("workers", $workers); + $this->set("branches", $this->DreamjobListBranch->find('list')); + $this->set("jobs", $this->DreamjobListJob->find('list')); + $this->set("kindofjobs", $this->DreamjobListKindofjob->find('list')); + $this->render('/Search/worker'); + }else { + $this->set('error', 'dreamjob.error.noPermision'); + $this->render('/Home/error'); + } + } + + public function education() { + $this->spezial('education'); + } + + public function academy() { + $this->spezial('academy'); + } + + public function internship() { + $this->spezial('internship'); + } + } diff --git a/app/View/Search/worker.ctp b/app/View/Search/worker.ctp index f7736dc..df12aed 100644 --- a/app/View/Search/worker.ctp +++ b/app/View/Search/worker.ctp @@ -1,7 +1,7 @@
Form->create('DreamjobWorker',$a); ?> -

+

Form->input('DreamjobWorker.name',$a); ?> - end(); ?>
-
+
element('user_worker_item',array('profil' => $worker)); } ?> -
+