From 5287b5ff741262c274f7d0b6fe7520eb0e2fab20 Mon Sep 17 00:00:00 2001 From: "clementine.desrucques" Date: Thu, 16 Dec 2021 16:50:32 +0100 Subject: [PATCH] Merge origin/master Conflicts: web/WEB-INF/feuilleGardes.jsp web/css/mycss.css --- src/java/bean/Gardes.java | 8 +++ src/java/form/DispoForm.java | 66 ++++++++++++++++++++ src/java/servlet/GardesServlet.java | 5 ++ web/WEB-INF/feuilleGardes.jsp | 95 ++++++++++++++++++----------- web/WEB-INF/jspf/header.jspf | 5 +- 5 files changed, 141 insertions(+), 38 deletions(-) diff --git a/src/java/bean/Gardes.java b/src/java/bean/Gardes.java index 41eca71..f697237 100644 --- a/src/java/bean/Gardes.java +++ b/src/java/bean/Gardes.java @@ -29,6 +29,14 @@ public class Gardes { this.deGarde = deGarde; } + public Gardes(Calendar jourGarde, int periode, Pompier pompier, boolean deGarde) { + this.jourGarde = jourGarde; + this.periode = periode; + this.pompier = pompier; + this.deGarde = deGarde; + } + + public Gardes(Calendar jourGarde, int periode, Pompier pompier) { this.jourGarde = jourGarde; this.periode = periode; diff --git a/src/java/form/DispoForm.java b/src/java/form/DispoForm.java index ae66fab..416e651 100644 --- a/src/java/form/DispoForm.java +++ b/src/java/form/DispoForm.java @@ -12,6 +12,7 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpSession; import java.util.ArrayList; import java.util.Map; +import javax.swing.JCheckBox; /** * @@ -28,6 +29,13 @@ public class DispoForm { GardeMySQL vm = new GardeMySQL(); Map map = request.getParameterMap(); String[] lesNvVentil = map.get("lesActivites"); + String[] lesNvGardes = map.get("cbGarde"); + ArrayList lesNvGardesN = new ArrayList<>(); + if(lesNvGardes != null){ + for(String uneGarde : lesNvGardes){ + lesNvGardesN.add(Integer.parseInt(uneGarde)); + } + } int i = 0; for (Gardes uneGarde : lesG) { int oldAct = uneGarde.getDisponibilite(); @@ -49,6 +57,64 @@ public class DispoForm { uneGarde.setIsInBDD(true); } + } + boolean oldGarde = uneGarde.isDeGarde(); + boolean newGarde = lesNvGardesN.contains(i)?true:false; + System.out.println("1: "+oldGarde +" "+ newGarde); + if(oldGarde!= newGarde){ + uneGarde.setDeGarde(newGarde); + System.out.println("2: "+oldGarde +" "+ newGarde); + if (uneGarde.isIsInBDD()) { + vm.update(uneGarde); + }else{ + vm.create(uneGarde); + uneGarde.setIsInBDD(true); + System.out.println("3: "+oldGarde +" "+ newGarde); + } + } + + + + + + + + + i++; + } + } + + public void verifGarde(HttpServletRequest request) { + HttpSession maS = request.getSession(); + ArrayList lesG = (ArrayList) maS.getAttribute("lesVentilInit"); + + GardeMySQL vm = new GardeMySQL(); + Map map = request.getParameterMap(); + String[] lesNvVentil = map.get("cbGarde"); +// JCheckBox garde = new JCheckBox(); + int i = 0; + for (Gardes uneGarde : lesG) { + boolean oldAct = uneGarde.isDeGarde(); + int newAct = Integer.parseInt(lesNvVentil[i]); + boolean newActO = (newAct==Integer.parseInt(lesNvVentil[i])); + + if (oldAct != newActO) { + if (uneGarde.isIsInBDD()) { + + if (newActO == false) { + vm.delete(uneGarde); + uneGarde.setIsInBDD(false); + uneGarde.isDeGarde(); + } else { + uneGarde.isDeGarde(); + vm.update(uneGarde); + } + } else { + uneGarde.isDeGarde(); + vm.create(uneGarde); + uneGarde.setIsInBDD(true); + } + } i++; } diff --git a/src/java/servlet/GardesServlet.java b/src/java/servlet/GardesServlet.java index 366b3d8..92a8e9e 100644 --- a/src/java/servlet/GardesServlet.java +++ b/src/java/servlet/GardesServlet.java @@ -94,6 +94,10 @@ public class GardesServlet extends HttpServlet { //System.out.println("lesVentilInit : " + lesVentilInit); maSession.setAttribute("lesVentilInit", lesVentilInit); +// GardeMySQL dg = new GardeMySQL(); +// ArrayList lesgardes = dg.(); +// //System.out.println("lesVentilInit : " + lesVentilInit); +// maSession.setAttribute("lesVentilInit", lesVentilInit); /* Initialisation des couleurs */ String[] lesCouleurs = {"blanc", "gris", "jaune"}; @@ -117,6 +121,7 @@ public class GardesServlet extends HttpServlet { // processRequest(request, response); DispoForm vf = new DispoForm(); vf.verifDispo(request); + getServletContext().getRequestDispatcher("/WEB-INF/pompierJSP.jsp").forward(request, response); } diff --git a/web/WEB-INF/feuilleGardes.jsp b/web/WEB-INF/feuilleGardes.jsp index 16b7dcb..af6f8e3 100644 --- a/web/WEB-INF/feuilleGardes.jsp +++ b/web/WEB-INF/feuilleGardes.jsp @@ -31,37 +31,53 @@ - + ${unePeriode.getCode()} - - - - - - - - - - ${uneVentil.getPompier().getId()} - ${uneVentil.getPompier().getNom()} ${uneVentil.getPompier().getPrenom()} + - - - - - - - - - - - + + - + + + + + ${uneVentil.getPompier().getId()} + ${uneVentil.getPompier().getNom()} ${uneVentil.getPompier().getPrenom()} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -71,27 +87,32 @@ De garde : ☑
-
- -
+
+ +
diff --git a/web/WEB-INF/jspf/header.jspf b/web/WEB-INF/jspf/header.jspf index 9baa2c7..aed80ed 100644 --- a/web/WEB-INF/jspf/header.jspf +++ b/web/WEB-INF/jspf/header.jspf @@ -14,7 +14,10 @@

Bienvenue ${sessionScope.lePompierConnecte.getPrenom()} ${sessionScope.lePompierConnecte.getNom()} ( - ${sessionScope.lePompierConnecte.getLeStatut().getValeur()}) + + ${sessionScope.lePompierConnecte.getLeStatut().getValeur()} + + )