initial commit
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Pdfmaker extends MY_Controller{
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$models = array(
|
||||
"Phantom_model",
|
||||
"monpas/Compactsop_model",
|
||||
"monpas/Schooldetails_model"
|
||||
|
||||
);
|
||||
$this->load->model($models);
|
||||
$this->load->helper('string');
|
||||
// if ( ! $this->check_online_status() ) {
|
||||
// echo json_encode( array('offline' => TRUE) );
|
||||
// die;
|
||||
// };// if
|
||||
}
|
||||
|
||||
function pdfSVG(){
|
||||
// if (!$this->userid) die;
|
||||
$inputstring = $this->input->post('data');
|
||||
$input = json_decode($inputstring);
|
||||
$inhoud = $input->pagina;
|
||||
$titel = $input->titel;
|
||||
$schoolid = $input->schoolid;
|
||||
$schooljaarnummer = $input->schooljaarnr;
|
||||
$organisatie = $this->Organisaties_model->get(['id' => $schoolid],false, true);
|
||||
$data['inhoud' ]= $inhoud;
|
||||
$html = $this->load->view('monpas/compactsop/sopcompact.php', $data, TRUE);
|
||||
$date = date('dmY');
|
||||
$zoek = [" ", "'", "/"];
|
||||
$schoolid = str_replace($zoek, "",$schoolid);
|
||||
$schoolnaam = str_replace($zoek, "",$organisatie->naamkort);
|
||||
$titel = str_replace($zoek, "",$titel);
|
||||
|
||||
$frameworklogo= $this->config->item('vendor_url').'/images/logos/frameworklogo.png';
|
||||
$logonaam = $this->Schooldetails_model->get(["organisatie_id" =>$schoolid],'logo', true);
|
||||
if (! $logonaam) $logonaam="monpaslogo.png";
|
||||
$schoollogo = $this->config->item('vendor_url').'/images/logos/'.$logonaam;
|
||||
|
||||
$headerdata = ['titel' =>$titel,
|
||||
'schoolnaam' =>$schoolnaam ? $schoolnaam : '',
|
||||
'logoframework' =>$frameworklogo,
|
||||
'logoschool' =>$schoollogo];
|
||||
$footerdata = "";
|
||||
$header = $this->load->view( "monpas/compactsop/compactheader", $headerdata, TRUE ) ;
|
||||
$footer = $this->load->view ("monpas/compactsop/compactfooter", $footerdata, TRUE);
|
||||
$filenaam = $this->compactsoppath.'sop.pdf';
|
||||
|
||||
$bestandsnaam = "compactsop".$schoolnaam.$schoolid.$titel.'-'.$date.'.pdf';
|
||||
$downloadnaam = $this->compactsoppath.$bestandsnaam;
|
||||
|
||||
// TODO check if exists
|
||||
$data = [ 'organisatie_id' =>$schoolid,
|
||||
'schooljaarnummer' => $schooljaarnummer];
|
||||
$csop = $this->Compactsop_model->get($data,false, true);
|
||||
|
||||
if ($csop && $csop->id){
|
||||
unlink($this->compactsoppath.$csop->pdfnaam);
|
||||
$this->Compactsop_model->update_record(['pdfnaam'=>$bestandsnaam], $csop->id);
|
||||
$sopid = $csop->id;
|
||||
} else {
|
||||
$data['pdfnaam'] = $bestandsnaam;
|
||||
$sopid = $this->Compactsop_model->insert_record($data);
|
||||
}
|
||||
$margins = [15, 15,10, 5, 150]; //100 was 45 = headerheight
|
||||
|
||||
$pdf= $this->Phantom_model->create_and_get_pdf($html, $filenaam, $header, TRUE, $margins,'portrait',TRUE,TRUE);
|
||||
file_put_contents($downloadnaam, $pdf);
|
||||
chmod($downloadnaam, 0777);
|
||||
|
||||
header( 'Content-Description: File Transfer' );
|
||||
header( 'Content-Type: application/pdf' );
|
||||
header( 'Content-disposition:inline; filename="' .$bestandsnaam.'"');
|
||||
header( 'Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0' );
|
||||
header( 'Pragma: public' );
|
||||
header( 'Content-Length: ' . filesize( $downloadnaam ) );
|
||||
readfile($downloadnaam);
|
||||
//
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user