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


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

$titre = "RECEPTION CONTRAT SIGNE";
?>
<!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 : Accus&eacute; r&eacute;ception contrat</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>

<!-- 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-fr.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 -->

<!-- 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:codecocl ; format:liste ; req:Y ; txt:Contrat non encore signé ; vmn:1 ; stok:frmok ; stbad:frmbad",
	"nom:signataire ; format:txt ; req:Y ; txt:Signé par ; lmx:70 ; stok:frmok ; stbad:frmbad");
</script>

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

</head>

<body onLoad="metFocus();">

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

<p align="center"> <span class="titrepage"><?PHP echo $titre ?></span></p>
<form name="coclrec_maj" id="coclrec_maj" method="post" action="coclrec_enr.php" onSubmit="javascript:; return (VForm(this,tab1_champ,'',''));">
	<input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
	<?PHP
	$rien_a_receptionner = TRUE;

	// Création de la liste des contrats non terminés, envoyés et non reçus
	
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	if ((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3))
		$rech ="SELECT * FROM ".TBCOCL." WHERE `cocl_datefin` = '0000-00-00' AND `cocl_dateenv` <> '0000-00-00' AND `cocl_daterec` = '0000-00-00' AND `cocl_codeage`='".@$_SESSION["code_age"]."' ORDER BY cocl_code DESC";
	else
		$rech ="SELECT * FROM ".TBCOCL." WHERE `cocl_datefin` = '0000-00-00' AND `cocl_dateenv` <> '0000-00-00' AND `cocl_daterec` = '0000-00-00' ORDER BY cocl_code DESC";
	
	$rs = mysql_query($rech) or die(mysql_error());
	
	if (mysql_num_rows($rs) <> 0)
	{
		$rien_a_receptionner = FALSE;
	?>
		<table width="360"  border="0" cellspacing="0" cellpadding="0" align="center">
		<tr>
			<td class="rubfrm" id="f_codecocl">
				<div align="center">Choisissez un contrat non encore sign&eacute; :</div>
			</td>
		</tr>
		<tr>
			<td>
				<div align="center">
				<select name="codecocl" id="codecocl">
				<?PHP
					echo "<option>-- Choisissez un contrat --</option>";

					while ($resultat = mysql_fetch_array($rs)) 
					{
						extract($resultat);

						$rech2 ="SELECT * FROM ".TBCLI." WHERE `cli_code` = '".$cocl_codecli."'";
						$rs2 = mysql_query($rech2) or die(mysql_error());
						
						if (mysql_num_rows($rs2) <> 0)
						{
							if ($row2 = mysql_fetch_array($rs2))
								extract ($row2);
						}
						if ($cli_ste <> "")
							$texte = $cocl_code." - ".$cli_ste;
						else
							$texte = $cocl_code." - ".$cli_nom;
						echo "<option value=\"".$cocl_code."\">".$texte."</option>";
					}
				?>
				</select>
				</div>
			</td>
		</tr>
		</table>
		<br>      
		<table width="120"  border="0" cellspacing="0" cellpadding="0" align="center">
		<tr>
			<td align="center" class="rubfrm" id="f_datesig">
				Sign&eacute; le :
			</td>
		</tr>
		<tr>
			<td align="center">
				<input name="datesigf" type="text" id="datesigf" value ="" size="10" maxlength="10" readonly="1">
				<img src="../img/calendar.png" id="f_img_datesigf" title="Choisir votre date" width="16" height="16">
				<a href="javascript:;" onclick="document.cocl_maj.datesigf.value=''"><img src="../img/raz.gif" width="12" height="12" border="0" align="absmiddle"></a> 
			</td>
		</tr>
		</table>
		<br>      
		<table width="500"  border="0" cellspacing="0" cellpadding="0" align="center">
		<tr>
			<td align="center" class="rubfrm" id="f_signataire">
				Sign&eacute; par :
			</td>
		</tr>
		<tr>
			<td align="center">
				  <input name="signataire" type="text" id="signataire" value ="" size="70" maxlength="70">
			</td>
		</tr>
		</table>
		<p align="center">
		  <input name="annul" type="button" class="bton_fmarr_std" id="annul" value="Annuler" onclick="javascript:; history.back();">
		  <input type="submit" class="bton_fmarr_std" name="submit" id="submit" value="Valider">
	<?PHP
	}
	else
	{
		echo "<span class=\"annot_gras_it\">";
		echo "<div align=\"center\">";
		echo "Pas de contrat ouvert, envoyé et non reçu";
		echo "</div>";
		echo "</span>";
	}
	
	mysql_free_result($rs);
	mysql_close($conn);
	?>
</p>
</form>
<?PHP
	if ($rien_a_receptionner == FALSE)
	{
?>
<script type="text/javascript">
	Calendar.setup({
		inputField     :    "datesigf",     // id of the input field
		ifFormat       :    "%d-%m-%Y",      // format of the input field
		button         :    "f_img_datesigf",  // trigger for the calendar (button ID)
		align          :    "Ll",           // alignment (defaults to "Bl")
		electric	   :	false,
		singleClick    :    true
	});
</script>
<?PHP
	}
include_once("pied.php");
?>
