72 lines
1.5 KiB
PHP
Executable File
72 lines
1.5 KiB
PHP
Executable File
<?php
|
|
App::uses('AppModel', 'Model');
|
|
App::uses('CakeEmail', 'Network/Email');
|
|
/**
|
|
*/
|
|
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(
|
|
);
|
|
|
|
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;
|
|
}
|
|
|
|
public $hasOne = array(
|
|
'DreamjobCompany' => array(
|
|
'className' => 'DreamjobCompany',
|
|
'foreignKey' => 'djaccount_ptr_id'
|
|
)
|
|
);
|
|
}
|