<!DOCTYPE html>
<html>
  <head>
    <title>Softemuco</title>
	<? include('head.php');?>
  </head>
  <body>
<? include('menu.php');?>

<? include('carousel.php');?>

	<div class="container">
      <div class="" align="center">
        <h3 class="">Contactenos</h3>
        <!--<p>50 años de experiencia en transporte y distribución</p>-->
      </div>
	</div>
	
<div class="container">

<form class="well form-horizontal" action="" method="post">
<fieldset>
<!-- Form Name -->
<!--<legend>Contáctenos</legend>-->

<!-- Text input-->
<div class="form-group">
  <label class="col-md-4 control-label">Nombre(*)</label>  
  <div class="col-md-4 inputGroupContainer">
  <div class="input-group">
  <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
  <input  name="first_name" placeholder="Nombre" class="form-control"  type="text" required>
    </div>
  </div>
</div>

<!-- Text input-->
<!--<div class="form-group">
  <label class="col-md-4 control-label">Ocupación(*)</label>  
  <div class="col-md-4 inputGroupContainer">
  <div class="input-group">
  <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
  <input  name="ocupation" placeholder="Ocupación" class="form-control"  type="text" required>
  </div>
  </div>
</div>-->

<!-- Text input-->
<div class="form-group">
  <label class="col-md-4 control-label">E-Mail(*)</label>  
  <div class="col-md-4 inputGroupContainer">
  <div class="input-group">
  <span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span>
  <input name="email" placeholder="E-Mail" class="form-control"  type="text" required>
  </div>
  </div>
</div>

<!-- Text input-->
       
<div class="form-group">
  <label class="col-md-4 control-label">Telefono(*)</label>  
  <div class="col-md-4 inputGroupContainer">
  <div class="input-group">
  <span class="input-group-addon"><i class="glyphicon glyphicon-earphone"></i></span>
  <input name="phone" placeholder="+56987654321" class="form-control" type="text" required>
  </div>
  </div>
</div>

<!-- Text area -->
<div class="form-group">
  <label class="col-md-4 control-label" for="message">Mensaje(*)</label>
    <div class="col-md-4 inputGroupContainer">
    <div class="input-group">
        <span class="input-group-addon"><i class="glyphicon glyphicon-pencil"></i></span>
        	<textarea class="form-control" rows="5" name="message" placeholder="Mensaje" required></textarea>
  </div>
  </div>
</div>
<!-- Success message -->
<!--<div class="alert alert-success" role="alert" id="success_message">Success <i class="glyphicon glyphicon-thumbs-up"></i> Thanks for contacting us, we will get back to you shortly.</div>-->

<!-- Button -->
<div class="form-group">
  <label class="col-md-4 control-label"></label>
  <div class="col-md-4">
    <button type="submit" class="btn btn-warning" name="envia_correo" >Enviar <span class="glyphicon glyphicon-send"></span></button>
  </div>
</div>

</fieldset>
</form>
</div><!-- /.container -->

	<? include('footer_script.php');?>
  </body>
</html>
<?
if(isset($_POST['envia_correo'])){
	
require 'class.phpmailer.php';

$correo_empresa='patricio.saez@softemuco.cl';
$cla_correo_empresa='ps2016';
$nombre_empresa='SOFTEMUCO';
$correo_cliente='patricio.saez@softemuco.cl';
$razon='';

$mail             = new PHPMailer();
//$mail->SMTPDebug  = 2;
$mail->IsSMTP(); 
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Host       = "mail.softemuco.cl"; // sets the SMTP server
$mail->Port       = 587;                    // set the SMTP port for the GMAIL server
//$mail->SMTPSecure = 'tls';       // set the SMTP port for the GMAIL server
$mail->Username   = $correo_empresa; // SMTP account username
$mail->Password   = $cla_correo_empresa;        // SMTP account password

$mail->SetFrom($correo_cliente, $nombre_empresa);      // desde

$mail->AddReplyTo($correo_cliente,$nombre_empresa);

$mail->Subject    = "Formulario de contacto SOFTEMUCO";

//$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$first_name_c=$_POST['first_name'];
//$ocupation_c=$_POST['ocupation'];
$email_c=$_POST['email'];
$phone_c=$_POST['phone'];
$message_c=$_POST['message'];

$form_contact="
<img src='img/logo.jpg' width='300' height=''/>
<h4>Formulario de contacto</h4>
<table width='100%'>
	<tr>
		<td>Nombre:</td>
		<td>$first_name_c</td>
	</tr>
	<tr>
		<td>E-mail:</td>
		<td>$email_c</td>
	</tr>
	<tr>
		<td>Telefono:</td>
		<td>$phone_c</td>
	</tr>
	<tr>
		<td>mensaje:</td>
		<td>$message_c</td>
	</tr>
</table>";

$mail->MsgHTML($form_contact);

$address = $correo_cliente;
//$address = 'dte_milka@softco.cl';   
//$address = 'pato.saez60@gmail.com';    
$mail->AddAddress($address, $razon);

//$mail->AddAttachment($docto_pdf);      // attachment
//$mail->AddAttachment($docto_firmado);      // attachment
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

if(!$mail->Send())
 {
  //echo "Mailer Error 1: " . $mail->ErrorInfo;
  ?>
  <script>
	alert ("¡Error al enviar correo!");
</script>
  <?php
} else {
  //echo "Message sent 1!";
  ?>
<script>
	alert ("¡Correo Enviado!");
</script>
  <?php
}
}
?>