This commit is contained in:
Martin Müller 2014-04-22 22:17:01 +02:00
parent f61c912b38
commit 50df1ab161
5 changed files with 114 additions and 30 deletions

View File

@ -10,7 +10,7 @@ class JobController extends AppController {
* @var array
*/
public $uses = array('DreamjobJobOpening','DreamjobJobFavority','DreamjobJobApplication','DreamjobPageText','DreamjobPageImage','DreamjobJobMsg','DreamjobCvCategory','DreamjobListBranch');
public $uses = array('DreamjobJobOpening','DreamjobJobFavority','DreamjobJobApplication','DreamjobPageText','DreamjobPageImage','DreamjobJobMsg','DreamjobCvEntry','DreamjobListBranch');
/**
* Displays a view
@ -245,7 +245,7 @@ class JobController extends AppController {
$this->set('msg',false);
// CV
if(!empty($this->request->params['vitea'])){
$cv = $this->DreamjobCvCategory->find('all',array('conditions' => array('worker_id'=> $application['DreamjobJobApplication']['worker_id'])));
$cv = $this->DreamjobCvEntry->find('all',array('conditions' => array('worker_id'=> $application['DreamjobJobApplication']['worker_id'])));
$this->set("cv",$cv);
}else{
if(!empty($this->request->params['page'])){

View File

@ -4,9 +4,32 @@ App::uses('AppController', 'Controller');
class PdfController extends AppController {
public $uses = array('DreamjobJobApplication','DreamjobCvEntry');
public function applicationGetPdf(){
$this->layout = 'pdf';
$this->render('/Pdf/opening');
$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', 'dreamjob.error.noPermision');
$this->render('/Home/error');
}else{
$this->set('application',$application);
$cv = $this->DreamjobCvEntry->find('all',array('conditions' => array('worker_id'=> $application['DreamjobJobApplication']['worker_id'])));
$this->set("cv",$cv);
$this->layout = 'pdf';
$this->render('/Pdf/opening');
}
}
}
?>

View File

@ -173,6 +173,12 @@ class DreamjobJobApplication extends AppModel {
public $hasOne = array(
'Mannerofaddress' => array(
'className' => 'Mannerofaddress',
'foreignKey' => false,
'conditions' => array('AppUserWorker.mannerofaddress_id = Mannerofaddress.id'),
'limit' => 1
),
'WorkerGraducation' => array(
'className' => 'DreamjobListGraducation',
'foreignKey' => false,
@ -185,6 +191,15 @@ class DreamjobJobApplication extends AppModel {
'conditions' => array('DreamjobJobApplication.worker_id = AppUserWorker.id and WorkerUser.id = AppUserWorker.user_id'),
'limit' => 1
),
'DreamjobWorkerListCity' => array(
'className' => 'DreamjobListCity',
'foreignKey' => false,
'conditions' => array('DreamjobUserWorker.city_id = DreamjobWorkerListCity.id'),
'limit' => 1
),
//achtung
'DreamjobCompany' => array(
'className' => 'DreamjobCompany',
@ -216,6 +231,15 @@ class DreamjobJobApplication extends AppModel {
'conditions' => array('DreamjobJobOpening.kindofjob_id = DreamjobListKindofjob.id'),
'limit' => 1
),
'DreamjobCompanyListCity' => array(
'className' => 'DreamjobListCity',
'foreignKey' => false,
'conditions' => array('DreamjobUser.city_id = DreamjobCompanyListCity.id'),
'limit' => 1
),
'DreamjobListGraducation' => array(
'className' => 'DreamjobListGraducation',
'foreignKey' => false,

View File

@ -1,26 +1,13 @@
<?php
App::import('Vendor','tcpdf/tcpdf');
class XTCPDF extends TCPDF
{
class XTCPDF extends TCPDF{
var $fontsize = 12 ;
var $font = 'freesans' ;
var $title = '' ;
var $mail = 'dasa@sdsa.de' ;
/**
* Rot #9d1c16
* Blau #0073b8
* Overwrites the default header
* set the text in the view using
* $fpdf->xheadertext = 'YOUR ORGANIZATION';
* set the fill color in the view using
* $fpdf->xheadercolor = array(0,0,100); (r, g, b)
* set the font in the view using
* $fpdf->setHeaderFont(array('YourFont','',fontsize));
*/
function Header()
{
$this->SetY(25);
@ -29,16 +16,11 @@ class XTCPDF extends TCPDF
$this->Cell(0,0, $this->title, array('B'=>array('width' => 1,'color'=>array(157,18,22))),1,'L');
$this->SetY(25);
if($this->title=='')
$this->Image(WWW_ROOT.DS.'img'.DS.'pdf-logo-lang.png',0,5,20,30,'','','','',300,'R');
$this->Image(WWW_ROOT.DS.'img'.DS.'pdf-logo-lang.png',0,10,85,20,'','','','',300,'R');
else
$this->Image(WWW_ROOT.DS.'img'.DS.'pdf-logo.png',0,5,20,20,'','','','',300,'R');
$this->Image(WWW_ROOT.DS.'img'.DS.'pdf-logo.png',0,10,20,20,'','','','',300,'R');
}
/**
* Overwrites the default footer
* set the text in the view using
* $fpdf->xfootertext = 'Copyright © %d YOUR ORGANIZATION. All rights reserved.';
*/
function Footer()
{
$this->SetY(-20);

View File

@ -1,26 +1,81 @@
<?php
App::import('Vendor','tcpdf/xtcpdf');
ob_end_clean();
$dev = 1;
$tcpdf = new XTCPDF();
$tcpdf->SetAuthor("Miconware");
$tcpdf->SetAutoPageBreak( false );
// add a page (required with recent versions of tcpdf)
$tcpdf->mail=$application['WorkerUser']['mail'];
$tcpdf->AddPage();
// Now you position and print your page content
// example:
// Deckblatt
$tcpdf->SetY(35);
$tcpdf->SetTextColor(0, 0, 0);
$tcpdf->SetFont($tcpdf->font);
$tcpdf->Cell(0,0, "Hello World", 0,1,'L');
$tcpdf->Image(WWW_ROOT.DS.'uploads'.DS.$application['AppUserWorker']['avatar'],0,35,0,140,'','','','',300,'L');
$tcpdf->SetY(180);
$tcpdf->SetFont($tcpdf->font,'B',$tcpdf->fontsize);
$tcpdf->Cell(0,0, __('dreamjob.application'), 0,1,'L');
$tcpdf->SetFont($tcpdf->font);
$tcpdf->Cell(0,0, __('dreamjob.application.for').' '.$application['DreamjobJobOpening']['title'], 0,1,'L');
$tcpdf->SetY(255);
$tcpdf->Cell(0,0, $application['Mannerofaddress']['name'].' '.$application['AppUserWorker']['first_name'].' '.$application['AppUserWorker']['last_name'], 0,1,'R');
$tcpdf->Cell(0,0, $application['DreamjobUserWorker']['street'], 0,1,'R');
$tcpdf->Cell(0,0, $application['DreamjobUserWorker']['postcode'].' '.$application['DreamjobWorkerListCity']['name'], 0,1,'R');
//Anschreiben
$tcpdf->title='Anschreiben';
$tcpdf->AddPage();
$tcpdf->SetY(35);
$tcpdf->SetTextColor(0, 0, 0);
$tcpdf->SetFont($tcpdf->font);
$tcpdf->Cell(0,0, "Hello World", 0,1,'L');
$tcpdf->Cell(0,0, $application['Mannerofaddress']['name'].' '.$application['AppUserWorker']['first_name'].' '.$application['AppUserWorker']['last_name'], 0,1,'L');
$tcpdf->Cell(0,0, $application['DreamjobUserWorker']['street'], 0,1,'L');
$tcpdf->Cell(0,0, $application['DreamjobUserWorker']['postcode'].' '.$application['DreamjobWorkerListCity']['name'], 0,1,'L');
$tcpdf->SetY(60);
$tcpdf->Cell(0,0, $application['AppUser']['nickname'].' '.$application['DreamjobCompany']['corporateform'], 0,1,'L');
$tcpdf->Cell(0,0, $application['DreamjobUser']['street'], 0,1,'L');
$tcpdf->Cell(0,0, $application['DreamjobUser']['postcode'].' '.$application['DreamjobListCity']['name'], 0,1,'L');
$tcpdf->SetY(85);
$tcpdf->SetFont($tcpdf->font,'B',$tcpdf->fontsize);
$tcpdf->Cell(0,0, __('dreamjob.application.subject'), 0,1,'L');
$tcpdf->SetFont($tcpdf->font);
$tcpdf->writeHTMLCell(0,175,10,95, $application['DreamjobJobApplication']['text'], $dev,0,false,true,'L');
//Lebenslauf
//Anhang
foreach($application['Page'] as $page){
$tcpdf->title=$page['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;
}
$tcpdf->writeHTMLCell(0,35,10,235, $pageType['text'], $dev,0,false,true,'L');
}else{
$tcpdf->Image(WWW_ROOT.DS.'uploads'.DS.$pageType['image'],0,35,0,235,'','','','',300,'C');
}
}
// ...
// etc.
// see the TCPDF examples