<?php
/****************************************************************************************
SMI (Services Maintenance Interventions) est une gestion libre de maintenance et de SAV

Copyright (C) 2006  Sylvain FATOME

This program is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation; 
either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program
(in the directory docs); 
if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
Boston, MA  02110-1301, USA.

Contact : galawa@free.fr
****************************************************************************************/

include ("../inc/config.inc.php");
?>
<?php require ("../inc/func.inc.php") ?>
<?php require ("../inc/func_log.inc.php") ?>
<?php include ("../inc/fic.inc.php") ?>
<?PHP
	Archivelog(@$HTTP_SESSION_VARS["code_log"]);
?>
<?php
	$titre = "EDITION FICHE VIERGE DE RELEVE";

	$row = lit_enr_age(@$HTTP_SESSION_VARS["code_age"]);
	extract ($row);

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>SMI - ESPACE PRIVE : Relev&eacute;s - Etat Vierge</title>

<!-- Feuille de style pour les affichages courants -->
<link href="../inc/smi.css" rel="stylesheet" type="text/css">

<!-- Feuille de style & Script pour le menu -->
<link href="../inc/menu.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="../coolmenus/coolmenus4.js"></script>

<!-- Scripts Javascript pour validation des formulaires -->
<script language="JavaScript" src="../inc/validator.js"></script>

<!-- Scripts Javascript pour affichages -->
<script language="JavaScript" src="../inc/aff.js"></script>

<!-- Affichage nouvelle fenêtre pour impression -->
<script type="text/javascript">
	function lanceimp(page)
	{
	  window.open(page,'impression','width='+screen.width+' height='+screen.height);
	}
</script>

</head>

<body>

<?php 
	include_once ("../inc/entete.php"); 
 	if (strip_tags(trim(@$_POST["submit"])) <> "Valider") // On a validé
	{
		if ((@$_POST["tfr"] <> "") AND (@$_POST["client"] <> ""))
		{
			$urlimp = "rel_pdf_vierge.php?tfr=".@$_POST["tfr"]."&cc=".@$_POST["client"];
	?>
			<script type="text/javascript">
			lanceimp('<?PHP echo $urlimp; ?>');
			</script>
	<?PHP
		}
	}
?>

<p align="center"> <span class="titrepage"><?PHP echo $titre ?></span></p>
<form name="rel_vierge" id="rel_vierge" method="post" action="rel_vierge.php" onsubmit="return v.exec()">
	<table width="360"  border="0" cellspacing="0" cellpadding="0" align="center">
	<tr>
		<td class="tfvNormal" id="f_tfr">
			<div align="center">Choisissez l'&eacute;tat &aacute; imprimer</div>
		</td>
	</tr>
	<tr>
		<td>
			<div align="center">
			<select name="tfr" id="tfr">
			  <option value="" selected>-- Choisissez le type d'&eacute;tat --</option>
			  <option value="1">Relev&eacute; licence vierge</option>
			  <option value="2">Relev&eacute; Mat&eacute;riel vierge</option>
			</select>
			</div>
		</td>
	</tr>
	</table>
	<br>
	
	<?PHP
	// Création de la liste des clients de l'agence
	
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech ="SELECT * FROM ".TBCLI." WHERE `cli_prop` = '".@$HTTP_SESSION_VARS["code_age"]."' OR `cli_prop` IS NULL ORDER BY cli_ste, cli_nom";
	
	$rs = mysql_query($rech) or die(mysql_error());
	
	if (mysql_num_rows($rs) <> 0)
	{
	?>
		<table width="360"  border="0" cellspacing="0" cellpadding="0" align="center">
		<tr>
			<td class="tfvNormal" id="f_client">
				<div align="center">Choisissez un client</div>
			</td>
		</tr>
		<tr>
			<td>
				<div align="center">
				<select name="client" id="client">
				<?PHP
					echo "<option value=\"\" selected>-- Choisissez un client --</option>";

					while ($row = mysql_fetch_array($rs)) 
					{
						extract($row);
						
						if ((dep_in_zc($cli_dep,$age_zone)) == TRUE)
						{
							if ($cli_ste <> "")
								$texte = $cli_ste;
							else
								$texte = $cli_nom." ".$cli_prenom." (".$cli_code.")";
							echo "<option value=\"".$cli_code."\">".$texte."</option>";
						}
					}
				?>
				</select>
				</div>
			</td>
		</tr>
		</table>
		<p align="center">
		  <input type="submit" name="submit" id="submit" value="Valider">
	<?PHP
	}
	else
	{
		echo "<span class=\"annot_gras_it\">";
		echo "<div align=\"center\">";
		echo "Pas de clients sur cette agence";
		echo "</div>";
		echo "</span>";
	?>
		</p>
	<?PHP
	}
	
	mysql_free_result($rs);
	mysql_close($conn);
	?>
</p>
</form>
<p>&nbsp;</p>
	
<script>
// form fields description structure
var a_fields = {
	'tfr':{'l':'Type relevé','r':true,'t':'f_tfr'},
	'client':{'l':'Client','r':true,'t':'f_client'}
},

o_config = {
	'to_disable' : ['submit'],
	'alert' : 1
}

// validator constructor call
var v = new validator('rel_vierge', a_fields, o_config);
</script>
