/** * Initialize the AddController 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 == 'AddController') { if (file_exists(_CUSTOMERS_VIEWS_ . '/' . $this->view_name . '.tpl')) { try { echo $this->twig->render($this->view_name . '.tpl', array('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 "' . _CUSTOMERS_VIEWS_ . '"!'); } } 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(_CUSTOMERS_MODELS_ . '/' . $this->model_name . 'Model.php')) { try { require_once _CUSTOMERS_MODELS_ . '/' . $this->model_name . 'Model.php'; Tools::getInstance()->createPost($_POST); if (!empty($_POST['firstName']) && !empty($_POST['lastName']) && !empty($_POST['adress']) && !empty($_POST['zipCode']) && !empty($_POST['city']) && !empty($_POST['telephone'])) { \Customer\AddModel::getInstance()->add_customer($_POST['lastName'], $_POST['adress'], $_POST['zipCode'], $_POST['city'], $_POST['telephone'], $_POST['firstName']); header('Location: /Cas-M-Ping/customers/show/all'); } else { header('Location: /Cas-M-Ping/customers/add'); } } 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 "' . _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 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(_CUSTOMERS_MODELS_ . '/' . $this->model_name . 'Model.php')) { if (file_exists(_CUSTOMERS_VIEWS_ . '/' . $this->view_name . '.tpl')) { try { require_once _CUSTOMERS_MODELS_ . '/' . $this->model_name . 'Model.php'; $id = Tools::getInstance()->getUrl_id($url); $data = \Customer\DisplayModel::getInstance()->display_customer($id); echo $this->twig->render($this->view_name . '.tpl', array('customer' => $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 "' . _CUSTOMERS_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 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(_CUSTOMERS_MODELS_ . '/' . $this->model_name . 'Model.php')) { try { require_once _CUSTOMERS_MODELS_ . '/' . $this->model_name . 'Model.php'; $id = Tools::getInstance()->getUrl_id($url); switch ($id) { case 'all': \Customer\DeleteModel::getInstance()->delete_Customers(); break; default: if (\Customer\DeleteModel::getInstance()->has_customer($id) == 1) { \Customer\DeleteModel::getInstance()->delete_Customer($id); } else { header('Location: /Cas-M-Ping/errors/404'); } break; } header('Location: /Cas-M-Ping/customers/show/all'); } catch (Exception $e) { throw new Exception('Une erreur est survenue durant la supression des données: ' . $e->getMessage()); } } 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!'); } }