<?php
   # Incluindo a classe
   require('googleTranslateTool.class.php');
   
   		$tempo_sessao =  120*300*120*50;
   		if (session_status() !== PHP_SESSION_ACTIVE) {//Verificar se a sessão não já está aberta.
   			ini_set('session.gc_maxlifetime', $tempo_sessao);
   			ini_set('session.cookie_lifetime', $tempo_sessao);
   			ini_set("session.cookie_secure", $tempo_sessao);
   			ini_set("session.sess_expiration", 0);
   			ini_set("session.sess_expire_on_close", TRUE);
   			ini_set('session.save_path',realpath(dirname(__FILE__).'/sessao'));
   			ini_set('session.gc_probability', 1);
   			session_start();
   		}
   		
   		//Obtendo o id da sessão iniciada: 
   		$idSession = session_id();
   		
   
   
   if(isset($_POST['pt_br'])){
   	
   	$_SESSION['language'] = 'pt-br';
   	$_SESSION['source'] = 'en';
   	$_SESSION['target'] = 'pt-br';
   	
   }elseif(isset($_POST['en'])){
   	
   	$_SESSION['language'] = 'en';
   	$_SESSION['source'] = 'pt-br';
   	$_SESSION['target'] = 'en';
   	
   }elseif(!isset($_POST['pt_br']) AND !isset($_POST['en'])){
   	
   	if(isset($_SESSION['language']) AND isset($_SESSION['source']) AND isset($_SESSION['target'])){
   
   		$_SESSION['language'] = $_SESSION['language'];
   		$_SESSION['source'] = $_SESSION['source'] ;
   		$_SESSION['target'] = $_SESSION['target'];
   
   	}else{
   		
   		$_SESSION['language'] = 'pt-br';
   		$_SESSION['source'] = 'en';
   		$_SESSION['target'] = 'pt-br';
   		
   	}
   	
   }
   
   

   
   include_once('admin/conexao.php');
   include_once('admin/funcao.php');
   include_once('admin/DAO/DAOcurriculo.php');
   include_once('admin/classes/curriculo.php');
   
   $instance     = new funcao();
   $conn         = new Conexao();
   $curriculo  = new DAOcurriculo();
   $z  = new curriculo();
   //$encoding = mb_internal_encoding();
   
   
   
   
   
   if (isset($_POST["cur_nome_candidato"])) {
   	
   	if (isset($_FILES['cur_curriculo']) && !empty($_FILES['cur_curriculo']['name']))
   	{
   	  $file_name = $_FILES['cur_curriculo']['name'];
            $file_type = $_FILES['cur_curriculo']['type'];
            $file_size = $_FILES['cur_curriculo']['size'];
            $file_error = $_FILES['cur_curriculo']['error'];
            $file_tmp_name = $_FILES['cur_curriculo']['tmp_name'];
     	$maxSize	= 1024 * 1024 * 2;
     	$permite 	= array('image/jpeg', 'image/gif', 'image/png','application/pdf','application/msword','application/vnd.openxmlformats-officedocument.wordprocessingml.document');
     	
     	$extensao = @end(explode('.', $file_name));
     	$novoNome = @md5(mt_rand(1,10000).$_FILES['name']).".$extensao";
     	$destino = 'admin/uploads/curriculo/';
     	
            if($file_error != 0){
     		//echo "$file_name : ".$errorMsg[$file_error];
     		$instance->alerta("Erro Desconhecido ao inserir logo!","view-curriculo.php");
     		//echo("<script language = 'javascript'> alert('Erro Desconhecido!'); </script>");
     		//echo "1";
     		return;
     	}else if(!in_array($file_type, $permite)){
     		//echo "$file_name : Erro Arquivo não Suportado!";
     		$instance->alerta("Formato de Arquivo($file_type) não Suportado!","view-curriculo.php");
     		//echo("<script language = 'javascript'> alert('Formato de Arquivo não Suportado!'); </script>");
     		//echo "2";
     		return;
     	}else if($file_size > $maxSize){
     		//echo "$file_name : Erro imagem ultrapassa o limite de 5MB";
     		$instance->alerta("Logo ultrapassa o limite de 5MB!","view-curriculo.php");
     		//echo("<script language = 'javascript'> alert('Imagem ultrapassa o limite de 5MB!'); </script>");
     		//echo "3";
     		return; 
     	}else{
     		move_uploaded_file($file_tmp_name,$destino.$novoNome);
     		//echo $novoNome;
     		//return;
     	}
        }else{$novoNome = $cur_curriculo;}
     	$z->setCur_curriculo($novoNome);	
   	$z->setCur_id("");
   	$z->setCur_nome_candidato($_POST["cur_nome_candidato"]);
   	$z->setCur_email_candidato($_POST["cur_email_candidato"]);
   	$z->setCur_telefone_candidato($_POST["cur_telefone_candidato"]);
   	
   	$curriculo->Atualizar($z);
   	
   	
   
   	/*
   	if ($curriculo->Atualizar($z)){
   		 $msg = "curriculo Atualizado com Sucesso!";
   	}else{
   		$msg = "ERRO: ao cadastrar META!";
   	}
   		$instance->alerta("curriculo Cadastrado com Sucesso!","view-curriculo.php");
   		*/
   		$link_destino = $_POST['link_destino'];
   		header("Location: $link_destino");
   
   	
   }
   		
   
   
   
   
   ?>
<!DOCTYPE html>
<html lang="pt-nr">
   <head>
      <meta charset="utf-8" />
      <?php include "titulo.php" ?>
      <meta content="width=device-width, initial-scale=1.0" name="viewport" />
      <meta content="" name="keywords" />
      <meta content="" name="description" />
      <!-- Favicon -->
      <link href="img/favicon.ico" rel="icon" />
      <!-- Google Web Fonts -->
      <link rel="preconnect" href="https://fonts.googleapis.com" />
      <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
      <link
         href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&family=Poppins:wght@600;700&display=swap"
         rel="stylesheet"
         />
      <!-- Icon Font Stylesheet -->
      <link
         href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.0/css/all.min.css"
         rel="stylesheet"
         />
      <link
         href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.4.1/font/bootstrap-icons.css"
         rel="stylesheet"
         />
      <!-- Libraries Stylesheet -->
      <link href="lib/animate/animate.min.css" rel="stylesheet" />
      <link href="lib/owlcarousel/assets/owl.carousel.min.css" rel="stylesheet" />
      <!-- Customized Bootstrap Stylesheet -->
      <link href="css/bootstrap.min.css" rel="stylesheet" />
      <!-- Template Stylesheet -->
      <link href="css/style.css" rel="stylesheet" />
   </head>
   <style>
      .text-light {
      color: #052F59 !important;
      }
      /*
      //dispositivos móveis
      @media screen and (max-width: 480px) {
      .w-100-carrossel {
      width: 100% !important;
      height: 400px !important;
      }
      }　
      //iPads, tablets
      @media screen and (min-width: 481px) and (max-width: 768px) {
      .w-100-carrossel {
      width: 100% !important;
      height: 450px !important;
      }
      }　
      //telas pequenas, laptops
      @media screen and (min-width: 769px) and (max-width: 1024px) {
      .w-100-carrossel {
      width: 100% !important;
      height: 798px !important;
      }
      }　
      //desktops, telas grandes
      @media screen and (min-width: 1025px) and (max-width: 1200px) {
      .w-100-carrossel {
      width: 100% !important;
      height: 798px !important;
      }
      }　
      //telas muito grandes, TVs
      @media screen and (min-width: 1201px) {
      .w-100-carrossel {
      width: 100% !important;
      height: 798px !important;
      }
      }　
      */
      /*TELA CELULAR*/
      @media screen and (max-width: 600px) {
      .w-100-carrossel {
      width: 100% !important;
      height: 450px !important;
      }
      }
      /*TELA DESKTOP*/
      @media screen and (min-width: 900px) {
      .w-100-carrossel {
      width: 100% !important;
      height: 798px !important;
      }
      }
      .position-absolute {
      position: static !important;
      }
   </style>
   <body>
      <!-- Spinner Start -->
      <div
         id="spinner"
         class="show bg-white position-fixed translate-middle w-100 vh-100 top-50 start-50 d-flex align-items-center justify-content-center"
         >
         <div class="spinner-grow text-primary" role="status"></div>
      </div>
      <!-- Spinner End -->
      <!-- Topbar Start -->
      <!-- Topbar End -->
      <!-- Navbar Start -->
      <?php include "menu.php" ?>
      <!-- Navbar End -->
      <!-- Page Header Start -->
      <div class="container-fluid page-header py-5 mb-5 wow fadeIn" data-wow-delay="0.1s">
         <div class="container text-center py-5">
            <h1 class="display-4 text-white animated slideInDown mb-4"><?php if($_SESSION['target'] == 'pt-br'){echo 'Contato';}else{echo GoogleTranslate::translate($_SESSION['source'], $_SESSION['target'],'Contato');} ?></h1>
            <nav aria-label="breadcrumb animated slideInDown">
               <ol class="breadcrumb justify-content-center mb-0">
                  <li class="breadcrumb-item">
                     <a class="text-white" href="index.php">Home</a>
                  </li>
               </ol>
            </nav>
         </div>
      </div>
      <!-- Page Header End -->
      <!-- A empresa -->
      <div class="container">
         <div class="row">
            <!--Contato-->
            <div class="col-lg-6 wow fadeInUp" data-wow-delay="0.1s" style="min-height: 450px">
               <div class="position-relative h-100">
                  <iframe
                     class="position-relative w-100 h-100"
                     src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3979.604472938199!2d-38.50210328523981!3d-4.100609797018334!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x7b8b01bd423cd19%3A0xd26e96001d15c7f0!2sR.%20Raimundo%20Nogueira%20Lopes%2C%20572%20-%20Horizonte%2C%20CE%2C%2062880-000!5e0!3m2!1spt-BR!2sbr!4v1663261431512!5m2!1spt-BR!2sbr"
                     frameborder="0"
                     style="min-height: 450px; border: 0"
                     allowfullscreen=""
                     aria-hidden="false"
                     tabindex="0"
                     ></iframe>
               </div>
            </div>
            <div class="col-lg-6 wow fadeInUp" data-wow-delay="0.5s">
               <div class="border-start border-5 border-primary ps-4 mb-5">
                  <h1 class="display-6 mb-0" style="text-align: left;color: rgb(36,62,99);font-weight: 900;">
                     <?php if($_SESSION['target'] == 'pt-br'){echo 'Contate-nos';}else{echo GoogleTranslate::translate($_SESSION['source'], $_SESSION['target'],'Contate-nos');} ?>
                  </h1>
               </div>
               <form>
					 <input type="hidden" id="numero_wpp" value="<?php echo $emp_celular; ?>" />
                  <div class="row g-3">
                     <div class="col-md-6">
                        <div class="form-floating">
                           <input
                              type="text"
                              class="form-control border-0 bg-light"
                              id="name_wpp"
                              placeholder="Your Name"
                              />
                           <label for="name"><?php if($_SESSION['target'] == 'pt-br'){echo 'Seu Nome';}else{echo GoogleTranslate::translate($_SESSION['source'], $_SESSION['target'],'Seu Nome');} ?></label>
                        </div>
                     </div>
                     <div class="col-md-6">
                        <div class="form-floating">
                           <input
                              type="email"
                              class="form-control border-0 bg-light"
                              id="email_wpp"
                              placeholder="Your Email"
                              />
                           <label for="email"><?php if($_SESSION['target'] == 'pt-br'){echo 'Seu E-mail';}else{echo GoogleTranslate::translate($_SESSION['source'], $_SESSION['target'],'Seu E-mail');} ?></label>
                        </div>
                     </div>
                     <div class="col-12">
                        <div class="form-floating">
                           <input
                              type="text"
                              class="form-control border-0 bg-light"
                              id="subject_wpp"
                              placeholder="Subject"
                              />
                           <label for="subject"><?php if($_SESSION['target'] == 'pt-br'){echo 'Assunto';}else{echo GoogleTranslate::translate($_SESSION['source'], $_SESSION['target'],'Assunto');} ?></label>
                        </div>
                     </div>
                     <div class="col-12">
                        <div class="form-floating">
                           <textarea
                              class="form-control border-0 bg-light"
                              placeholder="Leave a message here"
                              id="message_wpp"
                              style="height: 150px"
                              ></textarea>
                           <label for="message"><?php if($_SESSION['target'] == 'pt-br'){echo 'Menssagem';}else{echo GoogleTranslate::translate($_SESSION['source'], $_SESSION['target'],'Menssagem');} ?></label>
                        </div>
                     </div>
                     <div class="col-12">
                        <button onClick="mensagem_wpp()" class="btn btn-primary py-3 px-5" type="">
                        <?php if($_SESSION['target'] == 'pt-br'){echo 'Enviar';}else{echo GoogleTranslate::translate($_SESSION['source'], $_SESSION['target'],'Enviar');} ?>
                        </button>
                     </div>
                  </div>
               </form>
            </div>
         </div>
		 <script>
		 
			function mensagem_wpp(){
				var name_wpp = $("#name_wpp").val();
				var email_wpp = $("#email_wpp").val();
				var subject_wpp = $("#subject_wpp").val();
				var message_wpp = $("#message_wpp").val();
				var numero_wpp = $("#numero_wpp").val();
				
				location = "https://api.whatsapp.com/send?phone=55"+numero_wpp+"&text=*Nome:*"+name_wpp+"; *Email:*"+email_wpp+"; *Assunto:*"+subject_wpp+"; *Mensagem:*"+message_wpp;
				
			}
			
		 
		 </script>
         <div class="row" style="padding-top: 6rem;">
            <!--Trabalhe Conosco-->
            <div class="col-lg-6 wow fadeInUp" data-wow-delay="0.1s" style="min-height: 450px">
               <div class="position-relative h-100">
                  <img class="card-img-top" src="img/trabalhe_conosco.jpg" alt="Card image" style="width 100%;">
               </div>
            </div>
            <div class="col-lg-6 wow fadeInUp" data-wow-delay="0.5s">
               <div class="border-start border-5 border-primary ps-4 mb-5">
                  <h1 class="display-6 mb-0" style="text-align: left;color: rgb(36,62,99);font-weight: 900;">
                     <?php if($_SESSION['target'] == 'pt-br'){echo 'Trabalhe Conosco';}else{echo GoogleTranslate::translate($_SESSION['source'], $_SESSION['target'],'Trabalhe Conosco');} ?>
                  </h1>
               </div>
               <script>
                  //FUNÇÃO QUE CHECA FOMRULÁRIO ANTES DE ENVIAR
                  
                  	function check_form(){
                  		
                  		//alert('ooooo')
                  		$("#link_destino").val('contato.php');
                  		//alert('uuuuuuu')
                  		if(!$("#cur_nome_candidato").val() || (!$('input[type=file]').val() )){
                  			Swal.fire({
                  			  icon: 'error',
                  			  title: 'Oops...',
                  			  text: 'Preencher todos os campos obrigatórios!'
                  			  });
                  			return false;
                  		}
                  		//alert('ppppp')
                  		Swal.fire({
                  		  position: 'center',
                  		  icon: 'success',
                  		  title: 'Currículo enviado com sucesso!',
                  		  showConfirmButton: false,
                  		  timer: 1200
                  		});
                  		
                  		setTimeout(function(){ 
                  			document.getElementById("myForm").submit();
                  		}, 1200);
                  		
                  	}
                  
               </script>
               <form id="myForm" method="post" enctype="multipart/form-data" style="line-height: 1.2;">
			      <!--INPUT SERVA PARA GRAVAR O LINK DE DESTINO DO LOCATION APOS INSERÇÃO-->
                  <input type="hidden" id="link_destino" name="link_destino" value="" >
                  <div class="row g-3">
                     <div class="col-md-12">
                        <div class="form-floating">
                           <input type="text" class="form-control border-0 bg-light" id="cur_nome_candidato" name="cur_nome_candidato" placeholder="Seu Nome"/>
                           <label for="name"><?php if($_SESSION['target'] == 'pt-br'){echo 'Seu Nome';}else{echo GoogleTranslate::translate($_SESSION['source'], $_SESSION['target'],'Seu Nome');} ?></label>
                        </div>
                     </div>
                     <div class="col-md-12">
                        <div class="form-floating">
                           <input type="email" class="form-control border-0 bg-light" id="cur_email_candidato" name="cur_email_candidato" placeholder="Seu Email"/>
                           <label for="email"><?php if($_SESSION['target'] == 'pt-br'){echo 'Seu E-mail';}else{echo GoogleTranslate::translate($_SESSION['source'], $_SESSION['target'],'Seu E-mail');} ?></label>
                        </div>
                     </div>
                     <div class="col-12">
                        <div class="form-floating">
                           <input type="text" class="form-control border-0 bg-light phone-inputmask" id="cur_telefone_candidato" name="cur_telefone_candidato" placeholder="Subject"/>
                           <label for="subject"><?php if($_SESSION['target'] == 'pt-br'){echo 'Telefone';}else{echo GoogleTranslate::translate($_SESSION['source'], $_SESSION['target'],'Telefone');} ?></label>
                        </div>
                     </div>
                     <div class="col-12">
                        <div class="form-floating">
                           <input type="file" id="cur_curriculo" name="cur_curriculo" class="form-control border-0 bg-light"  placeholder="Currículo" type="file" accept="image/png, image/jpeg, image/gif, application/pdf"/>
                           <label for="subject"></label>
                        </div>
                     </div>
                     <div class="col-12">
                        <button onClick="check_form()" type="button" name="enviar" class="btn btn-primary py-3 px-5" >
                        <?php if($_SESSION['target'] == 'pt-br'){echo 'Enviar';}else{echo GoogleTranslate::translate($_SESSION['source'], $_SESSION['target'],'Enviar');} ?>
                        </button>
                     </div>
                  </div>
               </form>
            </div>
         </div>
      </div>
      </div>
      <!-- About End -->
      <!-- Team Start -->
      <!-- Team End -->
      <!-- Footer Start -->
      <?php include "rodape.php" ?>
      <!-- Footer End -->
      <!-- Back to Top -->
      <a href="#" class="btn btn-lg btn-primary btn-lg-square back-to-top"
         ><i class="bi bi-arrow-up"></i
         ></a>
		 
	<!--Sweet Alert--> 
	  <script src="admin/js/sweetalert2@10.js"></script>	 
	  <script src="admin/js/scripts/extensions/sweet-alerts.min.js"></script>	  
	  <!--Máscara-->
      <script src="admin/vendors/js/forms/extended/inputmask/jquery.inputmask.bundle.min.js"></script>
      <script src="admin/js/scripts/forms/extended/form-inputmask.min.js"></script>
      <!-- JavaScript Libraries -->
      <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/js/bootstrap.bundle.min.js"></script>
      <script src="lib/wow/wow.min.js"></script>
      <script src="lib/easing/easing.min.js"></script>
      <script src="lib/waypoints/waypoints.min.js"></script>
      <script src="lib/owlcarousel/owl.carousel.min.js"></script>
      <!-- Template Javascript -->
      <script src="js/main.js"></script>
   </body>
</html>
