workersuche mit isearch + subquery :(

This commit is contained in:
Martin Müller 2014-05-11 13:36:55 +02:00
parent 6b932ffb78
commit 315fe1ab67
2 changed files with 218 additions and 197 deletions

View File

@ -4,189 +4,207 @@ App::uses('AppController', 'Controller');
class SearchController extends AppController { class SearchController extends AppController {
/** /**
* This controller use User Model * This controller use User Model
* *
* @var array * @var array
*/ */
public $uses = array('DreamjobWorker', 'DreamjobJobOpening', 'DreamjobCompany','DreamjobISearch',
public $uses = array('DreamjobWorker','DreamjobJobOpening','DreamjobCompany', 'DreamjobListBranch', 'DreamjobListCity', 'DreamjobListJob', 'DreamjobListKindofjob', 'DreamjobListGraducation');
'DreamjobListBranch','DreamjobListCity','DreamjobListKindofjob','DreamjobListGraducation'); public $components = array('MiconwareSession');
public $components = array('MiconwareSession'); private static $TYPE_id = array('education' => 5, 'academy' => 6, 'internship' => 4);
private static $TYPE_id = array('education'=>5,'academy'=>6,'internship'=>4); /**
* Displays a view
*
/** * @param mixed What page to display
* Displays a view * @return void
* * @throws NotFoundException When the view file could not be found
* @param mixed What page to display * or MissingViewException in debug mode.
* @return void */
* @throws NotFoundException When the view file could not be found public function beforeFilter() {
* or MissingViewException in debug mode. $this->Security->unlockedActions[] = "opening";
*/ $this->Security->unlockedActions[] = "company";
public function beforeFilter(){ $this->Security->unlockedActions[] = "worker";
$this->Security->unlockedActions[]="opening"; $this->Security->unlockedActions[] = "auto";
$this->Security->unlockedActions[]="company"; $this->Security->unlockedActions[] = "education";
$this->Security->unlockedActions[]="auto"; $this->Security->unlockedActions[] = "academy";
$this->Security->unlockedActions[]="education"; $this->Security->unlockedActions[] = "internship";
$this->Security->unlockedActions[]="academy"; parent::beforeFilter();
$this->Security->unlockedActions[]="internship"; $this->set('MENU_SEARCH', true);
parent::beforeFilter(); }
$this->set('MENU_SEARCH', true);
} public function choose() {
$this->MiconwareSession->init($this);
public function choose() {
$this->MiconwareSession->init($this); $profil = $this->MiconwareSession->getCompany();
if (!empty($profil) and count($profil) > 0) {
$profil = $this->MiconwareSession->getCompany(); $this->worker();
if(!empty($profil) and count($profil) > 0){ } else {
$this->worker(); $this->opening();
}else{ }
$this->opening(); }
}
} private function spezial($type) {
$this->MiconwareSession->init($this);
private function spezial($type) { $this->MiconwareSession->initWeb($this);
$this->MiconwareSession->init($this); $profil = $this->MiconwareSession->getWorker();
$this->MiconwareSession->initWeb($this); if (!empty($profil) and count($profil) > 0 and isset(self::$TYPE_id[$type])) {
$profil = $this->MiconwareSession->getWorker(); $con = $this->MiconwareSession->getOpeningCondition();
if(!empty($profil) and count($profil) > 0 and isset(self::$TYPE_id[$type])){ $con['DreamjobJobOpening.kindofjob_id'] = 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']['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['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'];
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'));
$openings = $this->DreamjobJobOpening->find('all',array('conditions' => $con)); $this->set("cities", $this->DreamjobListCity->find('list'));
$this->set("branches",$this->DreamjobListBranch->find('list')); $this->set("openings", $openings);
$this->set("cities",$this->DreamjobListCity->find('list')); $this->render('/Search/' . $type);
$this->set("openings",$openings); } else {
$this->render('/Search/'.$type); $this->set('error', 'dreamjob.error.noPermision');
}else{ $this->render('/Home/error');
$this->set('error', 'dreamjob.error.noPermision'); }
$this->render('/Home/error'); }
}
public function opening() {
} $this->MiconwareSession->init($this);
public function opening() { $this->MiconwareSession->initWeb($this);
$this->MiconwareSession->init($this); $con = $this->MiconwareSession->getOpeningCondition();
$this->MiconwareSession->initWeb($this); if (!empty($this->request->data['DreamjobJobOpening']['branch_id']))
$con = $this->MiconwareSession->getOpeningCondition(); $con['DreamjobJobOpening.graducation_id'] = $this->request->data['DreamjobJobOpening']['branch_id'];
if(!empty($this->request->data['DreamjobJobOpening']['branch_id'])) if (!empty($this->request->data['DreamjobJobOpening']['graducation_id']))
$con['DreamjobJobOpening.graducation_id']=$this->request->data['DreamjobJobOpening']['branch_id']; $con['DreamjobJobOpening.graducation_id'] = $this->request->data['DreamjobJobOpening']['graducation_id'];
if(!empty($this->request->data['DreamjobJobOpening']['graducation_id'])) if (!empty($this->request->data['DreamjobJobOpening']['kindofjob_id']))
$con['DreamjobJobOpening.graducation_id']=$this->request->data['DreamjobJobOpening']['graducation_id']; $con['DreamjobJobOpening.kindofjob_id'] = $this->request->data['DreamjobJobOpening']['kindofjob_id'];
if(!empty($this->request->data['DreamjobJobOpening']['kindofjob_id'])) if (!empty($this->request->data['DreamjobJobOpening']['city']) and $this->request->data['DreamjobJobOpening']['city'] != 48) {
$con['DreamjobJobOpening.kindofjob_id']=$this->request->data['DreamjobJobOpening']['kindofjob_id']; $con['DreamjobJobOpening.city_id'] = $this->request->data['DreamjobJobOpening']['city'];
}
if(!empty($this->request->data['DreamjobJobOpening']['city']) and $this->request->data['DreamjobJobOpening']['city'] != 48){ if (!empty($this->request->data['DreamjobJobOpening']['postcode']))
$con['DreamjobJobOpening.city_id']=$this->request->data['DreamjobJobOpening']['city']; $con['DreamjobJobOpening.postcode LIKE'] = '%' . $this->request->data['DreamjobJobOpening']['postcode'] . '%';
}
if(!empty($this->request->data['DreamjobJobOpening']['postcode'])) if (!empty($this->request->data['DreamjobJobOpening']['title']))
$con['DreamjobJobOpening.postcode LIKE'] = '%'.$this->request->data['DreamjobJobOpening']['postcode'].'%'; $con['DreamjobJobOpening.title LIKE'] = '%' . $this->request->data['DreamjobJobOpening']['title'] . '%';
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'));
$openings = $this->DreamjobJobOpening->find('all',array('conditions' => $con)); $this->set("graducations", $this->DreamjobListGraducation->find('list'));
$this->set("branches",$this->DreamjobListBranch->find('list')); $this->set("kindofjobs", $this->DreamjobListKindofjob->find('list'));
$this->set("cities",$this->DreamjobListCity->find('list'));
$this->set("graducations",$this->DreamjobListGraducation->find('list')); $this->set("openings", $openings);
$this->set("kindofjobs",$this->DreamjobListKindofjob->find('list')); $this->render('/Search/opening');
}
$this->set("openings",$openings);
$this->render('/Search/opening'); public function company() {
$this->MiconwareSession->init($this);
}
public function company() { $this->MiconwareSession->initWeb($this);
$this->MiconwareSession->init($this);
$con = array();
$this->MiconwareSession->initWeb($this); if (!empty($this->request->data['DreamjobCompany']['branch_id']))
$con['DreamjobCompany.branch_id'] = $this->request->data['DreamjobCompany']['branch_id'];
$con=array();
if(!empty($this->request->data['DreamjobCompany']['branch_id'])) if (!empty($this->request->data['DreamjobUser']['city']) and $this->request->data['DreamjobUser']['city'] != 48) {
$con['DreamjobCompany.branch_id']=$this->request->data['DreamjobCompany']['branch_id']; $con['DreamjobUser.city_id'] = $this->request->data['DreamjobUser']['city'];
}
if(!empty($this->request->data['DreamjobUser']['city']) and $this->request->data['DreamjobUser']['city'] != 48){ if (!empty($this->request->data['AppUser']['nickname']))
$con['DreamjobUser.city_id']=$this->request->data['DreamjobUser']['city']; $con['AppUser.nickname LIKE'] = '%' . $this->request->data['AppUser']['nickname'] . '%';
}
if(!empty($this->request->data['AppUser']['nickname'])) $companies = $this->DreamjobCompany->find('all', array('conditions' => $con));
$con['AppUser.nickname LIKE'] = '%'.$this->request->data['AppUser']['nickname'].'%';
$this->set("branches", $this->DreamjobListBranch->find('list'));
$companies = $this->DreamjobCompany->find('all',array('conditions' => $con)); $this->set("cities", $this->DreamjobListCity->find('list'));
$this->set("branches",$this->DreamjobListBranch->find('list')); $this->set("companies", $companies);
$this->set("cities",$this->DreamjobListCity->find('list')); $this->render('/Search/company');
}
$this->set("companies",$companies);
$this->render('/Search/company'); public function auto() {
$this->MiconwareSession->init($this);
}
$this->MiconwareSession->initWeb($this);
public function auto() { $profil = $this->MiconwareSession->getWorker();
$this->MiconwareSession->init($this); if (!empty($profil) and count($profil) > 0) {
$con = $this->MiconwareSession->getOpeningCondition();
$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 {
$openings = $this->DreamjobJobOpening->find('all',array('conditions' => $con)); $this->set('error', 'dreamjob.error.noPermision');
$this->set("openings",$openings); $this->render('/Home/error');
$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);
public function worker(){ $profil = $this->MiconwareSession->getCompany();
$this->MiconwareSession->init($this); if (!empty($profil) and count($profil) > 0) {
$con = array('DreamjobWorker.searchhidden' => false);
$this->MiconwareSession->initWeb($this); $con2 = array();
$profil = $this->MiconwareSession->getCompany();
if(!empty($profil) and count($profil) > 0){ if (!empty($this->request->data['DreamjobISearch']['branch_id']))
//TODO iam $con2['DreamjobISearch.branch_id'] = $this->request->data['DreamjobISearch']['branch_id'];
$workers = $this->DreamjobWorker->find('all',array('conditions' => array('DreamjobWorker.searchhidden'=>false)));
$this->set("workers",$workers); if (!empty($this->request->data['DreamjobISearch']['job_id']))
$this->render('/Search/worker'); $con2['DreamjobISearch.job_id'] = $this->request->data['DreamjobISearch']['job_id'];
}else{
$this->set('error', 'dreamjob.error.noPermision'); if (!empty($this->request->data['DreamjobISearch']['kindofjob_id']))
$this->render('/Home/error'); $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();
public function education() { foreach ($a as $b)
$this->spezial('education'); $c[] = $b['DreamjobISearch']['worker_id'];
$con['DreamjobWorker.djaccount_ptr_id'] =$c;
} }
public function academy() { var_dump($con);
$this->spezial('academy'); $workers = $this->DreamjobWorker->find('all', array('conditions' => $con));
} $this->set("workers", $workers);
public function internship() { $this->set("branches", $this->DreamjobListBranch->find('list'));
$this->spezial('internship'); $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');
}
} }

View File

@ -1,7 +1,7 @@
<?php <?php
/* /*
* *
*/ */
?> ?>
<div class="box"> <div class="box">
<?php <?php
@ -11,7 +11,7 @@
$a['novalidate'] = true; $a['novalidate'] = true;
echo $this->Form->create('DreamjobWorker',$a); echo $this->Form->create('DreamjobWorker',$a);
?> ?>
<h3><?=__('dreamjob.search.worker');?></h3> <h3><?=__('dreamjob.search.worker');?></h3>
<?php <?php
$a = $default_hForm['inputDefaults']; $a = $default_hForm['inputDefaults'];
$a['between'] = false; $a['between'] = false;
@ -19,23 +19,26 @@
$a['placeholder'] = __('dreamjob.search.worker.placeholder'); $a['placeholder'] = __('dreamjob.search.worker.placeholder');
echo $this->Form->input('DreamjobWorker.name',$a); echo $this->Form->input('DreamjobWorker.name',$a);
?> ?>
<fieldset class="search"> <fieldset class="search">
<div class="form-group submit"> <?=$this->Form->input('DreamjobISearch.branch_id',array('label'=>__('dreamjob.branch'),'empty'=>__('dreamjob.chooseOne')));?>
<div> <?=$this->Form->input('DreamjobISearch.job_id',array('label'=>__('dreamjob.job'),'empty'=>__('dreamjob.chooseOne')));?>
<?=$this->Form->input('DreamjobISearch.kindofjob_id',array('label'=>__('dreamjob.kindofjob'),'empty'=>__('dreamjob.chooseOne')));?>
<div class="form-group submit">
<div>
<?=$this->Form->submit(__('dreamjob.search'),array('class'=>'btn btn-primary'));?> <?=$this->Form->submit(__('dreamjob.search'),array('class'=>'btn btn-primary'));?>
</div> </div>
</div> </div>
</fieldset> </fieldset>
<?php <?php
echo $this->end(); echo $this->end();
?> ?>
</div> </div>
<div class="box"> <div class="box">
<div class="openinggroup"> <div class="openinggroup">
<?php <?php
foreach($workers as $worker){ foreach($workers as $worker){
echo $this->element('user_worker_item',array('profil' => $worker)); echo $this->element('user_worker_item',array('profil' => $worker));
} }
?> ?>
</div> </div>
</div> </div>