<?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("10-11")==FALSE) header("Location: ../index.php");
include_once("../inc/fic_fici.inc.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_time.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/lst.inc.php");
Archivelog(@$_SESSION["code_log"]);
$pbm_conf=FALSE;
if (!exist_logo("cge")) $pbm_conf=TRUE;
if (!exist_logo(@$_SESSION["code_st"])) $pbm_conf=TRUE;
if (!existe_cdg()) $pbm_conf=TRUE;
$tx="m";
?>
<!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 : Index Donneur d'Ordres</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>

<?php
if ($pbm_conf==FALSE)
{
include_once("../inc/entete.inc.php"); 
?>
<p align="center"><span class="titrepage">VOTRE TABLEAU DE BORD</span><br></p>
<br>
<div id="menu_ageidx" class="menu_ongletfull">
<a class="ongleti" id="m1" href="javascript:;" onclick="set_mnu_ageidx(this.id);" onFocus="this.blur();">Bons de travail non clôts</a>
</div>
<br>

<div id="detailm1" style="display:none">
<?PHP
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);

	$rech = cree_strrechlstot($niv_urgence);
	if(!stristr($rech,"WHERE "))
		$rech .= " WHERE ".TBOT.".ot_codest='".@$_SESSION["code_st"]."' AND ".TBOT.".ot_codestatut <> 'CLOT'";
	else
		$rech .= " AND ".TBOT.".ot_codest='".@$_SESSION["code_st"]."' AND ".TBOT.".ot_codestatut <> 'CLOT'";
		
	$rech .= "ORDER BY ".TBOT.".ot_code DESC";
	// *** Fin de Chaîne de Recherche
		 
	$rs = mysql_query($rech) or die(mysql_error());
	$numrows = mysql_num_rows($rs); // Nombre de résultats à la requête
	
	if($numrows > 0)
	{
		echo "<span class=\"annot_std_it\">";
		echo "(Lieu/Statut : laisser la souris sur l'icône pour le d&eacute;tail)<br>";
		echo "</span>";
	
		// *** Affichage de la table
		 echo "<table class=\"Mtable\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";     
	
		// Création entête
		titlst(TRUE,$ot2_titre_col);
		echo "<th>".ucfirst("Cliquer")."</th>\n";
		
		$i = 0;
		
		while ($row = mysql_fetch_assoc($rs)) 
		{         
	 // Affichage résumé ordre

		// Création de l'entête de ligne (TR)
		creetrlst($i);

		echo "<td>";
		echo $row["ot_code"];
		echo "<div class=\"annot_petit_it\" align=\"right\">";
		echo Client." ".$row["int_codecli"];
		echo "</div>";
		echo "</td>\n";

		echo "<td>";
		echo "<div align=\"center\">";
		echo formatedate($row["ot_datedde"]);
		echo "</div>";
		echo "</td>\n";

		 // Affichage Icône Lieu
		 echo "<td>";
		 echo "<div align=\"center\">";
		 
		 $lieu = $row["ot_codelieu"];
		 $rechlieu = "SELECT * FROM ".TBLIEU." WHERE lieu_code = '$lieu'";
		 
		 $rslieu = mysql_query($rechlieu) or die(mysql_error());
		 
			if (mysql_num_rows($rslieu) <> 0)
			{
				 while ($rowlieu = mysql_fetch_array($rslieu)) 
				{
					extract ($rowlieu);
					if ($rowlieu["lieu_img"] <> "")
					{
						$lieuint = $rowlieu["lieu_desc"]." (".$lieu.")";
						echo "<img src=\"".$rowlieu["lieu_img"]."\" title=\"".$lieuint."\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\">";
					}
					else
					{
						 echo "<span class=\"annot_std_it\">";
						 echo $lieu;
						 echo "</span>";
					}
				}
			}
		 
			mysql_free_result($rslieu);

		 echo "</div>";
		 echo "</td>\n";

		echo "<td>";
		
		// Affichage détail urgence
		
		echo "<div align=\"center\">";
		echo $niv_urgence[$row["ot_urg"]];
		echo "</div>";
		
		// Fin affichage détail urgence
		
		echo "</td>\n";

		 // Affichage Icône Statut
		 echo "<td>";
		 echo "<div align=\"center\">";
		 
		 $statut = $row["ot_codestatut"];
		 $rechico = "SELECT * FROM ".TBSTA." WHERE statut_code = '$statut'";
		 
		 $rsico = mysql_query($rechico) or die(mysql_error());
		 
			if (mysql_num_rows($rsico) <> 0)
			{
				 while ($rowico = mysql_fetch_array($rsico)) 
				{
					extract ($rowico);
					if ($rowico["statut_img"] <> "")
					{
						$statint = $rowico["statut_desc"]." (".$statut.")";
						echo "<img src=\"".$rowico["statut_img"]."\" title=\"".$statint."\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\">";
					}
					else
					{
						 echo "<span class=\"annot_std_it\">";
						 echo $statut;
						 echo "</span>";
					}
				}
			}
		 
			mysql_free_result($rsico);

		 echo "</div>";
		 echo "</td>\n";

		// CREATION lien dynamique sur icône (édition, suppression, etc...)
		 echo "<td>";
		 echo "<div align=\"center\">";

		if ($row["ot_codestatut"] <> "CLOT")
		{
			$lst_maj = TRUE;
			echo "<a href=\"ot_maj.php?tx=".$tx."&td=edit&ci=".$row["ot_codeint"]."&co=".$row["ot_code"]."\"><img src=\"../img/edit.png\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\"></a>";
			echo " ";
		}
		else
		{
			$lst_voir = TRUE;
			echo "<a href=\"ot_maj.php?tx=".$tx."&td=view&ci=".$row["ot_codeint"]."&co=".$row["ot_code"]."\"><img src=\"../img/detail.gif\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\"></a>";
			echo " ";
		}

		$lst_imp = TRUE;
		$urlimp = "ot_pdf.php?co=".$row["ot_code"];
		echo "<a href=\"javascript:;\" onclick=\"lanceimp('".$urlimp."');\")><img src=\"../img/print.gif\" title=\"Imprimer l'ordre\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\"></a>";
		echo " ";

		if ($row["ot_codestatut"] <> "CLOT")
		{
			$del=TRUE;

			if ((@$_SESSION["niv_log"] == 11) OR (@$_SESSION["niv_log"] == 10))
				$del=FALSE;
	
			if ($del==TRUE)
			{
				$lst_del = TRUE;
				echo "<a href=\"ot_maj.php?tx=".$tx."&td=del&ci=".$row["ot_codeint"]."&co=".$row["ot_codeco"]."\"><img src=\"../img/del.gif\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\"></a>";
			}
		}
		 echo "</div>";
		 echo "</td>\n";

		 echo "</tr>\n";
	 // Fin affichage résumé ordre
			
			$i++;    
		}  
		echo "</table>\n";
		// *** Fin affichage de la table
		
		mysql_free_result($rs);
	}
	else
	{
		echo "<span class=\"annot_gras_it\">";
		echo "<br><br>Pas d'intervention en cours";
		echo "</span>";
	}	

	mysql_close($conn);  
	
	$taille_piedla="";
	include("../inc/piedla.inc.php"); ?>
</div>
<?PHP
include_once("pied.php");
}
else
{
?>
<p align="center"><span class="titrepageerr">PROBLEME DE CONFIGURATION</span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div align="center" class="annot_gras_it">SMI n'a pas encore &eacute;t&eacute; totalement configur&eacute; pour votre compte...<br><br>
Merci de contacter l'administrateur ou le centre de gestion</div>
<script type="text/javascript">
window.setTimeout("location=('../index.php');",2000)
</script>
<?PHP
}
?>