<?php
 include_once('conexao.php');
 include_once('controller.php');
 include_once('funcao.php');
 include_once('DAO/DAOdepoimentos.php');
 include_once('classes/depoimentos.php');
 
 $instance     = new funcao();
 $conn         = new Conexao();
 $depoimentos  = new DAOdepoimentos();
 $u  = new depoimentos();
 
 //$encoding = mb_internal_encoding();
 
 if($_GET["acao"] == 'editar'){
	 $acao = 'atulizado';

 }else{
	  $acao = 'gravado'; 
	
 }

	
	
	if(!empty($_GET["dep_id"])){

		$result = $depoimentos->pesquisardepoimentos($_GET["dep_id"]);
		foreach($result as $row){
			$dep_id = $row["dep_id"];
			$dep_texto = $row["dep_texto"];
			$dep_pessoa = $row["dep_pessoa"];
			$dep_cargo = $row["dep_cargo"];
			
		}
	}
	
	if (isset($_POST["dep_id"])) {
		


		
		
		$u->setDep_id($_GET["dep_id"]);
		$u->setDep_texto($_POST["dep_texto"]);
		$u->setDep_pessoa($_POST["dep_pessoa"]);
		$u->setDep_cargo($_POST["dep_cargo"]);

		$depoimentos->Atualizar($u);
		
		

		/*
		if ($depoimentos->Atualizar($z)){
			 $msg = "depoimentos Atualizado com Sucesso!";
		}else{
			$msg = "ERRO: ao cadastrar META!";
		}
			$instance->alerta("depoimentos Cadastrado com Sucesso!","view-depoimentos.php");
			*/
			$link_destino = $_POST['link_destino'];
			header("Location: $link_destino");

		
	}
?>
<!DOCTYPE html>
<html class="loading" lang="pt-br" data-textdirection="ltr">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
      <meta name="description" content="Geoveris">
      <meta name="keywords" content="admin template, robust admin template, dashboard template, flat admin template, responsive admin template, web app, crypto dashboard, bitcoin dashboard">
      <!--<meta name="author" content="PIXINVENT">-->
      <title><?php include "titulo.php" ?></title>
      <link rel="apple-touch-icon" href="images/ico/apple-icon-120.png">
      <!--Favicon-->
      <link rel="icon" href="images/favicon.png">
      <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i%7CMuli:300,400,500,700" rel="stylesheet">
	  	
		<link rel="stylesheet" type="text/css" href="fonts/feather/style.min.css">
		<link rel="stylesheet" type="text/css" href="fonts/simple-line-icons/style.min.css">
		<link rel="stylesheet" type="text/css" href="fonts/flag-icon-css/css/flag-icon.min.css">
		<link rel="stylesheet" type="text/css" href="vendors/css/extensions/pace.css">
		<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
		
      <!-- BEGIN VENDOR CSS-->
      <link rel="stylesheet" href="assets/font-awesome-4.7.0/css/font-awesome.min.css">
	
	  
	  <!--<link rel="stylesheet" type="text/css" href="vendors/css/extensions/sweetalert.css">-->
     
	 <link rel="stylesheet" type="text/css" href="vendors/css/forms/selects/select2.min.css">
      <link rel="stylesheet" type="text/css" href="vendors/css/forms/icheck/icheck.css">
      <link rel="stylesheet" type="text/css" href="vendors/css/forms/icheck/custom.css">
      <link rel="stylesheet" type="text/css" href="vendors/css/charts/morris.css">
      <link rel="stylesheet" type="text/css" href="vendors/css/extensions/unslider.css">
      <link rel="stylesheet" type="text/css" href="vendors/css/weather-icons/climacons.min.css">
      <!-- END VENDOR CSS-->
      <!-- BEGIN ROBUST CSS-->
      <link rel="stylesheet" type="text/css" href="css/app.min.css">
      <!-- END ROBUST CSS-->
      <!-- BEGIN Page Level CSS-->
      <link rel="stylesheet" type="text/css" href="css/core/menu/menu-types/horizontal-top-icon-menu.min.css">
      <link rel="stylesheet" type="text/css" href="css/core/colors/palette-climacon.css">
      <link rel="stylesheet" type="text/css" href="css/pages/users.min.css">
      <!-- END Page Level CSS-->
      <!-- BEGIN Custom CSS-->
      <link rel="stylesheet" type="text/css" href="assets/css/style.css">
      <!-- END Custom CSS-->
      <style>
         .card.card-fullscreen {
		display: block;
		z-index: 9999;
		position: fixed;
		width: 100% !important;
		height: 100% !important;
		top: 99px;
		right: 0;
		left: 0;
		bottom: 0;
		overflow: auto;
		}
		 
		 form .form-actions {
		 border-top: 1px solid #FFF;
		 padding: 1px 0;
		 margin-top: 20px;
		 }	
		 
		 @media screen and (max-width: 700px) {
			div.dt-buttons {
				float: none;
				width: 100%;
				text-align: center;
				margin-bottom: 3.5em;
			}	
}
		 
			 
      </style>
   </head>
   <body class="horizontal-layout horizontal-top-icon-menu 2-columns   menu-expanded" data-open="hover" data-menu="horizontal-menu" data-col="2-columns">
      <!-- Menu-->
      <?php include "menu.php" ?>
	  
	  
	   <?php
	   function selected( $value, $selected ){
			return $value==$selected ? ' selected="selected"' : '';
			}
	   ?>
   
      <!-- Horizontal navigation-->
      <div class="app-content content">
         <div class="content-wrapper">		
		   <div class="content-header row">
			  <div class="content-header-left col-md-6 col-12 mb-2">
				<h3 class="content-header-title"><i class="icon-note"></i>Cadastros</h3>
				<h5 class="content-header-title" style="margin-left: 7px;"><i class="ft-corner-down-right"></i><a href="view-lista-depoimentos.php" style="font-size: 12px;">Listar Depoimento</a></h5>
				<h5 class="content-header-title" style="margin-left: 17px;"><i class="ft-corner-down-right"></i><a href="view-depoimentos.php" style="font-size: 12px;">Cadastro Depoimento</a></h5>      
			  </div>        
			</div>
			
       <div class="content-body">
               <!-- Basic form layout section start -->
               <section id="basic-form-layouts">
                  <div class="row justify-content-md-center">
                     <div class="col-md-8">
                        <div class="card" style="margin-top: -100px;">
                           <div class="card-header">
                              <h4 class="card-title" id="basic-layout-card-center">Cadastro Depoimento</h4>
                              <a class="heading-elements-toggle"><i class="fa fa-ellipsis-v font-medium-3"></i></a>
                              <div class="heading-elements">
                                 <ul class="list-inline mb-0">
								 
								    <li><a href="view-lista-depoimentos.php"><i class="ft-eye" style="font-size: 19px;"></i>
									<li><a data-action="collapse"><i class="ft-minus" style="font-size: 19px;"></i></a></li>
									<li><a data-action="reload"><i class="ft-rotate-cw" style="font-size: 19px;"></i></a></li>
									<li><a data-action="expand"><i class="ft-maximize" style="font-size: 19px;"></i></a></li>
									<li><a data-action="close"><i class="ft-x" style="font-size: 19px;"></i></a></li>
                                 </ul>
                              </div>
                           </div>
                           <div class="card-content collapse show">
                              <div class="card-body">	

									<script>
									//FUNÇÃO QUE CHECA FOMRULÁRIO ANTES DE ENVIAR

										function check_form(destino){
											
											if(destino == '1'){
												$("#link_destino").val('view-depoimentos.php');
											}else{
												$("#link_destino").val('view-lista-depoimentos.php');
											};
											
											if(!$("#dep_texto").val()){
												Swal.fire({
												  icon: 'error',
												  title: 'Oops...',
												  text: 'Preencher todos os campos obrigatórios!'
												  });
												return false;
											}
											
											Swal.fire({
											  position: 'center',
											  icon: 'success',
											  title: 'depoimentos <?php echo $acao; ?> 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;">
                                 <!--<form class="form" style="line-height: 1.2;">-->
                                    <div class="form-body">
                                       <div class="row">
									   
									   <!--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="col-md-2">
                                             <div class="form-group">
                                                <label for="Codigo">Código</label>												
                                                <input type="text" class="form-control" id="dep_id" name="dep_id" readonly value="<?php echo $id_insercao;?>" style="font-size: 12px;">
                                             </div>
                                          </div>
                                          <div class="col-md-12">
                                             <div class="form-group">
                                                <label for="Pergunta">Texto</label>
                                                <input type="text" class="form-control" id="dep_texto" name="dep_texto" value="<?php echo $dep_texto; ?>" style="font-size: 12px;" placeholder="" >
                                             </div>
                                          </div> 
										  
										    <div class="col-md-12">
                                             <div class="form-group">
                                                <label for="Resposta">Pessoa</label>
                                                <input type="text" class="form-control" id="dep_pessoa" name="dep_pessoa" value="<?php echo $dep_pessoa; ?>" style="font-size: 12px;" placeholder="" >
                                             </div>
                                          </div> 
										  
										    <div class="col-md-12">
                                             <div class="form-group">
                                                <label for="Cargo">Cargo</label>
                                                <input type="text" class="form-control" id="dep_cargo" name="dep_cargo" value="<?php echo $dep_cargo; ?>" style="font-size: 12px;" placeholder="" >
                                             </div>
                                          </div>

										 
							  
										  
                                       </div>
									   
									   

									
										  					   
							   
                                    </div>
                                    <div class="form-actions center">
									

									 <?php if($acao == 'gravado'){ ?>
                                       <button onClick="check_form(1)" type="button" name="enviar_inc_novo" id="" class="btn btn-success">
                                       <i class="fa fa-check-square-o"></i> Salvar e Incluir Novo
                                       </button>
									 <?}?> 
									  
									   <button onClick="check_form(2)" type="button" name="enviar" id="" class="btn btn-success">
									   <i class="fa fa-check-square-o"></i> Salvar
									   </button>
									 
									   
									   <a href="view-lista-depoimentos.php">
                                       <button type="button" class="btn btn-danger mr-1">
                                       <i class="ft-x"></i> Cancelar
                                       </button>
									</a>
                                    </div>
									</form>
                              </div>
                           </div>
                        </div>
                     </div>
                  </div>
               </section>
               <!-- // Basic form layout section end -->
            </div>
         </div>
      </div>
      <!-- ////////////////////////////////////////////////////////////////////////////-->
      <?php include "footer.php" ?>
	  	  
	  <script src="js/sweetalert2@10.js"></script>
      <!-- BEGIN VENDOR JS-->
      <script src="vendors/js/vendors.min.js"></script>
      <!-- BEGIN VENDOR JS-->
      <!-- BEGIN PAGE VENDOR JS--> 
      <script src="vendors/js/ui/jquery.sticky.js"></script>
      <script src="vendors/js/charts/jquery.sparkline.min.js"></script>
	  <!--<script src="vendors/js/extensions/sweetalert.min.js"></script>-->
      <script src="vendors/js/forms/select/select2.full.min.js"></script>
      <!-- END PAGE VENDOR JS-->
      <!-- BEGIN ROBUST JS-->
      <script src="js/core/app-menu.min.js"></script>
      <script src="js/core/app.min.js"></script>
      <script src="js/scripts/customizer.min.js"></script>
      <!-- END ROBUST JS-->
      <!-- BEGIN PAGE LEVEL JS-->
      <script src="js/scripts/ui/breadcrumbs-with-stats.min.js"></script>
	  <script src="js/scripts/extensions/sweet-alerts.min.js"></script>
      <script src="js/scripts/forms/select/form-select2.min.js"></script>
	  <script src="js/scripts/navs/navs.min.js"></script>
      <!-- END PAGE LEVEL JS-->
	  <!--Máscara-->
	   <script src="vendors/js/forms/extended/inputmask/jquery.inputmask.bundle.min.js"></script>
	   <script src="js/scripts/forms/extended/form-inputmask.min.js"></script>
	   
	   
	   <!--<script src="js/jquery.3.2.1.min.js"></script>-->
	   
	   
   </body>
   <!-- Mirrored from pixinvent.com/bootstrap-admin-template/robust/html/ltr/horizontal-top-icon-menu-template/form-layout-basic.html by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 12 Feb 2021 19:25:59 GMT -->
</html>
	
	  <script>
	 // INICIO FUNÇÃO DE MASCARA MAIUSCULA
	function maiuscula(z){
		v = z.value.toUpperCase();
		z.value = v;
						 }
	//FIM DA FUNÇÃO MASCARA MAIUSCULA
	</script>
	
	
