diff --git a/app/Controller/JobController.php b/app/Controller/JobController.php index 528f703..c250c6e 100644 --- a/app/Controller/JobController.php +++ b/app/Controller/JobController.php @@ -42,24 +42,23 @@ class JobController extends AppController { public function openingAdd() { $this->MiconwareSession->init($this); $this->MiconwareSession->initWeb($this); - /* - $this->set('kindofjobs', $this->DreamjobJobOpening->DreamjobListKindofjob->find('list')); - $this->set('graducations', $this->DreamjobJobOpening->DreamjobListGraducation->find('list')); - */ - if(empty($this->MiconwareSession->getCompany())){ - $this->set('error', 'dreamjob.error.noCompany'); - $this->render('/Home/error'); - }else{ + $c = $this->MiconwareSession->getCompany(); + if(!empty($c)){ if ($this->request->is('post')) { $this->DreamjobJobOpening->create($this->request->data); - $this->DreamjobJobOpening->data['DreamjobJobOpening']['company_id'] = $this->MiconwareSession->getCompany()['AppUser']['id']; + $this->DreamjobJobOpening->data['DreamjobJobOpening']['company_id'] = $c['AppUser']['id']; if ($this->DreamjobJobOpening->save()) { $this->MiconwareSession->setFlash('dreamjob.opening.save.add','flash',array('alert'=>'success')); }else{ $this->MiconwareSession->setFlash('dreamjob.opening.save.error','flash',array('alert'=>'danger')); } } + $this->set('kindofjobs', $this->DreamjobJobOpening->DreamjobListKindofjob->find('list')); + $this->set('graducations', $this->DreamjobJobOpening->DreamjobListGraducation->find('list')); $this->render('/Job/opening_edit'); + }else{ + $this->set('error', 'dreamjob.error.noCompany'); + $this->render('/Home/error'); } } public function openingEdit() {