Compare commits
62 Commits
Ver_1.0.24
...
Dev_PDB1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8872d69f8 | ||
|
|
aad7822cfd | ||
|
|
fea61fda7d | ||
|
|
b1ff0ee3b7 | ||
|
|
87808caadf | ||
|
|
1d5002ea0f | ||
|
|
3b1b2b9c83 | ||
|
|
54443e784e | ||
|
|
6834dd1d55 | ||
|
|
3fcff43af0 | ||
|
|
07973fbf0a | ||
|
|
e1f2e799d6 | ||
|
|
2cdb83cddf | ||
|
|
7773c2a87b | ||
|
|
c79f6e8cc6 | ||
|
|
49ecb3edea | ||
|
|
68b4403138 | ||
|
|
11955b3242 | ||
|
|
e6009f66b9 | ||
|
|
e8cd676eef | ||
|
|
3e8be18473 | ||
|
|
c2d76ff10a | ||
|
|
07c210c59e | ||
|
|
3221cf8d25 | ||
|
|
fef8d0fbc7 | ||
|
|
970428a359 | ||
|
|
de13c42f8b | ||
|
|
39687265c8 | ||
|
|
bf1e9b83ba | ||
|
|
22771c1ea7 | ||
|
|
bd95e4457f | ||
|
|
3e0d0bf018 | ||
|
|
44b25fdf33 | ||
|
|
c94d5dc844 | ||
|
|
b5dbaafa91 | ||
|
|
789e3fde41 | ||
|
|
1017a3dfe2 | ||
|
|
b60f0f9e34 | ||
|
|
e809195f60 | ||
|
|
da9d5f25ea | ||
|
|
4a980aaad2 | ||
|
|
6ff9922a29 | ||
|
|
3191312372 | ||
|
|
204a625e06 | ||
|
|
9a83efaa3c | ||
|
|
6d8a5ae137 | ||
|
|
1268c961cf | ||
|
|
8c471c0e81 | ||
|
|
e6fd8e1fed | ||
|
|
1c31543af8 | ||
|
|
5a6c08e908 | ||
|
|
6e61138fde | ||
|
|
24f2b46cc8 | ||
|
|
26ab024514 | ||
|
|
9ca9ea6eaa | ||
|
|
e7b0fd1d95 | ||
|
|
acbc23e92d | ||
|
|
dacfc5a844 | ||
|
|
2151502d30 | ||
|
|
64bd3cebb3 | ||
|
|
9fe81713e5 | ||
|
|
d61808d1dd |
@@ -4,10 +4,10 @@ PDB=mypassword@1A
|
||||
SEND_EMAIL=0
|
||||
SEND_EMAIL_ORDERS=1
|
||||
PORT=3000
|
||||
appTelegram_TEST=["1","13"]
|
||||
appTelegram=["1","13"]
|
||||
appTelegram_TEST=["1","17","18"]
|
||||
appTelegram=["1","17","18"]
|
||||
DOMAIN=mongodb://localhost:27017/
|
||||
AUTH_MONGODB=true
|
||||
AUTH_MONGODB=1
|
||||
MONGODB_USER=admin
|
||||
MONGODB_PWD=mypwadmin@1A
|
||||
ENABLE_PUSHNOTIFICATION=1
|
||||
@@ -31,6 +31,9 @@ GCM_API_KEY=""
|
||||
PROD=0
|
||||
PROJECT_DESCR_MAIN='__PROJECTS'
|
||||
SECRK=Askb38v23jjDFaoskBOWj92axXCQ
|
||||
SECRTK=prova123prova567ASDADASDAS
|
||||
TOKEN_LIFE=2h
|
||||
REFRESH_TOKEN_LIFE=14d
|
||||
FTPSERVER_HOST=139.162.166.31
|
||||
FTPSERVER_PORT=21
|
||||
FTPSERVER_USER=ftpusrsrv_
|
||||
|
||||
@@ -7,7 +7,7 @@ PORT=3000
|
||||
appTelegram_TEST=["1","13"]
|
||||
appTelegram=["1","13"]
|
||||
DOMAIN=mongodb://localhost:27017/
|
||||
AUTH_MONGODB=true
|
||||
AUTH_MONGODB=1
|
||||
MONGODB_USER=admin
|
||||
MONGODB_PWD=mypwadmin@1A
|
||||
ENABLE_PUSHNOTIFICATION=1
|
||||
@@ -31,6 +31,9 @@ GCM_API_KEY=""
|
||||
PROD=0
|
||||
PROJECT_DESCR_MAIN='__PROJECTS'
|
||||
SECRK=Askb38v23jjDFaoskBOWj92axXCQ
|
||||
SECRTK=prova123prova567ASDADASDAS
|
||||
TOKEN_LIFE=2h
|
||||
REFRESH_TOKEN_LIFE=14d
|
||||
FTPSERVER_HOST=139.162.166.31
|
||||
FTPSERVER_PORT=21
|
||||
FTPSERVER_USER=ftpusrsrv_
|
||||
|
||||
@@ -7,7 +7,7 @@ PORT=3000
|
||||
appTelegram_TEST=["1","13"]
|
||||
appTelegram=["1","13"]
|
||||
DOMAIN=mongodb://localhost:27017/
|
||||
AUTH_MONGODB=true
|
||||
AUTH_MONGODB=1
|
||||
MONGODB_USER=admin
|
||||
MONGODB_PWD=mypwadmin@1A
|
||||
ENABLE_PUSHNOTIFICATION=1
|
||||
@@ -31,6 +31,9 @@ GCM_API_KEY=""
|
||||
PROD=0
|
||||
PROJECT_DESCR_MAIN='__PROJECTS'
|
||||
SECRK=Askb38v23jjDFaoskBOWj92axXCQ
|
||||
SECRTK=prova123prova567ASDADASDAS
|
||||
TOKEN_LIFE=2h
|
||||
REFRESH_TOKEN_LIFE=14d
|
||||
FTPSERVER_HOST=139.162.166.31
|
||||
FTPSERVER_PORT=21
|
||||
FTPSERVER_USER=ftpusrsrv_
|
||||
|
||||
@@ -4,8 +4,8 @@ PDB=suerteFreePlanet@1A
|
||||
SEND_EMAIL=1
|
||||
SEND_EMAIL_ORDERS=1
|
||||
PORT=3000
|
||||
appTelegram_TEST=["17"]
|
||||
appTelegram=["17"]
|
||||
appTelegram_TEST=["17","18"]
|
||||
appTelegram=["17","18"]
|
||||
ENABLE_PUSHNOTIFICATION=1
|
||||
DIRECTORY_SERVER=freeplanet_serverside
|
||||
SERVERDIR_WEBSITE=www.freeplanet_server
|
||||
@@ -29,4 +29,7 @@ PATH_SSL_CHAIN_PEM=chain.pem
|
||||
PROD=0
|
||||
PROJECT_DESCR_MAIN='__PROJECTS'
|
||||
SECRK=iUUb38v23jjDFaosWj92axkBOXCQ
|
||||
SECRTK=jAxKm02emx5SeJvz2IGmtRf6YqCgope
|
||||
TOKEN_LIFE=2h
|
||||
REFRESH_TOKEN_LIFE=14d
|
||||
AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNVZZ
|
||||
@@ -4,8 +4,8 @@ PDB=suerteFreePlanet@1A
|
||||
SEND_EMAIL=1
|
||||
SEND_EMAIL_ORDERS=1
|
||||
PORT=3001
|
||||
appTelegram_TEST=["17"]
|
||||
appTelegram=["17"]
|
||||
appTelegram_TEST=["17","18"]
|
||||
appTelegram=["17","18"]
|
||||
ENABLE_PUSHNOTIFICATION=1
|
||||
DIRECTORY_SERVER=freeplanet_serverside
|
||||
SERVERDIR_WEBSITE=test.freeplanet_server
|
||||
@@ -29,4 +29,6 @@ PATH_SSL_CHAIN_PEM=chain.pem
|
||||
PROD=0
|
||||
PROJECT_DESCR_MAIN='__PROJECTS'
|
||||
SECRK=iUUb38v23jjDFaosWj92axkBOXCQ
|
||||
TOKEN_LIFE=2h
|
||||
REFRESH_TOKEN_LIFE=14d
|
||||
AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNV
|
||||
@@ -4,10 +4,10 @@ PDB=suerteFreePlanet@1A
|
||||
SEND_EMAIL=1
|
||||
PORT=3001
|
||||
ENABLE_PUSHNOTIFICATION=1
|
||||
DIRECTORY_SERVER=freeplanet_serverside
|
||||
SERVERDIR_WEBSITE=test.freeplanet_server
|
||||
DIRECTORY_SERVER=/var/www/testriso.freeplanet_serverside
|
||||
SERVERDIR_WEBSITE=testriso.piuchebuono.app
|
||||
PORT_APP1="0"
|
||||
DOMAIN=mongodb://localhost:27018/
|
||||
DOMAIN=mongodb://localhost:32002/
|
||||
AUTH_MONGODB=1
|
||||
MONGODB_USER=admin
|
||||
MONGODB_PWD=mypwadmin@1A
|
||||
@@ -26,4 +26,6 @@ PATH_SSL_CHAIN_PEM=chain.pem
|
||||
PROD=0
|
||||
PROJECT_DESCR_MAIN='__PROJECTS'
|
||||
SECRK=iUUb38v23jjDFaosWj92axkBOXCQ
|
||||
TOKEN_LIFE=2h
|
||||
REFRESH_TOKEN_LIFE=14d
|
||||
AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNV
|
||||
32
.env.test2
Normal file
32
.env.test2
Normal file
@@ -0,0 +1,32 @@
|
||||
DATABASE=test_FreePlanet
|
||||
UDB=paofreeplanet
|
||||
PDB=suerteFreePlanet@1A
|
||||
SEND_EMAIL=1
|
||||
PORT=3001
|
||||
ENABLE_PUSHNOTIFICATION=1
|
||||
DIRECTORY_SERVER=freeplanet_serverside
|
||||
SERVERDIR_WEBSITE=test2.freeplanet_server
|
||||
URLBASE_APP1=https://test2.riso.app
|
||||
PORT_APP1="0"
|
||||
DOMAIN=mongodb://localhost:27018/
|
||||
AUTH_MONGODB=1
|
||||
MONGODB_USER=admin
|
||||
MONGODB_PWD=mypwadmin@1A
|
||||
SIGNCODE=SU2134hncaskjdbo231oihJSDNHEI$1@AB
|
||||
DEBUG=0
|
||||
LOCALE=0
|
||||
DELAY_SENDEMAIL=1000
|
||||
VAPI_KEY_SUBJECT="mailto:paolo@freeplanet.app"
|
||||
PUBLIC_VAPI_KEY="BGXRf1TgcqocqD6J7qnRgCG7AvM2lxAoW7peb7UEzB4SxBb6DxGRdJ0UvD9ewnrB9KrSrh0-aDCODXBm7sZ1DDs"
|
||||
PRIVATE_VAPI_KEY="St9UMzcS76Q9yKG6RInAuYydYjFRliqwHTJY3A5wjO0"
|
||||
GCM_API_KEY="AIzaSyD7w1jztfVV05mX1iyxoI-r1pZWxuxdUK8"
|
||||
PATH_CERT_KEY=key.pem
|
||||
PATH_SERVER_CRT=cert.pem
|
||||
PATH_SSL_ROOT_PEM=root.pem
|
||||
PATH_SSL_CHAIN_PEM=chain.pem
|
||||
PROD=0
|
||||
PROJECT_DESCR_MAIN='__PROJECTS'
|
||||
SECRK=iUUb38v23jjDFaosWj92axkBOXCQ
|
||||
TOKEN_LIFE=2h
|
||||
REFRESH_TOKEN_LIFE=14d
|
||||
AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNV
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -29,3 +29,5 @@ emails/.DS_Store
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
logtrans.txt
|
||||
yarn.lock
|
||||
logtrans.txt
|
||||
|
||||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -2,6 +2,7 @@
|
||||
"search.useIgnoreFiles": false,
|
||||
"files.watcherExclude": {
|
||||
"**/.git/objects/**": true,
|
||||
"**/node_modules/**": true
|
||||
"**/node_modules/**": true,
|
||||
"**/src/server/router/upload/**": true
|
||||
},
|
||||
}
|
||||
4
check_permessi_server_test2.sh
Executable file
4
check_permessi_server_test2.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
ssh -p 8855 suryapaolo@servereng "ls -ld /var/www/test2.freeplanet_server"
|
||||
|
||||
3592316
comuni_italia.geojson
Normal file
3592316
comuni_italia.geojson
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,15 +2,20 @@
|
||||
|
||||
source ./.env.test.risosrv
|
||||
|
||||
echo "Sincronizzazione in corso..."
|
||||
rsync -avz -e 'ssh -p 5522' css root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' docs root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' emails root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' images root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' plugins root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' sass root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' src root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' .env.test.risosrv root@risosrv:/var/www/$SERVERDIR_WEBSITE/.env.test
|
||||
rsync -avz -e 'ssh -p 5522' package.json root@risosrv:/var/www/$SERVERDIR_WEBSITE/package.json
|
||||
echo "Sincronizzazione in corso... $DIRECTORY_SERVER"
|
||||
rsync -avz -e 'scp -p 8822' .env.test.risosrv pcbuser@pcb:$DIRECTORY_SERVER/.env.test
|
||||
rsync -avz -e 'ssh -p 8822' ecosystem.config.testriso.js pcbuser@pcb:$DIRECTORY_SERVER/ecosystem.config.js
|
||||
rsync -avz -e 'ssh -p 8822' css pcbuser@pcb:$DIRECTORY_SERVER/
|
||||
rsync -avz -e 'ssh -p 8822' docs pcbuser@pcb:$DIRECTORY_SERVER/
|
||||
rsync -avz -e 'ssh -p 8822' emails pcbuser@pcb:$DIRECTORY_SERVER/
|
||||
rsync -avz -e 'ssh -p 8822' images pcbuser@pcb:$DIRECTORY_SERVER/
|
||||
rsync -avz -e 'ssh -p 8822' plugins pcbuser@pcb:$DIRECTORY_SERVER/
|
||||
rsync -avz -e 'ssh -p 8822' sass pcbuser@pcb:$DIRECTORY_SERVER/
|
||||
rsync -avz -e 'ssh -p 8822' src --exclude 'server/router/upload' pcbuser@pcb:$DIRECTORY_SERVER/
|
||||
rsync -avz -e 'ssh -p 8822' ecosystem.config.testriso.js pcbuser@pcb:$DIRECTORY_SERVER/ecosystem.config.js
|
||||
rsync -avz -e 'ssh -p 8822' package.json pcbuser@pcb:$DIRECTORY_SERVER/package.json
|
||||
|
||||
echo "Sincronizzazione TERMINATA! - SERVER TEST!"
|
||||
echo "**************************"
|
||||
echo "Sincronizzazione TERMINATA! - TESTSRISO.FREEPLANET_SERVER!"
|
||||
echo "https://testriso.piuchebuono.app"
|
||||
echo "**************************"
|
||||
|
||||
34
deploynodejs_on_test2.sh
Executable file
34
deploynodejs_on_test2.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
source ./.env.test2
|
||||
|
||||
echo "Directory attuale: $PWD"
|
||||
|
||||
msg="*** SERVER DI TEST2 **** SEI SICURO DI INVIARE GLI AGGIORNAMENTI SERVERSIDE (NODE JS) - SUL SERVER $SERVERDIR_WEBSITE (Y/N) ? "
|
||||
|
||||
if [ "$1" = "" ]; then
|
||||
read -p "$msg" risposta
|
||||
else
|
||||
echo $msg
|
||||
risposta=$1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [[ $risposta == "Y" || $risposta == "y" ]]; then
|
||||
|
||||
echo "Sincronizzazione in corso... $SERVERDIR_WEBSITE"
|
||||
echo "Copiando .env.test2..."
|
||||
rsync -avz -e 'ssh -p 8855' .env.test2 suryapaolo@servereng:/var/www/$SERVERDIR_WEBSITE/.env.test
|
||||
echo "Sincronizzazione in corso... src"
|
||||
rsync -avz -e 'ssh -p 8855' -a --exclude 'src/router/upload' src suryapaolo@servereng:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8855' package.json suryapaolo@servereng:/var/www/$SERVERDIR_WEBSITE/package.json
|
||||
rsync -avz -e 'ssh -p 8855' css suryapaolo@servereng:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8855' docs suryapaolo@servereng:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8855' emails suryapaolo@servereng:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8855' images suryapaolo@servereng:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8855' plugins suryapaolo@servereng:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8855' sass suryapaolo@servereng:/var/www/$SERVERDIR_WEBSITE/
|
||||
|
||||
echo "Sincronizzazione TERMINATA! - SERVER TEST2!"
|
||||
fi
|
||||
22
ecosystem.config.testriso.js
Executable file
22
ecosystem.config.testriso.js
Executable file
@@ -0,0 +1,22 @@
|
||||
module.exports = {
|
||||
apps : [
|
||||
{
|
||||
name: "TESTRISO2 FreePlanetServerSide",
|
||||
script: "./src/server/server.js",
|
||||
ignore_watch : ["node_modules"],
|
||||
interpreter: "/root/.nvm/versions/node/v16.19.0/bin/node",
|
||||
watch: false,
|
||||
//autorestart: true,
|
||||
instances: 1,
|
||||
env_test: {
|
||||
"PORT": 3001,
|
||||
"NODE_ENV": "test",
|
||||
},
|
||||
log_file: "logs/combined.outerr.log",
|
||||
error_file: "logs/err.log",
|
||||
out_file: "logs/out.log",
|
||||
merge_logs: true,
|
||||
log_date_format: "YYYY-MM-DD HH:mm:ss.SSSS Z"
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -67,7 +67,7 @@ html
|
||||
- var img = rec.order.product.productInfo.img
|
||||
- var price = rec.order.price
|
||||
- var after_price = rec.order.after_price
|
||||
- var TotalPriceProduct = rec.order.TotalPriceProduct
|
||||
- var TotalPriceProduct = rec.order.TotalPriceProductstr
|
||||
if (rec.order.gasordine)
|
||||
- var gasordine = rec.order.gasordine.name
|
||||
else
|
||||
@@ -75,6 +75,12 @@ html
|
||||
|
||||
- var qty = rec.order.quantity
|
||||
- var qtypreordered = rec.order.quantitypreordered
|
||||
if (rec.order.product.productInfo.sfuso && rec.order.product.productInfo.weight)
|
||||
- qtypreordered = qtypreordered * rec.order.product.productInfo.weight
|
||||
else if (rec.order.product.productInfo.weight)
|
||||
- qtypreordered = qtypreordered + ' x ' + rec.order.product.productInfo.weight
|
||||
|
||||
- var unit = rec.order.product.productInfo.unitstr
|
||||
- index = index + 1
|
||||
|
||||
table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
@@ -86,7 +92,7 @@ html
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
tr
|
||||
td
|
||||
img(src=baseimg + img, alt="", width="150" height="150")
|
||||
img(src=baseimg + img, alt="", width="150")
|
||||
td(class="column", valign="top")
|
||||
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
@@ -103,10 +109,10 @@ html
|
||||
p Prezzo: #{price} € #{after_price}
|
||||
if (qty > 0)
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità: #{qty}
|
||||
p Quantità: #{qty} #{unit}
|
||||
if (qtypreordered > 0)
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità Prenotata: #{qtypreordered}
|
||||
p Quantità Prenotata: #{qtypreordered} #{unit}
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Totale: #{TotalPriceProduct} €
|
||||
|
||||
@@ -1,168 +0,0 @@
|
||||
doctype html
|
||||
html
|
||||
head
|
||||
title Ordine n. #{ordernumber} Consegnato
|
||||
|
||||
//- import css/scss stylesheets
|
||||
//- these file names will be replace by gulp with proper css file paths
|
||||
link(rel="stylesheet", href="../sass/basic.scss")
|
||||
link(rel="stylesheet", href="../sass/one/styles.scss")
|
||||
|
||||
//- embdedded css allowed, but not sass
|
||||
style.
|
||||
.red {
|
||||
background-color: #E84C50;
|
||||
}
|
||||
|
||||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
body(yahoofix, style="background: #ffffff")
|
||||
- var baseimg = baseurl + '/';
|
||||
span(id='body_style', style='display:block')
|
||||
table(cellpadding="10", cellspacing="0", width="600", align="center")
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
|
||||
if (orders.items && orders.items.length > 0)
|
||||
- var mystorehouse = orders.items[0].order.storehouse
|
||||
else
|
||||
- var mystorehouse = null
|
||||
|
||||
tr
|
||||
td(class="emailContainer", valign="top")
|
||||
|
||||
- var mioheader = mystorehouse.email_html_header
|
||||
if (mioheader)
|
||||
p!= mioheader
|
||||
else
|
||||
p Ciao #{name},
|
||||
|
||||
p L'ordine n. #{ordernumber} è stato Consegnato correttamente !
|
||||
|
||||
if (orders.items[0].order.quantitypreordered > 0)
|
||||
- var miomakeorder = mystorehouse.email_html_GAS_order_consegnato
|
||||
else
|
||||
- var miomakeorder = mystorehouse.email_html_order_consegnato
|
||||
|
||||
if (miomakeorder)
|
||||
p!= miomakeorder
|
||||
|
||||
- var totalPrice = orders.totalPrice
|
||||
- var note = orders.note
|
||||
- var index = 0
|
||||
|
||||
each rec in orders.items
|
||||
- var descr = rec.order.product.productInfo.name
|
||||
- var img = rec.order.product.productInfo.img
|
||||
- var price = rec.order.product.price
|
||||
- var after_price = rec.order.product.after_price
|
||||
if (rec.order.gasordine)
|
||||
- var gasordine = rec.order.gasordine.name
|
||||
else
|
||||
- var gasordine = ''
|
||||
- var qty = rec.order.product.quantity
|
||||
- var qtypreordered = rec.order.quantitypreordered
|
||||
- var TotalPriceProduct = rec.order.TotalPriceProduct
|
||||
- index = index + 1
|
||||
|
||||
table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
tr
|
||||
td(class="column", valign="center" width="40")
|
||||
p.boldhigh #{index}.
|
||||
|
||||
td(class="column sectionArticleImage", valign="top" width="150")
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
tr
|
||||
td
|
||||
img(src=baseimg + img, alt="", width="150" height="150")
|
||||
td(class="column", valign="top")
|
||||
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
if (qtypreordered > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Gas Ordine: #{gasordine}
|
||||
p
|
||||
tr
|
||||
td(class="sectionContentTitle boldhigh", valign="top")
|
||||
p #{descr}
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Prezzo: #{price} € #{after_price}
|
||||
if (qty > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità: #{qty}
|
||||
if (qtypreordered > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità Prenotata: #{qtypreordered}
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Totale: #{TotalPriceProduct} €
|
||||
|
||||
if (note)
|
||||
p Note Aggiuntive: #{note}
|
||||
|
||||
p.sectionContentTitle.boldhigh.sectionTotal Totale Ordine: #{totalPrice} €
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
|
||||
tr
|
||||
td
|
||||
- var miofooter = mystorehouse.email_html_footer
|
||||
if (miofooter)
|
||||
p!= miofooter
|
||||
else
|
||||
p Grazie Mille
|
||||
|
||||
table.footer(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
tr
|
||||
td.firma
|
||||
p!= dataemail.firma
|
||||
|
||||
tr
|
||||
td.disclaimer
|
||||
p!= dataemail.disclaimer_out
|
||||
|
||||
tr
|
||||
td.bottom
|
||||
p!= dataemail.disc_bottom_out
|
||||
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
|
||||
style(type="text/css").
|
||||
html, body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
|
||||
.divbtn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.btn-lg {
|
||||
padding: 5px;
|
||||
margin: 5px;
|
||||
font-size: 26px;
|
||||
cursor: pointer;
|
||||
color: white;
|
||||
background: #027be3 !important;
|
||||
border-radius: 28px;
|
||||
|
||||
}
|
||||
@@ -71,7 +71,13 @@ html
|
||||
- var gasordine = ''
|
||||
- var qty = rec.order.product.quantity
|
||||
- var qtypreordered = rec.order.quantitypreordered
|
||||
- var TotalPriceProduct = rec.order.TotalPriceProduct
|
||||
if (rec.order.product.productInfo.sfuso && rec.order.product.productInfo.weight)
|
||||
- qtypreordered = qtypreordered * rec.order.product.productInfo.weight
|
||||
else if (rec.order.product.productInfo.weight)
|
||||
- qtypreordered = qtypreordered + ' x ' + rec.order.product.productInfo.weight
|
||||
|
||||
- var unit = rec.order.product.productInfo.unitstr
|
||||
- var TotalPriceProduct = rec.order.TotalPriceProductstr
|
||||
- index = index + 1
|
||||
|
||||
table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
@@ -83,7 +89,7 @@ html
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
tr
|
||||
td
|
||||
img(src=baseimg + img, alt="", width="150" height="150")
|
||||
img(src=baseimg + img, alt="", width="150")
|
||||
td(class="column", valign="top")
|
||||
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
@@ -101,11 +107,11 @@ html
|
||||
if (qty > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità: #{qty}
|
||||
p Quantità: #{qty} #{unit}
|
||||
if (qtypreordered > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità Prenotata: #{qtypreordered}
|
||||
p Quantità Prenotata: #{qtypreordered} #{unit}
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Totale: #{TotalPriceProduct} €
|
||||
|
||||
@@ -70,7 +70,13 @@ html
|
||||
- var gasordine = ''
|
||||
- var qty = rec.order.product.quantity
|
||||
- var qtypreordered = rec.order.quantitypreordered
|
||||
- var TotalPriceProduct = rec.order.TotalPriceProduct
|
||||
if (rec.order.product.productInfo.sfuso && rec.order.product.productInfo.weight)
|
||||
- qtypreordered = qtypreordered * rec.order.product.productInfo.weight
|
||||
else if (rec.order.product.productInfo.weight)
|
||||
- qtypreordered = qtypreordered + ' x ' + rec.order.product.productInfo.weight
|
||||
|
||||
- var unit = rec.order.product.productInfo.unitstr
|
||||
- var TotalPriceProduct = rec.order.TotalPriceProductstr
|
||||
- index = index + 1
|
||||
|
||||
table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
@@ -82,7 +88,7 @@ html
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
tr
|
||||
td
|
||||
img(src=baseimg + img, alt="", width="150" height="150")
|
||||
img(src=baseimg + img, alt="", width="150")
|
||||
td(class="column", valign="top")
|
||||
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
@@ -100,11 +106,11 @@ html
|
||||
if (qty > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità: #{qty}
|
||||
p Quantità: #{qty} #{unit}
|
||||
if (qtypreordered > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità Prenotata: #{qtypreordered}
|
||||
p Quantità Prenotata: #{qtypreordered} #{unit}
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Totale: #{TotalPriceProduct} €
|
||||
|
||||
32
filelog.txt
32
filelog.txt
@@ -134,3 +134,35 @@ come funziona:
|
||||
- per finire: cliccare su "procedi all'ordine" e confermate.
|
||||
|
||||
Dom 21/01 ORE 19:00: USER [paoloar77]: 👉🏻 indietro
|
||||
|
||||
Mar 23/04 ORE 22:31: USER [paoloar77]: ciao
|
||||
|
||||
Mer 24/04 ORE 20:45: USER [paoloar77]: invia a paolo
|
||||
|
||||
Mer 24/04 ORE 20:45: USER [paoloar77]: 📨 invia a paolo
|
||||
|
||||
Mer 24/04 ORE 20:58: USER [paoloar77]: grass e prova italic
|
||||
|
||||
Mer 24/04 ORE 21:19: USER [paoloar77]: 👍 si
|
||||
|
||||
Mer 24/04 ORE 22:02: USER [paoloar77]: ✅ la regolarizzazione può avv
|
||||
|
||||
Mer 24/04 ORE 22:15: USER [paoloar77]: ❗️importante❗️
|
||||
|
||||
💚🍚 cari membri dei circuiti ris,
|
||||
quando siete entrati nel vostro circuito territoriale, avete dichiarato di avere letto e approvato il regolamento di funzionamento dei circuiti ris.
|
||||
|
||||
📖 leggi qui il regolamento (https://riso.app/regolamento)
|
||||
|
||||
il gruppo dei facilitatori territoriali di riso ha individuato un punto che necessita di chiarimenti, per rendere più esplicito un meccanismo già presente nel testo stesso. propone dunque di aggiungere una nota esplicativa (vedi asterisco *) alla seguente frase del regolamento (indicata in corsivo):
|
||||
|
||||
➡️ "… ciascun detentore di un saldo negativo concorda che la sua esposizione funge da garanzia della quantità di ris equivalenti circolanti nel circuito e che può essere chiamato a regolarizzare con equivalente pagamento in euro * , entro un lasso di tempo ragionevolmente adeguato, nel caso in cui: la comunità, in accordo con il gruppo tecnico, deliberi il rientro di alcune posizioni con decisione motivata; l’utente decida di uscire per motivi personali; il circuito chiuda, per decisione deliberata o per motivi di forza maggiore.”
|
||||
|
||||
✅ * la regolarizzazione può avvenire con equivalente valore in beni e servizi, oppure, in ultima istanza, con pagamento in euro.
|
||||
|
||||
📣 invitiamo tutti a prendere visione della proposta, e ad esprimere eventuali osservazioni nel gruppo territoriale, oppure come commento a questo stesso post, pubblicato sul canale progetto riso, entro il giorno 5 maggio
|
||||
|
||||
https://t.me/riso_canale/739
|
||||
|
||||
in attesa di riscontri, salutiamo! 🍚💚
|
||||
il gruppo dei facilitatori territoriali riso
|
||||
|
||||
809
logevents.txt
809
logevents.txt
@@ -28,4 +28,811 @@ Sab 04/11 ORE 15:17: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
Sab 02/12 ORE 14:15: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||
Dom 21/01 ORE 19:00: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
👉🏻 indietro
|
||||
👉🏻 indietro
|
||||
Gio 28/03 ORE 18:10: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
✅ prova123 è stato Abilitato correttamente (da paoloar77)!
|
||||
Mar 23/04 ORE 22:33: APPARTIENE_CIRCUITO_RIS:
|
||||
contasolo
|
||||
Mar 23/04 ORE 22:33: 0 ✉️ Messaggi da Inviare
|
||||
Mar 23/04 ORE 22:33: APPARTIENE_CIRCUITO_RIS:
|
||||
contasolo
|
||||
Mar 23/04 ORE 22:38: APPARTIENE_CIRCUITO_RIS:
|
||||
contasolo
|
||||
Mar 23/04 ORE 22:41: APPARTIENE_CIRCUITO_RIS:
|
||||
contasolo
|
||||
Mar 23/04 ORE 22:41: APPARTIENE_CIRCUITO_RIS:
|
||||
contasolo
|
||||
Mar 23/04 ORE 22:42: APPARTIENE_CIRCUITO_RIS:
|
||||
contasolo
|
||||
Mar 23/04 ORE 22:42: 703 ✉️ Messaggi da Inviare
|
||||
Mar 23/04 ORE 22:44: APPARTIENE_CIRCUITO_RIS:
|
||||
nomecognome
|
||||
Mar 23/04 ORE 22:44: Paolo Surya(paoloar77)
|
||||
Sergio Mazzanti(sergiomazzanti)
|
||||
Alberto Sensoli(Alberto)
|
||||
Fabri (FabriNunzia)
|
||||
Sabrina Siri(SabrinaCucovaz)
|
||||
Lorenzo Essente(LorenzoVT)
|
||||
Gianni Recca(Gianni)
|
||||
Giovanni (Surfman)
|
||||
Lucia (Lucente)
|
||||
(Angerita)
|
||||
(giancarloscarva)
|
||||
Fabrizio Erani(fabris64)
|
||||
(Dena1703)
|
||||
(Aja)
|
||||
Max Feraco(Joymax68)
|
||||
(marcela)
|
||||
Vittorio Falegname(Falegname.Vittorio)
|
||||
(Fanny22)
|
||||
(ostecippa)
|
||||
Maria Pecoraro(pecorablu)
|
||||
Talia Felin(Eaglefly)
|
||||
Barby (Bbarbi)
|
||||
Vincenzo Demaio(vincidemi)
|
||||
Loretta (lunaloretta)
|
||||
Isabella (SognoAltea)
|
||||
Tempo di Vivere(tempodivivere.it)
|
||||
(Agotrip)
|
||||
Camillo Granchelli(Kami66)
|
||||
Antonio Graziano(Tonygraziano)
|
||||
(Ambessa)
|
||||
MarinaA (MarinaA)
|
||||
Carmine Cozzolino(Cicciomu)
|
||||
Angela (Angelare)
|
||||
Valentina Portelli(Nonnapapera)
|
||||
Andrea Bozzetto(abozzetto)
|
||||
BCMassimo (BCMassimo)
|
||||
Denis Vignocchi(Denis1970)
|
||||
(Ladycocca)
|
||||
Erica Brunello(Ericabru)
|
||||
Marina S.(Marina22)
|
||||
(Serena.Tre.Stelle)
|
||||
(antonioscioscia)
|
||||
Irene (IreneVit)
|
||||
Shakuntala Tiziana Riva(Shakuntala)
|
||||
(Rosablu)
|
||||
silvia (silvia7)
|
||||
(Rosanna)
|
||||
(Lamary)
|
||||
Luca Sartini(Sarto1978)
|
||||
(Fabiozero)
|
||||
(stefanci87)
|
||||
Raffaella Bonino(Spirale)
|
||||
(Paola_Cr)
|
||||
Elena Turilli(ballerina2909)
|
||||
Luisa Recchia(LuisaRecchia)
|
||||
Enrico Cantamessa(Enrico_Cantamessa)
|
||||
(MariaMasterReiki)
|
||||
Bianca Prugna(BiancaPrugna)
|
||||
Silvia Ruggieri(Liberalux)
|
||||
Erica (erica57)
|
||||
laura nocera(laura.nocera)
|
||||
Federico (eremita222)
|
||||
(Versolaluce)
|
||||
Alejandro (alecanque)
|
||||
(Mauro_EL)
|
||||
Gaetano (GaetanoSant)
|
||||
Natalia (Natalia)
|
||||
Stefania (StefaniaSantag)
|
||||
Giuliana Car(Guglielmina)
|
||||
Georgia Matteini Palmerini(GeorgiaMP)
|
||||
(saraprinc)
|
||||
(iosonoio58)
|
||||
(Ennepi)
|
||||
Silvia lorenza (Silvia88)
|
||||
(Messaggero6)
|
||||
(Carlos)
|
||||
Federico Palla(FedePallaLUMEN)
|
||||
Laura Salvetti(Laura5)
|
||||
Ciro (Riccardo)
|
||||
Sabrina (Sabrinap)
|
||||
Samuele Mastelloni(SamuelMast)
|
||||
Francesca Puppo(Open.curious)
|
||||
Simona Teresa Maria(SimonaPt)
|
||||
(Mila-Roberto)
|
||||
Antonella Scrittrice ecologia quantica(Antoquantica)
|
||||
Samuele Canestri(Evoluzionari)
|
||||
Arcangelo Casavola(arca33)
|
||||
Roberta Annecchino(Roberlina)
|
||||
Antonio Daniele(Antonio_N)
|
||||
(AlessioColombo)
|
||||
(Varia9)
|
||||
(MagiaMirtilla)
|
||||
Emilie Vandecandelaere(Emilie)
|
||||
(Natasha)
|
||||
(marino222)
|
||||
(Moscadri)
|
||||
Rosanna Fantucci(Roxanne)
|
||||
(Andrea_Tiziana)
|
||||
(Ritacam)
|
||||
Michela (michelaC)
|
||||
(DomSap)
|
||||
(L4il4-F)
|
||||
(Luisaaa)
|
||||
(Fly89it)
|
||||
(Annarosa)
|
||||
Nino (Ninosella)
|
||||
(Rosedane)
|
||||
(Marafox)
|
||||
RitaLuisa (RitaLuisa)
|
||||
(Frimel)
|
||||
Sergio (Precisin)
|
||||
(torneremoaballare)
|
||||
(pier_luigi_c)
|
||||
Stella (stella)
|
||||
Silvia (LaBrighid)
|
||||
(marcelloaloe)
|
||||
(Angisan21)
|
||||
Elena (RosEle70)
|
||||
(tilliutaio)
|
||||
Tera (tera0861)
|
||||
(gradar83)
|
||||
Alberto Soverchia(ThinkererSan)
|
||||
Viviana (Viviamarespira)
|
||||
Fulvio Faro(Fulvio_F)
|
||||
Valeria Pastorino(Valeriapastorino)
|
||||
(Robynora)
|
||||
(FrancyVeg72)
|
||||
inTuiziana (TiziaKaja)
|
||||
(rit_ale)
|
||||
(Cyberobe)
|
||||
(MaxCerba)
|
||||
(zelda23)
|
||||
Flavia (flaviaoak)
|
||||
Mario Romeo(zacc50)
|
||||
Samuela (Fioridisole)
|
||||
(cristianodisotto)
|
||||
Zeo (ZeoPleiadi)
|
||||
Ina (lafenjce)
|
||||
(Almaelena)
|
||||
(Robertocnm)
|
||||
(Grazia_22)
|
||||
(Ebiker2000)
|
||||
(JulienQ)
|
||||
Stefania (Metanoeite1973)
|
||||
(texdb70)
|
||||
(LauraRosaMarina)
|
||||
(Francyjones)
|
||||
(raffaele_costi)
|
||||
(RobertoCutillo)
|
||||
(Nicmestre)
|
||||
(Ellis92)
|
||||
(RobertoDCC)
|
||||
(armoniaserena)
|
||||
(Tris2_0)
|
||||
Davide (Metonimia)
|
||||
Elena Esposito(ElenaEspx)
|
||||
Roberto Nicolè(Bobobasss)
|
||||
Maria Rosa Favaro(Cheggioya)
|
||||
(Atmapriya64)
|
||||
Manuela (calendola)
|
||||
(santonimarco)
|
||||
Andrea Roncolini(barbaronx)
|
||||
(Elisagranello)
|
||||
Daniela (dania63)
|
||||
(EtruscanStateless)
|
||||
(Barbara_Nrd)
|
||||
(ClaudiaMariaRosaria)
|
||||
Vivien Russo(vivienru)
|
||||
(Borgomaestro)
|
||||
(letiziaferro)
|
||||
Donatella Parrini(siena1)
|
||||
Patripadova (patripadova)
|
||||
(pomps61)
|
||||
(COFEINA)
|
||||
Monica (Monicainviaggio)
|
||||
(Marititti)
|
||||
(IreneRocca37)
|
||||
(JwalaRegina)
|
||||
(An_el_a)
|
||||
Antonio Ciurlia(joliker)
|
||||
virna (donnacustodedelfuoco)
|
||||
Alessandra (ale_21giugno)
|
||||
(Sante2015)
|
||||
(Alestrale)
|
||||
Michele Padula(Michele_pm)
|
||||
(ritarevathy)
|
||||
Barbara Bonora(BarbaraBonora)
|
||||
Claudio Galassi(Jalsha2)
|
||||
(sganapigi)
|
||||
(gassuper3)
|
||||
(Cibuk176)
|
||||
(Naliber)
|
||||
Cinzia (cavaioni)
|
||||
(Riflessivo33)
|
||||
Erica Rosselli(Erica_Grace)
|
||||
(Nun988)
|
||||
(SimonettaSecchi)
|
||||
(mauribeni)
|
||||
(Ambrig)
|
||||
Fritz Baehler(Fritz_Baehler)
|
||||
(AndreaLemon)
|
||||
(simonetta63)
|
||||
(Laura_C61)
|
||||
Alicia Atzori(aliciaedu)
|
||||
Fede Faith (FedeFaith)
|
||||
(ElisV73)
|
||||
(VentoDiCambiamento)
|
||||
Concetta (Concyrau)
|
||||
Claudio (KenHunter)
|
||||
(danielaw63)
|
||||
(Antonio_Ferrandes)
|
||||
Giacomo (Unicorno_Giacomo)
|
||||
Federica Rizzi(FedericaFezz)
|
||||
JESSICA SHANTA DEVI (JessicaShantaDevi)
|
||||
(Alessia17love)
|
||||
Valeria (Rondinell)
|
||||
(Sidereo1)
|
||||
(Maia_73)
|
||||
Michele (M.Cicl8)
|
||||
Giusi Uc (ARGOGU)
|
||||
Giuseppe (iceborg500)
|
||||
Adriano Lai(AL72MB)
|
||||
Bodhitara (primotintorosso)
|
||||
Daniela Enrico(dan7se)
|
||||
Carmela (carvas5)
|
||||
Ines (Ineswild)
|
||||
Mariana (Mepar68)
|
||||
Fulvio Maresca(Fulvi00)
|
||||
Barbara M(Mnbo_7198)
|
||||
(Valentinabiodanzamindfulness)
|
||||
Luca Moretti(lucamop)
|
||||
Thor (ThorHammering)
|
||||
Laura Sc(LadyLauraSC)
|
||||
(AuryEdy)
|
||||
Tiziana Rimondi(pioggia8)
|
||||
Lara (trotttola)
|
||||
Alessandra Scotti(SulleAliDelCambiamento)
|
||||
Barbarastefania Ruta(matucnv)
|
||||
Stefano (step1608)
|
||||
(avvdona)
|
||||
Fabioa (fabioa_a)
|
||||
(MauMac95)
|
||||
(Millyfor)
|
||||
(edda47)
|
||||
Renzo (Renzosan7)
|
||||
Monia Camillini(monia69)
|
||||
(ottofeel)
|
||||
Loretta Rocchi(Blu_ris)
|
||||
Manuela69 (arcobalen8)
|
||||
Elizabeth (Elizabeth884)
|
||||
Silvia M(silvia418)
|
||||
Patrizia Zucchini(reiki1959)
|
||||
Francesco Rosa(franz12090)
|
||||
Susanna L(Susann1na)
|
||||
(Stonelpluriverso)
|
||||
Silvia Tog(silviatog)
|
||||
Loretta Z(Nove_mbre)
|
||||
Manuel Venturi(Manuel84d)
|
||||
Massimo Longati(Tranquillio)
|
||||
Emanuela (mondobiblio)
|
||||
(salute_yoga)
|
||||
Angela M.(Quanyin08)
|
||||
Sokol (LokoSaK)
|
||||
Nicole (NikkiZilli)
|
||||
Alberto Mengoni(Alberto_Mengoni)
|
||||
Jen B(Jenny_B)
|
||||
Laura Latticini(Lauralatt)
|
||||
Davide Mazzavillani(MazzavillaniDavide)
|
||||
Valerio D'alessio(Valerix64)
|
||||
Anna Bellet(Naanbe)
|
||||
Laura (lauraghini)
|
||||
Fabio Panciera(FabioPnc)
|
||||
Antonio (Napoleone2)
|
||||
Pianta (Didonemma)
|
||||
Annarita (TortellinaZen16)
|
||||
Maria Garofalo(marygary71)
|
||||
Girolamo (teacarfu)
|
||||
Erica (ericaalberonido)
|
||||
Eleonora Mora(EleVegan)
|
||||
Ciro Famiglietti(cirofamigliettivegan)
|
||||
Andrea (carpis77)
|
||||
Sandra Zamboni(alessandramondo)
|
||||
Federico (FedeSo72)
|
||||
(Dilu_69)
|
||||
Sonia Boni(Sonia28358)
|
||||
Su Fiu(SusanFiu)
|
||||
(Debbiesole)
|
||||
(Sole_4gatti)
|
||||
Ugo Maccaferri(Cavallo1011)
|
||||
Gabriella (gabriella_bologna)
|
||||
(Natural_68)
|
||||
Daniela De Simone(DanielaDeSimone)
|
||||
Katia (Katia_g83)
|
||||
David Martinī(Davidcasaviva)
|
||||
Milvia (Mil2227)
|
||||
Susi (frida71)
|
||||
Romina Martini(rominamartini)
|
||||
Deborah (ilventoeilbambu)
|
||||
Daniela Rogue5(Rogue571)
|
||||
Federico Paci(spadroneggio)
|
||||
Giusy ❤️ (giusylove)
|
||||
Giovanbattista Romano(Gianni_Romano_Coach)
|
||||
Ferdy (fernandoaloise)
|
||||
Laura Galli(Laurastella8)
|
||||
Leonardo (marconeuno)
|
||||
Arianna (AriannaTurchi)
|
||||
(Teresabmt)
|
||||
Matteo (Gandalf_il_verde)
|
||||
Alberto (AlbertG11)
|
||||
(EnryZord)
|
||||
Genoveffa Chiummo(louis_thelbri)
|
||||
Vanda (Vandanatalina)
|
||||
Dino Stella(Dinostella)
|
||||
Paola (Ubuntu75)
|
||||
Simone (DottorMaxillo)
|
||||
Lina Giardina(linagia)
|
||||
Rosaria (RosariaM23)
|
||||
Maurizio (mauriziola)
|
||||
Zacerchiataf (ZacerchiataF)
|
||||
Tiziana (tiziada)
|
||||
Nino (Cascant17)
|
||||
Tom (Tom21me)
|
||||
Franco Ciccio(Cicciofranco1964)
|
||||
Elena (Lanatama)
|
||||
Rossella (Animalibera62)
|
||||
Caterina (lcaterina)
|
||||
Adelina (Adelinafo)
|
||||
Cat (CatCat969)
|
||||
Lor (Lori_2)
|
||||
Giancarlo (giancalopresti)
|
||||
Maria Angela (masavoca)
|
||||
Francesco Musumeci(francescomusumeci7)
|
||||
Stefania (cucunci)
|
||||
Giusy Iam(giusyfashion)
|
||||
Maria Antonietta (noirginger)
|
||||
Angelo Spitale(AngeloSPIT)
|
||||
Sergio (sergiookarte)
|
||||
Daniele (DanieleSantinoA)
|
||||
Ermete Trismegisto(Ermete)
|
||||
Angela Raffaele(Angela_rfl)
|
||||
Vincenzo Torrisi(V1nce22)
|
||||
Mimmo Aloisio(Mimmutsu)
|
||||
Clelia Acireale (Cleocost)
|
||||
Margherita Fassari(MargheritadiCanalicchioterramore)
|
||||
Orazio (Orazio369)
|
||||
Consuelo (Consuelo_Messina)
|
||||
Daniela (Maemouna)
|
||||
Max Are(Edificium)
|
||||
Sebastiano (Vera1169)
|
||||
Merope (Merope)
|
||||
Giuli (giuliperilla)
|
||||
Valentina Pica(AttivacreaVale)
|
||||
Silvia Grilli(silviagrilli)
|
||||
Giuseppe (Gilgamesh72)
|
||||
(irenect)
|
||||
Alice_zen 🌺 (alice_zen)
|
||||
totò Grilletto(totogrilletto)
|
||||
Emilia (Emilia6613)
|
||||
Lorella (Corivitto)
|
||||
Giusy (Giuppass)
|
||||
Pamela (Q709fok)
|
||||
Salvatore Lo Giudice(Haku_tato)
|
||||
Giuseppina (Giuscrescim)
|
||||
Gaetano (Gaetano)
|
||||
Luigi (IAM09111967)
|
||||
Roberto (RobertoAudio)
|
||||
(Michele_Libero)
|
||||
Monica Sapio(monicasapio)
|
||||
Armando Lembo(harlem8)
|
||||
Simona (SimonaTrinart)
|
||||
Gianpiero (GianpieroC)
|
||||
Maria (MariaCal14)
|
||||
Antonio (antonio338)
|
||||
(RaffaellaBeauty)
|
||||
Antonino Castronovo(AntonAC)
|
||||
Andrea (Ubanjix)
|
||||
Marit (Scineve)
|
||||
Stefania Castagnozzi(Blue_Lagoon_111)
|
||||
lorenzo cambria(lorsindi)
|
||||
Rossella Cazzaniga(canoneinversotappeti)
|
||||
Antonella Ciucci(lantoanto)
|
||||
Stefano Viola(stef1269)
|
||||
Cla (Sesamo)
|
||||
Dario (Liune64)
|
||||
Leonardo (leonardoloscalzo)
|
||||
Giovanni Gorgone(giovannigorgone)
|
||||
Serena Giudici(mammamago)
|
||||
m.irene (irene13angeli)
|
||||
(moretta369)
|
||||
Damiano Lupezza(Damiano)
|
||||
Daniele (SistemaCorrotto)
|
||||
Sara Eligio(sarakey73)
|
||||
Stefilibera (Stefilibera)
|
||||
Francesca (es_pery15)
|
||||
Edel (Passinelsole)
|
||||
Marco (tyrchyus)
|
||||
Silvia (sillabasibilla)
|
||||
Simona Curatolo(Simona_CreaIdeando)
|
||||
(MarySaraJane)
|
||||
Monica (Merylav)
|
||||
Daniela (Jessiremi)
|
||||
Michela (Cive_13)
|
||||
Monique (Quattropeli)
|
||||
Leonardo (ldproma)
|
||||
Lauram (Laura7117)
|
||||
Armando Dolcini(adolcini)
|
||||
Giorgia Rita Zanellato(Giory73)
|
||||
Stefania (Stefyzann)
|
||||
Riccardo (RikyBalboa)
|
||||
Simona Meazzini(SimonAyurveda)
|
||||
Leda (altre_vie)
|
||||
Oreste (Forrest81)
|
||||
Roberta Carluccio(Famcarluccio)
|
||||
Inge369 (Inge369)
|
||||
Marzel M(zecastighetor)
|
||||
(Vetromile1975)
|
||||
Cinzia (Red_Naomi8)
|
||||
(natalina_candelo)
|
||||
Roberta (Ro_by7)
|
||||
Giovanna Moretti(Giom.VT)
|
||||
Cristina Marinelli(criss71)
|
||||
Sabrina (SabrinaStrozzi)
|
||||
Stefano Francesco Piva(Steve31958)
|
||||
Giacomo Bortoluzzi(JackBorto)
|
||||
Ileana Ziani(Ileana63)
|
||||
Marco (Marketto)
|
||||
Raffaella (roverella19)
|
||||
(ptommaso90)
|
||||
Grace (acia75)
|
||||
Giuliana B(GiulianaB88)
|
||||
Mariella (Mariella_Pichi)
|
||||
Marina Fiori(fiorimarina)
|
||||
(AngelaEnzingara)
|
||||
Cucu (Peterin0)
|
||||
(Eledibe)
|
||||
David Fogazza(DavFog)
|
||||
Giulia (julybi)
|
||||
Federica (Federicas04)
|
||||
Spyke Jones(SpykeJones)
|
||||
(ElenaLc)
|
||||
Ines Carlu(ineesee)
|
||||
Vivy x BORGO cohousing (vivy_BORGO_cohousing)
|
||||
(Nocciolo)
|
||||
Stefano (Stefano_93)
|
||||
Emilio Costantino Belmonte(iTecnologici)
|
||||
(ClaudProv)
|
||||
(CarFlora)
|
||||
Angelo (cavallo62)
|
||||
Marco (Marlet)
|
||||
Donata Guerci(Dona_1971)
|
||||
(stefanoTS)
|
||||
Lucie (Lu_Ma_03)
|
||||
Lorenza Beltrami(Lorenz_Lo)
|
||||
Claudia Barontini(CB1972)
|
||||
Paola Medeot(Paolamedeot)
|
||||
(LiberaValente)
|
||||
Roberto Sorato(Roby81)
|
||||
Carla (ribeka786)
|
||||
Nunzio (Nunzio1980)
|
||||
Alessandro Cavalli(Alecava496)
|
||||
Daniela Lazzarotto(daniela1511)
|
||||
Silvia Santagata(Silvia121Artist)
|
||||
(Tzilli_0)
|
||||
Alessandra (alessandrapiani)
|
||||
Antonia Bianco(biancainot)
|
||||
Nadia (Speranza10)
|
||||
Mimmo (MimmoUstica)
|
||||
Claudio Panicali(ClaudioDellaCoscienza)
|
||||
Raga (Ragaliliana)
|
||||
Anna D'acunio(annadac61)
|
||||
Ippolito (Ippolito)
|
||||
Sabrina Aguiari(sabracadabrax)
|
||||
Milena (milly4always)
|
||||
Damiano Furlan(FurioShin)
|
||||
Angela Rebeschini(dunia_iride)
|
||||
Fabio (Fabiobrent)
|
||||
Anna (AllaLuce)
|
||||
Chiara (chiara821)
|
||||
(Silvielli)
|
||||
Sandra (Ildega)
|
||||
Marco Campisano(Marcoscimmia)
|
||||
(Maicolnait)
|
||||
Nadia T.(Nadia_348)
|
||||
Alessandro Grasso(tutarancio)
|
||||
Riccardo Menolotto(riccardomenolotto)
|
||||
Luisa (luisageromet)
|
||||
(lollo22k)
|
||||
Fulvio Tango(AirblueFulvio)
|
||||
Mattia Bondi(MattiaBondi)
|
||||
Enza Restuccia(Vinrest22)
|
||||
(visvital)
|
||||
Piero Mazza(piterpm)
|
||||
Valentina Benedetti(ValeCipcip)
|
||||
Angelo Benedetto (Hamayl)
|
||||
Laura (PSailormoon)
|
||||
Gianluca Pavan(loziodm)
|
||||
Stefania Meda(Stefanya66)
|
||||
(LiberoEnri)
|
||||
Patrizia Chiara (TempoYoga)
|
||||
Miro (shining)
|
||||
Umberto (Umberto)
|
||||
Cinzia Cassandro(dollybonbon)
|
||||
Luciana (travaluci)
|
||||
Giulio Sassetti(giulsass)
|
||||
Valeria Civardi(Vallicivardi57)
|
||||
(Erica80)
|
||||
Lorena (LoBa82)
|
||||
Marco Ronzitti(Marco71CB)
|
||||
Terry (Terry00025)
|
||||
GiuliaAdele (Ilpontediluce)
|
||||
Barbara (Gelsomina25)
|
||||
(Monoinique)
|
||||
Harry Tallarita(HarryTallarita)
|
||||
L’aurariel (parolainterna)
|
||||
Marcos Cé(RaccoglitoriEclettici)
|
||||
(Rosangela)
|
||||
Robi (robertopigazzi)
|
||||
Giovanni (Giovanni_1066)
|
||||
Simona (sichilab)
|
||||
(gianca1210)
|
||||
Gloria (Smalll13)
|
||||
Manuela (Magdaleine76)
|
||||
(Arc_en_ciel_6)
|
||||
Barbara (Stelle74)
|
||||
Jessica BlackMagic(JesBMagic)
|
||||
Claudio Taroppi(CriptoSophia)
|
||||
Frank (Frankkk22F)
|
||||
(Anette)
|
||||
Emanuele (gemanuele)
|
||||
Lara Canevese(LaraCanevese)
|
||||
(Xeniasanvito)
|
||||
Giuseppe (lupobranco)
|
||||
Fabiana (fabiale69)
|
||||
(NickyvanderLaan)
|
||||
Diana (Diana_ddag)
|
||||
(Denna4)
|
||||
Atena (cascinaboccida)
|
||||
(Diegopinna)
|
||||
Paolo 8pax(Paolo8PAX)
|
||||
Gianni (iugola72)
|
||||
Letizia Gozzini(LetiziaFooFigthers64)
|
||||
Giacomo Di Fabio(Giacomo_1979)
|
||||
Franco (francomario)
|
||||
Lisa Franceschini(Lisa83)
|
||||
Carola (Carola)
|
||||
(Fatinaalc)
|
||||
(SuryaArena)
|
||||
Ale (Florealefiore)
|
||||
Alessandra (ale_5679)
|
||||
Sonia (SoniaCri)
|
||||
Federico (frixxx)
|
||||
Anna (biapanna)
|
||||
Mik (MikelaPi)
|
||||
(Giovannifruttadisicilia)
|
||||
Barbara Matteucci(BarbaraMatt)
|
||||
Ariette (ArietteMorano)
|
||||
Roberta Civirani (Robynlorien)
|
||||
Marina (Norminiax)
|
||||
Elisa Carbonetti(Nonnanena)
|
||||
Marinella Galletti(marinella964)
|
||||
Graziana Ungarelli(nonsiemaisoli)
|
||||
Agnese Ferrari(Agny11)
|
||||
Giovanna Simoni(Gio8marzo)
|
||||
Marta (Martasel)
|
||||
Luca Fraulini(FrauliniLuca)
|
||||
Maria Valentina Bresciani(Valesolovale)
|
||||
Onorio (Onorio69)
|
||||
Cristina (tictac1972)
|
||||
Cla (Clayoga77)
|
||||
Massimo Cognome(mcomparin)
|
||||
Marcola (Marcyfi)
|
||||
(BarbaraMiz)
|
||||
(TGuga)
|
||||
MARCO COPPOLA(MarcoTullioAntonio)
|
||||
Alessandra Barresi(Alessandra_Barresi)
|
||||
Paola Tierri(Paola0503)
|
||||
Gianluca Vannini(Cucca60)
|
||||
Lorena Benigna(lorenabenigna)
|
||||
(MF81B)
|
||||
(maema67)
|
||||
Miriam Notarangelo(LisandraFatina)
|
||||
Giulietta Gnutti(Giu_733)
|
||||
(SismaLux)
|
||||
Francesca (francescalivorno)
|
||||
(MarisaConti)
|
||||
Ale Mare(AlesMare)
|
||||
Anna Maria (accoglienzaa)
|
||||
Sebastiano (pielento)
|
||||
Stefano Giordano(Sankari9)
|
||||
Leon (Umanolistico)
|
||||
(Andrea_di_STATO_Calautti)
|
||||
Calliope (Calliopesca)
|
||||
Simona Turiano(simoNaturopata)
|
||||
Paola (alaya562)
|
||||
Andrea Sturniolo(yosoyvoz)
|
||||
(albertinamarinelli)
|
||||
Graziella (mammalella960)
|
||||
(memorelax)
|
||||
Francesca Marinelli(FrancescaM68)
|
||||
Patrizia (PattyChiarissimi)
|
||||
Marco Rastelli(marcorastelli)
|
||||
Gianni Bianco(ireteditore)
|
||||
(ClaudiaCalabria)
|
||||
Filo (i7specchi)
|
||||
(Charms64)
|
||||
(Lore12345670)
|
||||
Letizia 🌞 (Rissho_Ankoku_Ron)
|
||||
(AnnitaSpinelli)
|
||||
Franca Marin(FrancaM33)
|
||||
(Micbo77)
|
||||
(danieleduboin)
|
||||
(IvanoBo81)
|
||||
Patrizia Alvisi(Paciccia65)
|
||||
Stefano Baratti(StefanoB)
|
||||
(Sabrina_Monticelli)
|
||||
Natascia (Natty_Natty71)
|
||||
Riccardo Tonelli(crescerelaluce)
|
||||
(ClaudioFa)
|
||||
Grazia (GraziaGa)
|
||||
Giorgio (giorgio_p75)
|
||||
Massimo Trustee De Vita(Mcgiverbis)
|
||||
Adriana (AfeWellmade)
|
||||
(Ceramichedeby)
|
||||
(Erby66)
|
||||
Elena Trustee Marino(ALLEANZAdelDONO)
|
||||
Luca (Lucavernicolo)
|
||||
(LaraDea)
|
||||
Marie V(massaiarurale)
|
||||
Giuseppe Mercone(Enomerc82)
|
||||
Giovanni Canu(gheo3)
|
||||
Davide (Pippillino)
|
||||
(Kia_10)
|
||||
Leonardo (Leonardo2823)
|
||||
Fabio (Cecefabene)
|
||||
Paolo (PaUD70)
|
||||
(Gnampolo)
|
||||
franz (franz)
|
||||
araceli de la parra(liladivineplay)
|
||||
Mamo Bel(mamo_bel)
|
||||
Rossella (MazzuRoss)
|
||||
(Lellagab)
|
||||
Enzo Fazzino(enzofazzino)
|
||||
(Joska69)
|
||||
Pamela (Pami74Veronza)
|
||||
Iglis (Ziglis)
|
||||
(Mirella64)
|
||||
(carmen_bologna)
|
||||
Emi (EmiEllis)
|
||||
David Lendaro(dlend80)
|
||||
(FeelGM)
|
||||
Daniele Spina(Vincente7)
|
||||
Gloria Camporesi(picipaci)
|
||||
(Bibessa)
|
||||
Ruben Antonio Vladilo(Ruben369)
|
||||
Stefano Succi(Abbastanza_asociale)
|
||||
Andrea (Falko2222)
|
||||
Barbara (bosco2017)
|
||||
(AntonyHopi)
|
||||
(elsamoretto)
|
||||
Michele Ceccarelli(michelececca)
|
||||
Fabiana Nicoletti(Fabiananico)
|
||||
(Canacaya)
|
||||
(marziamoon)
|
||||
Sara (SaraRiflePla)
|
||||
Letizia Bergamini(Laetitia73)
|
||||
Lucia Mistrali(LuciaMistrali)
|
||||
(Rita_Lila)
|
||||
Lidia (bjoyautenticipernatura)
|
||||
Andrea (apasquali)
|
||||
Laura (Lauratabs)
|
||||
Noemi (NoemiJosephine)
|
||||
Ombretta Cecchetti(OmbrettaCecchetti)
|
||||
(MyGrace)
|
||||
Sebastiano Parmegiani(ZSeba)
|
||||
Simona (GiulioLunaLuce)
|
||||
Sara (sarabaraldi23)
|
||||
Mirca Forcellini(donnainevoluzione)
|
||||
(ciccibicci3)
|
||||
(Donpersival)
|
||||
Alessia (CentrOlisticoShanti)
|
||||
Robi G.(robig67)
|
||||
Cristina (cristina_espo)
|
||||
(Buc14)
|
||||
(Paperlella)
|
||||
Sergio Salutati(Sesarinos)
|
||||
Arianna (Tricric)
|
||||
(nikydeva)
|
||||
(SoloMario)
|
||||
Anna (Oona79)
|
||||
Barbara (Barbie)
|
||||
(ElisabettaTraficante)
|
||||
Gabriele Daprai(Gabry75)
|
||||
Massimo Costacurta(ilcosta54)
|
||||
(Katia)
|
||||
(isabellina1)
|
||||
Riccardo (riccaudace)
|
||||
(Gherarda24)
|
||||
Antonio Sorbello(antoniosorbello)
|
||||
Eric Souqi(GAMBERON3)
|
||||
Fabio Ricci(Fabioricci74)
|
||||
Daniela Stranieri(isolachenonce)
|
||||
Roberto (turo951)
|
||||
Laura (NOGIPPI)
|
||||
|
||||
Mer 24/04 ORE 20:44: APPARTIENE_CIRCUITO_RIS:
|
||||
contasolo
|
||||
Mer 24/04 ORE 20:44: 703 ✉️ Messaggi da Inviare
|
||||
Mer 24/04 ORE 20:45: 🤖: Da Sùrya (Paolo) (paoloar77):
|
||||
invia a paolo
|
||||
Mer 24/04 ORE 20:45: 🤖: Da Sùrya (Paolo) (paoloar77):
|
||||
📨 invia a paolo
|
||||
Mer 24/04 ORE 20:46: PAOLO:
|
||||
💚🍚 Cari membri dei Circuiti Ris,
|
||||
quando siete entrati nel vostro circuito territoriale, avete dichiarato di avere letto e approvato il Regolamento di funzionamento dei Circuiti Ris.
|
||||
|
||||
📖 Leggi qui il Regolamento
|
||||
|
||||
Il gruppo dei Facilitatori Territoriali di RISO ha individuato un punto che necessita di chiarimenti, per rendere più esplicito un meccanismo già presente nel testo stesso. Propone dunque di aggiungere una nota esplicativa (vedi asterisco *) alla seguente frase del Regolamento (indicata in corsivo):
|
||||
|
||||
➡️ "… Ciascun detentore di un saldo negativo concorda che la sua esposizione funge da garanzia della quantità di Ris equivalenti circolanti nel circuito e che può essere chiamato a regolarizzare con equivalente pagamento in euro *, entro un lasso di tempo ragionevolmente adeguato, nel caso in cui: la Comunità, in accordo con il Gruppo Tecnico, deliberi il rientro di alcune posizioni con decisione motivata; l’utente decida di uscire per motivi personali; il circuito chiuda, per decisione deliberata o per motivi di forza maggiore.”
|
||||
|
||||
✅ * La regolarizzazione può avvenire con equivalente valore in beni e servizi, oppure, in ultima istanza, con pagamento in euro.
|
||||
|
||||
📣 Invitiamo tutti a prendere visione della proposta, e ad esprimere eventuali osservazioni nel Gruppo Territoriale, oppure come commento a questo stesso post, pubblicato sul canale Progetto RISO, entro il giorno 5 maggio!
|
||||
|
||||
https://t.me/riso_canale/739
|
||||
|
||||
In attesa di riscontri, salutiamo! 🍚💚
|
||||
Il gruppo dei Facilitatori Territoriali RISO
|
||||
Mer 24/04 ORE 20:46: 1 ✉️ Messaggi Inviati !
|
||||
Mer 24/04 ORE 20:48: PAOLO:
|
||||
PROVA GRASSETTO
|
||||
Mer 24/04 ORE 20:48: 1 ✉️ Messaggi Inviati !
|
||||
Mer 24/04 ORE 20:58: 🤖: Da Sùrya (Paolo) (paoloar77):
|
||||
grass e prova italic
|
||||
Mer 24/04 ORE 21:11: PAOLO:
|
||||
grass e prova italic
|
||||
Mer 24/04 ORE 21:11: 1 ✉️ Messaggi Inviati !
|
||||
Mer 24/04 ORE 21:19: PAOLO:
|
||||
grass e prova italic
|
||||
Mer 24/04 ORE 21:19: 1 ✉️ Messaggi Inviati !
|
||||
Mer 24/04 ORE 21:32: PAOLO:
|
||||
❗️IMPORTANTE❗️
|
||||
|
||||
💚🍚 Cari membri dei Circuiti Ris,
|
||||
quando siete entrati nel vostro circuito territoriale, avete dichiarato di avere letto e approvato il Regolamento di funzionamento dei Circuiti Ris.
|
||||
|
||||
📖 Leggi qui il Regolamento
|
||||
|
||||
Il gruppo dei Facilitatori Territoriali di RISO ha individuato un punto che necessita di chiarimenti, per rendere più esplicito un meccanismo già presente nel testo stesso. Propone dunque di aggiungere una nota esplicativa (vedi asterisco *) alla seguente frase del Regolamento (indicata in corsivo):
|
||||
|
||||
➡️ "… Ciascun detentore di un saldo negativo concorda che la sua esposizione funge da garanzia della quantità di Ris equivalenti circolanti nel circuito e che può essere chiamato a regolarizzare con equivalente pagamento in euro *, entro un lasso di tempo ragionevolmente adeguato, nel caso in cui: la Comunità, in accordo con il Gruppo Tecnico, deliberi il rientro di alcune posizioni con decisione motivata; l’utente decida di uscire per motivi personali; il circuito chiuda, per decisione deliberata o per motivi di forza maggiore.”
|
||||
|
||||
✅ * La regolarizzazione può avvenire con equivalente valore in beni e servizi, oppure, in ultima istanza, con pagamento in euro.
|
||||
|
||||
📣 Invitiamo tutti a prendere visione della proposta, e ad esprimere eventuali osservazioni nel Gruppo Territoriale, oppure come commento a questo stesso post, pubblicato sul canale Progetto RISO, entro il giorno 5 maggio!
|
||||
|
||||
https://t.me/riso_canale/739
|
||||
|
||||
In attesa di riscontri, salutiamo! 🍚💚
|
||||
Il gruppo dei Facilitatori Territoriali RISO
|
||||
Mer 24/04 ORE 21:32: 1 ✉️ Messaggi Inviati !
|
||||
Mer 24/04 ORE 21:35: PAOLO:
|
||||
prova
|
||||
Mer 24/04 ORE 21:35: 1 ✉️ Messaggi Inviati !
|
||||
Mer 24/04 ORE 21:58: APPARTIENE_CIRCUITO_RIS:
|
||||
SDADA
|
||||
Mer 24/04 ORE 22:01: APPARTIENE_CIRCUITO_RIS:
|
||||
❗️IMPORTANTE❗️
|
||||
|
||||
💚🍚 Cari membri dei Circuiti Ris,
|
||||
quando siete entrati nel vostro circuito territoriale, avete dichiarato di avere letto e approvato il Regolamento di funzionamento dei Circuiti Ris.
|
||||
|
||||
📖 Leggi qui il Regolamento
|
||||
|
||||
Il gruppo dei Facilitatori Territoriali di RISO ha individuato un punto che necessita di chiarimenti, per rendere più esplicito un meccanismo già presente nel testo stesso. Propone dunque di aggiungere una nota esplicativa (vedi asterisco *) alla seguente frase del Regolamento (indicata in corsivo):
|
||||
|
||||
➡️ "… Ciascun detentore di un saldo negativo concorda che la sua esposizione funge da garanzia della quantità di Ris equivalenti circolanti nel circuito e che può essere chiamato a regolarizzare con equivalente pagamento in euro *, entro un lasso di tempo ragionevolmente adeguato, nel caso in cui: la Comunità, in accordo con il Gruppo Tecnico, deliberi il rientro di alcune posizioni con decisione motivata; l’utente decida di uscire per motivi personali; il circuito chiuda, per decisione deliberata o per motivi di forza maggiore.”
|
||||
|
||||
✅ * La regolarizzazione può avvenire con equivalente valore in beni e servizi, oppure, in ultima istanza, con pagamento in euro.
|
||||
|
||||
📣 Invitiamo tutti a prendere visione della proposta, e ad esprimere eventuali osservazioni nel Gruppo Territoriale, oppure come commento a questo stesso post, pubblicato sul canale Progetto RISO, entro il giorno 5 maggio!
|
||||
|
||||
https://t.me/riso_canale/739
|
||||
|
||||
In attesa di riscontri, salutiamo! 🍚💚
|
||||
Il gruppo dei Facilitatori Territoriali RISO
|
||||
Mer 24/04 ORE 22:02: 🤖: Da Sùrya (Paolo) (paoloar77):
|
||||
✅ la regolarizzazione può avv
|
||||
70
logtrans.txt
70
logtrans.txt
@@ -128,4 +128,72 @@ PaoloRiso: -44.4 €]
|
||||
Dom 07/01 ORE 16:24: [<b>Euro</b>]: Inviate Monete da PaoloRiso a 44.4 € [causale: Pagato Ordine n.101]
|
||||
Saldi:
|
||||
PaoloRiso: -88.8 €]
|
||||
: 88.8 €]
|
||||
: 88.8 €]
|
||||
Ven 16/02 ORE 13:51: [<b>Euro</b>]: Inviate Monete da PaoloRiso a piuchebuono 9.6 € [causale: Pagato Ordine n.169]
|
||||
Saldi:
|
||||
PaoloRiso: -98 €]
|
||||
piuchebuono: 1109.1799999999998 €]
|
||||
Ven 16/02 ORE 13:57: [<b>Euro</b>]: Inviate Monete da Barbara a piuchebuono 15.6 € [causale: Pagato Ordine n.171]
|
||||
Saldi:
|
||||
Barbara: -61.2 €]
|
||||
piuchebuono: 1124.7799999999997 €]
|
||||
Ven 16/02 ORE 14:05: [<b>Euro</b>]: Inviate Monete da Loabati a piuchebuono 6 € [causale: Pagato Ordine n.174]
|
||||
Saldi:
|
||||
Loabati: -24.6 €]
|
||||
piuchebuono: 1130.7799999999997 €]
|
||||
Sab 17/02 ORE 14:04: [<b>Circuito RIS Bologna</b>]: Inviate Monete da paoloar77 a SuryaArena 5 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: 31 RIS]
|
||||
SuryaArena: 5 RIS]
|
||||
Sab 17/02 ORE 14:10: [<b>Circuito RIS Bologna</b>]: Inviate Monete da SuryaArena a paoloar77 4 RIS [causale: Per Paolo]
|
||||
Saldi:
|
||||
SuryaArena: 1 RIS]
|
||||
paoloar77: 35 RIS]
|
||||
Sab 17/02 ORE 14:11: [<b>Circuito RIS Bologna</b>]: Inviate Monete da paoloar77 a SuryaArena 6 RIS [causale: Per Surya]
|
||||
Saldi:
|
||||
paoloar77: 29 RIS]
|
||||
SuryaArena: 7 RIS]
|
||||
Sab 17/02 ORE 14:50: [<b>Circuito RIS Bologna</b>]: Inviate Monete da paoloar77 a SuryaArena 3 RIS [causale: BBBBAAA]
|
||||
Saldi:
|
||||
paoloar77: 26 RIS]
|
||||
SuryaArena: 10 RIS]
|
||||
Sab 17/02 ORE 14:53: [<b>Circuito RIS Bologna</b>]: Inviate Monete da paoloar77 a SuryaArena 4 RIS [causale: GGGG]
|
||||
Saldi:
|
||||
paoloar77: 22 RIS]
|
||||
SuryaArena: 14 RIS]
|
||||
Sab 17/02 ORE 15:03: [<b>Circuito RIS Bologna</b>]: Inviate Monete da paoloar77 a SuryaArena 2 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: 20 RIS]
|
||||
SuryaArena: 16 RIS]
|
||||
Gio 11/04 ORE 16:54: [<b>Euro</b>]: Inviate Monete da paoloar77 a piuchebuono 110 € [causale: Pagato Ordine n.236]
|
||||
Saldi:
|
||||
paoloar77: -246.8 €]
|
||||
piuchebuono: 2181.0999999999985 €]
|
||||
Gio 11/04 ORE 16:55: [<b>Euro</b>]: Inviate Monete da paoloar77 a piuchebuono 110 € [causale: Pagato Ordine n.235]
|
||||
Saldi:
|
||||
paoloar77: -356.8 €]
|
||||
piuchebuono: 2291.0999999999985 €]
|
||||
Gio 11/04 ORE 16:57: [<b>Euro</b>]: Inviate Monete da paoloar77 a piuchebuono 110 € [causale: Pagato Ordine n.234]
|
||||
Saldi:
|
||||
paoloar77: -466.8 €]
|
||||
piuchebuono: 2401.0999999999985 €]
|
||||
Gio 25/04 ORE 11:43: [<b>Circuito RIS Bologna</b>]: Inviate Monete da SuryaArena a paoloar77 1 RIS [causale: ]
|
||||
Saldi:
|
||||
SuryaArena: -1 RIS]
|
||||
paoloar77: 38 RIS]
|
||||
Gio 25/04 ORE 14:37: [<b>Circuito RIS Bologna</b>]: Inviate Monete da paoloar77 a SuryaArena 38 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: 0 RIS]
|
||||
SuryaArena: 37 RIS]
|
||||
Gio 09/05 ORE 17:27: [<b>Circuito RIS Catania</b>]: Inviate Monete da paoloar77 a Giovannifruttadisicilia 1.5 RIS [causale: prova]
|
||||
Saldi:
|
||||
paoloar77: -1.50 RIS]
|
||||
Giovannifruttadisicilia: 1.50 RIS]
|
||||
Mar 28/05 ORE 16:51: [<b>Circuito RIS Italia</b>]: Inviate Monete da ElenaEspx a Giovannifruttadisicilia 14 RIS [causale: Acquisto arance 30genn24 RisoBologna 2]
|
||||
Saldi:
|
||||
ElenaEspx: -32.10 RIS]
|
||||
Giovannifruttadisicilia: 222.50 RIS]
|
||||
Mar 28/05 ORE 16:51: [<b>Circuito RIS Italia</b>]: Inviate Monete da ElenaEspx a Giovannifruttadisicilia 28 RIS [causale: Acquisto arance 30genn24 RisoBologna 1]
|
||||
Saldi:
|
||||
ElenaEspx: -60.10 RIS]
|
||||
Giovannifruttadisicilia: 250.50 RIS]
|
||||
47
outout.csv
Normal file
47
outout.csv
Normal file
@@ -0,0 +1,47 @@
|
||||
Num|Nome|Peso|Prezzo|Quantita|Totale|Ordini
|
||||
0|"Acqua distillata di rose di Damasco"|100|8|2|16|1
|
||||
0|"Artemisia in foglie"|20|1,5|7|10,5|3
|
||||
0|"Cannella"|100|3|4|12|3
|
||||
0|"Carruba macinata"|250|3|2|6|2
|
||||
0|"Cous cous 5 stelle (grano duro, mais, orzo, lenticchie ed avena)"|500|3,5|1|3,5|1
|
||||
0|"Cous cous d'avena"|500|3|3|9|2
|
||||
0|"Cous cous d'orzo"|500|3|1|3|1
|
||||
0|"Cous cous di grano duro (Akka)"|500|3,25|1|3,25|1
|
||||
0|"Cous cous di lenticchie"|500|3,5|4|14|3
|
||||
0|"Cous cous di miglio"|500|3|4|12|4
|
||||
0|"Couscous 5 cereali 1kg"|1|5,5|1|5,5|1
|
||||
0|"Couscous di grano duro 500g"|500|2,5|1|2,5|1
|
||||
0|"Curcuma"|100|3|5|15|4
|
||||
0|"Datteri boufeggous extra 1kg"|1|11|1|11|1
|
||||
0|"Datteri boufeggous extra 500g"|500|6,5|3|19,5|3
|
||||
0|"Datteri boustahammi 1kg"|1|5|11|55|6
|
||||
0|"Datteri boustahammi 500g"|500|3|3|9|3
|
||||
0|"Datteri bouzagagh 1kg"|1|5,5|2|11|2
|
||||
0|"Datteri bouzagagh 500g"|500|3,5|7|24,5|6
|
||||
0|"Farina di segale grigliata 1kg"|1|3,5|1|3,5|1
|
||||
0|"Fichi secchi bianchi 250g"|250|5|1|5|1
|
||||
0|"Fichi secchi bianchi 500g"|500|9|1|9|1
|
||||
0|"Fieno greco"|500|3,5|2|7|1
|
||||
0|"Ghassoul (pezzetti di argilla saponifera) per capelli"|100|4|2|8|2
|
||||
0|"Henné"|250|3|2|6|2
|
||||
0|"Henné (per tatuaggi e capelli)"|200|3,5|1|3,5|1
|
||||
0|"Henné (per tatuaggi e capelli)"|150|2,5|1|2,5|1
|
||||
0|"Menta Maachi (autoctona) in foglie"|20|1,5|1|1,5|1
|
||||
0|"Olio alle rose di Damasco"|60|9|2|18|2
|
||||
0|"Olio di argan cosmetico 30ml"|30|8|3|24|2
|
||||
0|"Olio di mandorle dolci"|30|5,5|1|5,5|1
|
||||
0|"Olio di nigella (cumino nero)"|30|5,5|1|5,5|1
|
||||
0|"Olio di sesamo"|30|5,5|1|5,5|1
|
||||
0|"Olive nere"|125|2|1|2|1
|
||||
0|"Olive nere alle piante aromatiche 1kg"|1|9|1|9|1
|
||||
0|"Olive nere alle piante aromatiche 500g"|500|5|1|5|1
|
||||
0|"Olive verdi alle piante aromatiche 1kg"|1|9|1|9|1
|
||||
0|"Olive verdi alle spezie 500g"|500|5|1|5|1
|
||||
0|"Paprika dolce senza olio"|100|3|2|6|2
|
||||
0|"Prugne secche"|250|3|2|6|2
|
||||
0|"Rose secche di Damasco"|50|2,5|2|5|2
|
||||
0|"Sapone a base di olio di argan"|80|4|3|12|3
|
||||
0|"Scrub Naama (rosa, in polvere)"|100|5|2|10|2
|
||||
0|"Sottopentola medio"|296|2,5|1|2,5|1
|
||||
0|"Verbena citronella in foglie"|20|1,5|1|1,5|1
|
||||
0|"Zenzero"|100|3|2|6|2
|
||||
|
@@ -37,6 +37,7 @@
|
||||
"image-downloader": "^4.3.0",
|
||||
"internet-available": "^1.0.0",
|
||||
"jade": "^1.9.2",
|
||||
"jsdom": "^24.0.0",
|
||||
"jsonwebtoken": "^9.0.1",
|
||||
"lodash": "^4.17.21",
|
||||
"mongodb": "^4.4.1",
|
||||
@@ -46,19 +47,21 @@
|
||||
"node-emoji": "^1.11.0",
|
||||
"node-image-resizer": "^1.0.0",
|
||||
"node-pre-gyp": "^0.14.0",
|
||||
"node-telegram-bot-api": "^0.59.0",
|
||||
"node-telegram-bot-api": "^0.65.1",
|
||||
"nodemailer": "^6.7.8",
|
||||
"npm-check-updates": "^16.1.0",
|
||||
"npm-check-updates": "^16.14.18",
|
||||
"pem": "^1.14.6",
|
||||
"preview-email": "^3.0.7",
|
||||
"pug": "^3.0.2",
|
||||
"rate-limiter-flexible": "^2.3.9",
|
||||
"request": "^2.34",
|
||||
"sanitize-html": "^2.13.0",
|
||||
"save": "^2.5.0",
|
||||
"sharp": "^0.30.7",
|
||||
"superagent": "^8.0.0",
|
||||
"url-parse": "^1.5.10",
|
||||
"validator": "^13.7.0",
|
||||
"web-push": "^3.5.0",
|
||||
"web-push": "^3.6.7",
|
||||
"xoauth2": "^1.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -16,7 +16,7 @@ process.env.LINK_UPDATE_PWD = '/updatepwd';
|
||||
process.env.LINK_CHECK_UPDATES = '/checkupdates';
|
||||
process.env.KEY_APP_ID = 'KKPPAA5KJK435J3KSS9F9D8S9F8SD98F9SDF';
|
||||
|
||||
// console.log("Starting Node with : " + file);
|
||||
console.log("Starting Node with: " + file);
|
||||
require('dotenv').config({ path: file });
|
||||
|
||||
process.env.DATABASE = process.env.DATABASE || 'FreePlanet';
|
||||
|
||||
@@ -38,6 +38,8 @@ let options = {
|
||||
// keepAliveInitialDelay: 300000 // keepAliveInitialDelay is the number of milliseconds to wait before initiating keepAlive on the socket.
|
||||
};
|
||||
|
||||
console.log('process.env.AUTH_MONGODB', process.env.AUTH_MONGODB);
|
||||
|
||||
if (process.env.AUTH_MONGODB === '1') {
|
||||
options.auth = {
|
||||
authSource: "admin",
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
{
|
||||
"Hello": "Ciao",
|
||||
"Hello %s": "Ciao %s",
|
||||
"Good": "Bene",
|
||||
"Service": "Servizio",
|
||||
"Hosp": "Ospitalità",
|
||||
"Good: %s": "Bene: %s",
|
||||
"Service: %s": "Servizio: %s",
|
||||
"NEW_GOOD": "❇️ <strong>%s</strong> ha aggiunto un nuovo Bene: \n<strong>%s</strong>",
|
||||
@@ -8,7 +11,9 @@
|
||||
"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_TELEGRAM": "%s\n\n❇️ <strong>%s</strong>\n\n%s\n\n%s",
|
||||
"ADDED_FROM": "\n\n<i>(Evento aggiunto da <strong>%s</strong>)</i>",
|
||||
"NEW_ANNUNCIO_TELEGRAM": "❇️ <strong>%s</strong>\n\n%s\n\n%s",
|
||||
"EVENT_ADDED_FROM": "\n\n<i>(Evento aggiunto da <strong>%s</strong>)</i>",
|
||||
"ADDED_FROM": "\n\n<i>(Aggiunto da <strong>%s</strong>)</i>",
|
||||
"CONTRIB": "\n💠 Contributo richiesto: %s",
|
||||
"ORGANIZED_BY": "\n<i>Organizzato da <strong>%s</strong></i>",
|
||||
"SHOW_POST": "👉🏻 vedi post su RISO",
|
||||
@@ -19,6 +24,7 @@
|
||||
"✅ %s accepted your Friendship request !": "✅ %s ha accettato la tua richiesta di Amicizia !",
|
||||
"✅ You have accepted %s' Friendship request!": "✅ Hai accettato la richiesta di Amicizia di %s !",
|
||||
"HANDSHAKE_SET": "<strong>%s</strong> ha comunicato che ti conosce personalmente e ha Fiducia in te (Stretta di mano).",
|
||||
"HANDSHAKE_SENT_FROM_YOU": "🤝 hai inviato una Stretta di Mano a <strong>%s</strong>, perché la conosci personalmente !",
|
||||
"HANDSHAKE_CONFIRMED": "🤝 Hai contraccambiato la stretta di mano di <strong>%s</strong>!",
|
||||
"HANDSHAKE_ACCEPTED": "🤝 <strong>%s</strong> ha contraccambiato la tua stretta di mano !",
|
||||
"GROUPS_ACCEPTED": "✅ Sei stato accettato a far parte del Gruppo %s (da parte di %s)",
|
||||
@@ -114,4 +120,4 @@
|
||||
"🚫 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 !",
|
||||
"✅ Hai Abilitato l'accesso alla App a %s !": "✅ Hai Abilitato l'accesso alla App a %s !"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ const auth_default = (req, res, next) => {
|
||||
|
||||
const authenticate = (req, res, next) => {
|
||||
const token = req.header('x-auth');
|
||||
//const refreshToken = req.header('x-refrtok');
|
||||
|
||||
// console.log('authenticate... ');
|
||||
|
||||
@@ -29,65 +30,80 @@ const authenticate = (req, res, next) => {
|
||||
|
||||
const access = 'auth';
|
||||
|
||||
User.findByToken(token, access).then((user) => {
|
||||
return User.findByToken(token, access, true).then((ris) => {
|
||||
|
||||
if (!user) {
|
||||
// tools.mylog("TOKEN " + token);
|
||||
// tools.mylog(" NOT FOUND! (Maybe Connected to other Page) ACCESS: '" + access + "'");
|
||||
return Promise.reject(server_constants.RIS_CODE_HTTP_INVALID_TOKEN);
|
||||
// res.status().send();
|
||||
if (ris && ris.user && !!ris.user.deleted) {
|
||||
if (ris.user.deleted)
|
||||
ris.user = null;
|
||||
}
|
||||
|
||||
if (!!user.deleted) {
|
||||
if (user.deleted)
|
||||
user = null;
|
||||
if (ris.code === server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED) {
|
||||
return Promise.reject(server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED);
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
if (!ris.user) {
|
||||
return Promise.reject(server_constants.RIS_CODE_HTTP_INVALID_TOKEN);
|
||||
}
|
||||
|
||||
if (!!user) {
|
||||
if (!!ris.user) {
|
||||
// Save last time online
|
||||
user.lasttimeonline = new Date();
|
||||
user.useragent = req.get('User-Agent');
|
||||
ris.user.lasttimeonline = new Date();
|
||||
ris.user.retry_pwd = 0
|
||||
ris.user.useragent = req.get('User-Agent');
|
||||
|
||||
return user.save().then(() => {
|
||||
req.user = user;
|
||||
return ris.user.save().then(() => {
|
||||
req.user = ris.user;
|
||||
req.token = token;
|
||||
// req.refreshToken = refreshToken;
|
||||
req.access = access;
|
||||
next();
|
||||
next(); // Esegui il codice successivo
|
||||
});
|
||||
}
|
||||
// tools.mylog('userid', user._id);
|
||||
|
||||
}).catch((e) => {
|
||||
if (e === server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED) {
|
||||
return res.status(server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED).send();
|
||||
}
|
||||
tools.mylog("ERR authenticate invalid Token =", e);
|
||||
res.status(server_constants.RIS_CODE_HTTP_INVALID_TOKEN).send();
|
||||
});
|
||||
};
|
||||
|
||||
const authenticate_noerror = (req, res, next) => {
|
||||
const token = req.header('x-auth');
|
||||
try {
|
||||
const token = req.header('x-auth');
|
||||
const refreshToken = req.header('x-refrtok');
|
||||
|
||||
const access = 'auth';
|
||||
const access = 'auth';
|
||||
|
||||
User.findByToken(token, access).then((user) => {
|
||||
if (!user) {
|
||||
return User.findByToken(token, access, false).then((ris) => {
|
||||
if (ris.code !== server_constants.RIS_CODE_OK) {
|
||||
req.user = null;
|
||||
req.token = null;
|
||||
req.access = null;
|
||||
req.code = ris.code;
|
||||
} else {
|
||||
req.user = ris.user;
|
||||
req.token = token;
|
||||
req.refreshToken = refreshToken;
|
||||
req.access = access;
|
||||
req.code = ris.code;
|
||||
}
|
||||
// Vai avanti ad eseguire il codice, in ogni modo !
|
||||
next();
|
||||
}).catch((e) => {
|
||||
req.user = null;
|
||||
req.token = null;
|
||||
req.access = null;
|
||||
} else {
|
||||
req.user = user;
|
||||
req.token = token;
|
||||
req.access = access;
|
||||
}
|
||||
next();
|
||||
}).catch((e) => {
|
||||
req.user = null;
|
||||
req.token = null;
|
||||
req.access = null;
|
||||
});
|
||||
req.code = 0;
|
||||
|
||||
// Continua comunque !
|
||||
next();
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = { authenticate, authenticate_noerror, auth_default };
|
||||
|
||||
@@ -244,6 +244,7 @@ AccountSchema.statics.addtoSaldo = async function (myaccount, amount, mitt) {
|
||||
|
||||
myaccountupdate.saldo = myaccount.saldo;
|
||||
myaccountupdate.totTransato = myaccount.totTransato;
|
||||
myaccountupdate.numtransactions = myaccount.numtransactions;
|
||||
myaccountupdate.date_updated = myaccount.date_updated;
|
||||
|
||||
const ris = await Account.updateOne({ _id: myaccount.id },
|
||||
@@ -251,8 +252,8 @@ AccountSchema.statics.addtoSaldo = async function (myaccount, amount, mitt) {
|
||||
$set: myaccountupdate
|
||||
});
|
||||
|
||||
|
||||
await myaccount.calcPending(mitt);
|
||||
// Calcola Saldo Pendente !
|
||||
await myaccount.calcPending(true);
|
||||
|
||||
return ris;
|
||||
|
||||
|
||||
54
src/server/models/author.js
Executable file
54
src/server/models/author.js
Executable file
@@ -0,0 +1,54 @@
|
||||
mongoose = require('mongoose').set('debug', false)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const AuthorSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
},
|
||||
surname: {
|
||||
type: String,
|
||||
},
|
||||
bio: {
|
||||
type: String,
|
||||
},
|
||||
img: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
var Author = module.exports = mongoose.model('Author', AuthorSchema);
|
||||
|
||||
module.exports.getFieldsForSearch = function () {
|
||||
return [
|
||||
{ field: 'name', type: tools.FieldType.string },
|
||||
{ field: 'surname', type: tools.FieldType.string },
|
||||
]
|
||||
};
|
||||
|
||||
module.exports.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
module.exports.findAllIdApp = async function (idapp) {
|
||||
const myfind = { idapp };
|
||||
|
||||
return await Author.find(myfind).sort({name: 1, surname: 1});
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
@@ -30,6 +30,9 @@ const CartSchema = new Schema({
|
||||
note: {
|
||||
type: String,
|
||||
},
|
||||
note_ordine_gas: {
|
||||
type: String,
|
||||
},
|
||||
modify_at: {
|
||||
type: Date,
|
||||
},
|
||||
@@ -52,20 +55,31 @@ module.exports.getCartByUserId = async function (uid, idapp) {
|
||||
|
||||
if (!!mycart) {
|
||||
for (const idkey in mycart.items) {
|
||||
try {
|
||||
idorder = mycart.items[idkey]._id.toString();
|
||||
const myorder = mycart.items[idkey].order;
|
||||
try {
|
||||
let idorder = mycart.items[idkey]._id.toString();
|
||||
let myorder = mycart.items[idkey].order;
|
||||
if (!!myorder) {
|
||||
idorder = mycart.items[idkey].order._id.toString();
|
||||
}
|
||||
const myord = await Order.getTotalOrderById(idorder);
|
||||
if (myord.length > 0) {
|
||||
mycart.items[idkey].order = myord[0];
|
||||
if (idorder) {
|
||||
let myord = await Order.getTotalOrderById(idorder);
|
||||
if (myord.length > 0) {
|
||||
mycart.items[idkey].order = myord[0];
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('err', e);
|
||||
}
|
||||
}
|
||||
|
||||
mycart.newitems = []
|
||||
for (let item of mycart.items) {
|
||||
if (item.order && item.order.hasOwnProperty('idapp') && (item.order.quantity > 0 || item.order.quantitypreordered > 0))
|
||||
mycart.newitems.push(item)
|
||||
}
|
||||
mycart.items = [...mycart.newitems]
|
||||
mycart.newitems = []
|
||||
|
||||
return mycart;
|
||||
}
|
||||
return null;
|
||||
@@ -110,6 +124,7 @@ module.exports.updateCartByCartId = async function (cartId, newCart) {
|
||||
const totalPrice = newCart.totalPrice;
|
||||
const totalPriceCalc = newCart.totalPriceCalc;
|
||||
const note = newCart.note;
|
||||
const note_ordine_gas = newCart.note_ordine_gas;
|
||||
|
||||
const modify_at = new Date();
|
||||
|
||||
@@ -120,6 +135,7 @@ module.exports.updateCartByCartId = async function (cartId, newCart) {
|
||||
totalPriceCalc,
|
||||
totalQty,
|
||||
note,
|
||||
note_ordine_gas,
|
||||
modify_at: new Date(),
|
||||
},
|
||||
}, { new: false }).lean().then((ris) => {
|
||||
|
||||
@@ -250,6 +250,18 @@ CircuitSchema.statics.findAllIdApp = async function (idapp) {
|
||||
return await Circuit.find(myfind, whatToShow).sort({ status: -1, numMembers: -1, name: 1 });
|
||||
};
|
||||
|
||||
CircuitSchema.statics.isCircuitAdmin = async function (idrec, username) {
|
||||
const Circuit = this;
|
||||
|
||||
|
||||
const mycirc = await Circuit.findOne({ _id: idrec }).lean();
|
||||
if (mycirc) {
|
||||
return mycirc.admins.some(admin => admin.username === username);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getFieldsForSearch = function () {
|
||||
return [
|
||||
{ field: 'name', type: tools.FieldType.string },
|
||||
@@ -593,6 +605,7 @@ CircuitSchema.statics.getUsersSingleCircuit = async function (idapp, username, c
|
||||
{
|
||||
$project: {
|
||||
username: 1,
|
||||
verified_by_aportador: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
profile: 1,
|
||||
@@ -730,8 +743,8 @@ CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig
|
||||
};
|
||||
await Circuit.updateOne({ _id: circuittable }, { $set: paramstoupdate });
|
||||
|
||||
extrarec.saldoOrig = accountorigTable.saldo;
|
||||
extrarec.saldoDest = accountdestTable.saldo;
|
||||
extrarec.saldoOrig = tools.arrotondaA2Decimali(accountorigTable.saldo);
|
||||
extrarec.saldoDest = tools.arrotondaA2Decimali(accountdestTable.saldo);
|
||||
|
||||
let orig = usernameOrig;
|
||||
if (extrarec.grouporig) {
|
||||
@@ -1229,6 +1242,401 @@ CircuitSchema.statics.setFido = async function (idapp, username, circuitName, gr
|
||||
return null;
|
||||
};
|
||||
|
||||
CircuitSchema.statics.CheckTransazioniCircuiti = async function (correggi) {
|
||||
const { User } = require('../models/user');
|
||||
const { MyGroup } = require('../models/mygroup');
|
||||
const { SendNotif } = require('../models/sendnotif');
|
||||
|
||||
const idapp = tools.RISO;
|
||||
|
||||
try {
|
||||
console.log('--------- INIZIO CONTROLLO CheckTransazioniCircuiti -----------');
|
||||
|
||||
if (correggi)
|
||||
console.log('CORREZIONE !');
|
||||
else
|
||||
console.log('SOLO VERIFICA');
|
||||
|
||||
|
||||
if (correggi) {
|
||||
// Trova tutti i documenti che contengono circuitname a null nell'array mycircuits
|
||||
const usersWithNullCircuit = await User.find({ idapp, "profile.mycircuits.circuitname": null });
|
||||
|
||||
// Itera su ciascun documento
|
||||
for (const user of usersWithNullCircuit) {
|
||||
// Rimuove i campi null dall'array mycircuits
|
||||
user.profile.mycircuits = user.profile.mycircuits.filter(circuit => circuit.circuitname !== null);
|
||||
|
||||
// Salva le modifiche al documento
|
||||
await User.findOneAndUpdate({ _id: user._id }, { $set: { 'profile.mycircuits': user.profile.mycircuits } });
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let usersWithDuplicateCircuits = await User.aggregate([
|
||||
{
|
||||
$unwind: "$profile.mycircuits"
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: {
|
||||
userId: "$_id",
|
||||
username: "$username",
|
||||
circuitname: "$profile.mycircuits.circuitname"
|
||||
},
|
||||
count: { $sum: 1 }
|
||||
}
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
count: { $gt: 1 }
|
||||
}
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: "$_id.userId",
|
||||
username: { $first: "$_id.username" },
|
||||
duplicatedCircuits: {
|
||||
$push: "$_id.circuitname"
|
||||
}
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
if (usersWithDuplicateCircuits.length > 0) {
|
||||
console.log("Utenti con circuitname duplicati:");
|
||||
usersWithDuplicateCircuits.forEach(user => {
|
||||
console.log("Username:", user.username);
|
||||
console.log("Circuiti duplicati:", user.duplicatedCircuits);
|
||||
});
|
||||
|
||||
if (correggi) {
|
||||
// CORREGGI DUPLICATI NEI CIRCUITI
|
||||
for (const user of usersWithDuplicateCircuits) {
|
||||
// Troviamo l'utente dal suo _id e aggiorniamo il suo documento
|
||||
const arraycirc = await User.findOne({ _id: user._id }).lean();
|
||||
|
||||
let risdel = await User.updateOne(
|
||||
{ _id: user._id },
|
||||
{ $pull: { "profile.mycircuits": { circuitname: { $in: user.duplicatedCircuits } } } }
|
||||
);
|
||||
|
||||
let risadd = await User.updateOne(
|
||||
{ _id: user._id },
|
||||
{ $push: { "profile.mycircuits": { $each: user.duplicatedCircuits.map(circuitname => ({ circuitname, date: arraycirc.profile.mycircuits.find((rec) => rec.circuitname === circuitname).date })) } } }
|
||||
);
|
||||
console.log('DEL', risdel, 'risadd', risadd);
|
||||
}
|
||||
}
|
||||
|
||||
console.log("*** FINE DUPLICATI *** ");
|
||||
} else {
|
||||
console.log("Nessun utente ha circuitname duplicati.");
|
||||
}
|
||||
|
||||
let numtransazionitot = 0;
|
||||
|
||||
const arrcircuits = await Circuit.find({ idapp }).lean();
|
||||
for (const circuit of arrcircuits) {
|
||||
let strusersnotinaCircuit = '';
|
||||
let strusersnotExist = '';
|
||||
numtransazionitot = 0;
|
||||
|
||||
let qta = 0;
|
||||
|
||||
let mystr = ''
|
||||
|
||||
// 1. Calcola la somma di tutti i Saldi
|
||||
|
||||
// prendo la lista di tutti gli account del circuito
|
||||
|
||||
let circuitId = circuit._id;
|
||||
|
||||
const accounts = await Account.find({ idapp, circuitId }).lean();
|
||||
|
||||
// CONTROLLA DUPLICATI !
|
||||
|
||||
const usernameCounts = accounts.reduce((acc, curr) => {
|
||||
if (curr.username !== '') {
|
||||
acc[curr.username] = (acc[curr.username] || 0) + 1;
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const duplicatedUsernames = Object.keys(usernameCounts).filter(username => usernameCounts[username] > 1);
|
||||
|
||||
if (duplicatedUsernames.length > 0) {
|
||||
mystr += ' Esistono username duplicati (escludendo quelli vuoti):' + duplicatedUsernames;
|
||||
}
|
||||
|
||||
let saldotot = 0;
|
||||
|
||||
let ris = await User.find({
|
||||
"profile.mycircuits": { $elemMatch: { circuitname: circuit.name } }
|
||||
}, "username").lean()
|
||||
|
||||
let arrusers_byprofile = ris ? ris.map(user => user.username) : [];
|
||||
|
||||
let risgroups = await MyGroup.find({
|
||||
"mycircuits": { $elemMatch: { circuitname: circuit.name } }
|
||||
}, "groupname").lean()
|
||||
|
||||
let arrgroups_byprofile = risgroups ? risgroups.map(group => group.groupname) : [];
|
||||
|
||||
let arrusers_byaccounts = [];
|
||||
let ind = 0
|
||||
let stracc = '';
|
||||
|
||||
for (const account of accounts) {
|
||||
let aggiorna = false;
|
||||
|
||||
if (account.username && !arrusers_byaccounts.includes(account.username)) {
|
||||
arrusers_byaccounts.push(account.username);
|
||||
} else if (account.groupname && !arrusers_byaccounts.includes(account.groupname)) {
|
||||
arrusers_byaccounts.push(account.groupname);
|
||||
} else if (account.contocom && !arrusers_byaccounts.includes(account.contocom)) {
|
||||
arrusers_byaccounts.push(account.contocom);
|
||||
}
|
||||
|
||||
// per ogni Account ricalcolo il numero di transazioni avvenute in Entrata/uscita
|
||||
let result = await Movement.aggregate([
|
||||
{
|
||||
$match: {
|
||||
$or: [
|
||||
{ accountFromId: account._id },
|
||||
{ accountToId: account._id },
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: null,
|
||||
numtransactions: { $sum: 1 },
|
||||
totTransato: { $sum: { $abs: "$amount" } },
|
||||
saldo: {
|
||||
$sum: {
|
||||
$cond: [
|
||||
{ $eq: ["$accountToId", account._id] },
|
||||
"$amount",
|
||||
{
|
||||
$cond: [
|
||||
{ $eq: ["$accountFromId", account._id] },
|
||||
{ $multiply: ["$amount", -1] },
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
let numtransactions = result && result.length > 0 ? result[0].numtransactions : 0;
|
||||
let totTransato = result && result.length > 0 ? result[0].totTransato : 0;
|
||||
let saldo = result && result.length > 0 ? result[0].saldo : 0;
|
||||
|
||||
// TRANSAZIONI PENDENTI:
|
||||
let saldo_pend = 0;
|
||||
let pendingtransactionsMittente = await SendNotif.getSumPendingTransactionsMittente(account.idapp, account.username, circuit.name, account.groupname);
|
||||
if (pendingtransactionsMittente.length > 0) {
|
||||
let saldopendingMitt = pendingtransactionsMittente.reduce((sum, rec) => sum + rec.extrarec.qty, 0);
|
||||
// transatopending = pendingtransactionsMittente.reduce((sum, rec) => sum + Math.abs(rec.extrarec.qty), 0);
|
||||
|
||||
saldo_pend = saldo - saldopendingMitt;
|
||||
} else {
|
||||
saldo_pend = saldo;
|
||||
}
|
||||
|
||||
let strtemp = '';
|
||||
|
||||
if (numtransactions > 0) {
|
||||
if (correggi)
|
||||
await Account.findOneAndUpdate({ _id: account._id }, { $set: { numtransactions } })
|
||||
}
|
||||
if (saldo !== account.saldo) {
|
||||
aggiorna = true;
|
||||
strtemp += ' SALDO DIFFERENTE ! => ' + '\nPRIMA: ' + account.saldo + '\nDOPO: ' + saldo;
|
||||
if (correggi)
|
||||
await Account.findOneAndUpdate({ _id: account._id }, { $set: { saldo } })
|
||||
}
|
||||
if (account.saldo_pend === undefined) {
|
||||
await Account.findOneAndUpdate({ _id: account._id }, { $set: { saldo_pend: 0 } })
|
||||
}
|
||||
if (saldo_pend !== account.saldo_pend) {
|
||||
aggiorna = true;
|
||||
strtemp += ' SALDO_PENDENTE DIFF. ! => ' + '\nPRIMA: ' + account.saldo_pend + '\nDOPO: ' + saldo_pend;
|
||||
if (correggi)
|
||||
await Account.findOneAndUpdate({ _id: account._id }, { $set: { saldo_pend } })
|
||||
}
|
||||
if (!account.totTransato || (totTransato !== account.totTransato)) {
|
||||
if (totTransato > account.totTransato || account.totTransato === undefined)
|
||||
if (correggi)
|
||||
await Account.findOneAndUpdate({ _id: account._id }, { $set: { totTransato } })
|
||||
}
|
||||
|
||||
saldotot += account.saldo;
|
||||
|
||||
// if (account.totTransato === NaN || account.totTransato === undefined)
|
||||
// stracc += ' TOTTRANSATO => ' + account.totTransato;
|
||||
|
||||
if (account.totTransato)
|
||||
qta += account.totTransato;
|
||||
if (account.numtransactions)
|
||||
numtransazionitot += account.numtransactions;
|
||||
|
||||
if (aggiorna && strtemp) {
|
||||
stracc += '\n ** Account ' + account.username + '\n' + strtemp;
|
||||
}
|
||||
|
||||
// await account.calcPending();
|
||||
ind++;
|
||||
}
|
||||
|
||||
let numaccounts = accounts.length;
|
||||
let esistecontocom = accounts.find((rec) => (rec.hasOwnProperty('contocom') && rec.contocom !== ''));
|
||||
|
||||
let numacc_profile = arrusers_byprofile.length + arrgroups_byprofile.length;
|
||||
if (esistecontocom && esistecontocom.contocom === circuit.path) {
|
||||
numacc_profile++;
|
||||
}
|
||||
|
||||
if (numacc_profile !== numaccounts) {
|
||||
mystr += ' IL NUMERO DI UTENTI NON COINCIDONO ! \n';
|
||||
mystr += 'Utenti Profilo = ' + numacc_profile + '\n';
|
||||
mystr += 'Utenti Accounts = ' + arrusers_byaccounts.length + '\n';
|
||||
|
||||
}
|
||||
|
||||
saldotot = saldotot.toFixed(2);
|
||||
|
||||
// mystr += ' numaccounts=' + numaccounts;
|
||||
if (strusersnotinaCircuit)
|
||||
mystr += ' Utenti non presenti nel Circuito ! => ' + strusersnotinaCircuit;
|
||||
if (strusersnotExist)
|
||||
mystr += ' Utenti non più esistenti ! => ' + strusersnotExist;
|
||||
|
||||
|
||||
// Verifica se saldotot è uguale a ZERO
|
||||
if (saldotot != 0) {
|
||||
mystr += '*** ATTENZIONE! ' + circuit.name + ' ha come somma un saldo di ' + saldotot + ' invece che ZERO';
|
||||
} else {
|
||||
if (numtransazionitot)
|
||||
mystr += ' qta=' + qta + ' numtransazionitot ' + numtransazionitot;
|
||||
}
|
||||
|
||||
if (mystr || stracc) {
|
||||
console.log('************************* ' + circuit.name + ':');
|
||||
console.log(mystr);
|
||||
if (stracc)
|
||||
console.log(stracc);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
console.log('--------- FINE CONTROLLO CheckTransazioniCircuiti -----------', 'Transazioni = ', numtransazionitot)
|
||||
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.replaceAllCircuitNames = async function (idapp) {
|
||||
const Circuit = this;
|
||||
|
||||
const { City } = require('../models/city');
|
||||
const { Province } = require('../models/province');
|
||||
|
||||
const { MyGroup } = require('../models/mygroup');
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
let circuits = [];
|
||||
try {
|
||||
circuits = await Circuit.find(myfind);
|
||||
|
||||
let quanti = 0;
|
||||
|
||||
for (const circuit of circuits) {
|
||||
if (!circuit || !circuit._id) {
|
||||
console.error('Error: circuit is null or has no _id property');
|
||||
continue;
|
||||
}
|
||||
const circuitId = circuit._id;
|
||||
|
||||
let provincia = '';
|
||||
if (circuit.idCity && circuit.idCity.length > 0) {
|
||||
provincia = await City.getProvinceByIdCity(circuit.idCity[0]);
|
||||
}
|
||||
if (!provincia)
|
||||
provincia = circuit.strProv;
|
||||
if (provincia) {
|
||||
provincia = await Province.getStrProvinceByProv(provincia);
|
||||
}
|
||||
|
||||
if (!provincia) {
|
||||
console.log('PROVINCIA NON ESISTENTE !', circuit.name);
|
||||
}
|
||||
|
||||
let path = '';
|
||||
|
||||
if (!circuit.showAlways) {
|
||||
let newname = 'Circuito RIS ' + provincia;
|
||||
|
||||
// Se newname contiene 'ROMA', allora non aggiorna
|
||||
|
||||
if (circuit.name == 'RIS Roma Sud Est ' || circuit.name === 'Circuito RIS Roma Sud Est') {
|
||||
newname = 'Circuito RIS Roma Sud Est';
|
||||
} else if (circuit.name == 'Circuito RIS Roma Sud e Litora') {
|
||||
newname = 'Circuito RIS Roma Sud e Litora';
|
||||
} else if (circuit.name.trim() === 'RISO Roma Nord' || circuit.name.trim() === 'Circuito RISO Roma Nord') {
|
||||
newname = 'Circuito RIS Roma Nord';
|
||||
} else if (circuit.name == 'Circuito RIS Benevento' || circuit.name == 'Circuito RIS Campania') {
|
||||
newname = 'Circuito RIS Campania';
|
||||
path = 'riscampania';
|
||||
} else if (circuit.name == 'Circuito RIS Milano Est') {
|
||||
newname = 'Circuito RIS Milano Est';
|
||||
} else if (circuit.name == 'Circuito RIS Repubblica di San Marino') {
|
||||
newname = 'Circuito RIS Repubblica di San Marino';
|
||||
}
|
||||
|
||||
if (((newname !== circuit.name) && (newname.indexOf('ROMA') === -1)) || path) {
|
||||
|
||||
console.log(`Sostituisci ${circuit.name} con ${newname}`);
|
||||
|
||||
quanti++;
|
||||
|
||||
if (path) {
|
||||
// Update path
|
||||
await Circuit.findOneAndUpdate({ _id: circuitId }, { $set: { path } })
|
||||
.catch(e => console.error('Err ', e));
|
||||
}
|
||||
|
||||
await Circuit.findOneAndUpdate({ _id: circuitId }, { $set: { name: newname } })
|
||||
.catch(e => console.error('Err ', e));
|
||||
|
||||
// Rename profile.mycircuits.circuitname in User
|
||||
await User.renameCircuitName(idapp, circuit.name, newname)
|
||||
.catch(e => console.error('Err ', e));
|
||||
|
||||
await MyGroup.renameCircuitName(idapp, circuit.name, newname)
|
||||
.catch(e => console.error('Err ', e));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log('Circuiti aggiornati: ' + quanti);
|
||||
|
||||
} catch (e) {
|
||||
console.error('Err ', e);
|
||||
return;
|
||||
}
|
||||
|
||||
};
|
||||
CircuitSchema.statics.addMovementByOrdersCart = async function (ordersCart, usernameDest, groupDest) {
|
||||
|
||||
const { User } = require('../models/user');
|
||||
|
||||
@@ -8,7 +8,9 @@ mongoose.level = 'F';
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
const fs = require('fs-extra');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
@@ -49,11 +51,14 @@ const CitySchema = new Schema({
|
||||
type: String,
|
||||
maxlength: 3,
|
||||
},
|
||||
geojson: {
|
||||
type: Object, // Tipo che può contenere le features GeoJSON
|
||||
},
|
||||
});
|
||||
|
||||
CitySchema.pre('save', async function(next) {
|
||||
CitySchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
const myrec = await City.findOne().limit(1).sort({_id: -1});
|
||||
const myrec = await City.findOne().limit(1).sort({ _id: -1 });
|
||||
if (!!myrec) {
|
||||
if (myrec._doc._id === 0)
|
||||
this._id = 1;
|
||||
@@ -68,8 +73,8 @@ CitySchema.pre('save', async function(next) {
|
||||
next();
|
||||
});
|
||||
|
||||
CitySchema.statics.getProvinceByIdCity = async function(idcity) {
|
||||
const myrec = await City.findOne({_id: idcity}).lean();
|
||||
CitySchema.statics.getProvinceByIdCity = async function (idcity) {
|
||||
const myrec = await City.findOne({ _id: idcity }).lean();
|
||||
if (myrec) {
|
||||
return myrec.prov;
|
||||
}
|
||||
@@ -77,10 +82,10 @@ CitySchema.statics.getProvinceByIdCity = async function(idcity) {
|
||||
return '';
|
||||
}
|
||||
|
||||
CitySchema.statics.getCircuitNameBystrProv = async function(strProv) {
|
||||
CitySchema.statics.getCircuitNameBystrProv = async function (strProv) {
|
||||
const { Circuit } = require('../models/circuit');
|
||||
|
||||
const myrec = await Circuit.findOne({strProv}).lean();
|
||||
const myrec = await Circuit.findOne({ strProv }).lean();
|
||||
if (myrec) {
|
||||
return myrec.name;
|
||||
}
|
||||
@@ -88,8 +93,8 @@ CitySchema.statics.getCircuitNameBystrProv = async function(strProv) {
|
||||
return '';
|
||||
}
|
||||
|
||||
CitySchema.statics.getRegionByIdCity = async function(idcity) {
|
||||
const myrec = await City.findOne({_id: idcity}).lean();
|
||||
CitySchema.statics.getRegionByIdCity = async function (idcity) {
|
||||
const myrec = await City.findOne({ _id: idcity }).lean();
|
||||
if (myrec) {
|
||||
return myrec.reg;
|
||||
}
|
||||
@@ -97,13 +102,13 @@ CitySchema.statics.getRegionByIdCity = async function(idcity) {
|
||||
return '';
|
||||
}
|
||||
|
||||
CitySchema.statics.findByCity = function(mycity) {
|
||||
CitySchema.statics.findByCity = function (mycity) {
|
||||
|
||||
let myregexp = new RegExp(mycity.trim().replace(' ', '|'), 'ig');
|
||||
|
||||
const query = [
|
||||
{$match: {comune: {$regex: myregexp}}},
|
||||
{$sort: {descr: 1}},
|
||||
{ $match: { comune: { $regex: myregexp } } },
|
||||
{ $sort: { descr: 1 } },
|
||||
];
|
||||
|
||||
return City.aggregate(query).then((arrrec) => {
|
||||
@@ -112,17 +117,17 @@ CitySchema.statics.findByCity = function(mycity) {
|
||||
|
||||
};
|
||||
|
||||
CitySchema.statics.getFieldsForSearch = function() {
|
||||
CitySchema.statics.getFieldsForSearch = function () {
|
||||
return [
|
||||
{field: 'comune', type: tools.FieldType.string},
|
||||
{field: 'prov', type: tools.FieldType.string},
|
||||
{field: 'reg', type: tools.FieldType.string},
|
||||
{field: 'pref', type: tools.FieldType.number},
|
||||
{field: 'cap', type: tools.FieldType.number},
|
||||
{ field: 'comune', type: tools.FieldType.string },
|
||||
{ field: 'prov', type: tools.FieldType.string },
|
||||
{ field: 'reg', type: tools.FieldType.string },
|
||||
{ field: 'pref', type: tools.FieldType.number },
|
||||
{ field: 'cap', type: tools.FieldType.number },
|
||||
];
|
||||
};
|
||||
|
||||
CitySchema.statics.executeQueryTable = function(idapp, params) {
|
||||
CitySchema.statics.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
|
||||
const strfind = params.search;
|
||||
@@ -134,7 +139,7 @@ CitySchema.statics.executeQueryTable = function(idapp, params) {
|
||||
return tools.executeQueryTable(this, 0, params);
|
||||
};
|
||||
|
||||
CitySchema.statics.executeQueryPickup = async function(idapp, params) {
|
||||
CitySchema.statics.executeQueryPickup = async function (idapp, params) {
|
||||
|
||||
const strfind = params.search;
|
||||
|
||||
@@ -144,19 +149,19 @@ CitySchema.statics.executeQueryPickup = async function(idapp, params) {
|
||||
|
||||
let filterfindexact = {};
|
||||
if (strfind) {
|
||||
filterfindexact = {comune: strfind};
|
||||
filterfindexact = { comune: strfind };
|
||||
}
|
||||
|
||||
let limit = 10;
|
||||
let risexact = [];
|
||||
|
||||
let filterfind = {comune: {$regex: '^' + strfind, $options: 'i'}};
|
||||
let filterfind = { comune: { $regex: '^' + strfind, $options: 'i' } };
|
||||
|
||||
let aggr1 = [
|
||||
{
|
||||
$match: {comune: strfind},
|
||||
$match: { comune: strfind },
|
||||
},
|
||||
{ $limit : 1 },
|
||||
{ $limit: 1 },
|
||||
{
|
||||
$project: {
|
||||
comune: { $concat: ["$comune", " (", "$prov", ")"] },
|
||||
@@ -165,7 +170,7 @@ CitySchema.statics.executeQueryPickup = async function(idapp, params) {
|
||||
];
|
||||
|
||||
if (params.filter) {
|
||||
filterfind = {...params.filter, ...filterfind};
|
||||
filterfind = { ...params.filter, ...filterfind };
|
||||
limit = 200;
|
||||
} else {
|
||||
// risexact = await City.find(filterfindexact, {comune: 1, prov: 1, reg: 1}).lean();
|
||||
@@ -176,7 +181,7 @@ CitySchema.statics.executeQueryPickup = async function(idapp, params) {
|
||||
{
|
||||
$match: filterfind,
|
||||
},
|
||||
{ $limit : limit },
|
||||
{ $limit: limit },
|
||||
{
|
||||
$project: {
|
||||
comune: { $concat: ["$comune", " (", "$prov", ")"] },
|
||||
@@ -192,17 +197,85 @@ CitySchema.statics.executeQueryPickup = async function(idapp, params) {
|
||||
|
||||
};
|
||||
|
||||
|
||||
CitySchema.statics.findAllIdApp = async function(idapp) {
|
||||
CitySchema.statics.findAllIdApp = async function (idapp) {
|
||||
const myfind = {};
|
||||
|
||||
return await City.find(myfind);
|
||||
};
|
||||
|
||||
CitySchema.statics.getGeoJsonByProvince = async function (prov) {
|
||||
let ris = null;
|
||||
if (prov)
|
||||
ris = await City.find({ prov }).lean();
|
||||
else
|
||||
ris = await City.find({}).lean();
|
||||
|
||||
try {
|
||||
if (ris) {
|
||||
const arrjson = ris
|
||||
.filter(record => record.geojson && typeof record.geojson === 'object' && record.geojson.geometry) // Prima filtra per mantenere solo gli oggetti con "geometry"
|
||||
.map((record, index) => {
|
||||
// Crea un nuovo oggetto con gli attributi desiderati da ogni record
|
||||
const newRecord = {
|
||||
...record.geojson, // Spread dell'oggetto geojson per prendere tutte le sue proprietà
|
||||
id: (index + 1).toString(), // Aggiunge un valore "id" incrementale in base all'indice
|
||||
};
|
||||
|
||||
// Aggiungi o aggiorna la proprietà "prov" in "properties" dentro l'oggetto geojson
|
||||
if (newRecord.properties) {
|
||||
newRecord.properties.prov = record.prov; // Se "properties" esiste già
|
||||
} else {
|
||||
newRecord.properties = { prov: record.prov }; // Crea "properties" se non esiste
|
||||
}
|
||||
|
||||
return newRecord;
|
||||
});
|
||||
|
||||
return arrjson;
|
||||
}
|
||||
return [];
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
}
|
||||
|
||||
return null
|
||||
};
|
||||
|
||||
|
||||
CitySchema.statics.insertGeojsonToMongoDB = async function (nomefilejson) {
|
||||
try {
|
||||
// Lettura del file GeoJSON
|
||||
const geojson = await fs.readJson(nomefilejson); // Sostituisci con il percorso del tuo file GeoJSON
|
||||
|
||||
let inseriti = 0;
|
||||
const numcomuni = geojson.features.length;
|
||||
for (const citta of geojson.features) {
|
||||
|
||||
// Identifica il documento esistente in cui vuoi aggiungere le features
|
||||
const reccity = await City.findOne({ istat: String(citta.properties.ISTAT).padStart(6, '0') });
|
||||
|
||||
if (reccity) {
|
||||
const ris = await City.updateOne({ _id: reccity._id }, { $set: { geojson: citta } });
|
||||
if (ris.ok === 1) {
|
||||
inseriti++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
console.log(`${inseriti} su ${numcomuni} comuni inseriti.`);
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
const City = mongoose.model('City', CitySchema);
|
||||
|
||||
City.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = {City};
|
||||
module.exports = { City };
|
||||
|
||||
@@ -25,10 +25,12 @@ const ContribtypeSchema = new Schema({
|
||||
});
|
||||
|
||||
ContribtypeSchema.statics.getFieldsForSearch = function () {
|
||||
|
||||
return [{field: 'label', type: tools.FieldType.string}]
|
||||
};
|
||||
|
||||
ContribtypeSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
@@ -47,7 +49,7 @@ ContribtypeSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
return await Contribtype.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
}).lean();
|
||||
};
|
||||
|
||||
const Contribtype = mongoose.model('Contribtype', ContribtypeSchema);
|
||||
|
||||
@@ -34,6 +34,9 @@ const gasordineSchema = new Schema({
|
||||
img: {
|
||||
type: String,
|
||||
},
|
||||
note_ordine_gas: {
|
||||
type: String,
|
||||
},
|
||||
|
||||
dataora_chiusura_ordini: {
|
||||
type: Date,
|
||||
|
||||
63
src/server/models/importamacro.js
Executable file
63
src/server/models/importamacro.js
Executable file
@@ -0,0 +1,63 @@
|
||||
mongoose = require('mongoose').set('debug', false)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
// A1P
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const ImportaMacroSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
_id: {
|
||||
type: String,
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
var ImportaMacro = module.exports = mongoose.model('ImportaMacro', ImportaMacroSchema);
|
||||
|
||||
ImportaMacroSchema.index({ idapp: 1 });
|
||||
|
||||
module.exports.getFieldsForSearch = function () {
|
||||
return [
|
||||
{ field: 'name', type: tools.FieldType.string },
|
||||
{ field: 'description', type: tools.FieldType.string },
|
||||
]
|
||||
};
|
||||
|
||||
module.exports.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
module.exports.getImportaMacroByCode = function (idapp, code) {
|
||||
return ImportaMacro.findAllIdApp(idapp, code);
|
||||
}
|
||||
|
||||
module.exports.getImportaMacroById = async function (id) {
|
||||
const arrris = await ImportaMacro.findAllIdApp('', '', id);
|
||||
return arrris && arrris.length > 0 ? arrris[0] : null
|
||||
}
|
||||
|
||||
module.exports.findAllIdApp = async function (idapp) {
|
||||
const ImportaMacro = this;
|
||||
|
||||
const myfind = { idapp, deleted: false };
|
||||
|
||||
return await ImportaMacro.find(myfind, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
};
|
||||
@@ -6,6 +6,7 @@ const tools = require('../tools/general');
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
const { User } = require('./user');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
@@ -13,115 +14,84 @@ mongoose.plugin(schema => {
|
||||
});
|
||||
|
||||
const MailingListSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
email: {
|
||||
type: String,
|
||||
trim: true,
|
||||
},
|
||||
hash: {
|
||||
type: String,
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
trim: true,
|
||||
},
|
||||
surname: {
|
||||
type: String,
|
||||
trim: true,
|
||||
},
|
||||
statesub: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
wrongerr: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
lastid_newstosent: {
|
||||
type: String
|
||||
}
|
||||
});
|
||||
|
||||
MailingListSchema.statics.getFieldsForSearch = function () {
|
||||
return [{ field: 'name', type: tools.FieldType.string },
|
||||
{ field: 'surname', type: tools.FieldType.string },
|
||||
{ field: 'email', type: tools.FieldType.string }]
|
||||
};
|
||||
|
||||
MailingListSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
params.fieldsearch = User.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
MailingListSchema.statics.findAllIdAppSubscribed = function (idapp) {
|
||||
const MailingList = this;
|
||||
|
||||
const myfind = { idapp, statesub: true, wrongerr: { $ne: true } };
|
||||
const myfind = {
|
||||
idapp,
|
||||
news_on: true,
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
$or: [
|
||||
{ email_errata: { $exists: false } },
|
||||
{ email_errata: { $exists: true, $ne: true } }],
|
||||
};
|
||||
|
||||
// Extract only the Teacher where in the users table the field permissions is set 'Teacher' bit.
|
||||
|
||||
return MailingList.find(myfind, (err, arrrec) => {
|
||||
return User.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
};
|
||||
|
||||
MailingListSchema.statics.getnumSent = async function (idapp, idmailinglist) {
|
||||
const MailingList = this;
|
||||
MailingListSchema.statics.getnumSent = async function (idapp, idUser) {
|
||||
|
||||
const myfind = { idapp, statesub: true, lastid_newstosent: idmailinglist };
|
||||
const myfind = { idapp, news_on: true, lastid_newstosent: idUser };
|
||||
|
||||
// Extract only the Teacher where in the users table the field permissions is set 'Teacher' bit.
|
||||
|
||||
return await MailingList.countDocuments(myfind);
|
||||
return await User.countDocuments(myfind);
|
||||
};
|
||||
|
||||
MailingListSchema.statics.isOk = async function (idapp, iduser, idmailinglist) {
|
||||
const MailingList = this;
|
||||
MailingListSchema.statics.isOk = async function (idapp, iduser, idUser) {
|
||||
|
||||
const myfind = { idapp, _id: iduser, statesub: true, lastid_newstosent: { $ne: idmailinglist } };
|
||||
|
||||
const myfind = { idapp, _id: iduser, news_on: true, lastid_newstosent: { $ne: idUser } };
|
||||
|
||||
// Extract only the Teacher where in the users table the field permissions is set 'Teacher' bit.
|
||||
|
||||
return await MailingList.countDocuments(myfind) > 0;
|
||||
return await User.countDocuments(myfind) > 0;
|
||||
};
|
||||
|
||||
MailingListSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const MailingList = this;
|
||||
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await MailingList.find(myfind, (err, arrrec) => {
|
||||
return await User.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
};
|
||||
|
||||
MailingListSchema.statics.isUnsubscribed = async function (idapp, hash) {
|
||||
const MailingList = this;
|
||||
|
||||
let myperson = await MailingList.findOne({ idapp, hash });
|
||||
console.log('myperson', myperson);
|
||||
let myperson = await User.findOne({ idapp, hash });
|
||||
if (!!myperson) {
|
||||
return (!myperson.statesub)
|
||||
return (!myperson.news_on)
|
||||
}
|
||||
};
|
||||
|
||||
MailingListSchema.statics.findByHash = function (idapp, hash) {
|
||||
const MailingList = this;
|
||||
|
||||
const myfind = { idapp, hash };
|
||||
|
||||
// Extract only the Teacher where in the users table the field permissions is set 'Teacher' bit.
|
||||
|
||||
return MailingList.findOne(myfind, (err, rec) => {
|
||||
return User.findOne(myfind, (err, rec) => {
|
||||
return rec
|
||||
});
|
||||
};
|
||||
|
||||
const MailingList = mongoose.model('MailingList', MailingListSchema);
|
||||
|
||||
MailingList.createIndexes((err) => {
|
||||
User.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
|
||||
@@ -366,16 +366,20 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function (idapp, username
|
||||
notifId: 1,
|
||||
'circuitfrom.symbol': 1,
|
||||
'circuitto.symbol': 1,
|
||||
'userfrom.verified_by_aportador': 1,
|
||||
'userfrom.username': 1,
|
||||
'userfrom.profile.img': 1,
|
||||
'userto.username': 1,
|
||||
'userto.profile.img': 1,
|
||||
'userto.verified_by_aportador': 1,
|
||||
'groupfrom.groupname': 1,
|
||||
'groupfrom.verified_by_aportador': 1,
|
||||
'groupfrom.title': 1,
|
||||
'groupfrom.photos': 1,
|
||||
'groupto.groupname': 1,
|
||||
'groupto.title': 1,
|
||||
'groupto.photos': 1,
|
||||
'groupto.verified_by_aportador': 1,
|
||||
'contocomfrom.path': 1,
|
||||
'contocomfrom.name': 1,
|
||||
'contocomto.path': 1,
|
||||
|
||||
@@ -309,7 +309,6 @@ MyGroupSchema.statics.getInfoGroupByGroupname = async function (idapp, groupname
|
||||
|
||||
const query = [
|
||||
{ $match: myfind },
|
||||
{ $unwind: '$mycircuits' },
|
||||
{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
@@ -337,6 +336,7 @@ MyGroupSchema.statics.getInfoGroupByGroupname = async function (idapp, groupname
|
||||
|
||||
];
|
||||
|
||||
|
||||
try {
|
||||
const ris = await MyGroup.aggregate(query);
|
||||
|
||||
@@ -628,6 +628,13 @@ MyGroupSchema.statics.getReceiveRISGroups = async function (idapp) {
|
||||
|
||||
};
|
||||
|
||||
|
||||
MyGroupSchema.statics.renameCircuitName = async function (idapp, oldcircuitname, newcircuitname) {
|
||||
|
||||
return await this.updateMany({ idapp, 'mycircuits.circuitname': oldcircuitname }, { $set: { 'profile.mycircuits.$.circuitname': newcircuitname } });
|
||||
};
|
||||
|
||||
|
||||
MyGroupSchema.statics.setReceiveRisGroup = async function (idapp, groupname) {
|
||||
|
||||
return await this.findOneAndUpdate({
|
||||
|
||||
@@ -9,6 +9,7 @@ const { ObjectID } = require('mongodb');
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
@@ -54,6 +55,9 @@ const orderSchema = new Schema({
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
TotalPriceProductstr: {
|
||||
type: String,
|
||||
},
|
||||
TotalPriceProductCalc: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
@@ -359,9 +363,10 @@ module.exports.updateTotals = function (order) {
|
||||
} else {
|
||||
mypricecalc = (order.price * order.quantity) + (order.price * order.quantitypreordered);
|
||||
}
|
||||
|
||||
|
||||
order.TotalPriceProductCalc += mypricecalc;
|
||||
order.TotalPriceProduct += mypricecalc;
|
||||
order.TotalPriceProductstr = parseFloat(order.TotalPriceProduct.toFixed(2));
|
||||
|
||||
return order;
|
||||
|
||||
@@ -409,6 +414,12 @@ module.exports.getTotalOrderById = async function (id) {
|
||||
as: 'producer'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$producer',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'storehouses',
|
||||
@@ -417,6 +428,12 @@ module.exports.getTotalOrderById = async function (id) {
|
||||
as: 'storehouse'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$storehouse',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'providers',
|
||||
@@ -425,6 +442,12 @@ module.exports.getTotalOrderById = async function (id) {
|
||||
as: 'provider'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$provider',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'gasordines',
|
||||
@@ -455,24 +478,6 @@ module.exports.getTotalOrderById = async function (id) {
|
||||
as: 'scontisticas'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$producer',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$storehouse',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$provider',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'orders',
|
||||
@@ -600,7 +605,175 @@ module.exports.getTotalOrderById = async function (id) {
|
||||
|
||||
];
|
||||
|
||||
return await Order.aggregate(query);
|
||||
const ris = await Order.aggregate(query);
|
||||
return ris;
|
||||
}
|
||||
|
||||
module.exports.RemoveDeletedOrdersInOrderscart = async function () {
|
||||
try {
|
||||
const OrdersCart = require('./orderscart');
|
||||
|
||||
// Cancella gli Ordini che non esistono in OrdersCart
|
||||
const arrorders = await OrdersCart.find({}).lean();
|
||||
for (const rec of arrorders) {
|
||||
let recordercart = await OrdersCart.getOrdersCartById(rec._id);
|
||||
|
||||
let arrord = []
|
||||
let cambiare = false;
|
||||
for (const recOrd of recordercart.items) {
|
||||
if (recOrd.order) {
|
||||
arrord.push(recOrd)
|
||||
} else {
|
||||
cambiare = true;
|
||||
}
|
||||
}
|
||||
if (cambiare) {
|
||||
await OrdersCart.findOneAndUpdate({ _id: recordercart._id }, { $set: { items: arrord } }, { new: false });
|
||||
}
|
||||
}
|
||||
|
||||
// Controllo se Order non esiste in OrdersCart
|
||||
const arrord = await Order.find({}).lean();
|
||||
for (const ord of arrord) {
|
||||
const idtofind = ord._id;
|
||||
|
||||
await OrdersCart.findOne({ 'items.order': { $in: [idtofind] } })
|
||||
.then(async (orderCart) => {
|
||||
if (!orderCart) {
|
||||
// NON TROVATO ! Allora lo cancello
|
||||
|
||||
await Order.findOneAndRemove({ _id: ord._id });
|
||||
}
|
||||
})
|
||||
.catch(err => console.error(err));
|
||||
}
|
||||
|
||||
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports.GeneraCSVOrdineProdotti = async function () {
|
||||
|
||||
const myidGasordine = '65c2a8cc379ee4f57e865ee7';
|
||||
|
||||
const myquery = [
|
||||
{ $match: { idGasordine: ObjectID(myidGasordine) } },
|
||||
{
|
||||
$lookup: {
|
||||
from: 'products',
|
||||
localField: 'idProduct',
|
||||
foreignField: '_id',
|
||||
as: 'product'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$product',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'productinfos',
|
||||
localField: 'product.idProductInfo',
|
||||
foreignField: '_id',
|
||||
as: 'productInfo'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$productInfo',
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'gasordines',
|
||||
localField: 'idGasordine',
|
||||
foreignField: '_id',
|
||||
as: 'gasordine'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$gasordine',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$or: [
|
||||
{ 'gasordine.active': true }, // Include documents where gasordines.active is true
|
||||
{ 'gasordine': { $exists: false } } // Include documents where gasordines array doesn't exist
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
$match: {
|
||||
$or: [
|
||||
{ quantity: { $gt: 0 }, },
|
||||
{ quantitypreordered: { $gt: 0 }, }
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
$group: {
|
||||
_id: "$product._id",
|
||||
name: { $first: "$productInfo.name" },
|
||||
weight: { $first: "$productInfo.weight" },
|
||||
price_acquistato: { $first: "$product.price_acquistato" },
|
||||
totalQuantity: { $sum: { $add: ["$quantity", "$quantitypreordered"] } },
|
||||
totalPrice_acquistato: { $sum: { $multiply: ["$product.price_acquistato", { $add: ["$quantity", "$quantitypreordered"] }] } },
|
||||
count: { $sum: 1 }
|
||||
}
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
name: 1 // Sort in ascending order based on the "date_created" field
|
||||
},
|
||||
}
|
||||
];
|
||||
|
||||
let myorderscart = await Order.aggregate(myquery);
|
||||
|
||||
console.log(myorderscart)
|
||||
|
||||
return generateCSV(myorderscart, 'outout.csv');
|
||||
|
||||
}
|
||||
|
||||
function generateCSV(data, outputPath) {
|
||||
const headers = ['Num', 'Nome', 'Peso', 'Prezzo', 'Quantita', 'Totale', 'Ordini'];
|
||||
|
||||
const rows = data.map(item => {
|
||||
const formattedPrice = item.price_acquistato.toString().replace(/\./g, ','); // Converti "." in ","
|
||||
const total = item.totalPrice_acquistato.toString().replace(/\./g, ','); // Converti "." in ","
|
||||
return [
|
||||
0,
|
||||
`"${item.name}"`,
|
||||
item.weight,
|
||||
formattedPrice,
|
||||
item.totalQuantity,
|
||||
total,
|
||||
item.count
|
||||
];
|
||||
});
|
||||
|
||||
rows.unshift(headers);
|
||||
|
||||
const csvData = rows.map(row => row.join('|'));
|
||||
|
||||
fs.writeFile(outputPath, csvData.join('\n'), (err) => {
|
||||
if (err) {
|
||||
console.error('Error writing CSV file:', err);
|
||||
} else {
|
||||
console.log('CSV file has been successfully generated:', outputPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -94,6 +94,9 @@ const OrdersCartSchema = new Schema({
|
||||
note_per_gestore: {
|
||||
type: String
|
||||
},
|
||||
note_ordine_gas: {
|
||||
type: String
|
||||
},
|
||||
note_per_admin: {
|
||||
type: String
|
||||
},
|
||||
@@ -206,96 +209,303 @@ module.exports.getOrdersCartById = async function (id) {
|
||||
|
||||
|
||||
module.exports.getOrdersCartByQuery = async function (query) {
|
||||
try {
|
||||
|
||||
let myorderscart = await OrdersCart.find(query)
|
||||
.populate('items.order')
|
||||
.populate({
|
||||
path: 'items.order',
|
||||
populate: {
|
||||
path: 'idProduct',
|
||||
model: 'Product',
|
||||
let myorderscart = await OrdersCart.find(query)
|
||||
.populate('items.order')
|
||||
.populate({
|
||||
path: 'items.order',
|
||||
populate: {
|
||||
path: 'idProductInfo',
|
||||
model: 'ProductInfo'
|
||||
}
|
||||
}
|
||||
})
|
||||
.populate({
|
||||
path: 'items.order',
|
||||
populate: {
|
||||
path: 'idProducer',
|
||||
model: 'Producer'
|
||||
}
|
||||
})
|
||||
.populate({
|
||||
path: 'items.order',
|
||||
populate: {
|
||||
path: 'idProvider',
|
||||
model: 'Provider'
|
||||
}
|
||||
})
|
||||
.populate({
|
||||
path: 'items.order',
|
||||
populate: {
|
||||
path: 'idGasordine',
|
||||
model: 'Gasordine'
|
||||
}
|
||||
})
|
||||
.populate({
|
||||
path: 'items.order',
|
||||
populate: {
|
||||
path: 'idStorehouse',
|
||||
model: 'Storehouse'
|
||||
}
|
||||
})
|
||||
.populate({
|
||||
path: 'items.order',
|
||||
populate: {
|
||||
path: 'idScontisticas',
|
||||
model: 'Scontistica'
|
||||
}
|
||||
})
|
||||
.populate({
|
||||
path: 'userId',
|
||||
model: 'User',
|
||||
select: '_id name surname username profile email lang'
|
||||
})
|
||||
.lean();
|
||||
|
||||
myorderscart = myorderscart.map(order => {
|
||||
order.user = order.userId;
|
||||
order.userId = order.user._id;
|
||||
order.items = order.items.map(item => {
|
||||
if (item.order) {
|
||||
try {
|
||||
if (item.order.idProduct) {
|
||||
item.order.idProduct.productInfo = item.order.idProduct.productInfo ? item.order.idProduct.productInfo : { ...item.order.idProduct.idProductInfo };
|
||||
item.order.idProduct.idProductInfo = item.order.idProduct.productInfo ? item.order.idProduct.productInfo._id : '';
|
||||
path: 'idProduct',
|
||||
model: 'Product',
|
||||
populate: {
|
||||
path: 'idProductInfo',
|
||||
model: 'ProductInfo'
|
||||
}
|
||||
item.order.product = { ...item.order.idProduct };
|
||||
item.order.idProduct = item.order.product ? item.order.product._id : '';
|
||||
item.order.producer = item.order.idProducer;
|
||||
item.order.idProducer = item.order.producer ? item.order.producer._id : '';
|
||||
item.order.storehouse = item.order.idStorehouse;
|
||||
item.order.idStorehouse = item.order.storehouse ? item.order.storehouse._id : '';
|
||||
item.order.provider = item.order.idProvider;
|
||||
item.order.idProvider = item.order.provider ? item.order.provider._id : '';
|
||||
item.order.gasordine = item.order.idGasordine;
|
||||
item.order.idGasordine = item.order.gasordine ? item.order.gasordine._id : '';
|
||||
item.order.scontisticas = item.order.scontisticas;
|
||||
item.order.idScontisticas = item.order.idScontisticas ? item.order.idScontisticas._id : '';
|
||||
} catch (e) {
|
||||
console.error('Err: ', e);
|
||||
}
|
||||
})
|
||||
.populate({
|
||||
path: 'items.order',
|
||||
populate: {
|
||||
path: 'idProducer',
|
||||
model: 'Producer'
|
||||
}
|
||||
})
|
||||
.populate({
|
||||
path: 'items.order',
|
||||
populate: {
|
||||
path: 'idProvider',
|
||||
model: 'Provider'
|
||||
}
|
||||
})
|
||||
.populate({
|
||||
path: 'items.order',
|
||||
populate: {
|
||||
path: 'idGasordine',
|
||||
model: 'Gasordine'
|
||||
}
|
||||
})
|
||||
.populate({
|
||||
path: 'items.order',
|
||||
populate: {
|
||||
path: 'idStorehouse',
|
||||
model: 'Storehouse'
|
||||
}
|
||||
})
|
||||
.populate({
|
||||
path: 'items.order',
|
||||
populate: {
|
||||
path: 'idScontisticas',
|
||||
model: 'Scontistica'
|
||||
}
|
||||
})
|
||||
.populate({
|
||||
path: 'userId',
|
||||
model: 'User',
|
||||
select: '_id name surname username profile email lang'
|
||||
})
|
||||
.lean();
|
||||
|
||||
myorderscart = myorderscart.map(order => {
|
||||
order.user = order.userId;
|
||||
order.userId = order.user._id;
|
||||
order.items = order.items.map(item => {
|
||||
if (item.order) {
|
||||
try {
|
||||
if (item.order.idProduct) {
|
||||
item.order.idProduct.productInfo = item.order.idProduct.productInfo ? item.order.idProduct.productInfo : { ...item.order.idProduct.idProductInfo };
|
||||
item.order.idProduct.productInfo.unitstr = tools.getUnitsMeasure(item.order.idProduct.productInfo.unit, true);
|
||||
item.order.idProduct.idProductInfo = item.order.idProduct.productInfo ? item.order.idProduct.productInfo._id : '';
|
||||
}
|
||||
const myid = item.order._id;
|
||||
// console.log('ID ORD', order.numorder, myid, order.user.name);
|
||||
item.order.product = { ...item.order.idProduct };
|
||||
item.order.idProduct = item.order.product ? item.order.product._id : '';
|
||||
item.order.producer = item.order.idProducer;
|
||||
item.order.idProducer = item.order.producer ? item.order.producer._id : '';
|
||||
item.order.storehouse = item.order.idStorehouse;
|
||||
item.order.idStorehouse = item.order.storehouse ? item.order.storehouse._id : '';
|
||||
item.order.provider = item.order.idProvider;
|
||||
item.order.idProvider = item.order.provider ? item.order.provider._id : '';
|
||||
item.order.gasordine = item.order.idGasordine;
|
||||
item.order.idGasordine = item.order.gasordine ? item.order.gasordine._id : '';
|
||||
item.order.scontisticas = item.order.scontisticas;
|
||||
item.order.idScontisticas = item.order.idScontisticas ? item.order.idScontisticas._id : '';
|
||||
} catch (e) {
|
||||
console.error('Err: ', e);
|
||||
}
|
||||
}
|
||||
return item;
|
||||
});
|
||||
return order;
|
||||
});
|
||||
|
||||
myorderscart = fixupdated(myorderscart);
|
||||
|
||||
/*
|
||||
let myquery = [
|
||||
{ $match: query }, // Match documents based on your query
|
||||
{
|
||||
$unwind: "$items"
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "orders", // Assuming the referenced collection is named "orders"
|
||||
localField: "items.order",
|
||||
foreignField: "_id",
|
||||
as: "items.order"
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: "$items.order",
|
||||
preserveNullAndEmptyArrays: true // Preserve items with no matching orders
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "products",
|
||||
localField: "items.order.idProduct",
|
||||
foreignField: "_id",
|
||||
as: "items.order.product"
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: "$items.order.product",
|
||||
preserveNullAndEmptyArrays: true // Preserve items with no matching orders
|
||||
}
|
||||
},
|
||||
// Populate 'items.order.idProduct.idProductInfo' with 'ProductInfo'
|
||||
{
|
||||
$lookup: {
|
||||
from: "productinfos",
|
||||
localField: "items.order.product.idProductInfo",
|
||||
foreignField: "_id",
|
||||
as: "items.order.product.productInfo"
|
||||
}
|
||||
},
|
||||
{ $unwind: "$items.order.product.productInfo" }, // Deconstruct the array
|
||||
|
||||
// Populate 'items.order.idProducer' with 'Producer'
|
||||
{
|
||||
$lookup: {
|
||||
from: "producers",
|
||||
localField: "items.order.product.IdProducer",
|
||||
foreignField: "_id",
|
||||
as: "items.order.producer"
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: "$items.order.producer",
|
||||
preserveNullAndEmptyArrays: true // Preserve items with no matching orders
|
||||
}
|
||||
},
|
||||
|
||||
// Populate 'items.order.idProvider' with 'Provider'
|
||||
{
|
||||
$lookup: {
|
||||
from: "providers",
|
||||
localField: "items.order.idProvider",
|
||||
foreignField: "_id",
|
||||
as: "items.order.provider"
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: "$items.order.provider",
|
||||
preserveNullAndEmptyArrays: true // Preserve items with no matching orders
|
||||
}
|
||||
},
|
||||
|
||||
// Populate 'items.order.idGasordine' with 'Gasordine'
|
||||
{
|
||||
$lookup: {
|
||||
from: "gasordines",
|
||||
localField: "items.order.idGasordine",
|
||||
foreignField: "_id",
|
||||
as: "items.order.gasordine"
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: "$items.order.gasordine",
|
||||
preserveNullAndEmptyArrays: true // Preserve items with no matching orders
|
||||
}
|
||||
},
|
||||
|
||||
// Populate 'items.order.idStorehouse' with 'Storehouse'
|
||||
{
|
||||
$lookup: {
|
||||
from: "storehouses",
|
||||
localField: "items.order.idStorehouse",
|
||||
foreignField: "_id",
|
||||
as: "items.order.storehouse"
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: "$items.order.storehouse",
|
||||
preserveNullAndEmptyArrays: true // Preserve items with no matching orders
|
||||
}
|
||||
},
|
||||
|
||||
// Populate 'items.order.idScontisticas' with 'Scontistica'
|
||||
{
|
||||
$lookup: {
|
||||
from: "scontisticas",
|
||||
localField: "items.order.product.idScontisticas",
|
||||
foreignField: "_id",
|
||||
as: "items.order.scontisticas"
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: "$items.order.scontisticas",
|
||||
preserveNullAndEmptyArrays: true // Preserve items with no matching orders
|
||||
}
|
||||
},
|
||||
|
||||
// Populate 'userId' with 'User'
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
localField: "userId",
|
||||
foreignField: "_id",
|
||||
as: "user"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
$unwind: {
|
||||
path: "$user",
|
||||
preserveNullAndEmptyArrays: true // Preserve items with no matching orders
|
||||
}
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: "$_id",
|
||||
}
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
_id: 1,
|
||||
'user.name': 1,
|
||||
'user.surname': 1,
|
||||
'user.username': 1,
|
||||
'user.profile': 1,
|
||||
'user.email': 1,
|
||||
'user.lang': 1,
|
||||
'totalQty': 1,
|
||||
'totalQtyPreordered': 1,
|
||||
'totalPrice': 1,
|
||||
"totalPriceCalc": 1,
|
||||
"confermato": 1,
|
||||
"pagato": 1,
|
||||
"spedito": 1,
|
||||
"consegnato": 1,
|
||||
"preparato": 1,
|
||||
"ricevuto": 1,
|
||||
"deleted": 1,
|
||||
"idapp": 1,
|
||||
"items": 1,
|
||||
"userId": 1,
|
||||
"status": 1,
|
||||
"note": 1,
|
||||
"numorder": 1,
|
||||
"numord_pers": 1,
|
||||
"created_at": 1,
|
||||
"modify_at": 1,
|
||||
}
|
||||
}
|
||||
return item;
|
||||
});
|
||||
return order;
|
||||
});
|
||||
];
|
||||
|
||||
myorderscart = fixupdated(myorderscart);
|
||||
// Project to select specific fields from 'User'
|
||||
/*{
|
||||
$project: {
|
||||
"_id": 1,
|
||||
"name": "$userId.name",
|
||||
"surname": "$userId.surname",
|
||||
"username": "$userId.username",
|
||||
"profile": "$userId.profile",
|
||||
"email": "$userId.email",
|
||||
"lang": "$userId.lang",
|
||||
"items": 1 // Include other fields as needed
|
||||
}
|
||||
}
|
||||
let myorderscart = await OrdersCart.aggregate(myquery);
|
||||
|
||||
*/
|
||||
|
||||
return myorderscart;
|
||||
|
||||
|
||||
// Optionally use toArray() to convert cursor to array
|
||||
return myorderscart;
|
||||
} catch (e) {
|
||||
console.error('err', e);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.getOrdersCartByUserId = async function (uid, idapp, numorder, filterStatus) {
|
||||
@@ -872,7 +1082,8 @@ module.exports.updateOrdersCartTotals = async function (idOrdersCart, update) {
|
||||
|
||||
let newOrdersCart = CartClass.constructByCart(orderscart);
|
||||
|
||||
await newOrdersCart.updatecarttotals(false);
|
||||
newOrdersCart.updatecarttotals(false);
|
||||
await newOrdersCart.updateExtraOrder();
|
||||
|
||||
if (update) {
|
||||
await OrdersCart.findOneAndUpdate({ _id: idOrdersCart }, {
|
||||
@@ -886,6 +1097,19 @@ module.exports.updateOrdersCartTotals = async function (idOrdersCart, update) {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/*
|
||||
for (const order of orderscart.items) {
|
||||
await Order.findOneAndUpdate({ _id: order.order._id }, {
|
||||
$set: {
|
||||
price: order.order.price,
|
||||
quantity: order.order.quantity,
|
||||
quantitypreordered: order.order.quantitypreordered,
|
||||
TotalPriceProduct: order.order.TotalPriceProduct,
|
||||
}
|
||||
})
|
||||
}*/
|
||||
|
||||
orderscart = await OrdersCart.getOrdersCartById(idOrdersCart);
|
||||
|
||||
return orderscart;
|
||||
@@ -918,12 +1142,17 @@ module.exports.getmsgorderTelegram = async function (ordersCart) {
|
||||
if (ord.order.quantitypreordered > 0)
|
||||
qtynum += ord.order.quantitypreordered;
|
||||
|
||||
qtystr += qtynum + ' ' + tools.getUnitsMeasure(ord.order.product.productInfo.unit, true);
|
||||
if (ord.order.product.productInfo.sfuso && ord.order.product.productInfo.weight)
|
||||
qtyrisult = qtynum * ord.order.product.productInfo.weight;
|
||||
else
|
||||
qtyrisult = qtynum + ' x ' + ord.order.product.productInfo.weight;
|
||||
|
||||
qtystr += qtyrisult + ' ' + tools.getUnitsMeasure(ord.order.product.productInfo.unit, true);
|
||||
|
||||
if (ord.order.quantitypreordered > 0)
|
||||
qtystr += ' Pre-Ordinati';
|
||||
|
||||
msg += '✅ [' + qtystr + '] ' + ord.order.product.productInfo.name + ' a ' + ord.order.price + '€ ' + (ord.order.after_price ? ord.order.after_price : '') + '<br>Totale = ' + ord.order.TotalPriceProduct + '€';
|
||||
msg += '✅ [' + qtystr + '] ' + ord.order.product.productInfo.name + ' a ' + ord.order.price + '€ ' + (ord.order.after_price ? ord.order.after_price : '') + '<br>Totale = ' + ord.order.TotalPriceProduct.toFixed(2) + '€';
|
||||
}
|
||||
|
||||
msg += '<br>';
|
||||
@@ -931,7 +1160,7 @@ module.exports.getmsgorderTelegram = async function (ordersCart) {
|
||||
let totqta = ordersCart.totalQty + ordersCart.totalQtyPreordered;
|
||||
|
||||
msg += '<br>Totale Prodotti: ' + totqta;
|
||||
msg += '<br>Totale Ordine: ' + ordersCart.totalPrice + ' € 💰';
|
||||
msg += '<br>Totale Ordine: ' + ordersCart.totalPrice.toFixed(2) + ' € 💰';
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -33,6 +33,9 @@ const productSchema = new Schema({
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
isbn: {
|
||||
type: String,
|
||||
},
|
||||
idProductInfo: { type: Schema.Types.ObjectId, ref: 'ProductInfo' },
|
||||
idProducer: { type: Schema.Types.ObjectId, ref: 'Producer' },
|
||||
idStorehouses: [
|
||||
@@ -53,6 +56,49 @@ const productSchema = new Schema({
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
arrvariazioni: [
|
||||
{
|
||||
active: {
|
||||
type: Boolean,
|
||||
},
|
||||
versione: {
|
||||
type: Number,
|
||||
},
|
||||
status: { //publish
|
||||
type: String,
|
||||
},
|
||||
price: {
|
||||
type: Number,
|
||||
},
|
||||
sale_price: {
|
||||
type: Number,
|
||||
},
|
||||
quantita: { // in magazzino
|
||||
type: Number,
|
||||
},
|
||||
numpages: {
|
||||
type: Number,
|
||||
},
|
||||
formato: {
|
||||
type: String,
|
||||
},
|
||||
tipologia: {
|
||||
type: String,
|
||||
},
|
||||
edizione: {
|
||||
type: String,
|
||||
},
|
||||
preOrderDate: {
|
||||
type: Date
|
||||
},
|
||||
addtocart_link: {
|
||||
type: String
|
||||
},
|
||||
eta: {
|
||||
type: String
|
||||
},
|
||||
}
|
||||
],
|
||||
price_acquistato: {
|
||||
type: Number,
|
||||
required: true,
|
||||
@@ -74,7 +120,6 @@ const productSchema = new Schema({
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
|
||||
stockQty: { // in magazzino
|
||||
type: Number,
|
||||
default: 0,
|
||||
@@ -182,6 +227,119 @@ module.exports.executeQueryTable = function (idapp, params) {
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
module.exports.executeQueryPickup = async function (idapp, params) {
|
||||
|
||||
let strfind = params.search;
|
||||
|
||||
strfind = strfind.replace(/[-@]/g, '');
|
||||
|
||||
if (strfind === '' && !params.filter) {
|
||||
return [];
|
||||
}
|
||||
|
||||
let filterfindexact = {};
|
||||
if (strfind) {
|
||||
filterfindexact = { comune: strfind };
|
||||
}
|
||||
|
||||
let limit = 10;
|
||||
let risexact = [];
|
||||
|
||||
let filterfind = {
|
||||
idapp,
|
||||
'productInfo.name': {
|
||||
$regex: `\\b${strfind}`, // Usa \\b per trovare solo le parole che iniziano con strfind
|
||||
$options: 'i' // Rendi la ricerca case-insensitive
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
let aggr1 = [
|
||||
{
|
||||
$lookup: {
|
||||
from: 'productinfos',
|
||||
localField: 'idProductInfo',
|
||||
foreignField: '_id',
|
||||
as: 'productInfo'
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'authors',
|
||||
localField: 'idAuthors',
|
||||
foreignField: '_id',
|
||||
as: 'authors'
|
||||
}
|
||||
},
|
||||
{
|
||||
$match: { 'productInfo.name': strfind },
|
||||
},
|
||||
{ $limit: 1 },
|
||||
{
|
||||
$project: {
|
||||
name: { $concat: ["$productInfo.name", " (", "$authors", ")"] },
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
if (params.filter) {
|
||||
filterfind = { ...params.filter, ...filterfind };
|
||||
limit = 200;
|
||||
} else {
|
||||
// risexact = await City.find(filterfindexact, {comune: 1, prov: 1, reg: 1}).lean();
|
||||
risexact = await City.aggregate(aggr1);
|
||||
}
|
||||
*/
|
||||
|
||||
if (params.filter) {
|
||||
filterfind = { ...params.filter, ...filterfind };
|
||||
limit = 200;
|
||||
}
|
||||
|
||||
let aggr2 = [
|
||||
{
|
||||
$lookup: {
|
||||
from: 'productinfos',
|
||||
localField: 'idProductInfo',
|
||||
foreignField: '_id',
|
||||
as: 'productInfo'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$productInfo',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'authors',
|
||||
localField: 'idAuthors',
|
||||
foreignField: '_id',
|
||||
as: 'authors'
|
||||
}
|
||||
},
|
||||
{
|
||||
$match: filterfind,
|
||||
},
|
||||
{ $limit: limit },
|
||||
{
|
||||
$project: {
|
||||
name: '$productInfo.name',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
// let ris = await City.find(filterfind, {comune: 1, prov: 1, reg: 1}).lean().limit(limit);
|
||||
let ris = await this.aggregate(aggr2).limit(limit);
|
||||
|
||||
return [...risexact, ...ris];
|
||||
|
||||
};
|
||||
|
||||
|
||||
module.exports.getProductByCode = function (idapp, code) {
|
||||
return Product.findAllIdApp(idapp, code);
|
||||
}
|
||||
@@ -320,12 +478,6 @@ module.exports.findAllIdApp = async function (idapp, code, id, all) {
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$producer',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'providers',
|
||||
@@ -342,18 +494,26 @@ module.exports.findAllIdApp = async function (idapp, code, id, all) {
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'catprods',
|
||||
localField: 'idCatProds',
|
||||
from: 'authors',
|
||||
localField: 'productInfo.idAuthors',
|
||||
foreignField: '_id',
|
||||
as: 'catprods'
|
||||
as: 'productInfo.authors'
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'catprods',
|
||||
localField: 'productInfo.idCatProds',
|
||||
foreignField: '_id',
|
||||
as: 'productInfo.catprods'
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'subcatprods',
|
||||
localField: 'idSubCatProds',
|
||||
localField: 'productInfo.idSubCatProds',
|
||||
foreignField: '_id',
|
||||
as: 'subcatprods'
|
||||
as: 'productInfo.subcatprods'
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -580,42 +740,65 @@ module.exports.convertAfterImportALLPROD = async function (idapp, dataObjects) {
|
||||
module.exports.getArrCatProds = async function (idapp, cosa) {
|
||||
|
||||
try {
|
||||
let addquery = {};
|
||||
let addquery = [];
|
||||
let arr = [];
|
||||
if (cosa === shared_consts.PROD.GAS) {
|
||||
addquery = { idapp, idGasordine: { $exists: true, $ne: null, $type: 'objectId' } }
|
||||
addquery = [
|
||||
{ $match: { idapp, idGasordine: { $exists: true, $ne: null, $type: 'objectId' } } }
|
||||
];
|
||||
|
||||
addquery.push(
|
||||
{
|
||||
$lookup: {
|
||||
from: 'gasordines',
|
||||
localField: 'idGasordine',
|
||||
foreignField: '_id',
|
||||
as: 'gasordine'
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
addquery.push(
|
||||
{
|
||||
$match: {
|
||||
"gasordine.active": true
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
} else if (cosa === shared_consts.PROD.BOTTEGA) {
|
||||
addquery = {
|
||||
idapp, $or: [
|
||||
{ idGasordine: { $exists: false } },
|
||||
{ idGasordine: { $exists: true, $eq: null } }
|
||||
]
|
||||
}
|
||||
addquery = [{
|
||||
$match: {
|
||||
idapp, $or: [
|
||||
{ idGasordine: { $exists: false } },
|
||||
{ idGasordine: { $exists: true, $eq: null } }
|
||||
]
|
||||
}
|
||||
}]
|
||||
} else {
|
||||
addquery = { idapp };
|
||||
addquery = [{ $match: { idapp } }];
|
||||
}
|
||||
|
||||
let myquery = [
|
||||
{ $match: addquery },
|
||||
{
|
||||
$lookup: {
|
||||
from: "productinfos",
|
||||
localField: "idProductInfo",
|
||||
foreignField: "_id",
|
||||
as: "productInfo",
|
||||
},
|
||||
let myquery = [...addquery,
|
||||
{
|
||||
$lookup: {
|
||||
from: "productinfos",
|
||||
localField: "idProductInfo",
|
||||
foreignField: "_id",
|
||||
as: "productInfo",
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "catprods",
|
||||
localField: "productInfo.idCatProds",
|
||||
foreignField: "_id",
|
||||
as: "category"
|
||||
}
|
||||
},
|
||||
{ $unwind: "$category" },
|
||||
{ $group: { _id: "$category._id", name: { $first: "$category.name" } } },
|
||||
{ $sort: { name: 1 } }
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "catprods",
|
||||
localField: "productInfo.idCatProds",
|
||||
foreignField: "_id",
|
||||
as: "category"
|
||||
}
|
||||
},
|
||||
{ $unwind: "$category" },
|
||||
{ $group: { _id: "$category._id", name: { $first: "$category.name" } } },
|
||||
{ $sort: { name: 1 } }
|
||||
];
|
||||
|
||||
arr = await Product.aggregate(myquery, (err, result) => {
|
||||
@@ -807,8 +990,8 @@ module.exports.singlerecconvert_AfterImport_AndSave = async function (idapp, pro
|
||||
|
||||
ris = await Product.updateOne({ _id: ObjectID(prod._id) }, { $unset: objDelete })
|
||||
|
||||
if (ris) {
|
||||
console.log('ris', ris);
|
||||
if (ris && ris.nModified > 0) {
|
||||
console.log('Modificato: ', objtoset.name);
|
||||
}
|
||||
|
||||
// const campodarimuovere = 'producer_name';
|
||||
|
||||
@@ -24,6 +24,9 @@ const productInfoSchema = new Schema({
|
||||
unique: true,
|
||||
required: true,
|
||||
},
|
||||
id_wp: { // id in wordpress
|
||||
type: String,
|
||||
},
|
||||
codice_EAN: {
|
||||
type: String,
|
||||
},
|
||||
@@ -36,39 +39,64 @@ const productInfoSchema = new Schema({
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
short_descr: {
|
||||
type: String,
|
||||
},
|
||||
idCatProds: [{ type: Schema.Types.ObjectId, ref: 'CatProd' }],
|
||||
idSubCatProds: [{ type: Schema.Types.ObjectId, ref: 'SubCatProd' }],
|
||||
color: {
|
||||
type: String
|
||||
},
|
||||
size: {
|
||||
type: String
|
||||
type: String // 11x4x3
|
||||
},
|
||||
weight: {
|
||||
type: Number
|
||||
},
|
||||
vegan: {
|
||||
type: Boolean
|
||||
weight_lordo: {
|
||||
type: Number
|
||||
},
|
||||
unit: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
unit_lordo: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
sfuso: { // serve se moltiplicare le qta (es: 12 kg) oppure fare (2 x 20 ml)
|
||||
type: Boolean
|
||||
},
|
||||
vegan: {
|
||||
type: Boolean
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
},
|
||||
img: {
|
||||
img: { // Se esiste img (sul server) visualizza questa, altrimenti vedi se esiste image_link
|
||||
type: String,
|
||||
},
|
||||
image_link: {
|
||||
type: String,
|
||||
},
|
||||
link_scheda: {
|
||||
type: String,
|
||||
},
|
||||
link: {
|
||||
type: String,
|
||||
},
|
||||
checkout_link: {
|
||||
type: String,
|
||||
},
|
||||
img2: {
|
||||
type: String,
|
||||
},
|
||||
img3: {
|
||||
type: String,
|
||||
},
|
||||
img4: {
|
||||
type: String,
|
||||
},
|
||||
ingredienti: {
|
||||
type: String,
|
||||
},
|
||||
@@ -78,6 +106,17 @@ const productInfoSchema = new Schema({
|
||||
note: {
|
||||
type: String,
|
||||
},
|
||||
idAuthors: [{ type: Schema.Types.ObjectId, ref: 'Author' }],
|
||||
idPublisher: { type: Schema.Types.ObjectId, ref: 'Publisher' },
|
||||
collezione: {
|
||||
type: String,
|
||||
},
|
||||
date_publishing: {
|
||||
type: Date,
|
||||
},
|
||||
productType: {
|
||||
type: Number,
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
@@ -132,6 +171,22 @@ module.exports.findAllIdApp = async function (idapp, code, id) {
|
||||
as: 'catprods'
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'authors',
|
||||
localField: 'idAuthors',
|
||||
foreignField: '_id',
|
||||
as: 'authors'
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'publishers',
|
||||
localField: 'idPublisher',
|
||||
foreignField: '_id',
|
||||
as: 'publisher'
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'subcatprods',
|
||||
|
||||
@@ -8,7 +8,7 @@ mongoose.level = 'F';
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
@@ -35,18 +35,25 @@ const ProvinceSchema = new Schema({
|
||||
link_grp: {
|
||||
type: String,
|
||||
},
|
||||
card : {
|
||||
card: {
|
||||
type: String,
|
||||
},
|
||||
|
||||
|
||||
link_telegram: {
|
||||
type: String,
|
||||
},
|
||||
}, { _id : false });
|
||||
lat: {
|
||||
type: Number,
|
||||
},
|
||||
long: {
|
||||
type: Number,
|
||||
},
|
||||
|
||||
}, { _id: false });
|
||||
|
||||
ProvinceSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
const myrec = await Province.findOne().limit(1).sort({_id:-1});
|
||||
const myrec = await Province.findOne().limit(1).sort({ _id: -1 });
|
||||
if (!!myrec) {
|
||||
if (myrec._doc._id === 0)
|
||||
this._id = 1;
|
||||
@@ -61,8 +68,8 @@ ProvinceSchema.pre('save', async function (next) {
|
||||
next();
|
||||
});
|
||||
|
||||
ProvinceSchema.statics.getRegionByStrProvince = async function(strprovince) {
|
||||
const myrec = await Province.findOne({prov: strprovince}).lean();
|
||||
ProvinceSchema.statics.getRegionByStrProvince = async function (strprovince) {
|
||||
const myrec = await Province.findOne({ prov: strprovince }).lean();
|
||||
if (myrec) {
|
||||
return myrec.reg;
|
||||
}
|
||||
@@ -70,8 +77,8 @@ ProvinceSchema.statics.getRegionByStrProvince = async function(strprovince) {
|
||||
return '';
|
||||
}
|
||||
|
||||
ProvinceSchema.statics.getStrProvinceByProv = async function(prov) {
|
||||
const myrec = await Province.findOne({prov}).lean();
|
||||
ProvinceSchema.statics.getStrProvinceByProv = async function (prov) {
|
||||
const myrec = await Province.findOne({ prov }).lean();
|
||||
if (myrec) {
|
||||
return myrec.descr;
|
||||
}
|
||||
@@ -79,14 +86,14 @@ ProvinceSchema.statics.getStrProvinceByProv = async function(prov) {
|
||||
return '';
|
||||
}
|
||||
|
||||
ProvinceSchema.statics.getFieldsForSearch = function() {
|
||||
ProvinceSchema.statics.getFieldsForSearch = function () {
|
||||
return [
|
||||
{field: 'prov', type: tools.FieldType.string},
|
||||
{field: 'descr', type: tools.FieldType.string},
|
||||
{ field: 'prov', type: tools.FieldType.string },
|
||||
{ field: 'descr', type: tools.FieldType.string },
|
||||
];
|
||||
};
|
||||
|
||||
ProvinceSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
ProvinceSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
|
||||
const strfind = params.search;
|
||||
@@ -98,7 +105,7 @@ ProvinceSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
return tools.executeQueryTable(this, 0, params);
|
||||
};
|
||||
|
||||
ProvinceSchema.statics.executeQueryPickup = async function(idapp, params) {
|
||||
ProvinceSchema.statics.executeQueryPickup = async function (idapp, params) {
|
||||
|
||||
const strfind = params.search;
|
||||
|
||||
@@ -106,12 +113,12 @@ ProvinceSchema.statics.executeQueryPickup = async function(idapp, params) {
|
||||
return [];
|
||||
}
|
||||
|
||||
let filterfindexact = {descr: strfind};
|
||||
let filterfindexact = { descr: strfind };
|
||||
const risexact = await Province.find(filterfindexact).lean();
|
||||
|
||||
let filterfind = {};
|
||||
|
||||
filterfind = {descr: {$regex: '^' + strfind, $options: 'i'}};
|
||||
filterfind = { descr: { $regex: '^' + strfind, $options: 'i' } };
|
||||
|
||||
const ris = await Province.find(filterfind).lean().limit(10);
|
||||
|
||||
@@ -119,16 +126,34 @@ ProvinceSchema.statics.executeQueryPickup = async function(idapp, params) {
|
||||
|
||||
};
|
||||
|
||||
ProvinceSchema.statics.findAllIdApp = async function(idapp) {
|
||||
ProvinceSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const myfind = {};
|
||||
|
||||
return Province.find(myfind).sort({descr: 1});
|
||||
return Province.find(myfind).sort({ descr: 1 });
|
||||
};
|
||||
|
||||
ProvinceSchema.statics.setCoordinatesOnDB = async function () {
|
||||
|
||||
const arrprov = await Province.find({}).lean();
|
||||
|
||||
// Funzione per ottenere le coordinate di tutte le città
|
||||
for (const prov of arrprov) {
|
||||
if (!prov.lat) {
|
||||
let coord = await tools.getCityCoordinates(prov);
|
||||
if (coord) {
|
||||
let ris = await Province.findOneAndUpdate({ _id: prov._id }, { $set: { lat: coord.lat, long: coord.long } }, { new: true });
|
||||
console.log(' *** Update ', prov.descr, 'lat', ris.lat, 'long', ris.long);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const Province = mongoose.model('Province', ProvinceSchema);
|
||||
|
||||
Province.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = {Province};
|
||||
module.exports = { Province };
|
||||
|
||||
50
src/server/models/publisher.js
Executable file
50
src/server/models/publisher.js
Executable file
@@ -0,0 +1,50 @@
|
||||
mongoose = require('mongoose').set('debug', false)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const PublisherSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
},
|
||||
link: {
|
||||
type: String,
|
||||
},
|
||||
img: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
var Publisher = module.exports = mongoose.model('Publisher', PublisherSchema);
|
||||
|
||||
module.exports.getFieldsForSearch = function () {
|
||||
return [
|
||||
{ field: 'name', type: tools.FieldType.string },
|
||||
]
|
||||
};
|
||||
|
||||
module.exports.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
module.exports.findAllIdApp = async function (idapp) {
|
||||
const myfind = { idapp };
|
||||
|
||||
return await Publisher.find(myfind);
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
@@ -20,6 +20,10 @@ const searchSchema = new Schema({
|
||||
userId: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
default: Date.now,
|
||||
},
|
||||
text: {
|
||||
type: String,
|
||||
},
|
||||
|
||||
@@ -161,18 +161,32 @@ sendNotifSchema.statics.getRecNotif = function (id) {
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function (username, lastdataread, idapp, limitrecord) {
|
||||
sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function (username, lastdataread, idapp, limitrecord, qualinotif, arroptionfilter) {
|
||||
const SendNotif = this;
|
||||
|
||||
if (!lastdataread)
|
||||
lastdataread = 0;
|
||||
|
||||
let arrfilter = [
|
||||
{ idapp },
|
||||
{ dest: username },
|
||||
{ datenotif: { $gt: new Date(lastdataread) } }
|
||||
];
|
||||
|
||||
if (qualinotif) {
|
||||
if (qualinotif === shared_consts.QualiNotifs.CIRCUITS) {
|
||||
arrfilter.push({ typedir: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS });
|
||||
} else {
|
||||
arrfilter.push({ typedir: { $ne: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS } });
|
||||
}
|
||||
}
|
||||
|
||||
if (arroptionfilter) {
|
||||
arrfilter = [...arrfilter, ...arroptionfilter];
|
||||
}
|
||||
|
||||
return SendNotif.find({
|
||||
$and: [
|
||||
{ idapp },
|
||||
{ 'dest': username },
|
||||
{ 'datenotif': { $gt: new Date(lastdataread) } },
|
||||
],
|
||||
$and: arrfilter,
|
||||
}).lean().limit(limitrecord).sort({ datenotif: -1 }).then(async (arrnotif) => {
|
||||
// console.log('arrnotif', arrnotif.length);
|
||||
|
||||
@@ -204,20 +218,27 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
}
|
||||
|
||||
if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_BACHECA) {
|
||||
let tablerec = '';
|
||||
if (recnotif.typeid === shared_consts.TypeNotifs.ID_BACHECA_NEW_GOOD) {
|
||||
newdescr = i18n.__('NEW_GOOD', userorig, mydescr);
|
||||
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYGOODS, true) + myidrec;
|
||||
tag = 'newgood';
|
||||
tablerec = 'mygoods';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_BACHECA_NEW_SERVICE) {
|
||||
newdescr = i18n.__('NEW_SERVICE', userorig, mydescr);
|
||||
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYSKILLS, true) + myidrec;
|
||||
tag = 'newservice';
|
||||
tablerec = 'myskills';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_BACHECA_NEW_HOSP) {
|
||||
newdescr = i18n.__('NEW_HOSP', userorig, mydescr);
|
||||
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYHOSPS, true) + myidrec;
|
||||
tag = 'newhosp';
|
||||
tablerec = 'myhosps';
|
||||
}
|
||||
recnotif.linkaddTelegram = 'Vedi annuncio';
|
||||
let eventobj = await tools.getAnnuncioForTelegram(recnotif.myrectableorig, tablerec, mydescr, userorig, true);
|
||||
newdescr = eventobj.newdescr;
|
||||
recnotif.textcontent_Telegram = eventobj.newdescrtelegram;
|
||||
recnotif.linkaddTelegram = '';
|
||||
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_EVENTS) {
|
||||
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYBACHECAS, true) + myidrec;
|
||||
tag = 'newevent';
|
||||
@@ -605,6 +626,7 @@ sendNotifSchema.statics.findLastNotifsByUserIdAndIdApp = function (username, ida
|
||||
$match: {
|
||||
idapp,
|
||||
dest: username,
|
||||
typedir: { $ne: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS },
|
||||
},
|
||||
},
|
||||
{ $limit: limit },
|
||||
@@ -620,6 +642,38 @@ sendNotifSchema.statics.findLastNotifsByUserIdAndIdApp = function (username, ida
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.findLastNotifCoinsByUserIdAndIdApp = function (username, idapp, limit, inattesa) {
|
||||
const SendNotif = this;
|
||||
|
||||
let filter = {
|
||||
idapp,
|
||||
typedir: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS,
|
||||
dest: username,
|
||||
}
|
||||
|
||||
if (inattesa) {
|
||||
filter.status = 0;
|
||||
} else {
|
||||
filter.status = { $ne: 0 };
|
||||
}
|
||||
|
||||
return SendNotif.aggregate([
|
||||
{
|
||||
$match: filter,
|
||||
},
|
||||
{ $limit: limit },
|
||||
{
|
||||
$sort: { datenotif: -1 },
|
||||
},
|
||||
]).then(async (arrnotif) => {
|
||||
return this.compileOtherFields(arrnotif);
|
||||
|
||||
}).catch((err) => {
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.saveAndSendNotif = async function (myrecnotif, req, res, user) {
|
||||
const SendNotif = this;
|
||||
|
||||
@@ -1090,18 +1144,18 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
|
||||
}
|
||||
|
||||
}
|
||||
/*} else if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
|
||||
if (shared_consts.TABLES_GROUPS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
|
||||
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.GroupsNotifs.STATUS_GROUPS_NEW)) {
|
||||
send = true;
|
||||
/*} else if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
|
||||
if (shared_consts.TABLES_GROUPS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
|
||||
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.GroupsNotifs.STATUS_GROUPS_NEW)) {
|
||||
send = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS) {
|
||||
if (shared_consts.TABLES_CIRCUITS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
|
||||
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.CircuitsNotif.STATUS_NEW)) {
|
||||
send = true;
|
||||
}
|
||||
}*/
|
||||
} else if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS) {
|
||||
if (shared_consts.TABLES_CIRCUITS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
|
||||
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.CircuitsNotif.STATUS_NEW)) {
|
||||
send = true;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
if (send) {
|
||||
@@ -1146,16 +1200,19 @@ sendNotifSchema.statics.getSumPendingTransactionsMittente = async function (idap
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
const query = {
|
||||
let query = {
|
||||
idapp,
|
||||
sender: username,
|
||||
sendergroup: groupname,
|
||||
typedir: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS,
|
||||
typeid: shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ,
|
||||
status: 0,
|
||||
'extrarec.circuitname': circuitname,
|
||||
};
|
||||
|
||||
if (groupname) {
|
||||
query.sendergroup = groupname;
|
||||
}
|
||||
|
||||
return await SendNotif.find(query).lean();
|
||||
|
||||
} catch (e) {
|
||||
@@ -1168,18 +1225,21 @@ sendNotifSchema.statics.getSumPendingTransactionsDest = async function (idapp, u
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
const query = {
|
||||
let query = {
|
||||
idapp,
|
||||
sender: username,
|
||||
sendergroup: groupname,
|
||||
typedir: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS,
|
||||
typeid: shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ,
|
||||
status: 0,
|
||||
'extrarec.circuitname': circuitname,
|
||||
'extrarec.dest': username,
|
||||
'extrarec.groupdest': groupname,
|
||||
};
|
||||
|
||||
if (groupname) {
|
||||
query.sendergroup = groupname;
|
||||
query.extrarec.groupdest = groupname;
|
||||
}
|
||||
|
||||
return await SendNotif.find(query).lean();
|
||||
|
||||
} catch (e) {
|
||||
|
||||
@@ -139,6 +139,7 @@ const SiteSchema = new Schema({
|
||||
enableTodos: { type: Boolean, default: false },
|
||||
enableRegByBot: { type: Boolean, default: false },
|
||||
enableRegMultiChoice: { type: Boolean, default: false },
|
||||
enableTokenExpired: { type: Boolean, default: false },
|
||||
enableDebugOn: { type: Boolean, default: false },
|
||||
enabledRegNeedTelegram: { type: Boolean, default: false },
|
||||
showViewEventi: { type: Boolean, default: false },
|
||||
@@ -189,6 +190,7 @@ const SiteSchema = new Schema({
|
||||
},
|
||||
ecomm: {
|
||||
enablePreOrders: { type: Boolean, default: false },
|
||||
NoteExtraOnCart: { type: String, default: '' },
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -56,10 +56,14 @@ const UserSchema = new mongoose.Schema({
|
||||
message: '{VALUE} is not a valid email'
|
||||
}*/
|
||||
},
|
||||
hash: {
|
||||
type: String,
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
|
||||
group: {
|
||||
type: Number,
|
||||
},
|
||||
@@ -120,6 +124,10 @@ const UserSchema = new mongoose.Schema({
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
refreshToken: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
date_login: {
|
||||
type: Date,
|
||||
},
|
||||
@@ -130,6 +138,9 @@ const UserSchema = new mongoose.Schema({
|
||||
ipaddr: {
|
||||
type: String,
|
||||
},
|
||||
banIp: {
|
||||
type: Boolean,
|
||||
},
|
||||
date_reg: {
|
||||
type: Date,
|
||||
},
|
||||
@@ -164,6 +175,12 @@ const UserSchema = new mongoose.Schema({
|
||||
news_on: {
|
||||
type: Boolean,
|
||||
},
|
||||
email_errata: {
|
||||
type: Boolean,
|
||||
},
|
||||
lastid_newstosent: {
|
||||
type: String
|
||||
},
|
||||
aportador_solidario: { // da cancellare
|
||||
type: String,
|
||||
},
|
||||
@@ -518,8 +535,21 @@ UserSchema.methods.generateAuthToken = function (req) {
|
||||
const access = 'auth';
|
||||
const browser = useragent;
|
||||
const prova = 'PROVAMSG@1A'
|
||||
const token = jwt.sign({ _id: prova, smart: user._id.toHexString(), access, un: user.username },
|
||||
process.env.SIGNCODE).toString();
|
||||
let attiva_scadenza = user.idapp ? tools.getEnableTokenExpiredByIdApp(user.idapp) : false;
|
||||
|
||||
let token = null;
|
||||
|
||||
let numsec = process.env.TOKEN_LIFE;
|
||||
|
||||
if (attiva_scadenza)
|
||||
token = jwt.sign({ _id: prova, smart: user._id.toHexString(), access, un: user.username },
|
||||
process.env.SIGNCODE, { expiresIn: numsec }).toString();
|
||||
else
|
||||
token = jwt.sign({ _id: prova, smart: user._id.toHexString(), access, un: user.username },
|
||||
process.env.SIGNCODE).toString();
|
||||
|
||||
const refreshToken = jwt.sign({ _id: prova, smart: user._id.toHexString(), access, un: user.username },
|
||||
process.env.SECRK, { expiresIn: process.env.REFRESH_TOKEN_LIFE }).toString();
|
||||
const date_login = new Date();
|
||||
|
||||
// CANCELLA IL PRECEDENTE !
|
||||
@@ -527,15 +557,18 @@ UserSchema.methods.generateAuthToken = function (req) {
|
||||
return (tok.access !== access) ||
|
||||
((tok.access === access) && (tok.browser !== browser));
|
||||
});
|
||||
user.tokens.push({ access, browser, token, date_login });
|
||||
|
||||
user.tokens.push({ access, browser, token, date_login, refreshToken });
|
||||
|
||||
user.lasttimeonline = new Date();
|
||||
|
||||
return user.save().then(() => {
|
||||
// console.log('Salvato refreshToken su DB', refreshToken);
|
||||
// console.log("TOKEN CREATO IN LOGIN : " + token);
|
||||
return token;
|
||||
return { token, refreshToken };
|
||||
}).catch(err => {
|
||||
console.log('Error', err.message);
|
||||
return { token: '', refreshToken: '' }
|
||||
});
|
||||
};
|
||||
|
||||
@@ -675,21 +708,57 @@ UserSchema.statics.isFacilitatore = function (perm) {
|
||||
}
|
||||
};
|
||||
|
||||
UserSchema.statics.findByToken = function (token, typeaccess) {
|
||||
UserSchema.statics.findByToken = async function (token, typeaccess, con_auth) {
|
||||
const User = this;
|
||||
let decoded;
|
||||
let code = server_constants.RIS_CODE_HTTP_INVALID_TOKEN;
|
||||
let user = null;
|
||||
|
||||
try {
|
||||
decoded = jwt.verify(token, process.env.SIGNCODE);
|
||||
if (token) {
|
||||
decoded = jwt.verify(token, process.env.SIGNCODE);
|
||||
|
||||
code = server_constants.RIS_CODE_OK;
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
return Promise.resolve(null);
|
||||
|
||||
if (e.expiredAt) {
|
||||
|
||||
code = server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED;
|
||||
if (con_auth) {
|
||||
return { user: null, code };
|
||||
}
|
||||
} else {
|
||||
console.error('Err findByToken:', e);
|
||||
}
|
||||
}
|
||||
|
||||
return User.findOne({
|
||||
'_id': decoded.smart,
|
||||
'tokens.token': token,
|
||||
'tokens.access': typeaccess,
|
||||
});
|
||||
if (code === server_constants.RIS_CODE_OK) {
|
||||
user = await User.findOne({
|
||||
'_id': decoded.smart,
|
||||
'tokens.token': token,
|
||||
'tokens.access': typeaccess,
|
||||
});
|
||||
|
||||
if (user) {
|
||||
let check_expiry_date = false
|
||||
// Controlla se il sito ha attivo il controllo del Token Scaduto
|
||||
if (tools.getEnableTokenExpiredByIdApp(user.idapp)) {
|
||||
check_expiry_date = true
|
||||
}
|
||||
|
||||
if (check_expiry_date && (decoded.exp < Date.now() / 1000)) {
|
||||
console.log('Il token è scaduto, generazione del nuovo token...');
|
||||
code = server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED;
|
||||
} else {
|
||||
// TOKEN ANCORA VALIDO
|
||||
code = server_constants.RIS_CODE_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { user, code };
|
||||
};
|
||||
|
||||
UserSchema.statics.findByTokenAnyAccess = function (token) {
|
||||
@@ -699,6 +768,7 @@ UserSchema.statics.findByTokenAnyAccess = function (token) {
|
||||
try {
|
||||
decoded = jwt.verify(token, process.env.SIGNCODE);
|
||||
} catch (e) {
|
||||
console.error('Err findByTokenAnyAccess:', e);
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
@@ -806,6 +876,57 @@ UserSchema.statics.findByUsername = async function (idapp, username, alsoemail,
|
||||
return rec;
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Find a user by their Telegram username.
|
||||
*
|
||||
* @param {string} idapp - The application ID
|
||||
* @param {string} username - The Telegram username
|
||||
* @param {boolean} alsoemail - Flag to indicate if email should also be considered
|
||||
* @param {boolean} onlyifVerifiedByAportador - Flag to indicate if only verified users should be returned
|
||||
* @return {Promise} A Promise that resolves to the found user or null
|
||||
**/
|
||||
|
||||
UserSchema.statics.findByUsernameTelegram = async function (idapp, username, alsoemail, onlyifVerifiedByAportador) {
|
||||
const User = this;
|
||||
|
||||
if (username && username[0] === '@') {
|
||||
username = username.substring(1);
|
||||
}
|
||||
|
||||
const myreg = ['^', username, '$'].join('');
|
||||
let regexusername = new RegExp(myreg, 'i');
|
||||
|
||||
//++TODO: Set only the necessary fields to get in memory
|
||||
|
||||
return await User.findOne({
|
||||
idapp: idapp,
|
||||
'profile.username_telegram': { $regex: regexusername },
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
}).then(async (ris) => {
|
||||
if ((!ris) && (alsoemail)) {
|
||||
regexemail = new RegExp(['^', username.toLowerCase(), '$'].join(''), 'i');
|
||||
|
||||
return await User.findOne({
|
||||
'idapp': idapp,
|
||||
'email': { $regex: regexemail },
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
});
|
||||
}
|
||||
return ris;
|
||||
}).then((rec) => {
|
||||
if (rec && onlyifVerifiedByAportador) {
|
||||
if (tools.getAskToVerifyReg(idapp)) {
|
||||
if (!rec.verified_by_aportador)
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return rec;
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.getProjectUser = function () {
|
||||
return {
|
||||
@@ -1146,6 +1267,70 @@ UserSchema.statics.setaportador_solidario = async function (
|
||||
return !!myrec;
|
||||
};
|
||||
|
||||
UserSchema.statics.setNewsletter = async function (
|
||||
idapp, username, newsletter_on) {
|
||||
const User = this;
|
||||
|
||||
if (username === undefined)
|
||||
return false;
|
||||
|
||||
const myquery = {
|
||||
'idapp': idapp,
|
||||
'username': username,
|
||||
};
|
||||
|
||||
const myrec = await User.findOneAndUpdate(myquery,
|
||||
{ $set: { 'news_on': newsletter_on } }, { new: false });
|
||||
|
||||
return !!myrec;
|
||||
};
|
||||
|
||||
UserSchema.statics.setEmailErrata = async function (
|
||||
idapp, username, email_errata) {
|
||||
const User = this;
|
||||
|
||||
if (username === undefined)
|
||||
return false;
|
||||
|
||||
const myquery = {
|
||||
'idapp': idapp,
|
||||
'username': username,
|
||||
};
|
||||
|
||||
const myrec = await User.findOneAndUpdate(myquery,
|
||||
{ $set: { email_errata } }, { new: false });
|
||||
|
||||
return !!myrec;
|
||||
};
|
||||
|
||||
UserSchema.statics.isEmailErrata = async function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({
|
||||
idapp, username,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
}).then((rec) => {
|
||||
return ((rec) ? rec.email_errata : false);
|
||||
}).catch((e) => {
|
||||
return false;
|
||||
});
|
||||
};
|
||||
UserSchema.statics.isNewsletterOn = async function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({
|
||||
idapp, username,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
}).then((rec) => {
|
||||
return ((rec) ? rec.news_on : false);
|
||||
}).catch((e) => {
|
||||
console.error('isNewsletterOn', e);
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
UserSchema.statics.setVerifiedByAportadorToALL = async function () {
|
||||
|
||||
return await User.updateMany({}, { $set: { 'verified_by_aportador': true } },
|
||||
@@ -1383,6 +1568,7 @@ UserSchema.statics.createNewReqRegistrationGetLink = async function (idapp, user
|
||||
// Se è scaduto, ne crea uno nuovo
|
||||
// Creo il tokenforgot
|
||||
|
||||
/*
|
||||
if (!user.date_tokenreg || (!user.tokenreg) || (user.tokenreg && (user.date_tokenreg < new Date().getTime()))) {
|
||||
|
||||
let mycodestr = user._id.toHexString() + new Date().getTime().toString();
|
||||
@@ -1401,11 +1587,14 @@ UserSchema.statics.createNewReqRegistrationGetLink = async function (idapp, user
|
||||
}
|
||||
|
||||
user.date_tokenreg = tools.AddDate(new Date(), 1);
|
||||
|
||||
|
||||
return await user.save().then(() => {
|
||||
return user.tokenreg;
|
||||
});
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1523,6 +1712,27 @@ UserSchema.methods.removeToken = function (token) {
|
||||
});
|
||||
};
|
||||
|
||||
// TODO: Cancellare i token che non hanno refreshToken, ad esempio quando l'utente esce dal browser
|
||||
// TODO: Cancellare i token con data_login meno di 2 giorni fa, per esempio se l'utente si è disconnesso dal browser ma è ancora online
|
||||
|
||||
UserSchema.statics.SvuotaTuttiGliAccessiOnlineConToken = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
return await User.updateMany({ idapp },
|
||||
{
|
||||
$pull: {
|
||||
tokens:
|
||||
{
|
||||
$or: [{ refreshToken: { $exists: false } },
|
||||
{ refreshToken: { $exists: true, $eq: '' } }
|
||||
]
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
UserSchema.statics.getEmailByUsername = async function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
@@ -1549,6 +1759,19 @@ UserSchema.statics.getUsernameById = async function (idapp, id) {
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsernameByEmail = async function (idapp, email) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({
|
||||
idapp, email,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
}, { username: 1 }).then((myuser) => {
|
||||
return ((myuser) ? myuser.username : '');
|
||||
}).catch((e) => {
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.getUserById = function (idapp, id) {
|
||||
const User = this;
|
||||
|
||||
@@ -1568,6 +1791,20 @@ UserSchema.statics.getUserByUsername = function (idapp, username) {
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.getUserByUsernameTelegram = function (idapp, username_telegram) {
|
||||
const User = this;
|
||||
|
||||
if (username_telegram[0] === '@') {
|
||||
username_telegram = username_telegram.substring(1);
|
||||
}
|
||||
|
||||
return User.findOne({
|
||||
idapp,
|
||||
'profile.username_telegram': username_telegram,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.isMyFriend = async function (idapp, username, myusername) {
|
||||
|
||||
const myfriends = await User.getUsernameFriendsByUsername(idapp, myusername);
|
||||
@@ -1638,8 +1875,8 @@ UserSchema.statics.getUserProfileByUsername = async function (
|
||||
'profile.username_telegram': 1,
|
||||
'profile.firstname_telegram': 1,
|
||||
'profile.lastname_telegram': 1,
|
||||
'profile.intcode_cell': 1,
|
||||
'profile.cell': 1,
|
||||
// 'profile.intcode_cell': 1,
|
||||
// 'profile.cell': 1,
|
||||
'profile.website': 1,
|
||||
'profile.img': 1,
|
||||
'profile.sex': 1,
|
||||
@@ -1937,6 +2174,14 @@ UserSchema.statics.removeFromCircuits = async function (idapp, username, circuit
|
||||
const circuitId = await Circuit.getCircuitIdByName(idapp, circuitname);
|
||||
let remove = false;
|
||||
|
||||
const circuit = await Circuit.findOne({ idapp, name: circuitname }).lean();
|
||||
if (circuit) {
|
||||
// Invio la notifica agli amministratori del circuito
|
||||
const title = `L\'utente ${username} è uscito dal ${circuitname}`;
|
||||
const msg = ``;
|
||||
await tools.sendNotifToCircuitsAdmin(idapp, circuit, true, title, msg, '')
|
||||
}
|
||||
|
||||
// Se il mio account non è stato utilizzato, allora lo cancello anche questo
|
||||
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false, false, '', '');
|
||||
if (myaccount && myaccount.totTransato === 0) {
|
||||
@@ -1971,15 +2216,20 @@ UserSchema.statics.addCircuitToUser = async function (idapp, usernameOrig, circu
|
||||
|
||||
} else {
|
||||
|
||||
// prima di aggiungerlo controlla se esiste già !
|
||||
|
||||
let update = {
|
||||
$push: {
|
||||
$addToSet: { // Utilizziamo $addToSet invece di $push per garantire che l'elemento venga aggiunto solo se non esiste già
|
||||
'profile.mycircuits': {
|
||||
circuitname,
|
||||
date: new Date(),
|
||||
},
|
||||
},
|
||||
$each: [{
|
||||
circuitname,
|
||||
date: new Date(),
|
||||
}],
|
||||
}
|
||||
}
|
||||
};
|
||||
ris = await User.updateOne({ idapp, username: usernameOrig }, update);
|
||||
|
||||
ris = await User.updateOne({ idapp, username: usernameOrig, 'profile.mycircuits': { $not: { $elemMatch: { circuitname } } } }, update);
|
||||
|
||||
if (confido) {
|
||||
// Elimina la richiesta:
|
||||
@@ -2230,6 +2480,10 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const already_stretta = await User.isMyHandShake(idapp, usernameDest, usernameOrig);
|
||||
const already_stretta_orig = await User.isMyHandShake(idapp, usernameOrig, usernameDest);
|
||||
|
||||
rec = await User.updateOne({ idapp, username: usernameDest }, update);
|
||||
|
||||
tools.sendNotificationByUsername(idapp, usernameDest, cmd, true, usernameOrig);
|
||||
@@ -2240,8 +2494,11 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
|
||||
if (!disablenotif) {
|
||||
const userDest = await User.getRecLangAndIdByUsername(idapp, usernameDest);
|
||||
const user = await User.getRecLangAndIdByUsername(idapp, usernameOrig);
|
||||
const already_stretta = await User.isMyHandShake(idapp, usernameDest, usernameOrig);
|
||||
const msgDest = i18n.__({ phrase: 'HANDSHAKE_CONFIRMED', locale: userDest.lang }, usernameDest);
|
||||
|
||||
let msgDest = i18n.__({ phrase: 'HANDSHAKE_SENT_FROM_YOU', locale: userDest.lang }, usernameDest);
|
||||
if (already_stretta)
|
||||
msgDest = i18n.__({ phrase: 'HANDSHAKE_CONFIRMED', locale: userDest.lang }, usernameDest);
|
||||
|
||||
let phrase = 'HANDSHAKE_SET';
|
||||
if (already_stretta) {
|
||||
phrase = 'HANDSHAKE_ACCEPTED';
|
||||
@@ -2516,6 +2773,19 @@ UserSchema.statics.ifAlreadyInCircuit = async function (idapp, usernameOrig, cir
|
||||
}).lean();
|
||||
};
|
||||
|
||||
//** Get true if in 'profile.mycircuits' exist at least one circuit */
|
||||
UserSchema.statics.ExistAtLeastOneCircuit = async function (idapp, username) {
|
||||
|
||||
// Controllo se è stato più inserito
|
||||
return await User.countDocuments({
|
||||
idapp,
|
||||
username,
|
||||
'profile.mycircuits': {
|
||||
$ne: [],
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.countUsersInGroup = async function (idapp, groupnameDest) {
|
||||
|
||||
// Controllo se è stato già inserito
|
||||
@@ -3011,7 +3281,8 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
|
||||
}
|
||||
|
||||
outres.recnotif = await SendNotif.getRecNotif(extrarec.notifId);
|
||||
outres.arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(username_action, extrarec.lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER);
|
||||
outres.arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(username_action, extrarec.lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER, shared_consts.QualiNotifs.OTHERS);
|
||||
outres.arrrecnotifcoins = await SendNotif.findAllNotifByUsernameIdAndIdApp(username_action, extrarec.lastdr, idapp, shared_consts.LIMIT_NOTIFCOINS_FOR_USER, shared_consts.QualiNotifs.CIRCUITS);
|
||||
|
||||
} else {
|
||||
outres.cansend = false;
|
||||
@@ -4191,6 +4462,7 @@ UserSchema.statics.getLastOnlineUsers = async function (idapp) {
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
date_reg: 1,
|
||||
verified_by_aportador: 1,
|
||||
'profile.img': 1,
|
||||
index: 1,
|
||||
}).sort({ lasttimeonline: -1 }).limit(lastn).then((arr) => {
|
||||
@@ -4217,6 +4489,7 @@ UserSchema.statics.getLastSharedLink = async function (idapp) {
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
verified_by_aportador: 1,
|
||||
date_reg: 1,
|
||||
'profile.img': 1,
|
||||
index: 1,
|
||||
@@ -4370,6 +4643,47 @@ UserSchema.statics.getUsersRegDaily = function (idapp, nrec) {
|
||||
return query;
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersRegDailyAverage = function (idapp, nrec) {
|
||||
const query = [
|
||||
{
|
||||
$match: {
|
||||
idapp,
|
||||
date_reg: { $gte: tools.IncDateNow(-(1000 * 60 * 60 * 24 * nrec)) },
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: {
|
||||
$dateToString: {
|
||||
format: '%Y-%m-%d',
|
||||
date: '$date_reg',
|
||||
timezone: 'Europe/Rome',
|
||||
},
|
||||
},
|
||||
count: { $sum: 1 },
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: null,
|
||||
total: { $sum: '$count' },
|
||||
days: { $sum: 1 },
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
_id: 0,
|
||||
dailyAverage: { $divide: ['$total', '$days'] },
|
||||
},
|
||||
},
|
||||
];
|
||||
return query;
|
||||
};
|
||||
|
||||
UserSchema.statics.getQueryUsersDiffusori = function (idapp) {
|
||||
|
||||
const query = [
|
||||
@@ -4461,6 +4775,7 @@ UserSchema.statics.getQueryUsersDiffusori = function (idapp) {
|
||||
idapp: 1,
|
||||
"profile.img": 1,
|
||||
'profile.mycircuits': 1,
|
||||
'profile.handshake': 1,
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -4668,6 +4983,19 @@ UserSchema.statics.getUsersRegWeekly = function (idapp, nrec) {
|
||||
count: { $sum: 1 },
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: null, // Raggruppa tutti i risultati
|
||||
total: { $sum: '$count' }, // Calcola il numero totale di iscritti
|
||||
days: { $sum: 1 }, // Calcola il numero totale di giorni
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
_id: 0, // Escludi il campo _id dal risultato finale
|
||||
dailyAverage: { $divide: ['$total', '$days'] }, // Calcola la media giornaliera
|
||||
},
|
||||
},
|
||||
{
|
||||
$sort: { _id: 1 },
|
||||
},
|
||||
@@ -4715,6 +5043,36 @@ UserSchema.statics.calcnumRegUntilDay = async function (idapp) {
|
||||
|
||||
};
|
||||
|
||||
function calculate30DayAverage(data) {
|
||||
const averages = [];
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const startDate = new Date(data[i]._id);
|
||||
let sum = data[i].count;
|
||||
let count = 1;
|
||||
|
||||
for (let j = i + 1; j < data.length; j++) {
|
||||
const currentDate = new Date(data[j]._id);
|
||||
const diffInTime = Math.abs(startDate.getTime() - currentDate.getTime());
|
||||
const diffInDays = Math.ceil(diffInTime / (1000 * 60 * 60 * 24));
|
||||
|
||||
if (diffInDays <= 30) {
|
||||
sum += data[j].count;
|
||||
count++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
averages.push({
|
||||
_id: data[i]._id,
|
||||
dailyAverage: sum / count
|
||||
});
|
||||
}
|
||||
|
||||
return averages;
|
||||
}
|
||||
|
||||
UserSchema.statics.calcRegDaily = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
@@ -4724,12 +5082,14 @@ UserSchema.statics.calcRegDaily = async function (idapp) {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
UserSchema.statics.calcRegWeekly = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
return await User.aggregate(User.getUsersRegWeekly(idapp, 20 * 7)).then(ris => {
|
||||
return await User.aggregate(User.getUsersRegDaily(idapp, 120)).then(ris => {
|
||||
// console.table(ris);
|
||||
return ris.slice(0, -1);
|
||||
return calculate30DayAverage(ris);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -5019,6 +5379,25 @@ UserSchema.statics.getExtraInfoByUsername = async function (idapp, username) {
|
||||
return null;
|
||||
|
||||
};
|
||||
UserSchema.statics.getProfilePerActivitiesByUsername = async function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
try {
|
||||
let myuser = await User.findOne({ idapp, username }).lean();
|
||||
if (myuser) {
|
||||
return {
|
||||
mygroups: myuser.profile.mygroups,
|
||||
mycircuits: myuser.profile.mycircuits
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('e', e);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.addExtraInfo = async function (idapp, recUser, recUserSave, version) {
|
||||
|
||||
try {
|
||||
@@ -5343,6 +5722,25 @@ UserSchema.statics.tooManyReqPassword = async function (idapp, email, set) {
|
||||
}
|
||||
|
||||
};
|
||||
UserSchema.statics.tooManyLoginWrong = async function (idapp, username, set) {
|
||||
const User = this;
|
||||
|
||||
const maxnum = 30;
|
||||
|
||||
const user = await User.findByUsername(idapp, username, true, false);
|
||||
if (user) {
|
||||
if (!user.retry_pwd)
|
||||
user.retry_pwd = 0
|
||||
if (set && user.retry_pwd <= maxnum) {
|
||||
user.retry_pwd++;
|
||||
|
||||
await User.findOneAndUpdate({ _id: user._id }, { $set: { retry_pwd: user.retry_pwd } });
|
||||
}
|
||||
return {troppilogin: user.retry_pwd > maxnum, retry_pwd: user.retry_pwd};
|
||||
}
|
||||
|
||||
return {troppilogin: false, retry_pwd: 0};
|
||||
};
|
||||
|
||||
UserSchema.statics.setLastCircuitOpened = async function (idapp, username, circuitpath) {
|
||||
|
||||
@@ -5383,7 +5781,7 @@ UserSchema.statics.addNewSite = async function (idappPass, body) {
|
||||
// cerca un IdApp Libero
|
||||
let idapp = await Site.generateNewSite_IdApp(idappPass, body, true);
|
||||
|
||||
|
||||
|
||||
if (idapp) {
|
||||
let arrSite = await Site.find({ idapp }).lean();
|
||||
let numutenti = 0;
|
||||
@@ -5393,7 +5791,7 @@ UserSchema.statics.addNewSite = async function (idappPass, body) {
|
||||
|
||||
if (arrSite && arrSite.length === 1 && numutenti < 2) {
|
||||
const MyTelegramBot = require('../telegram/telegrambot');
|
||||
|
||||
|
||||
// Nessun Sito Installato e Nessun Utente installato !
|
||||
let myuser = new User();
|
||||
myuser._id = new ObjectID();
|
||||
@@ -5435,6 +5833,12 @@ UserSchema.statics.addNewSite = async function (idappPass, body) {
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.renameCircuitName = async function (idapp, oldcircuitname, newcircuitname) {
|
||||
const User = this;
|
||||
|
||||
return await User.updateMany({ idapp, 'profile.mycircuits.circuitname': oldcircuitname }, { $set: { 'profile.mycircuits.$.circuitname': newcircuitname } });
|
||||
};
|
||||
|
||||
UserSchema.statics.createNewSubRecord = async function (idapp, req) {
|
||||
const User = this;
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ const cartModel = require('../models/cart')
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
const Gasordine = require('../models/gasordine');
|
||||
|
||||
const Order = require('../models/order');
|
||||
|
||||
class Cart {
|
||||
@@ -33,6 +35,7 @@ class Cart {
|
||||
mynewcart.department = cart.department;
|
||||
mynewcart.userId = cart.userId || "";
|
||||
mynewcart.modify_at = new Date();
|
||||
mynewcart.note_ordine_gas = '';
|
||||
|
||||
return mynewcart;
|
||||
} catch (e) {
|
||||
@@ -100,6 +103,7 @@ class Cart {
|
||||
myitem.order = Order.updateTotals(myitem.order);
|
||||
|
||||
this.updatecarttotals(false);
|
||||
await this.updateExtraOrder();
|
||||
await Order.findOneAndUpdate({ _id: myitem.order._id }, { $set: myitem.order }, { new: false });
|
||||
return myitem.order;
|
||||
}
|
||||
@@ -138,6 +142,7 @@ class Cart {
|
||||
}
|
||||
myitem.order = Order.updateTotals(myitem.order);
|
||||
this.updatecarttotals(false);
|
||||
await this.updateExtraOrder();
|
||||
|
||||
await Order.findOneAndUpdate({ _id: myitem.order._id }, { $set: myitem.order }, { new: false });
|
||||
return myitem.order;
|
||||
@@ -148,7 +153,7 @@ class Cart {
|
||||
}
|
||||
|
||||
|
||||
addItem(itemorder) {
|
||||
async addItem(itemorder) {
|
||||
// this.items.push(itemorder);
|
||||
|
||||
let ind = this.items.length;
|
||||
@@ -156,14 +161,16 @@ class Cart {
|
||||
this.items[ind].order = itemorder;
|
||||
this.items[ind].order = Order.updateTotals(this.items[ind].order);
|
||||
this.updatecarttotals(false);
|
||||
await this.updateExtraOrder();
|
||||
|
||||
return ind;
|
||||
}
|
||||
|
||||
removeItem(orderId) {
|
||||
async removeItem(orderId) {
|
||||
// this.items.push(itemorder);
|
||||
this.items = this.items.filter(item => item.order._id.toString() !== orderId.toString());
|
||||
this.updatecarttotals(false);
|
||||
await this.updateExtraOrder();
|
||||
}
|
||||
|
||||
generateModel() {
|
||||
@@ -177,6 +184,7 @@ class Cart {
|
||||
userId: this.userId,
|
||||
department: this.department,
|
||||
note: this.note,
|
||||
note_ordine_gas: this.note_ordine_gas,
|
||||
modify_at: this.modify_at
|
||||
})
|
||||
return newCart
|
||||
@@ -254,6 +262,7 @@ class Cart {
|
||||
order.TotalPriceProductCalc += mypricecalc;
|
||||
if (updatecalcprice) {
|
||||
order.TotalPriceProduct += mypricecalc;
|
||||
order.TotalPriceProductstr = parseFloat(order.TotalPriceProduct.toFixed(2));
|
||||
}
|
||||
|
||||
// Qui lo calcolo sempre, anche se lo cambio manualmente
|
||||
@@ -270,6 +279,39 @@ class Cart {
|
||||
|
||||
}
|
||||
|
||||
async updateExtraOrder() {
|
||||
try {
|
||||
|
||||
let arrGas = [];
|
||||
const precnoteordgas = this.note_ordine_gas
|
||||
this.note_ordine_gas = '';
|
||||
for (const rec in this.items) {
|
||||
let order = this.items[rec].order;
|
||||
if (!order) {
|
||||
order = this.items[rec];
|
||||
}
|
||||
// Prendo la nota valida e la metto visibile sul Carrello !
|
||||
if (order.idGasordine) {
|
||||
const recGas = await Gasordine.findOne({ _id: order.idGasordine }).lean();
|
||||
if (recGas) {
|
||||
if (recGas.note_ordine_gas) {
|
||||
if (!arrGas.includes(recGas._id.toString())) {
|
||||
if (this.note_ordine_gas)
|
||||
this.note_ordine_gas += '<br>'
|
||||
|
||||
this.note_ordine_gas += '<strong>' + recGas.name + '</strong>' + ':<br>' + recGas.note_ordine_gas;
|
||||
arrGas.push(recGas._id.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error('Err:', e);
|
||||
}
|
||||
}
|
||||
|
||||
generateArray() {
|
||||
let arr = [];
|
||||
for (let id in this.items) {
|
||||
|
||||
@@ -173,5 +173,17 @@ module.exports = {
|
||||
"label" : "Euro",
|
||||
"__v" : 0
|
||||
},
|
||||
{
|
||||
"_id" : ObjectID("51bc482667de9a1f64b254ff"),
|
||||
"idapp" : "13",
|
||||
"label" : "Bitcoin",
|
||||
"__v" : 0
|
||||
},
|
||||
{
|
||||
"_id" : ObjectID("51bc482667de9a1f64b255ff"),
|
||||
"idapp" : "13",
|
||||
"label" : "Banca del Tempo",
|
||||
"__v" : 0
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
module.exports = {
|
||||
list: [
|
||||
{_id: 1, descr: 'Abbigliamento'},
|
||||
{_id: 2, descr: 'Arredamento'},
|
||||
{_id: 3, descr: 'Auto e Moto'},
|
||||
{_id: 4, descr: 'Artigianato'},
|
||||
{_id: 5, descr: 'Bellezza e Igiene'},
|
||||
{_id: 6, descr: 'Bimbi'},
|
||||
{_id: 1, descr: 'Abbigliamento', icon: 'fas fa-tshirt', color: 'blue-7'},
|
||||
{_id: 2, descr: 'Arredamento', icon: 'fas fa-chair', color: 'green-7'},
|
||||
{_id: 3, descr: 'Auto e Moto', icon: 'fas fa-car', color: 'orange-7'},
|
||||
{_id: 4, descr: 'Artigianato', icon: 'fas fa-screwdriver', color: 'red-7'},
|
||||
{_id: 5, descr: 'Bellezza e Igiene', icon: 'fas fa-spa', color: 'purple-7'},
|
||||
{_id: 6, descr: 'Bimbi', icon: 'fas fa-child', color: 'cyan-7'},
|
||||
{_id: 7, descr: 'Cibo'},
|
||||
{_id: 8, descr: 'Collezionismo e Antiquariato'},
|
||||
{_id: 9, descr: 'Elettronica'},
|
||||
{_id: 10, descr: 'Giochi'},
|
||||
{_id: 11, descr: 'Hobby'},
|
||||
{_id: 12, descr: 'Libri'},
|
||||
{_id: 13, descr: 'Musica e Film'},
|
||||
{_id: 14, descr: 'Scuola e Ufficio'},
|
||||
{_id: 15, descr: 'Sport'},
|
||||
{_id: 16, descr: 'Un po\' di Tutto'},
|
||||
{_id: 17, descr: 'Attrezzature'},
|
||||
{_id: 10, descr: 'Giochi', icon: 'fas fa-gamepad', color: 'purple-7'},
|
||||
{_id: 11, descr: 'Hobby', icon: 'fas fa-guitar', color: 'cyan-7'},
|
||||
{_id: 12, descr: 'Libri', icon: 'fas fa-book', color: 'indigo-7'},
|
||||
{_id: 13, descr: 'Musica e Film', icon: 'fas fa-music', color: 'brown-7'},
|
||||
{_id: 14, descr: 'Scuola e Ufficio', icon: 'fas fa-graduation-cap', color: 'pink-7'},
|
||||
{_id: 15, descr: 'Sport', icon: 'fas fa-futbol', color: 'orange-7'},
|
||||
{_id: 16, descr: 'Un po\' di Tutto', icon: 'fas fa-globe-europe', color: 'red-7'},
|
||||
{_id: 17, descr: 'Attrezzature', icon: 'fas fa-tools', color: 'blue-7'},
|
||||
{_id: 18, descr: 'Animali', icon: 'fas fa-paw', color: 'green-7'},
|
||||
{_id: 19, descr: 'Arte / Decorazioni', icon: 'fas fa-palette', color: 'purple-7'},
|
||||
|
||||
],
|
||||
};
|
||||
|
||||
@@ -12,6 +12,6 @@ module.exports = {
|
||||
{_id: 11, descr: 'Progetti di Gruppo'},
|
||||
{_id: 12, descr: 'Salute'},
|
||||
{_id: 13, descr: 'Tecnologie'},
|
||||
{_id: 14, descr: 'Servizi'},
|
||||
{_id: 14, descr: 'Servizi'},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module.exports = {
|
||||
list: [
|
||||
{_id: 1, descr: 'Di Persona', icon:'fas fa-people-carry' },
|
||||
{_id: 2, descr: 'On Line', icon:'fas fa-desktop'},
|
||||
{_id: 1, descr: 'Di Persona', icon:'fas fa-people-carry', color:'green-8' },
|
||||
{_id: 2, descr: 'On Line', icon:'fas fa-desktop', color: 'indigo-7'},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -10,8 +10,11 @@ const tools = require('../tools/general');
|
||||
const { City } = require('../models/city');
|
||||
const Product = require('../models/product');
|
||||
const Inventariogm = require('../models/inventariogm');
|
||||
const Importamacro = require('../models/importamacro');
|
||||
const ProductInfo = require('../models/productInfo');
|
||||
const CatProd = require('../models/catprod');
|
||||
const Author = require('../models/author');
|
||||
const Publisher = require('../models/publisher');
|
||||
const SubCatProd = require('../models/subcatprod');
|
||||
const Gasordine = require('../models/gasordine');
|
||||
|
||||
@@ -38,21 +41,215 @@ router.post('/updateval', authenticate, async (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
router.post('/import', authenticate, async (req, res) => {
|
||||
const cmd = req.body.cmd;
|
||||
const idapp = req.body.idapp;
|
||||
const data = req.body.data;
|
||||
const options = req.body.data.options;
|
||||
function fixURL(url) {
|
||||
return url.replace(/https:\//g, 'https://');
|
||||
}
|
||||
|
||||
|
||||
async function completaSettaggioProduct_AndProductInfo(arrcampi_productInfo, arrcampi_product, rec, product, productInfo) {
|
||||
|
||||
try {
|
||||
if (shared_consts.CAMPI_PRODUCTINFO_CONVERT.includes('weight_and_unit')) {
|
||||
if (rec.hasOwnProperty('weight_and_unit')) {
|
||||
const ris1 = tools.getWeightAndUnitByText(rec['weight_and_unit']);
|
||||
if (ris1) {
|
||||
productInfo.weight = ris1.weight;
|
||||
productInfo.unit = ris1.unit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (shared_consts.CAMPI_PRODUCTINFO_CONVERT.includes('weight_and_unit_lordo')) {
|
||||
if (rec.hasOwnProperty('weight_and_unit_lordo')) {
|
||||
const ris2 = tools.getWeightAndUnitByText(rec['weight_and_unit_lordo']);
|
||||
if (ris2) {
|
||||
productInfo.weight_lordo = ris2.weight;
|
||||
productInfo.unit_lordo = ris2.unit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rec.hasOwnProperty('link_scheda')) {
|
||||
if (fixURL(rec['link_scheda']))
|
||||
productInfo['link_scheda'] = fixURL(rec['link_scheda'])
|
||||
}
|
||||
|
||||
for (const campo of shared_consts.PRODUCTINFO.CAMPI_FIRST_UPPERCASE) {
|
||||
|
||||
if (rec.hasOwnProperty(campo)) {
|
||||
let mystr = tools.capitalize(rec[campo]).trim();
|
||||
if (mystr)
|
||||
productInfo[campo] = mystr;
|
||||
}
|
||||
}
|
||||
|
||||
// Conversione in Euro
|
||||
for (campoprezzo of shared_consts.CAMPI_EURO) {
|
||||
if (rec.hasOwnProperty(campoprezzo)) {
|
||||
product[campoprezzo] = tools.convertPriceEurToValue(rec[campoprezzo])
|
||||
}
|
||||
}
|
||||
|
||||
if (!rec.hasOwnProperty('img') && product.code) {
|
||||
productInfo.img = 'upload/products/' + product.code + '.jpg';
|
||||
} else {
|
||||
if (rec.hasOwnProperty('img')) {
|
||||
productInfo.img = 'upload/products/' + rec['img'];
|
||||
}
|
||||
}
|
||||
|
||||
if (rec.hasOwnProperty('old_code')) {
|
||||
const old_code = rec['old_code'];
|
||||
let oldrec = await ProductInfo.findOne({ code: old_code }).lean();
|
||||
if (oldrec) {
|
||||
const precid = productInfo._id;
|
||||
const preccode = productInfo.code;
|
||||
|
||||
productInfo = oldrec;
|
||||
if (precid)
|
||||
productInfo._id = precid;
|
||||
else
|
||||
delete productInfo._id;
|
||||
|
||||
productInfo.code = preccode;
|
||||
}
|
||||
}
|
||||
if (rec.hasOwnProperty('productType')) {
|
||||
productInfo.productType = rec.hasOwnProperty('productType');
|
||||
} else {
|
||||
productInfo.productType = shared_consts.PRODUCTTYPE.PRODUCT;
|
||||
}
|
||||
|
||||
return { product, productInfo };
|
||||
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
}
|
||||
|
||||
|
||||
return { product, productInfo };
|
||||
}
|
||||
|
||||
function getValoriAndIndice(dati, arrinclude) {
|
||||
const campi = dati;
|
||||
|
||||
for (const key in campi) {
|
||||
if (Object.hasOwnProperty.call(obj, key)) {
|
||||
const value = obj[key];
|
||||
console.log(`${key}: ${value}`);
|
||||
}
|
||||
}
|
||||
|
||||
const risultato = campi.map((campo, indice) => {
|
||||
let mycampo = campo.trim();
|
||||
if (arrinclude) {
|
||||
if (arrinclude.includes(mycampo))
|
||||
return { name: mycampo, ind: indice };
|
||||
} else {
|
||||
return { name: mycampo, ind: indice };
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return risultato;
|
||||
}
|
||||
|
||||
function getValoriAndIndice_ProductInfo(dati) {
|
||||
//return getValoriAndIndice(dati, shared_consts.CAMPI_PRODUCTINFO)
|
||||
return shared_consts.CAMPI_PRODUCTINFO;
|
||||
}
|
||||
|
||||
function getValoriAndIndice_Product(dati) {
|
||||
//return getValoriAndIndice(dati, shared_consts.CAMPI_PRODUCT);
|
||||
return shared_consts.CAMPI_PRODUCT;
|
||||
}
|
||||
|
||||
async function extractArrayDataFromCSV(idapp, rec) {
|
||||
|
||||
try {
|
||||
// la prima riga contiene il nome della proprietà:
|
||||
let productInfo = {
|
||||
idapp: idapp,
|
||||
idCatProds: [],
|
||||
idSubCatProds: [],
|
||||
};
|
||||
|
||||
let product = {
|
||||
idapp,
|
||||
};
|
||||
|
||||
arrcampi_productInfo = getValoriAndIndice_ProductInfo(null);
|
||||
arrcampi_product = getValoriAndIndice_Product(null);
|
||||
|
||||
for (const campoobj of arrcampi_productInfo) {
|
||||
if (rec.hasOwnProperty(campoobj.name)) {
|
||||
let myval = tools.ripulisciCampo(rec[campoobj.name]);
|
||||
productInfo[campoobj.name] = (myval === 'TRUE' || myval.toUpperCase() === 'SI') ? true : ((myval === 'FALSE' || myval.toUpperCase() === 'NO') ? false : myval);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (const campoobj of arrcampi_product) {
|
||||
if (rec.hasOwnProperty(campoobj))
|
||||
product[campoobj] = rec[campoobj];
|
||||
}
|
||||
|
||||
const ris = await completaSettaggioProduct_AndProductInfo(arrcampi_productInfo, arrcampi_product, rec, product, productInfo);
|
||||
|
||||
/*
|
||||
// code: product.code,
|
||||
name: product.name,
|
||||
link: product.link,
|
||||
idCatProds: [],
|
||||
idSubCatProds: [],
|
||||
img: 'upload/products/' + product.code + '.jpg',
|
||||
weight: product.weight,
|
||||
unit: tools.getIdUnitsByText(product.unit),
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
return ris;
|
||||
|
||||
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
}
|
||||
|
||||
return dataObjects;
|
||||
|
||||
};
|
||||
|
||||
function extractNameAndSurnameByComplete(name_complete) {
|
||||
|
||||
if (name_complete) {
|
||||
const name = name_complete.split(' ')[0];
|
||||
const surname = name_complete.split(' ')[1];
|
||||
return { name, surname };
|
||||
} else {
|
||||
return { name: '', surname: '' };
|
||||
}
|
||||
}
|
||||
|
||||
router.post('/import', authenticate, async (req, res) => {
|
||||
|
||||
try {
|
||||
const cmd = req.body.cmd;
|
||||
const idapp = req.body.idapp;
|
||||
const data = req.body.data;
|
||||
const options = req.body.data.options;
|
||||
|
||||
const liste = require('../data/liste');
|
||||
let dataObjects = null;
|
||||
|
||||
if (cmd === shared_consts.Cmd.CITIES_SERVER) {
|
||||
return await City.insertMany(liste.Comuni).then((ris) => {
|
||||
return res.status(200).send(true);
|
||||
});
|
||||
} else if (cmd === shared_consts.Cmd.INVENTARIO) {
|
||||
let dataObjects = JSON.parse(`[${data.arrdata}]`);
|
||||
dataObjects = JSON.parse(`[${data.arrdata}]`);
|
||||
let updated = 0;
|
||||
let imported = 0;
|
||||
let errors = 0;
|
||||
@@ -64,13 +261,492 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
let inventario = recinv;
|
||||
|
||||
inventario.idapp = idapp;
|
||||
|
||||
|
||||
let risrec = await Inventariogm.findOneAndUpdate(queryprod, { $set: inventario }, { new: true, upsert: true });
|
||||
}
|
||||
|
||||
} else if (cmd === shared_consts.Cmd.MACRO_CATALOGO_JSON) {
|
||||
let updated = 0;
|
||||
let imported = 0;
|
||||
let errors = 0;
|
||||
|
||||
dataObjects = null;
|
||||
|
||||
try {
|
||||
dataObjects = JSON.parse(`[${data.arrdata}]`);
|
||||
} catch (e) {
|
||||
dataObjects = null;
|
||||
}
|
||||
|
||||
if (dataObjects && dataObjects[0]) {
|
||||
// Cancella la collection ImportaMacros
|
||||
await Importamacro.deleteMany({ idapp });
|
||||
|
||||
// Aggiungi i record su ImportaMacros
|
||||
for (const recinv of dataObjects[0]) {
|
||||
let isnuovo = false
|
||||
let setta = false
|
||||
|
||||
let recmacro = recinv;
|
||||
|
||||
recmacro.idapp = idapp;
|
||||
|
||||
recmacro._id = recmacro.id;
|
||||
|
||||
delete recmacro.id;
|
||||
|
||||
let queryprod = { idapp, _id: recmacro._id };
|
||||
|
||||
try {
|
||||
let risrec = await Importamacro.findOneAndUpdate(queryprod, { $set: recmacro }, { new: true, upsert: true, strict: false });
|
||||
if (risrec) {
|
||||
imported++;
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const cancella_categorie = false;
|
||||
|
||||
if (cancella_categorie) {
|
||||
await CatProd.deleteMany({ idapp });
|
||||
}
|
||||
|
||||
|
||||
// Rileggi tutti i record di ImportaMacros
|
||||
dataObjects = await Importamacro.find({ idapp }).lean();
|
||||
|
||||
console.log('*** INIZIO IMPORT PRODOTTI ... ');
|
||||
|
||||
let indprod = 0;
|
||||
let newprod = 0;
|
||||
|
||||
for (const product of dataObjects) {
|
||||
let isnuovo = false
|
||||
let setta = false
|
||||
|
||||
let importa = true;
|
||||
|
||||
if (!product.title || !product.isbn)
|
||||
importa = false;
|
||||
|
||||
if (importa) {
|
||||
let productInfo = {
|
||||
idapp: product.idapp,
|
||||
code: product.isbn,
|
||||
id_wp: product._id,
|
||||
name: product.title,
|
||||
description: product.description,
|
||||
short_descr: product.short_descr,
|
||||
publisher: product.Editore,
|
||||
collezione: product.Collezione,
|
||||
// author: product.Autore ? product.Autore : '',
|
||||
link: product.link ? product.link : '',
|
||||
idCatProds: [],
|
||||
idSubCatProds: [],
|
||||
//img: 'upload/products/' + product.code + '.jpg',
|
||||
image_link: product.image_link ? product.image_link : '',
|
||||
img2: product.img2 ? product.img2 : '',
|
||||
img3: product.img3 ? product.img3 : '',
|
||||
img4: product.img4 ? product.img4 : '',
|
||||
checkout_link: product.checkout_link ? product.checkout_link : '',
|
||||
}
|
||||
|
||||
let versione = 0;
|
||||
|
||||
// Download, DVD, Epub, Mobi, Nuovo, PDF, Streaming, Usato
|
||||
if (product.Versione === 'Nuovo')
|
||||
versione = shared_consts.VERSIONE.NUOVO
|
||||
else if (product.Versione === 'Usato')
|
||||
versione = shared_consts.VERSIONE.USATO;
|
||||
else if (product.Versione === 'Download')
|
||||
versione = shared_consts.VERSIONE.DOWNLOAD;
|
||||
else if (product.Versione === 'DVD')
|
||||
versione = shared_consts.VERSIONE.DVD;
|
||||
else if (product.Versione === 'Epub')
|
||||
versione = shared_consts.VERSIONE.EPUB;
|
||||
else if (product.Versione === 'Mobi')
|
||||
versione = shared_consts.VERSIONE.MOBI;
|
||||
else if (product.Versione === 'PDF')
|
||||
versione = shared_consts.VERSIONE.PDF;
|
||||
else if (product.Versione === 'Streaming')
|
||||
versione = shared_consts.VERSIONE.STREAMING;
|
||||
else
|
||||
versione = 100;
|
||||
|
||||
if (versione === shared_consts.VERSIONE.DOWNLOAD)
|
||||
productInfo.productType = shared_consts.PRODUCTTYPE.DOWNLOAD;
|
||||
else if (versione === shared_consts.VERSIONE.DVD)
|
||||
productInfo.productType = shared_consts.PRODUCTTYPE.DVD;
|
||||
else if (versione === shared_consts.VERSIONE.EPUB)
|
||||
productInfo.productType = shared_consts.PRODUCTTYPE.EPUB;
|
||||
else if (versione === shared_consts.VERSIONE.MOBI)
|
||||
productInfo.productType = shared_consts.PRODUCTTYPE.MOBI;
|
||||
else if (versione === shared_consts.VERSIONE.PDF)
|
||||
productInfo.productType = shared_consts.PRODUCTTYPE.PDF;
|
||||
else if (versione === shared_consts.VERSIONE.STREAMING)
|
||||
productInfo.productType = shared_consts.PRODUCTTYPE.STREAMING;
|
||||
else
|
||||
productInfo.productType = shared_consts.PRODUCTTYPE.LIBRO;
|
||||
|
||||
if (product.Data)
|
||||
productInfo.date_publishing = new Date(product.Data * 1000);
|
||||
|
||||
productInfo.name = productInfo.name.replace(/ - Usato$| - Nuovo$| - Epub$| - Ebook$| - Mobi$| - DVD$| - Streaming$| - Download$/, "");
|
||||
|
||||
if (product.Pagine) {
|
||||
try {
|
||||
productInfo.numpages = 0;
|
||||
productInfo.numpages = parseInt(product.Pagine);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
let reccateg = null;
|
||||
if (product.categories) {
|
||||
arrcat = product.categories.trim().split(',');
|
||||
for (const mycat of arrcat) {
|
||||
let mycatstr = mycat.trim();
|
||||
|
||||
// Controlla se ci sono le sottocategorie:
|
||||
arrsubcat = mycatstr.trim().split('>');
|
||||
|
||||
if (arrsubcat.length > 1) {
|
||||
// Ci sono delle sottocategorie
|
||||
mycatstr = arrsubcat[0].trim();
|
||||
product.subcat_name = arrsubcat[1].trim();;
|
||||
}
|
||||
|
||||
// Cerca la Categoria
|
||||
reccateg = await CatProd.findOne({ idapp, name: mycatstr }).lean();
|
||||
if (!reccateg) {
|
||||
// Non esiste questo produttore, quindi lo creo !
|
||||
reccateg = new CatProd({ idapp, name: mycatstr });
|
||||
ris = await reccateg.save();
|
||||
reccateg = await CatProd.findOne({ idapp, name: mycatstr }).lean();
|
||||
}
|
||||
|
||||
if (reccateg) {
|
||||
productInfo.idCatProds.push(reccateg._id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// "Autore" : "Silia,Marucelli, Stefano,Cattinelli",
|
||||
let arrAuthor = [];
|
||||
if (product.Autore) {
|
||||
const arrrecauthor = product.Autore.trim().split(',');
|
||||
|
||||
if (arrrecauthor.length >= 1) {
|
||||
try {
|
||||
let author = {
|
||||
name: arrrecauthor[0].trim(),
|
||||
}
|
||||
if (arrrecauthor.length === 1) {
|
||||
author = extractNameAndSurnameByComplete(arrrecauthor[0].trim());
|
||||
} else {
|
||||
author.surname = arrrecauthor[1].trim();
|
||||
}
|
||||
arrAuthor.push(author);
|
||||
|
||||
if (arrrecauthor.length > 1) {
|
||||
for (let i = 2; i < arrrecauthor.length; i = i + 2) {
|
||||
try {
|
||||
author = {
|
||||
name: arrrecauthor[i].trim()
|
||||
}
|
||||
if (arrrecauthor.length > i + 1) {
|
||||
author.surname = arrrecauthor[i + 1].trim()
|
||||
}
|
||||
arrAuthor.push(author);
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
productInfo.idAuthors = [];
|
||||
|
||||
for (const myauthor of arrAuthor) {
|
||||
// Cerca l'Autore
|
||||
recauthor = await Author.findOne({ idapp, name: myauthor.name, surname: myauthor.surname }).lean();
|
||||
if (!recauthor) {
|
||||
// Non esiste questo Autore, quindi lo creo !
|
||||
recauthor = new Author({ idapp, name: myauthor.name, surname: myauthor.surname });
|
||||
ris = await recauthor.save();
|
||||
recauthor = await Author.findOne({ idapp, name: myauthor.name, surname: myauthor.surname }).lean();
|
||||
}
|
||||
|
||||
if (recauthor) {
|
||||
productInfo.idAuthors.push(recauthor._id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (product.subcat_name) {
|
||||
arrsubcat = product.subcat_name.trim().split(',');
|
||||
for (const mysubcat of arrsubcat) {
|
||||
let mysubcatstr = mysubcat.trim();
|
||||
|
||||
// Cerca la Sotto Categoria
|
||||
let recsubcateg = await SubCatProd.findOne({ idapp, name: mysubcatstr }).lean();
|
||||
if (!recsubcateg) {
|
||||
// Non esiste questa Sotto Categoria, quindi la creo !
|
||||
const idCatProd = reccateg ? reccateg._id : ''
|
||||
recsubcateg = new SubCatProd({ idapp, name: mysubcatstr, idCatProd });
|
||||
ris = await recsubcateg.save();
|
||||
recsubcateg = await SubCatProd.findOne({ idapp, name: mysubcatstr, idCatProd }).lean();
|
||||
}
|
||||
|
||||
if (recsubcateg) {
|
||||
productInfo.idSubCatProds.push(recsubcateg._id);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (productInfo.publisher) {
|
||||
try {
|
||||
publisher = productInfo.publisher.trim();
|
||||
// Cerca la Sotto Categoria
|
||||
let recpublisher = await Publisher.findOne({ idapp, name: publisher }).lean();
|
||||
if (!recpublisher) {
|
||||
// Non esiste questo Editore, quindi la creo !
|
||||
recpublisher = new Publisher({ idapp, name: publisher });
|
||||
ris = await recpublisher.save();
|
||||
recpublisher = await Publisher.findOne({ idapp, name: publisher }).lean();
|
||||
}
|
||||
|
||||
if (recpublisher) {
|
||||
productInfo.idPublisher = recpublisher._id;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!product.hasOwnProperty('active')) {
|
||||
product.active = true;
|
||||
}
|
||||
|
||||
let esisteindb = await ProductInfo.findOne({ code: productInfo.code }).lean();
|
||||
// Update ProductInfo
|
||||
let risrecInfo = await ProductInfo.findOneAndUpdate({ code: productInfo.code }, { $set: productInfo }, { new: true, upsert: true });
|
||||
if (risrecInfo) {
|
||||
product.idProductInfo = risrecInfo._id;
|
||||
recnewInfo = await ProductInfo.findOne({ code: productInfo.code }).lean();
|
||||
|
||||
if (risrecInfo._id) {
|
||||
// Record existed, so it was updated
|
||||
let arrfieldchange = tools.differentObjects(productInfo, recnewInfo);
|
||||
if (arrfieldchange && arrfieldchange.length > 0) {
|
||||
updated++;
|
||||
console.log('Changed: ', recnewInfo.name + ': ' + arrfieldchange);
|
||||
}
|
||||
}
|
||||
|
||||
// Cerca il GAS
|
||||
let recGas = null;
|
||||
if (product.gas_name) {
|
||||
// Cerca il GAS
|
||||
recGas = await Gasordine.findOne({ idapp, name: product.gas_name }).lean();
|
||||
}
|
||||
|
||||
if (!recGas && !!product.gas_name) {
|
||||
recGas = new Gasordine({ idapp, name: product.gas_name, active: true });
|
||||
// Non esiste questo GAS, quindi lo creo !
|
||||
ris = await recGas.save();
|
||||
recGas = await Gasordine.findOne({ idapp, name: product.gas_name }).lean();
|
||||
}
|
||||
|
||||
let myproduct = {};
|
||||
|
||||
|
||||
let recProductExist = null;
|
||||
// ISBN e versione del prodotto sono le chiavi uniche
|
||||
let queryprod = { idProductInfo: product.idProductInfo };
|
||||
|
||||
if (recGas) {
|
||||
queryprod = { ...queryprod, idGasordine: recGas._id };
|
||||
}
|
||||
|
||||
recProductExist = await Product.findOne(queryprod).lean();
|
||||
|
||||
if (!recProductExist) {
|
||||
isnuovo = true;
|
||||
}
|
||||
|
||||
let arrvariazioni = [];
|
||||
if (isnuovo) {
|
||||
myproduct.isbn = product.isbn;
|
||||
myproduct.maxbookableGASQty = product.maxbookableGASQty ? product.maxbookableGASQty : null;
|
||||
myproduct.active = product.active;
|
||||
myproduct.idGasordine = recGas ? recGas._id : null;
|
||||
myproduct.idProductInfo = product.idProductInfo;
|
||||
myproduct.idapp = idapp;
|
||||
} else {
|
||||
arrvariazioni = recProductExist.arrvariazioni;
|
||||
if (!arrvariazioni) {
|
||||
arrvariazioni = [];
|
||||
}
|
||||
}
|
||||
|
||||
// cerca l'indice della versione in arrvariazioni
|
||||
let ind = arrvariazioni.findIndex(x => x.versione === versione);
|
||||
let nuovaVariazione = ind < 0;
|
||||
|
||||
//
|
||||
let variazione = {};
|
||||
if (!nuovaVariazione) {
|
||||
// Mantieni intatte questi campi del RECORD su DB:
|
||||
variazione.quantita = arrvariazioni[ind].quantita;
|
||||
}
|
||||
|
||||
variazione.active = true; // ++ ??
|
||||
variazione.versione = versione;
|
||||
variazione.status = product.Stato ? product.Stato : null;
|
||||
variazione.price = product.price ? parseFloat(tools.convertPriceEurToValue(product.price)) : null;
|
||||
variazione.sale_price = product.sale_price ? parseFloat(tools.convertPriceEurToValue(product.sale_price)) : null;
|
||||
variazione.formato = product.formato ? product.formato : '';
|
||||
variazione.tipologia = product.Tipologia ? product.Tipologia : '';
|
||||
variazione.edizione = product.Edizione ? product.Edizione : '';
|
||||
variazione.eta = product.eta ? product.eta : '';
|
||||
variazione.addtocart_link = product.addtocart_link ? product.addtocart_link : '';
|
||||
|
||||
|
||||
if (!options.aggiornaStockQty && !nuovaVariazione) {
|
||||
// non aggiornare la Quantita in magazzino
|
||||
} else if (product.Quantita) {
|
||||
variazione.quantita = parseInt(product.Quantita);
|
||||
}
|
||||
variazione.preOrderDate = product.preOrderDate ? product.preOrderDate : null;
|
||||
|
||||
// -----------------------------
|
||||
|
||||
if (ind >= 0)
|
||||
arrvariazioni[ind] = variazione; // aggiorna il record "ind" in arrvariazioni
|
||||
else
|
||||
arrvariazioni.push(variazione); // aggiunge un nuovo record in arrvariazioni
|
||||
|
||||
// Effettua l'ordinamento seguendo la "versione"
|
||||
arrvariazioni.sort((a, b) => a.versione - b.versione);
|
||||
|
||||
// Inserisce o aggiorna il record variazione nell'array delle variazioni, in base a "versione"
|
||||
if (isnuovo) {
|
||||
myproduct.arrvariazioni = arrvariazioni;
|
||||
}
|
||||
|
||||
let recold = await Product.findOne(queryprod).lean();
|
||||
|
||||
let risrec = null;
|
||||
if (isnuovo) {
|
||||
// CREA PRODUCT
|
||||
risrec = await Product.findOneAndUpdate(queryprod, { $set: myproduct }, { new: true, upsert: true });
|
||||
} else {
|
||||
// Esiste già, pertanto ci aggiorno arrvariazioni
|
||||
risrec = await Product.findOneAndUpdate(queryprod, { $set: { arrvariazioni } }, { new: true, upsert: true });
|
||||
}
|
||||
|
||||
let recnew = await Product.findOne(queryprod).lean();
|
||||
|
||||
if (risrec) {
|
||||
if (risrec._id) {
|
||||
|
||||
if (recold) {
|
||||
// Record existed, so it was updated
|
||||
let arrfieldchange = tools.differentObjects(recold, recnew);
|
||||
if (arrfieldchange.length > 0) {
|
||||
updated++;
|
||||
let modif = '';
|
||||
for (const field of arrfieldchange) {
|
||||
if (field === 'arrvariazioni') {
|
||||
modif += field + ': '
|
||||
|
||||
// Controlla quali campi sono variati tra recold.arrvariazioni e recnew.arrvariazioni
|
||||
for (const variazione of recnew.arrvariazioni) {
|
||||
// trova la versione in recold.arrvariazioni
|
||||
let ind = recold.arrvariazioni.findIndex(x => x.versione === variazione.versione);
|
||||
|
||||
if (ind < 0) {
|
||||
modif += 'Nuova Variazione [' + variazione.versione + '] ' + variazione.status + ' | Price: ' + variazione.price + ' -> Sale_Price: ' + variazione.sale_price + ' | ';
|
||||
} else {
|
||||
let oldvariazione = recold.arrvariazioni[ind];
|
||||
if (oldvariazione.status !== variazione.status) {
|
||||
modif += 'Variazione [' + oldvariazione.versione + '] ' + variazione.status + ' -> ' + variazione.status;
|
||||
}
|
||||
if (oldvariazione.price !== variazione.price) {
|
||||
modif += ' | Price: ' + oldvariazione.price + ' -> ' + variazione.price;
|
||||
}
|
||||
if (oldvariazione.sale_price !== variazione.sale_price) {
|
||||
modif += ' | Sale Price: ' + oldvariazione.sale_price + ' -> ' + variazione.sale_price;
|
||||
}
|
||||
if (oldvariazione.formato !== variazione.formato) {
|
||||
modif += ' | Formato: ' + oldvariazione.formato + ' -> ' + variazione.formato;
|
||||
}
|
||||
if (oldvariazione.tipologia !== variazione.tipologia) {
|
||||
modif += ' | Tipologia: ' + oldvariazione.tipologia + ' -> ' + variazione.tipologia;
|
||||
}
|
||||
if (oldvariazione.edizione !== variazione.edizione) {
|
||||
modif += ' | Edizione: ' + oldvariazione.edizione + ' -> ' + variazione.edizione;
|
||||
}
|
||||
if (oldvariazione.eta !== variazione.eta) {
|
||||
modif += ' | Età: ' + oldvariazione.eta + ' -> ' + variazione.eta;
|
||||
}
|
||||
if (oldvariazione.preOrderDate !== variazione.preOrderDate) {
|
||||
modif += ' | PreOrderDate: ' + oldvariazione.preOrderDate + ' -> ' + variazione.preOrderDate;
|
||||
}
|
||||
if (oldvariazione.addtocart_link !== variazione.addtocart_link) {
|
||||
modif += ' | AddToCart: ' + oldvariazione.addtocart_link + ' -> ' + variazione.addtocart_link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
modif += field + ': ' + recold[field] + ' -> ' + recnew[field] + ' | ';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
console.log('Changed: [' + indprod + '/' + dataObjects.length + ']', productInfo.name, '[' + myproduct.idProductInfo + '] : ' + modif);
|
||||
}
|
||||
} else {
|
||||
newprod++;
|
||||
console.log('Nuovo Prodotto : [' + newprod + '/' + dataObjects.length + ']', productInfo.name);
|
||||
}
|
||||
} else {
|
||||
// Record didn't exist, so it was created
|
||||
imported++;
|
||||
}
|
||||
} else {
|
||||
// risrec is null or undefined, indicating an error
|
||||
console.error('Error: ', myproduct.productInfo.name);
|
||||
errors++;
|
||||
}
|
||||
|
||||
await Product.singlerecconvert_AfterImport_AndSave(idapp, recnew, isnuovo);
|
||||
} else {
|
||||
console.error('Error ProductInfo: ', product.code);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
|
||||
indprod++;
|
||||
}
|
||||
|
||||
console.log('*** IMPORTATI: ', imported, '*** NUOVI: ', newprod, 'AGGIORNATI = ' + updated + ' (su ' + dataObjects.length + ' RECORD)');
|
||||
|
||||
return res.status(200).send({ updated, imported, errors });
|
||||
|
||||
} else if (cmd === shared_consts.Cmd.PRODUCTS) {
|
||||
let dataObjects = JSON.parse(`[${data.arrdata}]`);
|
||||
dataObjects = JSON.parse(`[${data.arrdata}]`);
|
||||
|
||||
let updated = 0;
|
||||
let imported = 0;
|
||||
@@ -90,6 +766,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
img: 'upload/products/' + product.code + '.jpg',
|
||||
weight: product.weight,
|
||||
unit: tools.getIdUnitsByText(product.unit),
|
||||
productType: shared_consts.PRODUCTTYPE.PRODUCT,
|
||||
}
|
||||
|
||||
let reccateg = null;
|
||||
@@ -97,7 +774,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
arrcat = product.cat_name.trim().split(',');
|
||||
for (const mycat of arrcat) {
|
||||
let mycatstr = mycat.trim();
|
||||
|
||||
|
||||
// Cerca la Categoria
|
||||
reccateg = await CatProd.findOne({ idapp, name: mycatstr }).lean();
|
||||
if (!reccateg) {
|
||||
@@ -117,7 +794,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
arrsubcat = product.subcat_name.trim().split(',');
|
||||
for (const mysubcat of arrsubcat) {
|
||||
let mysubcatstr = mysubcat.trim();
|
||||
|
||||
|
||||
// Cerca la Sotto Categoria
|
||||
let recsubcateg = await SubCatProd.findOne({ idapp, name: mysubcatstr }).lean();
|
||||
if (!recsubcateg) {
|
||||
@@ -176,16 +853,183 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
ris = await recGas.save();
|
||||
recGas = await Gasordine.findOne({ idapp, name: product.gas_name }).lean();
|
||||
}
|
||||
|
||||
|
||||
let recProductExist = null;
|
||||
let queryprod = { idProductInfo: product.idProductInfo };
|
||||
|
||||
|
||||
if (recGas) {
|
||||
queryprod = {...queryprod, idGasordine: recGas._id};
|
||||
queryprod = { ...queryprod, idGasordine: recGas._id };
|
||||
}
|
||||
|
||||
recProductExist = await Product.findOne({ queryprod }).lean();
|
||||
|
||||
recProductExist = await Product.findOne(queryprod).lean();
|
||||
|
||||
if (!recProductExist) {
|
||||
isnuovo = true;
|
||||
}
|
||||
|
||||
if (!options.aggiornaStockQty && esisteindb && !isnuovo) {
|
||||
delete product.stockQty;
|
||||
delete product.maxbookableGASQty;
|
||||
}
|
||||
|
||||
// AGGIORNA PRODUCT
|
||||
let risrec = await Product.findOneAndUpdate(queryprod, { $set: product }, { new: true, upsert: true });
|
||||
|
||||
let recnew = await Product.findOne(queryprod).lean();
|
||||
|
||||
if (risrec) {
|
||||
if (risrec._id) {
|
||||
// Record existed, so it was updated
|
||||
let arrfieldchange = tools.differentObjects(product, recnew);
|
||||
if (arrfieldchange.length > 0) {
|
||||
updated++;
|
||||
console.log('Changed:', product.idProductInfo + ': ' + arrfieldchange);
|
||||
}
|
||||
} else {
|
||||
// Record didn't exist, so it was created
|
||||
imported++;
|
||||
}
|
||||
} else {
|
||||
// risrec is null or undefined, indicating an error
|
||||
console.error('Error: ', product.productInfo.name);
|
||||
errors++;
|
||||
}
|
||||
|
||||
await Product.singlerecconvert_AfterImport_AndSave(idapp, recnew, isnuovo);
|
||||
} else {
|
||||
console.error('Error ProductInfo: ', product.code);
|
||||
errors++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return res.status(200).send({ updated, imported, errors });
|
||||
|
||||
} else if (cmd === shared_consts.Cmd.PRODUCTS_V2) {
|
||||
let mydata = `[${data.arrdata}]`;
|
||||
dataObjects = mydata.replace(/\n/g, '');
|
||||
let arrrec = [];
|
||||
try {
|
||||
arrrec = JSON.parse(dataObjects);
|
||||
} catch (e) {
|
||||
console.error("Errore durante l'analisi del JSON:", e);
|
||||
arrrec = [];
|
||||
}
|
||||
|
||||
let updated = 0;
|
||||
let imported = 0;
|
||||
let errors = 0;
|
||||
|
||||
let ind = 0
|
||||
|
||||
const [, ...myarrshift] = arrrec;
|
||||
|
||||
for (const rec of myarrshift) {
|
||||
|
||||
let risprod = await extractArrayDataFromCSV(idapp, rec);
|
||||
let product = risprod.product;
|
||||
let productInfo = risprod.productInfo;
|
||||
|
||||
|
||||
|
||||
let isnuovo = false
|
||||
let setta = false
|
||||
|
||||
let reccateg = null;
|
||||
if (rec.cat_name) {
|
||||
arrcat = rec.cat_name.trim().split(',');
|
||||
for (const mycat of arrcat) {
|
||||
let mycatstr = mycat.trim();
|
||||
|
||||
// Cerca la Categoria
|
||||
reccateg = await CatProd.findOne({ idapp, name: mycatstr }).lean();
|
||||
if (!reccateg) {
|
||||
// Non esiste questo produttore, quindi lo creo !
|
||||
reccateg = new CatProd({ idapp, name: mycatstr });
|
||||
ris = await reccateg.save();
|
||||
reccateg = await CatProd.findOne({ idapp, name: mycatstr }).lean();
|
||||
}
|
||||
|
||||
if (reccateg) {
|
||||
productInfo.idCatProds.push(reccateg._id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rec.subcat_name) {
|
||||
arrsubcat = rec.subcat_name.trim().split(',');
|
||||
for (const mysubcat of arrsubcat) {
|
||||
let mysubcatstr = mysubcat.trim();
|
||||
|
||||
// Cerca la Sotto Categoria
|
||||
let recsubcateg = await SubCatProd.findOne({ idapp, name: mysubcatstr }).lean();
|
||||
if (!recsubcateg) {
|
||||
// Non esiste questa Sotto Categoria, quindi la creo !
|
||||
const idCatProd = reccateg ? reccateg._id : ''
|
||||
recsubcateg = new SubCatProd({ idapp, name: mysubcatstr, idCatProd });
|
||||
ris = await recsubcateg.save();
|
||||
recsubcateg = await SubCatProd.findOne({ idapp, name: mysubcatstr, idCatProd }).lean();
|
||||
}
|
||||
|
||||
if (recsubcateg) {
|
||||
productInfo.idSubCatProds.push(recsubcateg._id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!rec.hasOwnProperty('active')) {
|
||||
product.active = true;
|
||||
}
|
||||
|
||||
let esisteindb = await ProductInfo.findOne({ code: productInfo.code }).lean();
|
||||
|
||||
// Update ProductInfo
|
||||
let risrecInfo = await ProductInfo.findOneAndUpdate({ code: productInfo.code }, { $set: productInfo }, { new: true, upsert: true });
|
||||
if (risrecInfo) {
|
||||
product.idProductInfo = risrecInfo._id;
|
||||
|
||||
recnewInfo = await ProductInfo.findOne({ code: productInfo.code }).lean();
|
||||
|
||||
if (risrecInfo._id) {
|
||||
// Record existed, so it was updated
|
||||
let arrfieldchange = tools.differentObjects(productInfo, recnewInfo);
|
||||
if (arrfieldchange && arrfieldchange.length > 0) {
|
||||
// updated++;
|
||||
console.log('Changed: ', recnewInfo.name + ': ' + arrfieldchange);
|
||||
}
|
||||
}
|
||||
|
||||
// Cerca il GAS
|
||||
let recGas = null;
|
||||
if (rec.gas_name) {
|
||||
// Cerca il GAS
|
||||
recGas = await Gasordine.findOne({ idapp, name: rec.gas_name }).lean();
|
||||
}
|
||||
|
||||
if (!recGas && !!rec.gas_name) {
|
||||
recGas = new Gasordine({ idapp, name: rec.gas_name, active: true });
|
||||
// Non esiste questo GAS, quindi lo creo !
|
||||
ris = await recGas.save();
|
||||
recGas = await Gasordine.findOne({ idapp, name: rec.gas_name }).lean();
|
||||
}
|
||||
|
||||
if (recGas) {
|
||||
if (rec.hasOwnProperty('note_ordine_gas')) {
|
||||
const note_ordine_gas = rec['note_ordine_gas'];
|
||||
await Gasordine.findOneAndUpdate({ _id: recGas._id }, { $set: { note_ordine_gas } });
|
||||
}
|
||||
}
|
||||
|
||||
let recProductExist = null;
|
||||
let queryprod = { idProductInfo: product.idProductInfo };
|
||||
|
||||
if (recGas) {
|
||||
queryprod = { ...queryprod, idGasordine: recGas._id };
|
||||
}
|
||||
|
||||
recProductExist = await Product.findOne(queryprod).lean();
|
||||
|
||||
if (!recProductExist) {
|
||||
isnuovo = true;
|
||||
}
|
||||
@@ -224,17 +1068,18 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
errors++;
|
||||
}
|
||||
|
||||
ind++;
|
||||
}
|
||||
|
||||
// L'opzione ordered: false gestisce gli errori senza interrompere l'inserimento
|
||||
/*return await Product.insertMany(dataObjects, { ordered: false })
|
||||
.then((ris) => {
|
||||
|
||||
|
||||
Product.convertAfterImportALLPROD(idapp, dataObjects).then((ris) => {
|
||||
return res.status(200).send(true);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
.catch((errors) => {
|
||||
console.error(errors);
|
||||
@@ -248,10 +1093,10 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('e', e);
|
||||
res.status(400).send();
|
||||
return res.status(400).send();
|
||||
}
|
||||
|
||||
res.status(400).send();
|
||||
return res.status(400).send();
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ const Order = require('../models/order');
|
||||
const Variant = require('../models/variant');
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
/*const Department = require('../models/Department')
|
||||
const Category = require('../models/Category')
|
||||
const TypedError = require('../modules/ErrorHandler')
|
||||
@@ -83,6 +85,7 @@ router.post('/:userId', authenticate, async function (req, res, next) {
|
||||
nuovo = true;
|
||||
}
|
||||
|
||||
|
||||
let newCart = CartClass.constructByCart(mycart);
|
||||
// order = await Product.updateProductInOrder(order);
|
||||
if (!nuovo) {
|
||||
@@ -93,7 +96,7 @@ router.post('/:userId', authenticate, async function (req, res, next) {
|
||||
} else if (subqty) {
|
||||
myord = await newCart.subqty(order);
|
||||
} else {
|
||||
const ind = newCart.addItem(order);
|
||||
const ind = await newCart.addItem(order);
|
||||
const arrord = await Order.getTotalOrderById(order._id);
|
||||
myord = arrord ? arrord[0] : null;
|
||||
}
|
||||
@@ -101,7 +104,8 @@ router.post('/:userId', authenticate, async function (req, res, next) {
|
||||
return res.send({ code: server_constants.RIS_CODE_ERR, cart: null, myord: null, msgerr: 'Non è possibile acquistare nello stesso ordine, su negozi differenti!' });
|
||||
}
|
||||
} else {
|
||||
await newCart.updatecarttotals(true);
|
||||
newCart.updatecarttotals(true);
|
||||
await newCart.updateExtraOrder();
|
||||
const arrord = await Order.getTotalOrderById(order._id);
|
||||
myord = arrord ? arrord[0] : null;
|
||||
}
|
||||
@@ -159,7 +163,7 @@ router.delete('/:userId', authenticate, async function (req, res) {
|
||||
// Rimuovere l'id sul Carrello
|
||||
|
||||
let newCart = CartClass.constructByCart(mycart);
|
||||
newCart.removeItem(orderId);
|
||||
await newCart.removeItem(orderId);
|
||||
let carttot = null;
|
||||
const cart = await Cart.updateCartByCartId(mycart._id, newCart.generateModel());
|
||||
|
||||
@@ -273,6 +277,7 @@ router.post('/:userId/createorderscart', authenticate, async function (req, res,
|
||||
totalQty: mycart.totalQty,
|
||||
totalPrice: mycart.totalPrice,
|
||||
totalPriceCalc: mycart.totalPriceCalc,
|
||||
note_ordine_gas: mycart.note_ordine_gas,
|
||||
userId,
|
||||
status,
|
||||
note,
|
||||
@@ -373,30 +378,31 @@ router.post('/:userId/ordercartstatus', authenticate, async function (req, res,
|
||||
const userDest = await User.findById(myOrdersCart.userId).lean();
|
||||
|
||||
if (ris) {
|
||||
let ordertype = '';
|
||||
|
||||
// Aggiorna gli Stati Interni !
|
||||
myOrdersCart = await OrdersCart.updateCmd(myOrdersCart, status, true, options);
|
||||
|
||||
let ordertype = '';
|
||||
if ((options.hasOwnProperty('sendmail') && options.sendmail) || !options.hasOwnProperty('sendmail')) {
|
||||
if (status === shared_consts.OrderStatus.ORDER_CONFIRMED) {
|
||||
ordertype = 'order_confirmed';
|
||||
} else if (status === shared_consts.OrderStatus.DELIVERED) {
|
||||
ordertype = 'order_consegnato';
|
||||
} else if (status === shared_consts.OrderStatus.CANCELED) {
|
||||
ordertype = 'order_canceled';
|
||||
}
|
||||
|
||||
if (status === shared_consts.OrderStatus.ORDER_CONFIRMED) {
|
||||
ordertype = 'order_confirmed';
|
||||
} else if (status === shared_consts.OrderStatus.DELIVERED) {
|
||||
ordertype = 'order_consegnato';
|
||||
} else if (status === shared_consts.OrderStatus.CANCELED) {
|
||||
ordertype = 'order_canceled';
|
||||
}
|
||||
if (ordertype !== '') {
|
||||
sendemail.sendEmail_Order(userDest.lang, idapp, myOrdersCart, userDest, ordertype, status)
|
||||
.then((ris) => {
|
||||
|
||||
if (ordertype !== '') {
|
||||
sendemail.sendEmail_Order(userDest.lang, idapp, myOrdersCart, userDest, ordertype, status)
|
||||
.then((ris) => {
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
let orderscart = null;
|
||||
|
||||
if (User.isManager(user.perm)) {
|
||||
@@ -417,4 +423,186 @@ router.post('/:userId/ordercartstatus', authenticate, async function (req, res,
|
||||
|
||||
});
|
||||
|
||||
//POST cart
|
||||
router.post('/:userId/gestord', authenticate, async function (req, res, next) {
|
||||
let idapp = req.body.idapp;
|
||||
const user = req.user;
|
||||
let idGasordine = req.body.idGasordine;
|
||||
|
||||
const { User } = require('../models/user');
|
||||
|
||||
try {
|
||||
|
||||
let queryord = []
|
||||
|
||||
let filtroOrdini = []
|
||||
|
||||
if (idGasordine) {
|
||||
const gasordine = {
|
||||
$match: {
|
||||
idGasordine: {
|
||||
$type: "objectId", // Checks if the field is of type ObjectId
|
||||
$eq: ObjectID(idGasordine) // Compares the value to a specific ObjectId
|
||||
}
|
||||
}
|
||||
}
|
||||
queryord.push(gasordine)
|
||||
}
|
||||
|
||||
|
||||
const query = [
|
||||
{
|
||||
$lookup: {
|
||||
from: 'products',
|
||||
localField: 'idProduct',
|
||||
foreignField: '_id',
|
||||
as: 'product',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$product',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'productinfos',
|
||||
localField: 'product.idProductInfo',
|
||||
foreignField: '_id',
|
||||
as: 'productInfo',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$productInfo',
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'gasordines',
|
||||
localField: 'idGasordine',
|
||||
foreignField: '_id',
|
||||
as: 'gasordine',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$gasordine',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$or: [
|
||||
{
|
||||
quantity: {
|
||||
$gt: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
quantitypreordered: {
|
||||
$gt: 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "orderscarts",
|
||||
localField: "_id",
|
||||
foreignField: "items.order",
|
||||
as: "matchingOrders",
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
"matchingOrders": {
|
||||
$ne: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: '$product._id',
|
||||
name: {
|
||||
$first: '$productInfo.name',
|
||||
},
|
||||
weight: {
|
||||
$first: '$productInfo.weight',
|
||||
},
|
||||
unit: {
|
||||
$first: '$productInfo.unit',
|
||||
},
|
||||
price_acquistato: {
|
||||
$first: '$product.price_acquistato',
|
||||
},
|
||||
price: {
|
||||
$first: '$product.price',
|
||||
},
|
||||
totalQuantity: {
|
||||
$sum: {
|
||||
$add: [
|
||||
'$quantity',
|
||||
'$quantitypreordered',
|
||||
],
|
||||
},
|
||||
},
|
||||
totalPrice_acquistato: {
|
||||
$sum: {
|
||||
$multiply: [
|
||||
'$product.price_acquistato',
|
||||
{
|
||||
$add: [
|
||||
'$quantity',
|
||||
'$quantitypreordered',
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
totalPrice: {
|
||||
$sum: {
|
||||
$multiply: [
|
||||
'$product.price',
|
||||
{
|
||||
$add: [
|
||||
'$quantity',
|
||||
'$quantitypreordered',
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
count: {
|
||||
$sum: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
name: 1,
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
queryord = [...queryord, ...query]
|
||||
|
||||
filtroOrdini = queryord;
|
||||
|
||||
const arrout = await Order.aggregate(filtroOrdini);
|
||||
|
||||
for (const rec of arrout) {
|
||||
|
||||
}
|
||||
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, arrout });
|
||||
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -84,13 +84,14 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
data.account = await Account.getAccountByUsernameAndCircuitId(idapp, '', data._id, false, false, '', data.path);
|
||||
}
|
||||
|
||||
const arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(req.user.username, lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER);
|
||||
const arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(req.user.username, lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER, shared_consts.QualiNotifs.OTHERS);
|
||||
const arrrecnotifcoins = await SendNotif.findAllNotifByUsernameIdAndIdApp(req.user.username, lastdr, idapp, shared_consts.LIMIT_NOTIFCOINS_FOR_USER, shared_consts.QualiNotifs.CIRCUITS);
|
||||
/// E' QUIIII !!!!
|
||||
const useraccounts = await Account.getUserAccounts(idapp, req.user.username);
|
||||
|
||||
await User.setLastCircuitOpened(idapp, req.user.username, path);
|
||||
|
||||
res.send({ circuit: data, users_in_circuit, arrrecnotif, useraccounts });
|
||||
res.send({ circuit: data, users_in_circuit, arrrecnotif, arrrecnotifcoins, useraccounts });
|
||||
|
||||
} catch (e) {
|
||||
console.error('Error in Circuits', e);
|
||||
|
||||
127
src/server/router/city_router.js
Executable file
127
src/server/router/city_router.js
Executable file
@@ -0,0 +1,127 @@
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
var server_constants = require('../tools/server_constants');
|
||||
|
||||
var { Project } = require('../models/project');
|
||||
|
||||
var { authenticate, auth_default } = require('../middleware/authenticate');
|
||||
|
||||
var mongoose = require('mongoose').set('debug', false)
|
||||
const Subscription = require('../models/subscribers');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
const { City } = require('../models/city');
|
||||
|
||||
|
||||
//POST
|
||||
router.post('/geojson', authenticate, function (req, res, next) {
|
||||
let prov = req.body.prov;
|
||||
// let idapp = req.body.idapp;
|
||||
return City.getGeoJsonByProvince(prov)
|
||||
.then((ris) => {
|
||||
|
||||
if (ris)
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, ris });
|
||||
|
||||
}).catch(err => {
|
||||
console.log('ERR:', err);
|
||||
res.status(400).send();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
router.post('/updateord', authenticate, async (req, res) => {
|
||||
const idOrdersCart = req.body.idOrdersCart;
|
||||
const idOrder = req.body.idOrder;
|
||||
const paramstoupdate = req.body.paramstoupdate;
|
||||
|
||||
try {
|
||||
// Aggiorno l'Ordine Singolo
|
||||
await Order.updateOrderByParams(idOrder, paramstoupdate);
|
||||
|
||||
// Aggiorno il Totale degli Ordini (OrdersCart)
|
||||
await OrdersCart.updateOrdersCartTotals(idOrdersCart, true)
|
||||
.then((orderscart) => {
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, orderscart });
|
||||
}).catch(err => {
|
||||
console.log('ERR:', err);
|
||||
res.status(400).send();
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
router.post('/update', authenticate, async (req, res) => {
|
||||
let orderscart = null;
|
||||
const idOrdersCart = req.body.idOrdersCart;
|
||||
const paramstoupdate = req.body.paramstoupdate;
|
||||
|
||||
try {
|
||||
// Aggiorno Orderscart con i parametri passati
|
||||
orderscart = await OrdersCart.updateOrdersCartByParams(idOrdersCart, paramstoupdate);
|
||||
|
||||
let updatetotals = true;
|
||||
if (paramstoupdate && paramstoupdate.hasOwnProperty('totalPrice')) {
|
||||
updatetotals = false;
|
||||
}
|
||||
if (updatetotals) {
|
||||
|
||||
// Aggiorno il Totale degli Ordini (OrdersCart)
|
||||
await OrdersCart.updateOrdersCartTotals(idOrdersCart, true)
|
||||
.then((orderscart) => {
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, orderscart });
|
||||
}).catch(err => {
|
||||
console.log('ERR:', err);
|
||||
res.status(400).send();
|
||||
});
|
||||
} else {
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, orderscart });
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
router.post('/sendmail', authenticate, async function (req, res, next) {
|
||||
const idOrdersCart = req.body.idOrdersCart;
|
||||
const idapp = req.body.idapp;
|
||||
const test = req.body.test;
|
||||
const previewonly = req.body.previewonly;
|
||||
const templemail_id = req.body.templemail_id;
|
||||
|
||||
try {
|
||||
// Invia Email
|
||||
let myOrderCart = await OrdersCart.getOrdersCartById(idOrdersCart);
|
||||
if (myOrderCart) {
|
||||
const userto = myOrderCart.user;
|
||||
let emailto = userto.email;
|
||||
|
||||
if (userto && emailto) {
|
||||
const emailsend = await sendemail.sendEmail_byTemplate(idapp, userto, previewonly, emailto, templemail_id, test);
|
||||
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, emailsend });
|
||||
}
|
||||
}
|
||||
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, emailsend: false });
|
||||
|
||||
} catch (e) {
|
||||
console.error('err:', e);
|
||||
res.status(400).send(e);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
@@ -25,6 +25,8 @@ const { CfgServer } = require('../models/cfgserver');
|
||||
const formidable = require('formidable');
|
||||
const folder = path.join(__dirname, 'upload');
|
||||
|
||||
const sanitizeHtml = require('sanitize-html');
|
||||
|
||||
if (!fs.existsSync(folder)) {
|
||||
fs.mkdirSync(folder);
|
||||
}
|
||||
@@ -71,6 +73,7 @@ const CatAI = require('../models/catai');
|
||||
const SubCatProd = require('../models/subcatprod');
|
||||
const Gasordine = require('../models/gasordine');
|
||||
const Product = require('../models/product');
|
||||
const Author = require('../models/author');
|
||||
const ProductInfo = require('../models/productInfo');
|
||||
const Scontistica = require('../models/scontistica');
|
||||
const Department = require('../models/department');
|
||||
@@ -157,7 +160,7 @@ router.post(process.env.ADD_NEW_SITE, async (req, res) => {
|
||||
console.log('Add New Site: idapp = ', idapp, 'email=', email, 'name=', name);
|
||||
|
||||
const ris = await User.addNewSite(idapp, body);
|
||||
|
||||
|
||||
if (ris) {
|
||||
res.send(ris);
|
||||
} else {
|
||||
@@ -168,7 +171,7 @@ router.post(process.env.ADD_NEW_SITE, async (req, res) => {
|
||||
console.log(process.env.ADD_NEW_SITE, e.message);
|
||||
res.status(400).send({ code: server_constants.RIS_CODE_ERR, msg: e });
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -185,8 +188,10 @@ router.post(process.env.LINK_REQUEST_NEWPASSWORD, async (req, res) => {
|
||||
|
||||
// Check if too many requests
|
||||
if (await User.tooManyReqPassword(idapp, email, true)) {
|
||||
console.log(process.env.LINK_REQUEST_NEWPASSWORD, 'TOO MANY REQUESTS !!! EXIT ', email);
|
||||
res.status(400).send({ code: server_constants.RIS_CODE_ERR, msg: 'TOO MANY REQUESTS' });
|
||||
let text = 'Troppe richieste di Password: ' + email;
|
||||
telegrambot.sendMsgTelegramToTheManagers(idapp, text);
|
||||
console.log(process.env.LINK_REQUEST_NEWPASSWORD, text, email);
|
||||
res.status(400).send({ code: server_constants.RIS_CODE_ERR, msg: text });
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -251,14 +256,15 @@ router.post(process.env.LINK_UPDATE_PWD, async (req, res) => {
|
||||
user.lasttimeonline = new Date();
|
||||
|
||||
// Crea token
|
||||
user.generateAuthToken(req).then(token => {
|
||||
user.generateAuthToken(req).then(ris => {
|
||||
user.tokenforgot = ''; // Svuota il tokenforgot perché non ti servirà più...
|
||||
user.tokenforgot_code = ''; // Svuota il tokenforgot perché non ti servirà più...
|
||||
|
||||
// Salva lo User
|
||||
user.save().then(() => {
|
||||
res.header('x-auth', token).
|
||||
send({ code: server_constants.RIS_CODE_OK }); // Ritorna il token di ritorno
|
||||
res.header('x-auth', ris.token)
|
||||
.header('x-refrtok', ris.refreshToken)
|
||||
.send({ code: server_constants.RIS_CODE_OK }); // Ritorna il token di ritorno
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -307,7 +313,7 @@ router.get('/test1', authenticate_noerror, async (req, res) => {
|
||||
router.post('/settable', authenticate, async (req, res) => {
|
||||
const params = req.body;
|
||||
const mytable = globalTables.getTableByTableName(params.table);
|
||||
|
||||
|
||||
let mydata = req.body.data;
|
||||
let extrarec = {};
|
||||
if (mydata && mydata.hasOwnProperty('extrarec')) {
|
||||
@@ -337,9 +343,12 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
consentito = true;
|
||||
}
|
||||
|
||||
if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) &&
|
||||
!User.isEditor(req.user.perm) && !User.isFacilitatore(req.user.perm)) &&
|
||||
!tools.ModificheConsentite(params.table, fieldsvalue)) {
|
||||
if ((!User.isAdmin(req.user.perm)
|
||||
&& !User.isManager(req.user.perm)
|
||||
&& !User.isEditor(req.user.perm)
|
||||
&& !User.isFacilitatore(req.user.perm))
|
||||
&&
|
||||
await !tools.ModificheConsentite(req, params.table, fieldsvalue, mydata ? mydata._id : '')) {
|
||||
// If without permissions, exit
|
||||
return res.status(404).
|
||||
send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' });
|
||||
@@ -649,8 +658,11 @@ router.post('/setsubrec', authenticate, (req, res) => {
|
||||
});
|
||||
|
||||
router.post('/gettable', authenticate, (req, res) => {
|
||||
const params = req.body;
|
||||
let idapp = req.user ? req.user.idapp : params.idapp;
|
||||
let params = req.body;
|
||||
|
||||
params.table = sanitizeHtml(params.table);
|
||||
|
||||
let idapp = req.user ? req.user.idapp : sanitizeHtml(params.idapp);
|
||||
const mytable = globalTables.getTableByTableName(params.table);
|
||||
//console.log('mytable', mytable);
|
||||
if (!mytable) {
|
||||
@@ -763,14 +775,15 @@ router.post('/getpage', async (req, res) => {
|
||||
const mypath = params.path;
|
||||
|
||||
let found = await MyPage.findOne({ idapp, path: mypath }).then((ris) => {
|
||||
if (ris)
|
||||
return res.send({ mypage: ris });
|
||||
if (ris && ris._doc)
|
||||
return res.send({ mypage: ris._doc });
|
||||
else
|
||||
return null;
|
||||
}).catch((e) => {
|
||||
console.log(e.message);
|
||||
res.status(400).send(e);
|
||||
});
|
||||
|
||||
if (!found) {
|
||||
// trova quelli con il :
|
||||
let regexp = new RegExp(`:`, 'ig')
|
||||
@@ -850,11 +863,14 @@ router.patch('/chval', authenticate, async (req, res) => {
|
||||
// tools.mylogshow('PATCH CHVAL: ', id, fieldsvalue);
|
||||
|
||||
// If I change my record...
|
||||
if (((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) &&
|
||||
!User.isEditor(req.user.perm) && !User.isFacilitatore(req.user.perm)) &&
|
||||
(req.user._id.toString() !== id) &&
|
||||
(!tools.ModificheConsentite(mydata.table, fieldsvalue)))
|
||||
&& !((mydata.table === 'accounts') && await Account.canEditAccountAdmins(req.user.username, mydata.id))
|
||||
if ((
|
||||
(!User.isAdmin(req.user.perm)
|
||||
&& !User.isManager(req.user.perm)
|
||||
&& !User.isEditor(req.user.perm)
|
||||
&& !User.isFacilitatore(req.user.perm))
|
||||
&& (await !tools.ModificheConsentite(req, mydata.table, fieldsvalue, id)))
|
||||
&& !((mydata.table === 'accounts')
|
||||
&& await Account.canEditAccountAdmins(req.user.username, mydata.id))
|
||||
) {
|
||||
// If without permissions, exit
|
||||
return res.status(404).
|
||||
@@ -1036,7 +1052,7 @@ router.patch('/chval', authenticate, async (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (tools.ModificheConsentite(mydata.table, fieldsvalue)) {
|
||||
if (await tools.ModificheConsentite(req, mydata.table, fieldsvalue)) {
|
||||
let msg = '';
|
||||
if (mydata.table === 'users') {
|
||||
if ('aportador_solidario' in fieldsvalue) {
|
||||
@@ -1227,7 +1243,7 @@ router.delete('/delrec/:table/:id', authenticate, async (req, res) => {
|
||||
// let notifBot = false;
|
||||
// const idapp = req.body.idapp;
|
||||
|
||||
console.log('id', id, 'table', tablename);
|
||||
console.log('delete RECORD: id', id, 'table', tablename);
|
||||
|
||||
const mytable = globalTables.getTableByTableName(tablename);
|
||||
|
||||
@@ -1235,7 +1251,7 @@ router.delete('/delrec/:table/:id', authenticate, async (req, res) => {
|
||||
|
||||
if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm)) &&
|
||||
(tablename !== 'extralist') &&
|
||||
!tools.ModificheConsentite(tablename, fields, id, req.user)) {
|
||||
await !tools.ModificheConsentite(req, tablename, fields, id, req.user)) {
|
||||
// If without permissions, exit
|
||||
return res.status(404).
|
||||
send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' });
|
||||
@@ -1246,17 +1262,30 @@ router.delete('/delrec/:table/:id', authenticate, async (req, res) => {
|
||||
//++Tools: Notify...
|
||||
tools.NotifyIfDelRecord(tablename);
|
||||
|
||||
if (!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm)) {
|
||||
// if (!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm)) {
|
||||
if (true) {
|
||||
if (tablename === 'users') {
|
||||
|
||||
let fieldsvalue = {
|
||||
deleted: true,
|
||||
date_deleted: new Date(),
|
||||
};
|
||||
const utente = await mytable.findById(id);
|
||||
|
||||
await mytable.findByIdAndUpdate(id, { $set: fieldsvalue });
|
||||
if (utente) {
|
||||
idapp = utente.idapp;
|
||||
await mytable.findByIdAndUpdate(id, { $set: fieldsvalue });
|
||||
|
||||
|
||||
// ...
|
||||
let text = `L\'utente ${utente.username} (${utente.name} ${utente.surname}) si è cancellato dal sito ` + tools.getNomeAppByIdApp(utente.idapp) + ` Deleted = true`;
|
||||
telegrambot.sendMsgTelegramToTheManagers(idapp, text);
|
||||
|
||||
}
|
||||
cancellato = true;
|
||||
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, msg: '' });
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1264,7 +1293,7 @@ router.delete('/delrec/:table/:id', authenticate, async (req, res) => {
|
||||
|
||||
if (!cancellato) {
|
||||
// ELIMINA VERAMENTE IL RECORD !!!
|
||||
ris = await mytable.deleteOne({_id: id}).then((rec) => {
|
||||
ris = await mytable.deleteOne({ _id: id }).then((rec) => {
|
||||
if (!rec) {
|
||||
// res.status(404).send();
|
||||
return false;
|
||||
@@ -1361,19 +1390,26 @@ router.get('/loadsite/:userId/:idapp', authenticate_noerror, (req, res) => {
|
||||
});
|
||||
|
||||
router.get('/loadsite/:userId/:idapp/:vers', authenticate_noerror,
|
||||
(req, res) => {
|
||||
async (req, res) => {
|
||||
let versionstr = req.params.vers;
|
||||
|
||||
let version = tools.getVersionint(versionstr);
|
||||
|
||||
load(req, res, version);
|
||||
return await load(req, res, version);
|
||||
|
||||
});
|
||||
|
||||
function load(req, res, version) {
|
||||
|
||||
const userId = req.params.userId;
|
||||
const idapp = req.params.idapp;
|
||||
|
||||
let status = 200
|
||||
if (req.code === server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED) {
|
||||
status = server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED
|
||||
}
|
||||
|
||||
|
||||
if (!version) {
|
||||
version = '0';
|
||||
}
|
||||
@@ -1394,7 +1430,7 @@ function load(req, res, version) {
|
||||
|
||||
let socioresidente = false;
|
||||
|
||||
if (!!req.user)
|
||||
if (req.user)
|
||||
socioresidente = req.user.profile.socioresidente;
|
||||
|
||||
if (userId !== '0') {
|
||||
@@ -1450,9 +1486,10 @@ function load(req, res, version) {
|
||||
try {
|
||||
if (req.user)
|
||||
ismanager = User.isManager(req.user.perm)
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
}
|
||||
let products = Product.findAllIdApp(idapp, undefined, undefined, ismanager);
|
||||
let authors = Author.findAllIdApp(idapp);
|
||||
let productInfos = ProductInfo.findAllIdApp(idapp);
|
||||
let scontisticas = Scontistica.findAllIdApp(idapp);
|
||||
let departments = Department.findAllIdApp(idapp);
|
||||
@@ -1473,7 +1510,6 @@ function load(req, res, version) {
|
||||
let site = Site.findAllIdApp(idapp);
|
||||
let mygroups = MyGroup.findAllGroups(idapp);
|
||||
let listcircuits = Circuit.findAllIdApp(idapp);
|
||||
// let cities = City.findAllIdApp(idapp);
|
||||
let provinces = Province.findAllIdApp(idapp);
|
||||
let cart = null;
|
||||
let orderscart = null;
|
||||
@@ -1530,7 +1566,6 @@ function load(req, res, version) {
|
||||
myuserextra, // 26
|
||||
sectors, // 27
|
||||
statusSkills, //28
|
||||
// cities,
|
||||
provinces,
|
||||
catgrps,
|
||||
adtypes,
|
||||
@@ -1551,6 +1586,7 @@ function load(req, res, version) {
|
||||
subcatprods,
|
||||
catprods_gas,
|
||||
catAI,
|
||||
authors,
|
||||
]).then((arrdata) => {
|
||||
// console.table(arrdata);
|
||||
let myuser = req.user;
|
||||
@@ -1564,7 +1600,7 @@ function load(req, res, version) {
|
||||
} catch (e) { }
|
||||
}
|
||||
if (version < 91) {
|
||||
res.send({
|
||||
res.status(status).send({
|
||||
bookedevent: arrdata[0],
|
||||
eventlist: arrdata[1],
|
||||
operators: arrdata[2],
|
||||
@@ -1591,7 +1627,7 @@ function load(req, res, version) {
|
||||
internalpages: arrdata[23],
|
||||
});
|
||||
} else {
|
||||
res.send({
|
||||
res.status(status).send({
|
||||
bookedevent: arrdata[0],
|
||||
eventlist: arrdata[1],
|
||||
operators: arrdata[2],
|
||||
@@ -1642,6 +1678,8 @@ function load(req, res, version) {
|
||||
subcatprods: arrdata[46],
|
||||
catprods_gas: arrdata[47],
|
||||
catAI: arrdata[48],
|
||||
code: req.code,
|
||||
authors: arrdata[49],
|
||||
});
|
||||
|
||||
const prova = 1;
|
||||
@@ -1654,49 +1692,60 @@ function load(req, res, version) {
|
||||
|
||||
}
|
||||
|
||||
router.get(process.env.LINK_CHECK_UPDATES, authenticate, async (req, res) => {
|
||||
const userId = req.user._id;
|
||||
router.get(process.env.LINK_CHECK_UPDATES, authenticate_noerror, async (req, res) => {
|
||||
const idapp = req.query.idapp;
|
||||
|
||||
// console.log("POST " + process.env.LINK_CHECK_UPDATES + " userId=" + userId);
|
||||
|
||||
if (!ObjectID.isValid(userId)) {
|
||||
return res.status(404).send();
|
||||
if (!req.user) {
|
||||
return res.status(200).send();
|
||||
}
|
||||
|
||||
await CfgServer.find({ idapp }).then((arrcfgrec) => {
|
||||
await CfgServer.find({ idapp }).then(async (arrcfgrec) => {
|
||||
|
||||
if (!arrcfgrec)
|
||||
return res.status(404).send();
|
||||
|
||||
// ++Add to Log Stat ....
|
||||
|
||||
let last_msgs = null;
|
||||
let last_notifs = null;
|
||||
let last_notifcoins = null;
|
||||
let usersList = null;
|
||||
// const sall = '0';
|
||||
|
||||
// msgs = SendMsg.findAllByUserIdAndIdApp(userId, req.user.username, req.user.idapp);
|
||||
let last_msgs = SendMsg.findLastGroupByUserIdAndIdApp(userId, req.user.username, idapp);
|
||||
let last_notifs = SendNotif.findLastNotifsByUserIdAndIdApp(req.user.username, idapp, 40);
|
||||
|
||||
let usersList = null;
|
||||
|
||||
if (req.user) {
|
||||
// If User is Admin, then send user Lists
|
||||
if (User.isAdmin(req.user.perm) || User.isEditor(req.user.perm) ||
|
||||
User.isManager(req.user.perm)) {
|
||||
|
||||
// Send UsersList
|
||||
usersList = User.getUsersList(idapp);
|
||||
// usersList = null;
|
||||
const userId = req.user._id;
|
||||
if (!ObjectID.isValid(userId)) {
|
||||
return res.status(404).send();
|
||||
}
|
||||
|
||||
last_msgs = SendMsg.findLastGroupByUserIdAndIdApp(userId, req.user.username, idapp);
|
||||
last_notifs = SendNotif.findLastNotifsByUserIdAndIdApp(req.user.username, idapp, 40);
|
||||
last_notifcoins_inattesa = SendNotif.findLastNotifCoinsByUserIdAndIdApp(req.user.username, idapp, 200, true);
|
||||
last_notifcoins = SendNotif.findLastNotifCoinsByUserIdAndIdApp(req.user.username, idapp, 1, false);
|
||||
|
||||
if (req.user) {
|
||||
// If User is Admin, then send user Lists
|
||||
if (User.isAdmin(req.user.perm) || User.isEditor(req.user.perm) ||
|
||||
User.isManager(req.user.perm)) {
|
||||
|
||||
// Send UsersList
|
||||
usersList = User.getUsersList(idapp);
|
||||
// usersList = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.all([usersList, last_msgs, last_notifs]).then((arrdata) => {
|
||||
return Promise.all([usersList, last_msgs, last_notifs, last_notifcoins, last_notifcoins_inattesa]).then((arrdata) => {
|
||||
// console.table(arrdata);
|
||||
return res.send({
|
||||
CfgServer: arrcfgrec,
|
||||
usersList: arrdata[0],
|
||||
last_msgs: arrdata[1],
|
||||
last_notifs: arrdata[2],
|
||||
last_notifcoins: [...arrdata[4], ...arrdata[3]],
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1824,7 +1873,7 @@ function uploadFile(req, res, version) {
|
||||
|
||||
oldpath = file.newFilename;
|
||||
|
||||
|
||||
|
||||
let fromfile = '.' + server_constants.DIR_UPLOAD + '/' + dir + '/' + oldpath;
|
||||
let tofile = '.' + server_constants.DIR_UPLOAD + '/' + dir + '/' + file.originalFilename;
|
||||
let mydircurrent = process.cwd() + '/src/server/router/upload/' + dir;
|
||||
@@ -1836,6 +1885,8 @@ function uploadFile(req, res, version) {
|
||||
// console.log('tofile', tofile);
|
||||
|
||||
if (!tools.sulServer()) {
|
||||
console.log('Dovresti copiare fromfile', fromfile, 'tofile', tofile);
|
||||
console.log('cp ', fromfile, tofile);
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ async function getDataNewsletter(lang, idapp) {
|
||||
|
||||
for (const user of arrml) {
|
||||
data.totemail++;
|
||||
if (user.statesub)
|
||||
if (user.news_on)
|
||||
data.totsubscribed++;
|
||||
else
|
||||
data.totunsubscribed++;
|
||||
@@ -284,6 +284,38 @@ router.post('/setactivate', authenticate, async (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
router.post('/unsubscribe_user', async (req, res) => {
|
||||
hashemail = req.body.em;
|
||||
email = req.body.email;
|
||||
idapp = req.body.idapp;
|
||||
locale = req.body.locale ?? 'it';
|
||||
|
||||
try {
|
||||
const myuser = await User.findOne({ idapp, email }).lean();
|
||||
|
||||
if (myuser) {
|
||||
const hashcalc = tools.getHash(myuser.email + myuser.username);
|
||||
|
||||
if (hashcalc === hashemail) {
|
||||
await User.setNewsletter(idapp, myuser.username, false);
|
||||
|
||||
return res.send({
|
||||
code: server_constants.RIS_UNSUBSCRIBED_OK,
|
||||
msg: server_constants.RIS_SUBSCRIBED_MSG[locale]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error('err', e);
|
||||
}
|
||||
res.send({
|
||||
code: server_constants.RIS_SUBSCRIBED_ERR
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
router.post('/unsubscribe', (req, res) => {
|
||||
|
||||
console.log('unsubscribe -> ', req.body);
|
||||
|
||||
@@ -31,7 +31,7 @@ const Cart = require('../models/cart');
|
||||
router.post('/', auth_default, async function (req, res, next) {
|
||||
const idapp = req.body.idapp;
|
||||
const userId = req.body.userId;
|
||||
|
||||
|
||||
let ismanager = await tools.isManagerByReq(req);
|
||||
|
||||
let products = await Product.findAllIdApp(idapp, "", undefined, ismanager);
|
||||
@@ -43,11 +43,32 @@ router.post('/', auth_default, async function (req, res, next) {
|
||||
orders = await OrdersCart.getOrdersCartByUserId(userId, idapp, 0, false);
|
||||
}
|
||||
|
||||
/*
|
||||
let ind = 0;
|
||||
for (const ord of orders) {
|
||||
let newitems = []
|
||||
for (myord of ord.items) {
|
||||
if (!myord.order) {
|
||||
console.log('NO ORDINE ', myord, 'Ind=', ind);
|
||||
} else {
|
||||
if (myord.order && !myord.order.hasOwnProperty('idGasordine')) {
|
||||
console.log('NO idGasordine', myord);
|
||||
} else {
|
||||
newitems.push(myord)
|
||||
}
|
||||
}
|
||||
}
|
||||
ind++;
|
||||
|
||||
ord.items = newitems
|
||||
}
|
||||
*/
|
||||
|
||||
if (products)
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, products, orders });
|
||||
else
|
||||
return res.status(400).send({ code: server_constants.RIS_CODE_OK, products, orders });
|
||||
|
||||
|
||||
});
|
||||
|
||||
router.post('/:code', auth_default, async function (req, res, next) {
|
||||
|
||||
@@ -4,10 +4,10 @@ const router = express.Router();
|
||||
const tools = require('../tools/general');
|
||||
const server_constants = require('../tools/server_constants');
|
||||
|
||||
const {authenticate} = require('../middleware/authenticate');
|
||||
const { authenticate } = require('../middleware/authenticate');
|
||||
|
||||
const {SendNotif} = require('../models/sendnotif');
|
||||
const {User} = require('../models/user');
|
||||
const { SendNotif } = require('../models/sendnotif');
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
@@ -23,9 +23,9 @@ router.post('/', authenticate, async (req, res) => {
|
||||
|
||||
const recout = await SendNotif.saveAndSendNotif(myrecnotif, req, res);
|
||||
if (recout) {
|
||||
return res.send({code: server_constants.RIS_CODE_OK, notif: '', record: recout});
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, notif: '', record: recout });
|
||||
} else {
|
||||
return res.send({code: server_constants.RIS_CODE_ERR, notif: ''});
|
||||
return res.send({ code: server_constants.RIS_CODE_ERR, notif: '' });
|
||||
}
|
||||
|
||||
});
|
||||
@@ -34,17 +34,17 @@ router.get('/setall/:username/:qualinotif/:idapp', authenticate, async (req, res
|
||||
|
||||
const idapp = req.params.idapp;
|
||||
const username = req.params.username;
|
||||
const qualinotif = req.params.qualinotif;
|
||||
const qualinotif = parseInt(req.params.qualinotif);
|
||||
const username_call = req.user.username;
|
||||
|
||||
try {
|
||||
if (username === username_call) {
|
||||
let query = {idapp, dest: username, read: false};
|
||||
let query = { idapp, dest: username, read: false };
|
||||
|
||||
if (qualinotif === shared_consts.QualiNotifs.CIRCUITS) {
|
||||
query.typedir = {$eq: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS};
|
||||
query.typedir = { $eq: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS };
|
||||
} else if (qualinotif === shared_consts.QualiNotifs.OTHERS) {
|
||||
query.typedir = {$neq: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS};
|
||||
query.typedir = { $ne: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS };
|
||||
}
|
||||
const arrNotifs = await SendNotif.find(query).lean();
|
||||
if (arrNotifs) {
|
||||
@@ -67,7 +67,7 @@ router.get('/set/:_id/:idapp', authenticate, async (req, res) => {
|
||||
const username_call = req.user.username;
|
||||
|
||||
try {
|
||||
let query = {_id, dest: username_call, read: false};
|
||||
let query = { _id, dest: username_call, read: false };
|
||||
|
||||
const rec = await SendNotif.findOne(query);
|
||||
if (rec) {
|
||||
@@ -83,17 +83,13 @@ router.get('/set/:_id/:idapp', authenticate, async (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
router.get('/del/:username/:id/:idapp', authenticate, async (req, res) => {
|
||||
|
||||
const idapp = req.params.idapp;
|
||||
const username = req.params.username;
|
||||
const myid = req.params.id;
|
||||
const username_call = req.user.username;
|
||||
async function delNotif(idapp, username, id, username_call) {
|
||||
|
||||
try {
|
||||
if (username === username_call) {
|
||||
|
||||
await SendNotif.findOneAndRemove({idapp, _id: myid});
|
||||
await SendNotif.findOneAndRemove({ idapp, _id: id });
|
||||
return res.send(true);
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -102,23 +98,34 @@ router.get('/del/:username/:id/:idapp', authenticate, async (req, res) => {
|
||||
|
||||
return res.send(false);
|
||||
|
||||
};
|
||||
|
||||
router.get('/del/:username/:id/:idapp', authenticate, async (req, res) => {
|
||||
|
||||
try {
|
||||
return delNotif(req.params.idapp, req.params.username, req.params.id, req.user.username);
|
||||
|
||||
} catch (e) {
|
||||
return res.status(400).send(e);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
router.get('/delall/:username/:qualinotif/:idapp', authenticate, async (req, res) => {
|
||||
|
||||
const idapp = req.params.idapp;
|
||||
const username = req.params.username;
|
||||
const qualinotif = req.params.qualinotif;
|
||||
const qualinotif = parseInt(req.params.qualinotif);
|
||||
const username_call = req.user.username;
|
||||
|
||||
try {
|
||||
if (username === username_call) {
|
||||
let query = {idapp, dest: username};
|
||||
let query = { idapp, dest: username };
|
||||
|
||||
if (qualinotif === shared_consts.QualiNotifs.CIRCUITS) {
|
||||
query.typedir = {$eq: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS};
|
||||
query.typedir = { $eq: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS };
|
||||
} else if (qualinotif === shared_consts.QualiNotifs.OTHERS) {
|
||||
query.typedir = {$neq: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS};
|
||||
query.typedir = { $ne: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS };
|
||||
}
|
||||
const ris = await SendNotif.deleteMany(query);
|
||||
if (ris)
|
||||
@@ -133,31 +140,38 @@ router.get('/delall/:username/:qualinotif/:idapp', authenticate, async (req, res
|
||||
});
|
||||
|
||||
router.get('/:username/:lastdataread/:idapp', authenticate, (req, res) => {
|
||||
// tools.mylog('GET NotifS : ', req.params);
|
||||
const username = req.params.username;
|
||||
const lastdataread = req.params.lastdataread;
|
||||
const idapp = req.params.idapp;
|
||||
// var category = req.params.category;
|
||||
return getNotif(req, res);
|
||||
});
|
||||
|
||||
if (req.user.idapp !== idapp) {
|
||||
// I'm trying to get something not mine!
|
||||
return res.status(404).send({code: server_constants.RIS_CODE_NOT_MY_USERNAME});
|
||||
}
|
||||
async function getNotif(req, res) {
|
||||
|
||||
try {
|
||||
// tools.mylog('GET NotifS : ', req.params);
|
||||
const username = req.params.username;
|
||||
const lastdataread = req.params.lastdataread;
|
||||
const idapp = req.params.idapp;
|
||||
|
||||
// var category = req.params.category;
|
||||
|
||||
if (req.user.idapp !== idapp) {
|
||||
// I'm trying to get something not mine!
|
||||
return res.status(404).send({ code: server_constants.RIS_CODE_NOT_MY_USERNAME });
|
||||
}
|
||||
|
||||
const arrnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdataread, idapp, shared_consts.LIMIT_NOTIF_FOR_USER, shared_consts.QualiNotifs.OTHERS);
|
||||
const arrnotifcoins_inattesa = await SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdataread, idapp, shared_consts.LIMIT_NOTIFCOINS_IN_ATTESA_FOR_USER, shared_consts.QualiNotifs.CIRCUITS, [{ status: 0 }]);
|
||||
const arrnotifcoins = await SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdataread, idapp, shared_consts.LIMIT_NOTIFCOINS_FOR_USER, shared_consts.QualiNotifs.CIRCUITS, [{ status: {$ne: 0 }}]);
|
||||
|
||||
return SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdataread, idapp, shared_consts.LIMIT_NOTIF_FOR_USER).then(async (arrnotif) => {
|
||||
// const wait = new Promise((resolve, reject) => {
|
||||
// setTimeout(() => {
|
||||
|
||||
//++Todo: Ottimizzare ! Non occorre inviare tutti questi dati !!! Solo per il Circuito ?!
|
||||
const userprofile = await User.getExtraInfoByUsername(idapp, req.user.username);
|
||||
|
||||
return res.send({arrnotif, userprofile});
|
||||
return res.send({ arrnotif, arrnotifcoins: [...arrnotifcoins, ...arrnotifcoins_inattesa], userprofile });
|
||||
|
||||
}).catch((e) => {
|
||||
} catch (e) {
|
||||
console.log(e.message);
|
||||
res.status(400).send(e);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -5,7 +5,7 @@ const Subscription = require('../models/subscribers');
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
var {authenticate} = require('../middleware/authenticate');
|
||||
var { authenticate } = require('../middleware/authenticate');
|
||||
|
||||
const isValidSaveRequest = (req, res) => {
|
||||
try {
|
||||
@@ -54,7 +54,7 @@ router.post('/', authenticate, async (req, res) => {
|
||||
|
||||
if (myitem === null) {
|
||||
myitem = subscriptionModel;
|
||||
tools.mylogshow('Subscription NOT EXISTED IN DB, so I use this created!')
|
||||
// tools.mylogshow('Subscription NOT EXISTED IN DB, so I use this created!')
|
||||
} else {
|
||||
myitem.endpoint = subscriptionModel.endpoint;
|
||||
myitem.keys = subscriptionModel.keys;
|
||||
@@ -79,7 +79,7 @@ router.post('/', authenticate, async (req, res) => {
|
||||
tools.sendBackNotif(subscription, req.body.options);
|
||||
}
|
||||
// console.log('Subscription saved... ')
|
||||
return res.send({data: 'Subscription saved.'});
|
||||
return res.send({ data: 'Subscription saved.' });
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -88,13 +88,19 @@ router.post('/', authenticate, async (req, res) => {
|
||||
|
||||
router.delete('/del', authenticate, (req, res) => {
|
||||
// tools.mylog("TOKENREM = " + req.token);
|
||||
const browser = req.get('User-Agent');
|
||||
Subscription.findOneAndRemove(
|
||||
{userId: req.user._id, access: req.access, browser}).then(() => {
|
||||
res.status(200).send();
|
||||
}, () => {
|
||||
res.status(400).send();
|
||||
});
|
||||
try {
|
||||
|
||||
|
||||
const browser = req.get('User-Agent');
|
||||
Subscription.findOneAndRemove(
|
||||
{ userId: req.user._id, access: req.access, browser }).then(() => {
|
||||
res.status(200).send();
|
||||
}, () => {
|
||||
res.status(400).send();
|
||||
});
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/', (req, res) => {
|
||||
|
||||
@@ -46,6 +46,8 @@ const TypedError = require('../modules/ErrorHandler');
|
||||
|
||||
const { MyGroup } = require('../models/mygroup');
|
||||
const { Circuit } = require('../models/circuit');
|
||||
const { Province } = require('../models/province');
|
||||
const { City } = require('../models/city');
|
||||
const { Account } = require('../models/account');
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
@@ -167,7 +169,9 @@ router.post('/', async (req, res) => {
|
||||
user.surname;
|
||||
tools.writeIPToBan(msg);
|
||||
|
||||
await telegrambot.sendMsgTelegramToTheAdmin(body.idapp, 'BAN: ' + msg, true);
|
||||
await User.findOneAndUpdate({ _id: user._id }, { $set: { banIp: true } });
|
||||
|
||||
await telegrambot.sendMsgTelegramToTheAdmin(body.idapp, '‼️ BAN: ' + msg, true);
|
||||
|
||||
await tools.snooze(5000);
|
||||
res.status(400).
|
||||
@@ -262,8 +266,16 @@ router.post('/', async (req, res) => {
|
||||
|
||||
user.aportador_solidario = user.aportador_solidario.trim();
|
||||
|
||||
const id_aportador = await User.getIdByUsername(user.idapp, user.aportador_solidario);
|
||||
let id_aportador = await User.getIdByUsername(user.idapp, user.aportador_solidario);
|
||||
if (!id_aportador) {
|
||||
// Cerca se esiste l'aportador solidario con l'username Telegram
|
||||
const useraportador = await User.getUserByUsernameTelegram(user.idapp, user.aportador_solidario);
|
||||
id_aportador = useraportador._id;
|
||||
user.aportador_solidario = useraportador.username;
|
||||
}
|
||||
|
||||
if (id_aportador) {
|
||||
// Ottiene l'username "corretto" (senza maiuscole o minuscole)
|
||||
user.aportador_solidario = await User.getRealUsernameByUsername(user.idapp, user.aportador_solidario);
|
||||
}
|
||||
|
||||
@@ -294,8 +306,11 @@ router.post('/', async (req, res) => {
|
||||
|
||||
await telegrambot.askConfirmationUser(myuser.idapp, shared_consts.CallFunz.REGISTRATION, myuser);
|
||||
|
||||
const token = await myuser.generateAuthToken(req);
|
||||
res.header('x-auth', token).send(myuser);
|
||||
const { token, refreshToken } = await myuser.generateAuthToken(req);
|
||||
res
|
||||
.header('x-auth', token)
|
||||
.header('x-refrtok', refreshToken)
|
||||
.send(myuser);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -329,7 +344,7 @@ router.post('/', async (req, res) => {
|
||||
return 0;
|
||||
}
|
||||
}).
|
||||
then(async (token) => {
|
||||
then(async (ris) => {
|
||||
// tools.mylog("passo il TOKEN: ", token);
|
||||
|
||||
if (recextra) {
|
||||
@@ -339,9 +354,9 @@ router.post('/', async (req, res) => {
|
||||
|
||||
// await User.fixUsername(user.idapp, user.ind_order, user.username);
|
||||
}
|
||||
return token;
|
||||
return ris;
|
||||
}).
|
||||
then(async (token) => {
|
||||
then(async (ris) => {
|
||||
|
||||
// tools.mylog("LINKREG = " + user.linkreg);
|
||||
// Invia un'email all'utente
|
||||
@@ -354,7 +369,10 @@ router.post('/', async (req, res) => {
|
||||
await sendemail.sendEmail_Registration(user.lang, user.email, user,
|
||||
user.idapp, user.linkreg);
|
||||
// }
|
||||
res.header('x-auth', token).send(user);
|
||||
res
|
||||
.header('x-auth', ris.token)
|
||||
.header('x-refrtok', ris.refreshToken)
|
||||
.send(user);
|
||||
return true;
|
||||
});
|
||||
}).catch((e) => {
|
||||
@@ -371,15 +389,18 @@ router.get('/:idapp/:username', async (req, res) => {
|
||||
// return res.status(200).send();
|
||||
// }
|
||||
|
||||
await User.findByUsername(idapp, username, false, true).then((user) => {
|
||||
await User.findByUsername(idapp, username, false, true).then(async (user) => {
|
||||
if (!user) {
|
||||
return res.status(404).send();
|
||||
user = await User.findByUsernameTelegram(idapp, username, false, true);
|
||||
if (!user)
|
||||
return res.status(404).send();
|
||||
}
|
||||
// console.log('TROVATO!')
|
||||
return res.status(200).send();
|
||||
}).catch((e) => {
|
||||
return res.status(400).send();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
router.patch('/:id', authenticate, (req, res) => {
|
||||
@@ -440,7 +461,7 @@ router.post('/receiveris', authenticate, (req, res) => {
|
||||
};
|
||||
});
|
||||
|
||||
router.post('/profile', authenticate_noerror, (req, res) => {
|
||||
router.post('/profile', authenticate, (req, res) => {
|
||||
const usernameOrig = req.user ? req.user.username : '';
|
||||
const perm = req.user ? req.user.perm : tools.Perm.PERM_NONE;
|
||||
const username = req.body['username'];
|
||||
@@ -461,7 +482,7 @@ router.post('/profile', authenticate_noerror, (req, res) => {
|
||||
return User.getFriendsByUsername(idapp, usernameOrig).
|
||||
then(async (friends) => {
|
||||
if (username === usernameOrig) {
|
||||
const userprofile = await User.getExtraInfoByUsername(idapp, username);
|
||||
const userprofile = await User.getExtraInfoByUsername(idapp, ris.username);
|
||||
ris.profile = userprofile;
|
||||
}
|
||||
|
||||
@@ -482,6 +503,54 @@ router.post('/profile', authenticate_noerror, (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
router.post('/activities', authenticate_noerror, (req, res) => {
|
||||
const usernameOrig = req.user ? req.user.username : '';
|
||||
const perm = req.user ? req.user.perm : tools.Perm.PERM_NONE;
|
||||
const username = req.body['username'];
|
||||
const idapp = req.body.idapp;
|
||||
const locale = req.body.locale;
|
||||
|
||||
//++Todo: controlla che tipo di dati ha il permesso di leggere
|
||||
|
||||
try {
|
||||
// Check if ìs a Notif to read
|
||||
const idnotif = req.body['idnotif'] ? req.body['idnotif'] : '';
|
||||
SendNotif.setNotifAsRead(idapp, usernameOrig, idnotif);
|
||||
|
||||
return User.getUserProfileByUsername(idapp, username, usernameOrig,
|
||||
false, perm).
|
||||
then((ris) => {
|
||||
|
||||
return User.getFriendsByUsername(idapp, usernameOrig).
|
||||
then(async (friends) => {
|
||||
let userprofile = null;
|
||||
if (req.user) {
|
||||
userprofile = await User.getExtraInfoByUsername(idapp, ris.username);
|
||||
} else {
|
||||
userprofile = await User.getProfilePerActivitiesByUsername(idapp, ris.username);
|
||||
ris.aportador_solidario = '';
|
||||
ris.date_reg = '';
|
||||
ris.email = '';
|
||||
}
|
||||
ris.profile = userprofile;
|
||||
|
||||
return { ris, friends };
|
||||
|
||||
}).then(tot => {
|
||||
return res.send({ user: tot.ris, friends: tot.friends });
|
||||
});
|
||||
|
||||
}).catch((e) => {
|
||||
tools.mylog('ERRORE IN Profile: ' + e.message);
|
||||
res.status(400).send();
|
||||
});
|
||||
} catch (e) {
|
||||
tools.mylogserr('Error profile: ', e);
|
||||
res.status(400).send();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
router.post('/panel', authenticate, async (req, res) => {
|
||||
const username = req.body['username'];
|
||||
idapp = req.body.idapp;
|
||||
@@ -553,7 +622,65 @@ router.post('/notifs', authenticate, async (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
router.post('/login', (req, res) => {
|
||||
router.post('/newtok', async (req, res) => {
|
||||
|
||||
try {
|
||||
const refreshToken = req.body.refreshToken;
|
||||
|
||||
// Ottieni l'utente in base al refreshtoken
|
||||
const recFound = await User.findOne({ 'tokens.refreshToken': refreshToken });
|
||||
|
||||
console.log('recFound', recFound ? recFound.name : 'NOTFOUND', 'Token=', refreshToken);
|
||||
|
||||
if (recFound) {
|
||||
return recFound.generateAuthToken(req)
|
||||
.then((ris) => {
|
||||
return res.status(200).send({
|
||||
usertosend: recFound,
|
||||
token: ris.token,
|
||||
refreshToken: ris.refreshToken
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
}
|
||||
|
||||
res.status(404).send({ code: server_constants.RIS_CODE_HTTP_INVALID_TOKEN });
|
||||
|
||||
});
|
||||
|
||||
// Dizionario per tenere traccia dei tentativi di accesso falliti per ogni utente
|
||||
const failedLoginAttempts = {};
|
||||
|
||||
// Costante per il numero massimo di tentativi di accesso falliti prima del blocco
|
||||
const MAX_FAILED_ATTEMPTS = 30;
|
||||
|
||||
// Costante per la durata del blocco in millisecondi (ad esempio 30 minuti)
|
||||
const BLOCK_DURATION = 30 * 60 * 1000; // 30 minuti
|
||||
|
||||
// Funzione per bloccare un utente per un periodo di tempo dopo un numero specificato di tentativi falliti
|
||||
function blockUser(username) {
|
||||
failedLoginAttempts[username] = Date.now() + BLOCK_DURATION;
|
||||
}
|
||||
|
||||
// Middleware per controllare se l'utente è bloccato
|
||||
function checkBlocked(req, res, next) {
|
||||
const { username } = req.body;
|
||||
const now = Date.now();
|
||||
|
||||
if (failedLoginAttempts[username] && failedLoginAttempts[username] > now) {
|
||||
text = 'Utente bloccato. Riprova più tardi. (username=' + username + ')';
|
||||
console.log(text);
|
||||
return res.status(403).json({ message: 'Utente bloccato. Riprova più tardi.' });
|
||||
}
|
||||
|
||||
next();
|
||||
}
|
||||
|
||||
|
||||
router.post('/login', checkBlocked, (req, res) => {
|
||||
var body = _.pick(req.body,
|
||||
['username', 'password', 'idapp', 'keyappid', 'lang']);
|
||||
var user = new User(body);
|
||||
@@ -570,25 +697,54 @@ router.post('/login', (req, res) => {
|
||||
|
||||
const myuser = user;
|
||||
|
||||
User.findByCredentials(user.idapp, user.username, user.password).
|
||||
return User.findByCredentials(user.idapp, user.username, user.password).
|
||||
then(async (user) => {
|
||||
// tools.mylog("CREDENZIALI ! ");
|
||||
if (!user) {
|
||||
|
||||
const rislogin = await User.tooManyLoginWrong(body.idapp, body.username, true);
|
||||
if (rislogin.troppilogin) {
|
||||
let text = 'Troppe richieste di Login ERRATE: ' + body.username + ' [IP: ' + tools.getiPAddressUser(req) + '] Tentativi: ' + rislogin.retry_pwd;
|
||||
telegrambot.sendMsgTelegramToTheManagers(body.idapp, text);
|
||||
console.log('/login', text);
|
||||
res.status(400).send({ code: server_constants.RIS_CODE_ERR, msg: text });
|
||||
return false;
|
||||
}
|
||||
|
||||
await tools.snooze(3000);
|
||||
const msg = 'Tentativo di Login ERRATO [' + body.username + ' , ' + ']\n' + '[IP: ' + tools.getiPAddressUser(req) +
|
||||
']';
|
||||
|
||||
if (!failedLoginAttempts[body.username]) {
|
||||
failedLoginAttempts[body.username] = 1;
|
||||
} else {
|
||||
failedLoginAttempts[body.username]++;
|
||||
}
|
||||
|
||||
|
||||
const msg = 'Tentativo (' + failedLoginAttempts[body.username] + ') di Login ERRATO [' + body.username + ' , ' + ']\n' + '[IP: ' + tools.getiPAddressUser(req) + ']';
|
||||
tools.mylogshow(msg);
|
||||
await telegrambot.sendMsgTelegramToTheAdmin(myuser.idapp, msg, true);
|
||||
tools.writeErrorLog(msg);
|
||||
// telegrambot.sendMsgTelegramToTheManagers(body.idapp, msg);
|
||||
res.status(404).send({ code: server_constants.RIS_CODE_LOGIN_ERR });
|
||||
|
||||
if (failedLoginAttempts[body.username] >= MAX_FAILED_ATTEMPTS) {
|
||||
blockUser(body.username);
|
||||
text = 'Troppi tentativi di accesso falliti. Utente bloccato (' + body.username + ')' + ' [IP: ' + tools.getiPAddressUser(req) + ']';
|
||||
tools.mylogshow(text);
|
||||
telegrambot.sendMsgTelegramToTheManagers(req.body.idapp, text);
|
||||
res.status(403).json({ message: text });
|
||||
resalreadysent = true;
|
||||
}
|
||||
|
||||
res.status(401).send({ code: server_constants.RIS_CODE_LOGIN_ERR });
|
||||
resalreadysent = true;
|
||||
|
||||
}
|
||||
return user;
|
||||
}).
|
||||
then(user => {
|
||||
// console.log('Lgn-Ok');
|
||||
if (user) {
|
||||
return user.generateAuthToken(req).then((token) => {
|
||||
return user.generateAuthToken(req).then((ris) => {
|
||||
var usertosend = new User();
|
||||
|
||||
shared_consts.fieldsUserToChange().forEach((field) => {
|
||||
@@ -603,7 +759,7 @@ router.post('/login', (req, res) => {
|
||||
// tools.mylog("user.verified_email:" + user.verified_email);
|
||||
// tools.mylog("usertosend.userId", usertosend.userId);
|
||||
|
||||
return { usertosend, token };
|
||||
return { usertosend, token: ris.token, refreshToken: ris.refreshToken };
|
||||
|
||||
}).then((myris) => {
|
||||
const access = 'auth';
|
||||
@@ -619,6 +775,7 @@ router.post('/login', (req, res) => {
|
||||
return {
|
||||
usertosend: myris.usertosend,
|
||||
token: myris.token,
|
||||
refreshToken: myris.refreshToken,
|
||||
subsExistonDb,
|
||||
};
|
||||
}).
|
||||
@@ -626,6 +783,7 @@ router.post('/login', (req, res) => {
|
||||
return {
|
||||
usertosend: myris.usertosend,
|
||||
token: myris.token,
|
||||
refreshToken: myris.refreshToken,
|
||||
subsExistonDb: false,
|
||||
};
|
||||
});
|
||||
@@ -633,11 +791,14 @@ router.post('/login', (req, res) => {
|
||||
// console.log('res', myris.token, myris.usertosend);
|
||||
|
||||
// SEND TOKEN AND CODE RESULT
|
||||
return res.header('x-auth', myris.token).send({
|
||||
usertosend: myris.usertosend,
|
||||
code: server_constants.RIS_CODE_OK,
|
||||
subsExistonDb: myris.subsExistonDb,
|
||||
});
|
||||
return res
|
||||
.header('x-auth', myris.token)
|
||||
.header('x-refrtok', myris.refreshToken)
|
||||
.send({
|
||||
usertosend: myris.usertosend,
|
||||
code: server_constants.RIS_CODE_OK,
|
||||
subsExistonDb: myris.subsExistonDb,
|
||||
});
|
||||
|
||||
// tools.mylog("TROVATOOO!");
|
||||
|
||||
@@ -741,9 +902,8 @@ router.post('/updatesaldo', authenticate, async (req, res) => {
|
||||
userprofile
|
||||
}
|
||||
|
||||
const arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER);
|
||||
|
||||
ris.arrrecnotif = arrrecnotif;
|
||||
ris.arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER, shared_consts.QualiNotifs.OTHERS);
|
||||
ris.arrrecnotifcoins = await SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdr, idapp, shared_consts.LIMIT_NOTIFCOINS_FOR_USER, shared_consts.QualiNotifs.CIRCUITS);
|
||||
|
||||
return res.send({ ris });
|
||||
|
||||
@@ -895,6 +1055,9 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
||||
|
||||
// } else if (mydata.dbop === 'rigeneraTutto') {
|
||||
// await ListaIngresso.Esegui_CronTab(idapp, mydata);
|
||||
} else if (mydata.dbop === 'ReplaceAllCircuits') {
|
||||
// ++ Replace All Circuitname with 'Circuito RIS %s'
|
||||
await Circuit.replaceAllCircuitNames(idapp);
|
||||
} else if (mydata.dbop === 'visuStat') {
|
||||
// ris = await User.visuUtentiNonInNavi(idapp);
|
||||
//} else if (mydata.dbop === 'creaNavi') {
|
||||
@@ -1245,6 +1408,32 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
||||
|
||||
} else if (mydata.dbop === 'updateReactionsCounts') {
|
||||
await Reaction.updateReactionsCounts();
|
||||
} else if (mydata.dbop === 'GeneraCSVOrdineProdotti') {
|
||||
await Order.GeneraCSVOrdineProdotti();
|
||||
} else if (mydata.dbop === 'RemoveDeletedOrdersInOrderscart') {
|
||||
await Order.RemoveDeletedOrdersInOrderscart();
|
||||
} else if (mydata.dbop === 'CheckTransazioniCircuiti') {
|
||||
await Circuit.CheckTransazioniCircuiti(false);
|
||||
} else if (mydata.dbop === 'CorreggiTransazioniCircuiti') {
|
||||
await Circuit.CheckTransazioniCircuiti(true);
|
||||
} else if (mydata.dbop === 'UpdateCoordProv') {
|
||||
await Province.setCoordinatesOnDB();
|
||||
} else if (mydata.dbop === 'insertGeojsonToMongoDB') {
|
||||
await City.insertGeojsonToMongoDB('comuni_italia.geojson');
|
||||
} else if (mydata.dbop === 'AbilitaNewsletterALL') {
|
||||
await User.updateMany({
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
|
||||
},
|
||||
{ $set: { news_on: true } },
|
||||
{ new: false });
|
||||
|
||||
} else if (mydata.dbop === 'SvuotaTuttiGliAccessiOnlineConToken') {
|
||||
await User.SvuotaTuttiGliAccessiOnlineConToken(idapp);
|
||||
} else if (mydata.dbop === 'removeRegulations') {
|
||||
await Circuit.updateMany({}, { $set: { regulation: '' } });
|
||||
|
||||
} else if (mydata.dbop === 'newRecordsFav') {
|
||||
// Passa le tabelle da users sulle nuove tabelle:
|
||||
@@ -1624,10 +1813,11 @@ async function eseguiDbOpUser(idapp, mydata, locale, req, res) {
|
||||
} else if (mydata.dbop === 'noFoto') {
|
||||
await User.findOneAndUpdate({ _id: mydata._id },
|
||||
{ $set: { 'profile.noFoto': mydata.value } });
|
||||
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
|
||||
console.log(e.message);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -1688,6 +1878,113 @@ router.post('/dbopuser', authenticate, async (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
router.post('/infomap', authenticate, async (req, res) => {
|
||||
|
||||
const idapp = req.body.idapp;
|
||||
const raggruppa = true;
|
||||
|
||||
try {
|
||||
let myquery = [
|
||||
{
|
||||
$match: {
|
||||
idapp,
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "provinces", // Collezione delle province
|
||||
localField: "profile.resid_province", // Campo nella collezione User che contiene l'ID della provincia
|
||||
foreignField: "prov", // Campo nella collezione Province che identifica l'ID della provincia
|
||||
as: "provinceInfo" // Nome del campo in cui verranno memorizzate le informazioni della provincia
|
||||
}
|
||||
},
|
||||
{
|
||||
$addFields: {
|
||||
"provinceInfo": { $arrayElemAt: ["$provinceInfo", 0] } // Estrae il primo elemento dell'array provinceInfo
|
||||
}
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
email: 1,
|
||||
verified_by_aportador: 1,
|
||||
aportador_solidario: 1,
|
||||
lasttimeonline: 1,
|
||||
'profile.img': 1,
|
||||
'profile.resid_province': 1,
|
||||
lat: "$provinceInfo.lat", // Aggiunge il campo lat preso dalla provincia
|
||||
long: "$provinceInfo.long" // Aggiunge il campo long preso dalla provincia
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
let ris = null;
|
||||
|
||||
if (raggruppa) {
|
||||
const myquery = [
|
||||
{
|
||||
$lookup: {
|
||||
from: "users", // Collezione degli utenti
|
||||
localField: "prov", // Campo nella collezione Province che identifica l'ID della provincia
|
||||
foreignField: "profile.resid_province", // Campo nella collezione User che contiene l'ID della provincia
|
||||
as: "users" // Nome del campo in cui verranno memorizzati gli utenti della provincia
|
||||
}
|
||||
},
|
||||
{
|
||||
$addFields: {
|
||||
userCount: { $size: "$users" } // Aggiunge il numero di utenti nella provincia
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "provinces", // Collezione delle province
|
||||
localField: "prov", // Campo nella collezione Province che identifica l'ID della provincia
|
||||
foreignField: "prov", // Campo nella collezione Province che identifica l'ID della provincia
|
||||
as: "provinceInfo" // Nome del campo in cui verranno memorizzate le informazioni della provincia
|
||||
}
|
||||
},
|
||||
{
|
||||
$addFields: {
|
||||
provinceDescr: { $arrayElemAt: ["$provinceInfo.descr", 0] } // Aggiunge il campo descr preso dalla provincia
|
||||
}
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
_id: 0, // Esclude il campo _id
|
||||
province: "$prov", // Rinomina il campo prov come province
|
||||
descr: "$provinceDescr",
|
||||
userCount: 1,
|
||||
lat: 1, // Include il campo lat
|
||||
long: 1 // Include il campo long
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
ris = await Province.aggregate(myquery);
|
||||
} else {
|
||||
ris = await User.aggregate(myquery);
|
||||
}
|
||||
|
||||
if (!ris) {
|
||||
ris = {};
|
||||
}
|
||||
|
||||
res.send({ code: server_constants.RIS_CODE_OK, ris });
|
||||
|
||||
} catch (e) {
|
||||
res.status(400).send({ code: server_constants.RIS_CODE_ERR, msg: e });
|
||||
|
||||
console.log(e.message);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
router.post('/mgt', authenticate, async (req, res) => {
|
||||
|
||||
const mydata = req.body.mydata;
|
||||
|
||||
@@ -540,7 +540,7 @@ module.exports = {
|
||||
|
||||
// Check if exist to the Mailing List
|
||||
let myperson = await MailingList.findByHash(idapp, hash);
|
||||
if (!myperson || !myperson.statesub || !myperson.wrongerr) {
|
||||
if (!myperson || !myperson.news_on || !myperson.email_errata) {
|
||||
if (!myperson) {
|
||||
myperson = new MailingList({
|
||||
name: mylocalsconf.name,
|
||||
@@ -557,8 +557,8 @@ module.exports = {
|
||||
}
|
||||
|
||||
myperson.idapp = idapp;
|
||||
myperson.statesub = true; // subscription
|
||||
myperson.wrongerr = false;
|
||||
myperson.news_on = true; // subscription
|
||||
myperson.email_errata = false;
|
||||
|
||||
// Add/save new record to the DB MailingList
|
||||
const res = await myperson.save();
|
||||
@@ -597,9 +597,9 @@ module.exports = {
|
||||
}
|
||||
|
||||
const fields_to_update = {
|
||||
statesub: false,
|
||||
news_on: false,
|
||||
};
|
||||
let myperson = await MailingList.findOneAndUpdate({
|
||||
let myperson = await User.findOneAndUpdate({
|
||||
idapp,
|
||||
hash: hashemail,
|
||||
}, { $set: fields_to_update }, { new: false });
|
||||
@@ -618,16 +618,20 @@ module.exports = {
|
||||
},
|
||||
|
||||
fieldsloop: function (mylocalsconf, myvar) {
|
||||
const baseurl = tools.getHostByIdApp(mylocalsconf.idapp);
|
||||
const urlunsibscribe = baseurl + '/unsubscribe?em=' + mylocalsconf.hashemail + '&mc=' + mylocalsconf.dataemail.mailchimpactive +
|
||||
'&email=' + mylocalsconf.emailto;
|
||||
let out = '';
|
||||
try {
|
||||
out = myvar.replace('{urlunsubscribe}', tools.getUnsubsribeUrl(mylocalsconf));
|
||||
out = out.replace('{urlunsubscribe_user}', tools.getUnsubsribeUrl_User({ idapp: mylocalsconf.idapp, email: mylocalsconf.emailto, username: mylocalsconf.username, name: mylocalsconf.name, surname: mylocalsconf.surname }));
|
||||
|
||||
let out = myvar.replace('{urlunsubscribe}', urlunsibscribe);
|
||||
out = out.replace('{email}', mylocalsconf.emailto);
|
||||
out = out.replace('{username}', mylocalsconf.username);
|
||||
out = out.replace('{name}', mylocalsconf.name ? mylocalsconf.name : mylocalsconf.username);
|
||||
out = out.replace('{surname}', mylocalsconf.surname ? mylocalsconf.surname : '');
|
||||
out = out.replace('{aportador_solidario}', mylocalsconf.aportador_solidario ? mylocalsconf.aportador_solidario : '');
|
||||
out = out.replace('{email}', mylocalsconf.emailto);
|
||||
out = out.replace('{username}', mylocalsconf.username);
|
||||
out = out.replace('{name}', mylocalsconf.name ? mylocalsconf.name : mylocalsconf.username);
|
||||
out = out.replace('{surname}', mylocalsconf.surname ? mylocalsconf.surname : '');
|
||||
out = out.replace('{aportador_solidario}', mylocalsconf.aportador_solidario ? mylocalsconf.aportador_solidario : '');
|
||||
} catch (e) {
|
||||
console.error('err fieldsloop', e);
|
||||
return out;
|
||||
}
|
||||
|
||||
return out;
|
||||
},
|
||||
@@ -641,6 +645,10 @@ module.exports = {
|
||||
if (mylocalsconf.dataemail.templ)
|
||||
mylocalsconf.dataemail.templ.testoheadermail_out = !!mylocalsconf.dataemail.templ.testoheadermail ? this.fieldsloop(mylocalsconf,
|
||||
mylocalsconf.dataemail.templ.testoheadermail) : '';
|
||||
|
||||
mylocalsconf.dataemail.templ.content = !!mylocalsconf.dataemail.templ.content ? this.fieldsloop(mylocalsconf,
|
||||
mylocalsconf.dataemail.templ.content) : '';
|
||||
|
||||
} catch (e) {
|
||||
console.error('Error replacefields: ' + e);
|
||||
}
|
||||
@@ -896,7 +904,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
//Put the result in the database, to check if is sent or not.
|
||||
const updateml = await MailingList.findOneAndUpdate({
|
||||
const updateml = await User.findOneAndUpdate({
|
||||
idapp,
|
||||
email: user.email,
|
||||
}, { $set: { lastid_newstosent: ObjectID(id_newstosent) } }, { new: false });
|
||||
@@ -949,7 +957,7 @@ module.exports = {
|
||||
|
||||
return await Newstosent.findNewsletter_To_Send(idapp).then((rec) => {
|
||||
if (rec)
|
||||
this.sendNewsletter(rec);
|
||||
this.sendNewsletter(rec, idapp);
|
||||
});
|
||||
}
|
||||
,
|
||||
@@ -993,6 +1001,7 @@ module.exports = {
|
||||
arrevents: myarrevents,
|
||||
name: 'TestNome',
|
||||
surname: 'TestCognome',
|
||||
username: await User.getUsernameByEmail(idapp, myemail),
|
||||
emailto: myemail,
|
||||
baseurl: tools.getHostByIdApp(idapp),
|
||||
hashemail: tools.getHash(myemail),
|
||||
@@ -1005,7 +1014,7 @@ module.exports = {
|
||||
|
||||
mylocalsconf.dataemail.subject = mylocalsconf.dataemail && mylocalsconf.dataemail.templ ? mylocalsconf.dataemail.templ.subject : '',
|
||||
|
||||
this.replacefields(mylocalsconf);
|
||||
this.replacefields(mylocalsconf);
|
||||
|
||||
const smtpTransport = this.getTransport(mylocalsconf);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ let credentials = null;
|
||||
|
||||
|
||||
if ((process.env.NODE_ENV === 'production')) {
|
||||
console.log('*** AMBIENTE DI PRODUZIONE !!!!')
|
||||
console.log('*** AMBIENTE DI PRODUZIONE (Aprile 2024) !!!!')
|
||||
} else if (process.env.NODE_ENV === 'test') {
|
||||
console.log('*** ### AMBIENTE DI TEST ')
|
||||
}
|
||||
@@ -126,6 +126,7 @@ myLoad().then(ris => {
|
||||
const products_router = require('./router/products_router');
|
||||
const cart_router = require('./router/cart_router');
|
||||
const orders_router = require('./router/orders_router');
|
||||
const city_router = require('./router/city_router');
|
||||
const myskills_router = require('./router/myskills_router');
|
||||
const mygoods_router = require('./router/mygoods_router');
|
||||
const mygen_router = require('./router/mygen_router');
|
||||
@@ -133,6 +134,9 @@ myLoad().then(ris => {
|
||||
|
||||
const { MyEvent } = require('./models/myevent');
|
||||
|
||||
app.use(bodyParser.json({ limit: '50mb' }));
|
||||
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
|
||||
|
||||
app.use(express.static('views'));
|
||||
|
||||
// app.use(express.static(path.join(__dirname, 'client')));
|
||||
@@ -156,7 +160,7 @@ myLoad().then(ris => {
|
||||
});
|
||||
|
||||
app.use(cors({
|
||||
exposedHeaders: ['x-auth'],
|
||||
exposedHeaders: ['x-auth', 'x-refrtok'],
|
||||
}));
|
||||
|
||||
app.use(bodyParser.json());
|
||||
@@ -194,6 +198,7 @@ myLoad().then(ris => {
|
||||
app.use('/products', products_router);
|
||||
app.use('/cart', cart_router);
|
||||
app.use('/orders', orders_router);
|
||||
app.use('/city', city_router);
|
||||
app.use('/myskills', myskills_router);
|
||||
app.use('/mygoods', mygoods_router);
|
||||
app.use('/mygen', mygen_router);
|
||||
@@ -348,6 +353,7 @@ async function mystart() {
|
||||
console.log('decrypted:', decrypt);
|
||||
}
|
||||
|
||||
mycron();
|
||||
if (!process.env.DEBUG) {
|
||||
mycron();
|
||||
}
|
||||
@@ -394,19 +400,25 @@ function populateDBadmin() {
|
||||
let cfg = new CfgServer(cfgserv[0]).save();
|
||||
}
|
||||
|
||||
function mycron() {
|
||||
async function mycron() {
|
||||
|
||||
const sendemail = require('./sendemail');
|
||||
try {
|
||||
const sendemail = require('./sendemail');
|
||||
|
||||
for (const app of tools.getApps()) {
|
||||
sendemail.checkifPendingNewsletter(app.idapp);
|
||||
sendemail.checkifSentNewsletter(app.idapp);
|
||||
const arr = await tools.getApps();
|
||||
|
||||
for (const app of arr) {
|
||||
sendemail.checkifPendingNewsletter(app.idapp);
|
||||
sendemail.checkifSentNewsletter(app.idapp);
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Err mycron', e);
|
||||
}
|
||||
}
|
||||
|
||||
async function mycron_30min() {
|
||||
for (const app of tools.getApps()) {
|
||||
for (const app of await tools.getApps()) {
|
||||
let enablecrontab = false;
|
||||
|
||||
enablecrontab = await Settings.getValDbSettings(app.idapp,
|
||||
@@ -418,6 +430,29 @@ async function mycron_30min() {
|
||||
}
|
||||
}
|
||||
|
||||
async function mycron_everyday() {
|
||||
try {
|
||||
|
||||
const { User } = require('./models/user');
|
||||
|
||||
const arrapps = await tools.getApps();
|
||||
for (const app of arrapps) {
|
||||
|
||||
// Azzera le richieste di password:
|
||||
const usersblocked = await User.find({ idapp: app.idapp, retry_pwd: { $exists: true, $gte: 29 } }).lean();
|
||||
for (const user of usersblocked) {
|
||||
await User.findOneAndUpdate({ _id: user._id }, { $set: { retry_pwd: 20 } });
|
||||
let text = `⚠️⚠️⚠️ L\'utente ${user.username} (${user.name} ${user.surname}) viene sbloccato dal numero massimo di tentativi di richiesta password!\nTelerlo d\'occhio !\n@${user.profile.username_telegram}`;
|
||||
await telegrambot.sendMsgTelegramToTheAdminAllSites(text, false);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('mycron_everyday: ', e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function testmsgwebpush() {
|
||||
const { User } = require('./models/user');
|
||||
|
||||
@@ -442,11 +477,11 @@ function testmsgwebpush() {
|
||||
}
|
||||
|
||||
// Cron every X minutes
|
||||
cron.schedule('*/2 * * * *', () => {
|
||||
cron.schedule('*/1 * * * *', () => {
|
||||
// console.log('Running Cron Job');
|
||||
if (!process.env.DEBUG) {
|
||||
mycron();
|
||||
}
|
||||
// if (!process.env.DEBUG) {
|
||||
mycron();
|
||||
// }
|
||||
});
|
||||
|
||||
// Cron every X minutes
|
||||
@@ -456,6 +491,11 @@ cron.schedule('*/60 * * * *', async () => {
|
||||
}
|
||||
});
|
||||
|
||||
// Cron every 21:00 (1 volta al giorno)
|
||||
cron.schedule('0 21 * * *', async () => {
|
||||
mycron_everyday();
|
||||
});
|
||||
|
||||
// mycron_30min();
|
||||
|
||||
// tools.writelogfile('test', 'prova.txt');
|
||||
@@ -482,6 +522,13 @@ async function resetProcessingJob() {
|
||||
async function inizia() {
|
||||
|
||||
try {
|
||||
if (true) {
|
||||
const url = 'https://raw.githubusercontent.com/matteocontrini/comuni-json/master/comuni.json';
|
||||
const outputPath = './comuni_italia_geojson.json';
|
||||
downloadGeoJSON(url, outputPath);
|
||||
}
|
||||
|
||||
mycron_everyday();
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
await telegrambot.sendMsgTelegram(tools.FREEPLANET,
|
||||
|
||||
@@ -9,6 +9,9 @@ const appTelegram_DEVELOP = [tools.RISO];
|
||||
const appTelegramFinti = ['2', tools.CNM];
|
||||
const appTelegramDest = [tools.FREEPLANET, tools.FREEPLANET];
|
||||
|
||||
|
||||
const appTeleg_BotOnGroup = [tools.IDAPP_BOTONGROUP];
|
||||
|
||||
//PIPPO
|
||||
|
||||
const printf = require('util').format;
|
||||
@@ -272,6 +275,7 @@ const Menu = {
|
||||
MSG_SI_INVITATI_NO_7REQ_INVITATI: emoji.get('incoming_envelope') +
|
||||
'Inv e NO 7 Req',
|
||||
MSGSTAFF: emoji.get('incoming_envelope') + ' Invia a STAFF',
|
||||
MSGAPPARTIENE_CIRCUITI_RIS: 'Invia a Utenti dei Circuiti RIS',
|
||||
MSGPAOLO: emoji.get('incoming_envelope') + ' Invia a PAOLO',
|
||||
RESTART_SRV: emoji.get('incoming_envelope') + 'Restart-NodeJs',
|
||||
REBOOT_SRV: emoji.get('incoming_envelope') + 'Reboot-VPS!',
|
||||
@@ -468,6 +472,7 @@ const Destin = {
|
||||
PAOLO: 9,
|
||||
DOMANDA: 10,
|
||||
RISPOSTA: 11,
|
||||
APPARTIENE_CIRCUITO_RIS: 20,
|
||||
};
|
||||
|
||||
const StatusMSGALL = {
|
||||
@@ -711,15 +716,18 @@ const MyTelegramBot = {
|
||||
} else {
|
||||
arrTeleg = appTelegram;
|
||||
}
|
||||
if (process.env.NODE_ENV === 'development')
|
||||
arrTeleg = appTelegram_DEVELOP;
|
||||
else if (process.env.NODE_ENV === 'test')
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
arrTeleg = MyTelegramBot.getAppTelegramDevelop();
|
||||
} else if (process.env.NODE_ENV === 'test') {
|
||||
arrTeleg = MyTelegramBot.getAppTelegramTest();
|
||||
} else {
|
||||
const arrTelegFromSite = tools.getArrTelegramFromSite();
|
||||
if (arrTelegFromSite.length > 0) {
|
||||
arrTeleg = arrTelegFromSite;
|
||||
}
|
||||
|
||||
const arrTelegFromSite = tools.getArrTelegramFromSite();
|
||||
if (arrTelegFromSite.length > 0) {
|
||||
arrTeleg = arrTelegFromSite;
|
||||
}
|
||||
|
||||
return arrTeleg;
|
||||
|
||||
},
|
||||
@@ -733,6 +741,15 @@ const MyTelegramBot = {
|
||||
|
||||
},
|
||||
|
||||
getAppTelegramDevelop: function () {
|
||||
if (process.env.appTelegram_TEST) {
|
||||
return JSON.parse(process.env.appTelegram_TEST);
|
||||
} else {
|
||||
return appTelegram_DEVELOP;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
local_sendMsgTelegramByIdTelegram: async function (idapp, idtelegram, text,
|
||||
message_id, chat_id, ripr_menuPrec,
|
||||
MyForm = null) {
|
||||
@@ -742,7 +759,7 @@ const MyTelegramBot = {
|
||||
|
||||
const cl = getclTelegByidapp(idapp);
|
||||
if (cl && idtelegram) {
|
||||
|
||||
|
||||
return await cl.sendMsg(idtelegram, text, null, MyForm, message_id,
|
||||
chat_id, ripr_menuPrec);
|
||||
}
|
||||
@@ -923,7 +940,7 @@ const MyTelegramBot = {
|
||||
|
||||
keyb = cl.getInlineKeyboard(myuser.lang, [
|
||||
{
|
||||
text: '✅ Abilita ' + myuser.username,
|
||||
text: '✅ Ammetti ' + myuser.username,
|
||||
callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + userDest,
|
||||
},
|
||||
/*{
|
||||
@@ -1338,6 +1355,25 @@ const MyTelegramBot = {
|
||||
invia = true;
|
||||
} else if (params.cmd === shared_consts.MsgTeleg.SHARE_TEXT) {
|
||||
invia = !!params.content;
|
||||
} else if (params.cmd === shared_consts.MsgTeleg.SHARE_ANNUNCIO) {
|
||||
const mytable = globalTables.getTableByTableName(params.tablerec);
|
||||
|
||||
if (params.idrec && params.idrec !== '0') {
|
||||
// const myrectableorig = await mytable.findOne({ _id: myrecnotifpass.idrec }).lean();
|
||||
const myrectableorig = await mytable.getCompleteRecord(params.idapp, params.idrec);
|
||||
|
||||
if (myrectableorig) {
|
||||
const eventobj = await tools.getAnnuncioForTelegram(myrectableorig, params.tablerec, '', user.username, false);
|
||||
if (eventobj) {
|
||||
params.textcontent_Telegram = eventobj.newdescrtelegram;
|
||||
params.typesend = shared_consts.TypeSend.TELEGRAM;
|
||||
//const rismsg =
|
||||
params.content = eventobj.newdescr;
|
||||
params.title = '';
|
||||
invia = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tipomsgtempl > 0) {
|
||||
@@ -1403,8 +1439,7 @@ async function local_sendMsgTelegramToTheManagers(
|
||||
if (username_bo)
|
||||
username = username_bo;
|
||||
|
||||
text = emo.ROBOT_FACE + ': Da ' + msg.chat.first_name + ' ' +
|
||||
msg.chat.last_name + ' (' + username + '): \n' + text;
|
||||
text = emo.ROBOT_FACE + ': Da ' + tools.getNomeCognomeTelegram(msg) + ' (' + username + '): \n' + text;
|
||||
tools.writeEventsLog(text);
|
||||
|
||||
if (usersmanagers) {
|
||||
@@ -1981,6 +2016,8 @@ class Telegram {
|
||||
await this.menumsgAll(msg);
|
||||
} else if (testo === Menu.MSGSTAFF) {
|
||||
await this.menumsgStaff(msg);
|
||||
} else if (testo === Menu.MSGAPPARTIENE_CIRCUITI_RIS) {
|
||||
await this.menumsgAppartieneCircuitiRis(msg);
|
||||
} else if (testo === Menu.MSGPAOLO) {
|
||||
await this.menumsgPaolo(msg);
|
||||
} else if (cmd1 === Menu.EXECSH) {
|
||||
@@ -2389,6 +2426,8 @@ class Telegram {
|
||||
return 'STAFF';
|
||||
else if (destin === Destin.PAOLO)
|
||||
return 'PAOLO';
|
||||
else if (destin === Destin.APPARTIENE_CIRCUITO_RIS)
|
||||
return 'APPARTIENE_CIRCUITO_RIS';
|
||||
else if (destin === Destin.NO_7_REQ)
|
||||
return 'No 7 Requisiti';
|
||||
else if (destin === Destin.NO_9_REQ)
|
||||
@@ -2420,6 +2459,10 @@ class Telegram {
|
||||
await this.menumsgGenerico(msg, Destin.STAFF);
|
||||
}
|
||||
|
||||
async menumsgAppartieneCircuitiRis(msg) {
|
||||
await this.menumsgGenerico(msg, Destin.APPARTIENE_CIRCUITO_RIS);
|
||||
}
|
||||
|
||||
async menumsgPaolo(msg) {
|
||||
await this.menumsgGenerico(msg, Destin.PAOLO);
|
||||
}
|
||||
@@ -2938,6 +2981,8 @@ class Telegram {
|
||||
// NOTHING
|
||||
} else {
|
||||
|
||||
let contanumutenti = 0;
|
||||
|
||||
let usersall = null;
|
||||
|
||||
let myusername = '';
|
||||
@@ -2979,6 +3024,7 @@ class Telegram {
|
||||
|
||||
// TEST usersall = await User.getUsersTelegALL(rec.user.idapp, 'paoloar77');
|
||||
|
||||
|
||||
for (const utente of usersall) {
|
||||
|
||||
let FormDaMostrare = null;
|
||||
@@ -2996,6 +3042,8 @@ class Telegram {
|
||||
let invia = false;
|
||||
if (destin === Destin.STAFF) {
|
||||
invia = User.isManager(utente.perm);
|
||||
} else if (destin === Destin.APPARTIENE_CIRCUITO_RIS) {
|
||||
invia = await User.ExistAtLeastOneCircuit(utente.idapp, utente.username);
|
||||
} else if (destin === Destin.TUTTI) {
|
||||
invia = true;
|
||||
} else if (destin === Destin.PAOLO) {
|
||||
@@ -3024,6 +3072,7 @@ class Telegram {
|
||||
preparatesto += utente.name + ' ' + utente.surname + '(' +
|
||||
utente.username + ')' + '\n';
|
||||
} else if (cmd === CONTA_SOLO) {
|
||||
contanumutenti++;
|
||||
// Niente
|
||||
} else if (cmd === CHEDI_SE_IMBARCARTI) {
|
||||
textdainviare = tools.gettranslate('VUOI_IMBARCARTI', lang);
|
||||
@@ -3065,8 +3114,16 @@ class Telegram {
|
||||
// if (process.env.PROD === "0") {
|
||||
// telegid = 12429864;
|
||||
// }
|
||||
await this.sendMsg(telegid, textdainviare, null,
|
||||
FormDaMostrare);
|
||||
if (rec.forwardMessage && rec.chatId && rec.messageId) {
|
||||
|
||||
// Inoltra il messaggio alla stessa chat o ad un'altra
|
||||
this.bot.forwardMessage(rec.chatId, telegid, rec.messageId);
|
||||
|
||||
} else {
|
||||
|
||||
await this.sendMsg(telegid, textdainviare, null,
|
||||
FormDaMostrare);
|
||||
}
|
||||
|
||||
// break;
|
||||
}
|
||||
@@ -3090,7 +3147,7 @@ class Telegram {
|
||||
|
||||
let msgris = '';
|
||||
if (cmd === CONTA_SOLO) {
|
||||
msgris = nummsgsent + ' ' +
|
||||
msgris = contanumutenti + ' ' +
|
||||
getstr(this.getlang(msg), 'MSG_MSG_TOSENT');
|
||||
} else if (cmd === NOME_COGNOME) {
|
||||
msgris = nummsgsent + ' ' + 'Utenti';
|
||||
@@ -3121,6 +3178,7 @@ class Telegram {
|
||||
} else {
|
||||
if (msgris) {
|
||||
tools.writeEventsLog(msgris);
|
||||
|
||||
await this.sendMsg(msg.chat.id, msgris);
|
||||
}
|
||||
}
|
||||
@@ -3269,6 +3327,14 @@ class Telegram {
|
||||
} else if (rec.msgall_status === StatusMSGALL.ASK) {
|
||||
if (!this.isSelMenu(msg, msg.text, 'INDIETRO')) {
|
||||
rec.msgtosent = msg.text;
|
||||
rec.entities = msg.entities;
|
||||
|
||||
// Se contiene della formattazione allora fai il FORWARD DEL MESSAGGIO
|
||||
//rec.forwardMessage = !!rec.entities;
|
||||
rec.forwardMessage = false;
|
||||
|
||||
rec.chatId = msg.chat.id;
|
||||
rec.messageId = msg.message_id;
|
||||
rec.msgall_status = StatusMSGALL.CONFIRM;
|
||||
const cmd = rec.msgtosent.toLowerCase();
|
||||
let achi = this.getDestinStr(msg, rec.msgall_achi, rec);
|
||||
@@ -3437,6 +3503,7 @@ class Telegram {
|
||||
msg_username_risposta: '',
|
||||
extraparam: '',
|
||||
msgtosent: '',
|
||||
entities: [],
|
||||
msgNo: '',
|
||||
msg_toDest_yes: '',
|
||||
msg_toDest_no: '',
|
||||
@@ -3913,6 +3980,7 @@ class Telegram {
|
||||
|
||||
async setPhotoProfile(user, telegid, showmsg = true) {
|
||||
try {
|
||||
console.log('setPhotoProfile', user ? user.username : '')
|
||||
if (user) {
|
||||
const idapp = this.idapp;
|
||||
const bot = this.bot;
|
||||
@@ -3924,6 +3992,10 @@ class Telegram {
|
||||
server_constants.DIR_UPLOAD + '/profile/' + username + '/';
|
||||
let user_profile = bot.getUserProfilePhotos(telegid);
|
||||
user_profile.then(function (res) {
|
||||
if (res.total_count === 0) {
|
||||
// Non ho l'accesso oppure sono davvero senza foto !
|
||||
|
||||
}
|
||||
if (res.photos[0]) {
|
||||
var file_id = res.photos[0][2].file_id;
|
||||
var file = bot.getFile(file_id);
|
||||
@@ -4024,14 +4096,22 @@ class Telegram {
|
||||
|
||||
const lang = this.getlang(msg);
|
||||
|
||||
this._inviaMsg(msg.from.id, domanda, {
|
||||
disable_web_page_preview: true,
|
||||
reply_markup: {
|
||||
resize_keyboard: true,
|
||||
one_time_keyboard: true,
|
||||
keyboard: this.getmenuKey(MenuYesNo, lang),
|
||||
},
|
||||
});
|
||||
if (msg.forwardMessage && msg.chatId && msg.messageId) {
|
||||
|
||||
// Inoltra il messaggio alla stessa chat o ad un'altra
|
||||
this.bot.forwardMessage(msg.chatId, msg.chatId, msg.messageId);
|
||||
|
||||
} else {
|
||||
this._inviaMsg(msg.from.id, domanda, {
|
||||
disable_web_page_preview: true,
|
||||
reply_markup: {
|
||||
resize_keyboard: true,
|
||||
one_time_keyboard: true,
|
||||
keyboard: this.getmenuKey(MenuYesNo, lang),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async ScegliLang(msg, lang) {
|
||||
@@ -4072,6 +4152,17 @@ function getclTelegBytoken(token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Funzione per ottenere il nome del gruppo
|
||||
async function getGroupName(bot, groupId) {
|
||||
try {
|
||||
const chat = await bot.getChat(groupId);
|
||||
return chat.title;
|
||||
} catch (error) {
|
||||
console.error('Errore durante l\'ottenimento del nome del gruppo:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function getclTelegByidapp(idapp) {
|
||||
// ****************************
|
||||
if (appTelegramFinti.includes(idapp)) {
|
||||
@@ -4095,7 +4186,82 @@ if (true) {
|
||||
|
||||
internetAvailable().then(() => {
|
||||
// ..
|
||||
console.log('TELEGRAM STARTING.... ' + process.env.NODE_ENV);
|
||||
|
||||
if (appTeleg_BotOnGroup.length > 0) {
|
||||
console.log('TELEGRAM BOT GROUP .... ');
|
||||
|
||||
for (const idapp of appTeleg_BotOnGroup) {
|
||||
|
||||
const token = tools.getTelegramKeyByIdApp(idapp);
|
||||
const nomebot = tools.getTelegramBotNameByIdApp(idapp);
|
||||
|
||||
if (token && nomebot) {
|
||||
const bot = new TelegramBot(token, { polling: true });
|
||||
|
||||
// Gestisce il comando /start
|
||||
bot.onText(/\/start/, (msg) => {
|
||||
console.log('START BOT GROUP ... ');
|
||||
/*
|
||||
const chatId = msg.chat.id;
|
||||
const message = 'Benvenuto! Usa il comando /request per inviare una richiesta di accesso al gruppo.';
|
||||
bot.sendMessage(chatId, message);
|
||||
*/
|
||||
});
|
||||
|
||||
bot.onText(/\/request/, (msg) => {
|
||||
const chatId = msg.chat.id;
|
||||
const fromId = msg.from.id;
|
||||
const fromUsername = msg.from.username;
|
||||
|
||||
const groupId = chatId;
|
||||
|
||||
if (chatId == groupId) {
|
||||
const message = `Richiesta di accesso al gruppo da parte di ${msg.from.first_name} ${msg.from.last_name} (@${fromUsername})`;
|
||||
bot.sendMessage(groupId, message);
|
||||
} else {
|
||||
console.log('Comando /request ricevuto in una chat privata.');
|
||||
}
|
||||
});
|
||||
|
||||
bot.on('text', (msg) => {
|
||||
console.log('TEXT...');
|
||||
const chatId = msg.chat.id;
|
||||
const userName = msg.from.username || msg.from.first_name;
|
||||
const userId = msg.from.id;
|
||||
});
|
||||
|
||||
bot.on('new_chat_members', async (msg) => {
|
||||
const chatId = msg.chat.id;
|
||||
const newMembers = msg.new_chat_members;
|
||||
|
||||
const groupId = chatId;
|
||||
|
||||
const nomegruppo = await getGroupName(bot, groupId);
|
||||
|
||||
// Ottiene la lista degli amministratori del gruppo
|
||||
const admins = await bot.getChatAdministrators(chatId);
|
||||
|
||||
// Trova l'ID dell'amministratore del gruppo
|
||||
const adminId = admins.find(admin => admin.status === 'administrator').user.id;
|
||||
|
||||
// Verifica se il nuovo membro è stato aggiunto al gruppo
|
||||
if (chatId == groupId) {
|
||||
newMembers.forEach(async (member) => {
|
||||
|
||||
//const message = `🔑 Nuova Richiesta di accesso al gruppo ${nomegruppo} da parte di ${member.username} (` + member.first_name + ' ' + member.last_name + ')';
|
||||
const message = `Benvenuto/a ${member.first_name} (${member.username}) sul gruppo "${nomegruppo}" !`;
|
||||
bot.sendMessage(adminId, message);
|
||||
|
||||
// bot.sendMessage(groupId, message);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('TELEGRAM STARTING.... ', process.env.NODE_ENV);
|
||||
|
||||
for (const idapp of arrTeleg) {
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,8 @@ module.exports = Object.freeze({
|
||||
RIS_ISCRIZIONE_OK: 5,
|
||||
|
||||
RIS_CODE_HTTP_INVALID_TOKEN: 403,
|
||||
RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED: 408,
|
||||
|
||||
RIS_CODE_TOKEN_RESETPASSWORD_NOT_FOUND: -23,
|
||||
|
||||
RIS_SUBSCRIBED_OK: 1,
|
||||
@@ -113,4 +115,11 @@ module.exports = Object.freeze({
|
||||
TYPE_SUBDIR: 2,
|
||||
},
|
||||
|
||||
User_Fields: [
|
||||
'name',
|
||||
'surname',
|
||||
'news_on',
|
||||
'profile',
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
@@ -3,7 +3,9 @@ module.exports = {
|
||||
CHECK_READ_GUIDELINES: 1,
|
||||
CHECK_SEE_VIDEO_PRINCIPI: 2,
|
||||
},
|
||||
LIMIT_NOTIF_FOR_USER: 200,
|
||||
LIMIT_NOTIF_FOR_USER: 50,
|
||||
LIMIT_NOTIFCOINS_FOR_USER: 50,
|
||||
LIMIT_NOTIFCOINS_IN_ATTESA_FOR_USER: 200,
|
||||
|
||||
QUERYTYPE_MYGROUP: 1,
|
||||
QUERYTYPE_REFUSED_USER_GRP: 2,
|
||||
@@ -196,6 +198,7 @@ module.exports = {
|
||||
'circuits',
|
||||
'accounts',
|
||||
'movements',
|
||||
'mygroups',
|
||||
],
|
||||
|
||||
TABLES_ID_NUMBER: [
|
||||
@@ -246,8 +249,8 @@ module.exports = {
|
||||
{ table: 'sectors', key: 'descr' },
|
||||
{ table: 'skills', key: 'descr' },
|
||||
{ table: 'statusSkills', key: 'descr' },
|
||||
// { table: 'catais', key: 'descr' },
|
||||
// { table: 'queryais', key: 'descr' },
|
||||
// { table: 'catais', key: 'descr' },
|
||||
// { table: 'queryais', key: 'descr' },
|
||||
],
|
||||
|
||||
|
||||
@@ -293,7 +296,9 @@ module.exports = {
|
||||
CAT_NO_SPAZI: 5,
|
||||
CAT_GOODS_TXT: 10,
|
||||
PRODUCTS: 20,
|
||||
PRODUCTS_V2: 22,
|
||||
INVENTARIO: 30,
|
||||
MACRO_CATALOGO_JSON: 40,
|
||||
},
|
||||
|
||||
WalletFinalStatusType: {
|
||||
@@ -346,6 +351,11 @@ module.exports = {
|
||||
OUT: 2,
|
||||
},
|
||||
|
||||
AdType: {
|
||||
OFFRO: 1,
|
||||
CERCO: 2,
|
||||
},
|
||||
|
||||
TypeCashStr: [
|
||||
{
|
||||
label: '[Nessuno]',
|
||||
@@ -383,7 +393,7 @@ module.exports = {
|
||||
},
|
||||
{
|
||||
label: 'Chili (kg)',
|
||||
short: 'Kg',
|
||||
short: 'kg',
|
||||
value: 2,
|
||||
},
|
||||
{
|
||||
@@ -401,6 +411,11 @@ module.exports = {
|
||||
short: 'p',
|
||||
value: 10,
|
||||
},
|
||||
{
|
||||
label: 'Uova',
|
||||
short: 'uova',
|
||||
value: 15,
|
||||
},
|
||||
],
|
||||
|
||||
|
||||
@@ -507,6 +522,7 @@ module.exports = {
|
||||
MsgTeleg: {
|
||||
SHARE_MSGREG: 1,
|
||||
SHARE_TEXT: 2,
|
||||
SHARE_ANNUNCIO: 3,
|
||||
},
|
||||
|
||||
TypeMsgTemplate: {
|
||||
@@ -775,6 +791,7 @@ module.exports = {
|
||||
longdescr: 1,
|
||||
regulation: 1,
|
||||
numMembers: 1,
|
||||
link_group: 1,
|
||||
totCircolante: 1,
|
||||
totTransato: 1,
|
||||
systemUserId: 1,
|
||||
@@ -873,6 +890,7 @@ module.exports = {
|
||||
|
||||
getProjectForAll(proj_add, table) {
|
||||
let proj = {
|
||||
idapp: 1,
|
||||
idContribType: 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
@@ -955,4 +973,106 @@ module.exports = {
|
||||
NEXT_10: 1,
|
||||
},
|
||||
|
||||
CAMPI_PRODUCTINFO_CONVERT: [
|
||||
'weight_and_unit',
|
||||
'weight_and_unit_lordo',
|
||||
],
|
||||
|
||||
CAMPI_PRODUCTINFO_RICOPIA_DATI: [
|
||||
'old_code',
|
||||
],
|
||||
|
||||
PRODUCTINFO: {
|
||||
CAMPI_FIRST_UPPERCASE: [
|
||||
'name',
|
||||
],
|
||||
},
|
||||
|
||||
CAMPI_TYPE: {
|
||||
STRING: 1,
|
||||
},
|
||||
|
||||
CAMPI_PRODUCTINFO: [
|
||||
{name: 'name', type: ''},
|
||||
{name: 'code', type: ''},
|
||||
{name: 'description', type: 1},
|
||||
{name: 'link_scheda', type: ''},
|
||||
{name: 'idCatProds', type: ''},
|
||||
{name: 'idSubCatProds', type: ''},
|
||||
{name: 'weight', type: ''},
|
||||
{name: 'weight_lordo', type: ''},
|
||||
{name: 'unit', type: ''},
|
||||
{name: 'unit_lordo', type: ''},
|
||||
{name: 'size', type: ''},
|
||||
{name: 'vegan', type: ''},
|
||||
{name: 'sfuso', type: ''},
|
||||
{name: 'img', type: ''},
|
||||
{name: 'image_link', type: ''},
|
||||
{name: 'link', type: ''},
|
||||
{name: 'ingredienti', type: ''},
|
||||
{name: 'valori_nutrizionali', type: ''},
|
||||
{name: 'author', type: ''},
|
||||
{name: 'collezione', type: ''},
|
||||
{name: 'publisher', type: ''},
|
||||
{name: 'numpages', type: ''},
|
||||
{name: 'note', type: ''},
|
||||
],
|
||||
|
||||
CAMPI_PRODUCT: [
|
||||
'active',
|
||||
'price',
|
||||
'stockQty',
|
||||
'perc_iva',
|
||||
'price_acquistato',
|
||||
'minBuyQty',
|
||||
'minStepQty',
|
||||
'cat_name',
|
||||
'subcat_name',
|
||||
'producer_name',
|
||||
'provider_name',
|
||||
'magazzino_name',
|
||||
'qtyToReachForGas',
|
||||
'maxbookableGASQty',
|
||||
'gas_name',
|
||||
'sconto1',
|
||||
'sconto2',
|
||||
],
|
||||
|
||||
CAMPI_EURO: [
|
||||
'price',
|
||||
'price_acquistato',
|
||||
],
|
||||
|
||||
MAX_QTA_PREORD: 5000,
|
||||
|
||||
STATUSSKILL_DI_PERSONA: 1,
|
||||
STATUSSKILL_ONLINE: 2,
|
||||
|
||||
TYPEHOSP_SCAMBIOCASA: 1,
|
||||
TYPEHOSP_OSPITALITA: 2,
|
||||
|
||||
PRODUCTTYPE: {
|
||||
BENE: 1,
|
||||
SERVIZIO: 2,
|
||||
OSPITALITA: 4,
|
||||
PRODOTTO: 10,
|
||||
LIBRO: 20,
|
||||
EBOOK: 21,
|
||||
AUDIOLIBRO: 22,
|
||||
VIDEO: 23,
|
||||
CARTE: 25,
|
||||
},
|
||||
|
||||
// Download, DVD, Epub, Mobi, Nuovo, PDF, Streaming, Usato
|
||||
VERSIONE: {
|
||||
NUOVO: 1,
|
||||
USATO: 2,
|
||||
DOWNLOAD: 3,
|
||||
DVD: 4,
|
||||
EPUB: 5,
|
||||
MOBI: 6,
|
||||
PDF: 7,
|
||||
STREAMING: 8,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user