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

Version 0.9.9

Copyright (C) 2006-2009  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

Web : http://smitst.homelinux.com
****************************************************************************************/

session_start(); 
if (!isset($_SESSION["lng"])) $_SESSION["lng"]="fr";
include_once("../lng/".$_SESSION["lng"].".inc.php"); // Paramètres de language
include_once("../inc/config.inc.php");
include_once("../inc/func_log.inc.php");
if (CheckURLLog(FALSE)==FALSE) header("Location: ../index.php");
if (CheckNivLog("5-9")==FALSE) header("Location: ../index.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_txt.inc.php");
Archivelog(@$_SESSION["code_log"]);

$td = strip_tags(trim($_GET['td']));
$coderech = strip_tags(trim($_GET['code']));
$is = strip_tags(trim($_GET['is']));

$pbm_tacc=FALSE;

if ($coderech <> "")
{
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech = "SELECT * FROM " .TBTACC. " WHERE tacc_code = '$coderech'";
	$rs = mysql_query($rech)or die(mysql_error());
	if (mysql_num_rows($rs) <> 0)
	{
		if ($row = mysql_fetch_array($rs)) 
			extract ($row);
	}
	else
		$pbm_tacc=TRUE;
	mysql_free_result($rs);
	mysql_close($conn);
}
else
{
	if ($td == "add")
	{
		$tacc_img = $is;
		$tacc_code = "";
		$tacc_desc = "";
	}
	else
		$pbm_tacc=TRUE;
}

switch ($td)
{
	case "add" :
		$titre = $titlein_tacc_maj_add;
		break;
	case "edit" :
		$titre = $titlein_tacc_maj_edit;
		break;
	case "del" :
		$titre = $titlein_tacc_maj_del;
		if ($tacc_delok==0)
			$pbm_tacc=TRUE;
		break;
	default :
		$pbm_tacc=TRUE;
		break;
}
?>
<!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 - <?PHP echo $title_esp_prive; ?> : <?PHP echo $title_tacc_maj; ?></title>

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

<!-- Feuille de style & Script pour le menu -->

<script language="JavaScript" src="../jscript/coolmenus/coolmenus4.js"></script>

<!-- Scripts Javascript pour fenêtres -->
<script language="JavaScript" src="../jscript/fen.js"></script>

<!-- Scripts Javascript pour contrôle de formulaire -->
<script	type="text/javascript" src="../jscript/vform/vform.js"></script>

<script language="javascript">
<!--
var tab1_champ=new Array(
	"nom:image ; format:txt ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_ico); ?> ; lmx:200 ; stok:frmok ; stbad:frmbad",
	"nom:code ; format:alphanum ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_code); ?> ; lmx:5 ; stok:frmok ; stbad:frmbad",
	"nom:desc; format:txt ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_lib); ?> ; lmx:50 ; stok:frmok ; stbad:frmbad");
//-->
</script>

<!-- Scripts Javascript pour alertes -->
<script language="JavaScript" src="../jscript/alertes.js"></script>

<!-- Scripts Javascript divers -->
<script language="JavaScript" src="../jscript/divers.js"></script>

</head>

<?PHP if ($td == "del"){ ?>
<body onload="warndel();metReadonly();">
<?PHP } else { ?>
<body onLoad="metFocus();">
<?PHP }
include_once("../inc/entete.inc.php");

if ($pbm_tacc==FALSE)
{
?>
<p align="center"> <span class="titrepage"><?PHP echo $titre ?></span></p>
<table width="100%"  border="0">
  <tr>
	<td width="33%"><strong><em><a href="tacc_lst.php"><?PHP echo $txt_lnk_ret_liste; ?></a></em></strong></td>
	<td width="33%"align="center" class="annot_petit_it">
	<?PHP if ($td<>"del")
		echo '(<img src="../img/oblig.png" align="absmiddle" alt="'.$alt_chp_oblig.'"> : '.$txt_div_saisoblg.')';
	else
		echo '&nbsp;';
	?>
	</td>
	<td width="33%">&nbsp;</td>
  </tr>
</table>
<form name="tacc_maj" method="post" action="tacc_enr.php" onSubmit="javascript:; return (VForm(this,tab1_champ,'','<?PHP echo $_SESSION["lng"]; ?>'));">
<input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
<input name="td" type="hidden" id="td" value="<?PHP echo $td ?>">
    <table width="100%"  border="0">
      <tr>
        <td width="10%" class="rubfrm" id="f_img" align="right"><?PHP echo $txt_chp_ico; ?></td>
	  	<td>
		<input name="image" type="hidden" id="image" value="<?PHP echo $tacc_img ?>">
      <?PHP 
	  	if (($td == "add")  OR ($td == "edit"))
	  	{ 
			if ($tacc_img <> "") 
			{ 
		?>
			<img src="<?PHP echo $tacc_img ?>" border="0" align="absmiddle">
		<?PHP 
			} 
			else 
			{ 
		?>
			<img src="../img/vide.png" align="absmiddle"> 
			<a href="icotacc_lst.php"><?PHP echo $txt_div_chxico; ?></a> <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
      		<span class="annot_std_it"><?PHP echo $txt_div_impprem; ?></span> 
        <?PHP 
			} 
	  	} 
		else 
		{ 
	  ?>
		<img src="<?PHP echo $tacc_img ?>" border="0" align="absmiddle">
      <?PHP 
	  	} 
	  ?>
		</td>
      </tr>
      <tr>
        <td width="10%" class="rubfrm" id="f_code" align="right"><?PHP echo $txt_chp_code; ?></td>
		<td width="47%">
      <?PHP if ($td == "add") { ?>
        <input name="code" type="text" id="code" value="<?PHP echo $tacc_code ?>" size="5" maxlength="5">
        <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
      <?PHP } else { ?>
        <input name="code" type="text" id="code" value="<?PHP echo $tacc_code ?>" size="5" maxlength="5" readonly="1">
      <?PHP } ?>
	  </td>
      </tr>
      <tr>
        <td width="10%" class="rubfrm" id="f_desc" align="right"><?PHP echo $txt_chp_lib; ?></td>
        <td><input name="desc" type="text" id="desc" value="<?PHP echo htmlspecialchars($tacc_desc) ?>" size="50">
        <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"></td>
      </tr>
    </table>
  <p align="center">
    <?PHP if (($td == "add") OR ($td == "edit")) { ?>
    <input name="RAZ" type="reset" class="bton_std" id="RAZ" value="<?PHP echo $but_reinit; ?>">
    <input name="submit" type="submit" class="bton_std" id="submit" value="<?PHP echo $but_enr; ?>">
    <?PHP } ?>
    <?PHP if ($td == "del") { ?>
    <input name="del" type="submit" class="bton_std" id="del" value="<?PHP echo $but_del; ?>">
    <?PHP } ?>
  </p>
</form>
<?PHP
}
else
	aff_ret_pbm_auto("tacc_lst.php",2000);
include_once("pied.php");
?>
