Notes
Notes - notes.io |
header("Content-type: application/vnd.ms-excel");
include('../admin/connect.php');
$q = "SELECT * FROM maj WHERE type='VISION_STOCK'";
$res = mysql_query($q) or die(mysql_error());
if (($row = mysql_num_rows($res)) != 0)
{
$row = mysql_fetch_array($res);
$month = $row['mois'];
$year = $row['annee'];
}
else
{
$month = 0;
$year = 0;
}
$file = "vision_des_stocks_" . $month . "_" . $year . ".xls";
header("Content-Disposition: attachment; filename=$file");
include('connect.php');
////////////////////////////// PARTIE VUE PAR ETAT /////////////////////////////
echo '<table>
<tr bgcolor=red><td colspan="13"></td></tr>
<tr bgcolor=red><td colspan="13" align=center style="color:white;">VUE PAR ETAT</td></tr>
<tr bgcolor=red><td colspan="13"></td></tr>
</table><br><br>';
$q = 'SELECT DISTINCT code_dcr, libelle_dcr FROM `dcr` WHERE `libelle_dcr` != "DRP"';
$res1 = mysql_query($q);
while ($row = mysql_fetch_assoc($res1))
{
$region = $row['libelle_dcr'];
echo '<span style="color:red;">' . $region . '</span>';
echo "<table>";
echo "<tr>
<th style="width:350px">Nom</th>
<th style="width:180px">Offre éditée en attente de remise emprunteur</th>
<th><Offre conclue</th>
<th>Total Général</th>";
$q = "SELECT DISTINCT v.nom, code_e, code_u, nb_doss
FROM v_vision_stock as v
LEFT OUTER JOIN (SELECT nom, SUM(nb_dossier) as code_e FROM v_vision_stock WHERE code_dern_etat_instr="E" AND dcr="" . mysql_real_escape_string($region) . "" GROUP BY nom) as a
ON a.nom = v.nom
LEFT OUTER JOIN (SELECT nom, SUM(nb_dossier) as code_u FROM v_vision_stock WHERE code_dern_etat_instr="U" AND dcr="" . mysql_real_escape_string($region) . "" GROUP BY nom) as u
ON u.nom = v.nom
LEFT OUTER JOIN (SELECT nom, SUM(nb_dossier) as nb_doss FROM v_vision_stock WHERE dcr="" . mysql_real_escape_string($region) . "" GROUP BY nom) as d
ON d.nom = v.nom WHERE nb_doss > 0";
$res = mysql_query($q) or die("SQL Error: " . mysql_error());
$i=0;
$code_e_tot=0;
$code_u_tot=0;
while ($row = mysql_fetch_array($res))
{
if ($i % 2)
$color="bgcolor=#D0E3FA";
else
$color="bgcolor=white";
echo "<tr><td style="text-align:left; padding-left:10px;" $color>" . $row['nom'] . "</td>";
echo "<td class="right_justify" $color>" . $row['code_e'] . "</td>
<td class="right_justify" $color>" . $row['code_u'] . "</td>
<td class="right_justify" $color>" . $row['nb_doss'] . "</td></tr>";
$code_e_tot += $row['code_e'];
$code_u_tot += $row['code_u'];
$i++;
}
$nb_dossier_tot = $code_e_tot + $code_u_tot;
echo "<tr><td style="font-weight:bold;">TOTAL</td>
<td class="right_justify_tot">" . $code_e_tot . "</td>
<td class="right_justify_tot">" . $code_u_tot . "</td>
<td class="right_justify_tot">" . $nb_dossier_tot . "</td></tr></table><br><br>";
}
echo '<span style="color:red;">TOTAL</span>';
echo "<table>";
echo "<tr>
<th style="width:300px">DCR</th>
<th>Offre éditée en attente de remise emprunteur</th>
<th>Offre conclue</th>
<th>Total Général</th>";
$q = "SELECT DISTINCT v.dcr, code_e, code_u, nb_doss FROM v_vision_stock as v JOIN
(SELECT dcr, SUM(nb_dossier) as code_e FROM v_vision_stock WHERE code_dern_etat_instr="E" GROUP BY dcr) as a
ON a.dcr = v.dcr
JOIN (SELECT dcr, SUM(nb_dossier) as code_u FROM v_vision_stock WHERE code_dern_etat_instr = "U" GROUP BY dcr) as u
ON u.dcr = v.dcr
JOIN (SELECT dcr, SUM(nb_dossier) as nb_doss FROM v_vision_stock GROUP BY dcr) as n
ON n.dcr = v.dcr ";
$res = mysql_query($q) or die("SQL Error: " . mysql_error());
$i=0;
$code_e_tot=0;
$code_u_tot=0;
while ($row = mysql_fetch_array($res))
{
if ($i % 2)
$color="bgcolor=#D0E3FA";
else
$color="bgcolor=white";
echo "<tr><td style="text-align:left; padding-left:10px;" $color>" . $row['dcr'] . "</td>";
echo "<td class="right_justify" $color>" . $row['code_e'] . "</td>
<td class="right_justify" $color>" . $row['code_u'] . "</td>
<td class="right_justify" $color>" . $row['nb_doss'] . "</td></tr>";
$code_e_tot += $row['code_e'];
$code_u_tot += $row['code_u'];
$i++;
}
$nb_dossier_tot = $code_e_tot + $code_u_tot;
echo "<tr><td style="font-weight:bold;">TOTAL</td>
<td class="right_justify_tot">" . $code_e_tot . "</td>
<td class="right_justify_tot">" . $code_u_tot . "</td>
<td class="right_justify_tot">" . $nb_dossier_tot . "</td></tr>";
echo "</table><br><br>";
////////////////////////////// PARTIE VUE PAR ANNEE /////////////////////////////
$year = array();
$q = "SELECT DISTINCT annee FROM v_vision_stock WHERE annee !=0 ORDER BY annee ASC";
$res = mysql_query($q) or die("SQL Error: " . mysql_error());
while ($row = mysql_fetch_array($res))
$year[] = $row['annee'];
echo '<table>
<tr bgcolor=red><td colspan="13"></td></tr>
<tr bgcolor=red><td colspan="13" align=center style="color:white;">VUE PAR ANNEE</td></tr>
<tr bgcolor=red><td colspan="13"></td></tr>
</table><br><br>';
$q = 'SELECT DISTINCT code_dcr, libelle_dcr FROM `dcr` WHERE `libelle_dcr` != "DRP"';
$res1 = mysql_query($q);
while ($row = mysql_fetch_assoc($res1))
{
$region = $row['libelle_dcr'];
echo '<span style="color:red;">' . $region . '</span>';
$len = count($year);
echo "<table>";
echo "<tr><th></th><th colspan=" . $len . ">Année d'autorisation</th><th></th>";
echo "<tr><th style="width:230px">Nom</th>";
$i = 0;
while ($i < $len)
{
echo "<th>" . $year[$i] . "</th>";
$i++;
}
echo "<th>Total Général</th>";
$q = "SELECT DISTINCT v.nom";
$i = 0;
while ($i < $len)
{
$q .= ", annee_" . $year[$i];
$i++;
}
$q .= ", nb_doss FROM v_vision_stock as v
LEFT OUTER JOIN (SELECT nom, SUM(nb_dossier) as nb_doss FROM v_vision_stock WHERE dcr="" . mysql_real_escape_string($region) . "" GROUP BY nom) as d
ON d.nom = v.nom ";
$i = 0;
while ($i < $len)
{
$q .= "LEFT OUTER JOIN (SELECT nom, SUM(nb_dossier) as annee_" . $year[$i] . " FROM v_vision_stock WHERE annee=" . $year[$i] . " AND dcr="" . mysql_real_escape_string($region) . "" GROUP BY nom) as a_" . $year[$i] . " ON a_" . $year[$i] . ".nom = v.nom ";
$i++;
}
$q .= " WHERE nb_doss > 0 ";
$res = mysql_query($q) or die("SQL Error: " . mysql_error());
$i=0;
while ($row = mysql_fetch_array($res))
{
if ($i % 2)
$color="bgcolor=#D0E3FA";
else
$color="bgcolor=white";
echo "<tr><td style="text-align:left; padding-left:10px;" $color>" . $row['nom'] . "</td>";
$j = 0;
while ($j < $len)
{
$tmp = "annee_" . $year[$j];
echo "<td class="right_justify" $color>" . $row[$tmp] . "</td>";
$j++;
}
echo "<td class="right_justify" $color>" . $row['nb_doss'] . "</td></tr>";
$i++;
}
$q = "SELECT DISTINCT v.dcr";
$i = 0;
while ($i < $len)
{
$q .= ", annee_" . $year[$i];
$i++;
}
$q .= ", nb_doss FROM v_vision_stock as v
LEFT OUTER JOIN (SELECT dcr, SUM(nb_dossier) as nb_doss FROM v_vision_stock WHERE dcr="" . mysql_real_escape_string($region) . "" GROUP BY dcr) as d
ON d.dcr = v.dcr ";
$i = 0;
while ($i < $len)
{
$q .= "LEFT OUTER JOIN (SELECT dcr, SUM(nb_dossier) as annee_" . $year[$i] . " FROM v_vision_stock WHERE annee=" . $year[$i] . " AND dcr="" . mysql_real_escape_string($region) . "" GROUP BY dcr) as a_" . $year[$i] . " ON a_" . $year[$i] . ".dcr = v.dcr ";
$i++;
}
$q .= " WHERE nb_doss > 0 ";
$res = mysql_query($q) or die("SQL Error: " . mysql_error());
$i=0;
while ($row = mysql_fetch_array($res))
{
if ($i % 2)
$color="bgcolor=#D0E3FA";
else
$color="bgcolor=white";
echo "<tr><td style="font-weight:bold;">TOTAL</td>";
$i = 0;
while ($i < $len)
{
$tmp = "annee_" . $year[$i];
echo "<td class="right_justify_tot">" . $row[$tmp] . "</td>";
$i++;
}
echo "<td class="right_justify_tot">" . $row['nb_doss'] . "</td></tr>";
$i++;
}
echo "</table><br><br>";
}
$len = count($year);
echo '<span style="color:red;">TOTAL</span>';
echo "<table>";
echo "<tr><th></th><th colspan=" . $len . ">Année d'autorisation</th><th></th>";
echo "<tr><th style="width:300px">DCR</th>";
$i = 0;
while ($i < $len)
{
$tmp = $i + 3;
echo "<th>" . $year[$i] . "</th>";
$i++;
}
echo "<th>Total</th>";
$q = "SELECT DISTINCT v.dcr";
$i = 0;
while ($i < $len)
{
$q .= ", annee_" . $year[$i];
$i++;
}
$q .= ", nb_doss FROM v_vision_stock as v
LEFT OUTER JOIN (SELECT dcr, SUM(nb_dossier) as nb_doss FROM v_vision_stock GROUP BY dcr) as d
ON d.dcr = v.dcr ";
$i = 0;
while ($i < $len)
{
$q .= "LEFT OUTER JOIN (SELECT dcr, SUM(nb_dossier) as annee_" . $year[$i] . " FROM v_vision_stock WHERE annee=" . $year[$i] . " GROUP BY dcr) as a_" . $year[$i] . " ON a_" . $year[$i] . ".dcr = v.dcr ";
$i++;
}
$q .= " WHERE nb_doss > 0 ";
$res = mysql_query($q) or die("SQL Error: " . mysql_error());
$i=0;
while ($row = mysql_fetch_array($res))
{
if ($i % 2)
$color="bgcolor=#D0E3FA";
else
$color="bgcolor=white";
echo "<tr><td style="text-align:left; padding-left:10px;" $color>" . $row['dcr'] . "</td>";
$j = 0;
while ($j < $len)
{
$tmp = "annee_" . $year[$j];
echo "<td class="right_justify" $color>" . $row[$tmp] . "</td>";
$j++;
}
echo "<td class="right_justify" $color>" . $row['nb_doss'] . "</td></tr>";
$i++;
}
// TOTAL
$q = "SELECT DISTINCT v.dcr";
$i = 0;
while ($i < $len)
{
$q .= ", annee_" . $year[$i];
$i++;
}
$q .= ", nb_doss FROM v_vision_stock as v
LEFT OUTER JOIN (SELECT dcr, SUM(nb_dossier) as nb_doss FROM v_vision_stock) as d
ON d.dcr = v.dcr ";
$i = 0;
while ($i < $len)
{
$q .= "LEFT OUTER JOIN (SELECT dcr, SUM(nb_dossier) as annee_" . $year[$i] . " FROM v_vision_stock WHERE annee=" . $year[$i] . ") as a_" . $year[$i] . " ON a_" . $year[$i] . ".dcr = v.dcr ";
$i++;
}
$q .= " WHERE nb_doss > 0 ";
$res = mysql_query($q) or die("SQL Error: " . mysql_error());
$i=0;
while ($row = mysql_fetch_array($res))
{
if ($i % 2)
$color="bgcolor=#D0E3FA";
else
$color="bgcolor=white";
echo "<tr><td style="font-weight:bold;">TOTAL</td>";
$i = 0;
while ($i < $len)
{
$tmp = "annee_" . $year[$i];
echo "<td class="right_justify_tot">" . $row[$tmp] . "</td>";
$i++;
}
echo "<td class="right_justify_tot">" . $row['nb_doss'] . "</td></tr>";
$i++;
}
echo "</table>";
?>
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team