From 14681036003e21d2ede8e488c12f498534000316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=BCller?= Date: Thu, 6 Nov 2014 19:19:34 +0100 Subject: [PATCH] Begrenzung stellenausschreibung + compareDate von < zu <= --- app/Controller/JobController.php | 15 ++++++++++++++- app/Model/DreamjobCvEntry.php | 2 +- app/webroot/js/dreamjob.js | 3 ++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/Controller/JobController.php b/app/Controller/JobController.php index 3ab6786..b6cdd0d 100644 --- a/app/Controller/JobController.php +++ b/app/Controller/JobController.php @@ -19,6 +19,9 @@ class JobController extends AppController { * @throws NotFoundException When the view file could not be found * or MissingViewException in debug mode. */ + private $OPENING_COUNT_GAP = 2; + + public function openingList() { $this->MiconwareSession->init($this); @@ -36,7 +39,7 @@ class JobController extends AppController { $o = $this->DreamjobJobOpening->findById($this->request->query['del']); if ($o['AppUser']['id'] == $self['AppUser']['id']) { $o['DreamjobJobOpening']['delete']=true; - $o['DreamjobJobOpening']['active']=false; + $o['DreamjobJobOpening']['active']=true; $this->DreamjobJobOpening->save($o); $this->MiconwareSession->setFlash(__('dreamjob.opening.delete.success'), 'flash', array('alert' => 'success')); } else { @@ -57,6 +60,9 @@ class JobController extends AppController { if ($this->request->is('post')) { $this->DreamjobJobOpening->create($this->request->data); $this->DreamjobJobOpening->data['DreamjobJobOpening']['company_id'] = $c['AppUser']['id']; + if(count($c['DreamjobJobOpening']) >= $this->OPENING_COUNT_GAP and !(strlen($c['DreamjobCompany']['bank_details'])>0)){ + $this->DreamjobJobOpening->data['DreamjobJobOpening']['active'] = false; + } if ($this->DreamjobJobOpening->save()) { $this->MiconwareSession->setFlash(__('dreamjob.opening.save.success'), 'flash', array('alert' => 'success')); if($this->request->data['DreamjobJobOpening']['active'] and $this->request->data['DreamjobJobOpening']['startdate'] <= date("Y-m-d") and $this->request->data['DreamjobJobOpening']['enddate'] >= date("Y-m-d", strtotime("+1 day") ) ) @@ -65,6 +71,10 @@ class JobController extends AppController { $this->MiconwareSession->setFlash(__('dreamjob.opening.save.error'), 'flash', array('alert' => 'danger')); } }else{ + if(strlen($c['DreamjobCompany']['bank_details']) > 0){ + $this->MiconwareSession->setFlash(__('dreamjob.opening.count.thanks'), 'flash', array('alert' => 'success')); + }else if(count($c['DreamjobJobOpening']) >= $this->OPENING_COUNT_GAP) + $this->MiconwareSession->setFlash(__('dreamjob.opening.count'), 'flash', array('alert' => 'danger')); $this->request->data['DreamjobJobOpening']['active']=true; } $this->set('kindofjobs', $this->DreamjobJobOpening->DreamjobListKindofjob->find('list')); @@ -101,6 +111,9 @@ class JobController extends AppController { $this->DreamjobJobOpening->create($this->request->data); $this->DreamjobJobOpening->data['DreamjobJobOpening']['id'] = $this->request->params['id']; $this->DreamjobJobOpening->data['DreamjobJobOpening']['company_id'] = $cid; + if(count($a['DreamjobJobOpening']) > $this->OPENING_COUNT_GAP and !($this->DreamjobJobOpening->data['DreamjobJobOpening']['active']) or (strlen($a['DreamjobCompany']['bank_details']) > 0)){ + $this->DreamjobJobOpening->data['DreamjobJobOpening']['active'] = false; + } if ($this->DreamjobJobOpening->save($this->DreamjobJobOpening->data)) { $this->MiconwareSession->setFlash(__('dreamjob.opening.save.success'), 'flash', array('alert' => 'success')); if($this->request->data['DreamjobJobOpening']['active'] and $this->request->data['DreamjobJobOpening']['startdate'] <= date("Y-m-d") and $this->request->data['DreamjobJobOpening']['enddate'] >= date("Y-m-d", strtotime("+1 day") )) diff --git a/app/Model/DreamjobCvEntry.php b/app/Model/DreamjobCvEntry.php index b5d667b..760820c 100644 --- a/app/Model/DreamjobCvEntry.php +++ b/app/Model/DreamjobCvEntry.php @@ -124,7 +124,7 @@ class DreamjobCvEntry extends AppModel { //The Associations below have been created with all possible keys, those that are not needed can be removed public function compareDates() { - return ($this->data[$this->alias]['startdate'] < $this->data[$this->alias]['enddate']) ? true : false; + return ($this->data[$this->alias]['startdate'] <= $this->data[$this->alias]['enddate']) ? true : false; } /** * belongsTo associations diff --git a/app/webroot/js/dreamjob.js b/app/webroot/js/dreamjob.js index 621fb1d..7aa0dd7 100755 --- a/app/webroot/js/dreamjob.js +++ b/app/webroot/js/dreamjob.js @@ -77,11 +77,13 @@ var global_load = null; $("tbody tr.new", $(this)).remove(); i=0; $("tbody tr", $(this)).each(function() { + if($(":input[name]", this).length > 0){ $(":input[name]", this).each(function() { str = $(this).attr("name").replace(/data\[(.*?)\]\[.*?\]\[(.+)\]/g, 'data[$1][' + i + '][$2]'); $(this).attr("name", str); }); i++; + } }); } $(":input[ name *= '_wysihtml5_mod' ]", this).remove(); @@ -103,7 +105,6 @@ var global_load = null; $(this).submit(function() { //stopLoad(evt); frame = $('#fileUpload').load(function() { - console.log("aha"); setContent($('#fileUpload').contents().find('html').html()); $('#fileUpload').unbind('load'); setTimeout(function() {