<?php require_once('Connections/cristal5.php'); ?>
<?php
//**************************function perso**********************************
function gala_statut($indice) {
	$lStatut = array( '-1' => 'OUI', '0' => 'NON');
		return $lStatut[$indice];
	}
	
function droit_inscription($indice) {
	$lStatut = array( '0' => 'N.A', '1' => 'Etudiant', '2' => 'Universitaire','3' => 'Industriel');
		return $lStatut[$indice];
	}
function prix_inscription($indice) {
	$lStatut = array( '0' => 0, '1' => 125, '2' => 250,'3' => 350);
		return $lStatut[$indice];
	}



//****************************************************************************
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
  $insertSQL = sprintf("INSERT INTO fiches_participants_cristal5 (nom_part, prenom_part, societe_universite, departement_part, adresse_part, code_postal, ville_part, email_part, telephone_part, fax_part, participe_au_gala, bon_de_commande_part, droit_inscription, date_inscription) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['nom_part'], "text"),
                       GetSQLValueString($_POST['prenom_part'], "text"),
                       GetSQLValueString($_POST['societe_universite'], "text"),
                       GetSQLValueString($_POST['departement_part'], "text"),
                       GetSQLValueString($_POST['adresse_part'], "text"),
                       GetSQLValueString($_POST['code_postal'], "text"),
                       GetSQLValueString($_POST['ville_part'], "text"),
                       GetSQLValueString($_POST['email_part'], "text"),
                       GetSQLValueString($_POST['telephone_part'], "text"),
                       GetSQLValueString($_POST['fax_part'], "text"),
					   GetSQLValueString(isset($_POST['participe_au_gala']) ? "true" : "", "defined","-1","0"),
                       GetSQLValueString($_POST['bon_de_commande_part'], "text"),
                       GetSQLValueString($_POST['droit_inscription'], "int"),
                       GetSQLValueString($_POST['date_inscription'], "date"));

  mysql_select_db($database_cristal5, $cristal5);
  $Result1 = mysql_query($insertSQL, $cristal5) or die(mysql_error());
  
  //*****************************************envoie du mail***************************************************
  /* ************************************************************************************** */
	
		$mail_clients = $_POST['email_part'];
		//$mail_clients ="buathier@lagep.cpe.fr";
		//$mail_cristal5="buathier@lagep.cpe.fr";
		$mail_cristal5="cristal5@lagep.cpe.fr";
		// Informations
		$informations = "";
		foreach($_POST as $cle=>$val){
			if ($cle != "Submit" and $cle != "MM_insert"){
				if ($cle == "participe_au_gala"){
				    $informations .= strtoupper($cle)." : ".gala_statut($val)."\r\n";
					$bool_gala = -1 ;
				} elseif (  $cle == "droit_inscription" ) {
					$informations .= strtoupper($cle)." : ".droit_inscription($val)."\r\n";
				} else {
				     $informations .= strtok(strtoupper($cle),"_")." : ".$val."\r\n";
				}
			}
		}
	
		if (!$bool_gala) {
			$informations .= strtoupper("participe_au_gala")." : ".gala_statut(0)."\r\n";
		}
		
		// Message pour l'inscrit
		$message = "Cher participant au congres
Nous avons bien recu votre inscription et nous vous en remercions
- si vous le souhaitez vous pouvez envoyer un bon de commande libellé à CPE Lyon, formation continue à envoyer au secretariat du Colloque:

Cristal 5 
(à l’attention de Mme. Nadia CHAPEL)
LAGEP ESCPE 
Bat 308G
43 bd du 11 novembre 1918
69622 VILLEURBANNE Cedex 
France

- Vous allez recevoir dans les jours qui viennent une facture qui vous permettra d'effectuer votre réglement



";
		$message .= "Renseignements fournis lors de l'inscription:
		
".$informations."
		";
		mail($mail_clients,"Inscription - congres",$message,"From:".$mail_cristal5);
		
		// Message pour le sécrétariat du congrès
		$message_congres = " La personne suivante s'est inscrite au Congres. Voici les informations qu'elle a entrees :\r\n\r\n";
		$message_congres .= $informations;
		
		//$cc = "plasari@ensic.inpl-nancy.fr";
		//$cc = "buathier@lagep.cpe.fr";
		mail($mail_cristal5,"Inscription cristal 5",$message_congres,"From:".$mail_cristal5); //."\r\nCc:".$cc);
  
  
  
  //***********************************************************************************************************

  $insertGoTo = "inscription_valide.html";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

$maxRows_testtable = 100;
$pageNum_testtable = 0;
if (isset($_GET['pageNum_testtable'])) {
  $pageNum_testtable = $_GET['pageNum_testtable'];
}
$startRow_testtable = $pageNum_testtable * $maxRows_testtable;

mysql_select_db($database_cristal5, $cristal5);
$query_testtable = "SELECT * FROM fiches_participants_cristal5";
$query_limit_testtable = sprintf("%s LIMIT %d, %d", $query_testtable, $startRow_testtable, $maxRows_testtable);
$testtable = mysql_query($query_limit_testtable, $cristal5) or die(mysql_error());
$row_testtable = mysql_fetch_assoc($testtable);

if (isset($_GET['totalRows_testtable'])) {
  $totalRows_testtable = $_GET['totalRows_testtable'];
} else {
  $all_testtable = mysql_query($query_testtable);
  $totalRows_testtable = mysql_num_rows($all_testtable);
}
$totalPages_testtable = ceil($totalRows_testtable/$maxRows_testtable)-1;
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
<style type="text/css">
<!--
.Style5 {color: #0000FF; font-weight: bold; }
.Style7 {color: #FF0000}
.Style8 {
	font-size: 16px;
	font-weight: bold;
	font-family: Arial, Helvetica, sans-serif;
	color: #0000FF;
}
.Style9 {font-size: 14}
-->
</style>
</head>

<body>
<form method="post" name="form2" action="<?php echo $editFormAction; ?>">
  <p align="center" class="Style8"><img src="travail/bandeau-haut premier UCBL titre logo.jpg" alt="bandeau cristal 5" width="760" height="80" border="0" usemap="#Map2" />
    <map name="Map2" id="Map2">
      <area shape="rect" coords="4,9,105,72" href="http://www.univ-lyon1.fr" target="_blank" alt=": : : LAGEP : : :" />
      <area shape="rect" coords="654,-1,752,78" href="index.htm" alt="&lt;&lt;&lt; accueil" />
    </map>
  </p>
  <p align="center" class="Style8">INSCRIPTION</p>
  <p align="right" class="Style8"><a href="index.htm" class="Style9">revenir &agrave; l'accueil </a></p>
  <table width="500" border="0" align="center" bordercolor="#0000FF" bgcolor="#666666">
    <tr valign="baseline">
      <td width="144" align="right" nowrap bgcolor="#999999"><div align="right">Nom*:</div></td>
      <td width="377" bgcolor="#CCCCCC"><input name="nom_part" type="text" value="" size="60"></td>
    </tr>
    <tr valign="baseline" bgcolor="#FF0000">
      <td align="right" nowrap bgcolor="#999999"><div align="right">Prenom*:</div></td>
      <td bgcolor="#CCCCCC"><input name="prenom_part" type="text" value="" size="60"></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap bgcolor="#999999"><div align="right">Societé ou Université*:</div></td>
      <td bgcolor="#CCCCCC"><input name="societe_universite" type="text" value="" size="60"></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap bgcolor="#999999"><div align="right">Service ou Laboratoire </div></td>
      <td bgcolor="#CCCCCC"><input name="departement_part" type="text" value="" size="60"></td>
    </tr>
    <tr valign="baseline">
      <td align="right" valign="top" nowrap bgcolor="#999999"><div align="right">Adresse*:</div></td>
      <td bgcolor="#CCCCCC">
      <textarea name="adresse_part" cols="60" rows="4"></textarea>      </td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap bgcolor="#999999"><div align="right">Code postal*:</div></td>
      <td bgcolor="#CCCCCC"><input name="code_postal" type="text" value="" size="60"></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap bgcolor="#999999"><div align="right">Ville*:</div></td>
      <td bgcolor="#CCCCCC"><input name="ville_part" type="text" value="" size="60"></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap bgcolor="#999999"><div align="right">Téléphone:</div></td>
      <td bgcolor="#CCCCCC"><input name="telephone_part" type="text" value="" size="60"></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap bgcolor="#999999"><div align="right">Fax:</div></td>
      <td bgcolor="#CCCCCC"><input name="fax_part" type="text" value="" size="60"></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap bgcolor="#999999"><div align="right">Participe au gala:</div></td>
      <td bgcolor="#CCCCCC"><div align="center" class="Style7"><strong><em>Inscriptions clauses </em></strong></div></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap bgcolor="#999999"><div align="right">REF bon de commande :</div></td>
      <td bgcolor="#CCCCCC"><input name="bon_de_commande_part" type="text" value="" size="60"></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap bgcolor="#999999"><div align="right">Droit inscription*:</div></td>
      <td bgcolor="#CCCCCC"><p class="Style5">
        <label>
          <input name="droit_inscription" type="radio" value="3" checked="checked" />
          Industriels</label>
        :<span class="Style7"><strong>350 &euro; TTC </strong>(292,64 &euro; HT) </span><br />
        <label>
          <input type="radio" name="droit_inscription" value="2" />
          Universitaires</label>
        :<span class="Style7"><strong>250 &euro; TTC</strong> (209,03 &euro; HT)</span> <br />
        <label>
          <input type="radio" name="droit_inscription" value="1" />
          Etudiants</label>
        :<span class="Style7"><strong>125 &euro; TTC </strong>(104,51 &euro; HT) </span><br />
      </p></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap bgcolor="#999999"><div align="right"><strong>E-mail</strong>*:</div></td>
      <td align="right" nowrap bgcolor="#999999"><div align="left">
        <input name="email_part" type="text" value="" size="60" />
      </div></td>
    </tr>
    <tr valign="baseline">
      <td colspan="2" align="right" nowrap bgcolor="#999999"><div align="right"></div>        <div align="center">
          <input type="submit" value="Soumettre l'inscription">
        </div></td>
    </tr>
  </table>
  <p>
    <input type="hidden" name="date_inscription" value="<?php echo date("Y/m/d");?>">
    <input type="hidden" name="MM_insert" value="form2">
  * champs obligatoires</p>
  <p>&nbsp;</p>
</form>
</body>
</html>
<?php
mysql_free_result($testtable);
?>
