/** * @Route("/{_locale}/project/deleteProject/{id}",name="deleteProject") */ public function deleteProjectAction(Request $request, $id) { $encryption = new Encryption(); $message = ""; $model = new ProjectModel($this->getDoctrine()->getEntityManager()); try { $model->mettrePoubelle($encryption->decode($id)); $message = "succed"; } catch (Exception $ex) { $message = $ex->getMessage(); } return new Response($message); }
/** * @Route("/{_locale}/trash/ajaxtrashedProjects",name="ajaxtrashedProjects") */ public function ajaxtrashedProjectsAction(Request $request) { $encryption = new Encryption(); $model = new TrashModel($this->getDoctrine()->getEntityManager()); $projects = $model->listTrashedProjects(1, 0, 100); $output = array('data' => array()); foreach ($projects as $project) { $date = $project->getDateCreation(); $dateFormat = "-------"; $projectId = $encryption->encode($project->getId()); if ($date != null) { $dateFormat = $date->format('Y-m-d'); } $output['data'][] = ['title' => $project->getTitle(), 'note' => $project->getNote(), 'date' => $dateFormat, 'action' => '<a href="editProject/' . $projectId . '" class="actions"><i class="fa fa-fw fa-edit"></i></a> <a href="deleteProject/' . $projectId . '" class="actions"><i class="fa fa-fw fa-trash-o"></i></a>']; } return new Response(json_encode($output), 200, ['Content-Type' => 'application/json']); }
/** * @Route("/{_locale}/admin/experiences/", name="experiences") */ public function experiencesAction(Request $req) { $message = ""; $action = ""; $isValid = true; $modelProfil = new ProfilModel($this->getDoctrine()->getEntityManager()); $encryption = new Encryption(); /** verfier que les parametres dans la requete */ $titre = $req->get("titre"); $firstdate = $req->get("firstdate"); $seconddate = $req->get("seconddate"); $description = $req->get("description"); $idExperience = $req->get("idExperience"); /** validate the attributes */ /** if valide make change */ if ($isValid) { $model = new UserModel($this->getDoctrine()->getEntityManager()); $user = $this->getUser(); if ($user != null) { /***** we test if the id of Experience is not null, if it's than we create a new Experience */ if ($idExperience != null) { /** we modify this diplome */ $experience = $modelProfil->getExperience($idExperience); if ($experience != null) { $experience->setTitre($titre); $experience->setDescription($description); $experience->setDatestart(new \DateTime($firstdate)); $experience->setDateend(new \DateTime($seconddate)); $modelProfil->updateExperience($experience); $message = "You changes have been successfuly done"; } else { $message = "Your Changes can not be done !."; } $action = "update"; } else { /*** diplome has not been created, and we create it right here */ $experience = new Experience(); $experience->setTitre($titre); $experience->setDescription($description); $experience->setDatestart(new \DateTime($firstdate)); $experience->setDateend(new \DateTime($seconddate)); $experience->setUser($user); $idExperience = $modelProfil->addExperience($experience); $idExperienceEncripted = $encryption->encode($idExperience); $action = "persist"; $message = "You changes have been successfuly done"; } } else { /** if user dos not exist */ $message = "This action can not be done, because of authentification problem."; } } else { /** if parametres are not valid */ $message = "This Change can not be done !!!"; } /** delete diplome if param action=delete */ if ($req->get("delete") != null) { $modelProfil->deleteExperience($idExperience); $action = "delete"; $message = "You changes have been successfuly done"; } $output = array("message" => $message, "action" => $action, "form" => "experiences", "idExperience" => $idExperience); return new Response(json_encode($output), 200, ['Content-Type' => 'application/json']); }