From f293ce8b0f7c0beae269bc8520ad267cfd065198 Mon Sep 17 00:00:00 2001 From: "clementine.desrucques" Date: Tue, 14 Dec 2021 08:43:01 +0100 Subject: [PATCH] Merge origin/master Conflicts: web/WEB-INF/feuilleGardes.jsp web/css/mycss.css --- src/java/servlet/AuthentifServlet.java | 1 + src/java/servlet/GPServlet.java | 132 +++++++++++++++++++++++++ web/WEB-INF/feuilleGardes.jsp | 6 +- web/WEB-INF/gardeJSP.jsp | 93 +++++++++++++++++ web/WEB-INF/web.xml | 8 ++ 5 files changed, 239 insertions(+), 1 deletion(-) create mode 100644 src/java/servlet/GPServlet.java create mode 100644 web/WEB-INF/gardeJSP.jsp diff --git a/src/java/servlet/AuthentifServlet.java b/src/java/servlet/AuthentifServlet.java index 73f6be7..46c0be6 100644 --- a/src/java/servlet/AuthentifServlet.java +++ b/src/java/servlet/AuthentifServlet.java @@ -66,6 +66,7 @@ public class AuthentifServlet extends HttpServlet { maSession.removeAttribute("lePompierConnecte"); maSession.removeAttribute("lesPompiers"); maSession.removeAttribute("lePompier"); + maSession.removeAttribute("lesVentilInit"); getServletContext().getRequestDispatcher("/WEB-INF/authentifJSP.jsp").forward(request, response); } diff --git a/src/java/servlet/GPServlet.java b/src/java/servlet/GPServlet.java new file mode 100644 index 0000000..54bc6c0 --- /dev/null +++ b/src/java/servlet/GPServlet.java @@ -0,0 +1,132 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package servlet; + +import bdd.GardeMySQL; +import bean.Gardes; +import bean.Pompier; +import form.DispoForm; +import java.io.IOException; +import java.io.PrintWriter; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; +import java.util.ArrayList; +import java.util.Calendar; +import util.TrmtDate; + +/** + * + * @author clementine.desrucques + */ +public class GPServlet extends HttpServlet { + + /** + * Processes requests for both HTTP GET and POST + * methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try ( PrintWriter out = response.getWriter()) { + /* TODO output your page here. You may use following sample code. */ + out.println(""); + out.println(""); + out.println(""); + out.println("Servlet GPServlet"); + out.println(""); + out.println(""); + out.println("

Servlet GPServlet at " + request.getContextPath() + "

"); + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { +// processRequest(request, response); + HttpSession maSession = request.getSession(); + + if(maSession.getAttribute("lesVentilInit") == null){ + ArrayList lesPompiers = (ArrayList) maSession.getAttribute("lesPompiers"); + Calendar[] lesDates = new Calendar[7]; + String[] lesDatesEnString = new String[7]; + lesDates[0] = TrmtDate.getDateDebutSemaine(); + lesDatesEnString[0] = TrmtDate.getDateAAfficher(lesDates[0]); + + for (int i = 1; i < lesDates.length; i++) { + lesDates[i] = TrmtDate.addDays(lesDates[0], i); + lesDatesEnString[i] = TrmtDate.getDateAAfficher(lesDates[i]); + } + maSession.setAttribute("lesDates", lesDates); + + maSession.setAttribute("lesDatesEnString", lesDatesEnString); + System.out.println(lesDatesEnString.toString()); + /*Initialisation des periodes */ + int[] lesPeriodes = {1,2,3,4}; + maSession.setAttribute("lesPeriodes", lesPeriodes); + System.out.println(lesPeriodes.toString()); + /* Recherche des ventilations */ + + GardeMySQL vm = new GardeMySQL(); + ArrayList lesVentilInit = vm.getLesDisponibilite(lesDates, lesPeriodes,request); + //System.out.println("lesVentilInit : " + lesVentilInit); + maSession.setAttribute("lesVentilInit", lesVentilInit); + + + /* Initialisation des couleurs */ + String[] lesCouleurs = {"blanc", "gris", "jaune"}; + maSession.setAttribute("lesCouleurs", lesCouleurs); + } + /* Affichage de la page de ventilation */ + getServletContext().getRequestDispatcher("/WEB-INF/gardeJSP.jsp").forward(request, response); + } + + /** + * Handles the HTTP POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { +// processRequest(request, response); + DispoForm vf = new DispoForm(); + vf.verifDispo(request); + getServletContext().getRequestDispatcher("/WEB-INF/pompierJSP.jsp").forward(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// + +} diff --git a/web/WEB-INF/feuilleGardes.jsp b/web/WEB-INF/feuilleGardes.jsp index 8c58418..0bbad22 100644 --- a/web/WEB-INF/feuilleGardes.jsp +++ b/web/WEB-INF/feuilleGardes.jsp @@ -31,14 +31,17 @@ + ${unePeriode} + - + + @@ -48,6 +51,7 @@ + diff --git a/web/WEB-INF/gardeJSP.jsp b/web/WEB-INF/gardeJSP.jsp new file mode 100644 index 0000000..c917e24 --- /dev/null +++ b/web/WEB-INF/gardeJSP.jsp @@ -0,0 +1,93 @@ +<%-- + Document : gardeJSP + Created on : 14 déc. 2021, 08:20:45 + Author : clementine.desrucques +--%> + +<%@page contentType="text/html" pageEncoding="UTF-8"%> +<%@include file= "jspf/debutJSP.jspf" %> + + <%@include file= "jspf/header.jspf" %> +
+
+ + + +
+ + + Feuille de gardes + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NoNom Prenom ${uneDate}
${unePeriode}
${uneVentil.getPompier().getId()}${uneVentil.getPompier().getNom()} ${uneVentil.getPompier().getPrenom()} + +
+
+ + Dispo + Indispo + Au travail + De garde : X + +
+
+
+
+
+ + diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml index c1f3319..dc3c550 100644 --- a/web/WEB-INF/web.xml +++ b/web/WEB-INF/web.xml @@ -20,6 +20,10 @@ feuilleGardes servlet.GardesServlet + + GPServlet + servlet.GPServlet + AuthentifServlet /authentification @@ -32,6 +36,10 @@ feuilleGardes /gardes + + GPServlet + /PompierGarde + 30