- posso fare upload dell'immagine del prodotto dalla lista

- corretto import dati
This commit is contained in:
Surya Paolo
2024-03-02 22:53:29 +01:00
parent 1017a3dfe2
commit 789e3fde41
6 changed files with 78 additions and 37 deletions

View File

@@ -1,11 +1,11 @@
DATABASE=test_FreePlanet DATABASE=test_PiuCheBuono
UDB=paofreeplanet UDB=paofreeplanet
PDB=mypassword@1A PDB=mypassword@1A
SEND_EMAIL=0 SEND_EMAIL=0
SEND_EMAIL_ORDERS=1 SEND_EMAIL_ORDERS=1
PORT=3000 PORT=3000
appTelegram_TEST=["1","13"] appTelegram_TEST=["1","17"]
appTelegram=["1","13"] appTelegram=["1","17"]
DOMAIN=mongodb://localhost:27017/ DOMAIN=mongodb://localhost:27017/
AUTH_MONGODB=true AUTH_MONGODB=true
MONGODB_USER=admin MONGODB_USER=admin

View File

@@ -6,7 +6,9 @@
"Hosp": "Ospitalità", "Hosp": "Ospitalità",
"Good: %s": "Bene: %s", "Good: %s": "Bene: %s",
"Service: %s": "Servizio: %s", "Service: %s": "Servizio: %s",
"Hosp: %s": "Ospitalità: %s", "NEW_GOOD": "❇️ <strong>%s</strong> ha aggiunto un nuovo Bene: \n<strong>%s</strong>",
"NEW_SERVICE": "❇️ <strong>%s</strong> ha aggiunto un nuovo Servizio: \n<strong>%s</strong>",
"NEW_HOSP": "❇️ <strong>%s</strong> ha aggiunto una nuova Ospitalità: \n<strong>%s</strong>",
"NEW_EVENT": "❇️ <strong>%s</strong> ha aggiunto un nuovo Evento: \n%s\n<strong>%s</strong>\n%s", "NEW_EVENT": "❇️ <strong>%s</strong> ha aggiunto un nuovo Evento: \n%s\n<strong>%s</strong>\n%s",
"NEW_EVENT_TELEGRAM": "%s\n\n❇ <strong>%s</strong>\n\n%s\n\n%s", "NEW_EVENT_TELEGRAM": "%s\n\n❇ <strong>%s</strong>\n\n%s\n\n%s",
"NEW_ANNUNCIO_TELEGRAM": "❇️ <strong>%s</strong>\n\n%s\n\n%s", "NEW_ANNUNCIO_TELEGRAM": "❇️ <strong>%s</strong>\n\n%s\n\n%s",
@@ -116,7 +118,5 @@
"🚫 Hai rifiutato l'accesso alla App di RISO da parte di %s!": "🚫 Hai rifiutato l'accesso alla App di RISO da parte di %s!", "🚫 Hai rifiutato l'accesso alla App di RISO da parte di %s!": "🚫 Hai rifiutato l'accesso alla App di RISO da parte di %s!",
"🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.": "🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.", "🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.": "🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.",
"🚫 %s ha rifiutato l'accesso alla App a %s !": "🚫 %s ha rifiutato l'accesso alla App a %s !", "🚫 %s ha rifiutato l'accesso alla App a %s !": "🚫 %s ha rifiutato l'accesso alla App a %s !",
"✅ Hai Abilitato l'accesso alla App a %s !": "✅ Hai Abilitato l'accesso alla App a %s !", "✅ Hai Abilitato l'accesso alla App a %s !": "✅ Hai Abilitato l'accesso alla App a %s !"
"Good %s": "Good %s", }
"NEW_SERVICE": "NEW_SERVICE"
}

View File

@@ -224,7 +224,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
let eventobj = await tools.getAnnuncioForTelegram(recnotif.myrectableorig, tablerec, mydescr, userorig, true); let eventobj = await tools.getAnnuncioForTelegram(recnotif.myrectableorig, tablerec, mydescr, userorig, true);
newdescr = eventobj.newdescr; newdescr = eventobj.newdescr;
recnotif.textcontent_Telegram = eventobj.newdescrtelegram; recnotif.textcontent_Telegram = eventobj.newdescrtelegram;
recnotif.linkaddTelegram = i18n.__('SHOW_POST'); recnotif.linkaddTelegram = '';
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_EVENTS) { } else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_EVENTS) {
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYBACHECAS, true) + myidrec; recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYBACHECAS, true) + myidrec;
tag = 'newevent'; tag = 'newevent';

View File

@@ -151,11 +151,11 @@ function extractArrayDataFromCSV(idapp, rec) {
arrcampi_product = getValoriAndIndice_Product(null); arrcampi_product = getValoriAndIndice_Product(null);
for (const campoobj of arrcampi_productInfo) { for (const campoobj of arrcampi_productInfo) {
if (rec.hasOwnProperty(campoobj)) { if (rec.hasOwnProperty(campoobj.name)) {
let myval = rec[campoobj]; let myval = tools.ripulisciCampo(rec[campoobj.name]);
productInfo[campoobj] = myval === 'TRUE' ? true : (myval === 'FALSE' ? false : myval); productInfo[campoobj.name] = (myval === 'TRUE' || myval.toUpperCase() === 'SI') ? true : ((myval === 'FALSE' || myval.toUpperCase() === 'NO') ? false : myval);
} }
} }
for (const campoobj of arrcampi_product) { for (const campoobj of arrcampi_product) {
@@ -198,13 +198,14 @@ router.post('/import', authenticate, async (req, res) => {
try { try {
const liste = require('../data/liste'); const liste = require('../data/liste');
let dataObjects = null;
if (cmd === shared_consts.Cmd.CITIES_SERVER) { if (cmd === shared_consts.Cmd.CITIES_SERVER) {
return await City.insertMany(liste.Comuni).then((ris) => { return await City.insertMany(liste.Comuni).then((ris) => {
return res.status(200).send(true); return res.status(200).send(true);
}); });
} else if (cmd === shared_consts.Cmd.INVENTARIO) { } else if (cmd === shared_consts.Cmd.INVENTARIO) {
let dataObjects = JSON.parse(`[${data.arrdata}]`); dataObjects = JSON.parse(`[${data.arrdata}]`);
let updated = 0; let updated = 0;
let imported = 0; let imported = 0;
let errors = 0; let errors = 0;
@@ -222,7 +223,7 @@ router.post('/import', authenticate, async (req, res) => {
} else if (cmd === shared_consts.Cmd.PRODUCTS) { } else if (cmd === shared_consts.Cmd.PRODUCTS) {
let dataObjects = JSON.parse(`[${data.arrdata}]`); dataObjects = JSON.parse(`[${data.arrdata}]`);
let updated = 0; let updated = 0;
let imported = 0; let imported = 0;
@@ -379,8 +380,15 @@ router.post('/import', authenticate, async (req, res) => {
} }
} else if (cmd === shared_consts.Cmd.PRODUCTS_V2) { } else if (cmd === shared_consts.Cmd.PRODUCTS_V2) {
let mydata = `[${data.arrdata}]`; let mydata = `[${data.arrdata}]`;
let cleanmydata = mydata.replace(/\n/g, ''); dataObjects = mydata.replace(/\n/g, '');
let arrrec = JSON.parse(cleanmydata); let arrrec = [];
try {
arrrec = JSON.parse(dataObjects);
} catch (e) {
console.error("Errore durante l'analisi del JSON:", e);
arrrec = [];
}
let updated = 0; let updated = 0;
let imported = 0; let imported = 0;
let errors = 0; let errors = 0;

View File

@@ -475,6 +475,7 @@ module.exports = {
listimages: 1024, listimages: 1024,
exact: 2048, exact: 2048,
image: 3000, image: 3000,
image_and_filename: 3100,
nationality: 4096, nationality: 4096,
intcode: 5000, intcode: 5000,
multioption: 6000, multioption: 6000,
@@ -4734,7 +4735,7 @@ module.exports = {
const result = []; const result = [];
text = text.replace(",", "."); text = text.replace(",", ".");
const regex = /^(\d+\.?\d*)\s*(ml|gr|l|kg)\s*$/; // Aggiunto un punto dopo \d+ per accettare anche i numeri con la virgola const regex = /^(\d+\.?\d*)\s*(ml|gr|l|kg|uova)\s*$/; // Aggiunto un punto dopo \d+ per accettare anche i numeri con la virgola
const match = regex.exec(text); const match = regex.exec(text);
if (match) { if (match) {
@@ -4778,7 +4779,30 @@ module.exports = {
}, },
removeescape(inputString) { removeescape(inputString) {
return inputString.replace('\\', '').replace(/"/g, '') // return inputString.replace(/\\/g, '').replace(/"/g, '');
if (inputString)
return inputString.replace(/\\/g, '').replace(/"/g, '');
else
return '';
},
escapeQuotes(stringa) {
if (stringa)
return stringa.replace(/"/g, '\\"');
else
return '';
},
replaceQuotesWithSingleQuotes(jsonString) {
if (jsonString)
return jsonString.replace(/"/g, "'");
else
return '';
},
ripulisciCampo(stringa) {
let mystr = this.replaceQuotesWithSingleQuotes(stringa);
return mystr;
}, },
convertToNumeroVirgola(valstr) { convertToNumeroVirgola(valstr) {

View File

@@ -407,6 +407,11 @@ module.exports = {
short: 'p', short: 'p',
value: 10, value: 10,
}, },
{
label: 'Uova',
short: 'uova',
value: 15,
},
], ],
@@ -974,25 +979,29 @@ module.exports = {
], ],
}, },
CAMPI_TYPE: {
STRING: 1,
},
CAMPI_PRODUCTINFO: [ CAMPI_PRODUCTINFO: [
'name', {name: 'name', type: ''},
'code', {name: 'code', type: ''},
'description', {name: 'description', type: 1},
'link_scheda', {name: 'link_scheda', type: ''},
'idCatProds', {name: 'idCatProds', type: ''},
'idSubCatProds', {name: 'idSubCatProds', type: ''},
'weight', {name: 'weight', type: ''},
'weight_lordo', {name: 'weight_lordo', type: ''},
'unit', {name: 'unit', type: ''},
'unit_lordo', {name: 'unit_lordo', type: ''},
'size', {name: 'size', type: ''},
'vegan', {name: 'vegan', type: ''},
'sfuso', {name: 'sfuso', type: ''},
'img', {name: 'img', type: ''},
'link', {name: 'link', type: ''},
'ingredienti', {name: 'ingredienti', type: ''},
'valori_nutrizionali', {name: 'valori_nutrizionali', type: ''},
'note', {name: 'note', type: ''},
], ],
CAMPI_PRODUCT: [ CAMPI_PRODUCT: [