0byt3m1n1
Path:
/
home
/
kassiope
/
www
/
administrer
/
[
Home
]
File: ventes.php
<?php $menu=1; 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"); $firstann = date('Y') - 5; $years1 = array(); for($i=0;$i<6;$i++) { $years1[] = $firstann+$i; } echo "<table width=\"100%\" border=\"0\" class=\"tablespace\">"; echo "<tr><th class=\"entete\" align=\"center\" colspan=\"2\">Résumé des ventes</th></tr>"; echo "<tr><td class=\"menu\" 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='dateselect'>"; echo "<b>DU</b>: "; //AFFICHE LES JOURS 1 echo "<select name=\"jour1\" class=\"input-small\">"; 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=\"input-small\">"; $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=\"input-small\">"; 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='dateselect'>"; echo "<b>AU</b>: "; //AFFICHE LES JOURS 2 echo "<select name=\"jour2\" class=\"input-small\">"; 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=\"input-small\">"; $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=\"input-small\">"; 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\">"; // AFFICHE LE STATUT CHOISI echo "Statut de la commande :"; echo "<select name=\"statut\" style=\"width:300px\">"; echo "<option value=\"0\">Commande initialisée</option>"; $sql_statut = "SELECT id, nom_".$_SESSION['langue']." FROM gaia_statut ORDER BY position"; $res_statut = mysql_query_override($sql_statut); while ($s = mysql_fetch_array_override($res_statut)) { echo "<option value=\"".$s['id']."\""; if ($s['id'] == vb($_GET['statut'])) { echo " selected";} echo ">".(stripslashes($s['nom_'.$_SESSION['langue'].'']))."</option>"; } echo "</select>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan=\"2\" align=\"center\" class=\"bouton\">"; 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)) { $gets = ''; foreach($_GET as $k => $v) : $gets .= '&'.$k.'='.$v; endforeach; echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" class=\"tablespace\">"; echo "<tr><th colspan=\"5\" class=\"entete\">Période du ".$_GET['jour1']."-".$_GET['mois1']."-".$_GET['an1']." au ".$_GET['jour2']."-".$_GET['mois2']."-".$_GET['an2']."</td>"; echo "<th colspan=\"5\" class=\"entete\"><a href=\"exportcom.php?1=1".$gets."\" style=\"font-size:12px; color:#fff\">Exporter</a></td></tr>"; $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 statut = '".$_GET['statut']."' ORDER BY o_timestamp"); $resultNum = mysql_num_rows_override($query); if($resultNum > 0) { echo "<tr bgcolor=\"#FFFFFF\">"; echo "<td class=\"menu\"><b>Action</b></td>"; echo "<td class=\"menu\"><b>Date</b></td>"; echo "<td align=\"center\" class=\"menu\"><b>Commande</b></td>"; echo "<td align=\"center\" class=\"menu\"><b>Facture</b></td>"; echo "<td class=\"menu\"><b>Email client</b></td>"; echo "<td align=\"center\" class=\"menu\"><b>HT</b></td>"; echo "<td align=\"center\" class=\"menu\"><b>TVA</b></td>"; echo "<td align=\"center\" class=\"menu\"><b>TTC</b></td>"; echo "<td align=\"center\" class=\"menu\"><b>Frais de port</b></td>"; echo "</tr>"; $totalVente = 0; $totalVente_ht = 0; $totalTransport = 0; $totalVente_tva = 0; while($result = mysql_fetch_array_override($query)) { $totalVente_ht += $result['montant_ht']; $totalVente_tva += $result['total_tva']; $totalVente += $result['montant']; $totalTransport += $result['cout_transport']; echo "<tr>"; echo "<td><a href=$wwwroot/administrer/commandes.php?id=".$result['id']."&mode=details><i class=\"icon-search icon-large\"></i></a></td>"; echo "<td>".return_date_fr($result['o_timestamp'])."</td>"; echo "<td align=\"center\">".$result['id']."</td>"; echo "<td align=\"center\">".($result['numero']>0?date('Ymd-').substr('000'.$result['numero'],-4,4):'-')."</td>"; echo "<td><a href=\"mailto:".$result['email']."\">".$result['email']."</a></td>"; echo "<td align=\"center\">".fprix($result['montant_ht'])." € HT</td>"; echo "<td align=\"center\">".fprix($result['total_tva'])." € TTC</td>"; echo "<td align=\"center\">".fprix($result['montant'])." € TTC</td>"; echo "<td align=\"center\">".fprix($result['cout_transport'])." € TTC</td>"; echo "</tr>"; } echo "<tr>"; echo "<td class=\"menu\"> </td>"; echo "<td colspan=\"4\" class=\"menu\">TOTAL</td>"; echo "<td align=\"center\" class=\"menu\"><strong>".fprix($totalVente_ht)." €</strong></td>"; echo "<td align=\"center\" class=\"menu\"><strong>".fprix($totalVente_tva)." €</strong></td>"; echo "<td align=\"center\" class=\"menu\"><strong>".fprix($totalVente)." €</strong></td>"; echo "<td align=\"center\" class=\"menu\"><strong>".$totalTransport." €</strong></td>"; echo "</tr>"; 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 { echo "<tr><td style= \"background:#fff\">Aucune commande pour cette période pour le statut demandé.</td></tr>"; } } else { echo "<tr><td style= \"background:#fff\">Date1 supérieure ou égale à date2, recommencer.</td></tr>"; } }else { echo "<tr><td style= \"background:#fff\">Date non valide, recommencer.</td></tr>"; } echo "</table>"; } include("modeles/bas.php"); ?>