1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
<?php
require('phpToPDF.php');
require('MysqlTable.php');
class PDF extends PDF_MySQL_Table
{
function Header()
{
//Titre
$this->SetFont('Arial','',18);
$this->Cell(0,6,'Information DA',0,1,'C');
$this->Ln(10);
//Imprime l'en-tête du tableau si nécessaire
parent::Header();
}
}
//Connexion à la base
mysql_connect("%%%%", "%%%%","%%%%");
mysql_select_db("%%%%");
$req1 = mysql_query("SELECT distinct cost_center FROM `data_txt` where cost_center like 'F1S%' limit 400");
$nb_result = mysql_num_rows($req1);
echo $nb_result;
$compteur = 0;
while ($section = mysql_fetch_array($req1))
{
set_time_limit();
$compteur++;
echo "$compteur</br>";
echo $section['cost_center']."</br>";
$pdf=new PDF();
//création d'une nouvel page
$pdf->AddPage();
$pdf->Text(80,20,"Section ".$section['cost_center']."");
//Insertion de l'image selon le type de pdf voulu
$pdf->Image("http://university.fr/reporting/outilSuiviDA/imgdata_graph.php?section=".$section['cost_center']."&request=$request",10,30,200,100,"PNG");
// Positionnement du curseur pour insérer le tableau
$pdf->SetX(10);
$pdf->SetY(150);
//Requete permettant de sortir les tableaux avec les résultat
$sqlrequest ="SELECT RIGHT(LEFT(`start_date`,7),2) AS Mois,
ROUND(SUM(item_total_cost),2) AS 'TOTAL Facturé + Engagé',
ROUND(SUM(case when course_number_1 LIKE 'EC%'
AND course_number_2 NOT LIKE 'DIF%'
then item_total_cost else 0 end),2) AS 'ECM',
ROUND(SUM(case when course_number_2 LIKE 'DIF%'
then item_total_cost else 0 end),2) as 'TOTAL DIF'
FROM data_txt WHERE company='FR-CIT FRANCE'
AND (order_status='Confirmed' OR order_status='Delivered') AND cost_center ='".$section['cost_center']."'
GROUP BY RIGHT(LEFT(`start_date`,7),2)";
$sqlrequestTotal="SELECT '2011' as 'Année',ROUND(SUM(item_total_cost),2) AS 'TOTAL Facturé + Engagé (EUROS)',
ROUND(SUM(case when course_number_1 LIKE 'EC%'
AND course_number_2 NOT LIKE 'DIF%'
then item_total_cost else 0 end),2) AS 'ECM (EUROS)',
ROUND(SUM(case when course_number_2 LIKE 'DIF%'
then item_total_cost else 0 end),2) as 'TOTAL DIF (EUROS)'
FROM data_txt WHERE company='FR-CIT FRANCE'
AND (order_status='Confirmed' OR order_status='Delivered') AND cost_center ='".$section['cost_center']."' ;";
//Création des tableaux depuis les requêtes SQL
$pdf->Table($sqlrequest);
$pdf->Table($sqlrequestTotal);
//Impression du document pdf dans la page
$pdf->Output("./document/".$section['cost_center'],"F");
}
?> |
Partager