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

// Vérification des tentatives de hack
$pos=strpos($_SERVER['PHP_SELF'],"inc.php");
if ($pos===FALSE)
	$ok_inc=TRUE;
else
	$ok_inc=FALSE;
if ($ok_inc==FALSE) header("Location: ../index.php");

include_once("../inc/fic_taxes.inc.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']));

$pbm_tva=FALSE;
$tvamod=TRUE;
$tvadesact=TRUE;
	
if ($coderech <> "")
{
	$row = lit_enr_tva($coderech,TRUE);
	if (is_array($row))
	{
		extract ($row);
		$tvamod=tva_modifiable($coderech,TRUE);
		$tvadesact=tva_desactivable($coderech,TRUE);
	}
	else
		$pbm_tva=TRUE;
}
else
{
	if ($td<>"add")	$pbm_tva=TRUE;
}

if ($pbm_tva==FALSE)
{
	switch ($td)
	{
		case "add" :
			$titre = "CREATION TVA";
			$tva_actif=TRUE;
			break;
		case "edit" :
			$titre = "MODIFICATION TVA";
			break;
		case "del" :
			$titre = "SUPPRESSION TVA";
			break;
		default :
			$pbm_tva=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; ?> : Fiche TVA</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 sur les champs -->
<script language="JavaScript" src="../jscript/verif_field.js"></script>

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

<script language="javascript">
<!--
var tab_champ=new Array(
	"nom:code ; format:alphanum ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_code); ?> ; lmn:1 ; lmx:10; stok:frmok ; stbad:frmbad",
	"nom:desc ; format:txt ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_lib); ?>; lmn:1 ; lmx:40; stok:frmok ; stbad:frmbad",
	"nom:taux ; format:reel_ns ; req:Y ; txt:Taux; lmn:1 ; lmx:10; 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_tva==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="tva_lst.php"><?PHP echo $txt_lnk_ret_liste; ?></a></em></strong></td>
	<td width="33%"align="center" class="annot_petit_it">(<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"> : <?PHP echo $txt_div_saisoblg; ?>)</td>
	<td width="33%">&nbsp;</td>
  </tr>
</table>
<form name="tva_maj" method="post" action="tva_enr.php" onSubmit="javascript:; return (VForm(this,tab_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_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 $tva_code ?>" size="10" onChange="javascript:this.value=this.value.toUpperCase();">
	<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 $tva_code ?>" size="10" readonly="1">
	</td>
	<?PHP } ?>
</tr>
<tr>
	<td 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($tva_desc); ?>" size="50" onChange="javascript:this.value=this.value.toUpperCase();">
	<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"></td>
</tr>
<tr>
	<td class="rubfrm" id="f_taux" align="right">Taux</td>
	<td>
	<input name="taux" type="text" id="taux" style="text-align:right" value="<?PHP echo $tva_tx; ?>" size="10" onChange="formatedeci(this.id,2);" <?PHP if ($tvamod==FALSE) echo "readonly=\"readonly\"" ?>>%
	<?PHP if ($tvamod==TRUE) { ?>
	<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	<?PHP } else { ?>
	<br><span class="annot_petit_it">Vous ne pouvez pas modifier le taux d'une TVA d&eacute;j&agrave; utilis&eacute;e dans une intervention ou un contrat sign&eacute;.
	<br>Il vaux mieux utiliser l'option "R&eacute;affecter"</span>
	<?PHP } ?>
	</td>
</tr>
<tr>
	<td class="rubfrm" id="f_actif" align="right"><?PHP echo $txt_chp_actif; ?></td>
	<td>
	<?PHP 
	if ((($td == "add") OR ($td == "edit")) AND ($tvadesact==TRUE))
	{ 
		echo "<select name=\"actif\" size=\"1\" id=\"actif\">";
		echo "<option value=\"Oui\"";
		if ($tva_actif==TRUE) echo " selected";
		echo ">".$sel_lst_oui."</option>";
		echo "<option value=\"Non\"";
		if ($tva_actif==FALSE) echo " selected";
		echo ">".$sel_lst_non."</option>";
		echo "</select>";
	?>
	<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	<?PHP 
	}
	
	if (($td == "del") OR ($td == "view") OR ($tvadesact==FALSE))
	{ 
	if ($tva_actif == TRUE)
	{
	?>
	<input name="actif" type="text" id="actif" value="Oui" size="3" maxlength="3" readonly="readonly">
	<?PHP
	}
	else
	{
	?>
	<input name="actif" type="text" id="actif" value="Non" size="3" maxlength="3" readonly="readonly">
	<?PHP
	}

	if ($tvadesact==FALSE) { ?>
	<br><span class="annot_petit_it">Vous ne pouvez pas d&eacute;sactiver une TVA d&eacute;j&agrave; utilis&eacute;e dans une intervention ou un contrat non clôts.</span>
	<?PHP }
	}
	?>
	</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("tva_lst.php",2000);
include_once("pied.php");
?>
