CompanyPro Table + systemwide fix

This commit is contained in:
Martin Müller 2014-11-18 02:17:46 +01:00
parent 809554fcc8
commit 32c041b795
21 changed files with 51 additions and 254 deletions

View File

@ -19,8 +19,11 @@ class JobController extends AppController {
* @throws NotFoundException When the view file could not be found
* or MissingViewException in debug mode.
*/
private $OPENING_COUNT_GAP = 2;
private $OPENING_COUNT_GAP = 1;
private function allowOpening($c,$diff=0){
return ((count($c['DreamjobJobOpening'])+$diff) >= (($this->OPENING_COUNT_GAP < $c['Pro']['opening_count'])?$c['Pro']['opening_count']:$this->OPENING_COUNT_GAP));
}
public function openingList() {
$this->MiconwareSession->init($this);
@ -60,7 +63,7 @@ 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)){
if(!$this->allowOpening($c)){
$this->DreamjobJobOpening->data['DreamjobJobOpening']['active'] = false;
}
if ($this->DreamjobJobOpening->save()) {
@ -71,9 +74,7 @@ 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)
if(!$this->allowOpening($c,-1))
$this->MiconwareSession->setFlash(__('dreamjob.opening.count'), 'flash', array('alert' => 'danger'));
$this->request->data['DreamjobJobOpening']['active']=true;
}
@ -111,11 +112,14 @@ 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)){
if(!$this->allowOpening($a)){
$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->allowOpening($a))
$this->MiconwareSession->setFlash(__('dreamjob.opening.save.count'), 'flash', array('alert' => 'info'));
else
$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") ))
return $this->redirect(array('action' => 'openingGet','id'=>$this->request->params['id']));
} else

View File

@ -46,9 +46,7 @@ class UserController extends AppController {
$self = $this->MiconwareSession->getCompany();
$self_company = true;
$_pro = decbin($self['DreamjobCompany']['pro_user']);
$_pro_l = strlen($_pro);
$self_company_pro = !empty($_pro[$_pro_l-1]);
$self_company_pro = $self['Pro']['worker_profil'];
}
//get Profil

View File

@ -49,8 +49,6 @@ class AppUser extends AppModel {
$result = false;
} else {
$result = $this->saveField('avatar', str_replace(DS, "/", str_replace(WWW_ROOT.$this->uploadDir.DS, "", $filename) ));
if($data["AppUser"]['take_systemwide'])
$result = $this->User->saveField('avatar', str_replace(DS, "/", str_replace(WWW_ROOT.$this->uploadDir.DS, "", $filename) ));
}
if ($result) {

View File

@ -4,7 +4,6 @@ App::uses('CakeEmail', 'Network/Email');
/**
* DreamjobCompany Model
*
* TODO
*
* @property
*/
@ -141,17 +140,7 @@ class DreamjobCompany extends AppModel {
if($result)
$result = $this->AppUser->saveField('take_systemwide',$data['AppUser']['take_systemwide']);
if($result and $data['AppUser']['take_systemwide']){
$result = $this->User->saveField('nickname',$data['AppUser']['nickname']);
if($result)
$result = $this->User->saveField('first_name',$data['AppUser']['first_name']);
if($result)
$result = $this->User->saveField('last_name',$data['AppUser']['last_name']);
if($result)
$result = $this->User->saveField('bday',$data['AppUser']['bday']);
if($result)
$result = $this->User->saveField('mannerofaddress_id',$data['AppUser']['mannerofaddress_id']);
}
if ($result) {
$dataSource->commit();
@ -215,16 +204,6 @@ class DreamjobCompany extends AppModel {
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'pro_user' => 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(
'DreamjobListBranch' => array(
@ -261,6 +240,11 @@ class DreamjobCompany extends AppModel {
'foreignKey' => false,
'conditions' => array('DreamjobCompany.djaccount_ptr_id=AppUser.id and User.id = AppUser.user_id'),
'limit' => 1
),
'Pro' => array(
'className' => 'DreamjobCompanyPro',
'foreignKey' => 'company_id',
'limit' => 1
),
'DreamjobListCity' => array(
'className' => 'DreamjobListCity',

View File

@ -160,19 +160,6 @@ class DreamjobWorker extends AppModel {
if($result)
$result = $this->AppUser->saveField('take_systemwide',$data['AppUser']['take_systemwide']);
if($result and $data['AppUser']['take_systemwide']){
$result = $this->User->saveField('nickname',$data['AppUser']['nickname']);
if($result)
$result = $this->User->saveField('first_name',$data['AppUser']['first_name']);
if($result)
$result = $this->User->saveField('last_name',$data['AppUser']['last_name']);
if($result)
$result = $this->User->saveField('bday',$data['AppUser']['bday']);
if($result)
$result = $this->User->saveField('mannerofaddress_id',$data['AppUser']['mannerofaddress_id']);
}
if ($result) {
$dataSource->commit();

View File

@ -149,36 +149,6 @@ class User extends AppModel {
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'first_name' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
//'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
),
),
'last_name' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
//'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
),
),
'is_staff' => array(
'boolean' => array(
'rule' => array('boolean'),
//'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
),
),
'is_active' => array(
'boolean' => array(
'rule' => array('boolean'),
@ -252,36 +222,6 @@ class User extends AppModel {
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'avatar' => array(
'url' => array(
'rule' => array('url'),
//'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
),
),
'bday' => array(
'date' => array(
'rule' => array('date'),
//'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
),
),
'comment' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
//'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
),
),
);
//The Associations below have been created with all possible keys, those that are not needed can be removed
@ -291,15 +231,6 @@ class User extends AppModel {
*
* @var array
*/
public $belongsTo = array(
'Mannerofaddress' => array(
'className' => 'Mannerofaddress',
'foreignKey' => 'mannerofaddress_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
);
public $hasMany = array(
'AppUser' => array(
'className' => 'AppUser',

View File

@ -4,17 +4,11 @@
*/
$avatar = false;
$url = '';
if($company['AppUser']['take_systemwide']){
if($company['User']['avatar']){
$url = $MEDIA.DS.$company['User']['avatar'];
$avatar = true;
}
}else{
if($company['AppUser']['avatar']){
$url = $MEDIA.DS.$company['AppUser']['avatar'];
$avatar = true;
}
if($company['AppUser']['avatar']){
$url = $MEDIA.DS.$company['AppUser']['avatar'];
$avatar = true;
}
?>
<div class="openingitem">

View File

@ -19,17 +19,11 @@
$avatar = false;
$url = '';
if($opening['AppUser']['take_systemwide']){
if($opening['User']['avatar']){
$url = $MEDIA.DS.$opening['User']['avatar'];
$avatar = true;
}
}else{
if($opening['AppUser']['avatar']){
$url = $MEDIA.DS.$opening['AppUser']['avatar'];
$avatar = true;
}
if($opening['AppUser']['avatar']){
$url = $MEDIA.DS.$opening['AppUser']['avatar'];
$avatar = true;
}
?>
<?php if(!empty($opening_MINI) or !($opening_in_app or $opening_in_fav)){ ?>
<div class="openingitem">

View File

@ -22,14 +22,7 @@ if($edit){
<table class="cv">
<tr>
<td><?=__("dreamjob.bday");?></td>
<td>
<?php
if($profil['AppUser']['take_systemwide'])
echo $this->Time->format('d.m.Y', $profil['User']['bday']);
else
echo $this->Time->format('d.m.Y', $profil['AppUser']['bday']);
?>
</td>
<td><?=$this->Time->format('d.m.Y', $profil['AppUser']['bday']);?></td>
</tr>
<tr>
<td><?=__("dreamjob.workexperience");?></td>

View File

@ -25,14 +25,7 @@ echo $this->Html->link($text,array('controller'=>'user','action'=>'profil'),arra
<?php if($cvc_item['DreamjobListCvCategory']['position'] == 0){ ?>
<tr>
<td><?=__("dreamjob.bday");?></td>
<td>
<?php
if($profil['AppUser']['take_systemwide'])
echo $this->Time->format('d.m.Y', $profil['User']['bday']);
else
echo $this->Time->format('d.m.Y', $profil['AppUser']['bday']);
?>
</td>
<td><?=$this->Time->format('d.m.Y', $profil['AppUser']['bday']);?></td>
<td></td>
</tr>
<tr>

View File

@ -26,14 +26,7 @@
<table class="cv">
<tr>
<td><?=__("dreamjob.bday");?></td>
<td>
<?php
if($profil['AppUser']['take_systemwide'])
echo $this->Time->format('d.m.Y', $profil['User']['bday']);
else
echo $this->Time->format('d.m.Y', $profil['AppUser']['bday']);
?>
</td>
<td><?=$this->Time->format('d.m.Y', $profil['AppUser']['bday']);?></td>
</tr>
<tr>
<td><?=__("dreamjob.workexperience");?></td>

View File

@ -7,12 +7,8 @@
<div class="bar avatar">
<?php
$url='/img/icon_user.png';
if($profil['AppUser']['take_systemwide']){
if($profil['User']['avatar'])
$url = $MEDIA.DS.$profil['User']['avatar'];
}else
if($profil['AppUser']['avatar'])
$url = $MEDIA.DS.$profil['AppUser']['avatar'];
if($profil['AppUser']['avatar'])
$url = $MEDIA.DS.$profil['AppUser']['avatar'];
?>
<img src="<?=$url;?>"/>
@ -26,25 +22,14 @@
<?php endif; ?>
</div>
<div class="bar">
<h1>
<?php
if($profil['AppUser']['take_systemwide'])
echo $profil['User']['first_name'].' '.$profil['User']['last_name'];
else
echo $profil['AppUser']['first_name'].' '.$profil['AppUser']['last_name'];
?>
</h1>
<h1><?=$profil['AppUser']['first_name'].' '.$profil['AppUser']['last_name'];?></h1>
<br/>
<p>
<?=__("dreamjob.iam");?>:<br/>
<?=$profil['DreamjobWorker']['iam'];?>
</p>
<?php
$pro = '00000000'.decbin($COMPANY['DreamjobCompany']['pro_user']);
$pro_l = strlen($pro);
$pro_user = !empty($pro[$pro_l-2]);
if(!empty($WORKER) and is_array($WORKER) and count($WORKER) > 0 and !isset($application) or $isLoggedin and $pro_user){
if(!empty($WORKER) and is_array($WORKER) and count($WORKER) > 0 and !isset($application) or $isLoggedin and !empty($COMPANY['Pro']['worker_mail'])){
?>
<h3><?=__("dreamjob.mail");?></h3>
<a href="mailto:<?=$profil['User']['mail'];?>">

View File

@ -15,23 +15,12 @@
// echo var_dump($profil);
?>
<div class="openingitem">
<h3>
<?php
if($profil[$AppUser]['take_systemwide'])
echo $profil[$User]['first_name'].' '.$profil[$User]['last_name'];
else
echo $profil[$AppUser]['first_name'].' '.$profil[$AppUser]['last_name'];
?>
</h3>
<h3><?=$profil[$AppUser]['first_name'].' '.$profil[$AppUser]['last_name'];?></h3>
<div class="icon">
<?php
$url='/img/icon_user.png';
if($profil[$AppUser]['take_systemwide']){
if($profil[$User]['avatar'])
$url = $MEDIA.DS.$profil[$User]['avatar'];
}else
if($profil[$AppUser]['avatar'])
$url = $MEDIA.DS.$profil[$AppUser]['avatar'];
if($profil[$AppUser]['avatar'])
$url = $MEDIA.DS.$profil[$AppUser]['avatar'];
?>
<img src="<?=$url;?>"/>

View File

@ -23,12 +23,8 @@ $tcpdf->SetTextColor(0, 0, 0);
$tcpdf->SetFont($tcpdf->font);
$url=WWW_ROOT.DS.'img'.DS.'icon_user.png';
if($application['AppUserWorker']['take_systemwide']){
if($application['WorkerUser']['avatar'])
$url = WWW_ROOT.DS.'uploads'.DS.$application['WorkerUser']['avatar'];
}else
if($profil['AppUserWorker']['avatar'])
$url = WWW_ROOT.DS.'uploads'.DS.$application['AppUserWorker']['avatar'];
if($profil['AppUserWorker']['avatar'])
$url = WWW_ROOT.DS.'uploads'.DS.$application['AppUserWorker']['avatar'];
$tcpdf->Image($url,0,40,0,140,'','','','',300,'L');
$tcpdf->SetY(185);

View File

@ -24,12 +24,8 @@ $tcpdf->SetTextColor(0, 0, 0);
$tcpdf->SetFont($tcpdf->font);
$url=WWW_ROOT.DS.'img'.DS.'icon_user.png';
if($application['AppUserWorker']['take_systemwide']){
if($application['WorkerUser']['avatar'])
$url = WWW_ROOT.DS.'uploads'.DS.$application['WorkerUser']['avatar'];
}else
if($profil['AppUserWorker']['avatar'])
$url = WWW_ROOT.DS.'uploads'.DS.$application['AppUserWorker']['avatar'];
if($profil['AppUserWorker']['avatar'])
$url = WWW_ROOT.DS.'uploads'.DS.$application['AppUserWorker']['avatar'];
$tcpdf->Image($url,0,40,0,140,'','','','',300,'L');
$tcpdf->SetY(185);

View File

@ -24,12 +24,8 @@ $tcpdf->SetTextColor(0, 0, 0);
$tcpdf->SetFont($tcpdf->font);
$url=WWW_ROOT.DS.'img'.DS.'icon_user.png';
if($WORKER['AppUser']['take_systemwide']){
if($WORKER['User']['avatar'])
$url = WWW_ROOT.DS.'uploads'.DS.$WORKER['User']['avatar'];
}else
if($profil['AppUser']['avatar'])
$url = WWW_ROOT.DS.'uploads'.DS.$WORKER['AppUser']['avatar'];
if($profil['AppUser']['avatar'])
$url = WWW_ROOT.DS.'uploads'.DS.$WORKER['AppUser']['avatar'];
$tcpdf->Image($url,0,40,0,140,'','','','',300,'L');
$tcpdf->SetY(185);
$tcpdf->SetFont($tcpdf->font,'B',$tcpdf->fontsize+4);

View File

@ -3,25 +3,18 @@
*
*/
$avatar = false;
if($profil['AppUser']['take_systemwide']){
if($profil['User']['avatar'])
if($profil['AppUser']['avatar'])
$avatar = true;
}else{
if($profil['AppUser']['avatar'])
$avatar = true;
}
?>
<div class="box-extra">
<?php if($avatar or $edit){ ?>
<div class="box-extra-left infofield">
<div class="box">
<?php
if($profil['AppUser']['take_systemwide'])
$url = $MEDIA.DS.$profil['User']['avatar'];
else
$url = $MEDIA.DS.$profil['AppUser']['avatar'];
if($edit and !isset($url))
$url = 'img/icon_company.png';
$url = $MEDIA.DS.$profil['AppUser']['avatar'];
if($edit and !isset($url))
$url = 'img/icon_company.png';
?>
<img src="<?=$url;?>"/>
<?php if($edit): ?>
@ -78,7 +71,7 @@ if($profil['AppUser']['take_systemwide']){
<?=$profil['DreamjobCompany']['owner'];?>
</p>
<p>
<?=__("dreamjob.branch");?>:<br/>
<?=__("dreamjob.branch");?>:<br/>
<?=$profil['DreamjobListBranch']['name'];?>
</p>
</div>

View File

@ -2,14 +2,6 @@
/*
*
*/
$avatar = false;
if($profil['AppUser']['take_systemwide']){
if($profil['User']['avatar'])
$avatar = true;
}else{
if($profil['AppUser']['avatar'])
$avatar = true;
}
?>
<div class="box">
<div class="tabs-below">

View File

@ -2,14 +2,7 @@
/*
*
*/
$avatar = false;
if($profil['AppUser']['take_systemwide']){
if($profil['User']['avatar'])
$avatar = true;
}else{
if($profil['AppUser']['avatar'])
$avatar = true;
}
?>
<div class="box">
<div class="tabs-below">

View File

@ -2,14 +2,6 @@
/*
*
*/
$avatar = false;
if($profil['AppUser']['take_systemwide']){
if($profil['User']['avatar'])
$avatar = true;
}else{
if($profil['AppUser']['avatar'])
$avatar = true;
}
$this->startIfEmpty('scriptEnd');
?>

View File

@ -9,12 +9,8 @@
?>
</div>
<?php
$pro = '00000000'.decbin($COMPANY['DreamjobCompany']['pro_user']);
$pro_l = strlen($pro);
$pro_user = !empty($pro[$pro_l-1]);
if(( !empty($COMPANY) and is_array($COMPANY) and count($COMPANY) > 0 and $pro_user )
if(( !empty($COMPANY) and is_array($COMPANY) and count($COMPANY) > 0 and $COMPANY['Pro']['worker_profil'] )
or ( !empty($WORKER) and is_array($WORKER) and count($WORKER) > 0 )
){
?>