Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ec330e6a8 | ||
|
|
66cd27995d | ||
|
|
4870d61f86 | ||
|
|
6ca3d0b765 | ||
|
|
ba268a33bc | ||
|
|
f641ccc519 | ||
|
|
6ea00db0dc |
@@ -1,22 +0,0 @@
|
||||
# Configuration Base de données
|
||||
POSTGRES_USER=myuser
|
||||
POSTGRES_PASSWORD=mypassword
|
||||
|
||||
# Configuration Email Brevo (SMTP Relay)
|
||||
# 1. Host: smtp-relay.brevo.com (ou smtp-relay.sendinblue.com)
|
||||
# 2. Port: 587 (TLS/STARTTLS) ou 465 (SSL)
|
||||
# 3. Username: Votre identifiant SMTP Brevo (visible dans Brevo > SMTP & API > SMTP)
|
||||
# 4. Password: Votre clef SMTP Brevo (Master Key ou Clef SMTP générée dans Brevo)
|
||||
SPRING_MAIL_HOST=smtp-relay.brevo.com
|
||||
SPRING_MAIL_PORT=587
|
||||
SPRING_MAIL_USERNAME=votre_login_smtp_brevo@exemple.com
|
||||
SPRING_MAIL_PASSWORD=xsmtpsib-votre_cle_smtp_brevo
|
||||
SPRING_MAIL_PROPERTIES_MAIL_SMTP_AUTH=true
|
||||
SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_ENABLE=true
|
||||
|
||||
# Expéditeur E-mail (doit être un expéditeur validé dans Brevo)
|
||||
APP_MAIL_FROM=astalange1933@gmail.com
|
||||
|
||||
# Configuration Captcha (si applicable)
|
||||
CAPTCHA_SITEKEY=
|
||||
CAPTCHA_SECRET=
|
||||
@@ -51,25 +51,11 @@ jobs:
|
||||
PROD_DB_PASSWORD: ${{ secrets.PROD_DB_PASSWORD }}
|
||||
CAPTCHA_SECRET: ${{ secrets.CAPTCHA_SECRET }}
|
||||
CAPTCHA_SITEKEY: ${{ secrets.CAPTCHA_SITEKEY }}
|
||||
MAIL_USERNAME: ${{ secrets.MAIL_USERNAME }}
|
||||
MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }}
|
||||
MAIL_FROM: ${{ secrets.MAIL_FROM }}
|
||||
run: |
|
||||
echo "POSTGRES_USER=${PROD_DB_USER:-myuser}" > .env
|
||||
echo "POSTGRES_PASSWORD=${PROD_DB_PASSWORD:-mypassword}" >> .env
|
||||
echo "CAPTCHA_SECRET=${CAPTCHA_SECRET:-1x0000000000000000000000000000000AA}" >> .env
|
||||
echo "CAPTCHA_SITEKEY=${CAPTCHA_SITEKEY:-1x00000000000000000000AA}" >> .env
|
||||
if [ -n "${MAIL_USERNAME}" ]; then
|
||||
echo "SPRING_MAIL_HOST=smtp-relay.brevo.com" >> .env
|
||||
echo "SPRING_MAIL_PORT=${MAIL_PORT:-2525}" >> .env
|
||||
echo "SPRING_MAIL_USERNAME=${MAIL_USERNAME}" >> .env
|
||||
echo "SPRING_MAIL_PASSWORD=${MAIL_PASSWORD}" >> .env
|
||||
echo "SPRING_MAIL_PROPERTIES_MAIL_SMTP_AUTH=true" >> .env
|
||||
echo "SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_ENABLE=true" >> .env
|
||||
if [ -n "${MAIL_FROM}" ]; then
|
||||
echo "APP_MAIL_FROM=${MAIL_FROM}" >> .env
|
||||
fi
|
||||
fi
|
||||
docker compose down app || true
|
||||
docker compose up -d --build app
|
||||
|
||||
|
||||
@@ -47,25 +47,11 @@ jobs:
|
||||
env:
|
||||
DB_USER: ${{ secrets.DB_USER }}
|
||||
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
|
||||
MAIL_USERNAME: ${{ secrets.MAIL_USERNAME }}
|
||||
MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }}
|
||||
MAIL_FROM: ${{ secrets.MAIL_FROM }}
|
||||
run: |
|
||||
echo "POSTGRES_USER=${DB_USER:-myuser}" > .env
|
||||
echo "POSTGRES_PASSWORD=${DB_PASSWORD:-mypassword}" >> .env
|
||||
echo "CAPTCHA_SECRET=1x0000000000000000000000000000000AA" >> .env
|
||||
echo "CAPTCHA_SITEKEY=1x00000000000000000000AA" >> .env
|
||||
if [ -n "${MAIL_USERNAME}" ]; then
|
||||
echo "SPRING_MAIL_HOST=smtp-relay.brevo.com" >> .env
|
||||
echo "SPRING_MAIL_PORT=${MAIL_PORT:-2525}" >> .env
|
||||
echo "SPRING_MAIL_USERNAME=${MAIL_USERNAME}" >> .env
|
||||
echo "SPRING_MAIL_PASSWORD=${MAIL_PASSWORD}" >> .env
|
||||
echo "SPRING_MAIL_PROPERTIES_MAIL_SMTP_AUTH=true" >> .env
|
||||
echo "SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_ENABLE=true" >> .env
|
||||
if [ -n "${MAIL_FROM}" ]; then
|
||||
echo "APP_MAIL_FROM=${MAIL_FROM}" >> .env
|
||||
fi
|
||||
fi
|
||||
docker compose down app || true
|
||||
docker compose up -d --build app
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>as-talange-parent</artifactId>
|
||||
<groupId>com.astalange</groupId>
|
||||
<version>1.7-SNAPSHOT</version>
|
||||
<version>1.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>as-talange-parent</artifactId>
|
||||
<groupId>com.astalange</groupId>
|
||||
<version>1.7-SNAPSHOT</version>
|
||||
<version>1.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -28,11 +28,6 @@
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
|
||||
@@ -50,18 +50,6 @@ public class Adherent {
|
||||
@Column(name = "ancienne_categorie", length = 50)
|
||||
private String ancienneCategorie;
|
||||
|
||||
@Column(name = "raison_changement_club")
|
||||
private String raisonChangementClub;
|
||||
|
||||
@Column(name = "comment_connu_club")
|
||||
private String commentConnuClub;
|
||||
|
||||
@Column(name = "taille_vetement", length = 50)
|
||||
private String tailleVetement;
|
||||
|
||||
@Column(length = 50)
|
||||
private String pointure;
|
||||
|
||||
private boolean residentTalange = true;
|
||||
|
||||
@Column(nullable = false, length = 10)
|
||||
@@ -117,18 +105,6 @@ public class Adherent {
|
||||
public String getAncienneCategorie() { return ancienneCategorie; }
|
||||
public void setAncienneCategorie(String ancienneCategorie) { this.ancienneCategorie = ancienneCategorie; }
|
||||
|
||||
public String getRaisonChangementClub() { return raisonChangementClub; }
|
||||
public void setRaisonChangementClub(String raisonChangementClub) { this.raisonChangementClub = raisonChangementClub; }
|
||||
|
||||
public String getCommentConnuClub() { return commentConnuClub; }
|
||||
public void setCommentConnuClub(String commentConnuClub) { this.commentConnuClub = commentConnuClub; }
|
||||
|
||||
public String getTailleVetement() { return tailleVetement; }
|
||||
public void setTailleVetement(String tailleVetement) { this.tailleVetement = tailleVetement; }
|
||||
|
||||
public String getPointure() { return pointure; }
|
||||
public void setPointure(String pointure) { this.pointure = pointure; }
|
||||
|
||||
public boolean isResidentTalange() { return residentTalange; }
|
||||
public void setResidentTalange(boolean residentTalange) { this.residentTalange = residentTalange; }
|
||||
|
||||
|
||||
@@ -36,10 +36,4 @@ public class AppUser {
|
||||
inverseJoinColumns = @JoinColumn(name = "role_id")
|
||||
)
|
||||
private Set<Role> roles = new HashSet<>();
|
||||
|
||||
@Column(name = "last_login_at")
|
||||
private java.time.LocalDateTime lastLoginAt;
|
||||
|
||||
@Column(name = "last_logout_at")
|
||||
private java.time.LocalDateTime lastLogoutAt;
|
||||
}
|
||||
|
||||
@@ -37,17 +37,11 @@ public class Categorie {
|
||||
@JoinColumn(name = "saison_id", nullable = false)
|
||||
private Saison saison;
|
||||
|
||||
@Column(name = "sport_easy_token")
|
||||
private String sportEasyToken;
|
||||
|
||||
@OneToMany(mappedBy = "categorie", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private List<CategorieEquipement> categorieEquipements = new ArrayList<>();
|
||||
|
||||
// Getters and Setters
|
||||
|
||||
public String getSportEasyToken() { return sportEasyToken; }
|
||||
public void setSportEasyToken(String sportEasyToken) { this.sportEasyToken = sportEasyToken; }
|
||||
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
|
||||
@@ -36,12 +36,6 @@ public class Dotation {
|
||||
@Column(nullable = false)
|
||||
private Boolean choisi = false;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Boolean commandee = false;
|
||||
|
||||
@Column(name = "date_commande")
|
||||
private java.time.LocalDateTime dateCommande;
|
||||
|
||||
// Getters and Setters
|
||||
|
||||
public Long getId() { return id; }
|
||||
@@ -70,113 +64,4 @@ public class Dotation {
|
||||
|
||||
public Boolean getChoisi() { return choisi; }
|
||||
public void setChoisi(Boolean choisi) { this.choisi = choisi; }
|
||||
|
||||
public Boolean getCommandee() { return commandee; }
|
||||
public void setCommandee(Boolean commandee) { this.commandee = commandee; }
|
||||
|
||||
public java.time.LocalDateTime getDateCommande() { return dateCommande; }
|
||||
public void setDateCommande(java.time.LocalDateTime dateCommande) { this.dateCommande = dateCommande; }
|
||||
|
||||
public static boolean isSizeMatch(String option, String adherentSize) {
|
||||
if (option == null || adherentSize == null) return false;
|
||||
String opt = option.trim();
|
||||
String adh = adherentSize.trim();
|
||||
if (opt.isEmpty() || adh.isEmpty()) return false;
|
||||
|
||||
if (opt.equalsIgnoreCase(adh)) return true;
|
||||
|
||||
String optNorm = opt.toLowerCase().replaceAll("\\s+", " ");
|
||||
String adhNorm = adh.toLowerCase().replaceAll("\\s+", " ");
|
||||
|
||||
if (optNorm.equals(adhNorm)) return true;
|
||||
|
||||
// 1. Age bracket matching: 5/6, 7/8, 9/10, 11/12, 13/14, 15/16
|
||||
java.util.regex.Pattern agePattern = java.util.regex.Pattern.compile("(?<!\\d)(5[/\\-]6|7[/\\-]8|9[/\\-]10|11[/\\-]12|13[/\\-]14|15[/\\-]16)(?!\\d)");
|
||||
java.util.regex.Matcher adhAgeMatcher = agePattern.matcher(adhNorm);
|
||||
java.util.regex.Matcher optAgeMatcher = agePattern.matcher(optNorm);
|
||||
boolean adhHasAge = adhAgeMatcher.find();
|
||||
boolean optHasAge = optAgeMatcher.find();
|
||||
|
||||
if (adhHasAge && optHasAge) {
|
||||
String adhAgeKey = adhAgeMatcher.group(1).replace("-", "/");
|
||||
String optAgeKey = optAgeMatcher.group(1).replace("-", "/");
|
||||
return adhAgeKey.equals(optAgeKey);
|
||||
} else if (adhHasAge) {
|
||||
String ageKey = adhAgeMatcher.group(1).replace("-", "/");
|
||||
String altAgeKey = ageKey.replace("/", "-");
|
||||
if (optNorm.contains(ageKey) || optNorm.contains(altAgeKey)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Height matching (3-digit numbers in cm, e.g. 115, 116, 126, 128, 138, 140, 150, 152, 162, 164, 176)
|
||||
java.util.regex.Pattern heightPattern = java.util.regex.Pattern.compile("(?<!\\d)(115|116|126|128|138|140|150|152|162|164|176)(?!\\d)");
|
||||
java.util.regex.Matcher adhHeightMatcher = heightPattern.matcher(adhNorm);
|
||||
java.util.regex.Matcher optHeightMatcher = heightPattern.matcher(optNorm);
|
||||
boolean adhHasHeight = adhHeightMatcher.find();
|
||||
boolean optHasHeight = optHeightMatcher.find();
|
||||
|
||||
if (adhHasHeight && optHasHeight) {
|
||||
int adhH = Integer.parseInt(adhHeightMatcher.group(1));
|
||||
int optH = Integer.parseInt(optHeightMatcher.group(1));
|
||||
return Math.abs(adhH - optH) <= 5;
|
||||
}
|
||||
|
||||
// 3. Shoe size / pointure matching: 27/30, 31/34, 35/38, 39/42, 43/46
|
||||
java.util.regex.Pattern shoePattern = java.util.regex.Pattern.compile("(?<!\\d)(27[/\\-]30|31[/\\-]34|35[/\\-]38|39[/\\-]42|43[/\\-]46)(?!\\d)");
|
||||
java.util.regex.Matcher adhShoeMatcher = shoePattern.matcher(adhNorm);
|
||||
java.util.regex.Matcher optShoeMatcher = shoePattern.matcher(optNorm);
|
||||
boolean adhHasShoe = adhShoeMatcher.find();
|
||||
boolean optHasShoe = optShoeMatcher.find();
|
||||
|
||||
if (adhHasShoe && optHasShoe) {
|
||||
String adhShoeKey = adhShoeMatcher.group(1).replace("-", "/");
|
||||
String optShoeKey = optShoeMatcher.group(1).replace("-", "/");
|
||||
return adhShoeKey.equals(optShoeKey);
|
||||
}
|
||||
|
||||
// 4. Sock size tag matching: "taille 0", "taille 1", "taille 2", "taille 3", "taille 4"
|
||||
java.util.regex.Pattern tNumPattern = java.util.regex.Pattern.compile("(?<![a-z0-9])taille\\s*([0-4])(?![0-9])");
|
||||
java.util.regex.Matcher adhTNumMatcher = tNumPattern.matcher(adhNorm);
|
||||
java.util.regex.Matcher optTNumMatcher = tNumPattern.matcher(optNorm);
|
||||
boolean adhHasTNum = adhTNumMatcher.find();
|
||||
boolean optHasTNum = optTNumMatcher.find();
|
||||
|
||||
if (adhHasTNum && optHasTNum) {
|
||||
return adhTNumMatcher.group(1).equals(optTNumMatcher.group(1));
|
||||
}
|
||||
|
||||
// 5. Letter size matching: XXL, XL, L, M, S, XS
|
||||
java.util.regex.Pattern letterPattern = java.util.regex.Pattern.compile("(?<![a-z0-9])(xxl|xl|l|m|s|xs)(?![a-z0-9])");
|
||||
java.util.regex.Matcher adhLetterMatcher = letterPattern.matcher(adhNorm);
|
||||
java.util.regex.Matcher optLetterMatcher = letterPattern.matcher(optNorm);
|
||||
boolean adhHasLetter = adhLetterMatcher.find();
|
||||
boolean optHasLetter = optLetterMatcher.find();
|
||||
|
||||
if (adhHasLetter && optHasLetter) {
|
||||
return adhLetterMatcher.group(1).equals(optLetterMatcher.group(1));
|
||||
}
|
||||
|
||||
// Substring fallback only if neither age, height, shoe, tag, nor letter pattern were present
|
||||
if (!adhHasAge && !optHasAge && !adhHasHeight && !optHasHeight && !adhHasShoe && !optHasShoe && !adhHasTNum && !optHasTNum && !adhHasLetter && !optHasLetter) {
|
||||
if (optNorm.length() >= 2 && adhNorm.contains(optNorm)) return true;
|
||||
if (adhNorm.length() >= 2 && optNorm.contains(adhNorm)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isTailleOptionSelected(String option) {
|
||||
if (option == null) return false;
|
||||
String trimmedOpt = option.trim();
|
||||
if (this.taille != null && !this.taille.trim().isEmpty()) {
|
||||
return this.taille.trim().equalsIgnoreCase(trimmedOpt);
|
||||
}
|
||||
if (this.licence == null || this.licence.getAdherent() == null) {
|
||||
return false;
|
||||
}
|
||||
Adherent adherent = this.licence.getAdherent();
|
||||
return isSizeMatch(trimmedOpt, adherent.getTailleVetement()) || isSizeMatch(trimmedOpt, adherent.getPointure());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,15 +33,6 @@ public class Equipement {
|
||||
private String couleursDisponibles;
|
||||
|
||||
|
||||
@Column(name = "has_flocage_prenom", nullable = false)
|
||||
private boolean hasFlocagePrenom = false;
|
||||
|
||||
@Column(name = "has_flocage_initiales", nullable = false)
|
||||
private boolean hasFlocageInitiales = false;
|
||||
|
||||
@Column(name = "has_flocage_numero", nullable = false)
|
||||
private boolean hasFlocageNumero = false;
|
||||
|
||||
@ManyToOne(optional = false, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "saison_id", nullable = false)
|
||||
private Saison saison;
|
||||
@@ -72,15 +63,6 @@ public class Equipement {
|
||||
public String getCouleursDisponibles() { return couleursDisponibles; }
|
||||
public void setCouleursDisponibles(String couleursDisponibles) { this.couleursDisponibles = couleursDisponibles; }
|
||||
|
||||
public boolean isHasFlocagePrenom() { return hasFlocagePrenom; }
|
||||
public void setHasFlocagePrenom(boolean hasFlocagePrenom) { this.hasFlocagePrenom = hasFlocagePrenom; }
|
||||
|
||||
public boolean isHasFlocageInitiales() { return hasFlocageInitiales; }
|
||||
public void setHasFlocageInitiales(boolean hasFlocageInitiales) { this.hasFlocageInitiales = hasFlocageInitiales; }
|
||||
|
||||
public boolean isHasFlocageNumero() { return hasFlocageNumero; }
|
||||
public void setHasFlocageNumero(boolean hasFlocageNumero) { this.hasFlocageNumero = hasFlocageNumero; }
|
||||
|
||||
public Saison getSaison() { return saison; }
|
||||
public void setSaison(Saison saison) { this.saison = saison; }
|
||||
}
|
||||
|
||||
@@ -41,30 +41,15 @@ public class Licence {
|
||||
@Column(name = "type_licence", length = 50)
|
||||
private String typeLicence;
|
||||
|
||||
@Column(columnDefinition = "TEXT")
|
||||
private String commentaire;
|
||||
|
||||
@Column(name = "sport_easy_email_sent", nullable = false)
|
||||
private Boolean sportEasyEmailSent = false;
|
||||
|
||||
@Column(name = "sport_easy_email_sent_at")
|
||||
private java.time.LocalDateTime sportEasyEmailSentAt;
|
||||
|
||||
@Column(name = "reduction_educateur", nullable = false)
|
||||
private Boolean reductionEducateur = false;
|
||||
|
||||
@Column(name = "pourcentage_reduction_educateur")
|
||||
private Integer pourcentageReductionEducateur = 100;
|
||||
|
||||
@OneToMany(mappedBy = "licence", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private List<Paiement> paiements = new ArrayList<>();
|
||||
|
||||
@OneToMany(mappedBy = "licence", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private List<Dotation> dotations = new ArrayList<>();
|
||||
|
||||
// Logic for Raw Price (before reduction)
|
||||
// Logic for Global Total Price
|
||||
@Transient
|
||||
public BigDecimal getPrixBrut() {
|
||||
public BigDecimal getPrixTotal() {
|
||||
if (categorie == null) return BigDecimal.ZERO;
|
||||
|
||||
BigDecimal prixTotal = (adherent != null && adherent.isResidentTalange())
|
||||
@@ -75,7 +60,7 @@ public class Licence {
|
||||
|
||||
if (dotations != null) {
|
||||
for (Dotation dot : dotations) {
|
||||
if (dot != null && Boolean.TRUE.equals(dot.getChoisi()) && dot.getEquipement() != null) {
|
||||
if (dot.getChoisi() && dot.getEquipement() != null) {
|
||||
BigDecimal price = categorie.getEquipementPrix(dot.getEquipement().getId());
|
||||
if (price != null) {
|
||||
prixTotal = prixTotal.add(price);
|
||||
@@ -87,50 +72,6 @@ public class Licence {
|
||||
return prixTotal;
|
||||
}
|
||||
|
||||
@Transient
|
||||
public BigDecimal getEquipementsContrib() {
|
||||
if (categorie == null) return BigDecimal.ZERO;
|
||||
BigDecimal tarifCategorie = (adherent != null && adherent.isResidentTalange())
|
||||
? categorie.getTarifBase()
|
||||
: categorie.getTarifExterieur();
|
||||
if (tarifCategorie == null) tarifCategorie = BigDecimal.ZERO;
|
||||
BigDecimal prixBrut = getPrixBrut();
|
||||
BigDecimal contrib = prixBrut.subtract(tarifCategorie);
|
||||
return contrib.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : contrib;
|
||||
}
|
||||
|
||||
// Logic for Global Total Price (after discount if applicable)
|
||||
@Transient
|
||||
public BigDecimal getPrixTotal() {
|
||||
BigDecimal prixBrut = getPrixBrut();
|
||||
|
||||
if (Boolean.TRUE.equals(reductionEducateur)) {
|
||||
int pct = (pourcentageReductionEducateur != null && pourcentageReductionEducateur >= 1 && pourcentageReductionEducateur <= 100)
|
||||
? pourcentageReductionEducateur
|
||||
: 100;
|
||||
|
||||
if (pct >= 100) {
|
||||
return BigDecimal.ZERO.setScale(2, java.math.RoundingMode.HALF_UP);
|
||||
} else {
|
||||
BigDecimal multiplier = BigDecimal.valueOf(100 - pct)
|
||||
.divide(BigDecimal.valueOf(100), 4, java.math.RoundingMode.HALF_UP);
|
||||
return prixBrut.multiply(multiplier).setScale(2, java.math.RoundingMode.HALF_UP);
|
||||
}
|
||||
}
|
||||
|
||||
return prixBrut.setScale(2, java.math.RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
@Transient
|
||||
public BigDecimal getMontantReduction() {
|
||||
if (!Boolean.TRUE.equals(reductionEducateur)) {
|
||||
return BigDecimal.ZERO.setScale(2, java.math.RoundingMode.HALF_UP);
|
||||
}
|
||||
BigDecimal prixBrut = getPrixBrut();
|
||||
BigDecimal prixTotal = getPrixTotal();
|
||||
return prixBrut.subtract(prixTotal).setScale(2, java.math.RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
// Logic for Reste A Payer
|
||||
@Transient
|
||||
public BigDecimal getResteAPayer() {
|
||||
@@ -187,29 +128,6 @@ public class Licence {
|
||||
public String getTypeLicence() { return typeLicence; }
|
||||
public void setTypeLicence(String typeLicence) { this.typeLicence = typeLicence; }
|
||||
|
||||
public String getCommentaire() { return commentaire; }
|
||||
public void setCommentaire(String commentaire) { this.commentaire = commentaire; }
|
||||
|
||||
public Boolean getSportEasyEmailSent() { return sportEasyEmailSent != null ? sportEasyEmailSent : false; }
|
||||
public void setSportEasyEmailSent(Boolean sportEasyEmailSent) { this.sportEasyEmailSent = sportEasyEmailSent; }
|
||||
|
||||
public java.time.LocalDateTime getSportEasyEmailSentAt() { return sportEasyEmailSentAt; }
|
||||
public void setSportEasyEmailSentAt(java.time.LocalDateTime sportEasyEmailSentAt) { this.sportEasyEmailSentAt = sportEasyEmailSentAt; }
|
||||
|
||||
public Boolean getReductionEducateur() { return reductionEducateur != null ? reductionEducateur : false; }
|
||||
public void setReductionEducateur(Boolean reductionEducateur) { this.reductionEducateur = reductionEducateur; }
|
||||
|
||||
public Integer getPourcentageReductionEducateur() { return pourcentageReductionEducateur != null ? pourcentageReductionEducateur : 100; }
|
||||
public void setPourcentageReductionEducateur(Integer pourcentageReductionEducateur) { this.pourcentageReductionEducateur = pourcentageReductionEducateur; }
|
||||
|
||||
@Transient
|
||||
public boolean isRenouvellement() {
|
||||
return typeDemande != null && (
|
||||
"Renouvellement".equalsIgnoreCase(typeDemande.trim()) ||
|
||||
"RENOUVELLEMENT".equalsIgnoreCase(typeDemande.trim())
|
||||
);
|
||||
}
|
||||
|
||||
public List<Paiement> getPaiements() { return paiements; }
|
||||
public void setPaiements(List<Paiement> paiements) { this.paiements = paiements; }
|
||||
|
||||
|
||||
@@ -64,18 +64,6 @@ public class PreInscription {
|
||||
@Column(name = "ancienne_categorie", length = 50)
|
||||
private String ancienneCategorie = "NA";
|
||||
|
||||
@Column(name = "raison_changement_club")
|
||||
private String raisonChangementClub;
|
||||
|
||||
@Column(name = "comment_connu_club")
|
||||
private String commentConnuClub;
|
||||
|
||||
@Column(name = "taille_vetement", length = 50)
|
||||
private String tailleVetement;
|
||||
|
||||
@Column(length = 50)
|
||||
private String pointure;
|
||||
|
||||
// Getters and Setters
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
@@ -130,16 +118,4 @@ public class PreInscription {
|
||||
|
||||
public String getAncienneCategorie() { return ancienneCategorie; }
|
||||
public void setAncienneCategorie(String ancienneCategorie) { this.ancienneCategorie = ancienneCategorie; }
|
||||
|
||||
public String getRaisonChangementClub() { return raisonChangementClub; }
|
||||
public void setRaisonChangementClub(String raisonChangementClub) { this.raisonChangementClub = raisonChangementClub; }
|
||||
|
||||
public String getCommentConnuClub() { return commentConnuClub; }
|
||||
public void setCommentConnuClub(String commentConnuClub) { this.commentConnuClub = commentConnuClub; }
|
||||
|
||||
public String getTailleVetement() { return tailleVetement; }
|
||||
public void setTailleVetement(String tailleVetement) { this.tailleVetement = tailleVetement; }
|
||||
|
||||
public String getPointure() { return pointure; }
|
||||
public void setPointure(String pointure) { this.pointure = pointure; }
|
||||
}
|
||||
|
||||
@@ -11,5 +11,4 @@ import com.astalange.core.entity.Saison;
|
||||
@Repository
|
||||
public interface DotationRepository extends JpaRepository<Dotation, Long>, JpaSpecificationExecutor<Dotation> {
|
||||
List<Dotation> findByLicence_SaisonAndChoisiTrueAndFourniFalse(Saison saison);
|
||||
List<Dotation> findByLicence_SaisonAndChoisiTrueAndCommandeeFalse(Saison saison);
|
||||
}
|
||||
|
||||
@@ -14,10 +14,6 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
public interface LicenceRepository extends JpaRepository<Licence, Long>, JpaSpecificationExecutor<Licence> {
|
||||
List<Licence> findByAdherentId(Long adherentId);
|
||||
|
||||
java.util.Optional<Licence> findByAdherentIdAndSaison(Long adherentId, com.astalange.core.entity.Saison saison);
|
||||
|
||||
List<Licence> findBySaison(com.astalange.core.entity.Saison saison);
|
||||
|
||||
List<Licence> findBySaisonAndCategorie(com.astalange.core.entity.Saison saison, com.astalange.core.entity.Categorie categorie);
|
||||
|
||||
long countByEtat(String etat);
|
||||
|
||||
@@ -16,17 +16,7 @@ public interface PaiementRepository extends JpaRepository<Paiement, Long> {
|
||||
"LEFT JOIN FETCH p.licence l " +
|
||||
"LEFT JOIN FETCH l.adherent a " +
|
||||
"LEFT JOIN FETCH l.categorie c " +
|
||||
"LEFT JOIN FETCH l.saison s " +
|
||||
"LEFT JOIN FETCH p.modePaiement m " +
|
||||
"ORDER BY p.datePaiement DESC, p.id DESC")
|
||||
java.util.List<Paiement> findAllWithAssociations();
|
||||
|
||||
@Query("SELECT p FROM Paiement p " +
|
||||
"LEFT JOIN FETCH p.licence l " +
|
||||
"LEFT JOIN FETCH l.adherent a " +
|
||||
"LEFT JOIN FETCH l.categorie c " +
|
||||
"LEFT JOIN FETCH l.saison s " +
|
||||
"LEFT JOIN FETCH p.modePaiement m " +
|
||||
"WHERE p.id = :id")
|
||||
java.util.Optional<Paiement> findByIdWithDetails(@org.springframework.data.repository.query.Param("id") Long id);
|
||||
}
|
||||
|
||||
-79
@@ -1,79 +0,0 @@
|
||||
package com.astalange.core.security;
|
||||
|
||||
import com.astalange.core.entity.AppUser;
|
||||
import com.astalange.core.repository.AppUserRepository;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
|
||||
import org.springframework.security.authentication.event.LogoutSuccessEvent;
|
||||
import org.springframework.security.core.context.SecurityContext;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.web.session.HttpSessionDestroyedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class AuthenticationEventListener {
|
||||
|
||||
private final AppUserRepository userRepository;
|
||||
|
||||
public AuthenticationEventListener(AppUserRepository userRepository) {
|
||||
this.userRepository = userRepository;
|
||||
}
|
||||
|
||||
@EventListener
|
||||
@Transactional
|
||||
public void onAuthenticationSuccess(AuthenticationSuccessEvent event) {
|
||||
String username = extractUsername(event.getAuthentication().getPrincipal());
|
||||
if (username != null) {
|
||||
userRepository.findByUsername(username).ifPresent(user -> {
|
||||
user.setLastLoginAt(LocalDateTime.now());
|
||||
userRepository.save(user);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventListener
|
||||
@Transactional
|
||||
public void onLogoutSuccess(LogoutSuccessEvent event) {
|
||||
if (event.getAuthentication() != null) {
|
||||
String username = extractUsername(event.getAuthentication().getPrincipal());
|
||||
if (username != null) {
|
||||
userRepository.findByUsername(username).ifPresent(user -> {
|
||||
user.setLastLogoutAt(LocalDateTime.now());
|
||||
userRepository.save(user);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventListener
|
||||
@Transactional
|
||||
public void onSessionDestroyed(HttpSessionDestroyedEvent event) {
|
||||
List<SecurityContext> contexts = event.getSecurityContexts();
|
||||
for (SecurityContext context : contexts) {
|
||||
if (context != null && context.getAuthentication() != null) {
|
||||
String username = extractUsername(context.getAuthentication().getPrincipal());
|
||||
if (username != null) {
|
||||
userRepository.findByUsername(username).ifPresent(user -> {
|
||||
if (user.getLastLogoutAt() == null || (user.getLastLoginAt() != null && user.getLastLogoutAt().isBefore(user.getLastLoginAt()))) {
|
||||
user.setLastLogoutAt(LocalDateTime.now());
|
||||
userRepository.save(user);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String extractUsername(Object principal) {
|
||||
if (principal instanceof UserDetails) {
|
||||
return ((UserDetails) principal).getUsername();
|
||||
} else if (principal instanceof String) {
|
||||
return (String) principal;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -123,23 +123,6 @@ public class CategorieService {
|
||||
continue;
|
||||
}
|
||||
|
||||
String matchedTaille = "";
|
||||
if (licence.getAdherent() != null) {
|
||||
String taillesDispo = ce.getEquipement().getTaillesDisponibles();
|
||||
if (taillesDispo != null && !taillesDispo.trim().isEmpty()) {
|
||||
String[] dispos = taillesDispo.split(",");
|
||||
String tv = licence.getAdherent().getTailleVetement();
|
||||
String pt = licence.getAdherent().getPointure();
|
||||
for (String t : dispos) {
|
||||
String trimmed = t.trim();
|
||||
if (Dotation.isSizeMatch(trimmed, tv) || Dotation.isSizeMatch(trimmed, pt)) {
|
||||
matchedTaille = trimmed;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean found = false;
|
||||
for (Dotation d : currentDotations) {
|
||||
if (ce.getEquipement().getId().equals(d.getEquipement().getId())) {
|
||||
@@ -147,9 +130,6 @@ public class CategorieService {
|
||||
if (Boolean.TRUE.equals(ce.getObligatoire()) && !Boolean.TRUE.equals(d.getChoisi())) {
|
||||
d.setChoisi(true);
|
||||
}
|
||||
if ((d.getTaille() == null || d.getTaille().trim().isEmpty()) && !matchedTaille.isEmpty()) {
|
||||
d.setTaille(matchedTaille);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -166,21 +146,10 @@ public class CategorieService {
|
||||
}
|
||||
newDotation.setChoisi(ce.getObligatoire() || (isMaillot && isNouvelle)); // Checked if obligatoire or if it's a new registration
|
||||
newDotation.setFourni(false);
|
||||
newDotation.setTaille(matchedTaille);
|
||||
newDotation.setTaille("");
|
||||
newDotation.setNumero("");
|
||||
if (licence.getAdherent() != null) {
|
||||
String defaultFlocage = "";
|
||||
if (ce.getEquipement().isHasFlocagePrenom() && ce.getEquipement().isHasFlocageInitiales()) {
|
||||
String firstInitial = licence.getAdherent().getNom() != null && !licence.getAdherent().getNom().isEmpty() ? licence.getAdherent().getNom().substring(0, 1).toUpperCase() + "." : "";
|
||||
defaultFlocage = (licence.getAdherent().getPrenom() != null ? licence.getAdherent().getPrenom() + " " : "") + firstInitial;
|
||||
} else if (ce.getEquipement().isHasFlocagePrenom()) {
|
||||
defaultFlocage = licence.getAdherent().getPrenom() != null ? licence.getAdherent().getPrenom() : "";
|
||||
} else if (ce.getEquipement().isHasFlocageInitiales()) {
|
||||
String firstInitP = licence.getAdherent().getPrenom() != null && !licence.getAdherent().getPrenom().isEmpty() ? licence.getAdherent().getPrenom().substring(0, 1).toUpperCase() : "";
|
||||
String firstInitN = licence.getAdherent().getNom() != null && !licence.getAdherent().getNom().isEmpty() ? licence.getAdherent().getNom().substring(0, 1).toUpperCase() : "";
|
||||
defaultFlocage = firstInitP + firstInitN;
|
||||
}
|
||||
newDotation.setFlocage(defaultFlocage.trim());
|
||||
newDotation.setFlocage(licence.getAdherent().getNom().toUpperCase() + " " + licence.getAdherent().getPrenom());
|
||||
}
|
||||
currentDotations.add(newDotation);
|
||||
}
|
||||
@@ -188,37 +157,4 @@ public class CategorieService {
|
||||
|
||||
licenceRepository.save(licence);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Categorie duplicateCategorie(Long id) {
|
||||
Categorie existing = categorieRepository.findById(id)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Invalid category ID: " + id));
|
||||
|
||||
Categorie duplicated = new Categorie();
|
||||
// Appending ' (dupliqué)' and truncating if necessary since nom is max 20 chars
|
||||
String newNom = existing.getNom() + " (dupliqué)";
|
||||
if (newNom.length() > 20) {
|
||||
newNom = newNom.substring(0, 20);
|
||||
}
|
||||
duplicated.setNom(newNom);
|
||||
duplicated.setSexe(existing.getSexe());
|
||||
duplicated.setAnneeMin(existing.getAnneeMin());
|
||||
duplicated.setAnneeMax(existing.getAnneeMax());
|
||||
duplicated.setTarifBase(existing.getTarifBase());
|
||||
duplicated.setTarifExterieur(existing.getTarifExterieur());
|
||||
duplicated.setSaison(existing.getSaison());
|
||||
|
||||
List<CategorieEquipement> nouveauxEquipements = new ArrayList<>();
|
||||
for (CategorieEquipement ce : existing.getCategorieEquipements()) {
|
||||
CategorieEquipement newCe = new CategorieEquipement();
|
||||
newCe.setCategorie(duplicated);
|
||||
newCe.setEquipement(ce.getEquipement());
|
||||
newCe.setObligatoire(ce.getObligatoire());
|
||||
newCe.setPrix(ce.getPrix() != null ? ce.getPrix() : java.math.BigDecimal.ZERO);
|
||||
nouveauxEquipements.add(newCe);
|
||||
}
|
||||
duplicated.getCategorieEquipements().addAll(nouveauxEquipements);
|
||||
|
||||
return categorieRepository.save(duplicated);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,70 +4,50 @@ import com.astalange.core.entity.Dotation;
|
||||
import com.astalange.core.entity.Saison;
|
||||
import com.astalange.core.repository.DotationRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class DotationService {
|
||||
|
||||
private final DotationRepository dotationRepository;
|
||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
|
||||
|
||||
public DotationService(DotationRepository dotationRepository) {
|
||||
this.dotationRepository = dotationRepository;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public String genererCsvCommandeEquipement(Saison saisonActive) {
|
||||
return genererCsvCommandeEquipementGrouped(saisonActive, true);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public String genererCsvCommandeEquipementGrouped(Saison saisonActive, boolean markAsCommandee) {
|
||||
List<Dotation> dotations = dotationRepository.findByLicence_SaisonAndChoisiTrueAndCommandeeFalse(saisonActive);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
String dateCommandeFormatted = now.format(DATE_FORMATTER);
|
||||
|
||||
Map<String, Integer> groupCountMap = new LinkedHashMap<>();
|
||||
|
||||
for (Dotation d : dotations) {
|
||||
String equipement = d.getEquipement() != null ? d.getEquipement().getNom() : "Inconnu";
|
||||
String reference = d.getEquipement() != null && d.getEquipement().getReference() != null ? d.getEquipement().getReference() : "";
|
||||
String taille = d.getTaille() != null && !d.getTaille().trim().isEmpty() ? d.getTaille() : "Non renseignée";
|
||||
|
||||
String key = equipement + "|||" + reference + "|||" + taille;
|
||||
groupCountMap.put(key, groupCountMap.getOrDefault(key, 0) + 1);
|
||||
|
||||
if (markAsCommandee) {
|
||||
d.setCommandee(true);
|
||||
d.setDateCommande(now);
|
||||
dotationRepository.save(d);
|
||||
}
|
||||
}
|
||||
List<Dotation> dotations = dotationRepository.findByLicence_SaisonAndChoisiTrueAndFourniFalse(saisonActive);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// BOM for Excel to open UTF-8 correctly
|
||||
sb.append('\ufeff');
|
||||
|
||||
|
||||
// Header
|
||||
sb.append("Équipement;Référence;Taille;Quantité;Commandé;Date de Commande\n");
|
||||
sb.append("Catégorie;Nom;Prénom;Poste;Sexe;Équipement;Référence;Taille;Flocage;Numéro\n");
|
||||
|
||||
for (Map.Entry<String, Integer> entry : groupCountMap.entrySet()) {
|
||||
String[] parts = entry.getKey().split("\\|\\|\\|", -1);
|
||||
String equipement = parts[0];
|
||||
String reference = parts[1];
|
||||
String taille = parts[2];
|
||||
int quantite = entry.getValue();
|
||||
for (Dotation d : dotations) {
|
||||
String categorie = d.getLicence().getCategorie() != null ? d.getLicence().getCategorie().getNom() : "";
|
||||
String nom = d.getLicence().getAdherent().getNom();
|
||||
String prenom = d.getLicence().getAdherent().getPrenom();
|
||||
String poste = d.getLicence().getAdherent().getTypeMaillot() != null ? d.getLicence().getAdherent().getTypeMaillot() : "";
|
||||
String sexe = d.getLicence().getAdherent().getSexe() != null ? d.getLicence().getAdherent().getSexe() : "";
|
||||
String equipement = d.getEquipement() != null ? d.getEquipement().getNom() : "";
|
||||
String reference = d.getEquipement() != null && d.getEquipement().getReference() != null ? d.getEquipement().getReference() : "";
|
||||
String taille = d.getTaille() != null ? d.getTaille() : "";
|
||||
String flocage = d.getFlocage() != null ? d.getFlocage() : "";
|
||||
String numero = d.getNumero() != null ? d.getNumero() : "";
|
||||
|
||||
sb.append(escapeCsv(equipement)).append(";")
|
||||
sb.append(escapeCsv(categorie)).append(";")
|
||||
.append(escapeCsv(nom)).append(";")
|
||||
.append(escapeCsv(prenom)).append(";")
|
||||
.append(escapeCsv(poste)).append(";")
|
||||
.append(escapeCsv(sexe)).append(";")
|
||||
.append(escapeCsv(equipement)).append(";")
|
||||
.append(escapeCsv(reference)).append(";")
|
||||
.append(escapeCsv(taille)).append(";")
|
||||
.append(quantite).append(";")
|
||||
.append("Oui").append(";")
|
||||
.append(escapeCsv(dateCommandeFormatted)).append("\n");
|
||||
.append(escapeCsv(flocage)).append(";")
|
||||
.append(escapeCsv(numero)).append("\n");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
@@ -77,9 +57,9 @@ public class DotationService {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// BOM for Excel to open UTF-8 correctly
|
||||
sb.append('\ufeff');
|
||||
|
||||
|
||||
// Header
|
||||
sb.append("Saison;Catégorie;Nom;Prénom;Poste;Sexe;Équipement;Référence;Taille;Flocage;Numéro;Fourni;Commandé;Date Commande\n");
|
||||
sb.append("Saison;Catégorie;Nom;Prénom;Poste;Sexe;Équipement;Référence;Taille;Flocage;Numéro;Fourni\n");
|
||||
|
||||
for (Dotation d : dotations) {
|
||||
String saison = d.getLicence().getSaison() != null ? d.getLicence().getSaison().getNom() : "";
|
||||
@@ -94,8 +74,6 @@ public class DotationService {
|
||||
String flocage = d.getFlocage() != null ? d.getFlocage() : "";
|
||||
String numero = d.getNumero() != null ? d.getNumero() : "";
|
||||
String fourni = Boolean.TRUE.equals(d.getFourni()) ? "Oui" : "Non";
|
||||
String commandee = Boolean.TRUE.equals(d.getCommandee()) ? "Oui" : "Non";
|
||||
String dateCommande = d.getDateCommande() != null ? d.getDateCommande().format(DATE_FORMATTER) : "";
|
||||
|
||||
sb.append(escapeCsv(saison)).append(";")
|
||||
.append(escapeCsv(categorie)).append(";")
|
||||
@@ -108,9 +86,7 @@ public class DotationService {
|
||||
.append(escapeCsv(taille)).append(";")
|
||||
.append(escapeCsv(flocage)).append(";")
|
||||
.append(escapeCsv(numero)).append(";")
|
||||
.append(escapeCsv(fourni)).append(";")
|
||||
.append(escapeCsv(commandee)).append(";")
|
||||
.append(escapeCsv(dateCommande)).append("\n");
|
||||
.append(escapeCsv(fourni)).append("\n");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
|
||||
@@ -1,274 +0,0 @@
|
||||
package com.astalange.core.service;
|
||||
|
||||
import com.astalange.core.entity.Licence;
|
||||
import com.astalange.core.entity.Paiement;
|
||||
import com.astalange.core.repository.PaiementRepository;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Locale;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Service
|
||||
public class PaiementEmailService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PaiementEmailService.class);
|
||||
|
||||
private final JavaMailSender mailSender;
|
||||
private final PaiementRepository paiementRepository;
|
||||
|
||||
@Value("${app.mail.from:${spring.mail.username:astalange1933@gmail.com}}")
|
||||
private String fromEmail = "astalange1933@gmail.com";
|
||||
|
||||
public PaiementEmailService(@Autowired(required = false) JavaMailSender mailSender,
|
||||
PaiementRepository paiementRepository) {
|
||||
this.mailSender = mailSender;
|
||||
this.paiementRepository = paiementRepository;
|
||||
}
|
||||
|
||||
private String getEffectiveFromEmail() {
|
||||
if (fromEmail != null && !fromEmail.trim().isEmpty() && fromEmail.contains("@")) {
|
||||
return fromEmail.trim();
|
||||
}
|
||||
return "astalange1933@gmail.com";
|
||||
}
|
||||
|
||||
public void sendPaiementConfirmationAsync(Long paiementId) {
|
||||
if (paiementId == null) {
|
||||
log.warn("Impossible d'envoyer l'e-mail de confirmation : ID de paiement nul.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Paiement paiement = paiementRepository.findByIdWithDetails(paiementId)
|
||||
.orElseGet(() -> paiementRepository.findById(paiementId).orElse(null));
|
||||
if (paiement == null) {
|
||||
log.warn("Impossible d'envoyer un e-mail de confirmation : paiement ID {} introuvable en base.", paiementId);
|
||||
return;
|
||||
}
|
||||
sendPaiementConfirmation(paiement);
|
||||
} catch (Exception e) {
|
||||
log.error("Erreur lors de l'envoi de l'e-mail de confirmation pour le paiement ID {}: ", paiementId, e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean sendPaiementConfirmation(Paiement paiement) {
|
||||
log.info(">>> [PaiementEmailService] Traitement de la confirmation de paiement pour le paiement ID: {}",
|
||||
paiement != null ? paiement.getId() : null);
|
||||
if (paiement == null || paiement.getLicence() == null) {
|
||||
log.warn("Impossible d'envoyer un e-mail de confirmation : paiement ou licence nulle.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Licence licence = paiement.getLicence();
|
||||
String recipientEmail = licence.getAdherent() != null ? licence.getAdherent().getEmail() : null;
|
||||
log.info(">>> [PaiementEmailService] Adhérent: {} {}, Email: {}",
|
||||
licence.getAdherent() != null ? licence.getAdherent().getPrenom() : "?",
|
||||
licence.getAdherent() != null ? licence.getAdherent().getNom() : "?",
|
||||
recipientEmail);
|
||||
|
||||
if (recipientEmail == null || recipientEmail.trim().isEmpty()) {
|
||||
log.info("Aucune adresse e-mail renseignée pour l'adhérent de la licence ID {}. E-mail non envoyé.", licence.getId());
|
||||
return false;
|
||||
}
|
||||
|
||||
BigDecimal resteAPayer = licence.getResteAPayer();
|
||||
boolean estTotalite = resteAPayer.compareTo(BigDecimal.ZERO) <= 0;
|
||||
|
||||
String adherentNom = licence.getAdherent() != null
|
||||
? licence.getAdherent().getPrenom() + " " + licence.getAdherent().getNom()
|
||||
: "Adhérent";
|
||||
String categorieNom = licence.getCategorie() != null ? licence.getCategorie().getNom() : "AS Talange";
|
||||
String saisonNom = licence.getSaison() != null ? licence.getSaison().getNom() : "";
|
||||
|
||||
String subject = estTotalite
|
||||
? "AS Talange - Confirmation de paiement (Solde intégralement réglé)"
|
||||
: "AS Talange - Confirmation de paiement partiel";
|
||||
|
||||
String htmlContent = buildEmailHtml(paiement, licence, adherentNom, categorieNom, saisonNom, estTotalite, resteAPayer);
|
||||
BigDecimal montantPaiement = paiement.getMontant();
|
||||
|
||||
// Envoi asynchrone via CompletableFuture pour ne pas bloquer la réponse HTTP
|
||||
CompletableFuture.runAsync(() -> {
|
||||
if (mailSender != null) {
|
||||
try {
|
||||
MimeMessage message = mailSender.createMimeMessage();
|
||||
MimeMessageHelper helper = new MimeMessageHelper(message, true, "UTF-8");
|
||||
helper.setFrom(getEffectiveFromEmail());
|
||||
helper.setTo(recipientEmail);
|
||||
helper.setSubject(subject);
|
||||
helper.setText(htmlContent, true);
|
||||
|
||||
mailSender.send(message);
|
||||
log.info("E-mail de confirmation de paiement envoyé avec succès via SMTP à {} (Montant: {} €)", recipientEmail, montantPaiement);
|
||||
} catch (Exception e) {
|
||||
log.warn("Impossible d'envoyer l'e-mail de paiement via SMTP pour {}: {}. Simulation en mode log.", recipientEmail, e.getMessage());
|
||||
logDevEmail(recipientEmail, subject, htmlContent);
|
||||
}
|
||||
} else {
|
||||
log.info("Aucun JavaMailSender configuré (Mode DEV). Simulation de l'envoi d'e-mail de paiement.");
|
||||
logDevEmail(recipientEmail, subject, htmlContent);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void logDevEmail(String recipient, String subject, String body) {
|
||||
log.info("==================== [SIMULATION E-MAIL PAIEMENT] ====================");
|
||||
log.info("Destinataire: {}", recipient);
|
||||
log.info("Sujet: {}", subject);
|
||||
log.info("Contenu:\n{}", body);
|
||||
log.info("======================================================================");
|
||||
}
|
||||
|
||||
private String buildEmailHtml(Paiement paiement, Licence licence, String adherentNom,
|
||||
String categorieNom, String saisonNom,
|
||||
boolean estTotalite, BigDecimal resteAPayer) {
|
||||
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
|
||||
String datePaiementStr = paiement.getDatePaiement() != null
|
||||
? paiement.getDatePaiement().format(dateFormatter)
|
||||
: "";
|
||||
|
||||
String montantStr = String.format(Locale.FRANCE, "%.2f €", paiement.getMontant());
|
||||
String prixTotalStr = String.format(Locale.FRANCE, "%.2f €", licence.getPrixTotal());
|
||||
String totalPayeStr = String.format(Locale.FRANCE, "%.2f €", licence.getSommePayee());
|
||||
String resteStr = String.format(Locale.FRANCE, "%.2f €", resteAPayer);
|
||||
|
||||
String modePaiementStr = paiement.getModePaiement() != null ? paiement.getModePaiement().getNom() : "-";
|
||||
if (paiement.getNumeroCheque() != null && !paiement.getNumeroCheque().isBlank()) {
|
||||
modePaiementStr += " (N° " + paiement.getNumeroCheque() + ")";
|
||||
}
|
||||
|
||||
String headerTitle = estTotalite ? "Confirmation de paiement intégral" : "Confirmation de paiement partiel";
|
||||
|
||||
String messageParagraph;
|
||||
if (estTotalite) {
|
||||
messageParagraph = """
|
||||
<p>Nous vous confirmons la bonne réception de votre versement de <strong>%s</strong> effectué le <strong>%s</strong> par <strong>%s</strong>.</p>
|
||||
<div class="alert alert-success">
|
||||
<strong>Paiement solde :</strong> Le paiement de votre cotisation pour la saison <strong>%s</strong> (catégorie <strong>%s</strong>) a été pris en compte et est désormais <strong>entièrement réglé</strong>.
|
||||
</div>
|
||||
""".formatted(montantStr, datePaiementStr, modePaiementStr, saisonNom, categorieNom);
|
||||
} else {
|
||||
messageParagraph = """
|
||||
<p>Nous vous confirmons la bonne réception de votre versement partiel de <strong>%s</strong> effectué le <strong>%s</strong> par <strong>%s</strong>.</p>
|
||||
<p>Ce paiement a bien été pris en compte pour la cotisation de la saison <strong>%s</strong> (catégorie <strong>%s</strong>).</p>
|
||||
<div class="alert alert-warning">
|
||||
<strong>Information Solde :</strong> Il reste actuellement la somme de <strong>%s</strong> à régler.
|
||||
</div>
|
||||
""".formatted(montantStr, datePaiementStr, modePaiementStr, saisonNom, categorieNom, resteStr);
|
||||
}
|
||||
|
||||
String soldeBadge = estTotalite
|
||||
? "<span class=\"badge badge-success\">0,00 € (Réglé)</span>"
|
||||
: "<span class=\"badge badge-warning\">" + resteStr + "</span>";
|
||||
|
||||
return """
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<style>
|
||||
body { font-family: Arial, sans-serif; background-color: #f4f6f8; margin: 0; padding: 20px; color: #333; }
|
||||
.container { max-width: 600px; margin: 0 auto; background: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
|
||||
.header { background-color: #1e3a8a; color: #ffffff; padding: 24px; text-align: center; }
|
||||
.header h1 { margin: 0; font-size: 22px; }
|
||||
.content { padding: 24px; line-height: 1.6; }
|
||||
.alert { padding: 14px 18px; border-radius: 6px; margin: 18px 0; font-size: 14px; }
|
||||
.alert-success { background-color: #d1fae5; border-left: 4px solid #10b981; color: #065f46; }
|
||||
.alert-warning { background-color: #fef3c7; border-left: 4px solid #f59e0b; color: #92400e; }
|
||||
.receipt-box { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; padding: 16px; margin-top: 20px; }
|
||||
.receipt-box h3 { margin-top: 0; margin-bottom: 12px; font-size: 16px; color: #1e3a8a; border-bottom: 1px solid #e5e7eb; padding-bottom: 8px; }
|
||||
.receipt-table { width: 100%%; border-collapse: collapse; font-size: 14px; }
|
||||
.receipt-table td { padding: 6px 0; }
|
||||
.receipt-table td.label { color: #6b7280; width: 50%%; }
|
||||
.receipt-table td.value { font-weight: bold; text-align: right; }
|
||||
.badge { display: inline-block; padding: 4px 10px; border-radius: 12px; font-weight: bold; font-size: 13px; }
|
||||
.badge-success { background-color: #d1fae5; color: #065f46; }
|
||||
.badge-warning { background-color: #fef3c7; color: #92400e; }
|
||||
.footer { background: #f9fafb; border-top: 1px solid #e5e7eb; padding: 16px; text-align: center; font-size: 12px; color: #6b7280; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>AS Talange - %s</h1>
|
||||
</div>
|
||||
<div class="content">
|
||||
<p>Bonjour <strong>%s</strong>,</p>
|
||||
|
||||
%s
|
||||
|
||||
<div class="receipt-box">
|
||||
<h3>Reçu de Paiement</h3>
|
||||
<table class="receipt-table">
|
||||
<tr>
|
||||
<td class="label">Adhérent :</td>
|
||||
<td class="value">%s</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Saison / Catégorie :</td>
|
||||
<td class="value">%s %s</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Date du paiement :</td>
|
||||
<td class="value">%s</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Montant versé :</td>
|
||||
<td class="value">%s</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Mode de règlement :</td>
|
||||
<td class="value">%s</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Montant total cotisation :</td>
|
||||
<td class="value">%s</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Total versé à ce jour :</td>
|
||||
<td class="value">%s</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Reste à payer :</td>
|
||||
<td class="value">%s</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<p style="margin-top: 20px;">Ce courriel vous sert de justificatif de paiement.<br>Sportivement,<br><strong>L'équipe de l'AS Talange</strong></p>
|
||||
</div>
|
||||
<div class="footer">
|
||||
Cet e-mail a été envoyé automatiquement par le système de gestion de l'AS Talange.
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
""".formatted(
|
||||
headerTitle,
|
||||
adherentNom,
|
||||
messageParagraph,
|
||||
adherentNom,
|
||||
saisonNom,
|
||||
categorieNom,
|
||||
datePaiementStr,
|
||||
montantStr,
|
||||
modePaiementStr,
|
||||
prixTotalStr,
|
||||
totalPayeStr,
|
||||
soldeBadge
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -48,10 +48,6 @@ public class PreInscriptionService {
|
||||
adherent.setAncienClub(pre.getAncienClub());
|
||||
adherent.setAncienneCategorie(pre.getAncienneCategorie());
|
||||
adherent.setSexe(pre.getSexe());
|
||||
adherent.setRaisonChangementClub(pre.getRaisonChangementClub());
|
||||
adherent.setCommentConnuClub(pre.getCommentConnuClub());
|
||||
adherent.setTailleVetement(pre.getTailleVetement());
|
||||
adherent.setPointure(pre.getPointure());
|
||||
// Par défaut
|
||||
adherent.setTypeMaillot("JOUEUR");
|
||||
adherent.setResidentTalange(false);
|
||||
|
||||
@@ -1,252 +0,0 @@
|
||||
package com.astalange.core.service;
|
||||
|
||||
import com.astalange.core.entity.Licence;
|
||||
import com.astalange.core.entity.Saison;
|
||||
import com.astalange.core.repository.LicenceRepository;
|
||||
import com.astalange.core.repository.SaisonRepository;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SportEasyEmailService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SportEasyEmailService.class);
|
||||
|
||||
private final LicenceRepository licenceRepository;
|
||||
private final SaisonRepository saisonRepository;
|
||||
private final JavaMailSender mailSender;
|
||||
|
||||
@Value("${sporteasy.base-url:https://www.sporteasy.net/join/}")
|
||||
private String sportEasyBaseUrl;
|
||||
|
||||
@Value("${app.mail.from:${spring.mail.username:astalange1933@gmail.com}}")
|
||||
private String fromEmail;
|
||||
|
||||
public SportEasyEmailService(LicenceRepository licenceRepository,
|
||||
SaisonRepository saisonRepository,
|
||||
@Autowired(required = false) JavaMailSender mailSender) {
|
||||
this.licenceRepository = licenceRepository;
|
||||
this.saisonRepository = saisonRepository;
|
||||
this.mailSender = mailSender;
|
||||
}
|
||||
|
||||
private String getEffectiveFromEmail() {
|
||||
if (fromEmail != null && !fromEmail.trim().isEmpty() && fromEmail.contains("@")) {
|
||||
return fromEmail.trim();
|
||||
}
|
||||
return "astalange1933@gmail.com";
|
||||
}
|
||||
|
||||
public record BatchSendResult(int sentCount, int skippedCount, int errorCount, String message) {}
|
||||
|
||||
public void sendInvitationForLicenceAsync(Long licenceId) {
|
||||
if (licenceId == null) {
|
||||
log.warn("Impossible d'envoyer l'invitation SportEasy : ID de licence nul.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
sendInvitationForLicence(licenceId, true);
|
||||
} catch (Exception e) {
|
||||
log.error("Erreur lors de l'envoi asynchrone de l'invitation SportEasy pour la licence ID {}: ", licenceId, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public boolean sendInvitationForLicence(Long licenceId, boolean forceResend) {
|
||||
Licence licence = licenceRepository.findById(licenceId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Licence introuvable avec l'ID: " + licenceId));
|
||||
|
||||
if (licence.isRenouvellement()) {
|
||||
log.info("Invitation SportEasy non envoyée pour la licence ID {} : il s'agit d'un renouvellement.", licenceId);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!forceResend && Boolean.TRUE.equals(licence.getSportEasyEmailSent())) {
|
||||
log.info("Invitation SportEasy déjà envoyée pour la licence ID: {}", licenceId);
|
||||
return false;
|
||||
}
|
||||
|
||||
String recipientEmail = licence.getAdherent() != null ? licence.getAdherent().getEmail() : null;
|
||||
if (recipientEmail == null || recipientEmail.trim().isEmpty()) {
|
||||
throw new IllegalStateException("L'adhérent n'a pas d'adresse e-mail renseignée.");
|
||||
}
|
||||
|
||||
String token = (licence.getCategorie() != null && licence.getCategorie().getSportEasyToken() != null)
|
||||
? licence.getCategorie().getSportEasyToken().trim()
|
||||
: "";
|
||||
|
||||
if (token.isEmpty()) {
|
||||
throw new IllegalStateException("Le lien d'invitation SportEasy n'a pas été renseigné pour la catégorie "
|
||||
+ (licence.getCategorie() != null ? licence.getCategorie().getNom() : "") + ".");
|
||||
}
|
||||
|
||||
String inviteUrl;
|
||||
if (token.startsWith("http://") || token.startsWith("https://")) {
|
||||
inviteUrl = token;
|
||||
} else {
|
||||
inviteUrl = sportEasyBaseUrl.endsWith("/") ? sportEasyBaseUrl + token : sportEasyBaseUrl + "/" + token;
|
||||
}
|
||||
|
||||
String adherentNom = licence.getAdherent().getPrenom() + " " + licence.getAdherent().getNom();
|
||||
String categorieNom = licence.getCategorie() != null ? licence.getCategorie().getNom() : "AS Talange";
|
||||
String saisonNom = licence.getSaison() != null ? licence.getSaison().getNom() : "";
|
||||
|
||||
String subject = "AS Talange - Invitation SportEasy (" + categorieNom + ")";
|
||||
String htmlContent = buildEmailHtml(adherentNom, categorieNom, saisonNom, inviteUrl);
|
||||
|
||||
licence.setSportEasyEmailSent(true);
|
||||
licence.setSportEasyEmailSentAt(LocalDateTime.now());
|
||||
licenceRepository.save(licence);
|
||||
|
||||
// Envoi asynchrone via CompletableFuture pour ne pas bloquer la réponse HTTP
|
||||
java.util.concurrent.CompletableFuture.runAsync(() -> {
|
||||
if (mailSender != null) {
|
||||
try {
|
||||
MimeMessage message = mailSender.createMimeMessage();
|
||||
MimeMessageHelper helper = new MimeMessageHelper(message, true, "UTF-8");
|
||||
helper.setFrom(getEffectiveFromEmail());
|
||||
helper.setTo(recipientEmail);
|
||||
helper.setSubject(subject);
|
||||
helper.setText(htmlContent, true);
|
||||
|
||||
mailSender.send(message);
|
||||
log.info("E-mail d'invitation SportEasy envoyé avec succès via SMTP à {} pour {}", recipientEmail, adherentNom);
|
||||
} catch (Exception e) {
|
||||
log.warn("Impossible d'envoyer l'e-mail via SMTP pour {}: {}. Bascule en mode simulation / log.", recipientEmail, e.getMessage());
|
||||
logDevEmail(recipientEmail, subject, htmlContent);
|
||||
}
|
||||
} else {
|
||||
log.info("Aucun JavaMailSender configuré (Mode DEV). Simulation de l'envoi d'e-mail SportEasy.");
|
||||
logDevEmail(recipientEmail, subject, htmlContent);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public BatchSendResult sendBatchInvitationsForActiveSaison(Long categoryId) {
|
||||
Saison activeSaison = saisonRepository.findByEstActiveTrue()
|
||||
.orElseThrow(() -> new IllegalStateException("Aucune saison active trouvée."));
|
||||
|
||||
List<Licence> licences;
|
||||
if (categoryId != null) {
|
||||
licences = licenceRepository.findBySaison(activeSaison).stream()
|
||||
.filter(l -> l.getCategorie() != null && categoryId.equals(l.getCategorie().getId()))
|
||||
.toList();
|
||||
} else {
|
||||
licences = licenceRepository.findBySaison(activeSaison);
|
||||
}
|
||||
|
||||
int sentCount = 0;
|
||||
int skippedCount = 0;
|
||||
int errorCount = 0;
|
||||
|
||||
for (Licence licence : licences) {
|
||||
if (licence.isRenouvellement()) {
|
||||
skippedCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(licence.getSportEasyEmailSent())) {
|
||||
skippedCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
String email = licence.getAdherent() != null ? licence.getAdherent().getEmail() : null;
|
||||
if (email == null || email.trim().isEmpty()) {
|
||||
skippedCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
boolean success = sendInvitationForLicence(licence.getId(), false);
|
||||
if (success) {
|
||||
sentCount++;
|
||||
} else {
|
||||
skippedCount++;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Erreur lors de l'envoi d'invitation SportEasy pour la licence ID {}: {}", licence.getId(), e.getMessage());
|
||||
errorCount++;
|
||||
}
|
||||
}
|
||||
|
||||
String msg = String.format("%d invitation(s) SportEasy envoyée(s) avec succès. %d ignorée(s) (déjà envoyées, renouvellements ou sans email), %d erreur(s).",
|
||||
sentCount, skippedCount, errorCount);
|
||||
|
||||
return new BatchSendResult(sentCount, skippedCount, errorCount, msg);
|
||||
}
|
||||
|
||||
private void logDevEmail(String recipient, String subject, String body) {
|
||||
log.info("==================== [SIMULATION E-MAIL SPORTEASY] ====================");
|
||||
log.info("Destinataire: {}", recipient);
|
||||
log.info("Sujet: {}", subject);
|
||||
log.info("Contenu:\n{}", body);
|
||||
log.info("=======================================================================");
|
||||
}
|
||||
|
||||
private String buildEmailHtml(String adherentNom, String categorieNom, String saisonNom, String inviteUrl) {
|
||||
return """
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<style>
|
||||
body { font-family: Arial, sans-serif; background-color: #f4f6f8; margin: 0; padding: 20px; color: #333; }
|
||||
.container { max-width: 600px; margin: 0 auto; background: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
|
||||
.header { background-color: #1e3a8a; color: #ffffff; padding: 24px; text-align: center; }
|
||||
.header h1 { margin: 0; font-size: 22px; }
|
||||
.content { padding: 24px; line-height: 1.6; }
|
||||
.btn { display: inline-block; background-color: #2563eb; color: #ffffff !important; padding: 12px 24px; border-radius: 6px; text-decoration: none; font-weight: bold; margin-top: 16px; text-align: center; }
|
||||
.url-box { background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 6px; padding: 12px; margin-top: 16px; font-size: 13px; word-break: break-all; color: #1f2937; }
|
||||
.footer { background: #f9fafb; border-top: 1px solid #e5e7eb; padding: 16px; text-align: center; font-size: 12px; color: #6b7280; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>AS Talange - Invitation SportEasy</h1>
|
||||
</div>
|
||||
<div class="content">
|
||||
<p>Bonjour <strong>%s</strong>,</p>
|
||||
<p>Afin d'assurer le suivi des entraînements, convocations et matchs pour la saison <strong>%s</strong> (catégorie <strong>%s</strong>), merci de rejoindre l'équipe sur la plateforme <strong>SportEasy</strong> en cliquant sur le lien ci-dessous :</p>
|
||||
|
||||
<p style="text-align: center;">
|
||||
<a href="%s" class="btn" target="_blank">Rejoindre la catégorie sur SportEasy</a>
|
||||
</p>
|
||||
|
||||
<div class="url-box">
|
||||
<strong>Lien d'invitation direct :</strong><br>
|
||||
<a href="%s" style="color: #2563eb;">%s</a>
|
||||
</div>
|
||||
|
||||
<p style="margin-top: 20px;">À très vite sur les terrains !<br><strong>L'équipe de l'AS Talange</strong></p>
|
||||
</div>
|
||||
<div class="footer">
|
||||
Cet e-mail a été envoyé automatiquement par le système de gestion de l'AS Talange.
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
""".formatted(
|
||||
adherentNom,
|
||||
saisonNom != null ? saisonNom : "",
|
||||
categorieNom,
|
||||
inviteUrl,
|
||||
inviteUrl,
|
||||
inviteUrl
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
ALTER TABLE licence ADD COLUMN commentaire TEXT;
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
ALTER TABLE pre_inscription ADD COLUMN raison_changement_club VARCHAR(255);
|
||||
ALTER TABLE pre_inscription ADD COLUMN comment_connu_club VARCHAR(255);
|
||||
ALTER TABLE pre_inscription ADD COLUMN taille_vetement VARCHAR(50);
|
||||
ALTER TABLE pre_inscription ADD COLUMN pointure VARCHAR(50);
|
||||
|
||||
ALTER TABLE adherent ADD COLUMN raison_changement_club VARCHAR(255);
|
||||
ALTER TABLE adherent ADD COLUMN comment_connu_club VARCHAR(255);
|
||||
ALTER TABLE adherent ADD COLUMN taille_vetement VARCHAR(50);
|
||||
ALTER TABLE adherent ADD COLUMN pointure VARCHAR(50);
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
ALTER TABLE equipement ADD COLUMN has_flocage_prenom BOOLEAN DEFAULT FALSE NOT NULL;
|
||||
ALTER TABLE equipement ADD COLUMN has_flocage_initiales BOOLEAN DEFAULT FALSE NOT NULL;
|
||||
ALTER TABLE equipement ADD COLUMN has_flocage_numero BOOLEAN DEFAULT FALSE NOT NULL;
|
||||
|
||||
-- Activation automatique de l'option "numéro" pour les équipements ayant déjà des dotations avec un numéro
|
||||
UPDATE equipement e
|
||||
SET has_flocage_numero = TRUE
|
||||
WHERE EXISTS (
|
||||
SELECT 1 FROM dotation d WHERE d.equipement_id = e.id AND d.numero IS NOT NULL AND d.numero != ''
|
||||
);
|
||||
|
||||
-- Activation automatique de l'option "prénom" (uniquement) pour les équipements ayant déjà des dotations avec un flocage
|
||||
UPDATE equipement e
|
||||
SET has_flocage_prenom = TRUE
|
||||
WHERE EXISTS (
|
||||
SELECT 1 FROM dotation d WHERE d.equipement_id = e.id AND d.flocage IS NOT NULL AND d.flocage != ''
|
||||
);
|
||||
|
||||
UPDATE dotation
|
||||
SET flocage = a.prenom
|
||||
FROM licence l
|
||||
JOIN adherent a ON l.adherent_id = a.id
|
||||
WHERE dotation.licence_id = l.id
|
||||
AND dotation.flocage IS NOT NULL
|
||||
AND dotation.flocage != ''
|
||||
AND EXISTS (
|
||||
SELECT 1 FROM equipement e
|
||||
WHERE e.id = dotation.equipement_id
|
||||
AND e.has_flocage_prenom = TRUE
|
||||
AND e.has_flocage_initiales = FALSE
|
||||
);
|
||||
@@ -1,2 +0,0 @@
|
||||
ALTER TABLE app_user ADD COLUMN last_login_at TIMESTAMP;
|
||||
ALTER TABLE app_user ADD COLUMN last_logout_at TIMESTAMP;
|
||||
@@ -1,3 +0,0 @@
|
||||
ALTER TABLE categorie ADD COLUMN sport_easy_token VARCHAR(255);
|
||||
ALTER TABLE licence ADD COLUMN sport_easy_email_sent BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ALTER TABLE licence ADD COLUMN sport_easy_email_sent_at TIMESTAMP;
|
||||
@@ -1,2 +0,0 @@
|
||||
ALTER TABLE dotation ADD COLUMN commandee BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ALTER TABLE dotation ADD COLUMN date_commande TIMESTAMP WITHOUT TIME ZONE;
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
ALTER TABLE licence ADD COLUMN reduction_educateur BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ALTER TABLE licence ADD COLUMN pourcentage_reduction_educateur INT DEFAULT 100;
|
||||
@@ -1,56 +0,0 @@
|
||||
package com.astalange.core;
|
||||
|
||||
import com.astalange.core.entity.Dotation;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class DotationSizeMatchTest {
|
||||
|
||||
@Test
|
||||
public void testAdherent60SizeMatchBugFix() {
|
||||
String adherentTaille = "11/12ANS (Taille 152cm)";
|
||||
String adherentPointure = "35/38 (Taille 2)";
|
||||
|
||||
// Equipment options for Junior Maillot / Shorts / Tracksuits
|
||||
String opt56 = "5/6ANS (Taille 116cm)";
|
||||
String opt78 = "7/8ANS (Taille 128cm)";
|
||||
String opt910 = "9/10ANS (Taille 140cm)";
|
||||
String opt1112 = "11/12ANS (Taille 152cm)";
|
||||
String opt1314 = "13/14ANS (Taille 164cm)";
|
||||
|
||||
assertFalse(Dotation.isSizeMatch(opt56, adherentTaille), "5/6ANS should NOT match 11/12ANS");
|
||||
assertFalse(Dotation.isSizeMatch(opt78, adherentTaille), "7/8ANS should NOT match 11/12ANS");
|
||||
assertFalse(Dotation.isSizeMatch(opt910, adherentTaille), "9/10ANS should NOT match 11/12ANS");
|
||||
assertTrue(Dotation.isSizeMatch(opt1112, adherentTaille), "11/12ANS MUST match 11/12ANS");
|
||||
assertFalse(Dotation.isSizeMatch(opt1314, adherentTaille), "13/14ANS should NOT match 11/12ANS");
|
||||
|
||||
// Sock sizes
|
||||
String sock2730 = "27/30 (Taille 0)";
|
||||
String sock3134 = "31/34 (Taille 1)";
|
||||
String sock3538 = "35/38 (Taille 2)";
|
||||
String sock3942 = "39/42 (Taille 3)";
|
||||
|
||||
assertFalse(Dotation.isSizeMatch(sock2730, adherentPointure), "27/30 should NOT match 35/38");
|
||||
assertFalse(Dotation.isSizeMatch(sock3134, adherentPointure), "31/34 should NOT match 35/38");
|
||||
assertTrue(Dotation.isSizeMatch(sock3538, adherentPointure), "35/38 MUST match 35/38");
|
||||
assertFalse(Dotation.isSizeMatch(sock3942, adherentPointure), "39/42 should NOT match 35/38");
|
||||
|
||||
// Ensure sock sizes do not match clothing size 152cm due to "Taille 1"
|
||||
assertFalse(Dotation.isSizeMatch(sock3134, adherentTaille), "Sock 31/34 (Taille 1) should NOT match clothing 152cm");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLetterSizes() {
|
||||
assertFalse(Dotation.isSizeMatch("S", "XL"));
|
||||
assertFalse(Dotation.isSizeMatch("M", "XL"));
|
||||
assertTrue(Dotation.isSizeMatch("XL", "XL"));
|
||||
assertTrue(Dotation.isSizeMatch("xxl", "XXL"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpaceVariations() {
|
||||
assertTrue(Dotation.isSizeMatch("5/6 ANS (Taille 116cm)", "5/6ANS"));
|
||||
assertTrue(Dotation.isSizeMatch("11/12 ANS (Taille 152cm)", "11/12ANS (Taille 152 cm)"));
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
package com.astalange.core;
|
||||
|
||||
import com.astalange.core.entity.Adherent;
|
||||
import com.astalange.core.entity.Categorie;
|
||||
import com.astalange.core.entity.Licence;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class LicenceReductionTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("Devrait calculer le prix normal sans réduction")
|
||||
void testPrixSansReduction() {
|
||||
Categorie cat = new Categorie();
|
||||
cat.setTarifBase(new BigDecimal("100.00"));
|
||||
cat.setTarifExterieur(new BigDecimal("120.00"));
|
||||
|
||||
Adherent adh = new Adherent();
|
||||
adh.setResidentTalange(true);
|
||||
|
||||
Licence licence = new Licence();
|
||||
licence.setCategorie(cat);
|
||||
licence.setAdherent(adh);
|
||||
licence.setReductionEducateur(false);
|
||||
|
||||
assertEquals(new BigDecimal("100.00"), licence.getPrixBrut());
|
||||
assertEquals(new BigDecimal("100.00"), licence.getPrixTotal());
|
||||
assertEquals(new BigDecimal("0.00"), licence.getMontantReduction());
|
||||
assertEquals(new BigDecimal("100.00"), licence.getResteAPayer());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Devrait calculer une réduction de 100% (gratuit)")
|
||||
void testReduction100Pourcent() {
|
||||
Categorie cat = new Categorie();
|
||||
cat.setTarifBase(new BigDecimal("140.00"));
|
||||
|
||||
Adherent adh = new Adherent();
|
||||
adh.setResidentTalange(true);
|
||||
|
||||
Licence licence = new Licence();
|
||||
licence.setCategorie(cat);
|
||||
licence.setAdherent(adh);
|
||||
licence.setReductionEducateur(true);
|
||||
licence.setPourcentageReductionEducateur(100);
|
||||
|
||||
assertEquals(new BigDecimal("140.00"), licence.getPrixBrut());
|
||||
assertEquals(new BigDecimal("0.00"), licence.getPrixTotal());
|
||||
assertEquals(new BigDecimal("140.00"), licence.getMontantReduction());
|
||||
assertEquals(new BigDecimal("0.00"), licence.getResteAPayer());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Devrait calculer une réduction partielle (ex: 50%)")
|
||||
void testReductionPartielle50Pourcent() {
|
||||
Categorie cat = new Categorie();
|
||||
cat.setTarifBase(new BigDecimal("150.00"));
|
||||
|
||||
Adherent adh = new Adherent();
|
||||
adh.setResidentTalange(true);
|
||||
|
||||
Licence licence = new Licence();
|
||||
licence.setCategorie(cat);
|
||||
licence.setAdherent(adh);
|
||||
licence.setReductionEducateur(true);
|
||||
licence.setPourcentageReductionEducateur(50);
|
||||
|
||||
assertEquals(new BigDecimal("150.00"), licence.getPrixBrut());
|
||||
assertEquals(new BigDecimal("75.00"), licence.getPrixTotal());
|
||||
assertEquals(new BigDecimal("75.00"), licence.getMontantReduction());
|
||||
assertEquals(new BigDecimal("75.00"), licence.getResteAPayer());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Devrait calculer une réduction partielle de 20%")
|
||||
void testReductionPartielle20Pourcent() {
|
||||
Categorie cat = new Categorie();
|
||||
cat.setTarifBase(new BigDecimal("200.00"));
|
||||
|
||||
Adherent adh = new Adherent();
|
||||
adh.setResidentTalange(true);
|
||||
|
||||
Licence licence = new Licence();
|
||||
licence.setCategorie(cat);
|
||||
licence.setAdherent(adh);
|
||||
licence.setReductionEducateur(true);
|
||||
licence.setPourcentageReductionEducateur(20);
|
||||
|
||||
assertEquals(new BigDecimal("200.00"), licence.getPrixBrut());
|
||||
assertEquals(new BigDecimal("160.00"), licence.getPrixTotal());
|
||||
assertEquals(new BigDecimal("40.00"), licence.getMontantReduction());
|
||||
assertEquals(new BigDecimal("160.00"), licence.getResteAPayer());
|
||||
}
|
||||
}
|
||||
-214
@@ -1,214 +0,0 @@
|
||||
package com.astalange.core.service;
|
||||
|
||||
import com.astalange.core.entity.*;
|
||||
import com.astalange.core.repository.CategorieRepository;
|
||||
import com.astalange.core.repository.DotationRepository;
|
||||
import com.astalange.core.repository.EquipementRepository;
|
||||
import com.astalange.core.repository.SaisonRepository;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class DotationIntegrationTest {
|
||||
|
||||
@Mock
|
||||
private CategorieRepository categorieRepository;
|
||||
|
||||
@Mock
|
||||
private SaisonRepository saisonRepository;
|
||||
|
||||
@Mock
|
||||
private EquipementRepository equipementRepository;
|
||||
|
||||
@Mock
|
||||
private com.astalange.core.repository.LicenceRepository licenceRepository;
|
||||
|
||||
@InjectMocks
|
||||
private CategorieService categorieService;
|
||||
|
||||
private Equipement maillotJunior;
|
||||
private Equipement chaussettesJunior;
|
||||
private Equipement maillotAdulte;
|
||||
private Equipement chaussettesAdulte;
|
||||
private Categorie catJunior;
|
||||
private Categorie catAdulte;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
// 1. Junior Equipment
|
||||
maillotJunior = new Equipement();
|
||||
maillotJunior.setId(1L);
|
||||
maillotJunior.setNom("Maillot de match Puma (Junior)");
|
||||
maillotJunior.setTypePublic("TOUS");
|
||||
maillotJunior.setTaillesDisponibles("5/6ANS (Taille 116cm),7/8ANS (Taille 128cm),9/10ANS (Taille 140cm),11/12ANS (Taille 152cm),13/14ANS (Taille 164cm),15/16ANS (Taille 176cm)");
|
||||
|
||||
chaussettesJunior = new Equipement();
|
||||
chaussettesJunior.setId(2L);
|
||||
chaussettesJunior.setNom("Chaussettes puma (Junior)");
|
||||
chaussettesJunior.setTypePublic("TOUS");
|
||||
chaussettesJunior.setTaillesDisponibles("27/30 (Taille 0),31/34 (Taille 1),35/38 (Taille 2),39/42 (Taille 3)");
|
||||
|
||||
catJunior = new Categorie();
|
||||
catJunior.setId(10L);
|
||||
catJunior.setNom("U11");
|
||||
|
||||
CategorieEquipement ce1 = new CategorieEquipement();
|
||||
ce1.setCategorie(catJunior);
|
||||
ce1.setEquipement(maillotJunior);
|
||||
ce1.setObligatoire(true);
|
||||
|
||||
CategorieEquipement ce2 = new CategorieEquipement();
|
||||
ce2.setCategorie(catJunior);
|
||||
ce2.setEquipement(chaussettesJunior);
|
||||
ce2.setObligatoire(true);
|
||||
|
||||
catJunior.setCategorieEquipements(List.of(ce1, ce2));
|
||||
|
||||
// 2. Adult Equipment
|
||||
maillotAdulte = new Equipement();
|
||||
maillotAdulte.setId(3L);
|
||||
maillotAdulte.setNom("Maillot de match Puma (Adulte)");
|
||||
maillotAdulte.setTypePublic("TOUS");
|
||||
maillotAdulte.setTaillesDisponibles("XS,S,M,L,XL,XXL");
|
||||
|
||||
chaussettesAdulte = new Equipement();
|
||||
chaussettesAdulte.setId(4L);
|
||||
chaussettesAdulte.setNom("Chaussettes puma (Adulte)");
|
||||
chaussettesAdulte.setTypePublic("TOUS");
|
||||
chaussettesAdulte.setTaillesDisponibles("35/38 (Taille 2),39/42 (Taille 3),43/46 (Taille 4)");
|
||||
|
||||
catAdulte = new Categorie();
|
||||
catAdulte.setId(20L);
|
||||
catAdulte.setNom("Seniors");
|
||||
|
||||
CategorieEquipement ce3 = new CategorieEquipement();
|
||||
ce3.setCategorie(catAdulte);
|
||||
ce3.setEquipement(maillotAdulte);
|
||||
ce3.setObligatoire(true);
|
||||
|
||||
CategorieEquipement ce4 = new CategorieEquipement();
|
||||
ce4.setCategorie(catAdulte);
|
||||
ce4.setEquipement(chaussettesAdulte);
|
||||
ce4.setObligatoire(true);
|
||||
|
||||
catAdulte.setCategorieEquipements(List.of(ce3, ce4));
|
||||
}
|
||||
|
||||
private Licence createLicence(Categorie cat, String tailleVetement, String pointure) {
|
||||
Adherent adherent = new Adherent();
|
||||
adherent.setTypeMaillot("JOUEUR");
|
||||
adherent.setTailleVetement(tailleVetement);
|
||||
adherent.setPointure(pointure);
|
||||
|
||||
Licence licence = new Licence();
|
||||
licence.setId(100L);
|
||||
licence.setAdherent(adherent);
|
||||
licence.setCategorie(cat);
|
||||
licence.setDotations(new ArrayList<>());
|
||||
return licence;
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Junior 11/12ANS (Bug initial Adhérent 60) -> Doit reporter 11/12ANS et 35/38")
|
||||
public void testAdherent60Synchronization() {
|
||||
Licence licence = createLicence(catJunior, "11/12ANS (Taille 152cm)", "35/38 (Taille 2)");
|
||||
|
||||
categorieService.syncDotationsForLicence(licence);
|
||||
|
||||
List<Dotation> dotations = licence.getDotations();
|
||||
assertEquals(2, dotations.size());
|
||||
Dotation dMaillot = dotations.stream().filter(d -> d.getEquipement().getId().equals(1L)).findFirst().orElseThrow();
|
||||
Dotation dChaussettes = dotations.stream().filter(d -> d.getEquipement().getId().equals(2L)).findFirst().orElseThrow();
|
||||
|
||||
assertEquals("11/12ANS (Taille 152cm)", dMaillot.getTaille(), "Le maillot doit être 11/12ANS et non 5/6ANS");
|
||||
assertEquals("35/38 (Taille 2)", dChaussettes.getTaille(), "Les chaussettes doivent être 35/38 et non 31/34");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Junior - Test de toutes les tailles (5/6, 7/8, 9/10, 11/12, 13/14, 15/16)")
|
||||
public void testAllJuniorSizes() {
|
||||
String[][] cases = {
|
||||
{"5/6ANS (Taille 116cm)", "27/30 (Taille 0)", "5/6ANS (Taille 116cm)", "27/30 (Taille 0)"},
|
||||
{"7/8ANS (Taille 128cm)", "31/34 (Taille 1)", "7/8ANS (Taille 128cm)", "31/34 (Taille 1)"},
|
||||
{"9/10ANS (Taille 140cm)", "31/34 (Taille 1)", "9/10ANS (Taille 140cm)", "31/34 (Taille 1)"},
|
||||
{"11/12ANS (Taille 152cm)", "35/38 (Taille 2)", "11/12ANS (Taille 152cm)", "35/38 (Taille 2)"},
|
||||
{"13/14ANS (Taille 164cm)", "35/38 (Taille 2)", "13/14ANS (Taille 164cm)", "35/38 (Taille 2)"},
|
||||
{"15/16ANS (Taille 176cm)", "39/42 (Taille 3)", "15/16ANS (Taille 176cm)", "39/42 (Taille 3)"}
|
||||
};
|
||||
|
||||
for (String[] testCase : cases) {
|
||||
String tv = testCase[0];
|
||||
String pt = testCase[1];
|
||||
String expectedMaillot = testCase[2];
|
||||
String expectedChaussettes = testCase[3];
|
||||
|
||||
Licence licence = createLicence(catJunior, tv, pt);
|
||||
categorieService.syncDotationsForLicence(licence);
|
||||
|
||||
List<Dotation> dotations = licence.getDotations();
|
||||
Dotation dMaillot = dotations.stream().filter(d -> d.getEquipement().getId().equals(1L)).findFirst().orElseThrow();
|
||||
Dotation dChaussettes = dotations.stream().filter(d -> d.getEquipement().getId().equals(2L)).findFirst().orElseThrow();
|
||||
|
||||
assertEquals(expectedMaillot, dMaillot.getTaille(), "Erreur pour la taille vêtement: " + tv);
|
||||
assertEquals(expectedChaussettes, dChaussettes.getTaille(), "Erreur pour la pointure: " + pt);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Adulte - Test de toutes les tailles (XS, S, M, L, XL, XXL)")
|
||||
public void testAllAdultSizes() {
|
||||
String[][] cases = {
|
||||
{"XS", "35/38 (Taille 2)", "XS", "35/38 (Taille 2)"},
|
||||
{"S", "39/42 (Taille 3)", "S", "39/42 (Taille 3)"},
|
||||
{"M", "39/42 (Taille 3)", "M", "39/42 (Taille 3)"},
|
||||
{"L", "43/46 (Taille 4)", "L", "43/46 (Taille 4)"},
|
||||
{"XL", "43/46 (Taille 4)", "XL", "43/46 (Taille 4)"},
|
||||
{"XXL", "43/46 (Taille 4)", "XXL", "43/46 (Taille 4)"}
|
||||
};
|
||||
|
||||
for (String[] testCase : cases) {
|
||||
String tv = testCase[0];
|
||||
String pt = testCase[1];
|
||||
String expectedMaillot = testCase[2];
|
||||
String expectedChaussettes = testCase[3];
|
||||
|
||||
Licence licence = createLicence(catAdulte, tv, pt);
|
||||
categorieService.syncDotationsForLicence(licence);
|
||||
|
||||
List<Dotation> dotations = licence.getDotations();
|
||||
Dotation dMaillot = dotations.stream().filter(d -> d.getEquipement().getId().equals(3L)).findFirst().orElseThrow();
|
||||
Dotation dChaussettes = dotations.stream().filter(d -> d.getEquipement().getId().equals(4L)).findFirst().orElseThrow();
|
||||
|
||||
assertEquals(expectedMaillot, dMaillot.getTaille(), "Erreur pour la taille adulte vêtement: " + tv);
|
||||
assertEquals(expectedChaussettes, dChaussettes.getTaille(), "Erreur pour la pointure adulte: " + pt);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Formats alternatifs (Espaces, sans mention de taille)")
|
||||
public void testAlternativeFormats() {
|
||||
Licence licence1 = createLicence(catJunior, "11/12 ANS (Taille 152 cm)", "35/38 (Taille 2)");
|
||||
categorieService.syncDotationsForLicence(licence1);
|
||||
|
||||
Dotation dMaillot1 = licence1.getDotations().stream().filter(d -> d.getEquipement().getId().equals(1L)).findFirst().orElseThrow();
|
||||
assertEquals("11/12ANS (Taille 152cm)", dMaillot1.getTaille());
|
||||
|
||||
Licence licence2 = createLicence(catJunior, "11/12ANS", "35/38");
|
||||
categorieService.syncDotationsForLicence(licence2);
|
||||
|
||||
Dotation dMaillot2 = licence2.getDotations().stream().filter(d -> d.getEquipement().getId().equals(1L)).findFirst().orElseThrow();
|
||||
Dotation dChaussettes2 = licence2.getDotations().stream().filter(d -> d.getEquipement().getId().equals(2L)).findFirst().orElseThrow();
|
||||
assertEquals("11/12ANS (Taille 152cm)", dMaillot2.getTaille());
|
||||
assertEquals("35/38 (Taille 2)", dChaussettes2.getTaille());
|
||||
}
|
||||
}
|
||||
-173
@@ -1,173 +0,0 @@
|
||||
package com.astalange.core.service;
|
||||
|
||||
import com.astalange.core.entity.Adherent;
|
||||
import com.astalange.core.entity.Categorie;
|
||||
import com.astalange.core.entity.Licence;
|
||||
import com.astalange.core.entity.ModePaiement;
|
||||
import com.astalange.core.entity.Paiement;
|
||||
import com.astalange.core.entity.Saison;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import com.astalange.core.repository.PaiementRepository;
|
||||
import java.util.Optional;
|
||||
|
||||
class PaiementEmailServiceTest {
|
||||
|
||||
private PaiementEmailService paiementEmailService;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
paiementEmailService = new PaiementEmailService(null, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSendPaiementConfirmation_Totalite_SimulatedMode() {
|
||||
Adherent adherent = new Adherent();
|
||||
adherent.setNom("DUPONT");
|
||||
adherent.setPrenom("Jean");
|
||||
adherent.setEmail("jean.dupont@example.com");
|
||||
|
||||
Categorie categorie = new Categorie();
|
||||
categorie.setNom("U13");
|
||||
categorie.setTarifBase(new BigDecimal("150.00"));
|
||||
categorie.setTarifExterieur(new BigDecimal("150.00"));
|
||||
|
||||
Saison saison = new Saison();
|
||||
saison.setNom("2026/2027");
|
||||
|
||||
Licence licence = new Licence();
|
||||
licence.setId(1L);
|
||||
licence.setAdherent(adherent);
|
||||
licence.setCategorie(categorie);
|
||||
licence.setSaison(saison);
|
||||
|
||||
ModePaiement modePaiement = new ModePaiement();
|
||||
modePaiement.setId(1L);
|
||||
modePaiement.setNom("Carte bancaire");
|
||||
|
||||
Paiement paiement = new Paiement();
|
||||
paiement.setId(10L);
|
||||
paiement.setLicence(licence);
|
||||
paiement.setMontant(new BigDecimal("150.00"));
|
||||
paiement.setDatePaiement(LocalDate.now());
|
||||
paiement.setModePaiement(modePaiement);
|
||||
|
||||
licence.addPaiement(paiement);
|
||||
|
||||
boolean result = paiementEmailService.sendPaiementConfirmation(paiement);
|
||||
assertTrue(result, "Dev simulation mode should return true when email processing succeeds");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSendPaiementConfirmation_Partiel_SimulatedMode() {
|
||||
Adherent adherent = new Adherent();
|
||||
adherent.setNom("MARTIN");
|
||||
adherent.setPrenom("Sophie");
|
||||
adherent.setEmail("sophie.martin@example.com");
|
||||
|
||||
Categorie categorie = new Categorie();
|
||||
categorie.setNom("Senior");
|
||||
categorie.setTarifBase(new BigDecimal("200.00"));
|
||||
categorie.setTarifExterieur(new BigDecimal("200.00"));
|
||||
|
||||
Saison saison = new Saison();
|
||||
saison.setNom("2026/2027");
|
||||
|
||||
Licence licence = new Licence();
|
||||
licence.setId(2L);
|
||||
licence.setAdherent(adherent);
|
||||
licence.setCategorie(categorie);
|
||||
licence.setSaison(saison);
|
||||
|
||||
ModePaiement modePaiement = new ModePaiement();
|
||||
modePaiement.setId(2L);
|
||||
modePaiement.setNom("Espèces");
|
||||
|
||||
Paiement paiement = new Paiement();
|
||||
paiement.setId(11L);
|
||||
paiement.setLicence(licence);
|
||||
paiement.setMontant(new BigDecimal("80.00"));
|
||||
paiement.setDatePaiement(LocalDate.now());
|
||||
paiement.setModePaiement(modePaiement);
|
||||
|
||||
licence.addPaiement(paiement);
|
||||
|
||||
boolean result = paiementEmailService.sendPaiementConfirmation(paiement);
|
||||
assertTrue(result);
|
||||
assertEquals(new BigDecimal("120.00"), licence.getResteAPayer(), "Remaining amount should be 120.00 €");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSendPaiementConfirmation_SansEmail() {
|
||||
Adherent adherent = new Adherent();
|
||||
adherent.setNom("SANS");
|
||||
adherent.setPrenom("Email");
|
||||
adherent.setEmail(null);
|
||||
|
||||
Licence licence = new Licence();
|
||||
licence.setAdherent(adherent);
|
||||
|
||||
Paiement paiement = new Paiement();
|
||||
paiement.setLicence(licence);
|
||||
|
||||
boolean result = paiementEmailService.sendPaiementConfirmation(paiement);
|
||||
assertFalse(result, "Should return false if adherent has no email");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSendPaiementConfirmation_WithJavaMailSender() {
|
||||
org.springframework.mail.javamail.JavaMailSender mailSenderMock = mock(org.springframework.mail.javamail.JavaMailSender.class);
|
||||
MimeMessage mimeMessage = new MimeMessage((jakarta.mail.Session) null);
|
||||
|
||||
when(mailSenderMock.createMimeMessage()).thenReturn(mimeMessage);
|
||||
|
||||
PaiementEmailService serviceWithMailSender = new PaiementEmailService(mailSenderMock, null);
|
||||
|
||||
Adherent adherent = new Adherent();
|
||||
adherent.setNom("DURAND");
|
||||
adherent.setPrenom("Paul");
|
||||
adherent.setEmail("paul.durand@example.com");
|
||||
|
||||
Categorie categorie = new Categorie();
|
||||
categorie.setNom("U11");
|
||||
categorie.setTarifBase(new BigDecimal("100.00"));
|
||||
categorie.setTarifExterieur(new BigDecimal("100.00"));
|
||||
|
||||
Saison saison = new Saison();
|
||||
saison.setNom("2026/2027");
|
||||
|
||||
Licence licence = new Licence();
|
||||
licence.setId(3L);
|
||||
licence.setAdherent(adherent);
|
||||
licence.setCategorie(categorie);
|
||||
licence.setSaison(saison);
|
||||
|
||||
ModePaiement modePaiement = new ModePaiement();
|
||||
modePaiement.setId(1L);
|
||||
modePaiement.setNom("Chèque");
|
||||
|
||||
Paiement paiement = new Paiement();
|
||||
paiement.setId(12L);
|
||||
paiement.setLicence(licence);
|
||||
paiement.setMontant(new BigDecimal("100.00"));
|
||||
paiement.setDatePaiement(LocalDate.now());
|
||||
paiement.setModePaiement(modePaiement);
|
||||
paiement.setNumeroCheque("CHK-999");
|
||||
|
||||
licence.addPaiement(paiement);
|
||||
|
||||
boolean result = serviceWithMailSender.sendPaiementConfirmation(paiement);
|
||||
|
||||
assertTrue(result);
|
||||
verify(mailSenderMock, timeout(2000).times(1)).send(any(MimeMessage.class));
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>as-talange-parent</artifactId>
|
||||
<groupId>com.astalange</groupId>
|
||||
<version>1.7-SNAPSHOT</version>
|
||||
<version>1.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -4,12 +4,10 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
@SpringBootApplication(scanBasePackages = "com.astalange")
|
||||
@EntityScan(basePackages = "com.astalange.core.entity")
|
||||
@EnableJpaRepositories(basePackages = "com.astalange.core.repository")
|
||||
@EnableAsync
|
||||
public class AsTalangeApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AsTalangeApplication.class, args);
|
||||
|
||||
@@ -24,16 +24,14 @@ public class AdherentController {
|
||||
private final com.astalange.core.repository.ModePaiementRepository modePaiementRepository;
|
||||
private final SaisonRepository saisonRepository;
|
||||
private final com.astalange.core.service.CategorieService categorieService;
|
||||
private final com.astalange.core.service.SportEasyEmailService sportEasyEmailService;
|
||||
|
||||
public AdherentController(AdherentRepository adherentRepository, CategorieRepository categorieRepository, com.astalange.core.repository.LicenceRepository licenceRepository, com.astalange.core.repository.ModePaiementRepository modePaiementRepository, SaisonRepository saisonRepository, com.astalange.core.service.CategorieService categorieService, com.astalange.core.service.SportEasyEmailService sportEasyEmailService) {
|
||||
public AdherentController(AdherentRepository adherentRepository, CategorieRepository categorieRepository, com.astalange.core.repository.LicenceRepository licenceRepository, com.astalange.core.repository.ModePaiementRepository modePaiementRepository, SaisonRepository saisonRepository, com.astalange.core.service.CategorieService categorieService) {
|
||||
this.adherentRepository = adherentRepository;
|
||||
this.categorieRepository = categorieRepository;
|
||||
this.licenceRepository = licenceRepository;
|
||||
this.modePaiementRepository = modePaiementRepository;
|
||||
this.saisonRepository = saisonRepository;
|
||||
this.categorieService = categorieService;
|
||||
this.sportEasyEmailService = sportEasyEmailService;
|
||||
}
|
||||
|
||||
@org.springframework.web.bind.annotation.ModelAttribute("equipes")
|
||||
@@ -47,13 +45,9 @@ public class AdherentController {
|
||||
@org.springframework.web.bind.annotation.RequestParam(required = false) String nom,
|
||||
@org.springframework.web.bind.annotation.RequestParam(required = false) String prenom,
|
||||
@org.springframework.web.bind.annotation.RequestParam(required = false) String categorie,
|
||||
@org.springframework.web.bind.annotation.RequestParam(required = false) String equipements,
|
||||
@org.springframework.web.bind.annotation.RequestParam(required = false) String licence,
|
||||
@org.springframework.web.bind.annotation.RequestParam(required = false) String email,
|
||||
@org.springframework.web.bind.annotation.RequestParam(required = false) String paiement,
|
||||
@org.springframework.web.bind.annotation.RequestParam(required = false) String sporteasy,
|
||||
@org.springframework.web.bind.annotation.RequestParam(required = false, defaultValue = "nom") String sortField,
|
||||
@org.springframework.web.bind.annotation.RequestParam(required = false, defaultValue = "asc") String sortDirection,
|
||||
@org.springframework.web.bind.annotation.RequestParam(defaultValue = "0") int page,
|
||||
@org.springframework.web.bind.annotation.RequestParam(defaultValue = "20") int size,
|
||||
Model model) {
|
||||
@@ -90,32 +84,6 @@ public class AdherentController {
|
||||
).collect(java.util.stream.Collectors.toList());
|
||||
model.addAttribute("categorieFilter", categorie.trim());
|
||||
}
|
||||
if (equipements != null && !equipements.trim().isEmpty()) {
|
||||
String eqFilter = equipements.trim();
|
||||
adherents = adherents.stream().filter(a -> {
|
||||
Licence lic = a.getLicenceActuelle();
|
||||
if (lic == null || lic.getDotations() == null || lic.getDotations().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
List<com.astalange.core.entity.Dotation> choisis = lic.getDotations().stream()
|
||||
.filter(d -> Boolean.TRUE.equals(d.getChoisi()))
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
if (choisis.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
long total = choisis.size();
|
||||
long fournis = choisis.stream().filter(d -> Boolean.TRUE.equals(d.getFourni())).count();
|
||||
if ("TOUT_FOURNI".equalsIgnoreCase(eqFilter)) {
|
||||
return fournis == total;
|
||||
} else if ("PARTIEL".equalsIgnoreCase(eqFilter)) {
|
||||
return fournis > 0 && fournis < total;
|
||||
} else if ("NON_FOURNI".equalsIgnoreCase(eqFilter)) {
|
||||
return fournis == 0;
|
||||
}
|
||||
return true;
|
||||
}).collect(java.util.stream.Collectors.toList());
|
||||
model.addAttribute("equipementsFilter", eqFilter);
|
||||
}
|
||||
if (licence != null && !licence.trim().isEmpty()) {
|
||||
String l = licence.trim().toLowerCase();
|
||||
adherents = adherents.stream().filter(a ->
|
||||
@@ -144,45 +112,8 @@ public class AdherentController {
|
||||
}).collect(java.util.stream.Collectors.toList());
|
||||
model.addAttribute("paiementFilter", paiement.trim());
|
||||
}
|
||||
if (sporteasy != null && !sporteasy.trim().isEmpty()) {
|
||||
adherents = adherents.stream().filter(a -> {
|
||||
Licence lic = a.getLicenceActuelle();
|
||||
if (lic == null) return false;
|
||||
if ("NON_INVITE".equalsIgnoreCase(sporteasy)) {
|
||||
return !lic.isRenouvellement() && !Boolean.TRUE.equals(lic.getSportEasyEmailSent());
|
||||
} else if ("INVITE".equalsIgnoreCase(sporteasy)) {
|
||||
return !lic.isRenouvellement() && Boolean.TRUE.equals(lic.getSportEasyEmailSent());
|
||||
} else if ("RENOUVELLEMENT".equalsIgnoreCase(sporteasy)) {
|
||||
return lic.isRenouvellement();
|
||||
}
|
||||
return true;
|
||||
}).collect(java.util.stream.Collectors.toList());
|
||||
model.addAttribute("sporteasyFilter", sporteasy.trim());
|
||||
}
|
||||
|
||||
// 3. Sort
|
||||
java.util.Comparator<Adherent> comparator = (a1, a2) -> 0;
|
||||
if ("nom".equalsIgnoreCase(sortField)) {
|
||||
comparator = java.util.Comparator.comparing(a -> a.getNom() != null ? a.getNom() : "");
|
||||
} else if ("prenom".equalsIgnoreCase(sortField)) {
|
||||
comparator = java.util.Comparator.comparing(a -> a.getPrenom() != null ? a.getPrenom() : "");
|
||||
} else if ("categorie".equalsIgnoreCase(sortField)) {
|
||||
comparator = java.util.Comparator.comparing(a -> (a.getLicenceActuelle() != null && a.getLicenceActuelle().getCategorie() != null && a.getLicenceActuelle().getCategorie().getNom() != null) ? a.getLicenceActuelle().getCategorie().getNom() : "");
|
||||
} else if ("licence".equalsIgnoreCase(sortField)) {
|
||||
comparator = java.util.Comparator.comparing(a -> (a.getLicenceActuelle() != null && a.getLicenceActuelle().getNumeroLicence() != null) ? a.getLicenceActuelle().getNumeroLicence() : "");
|
||||
} else if ("email".equalsIgnoreCase(sortField)) {
|
||||
comparator = java.util.Comparator.comparing(a -> a.getEmail() != null ? a.getEmail() : "");
|
||||
}
|
||||
|
||||
if ("desc".equalsIgnoreCase(sortDirection)) {
|
||||
comparator = comparator.reversed();
|
||||
}
|
||||
adherents.sort(comparator);
|
||||
|
||||
model.addAttribute("sortField", sortField);
|
||||
model.addAttribute("sortDirection", sortDirection);
|
||||
|
||||
// 4. Paginate
|
||||
// 3. Paginate
|
||||
int totalElements = adherents.size();
|
||||
int totalPages = (int) Math.ceil((double) totalElements / size);
|
||||
if (page < 0) page = 0;
|
||||
@@ -279,20 +210,12 @@ public class AdherentController {
|
||||
existing.setLieuNaissancePays(adherent.getLieuNaissancePays());
|
||||
existing.setNationalite(adherent.getNationalite());
|
||||
existing.setEmail(adherent.getEmail());
|
||||
existing.setTelephone(adherent.getTelephone());
|
||||
existing.setRepresentantLegal(adherent.getRepresentantLegal());
|
||||
existing.setResidentTalange(adherent.isResidentTalange());
|
||||
existing.setSexe(adherent.getSexe());
|
||||
existing.setTypeMaillot(adherent.getTypeMaillot());
|
||||
existing.setTailleVetement(adherent.getTailleVetement());
|
||||
existing.setPointure(adherent.getPointure());
|
||||
|
||||
adherentRepository.save(existing);
|
||||
|
||||
List<Licence> licences = licenceRepository.findByAdherentId(existing.getId());
|
||||
for (Licence licence : licences) {
|
||||
categorieService.syncDotationsForLicence(licence);
|
||||
}
|
||||
} else {
|
||||
adherentRepository.save(adherent);
|
||||
}
|
||||
@@ -329,57 +252,4 @@ public class AdherentController {
|
||||
adherentRepository.delete(adherent);
|
||||
return "redirect:/adherents";
|
||||
}
|
||||
|
||||
@org.springframework.web.bind.annotation.PostMapping("/{id}/sporteasy-invite")
|
||||
public String sendSportEasyInvite(
|
||||
@org.springframework.web.bind.annotation.PathVariable Long id,
|
||||
@org.springframework.web.bind.annotation.RequestParam(required = false, defaultValue = "false") boolean force,
|
||||
org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) {
|
||||
|
||||
Saison activeSaison = saisonRepository.findByEstActiveTrue().orElse(null);
|
||||
if (activeSaison == null) {
|
||||
redirectAttributes.addFlashAttribute("errorMessage", "Erreur : Aucune saison active trouvée.");
|
||||
return "redirect:/adherents";
|
||||
}
|
||||
|
||||
Licence licence = licenceRepository.findByAdherentIdAndSaison(id, activeSaison).orElse(null);
|
||||
if (licence == null) {
|
||||
redirectAttributes.addFlashAttribute("errorMessage", "Cet adhérent n'a pas de licence pour la saison active.");
|
||||
return "redirect:/adherents";
|
||||
}
|
||||
|
||||
if (licence.isRenouvellement()) {
|
||||
redirectAttributes.addFlashAttribute("infoMessage", "Les invitations SportEasy sont réservées aux nouveaux adhérents (nouvelle licence).");
|
||||
return "redirect:/adherents";
|
||||
}
|
||||
|
||||
try {
|
||||
boolean success = sportEasyEmailService.sendInvitationForLicence(licence.getId(), force);
|
||||
if (success) {
|
||||
redirectAttributes.addFlashAttribute("successMessage", "L'invitation SportEasy a été envoyée avec succès à l'adhérent.");
|
||||
} else {
|
||||
redirectAttributes.addFlashAttribute("infoMessage", "L'invitation SportEasy avait déjà été envoyée à cet adhérent.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
redirectAttributes.addFlashAttribute("errorMessage", "Erreur lors de l'envoi de l'invitation : " + e.getMessage());
|
||||
}
|
||||
|
||||
return "redirect:/adherents";
|
||||
}
|
||||
|
||||
@org.springframework.web.bind.annotation.PostMapping("/sporteasy-invite-batch")
|
||||
public String sendSportEasyInviteBatch(
|
||||
@org.springframework.web.bind.annotation.RequestParam(required = false) Long categoryId,
|
||||
org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) {
|
||||
|
||||
try {
|
||||
com.astalange.core.service.SportEasyEmailService.BatchSendResult result =
|
||||
sportEasyEmailService.sendBatchInvitationsForActiveSaison(categoryId);
|
||||
redirectAttributes.addFlashAttribute("successMessage", result.message());
|
||||
} catch (Exception e) {
|
||||
redirectAttributes.addFlashAttribute("errorMessage", "Erreur lors de l'envoi des invitations SportEasy : " + e.getMessage());
|
||||
}
|
||||
|
||||
return "redirect:/adherents";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,9 +36,7 @@ public class CategorieController {
|
||||
|
||||
@GetMapping("/new")
|
||||
public String showCreateForm(Model model) {
|
||||
if (!model.containsAttribute("categorie")) {
|
||||
model.addAttribute("categorie", new Categorie());
|
||||
}
|
||||
model.addAttribute("categorie", new Categorie());
|
||||
Saison activeSaison = saisonRepository.findByEstActiveTrue().orElse(null);
|
||||
model.addAttribute("allEquipements", activeSaison != null ? equipementRepository.findBySaison(activeSaison) : List.of());
|
||||
return "parametrage/categories_form";
|
||||
@@ -61,26 +59,7 @@ public class CategorieController {
|
||||
|
||||
@PostMapping
|
||||
public String saveCategorie(@ModelAttribute("categorie") Categorie categorie,
|
||||
jakarta.servlet.http.HttpServletRequest request,
|
||||
org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) {
|
||||
|
||||
Saison activeSaison;
|
||||
if (categorie.getId() == null) {
|
||||
activeSaison = saisonRepository.findByEstActiveTrue().orElse(null);
|
||||
} else {
|
||||
Categorie existing = categorieRepository.findById(categorie.getId()).orElse(null);
|
||||
activeSaison = existing != null ? existing.getSaison() : null;
|
||||
}
|
||||
|
||||
if (activeSaison != null) {
|
||||
for (Categorie c : categorieRepository.findBySaison(activeSaison)) {
|
||||
if (c.getNom().equalsIgnoreCase(categorie.getNom()) && (categorie.getId() == null || !c.getId().equals(categorie.getId()))) {
|
||||
redirectAttributes.addFlashAttribute("errorMessage", "Erreur : La catégorie '" + categorie.getNom() + "' existe déjà pour cette saison.");
|
||||
redirectAttributes.addFlashAttribute("categorie", categorie);
|
||||
return categorie.getId() == null ? "redirect:/categories/new" : "redirect:/categories/" + categorie.getId() + "/edit";
|
||||
}
|
||||
}
|
||||
}
|
||||
jakarta.servlet.http.HttpServletRequest request) {
|
||||
|
||||
java.util.Map<Long, com.astalange.core.service.CategorieService.EquipementConfig> configs = new java.util.HashMap<>();
|
||||
|
||||
@@ -114,10 +93,4 @@ public class CategorieController {
|
||||
categorieRepository.delete(categorie);
|
||||
return "redirect:/categories";
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/duplicate")
|
||||
public String duplicateCategorie(@PathVariable Long id) {
|
||||
categorieService.duplicateCategorie(id);
|
||||
return "redirect:/categories";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class DotationController {
|
||||
this.categorieRepository = categorieRepository;
|
||||
}
|
||||
|
||||
private Specification<Dotation> buildSpecification(Long equipementId, Long categorieId, Boolean fourni, Boolean commandee, Saison saisonActive) {
|
||||
private Specification<Dotation> buildSpecification(Long equipementId, Long categorieId, Boolean fourni, Saison saisonActive) {
|
||||
return (root, query, cb) -> {
|
||||
if (Long.class != query.getResultType() && long.class != query.getResultType()) {
|
||||
root.fetch("equipement", jakarta.persistence.criteria.JoinType.LEFT);
|
||||
@@ -67,9 +67,6 @@ public class DotationController {
|
||||
if (fourni != null) {
|
||||
predicates.add(cb.equal(root.get("fourni"), fourni));
|
||||
}
|
||||
if (commandee != null) {
|
||||
predicates.add(cb.equal(root.get("commandee"), commandee));
|
||||
}
|
||||
return cb.and(predicates.toArray(new Predicate[0]));
|
||||
};
|
||||
}
|
||||
@@ -79,36 +76,18 @@ public class DotationController {
|
||||
@RequestParam(required = false) Long equipementId,
|
||||
@RequestParam(required = false) Long categorieId,
|
||||
@RequestParam(required = false) Boolean fourni,
|
||||
@RequestParam(required = false) Boolean commandee,
|
||||
@RequestParam(defaultValue = "0") int page,
|
||||
@RequestParam(defaultValue = "20") int size,
|
||||
Model model) {
|
||||
|
||||
Saison saisonActive = saisonRepository.findByEstActiveTrue().orElse(null);
|
||||
Specification<Dotation> spec = buildSpecification(equipementId, categorieId, fourni, commandee, saisonActive);
|
||||
List<Dotation> allDotations = dotationRepository.findAll(spec);
|
||||
Specification<Dotation> spec = buildSpecification(equipementId, categorieId, fourni, saisonActive);
|
||||
List<Dotation> dotations = dotationRepository.findAll(spec);
|
||||
|
||||
int totalElements = allDotations.size();
|
||||
int totalPages = (int) Math.ceil((double) totalElements / size);
|
||||
if (page < 0) page = 0;
|
||||
if (page >= totalPages && totalPages > 0) page = totalPages - 1;
|
||||
|
||||
int start = page * size;
|
||||
int end = Math.min(start + size, totalElements);
|
||||
List<Dotation> pageContent = (start < totalElements) ? allDotations.subList(start, end) : List.of();
|
||||
|
||||
model.addAttribute("dotations", pageContent);
|
||||
model.addAttribute("dotations", dotations);
|
||||
model.addAttribute("equipements", equipementRepository.findAll());
|
||||
model.addAttribute("categories", categorieRepository.findAll());
|
||||
model.addAttribute("equipementId", equipementId);
|
||||
model.addAttribute("categorieId", categorieId);
|
||||
model.addAttribute("fourni", fourni);
|
||||
model.addAttribute("commandee", commandee);
|
||||
|
||||
model.addAttribute("currentPage", page);
|
||||
model.addAttribute("totalPages", totalPages);
|
||||
model.addAttribute("totalElements", totalElements);
|
||||
model.addAttribute("pageSize", size);
|
||||
|
||||
return "parametrage/equipements_recherche";
|
||||
}
|
||||
@@ -117,11 +96,10 @@ public class DotationController {
|
||||
public ResponseEntity<byte[]> exportRechercheEquipements(
|
||||
@RequestParam(required = false) Long equipementId,
|
||||
@RequestParam(required = false) Long categorieId,
|
||||
@RequestParam(required = false) Boolean fourni,
|
||||
@RequestParam(required = false) Boolean commandee) {
|
||||
@RequestParam(required = false) Boolean fourni) {
|
||||
|
||||
Saison saisonActive = saisonRepository.findByEstActiveTrue().orElse(null);
|
||||
Specification<Dotation> spec = buildSpecification(equipementId, categorieId, fourni, commandee, saisonActive);
|
||||
Specification<Dotation> spec = buildSpecification(equipementId, categorieId, fourni, saisonActive);
|
||||
List<Dotation> dotations = dotationRepository.findAll(spec);
|
||||
|
||||
String csvContent = dotationService.genererCsvSearchEquipement(dotations);
|
||||
@@ -143,7 +121,7 @@ public class DotationController {
|
||||
byte[] csvBytes = csvContent.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentDispositionFormData("attachment", "commande_equipements_regroupee_" + LocalDate.now() + ".csv");
|
||||
headers.setContentDispositionFormData("attachment", "commande_equipements_" + LocalDate.now() + ".csv");
|
||||
headers.setContentType(MediaType.parseMediaType("text/csv; charset=UTF-8"));
|
||||
|
||||
return new ResponseEntity<>(csvBytes, headers, org.springframework.http.HttpStatus.OK);
|
||||
|
||||
+6
-50
@@ -33,78 +33,34 @@ public class EquipementController {
|
||||
|
||||
@GetMapping("/new")
|
||||
public String showCreateForm(Model model) {
|
||||
if (!model.containsAttribute("equipement")) {
|
||||
model.addAttribute("equipement", new Equipement());
|
||||
}
|
||||
model.addAttribute("equipement", new Equipement());
|
||||
return "parametrage/equipements_form";
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/edit")
|
||||
public String showEditForm(@PathVariable Long id, Model model) {
|
||||
if (!model.containsAttribute("equipement")) {
|
||||
Equipement equipement = equipementRepository.findById(id)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Invalid equipment ID: " + id));
|
||||
model.addAttribute("equipement", equipement);
|
||||
}
|
||||
Equipement equipement = equipementRepository.findById(id)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Invalid equipment ID: " + id));
|
||||
model.addAttribute("equipement", equipement);
|
||||
return "parametrage/equipements_form";
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public String saveEquipement(@ModelAttribute("equipement") Equipement equipement,
|
||||
org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) {
|
||||
public String saveEquipement(@ModelAttribute("equipement") Equipement equipement) {
|
||||
|
||||
Saison activeSaison;
|
||||
if (equipement.getId() == null) {
|
||||
activeSaison = saisonRepository.findByEstActiveTrue()
|
||||
Saison activeSaison = saisonRepository.findByEstActiveTrue()
|
||||
.orElseThrow(() -> new IllegalStateException("Aucune saison active trouvée"));
|
||||
equipement.setSaison(activeSaison);
|
||||
} else {
|
||||
Equipement existing = equipementRepository.findById(equipement.getId())
|
||||
.orElseThrow(() -> new IllegalArgumentException("Invalid equipment ID: " + equipement.getId()));
|
||||
equipement.setSaison(existing.getSaison());
|
||||
activeSaison = existing.getSaison();
|
||||
}
|
||||
|
||||
if (activeSaison != null) {
|
||||
for (Equipement e : equipementRepository.findBySaison(activeSaison)) {
|
||||
if (e.getNom().equalsIgnoreCase(equipement.getNom()) && (equipement.getId() == null || !e.getId().equals(equipement.getId()))) {
|
||||
redirectAttributes.addFlashAttribute("errorMessage", "Erreur : L'équipement '" + equipement.getNom() + "' existe déjà pour cette saison.");
|
||||
redirectAttributes.addFlashAttribute("equipement", equipement);
|
||||
return equipement.getId() == null ? "redirect:/equipements/new" : "redirect:/equipements/" + equipement.getId() + "/edit";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
equipementRepository.save(equipement);
|
||||
return "redirect:/equipements";
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/duplicate")
|
||||
public String duplicateEquipement(@PathVariable Long id) {
|
||||
Equipement existing = equipementRepository.findById(id)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Invalid equipment ID: " + id));
|
||||
|
||||
Equipement duplicated = new Equipement();
|
||||
String newNom = existing.getNom() + " (dupliqué)";
|
||||
if (newNom.length() > 100) {
|
||||
newNom = newNom.substring(0, 100);
|
||||
}
|
||||
duplicated.setNom(newNom);
|
||||
duplicated.setReference(existing.getReference());
|
||||
duplicated.setDescription(existing.getDescription());
|
||||
duplicated.setGestionSexe(existing.isGestionSexe());
|
||||
duplicated.setTypePublic(existing.getTypePublic());
|
||||
duplicated.setTaillesDisponibles(existing.getTaillesDisponibles());
|
||||
duplicated.setCouleursDisponibles(existing.getCouleursDisponibles());
|
||||
duplicated.setHasFlocagePrenom(existing.isHasFlocagePrenom());
|
||||
duplicated.setHasFlocageInitiales(existing.isHasFlocageInitiales());
|
||||
duplicated.setHasFlocageNumero(existing.isHasFlocageNumero());
|
||||
duplicated.setSaison(existing.getSaison());
|
||||
|
||||
equipementRepository.save(duplicated);
|
||||
return "redirect:/equipements";
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/delete")
|
||||
public String deleteEquipement(@PathVariable Long id) {
|
||||
Equipement equipement = equipementRepository.findById(id)
|
||||
|
||||
@@ -49,10 +49,7 @@ public class LicenceController {
|
||||
@RequestParam(required = false) String numeroLicence,
|
||||
@RequestParam(required = false) String typeDemande,
|
||||
@RequestParam(required = false) String typeLicence,
|
||||
@RequestParam(required = false) String commentaire,
|
||||
@RequestParam(required = false) Long equipeId,
|
||||
@RequestParam(required = false, defaultValue = "false") Boolean reductionEducateur,
|
||||
@RequestParam(required = false, defaultValue = "100") Integer pourcentageReductionEducateur) {
|
||||
@RequestParam(required = false) Long equipeId) {
|
||||
|
||||
Adherent adherent = adherentRepository.findById(id)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Invalid Adherent ID"));
|
||||
@@ -76,9 +73,6 @@ public class LicenceController {
|
||||
licence.setNumeroLicence(numeroLicence);
|
||||
licence.setTypeDemande(typeDemande);
|
||||
licence.setTypeLicence(typeLicence);
|
||||
licence.setCommentaire(commentaire);
|
||||
licence.setReductionEducateur(Boolean.TRUE.equals(reductionEducateur));
|
||||
licence.setPourcentageReductionEducateur(pourcentageReductionEducateur != null ? pourcentageReductionEducateur : 100);
|
||||
|
||||
if (equipeId != null) {
|
||||
Equipe equipe = equipeRepository.findById(equipeId)
|
||||
@@ -103,10 +97,7 @@ public class LicenceController {
|
||||
@RequestParam(required = false) String numeroLicence,
|
||||
@RequestParam(required = false) String typeDemande,
|
||||
@RequestParam(required = false) String typeLicence,
|
||||
@RequestParam(required = false) String commentaire,
|
||||
@RequestParam(required = false) Long equipeId,
|
||||
@RequestParam(required = false, defaultValue = "false") Boolean reductionEducateur,
|
||||
@RequestParam(required = false, defaultValue = "100") Integer pourcentageReductionEducateur) {
|
||||
@RequestParam(required = false) Long equipeId) {
|
||||
|
||||
Licence licence = licenceRepository.findById(licenceId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Invalid Licence ID"));
|
||||
@@ -119,9 +110,6 @@ public class LicenceController {
|
||||
licence.setNumeroLicence(numeroLicence);
|
||||
licence.setTypeDemande(typeDemande);
|
||||
licence.setTypeLicence(typeLicence);
|
||||
licence.setCommentaire(commentaire);
|
||||
licence.setReductionEducateur(Boolean.TRUE.equals(reductionEducateur));
|
||||
licence.setPourcentageReductionEducateur(pourcentageReductionEducateur != null ? pourcentageReductionEducateur : 100);
|
||||
|
||||
if (equipeId != null) {
|
||||
Equipe equipe = equipeRepository.findById(equipeId)
|
||||
@@ -147,25 +135,14 @@ public class LicenceController {
|
||||
@RequestParam(required = false) String numeroLicence,
|
||||
@RequestParam(required = false) String email,
|
||||
@RequestParam(required = false) String typeDemande,
|
||||
@RequestParam(defaultValue = "0") int page,
|
||||
@RequestParam(defaultValue = "20") int size,
|
||||
org.springframework.ui.Model model) {
|
||||
|
||||
Saison saisonActive = saisonRepository.findByEstActiveTrue().orElse(null);
|
||||
org.springframework.data.jpa.domain.Specification<Licence> spec = buildLicenceSpecification(nom, prenom, categorieId, numeroLicence, email, typeDemande, saisonActive);
|
||||
|
||||
List<Licence> allLicences = licenceRepository.findAll(spec);
|
||||
List<Licence> licences = licenceRepository.findAll(spec);
|
||||
|
||||
int totalElements = allLicences.size();
|
||||
int totalPages = (int) Math.ceil((double) totalElements / size);
|
||||
if (page < 0) page = 0;
|
||||
if (page >= totalPages && totalPages > 0) page = totalPages - 1;
|
||||
|
||||
int start = page * size;
|
||||
int end = Math.min(start + size, totalElements);
|
||||
List<Licence> pageContent = (start < totalElements) ? allLicences.subList(start, end) : List.of();
|
||||
|
||||
model.addAttribute("licences", pageContent);
|
||||
model.addAttribute("licences", licences);
|
||||
model.addAttribute("categories", categorieRepository.findAll());
|
||||
model.addAttribute("nomFilter", nom);
|
||||
model.addAttribute("prenomFilter", prenom);
|
||||
@@ -174,11 +151,6 @@ public class LicenceController {
|
||||
model.addAttribute("emailFilter", email);
|
||||
model.addAttribute("typeDemandeFilter", typeDemande);
|
||||
|
||||
model.addAttribute("currentPage", page);
|
||||
model.addAttribute("totalPages", totalPages);
|
||||
model.addAttribute("totalElements", totalElements);
|
||||
model.addAttribute("pageSize", size);
|
||||
|
||||
return "parametrage/licences_recherche";
|
||||
}
|
||||
|
||||
@@ -197,7 +169,7 @@ public class LicenceController {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append('\ufeff');
|
||||
sb.append("Nom;Prénom;Catégorie;N° Licence;Email;Type de Demande;Réduction Éducateur;Saison;Etat\n");
|
||||
sb.append("Nom;Prénom;Catégorie;N° Licence;Email;Type de Demande;Saison;Etat\n");
|
||||
|
||||
for (Licence l : licences) {
|
||||
String n = l.getAdherent() != null && l.getAdherent().getNom() != null ? l.getAdherent().getNom() : "";
|
||||
@@ -206,7 +178,6 @@ public class LicenceController {
|
||||
String num = l.getNumeroLicence() != null ? l.getNumeroLicence() : "";
|
||||
String e = l.getAdherent() != null && l.getAdherent().getEmail() != null ? l.getAdherent().getEmail() : "";
|
||||
String td = l.getTypeDemande() != null ? l.getTypeDemande() : "";
|
||||
String red = Boolean.TRUE.equals(l.getReductionEducateur()) ? ("-" + l.getPourcentageReductionEducateur() + "%") : "Non";
|
||||
String s = l.getSaison() != null ? l.getSaison().getNom() : "";
|
||||
String etat = l.getEtat() != null ? l.getEtat() : "";
|
||||
|
||||
@@ -216,7 +187,6 @@ public class LicenceController {
|
||||
.append(escapeCsv(num)).append(";")
|
||||
.append(escapeCsv(e)).append(";")
|
||||
.append(escapeCsv(td)).append(";")
|
||||
.append(escapeCsv(red)).append(";")
|
||||
.append(escapeCsv(s)).append(";")
|
||||
.append(escapeCsv(etat)).append("\n");
|
||||
}
|
||||
|
||||
@@ -8,9 +8,6 @@ import com.astalange.core.repository.AuditLogPaiementRepository;
|
||||
import com.astalange.core.repository.LicenceRepository;
|
||||
import com.astalange.core.repository.ModePaiementRepository;
|
||||
import com.astalange.core.repository.PaiementRepository;
|
||||
import com.astalange.core.service.PaiementEmailService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -24,24 +21,16 @@ import java.time.LocalDate;
|
||||
@Controller
|
||||
public class PaiementController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PaiementController.class);
|
||||
|
||||
private final LicenceRepository licenceRepository;
|
||||
private final ModePaiementRepository modePaiementRepository;
|
||||
private final PaiementRepository paiementRepository;
|
||||
private final AuditLogPaiementRepository auditLogPaiementRepository;
|
||||
private final PaiementEmailService paiementEmailService;
|
||||
|
||||
public PaiementController(LicenceRepository licenceRepository,
|
||||
ModePaiementRepository modePaiementRepository,
|
||||
PaiementRepository paiementRepository,
|
||||
AuditLogPaiementRepository auditLogPaiementRepository,
|
||||
PaiementEmailService paiementEmailService) {
|
||||
public PaiementController(LicenceRepository licenceRepository, ModePaiementRepository modePaiementRepository, PaiementRepository paiementRepository, AuditLogPaiementRepository auditLogPaiementRepository) {
|
||||
this.licenceRepository = licenceRepository;
|
||||
this.modePaiementRepository = modePaiementRepository;
|
||||
this.paiementRepository = paiementRepository;
|
||||
this.auditLogPaiementRepository = auditLogPaiementRepository;
|
||||
this.paiementEmailService = paiementEmailService;
|
||||
}
|
||||
|
||||
@PostMapping("/licences/{id}/paiements")
|
||||
@@ -60,8 +49,6 @@ public class PaiementController {
|
||||
ModePaiement mode = modePaiementRepository.findById(modePaiementId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Invalid ModePaiement ID"));
|
||||
|
||||
log.info(">>> [PaiementController] Demande de création de paiement reçue pour Licence ID: {}, Adhérent ID: {}, Montant: {} €", id, adherentId, montant);
|
||||
|
||||
// Validation basique pour ne pas payer plus que le reste à payer
|
||||
if (montant.compareTo(licence.getResteAPayer()) > 0) {
|
||||
montant = licence.getResteAPayer();
|
||||
@@ -79,24 +66,15 @@ public class PaiementController {
|
||||
paiement.setGestionnaire(principal.getName());
|
||||
}
|
||||
paiementRepository.save(paiement);
|
||||
|
||||
licence.addPaiement(paiement);
|
||||
|
||||
AuditLogPaiement auditLog = new AuditLogPaiement();
|
||||
auditLog.setAction("CREATE");
|
||||
auditLog.setUtilisateur(principal != null ? principal.getName() : "Système");
|
||||
auditLog.setPaiementId(paiement.getId());
|
||||
auditLog.setMontant(montant);
|
||||
auditLog.setAdherentNomComplet(licence.getAdherent().getNom() + " " + licence.getAdherent().getPrenom());
|
||||
auditLog.setDetails("Création d'un paiement de " + montant + "€ via " + mode.getNom() + " pour la licence " + (licence.getNumeroLicence() != null ? licence.getNumeroLicence() : "sans numéro"));
|
||||
auditLogPaiementRepository.save(auditLog);
|
||||
|
||||
try {
|
||||
log.info("Appel de sendPaiementConfirmation depuis addPaiement pour le paiement ID: {}", paiement.getId());
|
||||
paiementEmailService.sendPaiementConfirmation(paiement);
|
||||
} catch (Exception e) {
|
||||
log.error("Erreur lors de l'appel à sendPaiementConfirmation: ", e);
|
||||
}
|
||||
|
||||
AuditLogPaiement log = new AuditLogPaiement();
|
||||
log.setAction("CREATE");
|
||||
log.setUtilisateur(principal != null ? principal.getName() : "Système");
|
||||
log.setPaiementId(paiement.getId());
|
||||
log.setMontant(montant);
|
||||
log.setAdherentNomComplet(licence.getAdherent().getNom() + " " + licence.getAdherent().getPrenom());
|
||||
log.setDetails("Création d'un paiement de " + montant + "€ via " + mode.getNom() + " pour la licence " + (licence.getNumeroLicence() != null ? licence.getNumeroLicence() : "sans numéro"));
|
||||
auditLogPaiementRepository.save(log);
|
||||
}
|
||||
|
||||
return "redirect:/adherents/" + adherentId + "/edit";
|
||||
@@ -141,14 +119,14 @@ public class PaiementController {
|
||||
}
|
||||
paiementRepository.save(paiement);
|
||||
|
||||
AuditLogPaiement auditLog = new AuditLogPaiement();
|
||||
auditLog.setAction("UPDATE");
|
||||
auditLog.setUtilisateur(principal != null ? principal.getName() : "Système");
|
||||
auditLog.setPaiementId(paiement.getId());
|
||||
auditLog.setMontant(montant);
|
||||
auditLog.setAdherentNomComplet(licence.getAdherent().getNom() + " " + licence.getAdherent().getPrenom());
|
||||
auditLog.setDetails("Modification du paiement: montant " + ancienMontant + "€ -> " + montant + "€, mode " + ancienMode + " -> " + mode.getNom());
|
||||
auditLogPaiementRepository.save(auditLog);
|
||||
AuditLogPaiement log = new AuditLogPaiement();
|
||||
log.setAction("UPDATE");
|
||||
log.setUtilisateur(principal != null ? principal.getName() : "Système");
|
||||
log.setPaiementId(paiement.getId());
|
||||
log.setMontant(montant);
|
||||
log.setAdherentNomComplet(licence.getAdherent().getNom() + " " + licence.getAdherent().getPrenom());
|
||||
log.setDetails("Modification du paiement: montant " + ancienMontant + "€ -> " + montant + "€, mode " + ancienMode + " -> " + mode.getNom());
|
||||
auditLogPaiementRepository.save(log);
|
||||
}
|
||||
|
||||
if (redirect != null && !redirect.isEmpty()) {
|
||||
@@ -168,14 +146,14 @@ public class PaiementController {
|
||||
|
||||
Long adherentId = paiement.getLicence().getAdherent().getId();
|
||||
|
||||
AuditLogPaiement auditLog = new AuditLogPaiement();
|
||||
auditLog.setAction("DELETE");
|
||||
auditLog.setUtilisateur(principal != null ? principal.getName() : "Système");
|
||||
auditLog.setPaiementId(paiement.getId());
|
||||
auditLog.setMontant(paiement.getMontant());
|
||||
auditLog.setAdherentNomComplet(paiement.getLicence().getAdherent().getNom() + " " + paiement.getLicence().getAdherent().getPrenom());
|
||||
auditLog.setDetails("Suppression du paiement de " + paiement.getMontant() + "€ via " + paiement.getModePaiement().getNom());
|
||||
auditLogPaiementRepository.save(auditLog);
|
||||
AuditLogPaiement log = new AuditLogPaiement();
|
||||
log.setAction("DELETE");
|
||||
log.setUtilisateur(principal != null ? principal.getName() : "Système");
|
||||
log.setPaiementId(paiement.getId());
|
||||
log.setMontant(paiement.getMontant());
|
||||
log.setAdherentNomComplet(paiement.getLicence().getAdherent().getNom() + " " + paiement.getLicence().getAdherent().getPrenom());
|
||||
log.setDetails("Suppression du paiement de " + paiement.getMontant() + "€ via " + paiement.getModePaiement().getNom());
|
||||
auditLogPaiementRepository.save(log);
|
||||
|
||||
paiementRepository.delete(paiement);
|
||||
|
||||
@@ -184,27 +162,4 @@ public class PaiementController {
|
||||
}
|
||||
return "redirect:/adherents/" + adherentId + "/edit";
|
||||
}
|
||||
|
||||
@PostMapping("/paiements/{id}/resend-email")
|
||||
public String resendPaiementEmail(
|
||||
@PathVariable Long id,
|
||||
@RequestParam(required = false) String redirect) {
|
||||
|
||||
log.info(">>> [PaiementController] Demande de renvoi d'e-mail reçue pour le paiement ID: {}", id);
|
||||
|
||||
Paiement paiement = paiementRepository.findById(id)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Invalid Paiement ID"));
|
||||
|
||||
try {
|
||||
log.info("Appel de sendPaiementConfirmation depuis resendPaiementEmail pour le paiement ID: {}", id);
|
||||
paiementEmailService.sendPaiementConfirmation(paiement);
|
||||
} catch (Exception e) {
|
||||
log.error("Erreur lors du renvoi de l'e-mail pour le paiement ID {}: ", id, e);
|
||||
}
|
||||
|
||||
if (redirect != null && !redirect.isEmpty()) {
|
||||
return "redirect:" + redirect;
|
||||
}
|
||||
return "redirect:/adherents/" + paiement.getLicence().getAdherent().getId() + "/edit";
|
||||
}
|
||||
}
|
||||
|
||||
+1
-20
@@ -7,9 +7,7 @@ import com.astalange.core.repository.PreInscriptionRepository;
|
||||
import com.astalange.core.repository.TokenPreInscriptionRepository;
|
||||
import com.astalange.core.repository.SaisonRepository;
|
||||
import com.astalange.core.repository.CategorieRepository;
|
||||
import com.astalange.core.repository.EquipementRepository;
|
||||
import com.astalange.core.entity.Categorie;
|
||||
import com.astalange.core.entity.Equipement;
|
||||
import com.astalange.core.service.CaptchaValidationService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@@ -22,8 +20,6 @@ import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
import java.util.List;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/inscription-public")
|
||||
@@ -34,20 +30,17 @@ public class PublicInscriptionController {
|
||||
private final PreInscriptionRepository preInscriptionRepository;
|
||||
private final SaisonRepository saisonRepository;
|
||||
private final CategorieRepository categorieRepository;
|
||||
private final EquipementRepository equipementRepository;
|
||||
|
||||
public PublicInscriptionController(CaptchaValidationService captchaValidationService,
|
||||
TokenPreInscriptionRepository tokenRepository,
|
||||
PreInscriptionRepository preInscriptionRepository,
|
||||
SaisonRepository saisonRepository,
|
||||
CategorieRepository categorieRepository,
|
||||
EquipementRepository equipementRepository) {
|
||||
CategorieRepository categorieRepository) {
|
||||
this.captchaValidationService = captchaValidationService;
|
||||
this.tokenRepository = tokenRepository;
|
||||
this.preInscriptionRepository = preInscriptionRepository;
|
||||
this.saisonRepository = saisonRepository;
|
||||
this.categorieRepository = categorieRepository;
|
||||
this.equipementRepository = equipementRepository;
|
||||
}
|
||||
|
||||
@Value("${captcha.sitekey:1x00000000000000000000AA}")
|
||||
@@ -104,18 +97,6 @@ public class PublicInscriptionController {
|
||||
|
||||
model.addAttribute("preInscription", new PreInscription());
|
||||
model.addAttribute("tokenUuid", tokenUuid);
|
||||
|
||||
// Fetch tailles and pointures (Standard exhaustive list)
|
||||
Set<String> tailles = new java.util.LinkedHashSet<>(java.util.Arrays.asList(
|
||||
"5/6ANS (Taille 116cm)", "7/8ANS (Taille 128cm)", "9/10ANS (Taille 140cm)",
|
||||
"11/12ANS (Taille 152cm)", "13/14ANS (Taille 164cm)", "XS", "S", "M", "L", "XL", "XXL"
|
||||
));
|
||||
Set<String> pointures = new java.util.LinkedHashSet<>(java.util.Arrays.asList(
|
||||
"27/30 (Taille 0)", "31/34 (Taille 1)", "35/38 (Taille 2)", "39/42 (Taille 3)", "43/46 (Taille 4)"
|
||||
));
|
||||
model.addAttribute("taillesDisponibles", tailles);
|
||||
model.addAttribute("pointuresDisponibles", pointures);
|
||||
|
||||
return "public/formulaire";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.astalange.web.controller;
|
||||
|
||||
import com.astalange.core.entity.AppUser;
|
||||
import com.astalange.core.entity.Role;
|
||||
import com.astalange.core.repository.AppUserRepository;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.core.session.SessionRegistry;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
@@ -11,9 +8,7 @@ import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Controller
|
||||
@@ -21,73 +16,22 @@ import java.util.stream.Collectors;
|
||||
public class SessionController {
|
||||
|
||||
private final SessionRegistry sessionRegistry;
|
||||
private final AppUserRepository userRepository;
|
||||
|
||||
public SessionController(SessionRegistry sessionRegistry, AppUserRepository userRepository) {
|
||||
public SessionController(SessionRegistry sessionRegistry) {
|
||||
this.sessionRegistry = sessionRegistry;
|
||||
this.userRepository = userRepository;
|
||||
}
|
||||
|
||||
public static class UserSessionDTO {
|
||||
private final Long id;
|
||||
private final String username;
|
||||
private final boolean online;
|
||||
private final LocalDateTime lastLoginAt;
|
||||
private final LocalDateTime lastLogoutAt;
|
||||
private final String roles;
|
||||
|
||||
public UserSessionDTO(Long id, String username, boolean online, LocalDateTime lastLoginAt, LocalDateTime lastLogoutAt, String roles) {
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.online = online;
|
||||
this.lastLoginAt = lastLoginAt;
|
||||
this.lastLogoutAt = lastLogoutAt;
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public Long getId() { return id; }
|
||||
public String getUsername() { return username; }
|
||||
public boolean isOnline() { return online; }
|
||||
public LocalDateTime getLastLoginAt() { return lastLoginAt; }
|
||||
public LocalDateTime getLastLogoutAt() { return lastLogoutAt; }
|
||||
public String getRoles() { return roles; }
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
public String viewSessions(Model model) {
|
||||
List<Object> principals = sessionRegistry.getAllPrincipals();
|
||||
Set<String> activeUsernames = principals.stream()
|
||||
List<String> activeUsers = principals.stream()
|
||||
.filter(principal -> principal instanceof UserDetails)
|
||||
.map(principal -> ((UserDetails) principal).getUsername())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
List<AppUser> allUsers = userRepository.findAll();
|
||||
|
||||
List<UserSessionDTO> userSessions = allUsers.stream().map(user -> {
|
||||
boolean isOnline = activeUsernames.contains(user.getUsername());
|
||||
String rolesStr = user.getRoles().stream()
|
||||
.map(Role::getName)
|
||||
.map(r -> r.replace("ROLE_", ""))
|
||||
.collect(Collectors.joining(", "));
|
||||
|
||||
return new UserSessionDTO(
|
||||
user.getId(),
|
||||
user.getUsername(),
|
||||
isOnline,
|
||||
user.getLastLoginAt(),
|
||||
user.getLastLogoutAt(),
|
||||
rolesStr
|
||||
);
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
long activeCount = userSessions.stream().filter(UserSessionDTO::isOnline).count();
|
||||
long offlineCount = userSessions.size() - activeCount;
|
||||
|
||||
model.addAttribute("userSessions", userSessions);
|
||||
model.addAttribute("activeCount", activeCount);
|
||||
model.addAttribute("offlineCount", offlineCount);
|
||||
model.addAttribute("totalCount", userSessions.size());
|
||||
.collect(Collectors.toList());
|
||||
|
||||
model.addAttribute("activeUsers", activeUsers);
|
||||
model.addAttribute("activeCount", activeUsers.size());
|
||||
return "admin/sessions";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,44 +9,17 @@ spring:
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: validate
|
||||
show-sql: false
|
||||
show-sql: true
|
||||
properties:
|
||||
hibernate:
|
||||
format_sql: false
|
||||
format_sql: true
|
||||
flyway:
|
||||
enabled: true
|
||||
locations: classpath:db/migration
|
||||
validate-on-migrate: false
|
||||
mail:
|
||||
host: ${SPRING_MAIL_HOST:localhost}
|
||||
port: ${SPRING_MAIL_PORT:1025}
|
||||
username: ${SPRING_MAIL_USERNAME:}
|
||||
password: ${SPRING_MAIL_PASSWORD:}
|
||||
properties:
|
||||
mail:
|
||||
smtp:
|
||||
auth: ${SPRING_MAIL_PROPERTIES_MAIL_SMTP_AUTH:false}
|
||||
starttls:
|
||||
enable: ${SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_ENABLE:false}
|
||||
connectiontimeout: ${SPRING_MAIL_PROPERTIES_MAIL_SMTP_CONNECTIONTIMEOUT:5000}
|
||||
timeout: ${SPRING_MAIL_PROPERTIES_MAIL_SMTP_TIMEOUT:5000}
|
||||
writetimeout: ${SPRING_MAIL_PROPERTIES_MAIL_SMTP_WRITETIMEOUT:5000}
|
||||
|
||||
server:
|
||||
port: 8080
|
||||
|
||||
app:
|
||||
version: @project.version@
|
||||
mail:
|
||||
from: ${APP_MAIL_FROM:${spring.mail.username:astalange1933@gmail.com}}
|
||||
|
||||
sporteasy:
|
||||
base-url: https://www.sporteasy.net/join/
|
||||
|
||||
logging:
|
||||
level:
|
||||
com.astalange: DEBUG
|
||||
org.hibernate: WARN
|
||||
org.hibernate.SQL: WARN
|
||||
org.hibernate.type.descriptor.sql: WARN
|
||||
|
||||
|
||||
@@ -187,30 +187,6 @@
|
||||
<option value="Senior">Senior</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label for="raisonChangementClub" class="block text-sm font-medium text-gray-700 mb-1">Raison du changement</label>
|
||||
<input type="text" id="raisonChangementClub" th:field="*{raisonChangementClub}"
|
||||
class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-colors">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mt-6">
|
||||
<div>
|
||||
<label for="tailleVetement" class="block text-sm font-medium text-gray-700 mb-1">Taille équipement</label>
|
||||
<input type="text" id="tailleVetement" th:field="*{tailleVetement}"
|
||||
class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-colors">
|
||||
</div>
|
||||
<div>
|
||||
<label for="pointure" class="block text-sm font-medium text-gray-700 mb-1">Pointure chaussettes</label>
|
||||
<input type="text" id="pointure" th:field="*{pointure}"
|
||||
class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-colors">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6" th:classappend="${adherent.typeDemande == 'RENOUVELLEMENT'} ? 'hidden-block' : ''">
|
||||
<label for="commentConnuClub" class="block text-sm font-medium text-gray-700 mb-1">Comment a-t-il connu le club ?</label>
|
||||
<input type="text" id="commentConnuClub" th:field="*{commentConnuClub}"
|
||||
class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-colors">
|
||||
</div>
|
||||
|
||||
<!-- Removed Adresse -->
|
||||
@@ -226,7 +202,7 @@
|
||||
<div th:if="${adherent.id != null}" class="max-w-6xl mx-auto bg-white rounded-xl shadow-sm border border-gray-100 p-8 mt-6">
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<h3 class="text-xl font-bold text-gray-900">Licences de l'adhérent</h3>
|
||||
<button onclick="openLicenceModal()" class="bg-green-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-green-700 transition-colors">
|
||||
<button th:if="${#lists.isEmpty(licences)}" onclick="openLicenceModal()" class="bg-green-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-green-700 transition-colors">
|
||||
+ Ajouter une Licence
|
||||
</button>
|
||||
</div>
|
||||
@@ -251,14 +227,14 @@
|
||||
</tr>
|
||||
<th:block th:each="lic : ${licences}">
|
||||
<tr class="hover:bg-gray-50 border-b border-gray-100 licence-row"
|
||||
th:data-tarif-base="${lic.categorie != null ? lic.categorie.tarifBase : 0}"
|
||||
th:data-tarif-exterieur="${lic.categorie != null ? lic.categorie.tarifExterieur : 0}"
|
||||
th:data-equipements-contrib="${lic.getEquipementsContrib()}"
|
||||
th:data-total-paye="${lic.getSommePayee()}">
|
||||
<td class="py-4 px-4 font-medium text-gray-900" th:text="${lic.saison != null ? lic.saison.nom : '-'}">2024-2025</td>
|
||||
th:data-tarif-base="${lic.categorie.tarifBase}"
|
||||
th:data-tarif-exterieur="${lic.categorie.tarifExterieur}"
|
||||
th:data-equipements-contrib="${lic.getPrixTotal().subtract(adherent.residentTalange ? lic.categorie.tarifBase : lic.categorie.tarifExterieur)}"
|
||||
th:data-total-paye="${lic.getPrixTotal().subtract(lic.getResteAPayer())}">
|
||||
<td class="py-4 px-4 font-medium text-gray-900" th:text="${lic.saison.nom}">2024-2025</td>
|
||||
<td class="py-4 px-4 text-gray-600">
|
||||
<span th:text="${lic.categorie != null ? (lic.categorie.nom + (lic.equipe != null ? ' (' + lic.equipe.nom + ')' : '')) : '-'}">U15</span>
|
||||
<span class="text-[10px] text-gray-400 block cell-tarif-categorie" th:text="${lic.categorie != null ? ((lic.adherent != null && lic.adherent.residentTalange ? lic.categorie.tarifBase : lic.categorie.tarifExterieur) + ' € (Catégorie)') : '-'}">100.00 € (Catégorie)</span>
|
||||
<span th:text="${lic.categorie.nom + (lic.equipe != null ? ' (' + lic.equipe.nom + ')' : '')}">U15</span>
|
||||
<span class="text-[10px] text-gray-400 block cell-tarif-categorie" th:text="${(lic.adherent != null && lic.adherent.residentTalange ? lic.categorie.tarifBase : lic.categorie.tarifExterieur) + ' € (Catégorie)'}">100.00 € (Catégorie)</span>
|
||||
</td>
|
||||
<td class="py-4 px-4 text-gray-600 text-xs">
|
||||
<div th:text="${lic.typeDemande != null ? lic.typeDemande : '-'}">Nouvelle</div>
|
||||
@@ -270,37 +246,22 @@
|
||||
th:classappend="${lic.etat == 'Validée' ? 'bg-blue-100 text-blue-800' : (lic.etat == 'Payée' ? 'bg-green-100 text-green-800' : 'bg-yellow-100 text-yellow-800')}"
|
||||
th:text="${lic.etat}">Brouillon</span>
|
||||
</td>
|
||||
<td class="py-4 px-4 font-medium cell-tarif-global">
|
||||
<div th:if="${lic.reductionEducateur}" class="flex flex-col">
|
||||
<span class="text-[10px] font-bold text-amber-700 bg-amber-50 border border-amber-200 px-2 py-0.5 rounded-full inline-block w-max mb-0.5"
|
||||
th:text="'Éducateur (-' + ${lic.pourcentageReductionEducateur != null ? lic.pourcentageReductionEducateur : 100} + '%)'">Éducateur (-100%)</span>
|
||||
<div class="flex items-center space-x-1 text-xs">
|
||||
<span th:if="${lic.getPrixBrut().compareTo(lic.getPrixTotal()) != 0}" class="line-through text-gray-400" th:text="${lic.getPrixBrut() + ' €'}">150.00 €</span>
|
||||
<span class="text-gray-900 font-bold" th:text="${lic.getPrixTotal() + ' €'}">0.00 €</span>
|
||||
</div>
|
||||
</div>
|
||||
<div th:if="${!lic.reductionEducateur}">
|
||||
<span class="text-gray-900" th:text="${lic.getPrixTotal() + ' €'}">130.00 €</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="py-4 px-4 text-gray-900 font-medium cell-tarif-global" th:text="${lic.getPrixTotal() + ' €'}">130.00 €</td>
|
||||
<td class="py-4 px-4 font-semibold cell-reste-payer"
|
||||
th:classappend="${lic.getResteAPayer().compareTo(T(java.math.BigDecimal).ZERO) == 0 ? 'text-green-600' : 'text-red-600'}"
|
||||
th:classappend="${lic.getResteAPayer() == 0 ? 'text-green-600' : 'text-red-600'}"
|
||||
th:text="${lic.getResteAPayer() + ' €'}">30.00 €</td>
|
||||
<td class="py-4 px-4 text-right flex justify-end space-x-2">
|
||||
<button type="button"
|
||||
th:data-licence-id="${lic.id}"
|
||||
th:data-categorie-id="${lic.categorie != null ? lic.categorie.id : ''}"
|
||||
th:data-numero-licence="${lic.numeroLicence != null ? lic.numeroLicence : ''}"
|
||||
th:data-etat="${lic.etat != null ? lic.etat : 'Brouillon'}"
|
||||
th:data-type-demande="${lic.typeDemande != null ? lic.typeDemande : ''}"
|
||||
th:data-type-licence="${lic.typeLicence != null ? lic.typeLicence : ''}"
|
||||
th:data-categorie-id="${lic.categorie.id}"
|
||||
th:data-numero-licence="${lic.numeroLicence}"
|
||||
th:data-etat="${lic.etat}"
|
||||
th:data-type-demande="${lic.typeDemande}"
|
||||
th:data-type-licence="${lic.typeLicence}"
|
||||
th:data-equipe-id="${lic.equipe != null ? lic.equipe.id : ''}"
|
||||
th:data-commentaire="${lic.commentaire != null ? lic.commentaire : ''}"
|
||||
th:data-reduction-educateur="${lic.reductionEducateur}"
|
||||
th:data-pourcentage-reduction="${lic.pourcentageReductionEducateur != null ? lic.pourcentageReductionEducateur : 100}"
|
||||
onclick="openLicenceModal(this.getAttribute('data-licence-id'), this.getAttribute('data-categorie-id'), this.getAttribute('data-numero-licence'), this.getAttribute('data-etat'), this.getAttribute('data-type-demande'), this.getAttribute('data-type-licence'), this.getAttribute('data-equipe-id'), this.getAttribute('data-commentaire'), this.getAttribute('data-reduction-educateur'), this.getAttribute('data-pourcentage-reduction'))"
|
||||
onclick="openLicenceModal(this.getAttribute('data-licence-id'), this.getAttribute('data-categorie-id'), this.getAttribute('data-numero-licence'), this.getAttribute('data-etat'), this.getAttribute('data-type-demande'), this.getAttribute('data-type-licence'), this.getAttribute('data-equipe-id'))"
|
||||
class="text-blue-600 hover:text-blue-800 font-medium bg-blue-50 px-3 py-1 rounded-lg">Modifier</button>
|
||||
<button th:if="${lic.getResteAPayer().compareTo(T(java.math.BigDecimal).ZERO) > 0}"
|
||||
<button th:if="${lic.getResteAPayer() > 0}"
|
||||
type="button"
|
||||
th:data-licence-id="${lic.id}"
|
||||
th:data-reste-a-payer="${lic.getResteAPayer()}"
|
||||
@@ -341,14 +302,6 @@
|
||||
<td class="py-2 px-3 text-right font-semibold text-green-600" th:text="${paiement.montant + ' €'}">50.00 €</td>
|
||||
<td class="py-2 px-3 text-right pr-4">
|
||||
<div class="flex justify-end items-center space-x-2">
|
||||
<form th:action="@{/paiements/{id}/resend-email(id=${paiement.id})}" method="post" class="inline m-0" onsubmit="return confirm('Renvoyer l\'e-mail de reçu de paiement à l\'adhérent ?');">
|
||||
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}" />
|
||||
<button type="submit" class="text-emerald-600 hover:text-emerald-900 bg-emerald-50 hover:bg-emerald-100 p-1.5 rounded transition-colors inline-flex items-center" title="Renvoyer le reçu par e-mail">
|
||||
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>
|
||||
</svg>
|
||||
</button>
|
||||
</form>
|
||||
<button type="button"
|
||||
th:data-paiement-id="${paiement.id}"
|
||||
th:data-montant="${paiement.montant}"
|
||||
@@ -436,29 +389,25 @@
|
||||
<label class="block text-[9px] uppercase font-bold text-gray-400">Taille</label>
|
||||
<select th:name="'taille_' + ${dot.id}" class="w-full text-xs border border-gray-300 rounded px-1 py-0.5 focus:ring-1 focus:ring-blue-500 outline-none">
|
||||
<option value="">Choisir...</option>
|
||||
<option th:if="${dot.taille != null and !dot.taille.isEmpty() and !#strings.contains(dot.equipement.taillesDisponibles, dot.taille)}"
|
||||
th:value="${dot.taille}"
|
||||
th:text="${dot.taille} + ' (Actuelle)'"
|
||||
selected></option>
|
||||
<option th:each="t : ${#strings.arraySplit(dot.equipement.taillesDisponibles, ',')}"
|
||||
th:value="${#strings.trim(t)}"
|
||||
th:text="${#strings.trim(t)}"
|
||||
th:selected="${dot.isTailleOptionSelected(#strings.trim(t))}"></option>
|
||||
th:selected="${dot.taille == #strings.trim(t)}"></option>
|
||||
</select>
|
||||
</div>
|
||||
<div th:if="${(dot.equipement.taillesDisponibles == null or dot.equipement.taillesDisponibles.trim().isEmpty()) and (dot.taille != null and !dot.taille.isEmpty())}">
|
||||
<label class="block text-[9px] uppercase font-bold text-gray-400">Taille</label>
|
||||
<input type="text" th:name="'taille_' + ${dot.id}" th:value="${dot.taille}" class="w-full text-xs border border-gray-300 rounded px-1 py-0.5 outline-none bg-gray-50 text-gray-500" readonly>
|
||||
</div>
|
||||
|
||||
<div th:if="${dot.equipement.couleursDisponibles != null and !dot.equipement.couleursDisponibles.trim().isEmpty()}">
|
||||
<label class="block text-[9px] uppercase font-bold text-gray-400">Couleur</label>
|
||||
<select th:name="'couleur_' + ${dot.id}" class="w-full text-xs border border-gray-300 rounded px-1 py-0.5 focus:ring-1 focus:ring-blue-500 outline-none">
|
||||
<option value="" th:selected="${dot.couleur == null or dot.couleur.isEmpty()}">Choisir...</option>
|
||||
<option th:if="${dot.couleur != null and !dot.couleur.isEmpty()}"
|
||||
th:value="${dot.couleur}"
|
||||
th:text="${dot.couleur} + ' (Actuelle)'"
|
||||
selected></option>
|
||||
<option value="">Choisir...</option>
|
||||
<option th:each="c : ${#strings.arraySplit(dot.equipement.couleursDisponibles, ',')}"
|
||||
th:if="${dot.couleur == null or dot.couleur != #strings.trim(c)}"
|
||||
th:value="${#strings.trim(c)}"
|
||||
th:text="${#strings.trim(c)}"></option>
|
||||
th:text="${#strings.trim(c)}"
|
||||
th:selected="${dot.couleur == #strings.trim(c)}"></option>
|
||||
</select>
|
||||
</div>
|
||||
<div th:if="${(dot.equipement.couleursDisponibles == null or dot.equipement.couleursDisponibles.trim().isEmpty()) and (dot.couleur != null and !dot.couleur.isEmpty())}">
|
||||
@@ -468,16 +417,16 @@
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-1.5 mb-1.5">
|
||||
<div th:if="${dot.equipement.hasFlocageNumero}">
|
||||
<div>
|
||||
<label class="block text-[9px] uppercase font-bold text-gray-400">Numéro</label>
|
||||
<input type="text" th:name="'numero_' + ${dot.id}" th:value="${dot.numero}" placeholder="Ex: 10"
|
||||
class="w-full text-xs border border-gray-300 rounded px-1 py-0.5 focus:ring-1 focus:ring-blue-500 outline-none">
|
||||
</div>
|
||||
<div th:if="${dot.equipement.hasFlocagePrenom or dot.equipement.hasFlocageInitiales}">
|
||||
<label class="block text-[9px] uppercase font-bold text-gray-400 whitespace-nowrap truncate" title="Flocage" th:text="'Flocage (' + (${dot.equipement.hasFlocagePrenom and dot.equipement.hasFlocageInitiales} ? 'Prénom/Init.' : (${dot.equipement.hasFlocagePrenom} ? 'Prénom' : 'Initiales')) + ')'">Flocage</label>
|
||||
<input type="text" th:name="'flocage_' + ${dot.id}" th:value="${dot.flocage}" placeholder="À floquer"
|
||||
class="w-full text-xs border border-gray-300 rounded px-1 py-0.5 focus:ring-1 focus:ring-blue-500 outline-none">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[9px] uppercase font-bold text-gray-400">Flocage</label>
|
||||
<input type="text" th:name="'flocage_' + ${dot.id}" th:value="${dot.flocage}" placeholder="Nom du joueur"
|
||||
class="w-full text-xs border border-gray-300 rounded px-1 py-0.5 focus:ring-1 focus:ring-blue-500 outline-none">
|
||||
</div>
|
||||
<div class="flex items-center pt-1.5">
|
||||
<label class="flex items-center space-x-1 cursor-pointer select-none">
|
||||
<input type="checkbox" th:name="'fourni_' + ${dot.id}" th:checked="${dot.fourni}" class="w-3.5 h-3.5 text-blue-600 border-gray-300 rounded focus:ring-blue-500">
|
||||
@@ -564,23 +513,6 @@
|
||||
<option value="Payée">Payée</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Commentaire</label>
|
||||
<textarea id="licenceCommentaireInput" name="commentaire" rows="3" class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none" placeholder="Commentaire optionnel..."></textarea>
|
||||
</div>
|
||||
<div class="bg-amber-50 p-3 rounded-lg border border-amber-200">
|
||||
<label class="flex items-center space-x-2 cursor-pointer select-none">
|
||||
<input type="checkbox" id="reductionEducateurInput" name="reductionEducateur" value="true" onchange="toggleReductionPourcentageVisibility()" class="w-4 h-4 text-amber-600 border-gray-300 rounded focus:ring-amber-500">
|
||||
<span class="text-sm font-semibold text-amber-900">Enfant d'éducateur / Réduction</span>
|
||||
</label>
|
||||
<div id="pourcentageReductionBlock" class="hidden mt-2 pt-2 border-t border-amber-200/60">
|
||||
<label class="block text-xs font-medium text-amber-800 mb-1">Taux de réduction (%)</label>
|
||||
<div class="flex items-center space-x-2">
|
||||
<input type="number" id="pourcentageReductionInput" name="pourcentageReductionEducateur" min="1" max="100" value="100" class="w-full border border-gray-300 rounded-lg px-3 py-1.5 text-sm focus:ring-2 focus:ring-amber-500 outline-none">
|
||||
<span class="text-xs font-bold text-amber-800">%</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="items-center px-4 py-3 flex justify-end space-x-2">
|
||||
<button type="button" onclick="closeLicenceModal()" class="px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50">Annuler</button>
|
||||
<button type="submit" class="px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700">Enregistrer</button>
|
||||
@@ -671,17 +603,7 @@
|
||||
</div>
|
||||
|
||||
<script th:inline="javascript">
|
||||
function toggleReductionPourcentageVisibility() {
|
||||
const chk = document.getElementById('reductionEducateurInput');
|
||||
const block = document.getElementById('pourcentageReductionBlock');
|
||||
if (chk && chk.checked) {
|
||||
block.classList.remove('hidden');
|
||||
} else if (block) {
|
||||
block.classList.add('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
function openLicenceModal(licenceId = null, categorieId = '', numeroLicence = '', etat = 'Brouillon', typeDemande = '', typeLicence = '', equipeId = '', commentaire = '', reductionEducateur = false, pourcentageReductionEducateur = 100) {
|
||||
function openLicenceModal(licenceId = null, categorieId = '', numeroLicence = '', etat = 'Brouillon', typeDemande = '', typeLicence = '', equipeId = '') {
|
||||
document.getElementById('licenceModal').classList.remove('hidden');
|
||||
const form = document.getElementById('licenceForm');
|
||||
const title = document.getElementById('licenceModalTitle');
|
||||
@@ -691,16 +613,6 @@
|
||||
|
||||
// Clean up team options first
|
||||
equipeSelect.innerHTML = '<option value="">Aucune équipe</option>';
|
||||
|
||||
const redChk = document.getElementById('reductionEducateurInput');
|
||||
const pctInput = document.getElementById('pourcentageReductionInput');
|
||||
if (redChk) {
|
||||
redChk.checked = (reductionEducateur === true || reductionEducateur === 'true');
|
||||
}
|
||||
if (pctInput) {
|
||||
pctInput.value = (pourcentageReductionEducateur !== null && pourcentageReductionEducateur !== undefined && pourcentageReductionEducateur !== '') ? pourcentageReductionEducateur : 100;
|
||||
}
|
||||
toggleReductionPourcentageVisibility();
|
||||
|
||||
if (licenceId) {
|
||||
title.textContent = 'Modifier la Licence';
|
||||
@@ -710,7 +622,6 @@
|
||||
document.getElementById('etatSelect').value = etat;
|
||||
document.getElementById('typeDemandeSelect').value = typeDemande;
|
||||
document.getElementById('typeLicenceSelect').value = typeLicence;
|
||||
document.getElementById('licenceCommentaireInput').value = commentaire || '';
|
||||
|
||||
// Fetch and populate teams
|
||||
if (categorieId) {
|
||||
@@ -726,7 +637,6 @@
|
||||
form.action = '/adherents/' + adherentId + '/licences';
|
||||
document.getElementById('numeroLicenceInput').value = '';
|
||||
document.getElementById('etatSelect').value = 'Brouillon';
|
||||
document.getElementById('licenceCommentaireInput').value = '';
|
||||
|
||||
// Pré-remplissage du type de demande
|
||||
const adherentTypeDemande = document.getElementById('typeDemande') ? document.getElementById('typeDemande').value : '';
|
||||
|
||||
@@ -29,28 +29,9 @@
|
||||
<div class="flex-1 overflow-auto p-6">
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<h3 class="text-xl font-bold text-gray-900">Liste des Adhérents</h3>
|
||||
<div class="flex items-center space-x-3">
|
||||
<form th:action="@{/adherents/sporteasy-invite-batch}" method="post" onsubmit="return confirm('Envoyer les invitations SportEasy à tous les adhérents non invités de la saison active ?');">
|
||||
<button type="submit" class="bg-indigo-50 text-indigo-700 hover:bg-indigo-100 border border-indigo-200 px-4 py-2 rounded-lg text-sm font-medium transition-colors flex items-center space-x-1.5 shadow-2xs">
|
||||
<svg class="w-4 h-4 text-indigo-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"></path></svg>
|
||||
<span>Inviter sur SportEasy</span>
|
||||
</button>
|
||||
</form>
|
||||
<a th:href="@{/adherents/new}" class="bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-blue-700 transition-colors inline-block">
|
||||
+ Nouvel Adhérent
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Messages d'information -->
|
||||
<div th:if="${successMessage}" class="mb-4 p-4 bg-green-50 border-l-4 border-green-500 rounded-lg text-sm text-green-800 font-medium">
|
||||
<span th:text="${successMessage}"></span>
|
||||
</div>
|
||||
<div th:if="${errorMessage}" class="mb-4 p-4 bg-red-50 border-l-4 border-red-500 rounded-lg text-sm text-red-800 font-medium">
|
||||
<span th:text="${errorMessage}"></span>
|
||||
</div>
|
||||
<div th:if="${infoMessage}" class="mb-4 p-4 bg-blue-50 border-l-4 border-blue-500 rounded-lg text-sm text-blue-800 font-medium">
|
||||
<span th:text="${infoMessage}"></span>
|
||||
<a th:href="@{/adherents/new}" class="bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-blue-700 transition-colors inline-block">
|
||||
+ Nouvel Adhérent
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Table Container with Wrapper-level HTMX triggers for filters -->
|
||||
@@ -74,68 +55,19 @@
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-left border-collapse min-w-[1150px]">
|
||||
<table class="w-full text-left border-collapse min-w-[1000px]">
|
||||
<thead>
|
||||
<tr class="bg-gray-50 text-gray-500 text-sm uppercase tracking-wider border-b border-gray-200">
|
||||
<th class="py-3 px-6 font-medium text-left cursor-pointer hover:bg-gray-100 transition-colors group select-none" onclick="updateSort('nom')">
|
||||
<div class="flex items-center space-x-1">
|
||||
<span>Nom</span>
|
||||
<span th:if="${sortField != 'nom'}"><svg class="w-3.5 h-3.5 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l4-4 4 4m0 6l-4 4-4-4"></path></svg></span>
|
||||
<span th:if="${sortField == 'nom'}">
|
||||
<svg th:if="${sortDirection == 'asc'}" class="w-3.5 h-3.5 text-gray-700" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M5 15l7-7 7 7"></path></svg>
|
||||
<svg th:if="${sortDirection == 'desc'}" class="w-3.5 h-3.5 text-gray-700" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M19 9l-7 7-7-7"></path></svg>
|
||||
</span>
|
||||
</div>
|
||||
</th>
|
||||
<th class="py-3 px-6 font-medium text-left cursor-pointer hover:bg-gray-100 transition-colors group select-none" onclick="updateSort('prenom')">
|
||||
<div class="flex items-center space-x-1">
|
||||
<span>Prénom</span>
|
||||
<span th:if="${sortField != 'prenom'}"><svg class="w-3.5 h-3.5 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l4-4 4 4m0 6l-4 4-4-4"></path></svg></span>
|
||||
<span th:if="${sortField == 'prenom'}">
|
||||
<svg th:if="${sortDirection == 'asc'}" class="w-3.5 h-3.5 text-gray-700" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M5 15l7-7 7 7"></path></svg>
|
||||
<svg th:if="${sortDirection == 'desc'}" class="w-3.5 h-3.5 text-gray-700" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M19 9l-7 7-7-7"></path></svg>
|
||||
</span>
|
||||
</div>
|
||||
</th>
|
||||
<th class="py-3 px-6 font-medium text-left cursor-pointer hover:bg-gray-100 transition-colors group select-none" onclick="updateSort('categorie')">
|
||||
<div class="flex items-center space-x-1">
|
||||
<span>Catégorie</span>
|
||||
<span th:if="${sortField != 'categorie'}"><svg class="w-3.5 h-3.5 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l4-4 4 4m0 6l-4 4-4-4"></path></svg></span>
|
||||
<span th:if="${sortField == 'categorie'}">
|
||||
<svg th:if="${sortDirection == 'asc'}" class="w-3.5 h-3.5 text-gray-700" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M5 15l7-7 7 7"></path></svg>
|
||||
<svg th:if="${sortDirection == 'desc'}" class="w-3.5 h-3.5 text-gray-700" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M19 9l-7 7-7-7"></path></svg>
|
||||
</span>
|
||||
</div>
|
||||
</th>
|
||||
<th class="py-3 px-4 font-medium text-center">Équipements</th>
|
||||
<th class="py-3 px-6 font-medium text-center cursor-pointer hover:bg-gray-100 transition-colors group select-none" onclick="updateSort('licence')">
|
||||
<div class="flex items-center justify-center space-x-1">
|
||||
<span>N° Licence</span>
|
||||
<span th:if="${sortField != 'licence'}"><svg class="w-3.5 h-3.5 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l4-4 4 4m0 6l-4 4-4-4"></path></svg></span>
|
||||
<span th:if="${sortField == 'licence'}">
|
||||
<svg th:if="${sortDirection == 'asc'}" class="w-3.5 h-3.5 text-gray-700" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M5 15l7-7 7 7"></path></svg>
|
||||
<svg th:if="${sortDirection == 'desc'}" class="w-3.5 h-3.5 text-gray-700" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M19 9l-7 7-7-7"></path></svg>
|
||||
</span>
|
||||
</div>
|
||||
</th>
|
||||
<th class="py-3 px-6 font-medium text-left cursor-pointer hover:bg-gray-100 transition-colors group select-none" onclick="updateSort('email')">
|
||||
<div class="flex items-center space-x-1">
|
||||
<span>Email</span>
|
||||
<span th:if="${sortField != 'email'}"><svg class="w-3.5 h-3.5 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l4-4 4 4m0 6l-4 4-4-4"></path></svg></span>
|
||||
<span th:if="${sortField == 'email'}">
|
||||
<svg th:if="${sortDirection == 'asc'}" class="w-3.5 h-3.5 text-gray-700" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M5 15l7-7 7 7"></path></svg>
|
||||
<svg th:if="${sortDirection == 'desc'}" class="w-3.5 h-3.5 text-gray-700" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M19 9l-7 7-7-7"></path></svg>
|
||||
</span>
|
||||
</div>
|
||||
</th>
|
||||
<th class="py-3 px-6 font-medium text-left">Nom</th>
|
||||
<th class="py-3 px-6 font-medium text-left">Prénom</th>
|
||||
<th class="py-3 px-6 font-medium text-left">Catégorie</th>
|
||||
<th class="py-3 px-6 font-medium text-center">N° Licence</th>
|
||||
<th class="py-3 px-6 font-medium text-left">Email</th>
|
||||
<th class="py-3 px-6 font-medium text-center">Paiement</th>
|
||||
<th class="py-3 px-4 font-medium text-center">SportEasy</th>
|
||||
<th class="py-3 px-6 font-medium text-right">Actions</th>
|
||||
</tr>
|
||||
<!-- Filter Row -->
|
||||
<tr id="filter-row" class="bg-gray-100 border-b border-gray-200 text-xs">
|
||||
<input type="hidden" name="sortField" id="sortField" th:value="${sortField}">
|
||||
<input type="hidden" name="sortDirection" id="sortDirection" th:value="${sortDirection}">
|
||||
<td class="py-2 px-3">
|
||||
<input type="text" id="filterNom" name="nom" th:value="${nomFilter}" placeholder="Filtrer Nom..." class="w-full border border-gray-300 rounded px-2 py-1 text-xs focus:ring-1 focus:ring-blue-500 focus:outline-none">
|
||||
</td>
|
||||
@@ -148,14 +80,6 @@
|
||||
<option th:each="cat : ${categories}" th:value="${cat.nom}" th:text="${cat.nom}" th:selected="${categorieFilter == cat.nom}"></option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="py-2 px-3">
|
||||
<select id="filterEquipements" name="equipements" class="w-full border border-gray-300 rounded px-2 py-1 text-xs focus:ring-1 focus:ring-blue-500 focus:outline-none">
|
||||
<option value="">Tous</option>
|
||||
<option value="TOUT_FOURNI" th:selected="${equipementsFilter == 'TOUT_FOURNI'}">Complet (Tous)</option>
|
||||
<option value="PARTIEL" th:selected="${equipementsFilter == 'PARTIEL'}">Partiel</option>
|
||||
<option value="NON_FOURNI" th:selected="${equipementsFilter == 'NON_FOURNI'}">Non fourni</option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="py-2 px-3">
|
||||
<input type="text" id="filterLicence" name="licence" th:value="${licenceFilter}" placeholder="Filtrer N°..." class="w-full border border-gray-300 rounded px-2 py-1 text-xs focus:ring-1 focus:ring-blue-500 focus:outline-none">
|
||||
</td>
|
||||
@@ -170,20 +94,12 @@
|
||||
<option value="AUCUNE" th:selected="${paiementFilter == 'AUCUNE'}">Aucune licence</option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="py-2 px-3">
|
||||
<select id="filterSportEasy" name="sporteasy" class="w-full border border-gray-300 rounded px-2 py-1 text-xs focus:ring-1 focus:ring-blue-500 focus:outline-none">
|
||||
<option value="">Tous</option>
|
||||
<option value="NON_INVITE" th:selected="${sporteasyFilter == 'NON_INVITE'}">Non invité</option>
|
||||
<option value="INVITE" th:selected="${sporteasyFilter == 'INVITE'}">Invité</option>
|
||||
<option value="RENOUVELLEMENT" th:selected="${sporteasyFilter == 'RENOUVELLEMENT'}">Renouvellement</option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="py-2 px-3"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-200 text-sm">
|
||||
<tr th:if="${#lists.isEmpty(adherents)}">
|
||||
<td colspan="9" class="py-8 text-center text-gray-500">Aucun adhérent enregistré.</td>
|
||||
<td colspan="7" class="py-8 text-center text-gray-500">Aucun adhérent enregistré.</td>
|
||||
</tr>
|
||||
<tr th:each="adherent : ${adherents}" class="hover:bg-gray-50 transition-colors adherent-row">
|
||||
<td class="py-4 px-6 font-medium text-gray-900">
|
||||
@@ -197,57 +113,6 @@
|
||||
<td class="py-4 px-6 font-medium text-gray-900" th:text="${adherent.prenom}">Jean</td>
|
||||
<td class="py-4 px-6 text-gray-600 font-medium"
|
||||
th:text="${adherent.getLicenceActuelle() != null ? adherent.getLicenceActuelle().getCategorie().getNom() + (adherent.getLicenceActuelle().getEquipe() != null ? ' (' + adherent.getLicenceActuelle().getEquipe().getNom() + ')' : '') : '-'}">-</td>
|
||||
<!-- Équipements Column -->
|
||||
<td class="py-3 px-4 text-center">
|
||||
<div th:with="choisis=${adherent.getLicenceActuelle() != null ? adherent.getLicenceActuelle().dotations.?[choisi == true] : null}">
|
||||
<div th:if="${choisis != null and !#lists.isEmpty(choisis)}" class="relative inline-block text-left">
|
||||
<button type="button"
|
||||
class="px-2.5 py-1 text-[9px] font-bold rounded-full border uppercase tracking-wider cursor-pointer hover:ring-2 hover:ring-offset-1 hover:ring-indigo-300 transition-all flex items-center space-x-1 mx-auto"
|
||||
th:with="total=${#lists.size(choisis)},
|
||||
fournis=${#lists.size(choisis.?[fourni == true])}"
|
||||
th:classappend="${fournis == total ? 'bg-emerald-100 text-emerald-800 border-emerald-200' : (fournis > 0 ? 'bg-amber-100 text-amber-800 border-amber-200' : 'bg-rose-100 text-rose-800 border-rose-200')}"
|
||||
onclick="toggleEquipementsPopover(this, event)">
|
||||
<span th:text="${fournis == total ? '🟢 Complet (' + fournis + '/' + total + ')' : (fournis > 0 ? '🟠 Partiel (' + fournis + '/' + total + ')' : '🔴 Non fourni (0/' + total + ')')}"
|
||||
th:data-total="${total}" th:data-fournis="${fournis}">
|
||||
Complet (3/3)
|
||||
</span>
|
||||
<svg class="w-3 h-3 text-current opacity-70" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>
|
||||
</button>
|
||||
|
||||
<!-- Popover dropdown -->
|
||||
<div class="hidden absolute left-1/2 -translate-x-1/2 mt-2 w-64 bg-white rounded-xl shadow-xl border border-gray-200 p-3 z-50 text-left transition-all equipement-popover">
|
||||
<div class="flex items-center justify-between pb-2 mb-2 border-b border-gray-100">
|
||||
<span class="text-xs font-semibold text-gray-800 flex items-center space-x-1">
|
||||
<span>Détail Équipements</span>
|
||||
<span class="text-[10px] font-bold text-gray-500 bg-gray-100 px-1.5 py-0.5 rounded-full" th:text="${#lists.size(choisis.?[fourni == true]) + '/' + #lists.size(choisis)}">3/3</span>
|
||||
</span>
|
||||
<button type="button" class="text-gray-400 hover:text-gray-600 text-xs font-bold px-1" onclick="closeAllEquipementPopovers()">×</button>
|
||||
</div>
|
||||
<div class="space-y-1.5 max-h-48 overflow-y-auto pr-0.5">
|
||||
<div th:each="dot : ${choisis}"
|
||||
class="flex items-center justify-between p-2 rounded-lg text-xs border"
|
||||
th:classappend="${dot.fourni ? 'bg-emerald-50/60 border-emerald-100 text-emerald-900' : 'bg-gray-50 border-gray-200 text-gray-700'}">
|
||||
<div class="flex flex-col">
|
||||
<span class="font-medium text-gray-900 leading-tight" th:text="${dot.equipement != null ? dot.equipement.nom : 'Équipement'}">Maillot</span>
|
||||
<div class="text-[10px] text-gray-500 flex flex-wrap items-center gap-1 mt-0.5" th:if="${(dot.taille != null and !dot.taille.isEmpty()) or (dot.flocage != null and !dot.flocage.isEmpty()) or (dot.numero != null and !dot.numero.isEmpty())}">
|
||||
<span th:if="${dot.taille != null and !dot.taille.isEmpty()}" class="font-mono bg-white/80 px-1 py-0.2 rounded border border-gray-200" th:text="'Taille: ' + ${dot.taille}">Taille: M</span>
|
||||
<span th:if="${dot.flocage != null and !dot.flocage.isEmpty()}" class="italic" th:text="${dot.flocage}">Flocage</span>
|
||||
<span th:if="${dot.numero != null and !dot.numero.isEmpty()}" class="font-mono font-bold" th:text="'#' + ${dot.numero}">#10</span>
|
||||
</div>
|
||||
</div>
|
||||
<span class="inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-bold flex-shrink-0"
|
||||
th:classappend="${dot.fourni ? 'bg-emerald-100 text-emerald-800' : 'bg-gray-200 text-gray-600'}">
|
||||
<span th:text="${dot.fourni ? '✓ Fourni' : '✗ Non fourni'}">✓ Fourni</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div th:if="${choisis == null or #lists.isEmpty(choisis)}" class="text-xs text-gray-400 italic">
|
||||
-
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="py-4 px-6 text-center text-gray-600 font-mono text-xs"
|
||||
th:text="${adherent.getLicenceActuelle() != null and adherent.getLicenceActuelle().numeroLicence != null and !adherent.getLicenceActuelle().numeroLicence.isEmpty() ? adherent.getLicenceActuelle().numeroLicence : '-'}">-</td>
|
||||
<td class="py-4 px-6 text-gray-600" th:text="${adherent.email}">jean@example.com</td>
|
||||
@@ -281,37 +146,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<!-- SportEasy Status Column -->
|
||||
<td class="py-3 px-4 text-center">
|
||||
<div th:if="${adherent.getLicenceActuelle() != null}">
|
||||
<div th:if="${adherent.getLicenceActuelle().isRenouvellement()}" class="text-xs text-gray-400 italic">
|
||||
Renouvellement
|
||||
</div>
|
||||
<div th:unless="${adherent.getLicenceActuelle().isRenouvellement()}">
|
||||
<div th:if="${adherent.getLicenceActuelle().getSportEasyEmailSent()}" class="flex flex-col items-center space-y-1">
|
||||
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-semibold bg-emerald-100 text-emerald-800 border border-emerald-200"
|
||||
th:title="${adherent.getLicenceActuelle().getSportEasyEmailSentAt() != null ? 'Envoyé le ' + #temporals.format(adherent.getLicenceActuelle().getSportEasyEmailSentAt(), 'dd/MM/yyyy HH:mm') : 'Invité'}">
|
||||
🟢 Invité
|
||||
</span>
|
||||
<form th:action="@{/adherents/{id}/sporteasy-invite(id=${adherent.id})}" method="post">
|
||||
<input type="hidden" name="force" value="true" />
|
||||
<button type="submit" class="text-[10px] text-gray-500 hover:text-blue-600 underline">Renvoyer</button>
|
||||
</form>
|
||||
</div>
|
||||
<div th:if="${!adherent.getLicenceActuelle().getSportEasyEmailSent()}" class="flex flex-col items-center space-y-1">
|
||||
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-600 border border-gray-200">
|
||||
⚪ Non invité
|
||||
</span>
|
||||
<form th:action="@{/adherents/{id}/sporteasy-invite(id=${adherent.id})}" method="post">
|
||||
<button type="submit" class="text-xs font-medium text-indigo-600 hover:text-indigo-800 bg-indigo-50 hover:bg-indigo-100 px-2.5 py-1 rounded-md border border-indigo-200 transition-colors">Inviter</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div th:if="${adherent.getLicenceActuelle() == null}" class="text-xs text-gray-400 italic">
|
||||
-
|
||||
</div>
|
||||
</td>
|
||||
<td class="py-4 px-6 text-right flex justify-end space-x-3 items-center">
|
||||
<a th:href="@{/adherents/{id}/edit(id=${adherent.id})}" class="text-indigo-600 hover:text-indigo-900 font-medium bg-indigo-50 px-3 py-1 rounded-lg">Voir / Modifier</a>
|
||||
<form th:action="@{/adherents/{id}/delete(id=${adherent.id})}" method="post" onsubmit="return confirm('Supprimer cet adhérent ?');">
|
||||
@@ -383,38 +217,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<script>
|
||||
function updateSort(field) {
|
||||
let sf = document.getElementById('sortField');
|
||||
let sd = document.getElementById('sortDirection');
|
||||
if (sf.value === field) {
|
||||
sd.value = sd.value === 'asc' ? 'desc' : 'asc';
|
||||
} else {
|
||||
sf.value = field;
|
||||
sd.value = 'asc';
|
||||
}
|
||||
sf.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
}
|
||||
|
||||
function toggleEquipementsPopover(btn, event) {
|
||||
if (event) event.stopPropagation();
|
||||
const popover = btn.nextElementSibling;
|
||||
const isVisible = popover && !popover.classList.contains('hidden');
|
||||
closeAllEquipementPopovers();
|
||||
if (popover && !isVisible) {
|
||||
popover.classList.remove('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
function closeAllEquipementPopovers() {
|
||||
document.querySelectorAll('.equipement-popover').forEach(p => p.classList.add('hidden'));
|
||||
}
|
||||
|
||||
document.addEventListener('click', function(event) {
|
||||
if (!event.target.closest('.equipement-popover')) {
|
||||
closeAllEquipementPopovers();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Utilisateurs & Sessions - AS Talange</title>
|
||||
<title>Utilisateurs Connectés - AS Talange</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script src="https://unpkg.com/htmx.org@1.9.11"></script>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
@@ -19,99 +19,41 @@
|
||||
<main class="flex-1 flex flex-col h-screen overflow-hidden">
|
||||
<!-- Header -->
|
||||
<header class="h-16 bg-white border-b border-gray-200 flex items-center justify-between px-6">
|
||||
<h2 class="text-lg font-semibold text-gray-800">Suivi des Connectivité & Sessions</h2>
|
||||
<h2 class="text-lg font-semibold text-gray-800">Utilisateurs Connectés</h2>
|
||||
</header>
|
||||
|
||||
<!-- Main section -->
|
||||
<div class="flex-1 overflow-auto p-6">
|
||||
|
||||
<!-- Cards summary -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6">
|
||||
<div class="bg-white p-5 rounded-xl shadow-sm border border-gray-100 flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-sm font-medium text-gray-500">Total Utilisateurs</p>
|
||||
<p class="text-2xl font-bold text-gray-900 mt-1" th:text="${totalCount}">0</p>
|
||||
</div>
|
||||
<div class="w-10 h-10 rounded-lg bg-blue-50 text-blue-600 flex items-center justify-center font-bold">
|
||||
👥
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white p-5 rounded-xl shadow-sm border border-gray-100 flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-sm font-medium text-gray-500">Sessions Actives (En ligne)</p>
|
||||
<p class="text-2xl font-bold text-green-600 mt-1" th:text="${activeCount}">0</p>
|
||||
</div>
|
||||
<div class="w-10 h-10 rounded-lg bg-green-50 text-green-600 flex items-center justify-center font-bold">
|
||||
🟢
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white p-5 rounded-xl shadow-sm border border-gray-100 flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-sm font-medium text-gray-500">Hors Ligne</p>
|
||||
<p class="text-2xl font-bold text-gray-600 mt-1" th:text="${offlineCount}">0</p>
|
||||
</div>
|
||||
<div class="w-10 h-10 rounded-lg bg-gray-100 text-gray-500 flex items-center justify-center font-bold">
|
||||
⚪
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Header & Action -->
|
||||
<div class="mb-6 flex justify-between items-center">
|
||||
<h3 class="text-xl font-bold text-gray-900">
|
||||
Liste des Utilisateurs
|
||||
Sessions Actives (<span th:text="${activeCount}">0</span>)
|
||||
</h3>
|
||||
<button hx-get="/admin/sessions" hx-target="body" hx-swap="outerHTML" class="bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-blue-700 transition-colors flex items-center space-x-2">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"></path>
|
||||
</svg>
|
||||
<span>Rafraîchir</span>
|
||||
<button hx-get="/admin/sessions" hx-target="body" hx-swap="outerHTML" class="bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-blue-700 transition-colors">
|
||||
Rafraîchir
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- User Table -->
|
||||
<div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
|
||||
<table class="w-full text-left border-collapse">
|
||||
<thead>
|
||||
<tr class="bg-gray-50 text-gray-500 text-xs uppercase tracking-wider border-b border-gray-200">
|
||||
<th class="py-3 px-6 font-medium text-left">Utilisateur</th>
|
||||
<th class="py-3 px-6 font-medium text-left">Rôle(s)</th>
|
||||
<tr class="bg-gray-50 text-gray-500 text-sm uppercase tracking-wider border-b border-gray-200">
|
||||
<th class="py-3 px-6 font-medium text-left">Nom d'utilisateur</th>
|
||||
<th class="py-3 px-6 font-medium text-left">Statut</th>
|
||||
<th class="py-3 px-6 font-medium text-left">Dernière Connexion</th>
|
||||
<th class="py-3 px-6 font-medium text-left">Dernière Déconnexion</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-200 text-sm">
|
||||
<tr th:if="${#lists.isEmpty(userSessions)}">
|
||||
<td colspan="5" class="py-8 text-center text-gray-500">Aucun utilisateur enregistré.</td>
|
||||
<tr th:if="${#lists.isEmpty(activeUsers)}">
|
||||
<td colspan="2" class="py-8 text-center text-gray-500">Aucun utilisateur connecté pour le moment.</td>
|
||||
</tr>
|
||||
<tr th:each="userSession : ${userSessions}" class="hover:bg-gray-50 transition-colors">
|
||||
<tr th:each="username : ${activeUsers}" class="hover:bg-gray-50 transition-colors">
|
||||
<td class="py-4 px-6 font-medium text-gray-900 flex items-center">
|
||||
<div class="w-8 h-8 rounded-full bg-blue-100 text-blue-600 flex items-center justify-center font-bold mr-3 text-xs">
|
||||
<span th:text="${#strings.substring(userSession.username, 0, 1).toUpperCase()}">U</span>
|
||||
<div class="w-8 h-8 rounded-full bg-blue-100 text-blue-600 flex items-center justify-center font-bold mr-3">
|
||||
<span th:text="${#strings.substring(username, 0, 1).toUpperCase()}">U</span>
|
||||
</div>
|
||||
<span th:text="${userSession.username}">username</span>
|
||||
<span th:text="${username}">username</span>
|
||||
</td>
|
||||
<td class="py-4 px-6">
|
||||
<span class="px-2.5 py-0.5 bg-gray-100 text-gray-700 text-xs font-medium rounded border border-gray-200" th:text="${userSession.roles}">ADMIN</span>
|
||||
</td>
|
||||
<td class="py-4 px-6">
|
||||
<span th:if="${userSession.online}" class="inline-flex items-center px-2.5 py-1 bg-green-100 text-green-800 text-xs font-semibold rounded-full">
|
||||
<span class="w-2 h-2 mr-1.5 bg-green-500 rounded-full animate-pulse"></span>
|
||||
En ligne
|
||||
</span>
|
||||
<span th:unless="${userSession.online}" class="inline-flex items-center px-2.5 py-1 bg-gray-100 text-gray-600 text-xs font-medium rounded-full">
|
||||
<span class="w-2 h-2 mr-1.5 bg-gray-400 rounded-full"></span>
|
||||
Hors ligne
|
||||
</span>
|
||||
</td>
|
||||
<td class="py-4 px-6 text-gray-600 font-mono text-xs">
|
||||
<span th:text="${userSession.lastLoginAt != null ? #temporals.format(userSession.lastLoginAt, 'dd/MM/yyyy HH:mm:ss') : 'Jamais'}">01/01/2026 10:00:00</span>
|
||||
</td>
|
||||
<td class="py-4 px-6 text-gray-600 font-mono text-xs">
|
||||
<span th:text="${userSession.lastLogoutAt != null ? #temporals.format(userSession.lastLogoutAt, 'dd/MM/yyyy HH:mm:ss') : '-'}">01/01/2026 12:00:00</span>
|
||||
<span class="px-2 py-1 bg-green-100 text-green-800 text-xs font-semibold rounded-full">En ligne</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -93,15 +93,6 @@
|
||||
<td class="py-4 px-6 text-right font-semibold text-green-600" th:text="${p.montant + ' €'}">50.00 €</td>
|
||||
<td class="py-4 px-6 text-right pr-6">
|
||||
<div class="flex justify-end items-center space-x-2">
|
||||
<form th:action="@{/paiements/{id}/resend-email(id=${p.id})}" method="post" class="inline m-0" onsubmit="return confirm('Renvoyer l\'e-mail de reçu de paiement à l\'adhérent ?');">
|
||||
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}" />
|
||||
<input type="hidden" name="redirect" value="/paiements" />
|
||||
<button type="submit" class="text-emerald-600 hover:text-emerald-900 bg-emerald-50 hover:bg-emerald-100 p-1.5 rounded transition-colors inline-flex items-center" title="Renvoyer le reçu par e-mail">
|
||||
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>
|
||||
</svg>
|
||||
</button>
|
||||
</form>
|
||||
<button type="button"
|
||||
th:data-paiement-id="${p.id}"
|
||||
th:data-montant="${p.montant}"
|
||||
@@ -151,7 +142,7 @@
|
||||
hx-target="#paiements-table-container"
|
||||
hx-select="#paiements-table-container"
|
||||
hx-include="#filter-form"
|
||||
th:attr="hx-vals=|{"page": ${currentPage - 1}}|"
|
||||
th:attr="hx-vals=|{'page': ${currentPage - 1}}|"
|
||||
class="px-3 py-1 border border-gray-300 rounded hover:bg-gray-100 transition-colors">
|
||||
Précédent
|
||||
</button>
|
||||
@@ -166,7 +157,7 @@
|
||||
hx-target="#paiements-table-container"
|
||||
hx-select="#paiements-table-container"
|
||||
hx-include="#filter-form"
|
||||
th:attr="hx-vals=|{"page": ${pageNum}}|"
|
||||
th:attr="hx-vals=|{'page': ${pageNum}}|"
|
||||
th:text="${pageNum + 1}"
|
||||
class="px-3 py-1 rounded transition-colors"
|
||||
th:classappend="${currentPage == pageNum ? 'bg-blue-600 text-white' : 'border border-gray-300 hover:bg-gray-100'}">
|
||||
@@ -181,7 +172,7 @@
|
||||
hx-target="#paiements-table-container"
|
||||
hx-select="#paiements-table-container"
|
||||
hx-include="#filter-form"
|
||||
th:attr="hx-vals=|{"page": ${currentPage + 1}}|"
|
||||
th:attr="hx-vals=|{'page': ${currentPage + 1}}|"
|
||||
class="px-3 py-1 border border-gray-300 rounded hover:bg-gray-100 transition-colors">
|
||||
Suivant
|
||||
</button>
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
<form th:action="@{/categories}" th:object="${categorie}" method="post" class="space-y-6">
|
||||
<input type="hidden" th:field="*{id}" />
|
||||
|
||||
<div th:if="${errorMessage}" class="bg-red-50 border-l-4 border-red-500 p-4 mb-6">
|
||||
<p class="text-sm text-red-700" th:text="${errorMessage}"></p>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Nom (ex: U15)</label>
|
||||
@@ -64,13 +60,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="sportEasyToken" class="block text-sm font-medium text-gray-700 mb-1">Lien d'invitation SportEasy de la catégorie</label>
|
||||
<input type="text" id="sportEasyToken" th:field="*{sportEasyToken}" placeholder="ex: https://www.sporteasy.net/join/XXXXXX"
|
||||
class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-colors">
|
||||
<p class="text-xs text-gray-500 mt-1">Saisissez le lien direct d'invitation SportEasy spécifique à cette catégorie.</p>
|
||||
</div>
|
||||
|
||||
<div class="pt-4 border-t border-gray-100">
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">Équipements liés à la catégorie</label>
|
||||
|
||||
|
||||
@@ -56,9 +56,6 @@
|
||||
<td class="py-4 px-6 text-right font-medium text-purple-600" th:text="${cat.tarifExterieur != null ? cat.tarifExterieur + ' €' : '-'}">130.00 €</td>
|
||||
<td class="py-4 px-6 text-right flex justify-end space-x-3 items-center">
|
||||
<a th:href="@{/categories/{id}/edit(id=${cat.id})}" class="text-indigo-600 hover:text-indigo-900 font-medium bg-indigo-50 px-3 py-1 rounded-lg">Modifier</a>
|
||||
<form th:action="@{/categories/{id}/duplicate(id=${cat.id})}" method="post">
|
||||
<button type="submit" class="text-green-600 hover:text-green-800 font-medium bg-green-50 px-3 py-1 rounded-lg">Dupliquer</button>
|
||||
</form>
|
||||
<form th:action="@{/categories/{id}/delete(id=${cat.id})}" method="post" onsubmit="return confirm('Supprimer cette catégorie ?');">
|
||||
<button type="submit" class="text-red-600 hover:text-red-800 font-medium">Supprimer</button>
|
||||
</form>
|
||||
|
||||
@@ -19,9 +19,6 @@
|
||||
|
||||
<div class="flex-1 overflow-auto p-6">
|
||||
<div class="max-w-xl mx-auto bg-white rounded-xl shadow-sm border border-gray-100 p-8">
|
||||
<div th:if="${errorMessage}" class="bg-red-50 border-l-4 border-red-500 p-4 mb-6">
|
||||
<p class="text-sm text-red-700" th:text="${errorMessage}"></p>
|
||||
</div>
|
||||
<form th:action="@{/equipements}" th:object="${equipement}" method="post" class="space-y-6">
|
||||
<input type="hidden" th:field="*{id}" />
|
||||
|
||||
@@ -59,32 +56,8 @@
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Tailles disponibles</label>
|
||||
|
||||
<div class="mb-2">
|
||||
<select id="grilleTailles" class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none bg-gray-50" onchange="applyGrilleTailles()">
|
||||
<option value="">-- Utiliser une grille prédéfinie --</option>
|
||||
<option value="5/6ANS (Taille 116cm),7/8ANS (Taille 128cm),9/10ANS (Taille 140cm),11/12ANS (Taille 152cm),13/14ANS (Taille 164cm)">Vêtements Junior</option>
|
||||
<option value="XS,S,M,L,XL,XXL">Vêtements Adulte</option>
|
||||
<option value="5/6ANS (Taille 116cm),7/8ANS (Taille 128cm),9/10ANS (Taille 140cm),11/12ANS (Taille 152cm),13/14ANS (Taille 164cm),XS,S,M,L,XL,XXL">Vêtements (Junior + Adulte)</option>
|
||||
<option value="27/30 (Taille 0),31/34 (Taille 1),35/38 (Taille 2),39/42 (Taille 3)">Pointures Junior</option>
|
||||
<option value="35/38 (Taille 2),39/42 (Taille 3),43/46 (Taille 4)">Pointures Adulte</option>
|
||||
<option value="27/30 (Taille 0),31/34 (Taille 1),35/38 (Taille 2),39/42 (Taille 3),43/46 (Taille 4)">Pointures (Junior + Adulte)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<input type="text" id="taillesDisponibles" th:field="*{taillesDisponibles}" placeholder="ex: XS, S, M, L, XL ou 5/6 ANS, 7/8 ANS..." class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none">
|
||||
<p class="text-xs text-gray-500 mt-1">Séparez les tailles par des virgules. Vous pouvez utiliser une grille ci-dessus et ajuster manuellement.</p>
|
||||
|
||||
<script>
|
||||
function applyGrilleTailles() {
|
||||
const select = document.getElementById('grilleTailles');
|
||||
const input = document.getElementById('taillesDisponibles');
|
||||
if (select.value) {
|
||||
input.value = select.value;
|
||||
select.value = ''; // Reset select after applying
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<input type="text" th:field="*{taillesDisponibles}" placeholder="ex: XS, S, M, L, XL ou 5/6 ANS, 7/8 ANS..." class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none">
|
||||
<p class="text-xs text-gray-500 mt-1">Séparez les tailles par des virgules. Laissez vide si taille unique ou standard.</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@@ -94,24 +67,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pt-4 border-t border-gray-100">
|
||||
<h3 class="text-sm font-medium text-gray-900 mb-4">Options de personnalisation (Flocage)</h3>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-center">
|
||||
<input type="checkbox" th:field="*{hasFlocagePrenom}" class="w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500">
|
||||
<label class="ml-2 block text-sm text-gray-700">Flocage : Prénom du joueur</label>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<input type="checkbox" th:field="*{hasFlocageInitiales}" class="w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500">
|
||||
<label class="ml-2 block text-sm text-gray-700">Flocage : Initiales du joueur</label>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<input type="checkbox" th:field="*{hasFlocageNumero}" class="w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500">
|
||||
<label class="ml-2 block text-sm text-gray-700">Flocage : Numéro</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pt-4 flex justify-end space-x-3 border-t border-gray-100">
|
||||
<a th:href="@{/equipements}" class="px-4 py-2 text-sm font-medium text-gray-700 border border-gray-300 rounded-lg hover:bg-gray-50">Annuler</a>
|
||||
<button type="submit" class="px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700">Enregistrer</button>
|
||||
|
||||
@@ -44,9 +44,6 @@
|
||||
<td class="py-4 px-6 text-gray-600" th:text="${equip.description != null ? equip.description : '-'}">Maillot de match officiel</td>
|
||||
<td class="py-4 px-6 text-right flex justify-end space-x-3 items-center">
|
||||
<a th:href="@{/equipements/{id}/edit(id=${equip.id})}" class="text-indigo-600 hover:text-indigo-900 font-medium bg-indigo-50 px-3 py-1 rounded-lg">Modifier</a>
|
||||
<form th:action="@{/equipements/{id}/duplicate(id=${equip.id})}" method="post">
|
||||
<button type="submit" class="text-green-600 hover:text-green-800 font-medium bg-green-50 px-3 py-1 rounded-lg">Dupliquer</button>
|
||||
</form>
|
||||
<form th:action="@{/equipements/{id}/delete(id=${equip.id})}" method="post" onsubmit="return confirm('Supprimer cet équipement ? Cela supprimera également les dotations associées de toutes les licences.');">
|
||||
<button type="submit" class="text-red-600 hover:text-red-800 font-medium">Supprimer</button>
|
||||
</form>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
<div class="bg-white p-6 rounded-lg border border-gray-200 shadow-sm mb-6">
|
||||
<form th:action="@{/admin/equipements/recherche}" method="get" class="space-y-4">
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-4">
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Équipement</label>
|
||||
<select name="equipementId" class="w-full border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm px-3 py-2 border">
|
||||
@@ -44,33 +44,15 @@
|
||||
<option value="false" th:selected="${fourni != null && !fourni}">Non</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Commandé</label>
|
||||
<select name="commandee" class="w-full border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm px-3 py-2 border">
|
||||
<option value="">Tous</option>
|
||||
<option value="false" th:selected="${commandee != null && !commandee}">Non commandé</option>
|
||||
<option value="true" th:selected="${commandee != null && commandee}">Commandé</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center pt-2">
|
||||
<a th:href="@{/admin/equipements/export-commande}"
|
||||
onclick="return confirm('Exporter les équipements non encore commandés et les marquer comme commandés ?');"
|
||||
class="bg-indigo-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-indigo-700 flex items-center space-x-1 shadow-sm">
|
||||
<svg class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
|
||||
</svg>
|
||||
Exporter Commande Équipementier (Regroupé)
|
||||
</a>
|
||||
<div class="flex space-x-3">
|
||||
<button type="submit" class="bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-blue-700">Rechercher</button>
|
||||
<a th:href="@{/admin/equipements/recherche/export(equipementId=${equipementId},categorieId=${categorieId},fourni=${fourni},commandee=${commandee})}" class="bg-green-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-green-700">Exporter Recherche</a>
|
||||
</div>
|
||||
<div class="flex justify-end space-x-3">
|
||||
<button type="submit" class="bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-blue-700">Rechercher</button>
|
||||
<a th:href="@{/admin/equipements/recherche/export(equipementId=${equipementId},categorieId=${categorieId},fourni=${fourni})}" class="bg-green-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-green-700">Exporter</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="equipements-table-container" class="bg-white rounded-lg border border-gray-200 overflow-hidden">
|
||||
<div class="bg-white rounded-lg border border-gray-200 overflow-hidden">
|
||||
<table class="w-full text-left border-collapse">
|
||||
<thead>
|
||||
<tr class="bg-gray-50 text-gray-500 text-xs uppercase tracking-wider border-b border-gray-200">
|
||||
@@ -80,13 +62,12 @@
|
||||
<th class="py-3 px-4 font-medium text-left">Équipement</th>
|
||||
<th class="py-3 px-4 font-medium text-left">Référence</th>
|
||||
<th class="py-3 px-4 font-medium text-left">Taille / Floc.</th>
|
||||
<th class="py-3 px-4 font-medium text-center">Commandé</th>
|
||||
<th class="py-3 px-4 font-medium text-center">Fourni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-200 text-sm">
|
||||
<tr th:if="${#lists.isEmpty(dotations)}">
|
||||
<td colspan="8" class="py-8 text-center text-gray-500">Aucun résultat trouvé pour cette recherche.</td>
|
||||
<td colspan="6" class="py-8 text-center text-gray-500">Aucun résultat trouvé pour cette recherche.</td>
|
||||
</tr>
|
||||
<tr th:each="dotation : ${dotations}" class="hover:bg-gray-50">
|
||||
<td class="py-3 px-4 font-medium text-gray-900">
|
||||
@@ -104,12 +85,6 @@
|
||||
<div th:if="${dotation.flocage != null && !dotation.flocage.isEmpty()}" th:text="'F: ' + ${dotation.flocage}">Flocage</div>
|
||||
<div th:if="${dotation.numero != null && !dotation.numero.isEmpty()}" th:text="'N: ' + ${dotation.numero}">N°</div>
|
||||
</td>
|
||||
<td class="py-3 px-4 text-center">
|
||||
<span th:if="${dotation.commandee}" class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-800" th:title="${dotation.dateCommande != null ? #temporals.format(dotation.dateCommande, 'dd/MM/yyyy HH:mm') : ''}">
|
||||
Oui <span th:if="${dotation.dateCommande != null}" class="ml-1 text-[10px] text-blue-600" th:text="'(' + ${#temporals.format(dotation.dateCommande, 'dd/MM')} + ')'"></span>
|
||||
</span>
|
||||
<span th:unless="${dotation.commandee}" class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-100 text-gray-600">Non</span>
|
||||
</td>
|
||||
<td class="py-3 px-4 text-center">
|
||||
<span th:if="${dotation.fourni}" class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800">Oui</span>
|
||||
<span th:unless="${dotation.fourni}" class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-red-100 text-red-800">Non</span>
|
||||
@@ -117,64 +92,6 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- Pagination Footer -->
|
||||
<div class="px-6 py-4 border-t border-gray-200 flex items-center justify-between bg-gray-50 text-sm text-gray-700">
|
||||
<div th:if="${totalElements > 0}">
|
||||
Affichage de <span class="font-semibold" th:text="${currentPage * pageSize + 1}">1</span> à
|
||||
<span class="font-semibold" th:text="${T(java.lang.Math).min((currentPage + 1) * pageSize, totalElements)}">20</span> sur
|
||||
<span class="font-semibold" th:text="${totalElements}">100</span> équipements
|
||||
</div>
|
||||
<div th:if="${totalElements == 0}">
|
||||
Aucun équipement à afficher
|
||||
</div>
|
||||
<div class="flex items-center space-x-2" th:if="${totalPages > 1}">
|
||||
<!-- Page Précédente -->
|
||||
<a th:if="${currentPage > 0}"
|
||||
th:href="@{/admin/equipements/recherche(equipementId=${equipementId},categorieId=${categorieId},fourni=${fourni},commandee=${commandee},page=${currentPage - 1})}"
|
||||
hx-get="/admin/equipements/recherche"
|
||||
hx-target="#equipements-table-container"
|
||||
hx-select="#equipements-table-container"
|
||||
hx-push-url="true"
|
||||
th:attr="hx-vals=|{"equipementId": "${equipementId != null ? equipementId : ''}", "categorieId": "${categorieId != null ? categorieId : ''}", "fourni": "${fourni != null ? fourni : ''}", "commandee": "${commandee != null ? commandee : ''}", "page": ${currentPage - 1}}|"
|
||||
class="px-3 py-1 border border-gray-300 rounded hover:bg-gray-100 transition-colors">
|
||||
Précédent
|
||||
</a>
|
||||
<span th:if="${currentPage == 0}" class="px-3 py-1 border border-gray-200 rounded text-gray-400 bg-gray-50 cursor-not-allowed">
|
||||
Précédent
|
||||
</span>
|
||||
|
||||
<!-- Numéros de pages -->
|
||||
<th:block th:each="pageNum : ${#numbers.sequence(0, totalPages - 1)}" th:if="${totalPages > 0}">
|
||||
<a th:href="@{/admin/equipements/recherche(equipementId=${equipementId},categorieId=${categorieId},fourni=${fourni},commandee=${commandee},page=${pageNum})}"
|
||||
hx-get="/admin/equipements/recherche"
|
||||
hx-target="#equipements-table-container"
|
||||
hx-select="#equipements-table-container"
|
||||
hx-push-url="true"
|
||||
th:attr="hx-vals=|{"equipementId": "${equipementId != null ? equipementId : ''}", "categorieId": "${categorieId != null ? categorieId : ''}", "fourni": "${fourni != null ? fourni : ''}", "commandee": "${commandee != null ? commandee : ''}", "page": ${pageNum}}|"
|
||||
th:text="${pageNum + 1}"
|
||||
class="px-3 py-1 rounded transition-colors"
|
||||
th:classappend="${currentPage == pageNum ? 'bg-blue-600 text-white' : 'border border-gray-300 hover:bg-gray-100'}">
|
||||
1
|
||||
</a>
|
||||
</th:block>
|
||||
|
||||
<!-- Page Suivante -->
|
||||
<a th:if="${currentPage < totalPages - 1}"
|
||||
th:href="@{/admin/equipements/recherche(equipementId=${equipementId},categorieId=${categorieId},fourni=${fourni},commandee=${commandee},page=${currentPage + 1})}"
|
||||
hx-get="/admin/equipements/recherche"
|
||||
hx-target="#equipements-table-container"
|
||||
hx-select="#equipements-table-container"
|
||||
hx-push-url="true"
|
||||
th:attr="hx-vals=|{"equipementId": "${equipementId != null ? equipementId : ''}", "categorieId": "${categorieId != null ? categorieId : ''}", "fourni": "${fourni != null ? fourni : ''}", "commandee": "${commandee != null ? commandee : ''}", "page": ${currentPage + 1}}|"
|
||||
class="px-3 py-1 border border-gray-300 rounded hover:bg-gray-100 transition-colors">
|
||||
Suivant
|
||||
</a>
|
||||
<span th:if="${currentPage == totalPages - 1}" class="px-3 py-1 border border-gray-200 rounded text-gray-400 bg-gray-50 cursor-not-allowed">
|
||||
Suivant
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="licences-table-container" class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
|
||||
<div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-left border-collapse min-w-[900px]">
|
||||
<thead>
|
||||
@@ -86,10 +86,7 @@
|
||||
</td>
|
||||
<td class="py-3 px-4 text-gray-600" th:text="${licence.categorie != null ? licence.categorie.nom : '-'}">Catégorie</td>
|
||||
<td class="py-3 px-4 text-gray-600 font-mono" th:text="${licence.numeroLicence != null ? licence.numeroLicence : '-'}">N°</td>
|
||||
<td class="py-3 px-4 text-gray-600">
|
||||
<div th:text="${licence.typeDemande != null ? licence.typeDemande : '-'}">Type</div>
|
||||
<span th:if="${licence.reductionEducateur}" class="text-[10px] font-bold text-amber-700 bg-amber-50 border border-amber-200 px-1.5 py-0.5 rounded-full inline-block mt-0.5" th:text="'Éducateur (-' + ${licence.pourcentageReductionEducateur} + '%)'">Éducateur (-100%)</span>
|
||||
</td>
|
||||
<td class="py-3 px-4 text-gray-600" th:text="${licence.typeDemande != null ? licence.typeDemande : '-'}">Type</td>
|
||||
<td class="py-3 px-4 text-gray-600" th:text="${licence.adherent.email != null ? licence.adherent.email : '-'}">Email</td>
|
||||
<td class="py-3 px-4 text-gray-600" th:text="${licence.etat != null ? licence.etat : '-'}">Etat</td>
|
||||
<td class="py-3 px-4 text-right">
|
||||
@@ -99,64 +96,6 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Pagination Footer -->
|
||||
<div class="px-6 py-4 border-t border-gray-200 flex items-center justify-between bg-gray-50 text-sm text-gray-700">
|
||||
<div th:if="${totalElements > 0}">
|
||||
Affichage de <span class="font-semibold" th:text="${currentPage * pageSize + 1}">1</span> à
|
||||
<span class="font-semibold" th:text="${T(java.lang.Math).min((currentPage + 1) * pageSize, totalElements)}">20</span> sur
|
||||
<span class="font-semibold" th:text="${totalElements}">100</span> licences
|
||||
</div>
|
||||
<div th:if="${totalElements == 0}">
|
||||
Aucune licence à afficher
|
||||
</div>
|
||||
<div class="flex items-center space-x-2" th:if="${totalPages > 1}">
|
||||
<!-- Page Précédente -->
|
||||
<a th:if="${currentPage > 0}"
|
||||
th:href="@{/admin/licences/recherche(nom=${nomFilter},prenom=${prenomFilter},categorieId=${categorieId},numeroLicence=${numeroLicenceFilter},email=${emailFilter},typeDemande=${typeDemandeFilter},page=${currentPage - 1})}"
|
||||
hx-get="/admin/licences/recherche"
|
||||
hx-target="#licences-table-container"
|
||||
hx-select="#licences-table-container"
|
||||
hx-push-url="true"
|
||||
th:attr="hx-vals=|{"nom": "${nomFilter != null ? nomFilter : ''}", "prenom": "${prenomFilter != null ? prenomFilter : ''}", "categorieId": "${categorieId != null ? categorieId : ''}", "numeroLicence": "${numeroLicenceFilter != null ? numeroLicenceFilter : ''}", "email": "${emailFilter != null ? emailFilter : ''}", "typeDemande": "${typeDemandeFilter != null ? typeDemandeFilter : ''}", "page": ${currentPage - 1}}|"
|
||||
class="px-3 py-1 border border-gray-300 rounded hover:bg-gray-100 transition-colors">
|
||||
Précédent
|
||||
</a>
|
||||
<span th:if="${currentPage == 0}" class="px-3 py-1 border border-gray-200 rounded text-gray-400 bg-gray-50 cursor-not-allowed">
|
||||
Précédent
|
||||
</span>
|
||||
|
||||
<!-- Numéros de pages -->
|
||||
<th:block th:each="pageNum : ${#numbers.sequence(0, totalPages - 1)}" th:if="${totalPages > 0}">
|
||||
<a th:href="@{/admin/licences/recherche(nom=${nomFilter},prenom=${prenomFilter},categorieId=${categorieId},numeroLicence=${numeroLicenceFilter},email=${emailFilter},typeDemande=${typeDemandeFilter},page=${pageNum})}"
|
||||
hx-get="/admin/licences/recherche"
|
||||
hx-target="#licences-table-container"
|
||||
hx-select="#licences-table-container"
|
||||
hx-push-url="true"
|
||||
th:attr="hx-vals=|{"nom": "${nomFilter != null ? nomFilter : ''}", "prenom": "${prenomFilter != null ? prenomFilter : ''}", "categorieId": "${categorieId != null ? categorieId : ''}", "numeroLicence": "${numeroLicenceFilter != null ? numeroLicenceFilter : ''}", "email": "${emailFilter != null ? emailFilter : ''}", "typeDemande": "${typeDemandeFilter != null ? typeDemandeFilter : ''}", "page": ${pageNum}}|"
|
||||
th:text="${pageNum + 1}"
|
||||
class="px-3 py-1 rounded transition-colors"
|
||||
th:classappend="${currentPage == pageNum ? 'bg-blue-600 text-white' : 'border border-gray-300 hover:bg-gray-100'}">
|
||||
1
|
||||
</a>
|
||||
</th:block>
|
||||
|
||||
<!-- Page Suivante -->
|
||||
<a th:if="${currentPage < totalPages - 1}"
|
||||
th:href="@{/admin/licences/recherche(nom=${nomFilter},prenom=${prenomFilter},categorieId=${categorieId},numeroLicence=${numeroLicenceFilter},email=${emailFilter},typeDemande=${typeDemandeFilter},page=${currentPage + 1})}"
|
||||
hx-get="/admin/licences/recherche"
|
||||
hx-target="#licences-table-container"
|
||||
hx-select="#licences-table-container"
|
||||
hx-push-url="true"
|
||||
th:attr="hx-vals=|{"nom": "${nomFilter != null ? nomFilter : ''}", "prenom": "${prenomFilter != null ? prenomFilter : ''}", "categorieId": "${categorieId != null ? categorieId : ''}", "numeroLicence": "${numeroLicenceFilter != null ? numeroLicenceFilter : ''}", "email": "${emailFilter != null ? emailFilter : ''}", "typeDemande": "${typeDemandeFilter != null ? typeDemandeFilter : ''}", "page": ${currentPage + 1}}|"
|
||||
class="px-3 py-1 border border-gray-300 rounded hover:bg-gray-100 transition-colors">
|
||||
Suivant
|
||||
</a>
|
||||
<span th:if="${currentPage == totalPages - 1}" class="px-3 py-1 border border-gray-200 rounded text-gray-400 bg-gray-50 cursor-not-allowed">
|
||||
Suivant
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
@@ -55,11 +55,6 @@
|
||||
<input type="text" id="ancienClub" th:field="*{ancienClub}" class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none" placeholder="Nom du club (laisser vide si aucun)">
|
||||
</div>
|
||||
|
||||
<div id="raisonChangementClubBlock" class="hidden">
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Raison du changement de club <span class="text-red-500">*</span></label>
|
||||
<input type="text" id="raisonChangementClub" th:field="*{raisonChangementClub}" class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none" placeholder="Pourquoi souhaitez-vous nous rejoindre ?">
|
||||
</div>
|
||||
|
||||
<div id="ancienneCategorieBlock" class="hidden">
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Ancienne catégorie <span class="text-red-500">*</span></label>
|
||||
<select id="ancienneCategorie" th:field="*{ancienneCategorie}" class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none">
|
||||
@@ -91,11 +86,6 @@
|
||||
<li>Pour les adhérents nés à l'étranger : Passeport + justificatif de domicile (du représentant légal en cas de mineur)</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Comment avez-vous connu l'AS Talange ?</label>
|
||||
<input type="text" th:field="*{commentConnuClub}" class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none" placeholder="Ex: Réseaux sociaux, amis, forum des associations...">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
@@ -162,25 +152,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Taille de vêtement souhaitée (équipement)</label>
|
||||
<select th:field="*{tailleVetement}" class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none">
|
||||
<option value="">Sélectionnez une taille...</option>
|
||||
<option th:each="taille : ${taillesDisponibles}" th:value="${taille}" th:text="${taille}"></option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Pointure souhaitée (chaussettes)</label>
|
||||
<select th:field="*{pointure}" class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none">
|
||||
<option value="">Sélectionnez une pointure...</option>
|
||||
<option th:each="pt : ${pointuresDisponibles}" th:value="${pt}" th:text="${pt}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="flex items-start pt-2">
|
||||
<div class="flex items-center h-5">
|
||||
<input id="consentementRgpd" name="consentementRgpd" type="checkbox" required class="w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500">
|
||||
@@ -250,29 +221,21 @@
|
||||
const ancienClubInput = document.getElementById('ancienClub');
|
||||
const ancienneCategorieBlock = document.getElementById('ancienneCategorieBlock');
|
||||
const ancienneCategorieSelect = document.getElementById('ancienneCategorie');
|
||||
const raisonChangementClubBlock = document.getElementById('raisonChangementClubBlock');
|
||||
const raisonChangementClubInput = document.getElementById('raisonChangementClub');
|
||||
|
||||
if (ancienClubInput) {
|
||||
ancienClubInput.addEventListener('input', function() {
|
||||
if (this.value.trim().length > 0) {
|
||||
ancienneCategorieBlock.classList.remove('hidden');
|
||||
ancienneCategorieSelect.required = true;
|
||||
raisonChangementClubBlock.classList.remove('hidden');
|
||||
raisonChangementClubInput.required = true;
|
||||
} else {
|
||||
ancienneCategorieBlock.classList.add('hidden');
|
||||
ancienneCategorieSelect.required = false;
|
||||
raisonChangementClubBlock.classList.add('hidden');
|
||||
raisonChangementClubInput.required = false;
|
||||
}
|
||||
});
|
||||
// Initial check
|
||||
if (ancienClubInput.value.trim().length > 0) {
|
||||
ancienneCategorieBlock.classList.remove('hidden');
|
||||
ancienneCategorieSelect.required = true;
|
||||
raisonChangementClubBlock.classList.remove('hidden');
|
||||
raisonChangementClubInput.required = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-18
@@ -24,14 +24,6 @@ services:
|
||||
- db
|
||||
restart: always
|
||||
|
||||
mailpit:
|
||||
image: axllent/mailpit
|
||||
container_name: astalange_mailpit
|
||||
ports:
|
||||
- "1025:1025"
|
||||
- "8025:8025"
|
||||
restart: always
|
||||
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
@@ -43,18 +35,10 @@ services:
|
||||
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/astalange
|
||||
- SPRING_DATASOURCE_USERNAME=${POSTGRES_USER:-myuser}
|
||||
- SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD:-mypassword}
|
||||
- SPRING_MAIL_HOST=${SPRING_MAIL_HOST:-mailpit}
|
||||
- SPRING_MAIL_PORT=${SPRING_MAIL_PORT:-1025}
|
||||
- SPRING_MAIL_USERNAME=${SPRING_MAIL_USERNAME:-}
|
||||
- SPRING_MAIL_PASSWORD=${SPRING_MAIL_PASSWORD:-}
|
||||
- SPRING_MAIL_PROPERTIES_MAIL_SMTP_AUTH=${SPRING_MAIL_PROPERTIES_MAIL_SMTP_AUTH:-false}
|
||||
- SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_ENABLE=${SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_ENABLE:-false}
|
||||
- APP_MAIL_FROM=${APP_MAIL_FROM:-}
|
||||
- CAPTCHA_SITEKEY=${CAPTCHA_SITEKEY:-}
|
||||
- CAPTCHA_SECRET=${CAPTCHA_SECRET:-}
|
||||
- CAPTCHA_SITEKEY=${CAPTCHA_SITEKEY}
|
||||
- CAPTCHA_SECRET=${CAPTCHA_SECRET}
|
||||
depends_on:
|
||||
- db
|
||||
- mailpit
|
||||
restart: always
|
||||
|
||||
volumes:
|
||||
|
||||
Reference in New Issue
Block a user