dreamjob/app/Controller/JobController.php

558 lines
32 KiB
PHP
Raw Permalink Normal View History

2015-03-31 14:49:03 +02:00
<?php
App::uses('AppController', 'Controller');
class JobController extends AppController {
/**
* This controller use User Model
*
* @var array
*/
public $uses = array('DreamjobJobOpening', 'DreamjobJobFavority', 'DreamjobJobApplication', 'DreamjobPageText', 'DreamjobPageImage', 'DreamjobJobMsg', 'DreamjobCvEntry', 'DreamjobListCvCategory', 'DreamjobListBranch', 'DreamjobListCity');
/**
* 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.
*/
private static function monthAdd($date,$interval){
$date = new DateTime($date);
return $date->add(new DateInterval('P'.$interval.'M'))->format("Y-m-d");
}
public function openingList() {
$this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this);
$self = $this->MiconwareSession->getCompany();
if (!is_array($self) or count($self) <= 0) {
$this->set('error', array('title'=>__('dreamjob.error.noPermision.title'),'text'=>__('dreamjob.error.noPermision.text')));
if(!$this->MiconwareSession->isLoggedin())
$this->render('/Home/login');
else
$this->render('/Home/error');
} else {
if (!empty($this->request->query['del'])) {
$o = $this->DreamjobJobOpening->findById($this->request->query['del']);
if ($o['AppUser']['id'] == $self['AppUser']['id']) {
$o['DreamjobJobOpening']['delete']=true;
$o['DreamjobJobOpening']['active']=true;
$this->DreamjobJobOpening->save($o);
$this->MiconwareSession->setFlash(__('dreamjob.opening.delete.success'), 'flash', array('alert' => 'success'));
} else {
$this->MiconwareSession->setFlash(__('dreamjob.opening.delete.error'), 'flash', array('alert' => 'danger'));
}
}
$openings = $this->DreamjobJobOpening->find('all', array('conditions' => array('DreamjobJobOpening.company_id' => $self['AppUser']['id'],'DreamjobJobOpening.delete'=>false)));
$this->set('openings', $openings);
$this->render('/Job/opening_list');
}
}
public function openingAdd() {
$this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this);
$c = $this->MiconwareSession->getCompany();
if (!empty($c)) {
if ($this->request->is('post')) {
if ($this->request->data['DreamjobJobOpening']['agb']) {
unset($this->request->data['DreamjobJobOpening']['agb']);
if ($this->request->data['DreamjobJobOpening']['cost']) {
unset($this->request->data['DreamjobJobOpening']['cost']);
$this->DreamjobJobOpening->create($this->request->data);
$this->DreamjobJobOpening->data['DreamjobJobOpening']['company_id'] = $c['AppUser']['id'];
$this->DreamjobJobOpening->data['DreamjobJobOpening']['enddate'] = JobController::monthAdd($this->DreamjobJobOpening->data['DreamjobJobOpening']['startdate'],3);
$this->request->data['DreamjobJobOpening']['enddate'] = $this->DreamjobJobOpening->data['DreamjobJobOpening']['enddate'];
if ($this->DreamjobJobOpening->save()) {
$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->DreamjobJobOpening->id));
$this->request->data=array();
$this->request->data['DreamjobJobOpening']['active']=true;
$this->request->data['DreamjobJobOpening']['company_id']=$c['AppUser']['id'];
} else {
$this->MiconwareSession->setFlash(__('dreamjob.opening.save.error'), 'flash', array('alert' => 'danger'));
}
}else{
$this->MiconwareSession->setFlash(__('dreamjob.cost.error.notAccept'), 'flash', array('alert' => 'danger'));
}
}else{
$this->MiconwareSession->setFlash(__('dreamjob.agb.error.notAccept'), 'flash', array('alert' => 'danger'));
}
}else{
$this->MiconwareSession->setFlash(__('dreamjob.opening.cost'), 'flash', array('alert' => 'danger'));
$this->request->data['DreamjobJobOpening']['active']=true;
$this->request->data['DreamjobJobOpening']['company_id']=$c['AppUser']['id'];
}
$this->set('enddate_no',false);
$this->set('kindofjobs', $this->DreamjobJobOpening->DreamjobListKindofjob->find('list'));
$this->set('graducations', $this->DreamjobJobOpening->DreamjobListGraducation->find('list'));
$this->set('branches', $this->DreamjobListBranch->find('list'));
$this->set('cities', $this->DreamjobListCity->find('list'));
$this->render('/Job/opening_edit');
} else {
$this->set('error', array('title'=>__('dreamjob.error.noCompany.title'),'text'=>__('dreamjob.error.noCompany.text')));
if(!$this->MiconwareSession->isLoggedin())
$this->render('/Home/login');
else
$this->render('/Home/error');
}
}
public function openingEdit() {
$this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this);
$a = $this->MiconwareSession->getCompany();
if (empty($a)) {
$this->set('error', array('title'=>__('dreamjob.error.noCompany.title'),'text'=>__('dreamjob.error.noCompany.text')));
if(!$this->MiconwareSession->isLoggedin())
$this->render('/Home/login');
else
$this->render('/Home/error');
}
if (!empty($this->request->params['id'])) {
$load = $this->DreamjobJobOpening->findById($this->request->params['id']);
$cid = $a['AppUser']['id'];
if (!empty($load) and $load['DreamjobJobOpening']['company_id'] == $cid and $load['DreamjobJobOpening']['delete']==false) {
$enddate_no = ($load['DreamjobJobOpening']['startdate']<=date("Y-m-d",strtotime("-1 day")));
$this->set('enddate_no',$enddate_no);
if ($this->request->is(array('post', 'put'))) {
if ($this->request->data['DreamjobJobOpening']['agb']) {
unset($this->request->data['DreamjobJobOpening']['agb']);
if ($this->request->data['DreamjobJobOpening']['cost']) {
unset($this->request->data['DreamjobJobOpening']['cost']);
$addToEnddate = !empty($this->request->data['DreamjobJobOpening']['addToEnddate']);
$this->DreamjobJobOpening->create($this->request->data);
$this->DreamjobJobOpening->data['DreamjobJobOpening']['id'] = $this->request->params['id'];
$this->DreamjobJobOpening->data['DreamjobJobOpening']['company_id'] = $cid;
if($enddate_no){
$this->DreamjobJobOpening->data['DreamjobJobOpening']['startdate'] = $load['DreamjobJobOpening']['startdate'];
if($addToEnddate)
$this->DreamjobJobOpening->data['DreamjobJobOpening']['enddate'] = JobController::monthAdd($load['DreamjobJobOpening']['enddate'],1);
else
$this->DreamjobJobOpening->data['DreamjobJobOpening']['enddate'] = $load['DreamjobJobOpening']['enddate'];
}else{
$this->DreamjobJobOpening->data['DreamjobJobOpening']['enddate'] = JobController::monthAdd($this->DreamjobJobOpening->data['DreamjobJobOpening']['startdate'],3);
$this->request->data['DreamjobJobOpening']['startdate'] = $this->DreamjobJobOpening->data['DreamjobJobOpening']['startdate'];
}
if ($this->DreamjobJobOpening->save($this->DreamjobJobOpening->data)) {
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']));
$load = $this->DreamjobJobOpening->findById($this->request->params['id']);
$enddate_no = ($load['DreamjobJobOpening']['startdate']<=date("Y-m-d",strtotime("-1 day")));
$this->set('enddate_no',$enddate_no);
$this->MiconwareSession->setFlash(__('dreamjob.opening.save.success'), 'flash', array('alert' => 'success'));
} else
$this->MiconwareSession->setFlash(__('dreamjob.opening.save.error'), 'flash', array('alert' => 'danger'));
}else{
$this->MiconwareSession->setFlash(__('dreamjob.cost.error.notAccept'), 'flash', array('alert' => 'danger'));
}
}else{
$this->MiconwareSession->setFlash(__('dreamjob.agb.error.notAccept'), 'flash', array('alert' => 'danger'));
}
}else{
$this->MiconwareSession->setFlash(__('dreamjob.opening.cost'), 'flash', array('alert' => 'danger'));
}
}
$this->request->data = $load;
$this->set('startdate',$load['DreamjobJobOpening']['startdate']);
$this->set('enddate',$load['DreamjobJobOpening']['enddate']);
$this->set('enddate_next',JobController::monthAdd($load['DreamjobJobOpening']['enddate'],3));
$this->set('kindofjobs', $this->DreamjobJobOpening->DreamjobListKindofjob->find('list'));
$this->set('graducations', $this->DreamjobJobOpening->DreamjobListGraducation->find('list'));
$this->set('branches', $this->DreamjobListBranch->find('list'));
$this->set('cities', $this->DreamjobListCity->find('list'));
}
if (empty($this->request->data['DreamjobJobOpening'])) {
$this->set('error', array('title'=>__('dreamjob.error.opening.notFound.title'),'text'=>__('dreamjob.error.opening.notFound.text')));
$this->render('/Home/error');
} elseif ($this->request->data['DreamjobJobOpening']['company_id'] != $a['AppUser']['id']) {
$this->set('error', array('title'=>__('dreamjob.error.noPermision.title'),'text'=>__('dreamjob.error.noPermision.text')));
$this->render('/Home/error');
} else {
$this->render('/Job/opening_edit');
}
}
public function openingGet() {
$this->MiconwareSession->init($this);
$opening = false;
if (!empty($this->request->params['id'])) {
if (!empty($this->request->params['extra'])){
if ($this->request->params['extra'] == 'favorite') {
$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']), 'modified' => false);
$data2 = array('DreamjobJobFavority.opening_id' => $this->request->params['id'], 'DreamjobJobFavority.worker_id' => $WORKER['AppUser']['id']);
if ($fav) {
$this->MiconwareSession->setFlash(__('dreamjob.opening.fav.delete.success'), 'flash', array('alert' => 'success'));
$this->DreamjobJobFavority->deleteAll($data2, false);
} else {
$this->DreamjobJobFavority->create();
$this->DreamjobJobFavority->save($data);
$this->MiconwareSession->setFlash(__('dreamjob.opening.fav.add.success'), 'flash', array('alert' => 'success'));
}
$this->set('OPP_NORMAL',true);
}elseif ($this->request->params['extra'] == 'openinginfo') {
$this->set('OPP_OPENING',true);
}elseif ($this->request->params['extra'] == 'companyinfo') {
$this->set('OPP_COMPANY',true);
}else{
$this->set('OPP_NORMAL',true);
}
}else
$this->set('OPP_NORMAL',true);
$con = $this->MiconwareSession->getOpeningCondition();
$con['DreamjobJobOpening.id'] = $this->request->params['id'];
$opening = $this->DreamjobJobOpening->find('first', array('conditions' => $con));
}
$this->MiconwareSession->refreshCache();
$this->MiconwareSession->initWeb($this);
if (!is_array($opening) or count($opening) <= 0) {
$this->set('error', array('title'=>__('dreamjob.error.opening.notFound.title'),'text'=>__('dreamjob.error.opening.notFound.text')));
if(!$this->MiconwareSession->isLoggedin())
$this->render('/Home/login');
else
$this->render('/Home/error');
$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) or count($self) <= 0) {
$this->set('error', array('title'=>__('dreamjob.error.noPermision.title'),'text'=>__('dreamjob.error.noPermision.text')));
if(!$this->MiconwareSession->isLoggedin())
$this->render('/Home/login');
else
$this->render('/Home/error');
} else {
$fav_id = array();
foreach ($self['Favority'] as $fav)
$fav_id[] = $fav['id'];
$con = $this->MiconwareSession->getOpeningCondition();
$con['DreamjobJobOpening.id'] = $fav_id;
$openings = $this->DreamjobJobOpening->find('all', array('conditions' => $con));
$this->set('openings', $openings);
$this->set('opening_MINI', true);
$this->render('/Job/favorite');
}
}
public function applicationList() {
$this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this);
$self = $this->MiconwareSession->getWorker();
if (!is_array($self) or count($self) <= 0) {
$this->set('error', array('title'=>__('dreamjob.error.noPermision.title'),'text'=>__('dreamjob.error.noPermision.text')));
if(!$this->MiconwareSession->isLoggedin())
$this->render('/Home/login');
else
$this->render('/Home/error');
} else {
$applications = $this->DreamjobJobApplication->find('all', array('conditions' => array('DreamjobJobApplication.worker_id' => $self['AppUser']['id'])));
$this->set('applications', $applications);
$this->set('opening_MINI', true);
$this->render('/Job/applicationWorker_list');
}
}
public function applicationGet() {
$this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this);
$WORKER = $this->MiconwareSession->getWorker();
$COMPANY = $self = $this->MiconwareSession->getCompany();
$application = null;
if (isset($this->request->params['id'])) {
if (is_array($WORKER) and count($WORKER) > 0)
$application = $this->DreamjobJobApplication->find('first', array('conditions' => array('DreamjobJobApplication.worker_id' => $WORKER['AppUser']['id'], 'DreamjobJobApplication.id' => $this->request->params['id'])));
if (is_array($COMPANY) and count($COMPANY) > 0)
$application = $this->DreamjobJobApplication->find('first', array('conditions' => array('DreamjobJobOpening.company_id' => $COMPANY['AppUser']['id'], 'DreamjobJobApplication.id' => $this->request->params['id'])));
}
if (!is_array($application) or count($application) <= 0) {
$this->set('error', array('title'=>__('dreamjob.error.noPermision.title'),'text'=>__('dreamjob.error.noPermision.text')));
if(!$this->MiconwareSession->isLoggedin())
$this->render('/Home/login');
else
$this->render('/Home/error');
} else {
$this->set('page', null);
$this->set("edit", false);
if (!empty($this->request->params['hiv'])) {
$this->DreamjobJobApplication->id = $application['DreamjobJobApplication']['id'];
if ($this->DreamjobJobApplication->saveField('closed', !$application['DreamjobJobApplication']['closed'])) {
$application = $this->DreamjobJobApplication->find('first', array('conditions' => array('DreamjobJobApplication.id' => $this->request->params['id'])));
$this->MiconwareSession->setFlash(__('dreamjob.application.archiv.success'), 'flash', array('alert' => 'success'));
} else {
$this->MiconwareSession->setFlash(__('dreamjob.application.archiv.error'), 'flash', array('alert' => 'danger'));
}
}
if (!empty($this->request->params['ages'])) {
$this->set('msg', true);
if ($this->request->is('post')) {
$this->DreamjobJobMsg->create($this->request->data);
$this->DreamjobJobMsg->data['DreamjobJobMsg']['saw'] = false;
$this->DreamjobJobMsg->data['DreamjobJobMsg']['application_id'] = $application['DreamjobJobApplication']['id'];
$this->DreamjobJobMsg->data['DreamjobJobMsg']['fromcompany'] = is_array($COMPANY) and count($COMPANY) > 0;
if ($this->DreamjobJobMsg->sendMessage()) {
$application = $this->DreamjobJobApplication->find('first', array('conditions' => array('DreamjobJobApplication.id' => $this->request->params['id'])));
$this->MiconwareSession->setFlash(__('dreamjob.application.msg.success'), 'flash', array('alert' => 'success'));
} else {
$this->MiconwareSession->setFlash(__('dreamjob.application.msg.error'), 'flash', array('alert' => 'danger'));
}
}
if (is_array($WORKER) and count($WORKER) > 0)
$this->DreamjobJobMsg->updateAll(array("saw" => true), array("DreamjobJobMsg.fromcompany" => true, "DreamjobJobMsg.application_id" => $this->request->params['id']));
if (is_array($COMPANY) and count($COMPANY) > 0)
$this->DreamjobJobMsg->updateAll(array("saw" => true), array("DreamjobJobMsg.fromcompany" => false, "DreamjobJobMsg.application_id" => $this->request->params['id']));
}else {
$this->set('msg', false);
// CV
if (!empty($this->request->params['vitea'])) {
$cv = $this->DreamjobCvEntry->find('all', array('conditions' => array('worker_id' => $application['DreamjobJobApplication']['worker_id'])));
$this->set("cv", $cv);
$cvp0 = $this->DreamjobListCvCategory->find('first', array('conditions' => array('DreamjobListCvCategory.position' => 0)));
$this->set('cvp0', $cvp0);
} else {
if (!empty($this->request->params['page'])) {
/* $this->set('pageInh',$this->DreamjobJobApplication->Page->find('first',
array('conditions' => array("Page.id" => $this->request->params['page']))
)); */
$page = $this->DreamjobJobApplication->PageText->find('first', array('conditions' => array("PageText.page_ptr_id" => $this->request->params['page']))
);
if (!is_array($page) or count($page) <= 0)
$page = $this->DreamjobJobApplication->PageImage->find('first', array('conditions' => array("PageImage.page_ptr_id" => $this->request->params['page']))
);
$this->set('page', $page);
}
}
}
$this->set('application', $application);
$this->render('/Job/application');
}
}
public function applicationByOpening() {
$this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this);
$COMPANY = $self = $this->MiconwareSession->getCompany();
$applications = null;
$opening = null;
if (isset($this->request->params['id'])) {
if (is_array($COMPANY) and count($COMPANY) > 0)
$opening = $this->DreamjobJobOpening->find('first', array('conditions' => array('DreamjobJobOpening.company_id' => $COMPANY['AppUser']['id'], 'DreamjobJobOpening.id' => $this->request->params['id'])));
if (!empty($this->request->query['archiv']) and count($opening) > 0) {
$application = $this->DreamjobJobApplication->find('first', array('conditions' => array('DreamjobJobApplication.id' => $this->request->query['archiv'], 'DreamjobJobApplication.opening_id' => $this->request->params['id'])));
$this->DreamjobJobApplication->id = $this->request->query['archiv'];
if ($this->DreamjobJobApplication->saveField('closed', !$application['DreamjobJobApplication']['closed'])) {
$application = $this->DreamjobJobApplication->find('first', array('conditions' => array('DreamjobJobApplication.id' => $this->request->params['id'])));
$this->MiconwareSession->setFlash(__('dreamjob.application.archiv.success'), 'flash', array('alert' => 'success'));
} else {
$this->MiconwareSession->setFlash(__('dreamjob.application.archiv.error'), 'flash', array('alert' => 'danger'));
}
}
$filter_current = false;
$filter_archiv = false;
$condition = array('DreamjobJobOpening.company_id' => $COMPANY['AppUser']['id'], 'DreamjobJobApplication.opening_id' => $this->request->params['id']);
if (isset($this->request->query['filter']) and $this->request->query['filter'] == 'all') {
} elseif (isset($this->request->query['filter']) and $this->request->query['filter'] == 'archiv') {
$condition['closed'] = true;
$filter_archiv = true;
} else {
$condition['closed'] = false;
$filter_current = true;
}
$applications = $this->DreamjobJobApplication->find('all', array('conditions' => $condition));
$this->set("filter_archiv", $filter_archiv);
$this->set("filter_current", $filter_current);
}
if (!is_array($opening) or count($opening) <= 0) {
$this->set('error', array('title'=>__('dreamjob.error.noPermision.title'),'text'=>__('dreamjob.error.noPermision.text')));
if(!$this->MiconwareSession->isLoggedin())
$this->render('/Home/login');
else
$this->render('/Home/error');
} else {
$this->set('opening', $opening);
$this->set('applications', $applications);
$this->render('/Job/applicationCompany_list');
}
}
public function applicationSend() {
$this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this);
$w = $this->MiconwareSession->getWorker();
if (!empty($w)) {
$opening = null;
if (!empty($this->request->params['id'])) {
$con = $this->MiconwareSession->getOpeningCondition();
$con['DreamjobJobOpening.id'] = $this->request->params['id'];
$opening = $this->DreamjobJobOpening->find('first', array('conditions' => $con));
}
if (!is_array($opening) or count($opening) <= 0) {
$this->set('error', array('title'=>__('dreamjob.error.opening.notFound.title'),'text'=>__('dreamjob.error.opening.notFound.text')));
$this->render('/Home/error');
} else {
if ($this->request->is('post')) {
if ($this->request->data['DreamjobJobApplication']['agb']) {
unset($this->request->data['DreamjobJobApplication']['agb']);
$this->request->data['DreamjobJobApplication']['worker_id'] = $w['AppUser']['id'];
$this->request->data['DreamjobJobApplication']['opening_id'] = $this->request->params['id'];
$pages = $this->request->data['DreamjobJobApplicationPage']['page_id'];
unset($this->request->data['DreamjobJobApplicationPage']['page_id']);
foreach ($pages as $id)
$this->request->data['DreamjobJobApplicationPage'][] = array('page_id' => $id);
$result = $this->DreamjobJobApplication->sendApplication($this->request->data);
if ($result) {
$this->MiconwareSession->setFlash(__('dreamjob.application.send.success'), 'flash', array('alert' => 'success'));
return $this->redirect(array('action' => 'applicationGet','id'=>$this->DreamjobJobApplication->id));
} else {
$this->MiconwareSession->setFlash(__('dreamjob.application.send.error'), 'flash', array('alert' => 'danger'));
}
} else {
$this->MiconwareSession->setFlash(__('dreamjob.agb.error.notAccept'), 'flash', array('alert' => 'danger'));
}
}
$this->set('pages', $w['DreamjobPageInh']);
$this->set('opening', $opening);
$this->render('/Job/application_send');
}
} else {
$this->set('error', array('title'=>__('dreamjob.error.noWorker.title'),'text'=>__('dreamjob.error.noWorker.text')));
if(!$this->MiconwareSession->isLoggedin())
$this->render('/Home/login');
else
$this->render('/Home/error');
}
}
public function applicationSendExt() {
$this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this);
$w = $this->MiconwareSession->getWorker();
if (!empty($w)) {
if ($this->request->is('post')) {
if ($this->request->data['DreamjobJobApplication']['agb']) {
unset($this->request->data['DreamjobJobApplication']['agb']);
$this->request->data['DreamjobJobApplication']['worker_id'] = $w['AppUser']['id'];
$pages = $this->request->data['DreamjobJobApplicationPage']['page_id'];
unset($this->request->data['DreamjobJobApplicationPage']['page_id']);
foreach ($pages as $id)
$this->request->data['Page'][] = array('id' => $id);
//$result = $this->DreamjobJobApplication->sendApplication($this->request->data);
$this->request->data['WorkerUser'] = $w['User'];
$this->request->data['AppUserWorker'] = $w['AppUser'];
$this->request->data['DreamjobWorker'] = $w['DreamjobWorker'];
$this->request->data['DreamjobUserWorker'] = $w['DreamjobUser'];
$this->request->data['Mannerofaddress'] = $w['Mannerofaddress'];
$this->request->data['WorkerGraducation'] = $w['DreamjobListGraducation'];
$this->request->data['DreamjobWorkerListCity'] = $w['DreamjobListCity'];
$this->request->data['PageImage'] = $w['DreamjobListCity'];
$this->request->data['PageText'] = $w['DreamjobListCity'];
$view = new View($this, false);
$view->set('cv',$this->DreamjobCvEntry->find('all',array('conditions' => array('worker_id'=> $w['AppUser']['id']))));
$view->set('cvp0',$this->DreamjobListCvCategory->find('first',array('conditions' => array('DreamjobListCvCategory.position' => 0))));
$view->set('edit', false);
$pageText = $this->DreamjobPageText->find('all',array('conditions' => array('DreamjobPageInh.user_id' =>$w['AppUser']['id'])));
$view->set("pageText",$pageText);
$pageImage = $this->DreamjobPageImage->find('all',array('conditions' => array('DreamjobPageInh.user_id' =>$w['AppUser']['id'])));
$view->set("pageImage",$pageImage);
$view->set('application',$this->request->data);
$view->set('profil',$w);
$pdf = $view->render('/Pdf/application_ext','pdf');
$Email = new CakeEmail('dreamjobMain');
$Email->from(array('noreply@dream-job.eu'=> $w['AppUser']['first_name'] .' '. $w['AppUser']['last_name']));
$Email->to($this->request->data['DreamjobUser']['mail']);
$Email->replyTo(array($w['User']['mail']));
$Email->bcc(array($w['User']['mail']));
$Email->subject('Bewerbung von '. $w['AppUser']['first_name'] .' '. $w['AppUser']['last_name']);
$Email->template('job_application_ext');
$Email->viewVars(array('w'=>$w));
$Email->attachments(array(__('dreamjob.application.extern.filename.pdf')=>array('data' =>$pdf,'mimetype' => 'application/pdf')));
if ($Email->send()) {
$this->MiconwareSession->setFlash(__('dreamjob.application.send.success'), 'flash', array('alert' => 'success'));
} else {
$this->MiconwareSession->setFlash(__('dreamjob.application.send.error'), 'flash', array('alert' => 'danger'));
}
} else {
$this->MiconwareSession->setFlash(__('dreamjob.agb.error.notAccept'), 'flash', array('alert' => 'danger'));
}
}elseif(count($this->request->query)>0){
$this->request->data['DreamjobUser']['mail'] = $this->request->query('mail');
$this->request->data['AppUser']['nickname'] = $this->request->query('company');
$this->request->data['DreamjobUser']['street'] = $this->request->query('street');
$this->request->data['DreamjobUser']['postcode'] = $this->request->query('postcode');
$this->request->data['DreamjobListCity']['name'] = $this->request->query('city');
}
$this->set('pages', $w['DreamjobPageInh']);
$this->set('MENU_EXT_APP', true);
$this->render('/Job/application_send_ext');
} else {
$this->set('error', array('title'=>__('dreamjob.error.noWorker.title'),'text'=>__('dreamjob.error.noWorker.text')));
if(!$this->MiconwareSession->isLoggedin())
$this->render('/Home/login');
else
$this->render('/Home/error');
}
}
public function applicationSendExtInfo() {
$this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this);
$this->set('MENU_EXT_APP', true);
$this->render('/Job/application_send_ext_info');
}
}
?>