<?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");

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/fic_mt.inc.php");
include_once("../inc/fic_prm.inc.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_log.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_time.inc.php");
include_once("../inc/func_txt.inc.php");
Archivelog(@$_SESSION["code_log"]);

$td = strip_tags(trim(@$_GET['td']));
$codemt = strip_tags(trim(@$_GET['code']));

$pbm_mt=FALSE;

if ($codemt <> "")
{
	// Récupération des données du moyen de transport
	$row = lit_enr_mt($codemt);
	if (is_array($row))
		extract ($row);
	else
		$pbm_mt=TRUE;
}			
else
	if ($td<>"add")
	$pbm_mt=TRUE;

switch ($td)
{
	case "add" :
		$titre = "SAISIE MOYEN DE TRANSPORT";
		break;
	case "edit" :
		$titre = "EDITION MOYEN DE TRANSPORT";
		break;
	case "del" :
		$titre = "SUPPRESSION MOYEN DE TRANSPORT";
		break;
	default :
		$pbm_mt=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; ?> : Moyen de transport</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:code; format:txt ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_co); ?> ; lmx:20 ; stok:frmok ; stbad:frmbad",
	"nom:des; format:txt ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_lib); ?> ; lmx:50 ; stok:frmok ; stbad:frmbad",
	"nom:notes; format:txt ; req:N ; txt:<?PHP echo html_entity_decode($txt_chp_notes); ?> ; stok:frmok ; stbad:frmbad",
	"nom:coutk; format:reel_ns ; req:N ; txt:Coût kilométrique ; lmx:10 ; stok:frmok ; stbad:frmbad",
	"nom:coutf; format:reel_ns ; req:N ; txt:Coût forfaitaire ; lmx:10 ; stok:frmok ; stbad:frmbad",
	"nom:kmi; format:reel_ns ; req:Y ; txt:Kilométrage inclus ; lmx:10 ; stok:frmok ; stbad:frmbad",
	"nom:coutc; format:reel_ns ; req:Y ; txt:Coût complémentaire; stok:frmok ; stbad:frmbad",
	"nom:tpsdi; format:liste ; req:Y ; txt:temps déplacement inclus; stok:frmok ; stbad:frmbad");
//-->
</script>

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

<!-- Scripts Javascript sur les champs -->
<script language="JavaScript" src="../jscript/verif_field.js"></script>

<!-- Scripts Javascript sur les formulaires -->
<script language="JavaScript" src="../jscript/verif_form.js"></script>

<!-- Définition Javascript pour calendrier popup -->
  <!-- Feuille de Style -->
  <link rel="stylesheet" type="text/css" media="all" href="../jscript/jscal/skins/aqua/theme.css" title="Aqua" />

  <!-- Script Javascript Principal -->
  <script type="text/javascript" src="../jscript/jscal/calendar.js"></script>

  <!-- Choix du langage -->
  <script type="text/javascript" src="../jscript/jscal/lang/calendar-<?PHP echo $_SESSION["lng"]; ?>.js"></script>

  <!-- the following script defines the Calendar.setup helper function, which makes
       adding a calendar a matter of 1 or 2 lines of code. -->
  <script type="text/javascript" src="../jscript/jscal/calendar-setup.js"></script>
<!-- Fin de la définition Javascript pour calendrier popup -->

</head>

<body onLoad="<?PHP if ($mt_coutk>0) echo "verif_interne('1');"; else echo "verif_externe('1');"; ?>metFocus()">

<?PHP
include_once("../inc/entete.inc.php"); 
if ($pbm_mt==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="mt_lst.php"><?PHP echo $txt_lnk_ret_liste; ?></a></em></strong>
	</td>
	<td width="33%">
	<div id="oblig" align="center" class="annot_petit_it">(<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"> : <?PHP echo $txt_div_saisoblg; ?>)
	</div>
	</td>
	<td width="33%">&nbsp;</td>
</tr>
</table>
<form name="mt_maj" method="post" action="mt_enr.php" onSubmit="javascript:; return (verif_mt(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 ?>">
<input name="mt" type="hidden" id="mt" value="<?PHP if ($mt_coutk>0) echo "0"; else echo "1"; ?>">
<table width="100%"  border="0">
<tr>
	<td width="25%" class="rubfrm" id="f_code" align="right"><?PHP echo $txt_chp_code; ?></td>
	<td width="75%">
	<?PHP if ($td=="add") { ?>
	<input name="code" type="text" id="code" value="<?PHP echo $mt_code ?>" size="20" maxlength="20" 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 $mt_code ?>" size="20" readonly="readonly">
	<?PHP } ?>
	</td> 
</tr>
<tr>
	<td class="rubfrm" id="f_des" align="right"><?PHP echo $txt_chp_lib; ?></td>
	<td>
	<input name="des" type="text" id="des" value="<?PHP echo htmlspecialchars($mt_des); ?>" 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_notes" align="right">Notes</td>
	<td>
	<textarea name="notes" rows="5" id="notes"><?PHP echo htmlspecialchars($mt_notes) ?></textarea>
	</td>
</tr>
<tr>
	<td width="20%" class="rubfrm" id="f_valid" align="right">Actif ?</td>
	<td width="30%">
	<?PHP
	if (($td == "add") OR ($td=="edit")) {
	echo "<select name=\"valid\" size=\"1\" id=\"valid\">";
	echo "<option value=\"Oui\"";
	if ($mt_valid == TRUE)
	echo" selected";
	echo">".$sel_lst_oui."</option>";
	echo "<option value=\"Non\"";
	if ($mt_valid == FALSE)
	echo" selected";
	echo ">".$sel_lst_non."</option>";
	echo "</select>";
	?>
	<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	<?PHP } else { ?>
	<input name="valid" type="hidden" id="valid" value="<?PHP echo $mt_valid; ?>">
	<input name="nvalid" type="text" id="nvalid" value="<?PHP echo $non_oui[$mt_valid]; ?>">
	<?PHP } ?>
	</td> 
</tr>
<tr>
<td class="rubfrm" colspan="2" align="center">Type de moyen de transport</td>
</tr>
<tr>
	<td colspan="2">
	<table width="100%"  border="0">
	<tr>
		<td width="100%" align="center" colspan="4" class="annot_petit_it">(Cliquez sur le type de moyen de transport)</td>
	</tr>
	<tr>
		<td width="50%" align="center" colspan="2">
		<a href="#" onClick="javascript:;verif_interne('1');">Interne</a>
		<span id="chx1" style="display:none;"><img src="../img/ok.png" align="absmiddle"></span>
		</td>
		<td align="center" colspan="2">
		<a href="#" onClick="javascript:;verif_externe('1');">Sous-trait&eacute;</a>
		<span id="chx2" style="display:none;"><img src="../img/ok.png" align="absmiddle"></span>
		</td>
	</tr>
	<tr>
		<td width="20%" class="rubfrm" id="f_coutk" align="right">Co&ucirc;t kilom&eacute;trique</td>
		<td width="30%">
		<input name="coutk" type="text" id="coutk" value="<?PHP echo format_num($mt_coutk ,2)?>" size="10" maxlength="10" onChange="formatedeci(this.id,2);verif_interne('0');">
		<?PHP echo $lang['symbole_monnaie']; ?>
		 <span id="obl11" style="display:none;"><img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"></span><br />
		<span class="annot_petit_it">(La d&eacute;cimale doit &ecirc;tre '.' et pas la virgule)</span>
		</td> 
		<td width="20%" class="rubfrm" id="f_coutf" align="right">Co&ucirc;t forfaitaire</td>
		<td width="30%">
		<input name="coutf" type="text" id="coutf" value="<?PHP echo format_num($mt_coutf,2) ?>" size="10" maxlength="10" onChange="formatedeci(this.id,2);verif_externe('0');verif_coutf();">
		<?PHP echo $lang['symbole_monnaie'];
		echo ' / ';
		echo '<span class="annot_petit_it">';
		echo '<input type="checkbox" id="coutas" name="coutas" value="ok" onChange="verif_externe(\'0\');verif_coutas();"';
		if ($mt_coutas == TRUE)
			echo ' checked';
			
		if ($td=="del")
			echo ' disabled';
		echo '> A saisir';
		echo '</span>';
		?>
		 <span id="obl21" style="display:none;"><img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"></span><br />
		<span class="annot_petit_it">(La d&eacute;cimale doit &ecirc;tre '.' et pas la virgule)</span>
		</td> 
	</tr>
	<tr>
		<td width="50%" colspan="2">&nbsp;</td>
		<td width="20%" class="rubfrm" id="f_kmi" align="right">Kilom&eacute;trage inclus</td>
		<td width="30%">
		<input name="kmi" type="text" id="kmi" value="<?PHP echo format_num($mt_kmi,2) ?>" size="10" maxlength="10" onChange="formatedeci(this.id,2);verif_externe('0');verif_km();">
		km / 
		<?PHP
		echo '<span class="annot_petit_it">';
		echo '<input type="checkbox" id="kmill" name="kmill" value="ok" onChange="verif_externe(\'0\');verif_kmill();"';
		if ($mt_kmill == TRUE)
			echo ' checked';
			
		if ($td=="del")
			echo ' disabled';
		echo '> Illimit&eacute;';
		echo '</span>';
		?>
 		 <span id="obl22" style="display:none;"><img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"></span>
 		<br /><span class="annot_petit_it">(Pour le forfait ci-dessus)</span>
		</td> 
	</tr>
	<tr>
		<td width="50%" colspan="2">&nbsp;</td>
		<td width="20%" class="rubfrm" id="f_kms" align="right">Kilom&egrave;tre suppl.</td>
		<td width="30%">
		<input name="kms" type="text" id="kms" value="<?PHP echo format_num($mt_kms,2) ?>" size="10" maxlength="10" onChange="formatedeci(this.id,2);verif_externe('0');verif_km();">
		<?PHP echo $lang['symbole_monnaie']; ?>
		 <span id="obl23" style="display:none;"><img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"></span><br />
		<span class="annot_petit_it">(Pour le forfait ci-dessus)</span>
		</td> 
	</tr>
	</table>
	</td>
</tr>
<tr>
<td class="rubfrm" colspan="2" align="center">Calculs</td>
</tr>
<tr>
	<td colspan="2">
	<table width="100%"  border="0">
	<tr>
		<td width="20%" class="rubfrm" id="f_coutc" align="right">Co&ucirc;t compl&eacute;mentaire</td>
		<td width="30%">
		<input name="coutc" type="text" id="coutc" value="<?PHP echo format_num($mt_coutc ,2)?>" size="10" maxlength="10" onChange="formatedeci(this.id,2);">
		<?PHP echo $lang['symbole_monnaie']; ?> <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"><br />
		<span class="annot_petit_it">(La d&eacute;cimale doit &ecirc;tre '.' et pas la virgule)</span>
		</td> 
		<td width="20%" class="rubfrm" id="f_tpsdi" align="right">Temps d&eacute;placement inclus</td>
		<td width="30%">
		<?PHP
		if (($td == "add") OR ($td=="edit")) {
		echo "<select name=\"tpsdi\" size=\"1\" id=\"tpsdi\">";
		echo "<option value=\"Oui\"";
		if ($mt_tpsdi == TRUE)
		echo" selected";
		echo">".$sel_lst_oui."</option>";
		echo "<option value=\"Non\"";
		if ($mt_tpsdi == FALSE)
		echo" selected";
		echo ">".$sel_lst_non."</option>";
		echo "</select>";
		?>
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		<br />
		<span class="annot_petit_it">(Si 'Non', le co&ucirc;t salarial du d&eacute;placement sera d&eacute;compt&eacute; dans le prix de revient)</span>
		<?PHP } else { ?>
		<input name="tpsdi" type="hidden" id="tpsdi" value="<?PHP echo $mt_tpsdi; ?>">
		<input name="ntpsdi" type="text" id="ntpsdi" value="<?PHP echo $non_oui[$mt_tpsdi]; ?>">
		<?PHP } ?>
		</td> 
	</tr>
	</table>
	</td>
</tr>
</table>
<p align="center">
<?PHP if ($td == "add") { ?>
<input name="RAZ" type="reset" class="bton_std" id="RAZ" value="<?PHP echo $but_reinit; ?>">
<input name="enr" type="submit" class="bton_std" id="enr" value="<?PHP echo $but_add; ?>">
<input name="annul" type="button" class="bton_std" id="annul" value="<?PHP echo $but_cancel; ?>" onclick="javascript:; self.close('fscomp');">
<?PHP } if ($td == "edit") { ?>
<input name="mod" type="submit" class="bton_std" id="mod" value="<?PHP echo $but_valider; ?>">
<input name="annul" type="button" class="bton_std" id="annul" value="<?PHP echo $but_cancel; ?>" onclick="javascript:; self.close('fscomp');">
<?PHP } if ($td == "del") { ?>
<input name="del" type="submit" class="bton_std" id="del" value="<?PHP echo $but_del; ?>">
<input name="annul" type="button" class="bton_std" id="annul" value="<?PHP echo $but_cancel; ?>" onclick="javascript:; self.close('fscomp');">
<?PHP } ?>
</p>
</form>
<?PHP
}
else
	aff_ret_pbm_auto("index.php",2000);
include_once("pied.php");
?>
