<?php

//USING
require_once '../Class/model/LoginModel.php';
require_once '../Class/controller/LoginControl.php';
require_once '../Class/controller/LoginControl.php';

$control = new LoginControl();
$model = new LoginModel();

$control->setAction();
$control->setId();

$action = $control->getAction();
$id = $control->getId();

//LoadDados
if ($id > 0)
{
	$model->load($id);
}

if($action == 'login')
{
	$result = $control->RealizaLogin();

	if($result != 0)
	{
		session_start();
		$_SESSION['login'] = $result;
		header( 'Location: index.php' );
	}
	elseif ($result == "senha")
	{
		echo "<script type='text/javascript'>";
		echo "alert('Verifique os dados de acesso, login ou senha incorreto.')";
		echo "</script>";
	}
	else
	{
		echo "<script type='text/javascript'>";
		echo "alert('Ocorreu um erro durante a gravação')";
		echo "</script>";
	}
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>Módulo Financeiro - Login</title>

<?php include_once('controls/import.php'); ?>
<script src="js/usuarios.js" type="text/javascript"></script>

</head>
<body>

<div class="header_out">
<div class="header">

<h1 class="logotipo"><a href="/sistema/">modulofinanceiro</a></h1>

<span class="clear"><span>&nbsp;</span></span></div>
</div>

<div class="content">

<h2>Login</h2>

<hr />
<div class="login">
	<form id="frmRegister" method="post" action="">
	<input type="hidden" id="hdnAction" name="action" value="login" /> 

	<span>Login:</span> 
	<input type="text" id="login" name="login" class="required text" /> 
	
	<span>Senha:</span>
	<input type="password" id="senha" name="senha" /> 
	
	<input type="submit" id="btnLogin" name="btnLogin" class="submit" value="Entrar" /> 
	<span class="clear"><span>&nbsp;</span></span>
	
</form>
</div>

</div>

<div class="footer_out">

<div class="footer">
<p>Módulo Financeiro - Login</p>

</div>
</div>

</body>
</html>
