| Current Path : /home/ataenra/www/ATA/INTRANET/GenPDF/8DIU/ |
| Current File : /home/ataenra/www/ATA/INTRANET/GenPDF/8DIU/genpdfDIU.php |
<?php
//Require Fpdf et FPDI
use setasign\Fpdi\Fpdi;
require_once('../../outils/fpdf/fpdf.php');
require_once('../../outils/fpdi-2.3.7/src/autoload.php');
//RECUPERATION DES DONNEES
//connexion a la base de donnée
require_once '../../Outils/co.php';
//generer l'attestation sur l'honneur meme sans primes
//recuperation les informations selon ID en get (page?ID=)
$ID = $_GET['ID'];
$Tp = $_GET['Tp'];
$sth = $dbco->prepare("SELECT * FROM dossier D JOIN client C ON D.IDclient=C.IDc JOIN ".$Tp." P ON P.IDp=D.IDprojet WHERE ID = $ID");
$sth->execute();
$R = $sth->fetch(PDO::FETCH_OBJ);
require "../../GenPDF/3Sonergia/genpdfBARTH.php";
// Création du nouveau répertoire
$chemin ="../../../FICHIERS/$ID/DIU";
if(!is_dir($chemin)) { mkdir($chemin, 0777,true);}
//--------------------------------------------------------- ASSEMBLAGE APRES SOMMAIRE SELON ORDRE----------------------------------------------
$pdf= new FPDI();
$pdf->SetAutoPagebreak(False);
$count = 0;
//SIMULATION
$pageCount = $pdf->setSourceFile('../../../FICHIERS/'.$ID.'/Simulation/Simulation'.$ID.'.pdf');
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++ ) {
$count++;
$tplIdx = $pdf->importPage($pageNo);
// add a page
$pdf->AddPage();
$pdf->useTemplate($tplIdx, 0, 0, 210);
//font and color selection
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
if ($count&1){
$pdf->SetXY(205, 292);}
else{$pdf->SetXY(0, 292);}
$pdf->Cell(5,5,''.$count.'',1,1,'C',true);
}
if ($count&1){$count++;
$pdf->AddPage();
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
if ($count&1){
$pdf->SetXY(205, 292);}
else{$pdf->SetXY(0, 292);}
$pdf->Cell(5,5,''.$count.'',1,1,'C',true);
}
//DEVIS SIGNE
$devis=0;
$pageCount = $pdf->setSourceFile('../../../FICHIERS/'.$ID.'/Devis/DevisValide.'.$ID.'.pdf');
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++ ) {
$count++;$devis++;
$tplIdx = $pdf->importPage($pageNo);
// add a page
$pdf->AddPage();
$pdf->useTemplate($tplIdx, 0, 0, 210);
//font and color selection
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
if ($count&1){
$pdf->SetXY(205, 292);}
else{$pdf->SetXY(0, 292);}
$pdf->Cell(5,5,''.$count.'',1,1,'C',true);
}
//saut de page devis
if ($count&1){$count++;
$pdf->AddPage();
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
if ($count&1){
$pdf->SetXY(205, 292);}
else{$pdf->SetXY(0, 292);}
$pdf->Cell(5,5,''.$count.'',1,1,'C',true);
}
//FACTURE
$pdf->AddPage();$count++;
$pdf->setSourceFile('../../../FICHIERS/'.$ID.'/Facture/Facture.'.$ID.'.pdf');
$tplIdx2 = $pdf->importPage(1);
$pdf->useTemplate($tplIdx2, 0, 0, 210);
//Etiquette Page
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
if ($count&1){
$pdf->SetXY(205, 292);}
else{$pdf->SetXY(0, 292);}
$pdf->Cell(5,5,''.$count.'',1,1,'C',true);
//saut de page facture
if ($count&1){$count++;
$pdf->AddPage();
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
if ($count&1){
$pdf->SetXY(205, 292);}
else{$pdf->SetXY(0, 292);}
$pdf->Cell(5,5,''.$count.'',1,1,'C',true);
}
if($R->PrimeATA =="Oui"){
//DOSSIER SONERGIA page 1 du dossier final /
$pdf->AddPage();$count++;
$pdf->setSourceFile('../../../FICHIERS/'.$ID.'/Sonergia/sonergiafinal'.$ID.'.pdf');
$tplIdx2 = $pdf->importPage(1);
$pdf->useTemplate($tplIdx2, 0, 0, 210);
//Etiquette Page
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
if ($count&1){
$pdf->SetXY(205, 292);}
else{$pdf->SetXY(0, 292);}
$pdf->Cell(5,5,''.$count.'',1,1,'C',true);
//DOSSIER SONERGIA page 2 du dossier primaire/
$pdf->AddPage();$count++;
$pdf->setSourceFile('../../../FICHIERS/'.$ID.'/Sonergia/sonergia'.$ID.'.pdf');
$tplIdx2 = $pdf->importPage(2);
$pdf->useTemplate($tplIdx2, 0, 0, 210);
//Etiquette Page
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
if ($count&1){
$pdf->SetXY(205, 292);}
else{$pdf->SetXY(0, 292);}
$pdf->Cell(5,5,''.$count.'',1,1,'C',true);
//DOSSIER SONERGIA
$pageCount = $pdf->setSourceFile('../../../FICHIERS/'.$ID.'/Sonergia/sonergia'.$ID.'.pdf');
for ($pageNo = $devis+3; $pageNo <= $pageCount; $pageNo++ ) {
$count++;
$tplIdx = $pdf->importPage($pageNo);
// add a page
$pdf->AddPage();
$pdf->useTemplate($tplIdx, 0, 0, 210);
//font and color selection
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
if ($count&1){
$pdf->SetXY(205, 292);}
else{$pdf->SetXY(0, 292);}
$pdf->Cell(5,5,''.$count.'',1,1,'C',true);
}
//saut de page dossier SOnergia
if ($count&1){$count++;
$pdf->AddPage();
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
if ($count&1){
$pdf->SetXY(205, 292);}
else{$pdf->SetXY(0, 292);}
$pdf->Cell(5,5,''.$count.'',1,1,'C',true);
}
//Validation SONERGIA
$pageCount = $pdf->setSourceFile('../../../FICHIERS/'.$ID.'/Sonergia/validationsonergia.'.$ID.'.pdf');
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++ ) {
$count++;
$tplIdx = $pdf->importPage($pageNo);
// add a page
$pdf->AddPage();
$pdf->useTemplate($tplIdx, 0, 0, 210);
//font and color selection
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
if ($count&1){
$pdf->SetXY(205, 292);}
else{$pdf->SetXY(0, 292);}
$pdf->Cell(5,5,''.$count.'',1,1,'C',true);
}
}
//BARTH
$pdf->AddPage();$count++;
$pdf->setSourceFile('../../../FICHIERS/'.$ID.'/documents/ah'.$ID.'.pdf');
$tplIdx2 = $pdf->importPage(1);
$pdf->useTemplate($tplIdx2, 0, 0, 210);
//Etiquette Page
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
if ($count&1){
$pdf->SetXY(205, 292);}
else{$pdf->SetXY(0, 292);}
$pdf->Cell(5,5,''.$count.'',1,1,'C',true);
//PV RECEPTION
$pdf->AddPage();$count++;
$pdf->setSourceFile('../../../FICHIERS/'.$ID.'/Signe/pvreception'.$ID.'.pdf');
$tplIdx2 = $pdf->importPage(1);
$pdf->useTemplate($tplIdx2, 0, 0, 210);
//Etiquette Page
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
if ($count&1){
$pdf->SetXY(205, 292);}
else{$pdf->SetXY(0, 292);}
$pdf->Cell(5,5,''.$count.'',1,1,'C',true);
//NOUVELLE REFERENCE QUALITENR
$pdf->AddPage();$count++;
$pdf->setSourceFile('../../../FICHIERS/'.$ID.'/Signe/qualitenrNR'.$ID.'.pdf');
$tplIdx2 = $pdf->importPage(1);
$pdf->useTemplate($tplIdx2, 0, 0, 210);
//Etiquette Page
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
if ($count&1){
$pdf->SetXY(205, 292);}
else{$pdf->SetXY(0, 292);}
$pdf->Cell(5,5,''.$count.'',1,1,'C',true);
$section2=$count+1;
//saut de page dossier technique
if ($count&1){$count++;
$pdf->AddPage();
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
if ($count&1){
$pdf->SetXY(205, 292);}
else{$pdf->SetXY(0, 292);}
$pdf->Cell(5,5,''.$count.'',1,1,'C',true);
}
//DOSSIER TECHNIQUE
$pageCount = $pdf->setSourceFile('../../../FICHIERS/'.$ID.'/Qualitenr/qualitenr'.$ID.'.pdf');
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++ ) {
$count++;
$tplIdx = $pdf->importPage($pageNo);
// add a page
$pdf->AddPage();
$pdf->useTemplate($tplIdx, 0, 0, 210);
//font and color selection
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
if ($count&1){
$pdf->SetXY(205, 292);}
else{$pdf->SetXY(0, 292);}
$pdf->Cell(5,5,''.$count.'',1,1,'C',true);
}
//CERFA QUALITENR
$fgaz = '../../../FICHIERS/'.$ID.'/signe/cerfa'.$ID.'.pdf';
if( file_exists ( $fgaz)){
$pdf->AddPage();$count++;
$pdf->setSourceFile('../../../FICHIERS/'.$ID.'/Signe/cerfa'.$ID.'.pdf');
$tplIdx2 = $pdf->importPage(1);
$pdf->useTemplate($tplIdx2, 0, 0, 210);
//Etiquette Page
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
if ($count&1){
$pdf->SetXY(205, 292);}
else{$pdf->SetXY(0, 292);}
$pdf->Cell(5,5,''.$count.'',1,1,'C',true);
}
//CONSUEL DEMANDE
$consuel = '../../../FICHIERS/'.$ID.'/signe/consuel'.$ID.'.pdf';
if( file_exists ( $consuel)){
$pdf->AddPage();$count++;
$pdf->setSourceFile('../../../FICHIERS/'.$ID.'/Signe/consuel'.$ID.'.pdf');
$tplIdx2 = $pdf->importPage(1);
$pdf->useTemplate($tplIdx2, 0, 0, 210);
//Etiquette Page
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
if ($count&1){
$pdf->SetXY(205, 292);}
else{$pdf->SetXY(0, 292);}
$pdf->Cell(5,5,''.$count.'',1,1,'C',true);
}
$section3=$count+1;
//CONTRAT ENTRETIEN
$ce = '../../../FICHIERS/'.$ID.'/signe/contrat'.$ID.'.pdf';
if( file_exists ( $ce)){
$pageCount = $pdf->setSourceFile('../../../FICHIERS/'.$ID.'/signe/contrat'.$ID.'.pdf');
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++ ) {
$count++;
$tplIdx = $pdf->importPage($pageNo);
// add a page
$pdf->AddPage();
$pdf->useTemplate($tplIdx, 0, 0, 210);
//font and color selection
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
if ($count&1){
$pdf->SetXY(205, 292);}
else{$pdf->SetXY(0, 292);}
$pdf->Cell(5,5,''.$count.'',1,1,'C',true);
}
}
$section4=$count+1;
//NOTICE UTILISATEUR
//selectionner la notice en fonction du modele de la pac dans le dossier Notice.
//saut de page inversé
if ($count&1){}else{$pdf->AddPage();
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);}
//DERNIERE PAGE
$pdf->AddPage();
$pdf->setSourceFile('../../../INTRANET/GENPDF/8DIU/Required/base/DossierDIU_4Couv.pdf');
$tplIdx2 = $pdf->importPage(1);
$pdf->useTemplate($tplIdx2, 0, 0, 210);
//Etiquette Page
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
$pdf->Output('F', '../../../FICHIERS/'.$ID.'/DIU/T2'.$ID.'.pdf');
//Couv / p1 et sommaire
$pdf= new FPDI();
$count = 0;
$pdf->SetAutoPagebreak(False);
//COUVERTURE
$pdf->AddPage();
$pdf->setSourceFile('../../../INTRANET/GENPDF/8DIU/Required/base/DossierDIU_Couv.pdf');
$tplIdx2 = $pdf->importPage(1);
$pdf->useTemplate($tplIdx2, 0, 0, 210);
// Coordonnées maitre ouvrage
$pdf->SetFont('Helvetica','','30');
$pdf->SetXY(180, 10.8);
$pdf->Cell(0,8,''.$R->ID.'',0,1,'L',false);
$pdf->SetFont('Helvetica','','12');
$pdf->SetXY(46, 258.6);
$pdf->Cell(0,8,''.$R->nom.'',0,1,'L',false);
$pdf->SetXY(100, 258.6);
$pdf->Cell(0,8,''.$R->prenom.'',0,1,'L',false);
$pdf->SetXY(52, 267.2);
$pdf->Cell(0,8,''.$R->rueC.'',0,1,'L',false);
$pdf->SetXY(58, 276.2);
$pdf->Cell(0,8,''.$R->CodePC.'',0,1,'L',false);
$pdf->SetXY(95, 276.2);
$pdf->Cell(0,8,''.$R->VilleC.'',0,1,'L',false);
//P2
$pdf->AddPage();
if($R->typeprojet =="PAC_AE_M"||$R->typeprojet =="PAC_AE_S"||$R->typeprojet =="PAC_AE_H"){$type = "DossierDIU_P1-PACAE";}
elseif($R->typeprojet =="PAC TH"){$type = "DossierDIU_P1-PACTH";}
elseif($R->typeprojet =="PAC AA"){$type = "DossierDIU_P1-PACAA";}
elseif($R->typeprojet =="SOL PV"){$type = "DossierDIU_P1-PV";}
elseif($R->typeprojet =="BOIS P"){$type = "DossierDIU_P1-POEL";}
elseif($R->typeprojet =="BOIS C"){$type = "DossierDIU_P1-BOISCH";}
$pdf->setSourceFile('../../../INTRANET/GENPDF/8DIU/Required/typeprojet/'.$type.'.pdf');
$tplIdx2 = $pdf->importPage(1);
$pdf->useTemplate($tplIdx2, 0, 0, 210);
$pdf->Image('required/IMG/'.$R->typeprojet.'.png',50,5,130);
//P2
$pdf->AddPage();
$pdf->setSourceFile('../../../INTRANET/GENPDF/8DIU/Required/base/DossierDIU_P2.pdf');
$tplIdx2 = $pdf->importPage(1);
$pdf->useTemplate($tplIdx2, 0, 0, 210);
$pdf->SetFont('Helvetica','','20');
$pdf->SetXY(160, 165);
$pdf->Cell(0,8,'Page 1',0,1,'L',false);
$pdf->SetXY(160, 185);
$pdf->Cell(0,8,'Page '.$section2.'',0,1,'L',false);
$pdf->SetXY(160, 205);
$pdf->Cell(0,8,'Page '.$section3.'',0,1,'L',false);
$pdf->SetXY(160, 225);
$pdf->Cell(0,8,'Page '.$section4.'',0,1,'L',false);
//Enregistrement partie 2
$pdf->Output('F', '../../../FICHIERS/'.$ID.'/DIU/T1'.$ID.'.pdf');
$pdf= new FPDI();
$pdf->SetAutoPagebreak(False);
$pageCount = $pdf->setSourceFile('../../../FICHIERS/'.$ID.'/DIU/T1'.$ID.'.pdf');
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++ ) {
$tplIdx = $pdf->importPage($pageNo);// add a page
$pdf->AddPage();
$pdf->useTemplate($tplIdx, 0, 0, 210);
//font and color selection
$pdf->SetFont('Helvetica','','10');
}
$pdf->AddPage();
$pdf->SetFont('Helvetica','','10');
$pdf->SetFillColor(255, 255, 255);
$pageCount = $pdf->setSourceFile('../../../FICHIERS/'.$ID.'/DIU/T2'.$ID.'.pdf');
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++ ) {
$tplIdx = $pdf->importPage($pageNo);// add a page
$pdf->AddPage();
$pdf->useTemplate($tplIdx, 0, 0, 210);
//font and color selection
$pdf->SetFont('Helvetica','','10');
}
//Enregistrement partie 2
$pdf->Output('F', '../../../FICHIERS/'.$ID.'/DIU/DIU'.$ID.'.pdf');
//UPDATE EN FIN DE CHANTIER ETAT EN ARCHIVE (Generation du DIU seulement lors du paiement de la facture finale Hors Sonergia et solde null)
$Update = $dbco->prepare('UPDATE dossier SET Etat = :Etat WHERE ID = :ID');
$Update->bindvalue('Etat','Archive');
$Update->bindvalue('ID', $ID);
$Update->execute();
header("location:../../../../index.php/agc");
?>