0byt3m1n1
Path:
/
home
/
k
/
a
/
s
/
kassiope
/
www
/
administrer
/
[
Home
]
File: ventes_affiliation.php
<?php include("../configuration.inc.php"); necessite_identification(); necessite_priv("admin"); $DOC_TITLE = "Rapport des ventes"; include("modeles/haut.php"); $nowDay = date("d"); $nowMonth = date("m"); $nowYear = date("Y"); if ($nowMonth=="1") $nowMonth = "Janvier"; if ($nowMonth=="2") $nowMonth = "Février"; if ($nowMonth=="3") $nowMonth = "Mars"; if ($nowMonth=="4") $nowMonth = "Avril"; if ($nowMonth=="5") $nowMonth = "Mai"; if ($nowMonth=="6") $nowMonth = "Juin"; if ($nowMonth=="7") $nowMonth = "Juillet"; if ($nowMonth=="8") $nowMonth = "Août"; if ($nowMonth=="9") $nowMonth = "Septembre"; if ($nowMonth=="10") $nowMonth= "Octobre"; if ($nowMonth=="11") $nowMonth= "Novembre"; if ($nowMonth=="12") $nowMonth= "Décembre"; if(isset($_GET['mois1']) and $_GET['mois1'] =="Janvier") $_GET['mois1']=1; if(isset($_GET['mois1']) and $_GET['mois1'] =="Février") $_GET['mois1']=2; if(isset($_GET['mois1']) and $_GET['mois1'] =="Mars") $_GET['mois1']=3; if(isset($_GET['mois1']) and $_GET['mois1'] =="Avril") $_GET['mois1']=4; if(isset($_GET['mois1']) and $_GET['mois1'] =="Mai") $_GET['mois1']=5; if(isset($_GET['mois1']) and $_GET['mois1'] =="Juin") $_GET['mois1']=6; if(isset($_GET['mois1']) and $_GET['mois1'] =="Juillet") $_GET['mois1']=7; if(isset($_GET['mois1']) and $_GET['mois1'] =="Août") $_GET['mois1']=8; if(isset($_GET['mois1']) and $_GET['mois1'] =="Septembre") $_GET['mois1']=9; if(isset($_GET['mois1']) and $_GET['mois1'] =="Octobre") $_GET['mois1']=10; if(isset($_GET['mois1']) and $_GET['mois1'] =="Novembre") $_GET['mois1']=11; if(isset($_GET['mois1']) and $_GET['mois1'] =="Décembre") $_GET['mois1']=12; if(isset($_GET['mois2']) and $_GET['mois2'] =="Janvier") $_GET['mois2']=1; if(isset($_GET['mois2']) and $_GET['mois2'] =="Février") $_GET['mois2']=2; if(isset($_GET['mois2']) and $_GET['mois2'] =="Mars") $_GET['mois2']=3; if(isset($_GET['mois2']) and $_GET['mois2'] =="Avril") $_GET['mois2']=4; if(isset($_GET['mois2']) and $_GET['mois2'] =="Mai") $_GET['mois2']=5; if(isset($_GET['mois2']) and $_GET['mois2'] =="Juin") $_GET['mois2']=6; if(isset($_GET['mois2']) and $_GET['mois2'] =="Juillet") $_GET['mois2']=7; if(isset($_GET['mois2']) and $_GET['mois2'] =="Août") $_GET['mois2']=8; if(isset($_GET['mois2']) and $_GET['mois2'] =="Septembre") $_GET['mois2']=9; if(isset($_GET['mois2']) and $_GET['mois2'] =="Octobre") $_GET['mois2']=10; if(isset($_GET['mois2']) and $_GET['mois2'] =="Novembre") $_GET['mois2']=11; if(isset($_GET['mois2']) and $_GET['mois2'] =="Décembre") $_GET['mois2']=12; $days1 = array("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"); $months1 = array("1"=>"Janvier","2"=>"Février","3"=>"Mars","4"=>"Avril","5"=>"Mai","6"=>"Juin","7"=>"Juillet","8"=>"Août","9"=>"Septembre","10"=>"Octobre","11"=>"Novembre","12"=>"Décembre"); $years1 = array("2005","2006","2007","2008","2009","2010"); echo "<table width=\"760\" align=\"center\" border=\"0\" class=\"tablespace\">"; echo "<tr><td class=\"entete\" align=\"center\" colspan=\"2\">RESUME DES VENTES</td></tr>"; echo "<tr><td class=\"label\" align=\"center\" colspan=\"2\">Aujourd'hui : ".date("d M Y")."</td></tr>"; echo "<form method=\"GET\" action=\"".$_SERVER['PHP_SELF']."\">"; echo "<tr>"; echo "<td class=\"label\">"; echo "<b>DU</b>: "; //AFFICHE LES JOURS 1 echo "<select name=\"jour1\" class=\"formulaire1\">"; for ($c=0; $c<= count($days1)-1; $c++) { $a=$c+1; if(isset($_GET['jour1'])) { if($days1[$c]== $_GET['jour1']) $sel1 = "selected"; else $sel1=""; } else { if($days1[$c]==$nowDay) $sel1 = "selected"; else $sel1=""; } echo "<option value=$a $sel1>$days1[$c]</option>"; } echo "</select>"; // AFFICHE LA LISTE DES MOIS 1 echo "<select name=\"mois1\" class=\"formulaire1\">"; $keys = array_keys($months1); for ($x1=1; $x1 <= count($months1); $x1++) { $p=$x1-1; if(isset($_GET['mois1'])) { if($keys[$p]== $_GET['mois1']) $sel2 = "selected"; else $sel2=""; } else { if($months1[$x1]==$nowMonth) $sel2 = "selected"; else $sel2=""; } echo "<option value=".$keys[$p]." $sel2>$months1[$x1]</option>"; } echo "</select>"; // AFFICHE LA LISTE DES ANNéES 1 echo "<select name=\"an1\" class=\"formulaire1\">"; for ($x3=0; $x3 <= count($years1)-1; $x3++) { if(isset($_GET['an1'])) { if($years1[$x3]== $_GET['an1']) $sel3 = "selected"; else $sel3=""; } else { if($years1[$x3]==$nowYear) $sel3 = "selected"; else $sel3=""; } echo "<option value=$years1[$x3] $sel3>$years1[$x3]</option>"; } echo "</select>"; echo "</td>"; echo "<td class=\"label\">"; echo "<b>AU</b>: "; //AFFICHE LES JOURS 2 echo "<select name=\"jour2\" class=\"formulaire1\">"; for ($c=0; $c<= count($days1)-1; $c++) { $a=$c+1; if(isset($_GET['jour2'])) { if($days1[$c]== $_GET['jour2']) $sel1 = "selected"; else $sel1=""; } else { if($days1[$c]==$nowDay) $sel1 = "selected"; else $sel1=""; } echo "<option value=$a $sel1>$days1[$c]</option>"; } echo "</select>"; // AFFICHE LA LISTE DES MOIS 2 echo "<select name=\"mois2\" class=\"formulaire1\">"; $keys = array_keys($months1); for ($x=1; $x <= count($months1); $x++) { $p=$x-1; if(isset($_GET['mois2'])) { if($keys[$p]== $_GET['mois2']) $sel2 = "selected"; else $sel2=""; } else { if($months1[$x]==$nowMonth) $sel2 = "selected"; else $sel2=""; } echo "<option value=$keys[$p] $sel2>$months1[$x]</option>"; } echo "</select>"; // AFFICHE LA LISTE DES ANNéES 2 echo "<select name=\"an2\" class=\"formulaire1\">"; for ($x=0; $x <= count($years1)-1; $x++) { if(isset($_GET['an2'])) { if($years1[$x]== $_GET['an2']) $sel3 = "selected"; else $sel3=""; } else { $n=$x3+1; if($years1[$x]==$nowYear) $sel3 = "selected"; else $sel3=""; } echo "<option $sel3>$years1[$x]</option>"; } echo "</select>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan=\"2\" align=\"center\" class=\"label\">"; // AFFICHE LE STATUT CHOISI echo "Statut de la commande :"; echo "<select name=\"id_utilisateur\" class=\"formulaire1\">"; echo "<option value=\"0\">Choisir votre affilié :</option>"; $sql_affilie = "SELECT id_utilisateur, email, societe, prenom, nom_famille FROM gaia_utilisateurs WHERE priv = 'affi' ORDER BY societe, nom_famille"; $res_affilie = mysql_query_override($sql_affilie); while ($u = mysql_fetch_array_override($res_affilie)) { echo "<option value=\"".$u['id_utilisateur']."\""; if ($u['id_utilisateur'] == vb($_GET['id_utilisateur'])) { echo " selected";} echo ">".html_entity_decode($u['societe'])." - ".html_entity_decode($u['email'])." (".html_entity_decode($u['prenom'])." ".html_entity_decode($u['nom_famille']).")</option>"; } echo "</select>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan=\"2\" align=\"center\">"; echo "<input type=\"submit\" name=\"Submit\" value=\"CALCULER\" class=\"bouton\">"; echo "</td>"; echo "</tr>"; echo "</form>"; echo "</table>"; /////////////////////////////////// ///////////// PROCESS ///////////// /////////////////////////////////// if(isset($_GET['jour1']) or isset($dateAdded1)) { $control1 = checkdate($_GET['mois1'],$_GET['jour1'],$_GET['an1']); $control2 = checkdate($_GET['mois2'],$_GET['jour2'],$_GET['an2']); if($control1 == true and $control2 == true) { $control11 = mktime(0,0,0,$_GET['mois1'],$_GET['jour1'],$_GET['an1']); $control21 = mktime(0,0,0,$_GET['mois2'],$_GET['jour2'],$_GET['an2']); if($control21 >= $control11) { $dateAdded1 = "".$_GET['an1']."-".$_GET['mois1']."-".$_GET['jour1']." 00:00:00"; $dateAdded2 = "".$_GET['an2']."-".$_GET['mois2']."-".$_GET['jour2']." 00:00:00"; $query = mysql_query_override("SELECT * FROM gaia_commandes WHERE TO_DAYS(o_timestamp) >= TO_DAYS('".$dateAdded1."') AND TO_DAYS(o_timestamp) <= TO_DAYS('".$dateAdded2."') AND id_utilisateur = '".intval($_GET['id_utilisateur'])."' ORDER BY o_timestamp"); $resultNum = mysql_num_rows_override($query); if($resultNum > 0) { echo "<p align=\"center\" class=\"label\">Période du ".$_GET['jour1']."-".$_GET['mois1']."-".$_GET['an1']." au ".$_GET['jour2']."-".$_GET['mois2']."-".$_GET['an2']."</p>"; echo "<table align=\"center\" border=\"0\" width=\"760\" class=\"tablespace\">"; echo "<tr bgcolor=\"#FFFFFF\">"; echo "<td align=\"center\" class=\"label\"><b>Date</b></td>"; echo "<td align=\"center\" class=\"label\"><b>Commande</b></td>"; echo "<td align=\"center\" class=\"label\"><b>Email client</b></td>"; echo "<td align=\"center\" class=\"label\"><b>Montant</b></td>"; echo "<td align=\"center\" class=\"label\" align=\"center\"><b>Commission</b></td>"; echo "<td align=\"center\" class=\"label\" align=\"center\"><b>Etat</b></td>"; echo "</tr>"; $totalVente = 0; $totalTransport = 0; while($result = mysql_fetch_array_override($query)) { $totalVente += $result['montant']; $totalTransport += $result['cout_transport']; if($c=="#E8E8E8") {$c="#F6F6EB";} else {$c="#E8E8E8";} echo "<tr bgcolor=\"".$c."\">"; echo "<td class=\"normal\">".return_date_fr($result['o_timestamp'])."</td>"; echo "<td class=\"normal\" align=\"center\">".$result['id']."</td>"; echo "<td class=\"normal\" align=\"center\"><a href=\"mailto:".$result['email']."\">".$result['email']."</a></td>"; echo "<td class=\"normal\" align=\"center\">".fprix($result['montant'])." € TTC</td>"; echo "<td class=\"normal\" align=\"center\">".fprix($result['montant_affilie'])." €</td>"; echo "<td class=\"normal\" align=\"center\">"; echo (empty($result['statut_affilie'])) ? "paiement en attente" : "paiement effectué"; echo "</td>"; echo "<td class=\"normal\"><a href=$wwwroot/administrer/commandes.php?id=".$result['id']."&mode=details>Voir</a></td>"; echo "</tr>"; } echo "<tr>"; echo "<td colspan=\"3\" class=\"label\">TOTAUX</td>"; echo "<td class=\"label\">".fprix($totalVente)." €</td>"; echo "<td class=\"label\">".$totalTransport." €</td>"; echo "<td class=\"label\"> </td>"; echo "</tr>"; echo "</table>"; if (!empty($_GET['statut'])) { $sRequete = "SELECT id, nom_".$_SESSION['langue']." FROM gaia_statut WHERE id = '".$_GET['statut']."'"; $sQuery = mysql_query_override($sRequete); $sObjet = mysql_fetch_array_override($sQuery); echo "<p align=\"center\" class=\"label\">Statut demandé : ". $sObjet['nom_'.$_SESSION['langue'].'']."</p>"; } else { } } else { echo "<p align=\"center\" class=\"label\">"; echo "DU : ".$_GET['jour1']."-".$_GET['mois1']."-".$_GET['an1'].""; echo " "; echo "AU : ".$_GET['jour2']."-".$_GET['mois2']."-".$_GET['an2'].""; echo "</p>"; echo "<div align=\"center\" class=\"normal\">Aucune commande pour cette période pour le statut demandé.</div>"; } } else { echo "<p align=\"center\" class=\"label\">"; echo "DU : ".$_GET['jour1']."-".$_GET['mois1']."-".$_GET['an1'].""; echo " "; echo "AU : ".$_GET['jour2']."-".$_GET['mois2']."-".$_GET['an2'].""; echo "</p>"; echo "<div align=\"center\" class=\"normal\">Date1 supérieure ou égale à date2, recommencer.</div>"; } }else { echo "<p align=\"center\" class=\"label\">"; echo "DU : ".$_GET['jour1']."-".$_GET['mois1']."-".$_GET['an1'].""; echo " "; echo "AU : ".$_GET['jour2']."-".$_GET['mois2']."-".$_GET['an2'].""; echo "</p>"; echo "<div align=\"center\" class=\"normal\">Date non valide, recommencer.</div>"; } } include("modeles/bas.php"); ?>