| Current Path : /home/ataenra/www/ATA/INTRANET/GenPDF/4DossierClient/ |
| Current File : /home/ataenra/www/ATA/INTRANET/GenPDF/4DossierClient/pdfcommande.php |
<?php
if(!empty($_GET['ID'])){
$ID=$_GET['ID'];
require "../Outils/co.php";
//Recup des infos dossier
$sth = $dbco->prepare("SELECT typeprojet FROM dossier WHERE ID = '".$ID."'");
$sth->execute();
$I = $sth->fetch(PDO::FETCH_OBJ);
//Recup des tables par le routeur
$sth = $dbco->prepare("SELECT * FROM gest_routeur WHERE routeur_Famille = '".$I->typeprojet."'");
$sth->execute();
$I = $sth->fetch(PDO::FETCH_OBJ);
$table_gamme = $I->table_gamme;
$table_jointure = $I->table_jointure;
$table_jointure_access = $I->table_jointure_access;
$table_ensemble = $I->table_ensemble;
$table_produits = $I->table_produits;
$table_projet = $I->table_projet;
}
use setasign\Fpdi\Fpdi;
require_once "../Outils/fpdf/fpdf.php";
require_once "../Outils/FPDI-2.3.7/src/autoload.php";
//Recuperer information dossier + client
$sth1 = $dbco->prepare("SELECT * FROM dossier D JOIN client C ON D.IDclient = C.IDc WHERE D.ID = '$ID'");
$sth1->execute();
$R1 = $sth1->fetch(PDO::FETCH_OBJ); //R1 sotck les infos client et dossier
//Recuperer la liste materiel de la commande fournisseur
$sth2 = $dbco->prepare("SELECT DISTINCT CD.DC_ID_produit AS produit, CD.DC_ID_article AS article, CD.DC_quantite AS QT
FROM gest_commande C
JOIN gest_detail_commande CD ON C.ID_com=CD.DC_ID_com
WHERE C.com_IDprojet='".$ID."' AND CD.DC_ID_frs='".$Fournisseur."'");
$sth2->execute();
//Creation des dossiers
$projet ="../../FICHIERS/".$ID."/Chantier";
$chemin ="../../FICHIERS/".$ID."/Chantier";
// Vérifie si le répertoire existe :
if(!is_dir($projet)) {mkdir($projet, 0777,true);}
// Création du nouveau répertoire
if(!is_dir($chemin)) {mkdir($chemin, 0777,true);}
$pdf= new FPDI();
//Create new pdf file
$pdf->setSourceFile('../GenPDF/4DossierClient/Required/FeuilleCommande.pdf');
$pdf->AddPage();
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, 0, 0, 210);
//Disable automatic page break
$pdf->SetAutoPageBreak(false);
//set initial y axis position per page
$y_axis_initial = 130;
//Set Row Height
$row_height = 6;
$y_axis = 124;
$y_axis = $y_axis + $row_height;
//initialize counter
$i = 0;
//Set maximum rows per page
$max = 25;
$pdf->SetFont('Helvetica','','10');
$pdf->SetXY(20, 65);
$pdf->Cell(0,5,'Bonjour Mr '.$IFRS->frs_contact.',',0,1,'L',false);
$pdf->SetXY(20, 70);
$pdf->Cell(0,5,'Je me permets de vous transferer le bon de commande suivant.',0,1,'L',false);
$pdf->SetFont('Helvetica','B','10');
$pdf->SetXY(20, 78);
$pdf->Cell(0,10,'REFERENCE PROJET Numero : '.$ID.' COMMANDE Numero : '.$lastcom.'',0,1,'L',false);
$pdf->SetXY(20, 86);
$pdf->SetFont('Helvetica','','10');
$pdf->Cell(0,6,'Client Final : '.$R1->nom.' '.$R1->prenom.'',0,1,'L',false);
$pdf->SetXY(20, 92);
$pdf->Cell(0,6,'Adresse Installation : '.$R1->rue.' '.$R1->CodeP.' '.$R1->Ville.'',0,1,'L',false);
$pdf->SetXY(20, 104);
$pdf->Cell(0,6,"Merci de livrer le materiel ci-dessous dans les meilleurs delais au siege de l'entreprise.",0,1,'L',false);
//print column titles
$pdf->SetFillColor(232,232,232);
$pdf->SetFont('Helvetica','B',10);
$pdf->SetY(115);
$pdf->SetX(20);
$pdf->Cell(30,6,'REFERENCE',1,0,'L',1);
$pdf->Cell(120,6,'DESIGNATION',1,0,'L',1);
$pdf->Cell(20,6,'QUANTITE',1,0,'L',1);
$y_axis = $y_axis + $row_height;
$pdf->SetFont('Helvetica','',10);
$pdf->SetY(121);
$pdf->SetX(20);
$y_axis = 127;
while($R2 = $sth2->fetch(PDO::FETCH_OBJ))
{if($R2->produit!=0){
$sth3 = $dbco->prepare("SELECT DISTINCT Ref, modele FROM ".$table_produits." P
JOIN ".$table_jointure." J ON P.ID_Produit=J.ID_produit
JOIN ".$table_ensemble." E ON E.ID_Ens=J.ID_ens
JOIN ".$table_gamme." G ON G.ID_gamme=E.ID_gamme
WHERE P.ID_Produit='".$R2->produit."'");
$sth3->execute();
$R3 = $sth3->fetch(PDO::FETCH_OBJ);
$code = $R3->Ref;
$modele = $R3->modele;
$qtp = $R2->QT;
$pdf->SetY($y_axis);
$pdf->SetX(20);
$pdf->Cell(30,6,$code,1,0,'L',0);
$pdf->Cell(120,6,$modele,1,0,'L',0);
$pdf->Cell(20,6,$qtp,1,0,'L',0);
//Go to next row
$y_axis = $y_axis + $row_height;
$i = $i + 1;
}
if($R2->article!=0){
$sth3 = $dbco->prepare("SELECT DISTINCT REFfrs, DESIGNATION FROM gest_articles
WHERE ID_Article='".$R2->article."'");
$sth3->execute();
$R3 = $sth3->fetch(PDO::FETCH_OBJ);
$code = $R3->REFfrs;
$modele = $R3->DESIGNATION;
$qta = $R2->QT;
$pdf->SetY($y_axis);
$pdf->SetX(20);
$pdf->Cell(30,6,$code,1,0,'L',0);
$pdf->Cell(120,6,$modele,1,0,'L',0);
$pdf->Cell(20,6,$qta,1,0,'L',0);
//Go to next row
$y_axis = $y_axis + $row_height;
$i = $i + 1;
}
}
$pdf->SetFont('Helvetica','','10');
$pdf->SetXY(0, 230);
$pdf->Cell(140,5,'Cordialement',0,1,'R',false);
$pdf->SetXY(0, 236);
$pdf->Cell(140,5,'Givry Anthony',0,1,'R',false);
$pdf->SetFont('Helvetica','','8');
$pdf->SetXY(0, 275);
$pdf->Cell(0,3,'SAS ATA ENRgies au Capital de 3000 euros - 4 Rue Leruste 59150 Wattrelos',0,1,'C',false);
//$pdf->SetXY(0, 273);
$pdf->Cell(0,3,'SIRET : XXX XXX XXX XXXXX - TVA Intra : FRXX XXXXXXXXX - RCS de LILLE B XXX XXX XXX',0,1,'C',false);
//$pdf->SetXY(0, 276);
$pdf->Cell(0,3,'Tel. : +33(0)3.20.80.80.60 - Email : contact@ata-enr.fr - www.ataenrgies.fr',0,1,'C',false);
//Send file
//$pdf->Output('I', 'commande'.$ID.'.pdf');
$pdf->Output('F', '../../FICHIERS/'.$ID.'/Chantier/Commande'.$lastcom.'.pdf');
//require "../GenPDF/4DossierClient/mailcommande.php";
//header("location:../../../index.php/agcom");
?>