par
master2011 » 29 août 2012, 13:53
suite:
<!----------------------------------------- Recherche des données --------------------------------------------->
<?php
$annee = 1900;
//Vérification de la période choisie
if($idb>0 && $ide>0)
{
//Vérifier que les périodes sont cohérentes
if($ide < $idb)
{
/*Afficher un message d'erreur
Maintenir le focus sur le fieldset période*/
}
//SINON
else
{
//La période choisite est comprise entre date début et une date fin
if($idd>0)
{
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit_detail.Nom_Sous_Produit_Detail,
dbvente.unites.Nom_Unite,
dbvente.vente_sous_detail.Volume,
dbvente.vente_sous_detail.Prix,
dbvente.vente_sous_detail.CA,
dbvente.vente_sous_detail.CA_Dinars
FROM
dbvente.vente_sous_detail,
dbvente.sous_produit_detail,
dbvente.periode,
dbvente.produit,
dbvente.sous_produit,
dbvente.unites,
dbvente.famille_produit
WHERE
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.produit.ID_Produit = ' . $idp . ' AND
dbvente.sous_produit.ID_Sous_Produit = ' . $ids . ' AND
dbvente.vente_sous_detail.ID_Marche = 2 AND
dbvente.vente_sous_detail.ID_Periode BETWEEN ' .$idb . ' AND ' . $ide . ' AND
dbvente.sous_produit_detail.ID_Sous_Produit_Detail = ' . $idd . ' AND
dbvente.vente_sous_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_sous_detail.ID_Sous_Produit_Detail = dbvente.sous_produit_detail.ID_Sous_Produit_Detail AND
dbvente.sous_produit_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente_sous_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.famille_produit.ID_Famille = dbvente.produit.ID_Famille
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
//if(!empty($vl) || !empty($pm) || !empty($cd) || !empty($cl)){
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
//if(!empty($vl))
{echo '<th>Volume</th>';}
//if(!empty($pm))
{echo '<th>Prix Moyen</th>';}
if(!empty($cd))
//{echo '<th>Chiffre affaire devise</th>';}
//if(!empty($cl))
{echo '<th>Chiffre affaire dinars</th>';}
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit_Detail']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}//}
?>
</table>
<?php
}
//SINON
else
{
if($ids>0)
{
/*afficher toutes les ventes réalisées du sous produit
je manipule à ce niveau la table vente de sous produit
et la table détail*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit_detail.Nom_Sous_Produit_Detail,
dbvente.unites.Nom_Unite,
dbvente.vente_sous_detail.Volume,
dbvente.vente_sous_detail.Prix,
dbvente.vente_sous_detail.CA,
dbvente.vente_sous_detail.CA_Dinars
FROM
dbvente.vente_sous_detail,
dbvente.sous_produit_detail,
dbvente.periode,
dbvente.produit,
dbvente.sous_produit,
dbvente.unites,
dbvente.famille_produit
WHERE
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.produit.ID_Produit = ' . $idp . ' AND
dbvente.sous_produit.ID_Sous_Produit = ' . $ids . ' AND
dbvente.vente_sous_detail.ID_Periode BETWEEN ' . $idb . ' AND ' . $ide . ' AND
dbvente.vente_sous_detail.ID_Marche = 2 AND
dbvente.vente_sous_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_sous_detail.ID_Sous_Produit_Detail = dbvente.sous_produit_detail.ID_Sous_Produit_Detail AND
dbvente.sous_produit_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente_sous_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.famille_produit.ID_Famille = dbvente.produit.ID_Famille
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Détail Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit_Detail']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
//SINON
else
{
if($idp>0)
{
/*afficher toutes les ventes réalisées du produit
je manipile à ce niveau la table vente globale
et la table de vente de sous produit*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit.Nom_Sous_Produit,
dbvente.unites.Nom_Unite,
dbvente.vente_detail.Volume,
dbvente.vente_detail.Prix,
dbvente.vente_detail.CA,
dbvente.vente_detail.CA_Dinars
FROM
dbvente.periode,
dbvente.sous_produit,
dbvente.vente_detail,
dbvente.produit,
dbvente.famille_produit,
dbvente.unites
WHERE
dbvente.vente_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.produit.ID_Famille = dbvente.famille_produit.ID_Famille AND
dbvente.vente_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.vente_detail.ID_Marche = 2 AND
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.sous_produit.ID_Produit = ' . $idp . ' AND
dbvente.vente_detail.ID_Periode BETWEEN ' . $idb . ' AND ' . $ide . ' '.'
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
else
{
if($idf>0)
{
/*afficher toutes les ventes réalisées de la famille
je manipile à ce niveau la table vente globale*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.produit.Nom_Produit,
dbvente.unites.Nom_Unite,
dbvente.vente.Volume,
dbvente.vente.Prix,
dbvente.vente.CA,
dbvente.vente.CA_Dinars
FROM
dbvente.periode,
dbvente.produit,
dbvente.vente,
dbvente.unites
WHERE
dbvente.vente.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.vente.ID_Marche = 2 AND
dbvente.vente.ID_Famille = ' . $idf . ' ' . 'AND
dbvente.vente.ID_Periode BETWEEN ' . $idb . ' AND '. $ide .' '.'
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Produit </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Produit']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
}
}
}
}
}
/*Sinon
Vérifier les intervales choisis*/
else
{
//La période choisie correspond à depuis une date début jusqu'à présent
if($idb>0 && $ide<=0)
{
if($idd>0)
{
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit_detail.Nom_Sous_Produit_Detail,
dbvente.unites.Nom_Unite,
dbvente.vente_sous_detail.Volume,
dbvente.vente_sous_detail.Prix,
dbvente.vente_sous_detail.CA,
dbvente.vente_sous_detail.CA_Dinars
FROM
dbvente.vente_sous_detail,
dbvente.sous_produit_detail,
dbvente.periode,
dbvente.produit,
dbvente.sous_produit,
dbvente.unites,
dbvente.famille_produit
WHERE
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.produit.ID_Produit = ' . $idp . ' AND
dbvente.sous_produit.ID_Sous_Produit = ' . $ids . ' AND
dbvente.vente_sous_detail.ID_Marche = 2 AND
dbvente.vente_sous_detail.ID_Periode >= ' .$idb . ' ' . '
dbvente.sous_produit_detail.ID_Sous_Produit_Detail = ' . $idd . ' AND
dbvente.vente_sous_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_sous_detail.ID_Sous_Produit_Detail = dbvente.sous_produit_detail.ID_Sous_Produit_Detail AND
dbvente.sous_produit_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente_sous_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.famille_produit.ID_Famille = dbvente.produit.ID_Famille
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit_Detail']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
//SINON
else
{
//SI produit selectionné ALORS
if($ids>0)
{
/*afficher toutes les ventes réalisées du sous produit
je manipule à ce niveau la table vente de sous produit
et la table détail*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit_detail.Nom_Sous_Produit_Detail,
dbvente.unites.Nom_Unite,
dbvente.vente_sous_detail.Volume,
dbvente.vente_sous_detail.Prix,
dbvente.vente_sous_detail.CA,
dbvente.vente_sous_detail.CA_Dinars
FROM
dbvente.vente_sous_detail,
dbvente.sous_produit_detail,
dbvente.periode,
dbvente.produit,
dbvente.sous_produit,
dbvente.unites,
dbvente.famille_produit
WHERE
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.produit.ID_Produit = ' . $idp . ' AND
dbvente.sous_produit.ID_Sous_Produit = ' . $ids . ' AND
dbvente.vente_sous_detail.ID_Periode >= ' . $idb . ' ' . '
dbvente.vente_sous_detail.ID_Marche = 2 AND
dbvente.vente_sous_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_sous_detail.ID_Sous_Produit_Detail = dbvente.sous_produit_detail.ID_Sous_Produit_Detail AND
dbvente.sous_produit_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente_sous_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.famille_produit.ID_Famille = dbvente.produit.ID_Famille
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit_Detail']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
//SINON
else
{
//SI sous produit selectionné ALORS
if($idp>0)
{
/*afficher toutes les ventes réalisées du produit
je manipile à ce niveau la table vente globale
et la table de vente de sous produit*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit.Nom_Sous_Produit,
dbvente.unites.Nom_Unite,
dbvente.vente_detail.Volume,
dbvente.vente_detail.Prix,
dbvente.vente_detail.CA,
dbvente.vente_detail.CA_Dinars
FROM
dbvente.periode,
dbvente.sous_produit,
dbvente.vente_detail,
dbvente.produit,
dbvente.famille_produit,
dbvente.unites
WHERE
dbvente.vente_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.produit.ID_Famille = dbvente.famille_produit.ID_Famille AND
dbvente.vente_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.vente_detail.ID_Marche = 2 AND
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.sous_produit.ID_Produit = ' . $idp . ' AND
dbvente.vente_detail.ID_Periode >= ' . $idb . ' ' .'
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
else
{
if($idf>0)
{
/*afficher toutes les ventes réalisées de la famille
je manipile à ce niveau la table vente globale*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.produit.Nom_Produit,
dbvente.unites.Nom_Unite,
dbvente.vente.Volume,
dbvente.vente.Prix,
dbvente.vente.CA,
dbvente.vente.CA_Dinars
FROM
dbvente.periode,
dbvente.produit,
dbvente.vente,
dbvente.unites
WHERE
dbvente.vente.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.vente.ID_Marche = 2 AND
dbvente.vente.ID_Famille = ' . $idf . ' ' . 'AND
dbvente.vente.ID_Periode >= ' . $idb . ' '.'
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Produit </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Produit']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
}
}
}
}
else
{
if($idb<=0 && $ide>0)
{
//La période choisie correspond à toutes les dates jusqu'à une date précise
if($idd>0)
{
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit_detail.Nom_Sous_Produit_Detail,
dbvente.unites.Nom_Unite,
dbvente.vente_sous_detail.Volume,
dbvente.vente_sous_detail.Prix,
dbvente.vente_sous_detail.CA,
dbvente.vente_sous_detail.CA_Dinars
FROM
dbvente.vente_sous_detail,
dbvente.sous_produit_detail,
dbvente.periode,
dbvente.produit,
dbvente.sous_produit,
dbvente.unites,
dbvente.famille_produit
WHERE
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.produit.ID_Produit = ' . $idp . ' AND
dbvente.sous_produit.ID_Sous_Produit = ' . $ids . ' AND
dbvente.vente_sous_detail.ID_Marche = 2 AND
dbvente.vente_sous_detail.ID_Periode <= ' .$ide . ' ' . '
dbvente.sous_produit_detail.ID_Sous_Produit_Detail = ' . $idd . ' AND
dbvente.vente_sous_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_sous_detail.ID_Sous_Produit_Detail = dbvente.sous_produit_detail.ID_Sous_Produit_Detail AND
dbvente.sous_produit_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente_sous_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.famille_produit.ID_Famille = dbvente.produit.ID_Famille
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit_Detail']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
//SINON
else
{
//SI produit selectionné ALORS
if($ids>0)
{
/*afficher toutes les ventes réalisées du sous produit
je manipule à ce niveau la table vente de sous produit
et la table détail*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit_detail.Nom_Sous_Produit_Detail,
dbvente.unites.Nom_Unite,
dbvente.vente_sous_detail.Volume,
dbvente.vente_sous_detail.Prix,
dbvente.vente_sous_detail.CA,
dbvente.vente_sous_detail.CA_Dinars
FROM
dbvente.vente_sous_detail,
dbvente.sous_produit_detail,
dbvente.periode,
dbvente.produit,
dbvente.sous_produit,
dbvente.unites,
dbvente.famille_produit
WHERE
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.produit.ID_Produit = ' . $idp . ' AND
dbvente.sous_produit.ID_Sous_Produit = ' . $ids . ' AND
dbvente.vente_sous_detail.ID_Periode <= ' . $ide . ' ' . '
dbvente.vente_sous_detail.ID_Marche = 2 AND
dbvente.vente_sous_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_sous_detail.ID_Sous_Produit_Detail = dbvente.sous_produit_detail.ID_Sous_Produit_Detail AND
dbvente.sous_produit_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente_sous_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.famille_produit.ID_Famille = dbvente.produit.ID_Famille
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit_Detail']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
//SINON
else
{
//SI sous produit selectionné ALORS
if($idp>0)
{
/*afficher toutes les ventes réalisées du produit
je manipile à ce niveau la table vente globale
et la table de vente de sous produit*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit.Nom_Sous_Produit,
dbvente.unites.Nom_Unite,
dbvente.vente_detail.Volume,
dbvente.vente_detail.Prix,
dbvente.vente_detail.CA,
dbvente.vente_detail.CA_Dinars
FROM
dbvente.periode,
dbvente.sous_produit,
dbvente.vente_detail,
dbvente.produit,
dbvente.famille_produit,
dbvente.unites
WHERE
dbvente.vente_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.produit.ID_Famille = dbvente.famille_produit.ID_Famille AND
dbvente.vente_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.vente_detail.ID_Marche = 2 AND
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.sous_produit.ID_Produit = ' . $idp . ' AND
dbvente.vente_detail.ID_Periode <= ' . $ide . ' ' .'
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
else
{
if($idf>0)
{
/*afficher toutes les ventes réalisées de la famille
je manipile à ce niveau la table vente globale*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.produit.Nom_Produit,
dbvente.unites.ID_Unite,
dbvente.vente.Volume,
dbvente.vente.Prix,
dbvente.vente.CA,
dbvente.vente.CA_Dinars
FROM
dbvente.periode,
dbvente.produit,
dbvente.vente,
dbvente.unites
WHERE
dbvente.vente.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente.ID_unite = dbvente.unites.ID_Unite AND
dbvente.vente.ID_Marche = 2 AND
dbvente.vente.ID_Famille = ' . $idf . ' ' . 'AND
dbvente.vente.ID_Periode <= ' . $ide . ' '.'
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Produit </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Produit']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
}
}
}
}
//SINON
else{
/*A ce niveau tout l'historique est à prendre en considération*/
if($idd>0)
{
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit_detail.Nom_Sous_Produit_Detail,
dbvente.unites.Nom_Unite,
dbvente.vente_sous_detail.Volume,
dbvente.vente_sous_detail.Prix,
dbvente.vente_sous_detail.CA,
dbvente.vente_sous_detail.CA_Dinars
FROM
dbvente.vente_sous_detail,
dbvente.sous_produit_detail,
dbvente.periode,
dbvente.produit,
dbvente.sous_produit,
dbvente.unites,
dbvente.famille_produit
WHERE
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.produit.ID_Produit = ' . $idp . ' AND
dbvente.sous_produit.ID_Sous_Produit = ' . $ids . ' AND
dbvente.vente_sous_detail.ID_Marche = 2 AND
dbvente.sous_produit_detail.ID_Sous_Produit_Detail = ' . $idd . ' AND
dbvente.vente_sous_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_sous_detail.ID_Sous_Produit_Detail = dbvente.sous_produit_detail.ID_Sous_Produit_Detail AND
dbvente.sous_produit_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente_sous_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.famille_produit.ID_Famille = dbvente.produit.ID_Famille
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit_Detail']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
//SINON
else
{
//SI produit selectionné ALORS
if($ids>0)
{
/*afficher toutes les ventes réalisées du sous produit
je manipule à ce niveau la table vente de sous produit
et la table détail*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit_detail.Nom_Sous_Produit_Detail,
dbvente.unites.Nom_Unite,
dbvente.vente_sous_detail.Volume,
dbvente.vente_sous_detail.Prix,
dbvente.vente_sous_detail.CA,
dbvente.vente_sous_detail.CA_Dinars
FROM
dbvente.vente_sous_detail,
dbvente.sous_produit_detail,
dbvente.periode,
dbvente.produit,
dbvente.sous_produit,
dbvente.unites,
dbvente.famille_produit
WHERE
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.produit.ID_Produit = ' . $idp . ' AND
dbvente.sous_produit.ID_Sous_Produit = ' . $ids . ' AND
dbvente.vente_sous_detail.ID_Marche = 2 AND
dbvente.vente_sous_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_sous_detail.ID_Sous_Produit_Detail = dbvente.sous_produit_detail.ID_Sous_Produit_Detail AND
dbvente.sous_produit_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente_sous_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.famille_produit.ID_Famille = dbvente.produit.ID_Famille
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit_Detail']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
//SINON
else
{
//SI sous produit selectionné ALORS
if($idp>0)
{
/*afficher toutes les ventes réalisées du produit
je manipile à ce niveau la table vente globale
et la table de vente de sous produit*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit.Nom_Sous_Produit,
dbvente.unites.Nom_Unite,
dbvente.vente_detail.Volume,
dbvente.vente_detail.Prix,
dbvente.vente_detail.CA,
dbvente.vente_detail.CA_Dinars
FROM
dbvente.periode,
dbvente.sous_produit,
dbvente.vente_detail,
dbvente.produit,
dbvente.famille_produit,
dbvente.unites
WHERE
dbvente.vente_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.produit.ID_Famille = dbvente.famille_produit.ID_Famille AND
dbvente.vente_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.vente_detail.ID_Marche = 2 AND
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.sous_produit.ID_Produit = ' . $idp . ' '.'
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
else
{
if($idf>0)
{
/*afficher toutes les ventes réalisées de la famille
je manipile à ce niveau la table vente globale*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.produit.Nom_Produit,
dbvente.unites.Nom_Unite,
dbvente.vente.Volume,
dbvente.vente.Prix,
dbvente.vente.CA,
dbvente.vente.CA_Dinars
FROM
dbvente.periode,
dbvente.produit,
dbvente.vente,
dbvente.unites
WHERE
dbvente.vente.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.vente.ID_Marche = 2 AND
dbvente.vente.ID_Famille = ' . $idf . ' ' . '
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Produit </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Produit']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
}
}
}
}
}
}
?>
suite:
[php]
<!----------------------------------------- Recherche des données --------------------------------------------->
<?php
$annee = 1900;
//Vérification de la période choisie
if($idb>0 && $ide>0)
{
//Vérifier que les périodes sont cohérentes
if($ide < $idb)
{
/*Afficher un message d'erreur
Maintenir le focus sur le fieldset période*/
}
//SINON
else
{
//La période choisite est comprise entre date début et une date fin
if($idd>0)
{
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit_detail.Nom_Sous_Produit_Detail,
dbvente.unites.Nom_Unite,
dbvente.vente_sous_detail.Volume,
dbvente.vente_sous_detail.Prix,
dbvente.vente_sous_detail.CA,
dbvente.vente_sous_detail.CA_Dinars
FROM
dbvente.vente_sous_detail,
dbvente.sous_produit_detail,
dbvente.periode,
dbvente.produit,
dbvente.sous_produit,
dbvente.unites,
dbvente.famille_produit
WHERE
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.produit.ID_Produit = ' . $idp . ' AND
dbvente.sous_produit.ID_Sous_Produit = ' . $ids . ' AND
dbvente.vente_sous_detail.ID_Marche = 2 AND
dbvente.vente_sous_detail.ID_Periode BETWEEN ' .$idb . ' AND ' . $ide . ' AND
dbvente.sous_produit_detail.ID_Sous_Produit_Detail = ' . $idd . ' AND
dbvente.vente_sous_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_sous_detail.ID_Sous_Produit_Detail = dbvente.sous_produit_detail.ID_Sous_Produit_Detail AND
dbvente.sous_produit_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente_sous_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.famille_produit.ID_Famille = dbvente.produit.ID_Famille
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
//if(!empty($vl) || !empty($pm) || !empty($cd) || !empty($cl)){
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
//if(!empty($vl))
{echo '<th>Volume</th>';}
//if(!empty($pm))
{echo '<th>Prix Moyen</th>';}
if(!empty($cd))
//{echo '<th>Chiffre affaire devise</th>';}
//if(!empty($cl))
{echo '<th>Chiffre affaire dinars</th>';}
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit_Detail']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}//}
?>
</table>
<?php
}
//SINON
else
{
if($ids>0)
{
/*afficher toutes les ventes réalisées du sous produit
je manipule à ce niveau la table vente de sous produit
et la table détail*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit_detail.Nom_Sous_Produit_Detail,
dbvente.unites.Nom_Unite,
dbvente.vente_sous_detail.Volume,
dbvente.vente_sous_detail.Prix,
dbvente.vente_sous_detail.CA,
dbvente.vente_sous_detail.CA_Dinars
FROM
dbvente.vente_sous_detail,
dbvente.sous_produit_detail,
dbvente.periode,
dbvente.produit,
dbvente.sous_produit,
dbvente.unites,
dbvente.famille_produit
WHERE
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.produit.ID_Produit = ' . $idp . ' AND
dbvente.sous_produit.ID_Sous_Produit = ' . $ids . ' AND
dbvente.vente_sous_detail.ID_Periode BETWEEN ' . $idb . ' AND ' . $ide . ' AND
dbvente.vente_sous_detail.ID_Marche = 2 AND
dbvente.vente_sous_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_sous_detail.ID_Sous_Produit_Detail = dbvente.sous_produit_detail.ID_Sous_Produit_Detail AND
dbvente.sous_produit_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente_sous_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.famille_produit.ID_Famille = dbvente.produit.ID_Famille
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Détail Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit_Detail']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
//SINON
else
{
if($idp>0)
{
/*afficher toutes les ventes réalisées du produit
je manipile à ce niveau la table vente globale
et la table de vente de sous produit*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit.Nom_Sous_Produit,
dbvente.unites.Nom_Unite,
dbvente.vente_detail.Volume,
dbvente.vente_detail.Prix,
dbvente.vente_detail.CA,
dbvente.vente_detail.CA_Dinars
FROM
dbvente.periode,
dbvente.sous_produit,
dbvente.vente_detail,
dbvente.produit,
dbvente.famille_produit,
dbvente.unites
WHERE
dbvente.vente_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.produit.ID_Famille = dbvente.famille_produit.ID_Famille AND
dbvente.vente_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.vente_detail.ID_Marche = 2 AND
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.sous_produit.ID_Produit = ' . $idp . ' AND
dbvente.vente_detail.ID_Periode BETWEEN ' . $idb . ' AND ' . $ide . ' '.'
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
else
{
if($idf>0)
{
/*afficher toutes les ventes réalisées de la famille
je manipile à ce niveau la table vente globale*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.produit.Nom_Produit,
dbvente.unites.Nom_Unite,
dbvente.vente.Volume,
dbvente.vente.Prix,
dbvente.vente.CA,
dbvente.vente.CA_Dinars
FROM
dbvente.periode,
dbvente.produit,
dbvente.vente,
dbvente.unites
WHERE
dbvente.vente.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.vente.ID_Marche = 2 AND
dbvente.vente.ID_Famille = ' . $idf . ' ' . 'AND
dbvente.vente.ID_Periode BETWEEN ' . $idb . ' AND '. $ide .' '.'
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Produit </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Produit']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
}
}
}
}
}
/*Sinon
Vérifier les intervales choisis*/
else
{
//La période choisie correspond à depuis une date début jusqu'à présent
if($idb>0 && $ide<=0)
{
if($idd>0)
{
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit_detail.Nom_Sous_Produit_Detail,
dbvente.unites.Nom_Unite,
dbvente.vente_sous_detail.Volume,
dbvente.vente_sous_detail.Prix,
dbvente.vente_sous_detail.CA,
dbvente.vente_sous_detail.CA_Dinars
FROM
dbvente.vente_sous_detail,
dbvente.sous_produit_detail,
dbvente.periode,
dbvente.produit,
dbvente.sous_produit,
dbvente.unites,
dbvente.famille_produit
WHERE
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.produit.ID_Produit = ' . $idp . ' AND
dbvente.sous_produit.ID_Sous_Produit = ' . $ids . ' AND
dbvente.vente_sous_detail.ID_Marche = 2 AND
dbvente.vente_sous_detail.ID_Periode >= ' .$idb . ' ' . '
dbvente.sous_produit_detail.ID_Sous_Produit_Detail = ' . $idd . ' AND
dbvente.vente_sous_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_sous_detail.ID_Sous_Produit_Detail = dbvente.sous_produit_detail.ID_Sous_Produit_Detail AND
dbvente.sous_produit_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente_sous_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.famille_produit.ID_Famille = dbvente.produit.ID_Famille
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit_Detail']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
//SINON
else
{
//SI produit selectionné ALORS
if($ids>0)
{
/*afficher toutes les ventes réalisées du sous produit
je manipule à ce niveau la table vente de sous produit
et la table détail*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit_detail.Nom_Sous_Produit_Detail,
dbvente.unites.Nom_Unite,
dbvente.vente_sous_detail.Volume,
dbvente.vente_sous_detail.Prix,
dbvente.vente_sous_detail.CA,
dbvente.vente_sous_detail.CA_Dinars
FROM
dbvente.vente_sous_detail,
dbvente.sous_produit_detail,
dbvente.periode,
dbvente.produit,
dbvente.sous_produit,
dbvente.unites,
dbvente.famille_produit
WHERE
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.produit.ID_Produit = ' . $idp . ' AND
dbvente.sous_produit.ID_Sous_Produit = ' . $ids . ' AND
dbvente.vente_sous_detail.ID_Periode >= ' . $idb . ' ' . '
dbvente.vente_sous_detail.ID_Marche = 2 AND
dbvente.vente_sous_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_sous_detail.ID_Sous_Produit_Detail = dbvente.sous_produit_detail.ID_Sous_Produit_Detail AND
dbvente.sous_produit_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente_sous_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.famille_produit.ID_Famille = dbvente.produit.ID_Famille
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit_Detail']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
//SINON
else
{
//SI sous produit selectionné ALORS
if($idp>0)
{
/*afficher toutes les ventes réalisées du produit
je manipile à ce niveau la table vente globale
et la table de vente de sous produit*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit.Nom_Sous_Produit,
dbvente.unites.Nom_Unite,
dbvente.vente_detail.Volume,
dbvente.vente_detail.Prix,
dbvente.vente_detail.CA,
dbvente.vente_detail.CA_Dinars
FROM
dbvente.periode,
dbvente.sous_produit,
dbvente.vente_detail,
dbvente.produit,
dbvente.famille_produit,
dbvente.unites
WHERE
dbvente.vente_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.produit.ID_Famille = dbvente.famille_produit.ID_Famille AND
dbvente.vente_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.vente_detail.ID_Marche = 2 AND
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.sous_produit.ID_Produit = ' . $idp . ' AND
dbvente.vente_detail.ID_Periode >= ' . $idb . ' ' .'
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
else
{
if($idf>0)
{
/*afficher toutes les ventes réalisées de la famille
je manipile à ce niveau la table vente globale*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.produit.Nom_Produit,
dbvente.unites.Nom_Unite,
dbvente.vente.Volume,
dbvente.vente.Prix,
dbvente.vente.CA,
dbvente.vente.CA_Dinars
FROM
dbvente.periode,
dbvente.produit,
dbvente.vente,
dbvente.unites
WHERE
dbvente.vente.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.vente.ID_Marche = 2 AND
dbvente.vente.ID_Famille = ' . $idf . ' ' . 'AND
dbvente.vente.ID_Periode >= ' . $idb . ' '.'
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Produit </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Produit']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
}
}
}
}
else
{
if($idb<=0 && $ide>0)
{
//La période choisie correspond à toutes les dates jusqu'à une date précise
if($idd>0)
{
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit_detail.Nom_Sous_Produit_Detail,
dbvente.unites.Nom_Unite,
dbvente.vente_sous_detail.Volume,
dbvente.vente_sous_detail.Prix,
dbvente.vente_sous_detail.CA,
dbvente.vente_sous_detail.CA_Dinars
FROM
dbvente.vente_sous_detail,
dbvente.sous_produit_detail,
dbvente.periode,
dbvente.produit,
dbvente.sous_produit,
dbvente.unites,
dbvente.famille_produit
WHERE
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.produit.ID_Produit = ' . $idp . ' AND
dbvente.sous_produit.ID_Sous_Produit = ' . $ids . ' AND
dbvente.vente_sous_detail.ID_Marche = 2 AND
dbvente.vente_sous_detail.ID_Periode <= ' .$ide . ' ' . '
dbvente.sous_produit_detail.ID_Sous_Produit_Detail = ' . $idd . ' AND
dbvente.vente_sous_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_sous_detail.ID_Sous_Produit_Detail = dbvente.sous_produit_detail.ID_Sous_Produit_Detail AND
dbvente.sous_produit_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente_sous_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.famille_produit.ID_Famille = dbvente.produit.ID_Famille
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit_Detail']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
//SINON
else
{
//SI produit selectionné ALORS
if($ids>0)
{
/*afficher toutes les ventes réalisées du sous produit
je manipule à ce niveau la table vente de sous produit
et la table détail*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit_detail.Nom_Sous_Produit_Detail,
dbvente.unites.Nom_Unite,
dbvente.vente_sous_detail.Volume,
dbvente.vente_sous_detail.Prix,
dbvente.vente_sous_detail.CA,
dbvente.vente_sous_detail.CA_Dinars
FROM
dbvente.vente_sous_detail,
dbvente.sous_produit_detail,
dbvente.periode,
dbvente.produit,
dbvente.sous_produit,
dbvente.unites,
dbvente.famille_produit
WHERE
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.produit.ID_Produit = ' . $idp . ' AND
dbvente.sous_produit.ID_Sous_Produit = ' . $ids . ' AND
dbvente.vente_sous_detail.ID_Periode <= ' . $ide . ' ' . '
dbvente.vente_sous_detail.ID_Marche = 2 AND
dbvente.vente_sous_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_sous_detail.ID_Sous_Produit_Detail = dbvente.sous_produit_detail.ID_Sous_Produit_Detail AND
dbvente.sous_produit_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente_sous_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.famille_produit.ID_Famille = dbvente.produit.ID_Famille
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit_Detail']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
//SINON
else
{
//SI sous produit selectionné ALORS
if($idp>0)
{
/*afficher toutes les ventes réalisées du produit
je manipile à ce niveau la table vente globale
et la table de vente de sous produit*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit.Nom_Sous_Produit,
dbvente.unites.Nom_Unite,
dbvente.vente_detail.Volume,
dbvente.vente_detail.Prix,
dbvente.vente_detail.CA,
dbvente.vente_detail.CA_Dinars
FROM
dbvente.periode,
dbvente.sous_produit,
dbvente.vente_detail,
dbvente.produit,
dbvente.famille_produit,
dbvente.unites
WHERE
dbvente.vente_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.produit.ID_Famille = dbvente.famille_produit.ID_Famille AND
dbvente.vente_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.vente_detail.ID_Marche = 2 AND
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.sous_produit.ID_Produit = ' . $idp . ' AND
dbvente.vente_detail.ID_Periode <= ' . $ide . ' ' .'
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
else
{
if($idf>0)
{
/*afficher toutes les ventes réalisées de la famille
je manipile à ce niveau la table vente globale*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.produit.Nom_Produit,
dbvente.unites.ID_Unite,
dbvente.vente.Volume,
dbvente.vente.Prix,
dbvente.vente.CA,
dbvente.vente.CA_Dinars
FROM
dbvente.periode,
dbvente.produit,
dbvente.vente,
dbvente.unites
WHERE
dbvente.vente.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente.ID_unite = dbvente.unites.ID_Unite AND
dbvente.vente.ID_Marche = 2 AND
dbvente.vente.ID_Famille = ' . $idf . ' ' . 'AND
dbvente.vente.ID_Periode <= ' . $ide . ' '.'
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Produit </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Produit']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
}
}
}
}
//SINON
else{
/*A ce niveau tout l'historique est à prendre en considération*/
if($idd>0)
{
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit_detail.Nom_Sous_Produit_Detail,
dbvente.unites.Nom_Unite,
dbvente.vente_sous_detail.Volume,
dbvente.vente_sous_detail.Prix,
dbvente.vente_sous_detail.CA,
dbvente.vente_sous_detail.CA_Dinars
FROM
dbvente.vente_sous_detail,
dbvente.sous_produit_detail,
dbvente.periode,
dbvente.produit,
dbvente.sous_produit,
dbvente.unites,
dbvente.famille_produit
WHERE
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.produit.ID_Produit = ' . $idp . ' AND
dbvente.sous_produit.ID_Sous_Produit = ' . $ids . ' AND
dbvente.vente_sous_detail.ID_Marche = 2 AND
dbvente.sous_produit_detail.ID_Sous_Produit_Detail = ' . $idd . ' AND
dbvente.vente_sous_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_sous_detail.ID_Sous_Produit_Detail = dbvente.sous_produit_detail.ID_Sous_Produit_Detail AND
dbvente.sous_produit_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente_sous_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.famille_produit.ID_Famille = dbvente.produit.ID_Famille
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit_Detail']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
//SINON
else
{
//SI produit selectionné ALORS
if($ids>0)
{
/*afficher toutes les ventes réalisées du sous produit
je manipule à ce niveau la table vente de sous produit
et la table détail*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit_detail.Nom_Sous_Produit_Detail,
dbvente.unites.Nom_Unite,
dbvente.vente_sous_detail.Volume,
dbvente.vente_sous_detail.Prix,
dbvente.vente_sous_detail.CA,
dbvente.vente_sous_detail.CA_Dinars
FROM
dbvente.vente_sous_detail,
dbvente.sous_produit_detail,
dbvente.periode,
dbvente.produit,
dbvente.sous_produit,
dbvente.unites,
dbvente.famille_produit
WHERE
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.produit.ID_Produit = ' . $idp . ' AND
dbvente.sous_produit.ID_Sous_Produit = ' . $ids . ' AND
dbvente.vente_sous_detail.ID_Marche = 2 AND
dbvente.vente_sous_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_sous_detail.ID_Sous_Produit_Detail = dbvente.sous_produit_detail.ID_Sous_Produit_Detail AND
dbvente.sous_produit_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente_sous_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.famille_produit.ID_Famille = dbvente.produit.ID_Famille
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit_Detail']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
//SINON
else
{
//SI sous produit selectionné ALORS
if($idp>0)
{
/*afficher toutes les ventes réalisées du produit
je manipile à ce niveau la table vente globale
et la table de vente de sous produit*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.sous_produit.Nom_Sous_Produit,
dbvente.unites.Nom_Unite,
dbvente.vente_detail.Volume,
dbvente.vente_detail.Prix,
dbvente.vente_detail.CA,
dbvente.vente_detail.CA_Dinars
FROM
dbvente.periode,
dbvente.sous_produit,
dbvente.vente_detail,
dbvente.produit,
dbvente.famille_produit,
dbvente.unites
WHERE
dbvente.vente_detail.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente_detail.ID_Sous_Produit = dbvente.sous_produit.ID_Sous_Produit AND
dbvente.sous_produit.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.produit.ID_Famille = dbvente.famille_produit.ID_Famille AND
dbvente.vente_detail.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.vente_detail.ID_Marche = 2 AND
dbvente.famille_produit.ID_Famille = ' . $idf . ' AND
dbvente.sous_produit.ID_Produit = ' . $idp . ' '.'
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Sous-Produits </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Sous_Produit']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
else
{
if($idf>0)
{
/*afficher toutes les ventes réalisées de la famille
je manipile à ce niveau la table vente globale*/
$reponse = $bdd->query('SELECT
dbvente.periode.An,
dbvente.produit.Nom_Produit,
dbvente.unites.Nom_Unite,
dbvente.vente.Volume,
dbvente.vente.Prix,
dbvente.vente.CA,
dbvente.vente.CA_Dinars
FROM
dbvente.periode,
dbvente.produit,
dbvente.vente,
dbvente.unites
WHERE
dbvente.vente.ID_Periode = dbvente.periode.ID_Periode AND
dbvente.vente.ID_Produit = dbvente.produit.ID_Produit AND
dbvente.vente.ID_Unite = dbvente.unites.ID_Unite AND
dbvente.vente.ID_Marche = 2 AND
dbvente.vente.ID_Famille = ' . $idf . ' ' . '
ORDER BY
dbvente.periode.An DESC');
?>
<table border="2" width="100%" cellpadding="3">
<?php
while ($donnees = $reponse->fetch())
{
if($annee != $donnees['An']){
echo '<tr>';
echo '<th colspan="6">' . $donnees['An']. '</th>';
echo '<tr>';
echo '<th> Produit </th>';
echo '<th> Unité </th>';
echo '<th>Volume</th>';
echo '<th>Prix Moyen</th>';
echo '<th>Chiffre affaire devise</th>';
echo '<th>Chiffre affaire dinars</th>';
echo '</tr>';
echo '</tr>';
}
echo '<tr><td>' . htmlspecialchars($donnees['Nom_Produit']) . '</td>';
echo '<td>' . $donnees['Nom_Unite']. '</td>';
echo '<td>' . $donnees['Volume']. '</td>';
if ($donnees['Prix']!=0){
echo '<td>' . $donnees['Prix']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA']!=0){
echo '<td>' . $donnees['CA']. '</td>';}else{echo '<td>ND</td>';}
if ($donnees['CA_Dinars']!=0){
echo '<td>' . $donnees['CA_Dinars']. '</td>';}else{echo '<td>ND</td>';}
$annee = $donnees['An'];
}
?>
</table>
<?php
}
}
}
}
}
}
}
?>
[/php]