<?php
include("conexao.php");
include_once("functions.php");
include_once(Idioma(1));
$idioma = empty($_COOKIE['idioma']) ? "br" : $_COOKIE['idioma'];
$lang = empty($_GET['lang']) ? "" : $_GET['lang'];
if(!empty($lang)) SalvarIdioma($lang);
global $_TRA;
$VerificarInfoSite = VerificarInfoSite();

$GET = empty($_GET['r']) ? "" : $_GET['r'];
$CadUser = UrlTeste(2, $GET);

//Verificar se o revendedor tem acessos para criar testes
$grupo = "N";
$SQLUrlT = "SELECT RevUrldeTeste FROM rev WHERE CadUser = :CadUser AND grupo = :grupo";
$SQLUrlT = $painel_acessos->prepare($SQLUrlT);
$SQLUrlT->bindParam(':CadUser', $CadUser, PDO::PARAM_STR);
$SQLUrlT->bindParam(':grupo', $grupo, PDO::PARAM_STR);
$SQLUrlT->execute();
$LnUrlT = $SQLUrlT->fetch();
$RevUrldeTeste = $LnUrlT['RevUrldeTeste'];

$VerTeste = VerTeste($CadUser);
$TempoDias = $VerTeste[1] > 1 ? $_TRA['dias'] : $_TRA['dia'];

if( ($VerTeste[0] == 1) && ($RevUrldeTeste == "S") ){
?>

<!DOCTYPE html>
<html lang="<?php echo $idioma; ?>" class="body-full-height">
    <head>        
        <!-- META SECTION -->
        <title><?php echo $VerificarInfoSite[0]; ?></title>            
        <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" />
        
        <link rel="icon" href="favicon.ico" type="image/x-icon" />
        <!-- END META SECTION -->
        
        <!-- CSS INCLUDE -->        
        <link rel="stylesheet" type="text/css" id="theme" href="css/<?php echo $VerificarInfoSite[2]; ?>.css"/>
        <!-- EOF CSS INCLUDE -->                               
    </head>
    <body>
        
        <div class="registration-container">            
            <div class="registration-box animated fadeInDown">
                <div class="registration-logo"><?php echo $VerificarInfoSite[0]; ?></div>
				<div class="registration-legenda"><?php echo $VerificarInfoSite[1]; ?></div>
                <div class="registration-body">
                    <div class="registration-title"><strong><?php echo $_TRA['ct']; ?></strong>, <?php echo $VerTeste[1]." ".$TempoDias; ?></div>
                                        
                    <form action="javascript:MDouglasMS();" class="TesteCadastrar form-horizontal" method="post" id="FormLogin">
                    
                    <h4><?php echo $_TRA['dp']; ?></h4>
                    <div class="form-group">
                        <div class="col-md-12">
                            <input name="nome" id="nome" type="text" class="form-control" placeholder="<?php echo $_TRA['nome']; ?>"/>
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <div class="col-md-12">
                            <input name="email" id="email" type="text" class="form-control" placeholder="<?php echo $_TRA['email']; ?>"/>
                        </div>
                    </div>
                    
                    <h4><?php echo $_TRA['Operadora']; ?></h4>
                    
                    <div class="form-group">
                    	<div class="col-md-12">                                        
                        	<select class="form-control select" id="Operadora" name="Operadora">
							<?php echo SelectOperadora($CadUser); ?>
                            </select>
                         </div>
                    </div>
                                         
                    <div class="form-group push-up-30">
                        <div class="col-md-12">
                        	<div id="StatusCadastro"></div>
                            <input name="r" id="r" type="hidden" value="<?php echo $GET; ?>"/>
                            <button class="CadastrarTeste btn btn-danger btn-block"><?php echo $_TRA['ct']; ?></button>
                        </div>
                    </div>
                    </form>
                </div>
                <div class="registration-footer">
                    <div class="pull-left">
                        &copy; 2017 <?php echo $VerificarInfoSite[0]; ?>
                    </div>
                    <div class="pull-right">
                       <?php echo $_TRA['Programador']; ?> # <?php echo $VerificarInfoSite[0]; ?>
                    </div>
                </div>
            </div>
            
        </div>
        
        <div id="StatusGeral"></div>  
        
 		 <!-- START PLUGINS -->
        <script type="text/javascript" src="js/plugins/jquery/jquery.min.js"></script>
        <script type="text/javascript" src="js/plugins/jquery/jquery-ui.min.js"></script>
        <script type="text/javascript" src="js/plugins/bootstrap/bootstrap.min.js"></script>
        <!-- END PLUGINS -->
  
        <script type='text/javascript' src='js/plugins/bootstrap/bootstrap-select.js'></script>        

        
        <script type="text/javascript" src="js/plugins.js"></script>
        <script type="text/javascript" src="js/actions.js"></script>
        <!-- END TEMPLATE -->
      
    </body>
</html>

<script type="text/javascript">
$(function(){  
 $("button.CadastrarTeste").click(function() {
	 
	 	panel_refresh($(".registration-container")); 
  
 		var Data = $(".TesteCadastrar").serialize();
				
		$.post('EnviarCadTeste.php', Data, function(resposta) {
			
				setTimeout(function(){
            		panel_refresh($(".registration-container")); 
        		},500);	
			
				$("#StatusGeral").append(resposta);
		});
	});
});
</script>

<?php
}else{
	echo Redirecionar('login.php');
}
?>





