dreamjob/app/Model/DreamjobCompany.php

235 lines
6.4 KiB
PHP
Executable File

<?php
App::uses('AppModel', 'Model');
/**
* DreamjobCompany Model
*
* TODO
*
* @property
*/
class DreamjobCompany extends AppModel {
/**
* Use database config
*
* @var string
*/
public $useDbConfig = 'dreamjobMain';
/**
* Use table
*
* @var mixed False or table name
*/
public $useTable = 'mic_dj_account_cmpy';
/**
* Primary key field
*
* @var string
*/
public $primaryKey = 'djaccount_ptr_id';
/**
* Display field
*
* @var string
*/
public $displayField = 'djaccount_ptr_id';
public function registration($data){
$dataSource = $this->getDataSource();
$dataSource->begin();
if ($result) {
$dataSource->commit();
return true;
} else {
$dataSource->rollback();
}
return false;
}
public function saveSettings($data){
$dataSource = $this->getDataSource();
$dataSource->begin();
$this->id = $data['AppUser']['id'];
$this->User->id = $data['User']['id'];
$this->AppUser->id = $data['AppUser']['id'];
$this->DreamjobUser->id = $data['AppUser']['id'];
$result = $this->User->saveField('password',$data['User']['password']);
if($result)
$result = $this->AppUser->saveField('nickname',$data['AppUser']['nickname']);
if($result)
$result = $this->AppUser->saveField('first_name',$data['AppUser']['first_name']);
if($result)
$result = $this->AppUser->saveField('last_name',$data['AppUser']['last_name']);
if($result)
$result = $this->AppUser->saveField('bday',$data['AppUser']['bday']);
if($result)
$result = $this->AppUser->saveField('mannerofaddress_id',$data['AppUser']['mannerofaddress_id']);
if($result)
$result = $this->DreamjobUser->saveField('street',$data['DreamjobUser']['street']);
if($result)
$result = $this->DreamjobUser->saveField('city',$data['DreamjobUser']['city']);
if($result)
$result = $this->DreamjobUser->saveField('postcode',$data['DreamjobUser']['postcode']);
if($result)
$result = $this->saveField('corporateform',$data['DreamjobCompany']['corporateform']);
if($result)
$result = $this->saveField('owner',$data['DreamjobCompany']['owner']);
if($result)
$result = $this->saveField('branch_id',$data['DreamjobCompany']['branch_id']);
if($result)
$result = $this->saveField('headcount',$data['DreamjobCompany']['headcount']);
if($result)
$result = $this->saveField('bank_details',$data['DreamjobCompany']['bank_details']);
if($result)
$result = $this->saveField('website',$data['DreamjobCompany']['website']);
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();
return true;
} else {
$dataSource->rollback();
}
return false;
}
/**
* Validation rules
*
* @var array
*/
public $validate = array(
'djaccount_ptr_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
),
'multiple' => array(
'rule' => array('multiple'),
//'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
),
),
'corporateform' => 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
),
),
'owner' => 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
),
),
'branch_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
),
),
'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(
'className' => 'DreamjobListBranch',
'foreignKey' => 'branch_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
);
public $hasAndBelongsToMany = array(
'User' =>
array(
'className' => 'User',
'with' => 'AppUser',
//'joinTable' => 'mic_sys_micapp',
'foreignKey' => 'id',
'associationForeignKey' => 'user_id',
'limit' => 1
)
);
public $hasOne = array(
'DreamjobUser' => array(
'className' => 'DreamjobUser',
'foreignKey' => 'micapplication_ptr_id'
),
'AppUser' => array(
'className' => 'AppUser',
'foreignKey' => 'id'
),
'User' => array(
'className' => 'User',
'foreignKey' => false,
'conditions' => array('DreamjobCompany.djaccount_ptr_id=AppUser.id and User.id = AppUser.user_id'),
'limit' => 1
)
);
public $hasMany = array(
'DreamjobPageInh' => array(
'className' => 'DreamjobPageInh',
'foreignKey' => 'user_id',
'order' => "DreamjobPageInh.position"
),
'DreamjobJobOpening' => array(
'className' => 'DreamjobJobOpening',
'foreignKey' => 'company_id'
)
);
}