diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 0bea72f..4fa4df0 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,9 +4,11 @@ - @@ -712,7 +722,8 @@ - diff --git a/frontend/components/reception/reception-weight.vue b/frontend/components/reception/reception-weight.vue index a227e1a..758b832 100644 --- a/frontend/components/reception/reception-weight.vue +++ b/frontend/components/reception/reception-weight.vue @@ -73,8 +73,14 @@ const printReceipt = async () => { return } + // Ouvre l'onglet tout de suite pour éviter le blocage popup de Chrome + const previewWindow = window.open('', '_blank') + if (previewWindow) { + previewWindow.opener = null + } + await saveWeight() - await printPdf(`/receptions/${receptionStore.current.id}/receipt`) + await printPdf(`/receptions/${receptionStore.current.id}/receipt`, previewWindow) // Laisse le temps a la boite de dialogue d'impression de s'ouvrir. await new Promise((resolve) => setTimeout(resolve, 600)) diff --git a/frontend/composables/usePdfPrinter.ts b/frontend/composables/usePdfPrinter.ts index f7215ac..e6440f5 100644 --- a/frontend/composables/usePdfPrinter.ts +++ b/frontend/composables/usePdfPrinter.ts @@ -5,7 +5,7 @@ export const usePdfPrinter = () => { const receptionStore = useReceptionStore() const currentReception = receptionStore.current - const printPdf = async (url: string): Promise => { + const printPdf = async (url: string, previewWindow?: Window | null): Promise => { const blob = await api.getBlob(url); const pdfBlob = blob.type === 'application/pdf' @@ -16,15 +16,17 @@ export const usePdfPrinter = () => { const filename = `${currentReception.identificationNumber}_${currentReception.supplier.name}_${currentReception.licensePlate}.pdf`; - const a = document.createElement('a'); - a.href = blobUrl; - a.download = filename; - a.style.display = 'none'; - document.body.appendChild(a); - a.click(); - a.remove(); + if (previewWindow) { + previewWindow.location.replace(blobUrl) + } - // L'ouverture dans un nouvel onglet déclenche un 2e PDF sans le nom personnalisé. + const a = document.createElement('a') + a.href = blobUrl + a.download = filename + a.style.display = 'none' + document.body.appendChild(a) + a.click() + a.remove() setTimeout(() => URL.revokeObjectURL(blobUrl), 60_000); } diff --git a/templates/reception_voucher.html.twig b/templates/reception_voucher.html.twig index 2bc2e96..6c94ccd 100644 --- a/templates/reception_voucher.html.twig +++ b/templates/reception_voucher.html.twig @@ -65,7 +65,7 @@ .bigtable-wrap{ border: 1px solid #000; - height: 425px; + height: 360px; margin-bottom: 10px; } @@ -107,8 +107,8 @@ .footer-block{ page-break-inside: avoid; } .signature-box { - height: 22mm; - margin-bottom: 4mm; + height: 130px; + margin-bottom: 10px; border: 0.5px solid #000; padding: 6px 10px; @@ -143,7 +143,16 @@
{{ reception.supplier.name }}
{{ reception.address.street }}
- {{ reception.address.postalCode }} {{ reception.address.city }} + {% if reception.address.street2 %} + {{ reception.address.street2 }}
+ {% endif %} + {{ reception.address.postalCode }} {{ reception.address.city }}
+ {% if reception.supplier.phone %} + {{ reception.supplier.phone }}
+ {% endif %} + {% if reception.supplier.email %} + {{ reception.supplier.email}}
+ {% endif %}