dev #109
@ -99,6 +99,11 @@ public class RPDF {
|
||||
});
|
||||
}
|
||||
|
||||
@WSReceiver(code = "getPodiumClub", permission = PermLevel.VIEW)
|
||||
public Uni<List<ResultService.ClubClassement>> 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<ResultCategoryData.ClassementData> podium) {
|
||||
|
||||
@ -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: ",
|
||||
|
||||
@ -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: ",
|
||||
|
||||
@ -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}) {
|
||||
<div className="form-check">
|
||||
<input className="form-check-input" type="checkbox" checked={podium} id="checkPrint7"
|
||||
onChange={e => setPodium(e.target.checked)}/>
|
||||
<label className="form-check-label" htmlFor="checkPrint7">Podium</label>
|
||||
<label className="form-check-label" htmlFor="checkPrint7">{t('podium')}</label>
|
||||
</div>
|
||||
{podium &&
|
||||
<div style={{marginLeft: "1em"}}>
|
||||
@ -521,6 +533,12 @@ function PrintModal({menuActions}) {
|
||||
<input type="range" className="form-range" min="1" max="20" step="1" id="range3" value={podiumRank}
|
||||
onChange={e => setPodiumRank(Number(e.target.value))}/>
|
||||
</div>}
|
||||
|
||||
<div className="form-check">
|
||||
<input className="form-check-input" type="checkbox" checked={podiumClub} id="checkPrint8"
|
||||
onChange={e => setPodiumClub(e.target.checked)}/>
|
||||
<label className="form-check-label" htmlFor="checkPrint8">{t('classementDesClub', {ns: "result"})}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div className="modal-footer">
|
||||
<button type="submit" className="btn btn-primary" data-bs-dismiss="modal" onClick={() => print("show")}>{t('afficher')}</button>
|
||||
|
||||
@ -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',
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user