<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Fred -- Fred</title>
</head>

<body>
<?php
require_once("../../config/constant.inc.php");
if(isset($_POST['v_action']))$v_action=($_POST['v_action']);else $v_action='';
if(isset($_REQUEST['s_annee']))$s_annee=$_REQUEST['s_annee']; else $s_annee=date('Y');
if(isset($_POST['s_type']))$s_type=($_POST['s_type']);else $s_type='';
 $server = 'localhost';
 $login = 'webbike';
 $password = 'honda';
 $base= 'webbike';
 $lannee = array(1 => '1999','2000','2001','2002','2003','2004','2005','2006','2007','2008','2009','2010','2011','2012','2013','2014','2015','2016','2017','2018','2019','2020','2021','2022','2023');
	
	mysql_connect( $server , MYSQLLOGIN,MYSQLPASSWORD) or erreur( 'Connexion au serveur de données impossible' ) ;
	
	$sql="SELECT DISTINCT Type FROM commande".ID_GARAGE." Group BY Type";
	$type=mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<BR>'.Connection::getConnection()->errorInfo());
	mysql_close();
?>
<table border=0 cellpadding=0 cellspacing=2>
	<tr>
		<td><form method=post action=Fred-request.php?v_action=showRes>
		<select width="100" name=s_annee value='$s_annee'>
				<?php for($k=0;$k<sizeof($lannee);$k++){ 
					if($s_annee==$lannee[$k]){
						echo '<option selected=selected>';
						echo $lannee[$k];
						continue;
						}
					echo '<option>'; 
					echo $lannee[$k];
					}
				?>
				</select></td>
		<?php
		//list deroulante type
		print"<td widht=50><b>Type: </b></td><td>";
		//$compagnie=$_SESSION['s_compagnie'];
		print "<select name='s_type'>";
		while($ligne0 = mysql_fetch_array($type)) {
			   print "<option>";
			   print $ligne0['Type'];
			}
			print"</select></td>";
		//fin list type
		?>
		<td><input name=form type=submit class=f-submit value=Submit></form></td>
	</tr>
</table><br><br>
<?php
if ($v_action='showRes'){
	mysql_connect( $server , $login , $password) or erreur( 'Connexion au serveur de données impossible' ) ;
	
	if(isset($_POST['s_annee']))$s_annee=$_POST['s_annee']; else $s_annee=date('Y');
	
		echo '<table bgcolor="#FFFFFF">';
		echo '<tr>';
		echo '<td bgcolor="#669999"><b>NoClient</b></td>';
		echo '<td bgcolor="#669999"><b>NoCommande</b></td>';
		echo '<td bgcolor="#669999"><b>Prix Multi</b></td>';
		echo '<td bgcolor="#669999"><b>MontantTotal</b></td>';
		echo '<td bgcolor="#669999"><b>Type</b></td>';
		echo '</tr>'."\n";
		
		if($s_type != '') { $cond .= "AND Type='$s_type' ORDER BY NoCLient ASC"; }
		//else $cond .= "AND Genre='F' ORDER BY NoCLient ASC";
			
		$request1="SELECT NoClient, NoCommande, Type, MontantTotal FROM commande".ID_GARAGE." WHERE DatePayement LIKE '%$s_annee%' AND Paye='O'";		
		$request1.=" $cond";
		
		$result1 = mysql_query($request1) or die('Erreur SQL !<br>'.$request1.'<BR>'.Connection::getConnection()->errorInfo());
		$nblignes1=mysql_num_rows($result1);
		$background=0;
				
	for ($i=0; $i < $nblignes1; $i++){		
		$ligne = mysql_fetch_assoc($result1);
		$nocmd= $ligne['NoCommande'];
		$req="SELECT SUM(Somme) FROM dbcash".ID_GARAGE." WHERE NoFacture = $nocmd";
		$MTot = mysql_query($req) or die('Erreur SQL !<br>'.$req.'<BR>'.Connection::getConnection()->errorInfo());
		$iTot= mysql_fetch_assoc($MTot);
		$Tot= $iTot['SUM(Somme)'];
		$nocli=$ligne['NoClient'];
				
		if ($Tot != $ligne['MontantTotal']){	
			$background++;
			if ($background%2) $l_hexa = "#E4E8E9";
			else $l_hexa = "#CCCCCC";
			echo '<tr bgcolor='.$l_hexa.'>';				
			echo '<td>'.$nocli.'</td>';
			echo '<td><a href="http://chg@192.168.1.2/webbike/default.php?NoCommande='.$nocmd.'&Type=4&Sous_Type=1&Etape=3&NoVisu=0" target=_new>'.$nocmd.'</a></td>';
			echo '<td>'.$Tot.'</td>';
			echo '<td>'.$ligne['MontantTotal'].'</td>';
			echo '<td>'.$ligne['Type'].'</td>';
			echo '</tr>';
			}
		}
	print '</tables>';
	mysql_close();
}
?>

</body>
</html>
