<?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
****************************************************************************************/

session_start(); 
?>
<?php if ((@$HTTP_SESSION_VARS["etat_log"] <> "connecte") or ((@$HTTP_SESSION_VARS["niv_log"] <> 9) AND (@$HTTP_SESSION_VARS["niv_log"] <> 5))) header("Location: ../index.php") ?>
<?php include ("../inc/config.inc.php") ?>
<?php include ("../inc/func.inc.php") ?>
<?php include ("../inc/func_log.inc.php") ?>
<?PHP
	Archivelog(@$HTTP_SESSION_VARS["code_log"]);
?>
<?php
	$dateheuref = date("d-m-Y H:i:s");
	$datef = date ("d-m-Y");
	$dateheurea = date("Y-m-d H:i:s");
	$datea = date ("Y-m-d");

	$titre = "";
	
	$typdde = strip_tags(trim($_GET['typ']));
	$coderech = strip_tags(trim($_GET['code']));
	$is = strip_tags(trim($_GET['is']));
	
	if ($coderech <> "")
	{
		if ($typdde == "del")
		{
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
			$rech = "SELECT * FROM " .TBSTA. " WHERE statut_code = '$coderech'";
			$rs = mysql_query($rech)or die(mysql_error());
			 while ($row = mysql_fetch_array($rs)) 
			{
				extract ($row);
			}
			if (mysql_num_rows($rs) == 0)
			mysql_free_result($rs);
			mysql_close($conn);

			$titre = "SUPPRESSION STATUT";
		}

	}
	else
	{
		if ($typdde == "add")
		{
			$statut_img = $is;
			$statut_code = "";
			$statut_desc = "";

			$titre = "CREATION STATUT";
		}
	}
?>

<!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 : Fiche Statut</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>

</head>

<?PHP if ($typdde == "del"){ ?>
<body onload=warndel()>
<?PHP } else { ?>
<body>
<?PHP } ?>

<?php 
	include_once ("../inc/entete.php"); 
?>

<p align="center"> <span class="titrepage"><?PHP echo $titre ?></span></p>
<table width="100%"  border="0">
  <tr>
    <td width="33%"><strong><em><a href="statut_lst.php?ta=m">Retour &agrave; la liste</a></em></strong></td>
    <td width="33%" bgcolor="#FF0000"><div align="center"><span class="titrerubrique1">Descriptif</span></div></td>
    <td width="33%">&nbsp;</td>
  </tr>
</table>
<div align="center">
    <span class="annot_gras_it">(<img src="../img/oblig.gif" width="10" height="11"> : Saisie obligatoire)</span>
</div>
<form name="statut_maj" method="post" action="statut_enr.php" onsubmit="return v.exec()">
  <div align="center">
    <input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
    <input name="typdde" type="hidden" id="typdde" value="<?PHP echo $typdde ?>">
    <?PHP if ($typdde <> "add") { ?>
    <input name="code" type="hidden" id="code" value="<?PHP echo $statut_code ?>">
    <?PHP } ?>
    <br>
  </div>
  <div align="center">
    <table width="100%"  border="0">
      <tr>
        <td width="10%" class="tfvNormal" id="f_img">Ic&ocirc;ne</td>
		<input name="img" type="hidden" id="img" value="<?PHP echo $statut_img ?>">
      <?PHP 
	  	if ($typdde == "add") 
	  	{ 
	  ?>
	  	<td>
		<?PHP 
			if ($statut_img <> "") 
			{ 
		?>
				<img src="<?PHP echo $statut_img ?>" width="22" height="22" border="0" align="absmiddle">
		<?PHP 
			} 
			else 
			{ 
		?>
			<img src="../img/vide.png" width="22" height="22" align="absmiddle"> 
        <?PHP 
			} 
		?>
			<a href="ico_lst.php?ta=i&cs=<?PHP echo $statut_code ?>&ds=<?PHP echo $statut_desc ?>">Choisir Ic&ocirc;ne</a> <img src="../img/oblig.gif" width="10" height="11">
      		<span class="annot_std_it">(imp&eacute;ratif en 1er !)</span> 
      <?PHP 	  		
	  	} 
		else 
		{ 
	  ?>
	  	<td>
			<img src="<?PHP echo $statut_img ?>" width="22" height="22" border="0" align="absmiddle">
      <?PHP 
	  	} 
	  ?>
		</td>
      </tr>
      <tr>
        <td width="10%" class="tfvNormal" id="f_code">Code</td>
      <?PHP if ($typdde == "add") { ?>
        <td width="89%"><input name="code" type="text" id="code" value="<?PHP echo $statut_code ?>" size="5" maxlength="5">
        <img src="../img/oblig.gif" width="10" height="11"></td>
      <?PHP } else { ?>
      <td width="43%"><?PHP echo $statut_code."<br>"; ?>      
      <?PHP } ?>
      </tr>
      <tr>
        <td width="10%" class="tfvNormal" id="f_desc">Descriptif</td>
        <td><input name="desc" type="text" id="desc" value="<?PHP echo $statut_desc ?>" size="50" maxlength="50">
        <img src="../img/oblig.gif" width="10" height="11"></td>
      </tr>
    </table>
    </div>
  <p align="center">
    <?PHP if ($typdde == "add") { ?>
    <input name="RAZ" type="reset" id="RAZ" value="R&eacute;initialiser">
    <input name="submit" type="submit" id="submit" value="Enregistrer">
    <?PHP } ?>
    <?PHP if ($typdde == "del") { ?>
    <input name="del" type="submit" id="del" value="Supprimer">
    <?PHP } ?>
  </p>
</form>
<p>&nbsp;</p>

<script>
// form fields description structure
var a_fields = {
	'img':{'l':'Icône','r':true,'t':'f_img','mx' : 200},
	'code':{'l':'Code','r':true,'f':'alphanum','t':'f_code','mx':5},
	'desc':{'l':'Descriptif','r':true,'t':'f_desc','mx':50}
},

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

// validator constructor call
var v = new validator('statut_maj', a_fields, o_config);

</script>
<p></p>
<p>&nbsp;</p>
<?php 
	include_once ("pied.php")
?>
