diff --git a/.env.prod.riso b/.env.prod.riso
index 03a36f8..23d2d70 100644
--- a/.env.prod.riso
+++ b/.env.prod.riso
@@ -30,8 +30,8 @@ SECRK=iUUb38v23jjDFaosWj92axkBOXCQ
TOKEN_LIFE=2h
REFRESH_TOKEN_LIFE=14d
AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNV
-DOMAINS=[{"hostname":"riso.app","port":"3006"},{"hostname":"freeplanet.app","port":"3000"}]
-DOMAINS_ALLOWED=["comunitanuovomondo.app","kolibrilab.it","artenergetica.org","freeplanet.app","www.freeplanet.app","freeplanet.app:3000","freeplanet.app:3001","www.freeplanet.app:3000","www.freeplanet.app:3001"]
+DOMAINS=[{"hostname":"riso.app","port":"3006"},{"hostname":"freeplanet.app","port":"3000"},{"hostname":"nuovomondo.app","port":"3032"}]
+DOMAINS_ALLOWED=["comunitanuovomondo.app","nuovomondo.app","kolibrilab.it","artenergetica.org","freeplanet.app","www.freeplanet.app","freeplanet.app:3000","freeplanet.app:3001","www.freeplanet.app:3000","www.freeplanet.app:3001"]
#DOMAINS=[{"hostname":"abitaregliiblei.it","port":"3021"},{"hostname":"riso.app","port":"3005"}]
SCRIPTS_DIR=admin_scripts
CLOUDFLARE_TOKENS=[{"label":"Paolo.arena77@gmail.com","value":"M9EM309v8WFquJKpYgZCw-TViM2wX6vB3wlK6GD0"},{"label":"gruppomacro.com","value":"bqmzGShoX7WqOBzkXocoECyBkPq3GfqcM5t6VFd8"}]
diff --git a/.env.test.risosrv b/.env.test.risosrv
index db14910..749a47b 100644
--- a/.env.test.risosrv
+++ b/.env.test.risosrv
@@ -31,7 +31,7 @@ SECRK=iUUb38v23jjDFaosWj92axkBOXCQ
TOKEN_LIFE=2h
REFRESH_TOKEN_LIFE=14d
AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNV
-DOMAINS=[{"hostname":"riso.app","port":"3005"}]
+DOMAINS=[{"hostname":"riso.app","port":"3005"},{"hostname":"nuovomondo.app","port":"3033"}]
DOMAINS_ALLOWED=["comunitanuovomondo.app","kolibrilab.it","artenergetica.org","freeplanet.app","www.freeplanet.app","freeplanet.app:3000","freeplanet.app:3001","www.freeplanet.app:3000","www.freeplanet.app:3001"]
SCRIPTS_DIR=admin_scripts
CLOUDFLARE_TOKENS=[{"label":"Paolo.arena77@gmail.com","value":"M9EM309v8WFquJKpYgZCw-TViM2wX6vB3wlK6GD0"},{"label":"gruppomacro.com","value":"bqmzGShoX7WqOBzkXocoECyBkPq3GfqcM5t6VFd8"}]
diff --git a/docs/apache2/sites-available/50_ssl_test.abitaregliiblei.it.conf b/docs/apache2/OLD_sites-available/50_ssl_test.abitaregliiblei.it.conf
similarity index 100%
rename from docs/apache2/sites-available/50_ssl_test.abitaregliiblei.it.conf
rename to docs/apache2/OLD_sites-available/50_ssl_test.abitaregliiblei.it.conf
diff --git a/docs/apache2/sites-available/dominioinclude_piuchebuono.app.conf b/docs/apache2/OLD_sites-available/dominioinclude_piuchebuono.app.conf
similarity index 100%
rename from docs/apache2/sites-available/dominioinclude_piuchebuono.app.conf
rename to docs/apache2/OLD_sites-available/dominioinclude_piuchebuono.app.conf
diff --git a/docs/apache2/sites-available/dominioinclude_test.abitaregliiblei.it.conf b/docs/apache2/OLD_sites-available/dominioinclude_test.abitaregliiblei.it.conf
similarity index 100%
rename from docs/apache2/sites-available/dominioinclude_test.abitaregliiblei.it.conf
rename to docs/apache2/OLD_sites-available/dominioinclude_test.abitaregliiblei.it.conf
diff --git a/docs/apache2/OLD_sites-available/dominioinclude_test.riso.app.conf b/docs/apache2/OLD_sites-available/dominioinclude_test.riso.app.conf
new file mode 100644
index 0000000..abb6667
--- /dev/null
+++ b/docs/apache2/OLD_sites-available/dominioinclude_test.riso.app.conf
@@ -0,0 +1,4 @@
+Define MIODOMINIO riso.app
+Define MIODOMINIO_COMPLETO test.riso.app
+Define MIOURL_API testapi.riso.app
+Define PORTA 3005
\ No newline at end of file
diff --git a/docs/apache2/sites-available/nodejs_3000_api.piuchebuono.app.conf b/docs/apache2/OLD_sites-available/nodejs_3000_api.piuchebuono.app.conf
similarity index 100%
rename from docs/apache2/sites-available/nodejs_3000_api.piuchebuono.app.conf
rename to docs/apache2/OLD_sites-available/nodejs_3000_api.piuchebuono.app.conf
diff --git a/docs/apache2/sites-available/nodejs_virtualhost_ssl_http_https.conf b/docs/apache2/OLD_sites-available/nodejs_virtualhost_ssl_http_https.conf
similarity index 100%
rename from docs/apache2/sites-available/nodejs_virtualhost_ssl_http_https.conf
rename to docs/apache2/OLD_sites-available/nodejs_virtualhost_ssl_http_https.conf
diff --git a/docs/apache2/sites-available/websites_ssl_piuchebuono.app.conf b/docs/apache2/OLD_sites-available/websites_ssl_piuchebuono.app.conf
similarity index 100%
rename from docs/apache2/sites-available/websites_ssl_piuchebuono.app.conf
rename to docs/apache2/OLD_sites-available/websites_ssl_piuchebuono.app.conf
diff --git a/docs/apache2/sites-available/websites_ssl_test.abitaregliiblei.it.conf b/docs/apache2/OLD_sites-available/websites_ssl_test.abitaregliiblei.it.conf
similarity index 100%
rename from docs/apache2/sites-available/websites_ssl_test.abitaregliiblei.it.conf
rename to docs/apache2/OLD_sites-available/websites_ssl_test.abitaregliiblei.it.conf
diff --git a/docs/apache2/OLD_sites-available/websites_ssl_virtualhost.conf b/docs/apache2/OLD_sites-available/websites_ssl_virtualhost.conf
new file mode 100644
index 0000000..c436992
--- /dev/null
+++ b/docs/apache2/OLD_sites-available/websites_ssl_virtualhost.conf
@@ -0,0 +1,30 @@
+
+ ServerName ${MIODOMINIO_COMPLETO}
+ RewriteEngine On
+
+ # Forza la connessione HTTPS
+ RewriteCond %{HTTPS} off
+ RewriteRule ^ https://${MIODOMINIO_COMPLETO}%{REQUEST_URI} [L,R=301]
+
+
+
+ ServerName ${MIODOMINIO_COMPLETO}
+ DocumentRoot /var/www/${MIODOMINIO_COMPLETO}
+ ServerAdmin surya@riso.app
+ SSLEngine On
+ SSLProtocol -ALL +TLSv1.2
+ SSLCompression Off
+ SSLHonorCipherOrder off
+ SSLCipherSuite ECDH+AESGCM:ECDH+AES256:!aNULL:!MD5:!DSS:!DH:!AES128
+ SSLVerifyDepth 10
+ SSLCertificateFile /etc/letsencrypt/live/${MIODOMINIO}/cert.pem
+ SSLCertificateKeyFile /etc/letsencrypt/live/${MIODOMINIO}/privkey.pem
+
+ CGIPassAuth On
+ Require all granted
+ AllowOverride All
+
+ LogLevel warn
+ ErrorLog "/var/www/${MIODOMINIO_COMPLETO}/logs/error.log"
+ CustomLog "/var/www/${MIODOMINIO_COMPLETO}/logs/access.log" combined
+
\ No newline at end of file
diff --git a/docs/apache2/sites-available/000-default-ssl.conf b/docs/apache2/sites-available/000-default-ssl.conf
new file mode 100644
index 0000000..18648c1
--- /dev/null
+++ b/docs/apache2/sites-available/000-default-ssl.conf
@@ -0,0 +1,11 @@
+
+ ServerName _default_
+ SSLEngine on
+ SSLCertificateFile /etc/letsencrypt/live/riso.app/fullchain.pem
+ SSLCertificateKeyFile /etc/letsencrypt/live/riso.app/privkey.pem
+ Include /etc/letsencrypt/options-ssl-apache.conf
+ Protocols h2 http/1.1
+
+ # Puoi anche fare un 403:
+ Redirect 403 /
+
\ No newline at end of file
diff --git a/docs/apache2/sites-available/dominioinclude.riso.app.conf b/docs/apache2/sites-available/dominioinclude.riso.app.conf
new file mode 100644
index 0000000..19ac50b
--- /dev/null
+++ b/docs/apache2/sites-available/dominioinclude.riso.app.conf
@@ -0,0 +1,4 @@
+Define MIODOMINIO riso.app
+Define MIODOMINIO_COMPLETO riso.app
+Define MIOURL_API api.riso.app
+Define PORTA 3006
\ No newline at end of file
diff --git a/docs/apache2/sites-available/websites_ssl.riso.app.conf b/docs/apache2/sites-available/websites_ssl.riso.app.conf
new file mode 100644
index 0000000..b711062
--- /dev/null
+++ b/docs/apache2/sites-available/websites_ssl.riso.app.conf
@@ -0,0 +1,3 @@
+Include /etc/apache2/sites-available/dominioinclude.riso.app.conf
+
+Include /etc/apache2/sites-available/websites_ssl_virtualhost.conf
\ No newline at end of file
diff --git a/docs/apache2/sites-available/websites_ssl_test.riso.app.conf b/docs/apache2/sites-available/websites_ssl_test.riso.app.conf
new file mode 100644
index 0000000..34dabf7
--- /dev/null
+++ b/docs/apache2/sites-available/websites_ssl_test.riso.app.conf
@@ -0,0 +1,3 @@
+Include /etc/apache2/sites-available/dominioinclude_test.riso.app.conf
+
+Include /etc/apache2/sites-available/websites_ssl_virtualhost_sottodomini.conf
\ No newline at end of file
diff --git a/docs/apache2/sites-available/websites_ssl_virtualhost.conf b/docs/apache2/sites-available/websites_ssl_virtualhost.conf
index c436992..6f24791 100644
--- a/docs/apache2/sites-available/websites_ssl_virtualhost.conf
+++ b/docs/apache2/sites-available/websites_ssl_virtualhost.conf
@@ -1,30 +1,94 @@
-
- ServerName ${MIODOMINIO_COMPLETO}
- RewriteEngine On
+# ==================== APEX (SITO) ====================
+# HTTP -> HTTPS
+
+ ServerName ${MIODOMINIO}
+ ServerAlias www.${MIODOMINIO}
- # Forza la connessione HTTPS
- RewriteCond %{HTTPS} off
- RewriteRule ^ https://${MIODOMINIO_COMPLETO}%{REQUEST_URI} [L,R=301]
+ RewriteEngine On
+ RewriteRule ^ https://${MIODOMINIO}%{REQUEST_URI} [R=301,L]
+
+ ErrorLog /var/log/apache2/${MIODOMINIO}-error.log
+ CustomLog /var/log/apache2/${MIODOMINIO}-access.log combined
-
- ServerName ${MIODOMINIO_COMPLETO}
- DocumentRoot /var/www/${MIODOMINIO_COMPLETO}
- ServerAdmin surya@riso.app
- SSLEngine On
- SSLProtocol -ALL +TLSv1.2
- SSLCompression Off
- SSLHonorCipherOrder off
- SSLCipherSuite ECDH+AESGCM:ECDH+AES256:!aNULL:!MD5:!DSS:!DH:!AES128
- SSLVerifyDepth 10
- SSLCertificateFile /etc/letsencrypt/live/${MIODOMINIO}/cert.pem
- SSLCertificateKeyFile /etc/letsencrypt/live/${MIODOMINIO}/privkey.pem
-
- CGIPassAuth On
- Require all granted
- AllowOverride All
-
- LogLevel warn
- ErrorLog "/var/www/${MIODOMINIO_COMPLETO}/logs/error.log"
- CustomLog "/var/www/${MIODOMINIO_COMPLETO}/logs/access.log" combined
+# HTTPS (servizio sito - NO proxy qui)
+
+ ServerName ${MIODOMINIO}
+ ServerAlias www.${MIODOMINIO}
+
+ DocumentRoot /var/www/${MIODOMINIO_COMPLETO}
+
+ SSLEngine on
+ SSLCertificateFile /etc/letsencrypt/live/${MIODOMINIO}/fullchain.pem
+ SSLCertificateKeyFile /etc/letsencrypt/live/${MIODOMINIO}/privkey.pem
+ Include /etc/letsencrypt/options-ssl-apache.conf
+ Protocols h2 http/1.1
+
+
+ Options Indexes FollowSymLinks
+ AllowOverride All
+ Require all granted
+
+
+ DirectoryIndex index.html
+
+ # (Opzionale per SPA Quasar/Vue)
+ # RewriteEngine On
+ # RewriteCond %{REQUEST_FILENAME} !-f
+ # RewriteCond %{REQUEST_FILENAME} !-d
+ # RewriteRule ^ /index.html [L]
+
+ ErrorLog /var/log/apache2/${MIODOMINIO}-error.log
+ CustomLog /var/log/apache2/${MIODOMINIO}-access.log combined
+
+
+
+# ==================== API ====================
+# HTTP -> HTTPS
+
+ ServerName ${MIOURL_API}
+
+ RewriteEngine On
+ RewriteRule ^ https://${MIOURL_API}%{REQUEST_URI} [R=301,L]
+
+ ErrorLog /var/log/apache2/${MIOURL_API}-error.log
+ CustomLog /var/log/apache2/${MIOURL_API}-access.log combined
+
+
+# HTTPS (proxy verso backend)
+
+ ServerName ${MIOURL_API}
+ ServerAdmin surya@riso.app
+
+ SSLEngine on
+ SSLCertificateFile /etc/letsencrypt/live/${MIODOMINIO}/fullchain.pem
+ SSLCertificateKeyFile /etc/letsencrypt/live/${MIODOMINIO}/privkey.pem
+ Include /etc/letsencrypt/options-ssl-apache.conf
+ Protocols h2 http/1.1
+
+ ProxyPreserveHost On
+
+ # ===== SCEGLI UNO DEI DUE BLOCCHI, in base al TUO backend su ${PORTA} =====
+ # --- Backend HTTP (più comune) ---
+ # ProxyPass / http://127.0.0.1:${PORTA}/ retry=0 timeout=310 connectiontimeout=30
+ # ProxyPassReverse / http://127.0.0.1:${PORTA}/
+
+ # --- Backend HTTPS (nel tuo caso probabile, visto l’“Empty reply” via HTTP) ---
+ SSLProxyEngine On
+ SSLProxyVerify none
+ SSLProxyCheckPeerName off
+ ProxyPass / https://127.0.0.1:${PORTA}/ retry=0 timeout=310 connectiontimeout=30
+ ProxyPassReverse / https://127.0.0.1:${PORTA}/
+ # ==========================================================================
+
+
+ Require all granted
+
+
+ ProxyTimeout 310
+ Timeout 310
+ ProxyBadHeader Ignore
+
+ ErrorLog /var/log/apache2/${MIOURL_API}-error.log
+ CustomLog /var/log/apache2/${MIOURL_API}-access.log combined
\ No newline at end of file
diff --git a/docs/apache2/sites-available/websites_ssl_virtualhost_sottodomini.conf b/docs/apache2/sites-available/websites_ssl_virtualhost_sottodomini.conf
new file mode 100644
index 0000000..2e4c8f4
--- /dev/null
+++ b/docs/apache2/sites-available/websites_ssl_virtualhost_sottodomini.conf
@@ -0,0 +1,92 @@
+# ==================== APEX (SITO) ====================
+# HTTP -> HTTPS
+
+ ServerName ${MIODOMINIO_COMPLETO}
+
+ RewriteEngine On
+ RewriteRule ^ https://${MIODOMINIO_COMPLETO}%{REQUEST_URI} [R=301,L]
+
+ ErrorLog /var/log/apache2/${MIODOMINIO_COMPLETO}-error.log
+ CustomLog /var/log/apache2/${MIODOMINIO_COMPLETO}-access.log combined
+
+
+# HTTPS (servizio sito - NO proxy qui)
+
+ ServerName ${MIODOMINIO_COMPLETO}
+
+ DocumentRoot /var/www/${MIODOMINIO_COMPLETO}
+
+ SSLEngine on
+ SSLCertificateFile /etc/letsencrypt/live/${MIODOMINIO}/fullchain.pem
+ SSLCertificateKeyFile /etc/letsencrypt/live/${MIODOMINIO}/privkey.pem
+ Include /etc/letsencrypt/options-ssl-apache.conf
+ Protocols h2 http/1.1
+
+
+ Options Indexes FollowSymLinks
+ AllowOverride All
+ Require all granted
+
+
+ DirectoryIndex index.html
+
+ # (Opzionale per SPA Quasar/Vue)
+ # RewriteEngine On
+ # RewriteCond %{REQUEST_FILENAME} !-f
+ # RewriteCond %{REQUEST_FILENAME} !-d
+ # RewriteRule ^ /index.html [L]
+
+ ErrorLog /var/log/apache2/${MIODOMINIO_COMPLETO}-error.log
+ CustomLog /var/log/apache2/${MIODOMINIO_COMPLETO}-access.log combined
+
+
+
+# ==================== API ====================
+# HTTP -> HTTPS
+
+ ServerName ${MIOURL_API}
+
+ RewriteEngine On
+ RewriteRule ^ https://${MIOURL_API}%{REQUEST_URI} [R=301,L]
+
+ ErrorLog /var/log/apache2/${MIOURL_API}-error.log
+ CustomLog /var/log/apache2/${MIOURL_API}-access.log combined
+
+
+# HTTPS (proxy verso backend)
+
+ ServerName ${MIOURL_API}
+ ServerAdmin surya@riso.app
+
+ SSLEngine on
+ SSLCertificateFile /etc/letsencrypt/live/${MIODOMINIO}/fullchain.pem
+ SSLCertificateKeyFile /etc/letsencrypt/live/${MIODOMINIO}/privkey.pem
+ Include /etc/letsencrypt/options-ssl-apache.conf
+ Protocols h2 http/1.1
+
+ ProxyPreserveHost On
+
+ # ===== SCEGLI UNO DEI DUE BLOCCHI, in base al TUO backend su ${PORTA} =====
+ # --- Backend HTTP (più comune) ---
+ # ProxyPass / http://127.0.0.1:${PORTA}/ retry=0 timeout=310 connectiontimeout=30
+ # ProxyPassReverse / http://127.0.0.1:${PORTA}/
+
+ # --- Backend HTTPS (nel tuo caso probabile, visto l’“Empty reply” via HTTP) ---
+ SSLProxyEngine On
+ SSLProxyVerify none
+ SSLProxyCheckPeerName off
+ ProxyPass / https://127.0.0.1:${PORTA}/ retry=0 timeout=310 connectiontimeout=30
+ ProxyPassReverse / https://127.0.0.1:${PORTA}/
+ # ==========================================================================
+
+
+ Require all granted
+
+
+ ProxyTimeout 310
+ Timeout 310
+ ProxyBadHeader Ignore
+
+ ErrorLog /var/log/apache2/${MIOURL_API}-error.log
+ CustomLog /var/log/apache2/${MIOURL_API}-access.log combined
+
\ No newline at end of file
diff --git a/src/server/models/order.js b/src/server/models/order.js
index 685fc1f..8077a1a 100755
--- a/src/server/models/order.js
+++ b/src/server/models/order.js
@@ -690,3 +690,6 @@ function generateCSV(data, outputPath) {
// const Order = mongoose.model('Order', OrderSchema);
// module.exports = { Order };
+
+
+// **** TOTALPRICE !!!
\ No newline at end of file
diff --git a/src/server/modules/CronMod.js b/src/server/modules/CronMod.js
index 928d0ad..012ec5c 100644
--- a/src/server/modules/CronMod.js
+++ b/src/server/modules/CronMod.js
@@ -495,36 +495,38 @@ class CronMod {
await MyBot.generateBotMenuRecords(idapp);
} else if (mydata.dbop === 'GenerateVapiKey') {
await tools.generateVapiKey();
+ } else if (mydata.dbop === 'convertProductInfos') {
+ const products = await Product.find({ idProductInfo: { $exists: true } });
+ console.log(
+ 'eseguiDbOpUser: convertProductInfos - TrovaticonvertProductInfos ',
+ products.length,
+ ' prodotti con idProductInfo'
+ );
- /*} else if (mydata.dbop === 'visuNave') {
- mystr = await Nave.getNavePos(idapp, parseInt(mydata.riga), parseInt(mydata.col));
-
- const visu_nave_Bot = await Settings.getValDbSettings(idapp, 'VISU_NAVE_BOT');
- if (visu_nave_Bot)
- telegrambot.sendMsgTelegramToTheAdmin(idapp, mystr, true);
-
- ris = { mystr };
- } else if (mydata.dbop === 'getnavibyuser') {
-
- let arrnavi = null;
-
- const user = await User.getUserShortDataByUsername(idapp, mydata.username);
- if (user) {
- arrnavi = await Nave.getArrPosizioniByUsername(idapp, user.username);
-
- for (let mynave of arrnavi) {
- mynave._doc.rec = await Nave.getNaveByRigaCol(idapp, mynave.riga, mynave.col);
- }
-
+ let aggiornati = 0;
+ for (const product of products) {
+ const productInfo = await ProductInfo.findById(product.idProductInfo);
+ if (productInfo) {
+ const productInfoObj = productInfo.toObject();
+ delete productInfoObj._id;
+ delete productInfoObj.__v;
+ await Product.updateOne(
+ { _id: product._id },
+ {
+ $set: { productInfo: productInfoObj },
+ $unset: { idProductInfo: 1 },
+ }
+ );
+
+ aggiornati++;
+
+ // ✅ Cancella il record ProductInfo ora che è stato copiato
+ await ProductInfo.deleteOne({ _id: productInfo._id });
}
-
- ris = { data: arrnavi };
-
- */
+ }
+ console.log('eseguiDbOpUser - Aggiornati ', aggiornati, ' prodotti');
}
- // console.log('ris', ris);
-
return ris;
} catch (e) {
console.log(e.message);
diff --git a/src/server/router/admin_router.js b/src/server/router/admin_router.js
index 5c3a129..74bc8d8 100755
--- a/src/server/router/admin_router.js
+++ b/src/server/router/admin_router.js
@@ -1316,193 +1316,6 @@ router.post('/import', authenticate, async (req, res) => {
);
return res.status(200).send({ updated, imported, errors });
- } else if (cmd === shared_consts.Cmd.MACRO_RANKING) {
- /*
- let updated = 0;
- let imported = 0;
- let errors = 0;
-
- const ripopola = true; // SETTARE su TRUE
-
- if (ripopola) {
- dataObjects = null;
-
- try {
- dataObjects = JSON.parse(`[${data.arrdata}]`);
- } catch (e) {
- dataObjects = null;
- }
-
- if (dataObjects && dataObjects[0]) {
- // Cancella la collection ImportaIsbn
- await ImportaIsbn.deleteMany({ idapp });
-
- const numtot = dataObjects[0].length
-
- console.log('Numero di RECORD da Importare = ', numtot);
-
- // Aggiungi i record su ImportaIsbn
- for (const recinv of dataObjects[0]) {
- let recmacro = recinv;
-
- recmacro.idapp = idapp;
-
- //recmacro._id = recmacro.id;
- recmacro.sku = recmacro.IdArticolo;
-
- if (recmacro.DataPubblicazione) {
-
- // delete recmacro.id;
-
- let queryprod = { idapp, sku: recmacro.sku };
-
- // 13872
-
- try {
- let risrec = await ImportaIsbn.findOneAndUpdate(queryprod, { $set: recmacro }, { new: true, upsert: true, strict: false });
- if (risrec) {
- imported++;
- if ((imported % 100) === 0)
- console.log('Importati dir TEMPORANEA ... ', imported + '/' + numtot);
- }
-
- } catch (e) {
- console.error(e);
- errors++;
- }
- }
- }
- }
- }
-
- // Rileggi tutti i record di ImportaIsbn
- dataObjects = await ImportaIsbn.find({ idapp }).lean();
-
- let numprod = dataObjects.length;
-
- console.log('*** INIZIO IMPORT RANKING ... NUMRECORD = ', numprod);
-
- let indprod = 0;
- let newprod = 0;
-
-
- if (numprod) {
- // Rimuove prima tutti i valori precedenti
- let risupdate = await ProductInfo.updateMany({ idapp }, {
- $set: {
- totVen: 0,
- totFat: 0,
- vLast3M: 0,
- vLast6M: 0,
- vLast1Y: 0,
- vLast2Y: 0,
- rank3M: 0,
- rank6M: 0,
- rank1Y: 0,
- }
- });
-
-
- }
-
- imported = 0;
-
- for (const product of dataObjects) {
- let isnuovo = false
- let setta = false
-
- let importa = true;
-
- //if (!product.title || !product.isbn)
- if (!product.sku || !product.DataPubblicazione)
- importa = false;
-
- if (importa) {
- let versGM = product.Versione ? product.Versione : '';
-
- // split versioneGM in array with separated ","
- let arrversGM = versGM.split(",").map(x => x.trim());
-
- const recproductInfoAttuale = await ProductInfo.findOne({ idapp, code: product.isbn });
-
- let productInfo = {
- idapp: product.idapp,
- code: product.isbn ? product.isbn : product.code,
- sku: product.sku,
- idCatProds: recproductInfoAttuale?.idCatProds,
-
- // id_wp: product._id,
-
- // name: product.title,
- totVen: product.totVen || 0,
- totFat: product.totFat || 0,
- vLast3M: product.vLast3M || 0,
- fatLast3M: product.fatLast3M || 0,
- fatLast6M: product.fatLast6M || 0,
- vLast6M: product.vLast6M || 0,
- vLast1Y: product.vLast1Y || 0,
- vLast2Y: product.vLast2Y || 0,
- rank3M: product.rank3M || 0,
- rank6M: product.rank6M || 0,
- rank1Y: product.rank1Y || 0,
-
- }
-
- if (!productInfo.idCatProds) {
- productInfo.idCatProds = [];
- }
-
-
- // Aggiorna la collana solo se non è stata già impostata nel record attuale
- //if (recproductInfoAttuale && !recproductInfoAttuale.idCollana && product.DescrizioneCollana) {
- if (recproductInfoAttuale && product.DescrizioneCollana) {
- const idCollanaNum = parseInt(product.IdCollana)
-
- reccollana = await Collana.findOne({ idapp, idCollana: idCollanaNum }).lean();
- if (!reccollana) {
- try {
- // Non esiste questa collana, quindi la creo !
- reccollana = new Collana({ idapp, idCollana: idCollanaNum, title: product.DescrizioneCollana });
- ris = await reccoll.save();
- } catch (e) {
- console.error('Err', e);
- }
- }
-
- if (reccollana)
- productInfo.idCollana = reccollana._id;
-
- }
-
- if (recproductInfoAttuale && product.DescrArgomento) {
-
- productInfo = await updateProductInfo(productInfo, product, idapp, product.DescrArgomento);
- }
-
- if (product.DataPubblicazione) {
- productInfo.date_pub = new Date(product.DataPubblicazione);
- // convert data to timestamp
- productInfo.date_pub_ts = productInfo.date_pub.getTime();
- }
- if (product.dataUltimoOrdine) {
- productInfo.dataUltimoOrdine = new Date(product.dataUltimoOrdine);
- }
-
-
- // Update ProductInfo
- let risrecInfo = await ProductInfo.findOneAndUpdate({ idapp, code: productInfo.code }, { $set: productInfo }, { new: true, upsert: false });
- if (risrecInfo) {
- imported++;
- if (imported % 100 === 0)
- console.log('Importati... ', imported + '/' + numprod);
- }
- }
- }
-
- console.log('*** IMPORTATI: ', imported, ' [Prodotti = ' + indprod + '] *** NUOVI: ', newprod, 'AGGIORNATI = ' + updated + ' (su ' + dataObjects.length + ' RECORD)');
-
- return res.status(200).send({ updated, imported, errors });
- */
} else if (cmd === shared_consts.Cmd.MACRO_CATALOGO_JSON) {
try {
const macro = new Macro(idapp, { importadaFDV: true }); // Crea un'istanza della classe Macro
@@ -1598,6 +1411,7 @@ router.post('/import', authenticate, async (req, res) => {
);
// .... ANDARE AVANTI DA QUI... .productInfo.... SISTEMARE!
+
if (risrecInfo) {
productImported.productInfo = risrecInfo._id;
diff --git a/src/server/router/api_router.js b/src/server/router/api_router.js
index d7bdd05..7517464 100644
--- a/src/server/router/api_router.js
+++ b/src/server/router/api_router.js
@@ -191,6 +191,26 @@ function subDays(date, days) {
return newDate;
}
+router.delete('/mypage/:id', authenticate, async (req, res) => {
+ try {
+ const { id } = req.params;
+
+
+
+ // Trova il record di MyPage da cancellare
+ const pageToDelete = await MyPage.findByIdAndRemove(id);
+
+ if (!pageToDelete) {
+ return res.status(404).json({ error: 'Pagina non trovata' });
+ }
+
+ res.json({ message: `Pagina eliminata con successo: ${pageToDelete.path}` });
+ } catch (err) {
+ console.error(err);
+ res.status(500).json({ error: 'Errore durante l\'eliminazione della pagina' });
+ }
+});
+
router.get('/pageviews/users', authenticate_noerror, async (req, res) => {
try {
const { idapp } = req.query;
diff --git a/src/server/router/index_router.js b/src/server/router/index_router.js
index 34b7181..f7d7321 100755
--- a/src/server/router/index_router.js
+++ b/src/server/router/index_router.js
@@ -900,6 +900,30 @@ router.post('/getpage', async (req, res) => {
return found;
});
+router.post('/savepage', authenticate, async (req, res) => {
+ const params = req.body;
+ const idapp = req.body.idapp;
+ const mypage = params.page;
+
+ try {
+ if (mypage?._id) {
+ let found = await MyPage.findOneAndUpdate({ idapp, _id: mypage._id }, mypage, { upsert: true, new: true })
+ .then((ris) => {
+ if (ris) {
+ return res.send({ code: server_constants.RIS_CODE_OK, mypage: ris });
+ }
+ return res.send({ code: server_constants.RIS_CODE_ERR, msg: '' });
+ })
+ .catch((e) => {
+ console.log(e.message);
+ res.status(400).send(e);
+ });
+ }
+ } catch (e) {
+ console.error('Error', e);
+ }
+});
+
async function exportPage(idapp, pageId) {
try {
const myexp = {
diff --git a/src/server/router/users_router.js b/src/server/router/users_router.js
index d1e5654..990f915 100755
--- a/src/server/router/users_router.js
+++ b/src/server/router/users_router.js
@@ -1126,23 +1126,6 @@ async function eseguiDbOpUser(idapp, mydata, locale, req, res) {
await User.findOneAndUpdate({ _id: mydata._id }, { $set: { 'profile.noCircIta': mydata.value } });
} else if (mydata.dbop === 'noFoto') {
await User.findOneAndUpdate({ _id: mydata._id }, { $set: { 'profile.noFoto': mydata.value } });
- } else if (mydata.dbop === 'convertProductInfos') {
- const products = await Product.find({ idProductInfo: { $exists: true } });
- for (const product of products) {
- const productInfo = await ProductInfo.findById(product.idProductInfo);
- if (productInfo) {
- const productInfoObj = productInfo.toObject();
- delete productInfoObj._id;
- delete productInfoObj.__v;
- await Product.updateOne(
- { _id: product._id },
- {
- $set: { productInfo: productInfoObj },
- $unset: { idProductInfo: 1 },
- }
- );
- }
- }
}
} catch (e) {
console.log(e.message);
diff --git a/src/server/server.js b/src/server/server.js
index 640de78..9a5e090 100755
--- a/src/server/server.js
+++ b/src/server/server.js
@@ -791,7 +791,10 @@ connectToDatabase(connectionUrl, options)
return [
'https://localhost:3000',
'https://localhost:8089',
+ 'https://localhost:8082',
+ 'https://localhost:8083',
'https://localhost:8084',
+ 'https://localhost:8085',
'https://localhost:8088',
'https://localhost:8099',
];
@@ -864,6 +867,7 @@ connectToDatabase(connectionUrl, options)
function setupMiddleware(app, corsOptions, isDebug = false) {
app.use(cors(corsOptions));
+ app.set('trust proxy', true);
app.use(express.json());
app.options('*', cors(corsOptions));
diff --git a/src/server/version.txt b/src/server/version.txt
index d5bad6d..0951b97 100644
--- a/src/server/version.txt
+++ b/src/server/version.txt
@@ -1 +1 @@
-1.2.67
\ No newline at end of file
+1.2.68
\ No newline at end of file