diff --git a/build.xml b/build.xml index ce3b2a1..90fd2bb 100644 --- a/build.xml +++ b/build.xml @@ -1,71 +1,71 @@ - - - - - - - - - - - Builds, tests, and runs the project sdis29M1. - - - + + + + + + + + + + + Builds, tests, and runs the project sdis29M1. + + + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index 0dbd1e3..1af4776 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -1,1434 +1,1434 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set build.web.dir - Must set build.generated.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.war - - - - - - - - - -The Java EE server classpath is not correctly set up - server home directory is missing. -Either open the project in the IDE and assign the server or setup the server classpath manually. -For example like this: - ant -Dj2ee.server.home=<app_server_installation_directory> - - -The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}. -Either open the project in the IDE and assign the server or setup the server classpath manually. -For example like this: - ant -Duser.properties.file=<path_to_property_file> (where you put the property "j2ee.platform.classpath" in a .properties file) -or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties file is used) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The libs.CopyLibs.classpath property is not set up. -This property must point to -org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part -of NetBeans IDE installation and is usually located at -<netbeans_installation>/java<version>/ant/extra folder. -Either open the project in the IDE and make sure CopyLibs library -exists or setup the property manually. For example like this: - ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.jsp.includes - - - - - - - - - - - - - - - - - - - - - - - - - - Must select a file in the IDE or set jsp.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable. - - - Launching ${browse.url} - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set build.web.dir + Must set build.generated.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.war + + + + + + + + + +The Java EE server classpath is not correctly set up - server home directory is missing. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Dj2ee.server.home=<app_server_installation_directory> + + +The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Duser.properties.file=<path_to_property_file> (where you put the property "j2ee.platform.classpath" in a .properties file) +or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +The libs.CopyLibs.classpath property is not set up. +This property must point to +org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part +of NetBeans IDE installation and is usually located at +<netbeans_installation>/java<version>/ant/extra folder. +Either open the project in the IDE and make sure CopyLibs library +exists or setup the property manually. For example like this: + ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.jsp.includes + + + + + + + + + + + + + + + + + + + + + + + + + + Must select a file in the IDE or set jsp.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable. + + + Launching ${browse.url} + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index b3e790c..b4c6904 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=b54f128f -build.xml.script.CRC32=111e10f7 -build.xml.stylesheet.CRC32=1707db4f@1.87.0.1 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=b54f128f -nbproject/build-impl.xml.script.CRC32=bc2b5756 -nbproject/build-impl.xml.stylesheet.CRC32=334708a0@1.87.0.1 +build.xml.data.CRC32=b54f128f +build.xml.script.CRC32=111e10f7 +build.xml.stylesheet.CRC32=1707db4f@1.86.0.1 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=b54f128f +nbproject/build-impl.xml.script.CRC32=bc2b5756 +nbproject/build-impl.xml.stylesheet.CRC32=334708a0@1.86.0.1 diff --git a/nbproject/project.properties b/nbproject/project.properties index 3e2694a..f2ff277 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -36,7 +36,7 @@ j2ee.compile.on.save=true j2ee.copy.static.files.on.save=true j2ee.deploy.on.save=true j2ee.platform=1.7-web -j2ee.platform.classpath=${j2ee.server.domain}/lib/annotations-api.jar:${j2ee.server.domain}/lib/catalina-ant.jar:${j2ee.server.domain}/lib/catalina-ha.jar:${j2ee.server.domain}/lib/catalina-ssi.jar:${j2ee.server.domain}/lib/catalina-storeconfig.jar:${j2ee.server.domain}/lib/catalina-tribes.jar:${j2ee.server.domain}/lib/catalina.jar:${j2ee.server.domain}/lib/ecj-4.20.jar:${j2ee.server.domain}/lib/el-api.jar:${j2ee.server.domain}/lib/jakartaee-migration-1.0.0-shaded.jar:${j2ee.server.domain}/lib/jasper-el.jar:${j2ee.server.domain}/lib/jasper.jar:${j2ee.server.domain}/lib/jaspic-api.jar:${j2ee.server.domain}/lib/jsp-api.jar:${j2ee.server.domain}/lib/servlet-api.jar:${j2ee.server.domain}/lib/tomcat-api.jar:${j2ee.server.domain}/lib/tomcat-coyote.jar:${j2ee.server.domain}/lib/tomcat-dbcp.jar:${j2ee.server.domain}/lib/tomcat-i18n-cs.jar:${j2ee.server.domain}/lib/tomcat-i18n-de.jar:${j2ee.server.domain}/lib/tomcat-i18n-es.jar:${j2ee.server.domain}/lib/tomcat-i18n-fr.jar:${j2ee.server.domain}/lib/tomcat-i18n-ja.jar:${j2ee.server.domain}/lib/tomcat-i18n-ko.jar:${j2ee.server.domain}/lib/tomcat-i18n-pt-BR.jar:${j2ee.server.domain}/lib/tomcat-i18n-ru.jar:${j2ee.server.domain}/lib/tomcat-i18n-zh-CN.jar:${j2ee.server.domain}/lib/tomcat-jdbc.jar:${j2ee.server.domain}/lib/tomcat-jni.jar:${j2ee.server.domain}/lib/tomcat-util-scan.jar:${j2ee.server.domain}/lib/tomcat-util.jar:${j2ee.server.domain}/lib/tomcat-websocket.jar:${j2ee.server.domain}/lib/websocket-api.jar +j2ee.platform.classpath=${j2ee.server.home}/lib/annotations-api.jar:${j2ee.server.home}/lib/catalina-ant.jar:${j2ee.server.home}/lib/catalina-ha.jar:${j2ee.server.home}/lib/catalina-ssi.jar:${j2ee.server.home}/lib/catalina-storeconfig.jar:${j2ee.server.home}/lib/catalina-tribes.jar:${j2ee.server.home}/lib/catalina.jar:${j2ee.server.home}/lib/ecj-4.20.jar:${j2ee.server.home}/lib/el-api.jar:${j2ee.server.home}/lib/jakartaee-migration-1.0.0-shaded.jar:${j2ee.server.home}/lib/jasper-el.jar:${j2ee.server.home}/lib/jasper.jar:${j2ee.server.home}/lib/jaspic-api.jar:${j2ee.server.home}/lib/jsp-api.jar:${j2ee.server.home}/lib/servlet-api.jar:${j2ee.server.home}/lib/tomcat-api.jar:${j2ee.server.home}/lib/tomcat-coyote.jar:${j2ee.server.home}/lib/tomcat-dbcp.jar:${j2ee.server.home}/lib/tomcat-i18n-cs.jar:${j2ee.server.home}/lib/tomcat-i18n-de.jar:${j2ee.server.home}/lib/tomcat-i18n-es.jar:${j2ee.server.home}/lib/tomcat-i18n-fr.jar:${j2ee.server.home}/lib/tomcat-i18n-ja.jar:${j2ee.server.home}/lib/tomcat-i18n-ko.jar:${j2ee.server.home}/lib/tomcat-i18n-pt-BR.jar:${j2ee.server.home}/lib/tomcat-i18n-ru.jar:${j2ee.server.home}/lib/tomcat-i18n-zh-CN.jar:${j2ee.server.home}/lib/tomcat-jdbc.jar:${j2ee.server.home}/lib/tomcat-jni.jar:${j2ee.server.home}/lib/tomcat-util-scan.jar:${j2ee.server.home}/lib/tomcat-util.jar:${j2ee.server.home}/lib/tomcat-websocket.jar:${j2ee.server.home}/lib/websocket-api.jar j2ee.server.type=Tomcat jar.compress=false javac.classpath=\ diff --git a/nbproject/project.xml b/nbproject/project.xml index 48b27ee..579a4b5 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -1,31 +1,31 @@ - - - org.netbeans.modules.web.project - - - sdis29M1 - 1.6.5 - - - ${file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar} - WEB-INF/lib - - - ${file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar} - WEB-INF/lib - - - ${file.reference.mysql-connector-java-8.0.26.jar} - WEB-INF/lib - - - - - - - - - - - - + + + org.netbeans.modules.web.project + + + sdis29M1 + 1.6.5 + + + ${file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar} + WEB-INF/lib + + + ${file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar} + WEB-INF/lib + + + ${file.reference.mysql-connector-java-8.0.26.jar} + WEB-INF/lib + + + + + + + + + + + + diff --git a/src/java/bdd/GardeMySQL.java b/src/java/bdd/GardeMySQL.java index fe1bab9..abf917f 100644 --- a/src/java/bdd/GardeMySQL.java +++ b/src/java/bdd/GardeMySQL.java @@ -8,7 +8,7 @@ package bdd; import bean.Caserne; import bean.Gardes; import bean.Pompier; -import com.sdis29a.util.TrmtDate; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -18,6 +18,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.logging.Level; import java.util.logging.Logger; +import util.TrmtDate; /** * diff --git a/src/java/bean/Gardes.java b/src/java/bean/Gardes.java index 8c19eb1..f2c3d9d 100644 --- a/src/java/bean/Gardes.java +++ b/src/java/bean/Gardes.java @@ -13,11 +13,11 @@ import java.util.Objects; * @author funcha.ahamadi */ public class Gardes { - public Calendar jourGarde; - public int periode; - public Pompier pompier; - public int disponibilite; - public boolean isInBDD; + Calendar jourGarde; + int periode; + Pompier pompier; + int disponibilite; + boolean isInBDD; public Gardes(Calendar jourGarde, int periode, Pompier pompier, int disponibilite, boolean isInBDD) { this.jourGarde = jourGarde; diff --git a/src/java/bean/Pompier.java b/src/java/bean/Pompier.java index 5b6548e..ad8b5d4 100644 --- a/src/java/bean/Pompier.java +++ b/src/java/bean/Pompier.java @@ -59,7 +59,6 @@ public class Pompier { this.nom = nom; this.prenom = prenom; } - public int getId() { return id; diff --git a/src/java/form/DispoForm.java b/src/java/form/DispoForm.java new file mode 100644 index 0000000..dc6f1c5 --- /dev/null +++ b/src/java/form/DispoForm.java @@ -0,0 +1,51 @@ +/* + * 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 form; + +import bdd.gardeMySQL; +import bean.Gardes; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpSession; +import java.util.ArrayList; +import java.util.Map; + +/** + * + * @author clementine.desrucques + */ +public class DispoForm { + HttpServletRequest request; + + public void verifDispo(HttpServletRequest request){ + HttpSession maS = request.getSession(); + ArrayList lesG = (ArrayList) maS.getAttribute("lesVentilInit"); + + gardeMySQL vm = new gardeMySQL(); + Map map = request.getParameterMap(); + String[] lesNvVentil = map.get("lesAct"); + int i = 0; + for(Gardes uneGarde : lesG){ + int oldAct = uneGarde.getDisponibilite(); + int newAct = Integer.parseInt(lesNvVentil[i]); + if(oldAct != newAct){ + if(uneGarde.isIsInBDD()){ + if(newAct == 0){ + vm.delete(uneGarde); + uneGarde.setIsInBDD(false); + } else { + uneGarde.setDisponibilite(newAct); + vm.update(uneGarde); + } + } else { + uneGarde.setDisponibilite(newAct); + vm.create(uneGarde); + uneGarde.setIsInBDD(true); + } + } + i++; + } + } +} diff --git a/src/java/servlet/GardesServlet.java b/src/java/servlet/GardesServlet.java index 2cd14ec..2fc8ecd 100644 --- a/src/java/servlet/GardesServlet.java +++ b/src/java/servlet/GardesServlet.java @@ -5,8 +5,12 @@ */ package servlet; +import bdd.GardeMySQL; +import bdd.gardeMySQL; +import bean.Gardes; import bean.Pompier; -import com.sdis29a.util.TrmtDate; +import form.DispoForm; +import util.TrmtDate; import java.io.IOException; import java.io.PrintWriter; import jakarta.servlet.ServletException; @@ -63,23 +67,38 @@ public class GardesServlet extends HttpServlet { 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); + //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/feuilleGardes.jsp").forward(request, response); } @@ -95,7 +114,10 @@ public class GardesServlet extends HttpServlet { @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - processRequest(request, response); +// processRequest(request, response); + DispoForm vf = new DispoForm(); + vf.verifDispo(request); + getServletContext().getRequestDispatcher("/WEB-INF/pompierJSP.jsp").forward(request, response); } /** diff --git a/src/java/servlet/PompierServlet.java b/src/java/servlet/PompierServlet.java index e20b467..946770c 100644 --- a/src/java/servlet/PompierServlet.java +++ b/src/java/servlet/PompierServlet.java @@ -36,7 +36,7 @@ public class PompierServlet extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); - try (PrintWriter out = response.getWriter()) { + try ( PrintWriter out = response.getWriter()) { /* TODO output your page here. You may use following sample code. */ out.println(""); out.println(""); @@ -74,7 +74,7 @@ public class PompierServlet extends HttpServlet { boolean isNumeric = StringUtils.isStrictlyNumeric(pageEnString); if (isNumeric) { pageDemandee = Integer.parseInt(pageEnString); - if (pageDemandee != 2 && pageDemandee != 3) { // erreur + if (pageDemandee != 2 && pageDemandee != 3 && pageDemandee != 5) { // erreur erreur = true; } } else { @@ -101,12 +101,13 @@ public class PompierServlet extends HttpServlet { page = 3; } } + if (erreur) { request.getRequestDispatcher("/authentification").forward(request, response); // redirection servlet } else { request.setAttribute("page", page); maSession.setAttribute("lePompier", lePompier); - getServletContext().getRequestDispatcher("/WEB-INF/" + jsp).forward(request, response); + getServletContext().getRequestDispatcher("/WEB-INF/" + jsp).forward(request, response); } } @@ -126,16 +127,16 @@ public class PompierServlet extends HttpServlet { depuis la validation du formulaire de choix du pompier à afficher (btAfficherPompier = "Afficher") depuis le bouton Ajouter du formulaire du choix du pompier (btAfficherPompier = "Ajouter") depuis le bouton de validation de mise à jour d'un pompier (btAfficherPompier = "ValiderMaj") - */ + */ int erreur = 0; String btValue = null; - ArrayList valeursBt = new ArrayList() ; - valeursBt.add("Afficher") ; - valeursBt.add("Ajouter") ; - valeursBt.add("ValiderMaj") ; - + ArrayList valeursBt = new ArrayList(); + valeursBt.add("Afficher"); + valeursBt.add("Ajouter"); + valeursBt.add("ValiderMaj"); + // Test du bouton btAfficherPompier - if (request.getParameter("btAfficherPompier")==null) { + if (request.getParameter("btAfficherPompier") == null) { erreur = 1; } else { btValue = request.getParameter("btAfficherPompier"); @@ -148,7 +149,7 @@ public class PompierServlet extends HttpServlet { //response.sendRedirect("/sdis29M1/authentification"); return; } - + HttpSession maSession = request.getSession(); ArrayList lesPompiers = (ArrayList) maSession.getAttribute("lesPompiers"); if (request.getParameter("btAfficherPompier").equals("Afficher") @@ -158,12 +159,12 @@ public class PompierServlet extends HttpServlet { maSession.setAttribute("lePompier", lesPompiers.get(noPompier)); request.setAttribute("page", 3); } - + if (request.getParameter("btAfficherPompier").equals("Ajouter")) { maSession.removeAttribute("lePompier"); } - - if (request.getParameter("btAfficherPompier").equals("ValiderMaj")) { + + if (request.getParameter("btAfficherPompier").equals("ValiderMaj")) { PompierForm pf = new PompierForm(request); boolean valid = pf.ctrlPompier(); // if (maSession.getAttribute("lePompier")==null) { @@ -178,8 +179,8 @@ public class PompierServlet extends HttpServlet { // } // } pf.majBDD(); - } - + } + getServletContext().getRequestDispatcher("/WEB-INF/pompierJSP.jsp").forward(request, response); } diff --git a/src/java/util/TrmtDate.java b/src/java/util/TrmtDate.java index ab20e1b..de03226 100644 --- a/src/java/util/TrmtDate.java +++ b/src/java/util/TrmtDate.java @@ -1,129 +1,129 @@ -package com.sdis29a.util; -/* - * Classe abstraite facilitant le traitement des dates - * Toutes les méthodes sont statiques, appel : TrmtDate.nomMéthode - */ - -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.GregorianCalendar; -import java.util.Locale; -import java.util.TimeZone; - -/** - * - * @author Dominique_2 - */ -public abstract class TrmtDate { - static Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Paris")); - - /** - * Recherche de la date du début de la semaine courante - * @return date du lundi de la semaine, format Calendar - */ - public static Calendar getDateDebutSemaine() { - return getDateDebutSemaine(getDateDuJour()); - } - - /** - * Recherche de la date du début de semaine à partir de la date passée en paramètre - * @param c Calendar, date de recherche - * @return Calendar, début semaine à partir de c - */ - public static Calendar getDateDebutSemaine(Calendar c) { - Calendar leCal = getClone(c); - leCal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); - //System.out.println("Date du lundi correspondant : " + nvCal.getTime()); - return leCal; - } - /** - * Retourne la date passée en paramètre sous la forme : lun.05/10 par exemple - * @param d date à transformer - * @return chaine de car., forme lun.05/10 par exemple - */ - public static String getDateAAfficher(Calendar d) { - Locale locale = Locale.getDefault(); - String dateAAfficher = d.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, locale); - SimpleDateFormat sdf = new SimpleDateFormat("dd/MM"); - String jrMois = sdf.format(d.getTime()); - dateAAfficher += jrMois; - return dateAAfficher; - } - - /** - * Retourne une date égale à la date passée en paramètre plus le nb jours indiqués - * @param dateInit date initiale, format Calendar - * @param days nb jours à ajouter - * @return dateInit + days, format Calendar - */ - public static Calendar addDays(Calendar dateInit, int days) { - Calendar leCal = getClone(dateInit); - leCal.setTime(dateInit.getTime()); - leCal.add(Calendar.DAY_OF_MONTH, days); - return leCal; - } - - /** - * Retourne une instance de Calendar correspondant à la date au format SQl - * passée en paramètre - * @param sqlDate : date au format java.sql.Date - * @return instance de Calendar - */ - public static Calendar getCalDate(java.sql.Date sqlDate) { - cal.setTime(new java.util.Date(sqlDate.getTime())); - return cal; - } - - /** - * Retourne une date sql à partir d'une instance de Calendar - * @param unCal - * @return date sql - */ - public static java.sql.Date getSQLDate(Calendar unCal) { - return new java.sql.Date(unCal.getTimeInMillis()); - } - - /** - * Retourne une instance de Calendar correspondant à la date - * passée en paramètre - * @param utilDate : date au format java.util.Date - * @return instance de Calendar - */ - public static Calendar getCalDate(java.util.Date utilDate) { - cal.setTime(utilDate); - return cal; - } - - /** - * Retourne la date du jour au format SQL - * @return Date au format sql - */ - public static java.sql.Date getSQLDateDuJour() { - return java.sql.Date.valueOf(java.time.LocalDate.now()); - } - - /** - * Retourne la date du jour au format Calendar - * @return Calendar - */ - public static Calendar getDateDuJour() { - Calendar nvCal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Paris")); - nvCal.set(Calendar.HOUR_OF_DAY, 0); - nvCal.set(Calendar.MINUTE, 0); - nvCal.set(Calendar.SECOND, 0); - nvCal.set(Calendar.MILLISECOND, 0); - //System.out.println("Date du jour : " + nvCal.getTime()); - return nvCal; - } - - /** - * Permet d'obtenir une autre instance de Calendar identique à celle passée en paramètre - * @param c Calendar à cloner - * @return nouvelle instance de Calendar - */ - public static Calendar getClone(Calendar c) { - Calendar leCal = Calendar.getInstance(); - leCal.setTime(c.getTime()); - return leCal; - } -} +package util; +/* + * Classe abstraite facilitant le traitement des dates + * Toutes les méthodes sont statiques, appel : TrmtDate.nomMéthode + */ + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; + +/** + * + * @author Dominique_2 + */ +public abstract class TrmtDate { + static Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Paris")); + + /** + * Recherche de la date du début de la semaine courante + * @return date du lundi de la semaine, format Calendar + */ + public static Calendar getDateDebutSemaine() { + return getDateDebutSemaine(getDateDuJour()); + } + + /** + * Recherche de la date du début de semaine à partir de la date passée en paramètre + * @param c Calendar, date de recherche + * @return Calendar, début semaine à partir de c + */ + public static Calendar getDateDebutSemaine(Calendar c) { + Calendar leCal = getClone(c); + leCal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); + //System.out.println("Date du lundi correspondant : " + nvCal.getTime()); + return leCal; + } + /** + * Retourne la date passée en paramètre sous la forme : lun.05/10 par exemple + * @param d date à transformer + * @return chaine de car., forme lun.05/10 par exemple + */ + public static String getDateAAfficher(Calendar d) { + Locale locale = Locale.getDefault(); + String dateAAfficher = d.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, locale); + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM"); + String jrMois = sdf.format(d.getTime()); + dateAAfficher += jrMois; + return dateAAfficher; + } + + /** + * Retourne une date égale à la date passée en paramètre plus le nb jours indiqués + * @param dateInit date initiale, format Calendar + * @param days nb jours à ajouter + * @return dateInit + days, format Calendar + */ + public static Calendar addDays(Calendar dateInit, int days) { + Calendar leCal = getClone(dateInit); + leCal.setTime(dateInit.getTime()); + leCal.add(Calendar.DAY_OF_MONTH, days); + return leCal; + } + + /** + * Retourne une instance de Calendar correspondant à la date au format SQl + * passée en paramètre + * @param sqlDate : date au format java.sql.Date + * @return instance de Calendar + */ + public static Calendar getCalDate(java.sql.Date sqlDate) { + cal.setTime(new java.util.Date(sqlDate.getTime())); + return cal; + } + + /** + * Retourne une date sql à partir d'une instance de Calendar + * @param unCal + * @return date sql + */ + public static java.sql.Date getSQLDate(Calendar unCal) { + return new java.sql.Date(unCal.getTimeInMillis()); + } + + /** + * Retourne une instance de Calendar correspondant à la date + * passée en paramètre + * @param utilDate : date au format java.util.Date + * @return instance de Calendar + */ + public static Calendar getCalDate(java.util.Date utilDate) { + cal.setTime(utilDate); + return cal; + } + + /** + * Retourne la date du jour au format SQL + * @return Date au format sql + */ + public static java.sql.Date getSQLDateDuJour() { + return java.sql.Date.valueOf(java.time.LocalDate.now()); + } + + /** + * Retourne la date du jour au format Calendar + * @return Calendar + */ + public static Calendar getDateDuJour() { + Calendar nvCal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Paris")); + nvCal.set(Calendar.HOUR_OF_DAY, 0); + nvCal.set(Calendar.MINUTE, 0); + nvCal.set(Calendar.SECOND, 0); + nvCal.set(Calendar.MILLISECOND, 0); + //System.out.println("Date du jour : " + nvCal.getTime()); + return nvCal; + } + + /** + * Permet d'obtenir une autre instance de Calendar identique à celle passée en paramètre + * @param c Calendar à cloner + * @return nouvelle instance de Calendar + */ + public static Calendar getClone(Calendar c) { + Calendar leCal = Calendar.getInstance(); + leCal.setTime(c.getTime()); + return leCal; + } +} diff --git a/web/WEB-INF/feuilleGardes.jsp b/web/WEB-INF/feuilleGardes.jsp index ffd469d..922d4d9 100644 --- a/web/WEB-INF/feuilleGardes.jsp +++ b/web/WEB-INF/feuilleGardes.jsp @@ -3,52 +3,44 @@ Created on : 6 déc. 2021, 15:07:45 Author : funcha.ahamadi --%> - <%@page contentType="text/html" pageEncoding="UTF-8"%> - - Feuille de gardes - -
- - - - - - - - +<%@include file= "jspf/debutJSP.jspf" %> + + + <%@include file= "jspf/header.jspf" %> +
+
+ + +
+ + + Feuille de gardes + + +
N° de BIPNom Prenom ${uneDate}
+ + + + + + + + + + + + + + + + + +
NoNom Prenom ${uneDate}
${unePeriode}
+
+ + + - - - - - ${unePeriode} - - - - - - - - - - - - ${uneVentil.getPompier().getId()} - ${uneVentil.getPompier().getNom()} ${uneVentil.getPompier().getPrenom()} - - - - - - - - - - - - - - \ No newline at end of file diff --git a/web/WEB-INF/jspf/formulairePompier.jspf b/web/WEB-INF/jspf/formulairePompier.jspf index 9c61a35..e293302 100644 --- a/web/WEB-INF/jspf/formulairePompier.jspf +++ b/web/WEB-INF/jspf/formulairePompier.jspf @@ -126,7 +126,56 @@ value="${lePompier.getCommentaire()}" /> +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
${uneDate}
${uneP}
${ventil.getSalarie().getId()}${ventil.getSalarie().getNom()} ${ventil.getSalarie().getPrenom()}
+
+ + Dispo + Indispo + Au travail + + +
+
+ + + +
${message}
@@ -134,10 +183,26 @@ Valider
- +

* zone obligatoire

- + + diff --git a/web/WEB-INF/jspf/header.jspf b/web/WEB-INF/jspf/header.jspf index f000f40..9baa2c7 100644 --- a/web/WEB-INF/jspf/header.jspf +++ b/web/WEB-INF/jspf/header.jspf @@ -90,18 +90,13 @@ @@ -110,4 +105,4 @@ - \ No newline at end of file +