diff --git a/config/bundles.php b/config/bundles.php index ab3a797..68958c2 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -3,16 +3,16 @@ return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true], - Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], - Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], - Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], - Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true], Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true], Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], - KnpU\OAuth2ClientBundle\KnpUOAuth2ClientBundle::class => ['all' => true], + Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], + Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], + Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], + Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true], Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true], - Omines\DataTablesBundle\DataTablesBundle::class => ['all'=>true], + Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true], + Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true], ]; diff --git a/config/packages/dev/swiftmailer.yaml b/config/packages/dev/swiftmailer.yaml new file mode 100644 index 0000000..b98158e --- /dev/null +++ b/config/packages/dev/swiftmailer.yaml @@ -0,0 +1,4 @@ +# See https://symfony.com/doc/current/email/dev_environment.html +swiftmailer: + # send all emails to a specific address + #delivery_addresses: ['me@example.com'] diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 3853c3f..7ecc37b 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -1,10 +1,11 @@ security: - encoders: App\Entity\User: - algorithm: bcrypt + algorithm: auto + # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers providers: + # used to reload user from session & other features (e.g. switch_user) app_user_provider: entity: class: App\Entity\User @@ -14,18 +15,16 @@ security: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false main: - anonymous: true + anonymous: lazy provider: app_user_provider - form_login: - login_path: login - check_path: login - default_target_path: accueil - guard: authenticators: - - App\Security\GoogleAuthenticator + - App\Security\LoginAuthAuthenticator logout: - path: logout + path: app_logout + # where to redirect after logout + # target: app_any_route + # activate different ways to authenticate # https://symfony.com/doc/current/security.html#firewalls-authentication @@ -35,5 +34,5 @@ security: # Easy way to control access for large sections of your site # Note: Only the *first* access control that matches will be used access_control: - - { path: ^/admin/*, roles: ROLE_ADMIN } + # - { path: ^/admin, roles: ROLE_ADMIN } # - { path: ^/profile, roles: ROLE_USER } diff --git a/config/packages/swiftmailer.yaml b/config/packages/swiftmailer.yaml new file mode 100644 index 0000000..00c6bde --- /dev/null +++ b/config/packages/swiftmailer.yaml @@ -0,0 +1,13 @@ +swiftmailer: + url: '%env(MAILER_URL)%' + transport: gmail + host: smtp.gmail.com + port: 465 + encryption: ssl + auth-mode: login + spool: { type: 'memory' } + stream_options: + ssl: + allow_self_signed: true + verify_peer: false + verify_peer_name: false \ No newline at end of file diff --git a/config/packages/test/swiftmailer.yaml b/config/packages/test/swiftmailer.yaml new file mode 100644 index 0000000..f438078 --- /dev/null +++ b/config/packages/test/swiftmailer.yaml @@ -0,0 +1,2 @@ +swiftmailer: + disable_delivery: true diff --git a/config/routes.yaml b/config/routes.yaml index 782f0a2..c3283aa 100644 --- a/config/routes.yaml +++ b/config/routes.yaml @@ -1,9 +1,3 @@ -index: - path: / - controller: App\Controller\HomeController::index -#connect_facebook_check: -# path: /connect/facebook/check -# controller: App\Controller\FacebookController::connectCheckAction -# schemes: [https] - - +#index: +# path: / +# controller: App\Controller\DefaultController::index diff --git a/migrations/Version20210303130124.php b/migrations/Version20210303130124.php new file mode 100644 index 0000000..e3054ed --- /dev/null +++ b/migrations/Version20210303130124.php @@ -0,0 +1,35 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE gerant (id_gerant VARCHAR(16) NOT NULL, nom VARCHAR(10) NOT NULL, prenom VARCHAR(10) NOT NULL, date_nais DATE NOT NULL, ad_email VARCHAR(50) NOT NULL, cin VARCHAR(8) NOT NULL, PRIMARY KEY(id_gerant)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('DROP TABLE gerant'); + } +} diff --git a/migrations/Version20210304133126.php b/migrations/Version20210304133126.php new file mode 100644 index 0000000..de977e2 --- /dev/null +++ b/migrations/Version20210304133126.php @@ -0,0 +1,36 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE activity (id INT AUTO_INCREMENT NOT NULL, id_act VARCHAR(16) NOT NULL, type VARCHAR(16) NOT NULL, description VARCHAR(255) DEFAULT NULL, date_val DATE NOT NULL, categorie VARCHAR(255) NOT NULL, Id_gerant VARCHAR(16) NOT NULL, INDEX IDX_AC74095A75126B3E (Id_gerant), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB'); + $this->addSql('ALTER TABLE activity ADD CONSTRAINT FK_AC74095A75126B3E FOREIGN KEY (Id_gerant) REFERENCES gerant (Id_gerant)'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('DROP TABLE activity'); + } +} diff --git a/migrations/Version20210310132328.php b/migrations/Version20210310132328.php new file mode 100644 index 0000000..cfc0c77 --- /dev/null +++ b/migrations/Version20210310132328.php @@ -0,0 +1,39 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE activity (id INT AUTO_INCREMENT NOT NULL, id_act VARCHAR(16) NOT NULL, type VARCHAR(16) NOT NULL, description VARCHAR(255) DEFAULT NULL, date_val DATE NOT NULL, categorie VARCHAR(255) NOT NULL, Id_gerant VARCHAR(16) DEFAULT NULL, INDEX IDX_AC74095A75126B3E (Id_gerant), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB'); + $this->addSql('ALTER TABLE activity ADD CONSTRAINT FK_AC74095A75126B3E FOREIGN KEY (Id_gerant) REFERENCES gerant (id_gerant)'); + $this->addSql('DROP TABLE activities'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE activities (id INT AUTO_INCREMENT NOT NULL, id_act VARCHAR(16) NOT NULL COLLATE utf8mb4_unicode_ci, type VARCHAR(16) NOT NULL COLLATE utf8mb4_unicode_ci, description VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, date_val DATE NOT NULL, categorie VARCHAR(255) NOT NULL COLLATE utf8mb4_unicode_ci, Id_gerant VARCHAR(16) DEFAULT NULL COLLATE utf8mb4_unicode_ci, FULLTEXT INDEX IDX_B5F1AFE531481D1E8CDE5729F7E3E99D (id_act, type, Id_gerant), INDEX IDX_B5F1AFE575126B3E (Id_gerant), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB COMMENT = \'\' '); + $this->addSql('ALTER TABLE activities ADD CONSTRAINT FK_B5F1AFE575126B3E FOREIGN KEY (Id_gerant) REFERENCES gerant (id_gerant)'); + $this->addSql('DROP TABLE activity'); + } +} diff --git a/migrations/Version20210310151408.php b/migrations/Version20210310151408.php new file mode 100644 index 0000000..eb546cc --- /dev/null +++ b/migrations/Version20210310151408.php @@ -0,0 +1,36 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE act_like (id INT AUTO_INCREMENT NOT NULL, post_id INT DEFAULT NULL, INDEX IDX_64EAA1564B89032C (post_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB'); + $this->addSql('ALTER TABLE act_like ADD CONSTRAINT FK_64EAA1564B89032C FOREIGN KEY (post_id) REFERENCES activity (id)'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('DROP TABLE act_like'); + } +} diff --git a/migrations/Version20210310163412.php b/migrations/Version20210310163412.php new file mode 100644 index 0000000..7d27b9d --- /dev/null +++ b/migrations/Version20210310163412.php @@ -0,0 +1,35 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_8D93D649E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('DROP TABLE user'); + } +} diff --git a/migrations/Version20210310192403.php b/migrations/Version20210310192403.php new file mode 100644 index 0000000..a7544e4 --- /dev/null +++ b/migrations/Version20210310192403.php @@ -0,0 +1,39 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE act_like ADD user_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE act_like ADD CONSTRAINT FK_64EAA156A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)'); + $this->addSql('CREATE INDEX IDX_64EAA156A76ED395 ON act_like (user_id)'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE act_like DROP FOREIGN KEY FK_64EAA156A76ED395'); + $this->addSql('DROP INDEX IDX_64EAA156A76ED395 ON act_like'); + $this->addSql('ALTER TABLE act_like DROP user_id'); + } +} diff --git a/src/Controller/ActivityController.php b/src/Controller/ActivityController.php new file mode 100644 index 0000000..5a0c77b --- /dev/null +++ b/src/Controller/ActivityController.php @@ -0,0 +1,248 @@ +render('activity/index.html.twig', [ + 'activities' => $activityRepository->findAll(), + ]); + } + /** + * @Route("/user", name="activity_user") + */ + public function user(ActivityRepository $activityRepository): Response + { + return $this->render('activity/user.html.twig', [ + 'activities' => $activityRepository->findAll(), + ]); + + + + } + + /** + * @Route("/new", name="activity_new", methods={"GET","POST"}) + */ + public function new(Request $request): Response + { + $activity = new Activity(); + $form = $this->createForm(ActivityType::class, $activity); + $form->add('ajouter',SubmitType::class,['attr'=> + ['class'=>'btn_3']]); + $form->handleRequest($request); + + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager = $this->getDoctrine()->getManager(); + $entityManager->persist($activity); + $entityManager->flush(); + + return $this->redirectToRoute('activity_index'); + } + + return $this->render('activity/new.html.twig', [ + 'activity' => $activity, + 'form' => $form->createView(), + ]); + } + + /** + * @Route("/{id}", name="activity_show", methods={"GET"}) + */ + public function show(Activity $activity): Response + { + return $this->render('activity/show.html.twig', [ + 'activity' => $activity, + ]); + } + /** + * @Route("/user/{id}", name="us_show") + */ + public function usershow(Activity $activity): Response + { + return $this->render('activity/usershow.html.twig', [ + 'activity' => $activity, + ]); + } + + /** + * @Route("/{id}/edit", name="activity_edit", methods={"GET","POST"}) + */ + public function edit(Request $request, Activity $activity): Response + { + $form = $this->createForm(ActivityType::class, $activity); + $form->add('Modifier',SubmitType::class,['attr'=> + ['class'=>'btn_3']]); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $this->getDoctrine()->getManager()->flush(); + + return $this->redirectToRoute('activity_index'); + } + + return $this->render('activity/edit.html.twig', [ + 'activity' => $activity, + 'form' => $form->createView(), + ]); + } + + /** + * @Route("/{id}", name="activity_delete", methods={"DELETE"}) + */ + public function delete(Request $request, Activity $activity): Response + { + if ($this->isCsrfTokenValid('delete'.$activity->getId(), $request->request->get('_token'))) { + $entityManager = $this->getDoctrine()->getManager(); + $entityManager->remove($activity); + $entityManager->flush(); + } + + return $this->redirectToRoute('activity_index'); + } + + /** + * @Route("/activity/{id}/like" , name="act_like") + * @param Activity $activity + * @param EntityManagerInterface $manager + * @param ActLikeRepository $likeRepo + * @return Response + */ +public function like(Activity $activity, EntityManagerInterface $manager , ActLikeRepository $likeRepo, \Swift_Mailer $mailer) : Response +{ + $user = $this->getUser(); + if(!$user) return $this->redirectToRoute('app_login'); + $mail = $user->getUsername(); + + if($activity->isLikedByUser($user)){ + $like = $likeRepo->findOneBy([ + 'post' => $activity, + 'user'=> $user]); + $manager->remove($like); + $manager->flush(); + + return $this->redirectToRoute('activity_user'); + } + $like = new ActLike(); + $like->setPost($activity) + ->setUser($user); + $manager->persist($like); + $manager->flush(); + $email = (new \Swift_Message($activity->getIdAct())) + ->setFrom('ahmed.jelassi@esprit.tn') + ->setTo('ahmed.jelassi@esprit.tn') + ->setBody($activity->getDescription()) + ; + $mailer->send($email); + + return $this->redirectToRoute('activity_user'); + +} + /** + * @Route("/recherche", name="recherche") + */ + public function searchAction(Request $request) + { + + $data = $request->request->get('search'); + + + $em = $this->getDoctrine()->getManager(); + $query = $em->createQuery('SELECT e FROM App\Entity\Activity e WHERE e.Id_act LIKE :data') + ->setParameter('data', '%'.$data.'%'); + + + $events = $query->getResult(); + + return $this->render('activity/index.html.twig', [ + 'activities' => $events, + ]); + } + /** + * @Route("/tri", name="tri") + */ + public function TriAction(Request $request) + { + + + + + $em = $this->getDoctrine()->getManager(); + $query = $em->createQuery( + 'SELECT e FROM App\Entity\Activity e + ORDER BY e.Id_act '); + + + + $candidats = $query->getResult(); + + return $this->render('activity/index.html.twig', array( + 'activities' => $candidats)); + + } + + /** + * @Route("/list/{id}", name="activity_list", methods={"GET"}) + */ + public function listp(Activity $produits) : Response + { +// Configure Dompdf according to your needs + $pdfOptions = new Options(); + $pdfOptions->set('defaultFont', 'Arial'); + + // Instantiate Dompdf with our options + $dompdf = new Dompdf($pdfOptions); + + + // Retrieve the HTML generated in our twig file + $html = $this->renderView('activity/list.html.twig', [ + 'activity' =>$produits, + ]); + + $html .= ''; + + // Load HTML to Dompdf + $dompdf->loadHtml($html); + + // (Optional) Setup the paper size and orientation 'portrait' or 'portrait' + $dompdf->setPaper('A4', 'portrait'); + + // Render the HTML as PDF + $dompdf->render(); + + // Output the generated PDF to Browser (force download) + $dompdf->stream("mypdf.pdf", [ + "Attachment" => true + ]); + + + + } + +} diff --git a/src/Controller/GerantController.php b/src/Controller/GerantController.php new file mode 100644 index 0000000..b2caeb0 --- /dev/null +++ b/src/Controller/GerantController.php @@ -0,0 +1,181 @@ +render('gerant/index.html.twig', [ + 'gerants' => $gerantRepository->findAll(), + ]); + } + + /** + * @Route("/new", name="gerant_new", methods={"GET","POST"}) + */ + public function new(Request $request): Response + { + $gerant = new Gerant(); + $form = $this->createForm(Gerant1Type::class, $gerant); + $form->add('ajouter',SubmitType::class,['attr'=> + ['class'=>'btn_3']]); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager = $this->getDoctrine()->getManager(); + $entityManager->persist($gerant); + $entityManager->flush(); + + return $this->redirectToRoute('gerant_index'); + } + + return $this->render('gerant/new.html.twig', [ + 'gerant' => $gerant, + 'form' => $form->createView(), + ]); + } + + /** + * @Route("/{Id_gerant}", name="gerant_show", methods={"GET"}) + */ + public function show(Gerant $gerant): Response + { + return $this->render('gerant/show.html.twig', [ + 'gerant' => $gerant, + ]); + } + + /** + * @Route("/edit/{Id_gerant}", name="gerant_edit", methods={"GET","POST"}) + */ + + public function edit(Request $request, Gerant $gerant): Response + { + $form = $this->createForm(Gerant1Type::class, $gerant); + $form->add('Modifier',SubmitType::class,['attr'=> + ['class'=>'btn_3']]); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $this->getDoctrine()->getManager()->flush(); + + return $this->redirectToRoute('gerant_index'); + } + + return $this->render('gerant/edit.html.twig', [ + 'gerant' => $gerant, + 'form' => $form->createView(), + ]); + } + + /** + * @Route("/{Id_gerant}", name="gerant_delete", methods={"DELETE"}) + */ + public function delete(Request $request, Gerant $gerant): Response + { + if ($this->isCsrfTokenValid('delete'.$gerant->getIdgerant(), $request->request->get('_token'))) { + $entityManager = $this->getDoctrine()->getManager(); + $entityManager->remove($gerant); + $entityManager->flush(); + } + + return $this->redirectToRoute('gerant_index'); + } + /** + * @Route("/list/{Id_gerant}", name="gerant_list", methods={"GET"}) + */ + public function listp(Gerant $produits) : Response + { +// Configure Dompdf according to your needs + $pdfOptions = new Options(); + $pdfOptions->set('defaultFont', 'Arial'); + + // Instantiate Dompdf with our options + $dompdf = new Dompdf($pdfOptions); + + + // Retrieve the HTML generated in our twig file + $html = $this->renderView('gerant/list.html.twig', [ + 'gerant' =>$produits, + ]); + + $html .= ''; + + // Load HTML to Dompdf + $dompdf->loadHtml($html); + + // (Optional) Setup the paper size and orientation 'portrait' or 'portrait' + $dompdf->setPaper('A4', 'portrait'); + + // Render the HTML as PDF + $dompdf->render(); + + // Output the generated PDF to Browser (force download) + $dompdf->stream("mypdf.pdf", [ + "Attachment" => false + ]); + + + + } + /** + * @Route("/tri", name="tri_g") + */ + public function TriAction(Request $request) + { + + + + + $em = $this->getDoctrine()->getManager(); + $query = $em->createQuery( + 'SELECT e FROM App\Entity\Gerant e + ORDER BY e.Id_gerant '); + + + + $candidats = $query->getResult(); + + return $this->render('gerant/index.html.twig', array( + 'gerants' => $candidats)); + + } + /** + * @Route("/recherche", name="recherche_g") + */ + public function searchAction(Request $request) + { + + $data = $request->request->get('search'); + + + $em = $this->getDoctrine()->getManager(); + $query = $em->createQuery('SELECT e FROM App\Entity\Gerant e WHERE e.Id_gerant LIKE :data') + ->setParameter('data', '%'.$data.'%'); + + + $events = $query->getResult(); + + return $this->render('gerant/index.html.twig', [ + 'gerants' => $events, + ]); + } +} diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php index e3dedc9..365ae8e 100644 --- a/src/Controller/HomeController.php +++ b/src/Controller/HomeController.php @@ -8,16 +8,12 @@ class HomeController extends AbstractController { - - - - /** - * @Route("/test", name="test") + * @Route("/", name="home") */ - public function test(): Response + public function index(): Response { - return $this->render('test.html.twig', [ + return $this->render('home/index.html.twig', [ 'controller_name' => 'HomeController', ]); } diff --git a/src/Controller/LoginAuthController.php b/src/Controller/LoginAuthController.php new file mode 100644 index 0000000..ca46c0c --- /dev/null +++ b/src/Controller/LoginAuthController.php @@ -0,0 +1,36 @@ +getUser()) { + // return $this->redirectToRoute('target_path'); + // } + + // get the login error if there is one + $error = $authenticationUtils->getLastAuthenticationError(); + // last username entered by the user + $lastUsername = $authenticationUtils->getLastUsername(); + + return $this->render('security/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]); + } + + /** + * @Route("/user/logout", name="app_logout") + */ + public function logout() + { + throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.'); + } +} diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php new file mode 100644 index 0000000..831d651 --- /dev/null +++ b/src/Controller/UserController.php @@ -0,0 +1,94 @@ +render('user/index.html.twig', [ + 'users' => $userRepository->findAll(), + ]); + } + + /** + * @Route("/new", name="user_new", methods={"GET","POST"}) + */ + public function new(Request $request): Response + { + $user = new User(); + $form = $this->createForm(UserType::class, $user); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager = $this->getDoctrine()->getManager(); + $entityManager->persist($user); + $entityManager->flush(); + + return $this->redirectToRoute('user_index'); + } + + return $this->render('user/new.html.twig', [ + 'user' => $user, + 'form' => $form->createView(), + ]); + } + + /** + * @Route("/{id}", name="user_show", methods={"GET"}) + */ + public function show(User $user): Response + { + return $this->render('user/show.html.twig', [ + 'user' => $user, + ]); + } + + /** + * @Route("/{id}/edit", name="user_edit", methods={"GET","POST"}) + */ + public function edit(Request $request, User $user): Response + { + $form = $this->createForm(UserType::class, $user); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $this->getDoctrine()->getManager()->flush(); + + return $this->redirectToRoute('user_index'); + } + + return $this->render('user/edit.html.twig', [ + 'user' => $user, + 'form' => $form->createView(), + ]); + } + + /** + * @Route("/{id}", name="user_delete", methods={"DELETE"}) + */ + public function delete(Request $request, User $user): Response + { + if ($this->isCsrfTokenValid('delete'.$user->getId(), $request->request->get('_token'))) { + $entityManager = $this->getDoctrine()->getManager(); + $entityManager->remove($user); + $entityManager->flush(); + } + + return $this->redirectToRoute('user_index'); + } +} diff --git a/src/DataFixtures/AppFixtures.php b/src/DataFixtures/AppFixtures.php new file mode 100644 index 0000000..92ccc7e --- /dev/null +++ b/src/DataFixtures/AppFixtures.php @@ -0,0 +1,63 @@ +encoder = $encoder; + } + + public function load(ObjectManager $manager) + { + $faker = Factory::create(); + $users=[]; + $user = new User(); + $user->setEmail('user@symfony.com') + ->setPassword($this->encoder->encodePassword($user, 'password')); + + $manager->persist($user); + $users[] = $user; + for($i = 0; $i<20;$i++) + { + $user = new User(); + $user->setEmail($faker->email) + ->setPassword($this->encoder->encodePassword($user,'password')); + $manager->persist($user); + $users[] = $user; + } + for ($i = 0; $i < 20; $i++) { + $post = new Activity(); + $post->setIdAct($faker->word) + ->setDescription($faker->paragraph()) + ->setCategorie($faker->sentence(1))->setType($faker->word); + + $manager->persist($post); + for($j=0; $j<10; $j++) + { + $like = new ActLike(); + $like->setPost($post) + ->setUser($faker->randomElement($users)); + $manager->persist($like); + } + } + + $manager->flush(); + } +} \ No newline at end of file diff --git a/src/Entity/ActLike.php b/src/Entity/ActLike.php new file mode 100644 index 0000000..13e1dde --- /dev/null +++ b/src/Entity/ActLike.php @@ -0,0 +1,58 @@ +id; + } + + public function getPost(): ?Activity + { + return $this->post; + } + + public function setPost(?Activity $post): self + { + $this->post = $post; + + return $this; + } + + public function getUser(): ?User + { + return $this->user; + } + + public function setUser(?User $user): self + { + $this->user = $user; + + return $this; + } +} diff --git a/src/Entity/Activity.php b/src/Entity/Activity.php new file mode 100644 index 0000000..50a333c --- /dev/null +++ b/src/Entity/Activity.php @@ -0,0 +1,193 @@ +Likes = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getIdAct(): ?string + { + return $this->Id_act; + } + + public function setIdAct(string $Id_act): self + { + $this->Id_act = $Id_act; + + return $this; + } + + public function getType(): ?string + { + return $this->Type; + } + + public function setType(string $Type): self + { + $this->Type = $Type; + + return $this; + } + + public function getDescription(): ?string + { + return $this->Description; + } + + public function setDescription(?string $Description): self + { + $this->Description = $Description; + + return $this; + } + + public function getDateVal(): ?\DateTimeInterface + { + return $this->Date_val; + } + + public function setDateVal(\DateTimeInterface $Date_val): self + { + $this->Date_val = $Date_val; + + return $this; + } + + public function getCategorie(): ?string + { + return $this->Categorie; + } + + public function setCategorie(string $Categorie): self + { + $this->Categorie = $Categorie; + + return $this; + } + + public function getGerant(): ?Gerant + { + return $this->gerant; + } + + public function setGerant(?Gerant $gerant): self + { + $this->gerant = $gerant; + + return $this; + } + + /** + * @return Collection|ActLike[] + */ + public function getLikes(): Collection + { + return $this->Likes; + } + + public function addLike(ActLike $like): self + { + if (!$this->Likes->contains($like)) { + $this->Likes[] = $like; + $like->setPost($this); + } + + return $this; + } + + public function removeLike(ActLike $like): self + { + if ($this->Likes->removeElement($like)) { + // set the owning side to null (unless already changed) + if ($like->getPost() === $this) { + $like->setPost(null); + } + } + + return $this; + } + + /** + * @param User $user + * @return bool + */ + public function isLikedByUser(User $user) : bool + { + foreach ($this->Likes as $like){ + if($like->getUser() === $user) return true; + } + return false; + + } +} + diff --git a/src/Entity/Gerant.php b/src/Entity/Gerant.php new file mode 100644 index 0000000..8d63fd2 --- /dev/null +++ b/src/Entity/Gerant.php @@ -0,0 +1,171 @@ +Activity = new ArrayCollection(); + } + + + public function getIdGerant(): ?string + { + return $this->Id_gerant; + } + + public function setIdGerant(string $Id_gerant): self + { + $this->Id_gerant = $Id_gerant; + + return $this; + } + + public function getNom(): ?string + { + return $this->Nom; + } + + public function setNom(string $Nom): self + { + $this->Nom = $Nom; + + return $this; + } + + public function getPrenom(): ?string + { + return $this->Prenom; + } + + public function setPrenom(string $Prenom): self + { + $this->Prenom = $Prenom; + + return $this; + } + + public function getDateNais(): ?\DateTimeInterface + { + return $this->Date_nais; + } + + public function setDateNais(\DateTimeInterface $Date_nais): self + { + $this->Date_nais = $Date_nais; + + return $this; + } + + public function getAdEmail(): ?string + { + return $this->Ad_Email; + } + + public function setAdEmail(string $Ad_Email): self + { + $this->Ad_Email = $Ad_Email; + + return $this; + } + + public function getCin(): ?string + { + return $this->Cin; + } + + public function setCin(string $Cin): self + { + $this->Cin = $Cin; + + return $this; + } + + /** + * @return Collection|Activity[] + */ + public function getActivity(): Collection + { + return $this->Activity; + } + + public function addActivity(Activity $activity): self + { + if (!$this->Activity->contains($activity)) { + $this->Activity[] = $activity; + $activity->setGerant($this); + } + + return $this; + } + + public function removeActivity(Activity $activity): self + { + if ($this->Activity->removeElement($activity)) { + // set the owning side to null (unless already changed) + if ($activity->getGerant() === $this) { + $activity->setGerant(null); + } + } + + return $this; + } + public function __toString() + { + return $this->Id_gerant; + } +} diff --git a/src/Entity/User.php b/src/Entity/User.php index 57fd32e..065582c 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -3,22 +3,15 @@ namespace App\Entity; use App\Repository\UserRepository; -use DateTime; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; -use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Security\Core\User\UserInterface; -use Symfony\Component\Validator\Constraints as Assert; - /** * @ORM\Entity(repositoryClass=UserRepository::class) - * @ORM\Table(name="`user`") - * @UniqueEntity( - * fields={"email"}, - * message="email existant" - * ) */ -class User implements UserInterface +class User implements UserInterface { /** * @ORM\Id @@ -27,70 +20,32 @@ class User implements UserInterface */ private $id; - - /** - * @ORM\Column(type="string", length=255) - * + * @ORM\Column(type="string", length=180, unique=true) */ private $email; /** - * @ORM\Column(type="string", length=255, nullable=true) - */ - private $first_name; - - /** - * @ORM\Column(type="string", length=255, nullable=true) - */ - private $last_name; - - /** - * @ORM\Column(type="string", length=255) - * @Assert\Length(min="8",minMessage="Password needs to be at least 8 characters long") - * - **/ - private $password; - /** - * @Assert\EqualTo (propertyPath="password",message="password mismatch") - * - */ - private $confirm_password; - - /** - * @ORM\Column(type="string", nullable=true,length=255) - */ - private $google_id; - - /** - * @ORM\Column(type="string", length=255, nullable=true) - */ - private $avatar; - - /** - * @ORM\Column(type="json", nullable=true) + * @ORM\Column(type="json") */ private $roles = []; /** - * @ORM\Column(type="integer", nullable=true) + * @var string The hashed password + * @ORM\Column(type="string") */ - private $cin; + private $password; /** - * @ORM\Column(type="datetime") + * @ORM\OneToMany(targetEntity=ActLike::class, mappedBy="user") */ - private $created_at; - + private $likes; public function __construct() { - $this->created_at=DateTime::createFromFormat('d-m-Y H:i:s','now'); + $this->likes = new ArrayCollection(); } - - - public function getId(): ?int { return $this->id; @@ -108,33 +63,41 @@ public function setEmail(string $email): self return $this; } - public function getFirstName(): ?string + /** + * A visual identifier that represents this user. + * + * @see UserInterface + */ + public function getUsername(): string { - return $this->first_name; + return (string) $this->email; } - public function setFirstName(?string $first_name): self + /** + * @see UserInterface + */ + public function getRoles(): array { - $this->first_name = $first_name; - - return $this; - } + $roles = $this->roles; + // guarantee every user at least has ROLE_USER + $roles[] = 'ROLE_USER'; - public function getLastName(): ?string - { - return $this->last_name; + return array_unique($roles); } - public function setLastName(?string $last_name): self + public function setRoles(array $roles): self { - $this->last_name = $last_name; + $this->roles = $roles; return $this; } - public function getPassword(): ?string + /** + * @see UserInterface + */ + public function getPassword(): string { - return $this->password; + return (string) $this->password; } public function setPassword(string $password): self @@ -144,95 +107,53 @@ public function setPassword(string $password): self return $this; } - public function getGoogleId(): ?string - { - return $this->google_id; - } - - public function setGoogleId(?string $google_id): self - { - $this->google_id = $google_id; - - return $this; - } - - public function getConfirmPassword():?string - { - return $this->confirm_password; - } - public function getAvatar(): ?string - { - return $this->avatar; - } - - public function setAvatar(?string $avatar): self - { - $this->avatar = $avatar; - - return $this; - } - public function getCin(): ?int - { - return $this->cin; - } - - public function setCin(?int $cin): self - { - $this->cin = $cin; - - return $this; - } - - public function setConfirmPassword(?string $confirm_password):self - { - $this->confirm_password=$confirm_password; - return $this; - } - - - public function getSalt() - { - // TODO: Implement getSalt() method. - } - - public function getUsername() + /** + * Returning a salt is only needed, if you are not using a modern + * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml. + * + * @see UserInterface + */ + public function getSalt(): ?string { - return $this->email; + return null; } + /** + * @see UserInterface + */ public function eraseCredentials() { - // TODO: Implement eraseCredentials() method. + // If you store any temporary, sensitive data on the user, clear it here + // $this->plainPassword = null; } - - public function getRoles():array + /** + * @return Collection|ActLike[] + */ + public function getLikes(): Collection { - $roles = $this->roles; - - - return array_unique($roles); + return $this->likes; } - public function setRoles(?array $roles): self + public function addLike(ActLike $like): self { - $this->roles = $roles; + if (!$this->likes->contains($like)) { + $this->likes[] = $like; + $like->setUser($this); + } return $this; } - public function getCreatedAt(): ?\DateTimeInterface + public function removeLike(ActLike $like): self { - return $this->created_at; - } - - public function setCreatedAt(\DateTimeInterface $created_at): self - { - $this->created_at = $created_at; + if ($this->likes->removeElement($like)) { + // set the owning side to null (unless already changed) + if ($like->getUser() === $this) { + $like->setUser(null); + } + } return $this; } - - - } diff --git a/src/Form/ActivityType.php b/src/Form/ActivityType.php new file mode 100644 index 0000000..2a7cf18 --- /dev/null +++ b/src/Form/ActivityType.php @@ -0,0 +1,30 @@ +add('Id_act') + ->add('Type') + ->add('Description') + ->add('Date_val') + ->add('Categorie') + ->add('gerant') + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => Activity::class, + ]); + } +} diff --git a/src/Form/Gerant1Type.php b/src/Form/Gerant1Type.php new file mode 100644 index 0000000..fdfea6c --- /dev/null +++ b/src/Form/Gerant1Type.php @@ -0,0 +1,30 @@ +add('Id_gerant') + ->add('Nom') + ->add('Prenom') + ->add('Date_nais') + ->add('Ad_Email') + ->add('Cin') + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => Gerant::class, + ]); + } +} diff --git a/src/Form/GerantType.php b/src/Form/GerantType.php new file mode 100644 index 0000000..4fadc7a --- /dev/null +++ b/src/Form/GerantType.php @@ -0,0 +1,30 @@ +add('Id_gerant') + ->add('Nom') + ->add('Prenom') + ->add('Date_nais') + ->add('Ad_Email') + ->add('Cin') + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => Gerant::class, + ]); + } +} diff --git a/src/Form/RatingType.php b/src/Form/RatingType.php new file mode 100644 index 0000000..bab6ccf --- /dev/null +++ b/src/Form/RatingType.php @@ -0,0 +1,42 @@ +vars = array_replace($view->vars, [ + 'stars' => $options['stars'] + ]); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'attr' => [ + 'class' => 'rating', + ], + 'scale' => 1, + 'stars' => 5, + ]); + } + + public function getParent() + { + return NumberType::class; + } + + public function getName() + { + return 'rating'; + } + +} \ No newline at end of file diff --git a/src/Form/UserType.php b/src/Form/UserType.php new file mode 100644 index 0000000..b227d1d --- /dev/null +++ b/src/Form/UserType.php @@ -0,0 +1,27 @@ +add('email') + ->add('roles') + ->add('password') + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => User::class, + ]); + } +} diff --git a/src/Kernel.php b/src/Kernel.php index ee3343b..41a2607 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -1,14 +1,12 @@ import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob'); $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob'); } + } diff --git a/src/Repository/ActLikeRepository.php b/src/Repository/ActLikeRepository.php new file mode 100644 index 0000000..aad4a97 --- /dev/null +++ b/src/Repository/ActLikeRepository.php @@ -0,0 +1,51 @@ +createQueryBuilder('a') + ->andWhere('a.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('a.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?ActLike + { + return $this->createQueryBuilder('a') + ->andWhere('a.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/ActivityRepository.php b/src/Repository/ActivityRepository.php new file mode 100644 index 0000000..836ca6e --- /dev/null +++ b/src/Repository/ActivityRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('a') + ->andWhere('a.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('a.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Activity + { + return $this->createQueryBuilder('a') + ->andWhere('a.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/GerantRepository.php b/src/Repository/GerantRepository.php new file mode 100644 index 0000000..164505c --- /dev/null +++ b/src/Repository/GerantRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('g') + ->andWhere('g.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('g.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Gerant + { + return $this->createQueryBuilder('g') + ->andWhere('g.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php index 2ebc111..1a38975 100644 --- a/src/Repository/UserRepository.php +++ b/src/Repository/UserRepository.php @@ -5,6 +5,9 @@ use App\Entity\User; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; +use Symfony\Component\Security\Core\Exception\UnsupportedUserException; +use Symfony\Component\Security\Core\User\PasswordUpgraderInterface; +use Symfony\Component\Security\Core\User\UserInterface; /** * @method User|null find($id, $lockMode = null, $lockVersion = null) @@ -12,13 +15,27 @@ * @method User[] findAll() * @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ -class UserRepository extends ServiceEntityRepository +class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, User::class); } + /** + * Used to upgrade (rehash) the user's password automatically over time. + */ + public function upgradePassword(UserInterface $user, string $newEncodedPassword): void + { + if (!$user instanceof User) { + throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user))); + } + + $user->setPassword($newEncodedPassword); + $this->_em->persist($user); + $this->_em->flush(); + } + // /** // * @return User[] Returns an array of User objects // */ diff --git a/src/Security/LoginAuthAuthenticator.php b/src/Security/LoginAuthAuthenticator.php new file mode 100644 index 0000000..1824490 --- /dev/null +++ b/src/Security/LoginAuthAuthenticator.php @@ -0,0 +1,107 @@ +entityManager = $entityManager; + $this->urlGenerator = $urlGenerator; + $this->csrfTokenManager = $csrfTokenManager; + $this->passwordEncoder = $passwordEncoder; + } + + public function supports(Request $request) + { + return self::LOGIN_ROUTE === $request->attributes->get('_route') + && $request->isMethod('POST'); + } + + public function getCredentials(Request $request) + { + $credentials = [ + 'email' => $request->request->get('email'), + 'password' => $request->request->get('password'), + 'csrf_token' => $request->request->get('_csrf_token'), + ]; + $request->getSession()->set( + Security::LAST_USERNAME, + $credentials['email'] + ); + + return $credentials; + } + + public function getUser($credentials, UserProviderInterface $userProvider) + { + $token = new CsrfToken('authenticate', $credentials['csrf_token']); + if (!$this->csrfTokenManager->isTokenValid($token)) { + throw new InvalidCsrfTokenException(); + } + + $user = $this->entityManager->getRepository(User::class)->findOneBy(['email' => $credentials['email']]); + + if (!$user) { + // fail authentication with a custom error + throw new CustomUserMessageAuthenticationException('Email could not be found.'); + } + + return $user; + } + + public function checkCredentials($credentials, UserInterface $user) + { + return $this->passwordEncoder->isPasswordValid($user, $credentials['password']); + } + + /** + * Used to upgrade (rehash) the user's password automatically over time. + */ + public function getPassword($credentials): ?string + { + return $credentials['password']; + } + + public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey) + { + if ($targetPath = $this->getTargetPath($request->getSession(), $providerKey)) { + return new RedirectResponse($targetPath); + } + + return new RedirectResponse($this->urlGenerator->generate('activity_user')); + throw new \Exception('TODO: provide a valid redirect inside '.__FILE__); + } + + protected function getLoginUrl() + { + return $this->urlGenerator->generate(self::LOGIN_ROUTE); + } +} diff --git a/templates/activity/_delete_form.html.twig b/templates/activity/_delete_form.html.twig new file mode 100644 index 0000000..fb940af --- /dev/null +++ b/templates/activity/_delete_form.html.twig @@ -0,0 +1,5 @@ +
+ + + +
diff --git a/templates/activity/_form.html.twig b/templates/activity/_form.html.twig new file mode 100644 index 0000000..de30751 --- /dev/null +++ b/templates/activity/_form.html.twig @@ -0,0 +1,43 @@ +
+
+
+ + + +
+
diff --git a/templates/activity/edit.html.twig b/templates/activity/edit.html.twig new file mode 100644 index 0000000..d6d9a5c --- /dev/null +++ b/templates/activity/edit.html.twig @@ -0,0 +1,13 @@ +{% extends 'back.html.twig' %} + +{% block title %}Edit Activity{% endblock %} + +{% block content %} +

Edit Activity

+ + {{ include('activity/_form.html.twig', {'button_label': 'Update'}) }} + + back to list + + {{ include('activity/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/activity/index.html.twig b/templates/activity/index.html.twig new file mode 100644 index 0000000..8438715 --- /dev/null +++ b/templates/activity/index.html.twig @@ -0,0 +1,62 @@ +{% extends 'back.html.twig' %} + +{% block title %}Activity index{% endblock %} + +{% block content %} +

Activity index

+ + + + + + + + + + + + + + + + {% for activity in activities %} + + + + + + + + + + {% else %} + + + + {% endfor %} + +
IdId_actTypeDescriptionDate_valCategorieactions
{{ activity.id }}{{ activity.IdAct }}{{ activity.Type }}{{ activity.Description }}{{ activity.DateVal ? activity.DateVal|date('Y-m-d') : '' }}{{ activity.Categorie }} + show + edit +
no records found
+ + + Create new +{% endblock %} + diff --git a/templates/activity/list.html.twig b/templates/activity/list.html.twig new file mode 100644 index 0000000..ba95ca9 --- /dev/null +++ b/templates/activity/list.html.twig @@ -0,0 +1,31 @@ + +

Activity

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Id{{ activity.id }}
Id_act{{ activity.IdAct }}
Type{{ activity.Type }}
Description{{ activity.Description }}
Date_val{{ activity.DateVal ? activity.DateVal|date('Y-m-d') : '' }}
Categorie{{ activity.Categorie }}
diff --git a/templates/activity/new.html.twig b/templates/activity/new.html.twig new file mode 100644 index 0000000..239248d --- /dev/null +++ b/templates/activity/new.html.twig @@ -0,0 +1,11 @@ +{% extends 'back.html.twig' %} + +{% block title %}New Activity{% endblock %} + +{% block content %} +

Create new Activity

+ + {{ include('activity/_form.html.twig') }} + + back to list +{% endblock %} diff --git a/templates/activity/pdf.html.twig b/templates/activity/pdf.html.twig new file mode 100644 index 0000000..5c00739 --- /dev/null +++ b/templates/activity/pdf.html.twig @@ -0,0 +1,9 @@ + + + + Title of the PDF + + +

{{ title }}

+

Lorem Ipsum

+ diff --git a/templates/activity/show.html.twig b/templates/activity/show.html.twig new file mode 100644 index 0000000..00ce941 --- /dev/null +++ b/templates/activity/show.html.twig @@ -0,0 +1,43 @@ +{% extends 'back.html.twig' %} + +{% block title %}Activity{% endblock %} + +{% block content %} +

Activity

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Id{{ activity.id }}
Id_act{{ activity.IdAct }}
Type{{ activity.Type }}
Description{{ activity.Description }}
Date_val{{ activity.DateVal ? activity.DateVal|date('Y-m-d') : '' }}
Categorie{{ activity.Categorie }}
+ + back to list + + edit + Download pdf + + + {{ include('activity/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/activity/user.html.twig b/templates/activity/user.html.twig new file mode 100644 index 0000000..e13e7b8 --- /dev/null +++ b/templates/activity/user.html.twig @@ -0,0 +1,77 @@ +{% extends 'base.html.twig' %} + + {% block title %}Activity index{% endblock %} + +{% block content %} +

Activity index

+ + + {% for activity in activities %} + +
+
+ Card image cap + +
+
+ {% else %} + + no records found + + + {% endfor %} + + + + Create new +{% endblock %} + +{% block js %} + + + +{% endblock %} \ No newline at end of file diff --git a/templates/activity/usershow.html.twig b/templates/activity/usershow.html.twig new file mode 100644 index 0000000..eb12e41 --- /dev/null +++ b/templates/activity/usershow.html.twig @@ -0,0 +1,39 @@ +{% extends 'base.html.twig' %} + +{% block title %}Activity{% endblock %} + +{% block content %} +

Activity

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Id{{ activity.id }}
Id_act{{ activity.IdAct }}
Type{{ activity.Type }}
Description{{ activity.Description }}
Date_val{{ activity.DateVal ? activity.DateVal|date('Y-m-d') : '' }}
Categorie{{ activity.Categorie }}
+ + back to list + +{% endblock %} diff --git a/templates/back.html.twig b/templates/back.html.twig new file mode 100644 index 0000000..abadbe8 --- /dev/null +++ b/templates/back.html.twig @@ -0,0 +1,874 @@ + + + + + + {% block title %} {% endblock %} + + + + + + + + + + +{% block header %} +
+ AdminLTELogo +
+ + + + + + + + + + + + +{% endblock %} +{% block content %} +{% endblock %} +{% block footer %} + Copyright © 2014-2021 AdminLTE.io. + All rights reserved. +
+ Version 3.1.0-rc +
+{% endblock %} +{% block js %} + + + + + + + + + + + + + + + + + + + + + + +{% endblock %} + + \ No newline at end of file diff --git a/templates/base.html.twig b/templates/base.html.twig index b7365fa..6667132 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -1,175 +1,95 @@ - + - {% block title %}Welcome!{% endblock %} + {% block title %} {% endblock %} - + - {% block stylesheets %} - {#{{ encore_entry_link_tags('app') }}#} - - - - - - - - - - - - - - - - - {% endblock %} - - {% block javascripts %} - - - - - {% endblock %} + + + + + + + + + + + + + + - {% block preloader %} {% endblock preloader %} -
- {% block header %} -
-
-
-
- {% block body %} - - - - {% endblock %} - -{% block scripts %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% endblock scripts %} + + {% endblock %} + {% block content %} - - + {% endblock %} + {% block js %} +
+
+
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% endblock %} + + + diff --git a/templates/gerant/_delete_form.html.twig b/templates/gerant/_delete_form.html.twig new file mode 100644 index 0000000..145497a --- /dev/null +++ b/templates/gerant/_delete_form.html.twig @@ -0,0 +1,5 @@ +
+ + + +
diff --git a/templates/gerant/_form.html.twig b/templates/gerant/_form.html.twig new file mode 100644 index 0000000..07d8299 --- /dev/null +++ b/templates/gerant/_form.html.twig @@ -0,0 +1,45 @@ + +
+
+
+ + + +
+
\ No newline at end of file diff --git a/templates/gerant/addGerant.html.twig b/templates/gerant/addGerant.html.twig new file mode 100644 index 0000000..44dfce3 --- /dev/null +++ b/templates/gerant/addGerant.html.twig @@ -0,0 +1,80 @@ +{# {{ form(form) }}#} +{% extends 'back.html.twig' %} + {% block title%} BestHost | Ajout Gérant {% endblock title %} +{% block content %} +
+ +
+
+
+
+
+
+

Ajout Gérant

+
+
+
+
+
+
+ + +
+
+
+ + + +
+
+ +
+ + +
+
+
+
+
+ +
+
+
+{{ form_end(form) }} +{% endblock %} \ No newline at end of file diff --git a/templates/gerant/edit.html.twig b/templates/gerant/edit.html.twig new file mode 100644 index 0000000..a82d791 --- /dev/null +++ b/templates/gerant/edit.html.twig @@ -0,0 +1,25 @@ + + {% extends 'back.html.twig' %} + + {% block title %}Edit Gerant{% endblock %} + {% block head %} + + + + + + + + + + + + {% endblock %} + + {% block content %} +

Edit Gerant

+ + {{ include('gerant/_form.html.twig',{'button_label': 'Update'}) }} + + back to list + {% endblock %} diff --git a/templates/gerant/index.html.twig b/templates/gerant/index.html.twig new file mode 100644 index 0000000..0262570 --- /dev/null +++ b/templates/gerant/index.html.twig @@ -0,0 +1,61 @@ +{% extends 'back.html.twig' %} + +{% block title %}Gerant index{% endblock %} + +{% block content %} +

Gerant index

+ + + + + + + + + + + + + + + + + {% for gerant in gerants %} + + + + + + + + + + {% else %} + + + + {% endfor %} + +
Id_gerantNomPrenomDate_naisAd_EmailCinactions
{{ gerant.IdGerant }}{{ gerant.Nom }}{{ gerant.Prenom }}{{ gerant.DateNais ? gerant.DateNais|date('Y-m-d') : '' }}{{ gerant.AdEmail }}{{ gerant.Cin }} + show + edit +
no records found
+ + Create new +{% endblock %} diff --git a/templates/gerant/list.html.twig b/templates/gerant/list.html.twig new file mode 100644 index 0000000..c96e6cb --- /dev/null +++ b/templates/gerant/list.html.twig @@ -0,0 +1,30 @@ +

Gerant

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Id_gerant{{ gerant.IdGerant }}
Nom{{ gerant.Nom }}
Prenom{{ gerant.Prenom }}
Date_nais{{ gerant.DateNais ? gerant.DateNais|date('Y-m-d') : '' }}
Ad_Email{{ gerant.AdEmail }}
Cin{{ gerant.Cin }}
\ No newline at end of file diff --git a/templates/gerant/listGerant.html.twig b/templates/gerant/listGerant.html.twig new file mode 100644 index 0000000..02f83f7 --- /dev/null +++ b/templates/gerant/listGerant.html.twig @@ -0,0 +1,36 @@ +{% extends 'base.html.twig' %} + {% block title%} BestHost | Liste Gérant {% endblock title %} +{% block content %} + {% if gerants %} + + + + + + + + + + {% for gerant in gerants %} + + + + + {% endfor %} + +
Les gérantsActions

{{ gerant.Nom }}

+

{{ gerant.Prenom }}

+

{{ gerant.Cin }}

+
+ Edit + Delete +
+{% else %} +

No articles to display

+ {% endif %} +{% endblock %} + +{% block javascripts %} + +{% endblock %} + diff --git a/templates/gerant/new.html.twig b/templates/gerant/new.html.twig new file mode 100644 index 0000000..6d739c0 --- /dev/null +++ b/templates/gerant/new.html.twig @@ -0,0 +1,11 @@ +{% extends 'back.html.twig' %} + +{% block title %}New Gerant{% endblock %} + +{% block content %} +

Create new Gerant

+ + {{ include('gerant/_form.html.twig') }} + + back to list +{% endblock %} diff --git a/templates/gerant/show.html.twig b/templates/gerant/show.html.twig new file mode 100644 index 0000000..36ed3ed --- /dev/null +++ b/templates/gerant/show.html.twig @@ -0,0 +1,44 @@ +{% extends 'back.html.twig' %} + +{% block title %}Gerant{% endblock %} + +{% block content %} +

Gerant

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Id_gerant{{ gerant.IdGerant }}
Nom{{ gerant.Nom }}
Prenom{{ gerant.Prenom }}
Date_nais{{ gerant.DateNais ? gerant.DateNais|date('Y-m-d') : '' }}
Ad_Email{{ gerant.AdEmail }}
Cin{{ gerant.Cin }}
+ + back to list + + edit + imprimer + + + {{ include('gerant/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/home/index.html.twig b/templates/home/index.html.twig new file mode 100644 index 0000000..5869d67 --- /dev/null +++ b/templates/home/index.html.twig @@ -0,0 +1,30 @@ +{% extends 'base.html.twig' %} +{% block title %} +Homepage +{% endblock %} +{% block content %} +
+
+ +
+
+
+
+
+

Select Your New Perfect Style

+

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat is aute irure.

+ +
+ Shop Now +
+
+
+
+
+ +
+
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/templates/security/login.html.twig b/templates/security/login.html.twig new file mode 100644 index 0000000..70cb5d8 --- /dev/null +++ b/templates/security/login.html.twig @@ -0,0 +1,40 @@ +{% extends 'base.html.twig' %} + +{% block title %}Log in!{% endblock %} + +{% block content %} + +{% endblock %}