diff --git a/app/Config/routes.php b/app/Config/routes.php index b683bf3..8f99ea9 100755 --- a/app/Config/routes.php +++ b/app/Config/routes.php @@ -37,6 +37,7 @@ Router::connect('/opening', array('controller' => 'job', 'action' => 'openingList')); Router::connect('/opening/add', array('controller' => 'job', 'action' => 'openingAdd')); + Router::connect('/opening/edit/:id', array('controller' => 'job', 'action' => 'openingEdit'),array("id" => "[0-9]+")); Router::connect('/opening/:id', array('controller' => 'job', 'action' => 'openingGet'),array("id" => "[0-9]+")); Router::connect('/opening/:id/:favorite', array('controller' => 'job', 'action' => 'openingGet'), array("id" => "[0-9]+",'favorite' => '(?i:favorite)')); diff --git a/app/Controller/JobController.php b/app/Controller/JobController.php index bf3d779..667e53f 100644 --- a/app/Controller/JobController.php +++ b/app/Controller/JobController.php @@ -24,6 +24,10 @@ 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->MiconwareSession->setFlash('dreamjob.opening.delete','flash',array('alert'=>'success')); + } if(!is_array($self) and count($self) <= 0){ $this->set('error', 'dreamjob.error.noPermision'); $this->render('/Home/error'); @@ -35,6 +39,24 @@ class JobController extends AppController { } public function openingAdd() { } + public function openingEdit() { + $this->MiconwareSession->init($this); + $this->MiconwareSession->initWeb($this); + $opening = false; + + + if(!empty($this->request->params['id'])){ + $this->request->data = $this->DreamjobJobOpening->findById($this->request->params['id']); + } + + 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_edit'); + } + } public function openingGet() { $this->MiconwareSession->init($this); diff --git a/app/View/Elements/job_opening_item.ctp b/app/View/Elements/job_opening_item.ctp index a453c8f..efc27f5 100644 --- a/app/View/Elements/job_opening_item.ctp +++ b/app/View/Elements/job_opening_item.ctp @@ -5,7 +5,7 @@ $opening_in_app = false; $opening_in_fav=false; - if(is_array($WORKER) and count($WORKER)>0){ + if(isset($WORKER) and is_array($WORKER) and count($WORKER)>0){ foreach($WORKER['Favority'] as $val){ if($val['id'] == $opening['DreamjobJobOpening']['id']) $opening_in_fav=true; @@ -66,12 +66,13 @@ if($opening['AppUser']['take_systemwide']){
- Html->link(__('dreamjob.opening.detail'),array('controller'=>'job', 'action'=>'openingGet', 'id'=> $opening['DreamjobJobOpening']['id']),array("class" => "btn btn-default"));?> - - "> - - - + Html->link(__('dreamjob.opening.detail'),array('controller'=>'job', 'action'=>'openingGet', 'id'=> $opening['DreamjobJobOpening']['id']),array("class" => "btn btn-default")); + + if( isset($COMPANY['AppUser']['id']) and $COMPANY['AppUser']['id'] == $opening['DreamjobJobOpening']['company_id']){ + echo $this->Html->link(__('dreamjob.opening.edit'),array('controller'=>'job', 'action'=>'openingEdit', 'id'=> $opening['DreamjobJobOpening']['id']),array("class" => "btn btn-default")); + echo $this->Html->link(__('dreamjob.opening.delete'),array('controller'=>'job', 'action'=>'openingList', '?' => array('del'=> $opening['DreamjobJobOpening']['id'])),array("class" => "btn btn-default")); + }elseif(false){ ?> @@ -89,7 +90,7 @@ if($opening['AppUser']['take_systemwide']){ disabled" href="{% url de.miconware.dreamjob.jobs.views.application_send opening.pk %}"> diff --git a/update.sql b/update.sql index 776d920..266e9c2 100644 --- a/update.sql +++ b/update.sql @@ -9,13 +9,16 @@ -- + CREATE TABLE IF NOT EXISTS `mic_dj_job_opening_worker` ( + `id` int(11) NOT NULL AUTO_INCREMENT, `opening_id` int(11) NOT NULL, `worker_id` int(11) NOT NULL, + PRIMARY KEY (`id`), UNIQUE KEY `opening_id` (`opening_id`,`worker_id`), KEY `mic_dj_job_opening_worker_favOpening` (`opening_id`), KEY `mic_dj_job_opening_worker_favWorker` (`worker_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; --