<?php
include(MODULE_ROOT."/functions.inc.php");
if(isset($_GET['logout'])){
	@session_unset();
	@session_destroy();
	@session_start();	
}else if($_SESSION['user']['logged']){
	header("Location: home/".$_SESSION['user']['grp']);
}

Login($_POST['cell'],$_POST['password']);

$p = new Page('Login');
$p->addCss('signin');
$p->addMenu('public');
$p->printHeader();
?>

<div class="panel panel-default panel-signin">
	<div class="panel-body">
    <form class="form-signin form-horizontal" role="form" onSubmit="return post(this,'f-result')">
    
        <h3 class="form-signin-heading top">Accedi al servizio</h3>
        <div class="form-group">
            <label class="control-label col-sm-4">Cellulare</label>
            <div class="col-sm-8">
                <input name="cell" type="text" class="input-lg form-control" autocomplete="off" value="<?php echo $_POST['cell'];?>" />
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-sm-4">Password</label>
            <div class="col-sm-8">
                <input name="password" type="password" class="input-lg form-control" value="<?php echo $_POST['password'];?>" />
                <div class="divider"></div>
			</div>
		</div>        
		<div id="f-result"><?php 
			if($loginMsg)
				echo $loginMsg;
			else if(isset($_GET['session_expired']))
				printMsg('Sessione scaduta. Eseguire nuovamente il login','warning',false);
		?>
	    </div>
        
        <button class="btn btn-lg btn-primary btn-block" type="submit">ENTRA</button>
	    <a class="btn btn-lg btn-info btn-block" href="./subscribe.html">Nuovo utente? Iscriviti ora</a>
        <br />
        <a href="javascript:;" data-open="modal" data-url="diag/pass_recovery/?for=<?php echo $_GET['e'];?>" data-small="1">Hai perso la password?</a>
    </form>
    </div>
</div>

<?php
$p->printFooter();
?>