From be3ffce3dbf1ff1a171a4c17f34ac5ee7edca61f Mon Sep 17 00:00:00 2001 From: "U-UNIMES\\bquiller" Date: Fri, 2 Feb 2024 15:41:09 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Externalisation=20des=20requ=C3=A8tes=20SQL?= =?UTF-8?q?=20de=20ApogeeService=20dans=20emargement.properties=20Ajout=20?= =?UTF-8?q?d'une=20cr=C3=A9ation=20de=20plan=20dans=20Administrateur>Lieux?= =?UTF-8?q?=20stock=C3=A9=20en=20json=20selon=20le=20param=20emargement.pl?= =?UTF-8?q?ans.path=20Attribution=20d'une=20place=20lors=20de=20la=20r?= =?UTF-8?q?=C3=A9partition=20et=20envoi=20lors=20de=20la=20convocation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../emargement/config/PlanConfig.java | 16 + .../esupportail/emargement/domain/Campus.java | 26 +- .../emargement/domain/Location.java | 51 +- .../esupportail/emargement/domain/Plan.java | 68 +++ .../emargement/domain/SessionType.java | 42 ++ .../emargement/domain/TagCheck.java | 14 + .../repositories/CampusRepository.java | 6 +- .../EmargementRepositoryAspect.java | 4 +- .../repositories/EsupSignatureRepository.java | 3 - .../repositories/LocationRepository.java | 36 +- .../SessionEpreuveRepository.java | 7 +- .../repositories/SessionTypeRepository.java | 15 + .../repositories/TagCheckRepository.java | 5 + .../emargement/services/ApogeeService.java | 462 +++++++++--------- .../emargement/services/CalendarService.java | 2 +- .../emargement/services/CampusService.java | 48 ++ .../emargement/services/ContextService.java | 7 - .../emargement/services/LocationService.java | 137 +++++- .../emargement/services/PresenceService.java | 21 +- .../services/SessionEpreuveService.java | 41 ++ .../emargement/services/TagCheckService.java | 3 +- .../web/admin/LocationController.java | 288 ++++++----- src/main/resources/emargement.properties | 70 +++ src/main/resources/messages.properties | 14 +- src/main/resources/security.properties | 2 +- src/main/resources/static/css/app.css | 22 +- src/main/resources/static/js/app.js | 142 ++++-- .../templates/admin/location/form.html | 204 ++++++++ .../templates/admin/location/list.html | 4 +- .../templates/admin/location/view.html | 58 +++ .../resources/templates/fragments/head.html | 4 +- .../templates/manager/extraction/index.html | 15 +- .../templates/manager/individu/index.html | 12 +- .../manager/sessionEpreuve/tagCheckList.html | 2 + .../manager/tagCheck/convocation.html | 2 +- src/main/resources/version.properties | 2 +- 36 files changed, 1336 insertions(+), 519 deletions(-) create mode 100755 src/main/java/org/esupportail/emargement/config/PlanConfig.java create mode 100755 src/main/java/org/esupportail/emargement/domain/Plan.java create mode 100755 src/main/java/org/esupportail/emargement/domain/SessionType.java create mode 100755 src/main/java/org/esupportail/emargement/repositories/SessionTypeRepository.java create mode 100755 src/main/java/org/esupportail/emargement/services/CampusService.java create mode 100755 src/main/resources/templates/admin/location/form.html create mode 100755 src/main/resources/templates/admin/location/view.html diff --git a/src/main/java/org/esupportail/emargement/config/PlanConfig.java b/src/main/java/org/esupportail/emargement/config/PlanConfig.java new file mode 100755 index 0000000..7c8cd39 --- /dev/null +++ b/src/main/java/org/esupportail/emargement/config/PlanConfig.java @@ -0,0 +1,16 @@ +package org.esupportail.emargement.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Component @ConfigurationProperties(prefix="emargement.plans") +public class PlanConfig { + + private String path; + public String getPath() { + return path; + } + public void setPath(String path) { + this.path = path; + } +} diff --git a/src/main/java/org/esupportail/emargement/domain/Campus.java b/src/main/java/org/esupportail/emargement/domain/Campus.java index 148cafd..f735477 100644 --- a/src/main/java/org/esupportail/emargement/domain/Campus.java +++ b/src/main/java/org/esupportail/emargement/domain/Campus.java @@ -6,6 +6,8 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.ManyToOne; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; import org.hibernate.annotations.Filter; import org.hibernate.annotations.FilterDef; @@ -17,22 +19,22 @@ @FilterDef(name = "contextFilter", parameters = {@ParamDef(name = "context", type = "long")}) @Filter(name = "contextFilter", condition = "context_id= :context") public class Campus implements ContextSupport { - + @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.AUTO) @JsonIgnore - private Long id; - + private Long id; + @ManyToOne @JsonIgnore private Context context; - - private String site; - - @Column(columnDefinition = "TEXT") - @JsonIgnore - private String description; - + + private String site; + + @Column(columnDefinition = "TEXT") + @JsonIgnore + private String description; + public Long getId() { return id; } @@ -58,5 +60,5 @@ public Context getContext() { public void setContext(Context context) { this.context = context; } - + } diff --git a/src/main/java/org/esupportail/emargement/domain/Location.java b/src/main/java/org/esupportail/emargement/domain/Location.java index 1c362db..cc6a45f 100644 --- a/src/main/java/org/esupportail/emargement/domain/Location.java +++ b/src/main/java/org/esupportail/emargement/domain/Location.java @@ -6,7 +6,7 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.ManyToOne; - +import javax.persistence.Transient; import org.hibernate.annotations.Filter; import org.hibernate.annotations.FilterDef; import org.hibernate.annotations.ParamDef; @@ -16,26 +16,29 @@ @FilterDef(name = "contextFilter", parameters = {@ParamDef(name = "context", type = "long")}) @Filter(name = "contextFilter", condition = "context_id= :context") public class Location implements ContextSupport { - + @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + @ManyToOne private Context context; - - private String nom; - - @ManyToOne - private Campus campus; - - @NumberFormat - private int capacite=0; - - @Column(columnDefinition = "TEXT") - private String adresse; - - private Long adeClassRoomId; + + private String nom; + + @ManyToOne + private Campus campus; + + @NumberFormat + private int capacite=0; + + @Transient + private Plan plan; + + @Column(columnDefinition = "TEXT") + private String adresse; + + private Long adeClassRoomId; public Long getId() { return id; @@ -67,7 +70,7 @@ public int getCapacite() { public void setCapacite(int capacite) { this.capacite = capacite; } - + public String getAdresse() { return adresse; } @@ -91,4 +94,14 @@ public Long getAdeClassRoomId() { public void setAdeClassRoomId(Long adeClassRoomId) { this.adeClassRoomId = adeClassRoomId; } + + public void setPlan(Plan plan) { + this.plan = plan; + } + + public Plan getPlan() { return plan; } + + public boolean hasPlan() { + return plan != null; + } } diff --git a/src/main/java/org/esupportail/emargement/domain/Plan.java b/src/main/java/org/esupportail/emargement/domain/Plan.java new file mode 100755 index 0000000..6c93710 --- /dev/null +++ b/src/main/java/org/esupportail/emargement/domain/Plan.java @@ -0,0 +1,68 @@ +package org.esupportail.emargement.domain; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotEmpty; + +import com.fasterxml.jackson.annotation.JsonIgnore; +public class Plan { + + private static final byte DEFAULT_SIZE = 10, MAX_SIZE = Byte.MAX_VALUE; + private boolean hasAlphanumEnum = true; + + @Min(value=1,message="Le plan a un nombre de colonnes inférieur à 1 !") + @Max(value=MAX_SIZE,message="Le plan a dépassé le maximum de colonnes !") + private byte columns = DEFAULT_SIZE; + + @Min(value=1,message="Le plan a un nombre de lignes inférieur à 1 !") + @Max(value=MAX_SIZE,message="Le plan a dépassé le maximum de lignes !") + private byte rows = DEFAULT_SIZE; + + private Short[] specialPlaces = new Short[0]; + + @NotEmpty(message="Le plan n'a pas de place !") + private Short[] standardPlaces = new Short[0]; + + public void setHasAlphanumEnum(boolean alphanum) { + hasAlphanumEnum = alphanum; + } + + public void setColumns(byte cols) { + columns = cols; + } + + public void setRows(byte rows) { + this.rows = rows; + } + + public void setSpecialPlaces(Short[] places) { + this.specialPlaces = places; + } + + public void setStandardPlaces(Short[] places) { + this.standardPlaces = places; + } + + public boolean getHasAlphanumEnum() { + return hasAlphanumEnum; + } + + public byte getColumns() { + return columns; + } + + public byte getRows() { + return rows; + } + + @JsonIgnore public short getCapacity() { + return (short)standardPlaces.length; + } + + public Short[] getSpecialPlaces() { + return specialPlaces; + } + + public Short[] getStandardPlaces() { + return standardPlaces; + } +} diff --git a/src/main/java/org/esupportail/emargement/domain/SessionType.java b/src/main/java/org/esupportail/emargement/domain/SessionType.java new file mode 100755 index 0000000..a8dc5b2 --- /dev/null +++ b/src/main/java/org/esupportail/emargement/domain/SessionType.java @@ -0,0 +1,42 @@ +package org.esupportail.emargement.domain; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.SequenceGenerator; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Transient; +import javax.persistence.UniqueConstraint; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import org.apache.commons.lang3.ArrayUtils; +import org.hibernate.annotations.Filter; +import org.hibernate.annotations.FilterDef; +import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.ParamDef; +import org.hibernate.annotations.Parameter; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +@Entity @Table(uniqueConstraints={@UniqueConstraint(columnNames={"key","context_id"})}) @FilterDef(name="filter",parameters={@ParamDef(type="short",name="context")}) @Filter(name="filter",condition="context_id = :context") public class SessionType implements ContextSupport { + private static final String[] NATIVE_KEYS = { "CM", "COL", "CONC", "CONF", "EXAM", "EXPO", "FOR", "REU", "SEM", "TD", "TP" }; + @Id @GenericGenerator(name="gen",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={@Parameter(name="increment",value="1"),@Parameter(name="sequence_name",value="session_type_sequence")}) @GeneratedValue(generator="gen") @JsonIgnore private Short id; + @NotBlank(message="Le code du type de session est vide !") @Size(max=5,message="Le code du type de session comporte plus de 5 caractères !") @Column(unique=true) @JsonIgnore private String key; + @NotBlank(message="L'intitulé du type de session est vide !") @Size(max=64,message="L'intitulé du type de session comporte plus de 64 caractères !") private String title; + @Size(max=256,message="La description du type de session comporte plus de 256 caractères !") @JsonIgnore private String description; + @NotNull(message="Le contexte du type de session est inconnu !") @ManyToOne @JsonIgnore private Context context; + public void setId(short id) { this.id = id; } + public void setKey(String key) { this.key = key; } + public void setTitle(String title) { this.title = title; } + public void setDescription(String description) { this.description = description; } + public void setContext(Context context) { this.context = context; } + public boolean getNative() { return ArrayUtils.contains(NATIVE_KEYS, key); } + public Short getId() { return id; } + public String getKey() { return key; } + public String getTitle() { return title; } + public String getDescription() { return description; } + public Context getContext() { return context; } +} diff --git a/src/main/java/org/esupportail/emargement/domain/TagCheck.java b/src/main/java/org/esupportail/emargement/domain/TagCheck.java index 5e6190e..3686713 100644 --- a/src/main/java/org/esupportail/emargement/domain/TagCheck.java +++ b/src/main/java/org/esupportail/emargement/domain/TagCheck.java @@ -88,6 +88,12 @@ public static enum TypeEmargement { private Integer nbBadgeage; + private String place; + + public String toString() { + return getClass().getName() + "@" + Integer.toHexString(hashCode()) + " - place : "+ place; + } + public Long getId() { return id; } @@ -271,4 +277,12 @@ public Boolean getIsBlacklisted() { public void setIsBlacklisted(Boolean isBlacklisted) { this.isBlacklisted = isBlacklisted; } + + public String getPlace() { + return place; + } + public void setPlace(String place) { + this.place = place; + } + } diff --git a/src/main/java/org/esupportail/emargement/repositories/CampusRepository.java b/src/main/java/org/esupportail/emargement/repositories/CampusRepository.java index 0b3e288..9778ea1 100644 --- a/src/main/java/org/esupportail/emargement/repositories/CampusRepository.java +++ b/src/main/java/org/esupportail/emargement/repositories/CampusRepository.java @@ -10,7 +10,7 @@ @Repository public interface CampusRepository extends JpaRepository { - + Long countBySite(String site); List findByContext(Context context); @@ -18,4 +18,8 @@ public interface CampusRepository extends JpaRepository { //STATS @Query(value = "select key, count(*) as count from campus, context where campus.context_id=context.id group by key order by key, count desc", nativeQuery = true) List countCampusesByContext(); + + @Query(nativeQuery=true,value="SELECT key, COUNT(*) AS count FROM campus JOIN context ON context_id = context.id GROUP BY key ORDER BY key, count DESC") + List countByContext(); + } diff --git a/src/main/java/org/esupportail/emargement/repositories/EmargementRepositoryAspect.java b/src/main/java/org/esupportail/emargement/repositories/EmargementRepositoryAspect.java index 2f10567..f27e167 100644 --- a/src/main/java/org/esupportail/emargement/repositories/EmargementRepositoryAspect.java +++ b/src/main/java/org/esupportail/emargement/repositories/EmargementRepositoryAspect.java @@ -25,7 +25,7 @@ public class EmargementRepositoryAspect { // Attention, ne fonctionne pas sur les native query ... // De même cf doc hibernate "Filters apply to entity queries, but not to direct fetching." @Before( - value="(execution(public * org.springframework.data.jpa.repository.*.*(..)) || execution(public * org.esupportail.emargement.repositories.*.*(..)) || execution(public * org.esupportail.emargement.repositories.custom.*.*(..)))" + + value="(execution(public * org.esupportail.emargement.repositories.*.*(..)) || execution(public * org.esupportail.emargement.repositories.custom.*.*(..)))" + "&& !execution(public * org.esupportail.emargement.repositories.*.findByContextKey(..)) " + "&& !execution(public * org.esupportail.emargement.repositories.*.findByContextId(..)) " + "&& !execution(public * org.esupportail.emargement.repositories.*.findByContext(..)) " + @@ -53,7 +53,7 @@ public void enableFilterIfNeeded(JoinPoint joinPoint) throws Throwable { } @After( - value="(execution(public * org.springframework.data.jpa.repository.*.*(..)) || execution(public * org.esupportail.emargement.repositories.*.*(..)) || execution(public * org.esupportail.emargement.repositories.custom.*.*(..)))", + value="(execution(public * org.esupportail.emargement.repositories.*.*(..)) || execution(public * org.esupportail.emargement.repositories.custom.*.*(..)))", argNames="joinPoint") public void disableFilter(JoinPoint joinPoint) throws Throwable { em.unwrap(Session.class).disableFilter("contextFilter"); diff --git a/src/main/java/org/esupportail/emargement/repositories/EsupSignatureRepository.java b/src/main/java/org/esupportail/emargement/repositories/EsupSignatureRepository.java index d3d8636..8fa4819 100644 --- a/src/main/java/org/esupportail/emargement/repositories/EsupSignatureRepository.java +++ b/src/main/java/org/esupportail/emargement/repositories/EsupSignatureRepository.java @@ -2,7 +2,6 @@ import java.util.List; -import org.esupportail.emargement.domain.Context; import org.esupportail.emargement.domain.EsupSignature; import org.esupportail.emargement.domain.SessionEpreuve; import org.esupportail.emargement.domain.TagCheck; @@ -13,8 +12,6 @@ @Repository public interface EsupSignatureRepository extends JpaRepository{ - - List findByContext(Context context); List findBySignRequestId(Long signRequestId); diff --git a/src/main/java/org/esupportail/emargement/repositories/LocationRepository.java b/src/main/java/org/esupportail/emargement/repositories/LocationRepository.java index e6d7235..5bece7d 100644 --- a/src/main/java/org/esupportail/emargement/repositories/LocationRepository.java +++ b/src/main/java/org/esupportail/emargement/repositories/LocationRepository.java @@ -1,10 +1,12 @@ package org.esupportail.emargement.repositories; import java.util.List; +import java.util.Optional; import org.esupportail.emargement.domain.Campus; import org.esupportail.emargement.domain.Context; import org.esupportail.emargement.domain.Location; +import org.esupportail.emargement.domain.SessionEpreuve; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -14,19 +16,43 @@ @Repository public interface LocationRepository extends JpaRepository{ + public boolean existsById(short id); + public boolean existsByNom(String nom); + public boolean existsByCampus(Campus c); + Long countByNom(String nom); - + + public Optional findByNom(String nom); + Page findByNom(String nom, Pageable pageable); - List findLocationByCampus(Campus campus); + public List findByCampus(Campus c); + List findLocationByCampus(Campus campus); + List findByAdeClassRoomIdAndContext(Long id, Context context); - + List findLocationByContext(Context context); - + Long countByAdeClassRoomId(Long id); - + //STATS @Query(value = "select key, count(*) as count from location, context where location.context_id=context.id group by key order by key, count desc", nativeQuery = true) List countLocationsByContext(); + + @Query(nativeQuery=true,value="SELECT CASE WHEN COUNT(S.id) > 0 THEN true ELSE false END FROM session_epreuve S JOIN session_location L ON S.id = paper_id WHERE location_id = :id AND statut <> 'CLOSED'") + public boolean existsSessionByLocation_IdAndStatutNotClosed(Long id); + + @Query(nativeQuery=true,value="SELECT S.* FROM session_epreuve P JOIN session_location L ON P.id = paper_id WHERE location_id = :id AND statut <> 'CLOSED' ORDER BY nom") + public List findSessionByLocation_IdAndStatutNotClosed(Long id); + + @Query(nativeQuery=true,value="SELECT CASE WHEN COUNT(S.id) > 0 THEN true ELSE false END FROM session_epreuve S JOIN session_location L ON S.id = paper_id WHERE location_id = :id AND statut <> 'CLOSED' AND capacite > :capacity") + public boolean existsSessionByLocation_IdAndStatutNotClosedAndCapacityGreaterThan(Long id, int capacity); + + + @Query(nativeQuery = true, value = "SELECT * FROM location WHERE campus_id = :campus AND id NOT IN (SELECT L.id FROM location L JOIN session_location ON L.id = location_id JOIN session_epreuve P ON paper_id = P.id WHERE P.id = :paper)") + public List findByCampus_IdAndPaper_IdNot(Long campus, int paper); + + + } diff --git a/src/main/java/org/esupportail/emargement/repositories/SessionEpreuveRepository.java b/src/main/java/org/esupportail/emargement/repositories/SessionEpreuveRepository.java index 07c3f96..a4191f7 100644 --- a/src/main/java/org/esupportail/emargement/repositories/SessionEpreuveRepository.java +++ b/src/main/java/org/esupportail/emargement/repositories/SessionEpreuveRepository.java @@ -40,9 +40,7 @@ public interface SessionEpreuveRepository extends JpaRepository findAllByDateExamenGreaterThanEqualAndDateExamenLessThanEqual(Date startDate, Date endDate); - - List findAllByDateExamenLessThanEqualAndDateFinGreaterThanEqualOrDateExamenGreaterThanEqualAndDateExamenLessThanEqualOrDateFinGreaterThanEqualAndDateFinLessThanEqual(Date startDate1, Date endDate1, Date startDate, Date endDate, Date startDateFin, Date endDateFin); - + List findAllByDateExamenGreaterThanEqualAndDateExamenLessThanEqualOrDateFinGreaterThanEqualAndDateFinLessThanEqual(Date startDate, Date endDate, Date startDateFin, Date endDateFin); List findAllByDateExamen(Date date); @@ -74,8 +72,7 @@ public interface SessionEpreuveRepository extends JpaRepository= :startDate and date_examen <= :endDate) or " - + " (date_fin >= :startDate and date_fin <= :endDate) or " - + "(date_examen <= :startDate and date_fin >= :endDate)" , nativeQuery = true) + + " (date_fin >= :startDate and date_fin <= :endDate)", nativeQuery = true) List getAllSessionEpreuveForCalendar(Date startDate, Date endDate); @Query(value = "select session_epreuve.id from tag_check, person, session_epreuve " diff --git a/src/main/java/org/esupportail/emargement/repositories/SessionTypeRepository.java b/src/main/java/org/esupportail/emargement/repositories/SessionTypeRepository.java new file mode 100755 index 0000000..47ac4e1 --- /dev/null +++ b/src/main/java/org/esupportail/emargement/repositories/SessionTypeRepository.java @@ -0,0 +1,15 @@ +package org.esupportail.emargement.repositories; +import java.util.List; +import java.util.Optional; +import org.esupportail.emargement.domain.Context; +import org.esupportail.emargement.domain.SessionType; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +@Repository public interface SessionTypeRepository extends JpaRepository { + boolean existsByKey(String key); + boolean existsByKeyIgnoreCase(String key); + SessionType findByKey(String key); + Optional findByKeyIgnoreCase(String key); + List findByContext(Context context); + List findAllByOrderByTitle(); +} diff --git a/src/main/java/org/esupportail/emargement/repositories/TagCheckRepository.java b/src/main/java/org/esupportail/emargement/repositories/TagCheckRepository.java index b96fdca..bfc23b8 100644 --- a/src/main/java/org/esupportail/emargement/repositories/TagCheckRepository.java +++ b/src/main/java/org/esupportail/emargement/repositories/TagCheckRepository.java @@ -233,6 +233,11 @@ public interface TagCheckRepository extends JpaRepository{ List findBySessionEpreuveAndPersonEppnAndIsUnknownFalse(SessionEpreuve se, String Eppn); + // TODO : renommer + List findByIsTiersTempsFalseAndSessionEpreuve_IdAndSessionLocationExpectedIsNull(Long paper); + List findByIsTiersTempsFalseAndSessionEpreuve_IdAndSessionLocationExpectedIsNullOrderByPerson_Id(Long paper); + + //countSessionEpreuveIdExpected Long countByPersonEppnAndSessionEpreuveDateExamen(String eppn, Date date); diff --git a/src/main/java/org/esupportail/emargement/services/ApogeeService.java b/src/main/java/org/esupportail/emargement/services/ApogeeService.java index 56f3414..b461980 100644 --- a/src/main/java/org/esupportail/emargement/services/ApogeeService.java +++ b/src/main/java/org/esupportail/emargement/services/ApogeeService.java @@ -11,13 +11,12 @@ import org.esupportail.emargement.domain.ApogeeBean; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.beans.factory.annotation.Value; import org.springframework.dao.DataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; @Service -@ConditionalOnBean(name = "apogeeJdbcTemplate") public class ApogeeService { @Resource @@ -25,14 +24,49 @@ public class ApogeeService { private final Logger log = LoggerFactory.getLogger(getClass()); + @Value("${emargement.datasource.apogee.query.composantes}") + private String queryComposantes; + + @Value("${emargement.datasource.apogee.query.elementsPedagogiques}") + private String queryElementsPedagogiques; + + @Value("${emargement.datasource.apogee.query.matieres}") + private String queryMatieres; + + @Value("${emargement.datasource.apogee.query.countAutorisesEpreuve}") + private String queryCountAutorisesEpreuve; + + @Value("${emargement.datasource.apogee.query.autorisesEpreuve}") + private String queryAutorisesEpreuve; + + @Value("${emargement.datasource.apogee.query.groupes}") + private String queryGroupes; + + @Value("${emargement.datasource.apogee.query.countAutorisesEpreuveGroupe}") + private String queryCountAutorisesEpreuveGroupe; + + @Value("${emargement.datasource.apogee.query.autorisesEpreuveGroupe}") + private String queryAutorisesEpreuveGroupe; + + @Value("${emargement.datasource.apogee.query.autorisesEpreuveComposante}") + private String queryAutorisesEpreuveComposante; + + @Value("${emargement.datasource.apogee.query.countAutorisesEpreuveComposante}") + private String queryCountAutorisesEpreuveComposante; + + @Value("${emargement.datasource.apogee.query.autorisesEpreuveDiplome}") + private String queryAutorisesEpreuveDiplome; + + @Value("${emargement.datasource.apogee.query.countAutorisesEpreuveDiplome}") + private String queryCountAutorisesEpreuveDiplome; + //Réquete 0 : Récupération de la liste des composantes public List getComposantes(){ List> composantes = new ArrayList>(); List abComposantes = new ArrayList(); - String query = "SELECT COMPOSANTE.COD_CMP, COMPOSANTE.LIB_CMP FROM APOGEE.COMPOSANTE COMPOSANTE " - + "WHERE (COMPOSANTE.TEM_EN_SVE_CMP='O') ORDER BY COMPOSANTE.LIB_CMP"; - + String query = queryComposantes; + try { composantes = apogeeJdbcTemplate.queryForList(query); for(Map so : composantes) { @@ -53,21 +87,15 @@ public List getComposantes(){ public List getElementsPedagogiques(ApogeeBean apogeeBean){ List> inscrits = new ArrayList>(); List elementsPedagogiques = new ArrayList(); - String query = "SELECT DISTINCT (IAE.COD_ETP||'-'||IAE.COD_VRS_VET) as code, vet.lib_web_vet as lib " + - "FROM ETAPE ETP , INS_ADM_ETP IAE INNER JOIN VERSION_ETAPE VET " + - "ON (IAE.COD_ETP = VET.COD_ETP AND IAE.COD_VRS_VET = VET.COD_VRS_VET) " + - "WHERE IAE.COD_ETP = ETP.COD_ETP " + - "AND IAE.COD_ANU= ? " + - "AND IAE.COD_CMP= ? " + - "AND etp.cod_cur IN ('L','M') " + - "ORDER BY lib"; + + String query = queryElementsPedagogiques; try { inscrits = apogeeJdbcTemplate.queryForList(query, new Object[] {apogeeBean.getCodAnu(), apogeeBean.getCodCmp()}); for(Map so : inscrits) { ApogeeBean ab = new ApogeeBean(); - ab.setCodEtp((so.get("code")!=null)? so.get("code").toString(): ""); - ab.setLibEtp((so.get("lib")!=null)? so.get("lib").toString(): ""); + ab.setCodEtp((so.get("COD_ETP")!=null)? so.get("COD_ETP").toString(): ""); + ab.setLibEtp((so.get("LIB_ETP")!=null)? so.get("LIB_ETP").toString(): ""); elementsPedagogiques.add(ab); } @@ -84,19 +112,11 @@ public List getMatieres(ApogeeBean apogeeBean){ List> matieres = new ArrayList>(); List elementsPedagogiques = new ArrayList(); - String query = "SELECT DISTINCT ELEMENT_PEDAGOGI.COD_ELP, ELEMENT_PEDAGOGI.LIB_ELP " + - "FROM APOGEE.ELEMENT_PEDAGOGI ELEMENT_PEDAGOGI, APOGEE.IND_CONTRAT_ELP IND_CONTRAT_ELP " + - "WHERE IND_CONTRAT_ELP.COD_ELP = ELEMENT_PEDAGOGI.COD_ELP AND ((ELEMENT_PEDAGOGI.COD_NEL LIKE 'M%' ) " + - "AND (IND_CONTRAT_ELP.COD_ANU= ? ) AND (IND_CONTRAT_ELP.COD_ETP= ? ) " + - "OR (ELEMENT_PEDAGOGI.COD_NEL='CM') AND (IND_CONTRAT_ELP.COD_ANU= ? ) AND (IND_CONTRAT_ELP.COD_ETP= ? ) " + - "OR (ELEMENT_PEDAGOGI.COD_NEL='TD') AND (IND_CONTRAT_ELP.COD_ANU= ? ) AND (IND_CONTRAT_ELP.COD_ETP= ? ))" + - "ORDER BY ELEMENT_PEDAGOGI.LIB_ELP"; + String query = queryMatieres; try { - - String [] splitCodetEtp = apogeeBean.getCodEtp().split("-"); - matieres = apogeeJdbcTemplate.queryForList(query, new Object[] {apogeeBean.getCodAnu(), splitCodetEtp[0], apogeeBean.getCodAnu(), - splitCodetEtp[0], apogeeBean.getCodAnu(), splitCodetEtp[0]}); + matieres = apogeeJdbcTemplate.queryForList(query, new Object[] {apogeeBean.getCodAnu(), apogeeBean.getCodEtp(), apogeeBean.getCodAnu(), + apogeeBean.getCodEtp(), apogeeBean.getCodAnu(), apogeeBean.getCodEtp()}); for(Map so : matieres) { ApogeeBean ab = new ApogeeBean(); ab.setCodElp((so.get("COD_ELP")!=null)? so.get("COD_ELP").toString(): ""); @@ -114,14 +134,7 @@ public List getMatieres(ApogeeBean apogeeBean){ //Requete 3 : Comptage du nombre d’étudiants public int countAutorisesEpreuve(ApogeeBean apogeeBean) { int count = 0; - String query = "SELECT Count(RESULTAT_ELP.COD_IND) " + - "FROM RESULTAT_ELP " + - "WHERE RESULTAT_ELP.COD_ADM='1' " + - "AND RESULTAT_ELP.COD_ELP= ? " + - "AND RESULTAT_ELP.COD_SES= ? " + - "AND RESULTAT_ELP.TEM_IND_CRN_ELP='CS' " + - "AND RESULTAT_ELP.TEM_NOT_RPT_ELP='N' " + - "AND RESULTAT_ELP.COD_ANU = ?"; + String query = queryCountAutorisesEpreuve; try { count =apogeeJdbcTemplate.queryForObject( @@ -139,16 +152,7 @@ public List getAutorisesEpreuve(ApogeeBean apogeeBean){ List> results = new ArrayList>(); List autorisesEpreuve = new ArrayList(); - String query = "SELECT INDIVIDU.COD_ETU, INDIVIDU.LIB_NOM_PAT_IND, INDIVIDU.LIB_PR1_IND, INDIVIDU.DATE_NAI_IND " + - "FROM INDIVIDU, RESULTAT_ELP " + - "WHERE RESULTAT_ELP.COD_IND = INDIVIDU.COD_IND " + - "AND RESULTAT_ELP.COD_ADM='1' " + - "AND RESULTAT_ELP.COD_ELP= ? " + - "AND RESULTAT_ELP.COD_SES= ? " + - "AND RESULTAT_ELP.TEM_IND_CRN_ELP='CS' " + - "AND RESULTAT_ELP.TEM_NOT_RPT_ELP='N' " + - "AND RESULTAT_ELP.COD_ANU = ? " + - "ORDER BY INDIVIDU.LIB_NOM_PAT_IND"; + String query = queryAutorisesEpreuve; try { results = apogeeJdbcTemplate.queryForList(query, new Object[] {apogeeBean.getCodElp(), apogeeBean.getCodSes(), apogeeBean.getCodAnu()}); @@ -177,17 +181,16 @@ public List getAutorisesEpreuve(ApogeeBean apogeeBean){ public List getGroupes(ApogeeBean apogeeBean){ List> results = new ArrayList>(); List groupesTD = new ArrayList(); - String query = "SELECT DISTINCT GROUPE.COD_GPE, GROUPE.LIB_GPE FROM APOGEE.GPE_OBJ, APOGEE.GROUPE, " + - "APOGEE.IND_AFFECTE_GPE WHERE GPE_OBJ.COD_GPE = GROUPE.COD_GPE AND IND_AFFECTE_GPE.COD_GPE = GROUPE.COD_GPE " + - "AND IND_AFFECTE_GPE.COD_ANU= ? AND GPE_OBJ.COD_ELP= ? ORDER BY GROUPE.COD_GPE"; + String query = queryGroupes; try { results = apogeeJdbcTemplate.queryForList(query, new Object[] {apogeeBean.getCodAnu(), apogeeBean.getCodElp()}); for(Map so : results) { ApogeeBean ab = new ApogeeBean(); ab.setCodAnu(apogeeBean.getCodAnu()); + ab.setCodEtp(apogeeBean.getCodEtp()); ab.setCodElp(apogeeBean.getCodElp()); - ab.setCodExtGpe((so.get("COD_GPE")!=null)? so.get("COD_GPE").toString(): ""); + ab.setCodExtGpe((so.get("COD_EXT_GPE")!=null)? so.get("COD_EXT_GPE").toString(): ""); ab.setLibGpe((so.get("LIB_GPE")!=null)? so.get("LIB_GPE").toString(): ""); groupesTD.add(ab); } @@ -201,11 +204,7 @@ public List getGroupes(ApogeeBean apogeeBean){ //Requete 6 nb d'étudiant dans le groupe public int countAutorisesEpreuveGroupe(ApogeeBean apogeeBean) { int count = 0; - String query = "SELECT Count(*) " - + "FROM APOGEE.GPE_OBJ GPE_OBJ, APOGEE.GROUPE GROUPE, APOGEE.IND_AFFECTE_GPE IND_AFFECTE_GPE, " - + "APOGEE.INDIVIDU INDIVIDU WHERE INDIVIDU.COD_IND = IND_AFFECTE_GPE.COD_IND AND " - + "GPE_OBJ.COD_GPE = IND_AFFECTE_GPE.COD_GPE AND GROUPE.COD_GPE = GPE_OBJ.COD_GPE " - + "AND IND_AFFECTE_GPE.COD_ANU = ? AND GROUPE.COD_GPE = ? "; + String query = queryCountAutorisesEpreuveGroupe; try { count =apogeeJdbcTemplate.queryForObject( @@ -215,6 +214,7 @@ public int countAutorisesEpreuveGroupe(ApogeeBean apogeeBean) { } return count; + } //Requete 7 : Récupération de la liste étudiants d'un groupe @@ -222,12 +222,7 @@ public List getAutorisesEpreuveGroupe(ApogeeBean apogeeBean){ List> results = new ArrayList>(); List autorisesEpreuve = new ArrayList(); - String query = "SELECT INDIVIDU.COD_ETU, INDIVIDU.LIB_NOM_PAT_IND, INDIVIDU.LIB_PR1_IND, INDIVIDU.DATE_NAI_IND " - + "FROM APOGEE.GPE_OBJ GPE_OBJ, APOGEE.GROUPE GROUPE, APOGEE.IND_AFFECTE_GPE IND_AFFECTE_GPE, " - + "APOGEE.INDIVIDU INDIVIDU WHERE INDIVIDU.COD_IND = IND_AFFECTE_GPE.COD_IND AND " - + "GPE_OBJ.COD_GPE = IND_AFFECTE_GPE.COD_GPE AND GROUPE.COD_GPE = GPE_OBJ.COD_GPE " - + "AND IND_AFFECTE_GPE.COD_ANU = ? AND GROUPE.COD_GPE = ? AND GPE_OBJ.COD_ELP = ?" - + "ORDER BY INDIVIDU.LIB_NOM_PAT_IND"; + String query = queryAutorisesEpreuveGroupe; try { results = apogeeJdbcTemplate.queryForList(query, new Object[] {apogeeBean.getCodAnu(), apogeeBean.getCodExtGpe(),apogeeBean.getCodElp()}); @@ -252,156 +247,120 @@ public List getAutorisesEpreuveGroupe(ApogeeBean apogeeBean){ return autorisesEpreuve; } - - //Requete 8 : Récupération des étudiants d'une composante - public List getAutorisesEpreuveComposante(ApogeeBean apogeeBean){ - List> results = new ArrayList>(); - List autorisesEpreuve = new ArrayList(); - - String query = "SELECT DISTINCT INDIVIDU.COD_ETU, INDIVIDU.LIB_NOM_PAT_IND, INDIVIDU.LIB_PR1_IND, INDIVIDU.DATE_NAI_IND " + - "FROM INDIVIDU INNER JOIN INS_ADM_ETP IAE ON (INDIVIDU.COD_IND = IAE.COD_IND) " + - "WHERE IAE.COD_ANU = ? " + - "AND IAE.COD_CMP = ? " + - "AND IAE.ETA_IAE = 'E' " + - "AND IAE.ETA_PMT_IAE in ('P','A') " + - "ORDER BY 2"; - - try { - results = apogeeJdbcTemplate.queryForList(query, new Object[] {apogeeBean.getCodAnu(), apogeeBean.getCodCmp()}); - for(Map so : results) { - ApogeeBean ab = new ApogeeBean(); - ab.setCodExtGpe(apogeeBean.getCodExtGpe()); - ab.setCodAnu(apogeeBean.getCodAnu()); - ab.setCodSes(apogeeBean.getCodSes()); - ab.setCodCmp(apogeeBean.getCodCmp()); - ab.setCodEtu((so.get("COD_ETU")!=null)? so.get("COD_ETU").toString(): ""); - ab.setLibNomPatInd((so.get("LIB_NOM_PAT_IND")!=null)? so.get("LIB_NOM_PAT_IND").toString(): ""); - ab.setLibPr1Ind((so.get("LIB_PR1_IND")!=null)? so.get("LIB_PR1_IND").toString(): ""); - ab.setDateNaiInd((so.get("DATE_NAI_IND")!=null)? so.get("DATE_NAI_IND").toString(): ""); - autorisesEpreuve.add(ab); - } - - } catch (Exception e) { - log.error("Erreur lors de la récupération de la liste étudiants d'une composante", e); - } - - return autorisesEpreuve; - } - - //Requete 9 nb d'étudiant dans une composante - public int countAutorisesEpreuveComposante(ApogeeBean apogeeBean) { - int count = 0; - String query = "SELECT Count(DISTINCT INDIVIDU.COD_ETU) " + - "FROM INDIVIDU INNER JOIN INS_ADM_ETP IAE ON (INDIVIDU.COD_IND = IAE.COD_IND) " + - "WHERE IAE.COD_ANU = ? " + - "AND IAE.COD_CMP = ? " + - "AND IAE.ETA_IAE = 'E' " + - "AND IAE.ETA_PMT_IAE in ('P','A') "; - try { - count =apogeeJdbcTemplate.queryForObject( - query, Integer.class, apogeeBean.getCodAnu(), apogeeBean.getCodCmp()); - } catch (DataAccessException e) { - log.error("Erreur lors du comptage du nombre d'étudiants d'une composante", e); - } - - return count; - } - - //Requete 10 : Récupération de la liste étudiants d'une étape(diplome) - public List getAutorisesEpreuveDiplome(ApogeeBean apogeeBean){ - List> results = new ArrayList>(); - List autorisesEpreuve = new ArrayList(); - - String query = "SELECT DISTINCT INDIVIDU.COD_ETU, INDIVIDU.LIB_NOM_PAT_IND, INDIVIDU.LIB_PR1_IND, INDIVIDU.DATE_NAI_IND " + - "FROM INDIVIDU, RESULTAT_VET " + - "WHERE RESULTAT_VET.COD_IND = INDIVIDU.COD_IND " + - "AND RESULTAT_VET.COD_ADM='1' " + - "AND RESULTAT_VET.COD_ETP = ? " + - "AND RESULTAT_VET.COD_VRS_VET = ? " + - "AND RESULTAT_VET.COD_SES= ? " + - "AND RESULTAT_VET.TEM_IND_CRN_VET='CS' " + - "AND RESULTAT_VET.TEM_TRT_RPT_VET='N' " + - "AND RESULTAT_VET.COD_ANU = ? " + - "ORDER BY INDIVIDU.LIB_NOM_PAT_IND"; - - try { - String [] splitCodetEtp = apogeeBean.getCodEtp().split("-"); - results = apogeeJdbcTemplate.queryForList(query, new Object[] {splitCodetEtp[0], splitCodetEtp[1], apogeeBean.getCodSes(), apogeeBean.getCodAnu()}); - for(Map so : results) { - ApogeeBean ab = new ApogeeBean(); - ab.setCodExtGpe(apogeeBean.getCodExtGpe()); - ab.setCodAnu(apogeeBean.getCodAnu()); - ab.setCodEtp(splitCodetEtp[0]); - ab.setCodElp(apogeeBean.getCodElp()); - ab.setLibElp(apogeeBean.getLibElp()); - ab.setCodSes(apogeeBean.getCodSes()); - ab.setCodEtu((so.get("COD_ETU")!=null)? so.get("COD_ETU").toString(): ""); - ab.setLibNomPatInd((so.get("LIB_NOM_PAT_IND")!=null)? so.get("LIB_NOM_PAT_IND").toString(): ""); - ab.setLibPr1Ind((so.get("LIB_PR1_IND")!=null)? so.get("LIB_PR1_IND").toString(): ""); - ab.setDateNaiInd((so.get("DATE_NAI_IND")!=null)? so.get("DATE_NAI_IND").toString(): ""); - autorisesEpreuve.add(ab); - } - - } catch (Exception e) { - log.error("Erreur lors de la récupération de la liste étudiants d'un groupe", e); - } - - return autorisesEpreuve; - } - - - //Requete 11 nb d'étudiant dans une étape - public int countAutorisesEpreuveDiplome(ApogeeBean apogeeBean) { - int count = 0; - String query = "SELECT count(*) " + - "FROM INDIVIDU, RESULTAT_VET " + - "WHERE RESULTAT_VET.COD_IND = INDIVIDU.COD_IND " + - "AND RESULTAT_VET.COD_ADM='1' " + - "AND RESULTAT_VET.COD_ETP = ? " + - "AND RESULTAT_VET.COD_VRS_VET = ? " + - "AND RESULTAT_VET.COD_SES= ? " + - "AND RESULTAT_VET.TEM_IND_CRN_VET='CS' " + - "AND RESULTAT_VET.TEM_TRT_RPT_VET='N' " + - "AND RESULTAT_VET.COD_ANU = ? "; - try { - String codEtp = ""; - String codVet = ""; - if(!apogeeBean.getCodEtp().isEmpty()) { - String [] splitCodetEtp = apogeeBean.getCodEtp().split("-"); - codEtp = splitCodetEtp[0]; - codVet = splitCodetEtp[1]; - } - count =apogeeJdbcTemplate.queryForObject( - query, Integer.class, codEtp, codVet, apogeeBean.getCodSes(), apogeeBean.getCodAnu()); - } catch (DataAccessException e) { - log.error("Erreur lors du comptage du nombre d'étudiants d'une étape", e); - } - - return count; - } + //Requete 8 : Récupération des étudiants d'une composante + public List getAutorisesEpreuveComposante(ApogeeBean apogeeBean){ + List> results = new ArrayList>(); + List autorisesEpreuve = new ArrayList(); + + String query = queryAutorisesEpreuveComposante; + + try { + results = apogeeJdbcTemplate.queryForList(query, new Object[] {apogeeBean.getCodAnu(), apogeeBean.getCodCmp()}); + for(Map so : results) { + ApogeeBean ab = new ApogeeBean(); + ab.setCodExtGpe(apogeeBean.getCodExtGpe()); + ab.setCodAnu(apogeeBean.getCodAnu()); + ab.setCodSes(apogeeBean.getCodSes()); + ab.setCodCmp(apogeeBean.getCodCmp()); + ab.setCodEtu((so.get("COD_ETU")!=null)? so.get("COD_ETU").toString(): ""); + ab.setLibNomPatInd((so.get("LIB_NOM_PAT_IND")!=null)? so.get("LIB_NOM_PAT_IND").toString(): ""); + ab.setLibPr1Ind((so.get("LIB_PR1_IND")!=null)? so.get("LIB_PR1_IND").toString(): ""); + ab.setDateNaiInd((so.get("DATE_NAI_IND")!=null)? so.get("DATE_NAI_IND").toString(): ""); + autorisesEpreuve.add(ab); + } + + } catch (Exception e) { + log.error("Erreur lors de la récupération de la liste étudiants d'une composante", e); + } + + return autorisesEpreuve; + } + + //Requete 9 nb d'étudiant dans une composante + public int countAutorisesEpreuveComposante(ApogeeBean apogeeBean) { + int count = 0; + String query = queryCountAutorisesEpreuveComposante; + + try { + count =apogeeJdbcTemplate.queryForObject( + query, Integer.class, apogeeBean.getCodAnu(), apogeeBean.getCodCmp()); + } catch (DataAccessException e) { + log.error("Erreur lors du comptage du nombre d'étudiants d'une composante", e); + } + + return count; + } + + + //Requete 10 : Récupération de la liste étudiants d'une étape(diplome) + public List getAutorisesEpreuveDiplome(ApogeeBean apogeeBean){ + List> results = new ArrayList>(); + List autorisesEpreuve = new ArrayList(); + + String query = queryAutorisesEpreuveDiplome; + + try { + String [] splitCodetEtp = apogeeBean.getCodEtp().split("-"); + results = apogeeJdbcTemplate.queryForList(query, new Object[] {splitCodetEtp[0], splitCodetEtp[1], apogeeBean.getCodSes(), apogeeBean.getCodAnu()}); + for(Map so : results) { + ApogeeBean ab = new ApogeeBean(); + ab.setCodExtGpe(apogeeBean.getCodExtGpe()); + ab.setCodAnu(apogeeBean.getCodAnu()); + ab.setCodEtp(splitCodetEtp[0]); + ab.setCodElp(apogeeBean.getCodElp()); + ab.setLibElp(apogeeBean.getLibElp()); + ab.setCodSes(apogeeBean.getCodSes()); + ab.setCodEtu((so.get("COD_ETU")!=null)? so.get("COD_ETU").toString(): ""); + ab.setLibNomPatInd((so.get("LIB_NOM_PAT_IND")!=null)? so.get("LIB_NOM_PAT_IND").toString(): ""); + ab.setLibPr1Ind((so.get("LIB_PR1_IND")!=null)? so.get("LIB_PR1_IND").toString(): ""); + ab.setDateNaiInd((so.get("DATE_NAI_IND")!=null)? so.get("DATE_NAI_IND").toString(): ""); + autorisesEpreuve.add(ab); + } + + } catch (Exception e) { + log.error("Erreur lors de la récupération de la liste étudiants d'un groupe", e); + } + + return autorisesEpreuve; + } + + + + //Requete 11 nb d'étudiant dans une étape + public int countAutorisesEpreuveDiplome(ApogeeBean apogeeBean) { + int count = 0; + String query = queryCountAutorisesEpreuveDiplome; + try { + System.out.println("----------------------> codEtp : " + apogeeBean.getCodEtp() ); + + String codEtp = ""; + String codVet = ""; + if(!apogeeBean.getCodEtp().isEmpty()) { + String [] splitCodetEtp = apogeeBean.getCodEtp().split("-"); + codEtp = splitCodetEtp[0]; + codVet = splitCodetEtp[1]; + } + System.out.println("----------------------> codEtp : " + codEtp ); + count =apogeeJdbcTemplate.queryForObject( + query, Integer.class, codEtp, codVet, apogeeBean.getCodSes(), apogeeBean.getCodAnu()); + } catch (DataAccessException e) { + log.error("Erreur lors du comptage du nombre d'étudiants d'une étape", e); + } + + return count; + } + public List getListeFutursInscrits(ApogeeBean apogeeBean) { List futursInscrits = new ArrayList(); List autorisesEpreuve = new ArrayList(); int countAutorisesEpreuve = 0; - if(apogeeBean.getCodEtp()==null || apogeeBean.getCodEtp().isEmpty()) { - if(apogeeBean.getCodCmp()!=null || !apogeeBean.getCodCmp().isEmpty()) { - autorisesEpreuve = this.getAutorisesEpreuveComposante(apogeeBean); - countAutorisesEpreuve = this.countAutorisesEpreuveComposante(apogeeBean); - } - }else if(apogeeBean.getCodElp()==null || apogeeBean.getCodElp().isEmpty()) { - if(apogeeBean.getCodEtp()!=null || !apogeeBean.getCodEtp().isEmpty()) { - autorisesEpreuve = this.getAutorisesEpreuveDiplome(apogeeBean); - countAutorisesEpreuve = this.countAutorisesEpreuveDiplome(apogeeBean); - } - }else if(apogeeBean.getCodExtGpe()==null || apogeeBean.getCodExtGpe().isEmpty()) { - if(apogeeBean.getCodElp()!=null || !apogeeBean.getCodElp().isEmpty()) { - autorisesEpreuve = this.getAutorisesEpreuve(apogeeBean); - countAutorisesEpreuve = this.countAutorisesEpreuve(apogeeBean); - } - }else if(apogeeBean.getCodExtGpe() !=null || !apogeeBean.getCodExtGpe().isEmpty()) { + if(apogeeBean.getCodExtGpe()==null ||apogeeBean.getCodExtGpe().isEmpty()) { + autorisesEpreuve = this.getAutorisesEpreuve(apogeeBean); + countAutorisesEpreuve = this.countAutorisesEpreuve(apogeeBean); + }else { autorisesEpreuve = this.getAutorisesEpreuveGroupe(apogeeBean); countAutorisesEpreuve = this.countAutorisesEpreuveGroupe(apogeeBean); } @@ -420,8 +379,22 @@ public List getListeFutursInscrits(ApogeeBean apogeeBean) { return futursInscrits; } + public List> getListeFutursInscritsDirectImport(List futursInscrits){ + + List> finalList = new ArrayList>(); + for(ApogeeBean ab : futursInscrits ) { + List strings = new ArrayList(); + strings.add(ab.getCodEtu()); + finalList.add(strings); + } + + return finalList; + } +/* + public List> getListeFutursInscritsDirectImport(ApogeeBean apogeeBean){ + List futursInscrits = getListeFutursInscrits(apogeeBean); List> finalList = new ArrayList>(); for(ApogeeBean ab : futursInscrits ) { List strings = new ArrayList(); @@ -431,52 +404,53 @@ public List> getListeFutursInscritsDirectImport(List f return finalList; } - +*/ public int countAutorises(String param, ApogeeBean apogeeBean) { - int count = 0; - switch(param){ - case "composante": - count= countAutorisesEpreuveComposante(apogeeBean); - break; - case "diplome": - count = countAutorisesEpreuveDiplome(apogeeBean); - break; - case "matiere": - count = countAutorisesEpreuve(apogeeBean); - break; - case "groupe": - count =countAutorisesEpreuveGroupe(apogeeBean); - break; - } - - return count; + int count = 0; + switch(param){ + case "composante": + count= countAutorisesEpreuveComposante(apogeeBean); + break; + case "diplome": + count = countAutorisesEpreuveDiplome(apogeeBean); + break; + case "matiere": + count = countAutorisesEpreuve(apogeeBean); + break; + case "groupe": + count =countAutorisesEpreuveGroupe(apogeeBean); + break; + } + + return count; } - + public List searchList(String param, ApogeeBean apogeeBean) { - List list= new ArrayList(); - switch(param){ - case "diplome": - list = getElementsPedagogiques(apogeeBean); - break; - case "matiere": - list = getMatieres(apogeeBean); - break; - case "groupe": - list = getGroupes(apogeeBean); - break; - } - - return list; + List list= new ArrayList(); + switch(param){ + case "diplome": + list = getElementsPedagogiques(apogeeBean); + break; + case "matiere": + list = getMatieres(apogeeBean); + break; + case "groupe": + list = getGroupes(apogeeBean); + break; + } + + return list; } - + public Map getMapEtapes(ApogeeBean apogeebean, List futursInscrits){ - Map mapEtapes = new HashMap(); - List list = getElementsPedagogiques(apogeebean); - Map mapEtp = list.stream().collect( - Collectors.toMap(ApogeeBean::getCodEtp, ApogeeBean::getLibEtp)); - for(ApogeeBean apogeeBean : futursInscrits) { - mapEtapes.put(apogeeBean.getCodEtu(), apogeeBean.getCodEtp() + " - " + mapEtp.get(apogeeBean.getCodEtp())); - } - return mapEtapes; + Map mapEtapes = new HashMap(); + List list = getElementsPedagogiques(apogeebean); + Map mapEtp = list.stream().collect( + Collectors.toMap(ApogeeBean::getCodEtp, ApogeeBean::getLibEtp)); + for(ApogeeBean apogeeBean : futursInscrits) { + mapEtapes.put(apogeeBean.getCodEtu(), apogeeBean.getCodEtp() + " - " + mapEtp.get(apogeeBean.getCodEtp())); + } + return mapEtapes; } + } diff --git a/src/main/java/org/esupportail/emargement/services/CalendarService.java b/src/main/java/org/esupportail/emargement/services/CalendarService.java index 063aa5f..ca761d7 100644 --- a/src/main/java/org/esupportail/emargement/services/CalendarService.java +++ b/src/main/java/org/esupportail/emargement/services/CalendarService.java @@ -54,7 +54,7 @@ public String getEvents(String context, String start, String end, boolean isAll) if(isAll) { listSe = sessionEpreuveRepository.getAllSessionEpreuveForCalendar(startDate, endDate); }else { - listSe = sessionEpreuveRepository.findAllByDateExamenLessThanEqualAndDateFinGreaterThanEqualOrDateExamenGreaterThanEqualAndDateExamenLessThanEqualOrDateFinGreaterThanEqualAndDateFinLessThanEqual(startDate, endDate, startDate, endDate, startDate, endDate); + listSe = sessionEpreuveRepository.findAllByDateExamenGreaterThanEqualAndDateExamenLessThanEqualOrDateFinGreaterThanEqualAndDateFinLessThanEqual(startDate, endDate, startDate, endDate); } if(!listSe.isEmpty()) { for(SessionEpreuve se : listSe) { diff --git a/src/main/java/org/esupportail/emargement/services/CampusService.java b/src/main/java/org/esupportail/emargement/services/CampusService.java new file mode 100755 index 0000000..dc31b34 --- /dev/null +++ b/src/main/java/org/esupportail/emargement/services/CampusService.java @@ -0,0 +1,48 @@ +package org.esupportail.emargement.services; + +import java.util.ArrayList; +import java.util.List; +import org.esupportail.emargement.domain.Campus; +import org.esupportail.emargement.domain.Location; +import org.esupportail.emargement.repositories.CampusRepository; +import org.esupportail.emargement.repositories.LocationRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +@Service +public class CampusService { + + private final CampusRepository repository; + private final LocationRepository locationRepository; + @Autowired public CampusService(CampusRepository r, LocationRepository lR) { + repository = r; + locationRepository = lR; + } + public boolean existsById(Long id) { + boolean result; + try { result = repository.existsById(id); } + catch(Throwable t) { result = false; } + return result; + } + public Campus findById(Long id) { + Campus c; + try { c = repository.findById(id).orElse(null); } + catch(Throwable e) { c = null; } + return c; + } + public List findAll() { + List campuses; + try { campuses = repository.findAll(); } + catch(Throwable e) { campuses = new ArrayList(); } + return campuses; + } + public List findLocations(Campus c) { return locationRepository.findByCampus(c); } + public Page findAll(Pageable p) { + Page page; + try { page = repository.findAll(p); } + catch(Throwable e) { page = Page.empty(p); } + return page; + } +} diff --git a/src/main/java/org/esupportail/emargement/services/ContextService.java b/src/main/java/org/esupportail/emargement/services/ContextService.java index 2a4040b..38d8a21 100644 --- a/src/main/java/org/esupportail/emargement/services/ContextService.java +++ b/src/main/java/org/esupportail/emargement/services/ContextService.java @@ -8,7 +8,6 @@ import org.esupportail.emargement.domain.BigFile; import org.esupportail.emargement.domain.Campus; import org.esupportail.emargement.domain.Context; -import org.esupportail.emargement.domain.EsupSignature; import org.esupportail.emargement.domain.Event; import org.esupportail.emargement.domain.Groupe; import org.esupportail.emargement.domain.Guest; @@ -27,7 +26,6 @@ import org.esupportail.emargement.repositories.BigFileRepository; import org.esupportail.emargement.repositories.CampusRepository; import org.esupportail.emargement.repositories.ContextRepository; -import org.esupportail.emargement.repositories.EsupSignatureRepository; import org.esupportail.emargement.repositories.EventRepository; import org.esupportail.emargement.repositories.GroupeRepository; import org.esupportail.emargement.repositories.GuestRepository; @@ -112,9 +110,6 @@ public class ContextService { @Autowired TypeSessionRepository typeSessionRepository; - @Autowired - EsupSignatureRepository esupSignatureRepository; - public String getDefaultContext() { String defaultContext = null; Authentication auth = SecurityContextHolder.getContext() @@ -189,8 +184,6 @@ public void deleteContext(Context context) throws Exception { eventRepository.deleteAll(events); List typeSessions = typeSessionRepository.findByContext(context); typeSessionRepository.deleteAll(typeSessions); - List signs = esupSignatureRepository.findByContext(context); - esupSignatureRepository.deleteAll(signs); contextRepository.delete(context); } diff --git a/src/main/java/org/esupportail/emargement/services/LocationService.java b/src/main/java/org/esupportail/emargement/services/LocationService.java index e9e5010..2c83ca5 100644 --- a/src/main/java/org/esupportail/emargement/services/LocationService.java +++ b/src/main/java/org/esupportail/emargement/services/LocationService.java @@ -1,31 +1,150 @@ package org.esupportail.emargement.services; +import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; -import javax.annotation.Resource; - +import org.esupportail.emargement.config.PlanConfig; +import org.esupportail.emargement.domain.Location; +import org.esupportail.emargement.domain.Plan; +import org.esupportail.emargement.domain.SessionEpreuve; import org.esupportail.emargement.repositories.LocationRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.fasterxml.jackson.core.exc.StreamReadException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DatabindException; +import com.fasterxml.jackson.databind.ObjectMapper; import net.fortuna.ical4j.data.ParserException; -@Service +@Service public class LocationService { - + + private static final Logger log = LoggerFactory.getLogger(LocationService.class); + private static final ObjectMapper mapper = new ObjectMapper(); + private final File file; + private final Map plans; + private final LocationRepository repository; + private final EventService eventService; + @Autowired LocationRepository locationRepository; - - @Resource - EventService eventService; - - public List getSuggestedLocation() throws IOException, ParserException { + + @Autowired + public LocationService(PlanConfig conf, LocationRepository r, EventService eS) throws StreamReadException, DatabindException, IOException { + Path path; + File file; + Map plans; + path = Paths.get(conf.getPath()).toAbsolutePath().normalize(); + file = path.toFile(); + if(file.exists()) plans = mapper.readValue(file, new TypeReference>(){}); // + else { + Files.write(Files.createFile(path), "{}".getBytes()); + plans = new HashMap<>(); + } + this.file = file; + this.plans = plans; + repository = r; + eventService = eS; + } + + public boolean existsById(Long id) { + boolean existing; + try { existing = repository.existsById(id); } + catch(Throwable e) { existing = false; } + return existing; + } + public boolean existsPlan(Long id) { return plans.containsKey(id); } + + @Transactional(rollbackFor = Exception.class) + public byte save(Location loc) throws Exception { + byte result; + Long id = loc.getId(); + System.out.println("id ==================== " + id); + if(id == null || !repository.existsSessionByLocation_IdAndStatutNotClosedAndCapacityGreaterThan(id, loc.getCapacite())) { + String nom = loc.getNom(); + if(!repository.existsByNom(nom) || repository.findByNom(nom).get().getId().equals(id)) { + repository.save(loc); + if(loc.hasPlan()) { + plans.put(loc.getId(), loc.getPlan()); + mapper.writeValue(file, plans); + } + else if(plans.remove(loc.getId()) != null) mapper.writeValue(file, plans);; + result = 0; + } + else result = 1; + } + else result = 2; + return result; + } + @Transactional(rollbackFor = { Throwable.class }) + public byte delete(Long id) throws Throwable { + byte result; + if(!repository.existsSessionByLocation_IdAndStatutNotClosed(id)) { + if(plans.remove(id) != null) mapper.writeValue(file, plans); + repository.deleteById(id); + result = 0; + } + else result = 1; + return result; + } + public Long count() { return (Long)repository.count(); } + public Location findById(boolean shouldFindPlan, Long id) { + Location loc; + try { + loc = repository.findById(id).orElse(null); + if(shouldFindPlan && loc != null && plans.containsKey(id)) loc.setPlan(plans.get(id)); + } + catch(Throwable e) { loc = null; } + return loc; + } + public Location findByNom(String nom) { return repository.findByNom(nom).orElse(null); } + public Plan findPlan(Long id) { return plans.get(id); } + + public List getSuggestedLocation() throws IOException, ParserException { + List locationsFromIcs = eventService.getLocationsFromICs(eventService.getAllUrlList()); List locations = locationRepository.findAll().stream().map(l -> l.getNom().trim()).collect(Collectors.toList()); locationsFromIcs.removeAll(locations); return locationsFromIcs; } + + + public List findSessions(Long id) { return repository.findSessionByLocation_IdAndStatutNotClosed(id); } + public Page findByNomStartsWith(String nom, Pageable p) { + Page page; + try { + page = repository.findByNom(nom, p); + page.forEach(location -> location.setPlan(findPlan(location.getId()))); + } + catch(Throwable e) { page = Page.empty(p); } + return page; + } + public Page findAll(Pageable p) { + Page page; + try { + page = repository.findAll(p); + page.forEach(location -> location.setPlan(findPlan(location.getId()))); + } + catch(Throwable e) { page = Page.empty(); } + return page; + } + + + } diff --git a/src/main/java/org/esupportail/emargement/services/PresenceService.java b/src/main/java/org/esupportail/emargement/services/PresenceService.java index b33ddd3..f54e0f8 100644 --- a/src/main/java/org/esupportail/emargement/services/PresenceService.java +++ b/src/main/java/org/esupportail/emargement/services/PresenceService.java @@ -219,7 +219,11 @@ public void getPdfPresence(Document document, HttpServletResponse response, Lon mainTable.setWidthPercentage(100); mainTable.setWidths(new float[] { 0.7f,1.5f,1.5f,2,0.8f,1.5f,1.4f}); mainTable.setSpacingBefore(20.0f); - mainTable.addCell(pdfGenaratorUtil.getMainHeaderCell("#")); + + // Ajout de la place dans le PDF de présence + if (sl.getLocation().hasPlan()) mainTable.addCell(pdfGenaratorUtil.getMainHeaderCell("Place")); + else mainTable.addCell(pdfGenaratorUtil.getMainHeaderCell("#")); + mainTable.addCell(pdfGenaratorUtil.getMainHeaderCell("Nom")); mainTable.addCell(pdfGenaratorUtil.getMainHeaderCell("Prénom")); mainTable.addCell(pdfGenaratorUtil.getMainHeaderCell("Identifiant")); @@ -233,12 +237,14 @@ public void getPdfPresence(Document document, HttpServletResponse response, Lon int i =0;int j =1; for(TagCheck tc : list) { String dateEmargement = ""; + String place = ""; String nom = ""; String prenom = ""; String identifiant = ""; String typeemargement = ""; String typeIndividu = ""; if(tc.getPerson() !=null ) { + place = tc.getPlace(); nom = tc.getPerson().getNom(); prenom = tc.getPerson().getPrenom(); identifiant = tc.getPerson().getNumIdentifiant(); @@ -247,6 +253,7 @@ public void getPdfPresence(Document document, HttpServletResponse response, Lon } typeIndividu = messageSource.getMessage("person.type.".concat(tc.getPerson().getType()), null, null).substring(0,1); }else if(tc.getGuest() !=null ) { + place = tc.getPlace(); nom = tc.getGuest().getNom(); prenom = tc.getGuest().getPrenom(); identifiant = tc.getGuest().getEmail(); @@ -267,7 +274,11 @@ public void getPdfPresence(Document document, HttpServletResponse response, Lon typeemargement = messageSource.getMessage("typeEmargement.".concat(tc.getTypeEmargement().name().toLowerCase()), null, null) + "\n"; } typeemargement += (tc.getProxyPerson()!=null)? "Proc : " + tc.getProxyPerson().getPrenom() + ' ' + tc.getProxyPerson().getNom(): ""; - mainTable.addCell(pdfGenaratorUtil.getMainRowCell(String.valueOf(j))); + + // Ajout de la place dans le PDF de présence + if (place != null)mainTable.addCell(pdfGenaratorUtil.getMainRowCell(place)); + else mainTable.addCell(pdfGenaratorUtil.getMainRowCell(String.valueOf(j))); + mainTable.addCell(pdfGenaratorUtil.getMainRowCell(nom)); mainTable.addCell(pdfGenaratorUtil.getMainRowCell(prenom)); mainTable.addCell(pdfGenaratorUtil.getMainRowCell(identifiant)); @@ -290,7 +301,11 @@ public void getPdfPresence(Document document, HttpServletResponse response, Lon mainTable.setWidthPercentage(100); mainTable.setWidths(new float[] { 0.7f,1.5f,1.5f,2,0.8f,1.5f,1.4f}); mainTable.setSpacingBefore(20.0f); - mainTable.addCell(pdfGenaratorUtil.getMainHeaderCell("#")); + + // Ajout de la place dans le PDF de présence + if (sl.getLocation().hasPlan()) mainTable.addCell(pdfGenaratorUtil.getMainHeaderCell("Place")); + else mainTable.addCell(pdfGenaratorUtil.getMainHeaderCell("#")); + mainTable.addCell(pdfGenaratorUtil.getMainHeaderCell("Nom")); mainTable.addCell(pdfGenaratorUtil.getMainHeaderCell("Prénom")); mainTable.addCell(pdfGenaratorUtil.getMainHeaderCell("Identifiant")); diff --git a/src/main/java/org/esupportail/emargement/services/SessionEpreuveService.java b/src/main/java/org/esupportail/emargement/services/SessionEpreuveService.java index 205f922..f052a2a 100644 --- a/src/main/java/org/esupportail/emargement/services/SessionEpreuveService.java +++ b/src/main/java/org/esupportail/emargement/services/SessionEpreuveService.java @@ -23,6 +23,8 @@ import org.apache.commons.lang3.StringUtils; import org.esupportail.emargement.domain.AppliConfig; import org.esupportail.emargement.domain.Context; +import org.esupportail.emargement.domain.Location; +import org.esupportail.emargement.domain.Plan; import org.esupportail.emargement.domain.Prefs; import org.esupportail.emargement.domain.PropertiesForm; import org.esupportail.emargement.domain.SessionEpreuve; @@ -123,6 +125,9 @@ public class SessionEpreuveService { @Resource LogService logService; + @Resource + LocationService locationService; + @Resource AppliConfigService appliConfigService; @@ -237,6 +242,42 @@ public boolean executeRepartition(Long sessionEpreuveId, String tagCheckOrder) { } //on compte le nombre le nombre de place utilisé dans cette salle Long nbUsedPlace = tagCheckRepository.countTagCheckBySessionEpreuveIdAndSessionLocationExpectedIsNotNullAndIsTiersTempsFalseAndSessionLocationExpectedId(sessionEpreuveId, sl.getId()); + + // Pour le plan + List checks = tagCheckOrder.compareTo("1")==0 ? + tagCheckRepository.findByIsTiersTempsFalseAndSessionEpreuve_IdAndSessionLocationExpectedIsNullOrderByPerson_Id(sessionEpreuveId) + : tagCheckRepository.findByIsTiersTempsFalseAndSessionEpreuve_IdAndSessionLocationExpectedIsNull(sessionEpreuveId); + + System.out.println("checks -----------------> " + checks); + if(!checks.isEmpty()) { + + short i = 0; + + Location location = sl.getLocation(); + Plan plan = locationService.findPlan(location.getId()); + System.out.println("plan -----------------> " + plan); + if(plan != null) { + short planCols = plan.getColumns(); + Short[] places = plan.getStandardPlaces(); + while(nbUsedPlace < sl.getCapacite() && i < checks.size()) { + TagCheck check = checks.get(i); + if(check.getIsUnknown()) tagCheckRepository.delete(check); + else { + Short place = places[i]; + check.setPlace(plan.getHasAlphanumEnum() ? String.format("%c%d", 'A' + Math.floorDiv(place - 1, planCols), 1 + (place - 1) % planCols) : String.valueOf(place)); + check.setSessionLocationExpected(sl); + check.setNumAnonymat(constructNumAnonymat(sessionEpreuve, j)); + tagCheckRepository.save(check); + nbUsedPlace++; + j++; + i++; + } + + System.out.println("check -----------------> " + check); + } + } + } + if(!tagCheckList.isEmpty()) { if(nbUsedPlace.intValue()0) { size = count.intValue(); @@ -111,123 +119,157 @@ public String list(Model model, @PageableDefault(direction = Direction.ASC, sort model.addAttribute("location", location); model.addAttribute("collapse", "show"); } - model.addAttribute("locationPage", locationPage); - model.addAttribute("paramUrl", "0"); - model.addAttribute("help", helpService.getValueOfKey(ITEM)); - model.addAttribute("selectAll", count); + model.addAttribute("locationPage", locationPage); + model.addAttribute("paramUrl", "0"); + model.addAttribute("help", helpService.getValueOfKey(ITEM)); + model.addAttribute("selectAll", count); return "admin/location/list"; } - + @GetMapping(value = "/admin/location/{id}", produces = "text/html") - public String show(@PathVariable("id") Long id, Model uiModel) { - uiModel.addAttribute("location", locationRepository.findById(id).get()); - uiModel.addAttribute("help", helpService.getValueOfKey(ITEM)); - return "admin/location/show"; - } + public String show(@PathVariable("id") Long id, Model uiModel) { + uiModel.addAttribute("location", locationRepository.findById(id).get()); + uiModel.addAttribute("help", helpService.getValueOfKey(ITEM)); + return "admin/location/show"; + } + + @GetMapping(value = "/admin/location", params = "form", produces = "text/html") + public String createForm(Model uiModel) throws IOException, ParserException { + Location location = new Location(); + uiModel.addAttribute("eventLocations", locationService.getSuggestedLocation()); + populateEditForm(uiModel, location); + return "admin/location/create"; + } - @GetMapping(value = "/admin/location", params = "form", produces = "text/html") - public String createForm(Model uiModel) throws IOException, ParserException { - Location location = new Location(); - uiModel.addAttribute("eventLocations", locationService.getSuggestedLocation()); - populateEditForm(uiModel, location); - return "admin/location/create"; - } - - @GetMapping(value = "/admin/location/{id}", params = "form", produces = "text/html") - public String updateForm(@PathVariable("id") Long id, Model uiModel) { - Location location = locationRepository.findById(id).get(); - populateEditForm(uiModel, location); - return "admin/location/update"; - } - - void populateEditForm(Model uiModel, Location Location) { - uiModel.addAttribute("allCampuses", campusRepository.findAll()); - uiModel.addAttribute("location", Location); - uiModel.addAttribute("help", helpService.getValueOfKey(ITEM)); - } - - @PostMapping("/admin/location/create") - public String create(@PathVariable String emargementContext, @Valid Location location, BindingResult bindingResult, Model uiModel, - HttpServletRequest httpServletRequest, final RedirectAttributes redirectAttributes) throws IOException { - if (bindingResult.hasErrors()) { - populateEditForm(uiModel, location); - return "admin/location/create"; - } - uiModel.asMap().clear(); - Authentication auth = SecurityContextHolder.getContext().getAuthentication(); - if(locationRepository.countByNom(location.getNom())>0) { - redirectAttributes.addFlashAttribute("nom", location.getNom()); - redirectAttributes.addFlashAttribute("error", "constrainttError"); - log.info("Erreur lors de la création, lieu déjà existant : " + location.getNom().concat(" - ").concat(location.getCampus().getSite())); - return String.format("redirect:/%s/admin/location?form", emargementContext); - }else { - location.setContext(contexteService.getcurrentContext()); - locationRepository.save(location); - log.info("ajout d'un lieu : " + location.getNom().concat(" - ").concat(location.getCampus().getSite())); - logService.log(ACTION.AJOUT_LOCATION, RETCODE.SUCCESS, location.getNom().concat(" - ").concat(location.getCampus().getSite()), auth.getName(), null, emargementContext, null); - return String.format("redirect:/%s/admin/location", emargementContext); - } - } - - @PostMapping("/admin/location/update/{id}") - public String update(@PathVariable String emargementContext, @PathVariable("id") Long id, @Valid Location location, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest, final RedirectAttributes redirectAttributes) throws IOException { - if (bindingResult.hasErrors()) { - populateEditForm(uiModel, location); - return "admin/location/update"; - } - uiModel.asMap().clear(); - Authentication auth = SecurityContextHolder.getContext().getAuthentication(); - - List sls = sessionLocationRepository.findByLocationIdAndCapaciteGreaterThan(location.getId(), location.getCapacite()); - if(locationRepository.countByNom(location.getNom())>0 && !location.getNom().equalsIgnoreCase(locationRepository.findById(location.getId()).get().getNom())) { - redirectAttributes.addFlashAttribute("nom", location.getNom()); - redirectAttributes.addFlashAttribute("error", "constrainttError"); - log.info("Erreur lors de la maj, lieu déjà existant : " + location.getNom().concat(" - ").concat(location.getCampus().getSite())); - return String.format("redirect:/%s/admin/location/%s?form", emargementContext, location.getId()); - }else if(!sls.isEmpty()){ - redirectAttributes.addFlashAttribute("capacite", location.getCapacite()); - redirectAttributes.addFlashAttribute("sls", sls); - log.info("Erreur lors de la maj, la capacité de " + location.getCapacite() + " est insuffisante car plus élevée dans un lieu de session utilisé !!! "); - return String.format("redirect:/%s/admin/location/%s?form", emargementContext, location.getId()); - }else { - location.setCampus(location.getCampus()); - location.setContext(contexteService.getcurrentContext()); - locationRepository.save(location); - log.info("maj lieu : " + location.getNom().concat(" - ").concat(location.getCampus().getSite())); - logService.log(ACTION.UPDATE_LOCATION, RETCODE.SUCCESS, location.getNom().concat(" - ").concat(location.getCampus().getSite()), auth.getName(), null, emargementContext, null); - return String.format("redirect:/%s/admin/location", emargementContext); - } - } - - @PostMapping(value = "/admin/location/{id}") - public String delete(@PathVariable String emargementContext, @PathVariable("id") Long id, Model uiModel, final RedirectAttributes redirectAttributes) { - Location location = locationRepository.findById(id).get(); - Authentication auth = SecurityContextHolder.getContext().getAuthentication(); - try { - locationRepository.delete(location); - log.info("Suppression du lieu : " + location.getNom().concat(" - ").concat(location.getCampus().getSite())); - logService.log(ACTION.DELETE_LOCATION, RETCODE.SUCCESS, location.getNom().concat(" - ").concat(location.getCampus().getSite()), auth.getName(), null, emargementContext, null); + // @GetMapping(name = "CreateForm", path = ITEM + "/form") + @GetMapping(value = "/admin/location/plan/{id}", params = "form", produces = "text/html") + public String form(@PathVariable String emargementContext, @PathVariable("id") Long id, Model uiModel) throws IOException, ParserException { + // public String createForm(@PathVariable String emargementContext, @PathVariable String ctx, @RequestParam(required = false) Object id, Model m) throws IOException, ParserException { + + boolean existing; + boolean hasId = id != null; + // Long id_long = Long.parseLong(id); + String response; + Location location = hasId ? locationService.findById(true, id) : null; + + + if(location != null) { + existing = true; + response = "admin/location"; + } + else { + existing = false; + if(hasId) response = getRedirectRoute(emargementContext); + else { + response = "admin/location"; + uiModel.addAttribute("suggestedLocations", locationService.getSuggestedLocation()); + } + location = new Location(); + } + uiModel.addAttribute("existing", existing); + uiModel.addAttribute("help", helpService.getValueOfKey("location")); + uiModel.addAttribute(ITEM, location); + uiModel.addAttribute("allCampuses", campusService.findAll()); + return response + "/form"; + } + + @GetMapping(value = "/admin/location/{id}", params = "form", produces = "text/html") + public String updateForm(@PathVariable("id") Long id, Model uiModel) { + Location location = locationRepository.findById(id).get(); + populateEditForm(uiModel, location); + return "admin/location/update"; + } + + void populateEditForm(Model uiModel, Location Location) { + uiModel.addAttribute("allCampuses", campusRepository.findAll()); + uiModel.addAttribute("location", Location); + uiModel.addAttribute("help", helpService.getValueOfKey(ITEM)); + } + + @PostMapping("/admin/location/create") + public String create(@PathVariable String emargementContext, @Valid Location location, BindingResult bindingResult, Model uiModel, + HttpServletRequest httpServletRequest, final RedirectAttributes redirectAttributes) throws Exception { + if (bindingResult.hasErrors()) { + populateEditForm(uiModel, location); + return "admin/location/create"; + } + uiModel.asMap().clear(); + Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + if(locationRepository.countByNom(location.getNom())>0) { + redirectAttributes.addFlashAttribute("nom", location.getNom()); + redirectAttributes.addFlashAttribute("error", "constrainttError"); + log.info("Erreur lors de la création, lieu déjà existant : " + location.getNom().concat(" - ").concat(location.getCampus().getSite())); + return String.format("redirect:/%s/admin/location?form", emargementContext); + }else { + location.setContext(contexteService.getcurrentContext()); + locationService.save(location); + locationRepository.save(location); + log.info("ajout d'un lieu : " + location.getNom().concat(" - ").concat(location.getCampus().getSite())); + logService.log(ACTION.AJOUT_LOCATION, RETCODE.SUCCESS, location.getNom().concat(" - ").concat(location.getCampus().getSite()), auth.getName(), null, emargementContext, null); + return String.format("redirect:/%s/admin/location", emargementContext); + } + } + + @PostMapping(name = "Location#Update", path = "/admin/location/update/{id}") + public String update(@PathVariable String emargementContext, @PathVariable("id") Long id, @Valid Location location, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest, final RedirectAttributes redirectAttributes) throws Exception { + if (bindingResult.hasErrors()) { + populateEditForm(uiModel, location); + return "admin/location/update"; + } + uiModel.asMap().clear(); + Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + + List sls = sessionLocationRepository.findByLocationIdAndCapaciteGreaterThan(location.getId(), location.getCapacite()); + if(locationRepository.countByNom(location.getNom())>0 && !location.getNom().equalsIgnoreCase(locationRepository.findById(location.getId()).get().getNom())) { + redirectAttributes.addFlashAttribute("nom", location.getNom()); + redirectAttributes.addFlashAttribute("error", "constrainttError"); + log.info("Erreur lors de la maj, lieu déjà existant : " + location.getNom().concat(" - ").concat(location.getCampus().getSite())); + return String.format("redirect:/%s/admin/location/%s?form", emargementContext, location.getId()); + }else if(!sls.isEmpty()){ + redirectAttributes.addFlashAttribute("capacite", location.getCapacite()); + redirectAttributes.addFlashAttribute("sls", sls); + log.info("Erreur lors de la maj, la capacité de " + location.getCapacite() + " est insuffisante car plus élevée dans un lieu de session utilisé !!! "); + return String.format("redirect:/%s/admin/location/%s?form", emargementContext, location.getId()); + }else { + location.setCampus(location.getCampus()); + location.setContext(contexteService.getcurrentContext()); + locationService.save(location); + locationRepository.save(location); + log.info("maj lieu : " + location.getNom().concat(" - ").concat(location.getCampus().getSite())); + logService.log(ACTION.UPDATE_LOCATION, RETCODE.SUCCESS, location.getNom().concat(" - ").concat(location.getCampus().getSite()), auth.getName(), null, emargementContext, null); + return String.format("redirect:/%s/admin/location", emargementContext); + } + } + + @PostMapping(value = "/admin/location/{id}") + public String delete(@PathVariable String emargementContext, @PathVariable("id") Long id, Model uiModel, final RedirectAttributes redirectAttributes) { + Location location = locationRepository.findById(id).get(); + Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + try { + locationRepository.delete(location); + log.info("Suppression du lieu : " + location.getNom().concat(" - ").concat(location.getCampus().getSite())); + logService.log(ACTION.DELETE_LOCATION, RETCODE.SUCCESS, location.getNom().concat(" - ").concat(location.getCampus().getSite()), auth.getName(), null, emargementContext, null); } catch (Exception e) { e.printStackTrace(); redirectAttributes.addFlashAttribute("item", location.getNom()); redirectAttributes.addFlashAttribute("error", "constrainttError"); } - return String.format("redirect:/%s/admin/location", emargementContext); - } - - @GetMapping("/admin/location/search") - @ResponseBody - public List search(@PathVariable String emargementContext, @RequestParam("searchValue") String searchString){ - HttpHeaders headers = new HttpHeaders(); + return String.format("redirect:/%s/admin/location", emargementContext); + } + + @GetMapping("/admin/location/search") + @ResponseBody + public List search(@PathVariable String emargementContext, @RequestParam("searchValue") String searchString){ + HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "application/json; charset=utf-8"); List locations= locationRepositoryCustom.findAll(searchString, emargementContext); - - return locations; - } - - @GetMapping("/admin/location/addAll") - @Transactional - public String addAll(@PathVariable String emargementContext, final RedirectAttributes redirectAttributes) throws IOException, ParserException{ + + return locations; + } + + @GetMapping("/admin/location/addAll") + @Transactional + public String addAll(@PathVariable String emargementContext, final RedirectAttributes redirectAttributes) throws IOException, ParserException{ List nomLocations = locationService.getSuggestedLocation(); Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if(!nomLocations.isEmpty()) { @@ -242,5 +284,5 @@ public String addAll(@PathVariable String emargementContext, final RedirectAttr } redirectAttributes.addAttribute("msgModal", "ddd"); return String.format("redirect:/%s/admin/location", emargementContext); - } + } } diff --git a/src/main/resources/emargement.properties b/src/main/resources/emargement.properties index c91ad9f..8ea9cc7 100644 --- a/src/main/resources/emargement.properties +++ b/src/main/resources/emargement.properties @@ -75,3 +75,73 @@ emargement.ade.sync.range = 7 emargement.esupsignature.url = https://esup-signature.univ-ville.fr emargement.esupsignature.workflow.id = 1250 + +emargement.datasource.apogee.query.composantes=SELECT FDOM_CODE as COD_CMP, FDOM_LIBELLE as LIB_CMP \ + from SCOLARITE.SCOL_FORMATION_DOMAINE \ + WHERE FDOM_VALIDITE='O' and FDOM_CODE_SISE is not null \ + ORDER BY FDOM_LIBELLE +emargement.datasource.apogee.query.elementsPedagogiques=SELECT DISTINCT mrsem.MSEM_KEY as COD_ETP, fdip.FGRA_CODE||FHAB_NIVEAU||' '||case when fdip.FDIP_ABREVIATION = FSPN_LIBELLE then FSPN_LIBELLE else fdip.FDIP_ABREVIATION || ' '||FSPN_LIBELLE end||' '||mpar.mpar_libelle||' semestre '||msem_ordre as LIB_ETP \ + FROM SCOLARITE.scol_formation_habilitation fhab, \ + SCOLARITE.scol_formation_specialisation fspn, \ + SCOLARITE.scol_formation_diplome fdip, \ + SCOLARITE.scol_maquette_parcours mpar, \ + SCOLARITE.scol_maquette_repartition_sem mrsem, \ + SCOLARITE.scol_maquette_semestre msem \ + WHERE msem.msem_ordre IN (((fhab.fhab_niveau * 2) - 1), (fhab.fhab_niveau * 2)) \ + AND mrsem.msem_key = msem.msem_key \ + AND fhab.fann_key = mrsem.fann_key \ + AND mpar.mpar_key = mrsem.mpar_key \ + AND fspn.fspn_key = mpar.fspn_key \ + AND fhab.fspn_key = fspn.fspn_key \ + AND fspn.fdip_code = fdip.fdip_code \ + AND fhab.FANN_KEY= ? \ + AND FDOM_CODE= ? \ + AND FGRA_CODE In ('L','M') \ + ORDER BY LIB_ETP +emargement.datasource.apogee.query.matieres=SELECT MEC_KEY as COD_ELP, MEC_CODE ||' '|| MEC_LIBELLE as LIB_ELP \ + FROM SCOLARITE.V_SCOL_MAQUETTE_EC \ + WHERE FANN_KEY = ? AND MSEM_KEY = ? \ + AND 'NE_PAS_UTILISER'!=? AND 'NE_PAS_UTILISER'!=? AND 'NE_PAS_UTILISER'!=? AND 'NE_PAS_UTILISER'!=? \ + ORDER BY MEC_CODE +emargement.datasource.apogee.query.countAutorisesEpreuve=SELECT Count(NO_INDIVIDU) \ + FROM SCOLARITE.V_SCOL_INSCRIPTION_EC \ + WHERE MEC_KEY= ? \ + AND 'NE_PAS_UTILISER'!=? \ + AND FANN_KEY = ? +emargement.datasource.apogee.query.autorisesEpreuve=SELECT vsiec.ETUD_NUMERO as COD_ETU, vsiec.NOM_USUEL as LIB_NOM_PAT_IND, ind.PRENOM_USUEL as LIB_PR1_IND, ind.D_NAISSANCE as DATE_NAI_IND \ + FROM SCOLARITE.V_SCOL_INSCRIPTION_EC vsiec, GRHUM.INDIVIDU_ULR ind \ + WHERE ind.NO_INDIVIDU=vsiec.NO_INDIVIDU \ + AND MEC_KEY= ? AND 'NE_PAS_UTILISER'!=? \ + AND FANN_KEY = ? +emargement.datasource.apogee.query.groupes=SELECT DISTINCT EENT_KEY as COD_EXT_GPE, EENT_LIBELLE || ' session '|| EENT_SESSION as LIB_GPE \ + FROM SCOLARITE.SCOL_EXAMEN_ENTETE WHERE FANN_KEY = ? AND MEC_KEY=? +emargement.datasource.apogee.query.countAutorisesEpreuveGroupe=SELECT Count(*) \ + FROM SCOLARITE.SCOL_INSCRIPTION_EXAMEN siex, SCOLARITE.SCOL_INSCRIPTION_ETUDIANT sie, GRHUM.INDIVIDU_ULR ind \ + WHERE ind.NO_INDIVIDU = sie.NO_INDIVIDU AND sie.IDIPL_NUMERO = siex.IDIPL_NUMERO \ + AND sie.FANN_KEY = ? AND siex.EENT_KEY = ? +emargement.datasource.apogee.query.autorisesEpreuveGroupe=SELECT sie.etud_numero as COD_ETU, ind.NOM_USUEL, ind.PRENOM_USUEL, ind.D_NAISSANCE \ + FROM SCOLARITE.SCOL_INSCRIPTION_EXAMEN siex, SCOLARITE.SCOL_INSCRIPTION_ETUDIANT sie, GRHUM.INDIVIDU_ULR ind \ + WHERE ind.NO_INDIVIDU = sie.NO_INDIVIDU AND sie.IDIPL_NUMERO = siex.IDIPL_NUMERO \ + AND sie.FANN_KEY = ? AND siex.EENT_KEY = ? +emargement.datasource.apogee.query.autorisesEpreuveComposante=SELECT sie.etud_numero as COD_ETU, ind.NOM_USUEL, ind.PRENOM_USUEL, ind.D_NAISSANCE \ + FROM SCOLARITE.SCOL_INSCRIPTION_EXAMEN siex, SCOLARITE.SCOL_INSCRIPTION_ETUDIANT sie, GRHUM.INDIVIDU_ULR ind \ + WHERE ind.NO_INDIVIDU = sie.NO_INDIVIDU AND sie.IDIPL_NUMERO = siex.IDIPL_NUMERO \ + AND sie.FANN_KEY = ? AND sie.FDOM_CODE = ? +emargement.datasource.apogee.query.countAutorisesEpreuveComposante=SELECT Count(distinct sie.idipl_numero) \ + FROM SCOLARITE.SCOL_INSCRIPTION_EXAMEN siex, SCOLARITE.SCOL_INSCRIPTION_ETUDIANT sie, GRHUM.INDIVIDU_ULR ind \ + WHERE ind.NO_INDIVIDU = sie.NO_INDIVIDU AND sie.IDIPL_NUMERO = siex.IDIPL_NUMERO \ + AND sie.FANN_KEY = ? AND sie.FDOM_CODE = ? +emargement.datasource.apogee.query.autorisesEpreuveDiplome=SELECT sie.etud_numero as COD_ETU, ind.NOM_USUEL, ind.PRENOM_USUEL, ind.D_NAISSANCE \ + FROM SCOLARITE.SCOL_INSCRIPTION_EXAMEN siex, SCOLARITE.SCOL_INSCRIPTION_ETUDIANT sie, GRHUM.INDIVIDU_ULR ind, \ + SCOLARITE.SCOL_INSCRIPTION_SEMESTRE sis, SCOLARITE.SCOL_MAQUETTE_REPARTITION_SEM smrs \ + WHERE ind.NO_INDIVIDU = sie.NO_INDIVIDU AND sie.IDIPL_NUMERO = siex.IDIPL_NUMERO \ + AND sis.MRSEM_KEY=smrs.MRSEM_KEY AND sis.idipl_numero=sie.idipl_numero \ + AND smrs.MSEM_KEY = ? AND (1=1 OR 'NE_PAS_UTILISER'!=? AND 'NE_PAS_UTILISER'!=?) AND sie.FANN_KEY = ? +emargement.datasource.apogee.query.countAutorisesEpreuveDiplome=SELECT Count(distinct sie.idipl_numero) \ + FROM SCOLARITE.SCOL_INSCRIPTION_EXAMEN siex, SCOLARITE.SCOL_INSCRIPTION_ETUDIANT sie, GRHUM.INDIVIDU_ULR ind, \ + SCOLARITE.SCOL_INSCRIPTION_SEMESTRE sis, SCOLARITE.SCOL_MAQUETTE_REPARTITION_SEM smrs \ + WHERE ind.NO_INDIVIDU = sie.NO_INDIVIDU AND sie.IDIPL_NUMERO = siex.IDIPL_NUMERO \ + AND sis.MRSEM_KEY=smrs.MRSEM_KEY AND sis.idipl_numero=sie.idipl_numero \ + AND smrs.MSEM_KEY = ? AND (1=1 OR 'NE_PAS_UTILISER'!=? AND 'NE_PAS_UTILISER'!=?) AND sie.FANN_KEY = ? + +emargement.plans.path=plans.json diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index e2874cf..80bb44b 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -117,7 +117,7 @@ config.value.consignes_enabled = false config.value.convoc_body_mail = [Convocaction] config.value.convoc_enabled = false config.value.convoc_sujet_mail = [Sujet convocation] -config.value.convoc_type =

Session : @nomSession@ 

\n

Dur\u00E9e : @dureeEpreuve@

\n

@civilite@ @prenom@ @nom@

\n

Vous \u00EAtes convoqu\u00E9 le @dateExamen@ \u00E0 @heureConvocation@ pr\u00E9cise \u00E0 l'adresse suivante : @adresse@ sur le site de @site@

\n

L'\u00E9preuve se d\u00E9roulera @salle@ entre  @debutEpreuve@ et @finEpreuve@

+config.value.convoc_type =

Session : @nomSession@ 

\n

Dur\u00E9e : @dureeEpreuve@

\n

@civilite@ @prenom@ @nom@

\n

Vous \u00EAtes convoqu\u00E9 le @dateExamen@ \u00E0 @heureConvocation@ pr\u00E9cise \u00E0 l'adresse suivante : @adresse@ sur le site de @site@

\n

L'\u00E9preuve se d\u00E9roulera salle @salle@ entre  @debutEpreuve@ et @finEpreuve@ place @place@

config.value.email_link_emarger = Bonjour @@nom@@,\n\nvotre universit\u00E9 vous envoie un email pour confirmer votre pr\u00E9sence \u00E0 la session \n\n@@session@@\n\nMerci d'\u00E9marger sur la page suivante :\n\n@@link@@ config.value.email_sujet_link_emarger = Participation \u00E0 la session @@session@@ config.value.enable_card_qrcode = false @@ -138,6 +138,7 @@ config.value.send_emails = false config.value.test_email = test@univ-ville.fr config.value.tri_badgeage_alpha = false +help.plan.places =
Pas de place
Place standard
Place réservée
help.ctx.session.alerte = Affiche un message indicatif du nombre de badgeage si l'on d\u00E9passe le chiffre indiqu\u00E9. help.ctx.session.displayGroupe = La colonne "Groupe" sera affich\u00E9e dans la liste d'\u00E9margement et celle des inscrits. help.ctx.session.groupe = Ne valide pas l'\u00E9margement des individus de ce groupe lors d'une session. Si on veut l'auto-alimenter avec les badgeages, on coche "Enregistrement automatique" @@ -288,13 +289,10 @@ title.typeSession = {0} -- Type session title.user = {0} -- Participant title.userApp = {0} -- Agents -typeEmargement.card = Carte -typeEmargement.link = Lien -typeEmargement.manual = Manuel -typeEmargement.qrcode = QrCode -typeEmargement.qrcode_card = QrCode carte -typeEmargement.qrcode_session = QrCode de session -typeEmargement.qrcode_user = QrCode participant +typeEmargement.card = Carte +typeEmargement.link = Lien +typeEmargement.manual = Manuel +typeEmargement.qrcode = QrCode typeSession.libelle.cm = Cours magistral typeSession.libelle.col = Colloque diff --git a/src/main/resources/security.properties b/src/main/resources/security.properties index b73091e..170df0b 100644 --- a/src/main/resources/security.properties +++ b/src/main/resources/security.properties @@ -5,5 +5,5 @@ # # local, esup-nfc-tag-test, esup-nfc-tag-prod -accessRestrictionWSRest= 127.0.0.1 +accessRestrictionWSRest= 127.0.0.1,172.16.15.38,172.16.97.34 diff --git a/src/main/resources/static/css/app.css b/src/main/resources/static/css/app.css index b8314df..e3a3287 100644 --- a/src/main/resources/static/css/app.css +++ b/src/main/resources/static/css/app.css @@ -286,4 +286,24 @@ dl dd:after { .jstree-anchor { white-space: break-spaces !important; height: auto !important; -} \ No newline at end of file +} + + +/* Pour le plan */ +#places { + height:70vh; + display:flex; + flex-direction:column-reverse; +} +#places > .row { flex: 1 1 0; } +#none, .place-none { background-color:#888; } +#special, .place-special { background-color:blue; } +#standard, .place-standard { background-color:#fff; } +#none, #special, #standard { + outline:transparent solid 1px; + outline-offset:4px; + border-color:#000; + background-image:none; +} +:is(#none, #special, #standard):checked { outline-color: blue; } +#places :is(.place-none, .place-special, .place-standard) { border:1px solid #000; } diff --git a/src/main/resources/static/js/app.js b/src/main/resources/static/js/app.js index af58a3d..b17690a 100644 --- a/src/main/resources/static/js/app.js +++ b/src/main/resources/static/js/app.js @@ -113,13 +113,6 @@ function getCalendar(calendarEl, urlEvents, editable) { calendar.render(); } -function createDateFromString(dateString) { - const [day, month, year] = dateString.split('-').map(Number); - const adjustedYear = year < 70 ? 2000 + year : 1900 + year; - - return new Date(adjustedYear, month - 1, day); // month is 0-indexed in JavaScript Date objects -} - function searchUsersAutocomplete(id, url, paramurl, maxItems) { var searchBox = document.getElementById(id); if (searchBox != null) { @@ -1674,7 +1667,6 @@ document.addEventListener('DOMContentLoaded', function() { maxFileSize: 1000, maxFileCount: 10, mainClass: "input-group-lg", - dropZoneEnabled: false }); } else { const config = { @@ -2144,33 +2136,8 @@ document.addEventListener('DOMContentLoaded', function() { formAction=""; $('#commentTagCheckModal').modal('show'); }); - - //Recherche assiduité - let minDate, maxDate; - DataTable.ext.search.push(function (settings, data, dataIndex) { - let min = minDate.val(); - let max = maxDate.val(); - let date = new Date(newDate = createDateFromString(data[4])); - if ( - (min === null && max === null) || - (min === null && date <= max) || - (min <= date && max === null) || - (min <= date && date <= max) - ) { - return true; - } - return false; - }); - // Create date inputs - minDate = new DateTime('#min', { - format: 'DD-MM-YY' - }); - maxDate = new DateTime('#max', { - format: 'DD-MM-YY' - }); - var title = ''; - var dataTableOptions = { + $('table.assiduite').DataTable( { responsive: true, ordering: true, paging: true, @@ -2191,18 +2158,95 @@ document.addEventListener('DOMContentLoaded', function() { {extend: 'pdf', exportOptions: {orthogonal: 'filter', columns: ':not(.exclude)'}, title:function () {return 'assiduite_' + title;}}, {extend: 'print', exportOptions: {orthogonal: 'filter', columns: ':not(.exclude)'}, title:function () {return 'assiduite_' + title;}} ] - } - - $('table.assiduite').DataTable(dataTableOptions).on('buttons-processing', function(e, buttonApi, dataTable, node, config) { - title = $(dataTable.table().node()).attr('data-export-title'); - }); - - let table3 = $('table.assiduite2').DataTable(dataTableOptions).on('buttons-processing', function(e, buttonApi, dataTable, node, config) { - title = $(dataTable.table().node()).attr('data-export-title'); - }); - - // Refilter the table - document.querySelectorAll('#min, #max').forEach((el) => { - el.addEventListener('change', () => table3.draw()); - }); -}); \ No newline at end of file + }).on('buttons-processing', function(e, buttonApi, dataTable, node, config) { + title = $(dataTable.table().node()).attr('data-export-title'); + }); + + + // Plan + $(document).on('change', '#plan\\.hasAlphanumEnum1', function (){ + // alert('test1'); + // console.log($("#num-place")); + $("span#num-place").toggleClass('d-none'); + $("span#alpha-place").toggleClass('d-none'); + }); + $(document).on('change', '#hasPlan', function (){ + $("#plan-editor").toggleClass('d-none'); + }); + if ($('#hasPlan').is(':checked')) { + $("#plan-editor").removeClass('d-none'); + } + + const placePrefix = 'place-'; + const placeRow = document.createElement('div'); + const place = document.createElement('div'); + const placeTypes = [`${placePrefix}none`, `${placePrefix}standard`, `${placePrefix}special`]; + const locationForm = document.forms.location; + placeRow.classList.add('row'); + place.classList.add('col', placeTypes[1]); + if(locationForm != null) { + const editorTogglingClass = 'd-lg-block'; + const planEditor = locationForm.querySelector('#plan-editor'); + const places = planEditor.querySelector('#places'); + const hasPlanField = locationForm.elements.hasPlan; + const capacityField = locationForm.elements.capacity; + const editorClasses = planEditor.classList; + hasPlanField.addEventListener('change', (e) => { + const state = e.currentTarget.checked; + capacityField.disabled = state; + if(state) editorClasses.add(editorTogglingClass); + else editorClasses.remove(editorTogglingClass); + planEditor.querySelectorAll('input').forEach((field) => { field.disabled = !state; }); + }); + hasPlanField.dispatchEvent(new Event('change')); + locationForm.elements['plan.columns'].addEventListener('change', updateCols); + locationForm.elements['plan.rows'].addEventListener('change', updateRows); + const placeTypesSelector = placeTypes.map(type => '.' + type).toString(); + $(places).on('dragstart', placeTypesSelector, (event) => event.preventDefault()); + $(places).on('mousedown', placeTypesSelector, (event) => { + const selectedType = placePrefix + locationForm.elements.place.value; + const place = event.currentTarget; + place.classList.remove(...placeTypes.filter(type => type != selectedType)); + place.classList.add(selectedType); + }); + $(places).on('mouseenter', placeTypesSelector, (event) => { if(event.buttons == 1) $(event.currentTarget).trigger('mousedown') }); + locationForm.addEventListener('submit', function() { + const cols = locationForm.elements['plan.columns'].value; + standardPlaces = []; + specialPlaces = []; + placeRows = places.children; + for(let row = 0; row < placeRows.length; row++) { + const rowPlaces = placeRows[row].children; + let i = 0; + while(i < rowPlaces.length) { + const classes = rowPlaces[i++].classList; + if(classes.contains(placeTypes[1]) || classes.contains(placeTypes[2])) { + const rowPlace = cols * row + i; + if(classes.contains(placeTypes[1])) standardPlaces.push(rowPlace); + else specialPlaces.push(rowPlace); + } + } + } + locationForm.elements['plan.specialPlaces'].value = specialPlaces; + locationForm.elements['plan.standardPlaces'].value = standardPlaces; + }); + alert(document.forms.session.elements.dateExamen.value); + } + function updateCols(e) { + const rows = places.children; + const n = e.currentTarget.value - rows[0].children.length; + if(n > 0) for(let i = 0; i < n; i++) for(const row of rows) row.appendChild(place.cloneNode()); + else for(let i = 0; i > n; i--) { for(const row of rows) row.lastElementChild.remove(); } + } + function updateRows(e) { + const n = e.currentTarget.value - places.children.length; + if(n > 0) { + for(let i = 0; i < n; i++) { + const row = placeRow.cloneNode(); + for(let col = 0; col < locationForm.elements['plan.columns'].value; col++) row.appendChild(place.cloneNode()); + places.appendChild(row); + } + } + else for(let i = 0; i > n; i--) places.lastElementChild.remove(); + } +}); diff --git a/src/main/resources/templates/admin/location/form.html b/src/main/resources/templates/admin/location/form.html new file mode 100755 index 0000000..7e5c57a --- /dev/null +++ b/src/main/resources/templates/admin/location/form.html @@ -0,0 +1,204 @@ + + + + + +
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+ +
+ + +
+
+ +
+
+ +
+ +
+ +
+
+
+ +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ +
+
+
+
+
+
+
+ + diff --git a/src/main/resources/templates/admin/location/list.html b/src/main/resources/templates/admin/location/list.html index d45dcd4..78c7eb1 100644 --- a/src/main/resources/templates/admin/location/list.html +++ b/src/main/resources/templates/admin/location/list.html @@ -36,6 +36,7 @@

Lieux

Capacité maximale Site Adresse + Plan Actions @@ -45,8 +46,9 @@

Lieux

+ - +