diff --git a/scripts/_ALL_SITES/gruppomacro.app/public/images/nutriben-logo.png b/scripts/_ALL_SITES/gruppomacro.app/public/images/nutriben-logo.png deleted file mode 100644 index 6acb69f2..00000000 Binary files a/scripts/_ALL_SITES/gruppomacro.app/public/images/nutriben-logo.png and /dev/null differ diff --git a/scripts/_ALL_SITES/gruppomacro.app/src/db/static_data.ts b/scripts/_ALL_SITES/gruppomacro.app/src/db/static_data.ts index 878cb8f7..1577b9f4 100755 --- a/scripts/_ALL_SITES/gruppomacro.app/src/db/static_data.ts +++ b/scripts/_ALL_SITES/gruppomacro.app/src/db/static_data.ts @@ -38,7 +38,7 @@ const firstPage = { path: '/', materialIcon: 'home', name: 'pages.home', - component: () => import('@src/root/mainview/mainview/home.vue'), + component: () => import('@src/root/mainview/mainview.vue'), reqauth: false, inmenu: true, infooter: true, diff --git a/src/components/CGridTableRec/CGridTableRec.ts b/src/components/CGridTableRec/CGridTableRec.ts index f3cd5599..4df35dfb 100755 --- a/src/components/CGridTableRec/CGridTableRec.ts +++ b/src/components/CGridTableRec/CGridTableRec.ts @@ -767,6 +767,11 @@ export default defineComponent({ globalStore.myselector.data = { _id: 0, comune: '' } } + } else { + const rec = searchList.value.find((rec) => rec.table === table && rec.bool) + if (rec) { + tools.setCookieBool(tools.COOK_SEARCH + costanti.FILTER_SEP + table + costanti.FILTER_SEP + rec.key, rec.value) + } } @@ -2839,7 +2844,7 @@ export default defineComponent({ } function getisDettagliByCatalog() { - const rec = searchList.value.find((myrec) => myrec.table === shared_consts.TABLES_CATALOG && myrec.key === 'dettagli') + const rec = searchList.value.find((myrec) => myrec.table === ('finto_' + myrec.key) && myrec.key === 'dettagli') if (rec) { return rec.value } diff --git a/src/components/CGridTableRec/CGridTableRec.vue b/src/components/CGridTableRec/CGridTableRec.vue index 49e477ad..9fb715af 100755 --- a/src/components/CGridTableRec/CGridTableRec.vue +++ b/src/components/CGridTableRec/CGridTableRec.vue @@ -253,7 +253,7 @@ v-else-if="item.type === costanti.FieldType.boolean" :label="item.label" v-model="item.value" - @update:model-value="refresh" + @update:model-value="searchval(item.value, item.table)" color="green" /> @@ -923,7 +923,7 @@ v-else-if="item.type === costanti.FieldType.boolean" :label="item.label" v-model="item.value" - @update:model-value="refresh" + @update:model-value="searchval(item.value, item.table)" color="green" /> diff --git a/src/db/static_data.ts b/src/db/static_data.ts index 878cb8f7..1577b9f4 100755 --- a/src/db/static_data.ts +++ b/src/db/static_data.ts @@ -38,7 +38,7 @@ const firstPage = { path: '/', materialIcon: 'home', name: 'pages.home', - component: () => import('@src/root/mainview/mainview/home.vue'), + component: () => import('@src/root/mainview/mainview.vue'), reqauth: false, inmenu: true, infooter: true, diff --git a/src/store/Modules/tools.ts b/src/store/Modules/tools.ts index 7fa472e1..8eb3d2cb 100644 --- a/src/store/Modules/tools.ts +++ b/src/store/Modules/tools.ts @@ -4482,6 +4482,14 @@ export const tools = { return def } }, + getCookieBool(mytok: any, def?: any) { + const ris = Cookies.get(mytok) + if (ris === 'null') + return def + + return ris === '1' ? true : false + + }, localStSetItem(item: string, value: string) { if (localStorage.getItem('cookie-id') === 'decline') @@ -4502,6 +4510,13 @@ export const tools = { return Cookies.set(mytok, value) }, + setCookieBool(mytok: any, valbool: boolean) { + if (localStorage.getItem('cookie-id') === 'decline') + return null + + return Cookies.set(mytok, valbool ? '1' : '0') + }, + removeCookie(mytok: any) { return Cookies.remove(mytok) }, @@ -9846,11 +9861,13 @@ export const tools = { icon: 'fas fa-user' }, { + table: 'finto_active', visible: !this.isUtente(), label: 'Pubblicati OnLine', key: 'active', type: costanti.FieldType.boolean, - value: this.isUtente() ? true: this.getCookie(this.COOK_SEARCH + costanti.FILTER_SEP + shared_consts.TABLES_CATALOG + costanti.FILTER_SEP + 'active', true), + value: this.isUtente() ? true: this.getCookieBool(this.COOK_SEARCH + costanti.FILTER_SEP + 'finto_active' + costanti.FILTER_SEP + 'active', true), + bool: true, keycookie: '', addall: true, arrvalue: [], @@ -9859,11 +9876,13 @@ export const tools = { icon: 'fas fa-globe' }, { + table: 'finto_isCatalogoGenerale', visible: !this.isUtente(), label: 'Solo Catalogo Generale', key: 'isCatalogoGenerale', type: costanti.FieldType.boolean, - value: this.isUtente() ? isCatalogoGenerale: this.getCookie(this.COOK_SEARCH + costanti.FILTER_SEP + shared_consts.TABLES_CATALOG + costanti.FILTER_SEP + 'isCatalogoGenerale', isCatalogoGenerale), + value: this.isUtente() ? isCatalogoGenerale: this.getCookieBool(this.COOK_SEARCH + costanti.FILTER_SEP + 'finto_isCatalogoGenerale' + costanti.FILTER_SEP + 'isCatalogoGenerale', isCatalogoGenerale), + bool: true, keycookie: '', addall: true, arrvalue: [], @@ -9874,11 +9893,12 @@ export const tools = { { visible: !this.isUtente(), label: 'Dettagli', - table: shared_consts.TABLES_CATALOG, + table: 'finto_dettagli', key: 'dettagli', + bool: true, notinsearch: true, // non usarlo nella ricerca filtro type: costanti.FieldType.boolean, - value: this.isUtente() ? false: this.getCookie(this.COOK_SEARCH + costanti.FILTER_SEP + shared_consts.TABLES_CATALOG + costanti.FILTER_SEP + 'dettagli', true), + value: this.isUtente() ? false: this.getCookieBool(this.COOK_SEARCH + costanti.FILTER_SEP + 'finto_dettagli' + costanti.FILTER_SEP + 'dettagli', true), keycookie: '', addall: true, arrvalue: [], diff --git a/src/store/globalStore.ts b/src/store/globalStore.ts index 03e81f42..8fc19196 100644 --- a/src/store/globalStore.ts +++ b/src/store/globalStore.ts @@ -2538,6 +2538,7 @@ export const useGlobalStore = defineStore('GlobalStore', { file_out: string = '', print: boolean = false, optcatalogo: IOptCatalogo | null = null, + salvasufiledascaricare ) { try { if (!pdfFile) { @@ -2567,16 +2568,20 @@ export const useGlobalStore = defineStore('GlobalStore', { const response = await this.execConvertPDF(formData); if (response) { - const blob = new Blob([response], { type: 'application/pdf' }); - const downloadUrl = window.URL.createObjectURL(blob); - const link = document.createElement('a'); - link.href = downloadUrl; - link.setAttribute('download', filenameToDownload); - document.body.appendChild(link); - link.click(); - link.remove(); + if (salvasufiledascaricare) { + const blob = new Blob([response], { type: 'application/pdf' }); + const downloadUrl = window.URL.createObjectURL(blob); + const link = document.createElement('a'); + link.href = downloadUrl; + link.setAttribute('download', filenameToDownload); + document.body.appendChild(link); + link.click(); + link.remove(); - window.URL.revokeObjectURL(downloadUrl); + window.URL.revokeObjectURL(downloadUrl); + } else { + return response + } } else { console.error('No data returned from the server.'); } diff --git a/src/views/ecommerce/catalogo/catalogo.ts b/src/views/ecommerce/catalogo/catalogo.ts index 90745964..540b9af0 100755 --- a/src/views/ecommerce/catalogo/catalogo.ts +++ b/src/views/ecommerce/catalogo/catalogo.ts @@ -1747,66 +1747,85 @@ export default defineComponent({ const pages = document.querySelectorAll(pagesSelector); const pdfs = []; - for (let i = 0; i < pages.length; i++) { - const page = pages[i]; + try { + for (let i = 0; i < pages.length; i++) { + const page = pages[i]; - // Nascondi altre pagine - pages.forEach((p) => p.classList.add('hidden')); - page.classList.remove('hidden'); + // Nascondi altre pagine + pages.forEach((p) => p.classList.add('hidden')); + page.classList.remove('hidden'); - await new Promise((resolve) => setTimeout(resolve, 100)); + await new Promise((resolve) => setTimeout(resolve, 100)); - // Genera singolo PDF - const pdfBlob = await new Promise((resolve) => { - html2pdf() - .set(opt) - .from(page) - .toPdf() - .output('blob', { compress: true }) - .then(resolve) - .catch(() => resolve(null)); - }); + // Genera singolo PDF + const pdfBlob = await new Promise((resolve) => { + html2pdf() + .set(opt) + .from(page) + .toPdf() + .output('blob', { compress: true }) + .then(resolve) + .catch(() => resolve(null)); + }); - if (pdfBlob) { - pdfs.push(pdfBlob); + if (pdfBlob) { + pdfs.push(pdfBlob); + } } + + // Unisci PDF + const finalPdf = await PDFDocument.create(); + for (const blob of pdfs) { + const pdf = await PDFDocument.load(await blob.arrayBuffer()); + const copiedPages = await finalPdf.copyPages(pdf, pdf.getPageIndices()); + copiedPages.forEach((p) => finalPdf.addPage(p)); + } + + const finalPdfBytes = await finalPdf.save(); // Uint8Array + + // ✅ Conversione in Blob + const blob = new Blob([finalPdfBytes], { type: 'application/pdf' }); + + // ✅ Download + if (salvasufiledascaricare) { + saveAs(blob, opt.filename); + } else { + // ✅ Crea un oggetto File da Blob + const pdfFile = new File([blob], 'report.pdf', { type: 'application/pdf' }); + + // Converti il file appena generato + const ris = await globalStore.convertPdf( + pdfFile, + widthpdf.value, + heightpdf.value, + compressionepdf.value, + dir_out, + file_out, + true, + optcatalogo.value, + salvasufiledascaricare + ); + + if (ris) { + const catalog = getCatalogoByMyPage.value; + if (ris.pdf_generato) { + catalog.pdf_generato = ris.pdf_generato; + catalog.data_generato = tools.getDateNow(); + } + if (ris.pdf_generato_stampa) { + catalog.pdf_generato_stampa = ris.pdf_generato_stampa; + catalog.data_generato_stampa = tools.getDateNow(); + } + + await saveCatalog(); + } + } + + // Ripristina visibilità + pages.forEach((p) => p.classList.remove('hidden')); + } catch (e) { + console.error('Err', e.message); } - - // Unisci PDF - const finalPdf = await PDFDocument.create(); - for (const blob of pdfs) { - const pdf = await PDFDocument.load(await blob.arrayBuffer()); - const copiedPages = await finalPdf.copyPages(pdf, pdf.getPageIndices()); - copiedPages.forEach((p) => finalPdf.addPage(p)); - } - - const finalPdfBytes = await finalPdf.save(); // Uint8Array - - // ✅ Conversione in Blob - const blob = new Blob([finalPdfBytes], { type: 'application/pdf' }); - - // ✅ Download - if (salvasufiledascaricare) { - saveAs(blob, opt.filename); - } else { - // ✅ Crea un oggetto File da Blob - const pdfFile = new File([blob], 'report.pdf', { type: 'application/pdf' }); - - // Converti il file appena generato - await globalStore.convertPdf( - pdfFile, - widthpdf.value, - heightpdf.value, - compressionepdf.value, - dir_out, - file_out, - true, - optcatalogo.value, - ); - } - - // Ripristina visibilità - pages.forEach((p) => p.classList.remove('hidden')); } const generatePDF = async () => { @@ -1860,12 +1879,7 @@ export default defineComponent({ const element = document.getElementById('pdf-content'); const opt = { - margin: [ - defaultMargin, - defaultMargin, - defaultMargin, - defaultMargin, - ], + margin: [defaultMargin, defaultMargin, defaultMargin, defaultMargin], filename: myfile, image: { type: 'jpeg', @@ -1890,7 +1904,7 @@ export default defineComponent({ // a4: [595.28, 841.89] if (true) { - await generateLargePDF(opt, '.pdf-section', false, 'upload/', file_out); + await generateLargePDF(opt, '.pdf-section', false, 'upload/cataloghi/', file_out); } else { await html2pdf().set(opt).from(element).save(); } diff --git a/src/views/ecommerce/catalogo/catalogo.vue b/src/views/ecommerce/catalogo/catalogo.vue index 2bece10d..af9ea271 100755 --- a/src/views/ecommerce/catalogo/catalogo.vue +++ b/src/views/ecommerce/catalogo/catalogo.vue @@ -432,6 +432,25 @@ :color="optcatalogo.indebug ? `positive` : 'primary'" > +
+
+ PDF: + + {{tools.getHost() + getCatalogoByMyPage.pdf_generato}} + + - +
(Generato il {{ tools.getstrDateTime(getCatalogoByMyPage.data_generato)}}) +
+
+
+ PDF Stampa: + + {{tools.getHost() + getCatalogoByMyPage.pdf_generato_stampa}} + + - +
(Generato il {{ tools.getstrDateTime(getCatalogoByMyPage.data_generato_stampa) }}) +
+