- Sistemato link pdf che ogni volta che si aggiorna prendeva il PDF dalla cache...
- Raccolta Cataloghi, procedura che li AUTO genera in automatico.
This commit is contained in:
@@ -513,7 +513,7 @@ async function ConvertPDF_Generatore(options, instampa) {
|
||||
let marginLeft = instampa ? parseFloat(options.print_left) : 0;
|
||||
|
||||
if (instampa) {
|
||||
suffisso_filename = '-stampabile_generato';
|
||||
suffisso_filename = '_stampabile_generato';
|
||||
} else {
|
||||
suffisso_filename = '_generato';
|
||||
}
|
||||
@@ -614,72 +614,13 @@ async function ConvertPDF_Generatore(options, instampa) {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
router.post('/online-pdf', authenticate, async (req, res) => {
|
||||
console.log('/online-pdf');
|
||||
|
||||
idapp = req.body.idapp;
|
||||
id_catalog = req.body.id_catalog;
|
||||
id_raccolta = req.body.id_raccolta;
|
||||
stampa = req.body.stampa;
|
||||
compresso = req.body.compresso;
|
||||
let mydir = '';
|
||||
let risout = {};
|
||||
|
||||
try {
|
||||
let myrec = null;
|
||||
|
||||
// Aggiorna il PDF OnLine, copiando il file da Generato a OnLine
|
||||
if (id_catalog) {
|
||||
myrec = await Catalog.findOne({ _id: id_catalog });
|
||||
} else if (id_raccolta) {
|
||||
myrec = await RaccoltaCataloghi.findOne({ _id: id_raccolta });
|
||||
}
|
||||
|
||||
if (myrec) {
|
||||
mydir = tools.getdirByIdApp(idapp) + '/';
|
||||
// const baseurl = this.getHostByIdApp(idapp);
|
||||
|
||||
if (stampa) {
|
||||
myrec.pdf_online_stampa = myrec.pdf_generato_stampa.replace('_generato', '');
|
||||
} else {
|
||||
myrec.pdf_online = myrec.pdf_generato?.replace('_generato', '');
|
||||
}
|
||||
|
||||
// Aggiorna il PDF OnLine, copiando il file da Generato a OnLine
|
||||
let fileOrigin = mydir + (stampa ? myrec.pdf_generato_stampa : myrec.pdf_generato);
|
||||
|
||||
if (compresso) {
|
||||
let fileInCompressed = tools.removeFileExtension(fileOrigin) + `_compressed.pdf`;
|
||||
// Se esiste allora prende questo COmpresso !
|
||||
if (await tools.isFileExistsAsync(fileInCompressed)) {
|
||||
fileOrigin = fileInCompressed;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
const fileDest = mydir + (stampa ? myrec.pdf_online_stampa : myrec.pdf_online);
|
||||
const fileDestNoDir = stampa ? myrec.pdf_online_stampa : myrec.pdf_online;
|
||||
// copia il file
|
||||
await fs.promises.copyFile(fileOrigin, fileDest);
|
||||
|
||||
if (stampa) {
|
||||
myrec.pdf_online_stampa_size = await tools.getSizeFile(fileDest);
|
||||
} else {
|
||||
myrec.pdf_online_size = await tools.getSizeFile(fileDest);
|
||||
}
|
||||
|
||||
if (stampa) {
|
||||
myrec.data_online_stampa = myrec.data_generato_stampa;
|
||||
} else {
|
||||
myrec.data_online = myrec.data_generato;
|
||||
}
|
||||
|
||||
// Aggiorna il record
|
||||
await myrec.save();
|
||||
|
||||
risout = { record: myrec._doc };
|
||||
}
|
||||
|
||||
// risout
|
||||
const risout = await GenPdf.onlinePdf(req.body);
|
||||
|
||||
return res.status(200).send(risout);
|
||||
} catch (e) {
|
||||
@@ -687,6 +628,7 @@ router.post('/online-pdf', authenticate, async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
async function JoinPDFCatalogs(cataloghi, options, outputFile, stampa) {
|
||||
try {
|
||||
// Per ogni catalogo prendi il suo PDF Generato
|
||||
@@ -769,7 +711,7 @@ router.post('/join-pdf', authenticate, async (req, res) => {
|
||||
|
||||
if (options.stampa) {
|
||||
outputFileStampa =
|
||||
path.join(full_dir_out, path.basename(tools.removeFileExtension(outputFile))) + '-stampabile.pdf';
|
||||
path.join(full_dir_out, path.basename(tools.removeFileExtension(outputFile))) + '_stampabile.pdf';
|
||||
// Creazione file per STAMPA
|
||||
const ris_stampa = await JoinPDFCatalogs(cataloghi, options, outputFileStampa, true);
|
||||
if (ris_stampa) {
|
||||
@@ -805,7 +747,7 @@ router.post('/join-pdf', authenticate, async (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
raccolta.save();
|
||||
await raccolta.save();
|
||||
|
||||
risout = { raccolta: raccolta._doc };
|
||||
}
|
||||
@@ -1978,7 +1920,6 @@ async function importaCatalogo(data) {
|
||||
|
||||
let nontrovati = 0;
|
||||
|
||||
|
||||
for (const product of dataObjects) {
|
||||
let isnuovo = false;
|
||||
let setta = false;
|
||||
|
||||
Reference in New Issue
Block a user