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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
<?php
//echo phpinfo();
//$ns= NULL;
if(isset($_GET['nom'])){
$ns =$_GET['nom'];
$sql_camembert =
'SELECT
Release_gsm AS "Release"
, Sub_release_gsm AS "Sub_Release"
, SUM(' . $ns . ') AS "Qty"
, FORMAT(100*SUM(' . $ns . ')/(SELECT SUM(' . $ns . ') FROM customer), 1) AS "Pourcentage"
, COUNT(*) AS "Total"
-- , SUM( )
FROM
customer
WHERE
network_status = "active" -- réseau actif
AND NOT Release_gsm = "/"
GROUP BY
Release_gsm
, Sub_release_gsm
-- WITH ROLLUP'
;
/*$sql_tableau =
'SELECT
Release_gsm AS "Release"
, Sub_release_gsm AS "Sub_Release"
, COUNT(*) AS "Total"
-- , FORMAT(100*SUM(' . $ns . ')/(SELECT SUM(' . $ns . ') FROM customer), 1) AS "Pourcentage"
FROM
customer
WHERE
network_status = "active" -- réseau actif
AND NOT Release_gsm = "/"
GROUP BY
Release_gsm
, Sub_Release_gsm
-- WITH ROLLUP'
;*/
//unset($ns);
}
// Connexion au serveur de base de données
$link = mysql_connect("127.0.0.1","root","npidb");
if (!$link)
{
die('Connexion impossible : ' . mysql_error());
}
//echo 'Connecté correctement';
// Sélection de la base de données
$db_selected = mysql_select_db('npidb',$link);
if (!$db_selected)
{
die ('Impossible de sélectionner la base de données : ' . mysql_error());
}
ob_start();
$data=array();
$data_legend=array();
$result = mysql_query($sql_camembert) or die('Erreur SQL : <br />' . $sql_camembert . '<br />' . mysql_error());
// On affiche le contenu si la table n'est pas vide
if (mysql_num_rows($result) > 0)
{
//echo "<hr>Début de test<br>";
while ($donnees = mysql_fetch_assoc($result))
{
if ($donnees['Pourcentage']>='0.01')
{
$data[] = (float)$donnees['Pourcentage'];
$data_legend[] = $donnees['Release'].(" ").(string)$donnees['Sub_Release'];
//echo "Valeur : ".$donnees['Pourcentage']." légende : ".$donnees['Sub_Release']."<br>";
//echo $ns;
}
//echo "<hr>Milieu de test<br>";
$indice=0;
//echo "données<br>";
foreach($data as $val)
{
//echo "$indice : ".$val."<br>";
$indice+=1;
}
$indice=0;
//echo "Légendes<br>";
foreach($data_legend as $val)
{
//echo "$indice : ".$val."<br>";
$indice+=1;
}
//echo "<br>Fin de test<hr>";
}
}
//echo "<hr>Fin de test<br>";
//var_dump($data);
//var_dump($data_legend);
//echo "<hr>";
echo"<page backtop=5% backbottom=5% backleft=5% backright=5%>";
$data_serialized=base64_encode(serialize($data));
$data_legend_serialized=base64_encode(serialize($data_legend));
echo"<img src='./graph1.php?data_serialized=$data_serialized&data_legend_serialized=$data_legend_serialized'>";
unset($data);
unset($data_legend);
?>
<html>
<head>
<title>latest TPM updates</title>
</head>
<body>
<?php
$result = mysql_query($sql_camembert) or die('Erreur SQL !<br />'.$sql_camembert.'<br />'.mysql_error());
?>
<div style="float:right; top; width:400px; margin-top:-370px;">
<b style="font-size:14px;">YOUR SELECTION :</b><input type="text" value="<?php echo $ns ?>" style="font-size:14px;" />
<TABLE border="4" cellspacing="2" cellpadding="2" width="30%">
<tr>
<th>Release Per Network</th>
<th>Sub_Release</th>
<th>Total</th>
<th> </th>
<th> </th>
<th>Distribution Per Release</th>
<th>Sub_Release</th>
<th>Qty</th>
</tr>
<?php
while ($donnees = mysql_fetch_assoc($result)) {
//if ($donnees['Pourcentage']>='0.01')
//{
?>
<tr><td><I><B>
<?php echo $donnees['Release']; ?>
</B></I></td><td><I>
<?php echo $donnees['Sub_Release']; ?>
</I></td><td><I>
<?php echo $donnees['Total']; ?>
</I></td><td>
</td><td>
</td><td><I><B>
<?php echo $donnees['Release']; ?>
</B></I></td><td><I>
<?php echo $donnees['Sub_Release'];?>
</I></td><td><I>
<?php echo $donnees['Qty']; ?>
</I></td>
<?php
echo"</page>";
$content = ob_get_clean();
require ('html2pdf/html2pdf.class.php');
$pdf= new HTML2PDF('P','A4','fr','true');
$pdf-> WriteHTML($content);
$pdf-> Output('Exemple.pdf');
?>
<?php
//}
}
//echo $ns;
mysql_free_result ($result);
mysql_close ();
?> |
Partager