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 169 170
| <?php
session_start();
if (!isset($_SESSION['email'])) {
header ('Location: index.php');
exit();
}
$session_email = mysql_escape_string($_SESSION['email']);
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<title>Gestion des feuilles de route</title>
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<a href="membre.php" data-icon="home">Retour</a>
<h1>Gestion des feuilles de route de EXAPAQ</h1>
<a href="ajout_exa.php" data-icon="plus">Ajouter une tournée</a>
</div><!-- /Entete de la page -->
<div data-role="content">
<form action="exa_admin.php" method="post" data-ajax="false">
<fieldset class="ui-grid-b">
<div class="ui-block-a">
<label for="select-choice-1" class="select"></label>
<select name="mois" id="select-choice-1">
<?php
$base = mysql_connect ('sql.free.fr', '******', '******');
mysql_select_db ('******', $base);
$reponse = mysql_query('SELECT DISTINCT MONTH(Date_liv) AS mois FROM `tournee_exa` ORDER BY mois');
while($donnees = mysql_fetch_array($reponse))
{
?>
<option VALUE="<?php echo $donnees['mois'];?>"><?php echo $donnees['mois'];?></option>
<?php
}
?>
</select>
</div>
<div class="ui-block-b">
<label for="select-choice-1" class="select"></label>
<select name="annee" id="select-choice-1">
<?php
$base = mysql_connect ('sql.free.fr', '******', '******');
mysql_select_db ('******', $base);
$reponse = mysql_query('SELECT DISTINCT YEAR(Date_liv) AS annee FROM `tournee_exa` ORDER BY annee');
while($donnees = mysql_fetch_array($reponse))
{
?>
<option VALUE="<?php echo $donnees['annee'];?>"><?php echo $donnees['annee'];?></option>
<?php
}
?>
</select>
</div>
<div class="ui-block-c">
<label for="afficher"></label><input type="submit" name="afficher" id="afficher" value="Afficher" data-theme="b" />
</div>
</fieldset>
</form>
<?php
if (isset($_POST['afficher']) && $_POST['afficher'] == 'Afficher') {
$base = mysql_connect ('sql.free.fr', '******', '******');
mysql_select_db ('******', $base);
$result2 = mysql_query('SELECT DISTINCT Numero FROM tournee_exa ORDER BY Numero');
while($row= mysql_fetch_array($result2)) {
$tblNumero[] = $row['Numero'];
}
/*ICI*/
$result = mysql_query('SELECT Numero, Nb_pt_liv, Pickup, Date_liv FROM tournee_exa WHERE MONTH(Date_liv) = "'.mysql_escape_string($_POST['mois']).'" AND YEAR(Date_liv) = "'.mysql_escape_string($_POST['annee']).'" ORDER BY Date_liv');
while ($row = mysql_fetch_assoc($result)) {
$data[$row['Date_liv']][$row['Numero']] = array('points'=>$row['Nb_pt_liv'], 'pickup'=>$row['Pickup']);
}
echo '<table id="gradient-style" summary="Meeting Results"><tr><th scope="col">Points - Ramasses</th>';
foreach ($tblNumero as $numero) {
echo '<th scope="col">' . $numero . '</th>';
$i = $i+1;
}
echo '</tr>';
foreach($data as $date=>$data_numeros) {
echo '<tr><th scope="col">'. $date . '</th>';
foreach ($tblNumero as $numero) {
if (isset($data_numeros[$numero])) {
$points = $data_numeros[$numero]['points'];
$pickup = $data_numeros[$numero]['pickup'];
}
else {
$points = '';
$pickup = '';
}
echo '<td>' . $points . ' - ' . $pickup . '</td>';
}
echo '</tr>';
}
echo '<tr><th scope="col">Total</th>';
$result2 = mysql_query('SELECT DISTINCT Numero FROM tournee_exa ORDER BY Numero');
while($row= mysql_fetch_array($result2)) {
$num = $row['Numero'];
$mois = mysql_escape_string($_POST['mois']);
$annee = mysql_escape_string($_POST['annee']);
$nb_pt="SELECT SUM(Nb_pt_liv) AS nb_pt, SUM(Pickup) AS pick FROM tournee_exa WHERE Numero ='$num' AND MONTH(Date_liv) = '$mois' AND YEAR(Date_liv) = '$annee' ORDER BY Numero";
$req_nb_pt=mysql_query($nb_pt);
$tab_nb_pt=mysql_fetch_array($req_nb_pt) ;
echo '<th scope="col">'.$tab_nb_pt["nb_pt"].' - '.$tab_nb_pt["pick"].'</th>';
}
echo '</tr></table>';
} else {
$base = mysql_connect ('sql.free.fr', '******', '******');
mysql_select_db ('******', $base);;
$result2 = mysql_query('SELECT DISTINCT Numero FROM tournee_exa ORDER BY Numero');
while($row= mysql_fetch_array($result2)) {
$tblNumero[] = $row['Numero'];
}
/*ICI*/
$result = mysql_query('SELECT Numero, Nb_pt_liv, Pickup, Date_liv FROM tournee_exa WHERE MONTH(Date_liv) = MONTH(Now()) AND YEAR(Date_liv) = YEAR(Now()) ORDER BY Date_liv');
while ($row = mysql_fetch_assoc($result)) {
$data[$row['Date_liv']][$row['Numero']] = array('points'=>$row['Nb_pt_liv'], 'pickup'=>$row['Pickup']);
}
echo '<table id="gradient-style" summary="Meeting Results"><tr><th scope="col">Points - Ramasses</th>';
foreach ($tblNumero as $numero) {
echo '<th scope="col">' . $numero . '</th>';
$i = $i+1;
}
echo '</tr>';
foreach($data as $date=>$data_numeros) {
echo '<tr><th scope="col">'. $date . '</th>';
foreach ($tblNumero as $numero) {
if (isset($data_numeros[$numero])) {
$points = $data_numeros[$numero]['points'];
$pickup = $data_numeros[$numero]['pickup'];
}
else {
$points = '';
$pickup = '';
}
echo '<td>' . $points . ' - ' . $pickup . '</td>';
}
echo '</tr>';
}
echo '<tr><th scope="col">Total</th>';
$result2 = mysql_query('SELECT DISTINCT Numero FROM tournee_exa ORDER BY Numero');
while($row= mysql_fetch_array($result2)) {
$num = $row['Numero'];
$nb_pt="SELECT SUM(Nb_pt_liv) AS nb_pt, SUM(Pickup) AS pick FROM tournee_exa WHERE Numero ='$num' AND MONTH(Date_liv) = MONTH(Now()) AND YEAR(Date_liv) = YEAR(Now()) ORDER BY Numero";
$req_nb_pt=mysql_query($nb_pt);
$tab_nb_pt=mysql_fetch_array($req_nb_pt) ;
echo '<th scope="col">'.$tab_nb_pt["nb_pt"].' - '.$tab_nb_pt["pick"].'</th>';
}
echo '</tr></table>';
}
?>
</div>
<div data-role="footer">
<div class="ui-grid-b">
<div class="ui-block-a"></div>
<div class="ui-block-b"><a href="exa.php" data-role="button" data-type="horizontal">Mes tournées</a><h4 style="text-align:center">© Aldana - Antony 2013</h4></div>
<div class="ui-block-c"></div>
</div><!-- /grid-b -->
</div><!-- /Pied de page -->
</div>
</body>
</html> |
Partager