<?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)) header("Location: ../index.php") ?>
<?php 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 include("../classes/fckeditor/fckeditor.php") ; ?>
<?PHP
	Archivelog(@$HTTP_SESSION_VARS["code_log"]);
?>
<?php
	$td = strip_tags(trim($_GET['typ']));
	$coderech = strip_tags(trim($_GET['code']));
	
	if ($coderech <> "")
	{
		// Récupération des informations périodicité
		$row = lit_enr_txt($coderech);
		extract ($row);

		if ($td == "add")
		{
			$txt_code = "(2)".$txt_code;
			$txt_code =substr($txt_code,0,19); // Le code ne doit pas dépasser 20 caractères
			$titre = "CREATION TEXTE TYPE";
		}

		if ($td == "edit")
			$titre = "MISE A JOUR TEXTE TYPE";

		if ($td == "del")
			$titre = "SUPPRESSION TEXTE TYPE";
	}
	else
	{
		if ($td == "add")
			$titre = "CREATION TEXTE TYPE";
	}
?>

<!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 Texte Type</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 affichages -->
<script language="JavaScript" src="../inc/aff.js"></script>

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

</head>

<body>

<?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="txt_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%"><div align="right"><strong><em></em> </strong></div></td>
  </tr>
</table>
<?PHP
if (($td == "add") OR ($td == "edit"))
{
?>
<div align="center">
    <span class="annot_gras_it">(<img src="../img/oblig.gif" width="10" height="11"> : Saisie obligatoire)</span>
</div>
<?PHP
}
?>

<form name="txt_maj" id="txt_maj" method="post" action="txt_enr.php" onsubmit="return v.exec()">
      <input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
      <input name="typdde" type="hidden" id="typdde" value="<?PHP echo $td ?>">

<table width="100%"  border="0">
    <tr>
      <td width="20%" class="tfvNormal" id="f_code"><div align="right">Code</div></td>
      <td>
      <?PHP if ($td == "add") { ?>
		  <input name="code" type="text" id="code" value="<?PHP echo $txt_code ?>" size="20" maxlength="20" onChange="javascript:this.value=this.value.toUpperCase();">
          <img src="../img/oblig.gif" width="10" height="11">
      <?PHP } else { ?>
		  <input name="code" type="text" id="code" value="<?PHP echo $txt_code ?>" size="20" maxlength="20" readonly="1">
      <?PHP } ?>
	  </td>
    </tr>
    <tr>
      <td width="20%" class="tfvNormal" id="f_desc"><div align="right">Descriptif</div></td>
      <td>
	  	<input name="desc" type="text" id="desc" value="<?PHP echo $txt_desc ?>" size="80" maxlength="200">
		<?PHP
		if (($td == "add") OR ($td == "edit"))
		{
		?>
		  	<img src="../img/oblig.gif" width="10" height="11">
		<?PHP
		}
		?>
	  </td>
    </tr>
    <tr>
      <td width="20%" class="tfvNormal" id="f_ent"><div align="right">Ent&ecirc;te</div></td>
      <td>
	  	<input name="ent" type="text" id="ent" value="<?PHP echo $txt_entete ?>" size="50" maxlength="50">
	  </td>
    </tr>
    <tr>
      <td width="20%" class="tfvNormal" id="f_texte"><div align="right">Texte</div></td>
      <td>
		<?PHP
		if (($td == "add") OR ($td == "edit"))
		{
			$sBasePath = $_SERVER['PHP_SELF'] ;
			$sBasePath = substr( $sBasePath, 0, strpos( $sBasePath, "admin" ) ).'classes/fckeditor/' ;
			
			$oFCKeditor = new FCKeditor('FCKeditor1') ;
			$oFCKeditor->BasePath	= $sBasePath;
			$oFCKeditor->Value		= $txt_texte;
			$oFCKeditor->Height 	= '400';
			$oFCKeditor->ToolbarSet = 'SMI';
			$oFCKeditor->Create();
		?>
        <img src="../img/oblig.gif" width="10" height="11" align="top"> 
		<?PHP
		}
		else
		{
		?>
			<textarea name="texte" cols="90" rows="10" readonly="readonly" id="texte"><?PHP echo $txt_texte ?></textarea>
		<?PHP
		}
		?>
	  </td>
    </tr>
  </table>
  <p align="center">
    <?PHP if (($td == "add") OR ($td == "edit")) { ?>
    <input name="RAZ" type="reset" id="RAZ" value="R&eacute;initialiser">
    <input name="submit" type="submit" id="submit" value="Enregistrer">
    <?PHP } ?>
    <?PHP if ($td == "del") { ?>
    <input name="del" type="submit" id="del" value="Supprimer">
    <input name="annul" type="button" id="annul" value="Annuler" onclick="javascript:; history.back();">
    <?PHP } ?>
  </p>
</form>
<p>&nbsp;</p>
<?PHP if ($td == "del") 
{
?>
	<script>
	warndelage();
	</script>
<?PHP
}
?>
	
<script>
// form fields description structure
var a_fields = {
	'code':{'l':'Code','r':true,'f':'alphanum','t':'f_code','mx':20},
	'desc':{'l':'Nom','r':true,'t':'f_desc','mx':100},
	'ent':{'l':'Entête','r':false,'t':'f_ent','mx':50}
},

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

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

</script>

<?php 
	include_once ("pied.php")
?>
