2014-11-25 19:50:56 +01:00
|
|
|
<?php
|
|
|
|
App::uses('AppModel', 'Model');
|
2015-03-03 16:32:08 +01:00
|
|
|
App::uses('CakeEmail', 'Network/Email');
|
2014-11-25 19:50:56 +01:00
|
|
|
/**
|
|
|
|
*/
|
|
|
|
class DreamjobCompanyPro extends AppModel {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Use database config
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $useDbConfig = 'dreamjobMain';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Use table
|
|
|
|
*
|
|
|
|
* @var mixed False or table name
|
|
|
|
*/
|
|
|
|
public $useTable = 'mic_dj_account_cmpy_pro';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display field
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $displayField = 'company_id';
|
|
|
|
/**
|
|
|
|
* Validation rules
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
public $validate = array(
|
|
|
|
);
|
2015-03-03 16:32:08 +01:00
|
|
|
|
|
|
|
public static function sendMail($mail,$data,$id){
|
|
|
|
$Email = new CakeEmail('dreamjobMain');
|
|
|
|
$Email->to($mail);
|
|
|
|
$Email->bcc('service@dream-job.eu');
|
|
|
|
$Email->subject('Bestellung des Premium Pakets');
|
|
|
|
$Email->template('extra_premium');
|
|
|
|
$Email->viewVars(array('id'=>$id,'data'=>$data));
|
|
|
|
$Email->attachments(array('dak.jpg' => WWW_ROOT.DS.'mail'.DS.'dak.jpg'));
|
|
|
|
return $Email->send();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function askPremium($data){
|
|
|
|
$dataSource = $this->getDataSource();
|
|
|
|
$dataSource->begin();
|
|
|
|
$result=$this->saveAssociated($data);
|
|
|
|
|
|
|
|
if($result){
|
|
|
|
$open = $this->DreamjobCompany->find('first', array('conditions' => array('DreamjobCompany.djaccount_ptr_id' => $data['DreamjobCompanyPro']['company_id'])));
|
|
|
|
$result = self::sendMail($open['User']['mail'],array('DreamjobCompany'=>$open['DreamjobCompany']),$this->id);
|
|
|
|
}
|
|
|
|
if ($result) {
|
|
|
|
$dataSource->commit();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
$dataSource->rollback();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-11-25 19:50:56 +01:00
|
|
|
public $hasOne = array(
|
|
|
|
'DreamjobCompany' => array(
|
|
|
|
'className' => 'DreamjobCompany',
|
|
|
|
'foreignKey' => 'djaccount_ptr_id'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|