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

Version 0.9.7

Copyright (C) 2006-2007  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(); 
include_once("../inc/config.inc.php");
include_once("../inc/func_log.inc.php");
if (CheckURLLog(FALSE)==FALSE) header("Location: ../index.php");
if (CheckNivLog("9")==FALSE) header("Location: ../index.php");
include_once("../inc/fic_age.inc.php");
include_once("../inc/fic_cli.inc.php");
include_once("../inc/fic_ope.inc.php");
include_once("../inc/fic_tec.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"]);

// Variables Formulaire
$categorie = $_GET["cat"];
$pbm_cat=FALSE;
$retouridx=FALSE;

switch ($categorie)
{
	case "siege" :
		$titre = "MOT DE PASSE DU SIEGE";
		break;
	case "age" :
		$titre = "MOTS DE PASSE AGENCES";
		break;
	case "tec" :
		$titre = "MOTS DE PASSE TECHNICIENS";
		break;
	case "cli" :
		$titre = "MOTS DE PASSE CLIENTS";
		break;
	case "ope" :
		$titre = "MOTS DE PASSE OPERATEURS";
		break;
	default :
		$pbm_cat=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 - ESPACE PRIVE : Mot de Passe</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 divers -->
<script language="JavaScript" src="../jscript/divers.js"></script>

</head>
<body onLoad="metFocus();">

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

if ($pbm_cat==FALSE)
{
?>
	
	<p align="center"><span class="titrepage"><?PHP echo $titre; ?></span></p>
	<p align="center"><span class="annot_gras_it">Que souhaitez-vous faire ?</span></p>
	<form name="mdp_maj" method="post" action="mdp_enr.php?cat=<?PHP echo $categorie; ?>">
	<input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
	<?PHP
	switch ($categorie)
	{
		case "siege" :
			if (existe_cdg()==FALSE)
				$retouridx=TRUE;
			break;

		case "age" :
			if (nb_age_actives()>0)
			{
	?>
	<div align="center">
	Choisissez l'agence : 
	<select name="code" id="code">
	<?PHP
	// Création de la liste des agences ouvertes
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rs = mysql_query("SELECT * FROM ".TBAGE." WHERE `age_ouvert` = '1' ORDER BY age_nom");
	while ($resultat = mysql_fetch_array($rs)) 
	{
		extract($resultat);
		$txt_age = $age_nom." (".$age_code.")";
		echo '<option value="'.$age_code.'">'.$txt_age.'</option>';
	}
	mysql_free_result($rs);
	mysql_close($conn);
	?>
	</select>
	</div>
	<?PHP
			}
			else
				$retouridx=TRUE;
			break;

		case "tec" :
			if (nb_tec("")>0)
			{
	?>
	<div align="center">
	Choisissez le technicien : 
	<select name="code" id="code">
	<?PHP
	// Création de la liste des techniciens présents
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rs = mysql_query("SELECT * FROM ".TBTEC." WHERE `tec_out` = '0' ORDER BY tec_nom");
	while ($resultat = mysql_fetch_array($rs)) 
	{
		extract($resultat);
		$txt_tec = $tec_nom." ".$tec_prenom." (".$tec_code."), ";
		if (trim($tec_codeage)<>"")
			$txt_tec.="agence ".$tec_codeage;
		if (trim($tec_codedo)<>"")
			$txt_tec.="donneur d'ordres ".$tec_codedo;
		if (trim($tec_codest)<>"")
			$txt_tec.="sous-traitant ".$tec_codest;
		echo '<option value="'.$tec_code.'">'.$txt_tec.'</option>';
	}
	mysql_free_result($rs);
	mysql_close($conn);
	?>
	</select>
	</div>
	<?PHP
			}
			else
				$retouridx=TRUE;
			break;

		case "cli" :
			if (nb_cli("")>0)
			{
	?>
	<div align="center">
	Choisissez le client : 
	<select name="code" id="code">
	<?PHP
	// Création de la liste des clients
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rs = mysql_query("SELECT * FROM ".TBCLI." ORDER BY cli_ste,cli_nom");
	while ($resultat = mysql_fetch_array($rs)) 
	{
		extract($resultat);
		if ($cli_ste <> "")
			$txt_cli = $cli_ste." (".Retournecp_openId($cli_ville,FALSE).", ".Retourneville_openId($cli_ville,FALSE).") - ".$cli_code;
		else
			$txt_cli = $cli_nom." ".$cli_prenom." (".Retournecp_openId($cli_ville,FALSE).", ".Retourneville_openId($cli_ville,FALSE).") - ".$cli_code;
		echo '<option value="'.$cli_code.'">'.$txt_cli.'</option>';
	}
	mysql_free_result($rs);
	mysql_close($conn);
	?>
	</select>
	</div>
	<?PHP
			}
			else
				$retouridx=TRUE;
			break;

		case "ope" :
			if (nb_ope()>0)
			{
	?>
	<div align="center">
	Choisissez l'op&eacute;rateur : 
	<select name="code" id="code">
	<?PHP
	// Création de la liste des opérateurs présents
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rs = mysql_query("SELECT * FROM ".TBOPE." WHERE `ope_out` = '0' ORDER BY ope_nom");
	while ($resultat = mysql_fetch_array($rs)) 
	{
		extract($resultat);
		$txt_ope = $ope_nom." ".$ope_prenom." (".$ope_code.")";
		echo '<option value="'.$ope_code.'">'.$txt_ope.'</option>';
	}
	mysql_free_result($rs);
	mysql_close($conn);
	?>
	</select>
	</div>
	<?PHP
			}
			else
				$retouridx=TRUE;
			break;
	}

	if ($retouridx==FALSE)
	{
	?>
	<p align="center">
	<input name="RAZ" type="button" class="bton_fmarr_std" id="RAZ" value="Ne rien faire" onclick="javascript:; self.location.href=('index.php');">
	<input name="init" type="submit" class="bton_fmarr_std" id="init" value="R&eacute;initialiser">
	<?PHP
	if ($categorie<>"siege")
	{
	?>
	<input name="init" type="submit" class="bton_fmarr_std" id="init" value="D&eacute;sactiver">
	<input name="init" type="submit" class="bton_fmarr_std" id="init" value="R&eacute;activer">
	<br>
	<span class="annot_petit_it">(La d&eacute;sactivation  emp&ecirc;che la connexion, mais ne supprime pas la fiche) </span>
	<?PHP
	}
	?>
	</p>
	<?PHP
	}
	?>
	</form>
<?PHP
	if ($retouridx==TRUE)
	{
?>
	<script type="text/javascript">
	setTimeout("self.location.href=('index.php');",2000)
	</script>
	<p align="center" class="annot_std_it">Pas d'enregistrement...</p>
<?PHP
	}
}
else
{
?>
	<script type="text/javascript">
	setTimeout("self.location.href=('index.php');",2000)
	</script>
	<p align="center" class="annot_std_it">Cat&eacute;gorie inconnue...</p>
<?php 
}
include_once("pied.php")
?>
