diff --git a/src/main/java/fr/titionfire/ffsaf/ws/recv/RPDF.java b/src/main/java/fr/titionfire/ffsaf/ws/recv/RPDF.java index 7aa1a17..ba732fd 100644 --- a/src/main/java/fr/titionfire/ffsaf/ws/recv/RPDF.java +++ b/src/main/java/fr/titionfire/ffsaf/ws/recv/RPDF.java @@ -99,6 +99,11 @@ public class RPDF { }); } + @WSReceiver(code = "getPodiumClub", permission = PermLevel.VIEW) + public Uni> getPodiumClub(WebSocketConnection connection, Object o) { + return resultService.getAllClubArray(connection.pathParam("uuid"), false); + } + @RegisterForReflection public static record PodiumEntity(String poule_name, String source, Categorie categorie, List podium) { diff --git a/src/main/webapp/public/locales/en/cm.json b/src/main/webapp/public/locales/en/cm.json index db892dc..a0ce0af 100644 --- a/src/main/webapp/public/locales/en/cm.json +++ b/src/main/webapp/public/locales/en/cm.json @@ -120,6 +120,8 @@ "obs.préfixDesSources": "Source prefix", "pays": "Country", "personnaliser": "Personalize", + "podium": "Podium", + "podiumDesClubs": "Club podium", "poids": "Weight", "poule": "Pool", "poulePour": "Pool for: ", diff --git a/src/main/webapp/public/locales/fr/cm.json b/src/main/webapp/public/locales/fr/cm.json index 86a559f..7e8ba4c 100644 --- a/src/main/webapp/public/locales/fr/cm.json +++ b/src/main/webapp/public/locales/fr/cm.json @@ -120,6 +120,8 @@ "obs.préfixDesSources": "Préfix des sources", "pays": "Pays", "personnaliser": "Personnaliser", + "podium": "Podium", + "podiumDesClubs": "Podium des clubs", "poids": "Poids", "poule": "Poule", "poulePour": "Poule pour: ", diff --git a/src/main/webapp/src/pages/competition/editor/CMAdmin.jsx b/src/main/webapp/src/pages/competition/editor/CMAdmin.jsx index 8ee1395..bbf4d7d 100644 --- a/src/main/webapp/src/pages/competition/editor/CMAdmin.jsx +++ b/src/main/webapp/src/pages/competition/editor/CMAdmin.jsx @@ -407,6 +407,7 @@ function PrintModal({menuActions}) { const [allCatEmpty, setAllCatEmpty] = useState(false); const [podium, setPodium] = useState(false); const [podiumRank, setPodiumRank] = useState(4); + const [podiumClub, setPodiumClub] = useState(false); const [presetSelect, setPresetSelect] = useState(-1) @@ -416,12 +417,20 @@ function PrintModal({menuActions}) { const podiumPromise = (podiumRank_) => { return sendRequest("getPodium", {}).then(data => { - return [welcomeData?.name + " - " + "Podium", [ + return [welcomeData?.name + " - " + t('podium'), [ {type: "podium", params: ({data, maxRank: podiumRank_, minRank: Math.min(4, podiumRank_)})}, ]]; }); } + const podiumClubPromise = () => { + return sendRequest("getPodiumClub", {}).then(data => { + return [welcomeData?.name + " - " + t('classementDesClub', {ns: "result"}), [ + {type: "podiumClub", params: ({data})}, + ]]; + }); + } + const print = (action) => { const pagesPromise = []; @@ -437,6 +446,9 @@ function PrintModal({menuActions}) { if (podium) pagesPromise.push(podiumPromise(podiumRank)); + if (podiumClub) + pagesPromise.push(podiumClubPromise()); + toast.promise( toDataURL("/Logo-FFSAF-2023.png").then(logo => { return Promise.allSettled(pagesPromise).then(results => { @@ -513,7 +525,7 @@ function PrintModal({menuActions}) {
setPodium(e.target.checked)}/> - +
{podium &&
@@ -521,6 +533,12 @@ function PrintModal({menuActions}) { setPodiumRank(Number(e.target.value))}/>
} + +
+ setPodiumClub(e.target.checked)}/> + +
diff --git a/src/main/webapp/src/utils/cmPdf.js b/src/main/webapp/src/utils/cmPdf.js index 767b952..9effb55 100644 --- a/src/main/webapp/src/utils/cmPdf.js +++ b/src/main/webapp/src/utils/cmPdf.js @@ -45,6 +45,9 @@ export function makePDF(action, pagesList, name, c_name, getComb, t, logo) { case "podium": generatePodium(context); break; + case "podiumClub": + generateClubPodium(context); + break; default: break } @@ -372,7 +375,7 @@ function generateCategoriePDF({pdf_doc, cat, matches, groups, getComb, cards_v, } function generatePodium({pdf_doc, data, t, logo, c_name, minRank = 4, maxRank = 4}) { - makeHeader(pdf_doc, c_name, "Podium", logo) + makeHeader(pdf_doc, c_name, t('podium'), logo) const data2 = data.sort((a, b) => { let tmp = sortCategories(a.categorie, b.categorie); @@ -441,3 +444,59 @@ function generatePodium({pdf_doc, data, t, logo, c_name, minRank = 4, maxRank = } pdf_doc.lastAutoTable.finalY = Math.max(finalY2, pdf_doc.lastAutoTable.finalY); } + +function generateClubPodium({pdf_doc, data, t, logo, c_name}) { + makeHeader(pdf_doc, c_name, t('podiumDesClubs'), logo) + + const body = data.map(c => [ + {content: [c.name], styles: {halign: "center"}}, + {content: c.score[0], styles: {halign: "center"}}, + {content: c.score[1], styles: {halign: "center"}}, + {content: c.score[2], styles: {halign: "center"}}, + {content: c.tt_score, styles: {halign: "center"}}, + ]); + + let rank = 0; + let lastScores = null; + let lastB = null; + for (const b of body) { + const scores = [b[1].content, b[2].content, b[3].content, b[4].content]; + if (lastScores !== scores) { + rank++; + b.unshift({content: rank, styles: {halign: "center"}}) + lastB = b + } else { + lastB[1].content.push(b[0].content); + delete body.indexOf(b); + } + } + for (const b of body) { + b[1].content = b[1].content.join(", ") + } + + autoTable(pdf_doc, { + startY: pdf_doc.lastAutoTable.finalY + 7, + styles: {fontSize: 10, cellPadding: 3}, + columnStyles: { + 0: {cellWidth: 35}, + 1: {cellWidth: "auto"}, + 2: {cellWidth: 45}, + 3: {cellWidth: 45}, + 4: {cellWidth: 45}, + 5: {cellWidth: 40}, + }, + pageBreak: "avoid", + showHead: 'firstPage', + head: [[ + {content: t('place', {ns: "result"}), styles: {halign: "center"}}, + {content: t('club', {ns: 'result'}), styles: {halign: "center"}}, + {content: t('1er', {ns: 'result'}), styles: {halign: "center"}}, + {content: t('2eme', {ns: 'result'}), styles: {halign: "center"}}, + {content: t('3eme', {ns: 'result'}), styles: {halign: "center"}}, + {content: t('scores', {ns: 'result'}), styles: {halign: "center"}}, + ]], + body: body, + rowPageBreak: 'auto', + theme: 'grid', + }) +}