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 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
<?php
session_start ();
echo "Utilisateur : ";
echo $_SESSION['pseudo'];
if (($_SESSION['level']==1) AND ($_SESSION['level']==2))
header('location:../index.php');
echo " <a href ='../index.php'> Retour index </a>";
echo'<br>';
?>
<body font-size='xx-small'>
<a href ='../index.php'> Retour index </a>
<h2><center><b><u> Ventilation des montants par année d'origine</u></b></center></h2><br>
<?php
include('../inc/inc_connexion.php');
include('../inc/fonction.php');
$result = mysql_query("SELECT nom_region FROM region group by nom_region")or die(mysql_error());
echo '<form action="detail_region.php" method="post">';
echo 'Choissisez votre région dans la liste : ';
echo '<select name="frm_select_region">';
while ($row = mysql_fetch_array($result))
{
//si c'est le nom de la région qui est commun aux deux tables c'est le champ nom_region que tu dois mettre en value de ton select//
echo '<option value="'.$row['nom_region'].'">'.$row['nom_region'].'</option>';
}
echo '</select>';
echo '<input type="submit" value="Go" />';
echo '</form>';
$var = "";
$ligne = "<table BORDER=1 BORDERCOLOR=#CCCCCC BGCOLOR=#fffccc CELLSPACING=0 CELLPADDING=1 WIDTH=98% ALIGN=center font-family='Verdana' font-size='xx-small' >
<td bgcolor='#669999'><b><u>Numero</u></b></td>
<td bgcolor='#669999'><b><u>Societe</u></b></td>
<td bgcolor='#669999'><b><u>Adhérent</u></b></td>
<td bgcolor='#669999' WIDTH=15px><b><u>Montant</u></b></td>
<td bgcolor='#669999' WIDTH=15px><b><u>Anterieur à 2008</u></b></td>
<td bgcolor='#669999' WIDTH=15px><b><u>2008</u></b></td>
<td bgcolor='#669999' WIDTH=15px><b><u>2009</u></b></td>
<td bgcolor='#669999' WIDTH=15px><b><u>2010</u></b></td>
<td bgcolor='#669999' WIDTH=15px><b><u>2011</u></b></td>
<td bgcolor='#669999' WIDTH=15px><b><u>-1 mois</u></b></td>
<td bgcolor='#669999' WIDTH=15px><b><u>Vérif</u></b></td>";
$total = 0;
//ici initialisation des variables total pour chaque année//
$Tant08 = 0;
$Ta08 = 0;
$Ta09 = 0;
$Ta10 = 0;
$Ta11 = 0;
$Ta_1 = 0; //c'est pour les facture datant d'un - d'un mois ($Ta_1)//
$Tmont_3 = 0; // sert à la totalisation de la colonne des totaux
if(isset($_POST["frm_select_region"]) AND $_POST["frm_select_region"] != NULL)
{
$var = $_POST["frm_select_region"];
echo "Détail des dus pour la région : "; echo $var;
}
$rqt = mysql_query("SELECT fact_id, soc_ville, soc_telephone, soc_fax, soc_siret, soc_enseigne,soc_code, soc_region, soc_societe, fact_montant, soc_adherent, fact_annee FROM societe, facture WHERE soc_region = '$var' and fact_id = soc_id GROUP BY soc_id") or die(mysql_error());
if(mysql_num_rows($rqt) > 0)
{
while($tableau = mysql_fetch_array($rqt))
{
$id = $tableau['fact_id'];
$societe = $tableau['soc_societe'];
$adherent = $tableau['soc_adherent'];
$ville = $tableau['soc_ville'];
$region = $tableau['soc_region'];
$enseigne = $tableau['soc_enseigne'];
$telephone = $tableau['soc_telephone'];
$fax = $tableau['soc_fax'];
$siret = $tableau['soc_siret'];
$ant08 = 0; //ici l'initialisation des variables par année//
$a08 = 0;
$a09 = 0;
$a10 = 0;
$a11 = 0;
$a_1 = 0;
$Tmont_2 = 0; // sert a la totalisation des lignes
$fact_annee= "";
$mont = 0;
//calcul par année//
if($tableau['fact_annee'] == '20081')
{
$ant08 += $tableau['fact_montant'];
}
if($tableau['fact_annee'] == '20080')
{
$a08 += $tableau['fact_montant'];
}
if($tableau['fact_annee'] == '20090')
{
$a09 += $tableau['fact_montant'];
}
if($tableau['fact_annee'] == '20100')
{
$a10 += $tableau['fact_montant'];
}
if($tableau['fact_annee'] == '20110')
{
$a11 += $tableau['fact_montant'];
}
if($tableau['fact_annee'] == '20101')
{
$a_1 += $tableau['fact_montant'];
}
//fin du calcul par année//
$mont += $tableau['fact_montant'];
//***********************************************************************************************************************
// Calcul des totaux des colonnes en fonction de la region et de l'année
if(($tableau['soc_region'] == $var) or ($tableau['soc_region'] =!NULL))
{
$Tant08 += $ant08;
}
if(($tableau['soc_region'] == $var) or ($tableau['soc_region'] =!NULL))
{
$Ta08 += $a08;
}
if(($tableau['soc_region'] == $var) or ($tableau['soc_region'] =!NULL))
{
$Ta09 += $a09;
}
if(($tableau['soc_region'] == $var) or ($tableau['soc_region'] =!NULL))
{
$Ta10 += $a10;
}
if(($tableau['soc_region'] == $var) or ($tableau['soc_region'] =!NULL))
{
$Ta11 += $a11;
}
if(($tableau['soc_region'] == $var) or ($tableau['soc_region'] =!NULL))
{
$Ta_1 += $a_1;
}
// fin du calcul des totaux par colonne
//**************************************************************************************
// création du total par ligne " vérification avec le montant "
$Tmont_2 = ($ant08 + $a08 + $a09 + $a10 + $a11 + $a_1);
//*************************************************************************************
$Tmont_3 += $Tmont_2;
//*****************************************************************************************
// Calcul du total final par région
$total += $mont;
//**********************************************************************************************************************
if($mont > 0)
{
$ligne .= "<tr>
<td>".$id."</td>
<td> <font size ='2.5'>".$societe."<font></td>
<td> <font size ='2.5'>".$adherent."<font></td>
<td align='right' bgcolor='#669999'><font size ='2.5'>".$mont."<font></td>
<td align='right'><font size ='2.5'>".$ant08."<font></td>
<td align='right'><font size ='2.5'>".$a08."<font></td>
<td align='right'><font size ='2.5'>".$a09."<font></td>
<td align='right'><font size ='2.5'>".$a10."<font></td>
<td align='right'><font size ='2.5'>".$a11."<font></td>
<td align='right'><font size ='2.5'>".$a_1."<font></td>
<td align='right' bgcolor='#669999'><font size ='2.5'>".$Tmont_2."<font></td></tr>"; // total de la ligne //
}
}
$ligne .= "<tr><td colspan='3' bgcolor='#669999'><font size ='2.5'>Total Final<font></td><td align='right' bgcolor='#669999'><font size ='2.5'>".$total."<font></td>";
$ligne .= "<td colspan='1' align='right' bgcolor='#669999'><font size ='2.5'>".$Tant08."<font></td>";
$ligne .= "<td colspan='1' align='right' bgcolor='#669999'><font size ='2.5'>".$Ta08."<font></td>";
$ligne .= "<td colspan='1' align='right' bgcolor='#669999'><font size ='2.5'>".$Ta09."<font></td>";
$ligne .= "<td colspan='1' align='right' bgcolor='#669999'><font size ='2.5'>".$Ta10."<font></td>";
$ligne .= "<td colspan='1' align='right' bgcolor='#669999'><font size ='2.5'>".$Ta11."<font></td>";
$ligne .= "<td colspan='1' align='right' bgcolor='#669999'><font size ='2.5'>".$Ta_1."<font></td>"; // concerne les factures de moins d'un mois //
$ligne .= "<td colspan='1' align='right' bgcolor='#669999'><font size ='2.5'>".$Tmont_3."<font></td></tr>"; // total des differents totaux //
$ligne .= "</table>";
}
echo $ligne;
?> |
Partager