Merge origin/master

Conflicts:
	web/WEB-INF/feuilleGardes.jsp
	web/css/mycss.css
This commit is contained in:
clementine.desrucques 2021-12-14 08:43:01 +01:00
parent c1b8fa7a27
commit f293ce8b0f
5 changed files with 239 additions and 1 deletions

View File

@ -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);
}

View File

@ -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 <code>GET</code> and <code>POST</code>
* 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("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet GPServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet GPServlet at " + request.getContextPath() + "</h1>");
out.println("</body>");
out.println("</html>");
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> 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<Pompier> lesPompiers = (ArrayList<Pompier>) 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<Gardes> 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 <code>POST</code> 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";
}// </editor-fold>
}

View File

@ -31,14 +31,17 @@
<tr>
<c:forEach var="i" begin="0" end="6" step="1">
<c:forEach items='${sessionScope.lesPeriodes}' var="unePeriode" varStatus="status">
<c:set var="periode" value="${unePeriode.getCode()}" scope="page"/>
<td class="text-center">${unePeriode}</td>
</c:forEach>
</c:forEach>
</tr>
</thead>
<tbody>
<c:set var="oldId" value="-1" scope="page"/>
<tr>
<tr>
<c:forEach items='${sessionScope.lesVentilInit}' var="uneVentil" varStatus="status">
<c:set var="newId" value='${uneVentil.getPompier().getId()}' scope="page"/>
<c:if test='${oldId != newId}' var="test" scope="page">
@ -48,6 +51,7 @@
<c:set var="oldId" value='${newId}' scope="page"/>
</c:if>
<c:set var="activite" value='${uneVentil.getDisponibilite()}' scope="page"/>
<td>
<input readonly type="text" value='${activite}' name="lesActivites"class="ztVentil ${sessionScope.lesCouleurs[activite]}"/>

93
web/WEB-INF/gardeJSP.jsp Normal file
View File

@ -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" %>
<body>
<%@include file= "jspf/header.jspf" %>
<div class="container">
<section id="contenueAffiche" class="row">
<fieldset class="row mt-1 mb-10">
<legend>
Feuille de gardes
</legend>
<form action="gardes" method="POST">
<table class="table">
<thead>
<tr>
<th rowspan="2">No</th>
<th rowspan="2">Nom Prenom</th>
<c:forEach items='${sessionScope.lesDatesEnString}' var="uneDate" varStatus="status">
<th colspan="4" class="text-center"> ${uneDate}</th>
</c:forEach>
</tr>
<tr>
<c:forEach var="i" begin="0" end="6" step="1">
<c:forEach items='${sessionScope.lesPeriodes}' var="unePeriode" varStatus="status">
<c:set var="periode" value="${unePeriode.getCode()}" scope="page"/>
<td class="text-center">${unePeriode}</td>
</c:forEach>
</c:forEach>
</tr>
</thead>
<tbody>
<c:set var="oldId" value="-1" scope="page"/>
<tr>
<c:forEach items='${sessionScope.lesVentilInit}' var="uneVentil" varStatus="status">
<c:set var="newId" value='${uneVentil.getPompier().getId()}' scope="page"/>
<c:if test='${oldId != newId}' var="test" scope="page">
</tr><tr>
<td>${uneVentil.getPompier().getId()}</td>
<td>${uneVentil.getPompier().getNom()} ${uneVentil.getPompier().getPrenom()}</td>
<c:set var="oldId" value='${newId}' scope="page"/>
</c:if>
<c:set var="activite" value='${uneVentil.getDisponibilite()}' scope="page"/>
<td>
<input readonly type="text" value='${activite}' name="lesActivites"class="ztVentil ${sessionScope.lesCouleurs[activite]}"/>
</td>
</c:forEach>
</tr>
</tbody>
</table>
<div id="legendCouleur">
<span style="background-color: white">Dispo</span>
<span style="background-color: gray">Indispo</span>
<span style="background-color: yellow">Au travail</span>
<span>De garde : X</span>
</div>
</form>
</fieldset>
</section>
</div>
</body>
<script>
var couleurs = ["blanc", "gris", "jaune"];
var lesAct = document.getElementsByClassName("ztVentil");
for (var uneAct of lesAct) {
uneAct.onclick = function () {
var act = this.value;
var newAct = (act + 1) % 3;
var coul = couleurs[newAct];
this.classList.remove(couleurs[act]);
this.classList.add(coul);
this.value = newAct;
}
}
</script>

View File

@ -20,6 +20,10 @@
<servlet-name>feuilleGardes</servlet-name>
<servlet-class>servlet.GardesServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>GPServlet</servlet-name>
<servlet-class>servlet.GPServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AuthentifServlet</servlet-name>
<url-pattern>/authentification</url-pattern>
@ -32,6 +36,10 @@
<servlet-name>feuilleGardes</servlet-name>
<url-pattern>/gardes</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>GPServlet</servlet-name>
<url-pattern>/PompierGarde</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30