<?php

require_once 'model/Login.Model.php';

class LoginController
{
    
    private $model;
    
    public function __CONSTRUCT()
    {
        $this->model = new Login();
    }
    
    public function Logout()
    {
       
        /* Destruye la session de usuario, exigiendo un nuevo logueo */
        session_destroy();
        require_once 'views/header.php';
        require_once 'views/login.php';
        require_once 'views/footer.php';
    }   

    public function Index()
    {
        require_once 'views/header.php';
        require_once 'views/login.php';
        require_once 'views/footer.php';
    }   
	
	
	public function VerificarUsers()
  {
        /* Iniciando proceso de verificacion de usuario */

   
        $TmpUsr = $_REQUEST['usuario'];
        $TmpPwd = $_REQUEST['password'];
        $current_user_id =0;

        foreach($this->model->Esusuario_autenticado($TmpUsr,$TmpPwd) as $p)
        {
           $current_user_id = $p->idusuario;

           if($current_user_id>0)
           {
                $_SESSION["current_user_id"] = $current_user_id;
                
                break;
           }
          
        }         

       
        if($current_user_id<=0)
            {
              
              require_once 'alert.php';

            }
            else
            {
                require_once 'views/header.php';
                require_once 'views/leftmenu.php';  
                require_once 'views/main_desktop.php';  
                require_once 'views/footer.php';
            }



    }

} 