favoriten

This commit is contained in:
Martin Müller 2014-02-19 00:03:29 +01:00
parent 27e5c04e28
commit 562b2db078
6 changed files with 282 additions and 0 deletions

View File

@ -0,0 +1,98 @@
<?php
App::uses('AppController', 'Controller');
class JobController extends AppController {
/**
* This controller use User Model
*
* @var array
*/
public $uses = array('DreamjobJobOpening','DreamjobJobFavority');
/**
* Displays a view
*
* @param mixed What page to display
* @return void
* @throws NotFoundException When the view file could not be found
* or MissingViewException in debug mode.
*/
public function openingList() {
$this->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');
}
}
}
?>

View File

@ -0,0 +1,50 @@
<?php
App::uses('AppModel', 'Model');
/**
* MicSysMicapp Model
*
* @property User $User
* @property Mannerofaddress $Mannerofaddress
*/
class DreamjobJobFavority extends AppModel {
public $useDbConfig = 'dreamjobMain';
public $useTable = 'mic_dj_job_opening_worker';
public $validate = array(
'worker_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
),
),
'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'
)
);
}

15
app/View/Job/favorite.ctp Normal file
View File

@ -0,0 +1,15 @@
<?php
/*
*
*/
?>
<div class="box">
<h3><?=__('dreamjob.my.favority');?></h3>
<div class="openinggroup">
<?php
foreach($openings as $opening){
echo $this->element('job_opening_item',array('opening' => $opening));
}
?>
</div>
</div>

60
app/View/Job/opening.ctp Normal file
View File

@ -0,0 +1,60 @@
<?php
/*
*
*/
$fav=false;
foreach($WORKER['Favority'] as $val){
if($val['id'] == $opening['DreamjobJobOpening']['id'])
$fav=true;
}
?>
<div>
<span><?=$this->Html->link(__('dreamjob.company.to'),array('controller'=>'user','action'=>'profil','id'=>$opening['AppUser']['id']));?></span>
<?php
if(is_array($WORKER) and count($WORKER) > 0){
?>
<span style="float: right;">
<?php
//TODO bereits beworben
if(false)
echo $this->Html->link(__('dreamjob.my.application'),array('controller'=>'job','action'=>'openingGet','id'=>$opening['DreamjobJobOpening']['id'],'favorite'=>'favorite'));
else{
//TODO isFavority
$link='dreamjob.favority.adding';
if($fav)
$link='dreamjob.favority.removeing';
echo $this->Html->link(__($link),array('controller'=>'job','action'=>'openingGet','id'=>$opening['DreamjobJobOpening']['id'],'favorite'=>'favorite'));
}
?>
</span>
<?php } ?>
</div>
<div class="box">
<div class="box-title">
<h3><?=$opening['AppUser']['nickname']." ".$opening['DreamjobCompany']['corporateform'];?></h3>
<h1><?=$opening['DreamjobJobOpening']['title'];?></h1>
</div>
<p>
<h4><?=__("dreamjob.opening.titleinfo");?></h4>
<?=__("dreamjob.graducation.company");?>: <?=$opening['DreamjobListGraducation']['name'];?><br/>
<?=__("dreamjob.branch");?>: <?=$opening['DreamjobJobOpening']['branch'];?><br/>
<?=__("dreamjob.kindofjob");?>: <?=$opening['DreamjobListKindofjob']['name'];?><br/>
<span<?php if( time() > strtotime($opening['DreamjobJobOpening']['enddate'])){ ?> class="opening_outdate"<?php } ?>><?=__("dreamjob.opening.enddate");?>: <?=$this->Time->format('d.m.Y', $opening['DreamjobJobOpening']['enddate']);?></span>
</p>
<br/>
<p>
<h4><?=__("dreamjob.company.titleinfo");?></h4>
<?=__("dreamjob.company");?>: <?=$opening['AppUser']['nickname']." ".$opening['DreamjobCompany']['corporateform'];?><br/>
<?=__("dreamjob.headcount");?>: <?=$opening['DreamjobCompany']['headcount'];?><br/>
<?=__("dreamjob.owner");?>: <?=$opening['DreamjobCompany']['owner'];?>
</p>
<p>
<?=__("dreamjob.address");?>: <br/>
<?=$opening['DreamjobUser']['street'];?><br/>
<?=$opening['DreamjobUser']['postcode']." ".$opening['DreamjobUser']['city'];?>
</p>
<br/>
<div>
<?=$opening['DreamjobJobOpening']['text'];?>
</div>
</div>

View File

@ -0,0 +1,21 @@
<?php
/*
*
*/
?>
<div class="box">
<h3><?=__('dreamjob.my.opening');?></h3>
<div>
<span>&nbsp;</span>
<span style="float: right;">
<?=$this->Html->link(__('dreamjob.opening.add'),array('controller'=>'job','action'=>'openingAdd'));?>
</span>
</div>
<div class="openinggroup">
<?php
foreach($openings as $opening){
echo $this->element('job_opening_item',array('opening' => $opening));
}
?>
</div>
</div>

38
update.sql Normal file
View File

@ -0,0 +1,38 @@
--
-- Datenbank: `muellersql3`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `mic_dj_job_opening_worker`
--
CREATE TABLE IF NOT EXISTS `mic_dj_job_opening_worker` (
`opening_id` int(11) NOT NULL,
`worker_id` int(11) NOT NULL,
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;
--
-- Tabellenstruktur für Tabelle `mic_dj_account_cmpy` ändern
-- ProCompanyAccount
--
ALTER TABLE `mic_dj_account_cmpy` ADD `pro_user` INT NOT NULL ;
--
-- Constraints der exportierten Tabellen
--
--
-- Constraints der Tabelle `mic_dj_job_opening_worker`
--
ALTER TABLE `mic_dj_job_opening_worker`
ADD CONSTRAINT `mic_dj_job_opening_worker_favOpening` FOREIGN KEY (`opening_id`) REFERENCES `mic_dj_jobs_opening` (`id`),
ADD CONSTRAINT `mic_dj_job_opening_worker_favWorker` FOREIGN KEY (`worker_id`) REFERENCES `mic_dj_account_wrk` (`djaccount_ptr_id`);