コード例 #1
0
 /**
  * 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(_RENTALS_MODELS_ . '/' . $this->model_name . 'Model.php')) {
                 if (file_exists(_RENTALS_VIEWS_ . '/' . $this->view_name . '.tpl')) {
                     try {
                         require_once _RENTALS_MODELS_ . '/' . $this->model_name . 'Model.php';
                         $id = Tools::getInstance()->getUrl_id($url);
                         $data = \Rental\DisplayModel::getInstance()->display_rental($id);
                         echo $this->twig->render($this->view_name . '.tpl', array('rental' => $data[0], '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 "' . _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!');
     }
 }
コード例 #2
0
 /**
  * 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!');
     }
 }
コード例 #3
0
 /**
  * Initialize the RentalController class
  */
 public function init()
 {
     if (self::$initialized) {
         return;
     }
     self::$initialized = true;
     if (file_exists(_TWIG_AUTOLOADER_)) {
         try {
             require_once _TWIG_AUTOLOADER_;
             Twig_Autoloader::register();
             $loader = new Twig_Loader_Filesystem(array(_DEPENDENCIES_DIR_, _RENTALS_VIEWS_));
             $this->twig = new Twig_Environment($loader, array('cache' => _TWIG_CACHE_));
         } catch (Exception $e) {
             throw new Exception('Le fichier de démarrage Twig ne peut pas s\'executer!');
         }
     } else {
         throw new Exception('Il n\'existe pas le fichier de démarrage Twig à cet emplacement "' . _TWIG_AUTOLOADER_ . '"!');
     }
 }
コード例 #4
0
 /**
  * Initialize the DeleteController 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 == 'DeleteController') {
             if (file_exists(_RENTALS_MODELS_ . '/' . $this->model_name . 'Model.php')) {
                 try {
                     require_once _RENTALS_MODELS_ . '/' . $this->model_name . 'Model.php';
                     $id = Tools::getInstance()->getUrl_id($url);
                     switch ($id) {
                         case 'all':
                             \Rental\DeleteModel::getInstance()->delete_rentals();
                             break;
                         default:
                             if (\Rental\DeleteModel::getInstance()->has_rental($id) == 1) {
                                 \Rental\DeleteModel::getInstance()->delete_rental($id);
                             } else {
                                 header('Location: /Cas-M-Ping/errors/404');
                             }
                             break;
                     }
                     header('Location: /Cas-M-Ping/rentals/show/all');
                 } catch (Exception $e) {
                     throw new Exception('Une erreur est survenue durant la suppression des données: ' . $e->getMessage());
                 }
             } 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!');
     }
 }
コード例 #5
0
 /**
  * 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(_RENTALS_MODELS_ . '/' . $this->model_name . 'Model.php')) {
                 try {
                     require_once _RENTALS_MODELS_ . '/' . $this->model_name . 'Model.php';
                     $id = Tools::getInstance()->getUrl_id($url);
                     $datetime1 = new DateTime($_POST['beginDate']);
                     $datetime2 = new DateTime($_POST['endDate']);
                     $interval = $datetime1->diff($datetime2);
                     Tools::getInstance()->createPost($_POST);
                     if (!empty($_POST['name']) && !empty($_POST['beginDate']) && !empty($_POST['endDate']) && !empty($_POST['peopleNumber']) && $interval->days > 0 && !empty($_POST['paymentState'])) {
                         \Rental\ModifyModel::getInstance()->modify_model($_POST['name'], $_POST['beginDate'], $_POST['endDate'], $_POST['peopleNumber'], '', $_POST['paymentState'], $interval->days, $_POST['deposit'], $id);
                         header('Location: /Cas-M-Ping/rentals/show/' . $id);
                     } else {
                         header('Location: /Cas-M-Ping/rentals/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_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!');
     }
 }
コード例 #6
0
 /**
  * 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!');
     }
 }
コード例 #7
0
 /**
  * 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!');
     }
 }