ppeasy/public/pdf-creation.php

484 lines
19 KiB
PHP

<head>
<meta charset="UTF-8">
</head>
<?php require_once('../Connections/cmctrfdb.php'); ?>
<?php require_once('../webassist/mysqli/rsobj.php');
require_once('../webassist/mysqli/queryobj.php'); ?>
<?php
//global variable
include('include/generalsettings.php');
// start fpdf
require('fpdf/fpdf.php');
include('languages/' . $_SESSION['langselect'] . '/pdflang.php');
function convertToPDFEncoding($string)
{
$decoded = html_entity_decode($string, ENT_QUOTES, 'UTF-8');
return iconv('UTF-8', 'windows-1252', $decoded);
}
//include('include/headscript.php');
?>
<?php
if (isset($_GET["idtrf"])) {
$idtrf = $_GET["idtrf"];
}
if (isset($_POST["idtrf"])) {
$idtrf = $_POST["idtrf"];
}
//zip creation
include('include/zipcreation.php');
include('datarecover/parsedata.php');
$nappform = $trfData['trfnumber'];
if ($trfData['revtrf'] == 0) {
$nappformfinaltest = $pdnappformtest . ' ' . $nappform;
} else {
$revnbr = $trfData['revtrf'];
$nappformfinaltest = $pdnappformtest . ' ' . $nappform . 'R' . $revnbr;
}
if ($trfData['revtrf'] == 0) {
$nappformfinal = $pdnappform . ' ' . $nappform;
} else {
$revnbr = $trfData['revtrf'];
$nappformfinal = $pdnappform . ' ' . $nappform . 'R' . $revnbr;
}
$nappformfinaltest = html_entity_decode($nappformfinaltest, ENT_QUOTES);
$nappformfinaltest = iconv('UTF-8', 'windows-1252//IGNORE', $nappformfinaltest);
$nappformfinal = html_entity_decode($nappformfinal, ENT_QUOTES);
$nappformfinal = iconv('UTF-8', 'windows-1252//IGNORE', $nappformfinal);
//$nappformtest=$pdnappformtest.' '.$nappform;
//$nappformfinal=$nappform;
//$nappformfinal=$nappformtest;
$_SESSION["idcertificatesession"] = $idcertificate;
$_SESSION["sndrptsession"] = $sndrpt;
$_SESSION["revisioncert"] = $certificationrevision->getColumnVal("rev");
$_SESSION["revisioncertm30"] = $certificationrevision->getColumnVal("revm30");
$_SESSION["certname"] = $certificationrevision->getColumnVal("name_certification");
$_SESSION["certname30"] = $certificationrevision->getColumnVal("m30namecert");
$daterevformat = $certificationrevision->getColumnVal("date");
$timeStamp = strtotime($daterevformat);
$_SESSION["certdate"] = date("d-m-Y", $timeStamp);
$daterevformatm30 = $certificationrevision->getColumnVal("datem30");
$timeStampm30 = strtotime($daterevformatm30);
$_SESSION["certdatem30"] = date("d-m-Y", $timeStampm30);
$_SESSION["certtitle"] = $_SESSION["certname"] . ' rev. ' . $_SESSION["revisioncert"] . ' del ' . $_SESSION["certdate"];
$_SESSION["certtitlem30"] = $_SESSION["certname30"] . ' rev. ' . $_SESSION["revisioncertm30"] . ' del ' . $_SESSION["certdatem30"];
class PDF extends FPDF
{
/* CENTER IMAGE IN CELL */
const DPI = 96;
const MM_IN_INCH = 25.4;
const A4_HEIGHT = 297;
const A4_WIDTH = 210;
// tweak these values (in pixels), convert mm to px
const MAX_WIDTH = 359.05511811; /* IMG CONTAINER - WIDTH */
const MAX_HEIGHT = 226.77165354; /* IMG CONTAINER - HEIGHT */
const MAX_WIDTH_S = 264.56692913; /* IMG CONTAINER SMALL - WIDTH */
const MAX_HEIGHT_S = 158.74015748; /* IMG CONTAINER SMALL - HEIGHT */
function pixelsToMM($val)
{
return $val * self::MM_IN_INCH / self::DPI;
}
function resizeToFit($imgFilename, $cellWidth, $cellHeight, $containerSize)
{
list($width, $height) = getimagesize($imgFilename);
if ($containerSize == 'S') {
/* SMALL CONTAINER SIZE */
$widthScale = self::MAX_WIDTH_S / $width;
$heightScale = self::MAX_HEIGHT_S / $height;
} else {
/* DEFAULT CONTAINER SIZE */
$widthScale = self::MAX_WIDTH / $width;
$heightScale = self::MAX_HEIGHT / $height;
}
$scale = min($widthScale, $heightScale);
$width_in_mm = round($this->pixelsToMM($scale * $width)); /* IMAGE WIDTH */
$height_in_mm = round($this->pixelsToMM($scale * $height)); /* IMAGE HEIGHT */
/* IF IMAGE WIDTH IS SMALLER THAN THE CELL WIDTH, STRETCH IMAGE */
if ($width_in_mm < $cellWidth) {
$add_w = $cellWidth - $width_in_mm;
} else {
$add_w = 0;
}
/* IF IMAGE IS IN PORTRAIT MODE, ALIGN TO CENTER */
if ($width_in_mm <= ($cellWidth / 2)) {
$image_x = $width_in_mm / 2;
$add_w = 0;
} else {
$image_x = 1;
}
/* IF IMAGE IS TALLER THAN CELL HEIGHT, RESIZE TO FIT */
if ($height_in_mm > $cellHeight) {
$height_in_mm = $cellHeight;
}
/* IF IMAGE IS WIDER THAN CELL, RESIZE TO FIT */
if ($width_in_mm > $cellWidth) {
$width_in_mm = $cellWidth - 2;
}
return array(
$width_in_mm,
$height_in_mm,
$add_w,
$image_x
);
}
function centreImage($img, $cellWidth, $cellHeight, $containerSize)
{
list($width, $height, $add_image_width, $add_abscissa) = $this->resizeToFit($img, $cellWidth - 2, $cellHeight - 1, $containerSize);
// $this->Image($img, $this->GetX()+$add_abscissa, $this->GetY(), $width+$add_image_width, $height);
$this->Image($img, $this->GetX() + $add_abscissa, $this->GetY() + 1, $width + $add_image_width, $height - 1);
}
/* END CENTER IMAGE IN CELL */
// Page header
function Header()
{
// Logo
$this->Image('../images/cimac-logo.png', 5, 5, 70);
$this->SetFont('Arial', '', 7);
//$this->Cell(0,-5,'A.N.C.I. Servizi S.r.l. a socio unico',0,0,"R");
//$this->Cell(0,2,'Sede operativa / Operational headquarters: Via Aguzzafame 60/b - 27029 Vigevano (PV)',0,0,"R");
//$this->Cell(0,9,'ORGANISMO NOTIFICATO / NOTIFIED BODY N. 0465',0,0,"R");
$this->SetFont('Arial', 'B', 14);
if ($_SESSION["sndrptsession"] == 'N' and $_SESSION["idcertificatesession"] == 1 || $_SESSION["idcertificatesession"] == 3 || $_SESSION["idcertificatesession"] == 8 || $_SESSION["idcertificatesession"] == 9 || $_SESSION["idcertificatesession"] == 4) {
$this->Cell(0, 35, $GLOBALS['nappformfinaltest'], 0, 0, "C");
} else {
$this->Cell(0, 35, $GLOBALS['nappformfinal'], 0, 0, "C");
}
// Line break
$this->Ln(25);
}
// Page footer
function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-45);
// Arial italic 8
$this->SetFont('Arial', '', 8);
// Page number and certification revision
// $revisioncert=$certificationrevision->getColumnVal("rev");
// $certname=$certificationrevision->getColumnVal("name_certification");
// $certdate=$certificationrevision->getColumnVal("date");
// $certtitle=$certname.' rev. '.$revisioncert.' '.$certdate;
$certittle = $_SESSION["certtitle"];
$certittlem30 = $_SESSION["certtitlem30"];
if ($_SESSION["sndrptsession"] == 'N' and $_SESSION["idcertificatesession"] == 1 || $_SESSION["idcertificatesession"] == 3 || $_SESSION["idcertificatesession"] == 8 || $_SESSION["idcertificatesession"] == 9) {
$this->Cell(0, 10, $certittlem30 . ' - Pagina ' . $this->PageNo() . '/{nb}', 0, 0, 'C');
$this->Image('../images/cimaclaboratories.png', 10, 260, 190);
} else {
$this->Cell(0, 10, $certittle . ' - Pagina ' . $this->PageNo() . '/{nb}', 0, 0, 'C');
$this->Image('../images/cimaccertifications.png', 10, 260, 190);
}
}
//include('pdfcreation/headerandfooter.php');
}
//some general data
$certname = $certificationrevision->getColumnVal("name_certification");
// Instanciation of inherited class
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times', '', 9);
$pdf->SetAutoPageBreak(true, 45);
// from here start customization based on certification required required
// certificate 5 and 6 Table: contacts auditdpi and documents
if ($idcertificate == 5 || $idcertificate == 6) {
include('pdfcreation/pdf5and6.php');
} elseif ($sndrpt == 'Y' and $idcertificate == 4) {
include('pdfcreation/pdf4snd.php');
} elseif ($sndrpt == 'Y' and $idcertificate == 1) {
echo "sndrptyes";
include('pdfcreation/pdf1snd.php');
} elseif ($sndrpt == 'N' and $idcertificate == 4) {
include('pdfcreation/pdf4.php');
} elseif ($sndrpt == 'N' and $idcertificate == 1) {
include('pdfcreation/pdf1.php');
} elseif ($idcertificate == 2) {
include('pdfcreation/pdf2.php');
} elseif ($sndrpt == 'Y' and $idcertificate == 3) {
include('pdfcreation/pdf3snd.php');
} elseif ($sndrpt == 'N' and $idcertificate == 3) {
include('pdfcreation/pdf3.php');
} elseif ($sndrpt == 'Y' and $idcertificate == 8) {
include('pdfcreation/pdf8snd.php');
} elseif ($sndrpt == 'N' and $idcertificate == 8) {
include('pdfcreation/pdf8.php');
} else {
//othercertificate
//description table
include('pdfcreation/descriptiontable.php');
$pdf->Ln();
// standards table
include('pdfcreation/standardstable.php');
$pdf->Ln();
// additionalinfo requirements
include('pdfcreation/addreqtable.php');
$pdf->Ln();
// additionalinfo
include('pdfcreation/addinfotable.php');
$pdf->Ln();
// parts table
include('pdfcreation/partstable.php');
$pdf->Ln();
// chem table
include('pdfcreation/chemtable.php');
$pdf->Ln();
//trf option
include('pdfcreation/trfoption.php');
$pdf->Ln();
//trf option
include('pdfcreation/fileattached.php');
$pdf->Ln();
$pdf->Ln();
//header report contact
include('pdfcreation/headerreporttable.php');
$pdf->Ln();
//header certificate contact
include('pdfcreation/headercertificatetable.php');
$pdf->Ln();
//invoice contact
include('pdfcreation/invoicecontacttable.php');
$pdf->Ln();
//Sign datatable
include('pdfcreation/signdatatable.php');
$pdf->Ln();
}
//outpt pdf for all certificate
include('pdfcreation/pdfoutput.php');
//include('pdfcreation/pdf1sndbis.php');
?>
<?php
//second pdf creation
if ($idcertificate == 1 or $idcertificate == 3 or $idcertificate == 8 or $idcertificate == 9 or $idcertificate == 4) {
if (isset($_GET["idtrf"])) {
$idtrf = $_GET["idtrf"];
}
if (isset($_POST["idtrf"])) {
$idtrf = $_POST["idtrf"];
}
//zip creation
include('include/zipcreation.php');
include('datarecover/parsedata.php');
$_SESSION["sndrptsession"] = 'Y';
$_SESSION["idcertificatesession"] = $idcertificate;
$sndrpt = "Y";
//exit();
$_SESSION["revisioncert"] = $certificationrevision->getColumnVal("rev");
$_SESSION["revisioncertm30"] = $certificationrevision->getColumnVal("revm30");
$_SESSION["certname"] = $certificationrevision->getColumnVal("name_certification");
$_SESSION["certname30"] = $certificationrevision->getColumnVal("m30namecert");
$daterevformat = $certificationrevision->getColumnVal("date");
$timeStamp = strtotime($daterevformat);
$_SESSION["certdate"] = date("d-m-Y", $timeStamp);
$daterevformatm30 = $certificationrevision->getColumnVal("datem30");
$timeStampm30 = strtotime($daterevformatm30);
$_SESSION["certdatem30"] = date("d-m-Y", $timeStampm30);
$_SESSION["certtitle"] = $_SESSION["certname"] . ' rev. ' . $_SESSION["revisioncert"] . ' del ' . $_SESSION["certdate"];
$_SESSION["certtitlem30"] = $_SESSION["certname30"] . ' rev. ' . $_SESSION["revisioncertm30"] . ' del ' . $_SESSION["certdatem30"];
class PDF2 extends FPDF
{
/* CENTER IMAGE IN CELL */
const DPI = 96;
const MM_IN_INCH = 25.4;
const A4_HEIGHT = 297;
const A4_WIDTH = 210;
// tweak these values (in pixels), convert mm to px
const MAX_WIDTH = 359.05511811; /* IMG CONTAINER - WIDTH */
const MAX_HEIGHT = 226.77165354; /* IMG CONTAINER - HEIGHT */
const MAX_WIDTH_S = 264.56692913; /* IMG CONTAINER SMALL - WIDTH */
const MAX_HEIGHT_S = 158.74015748; /* IMG CONTAINER SMALL - HEIGHT */
function pixelsToMM($val)
{
return $val * self::MM_IN_INCH / self::DPI;
}
function resizeToFit($imgFilename, $cellWidth, $cellHeight, $containerSize)
{
list($width, $height) = getimagesize($imgFilename);
if ($containerSize == 'S') {
/* SMALL CONTAINER SIZE */
$widthScale = self::MAX_WIDTH_S / $width;
$heightScale = self::MAX_HEIGHT_S / $height;
} else {
/* DEFAULT CONTAINER SIZE */
$widthScale = self::MAX_WIDTH / $width;
$heightScale = self::MAX_HEIGHT / $height;
}
$scale = min($widthScale, $heightScale);
$width_in_mm = round($this->pixelsToMM($scale * $width)); /* IMAGE WIDTH */
$height_in_mm = round($this->pixelsToMM($scale * $height)); /* IMAGE HEIGHT */
/* IF IMAGE WIDTH IS SMALLER THAN THE CELL WIDTH, STRETCH IMAGE */
if ($width_in_mm < $cellWidth) {
$add_w = $cellWidth - $width_in_mm;
} else {
$add_w = 0;
}
/* IF IMAGE IS IN PORTRAIT MODE, ALIGN TO CENTER */
if ($width_in_mm <= ($cellWidth / 2)) {
$image_x = $width_in_mm / 2;
$add_w = 0;
} else {
$image_x = 1;
}
/* IF IMAGE IS TALLER THAN CELL HEIGHT, RESIZE TO FIT */
if ($height_in_mm > $cellHeight) {
$height_in_mm = $cellHeight;
}
/* IF IMAGE IS WIDER THAN CELL, RESIZE TO FIT */
if ($width_in_mm > $cellWidth) {
$width_in_mm = $cellWidth - 2;
}
return array(
$width_in_mm,
$height_in_mm,
$add_w,
$image_x
);
}
function centreImage($img, $cellWidth, $cellHeight, $containerSize)
{
list($width, $height, $add_image_width, $add_abscissa) = $this->resizeToFit($img, $cellWidth - 2, $cellHeight - 1, $containerSize);
// $this->Image($img, $this->GetX()+$add_abscissa, $this->GetY(), $width+$add_image_width, $height);
$this->Image($img, $this->GetX() + $add_abscissa, $this->GetY() + 1, $width + $add_image_width, $height - 1);
}
/* END CENTER IMAGE IN CELL */
// Page header
function Header()
{
// Logo
// if ($_SESSION["sndrptsession"]=='N' and $_SESSION["idcertificatesession"]==1 || $_SESSION["idcertificatesession"]==3 || $_SESSION["idcertificatesession"]==5 || $_SESSION["idcertificatesession"]==7) {
//$this->Image('../images/cimaclaboratories.png',10,5,190);
// } else {
$this->Image('../images/cimac-logo.png', 5, 5, 70);
$this->SetFont('Arial', '', 7);
//$this->Cell(0,-5,'A.N.C.I. Servizi S.r.l. a socio unico',0,0,"R");
//$this->Cell(0,2,'Sede operativa / Operational headquarters: Via Aguzzafame 60/b - 27029 Vigevano (PV)',0,0,"R");
//$this->Cell(0,9,'ORGANISMO NOTIFICATO / NOTIFIED BODY N. 0465',0,0,"R");
$this->SetFont('Arial', 'B', 14);
$this->Cell(0, 35, $GLOBALS['nappformfinal'], 0, 0, "C");
// Line break
$this->Ln(25);
}
// Page footer
function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-45);
// Arial italic 8
$this->SetFont('Arial', '', 8);
// Page number and certification revision
// $revisioncert=$certificationrevision->getColumnVal("rev");
// $certname=$certificationrevision->getColumnVal("name_certification");
// $certdate=$certificationrevision->getColumnVal("date");
// $certtitle=$certname.' rev. '.$revisioncert.' '.$certdate;
$certittle = $_SESSION["certtitle"];
$this->Cell(0, 10, $certittle . ' - Pagina ' . $this->PageNo() . '/{nb}', 0, 0, 'C');
$this->Image('../images/cimaccertifications.png', 10, 260, 190); //}
}
//include('pdfcreation/headerandfooter.php');
}
//some general data
$certname = $certificationrevision->getColumnVal("name_certification");
// Instanciation of inherited class
$pdf = new PDF2();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times', '', 9);
$pdf->SetAutoPageBreak(true, 45);
// from here start customization based on certification required required
// certificate 5 and 6 Table: contacts auditdpi and documents
if ($idcertificate == 5 and $idcertificate == 6) {
include('pdfcreation/pdf5and6.php');
} elseif ($sndrpt == 'Y' and $idcertificate == 4) {
include('pdfcreation/pdf4snd.php');
} elseif ($sndrpt == 'Y' and $idcertificate == 1) {
include('pdfcreation/pdf1snd.php');
} elseif ($sndrpt == 'N' and $idcertificate == 4) {
include('pdfcreation/pdf4.php');
} elseif ($sndrpt == 'N' and $idcertificate == 1) {
include('pdfcreation/pdf1.php');
} elseif ($idcertificate == 2) {
include('pdfcreation/pdf2.php');
} elseif ($sndrpt == 'Y' and $idcertificate == 3) {
include('pdfcreation/pdf3snd.php');
} elseif ($sndrpt == 'N' and $idcertificate == 3) {
include('pdfcreation/pdf3.php');
} elseif ($sndrpt == 'Y' and $idcertificate == 8) {
include('pdfcreation/pdf8snd.php');
} elseif ($sndrpt == 'N' and $idcertificate == 8) {
include('pdfcreation/pdf8.php');
} else {
//othercertificate
//description table
include('pdfcreation/descriptiontable.php');
$pdf->Ln();
// standards table
include('pdfcreation/standardstable.php');
$pdf->Ln();
// additionalinfo requirements
include('pdfcreation/addreqtable.php');
$pdf->Ln();
// additionalinfo
include('pdfcreation/addinfotable.php');
$pdf->Ln();
// parts table
include('pdfcreation/partstable.php');
$pdf->Ln();
// chem table
include('pdfcreation/chemtable.php');
$pdf->Ln();
//trf option
include('pdfcreation/trfoption.php');
$pdf->Ln();
//trf option
include('pdfcreation/fileattached.php');
$pdf->Ln();
$pdf->Ln();
//header report contact
include('pdfcreation/headerreporttable.php');
$pdf->Ln();
//header certificate contact
include('pdfcreation/headercertificatetable.php');
$pdf->Ln();
//invoice contact
include('pdfcreation/invoicecontacttable.php');
$pdf->Ln();
//Sign datatable
include('pdfcreation/signdatatable.php');
$pdf->Ln();
include('photobook.php');
}
//outpt pdf for all certificate
include('pdfcreation/pdfoutput.php');
}
?>