<?

include('funciones.php');
$email="";
if(isset($HTTP_POST_VARS["email"])) $email=$HTTP_POST_VARS["email"];

$errorCaptcha = false;

if (isset($_REQUEST['Submit2'])){

 
  //echo $_REQUEST['captcha']."=".$_SESSION['tmptxt'];
  
  if ($_REQUEST['captcha']!=$_SESSION['tmptxt'])
  {
     $email        = '';
     $errorCaptcha = true;
  }
}


if (!empty($email)){

    $cuerpo  = "Formulari de Contacte enviat pel Web\n\n\n"; 
	  $cuerpo .= "Nom del Remitent:     " . $HTTP_POST_VARS["nombre"] . "\n\n"; 
	  $cuerpo .= "Es Col-legiat?:     " . $HTTP_POST_VARS["colegiat"] . "\n\n";
	  $cuerpo .= "Tipus de Col-legiat: " . $HTTP_POST_VARS["tipus"] . "\n\n"; 
    $cuerpo .= "C&#224;rrec: " . $HTTP_POST_VARS["carrec"] . "\n\n"; 
    $cuerpo .= "Adre&#231;a:      " . $HTTP_POST_VARS["adresa:"] . "\n\n"; 
    $cuerpo .= "CP i Poblaci&#243;:      " . $HTTP_POST_VARS["cp"] . "\n\n"; 
  	$cuerpo .= "Fax:      " . $HTTP_POST_VARS["fax"] . "\n\n";
  	$cuerpo .= "Tel&#232;fon:      " . $HTTP_POST_VARS["telefon"] . "\n\n";
  	$cuerpo .= "E-Mail:      " . $HTTP_POST_VARS["email"] . "\n\n";
  	$cuerpo .= "Tipus de Consulta:      " . $HTTP_POST_VARS["consulta"] . "\n\n";
  	$cuerpo .= "Observacions:  " . $HTTP_POST_VARS["observacions"] . "\n\n";

  	$subject = "Formulari de Contacte enviat pel Web Colegi";

	$body ="<html>
          <html>
          <body>
          <table border='1' bordercolor=gray width='600'>
          	<tr><td>
          	<table border='0' width='100%'>
          	<tr><td height='20' colspan='2' bgcolor=gray><font color=white><b>&#160;Formulari de Contate de la Web</b></td></tr>	
          <tr><td height='20' colspan='2'>&#160;</td></tr>	
          <tr><td>Nom del Remitent:</td><td width='300'>" . $HTTP_POST_VARS["nombre"] . "</td></tr>
          <tr><td>E-Mail:</td><td width='300'>" . $HTTP_POST_VARS["email"] . "</td></tr>
          <tr><td>Tel&#232;fon:</td><td>" . $HTTP_POST_VARS["telefon"] . "</td></tr>
          <tr><td>Tipus de Consulta:</td><td width='300'>" . $HTTP_POST_VARS["consulta"] . "</td></tr>
		  <tr><td>Assumpte:</td><td width='300'>" . $HTTP_POST_VARS["assumpte"] . "</td></tr>
          <tr><td>Descripció:</td><td width='300'>" . $HTTP_POST_VARS["observacions"] . "</td></tr>
		  <tr><td>Adjunts:</td><td width='300'>" . $HTTP_POST_VARS["adjunto"] . "</td></tr>
          </table>
          	</body>
          </html>";

          
    if ($_FILES['adjunto']['tmp_name'])
	       mail_attachment($_FILES['adjunto'], "", "montse.ferrer@elcol-legi.org", "montse.ferrer@elcol-legi.org", "elcol-legi.org", "montse.ferrer@elcol-legi.org", $subject, $body);							 
	   else
         fn_send_mail($subject, $body,"montse.ferrer@elcol-legi.org","montse.ferrer@elcol-legi.org");
 	




echo <<<HTML
<html>
<head>
<script type="text/javascript" src="utils.js"></script>
<link type="text/css" media="screen" rel="stylesheet" href="estilos.css" />
</head>
<body>

<table border="0" width="430">
<tr><td height="15"></td></tr>
<tr><td><b><center><font size=1 face='Verdana, Arial, Helvetica, sans-serif'><b>El seu Correu s´ha enviat correctament:</center> 
<br><center>En breu ens possarem en contacte amb vostè.</center>
<br><center>Gràcies per contactar amb nosaltres.</center></td>
</tr></table></body>
</html><br>
HTML;

}else{

?>


<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script language="javascript">
	function validar(){
	var error='true';
	var radio = false;

		if (this.document.f.nombre.value==''){
			alert("Si us plau indiqui un nom de contacte.");
			this.document.f.nombre.focus();
			return false;
						
         }
		 if (this.document.f.email.value==''){
			alert("Si us plau indiqui un e-mail.");
			this.document.f.email.focus();
			return false;
						
            			
         }
      
      if (this.document.f.consulta.value==0){
		      	alert("Si us plau indiqui una Opció.");
			      this.document.f.consulta.focus();
			      return false;
      }
   
         
         
		 if (this.document.f.assumpte.value==''){
			alert("Si us plau indiqui l’assumpte.");
			this.document.f.assumpte.focus();
			return false;
						
         }
	/*
  	 if (this.document.f.observaciones.value==''){
			alert("Si us plau, Escrigui Descripció.");
			this.document.f.observaciones.focus();
			return false;
						
         }
         
    */     

    if (this.document.f.captcha.value==''){
			alert("Si us Plau, indiqui captcha.");
			this.document.f.captcha.focus();
			return false;

		}
		
		
		
		
		if (this.document.f.condiciones.checked != 1 ){
			alert("Si us plau Accepti les Condicions Legals.");
			return false;
		}else{
			return true;
		 }
	  
	return error;
	
	}
	
	function seleccion(){
    if (!this.document.f.adjunto.value){
       document.getElementById("Error").innerHTML = "No s’ha adjuntat cap arxiu"
    	 // return false;
    }else{
      
        var paht  = this.document.f.adjunto.value.split('\\');

        var name  = paht[(paht.length-1)];
        document.getElementById("Error").innerHTML = "Nom: <b>"+name+"<b>";
    }
  }
	
function controlNumerico(){ 
	//funcion en la que controlamos que solo se escriban numeros
	var key=window.event.keyCode; 
	if (key < 48 || key > 57){  
		window.event.keyCode=0; 
	}
}
</script>


</head>

<body>
<link type="text/css" media="screen" rel="stylesheet" href="forniture/css.css" />

<table border="0" bordercolor="blue" bgcolor="" width="460" height="5" bgcolor="" cellspacing="0" 
cellpadding="0">
<tr valign="top"><td></td></tr>
<tr valign="top"><td>
<table border="0" bordercolor="blue" bgcolor=""  height="5" bgcolor="" cellspacing="0" 
cellpadding="0"><tr valign="top">
<td width="100%">


<table border="0" bordercolor="blue" bgcolor="#437FAE" width="100%" height="5" bgcolor="" cellspacing="2" 
cellpadding="10">
<tr valign="top"><td bgcolor="#ffffff">

<table border="0" bordercolor="red" bgcolor="" width="100%" height="5" bgcolor="" cellspacing="0" 
cellpadding="0"><tr valign="top"><td>

<form action="<?PHP_SELF?>" method="post" name="f" onsubmit="return validar()" enctype="multipart/form-data">
<table border="0" bordercolor="green" width="100%" height="" bgcolor="" cellspacing="0" cellpadding="0">

<tr><td colspan="4"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Si us plau, utilitzi el formulari per realitzar la seva petició</td></tr>


<tr><td colspan="4"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>&nbsp;</td></tr>


<tr><td><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>&nbsp;Nom:</td>
<td height="0">&nbsp;</td>
<td width=""><input name="nombre" type="text" value="" size="40"></td><td><font color="red" size="2"><b>*</b></font></td></tr>

<tr><td colspan="4" height="5"></td></tr>
<tr><td><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>&nbsp;E-mail:</td>
<td height="0">&nbsp;</td>
<td><input name="email" type="text" value="" size="40"></td><td><font color="red" size="2"><b>*</b></font></td></tr>
<tr><td colspan="4" height="5"></td></tr>
<td><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>&nbsp;Telèfon:</td>
<td height="0">&nbsp;</td>
<td><input name="telefon" type="text" value="" size="40"></td><td>&nbsp;</td></tr>

<tr><td colspan="4" height="5"></td></tr>
<tr valign="top"><td><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>&nbsp;Opció:</font></td>
<td height="0">&nbsp;</td>
<td>
<select name="consulta" style="font-size:8pt">

											<option value="0">
                      <font size="1"><font color="#797676"><font size="1" 
											face="Verdana, Arial, Helvetica, sans-serif">[Seleccionar]</option>
											
											<option value="Sol·licitud de Col·legiació"><font size="1"><font color="#797676"><font size="1" 
											face="Verdana, Arial, Helvetica, sans-serif">Sol&middot;licitud de Col&middot;legiació</option>
											
											<option value="Departament d'Atenció al Client"><font size="1"><font color="#797676"><font size="1" 
											face="Verdana, Arial, Helvetica, sans-serif">Departament d'Atenció al Client</option>
											
											<option value="Servei per donar compliment a la llei de Prevenció del Blanqueig de Capitals"><font size="1"><font color="#797676"><font size="1" 
											face="Verdana, Arial, Helvetica, sans-serif">Servei per donar compliment a la llei de PREBLAC</option>
											
											<option value="Servei per donar compliment a les obligacions de la Llei Orgànica de Protecció de Dades"><font size="1"><font color="#797676"><font size="1" 
											face="Verdana, Arial, Helvetica, sans-serif">Servei per donar compliment a la LOPD</option>
											
											<option value="Servei d'Atenció al Consumidor"><font size="1"><font color="#797676"><font size="1" 
											face="Verdana, Arial, Helvetica, sans-serif">Servei d'Atenció al Consumidor</option>
											
											<option value="Sol•licitud d'informació i d'altres tràmits"><font size="1"><font color="#797676"><font size="1" 
											face="Verdana, Arial, Helvetica, sans-serif">Sol&middot;licitud d'informació i d'altres tràmits</option>

								  </select>
</td><td><font color="red" size="2"><b>*</b></font></td></tr>

<tr><td colspan="4" height="5"></td></tr>
<tr><td><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>&nbsp;Assumpte:</td>
<td height="0">&nbsp;</td>
<td><input name="assumpte" type="text" value="" size="40"><td><font color="red" size="2"><b>*</b></font></td></td>
</tr><tr>

<tr><td colspan="4" height="5"></td></tr>

<tr><td><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>&nbsp;Descripció:</td>
<td height="0">&nbsp;</td>
<td><textarea name="observacions" cols="30" rows="6" 
wrap="VIRTUAL"></textarea><td>&nbsp;</td></td>
</tr><tr>

<tr><td colspan="4" height="5"></td></tr>
<tr><td><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Document Adjunt <br><i>Opcional:</td>
<td height="0">&nbsp;</td>
<td>
<input type="file" name="adjunto" id="adjunto" onchange="seleccion()" /><br>
<div id="Error" style="display:">
  <font size="1" face="Verdana, Arial, Helvetica, sans-serif"> No s’ha adjuntat cap arxiu
</div>
<br>
Extensions d'arxiu permeses: .doc, .docx, .txt, .pdf, .odt<td>&nbsp;</td></td>
</tr><tr>


 <tr><td colspan="4" height="10"></td></tr>
<tr><td><font size="1" face="Verdana, Arial, Helvetica, sans-serif">
<b>&nbsp;Verificació:</td>
<td height="0">&nbsp;</td>
<td><font size="1" face="Verdana, Arial, Helvetica, 
sans-serif">
<img src="captcha/captcha.php" width="100" height="30" title="captcha" alt="captcha">
<?
    if ($errorCaptcha) echo "<p style='color:#FF0000'>Error, codigo de seguridad.</p>";
?>
<input type="text" name="captcha" id="captcha" /> <br><i>Introdueixi el text de la imatge<td>&nbsp;</td></td>
</tr><tr>



<tr><td colspan="4" height="10"></td></tr>

<tr><td colspan="4"><table border="0" bordercolor="green" width="100%" height="" bgcolor="" cellspacing="0" 
cellpadding="0">
<tr><td colspan="4" bgcolor=""><input name="condiciones" type="checkbox" id="condiciones" value="1">&#160;
<font color="#797676"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Accepto (Avís Legal) 
</a></b></td></tr>

<tr><td colspan="4" height="15"></td></tr>

<tr><td colspan="4" bgcolor="">
<input type="submit" class="verddeu" name="Submit2" id="Submit2" 
value="Enviar">&nbsp;<input name="Submit22" type="reset" class="verddeu" value="Restablir">
</td></tr>
</form>
</table></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></tr></table>


 <br>
</body>
</html>
<?}?>

