Merge origin/master
Conflicts: web/WEB-INF/feuilleGardes.jsp web/css/mycss.css
This commit is contained in:
parent
332960f92d
commit
3162d0eeb3
@ -1,132 +0,0 @@
|
||||
/*
|
||||
* 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>
|
||||
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
<%--
|
||||
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">
|
||||
|
||||
<td class="text-center">${unePeriode.getCode()}</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>
|
Loading…
x
Reference in New Issue
Block a user