From d76de46eb6df179b21dc0ba115b5ca24d12d790d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=BCller?= Date: Sat, 16 Aug 2014 12:58:29 +0200 Subject: [PATCH] externe bewerbung Formulat --- app/Controller/JobController.php | 44 ++++++++++++++++++++++++++++-- app/View/Pdf/application_ext.ctp | 47 +++++++++++++++++++------------- 2 files changed, 69 insertions(+), 22 deletions(-) diff --git a/app/Controller/JobController.php b/app/Controller/JobController.php index 0f98f9f..75ca0aa 100644 --- a/app/Controller/JobController.php +++ b/app/Controller/JobController.php @@ -381,10 +381,46 @@ class JobController extends AppController { $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); + $this->request->data['Page'][] = array('id' => $id); //$result = $this->DreamjobJobApplication->sendApplication($this->request->data); - $result = false; - if ($result) { + + $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'); + + $Email = new CakeEmail('dreamjobMain'); + + $Email->to($this->request->data['DreamjobUser']['mail']); + $Email->subject(__('dreamjob.application.extern')); + $Email->template('simple_message'); + $Email->viewVars(array('data'=>'test')); + $Email->attachments(array('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')); @@ -399,8 +435,10 @@ class JobController extends AppController { $this->request->data['DreamjobUser']['postcode'] = $this->request->query('postcode'); $this->request->data['DreamjobListCity']['name'] = $this->request->query('city'); } + $this->set('pages', $w['DreamjobPageInh']); $this->render('/Job/application_send_ext'); + } else { $this->set('error', array('title'=>__('dreamjob.error.noWorker.title'),'text'=>__('dreamjob.error.noWorker.text'))); $this->render('/Home/error'); diff --git a/app/View/Pdf/application_ext.ctp b/app/View/Pdf/application_ext.ctp index 6ebad03..130cdfd 100644 --- a/app/View/Pdf/application_ext.ctp +++ b/app/View/Pdf/application_ext.ctp @@ -1,7 +1,8 @@ element('user_worker_cv_pdf',array('profil'=>array('User'=>$application['WorkerUser'] ,'AppUser'=>$application['AppUserWorker'],'DreamjobWorker'=>$application['DreamjobWorker'],'DreamjobListGraducation'=>$application['WorkerGraducation'],'DreamjobListCity'=>$application['DreamjobWorkerListCity']))); @@ -35,7 +36,7 @@ $tcpdf->SetY(185); //$tcpdf->SetFont($tcpdf->font,'B',$tcpdf->fontsize+4); //$tcpdf->Cell(0,0, , 0,1,'L'); //$tcpdf->SetFont($tcpdf->font,'',$tcpdf->fontsize); -$tcpdf->writeHTML('

'.__('dreamjob.application.extern').'

'.__('dreamjob.application.for').' '.$application['DreamjobJobOpening']['title']); +$tcpdf->writeHTML('

'.__('dreamjob.application.extern').'

'); $tcpdf->SetY(255); $tcpdf->Cell(0,0, $application['Mannerofaddress']['name'].' '.$application['AppUserWorker']['first_name'].' '.$application['AppUserWorker']['last_name'], 0,1,'R'); @@ -60,6 +61,7 @@ $tcpdf->Cell(0,0, $application['DreamjobUser']['postcode'].' '.$application['Dre $tcpdf->writeHTML('

'.$application['DreamjobJobApplication']['subject'].'


'.$application['DreamjobJobApplication']['text']); + //Lebenslauf $tcpdf->title=__('dreamjob.cv'); $tcpdf->AddPage(); @@ -72,26 +74,32 @@ $tcpdf->SetAutoPageBreak( false ); //Anhang foreach($application['Page'] as $page){ - $tcpdf->title=$page['title']; + + $pageType = null; + $pageTypeI = false; + foreach($pageImage as $pg){ + if($page['id'] == $pg['DreamjobPageInh']['id']){ + $pageType=$pg; + $pageTypeI=true; + } + } + if($pageType==null){ + foreach($pageText as $pg){ + if($page['id'] == $pg['DreamjobPageInh']['id']) + $pageType=$pg; + } + } + + $tcpdf->title=$pageType['DreamjobPageInh']['title']; $tcpdf->AddPage(); $tcpdf->SetY(35); $tcpdf->SetTextColor(0, 0, 0); $tcpdf->SetFont($tcpdf->font); - - $pageType = null; - foreach($application['PageImage'] as $pg){ - if($page['id'] == $pg['page_ptr_id']) - $pageType=$pg; - } - if($pageType==null){ - foreach($application['PageText'] as $pg){ - if($page['id'] == $pg['page_ptr_id']) - $pageType=$pg; - } + if(!$pageTypeI){ //$tcpdf->writeHTMLCell(0,235,10,35, $pageType['text'], $dev,0,false,true,'L'); - $tcpdf->writeHTML($pageType['text']); + $tcpdf->writeHTML($pageType['DreamjobPageText']['text']); }else{ - $tcpdf->Image(WWW_ROOT.DS.'uploads'.DS.$pageType['image'],0,35,0,235,'','','','',300,'C'); + $tcpdf->Image(WWW_ROOT.DS.'uploads'.DS.$pageType['DreamjobPageImage']['image'],0,35,0,235,'','','','',300,'C'); } } // ... @@ -100,6 +108,7 @@ foreach($application['Page'] as $page){ //$tcpdf->Output('filename.pdf','I'); // TO Download -$tcpdf->Output('/tmp/filename.pdf','F'); -// return null; +echo $tcpdf->Output('filename.pdf','S'); +//return null; +//ob_start(); ?>