Compare commits
2 Commits
81f6169d41
...
2772e44456
| Author | SHA1 | Date | |
|---|---|---|---|
| 2772e44456 | |||
| 8f0e3c0738 |
@@ -216,7 +216,7 @@ public class MembreService {
|
|||||||
public Uni<List<SimpleMembreInOutData>> getAllExport(String subject) {
|
public Uni<List<SimpleMembreInOutData>> getAllExport(String subject) {
|
||||||
return repository.find("userId = ?1", subject).firstResult()
|
return repository.find("userId = ?1", subject).firstResult()
|
||||||
.chain(membreModel -> repository.list("club = ?1", membreModel.getClub()))
|
.chain(membreModel -> repository.list("club = ?1", membreModel.getClub()))
|
||||||
.chain(membres -> licenceRepository.list("saison = ?1 AND membre IN ?2", Utils.getSaison(), membres)
|
.chain(membres -> licenceRepository.list("membre IN ?1", membres)
|
||||||
.map(l -> membres.stream().map(m -> SimpleMembreInOutData.fromModel(m, l)).toList()));
|
.map(l -> membres.stream().map(m -> SimpleMembreInOutData.fromModel(m, l)).toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,14 @@ package fr.titionfire.ffsaf.rest.data;
|
|||||||
|
|
||||||
import fr.titionfire.ffsaf.data.model.LicenceModel;
|
import fr.titionfire.ffsaf.data.model.LicenceModel;
|
||||||
import fr.titionfire.ffsaf.data.model.MembreModel;
|
import fr.titionfire.ffsaf.data.model.MembreModel;
|
||||||
|
import fr.titionfire.ffsaf.utils.Utils;
|
||||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -24,7 +28,27 @@ public class SimpleMembreInOutData {
|
|||||||
|
|
||||||
public static SimpleMembreInOutData fromModel(MembreModel membreModel, List<LicenceModel> lc) {
|
public static SimpleMembreInOutData fromModel(MembreModel membreModel, List<LicenceModel> lc) {
|
||||||
LicenceModel currentLicence = lc.stream().filter(l -> l.getMembre().getId().equals(membreModel.getId()))
|
LicenceModel currentLicence = lc.stream().filter(l -> l.getMembre().getId().equals(membreModel.getId()))
|
||||||
.findFirst().orElse(null);
|
.max(Comparator.comparingInt(LicenceModel::getSaison)).orElse(null);
|
||||||
|
|
||||||
|
String certif = null;
|
||||||
|
if (currentLicence != null && currentLicence.getCertificate() != null) {
|
||||||
|
String[] strings = currentLicence.getCertificate().split("¤");
|
||||||
|
if (currentLicence.getSaison() == Utils.getSaison()) {
|
||||||
|
certif = currentLicence.getCertificate();
|
||||||
|
} else if (strings.length > 1) {
|
||||||
|
try {
|
||||||
|
Date date = new SimpleDateFormat("yyyy-MM-dd").parse(strings[1]);
|
||||||
|
Calendar max = Utils.getFirstDateOfSaison();
|
||||||
|
max.add(Calendar.YEAR, -2);
|
||||||
|
|
||||||
|
if (max.getTime().compareTo(date) < 0) {
|
||||||
|
certif = currentLicence.getCertificate();
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return new SimpleMembreInOutData(
|
return new SimpleMembreInOutData(
|
||||||
membreModel.getLicence(),
|
membreModel.getLicence(),
|
||||||
@@ -33,8 +57,8 @@ public class SimpleMembreInOutData {
|
|||||||
membreModel.getEmail(),
|
membreModel.getEmail(),
|
||||||
membreModel.getGenre().str,
|
membreModel.getGenre().str,
|
||||||
membreModel.getBirth_date(),
|
membreModel.getBirth_date(),
|
||||||
currentLicence != null,
|
currentLicence != null && currentLicence.getSaison() == Utils.getSaison(),
|
||||||
currentLicence == null ? null : currentLicence.getCertificate()
|
certif
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,6 +119,15 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Calendar getFirstDateOfSaison() {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
|
||||||
|
calendar.set(getSaison(), Calendar.SEPTEMBER, 1, 0, 0, 0);
|
||||||
|
calendar.set(Calendar.MILLISECOND, 0);
|
||||||
|
|
||||||
|
return calendar;
|
||||||
|
}
|
||||||
|
|
||||||
public static Calendar toCalendar(Date date) {
|
public static Calendar toCalendar(Date date) {
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.setTime(date);
|
cal.setTime(date);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export function MemberList({source}) {
|
|||||||
payment: 2,
|
payment: 2,
|
||||||
order: "",
|
order: "",
|
||||||
categorie: "",
|
categorie: "",
|
||||||
archived: false,
|
archived: sessionStorage.getItem("showMembreArchived") || true,
|
||||||
...JSON.parse(decodeURI(hash.substring(1)) || "{}"),
|
...JSON.parse(decodeURI(hash.substring(1)) || "{}"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +117,10 @@ export function MemberList({source}) {
|
|||||||
<div className="card-header">{t('filtre')}</div>
|
<div className="card-header">{t('filtre')}</div>
|
||||||
<div className="card-body">
|
<div className="card-body">
|
||||||
<FiltreBar showArchived={filter.archived}
|
<FiltreBar showArchived={filter.archived}
|
||||||
setShowArchived={e => setFilter({...filter, archived: e})}
|
setShowArchived={e => {
|
||||||
|
setFilter({...filter, archived: e})
|
||||||
|
sessionStorage.setItem("showMembreArchived", e);
|
||||||
|
}}
|
||||||
clubFilter={filter.club}
|
clubFilter={filter.club}
|
||||||
setClubFilter={e => setFilter({...filter, club: e})}
|
setClubFilter={e => setFilter({...filter, club: e})}
|
||||||
source={source}
|
source={source}
|
||||||
@@ -147,6 +150,7 @@ export function MemberList({source}) {
|
|||||||
|
|
||||||
function FileOutput() {
|
function FileOutput() {
|
||||||
const {t} = useTranslation();
|
const {t} = useTranslation();
|
||||||
|
|
||||||
function formatColumnDate(worksheet, col) {
|
function formatColumnDate(worksheet, col) {
|
||||||
const range = XLSX.utils.decode_range(worksheet['!ref'])
|
const range = XLSX.utils.decode_range(worksheet['!ref'])
|
||||||
// note: range.s.r + 1 skips the header row
|
// note: range.s.r + 1 skips the header row
|
||||||
@@ -165,6 +169,7 @@ function FileOutput() {
|
|||||||
toast.promise(
|
toast.promise(
|
||||||
apiAxios.get(`/member/club/export`), getToastMessage("membre.toast.licences.export"))
|
apiAxios.get(`/member/club/export`), getToastMessage("membre.toast.licences.export"))
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
console.log(data)
|
||||||
const dataOut = []
|
const dataOut = []
|
||||||
for (const e of data.data) {
|
for (const e of data.data) {
|
||||||
const tmp = {
|
const tmp = {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {useEffect, useReducer, useState} from "react";
|
|||||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||||
import {faEuroSign, faPen} from "@fortawesome/free-solid-svg-icons";
|
import {faEuroSign, faPen} from "@fortawesome/free-solid-svg-icons";
|
||||||
import {AxiosError} from "../../../components/AxiosError.jsx";
|
import {AxiosError} from "../../../components/AxiosError.jsx";
|
||||||
import {apiAxios, getSaison, getToastMessage} from "../../../utils/Tools.js";
|
import {apiAxios, getFirstDateOfSaison, getSaison, getToastMessage} from "../../../utils/Tools.js";
|
||||||
import {toast} from "react-toastify";
|
import {toast} from "react-toastify";
|
||||||
import {useTranslation} from "react-i18next";
|
import {useTranslation} from "react-i18next";
|
||||||
|
|
||||||
@@ -51,13 +51,34 @@ export function LicenceCard({userData}) {
|
|||||||
dispatch({type: 'SORT'})
|
dispatch({type: 'SORT'})
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
|
const handleAsk = () => {
|
||||||
|
const currentLicence = licences[0];
|
||||||
|
|
||||||
|
let certif = undefined;
|
||||||
|
if (currentLicence != null && currentLicence.certificate != null) {
|
||||||
|
const strings = currentLicence.certificate.split('¤');
|
||||||
|
if (currentLicence.saison === getSaison()) {
|
||||||
|
certif = currentLicence.certificate;
|
||||||
|
} else if (strings.length > 1) {
|
||||||
|
const date = new Date(strings[1]);
|
||||||
|
const max = getFirstDateOfSaison();
|
||||||
|
max.setFullYear(max.getFullYear() - 2);
|
||||||
|
|
||||||
|
if (max < date) {
|
||||||
|
certif = currentLicence.certificate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setModal({id: -1, membre: userData.id, certificate: certif});
|
||||||
|
}
|
||||||
|
|
||||||
return <div className="card mb-4 mb-md-0">
|
return <div className="card mb-4 mb-md-0">
|
||||||
<div className="card-header container-fluid">
|
<div className="card-header container-fluid">
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col">{t('licence')}</div>
|
<div className="col">{t('licence')}</div>
|
||||||
<div className="col" style={{textAlign: 'right'}}>
|
<div className="col" style={{textAlign: 'right'}}>
|
||||||
<button className="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#LicenceModal"
|
<button className="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#LicenceModal"
|
||||||
onClick={_ => setModal({id: -1, membre: userData.id})}>{t('button.ajouter')}
|
onClick={handleAsk}>{t('button.ajouter')}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -141,13 +162,6 @@ function ModalContent({licence, dispatch}) {
|
|||||||
if (licence.id !== -1) {
|
if (licence.id !== -1) {
|
||||||
setNew(false)
|
setNew(false)
|
||||||
setSaison(licence.saison)
|
setSaison(licence.saison)
|
||||||
if (licence.certificate === null) {
|
|
||||||
setCertificateBy("")
|
|
||||||
setCertificateDate("")
|
|
||||||
} else {
|
|
||||||
setCertificateBy(licence.certificate.split('¤')[0])
|
|
||||||
setCertificateDate(licence.certificate.split('¤')[1])
|
|
||||||
}
|
|
||||||
setValidate(licence.validate)
|
setValidate(licence.validate)
|
||||||
setPay(licence.pay);
|
setPay(licence.pay);
|
||||||
} else {
|
} else {
|
||||||
@@ -158,6 +172,13 @@ function ModalContent({licence, dispatch}) {
|
|||||||
setValidate(false)
|
setValidate(false)
|
||||||
setPay(false);
|
setPay(false);
|
||||||
}
|
}
|
||||||
|
if (licence.certificate) {
|
||||||
|
setCertificateBy(licence.certificate.split('¤')[0])
|
||||||
|
setCertificateDate(licence.certificate.split('¤')[1])
|
||||||
|
} else {
|
||||||
|
setCertificateBy("")
|
||||||
|
setCertificateDate("")
|
||||||
|
}
|
||||||
}, [licence]);
|
}, [licence]);
|
||||||
|
|
||||||
return <form onSubmit={e => sendLicence(e, dispatch)}>
|
return <form onSubmit={e => sendLicence(e, dispatch)}>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {useEffect, useReducer, useState} from "react";
|
|||||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||||
import {faInfo, faPen} from "@fortawesome/free-solid-svg-icons";
|
import {faInfo, faPen} from "@fortawesome/free-solid-svg-icons";
|
||||||
import {AxiosError} from "../../../components/AxiosError.jsx";
|
import {AxiosError} from "../../../components/AxiosError.jsx";
|
||||||
import {apiAxios, getSaison, getToastMessage} from "../../../utils/Tools.js";
|
import {apiAxios, getFirstDateOfSaison, getSaison, getToastMessage} from "../../../utils/Tools.js";
|
||||||
import {toast} from "react-toastify";
|
import {toast} from "react-toastify";
|
||||||
import {ColoredText} from "../../../components/ColoredCircle.jsx";
|
import {ColoredText} from "../../../components/ColoredCircle.jsx";
|
||||||
import {useTranslation} from "react-i18next";
|
import {useTranslation} from "react-i18next";
|
||||||
@@ -32,7 +32,7 @@ function licenceReducer(licences, action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function LicenceCard({userData}) {
|
export function LicenceCard({userData}) {
|
||||||
const defaultLicence = {id: -1, membre: userData.id, validate: false, saison: getSaison(), certificate: false}
|
const defaultLicence = {id: -1, membre: userData.id, validate: false, saison: getSaison(), certificate: null}
|
||||||
const {t} = useTranslation();
|
const {t} = useTranslation();
|
||||||
|
|
||||||
const setLoading = useLoadingSwitcher()
|
const setLoading = useLoadingSwitcher()
|
||||||
@@ -48,13 +48,33 @@ export function LicenceCard({userData}) {
|
|||||||
dispatch({type: 'SORT'})
|
dispatch({type: 'SORT'})
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
|
const handleAsk = () => {
|
||||||
|
const currentLicence = licences[0];
|
||||||
|
|
||||||
|
let certif = undefined;
|
||||||
|
if (currentLicence != null && currentLicence.certificate != null) {
|
||||||
|
const strings = currentLicence.certificate.split('¤');
|
||||||
|
if (currentLicence.saison === getSaison()) {
|
||||||
|
certif = currentLicence.certificate;
|
||||||
|
} else if (strings.length > 1) {
|
||||||
|
const date = new Date(strings[1]);
|
||||||
|
const max = getFirstDateOfSaison();
|
||||||
|
max.setFullYear(max.getFullYear() - 2);
|
||||||
|
|
||||||
|
if (max < date)
|
||||||
|
certif = currentLicence.certificate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setModal({...defaultLicence, certificate: certif});
|
||||||
|
}
|
||||||
|
|
||||||
return <div className="card mb-4 mb-md-0">
|
return <div className="card mb-4 mb-md-0">
|
||||||
<div className="card-header container-fluid">
|
<div className="card-header container-fluid">
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col">{t('licence')}</div>
|
<div className="col">{t('licence')}</div>
|
||||||
<div className="col" style={{textAlign: 'right'}}>
|
<div className="col" style={{textAlign: 'right'}}>
|
||||||
<button className="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#LicenceModal"
|
<button className="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#LicenceModal"
|
||||||
onClick={() => setModal(defaultLicence)}
|
onClick={handleAsk}
|
||||||
disabled={licences.some(licence => licence.saison === getSaison())}>{t('demander')}
|
disabled={licences.some(licence => licence.saison === getSaison())}>{t('demander')}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -127,15 +147,14 @@ function ModalContent({licence, dispatch}) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (licence.id !== -1) {
|
if (licence.id !== -1) {
|
||||||
setNew(false)
|
setNew(false)
|
||||||
if (licence.certificate === null) {
|
|
||||||
setCertificateBy("")
|
|
||||||
setCertificateDate("")
|
|
||||||
} else {
|
|
||||||
setCertificateBy(licence.certificate.split('¤')[0])
|
|
||||||
setCertificateDate(licence.certificate.split('¤')[1])
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
setNew(true)
|
setNew(true)
|
||||||
|
}
|
||||||
|
if (licence.certificate) {
|
||||||
|
setCertificateBy(licence.certificate.split('¤')[0])
|
||||||
|
setCertificateDate(licence.certificate.split('¤')[1])
|
||||||
|
} else {
|
||||||
setCertificateBy("")
|
setCertificateBy("")
|
||||||
setCertificateDate("")
|
setCertificateDate("")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,6 +117,14 @@ export function getSaison(currentDate = new Date()) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getFirstDateOfSaison() {
|
||||||
|
const year = getSaison();
|
||||||
|
const firstDate = new Date(year, 8, 1); // 8 = septembre, 1 = premier jour
|
||||||
|
firstDate.setHours(0, 0, 0, 0); // Heure, minutes, secondes, millisecondes à 0
|
||||||
|
|
||||||
|
return firstDate;
|
||||||
|
}
|
||||||
|
|
||||||
export function getCatName(cat) {
|
export function getCatName(cat) {
|
||||||
switch (cat) {
|
switch (cat) {
|
||||||
case "SUPER_MINI":
|
case "SUPER_MINI":
|
||||||
|
|||||||
Reference in New Issue
Block a user