diff --git a/app/Controller/JobController.php b/app/Controller/JobController.php index 667e53f..e7f01ec 100644 --- a/app/Controller/JobController.php +++ b/app/Controller/JobController.php @@ -25,7 +25,7 @@ class JobController extends AppController { $this->MiconwareSession->initWeb($this); $self = $this->MiconwareSession->getCompany(); if(!empty($this->request->query['del'])){ - //$this->DreamjobJobFavority->delete($this->request->query['del'],false); + $this->DreamjobJobFavority->delete($this->request->query['del'],false); $this->MiconwareSession->setFlash('dreamjob.opening.delete','flash',array('alert'=>'success')); } if(!is_array($self) and count($self) <= 0){ @@ -38,22 +38,66 @@ 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{ + if ($this->request->is('post')) { + $this->DreamjobJobOpening->create($this->request->data); + $this->DreamjobJobOpening->data['DreamjobJobOpening']['company_id'] = $this->MiconwareSession->getCompany()['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->render('/Job/opening_edit'); + } } public function openingEdit() { $this->MiconwareSession->init($this); $this->MiconwareSession->initWeb($this); - $opening = false; - + $a = $this->MiconwareSession->getCompany(); + if(empty($a)){ + $this->set('error', 'dreamjob.error.noCompany'); + $this->render('/Home/error'); + return null; + } if(!empty($this->request->params['id'])){ - $this->request->data = $this->DreamjobJobOpening->findById($this->request->params['id']); + $load = $this->DreamjobJobOpening->findById($this->request->params['id']); + $cid = $a['AppUser']['id']; + if (!empty($load) and $load['DreamjobJobOpening']['company_id'] == $cid) { + if ($this->request->is(array('post', 'put'))) { + $this->DreamjobJobOpening->create($this->request->data); + $this->DreamjobJobOpening->data['DreamjobJobOpening']['id'] = $this->request->params['id']; + $this->DreamjobJobOpening->data['DreamjobJobOpening']['company_id'] = $cid; + echo var_dump($this->DreamjobJobOpening); + if ($this->DreamjobJobOpening->save($this->DreamjobJobOpening->data)) { + $this->MiconwareSession->setFlash('dreamjob.opening.save','flash',array('alert'=>'success')); + + }else + $this->MiconwareSession->setFlash('dreamjob.opening.save.error','flash',array('alert'=>'danger')); + } + } + $this->request->data=$load; + $this->set('kindofjobs', $this->DreamjobJobOpening->DreamjobListKindofjob->find('list')); + $this->set('graducations', $this->DreamjobJobOpening->DreamjobListGraducation->find('list')); } - if(!is_array($opening) and count($opening) <= 0 ){ + if(empty($this->request->data['DreamjobJobOpening'])){ $this->set('error', 'dreamjob.error.opening.notFound'); $this->render('/Home/error'); + }elseif( $this->request->data['DreamjobJobOpening']['company_id'] != $a['AppUser']['id']){ + $this->set('error', 'dreamjob.error.noPermission'); + $this->render('/Home/error'); }else{ - $this->set('opening',$opening); $this->render('/Job/opening_edit'); } } diff --git a/app/Model/DreamjobJobOpening.php b/app/Model/DreamjobJobOpening.php index c874fb7..bc08331 100644 --- a/app/Model/DreamjobJobOpening.php +++ b/app/Model/DreamjobJobOpening.php @@ -44,15 +44,7 @@ class DreamjobJobOpening extends AppModel { //'required' => false, //'last' => false, // Stop validation after this rule //'on' => 'create', // Limit validation to 'create' or 'update' operations - ), - 'userDefined' => array( - 'rule' => array('userDefined'), - //'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 - ), + ) ), 'street' => array( 'notEmpty' => array( diff --git a/app/View/Elements/barleft.ctp b/app/View/Elements/barleft.ctp index 2de58bc..c01f3f3 100755 --- a/app/View/Elements/barleft.ctp +++ b/app/View/Elements/barleft.ctp @@ -15,6 +15,7 @@ if($isLoggedin){ } .column-center{ padding-left:50px; + width:1010px; } --> diff --git a/app/View/Job/opening_edit.ctp b/app/View/Job/opening_edit.ctp index 08af7a2..bae1169 100644 --- a/app/View/Job/opening_edit.ctp +++ b/app/View/Job/opening_edit.ctp @@ -20,122 +20,34 @@ echo $this->Form->create('DreamjobJobOpening',$default_Form); */ - echo $this->request->data['DreamjobJobOpening']['title']; + echo $this->Form->hidden("DreamjobJobOpening.company_id"); + if(!empty($this->request->data['DreamjobJobOpening'])) + echo $this->request->data['DreamjobJobOpening']['title']; + else + echo __("dreamjob.opening.addForm"); ?> - Form->input('DreamjobJobOpening.title',array('label'=>__("dreamjob.title"))); ?> -