Example #1
0
	public function frm($id=NULL){
		$ticket=$this->getInstance($id);
		if ($ticket->getTitre() != "") {
			$notif = DAO::getOne("Notification", 'idUser = '******' AND idTicket = '.$ticket->getId());
			if ($notif != null) {
				DAO::delete($notif);
			}
		}
		
		//recuperer les message associé au ticket
		DAO::getOneToMany($ticket,"messages");
		$messages=$ticket->getMessages();
		foreach ($messages as $message){
			$message->setUser(DAO::getAll("User", "id=".$message->getUser()->getId())[0]);
		}

		//recuperer la ou les catégorie(s) du ticket
		$categories=DAO::getAll("Categorie");
		if($ticket->getCategorie()==null){
			$cat=-1;
		}else{
			$cat=$ticket->getCategorie()->getId();
		}
		
		//permet la séléction d'une catégorie
		$listCat=Gui::select($categories,$cat,"Sélectionner une catégorie ...");
		$listType=Gui::select(array("demande","incident"),$ticket->getType(),"Sélectionner un type ...");

		//affiche la vue vAdd du ticket
		$this->loadView("ticket/vAdd",array("ticket"=>$ticket,"listCat"=>$listCat,"listType"=>$listType));
		//affiche la vue permettant l'affichage des information du ticket
		$this->loadView("ticket/vInfoTicket",array("ticket"=>$ticket,"listCat"=>$listCat,"listType"=>$listType));
		
		//div contenant les messages
		echo "<div class='container contentMessages'>";
		//charge les messages et les affiches
		$this->loadView("ticket/vMessage",array("messages"=>$messages, "ticket" => $ticket));
		//instancie CKEditor
		echo Jquery::executeOn('.submitMessage', "click", "
			for ( instance in CKEDITOR.instances )
        		CKEDITOR.instances[instance].updateElement();
		");
		//lors du clic sur le bouton submitMessage, éxécute l'update du message et l'affiche
		echo Jquery::postFormOn("click",".submitMessage","Messages/update","frm",".contentMessages");

		if($ticket->getTitre() != "") echo Jquery::execute("$('.panel-body.infoTicket').hide();");
		echo "</div>";
		
		echo Jquery::executeOn(".montreInfoTicket","click", 
				"$('.montreInfoTicket').toggleClass('glyphicon-chevron-up');
				$('.montreInfoTicket').toggleClass('glyphicon-chevron-down');
				$('.panel-body.infoTicket').slideToggle('slow');");
	}
Example #2
0
	public function updatePass(){
		$user = DAO::getOne("User", "id = ".$_SESSION['resetPass']['idUser']);
		if ($_POST['pass'] == $_POST['pass']) {
			$user->setPassword(password_hash($_POST['pass'], PASSWORD_BCRYPT));
			DAO::update($user);
			
			$token = DAO::getOne('Token', $_SESSION['resetPass']['token']);
			DAO::delete($token);
			$_SESSION['resetPass'] = null;
			return $this->_showMessage("Votre mot de passe a été correctement modifié. ".Auth::getInfoUser(), 'success');
		}else{
			return $this->_showMessage("Mots de passe différents !", 'warning');
		}
	}
 /**
  * Supprime l'instance dont l'id est $id dans la BDD
  * @param int $id
  */
 public function delete($id)
 {
     try {
         $object = DAO::getOne($this->model, $id[0]);
         if ($object !== NULL) {
             DAO::delete($object);
             $msg = new DisplayedMessage($this->model . " `{$object->toString()}` supprimé(e)");
         } else {
             $msg = new DisplayedMessage($this->model . " introuvable", "warning");
         }
     } catch (Exception $e) {
         $msg = new DisplayedMessage("Impossible de supprimer l'instance de " . $this->model, "danger");
     }
     $this->forward(get_class($this), "index", $msg);
 }