diff --git a/app/Controller/JobController.php b/app/Controller/JobController.php new file mode 100644 index 0000000..8f0e0f3 --- /dev/null +++ b/app/Controller/JobController.php @@ -0,0 +1,98 @@ +MiconwareSession->init($this); + + $this->MiconwareSession->initWeb($this); + $self = $this->MiconwareSession->getCompany(); + if(!is_array($self) and count($self) <= 0){ + $this->set('error', 'dreamjob.error.noPermision'); + $this->render('/Home/error'); + }else{ + $openings = $this->DreamjobJobOpening->find('all',array('conditions' => array('DreamjobJobOpening.company_id' => $self['AppUser']['id']))); + $this->set('openings',$openings); + $this->render('/Job/opening_list'); + } + } + public function openingAdd() { + } + + public function openingGet() { + $this->MiconwareSession->init($this); + + $opening = false; + + + if(!empty($this->request->params['id'])){ + if(!empty($this->request->params['favorite']) and count($this->request->params['favorite'])>0){ + $WORKER = $this->MiconwareSession->getWorker(); + $fav=false; + foreach($WORKER['Favority'] as $val){ + if($val['id'] == $this->request->params['id']) + $fav=true; + } + $data = array('DreamjobJobFavority' => array('opening_id' => $this->request->params['id'], 'worker_id' => $WORKER['AppUser']['id'])); + $data2 = array('DreamjobJobFavority.opening_id' => $this->request->params['id'], 'DreamjobJobFavority.worker_id' => $WORKER['AppUser']['id']); + if($fav){ + $this->MiconwareSession->setFlash('dreamjob.opening.fav.delete','flash',array('alert'=>'success')); + $this->DreamjobJobFavority->deleteAll($data2,false); + }else{ + $this->DreamjobJobFavority->create(); + $this->DreamjobJobFavority->save($data); + $this->MiconwareSession->setFlash('dreamjob.opening.fav.add','flash',array('alert'=>'success')); + } + } + $opening = $this->DreamjobJobOpening->find('first',array('conditions' => array('DreamjobJobOpening.id' => $this->request->params['id']))); + } + + + $this->MiconwareSession->refreshCache(); + $this->MiconwareSession->initWeb($this); + + if(!is_array($opening) and count($opening) <= 0 ){ + $this->set('error', 'dreamjob.error.opening.notFound'); + $this->render('/Home/error'); + }else{ + $this->set('opening',$opening); + $this->render('/Job/opening'); + } + } + + public function favorite() { + $this->MiconwareSession->init($this); + + $this->MiconwareSession->initWeb($this); + $self = $this->MiconwareSession->getWorker(); + if(!is_array($self) and count($self) <= 0){ + $this->set('error', 'dreamjob.error.noPermision'); + $this->render('/Home/error'); + }else{ + $fav_id = array(); + foreach($self['Favority'] as $fav) + $fav_id[]=$fav['id']; + $openings = $this->DreamjobJobOpening->find('all',array('conditions' => array('DreamjobJobOpening.id' =>$fav_id))); + $this->set('openings',$openings); + $this->render('/Job/favorite'); + } + } +} +?> diff --git a/app/Model/DreamjobJobFavority.php b/app/Model/DreamjobJobFavority.php new file mode 100644 index 0000000..f7c40c6 --- /dev/null +++ b/app/Model/DreamjobJobFavority.php @@ -0,0 +1,50 @@ + array( + 'numeric' => array( + 'rule' => array('numeric'), + //'message' => 'Your custom message here', + //'allowEmpty' => false, + //'required' => false, + //'last' => false, // Stop validation after this rule + //'on' => 'create', // Limit validation to 'create' or 'update' operations + ), + ), + 'opening_id' => array( + 'numeric' => array( + 'rule' => array('numeric'), + //'message' => 'Your custom message here', + //'allowEmpty' => false, + //'required' => false, + //'last' => false, // Stop validation after this rule + //'on' => 'create', // Limit validation to 'create' or 'update' operations + ), + ), + ); + + + public $belongsTo = array( + 'DreamjobWorker' => array( + 'className' => 'DreamjobWorker', + 'foreignKey' => 'worker_id' + ), + 'DreamjobJobOpening' => array( + 'className' => 'DreamjobJobOpening', + 'foreignKey' => 'opening_id' + ) + ); +} + diff --git a/app/View/Job/favorite.ctp b/app/View/Job/favorite.ctp new file mode 100644 index 0000000..4c9479b --- /dev/null +++ b/app/View/Job/favorite.ctp @@ -0,0 +1,15 @@ + +
+
+
+ =__("dreamjob.address");?>:
+ =$opening['DreamjobUser']['street'];?>
+ =$opening['DreamjobUser']['postcode']." ".$opening['DreamjobUser']['city'];?>
+