/**
  * Initialize the DisplayController class and their parents
  */
 public function init()
 {
     try {
         parent::init();
     } catch (Exception $e) {
         throw new Exception('Une erreur est survenue durant le chargement du module: ' . $e->getMessage());
     }
     if (file_exists(_CONTROLLERS_DIR_ . '/Tools.php')) {
         $url = Tools::getInstance()->request_url;
         $controller = Tools::getInstance()->getUrl_controller($url);
         if ($controller == 'DisplayController') {
             if (file_exists(_SECTORS_MODELS_ . '/' . $this->model_name . 'Model.php') && file_exists(_LOCATIONS_MODELS_ . '/' . $this->model_name . 'Model.php')) {
                 if (file_exists(_SECTORS_VIEWS_ . '/' . $this->view_name . '.tpl')) {
                     try {
                         require_once _SECTORS_MODELS_ . '/' . $this->model_name . 'Model.php';
                         require_once _LOCATIONS_MODELS_ . '/' . $this->model_name . 'Model.php';
                         $id = Tools::getInstance()->getUrl_id($url);
                         switch ($id) {
                             case 'all':
                                 $sectors = \Sector\DisplayModel::getInstance()->display_sectors();
                                 $locations = \Location\DisplayModel::getInstance()->display_locationAll();
                                 break;
                             default:
                                 if (\Sector\DisplayModel::getInstance()->has_sector($id) == 1) {
                                     $data = \Sector\DisplayModel::getInstance()->display_sector($id);
                                     $sectors = \Sector\DisplayModel::getInstance()->display_sector($id);
                                     $locations = \Location\DisplayModel::getInstance()->display_locationAll();
                                 } else {
                                     header('Location: /Cas-M-Ping/errors/404');
                                 }
                                 break;
                         }
                         echo $this->twig->render($this->view_name . '.tpl', array('sectors' => $sectors, 'locations' => $locations, 'bootstrapPath' => _BOOTSTRAP_FILE_));
                     } catch (Exception $e) {
                         throw new Exception('Une erreur est survenue durant la récupération des données: ' . $e->getMessage());
                     }
                 } else {
                     throw new Exception('Le template "' . $this->view_name . '" n\'existe pas dans "' . _SECTORS_VIEWS_ . '"!');
                 }
             } else {
                 throw new Exception('Le modèle "' . $this->model_name . '" n\'existe pas dans "' . _SECTORS_MODELS_ . '"!');
             }
         } else {
             throw new Exception('Une erreur est survenue durant la phase de routage!');
         }
     } else {
         throw new Exception('L\'URL n\'est pas évaluable!');
     }
 }
 /**
  * Initialize the ConfirmAddController class and their parents
  */
 public function init()
 {
     try {
         parent::init();
     } catch (Exception $e) {
         throw new Exception('Une erreur est survenue durant le chargement du module: ' . $e->getMessage());
     }
     if (file_exists(_CONTROLLERS_DIR_ . '/Tools.php')) {
         $url = Tools::getInstance()->request_url;
         $url .= '&id=ukn';
         $controller = Tools::getInstance()->getUrl_controller($url);
         if ($controller == 'ConfirmAddController') {
             if (file_exists(_RENTALS_MODELS_ . '/' . $this->model_nameDisplay . 'Model.php') && file_exists(_SEASONS_MODELS_ . '/' . $this->model_nameDisplay . 'Model.php') && file_exists(_LOCATIONS_MODELS_ . '/' . $this->model_nameDisplay . 'Model.php')) {
                 try {
                     require_once _RENTALS_MODELS_ . '/' . $this->model_nameDisplay . 'Model.php';
                     require_once _RENTALS_MODELS_ . '/' . $this->model_nameCreate . 'Model.php';
                     require_once _SEASONS_MODELS_ . '/' . $this->model_nameDisplay . 'Model.php';
                     require_once _LOCATIONS_MODELS_ . '/' . $this->model_nameDisplay . 'Model.php';
                     Tools::getInstance()->createPost($_POST);
                     $datetime1 = new DateTime($_POST['beginDate']);
                     $datetime2 = new DateTime($_POST['endDate']);
                     $interval = $datetime1->diff($datetime2);
                     if (!empty($_POST['rent_cust_id']) && !empty($_POST['rent_name']) && !empty($_POST['beginDate']) && !empty($_POST['location']) && !empty($_POST['endDate']) && !empty($_POST['person']) && !empty($_POST['price_c']) && !empty($_POST['val']) && $interval->days > 0) {
                         $date = \Season\displayModel::getInstance()->display_seasonCoeff($_POST['beginDate']);
                         $price = \Location\DisplayModel::getInstance()->display_location($_POST['location']);
                         $priceTT = $date[0]['seas_coeff'] * $price[0]['type_location_price'] * $interval->days + $_POST['price_c'];
                         \Rental\CreateModel::getInstance()->create_rental($_POST['rent_name'], $_POST['beginDate'], $_POST['endDate'], $_POST['person'], '', $_POST['price_c'], $interval->days, $priceTT, $_POST['rent_cust_id'], $_POST['val'], $_POST['location']);
                         header('Location: /Cas-M-Ping/rentals/show/all');
                     } else {
                         header('Location: /Cas-M-Ping/rentals/add');
                     }
                 } catch (Exception $e) {
                     throw new Exception('Une erreur est survenue durant l\'ajout des données: ' . $e->getMessage());
                 }
             } else {
                 throw new Exception('Le modèle "' . $this->model_nameDisplay . '" n\'existe pas dans "' . _RENTALS_MODELS_ . '"!');
             }
         } else {
             throw new Exception('Une erreur est survenue durant la phase de routage!');
         }
     } else {
         throw new Exception('L\'URL n\'est pas évaluable!');
     }
 }
 /**
  * Initialize the ModifyController class and their parents
  */
 public function init()
 {
     try {
         parent::init();
     } catch (Exception $e) {
         throw new Exception('Une erreur est survenue durant le chargement du module: ' . $e->getMessage());
     }
     if (file_exists(_CONTROLLERS_DIR_ . '/Tools.php')) {
         $url = Tools::getInstance()->request_url;
         $controller = Tools::getInstance()->getUrl_controller($url);
         if ($controller == 'ModifyController') {
             if (file_exists(_LOCATIONS_MODELS_ . '/' . $this->model_name . 'Model.php') && file_exists(_SECTORS_MODELS_ . '/' . $this->model_name . 'Model.php')) {
                 if (file_exists(_LOCATIONS_VIEWS_ . '/' . $this->view_name . '.tpl')) {
                     try {
                         require_once _LOCATIONS_MODELS_ . '/' . $this->model_name . 'Model.php';
                         require_once _SECTORS_MODELS_ . '/' . $this->model_name . 'Model.php';
                         $id = Tools::getInstance()->getUrl_id($url);
                         $sectors = \Sector\DisplayModel::getInstance()->display_sectors();
                         $type_locations = \Location\DisplayModel::getInstance()->display_TypeLocationModels();
                         $data = \Location\DisplayModel::getInstance()->display_location($id);
                         echo $this->twig->render($this->view_name . '.tpl', array('sectors' => $sectors, 'typeLocations' => $type_locations, 'id' => $data[0], 'bootstrapPath' => _BOOTSTRAP_FILE_));
                     } catch (Exception $e) {
                         throw new Exception('Une erreur est survenue durant l\'affichage des données: ' . $e->getMessage());
                     }
                 } else {
                     throw new Exception('Le template "' . $this->view_name . '" n\'existe pas dans "' . _LOCATIONS_VIEWS_ . '"!');
                 }
             } else {
                 throw new Exception('Le modèle "' . $this->model_name . '" n\'existe pas dans "' . _LOCATIONS_MODELS_ . '" ou "' . _SECTORS_MODELS_ . '"!');
             }
         } else {
             throw new Exception('Une erreur est survenue durant la phase de routage!');
         }
     } else {
         throw new Exception('L\'URL n\'est pas évaluable!');
     }
 }
 /**
  * Initialize the ConfirmModifyController class and their parents
  */
 public function init()
 {
     try {
         parent::init();
     } catch (Exception $e) {
         throw new Exception('Une erreur est survenue durant le chargement du module: ' . $e->getMessage());
     }
     if (file_exists(_CONTROLLERS_DIR_ . '/Tools.php')) {
         $url = Tools::getInstance()->request_url;
         $controller = Tools::getInstance()->getUrl_controller($url);
         if ($controller == 'ConfirmModifyController') {
             if (file_exists(_LOCATIONS_MODELS_ . '/' . $this->model_nameModify . 'Model.php') && file_exists(_LOCATIONS_MODELS_ . '/' . $this->model_nameDisplay . 'Model.php')) {
                 try {
                     require_once _LOCATIONS_MODELS_ . '/' . $this->model_nameModify . 'Model.php';
                     require_once _LOCATIONS_MODELS_ . '/' . $this->model_nameDisplay . 'Model.php';
                     $id = Tools::getInstance()->getUrl_id($url);
                     Tools::getInstance()->createPost($_POST);
                     if (!empty($_POST['sector']) && !empty($_POST['location'])) {
                         $data = \Location\DisplayModel::getInstance()->display_location($id);
                         \Location\ModifyModel::getInstance()->modify_location($data[0]['loc_sec_id'], $data[0]['loc_type_id'], $_POST['sector'], $_POST['location']);
                         header('Location: /Cas-M-Ping/locations/show/' . $id);
                     } else {
                         header('Location: /Cas-M-Ping/locations/modify/' . $id);
                     }
                 } catch (Exception $e) {
                     throw new Exception('Une erreur est survenue durant la modification des données: ' . $e->getMessage());
                 }
             } else {
                 throw new Exception('Le modèle "' . $this->model_nameModify . '" ou "' . $this->model_nameDisplay . '" n\'existe pas dans "' . _LOCATIONS_MODELS_ . '"!');
             }
         } else {
             throw new Exception('Une erreur est survenue durant la phase de routage!');
         }
     } else {
         throw new Exception('L\'URL n\'est pas évaluable!');
     }
 }
 /**
  * Initialize the CreateController class and their parents
  */
 public function init()
 {
     try {
         parent::init();
     } catch (Exception $e) {
         throw new Exception('Une erreur est survenue durant le chargement du module: ' . $e->getMessage());
     }
     if (file_exists(_CONTROLLERS_DIR_ . '/Tools.php')) {
         $url = Tools::getInstance()->request_url;
         $url .= '&id=ukn';
         $controller = Tools::getInstance()->getUrl_controller($url);
         if ($controller == 'CreateController') {
             if (file_exists(_CUSTOMERS_MODELS_ . '/' . $this->model_name . 'Model.php') && file_exists(_LOCATIONS_MODELS_ . '/' . $this->model_name . 'Model.php')) {
                 if (file_exists(_RENTALS_VIEWS_ . '/' . $this->view_name . '.tpl')) {
                     try {
                         require_once _CUSTOMERS_MODELS_ . '/' . $this->model_name . 'Model.php';
                         require_once _LOCATIONS_MODELS_ . '/' . $this->model_name . 'Model.php';
                         $customers = \Customer\DisplayModel::getInstance()->display_customers();
                         $locations = \Location\DisplayModel::getInstance()->display_locations();
                         echo $this->twig->render($this->view_name . '.tpl', array('customers' => $customers, 'locations' => $locations, 'bootstrapPath' => _BOOTSTRAP_FILE_));
                     } catch (Exception $e) {
                         throw new Exception('Une erreur est survenue durant l\'affichage des données: ' . $e->getMessage());
                     }
                 } else {
                     throw new Exception('Le template "' . $this->view_name . '" n\'existe pas dans "' . _RENTALS_VIEWS_ . '"!');
                 }
             } else {
                 throw new Exception('Le modèle "' . $this->model_name . '" n\'existe pas dans "' . _CUSTOMERS_MODELS_ . '"!');
             }
         } else {
             throw new Exception('Une erreur est survenue durant la phase de routage!');
         }
     } else {
         throw new Exception('L\'URL n\'est pas évaluable!');
     }
 }
 /**
  * Initialize the DisplayController class and their parents
  */
 public function init()
 {
     try {
         parent::init();
     } catch (Exception $e) {
         throw new Exception('Une erreur est survenue durant le chargement du module: ' . $e->getMessage());
     }
     if (file_exists(_CONTROLLERS_DIR_ . '/Tools.php')) {
         $url = Tools::getInstance()->request_url;
         $controller = Tools::getInstance()->getUrl_controller($url);
         if ($controller == 'DisplayController') {
             if (file_exists(_RENTALS_MODELS_ . '/' . $this->model_name . 'Model.php') && file_exists(_RENTALS_MODELS_ . '/' . $this->model_name . 'Model.php') && file_exists(_LOCATIONS_MODELS_ . '/' . $this->model_name . 'Model.php') && file_exists(_SEASONS_MODELS_ . '/' . $this->model_name . 'Model.php') && file_exists(_CARAVANS_MODELS_ . '/' . $this->model_name . 'Model.php')) {
                 if (file_exists(_RENTALS_VIEWS_ . '/' . $this->view_nameAll . '.tpl') && file_exists(_RENTALS_VIEWS_ . '/' . $this->view_nameId . '.tpl')) {
                     try {
                         require_once _RENTALS_MODELS_ . '/' . $this->model_name . 'Model.php';
                         require_once _LOCATIONS_MODELS_ . '/' . $this->model_name . 'Model.php';
                         require_once _SEASONS_MODELS_ . '/' . $this->model_name . 'Model.php';
                         require_once _CARAVANS_MODELS_ . '/' . $this->model_name . 'Model.php';
                         $id = Tools::getInstance()->getUrl_id($url);
                         switch ($id) {
                             case 'all':
                                 $data = \Rental\DisplayModel::getInstance()->display_rentals();
                                 echo $this->twig->render($this->view_nameAll . '.tpl', array('rentals' => $data, 'bootstrapPath' => _BOOTSTRAP_FILE_));
                                 break;
                             default:
                                 if (\Rental\DisplayModel::getInstance()->has_rental($id) == 1) {
                                     $rentals = \Rental\DisplayModel::getInstance()->display_rental($id);
                                     $seasons = array();
                                     $caravans = array();
                                     $locations = array();
                                     $buffer = null;
                                     for ($i = 0; $i < count($rentals); $i++) {
                                         $buffer = \Season\DisplayModel::getInstance()->get_SeasonByRental($rentals[$i]['rent_id']);
                                         if (count($buffer) > 0) {
                                             $seasons = array_merge($seasons, $buffer);
                                         }
                                         $buffer = null;
                                         $buffer = \Caravan\DisplayModel::getInstance()->get_caravanByRental($rentals[$i]['rent_id']);
                                         if (count($buffer) > 0) {
                                             $caravans = array_merge($caravans, $buffer);
                                         }
                                         $buffer = null;
                                         $buffer = \Location\DisplayModel::getInstance()->get_LocationByRental($rentals[$i]['rent_id']);
                                         if (count($buffer) > 0) {
                                             $locations = array_merge($locations, $buffer);
                                         }
                                         $buffer = null;
                                     }
                                     echo $this->twig->render($this->view_nameId . '.tpl', array('rental' => $rentals, 'seasons' => $seasons, 'caravans' => $caravans, 'locations' => $locations, 'bootstrapPath' => _BOOTSTRAP_FILE_));
                                 } else {
                                     header('Location: /Cas-M-Ping/errors/404');
                                 }
                                 break;
                         }
                     } catch (Exception $e) {
                         throw new Exception('Une erreur est survenue durant la récupération des données: ' . $e->getMessage());
                     }
                 } else {
                     throw new Exception('Le template "' . $this->view_nameAll . '" ou "' . $this->view_nameId . '" n\'existe pas dans "' . _RENTALS_VIEWS_ . '"!');
                 }
             } else {
                 throw new Exception('Le modèle "' . $this->model_name . '" n\'existe pas dans "' . _RENTALS_MODELS_ . '"!');
             }
         } else {
             throw new Exception('Une erreur est survenue durant la phase de routage!');
         }
     } else {
         throw new Exception('L\'URL n\'est pas évaluable!');
     }
 }