<?php

class VisitorController
{
    function __construct()
    {
        try {
            echo "VisitorController1\n";
            global $dsn, $rep, $vues, $error;
            $model = new VisitorModel();
            $action = $_REQUEST['action'];
            switch ($action) {
                case NULL:
                    $model->goToHome();
                    break;
                case "signUp":
                    $model->signUp();
                    break;
                case "login":
                    $model->login();
                    break;
                case "goToHome":
                    $model->goToHome();
                    break;
                case "goToLogin":
                    $model->goToLogin();
                    break;
                case "goToSignUp":
                    $model->goToSignUp();
                    break;
                case "goToQueue":
                    $model->goToLogin();
                    break;
                default:
                    $error = "Action non valide";
                    require($rep . $vues['erreur']);
                    break;
            }
        } catch (PDOException $e) {
            $error = $e->getMessage();
            require($rep . $vues['erreur']);
        } catch (Exception $e2) {
            $error = $e2->getMessage();
            require($rep . $vues['erreur']);
        }
    }
}