136 Commits

Author SHA1 Message Date
Surya Paolo
0c2a8ecef5 AITools prime cose 2024-01-30 14:00:37 +01:00
Surya Paolo
aeabf96efe agiornamento, sistemazioni varie PCB 2024-01-23 00:10:40 +01:00
Surya Paolo
e4504bcf9e regNameSurnameMandatory
askUSernameTelegramToTheReg
@ davanti all'username
2024-01-19 23:38:08 +01:00
Surya Paolo
dbcdbd689b fix order non si vedeva.. e msg login errato 2024-01-17 21:49:59 +01:00
Surya Paolo
f6a0876178 fix problema sul caricamento della home da offline... 2024-01-17 20:30:07 +01:00
Surya Paolo
1ef3103a9d risolto qtaminima "|" era sbagliato, corretto: product.minBuyQty || 1 2024-01-17 11:13:13 +01:00
Surya Paolo
d7122af70e ciao corretto 2024-01-16 23:09:04 +01:00
Surya Paolo
3d1a330fa2 Poter inserire un Ordine anche per un altra persona... (Modalità Cassa) 2024-01-16 23:00:10 +01:00
Surya Paolo
a2c9dcb38c gasordine 2024-01-16 17:09:55 +01:00
Surya Paolo
d22e808626 aggio gasordine 2024-01-16 16:56:39 +01:00
Surya Paolo
9265e9bfb3 fix_ismanager 2024-01-16 11:22:22 +01:00
Surya Paolo
504e9fd88c fix2 2024-01-16 11:17:48 +01:00
Surya Paolo
4b9fe4d267 fix 2024-01-16 11:16:31 +01:00
Surya Paolo
d81f533ecb fix totqta 2024-01-16 10:49:20 +01:00
Surya Paolo
65d75cb2c5 aggio 2024-01-16 09:05:02 +01:00
Surya Paolo
212f895650 corretto 2024-01-15 22:46:38 +01:00
Surya Paolo
3183825137 possibilità di modificare un ordine, e anche i totali 2024-01-15 22:19:26 +01:00
Surya Paolo
79ca364e84 product 2024-01-13 16:21:07 +01:00
Surya Paolo
7bf549569d - edit campi prodotti
- edit ordini
2024-01-13 00:28:53 +01:00
Surya Paolo
c63e345285 subcatprod 2024-01-12 13:02:59 +01:00
Surya Paolo
9b4a9dbf28 aggio modif 2024-01-10 20:44:43 +01:00
Surya Paolo
a71c487697 email da inviare ai clienti ... 2024-01-09 23:57:30 +01:00
Surya Paolo
3dfb990620 aggiorna 2024-01-09 15:31:59 +01:00
Surya Paolo
4cdc4f7de1 pcb 2024-01-09 08:38:00 +01:00
Surya Paolo
7ea6c2a76b aggio numtransaction 2024-01-09 08:34:28 +01:00
Surya Paolo
db81980046 Corretto il pagato
- fix Group Add link
2024-01-07 17:27:20 +01:00
Surya Paolo
fb16a1729e menu RIS 2024-01-07 16:03:39 +01:00
Surya Paolo
d7ae8baec4 inserimento in Movimenti del Circuito 2024-01-04 15:43:13 +01:00
Surya Paolo
b754492b41 - abilitato circuits e groups 2024-01-03 23:46:31 +01:00
Surya Paolo
0aaa331b3f addOrderToMovement 2024-01-03 23:19:15 +01:00
Surya Paolo
66e4c577c7 addtocash using sendcoins Circuit 2024-01-03 15:46:42 +01:00
Surya Paolo
75ef581635 update 2024-01-02 15:39:29 +01:00
Surya Paolo
4e0c18f47c ++ Cassa - parte 1 2024-01-02 15:24:44 +01:00
Surya Paolo
3fb78ff39a - migliorata grafica prodotti 2023-12-31 14:34:01 +01:00
Surya Paolo
6313476d54 - migliorie grafiche 2023-12-30 23:58:35 +01:00
Surya Paolo
b6204c7612 - Uscita PRIMA VERSIONE PiuCheBuono.app 2023-12-30 21:33:59 +01:00
Surya Paolo
ade9c149c5 - preordinabili corretti + altro 2023-12-29 21:17:17 +01:00
Surya Paolo
633b9a2d8c aggiornato prodotti e scontistica 2023-12-29 15:19:15 +01:00
Surya Paolo
3d1dddba39 - poster 2023-12-29 01:27:47 +01:00
Surya Paolo
db7724cca4 - aggiunta campi Gas data + fix 2023-12-28 23:53:11 +01:00
Surya Paolo
5afe9dd1e2 - aggiunta campi Gas data + fix 2023-12-28 23:48:03 +01:00
Surya Paolo
c001587702 - filtro se GAS o Prodotti 2023-12-28 21:00:02 +01:00
Surya Paolo
ca6d29414a - Email Ordine da template HTML 2023-12-28 15:53:00 +01:00
Surya Paolo
f23047bcd5 - Aggiornamento template mail (tramite i campi in HTML)
- Aggiornato Carrello
2023-12-28 00:50:35 +01:00
Surya Paolo
15d831eecc - Categorie
- ProductInfo
2023-12-27 02:58:15 +01:00
Surya Paolo
f0495d93b3 Seleziona l'ordine GAS e compare sulla email 2023-12-24 00:55:49 +01:00
Surya Paolo
0eb287db06 - Creazione pagina Home logout
- Nuovo Gasordine
- Visualizzazione GAS / BOTTEGA
2023-12-21 15:21:24 +01:00
Surya Paolo
322bfb9738 Merge branch 'Dev_PDB1' of ssh://risosrv:5522/~/repository/freeplanet_serverside into Dev_PDB1 2023-12-21 10:58:18 +01:00
Surya Paolo
428a5ca0e9 modif 2023-12-21 10:58:15 +01:00
Surya Paolo
000e900f48 ++GasOrdini 2023-12-21 02:23:52 +01:00
Surya Paolo
2ab4bd4e2a Corretto incongruenze OrdersCart 2023-12-21 01:34:33 +01:00
Surya Paolo
7af909d2be Aggiornamento modifiche preOrdini 2023-12-20 21:56:15 +01:00
Surya Paolo
0e1fc359a0 Aggiornamento modifiche preOrdini 2023-12-20 21:52:17 +01:00
Surya Paolo
d00c7eccc8 Corretto l'url delle immagini dei prodotti ! 2023-12-18 16:37:26 +01:00
Surya Paolo
7e7d7ca6b4 Aggiungi il codice alla cassa in automatico 2023-12-18 15:21:07 +01:00
Surya Paolo
a3913a4575 corretto totali in attesa 2023-12-18 13:04:38 +01:00
Surya Paolo
7628fb97fc Carrello con scontistica aggiornata 2023-12-18 12:11:12 +01:00
Surya Paolo
56b5bac5f0 Merge branch 'Dev_PDB1' of ssh://risosrv:5522/~/repository/freeplanet_serverside into Dev_PDB1 2023-12-18 08:34:51 +01:00
Surya Paolo
e7021e1f14 aaa 2023-12-18 08:32:03 +01:00
Surya Paolo
139d7ea33c Risolto problema blocco 2023-12-18 08:02:28 +01:00
Surya Paolo
50d610b1b1 aggiornamento... 2023-12-17 19:19:04 +01:00
Surya Paolo
c71f4af370 Abilitazione del BOT 2023-12-17 16:20:44 +01:00
Surya Paolo
4290895a97 aggiornamento scontistica, corretto errori 2023-12-16 18:40:17 +01:00
Surya Paolo
ab3a31d4fb Scontistica- Parte 1 2023-12-16 00:51:03 +01:00
Surya Paolo
1ca72118f1 lista ordini aggiornata 2023-12-15 23:36:43 +01:00
Surya Paolo
4d9eccd1ae Corretto Ordini e visualizzazione dei Totali 2023-12-15 21:50:21 +01:00
Surya Paolo
05ec283882 import dati prodotti + fornitore + produttore 2023-12-15 00:57:14 +01:00
Surya Paolo
ea2b7095c9 aggiornamento ordini 2023-12-14 15:20:21 +01:00
Surya Paolo
d0bf7e1b6a aggiornato stockQta quando l'ordine viene evaso 2023-12-14 00:55:07 +01:00
Surya Paolo
fcdd826c54 Gestione Ordini: evaso... 2023-12-13 19:17:53 +01:00
Surya Paolo
a2bd4f6e97 aggio query 2023-12-12 15:42:41 +01:00
Surya Paolo
5f3c8a65ea corretto abiltiazione fiducia concessa 2023-12-12 00:56:40 +01:00
Surya Paolo
caadbaae5f aggio2 2023-12-11 20:48:52 +01:00
Surya Paolo
296b7b4fb8 modif 2023-12-11 19:06:22 +01:00
Surya Paolo
ff81ab7be3 dev 2023-12-11 11:25:16 +01:00
Surya Paolo
8ce4f66c55 a1p 2023-12-11 10:10:52 +01:00
Surya Paolo
daacde7455 aggiornamento visualizzazione Ordini e Carrello 2023-12-09 19:38:23 +01:00
Surya Paolo
023ba26003 aggiornamento Indici 2023-12-09 11:55:58 +01:00
Surya Paolo
502ed32c42 - Installazione primo Sito Web del server
- Creazione prima pagina Home
2023-12-09 00:19:40 +01:00
Surya Paolo
74c4a829b0 Creazione Sito Web da pagina 2023-12-08 14:07:32 +01:00
Surya Paolo
f7bcb0c361 modif 2023-12-07 11:28:01 +01:00
Surya Paolo
72a7e3fa37 modif 2023-12-07 11:27:30 +01:00
Surya Paolo
4871c2d868 Aggiornata Chiave Segreta per accesso SIGNCODE.
- Inserito autenticazione MongoDB ai database.
-PCB: Aggiunto altri campi a products
2023-12-07 08:34:24 +01:00
Surya Paolo
d5bc76335f - Entri in Circuito Italia solo se hai il fido nel circuito provinciale
- Aggiunta Zona, oltre alla provincia, per visualizzare i vari circuiti della prov
2023-12-06 00:41:50 +01:00
Surya Paolo
6edba03eff Versione 1.0.21 - RIS ITALIA 2023-12-02 15:23:35 +01:00
Surya Paolo
8e42baf79e bottoni fiducia 2023-11-30 19:50:12 +01:00
Surya Paolo
e3ed2934ee Struttura Scheda Prodotti... 2023-11-30 14:27:37 +01:00
Surya Paolo
e895e7dae2 ignore 2023-11-30 01:49:51 +01:00
Surya Paolo
4a408b4ebd Riso: Ris Italia, altre modifiche grafiche
Lista Utenti da Verificare
2023-11-30 01:49:17 +01:00
Surya Paolo
0e3ba5ff87 agg 2023-11-28 15:04:17 +01:00
Surya Paolo
a66cd610dd Develop PDB 1 2023-11-28 14:20:22 +01:00
Surya Paolo
5aa6accfc5 Merge branch 'develop' of ssh://risosrv:5522/~/repository/freeplanet_serverside into develop 2023-11-27 16:42:52 +01:00
Surya Paolo
35178684af aaa 2023-11-27 16:42:44 +01:00
Surya Paolo
bba0df4302 aa 2023-11-27 14:43:13 +01:00
Surya Paolo
f1954d98d6 Merge branch 'develop' of ssh://risosrv:5522/~/repository/freeplanet_serverside into develop 2023-11-27 11:16:13 +01:00
Surya Paolo
34b00bdf98 ds 2023-11-27 11:16:09 +01:00
Surya Paolo
0cfabed233 - tutorial Circuito Ris Italia
- Invia RIS (visibile per tutti)
2023-11-26 01:38:02 +01:00
Surya Paolo
c92dc8f216 fixed: se aggiungo una Provincia sul frontend non si aggiungeva 2023-11-24 17:52:17 +01:00
Surya Paolo
7b14c09fd5 Merge branch 'develop' of ssh://risosrv:5522/~/repository/freeplanet_serverside into develop 2023-11-23 16:06:38 +01:00
Surya Paolo
2258e8e7e1 aaa 2023-11-23 16:06:20 +01:00
Surya Paolo
e8c961f500 aaa 2023-11-23 15:58:13 +01:00
Surya Paolo
b395d1a30a aaa 2023-11-23 15:57:02 +01:00
Surya Paolo
341af6a3b2 test 2 2023-11-23 15:55:55 +01:00
Surya Paolo
3d876687b6 Merge branch 'develop' of ssh://risosrv:5522/~/repository/freeplanet_serverside into develop 2023-11-23 15:55:16 +01:00
Surya Paolo
560a532a85 aaa 2023-11-23 15:33:45 +01:00
Surya Paolo
aac8ce0a4c ok 2023-11-23 12:45:27 +01:00
Surya Paolo
d434374ed9 Click per mandare un messaggio al Destinatario dei RIS, se non è entrato ancora in RIS ITALIA. 2023-11-19 23:40:38 +01:00
Surya Paolo
045057082c Se aggiorno il fido e massimo di un circuito, devo aggiornare anche tutti gli account dei Circuiti Nazionali 2023-11-15 18:23:10 +01:00
Surya Paolo
18c5630a45 Quando accedi al Circuito RIS Nazionale, ti imposta il Fido e QtaMax DOPPIA rispetto al tuo Circuito Locale 2023-11-15 17:50:14 +01:00
Surya Paolo
7f1bd15bcf ver 1.0.19 2023-11-03 12:49:10 +01:00
Surya Paolo
c1a9a9a555 Versione 1.0.17
- Fix saldo pendente
- aggiunto bottone markup Telegram
- aggionta opzione per registrarsi direttamente su Telegram, senza doversi registrare ad un sito
2023-10-21 15:27:53 +02:00
Surya Paolo
536fbd1752 - se iOS non ricarica la pagina ma disinstalla il SW precedente e chiede di riavviare
- fixed: Creando un Conto di Gruppo, pare che venga impostato anche l'username... invece dev'essere solo il groupname
-
2023-10-03 23:16:52 +02:00
Surya Paolo
d6303f5880 Merge branch 'develop' of gitlab.com:surya89/freeplanet_serverside into develop 2023-10-03 00:44:24 +02:00
Surya Paolo
b6579832b6 correzione numseen, numfav, ...: ora li ho aggiunti alle tabelle... 2023-10-03 00:40:42 +02:00
Surya Paolo
04c8e929ee - Migliorata la Notifica degli Eventi su Telegram
- Gli annunci (beni/servizi/ospitalità) ora possono essere visti anche tramite un link, anche per chi non è dentro alla App.
- Aggiunto bottone "Aggiorna" per aggiornare il Saldo attuale.
- I "Conti Collettivi" ora vengono chiamati Gruppi (o Conto di Gruppo).
2023-10-01 01:24:47 +02:00
Surya Paolo
142dcadca9 Fixed: le reactions devono stare in una tabella a parte (reactions).
- cambiata la gestione dei seen, fav, book, attend
2023-09-27 18:38:57 +02:00
Surya Paolo
ad6b4c2bfa Modifiche prima di Luglio... 2023-08-27 23:55:31 +02:00
Surya Paolo
ba81a33c88 l'admin non riesce a cambiare il fido degli utenti... 2023-06-20 01:07:57 +02:00
Surya Paolo
baf56b59d0 default min e max fido e accumulo, per Circuito 2023-06-19 00:47:13 +02:00
Surya Paolo
3393af36aa la creazione dell'annuncio impiega troppo tempo (e le persone cliccavano su "Salva" più volte)... 2023-06-18 22:29:06 +02:00
Surya Paolo
95a812f002 - transazioni pendenti errore fixed (Elena) 2023-06-15 23:30:48 +02:00
Surya Paolo
aff50b03d4 Controllare che le notifiche per gli Eventi arrivino agli utenti (se io sono in una provincia mi deve arrivare almeno quella) 2023-06-07 18:46:04 +02:00
Surya Paolo
e28cd5f043 Poter modificare i limiti min e max su di 1 circuito specifico 2023-06-07 12:41:01 +02:00
Surya Paolo
9e499b8f43 Notifica Telegram e Push quando mandi la stretta di mano 2023-06-07 10:14:57 +02:00
Surya Paolo
84328e7bcd Filtra Ricerca... 2023-06-05 16:36:00 +02:00
Surya Paolo
a79e79a85e - L'utente entra direttamente sul circuito, con fido a zero.
++Abilitazione Fido utente (per admin).
2023-06-01 11:39:53 +02:00
Surya Paolo
0945f1af08 ++ aggiunta la prenotazione negli eventi. con la lista degli utenti. 2023-04-17 00:11:36 +02:00
Surya Paolo
eea6e63c58 aggiunto "Seen" 2023-04-13 14:27:00 +02:00
Surya Paolo
cda0bff21f set notif if service your province 2023-04-13 13:46:48 +02:00
Surya Paolo
cada7aa0b6 favorite: send if alert active 2023-04-12 16:29:22 +02:00
Surya Paolo
f13786fca1 fix: ordinamento membri (namecomplete (concat: name, surname, username) 2023-04-12 15:37:54 +02:00
Surya Paolo
5bb6611384 Revert "Aggiornamento a 0.6.1"
This reverts commit 198b5914bc.
2023-04-07 21:02:33 +02:00
Surya Paolo
0d5bff5849 Revert "cambio nome ai circuiti"
This reverts commit 6d1ad4132f.
2023-04-07 17:19:59 +02:00
Surya Paolo
198b5914bc Aggiornamento a 0.6.1 2023-04-07 17:14:44 +02:00
Surya Paolo
94ef2c4c85 nuova veste grafica: myskills, mygoods, mybachecas, myhosps,
- cambiato id (da numero a stringa)
2023-04-07 02:45:21 +02:00
Surya Paolo
8a77dabc22 new version Visualizzazione Service 2023-04-04 15:26:56 +02:00
167 changed files with 21561 additions and 13127 deletions

BIN
.DS_Store vendored

Binary file not shown.

4
.dockerignore Normal file
View File

@@ -0,0 +1,4 @@
./node_modules
Dockerfile
.dockerignore
docker-compose.yml

38
.env.dev.pcb Normal file
View File

@@ -0,0 +1,38 @@
DATABASE=test_PiuCheBuono
UDB=paofreeplanet
PDB=mypassword@1A
SEND_EMAIL=0
SEND_EMAIL_ORDERS=1
PORT=3000
appTelegram_TEST=["1","13"]
appTelegram=["1","13"]
DOMAIN=mongodb://localhost:27017/
AUTH_MONGODB=true
MONGODB_USER=admin
MONGODB_PWD=mypwadmin@1A
ENABLE_PUSHNOTIFICATION=1
URLBASE_APP1=https://localhost
PORT_APP1=8080
SIGNCODE=SU2134hncaskjdbo231oihJSDNHEI$1@AB
HTTPS_LOCALHOST=true
DEBUG=0
DEBUG=0
TESTING_ON=1
LOCALE=1
DELAY_SENDEMAIL=2000
VAPI_KEY_SUBJECT=mailto:paolo@freeplanet.app
PUBLIC_VAPI_KEY=BDncvMiUZmjaCG2Kr1V9N0_33hOG-AuNSbHSvL24y2dzBiUjAxKm02emx5SeJvz2IGmtRf6YqCgopeQwCwUmZw8
PRIVATE_VAPI_KEY=uB2-jQkrbysyDtqN3ziMBDsVn0wdEaDsksX81zoOGQo
PATH_CERT_KEY=localhost.key
PATH_SERVER_CRT=localhost.crt
PATH_SSL_ROOT_PEM=root.pem
PATH_SSL_CHAIN_PEM=chain.pem
GCM_API_KEY=""
PROD=0
PROJECT_DESCR_MAIN='__PROJECTS'
SECRK=Askb38v23jjDFaoskBOWj92axXCQ
FTPSERVER_HOST=139.162.166.31
FTPSERVER_PORT=21
FTPSERVER_USER=ftpusrsrv_
FTPSERVER_PWD=ftpmypwd@1A_
AUTH_NEW_SITES=123123123

38
.env.dev.riso Normal file
View File

@@ -0,0 +1,38 @@
DATABASE=test_FreePlanet
UDB=paofreeplanet
PDB=mypassword@1A
SEND_EMAIL=0
SEND_EMAIL_ORDERS=1
PORT=3000
appTelegram_TEST=["1","13"]
appTelegram=["1","13"]
DOMAIN=mongodb://localhost:27017/
AUTH_MONGODB=true
MONGODB_USER=admin
MONGODB_PWD=mypwadmin@1A
ENABLE_PUSHNOTIFICATION=1
URLBASE_APP1=https://localhost
PORT_APP1=8080
SIGNCODE=SU2134hncaskjdbo231oihJSDNHEI$1@AB
HTTPS_LOCALHOST=true
DEBUG=0
DEBUG=0
TESTING_ON=1
LOCALE=1
DELAY_SENDEMAIL=2000
VAPI_KEY_SUBJECT=mailto:paolo@freeplanet.app
PUBLIC_VAPI_KEY=BDncvMiUZmjaCG2Kr1V9N0_33hOG-AuNSbHSvL24y2dzBiUjAxKm02emx5SeJvz2IGmtRf6YqCgopeQwCwUmZw8
PRIVATE_VAPI_KEY=uB2-jQkrbysyDtqN3ziMBDsVn0wdEaDsksX81zoOGQo
PATH_CERT_KEY=localhost.key
PATH_SERVER_CRT=localhost.crt
PATH_SSL_ROOT_PEM=root.pem
PATH_SSL_CHAIN_PEM=chain.pem
GCM_API_KEY=""
PROD=0
PROJECT_DESCR_MAIN='__PROJECTS'
SECRK=Askb38v23jjDFaoskBOWj92axXCQ
FTPSERVER_HOST=139.162.166.31
FTPSERVER_PORT=21
FTPSERVER_USER=ftpusrsrv_
FTPSERVER_PWD=ftpmypwd@1A_
AUTH_NEW_SITES=123123123

38
.env.development Normal file
View File

@@ -0,0 +1,38 @@
DATABASE=test_FreePlanet
UDB=paofreeplanet
PDB=mypassword@1A
SEND_EMAIL=0
SEND_EMAIL_ORDERS=1
PORT=3000
appTelegram_TEST=["1","13"]
appTelegram=["1","13"]
DOMAIN=mongodb://localhost:27017/
AUTH_MONGODB=true
MONGODB_USER=admin
MONGODB_PWD=mypwadmin@1A
ENABLE_PUSHNOTIFICATION=1
URLBASE_APP1=https://localhost
PORT_APP1=8080
SIGNCODE=SU2134hncaskjdbo231oihJSDNHEI$1@AB
HTTPS_LOCALHOST=true
DEBUG=0
DEBUG=0
TESTING_ON=1
LOCALE=1
DELAY_SENDEMAIL=2000
VAPI_KEY_SUBJECT=mailto:paolo@freeplanet.app
PUBLIC_VAPI_KEY=BDncvMiUZmjaCG2Kr1V9N0_33hOG-AuNSbHSvL24y2dzBiUjAxKm02emx5SeJvz2IGmtRf6YqCgopeQwCwUmZw8
PRIVATE_VAPI_KEY=uB2-jQkrbysyDtqN3ziMBDsVn0wdEaDsksX81zoOGQo
PATH_CERT_KEY=localhost.key
PATH_SERVER_CRT=localhost.crt
PATH_SSL_ROOT_PEM=root.pem
PATH_SSL_CHAIN_PEM=chain.pem
GCM_API_KEY=""
PROD=0
PROJECT_DESCR_MAIN='__PROJECTS'
SECRK=Askb38v23jjDFaoskBOWj92axXCQ
FTPSERVER_HOST=139.162.166.31
FTPSERVER_PORT=21
FTPSERVER_USER=ftpusrsrv_
FTPSERVER_PWD=ftpmypwd@1A_
AUTH_NEW_SITES=123123123

32
.env.prod.pcb Normal file
View File

@@ -0,0 +1,32 @@
DATABASE=PiuCheBuono
UDB=paofreeplanet
PDB=suerteFreePlanet@1A
SEND_EMAIL=1
SEND_EMAIL_ORDERS=1
PORT=3000
appTelegram_TEST=["17"]
appTelegram=["17"]
ENABLE_PUSHNOTIFICATION=1
DIRECTORY_SERVER=freeplanet_serverside
SERVERDIR_WEBSITE=www.freeplanet_server
PORT_APP1="0"
DOMAIN=mongodb://localhost:32001/
AUTH_MONGODB=1
MONGODB_USER=admin
MONGODB_PWD=mypwadminREAL@1A
SIGNCODE=SU2134hncaskjdbo231oihJSDNHEI$1@AB
DEBUG=0
LOCALE=0
DELAY_SENDEMAIL=1000
VAPI_KEY_SUBJECT="mailto:surya@riso.app"
PUBLIC_VAPI_KEY="BJgo8XR_upbnbMLWgCAUELo6DK7dRXffYAnFOxbaMMz5favBgcQBKT-eISqouO-jRad4Sw8l5nd2wCF6KorGiTc"
PRIVATE_VAPI_KEY="LVpFDJuKscdHuQr5pe20dFuYuWX1-ZRb6x72PP-Pp4I"
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
AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNVZZ

32
.env.test.pcb Normal file
View File

@@ -0,0 +1,32 @@
DATABASE=test_PiuCheBuono
UDB=paofreeplanet
PDB=suerteFreePlanet@1A
SEND_EMAIL=1
SEND_EMAIL_ORDERS=1
PORT=3001
appTelegram_TEST=["17"]
appTelegram=["17"]
ENABLE_PUSHNOTIFICATION=1
DIRECTORY_SERVER=freeplanet_serverside
SERVERDIR_WEBSITE=test.freeplanet_server
PORT_APP1="0"
DOMAIN=mongodb://localhost:32002/
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:surya@riso.app"
PUBLIC_VAPI_KEY="BJgo8XR_upbnbMLWgCAUELo6DK7dRXffYAnFOxbaMMz5favBgcQBKT-eISqouO-jRad4Sw8l5nd2wCF6KorGiTc"
PRIVATE_VAPI_KEY="LVpFDJuKscdHuQr5pe20dFuYuWX1-ZRb6x72PP-Pp4I"
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
AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNV

View File

@@ -8,7 +8,10 @@ DIRECTORY_SERVER=freeplanet_serverside
SERVERDIR_WEBSITE=test.freeplanet_server
PORT_APP1="0"
DOMAIN=mongodb://localhost:27018/
SIGNCODE=abc123
AUTH_MONGODB=1
MONGODB_USER=admin
MONGODB_PWD=mypwadmin@1A
SIGNCODE=SU2134hncaskjdbo231oihJSDNHEI$1@AB
DEBUG=0
LOCALE=0
DELAY_SENDEMAIL=1000
@@ -23,3 +26,4 @@ PATH_SSL_CHAIN_PEM=chain.pem
PROD=0
PROJECT_DESCR_MAIN='__PROJECTS'
SECRK=iUUb38v23jjDFaosWj92axkBOXCQ
AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNV

6
.gitignore vendored
View File

@@ -1,6 +1,5 @@
node_modules/
.env.test
.env.development
.env.production
.env.production.bak
ESEMPI/
@@ -25,3 +24,8 @@ src/.DS_Store
.gitignore
src/server/router/.DS_Store
src/server/.DS_Store
emails/.DS_Store
.DS_Store
.DS_Store
.DS_Store
logtrans.txt

47
.vscode/launch.json vendored
View File

@@ -2,17 +2,50 @@
"version": "0.2.0",
"configurations": [
{
"name": "Server Debug",
"type": "node",
"request": "launch",
"name": "Launch via Nodemon",
"program": "${workspaceFolder}/node_modules/nodemon/bin/nodemon.js",
"restart": true,
"runtimeExecutable": "node",
"runtimeArgs": [
"run-script",
"start"
"--inspect=9229" // Use "--inspect=0.0.0.0:9229" for remote debugging
],
"runtimeExecutable": "npm",
"skipFiles": [
"<node_internals>/**"
"args": [
"${workspaceFolder}/src/server/server.js"
], // Replace with your entry file
"cwd": "${workspaceFolder}",
"autoAttachChildProcesses": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"sourceMaps": true,
"env": {
"NODE_ENV": "development",
"TESTING_ON": "1"
},
},
{
"type": "node",
"request": "launch",
"name": "Launch Trace Warning",
"program": "${workspaceFolder}/node_modules/nodemon/bin/nodemon.js",
"restart": true,
"runtimeExecutable": "node",
"runtimeArgs": [
"--trace-warnings" // Use "--inspect=0.0.0.0:9229" for remote debugging
],
"type": "node"
"args": [
"${workspaceFolder}/src/server/server.js"
], // Replace with your entry file
"cwd": "${workspaceFolder}",
"autoAttachChildProcesses": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"sourceMaps": true,
"env": {
"NODE_ENV": "development",
"TESTING_ON": "1"
},
},
{
"name": "ServerSide",

View File

@@ -1,3 +1,7 @@
{
"search.useIgnoreFiles": false
"search.useIgnoreFiles": false,
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/node_modules/**": true
},
}

7
Dockerfile Normal file
View File

@@ -0,0 +1,7 @@
FROM node:alpine
WORKDIR /Users/suryapaolo/myproject/freeplanet_serverside
COPY package*.json .
RUN npm ci
COPY . .
#CMD ["npm", "start"]
CMD ["npm", "run", "dev"]

18
deploy_solo1.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
source ./.env.production
msg="*** SERVER DI PRODUZIONE **** SEI SICURO DI INVIARE IL SINGOLO FILE GENERAL.JS - SUL SERVER DI PRODUZIONE ?? $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 di 1 FILE in corso..."
rsync -avz -e 'ssh -p 8855' src/server/tools/general.js suryapaolo@servereng:/var/www/$SERVERDIR_WEBSITE/src/server/tools/general.js
echo "Sincronizzazione TERMINATA - SERVER PRODUZIONE!"
fi

18
deploynode_on_prod_pcb.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
source ./.env.prod.pcb
echo "Sincronizzazione in corso PCB PRODUZIONE ... /var/www/$SERVERDIR_WEBSITE/"
echo ""
rsync -avz -e 'ssh -p 8822' css pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
rsync -avz -e 'ssh -p 8822' docs pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
rsync -avz -e 'ssh -p 8822' emails pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
rsync -avz -e 'ssh -p 8822' images pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
rsync -avz -e 'ssh -p 8822' plugins pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
rsync -avz -e 'ssh -p 8822' sass pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
rsync -avz -e 'ssh -p 8822' src pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
rsync -avz -e 'ssh -p 8822' .env.prod.pcb pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/.env.production
rsync -avz -e 'ssh -p 8822' package.json pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/package.json
echo "Sincronizzazione TERMINATA! - SERVER PCB!"

19
deploynode_on_test_pcb.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/bash
source ./.env.test.pcb
echo "Sincronizzazione in corso PCB TEST ... /var/www/$SERVERDIR_WEBSITE/"
echo ""
rsync -avz -e 'ssh -p 8822' css pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
rsync -avz -e 'ssh -p 8822' docs pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
rsync -avz -e 'ssh -p 8822' emails pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
rsync -avz -e 'ssh -p 8822' images pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
rsync -avz -e 'ssh -p 8822' plugins pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
rsync -avz -e 'ssh -p 8822' sass pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
rsync -avz -e 'ssh -p 8822' src pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
rsync -avz -e 'ssh -p 8822' .env.test.pcb pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/.env.test
rsync -avz -e 'ssh -p 8822' .env.test.pcb pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
rsync -avz -e 'ssh -p 8822' package.json pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/package.json
echo "Sincronizzazione TERMINATA! - SERVER PCB!"

30
docker-compose.yml Normal file
View File

@@ -0,0 +1,30 @@
version: '3.9'
services:
# mongoDB service
mongo_db:
container_name: db_container
image: mongo:4.4
restart: always
ports:
- 2717:27017
volumes:
- mongo_db:/data/db
# Node API service
api:
build: .
ports:
- 4000:3000
volumes:
- .:/Users/suryapaolo/myproject/freeplanet_serverside
environment:
PORT: 3000
DOMAIN: mongodb://mongo_db:27017/
DATABASE: test_FreePlanet
UDB: paofreeplanet
depends_on:
- mongo_db
volumes:
mongo_db: {}

0
docs/prova.txt Normal file
View File

View File

@@ -4,7 +4,10 @@ module.exports = {
name: "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: {
"PORT": 3000,
"NODE_ENV": "development",
@@ -17,9 +20,9 @@ module.exports = {
"PORT": 3000,
"NODE_ENV": "production",
},
log_file: "combined.outerr.log",
error_file: "err.log",
out_file: "out.log",
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"
}

BIN
emails/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -1,5 +1,6 @@
p Ciao,
p Ti avvisiamo che #{username} (#{name} #{surname}) ha appena cancellato la prenotazione per l'evento #{event}:
span #{msgbooking}
span #{participants}
span #{participantsLunch}
span #{participantsDinner}

View File

@@ -1,5 +1,6 @@
p Ciao,
p Ti confermiamo che #{username} (#{name} #{surname}) ha appena inviato una richiesta di prenotazione per l'evento #{event}
p #{msgbooking}
p #{participants}
p #{participantsLunch}
p #{participantsDinner}

View File

@@ -1,5 +1,6 @@
p Ciao,
p Ti confermiamo che #{username} (#{name} #{surname}) ha appena Modificato la sua prenotazione per l'evento #{event}
p #{msgbooking}
p #{participants}
p #{participantsLunch}
p #{participantsDinner}

BIN
emails/admin/registration/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -1,5 +1,6 @@
p Ciao #{name},
p Ti confermiamo che la prenotazione per l'evento "#{event}" è stata cancellata.
p #{msgbooking}
p #{participants}
p #{participantsLunch}
p #{participantsDinner}

View File

@@ -1,5 +1,6 @@
p Ciao #{name},
p Ti confermiamo che hai appena inviato una richiesta di prenotazione per l'evento #{event}
p #{msgbooking}
p #{participants}
p #{participantsLunch}
p #{participantsDinner}

View File

@@ -1,5 +1,6 @@
p Ciao #{name},
p Ti confermiamo che hai modificato la prenotazione per l'evento #{event}
p #{msgbooking}
p #{participants}
p #{participantsLunch}
p #{participantsDinner}

View File

@@ -19,17 +19,40 @@ html
}
body(yahoofix, style="background: #ffffff")
- var baseimg = baseurl + '/statics/'
- 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 &nbsp;
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
- var mioname = name
if (!mioname)
- var mioname = user.username
p Ciao #{mioname},
if (orders.items[0].order.quantitypreordered > 0)
- var miomakeorder = mystorehouse.email_html_GAS_makeorder
else
- var miomakeorder = mystorehouse.email_html_makeorder
if (miomakeorder)
p!= miomakeorder
else
p Ti arriverà una email quando i prodotti saranno disponibili per poterli venire a ritirare.
p Il pagamento, se non diversamente comunicato, potrai farlo direttamente in sede.
p Ciao #{username},
p Ti confermiamo che hai appena inviato un'ordine di prenotazione dei seguenti prodotti:
tr
td(class="whitespace", height="10")
@@ -39,12 +62,19 @@ html
- var note = orders.note
- var index = 0
each product in orders.items
- var descr = product.order.product.name
- var img = product.order.product.img
- var price = product.order.price
- var after_price = product.order.after_price
- var qty = product.order.quantity
each rec in orders.items
- var descr = rec.order.product.productInfo.name
- var img = rec.order.product.productInfo.img
- var price = rec.order.price
- var after_price = rec.order.after_price
- var TotalPriceProduct = rec.order.TotalPriceProduct
if (rec.order.gasordine)
- var gasordine = rec.order.gasordine.name
else
- var gasordine = ''
- var qty = rec.order.quantity
- var qtypreordered = rec.order.quantitypreordered
- index = index + 1
table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
@@ -60,24 +90,40 @@ html
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 &nbsp;
tr
td(class="sectionContentTitle boldhigh", valign="top")
p #{descr}
tr
td(class="sectionContent", valign="top")
p Prezzo: #{price} € #{after_price}
tr
if (qty > 0)
td(class="sectionContent", valign="top")
p Quantità: #{qty}
if (qtypreordered > 0)
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")
p Ti arriverà una email quando i prodotti saranno disponibili per poterli venire a ritirare.
p Il pagamento potrai farlo direttamente in sede.
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")

View File

@@ -28,7 +28,12 @@ html
tr
td(class="emailContainer", valign="top")
p Ciao #{name},
- var mioname = name
if (!mioname)
- var mioname = user.username
p Ciao #{mioname},
p L'ordine è stato Cancellato.
p Se è stato un errore, procedi a ripetere l'Ordine, ripartendo dalla lista prodotti.
p Grazie Mille

View File

@@ -1,80 +0,0 @@
doctype html
html
head
title Ordine Completato
//- 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 + '/statics/'
span(id='body_style', style='display:block')
table(cellpadding="10", cellspacing="0", width="600", align="center")
tr
td(class="whitespace", height="10")
p &nbsp;
tr
td(class="emailContainer", valign="top")
p Ciao #{name},
p L'ordine n. #{ordernumber} è stato Completato correttamente !
p Grazie Mille per aver contribuito a far crescere la Comunità
table.footer(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
tr
td(class="whitespace", height="10")
p &nbsp;
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 &nbsp;
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;
}

View File

@@ -1 +0,0 @@
=`Ordine n. ${ordernumber} Completato`

View File

@@ -0,0 +1,168 @@
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 &nbsp;
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 &nbsp;
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 &nbsp;
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 &nbsp;
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;
}

View File

@@ -1,7 +1,7 @@
doctype html
html
head
title Ordine Confermato
title Ordine n. #{ordernumber} Confermato
//- import css/scss stylesheets
//- these file names will be replace by gulp with proper css file paths
@@ -19,32 +19,59 @@ html
}
body(yahoofix, style="background: #ffffff")
- var baseimg = baseurl + '/statics/'
- 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 &nbsp;
if (orders.items && orders.items.length > 0)
- var mystorehouse = orders.items[0].order.storehouse
else
- var mystorehouse = null
tr
td(class="emailContainer", valign="top")
p Ciao #{name},
p L'ordine dei seguenti prodotti è stato Confermato:
- var mioheader = mystorehouse.email_html_header
if (mioheader)
p!= mioheader
- var mioname = name
if (!mioname)
- var mioname = user.username
p Ciao #{mioname},
if (orders.items[0].order.quantitypreordered > 0)
- var miordconfirmed = mystorehouse.email_html_GAS_order_confirmed
else
- var miordconfirmed = mystorehouse.email_html_order_confirmed
if (miordconfirmed)
p!= miordconfirmed
else
p Puoi pertanto venire a ritirarli direttamente in sede, negli orari che ti sono stati indicati.
tr
td(class="whitespace", height="10")
p &nbsp;
- var totalPrice = orders.totalPrice
- var note = orders.note
- var index = 0
each product in orders.items
- var descr = product.order.product.name
- var img = product.order.product.img
- var price = product.order.price
- var after_price = product.order.after_price
- var qty = product.order.quantity
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")
@@ -60,23 +87,42 @@ html
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 &nbsp;
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")
p Puoi pertanto venire a ritirarli direttamente in sede.
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")

View File

@@ -0,0 +1,173 @@
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 &nbsp;
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
- var mioname = name
if (!mioname)
- var mioname = user.username
p Ciao #{mioname},
p L'ordine n. #{ordernumber} è stato Consegnato correttamente 📦 !
p Grazie per averci scelto 🙏🏻 e alla prossima !
p &nbsp;
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 &nbsp;
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 &nbsp;
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 &nbsp;
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;
}

View File

@@ -0,0 +1 @@
=`Ordine n. ${ordernumber} Consegnato`

View File

@@ -11,15 +11,16 @@
-}
- var urlcal = baseurl + '/calendario-eventi/'
- var imginstagram = baseurl + '/statics/images/images/footer-instagram-icon.png'
- var imgtwitter = baseurl + '/statics/images/images/footer-twitter-icon.png'
- var imgyoutube = baseurl + '/statics/images/images/footer-youtube-icon.png'
- var imgfb = baseurl + '/statics/images/images/footer-facebook-icon.png'
- var baseimg = baseurl + '/statics/'
- var imginstagram = baseurl + '/images/images/footer-instagram-icon.png'
- var imgtwitter = baseurl + '/images/images/footer-twitter-icon.png'
- var imgyoutube = baseurl + '/images/images/footer-youtube-icon.png'
- var imgfb = baseurl + '/images/images/footer-facebook-icon.png'
- var baseimg = baseurl + '/'
doctype html
html
- if (dataemail.title)
head
title Calendario Eventi
title dataemail.subject
//- import css/scss stylesheets
//- these file names will be replace by gulp with proper css file paths
@@ -37,20 +38,15 @@ html
}
body(yahoofix)
span(id='body_style', style='display:block')
table(class="preheader", cellpadding="0", cellspacing="0", width="100%")
tr
td.webversion
p non vedi le immagini?&nbsp;
a(href=urlcal) Apri il Calendario
table(class="topHeader", cellpadding="0", cellspacing="0", width="100%")
- if (dataemail.height_logo)
tr
td
table(cellpadding="0", cellspacing="0", align="center", summary="")
tr
td.logoContainer
a(href=baseurl, title='logo')
img.logo(src=baseurl+"/statics/images/logo.png", height=dataemail.height_logo)
img.logo(src=baseurl+"/images/logo.png", height=dataemail.height_logo)
tr
td.testomail
@@ -201,10 +197,6 @@ html
td(class="whitespace", height="20")
p &nbsp;
tr
td(class="whitespace", height="20")
p &nbsp;
// Social Media
table.socialMedia(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
tr

View File

@@ -25,3 +25,112 @@ Gio 05/01 ORE 19:28: USER [paoloar77]: vai al sito
Gio 05/01 ORE 19:28: USER [paoloar77]: link da condividere
Gio 16/02 ORE 18:14: USER [paoloar77]: vai al sito
Mar 06/06 ORE 19:39: USER [paoloar77]: ciaooooooooooooooooo
Mar 06/06 ORE 19:54: USER [paoloar77]: dasjdalksjdasdklasjkldasjlkdjasl
Sab 17/06 ORE 20:03: USER [paoloar77]: pro v adsasdasdaksdas
Dom 18/06 ORE 19:22: USER [paoloar77]: /start inv
Dom 18/06 ORE 19:42: USER [paoloar77]: /start inv
Dom 18/06 ORE 19:58: USER [paoloar77]: /start inv
Dom 18/06 ORE 19:59: USER [paoloar77]: /start inv
Dom 18/06 ORE 19:59: USER [paoloar77]: /start inv
Ven 23/06 ORE 14:08: USER [paoloar77]: link da condividere
Sab 30/09 ORE 00:21: USER [SuryaArena]: vai al sito
Sab 30/09 ORE 00:32: USER [SuryaArena]: vai al sito
Gio 12/10 ORE 11:11: USER [paoloar77]: prova
Gio 12/10 ORE 11:48: USER [paoloar77]: prova
Gio 12/10 ORE 12:07: USER [SuryaArena]: prova
Gio 12/10 ORE 12:07: USER [SuryaArena]: prova
Gio 12/10 ORE 12:09: USER [SuryaArena]: prova
Gio 12/10 ORE 12:10: USER [SuryaArena]: prova
Gio 12/10 ORE 12:10: USER [SuryaArena]: prova
Gio 12/10 ORE 12:13: USER [SuryaArena]: prova
Gio 12/10 ORE 12:14: USER [SuryaArena]: prova
Gio 12/10 ORE 12:16: USER [SuryaArena]: prova
Gio 12/10 ORE 12:21: USER [SuryaArena]: prova
Gio 12/10 ORE 12:33: USER [paoloar77]: prova
Gio 12/10 ORE 12:33: USER [SuryaArena]: ciao
Gio 12/10 ORE 12:33: USER [SuryaArena]: prova
Gio 12/10 ORE 12:45: USER [SuryaArena]: bottone
Gio 12/10 ORE 14:49: USER [paoloar77]: bottone
Gio 12/10 ORE 14:49: USER [paoloar77]: bottone
Gio 12/10 ORE 14:49: USER [paoloar77]: bottone
Gio 12/10 ORE 14:52: USER [paoloar77]: bottone
Gio 12/10 ORE 14:57: USER [paoloar77]: bottone
Gio 12/10 ORE 15:06: USER [paoloar77]: bottone
Ven 13/10 ORE 11:05: USER [SuryaArena]: bottone
Ven 13/10 ORE 11:40: USER [SuryaArena]: bottone
Dom 17/12 ORE 15:38: USER [admin]: prova
Dom 17/12 ORE 16:18: USER [admin]: vai al sito
Dom 17/12 ORE 16:19: USER [admin]: vai al sito
Dom 17/12 ORE 16:19: USER [admin]: il mio profilo
Dom 17/12 ORE 16:19: USER [admin]: prova
Dom 17/12 ORE 16:19: USER [admin]: link da condividere
Sab 30/12 ORE 20:06: USER [admin]: gruppo di acquisto per le arance:
produttore:
🍊sicilia frutta express (catania)
la piccola azienda a conduzione familiare di giovanni si trova in provincia di catania (sicilia), i frutti vengono prodotti rispettando i principi della biodinamica infatti non viene utilizzato nulla di chimico (niente irrorazioni) e la concimazione avviene tramite concimi naturali (letame).
⚠️ offerta sconto valida solo fino al 3 gennaio 2024, raggiungendo 100 kg totali di ordini di arance:
i prezzi sono compresi di spese di spedizione e di gestione.
🍊 arance tarocco spremuta: 1,20 € / kg
🥑 avocado: 7,80 € / kg
🍋 limoni: 2,40 € / kg
👉🏻 entra sul gruppo telegram piu che buono
per le prenotazioni potete registratevi sul nuovo sito:
👉🏻 piu che buono - gas e bottega (piuchebuono.app)
come funziona:
- registratevi su piuchebuono.app, verificate la email.
- accedete e poi cliccate su "gruppo di acquisto".
- cliccate sul carrello verde 🛒 per aggiungere i kg che desiderate.
- per finire: cliccare su "procedi all'ordine" e confermate.
Dom 21/01 ORE 19:00: USER [paoloar77]: 👉🏻 indietro

31
logevents.txt Normal file
View File

@@ -0,0 +1,31 @@
Mar 06/06 ORE 19:06: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena2 è stato Abilitato correttamente (da paoloar77)!
Mar 06/06 ORE 19:07: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena2 è stato Abilitato correttamente (da paoloar77)!
Mar 06/06 ORE 19:38: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena2 è stato Abilitato correttamente (da paoloar77)!
Mar 06/06 ORE 19:39: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
ciaooooooooooooooooo
Mar 06/06 ORE 19:49: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena2 è stato Abilitato correttamente (da paoloar77)!
Mar 06/06 ORE 19:54: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
dasjdalksjdasdklasjkldasjlkdjasl
Sab 17/06 ORE 20:03: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
pro v adsasdasdaksdas
Dom 18/06 ORE 19:22: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
/start inv
Ven 23/06 ORE 14:13: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
Dom 25/06 ORE 16:11: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
Ven 29/09 ORE 23:18: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
Mar 03/10 ORE 22:49: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
Sab 04/11 ORE 15:17: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena è stato Abilitato correttamente (da 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

View File

@@ -5,3 +5,127 @@ Lun 06/02 ORE 23:17: Inviate Monete da paoloar77 a surya1977 1 RISTEST [causale:
Dom 12/03 ORE 13:35: Inviate Monete da paoloar77 a 1 RIS [causale: ] [Saldo paoloar77: 3 RIS] [Saldo : 2 RIS]
Mer 15/03 ORE 22:15: Inviate Monete da pontiUmani (paoloar77) a paoloar77 1 RIS [causale: ] [Saldo pontiUmani (paoloar77): 1 RIS] [Saldo paoloar77: 4 RIS]
Mer 15/03 ORE 22:37: Inviate Monete da pontiUmani (paoloar77) a surya1977 1 RIS [causale: ] [Saldo pontiUmani (paoloar77): 0 RIS] [Saldo surya1977: 1 RIS]
Ven 28/04 ORE 01:33: Inviate Monete da surya1977 a risotest 1 RISTEST [causale: ] [Saldo surya1977: 0 RISTEST] [Saldo risotest: 9.5 RISTEST]
Gio 01/06 ORE 12:22: Inviate Monete da paoloar77 a surya1977 1 RIS [causale: ] [Saldo paoloar77: -2 RIS] [Saldo surya1977: 1 RIS]
Gio 01/06 ORE 12:25: Inviate Monete da paoloar77 a surya1977 2 RIS [causale: ] [Saldo paoloar77: -4 RIS] [Saldo surya1977: 3 RIS]
Gio 01/06 ORE 12:31: Inviate Monete da paoloar77 a surya1977 4 RIS [causale: ] [Saldo paoloar77: -8 RIS] [Saldo surya1977: 7 RIS]
Gio 01/06 ORE 17:26: Inviate Monete da paoloar77 a surya1977 1 RIS [causale: ] [Saldo paoloar77: -9 RIS] [Saldo surya1977: 8 RIS]
Gio 01/06 ORE 17:41: Inviate Monete da paoloar77 a surya1977 1 RIS [causale: ] [Saldo paoloar77: -10 RIS] [Saldo surya1977: 9 RIS]
Ven 02/06 ORE 19:29: Inviate Monete da paoloar77 a 2 RIS [causale: ] [Saldo paoloar77: 8 RIS] [Saldo : -261 RIS]
Ven 02/06 ORE 19:31: Inviate Monete da paoloar77 a pontiUmani 4 RIS [causale: ] [Saldo paoloar77: 0 RIS] [Saldo pontiUmani: -253 RIS]
Lun 26/06 ORE 23:23: [<b>Circuito RIS Ragusa</b>]: Inviate Monete da risragusa (paoloar77) a paogruppo2 300 RIS [causale: aaa]
Saldi:
risragusa (paoloar77): -300 RIS]
paogruppo2: 300 RIS]
Lun 26/06 ORE 23:27: [<b>Circuito RIS Ragusa</b>]: Inviate Monete da paoloar77 a paogruppo2 20 RIS [causale: ]
Saldi:
paoloar77: -20 RIS]
paogruppo2: 320 RIS]
Sab 30/09 ORE 13:32: [<b>Circuito RIS Bologna</b>]: Inviate Monete da SuryaArena a paoloar77 1 RIS [causale: aaa]
Saldi:
SuryaArena: -1 RIS]
paoloar77: 11 RIS]
Lun 09/10 ORE 09:04: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -2 RIS]
SuryaArena2: 1 RIS]
Lun 09/10 ORE 09:21: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -3 RIS]
SuryaArena2: 2 RIS]
Lun 09/10 ORE 10:25: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -4 RIS]
SuryaArena2: 3 RIS]
Lun 09/10 ORE 10:26: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -5 RIS]
SuryaArena2: 4 RIS]
Lun 09/10 ORE 23:26: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -2 RIS]
SuryaArena2: 1 RIS]
Lun 09/10 ORE 23:36: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -3 RIS]
SuryaArena2: 2 RIS]
Lun 09/10 ORE 23:36: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -4 RIS]
SuryaArena2: 3 RIS]
Mar 10/10 ORE 00:04: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -5 RIS]
SuryaArena2: 4 RIS]
Mar 10/10 ORE 00:21: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -6 RIS]
SuryaArena2: 5 RIS]
Mar 10/10 ORE 00:34: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -7 RIS]
SuryaArena2: 6 RIS]
Mar 10/10 ORE 22:47: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 1 RIS [causale: ]
Saldi:
paoloar77: -8 RIS]
PaoTEST1: 1 RIS]
Mar 10/10 ORE 22:49: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 1 RIS [causale: ]
Saldi:
paoloar77: -9 RIS]
PaoTEST1: 2 RIS]
Mar 10/10 ORE 23:08: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 2 RIS [causale: ]
Saldi:
paoloar77: -11 RIS]
PaoTEST1: 4 RIS]
Mar 10/10 ORE 23:13: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 3 RIS [causale: ]
Saldi:
paoloar77: -14 RIS]
PaoTEST1: 7 RIS]
Mar 10/10 ORE 23:22: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 1 RIS [causale: ]
Saldi:
paoloar77: -15 RIS]
PaoTEST1: 8 RIS]
Mer 11/10 ORE 22:33: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 1 RIS [causale: ]
Saldi:
paoloar77: -16 RIS]
PaoTEST1: 9 RIS]
Gio 12/10 ORE 08:05: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 1 RIS [causale: ]
Saldi:
paoloar77: -17 RIS]
PaoTEST1: 10 RIS]
Gio 12/10 ORE 08:06: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -18 RIS]
SuryaArena2: 7 RIS]
Mer 29/11 ORE 16:35: [<b>Circuito RIS Italia</b>]: Inviate Monete da SuryaArena a paoloar77 5 RIS [causale: Seconda]
Saldi:
SuryaArena: -5 RIS]
paoloar77: 5 RIS]
Mer 29/11 ORE 16:44: [<b>Circuito RIS Italia</b>]: Inviate Monete da SuryaArena a paoloar77 3 RIS [causale: Eccolo]
Saldi:
SuryaArena: -8 RIS]
paoloar77: 8 RIS]
Mer 29/11 ORE 16:50: [<b>Circuito RIS Italia</b>]: Inviate Monete da SuryaArena a paoloar77 3 RIS [causale: Ricevuto un bel massaggio]
Saldi:
SuryaArena: -11 RIS]
paoloar77: 11 RIS]
Mer 29/11 ORE 16:52: [<b>Circuito RIS Bologna</b>]: Inviate Monete da SuryaArena a paoloar77 4 RIS [causale: Un bel massaggio con olio caldo]
Saldi:
SuryaArena: -4 RIS]
paoloar77: 14 RIS]
Mer 29/11 ORE 17:14: [<b>Circuito RIS Italia</b>]: Inviate Monete da SuryaArena a paoloar77 2 RIS [causale: Massaggio !]
Saldi:
SuryaArena: -13 RIS]
paoloar77: 13 RIS]
Gio 04/01 ORE 14:00: [<b>Euro</b>]: Inviate Monete da PaoloRiso a piuchebuono 44.4 € [causale: Pagato Ordine n.101]
Saldi:
PaoloRiso: -44.4 €]
piuchebuono: 44.4 €]
Dom 07/01 ORE 16:22: [<b>Euro</b>]: Inviate Monete da PaoloRiso a 44.4 € [causale: Pagato Ordine n.101]
Saldi:
PaoloRiso: -44.4 €]
: 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 €]

View File

@@ -10,91 +10,345 @@ let aggregation = [
{
$match: {
idapp: "13",
},
},
{
$sort: {
date_updated: -1,
},
},
{
$addFields: {
myId1: {
$toObjectId: "$userId",
},
},
},
{
$lookup: {
from: "users",
localField: "myId1",
foreignField: "_id",
as: "user",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$user",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recGood: 1,
sectorGood: 1,
idSectorGood: 1,
idGood: 1,
mygood: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
"profile.resid_card": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
},
{
$lookup: {
from: "goods",
localField: "idGood",
foreignField: "_id",
as: "recGood",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$recGood",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recGood: 1,
sectorGood: 1,
idSectorGood: 1,
idGood: 1,
mygood: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
"profile.resid_card": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
},
{
$lookup: {
from: "sectorgoods",
localField: "idSectorGood",
foreignField: "_id",
as: "sectorGood",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$sectorGood",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recGood: 1,
sectorGood: 1,
idSectorGood: 1,
idGood: 1,
mygood: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
},
{
$lookup: {
from: "cities",
localField: "idCity",
foreignField: "_id",
as: "mycities",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$mycities",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recGood: 1,
sectorGood: 1,
idSectorGood: 1,
idGood: 1,
mygood: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
},
{
$match: {
$or: [
{
deleted: {
$and: [
{
"profile.mygroups": {
$elemMatch: {
groupname: {
$in: [
"000017",
"risoprova",
"VillaggiamoItalia",
"Terraw",
"RisoBenevento",
"111",
"gruppodefaultriso",
"pontiUmani",
],
},
},
},
},
{
pub_to_share: 1,
},
],
},
{
$or: [
{
pub_to_share: {
$exists: false,
},
},
{
deleted: {
pub_to_share: {
$exists: true,
$eq: false,
$eq: 0,
},
},
],
},
],
},
},
{
$match: {
$and: [
{
"mycities.reg": "EMR",
},
],
},
},
{
$group: {
_id: "$aportador_solidario",
_id: null,
count: {
$sum: 1,
},
},
},
{
$match: { "count": { $gte: 2 } }
},
{
$sort: {
count: -1,
},
},
{
$lookup: {
from: "users",
let: {
username: "$_id",
idapp: "13",
},
pipeline: [
{
$match: {
$expr: {
$and: [
{
$eq: [
"$$username",
"$username",
],
},
{
$eq: [
"$$idapp",
"$idapp",
],
},
],
},
},
},
],
as: "user",
},
},
{ $unwind: "$user" },
{
$replaceRoot: {
newRoot: {
$mergeObjects: [ "$user", "$$ROOT" ],
results: {
$push: "$$ROOT",
},
},
},
{
$project: {
_id: 0,
count: 1,
aportador_solidario: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
idapp: 1,
"profile.img": 1,
rows: {
$slice: [
"$results",
0,
10,
],
},
},
},
];
db.users.aggregate(aggregation);
db.myskills.aggregate(aggregation);

432
mongodb/Favorite.mongodb Normal file
View File

@@ -0,0 +1,432 @@
use('test_FreePlanet');
let aggregation = [
{
$match: {
idapp: "13",
},
},
{
$sort: {
date_updated: -1,
},
},
{
$lookup: {
from: "users",
let: {
tab: 1,
id: "$_id",
},
pipeline: [
{
$unwind: "$profile.favorite",
},
{
$match: {
$expr: {
$and: [
{
$eq: [
"$profile.favorite.id",
"$$id",
],
},
{
$eq: [
"$profile.favorite.tab",
"$$tab",
],
},
{
$eq: [
"$idapp",
"13",
],
},
],
},
},
},
{ $project: { username: 1, _id: 0 } },
],
as: "myfav",
},
},
{
$lookup: {
from: "users",
let: {
tab: 1,
id: "$_id",
},
pipeline: [
{
$unwind: "$profile.bookmark",
},
{
$match: {
$expr: {
$and: [
{
$eq: [
"$profile.bookmark.id",
"$$id",
],
},
{
$eq: [
"$profile.bookmark.tab",
"$$tab",
],
},
],
},
},
},
],
as: "mybook",
},
},
{
$addFields: {
myId1: {
$toObjectId: "$userId",
},
},
},
{
$lookup: {
from: "users",
localField: "myId1",
foreignField: "_id",
as: "user",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$user",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recSkill: 1,
sector: 1,
idSector: 1,
idSkill: 1,
myskill: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
myfav: 1,
mybook: 1,
},
},
{
$lookup: {
from: "skills",
localField: "idSkill",
foreignField: "_id",
as: "recSkill",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$recSkill",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recSkill: 1,
sector: 1,
idSector: 1,
idSkill: 1,
myskill: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
myfav: 1,
mybook: 1,
},
},
{
$lookup: {
from: "sectors",
localField: "idSector",
foreignField: "_id",
as: "sector",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$sector",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recSkill: 1,
sector: 1,
idSector: 1,
idSkill: 1,
myskill: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
myfav: 1,
mybook: 1,
myseen: 1,
},
},
{
$lookup: {
from: "cities",
localField: "idCity",
foreignField: "_id",
as: "mycities",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$mycities",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recSkill: 1,
sector: 1,
idSector: 1,
idSkill: 1,
myskill: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
myfav: 1,
mybook: 1,
},
},
{
$match: {
$or: [
{
$and: [
{
"profile.mygroups": {
$elemMatch: {
groupname: {
$in: [
"000017",
"risoprova",
"VillaggiamoItalia",
"Terraw",
"RisoBenevento",
"111",
"gruppodefaultriso",
"pontiUmani",
],
},
},
},
},
{
pub_to_share: 1,
},
],
},
{
$or: [
{
pub_to_share: {
$exists: false,
},
},
{
pub_to_share: {
$exists: true,
$eq: 0,
},
},
],
},
],
},
},
{
$match: {
$and: [
{
"mycities.reg": "EMR",
},
],
},
},
{
$group: {
_id: null,
count: {
$sum: 1,
},
results: {
$push: "$$ROOT",
},
},
},
{
$project: {
count: 1,
rows: {
$slice: [
"$results",
0,
10,
],
},
},
},
];
db.myskills.aggregate(aggregation);

203
mongodb/Members.mongodb Normal file
View File

@@ -0,0 +1,203 @@
use('test_FreePlanet');
let aggregation = [
{
$match: {
idapp: "13",
"profile.mycircuits": {
$elemMatch: {
circuitname: {
$eq: "Circuito RIS Bologna",
},
},
},
},
},
{
$lookup: {
from: "circuits",
as: "circuit",
let: {
circuitname: "Circuito RIS Bologna",
idapp: "$idapp",
},
pipeline: [
{
$match: {
$expr: {
$and: [
{
$eq: [
"$name",
"$$circuitname",
],
},
{
$eq: [
"$idapp",
"$$idapp",
],
},
],
},
},
},
],
},
},
{
$unwind: "$circuit",
},
{
$project: {
username: 1,
name: 1,
surname: 1,
date_reg: 1,
profile: 1,
idapp: 1,
"circuit.name": 1,
"circuit._id": 1,
},
},
{
$lookup: {
from: "accounts",
as: "account",
let: {
username: "$username",
idapp: "$idapp",
circuitId: "$circuit._id",
},
pipeline: [
{
$match: {
$expr: {
$and: [
{
$eq: [
"$$username",
"$username",
],
},
{
$eq: [
"$$idapp",
"$idapp",
],
},
{
$eq: [
"$$circuitId",
"$circuitId",
],
},
],
},
},
},
],
},
},
{
$unwind: "$account",
},
{
$match: {
idapp: "13",
},
},
{
$addFields: {
myId1: {
$toObjectId: "$userId",
},
namecomplete: {
$concat: [
{
$toLower: "$name",
},
{
$toLower: "$surname",
},
{ $toLower: "$username" },
],
},
},
},
{
$lookup: {
from: "users",
localField: "myId1",
foreignField: "_id",
as: "user",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$user",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
username: 1,
name: 1,
surname: 1,
"profile.img": 1,
"profile.mycircuits": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
"account._id": 1,
"account.saldo": 1,
"account.fidoConcesso": 1,
"account.qta_maxConcessa": 1,
"account.totTransato": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
namecomplete: 1,
date_reg: 1,
},
},
{
$sort: {
date_reg: 1,
},
},
{
$group: {
_id: null,
count: {
$sum: 1,
},
results: {
$push: "$$ROOT",
},
},
},
{
$project: {
count: 1,
rows: {
$slice: [
"$results",
1,
15,
],
},
},
},
];
db.users.aggregate(aggregation);

352
mongodb/MySkills.mongodb Normal file
View File

@@ -0,0 +1,352 @@
// MongoDB Playground
// To disable this template go to Settings | MongoDB | Use Default Template For Playground.
// Make sure you are connected to enable completions and to be able to run a playground.
// Use Ctrl+Space inside a snippet or a string literal to trigger completions.
// Select the database to use.
use('test_FreePlanet');
let aggregation = [
{
$match: {
idapp: "13",
},
},
{
$sort: {
date_updated: -1,
},
},
{
$addFields: {
myId1: {
$toObjectId: "$userId",
},
},
},
{
$lookup: {
from: "users",
localField: "myId1",
foreignField: "_id",
as: "user",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$user",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recGood: 1,
sectorGood: 1,
idSectorGood: 1,
idGood: 1,
mygood: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
},
{
$lookup: {
from: "goods",
localField: "idGood",
foreignField: "_id",
as: "recGood",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$recGood",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recGood: 1,
sectorGood: 1,
idSectorGood: 1,
idGood: 1,
mygood: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
},
{
$lookup: {
from: "sectorgoods",
localField: "idSectorGood",
foreignField: "_id",
as: "sectorGood",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$sectorGood",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recGood: 1,
sectorGood: 1,
idSectorGood: 1,
idGood: 1,
mygood: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
},
{
$lookup: {
from: "cities",
localField: "idCity",
foreignField: "_id",
as: "mycities",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$mycities",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recGood: 1,
sectorGood: 1,
idSectorGood: 1,
idGood: 1,
mygood: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
},
{
$match: {
$or: [
{
$and: [
{
"profile.mygroups": {
$elemMatch: {
groupname: {
$in: [
"000017",
"risoprova",
"VillaggiamoItalia",
"Terraw",
"RisoBenevento",
"111",
"gruppodefaultriso",
"pontiUmani",
],
},
},
},
},
{
pub_to_share: 1,
},
],
},
{
$or: [
{
pub_to_share: {
$exists: false,
},
},
{
pub_to_share: {
$exists: true,
$eq: 0,
},
},
],
},
],
},
},
{
$match: {
$and: [
{
"mycities.reg": "EMR",
},
],
},
},
{
$group: {
_id: null,
count: {
$sum: 1,
},
results: {
$push: "$$ROOT",
},
},
},
{
$project: {
count: 1,
rows: {
$slice: [
"$results",
0,
10,
],
},
},
},
];
db.myskills.aggregate(aggregation);

View File

@@ -278,3 +278,11 @@ if (test) {
// Use toArray() to exhaust the cursor to return the whole result set.
// You can use hasNext()/next() to iterate through the cursor page by page.
db.users.aggregate(aggregation);
db.getCollection('myskills').deleteMany({ '_id': { $lte: 10000 }})
db.getCollection('mygoods').deleteMany({ '_id': { $lte: 10000 }})
db.getCollection('mybachecas').deleteMany({ '_id': { $lte: 10000 }})
db.getCollection('myhosps').deleteMany({ '_id': { $lte: 10000 }})
db.getCollection('mygroups').deleteMany({ '_id': { $lte: 10000 }})

View File

@@ -0,0 +1,23 @@
use('test_FreePlanet');
let aggregation = [
{
$match: {
idapp: "13",
"profile.favorite": {
$elemMatch:
{ id: '10256', tab: 4 }
}
},
},
{
$group:
{
_id: null,
count: { $sum: 1 },
}
},
{ $project: { _id: 0 } }
];
db.users.aggregate(aggregation);

View File

@@ -4,7 +4,8 @@
"description": "freeplanet serverside",
"main": "server/server.js",
"scripts": {
"start": "NODE_ENV=development nodemon src/server/server.js",
"start": "node src/server/server.js",
"dev": "NODE_ENV=development nodemon src/server/server.js",
"build": "gulp build",
"watch": "gulp watch",
"test": "export NODE_ENV=development || SET NODE_ENV=development && mocha src/server/**/*.test.js",
@@ -13,7 +14,7 @@
"test-watch": "nodemon --exec 'npm test'"
},
"engines": {
"node": "^16.14.0"
"node": "^18.19.0"
},
"author": "Paolo Arena",
"license": "MIT",
@@ -35,8 +36,8 @@
"i18n": "^0.15.0",
"image-downloader": "^4.3.0",
"internet-available": "^1.0.0",
"jade": "^1.11.0",
"jsonwebtoken": "^8.5.1",
"jade": "^1.9.2",
"jsonwebtoken": "^9.0.1",
"lodash": "^4.17.21",
"mongodb": "^4.4.1",
"mongoose": "^5.13.15",
@@ -53,7 +54,7 @@
"pug": "^3.0.2",
"rate-limiter-flexible": "^2.3.9",
"save": "^2.5.0",
"sharp": "0.30.0",
"sharp": "^0.30.7",
"superagent": "^8.0.0",
"url-parse": "^1.5.10",
"validator": "^13.7.0",
@@ -63,15 +64,15 @@
"devDependencies": {
"browser-sync": "^2.27.10",
"expect": "^29.0.2",
"gulp": "^4.0.2",
"gulp-inline-css": "^4.0.0",
"gulp": "^3.9.1",
"gulp-inline-css": "^2.0.0",
"gulp-pug": "^5.0.0",
"gulp-rename": "^2.0.0",
"gulp-replace": "^1.1.3",
"gulp-sass": "^5.1.0",
"jest": "^29.0.2",
"mocha": "^10.0.0",
"nodemon": "^2.0.19",
"nodemon": "^3.0.1",
"supertest": "^6.2.4"
}
}

0
prova111 Normal file
View File

View File

@@ -2,7 +2,7 @@
body, #body_style {
margin: 0;
padding: 0;
background: #E9F2F9;
background: #E9F2F9 !important;
color: #5b656e;
}

View File

@@ -5,6 +5,9 @@
},
{
"path": "../../../newfreeplanet"
},
{
"path": "../../../cnm"
}
],
"settings": {

View File

@@ -2,12 +2,15 @@ const tools = require('../tools/general');
// still in app.js
const node_env = process.env.NODE_ENV || 'production';
console.log('node_env=', node_env);
var file = `.env.${node_env}`;
// GLOBALI (Uguali per TUTTI)
process.env.LINKVERIF_REG = '/vreg';
process.env.LINK_REQUEST_NEWPASSWORD = '/requestnewpwd';
process.env.ADD_NEW_SITE = '/addNewSite';
process.env.LINK_UPDATE_PASSWORD = '/updatepassword';
process.env.LINK_UPDATE_PWD = '/updatepwd';
process.env.LINK_CHECK_UPDATES = '/checkupdates';
@@ -18,7 +21,10 @@ require('dotenv').config({ path: file });
process.env.DATABASE = process.env.DATABASE || 'FreePlanet';
console.log('process.env.DOMAIN:', process.env.DOMAIN);
process.env.MONGODB_URI = process.env.DOMAIN + process.env.DATABASE;
console.log('process.env.MONGODB_URI:', process.env.MONGODB_URI);
/*

View File

@@ -11,7 +11,7 @@ mongoose.plugin(schema => {
mongoose.set('debug', false);
const options = {
let options = {
// user: process.env.UDB,
// pass: process.env.PDB,
// useMongoClient: true,
@@ -38,18 +38,35 @@ const options = {
// keepAliveInitialDelay: 300000 // keepAliveInitialDelay is the number of milliseconds to wait before initiating keepAlive on the socket.
};
if (process.env.AUTH_MONGODB === '1') {
options.auth = {
authSource: "admin",
poolSize: 10,
user: process.env.MONGODB_USER,
password: process.env.MONGODB_PWD,
};
}
if (options.auth && options.auth.user) {
console.log('MongoDb con Authenticazione:', options.auth.user, '******');
} else {
console.log('### MongoDb SENZA Authenticazione !!! ');
}
const db = mongoose.connection;
console.log('Node Version ' + process.version);
console.log('Mongoose Version ' + mongoose.version);
// mongoose.connect(process.env.MONGODB_URI + '?authSource=admin', { options })
// console.log(' -> PASSAGGIO PARAMETRI MONGOOSE')
mongoose.connect(process.env.MONGODB_URI, options);
connectionUrl = process.env.MONGODB_URI;
console.log('Connessione a ' + connectionUrl + ' in corso...');
mongoose.connect(connectionUrl, options);
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function () {
// we're connected!
console.log('*** CONNESSIONE EFFETTUATA ! ' + process.env.MONGODB_URI + ' db: ' + process.env.DATABASE)
console.log('*** CONNESSIONE EFFETTUATA ! ' + connectionUrl + ' db: ' + process.env.DATABASE)
});

View File

@@ -3,15 +3,24 @@
"Hello %s": "Ciao %s",
"Good: %s": "Bene: %s",
"Service: %s": "Servizio: %s",
"<strong>%s</strong> new Good: %s": "<strong>%s</strong> nuovo Bene: %s",
"<strong>%s</strong> new Service: %s": "<strong>%s</strong> nuovo Servizio: %s",
"NEW_GOOD": "❇️ <strong>%s</strong> ha aggiunto un nuovo Bene: \n<strong>%s</strong>",
"NEW_SERVICE": "❇️ <strong>%s</strong> ha aggiunto un nuovo Servizio: \n<strong>%s</strong>",
"NEW_HOSP": "❇️ <strong>%s</strong> ha aggiunto una nuova Ospitalità: \n<strong>%s</strong>",
"NEW_EVENT": "❇️ <strong>%s</strong> ha aggiunto un nuovo Evento: \n%s\n<strong>%s</strong>\n%s",
"NEW_EVENT_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>",
"CONTRIB": "\n💠 Contributo richiesto: %s",
"ORGANIZED_BY": "\n<i>Organizzato da <strong>%s</strong></i>",
"SHOW_POST": "👉🏻 vedi post su RISO",
"OPEN PAGE": "<em>APRI la APP RISO oppure visita riso.app</em>",
"<strong>%s</strong> asked you for Friendship": "<strong>%s</strong> ti ha chiesto l'Amicizia",
"<strong>%s</strong> accepted your Friendship": "<strong>%s</strong> ha accettato l'Amicizia",
"<strong>%s</strong> refused your Friendship": "<strong>%s</strong> ha rifiutato l'Amicizia",
"✅ %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.",
"HANDSHAKE_SET": "<strong>%s</strong> ha comunicato che ti conosce personalmente e ha Fiducia in te (Stretta di mano).",
"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)",
"GROUPS_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del Gruppo %s. Se pensi sia un'errore, contatta l'amministratore del Gruppo.",
"GROUPS_REMOVED": "❌ l'utente %s è stato rimosso del Gruppo %s (da parte di %s)",
@@ -34,57 +43,75 @@
"FRIEND_UNBLOCKED_TO_ME": "Sei stato riattivato da %s",
"FRIEND_UNBLOCKED": "E' stato riattivato %s da %s.",
"FRIEND_UNBLOCKED_YOU": "Hai riattivato %s.",
"CIRCUIT_ACCEPT_NEWENTRY": "❇️👥 🧍‍♂️ Accetta Ingresso nel Circuito %s:",
"CIRCUIT_ACCEPT_NEWENTRY_BYGROUP": "❇️👥 🧍‍♂️ Accetta Ingresso nel Circuito il gruppo %s:",
"CIRCUIT_REQUEST_TO_ENTER": "%s ha chiesto di entrare nel circuito %s",
"CIRCUIT_REQUEST_TO_ENTER_WITH_GROUP": "il gruppo %s ha chiesto di entrare nel circuito %s",
"CIRCUIT_ACCEPT_NEWENTRY": "❇️👥 🧍‍♂️ Abilita Fiducia a %s nel '%s':",
"CIRCUIT_ACCEPT_NEWENTRY_BYGROUP": "❇️👥 🧍‍♂️ Abilita Fiducia nel Circuito al gruppo %s:",
"CIRCUIT_OPEN_RISITALIA": "Apri il Circuito RIS Italia e chiedi di entrare",
"CIRCUIT_REQUEST_TO_ENTER": "%s è entrato nel %s (con %s iscritti) ed è in attesa di essere abilitato alla Fiducia\n🙎🏻 Invitato da %s",
"CIRCUIT_ADMINS": "Gli amministratori del circuito sono %s:\n%s",
"CIRCUIT_WHERE_IS_PRESENT": "\nAttualmente è presente in: %s",
"CIRCUIT_REQUEST_TO_ENTER_WITH_GROUP": "il gruppo %s ha chiesto di entrare nel %s (con %s iscritti)",
"CIRCUIT_CREATED": "✅ %s ha creato un nuovo Circuito chiamato %s",
"CIRCUIT_REQUEST": "Richiesta di entrare nel Circuito %s da parte di %s",
"CIRCUIT_ADDED_ADMIN": "E' stato aggiunto %s come Amministratore del circuito %s da parte di %s",
"CIRCUIT_ADDED_ADMIN_YOU": "Sei stato aggiunto come Amministratore del circuito %s da parte di %s",
"CIRCUIT_REMOVED_ADMIN": "E' stato rimosso l'incarico di Amministratore a %s del circuito %s da parte di %s",
"CIRCUIT_REMOVED_ADMIN_YOU": "Ti è stato rimosso l'incarico di Amministratore del circuito %s da parte di %s",
"RICHIESTA_BLOCCO_CIRCUIT": "Richiesta di bloccare il Circuito %s da parte di %s",
"CIRCUIT_ELIMINATO": "Il circuito %s è stato eliminato da parte di %s",
"ACCETTATO_NOTIFICA_ADMINS_CIRCUIT": "✅ l'utente %s è stato accettato a far parte del Circuito %s (da parte di %s)",
"ACCETTATO_NOTIFICA_ADMINS_CIRCUIT_MYGROUP": "✅ il Conto Collettivo %s è stato accettato a far parte del Circuito %s (da parte di %s)",
"CIRCUIT_ACCEPTED": "✅ Sei stato accettato da %s a far parte del Circuito %s.\nApri la APP e clicca in alto a destra sull'icona delle monete, oppure clicca qui: %s",
"CIRCUIT_ACCEPTED_YOU": "✅ Hai accettato %s a far parte del Circuito %s",
"CIRCUIT_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del Circuito %s. Se pensi sia un'errore, contatta l'amministratore del Circuito.",
"CIRCUIT_REMOVED": "❌ l'utente %s è stato rimosso del Circuito %s (da parte di %s)",
"CIRCUIT_REFUSED_TO_ME": "All'utente %s gli è stato rifiutato l'accesso a far parte del Circuito %s (da parte di %s).",
"CIRCUIT_REFUSED_TO_MYGROUP": "Al Conto Collettivo %s gli è stato rifiutato l'accesso a far parte del Circuito %s (da parte di %s).",
"CIRCUIT_EXIT_USER": "❌ l'utente %s è uscito dal Circuito %s",
"CIRCUIT_EXIT_USER_TO_ME": "❌ Sei uscito dal Circuito %s",
"CIRCUIT_REMOVED_TO_ME": "❌ Sei stato rimosso dal Circuito %s (da parte di %s)",
"CIRCUIT_SENDCOINSREQ": "%s ti sta inviando <strong>%s %s</strong>.",
"CIRCUIT_REQUEST": "Richiesta di entrare nel %s da parte di %s",
"CIRCUIT_ADDED_ADMIN": "E' stato aggiunto %s come Amministratore del %s da parte di %s",
"CIRCUIT_ADDED_ADMIN_YOU": "%s sei stato aggiunto come Amministratore del %s da parte di %s",
"CIRCUIT_REMOVED_ADMIN": "E' stato rimosso l'incarico di Amministratore a %s del %s da parte di %s",
"CIRCUIT_REMOVED_ADMIN_YOU": "%s ti è stato rimosso l'incarico di Amministratore del %s da parte di %s",
"RICHIESTA_BLOCCO_CIRCUIT": "Richiesta di bloccare il %s da parte di %s",
"CIRCUIT_ELIMINATO": "Il %s è stato eliminato da parte di %s",
"FIDO_IMPOSTATO_ADMINS_CIRCUIT": "✅ l'utente %s è stato abilitato alla Fiducia (%s RIS) sul '%s' (da parte di %s)",
"FIDO_IMPOSTATO_ADMINS_CIRCUIT_MYGROUP": "✅ il Conto di Gruppo %s è stato abilitato alla Fiducia fino a -%s sul '%s' (da parte di %s)",
"ACCETTATO_NOTIFICA_ADMINS_CIRCUIT": "✅ l'utente %s è stato accettato a far parte del '%s' (da parte di %s)",
"ACCETTATO_NOTIFICA_ADMINS_CIRCUIT_MYGROUP": "✅ il Conto di Gruppo %s è stato accettato a far parte del '%s' (da parte di %s)",
"CIRCUIT_ACCEPTED": "✅ Sei stato accettato da %s a far parte del %s.\nApri la APP e clicca in alto a destra sull'icona delle monete, oppure clicca qui: %s",
"FIDO_IMPOSTATO": "✅ Ti è stata attivata la possibilità di utilizzare la Fiducia Concessa fino a %s RIS da %s sul '%s'.",
"CIRCUIT_ACCEPTED_YOU": "✅ Hai accettato %s a far parte del '%s'",
"CIRCUIT_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del '%s'. Se pensi sia un'errore, contatta l'amministratore del Circuito.",
"CIRCUIT_REMOVED": "❌ l'utente %s è stato rimosso del %s (da parte di %s)",
"CIRCUIT_REFUSED_TO_ME": "All'utente %s gli è stato rifiutato l'accesso a far parte del '%s' (da parte di %s).",
"CIRCUIT_REFUSED_TO_MYGROUP": "Al Conto Collettivo %s gli è stato rifiutato l'accesso a far parte del '%s' (da parte di %s).",
"CIRCUIT_EXIT_USER": "❌ l'utente %s è uscito dal '%s'",
"CIRCUIT_EXIT_USER_TO_ME": "❌ Sei uscito dal '%s'",
"CIRCUIT_REMOVED_TO_ME": "❌ Sei stato rimosso dal '%s' (da parte di %s)",
"CIRCUIT_SENDCOINSREQ": "%s ti sta inviando <strong>%s %s</strong> sul <strong>'%s'</strong>",
"COMUNITARIO": "Comunitario",
"COLLETTIVO": "Collettivo",
"CIRCUIT_SENDCOINSREQ_GROUP": "%s sta inviando <strong>%s %s</strong> al Conto %s '%s'.",
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_USER": "il conto %s '%s' (%s) sta inviando <strong>%s %s</strong> a %s.",
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_YOU": "il conto %s '%s' (%s) ti sta inviando <strong>%s %s</strong>",
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_GROUP": "il conto %s '%s' (%s) sta inviando <strong>%s %s</strong> al conto %s '%s'.",
"CIRCUIT_SENDCOINSREQ_TO_ME": "Stai inviando <strong>%s %s</strong> a %s. \nIl destinatario deve accettare la transazione.",
"CIRCUIT_SENDCOINSREQ_TO_GROUP": "Stai inviando <strong>%s %s</strong> al Conto %s '%s'. \nIl destinatario deve accettare la transazione.",
"ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_YOU": "<strong>%s %s</strong> accettati dal Conto %s '%s' (%s).",
"ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_GROUP": "il conto %s '%s' (%s) ha accettato <strong>%s %s</strong> dal conto %s '%s' (%s).",
"ID_CIRCUIT_COINS_ACCEPTED_FROM_ME_TO_GROUP": "il conto %s '%s' (%s) ha accettato <strong>%s %s</strong> da %s.",
"ID_CIRCUIT_COINS_ACCEPTED_FROM_ME_TO_YOU": "<strong>%s %s</strong> accettati da %s.",
"ID_CIRCUIT_COINS_ACCEPTED": "<strong>%s %s</strong> accettati da %s.",
"SALDO_UPDATE": "[Saldo <strong>%s %s</strong>]",
"SALDO_UPDATE_WHO": "[Saldo %s <strong>%s %s</strong>]",
"ID_CIRCUIT_COINS_ACCEPTED_TO_ME": "<strong>%s %s</strong> sono stati accettati da %s.",
"ID_CIRCUIT_COINS_REFUSED": "%s %s rifiutati da %s.",
"ID_CIRCUIT_COINS_REFUSED_TO_ME": "%s %s rifiutati da %s.",
"COLLETTIVO": "Gruppo",
"CIRCUIT_SENDCOINSREQ_GROUP": "%s sta inviando <strong>%s %s</strong> al Conto %s '%s' sul '%s'.",
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_USER": "il conto %s '%s' (%s) sta inviando <strong>%s %s</strong> a %s sul '%s'.",
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_YOU": "il conto %s '%s' (%s) ti sta inviando <strong>%s %s</strong> sul '%s'",
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_GROUP": "il conto %s '%s' (%s) sta inviando <strong>%s %s</strong> al conto %s '%s' sul '%s'.",
"CIRCUIT_SENDCOINSREQ_TO_ME": "Stai inviando <strong>%s %s</strong> a %s sul '%s'. \nIl destinatario deve accettare la transazione.",
"CIRCUIT_SENDCOINSREQ_TO_GROUP": "Stai inviando <strong>%s %s</strong> al Conto %s '%s' sul '%s'. \nIl destinatario deve accettare la transazione.",
"ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_YOU": "<strong>%s %s</strong> accettati dal Conto %s '%s' sul '%s' (%s) .",
"ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_GROUP": "il conto %s '%s' (%s) ha accettato <strong>%s %s</strong> dal conto %s '%s' sul '%s' (%s).",
"ID_CIRCUIT_COINS_ACCEPTED_FROM_ME_TO_GROUP": "il conto %s '%s' (%s) ha accettato <strong>%s %s</strong> da %s sul '%s'.",
"ID_CIRCUIT_COINS_ACCEPTED_FROM_ME_TO_YOU": "<strong>%s %s</strong> accettati da %s sul '%s'.",
"ID_CIRCUIT_COINS_ACCEPTED": "<strong>%s %s</strong> accettati da %s sul '%s'.",
"SALDO_UPDATE": "[Saldo <strong>%s %s</strong> sul '%s']",
"SALDO_UPDATE_WHO": "[Saldo %s <strong>%s %s</strong> sul '%s']",
"ID_CIRCUIT_COINS_ACCEPTED_TO_ME": "<strong>%s %s</strong> sono stati accettati da %s sul '%s'.",
"ID_CIRCUIT_COINS_REFUSED": "%s %s rifiutati da %s sul '%s'.",
"ID_CIRCUIT_COINS_REFUSED_TO_ME": "%s %s rifiutati da %s sul '%s'.",
"CIRCUIT_AMOUNT_EXCEED_FIDO": "L'importo supera la quantità massima concessa per %s",
"CIRCUIT_AMOUNT_EXCEED_QTAMAX": "L'importo supera la quantità massima che il destinatario (%s) può accumulare",
"CIRCUIT_COINS_ALREADY_PROCESSED": "La richiesta è stata già processata. Stato %s",
"STATUS_SENT": "Inviato",
"STATUS_REFUSED": "Rifiutato",
"SALDO_VARIATO": "[Circuito %s] l'utente %s ha variato il Saldo di %s da %s a %s %s",
"FIDOCONCESSO_VARIATO": "[Circuito %s] l'utente %s ha variato il Fido Concesso di %s da %s a %s %s",
"QTAMAX_VARIATO": "[Circuito %s] l'utente %s ha variato la quantità massima concessa di %s da %s a %s %s",
"CLICCA_QUI": "CLICCA QUI"
"SALDO_VARIATO": "[%s] l'utente %s ha variato il Saldo di %s da %s a %s %s",
"FIDOCONCESSO_VARIATO": "[%s] l'utente %s ha variato la Fiducia Concessa di %s da %s a %s %s",
"QTAMAX_VARIATO": "[%s] l'utente %s ha variato la quantità massima concessa di %s da %s a %s %s",
"SET_FAVORITE": "%s ha messo 'Mi Piace' al tuo post: %s",
"SET_FAVORITE_OTHERS": "%s e altre %s persone hanno messo 'Mi Piace' al tuo post: %s",
"EVENT_SEND_MSG": "%s ha mandato un messaggio sull'evento %s: \n%s",
"SET_ATTEND": "%s ha detto che Parteciperà all'evento: %s",
"SET_ATTEND_OTHERS": "%s e altre %s persone hanno detto che Parteciperanno all'evento: %s",
"DATEDAYONLY": "%s dalle %s alle %s",
"DATE_2DAYS": "%s dalle %s fino a %s alle %s",
"SENDMSG_ENTRA_IN_RISO_ITALIA": "Ciao %s!<br>%s che appartiene al <em>%s</em> vuole inviarti dei RIS. Per poterli ricevere dovete entrambi utilizzare il <strong>Circuito RIS Italia</strong>.",
"CLICCA_QUI": "CLICCA QUI",
"✅ %s è stato Abilitato correttamente (da %s)!": "✅ %s è stato Abilitato correttamente (da %s)!",
"✅ Sei stato Abilitato correttamente da %s!": "✅ Sei stato Abilitato correttamente da %s!",
"🚫 Hai rifiutato l'accesso alla App di RISO da parte di %s!": "🚫 Hai rifiutato l'accesso alla App di RISO da parte di %s!",
"🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.": "🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.",
"🚫 %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 !"
}

View File

@@ -30,6 +30,9 @@ const AccountSchema = new Schema({
idapp: {
type: String,
},
numtransactions: {
type: Number,
},
username: {
type: String,
},
@@ -56,12 +59,23 @@ const AccountSchema = new Schema({
},
importo_iniziale: {
type: Number,
default: 0,
},
saldo: {
type: Number,
default: 0,
},
totTransato: {
type: Number,
default: 0,
},
saldo_pend: {
type: Number,
default: 0,
},
totTransato_pend: {
type: Number,
default: 0,
},
regulation_ok: {
type: Boolean,
@@ -138,7 +152,7 @@ AccountSchema.statics.calcTotCircolante = async function (idapp, circuitId) {
{ $group: { _id: null, count: { $sum: '$saldo' } } }
];
ris = await Account.aggregate(aggr1);
const ris = await Account.aggregate(aggr1);
return ris ? ris[0].count : 0;
@@ -147,23 +161,69 @@ AccountSchema.statics.calcTotCircolante = async function (idapp, circuitId) {
}
};
AccountSchema.methods.addtoSaldoSave = async function (amount) {
AccountSchema.methods.calcPending = async function (mittente) {
try {
const account = this;
if (account) {
account.saldo = account.saldo + amount;
if (!account.totTransato) {
account.totTransato = 0;
}
account.totTransato += Math.abs(amount);
account.date_updated = new Date();
return await account.save();
}
const { SendNotif } = require('../models/sendnotif');
const { Circuit } = require('../models/circuit');
return null;
// *** Calc Pending Transactions ***
const circuit = await Circuit.getCircuitById(account.circuitId);
if (circuit) {
let prec_saldo_pend = account.saldo_pend;
let prec_totTransato_pend = account.totTransato_pend;
let transatopending = 0;
if (mittente) {
let pendingtransactionsMittente = await SendNotif.getSumPendingTransactionsMittente(account.idapp, account.username, circuit.name, account.groupname);
let saldopendingMitt = pendingtransactionsMittente.reduce((sum, rec) => sum + rec.extrarec.qty, 0);
transatopending = pendingtransactionsMittente.reduce((sum, rec) => sum + Math.abs(rec.extrarec.qty), 0);
account.saldo_pend = account.saldo - saldopendingMitt;
} else {
// let pendingtransactionsDest = await SendNotif.getSumPendingTransactionsMittente(account.idapp, account.username, circuit.name, account.groupname);
// let saldopendingDest = pendingtransactionsDest.reduce((sum, rec) => sum + rec.extrarec.qty, 0);
// transatopending = pendingtransactionsDest.reduce((sum, rec) => sum + Math.abs(rec.extrarec.qty), 0);
// account.saldo_pend = account.saldo + saldopendingDest;
account.saldo_pend = account.saldo;
}
account.totTransato_pend = account.totTransato + transatopending;
if (prec_saldo_pend !== account.saldo_pend || prec_totTransato_pend !== account.totTransato_pend) {
const myaccountupdate = {
saldo_pend: account.saldo_pend,
totTransato_pend: account.totTransato_pend,
};
AccountSchema.statics.addtoSaldo = async function (myaccount, amount) {
// Update Record
return await Account.findByIdAndUpdate(account.id,
{
$set: myaccountupdate
}).then((ris) => {
console.log('calcPending', ris);
}).catch((err) => {
console.error('calcPending', err);
});
}
}
// -----
} catch (e) {
console.error(e);
}
}
AccountSchema.statics.addtoSaldo = async function (myaccount, amount, mitt) {
const Account = this;
try {
@@ -175,16 +235,27 @@ AccountSchema.statics.addtoSaldo = async function (myaccount, amount) {
myaccount.totTransato = 0;
}
myaccount.totTransato += Math.abs(amount);
if (!myaccount.numtransactions)
myaccount.numtransactions = 0;
myaccount.numtransactions++;
myaccount.date_updated = new Date();
myaccountupdate.saldo = myaccount.saldo;
myaccountupdate.totTransato = myaccount.totTransato;
myaccountupdate.date_updated = myaccount.date_updated;
return await Account.updateOne({ _id: myaccount.id },
const ris = await Account.updateOne({ _id: myaccount.id },
{
$set: myaccountupdate
});
await myaccount.calcPending(mitt);
return ris;
}
} catch (e) {
console.error('error', e);
@@ -195,13 +266,96 @@ AccountSchema.statics.addtoSaldo = async function (myaccount, amount) {
AccountSchema.pre('save', async function (next) {
if (this.isNew) {
if (!this.date_created)
this.date_created = new Date();
}
next();
});
AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp, username, circuitId, createifnotexist, groupname = '', contocom = "") {
AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp, username, circuitId, createifnotexist, confido, groupname = '', contocom = "") {
const Account = this;
try {
const { Circuit } = require('../models/circuit');
// if (username === undefined)
// return false;
let myquery = {
idapp,
circuitId,
};
if (groupname) {
myquery.groupname = groupname;
} else if (contocom) {
myquery.contocom = contocom;
} else {
myquery.username = username;
}
let mycircuit = await Circuit.getCircuitById(circuitId);
if (mycircuit) {
let myaccount = await Account.findOne(myquery);
if (!myaccount && createifnotexist) {
myaccount = new Account({
_id: new ObjectID().toString(),
idapp,
username: (!groupname && !contocom) ? username : '',
groupname,
contocom,
circuitId: mycircuit._id,
deperibile: false,
importo_iniziale: 0,
saldo: 0,
saldo_pend: 0,
fidoConcesso: 0,
qta_maxConcessa: 0,
totTransato: 0,
numtransactions: 0,
totTransato_pend: 0,
});
if (contocom) {
myaccount.fidoConcesso = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_CONTO_COMUNITARIO;
myaccount.qta_maxConcessa = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_CONTO_COMUNITARIO;
} else {
if (!mycircuit.fido_scoperto_default_grp)
mycircuit.fido_scoperto_default_grp = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_GRP;
if (!mycircuit.qta_max_default_grp)
mycircuit.qta_max_default_grp = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_GRP;
if (groupname) {
myaccount.fidoConcesso = mycircuit.fido_scoperto_default_grp;
myaccount.qta_maxConcessa = mycircuit.qta_max_default_grp;
} else {
myaccount.fidoConcesso = mycircuit.fido_scoperto_default;
myaccount.qta_maxConcessa = mycircuit.qta_max_default;
}
}
if (!confido) {
myaccount.fidoConcesso = 0;
}
return await myaccount.save();
}
return myaccount;
}
return null;
} catch (e) {
console.error('error', e);
}
};
AccountSchema.statics.isExistAccountByUsernameAndCircuitId = async function (idapp, username, circuitId, groupname = '', contocom = "") {
const Account = this;
try {
@@ -228,47 +382,10 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
if (mycircuit) {
let myaccount = await Account.findOne(myquery);
if (!myaccount && createifnotexist) {
myaccount = new Account({
_id: new ObjectID().toString(),
idapp,
username,
groupname,
contocom,
circuitId: mycircuit._id,
deperibile: false,
importo_iniziale: 0,
saldo: 0,
fidoConcesso: 0,
qta_maxConcessa: 0,
});
if (contocom) {
myaccount.fidoConcesso = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_CONTO_COMUNITARIO;
myaccount.qta_maxConcessa = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_CONTO_COMUNITARIO;
} else {
if (!mycircuit.fido_scoperto_default_grp)
mycircuit.fido_scoperto_default_grp = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_GRP;
if (!mycircuit.qta_max_default_grp)
mycircuit.qta_max_default_grp = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_GRP;
if (groupname) {
myaccount.fidoConcesso = mycircuit.fido_scoperto_default_grp;
myaccount.qta_maxConcessa = mycircuit.qta_max_default_grp;
} else {
myaccount.fidoConcesso = mycircuit.fido_scoperto_default;
myaccount.qta_maxConcessa = mycircuit.qta_max_default;
}
return !!myaccount
}
return await myaccount.save();
}
return myaccount;
}
return null;
return false;
} catch (e) {
console.error('error', e);
@@ -276,14 +393,14 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
};
AccountSchema.statics.createAccount = async function (idapp, username, circuitName, groupname = '', contocom = '') {
AccountSchema.statics.createAccount = async function (idapp, username, circuitName, confido, groupname = '', contocom = '') {
const { Circuit } = require('../models/circuit');
try {
mycircuit = await Circuit.findOne({ name: circuitName }, { _id: 1 });
if (mycircuit) {
return await Account.getAccountByUsernameAndCircuitId(idapp, username, mycircuit._id, true, groupname, contocom);
return await Account.getAccountByUsernameAndCircuitId(idapp, username, mycircuit._id, true, confido, groupname, contocom);
} else {
return null;
}
@@ -295,6 +412,7 @@ AccountSchema.statics.createAccount = async function (idapp, username, circuitNa
};
AccountSchema.statics.getUserAccounts = async function (idapp, username) {
const { SendNotif } = require('../models/sendnotif');
try {
let aggr1 = [
@@ -326,42 +444,64 @@ AccountSchema.statics.getUserAccounts = async function (idapp, username) {
$match: {
$expr: {
$and: [
{ $eq: ['$idapp', '$$idapp'] },
{ $eq: ['$typedir', '$$typedir'] },
{ $eq: ['$typeid', '$$typeid'] },
{ $eq: ['$status', 0] },
{ $eq: ['$sender', '$$username'] },
{ $eq: ['$idapp', '$$idapp'] },
{ $eq: ['$extrarec.circuitname', '$$circuitname'] },
],
},
},
},
{
$group:
{ _id: "$extrarec.notifIdToUpdate", result: { $first: "$$ROOT" } }
},
],
},
},
];
ris = await this.aggregate(aggr1);
const ris = await this.aggregate(aggr1);
const { SendNotif } = require('../models/sendnotif');
// console.log('1 - INIZIA getUserAccounts ')
// console.log(aggr1);
if (ris) {
/* if (ris) {
for (const account of ris) {
const pendingtransactions = await SendNotif.getSumPendingTransactions(idapp, username, account.circuit.name);
const saldopending = pendingtransactions.reduce((sum, rec) => sum + rec.extrarec.qty, 0);
try {
//++OTTIMIZZARE QUESTA PARTE ! (CON UNA QUERY...)
// console.log(' 1B - PENDIND... ')
let pendingtransactions = await SendNotif.getSumPendingTransactions(idapp, username, account.circuit.name);
let saldopending = pendingtransactions.reduce((sum, rec) => sum + rec.extrarec.qty, 0);
if (saldopending !== 0) {
account.saldo -= saldopending;
account.totTransato = account.totTransato || 0;
}
} catch (e) {
console.error('getUserAccounts 1) ', e);
}
}
} */
return ris;
} catch (e) {
console.error('e', e);
console.error('getUserAccounts', e);
}
};
AccountSchema.statics.getGroupAccounts = async function (idapp, groupname) {
if (!groupname) {
return [];
}
try {
let aggr1 = [
{
@@ -402,22 +542,16 @@ AccountSchema.statics.getGroupAccounts = async function (idapp, groupname) {
},
},
},
{
$group:
{ _id: "$extrarec.notifIdToUpdate", result: { $first: "$$ROOT" } }
},
],
},
},
];
ris = await this.aggregate(aggr1);
const { SendNotif } = require('../models/sendnotif');
if (ris) {
for (const account of ris) {
const pendingtransactions = await SendNotif.getSumPendingTransactions(idapp, '', account.circuit.name, groupname);
const saldopending = pendingtransactions.reduce((sum, rec) => sum + rec.extrarec.qty, 0);
account.saldo -= saldopending;
}
}
const ris = await this.aggregate(aggr1);
return ris;
} catch (e) {
@@ -430,7 +564,7 @@ AccountSchema.statics.getGroupAccounts = async function (idapp, groupname) {
AccountSchema.statics.SetMinMaxCollettivi = async function (idapp, valmin, valmax) {
const Account = this;
ris = await Account.updateMany({ idapp, groupname: { "$nin": [null, ""] } },
const ris = await Account.updateMany({ idapp, groupname: { "$nin": [null, ""] } },
{
$set:
{
@@ -445,7 +579,7 @@ AccountSchema.statics.SetMinMaxCollettivi = async function (idapp, valmin, valma
AccountSchema.statics.SetMinMaxComunitari = async function (idapp, valmin, valmax) {
const Account = this;
ris = await Account.updateMany({ idapp, contocom: { "$nin": [null, ""] } },
const ris = await Account.updateMany({ idapp, contocom: { "$nin": [null, ""] } },
{
$set:
{
@@ -457,18 +591,121 @@ AccountSchema.statics.SetMinMaxComunitari = async function (idapp, valmin, valma
};
// Imposta a tutti i Conti Personali, i seguenti minimi e massimi
AccountSchema.statics.SetMinMaxPersonali = async function (idapp, valmin, valmax) {
AccountSchema.statics.SetMinMaxPersonali = async function (idapp, fidoConcesso, qta_maxConcessa, circuitId) {
const Account = this;
ris = await Account.updateMany({ idapp, username: { "$nin": [null, ""] } },
if (circuitId) {
const ris = await Account.updateMany({ idapp, circuitId, fidoConcesso: { $gt: 0 }, username: { "$nin": [null, ""] } },
{
$set:
{
fidoConcesso: valmin,
qta_maxConcessa: valmax,
fidoConcesso,
qta_maxConcessa,
}
});
// Se aggiorno questi dati, allora devo aggiornare anche gli account del RIS Nazionale
await Account.updateAccountCircuitoNazionaleByLimiti(idapp, circuitId, fidoConcesso, qta_maxConcessa);
} else {
const ris = await Account.updateMany({ idapp, fidoConcesso: { $gt: 0 }, username: { "$nin": [null, ""] } },
{
$set:
{
fidoConcesso,
qta_maxConcessa,
}
});
}
};
AccountSchema.statics.updateFido = async function (idapp, username, groupname, circuitId, fido) {
let paramstoupdate = {
fidoConcesso: fido,
};
let risult = null;
if (groupname)
risult = await Account.updateOne({ idapp, circuitId, groupname }, { $set: paramstoupdate });
else
risult = await Account.updateOne({ idapp, username, circuitId }, { $set: paramstoupdate });
return risult;
};
AccountSchema.statics.updateQtaMax = async function (idapp, username, groupname, circuitId, qtamax) {
let paramstoupdate = {
qta_maxConcessa: qtamax,
};
let risult = null;
if (groupname)
risult = await Account.updateOne({ idapp, circuitId, groupname }, { $set: paramstoupdate });
else
risult = await Account.updateOne({ idapp, username, circuitId }, { $set: paramstoupdate });
return risult && risult.nModified > 0;
};
AccountSchema.statics.getAccountsCircuitiNazionali = async function (idapp) {
const { Circuit } = require('../models/circuit');
const circuit = await Circuit.find({ idapp, showAlways: true });
return Account.find({ idapp, circuitId: circuit.id });
};
AccountSchema.statics.updateAccountCircuitoNazionaleByLimiti = async function (idapp, circuitId, fidoConcesso, qta_maxConcessa) {
const { Circuit } = require('../models/circuit');
try {
const accounts = await this.getAccountsCircuitiNazionali(idapp);
for (const account of accounts) {
const circuitId = account.circuitId;
const circuit = await Circuit.findOne({ _id: circuitId });
if (circuit) {
let fido = 0;
let qtamax = 0;
if (account.groupname) {
fido = circuit.fido_scoperto_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
qtamax = circuit.qta_max_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
} else {
fido = circuit.fido_scoperto_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
qtamax = circuit.qta_max_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
}
let paramstoupdate = {
fidoConcesso: fido,
qta_maxConcessa: qtamax,
};
risult = await Account.updateOne({ _id: account.id }, { $set: paramstoupdate });
}
}
return risult;
} catch (e) {
console.error('updateAccountCircuitoNazionaleByLimiti', e);
}
return false;
};
AccountSchema.statics.canEditAccountAdmins = async function (username, id) {
const account = await Account.findOne({ _id: id }).lean();
const { Circuit } = require('../models/circuit');
if (account) {
const circuit = await Circuit.findOne({ _id: account.circuitId }).lean();
if (circuit) {
return circuit.admins.findIndex((admin) => admin.username === username) >= 0;
}
}
return false;
};
AccountSchema.statics.addToPeopleOfMyAccount = async function (idapp, username, circuitId, person_username, perm) {
@@ -489,12 +726,32 @@ AccountSchema.statics.addToPeopleOfMyAccount = async function (idapp, username,
// Rimuovi dagli Admin del Account
AccountSchema.statics.removeAdminOfAccount = async function (idapp, username, circuitId, person_username, perm) {
const { Circuit } = require('../models/circuit');
return await Circuit.updateOne({ idapp, username, circuitId },
{ $pull: { people: { username: { $in: [person_username] } } } });
};
// Rimuovi l'account
AccountSchema.statics.removeAccount = async function (accountId) {
return await Account.deleteOne({ _id: accountId});
};
AccountSchema.statics.updateSaldoAndTransato_AllAccounts = async function (idapp) {
const recaccounts = await Account.find({ idapp });
for (const account of recaccounts) {
await account.calcPending();
}
};
const Account = mongoose.model('Account', AccountSchema);
Account.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Account };

View File

@@ -64,4 +64,8 @@ AdTypeSchema.statics.executeQueryTable = function(idapp, params) {
const AdType = mongoose.model('AdType', AdTypeSchema);
AdType.createIndexes((err) => {
if (err) throw err;
});
module.exports = {AdType};

View File

@@ -64,4 +64,8 @@ AdTypeGoodSchema.statics.executeQueryTable = function(idapp, params) {
const AdTypeGood = mongoose.model('AdTypeGood', AdTypeGoodSchema);
AdTypeGood.createIndexes((err) => {
if (err) throw err;
});
module.exports = {AdTypeGood};

View File

@@ -20,6 +20,12 @@ const bookingSchema = new Schema({
userId: {
type: String,
},
username: {
type: String,
},
tableType: {
type: Number,
},
id_bookedevent: {
type: String,
},
@@ -116,4 +122,8 @@ bookingSchema.statics.findAllDistinctByBooking = function (idapp) {
const Booking = mongoose.model('Booking', bookingSchema);
Booking.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Booking };

View File

@@ -66,6 +66,135 @@ BotSchema.statics.DuplicateAllRecords = async function (idapporig, idappdest) {
};
BotSchema.statics.generateBotMenuRecords = async function (idapp) {
try {
let arrrec = [
{
"page": 1,
"index": 1,
"riga": 1,
"active": true,
"label": "Vai al Sito",
"type": 3,
"value": "{host}",
"visibility": 0,
idapp,
"lang": "it",
"main": true
},
{
"page": 1,
"index": 1,
"riga": 2,
"active": true,
"label": "Il mio Profilo",
"type": 3,
"value": "{host}/my/{username}",
"visibility": 1,
idapp,
"lang": "it",
"main": true
},
{
"page": 1,
"index": 1,
"riga": 3,
"active": true,
"label": "Link da Condividere",
"type": 2,
"value": "{host}/registrati/{username}",
"visibility": 1,
idapp,
"lang": "it",
"main": true,
},
{
"page": 1,
"index": 2,
"riga": 1,
"active": true,
"label": "🔮 Help",
"type": 4,
"value": "",
"visibility": 0,
idapp,
"lang": "it",
"main": true,
},
{
"page": 1,
"index": 1,
"riga": 3,
"active": true,
"label": "💁‍♀️ Admin",
"type": 4,
"value": "",
"visibility": 5,
idapp,
"lang": "it",
"main": true
},
{
"page": 1,
"index": 2,
"riga": 2,
"active": true,
"label": "Imposta Foto Profilo",
"type": 4,
"value": "🖼 SetPicProfile",
"visibility": 1,
idapp,
"lang": "it",
"main": true
},
{
"page": 1,
"index": 2,
"riga": 3,
"active": true,
"label": "🛠 Strumenti",
"type": 1,
"value": "2",
"visibility": 1,
idapp,
"lang": "it",
"main": true,
},
{
"page": 2,
"index": 1,
"riga": 1,
"active": true,
"label": "🔑 Cambio Password",
"type": 4,
"value": "🔑 SetResetPwd",
"visibility": 1,
idapp,
"lang": "it",
},
{
"page": 2,
"index": 1,
"riga": 2,
"active": true,
"label": "👉🏻 Indietro",
"type": 1,
"value": "1",
"visibility": 1,
idapp,
"lang": "it",
}];
const ris = await MyBot.insertMany(arrrec);
return ris;
} catch (e) {
console.error('Err:', e);
}
}
BotSchema.statics.findAllIdApp = async function (idapp) {
const Bot = this;
@@ -76,4 +205,8 @@ BotSchema.statics.findAllIdApp = async function(idapp) {
const MyBot = mongoose.model('Bot', BotSchema);
MyBot.createIndexes((err) => {
if (err) throw err;
});
module.exports = { MyBot };

View File

@@ -76,4 +76,8 @@ CalZoomSchema.statics.getNextZoom = async function (idapp) {
const CalZoom = mongoose.model('CalZoom', CalZoomSchema);
CalZoom.createIndexes((err) => {
if (err) throw err;
});
module.exports = { CalZoom };

View File

@@ -1,9 +1,14 @@
const mongoose = require('mongoose').set('debug', false);
const Schema = mongoose.Schema;
const shared_consts = require('../tools/shared_nodejs');
mongoose.Promise = global.Promise;
mongoose.level = "F";
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true
});
const Order = require('../models/order');
const CartSchema = new Schema({
idapp: {
@@ -12,6 +17,7 @@ const CartSchema = new Schema({
userId: { type: Schema.Types.ObjectId, ref: 'User' },
totalQty: { type: Number, default: 0 },
totalPrice: { type: Number, default: 0 },
totalPriceCalc: { type: Number, default: 0 },
department: {
type: String, ref: 'Department',
},
@@ -38,6 +44,9 @@ module.exports.findAllIdApp = async function(idapp, userId) {
};
module.exports.getCartByUserId = async function (uid, idapp) {
try {
const Order = require('../models/order');
let query = { userId: uid, idapp };
const mycart = await Cart.findOne(query).lean();
@@ -60,6 +69,9 @@ module.exports.getCartByUserId = async function(uid, idapp) {
return mycart;
}
return null;
} catch (e) {
console.log('getCartByUserId err', e);
}
};
@@ -77,6 +89,7 @@ module.exports.updateCartByUserId = function(userId, newCart, callback) {
items: newCart.items,
totalQty: newCart.totalQty,
totalPrice: newCart.totalPrice,
totalPriceCalc: newCart.totalPriceCalc,
userId: userId,
},
},
@@ -95,6 +108,8 @@ module.exports.updateCartByCartId = async function(cartId, newCart) {
const items = newCart.items;
const totalQty = newCart.totalQty;
const totalPrice = newCart.totalPrice;
const totalPriceCalc = newCart.totalPriceCalc;
const note = newCart.note;
const modify_at = new Date();
@@ -102,8 +117,10 @@ module.exports.updateCartByCartId = async function(cartId, newCart) {
$set: {
items,
totalPrice,
totalPriceCalc,
totalQty,
modify_at,
note,
modify_at: new Date(),
},
}, { new: false }).lean().then((ris) => {
return ris;
@@ -122,3 +139,7 @@ module.exports.createCart = async function(newCart) {
return await newCart.save();
};
Cart.createIndexes((err) => {
if (err) throw err;
});

View File

@@ -1,127 +0,0 @@
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
mongoose.Promise = global.Promise;
mongoose.level = "F";
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true
});
const CashSchema = new Schema({
idapp: {
type: String,
},
creatorUserId: {
type: String,
},
idCashCategory: {
type: String
},
idSubCashCategory: {
type: String
},
type: { // CashType: TYPE_IN, TYPE_OUT
type: Number
},
date_created: {
type: Date
},
date_payment: {
type: Date
},
descr: {
type: String,
},
price: {
type: Number
},
quantity: {
type: Number
},
total: {
type: Number
},
fromWalletUserId: { // walletCommonCash or any Member
type: String,
},
toWalletUserId: { // walletCommonCash or any Member
type: String,
},
walletStatus: { // WalletFinalStatusType: None: 0, InCommonCash: 1, InMyWallet : 2
type: Number,
},
walletTemporaryToUserId: { // WalletCommonCash
type: String,
},
walletCashId: {
type: String,
},
internal: {
type: Boolean,
default: false,
},
extra: {
type: Boolean,
default: false,
},
notes: {
type: String
},
confirmed: {
type: Boolean,
default: false,
},
});
var Cash = module.exports = mongoose.model('Cash', CashSchema);
module.exports.getFieldsForSearch = function () {
return []
};
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 Cash.find(myfind);
};
module.exports.getAllCash = function (query, sort, callback) {
Cash.find(query, null, sort, callback)
}
module.exports.getCashByUserId = function (userId, sort, callback) {
Cash.find({ userId }, null, sort, callback)
}
module.exports.getCashByID = function (id, callback) {
Cash.findById(id, callback);
}
module.exports.createCash = async function (Cash) {
const CashModel = new Cash(Cash);
return await CashModel.save(Cash)
.then((ris) => {
if (!!ris)
return ris._id;
return null;
});
}
// const Cash = mongoose.model('Cash', CashSchema);
// module.exports = { Cash };

View File

@@ -28,6 +28,10 @@ const CashCategorySchema = new Schema({
var CashCategory = module.exports = mongoose.model('CashCategory', CashCategorySchema);
CashCategory.createIndexes((err) => {
if (err) throw err;
});
module.exports.getFieldsForSearch = function () {
return []
};
@@ -66,3 +70,4 @@ module.exports.createCashCategory = async function (CashCategory) {
return null;
});
}

View File

@@ -69,3 +69,7 @@ module.exports.createCashSubCategory = async function (CashSubCategory) {
return null;
});
}
module.exports.createIndexes((err) => {
if (err) throw err;
});

61
src/server/models/catai.js Executable file
View File

@@ -0,0 +1,61 @@
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;
mongoose.level = "F";
const tools = require('../tools/general');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true
});
const CatAISchema = new Schema({
_id: {
type: Number,
},
name: {
type: String,
},
img: {
type: String,
},
icon: {
type: String,
},
color: {
type: String,
},
});
CatAISchema.statics.getAllCategories = function (callback) {
CatAI.find(callback)
}
CatAISchema.statics.getCatAIById = function (id, callback) {
CatAI.findById(id, callback);
}
CatAISchema.statics.getFieldsForSearch = function () {
return [{ field: 'name', type: tools.FieldType.string }]
};
CatAISchema.statics.executeQueryTable = function (idapp, params) {
return tools.executeQueryTable(this, idapp, params);
};
CatAISchema.statics.findAllIdApp = async function (idapp) {
const myfind = {};
return await CatAI.find(myfind).sort({ name: 1 });
};
const CatAI = mongoose.model('CatAI', CatAISchema);
CatAI.createIndexes((err) => {
if (err) throw err;
});
module.exports = CatAI;

View File

@@ -1,9 +1,11 @@
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;
mongoose.level = "F";
const tools = require('../tools/general');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
@@ -11,20 +13,46 @@ mongoose.plugin(schema => {
});
const CategorySchema = new Schema({
idapp: {
type: String,
},
name: {
type: String,
unique: true,
index: true,
lowercase: true
}
},
img: {
type: String,
},
});
module.exports.getAllCategories = function (callback) {
CategorySchema.statics.getAllCategories = function (callback) {
Category.find(callback)
}
module.exports.getCategoryById = function (id, callback) {
CategorySchema.statics.getCategoryById = function (id, callback) {
Category.findById(id, callback);
}
module.exports = mongoose.model('Category', CategorySchema);
CategorySchema.statics.getFieldsForSearch = function () {
return [{ field: 'name', type: tools.FieldType.string }]
};
CategorySchema.statics.executeQueryTable = function (idapp, params) {
return tools.executeQueryTable(this, idapp, params);
};
CategorySchema.statics.findAllIdApp = async function (idapp) {
const myfind = { idapp };
return await Category.find(myfind);
};
const Category = mongoose.model('Category', CategorySchema);
Category.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Category };

View File

@@ -80,4 +80,8 @@ CatGrpSchema.statics.executeQueryTable = function (idapp, params) {
const CatGrp = mongoose.model('CatGrp', CatGrpSchema);
CatGrp.createIndexes((err) => {
if (err) throw err;
});
module.exports = { CatGrp };

62
src/server/models/catprod.js Executable file
View File

@@ -0,0 +1,62 @@
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;
mongoose.level = "F";
const tools = require('../tools/general');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true
});
const CatProdSchema = new Schema({
idapp: {
type: String,
},
name: {
type: String,
},
img: {
type: String,
},
icon: {
type: String,
},
color: {
type: String,
},
});
CatProdSchema.statics.getAllCategories = function (callback) {
CatProd.find(callback)
}
CatProdSchema.statics.getCatProdById = function (id, callback) {
CatProd.findById(id, callback);
}
CatProdSchema.statics.getFieldsForSearch = function () {
return [{ field: 'name', type: tools.FieldType.string }]
};
CatProdSchema.statics.executeQueryTable = function (idapp, params) {
return tools.executeQueryTable(this, idapp, params);
};
CatProdSchema.statics.findAllIdApp = async function (idapp) {
const myfind = { idapp };
return await CatProd.find(myfind).sort({ name: 1 });
};
const CatProd = mongoose.model('CatProd', CatProdSchema);
CatProd.createIndexes((err) => {
if (err) throw err;
});
module.exports = CatProd;

View File

@@ -43,5 +43,9 @@ CfgServerSchema.statics.findAllIdApp = async function(idapp) {
const CfgServer = mongoose.model('CfgServer', CfgServerSchema);
CfgServer.createIndexes((err) => {
if (err) throw err;
});
module.exports = {CfgServer};

View File

@@ -57,6 +57,10 @@ const CircuitSchema = new Schema({
{
type: String,
},
card: // Punti cardinali
{
type: String,
},
pub_to_share: {
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
},
@@ -212,10 +216,18 @@ const CircuitSchema = new Schema({
type: Number,
default: 0,
},
showAlways: {
type: Boolean,
default: false,
},
status: {
type: Number,
default: 0,
},
ignoreLimits: {
type: Boolean,
default: false,
},
});
CircuitSchema.pre('save', async function (next) {
@@ -276,12 +288,14 @@ CircuitSchema.statics.getWhatToShow = function (idapp, username) {
fido_scoperto_default_grp: 1,
qta_max_default_grp: 1,
deperimento: 1,
showAlways: 1,
transactionsEnabled: 1,
status: 1,
valuta_per_euro: 1,
symbol: 1,
idCity: 1,
strProv: 1,
card: 1,
link_group: 1,
pub_to_share: 1,
visibility: 1,
@@ -331,6 +345,7 @@ CircuitSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
longdescr: 1,
regulation: 1,
numMembers: 1,
showAlways: 1,
systemUserId: 1,
founderUserId: 1,
nome_valuta: 1,
@@ -345,6 +360,7 @@ CircuitSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
color: 1,
idCity: 1,
strProv: 1,
card: 1,
link_group: 1,
pub_to_share: 1,
visibility: 1,
@@ -469,12 +485,39 @@ CircuitSchema.statics.getCircuitByName = async function (idapp, name) {
};
CircuitSchema.statics.getCircuitByProvince = async function (idapp, strProv) {
CircuitSchema.statics.getCircuitIdByName = async function (idapp, name) {
const myfind = {
idapp,
name,
};
try {
const circuit = await Circuit.findOne(myfind);
return (!!circuit ? circuit._id : 0);
} catch (e) {
return null;
}
};
CircuitSchema.statics.getCircuitByProvinceAndCard = async function (idapp, strProv, card) {
let myfind = {};
if (card) {
myfind = {
idapp,
strProv,
card
};
} else {
myfind = {
idapp,
strProv,
};
}
try {
return await Circuit.findOne(myfind);
@@ -505,59 +548,6 @@ CircuitSchema.statics.deleteCircuit = async function (idapp, usernameOrig, name)
return await Circuit.findOneAndRemove({ idapp, name });
};
CircuitSchema.statics.getUserCircuits = async function (idapp, username) {
try {
let aggr1 = [
{
$match: {
idapp, username,
$or: [
{ deleted: { $exists: false } },
{ deleted: { $exists: true, $eq: false } }],
},
},
{
$lookup: {
from: 'circuits',
localField: 'circuitId',
foreignField: '_id',
as: 'circuit',
},
},
{
'$replaceRoot': {
'newRoot': {
'$mergeObjects': [
{
'$arrayElemAt': [
'$circuit',
0,
],
},
'$$ROOT',
],
},
},
},
/*
{
$project: {
"circuit.name": 1,
},
},
*/
];
ris = await this.aggregate(aggr1);
return ris;
} catch (e) {
console.error('e', e);
}
};
CircuitSchema.statics.getUsersSingleCircuit = async function (idapp, username, circuitname, circuitId) {
@@ -658,6 +648,8 @@ CircuitSchema.statics.getCircolanteSingolaTransaz = function (accountorigTable,
CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig, extrarec) {
const { User } = require('../models/user');
let ris = {
result: false,
cansend: true,
@@ -676,26 +668,51 @@ CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig
if (circuittable) {
const myqty = Math.abs(extrarec.qty);
const accountdestTable = await Account.getAccountByUsernameAndCircuitId(idapp, extrarec.dest, circuittable._id, true, extrarec.groupdest, extrarec.contoComDest);
const accountorigTable = await Account.getAccountByUsernameAndCircuitId(idapp, usernameOrig, circuittable._id, true, extrarec.grouporig, extrarec.contoComOrig);
const esisteDest = await Account.isExistAccountByUsernameAndCircuitId(idapp, extrarec.dest, circuittable._id, extrarec.groupdest, extrarec.contoComDest);
if (!esisteDest) {
// Fallo entrare anche sul Circuito (oltre ad aver creato l'Account).
await User.addCircuitToUser(idapp, usernameOrig, extrarec.circuitname, false, extrarec.groupdest, extrarec.contoComDest);
}
if (extrarec.dest) {
const foundIfAlreadyCircuit = await User.ifAlreadyInCircuit(idapp, extrarec.dest, extrarec.circuitname);
if (!foundIfAlreadyCircuit) {
update = {
$push: {
'profile.mycircuits': {
circuitname: extrarec.circuitname,
date: new Date(),
},
},
};
const ris = await User.updateOne({ idapp, username: extrarec.dest }, update);
}
}
const accountdestTable = await Account.getAccountByUsernameAndCircuitId(idapp, extrarec.dest, circuittable._id, true, false, extrarec.groupdest, extrarec.contoComDest);
const accountorigTable = await Account.getAccountByUsernameAndCircuitId(idapp, usernameOrig, circuittable._id, true, true, extrarec.grouporig, extrarec.contoComOrig);
const circolantePrec = this.getCircolanteSingolaTransaz(accountorigTable, accountdestTable);
if (!circuittable.ignoreLimits) {
// Check if Sender has enough money
if (accountorigTable.saldo - myqty < -accountorigTable.fidoConcesso) {
ris.cansend = false;
ris.errormsg = i18n.__('CIRCUIT_AMOUNT_EXCEED_FIDO', usernameOrig);
}
if (accountdestTable.saldo + myqty > accountorigTable.qta_maxConcessa) {
if (accountdestTable.saldo + myqty > accountdestTable.qta_maxConcessa) {
ris.cansend = false;
ris.errormsg = i18n.__('CIRCUIT_AMOUNT_EXCEED_QTAMAX', extrarec.dest);
}
}
if (!onlycheck) {
// Add a Transaction !
if (ris.cansend) {
ris.rec = await Movement.addMov(idapp, accountorigTable, accountdestTable, myqty, extrarec.causal, extrarec.notifId);
ris.rec = await Movement.addMov(idapp, accountorigTable, accountdestTable, myqty, extrarec.causal, extrarec.notifId, extrarec.idOrdersCart);
}
if (ris.cansend && ris.rec) {
@@ -723,10 +740,11 @@ CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig
if (extrarec.contoComOrig) {
orig = extrarec.contoComOrig + ' (' + usernameOrig + ')'
}
let dest = (extrarec.dest ? extrarec.dest : '') + (extrarec.groupDest ? extrarec.groupDest : '') + (extrarec.contoComDest ? extrarec.contoComDest : '');
let dest = (extrarec.dest ? extrarec.dest : '') + (extrarec.groupdest ? extrarec.groupdest : '') + (extrarec.contoComDest ? extrarec.contoComDest : '');
ris.result = true;
let msg = 'Inviate Monete da ' + orig + ' a ' + dest + ' ' + myqty + ' ' + circuittable.symbol + ' [causale: ' + extrarec.causal + `] [Saldo ${orig}: ` + extrarec.saldoOrig + ' ' + circuittable.symbol + '] ' + ` [Saldo ${dest}: ` + extrarec.saldoDest + ' ' + circuittable.symbol + ']';
let msg = '[<b>' + circuittable.name + '</b>]: Inviate Monete da ' + orig + ' a ' + dest + ' ' + myqty + ' ' + circuittable.symbol + ' [causale: ' + extrarec.causal +
`]\nSaldi:\n${orig}: ` + extrarec.saldoOrig + ' ' + circuittable.symbol + '] ' + `\n${dest}: ` + extrarec.saldoDest + ' ' + circuittable.symbol + ']';
console.log(msg);
ris.useraccounts = await Account.getUserAccounts(idapp, usernameOrig);
@@ -817,7 +835,13 @@ CircuitSchema.statics.updateData = async function (idapp, circuitname) {
const ris = await User.aggregate(aggr1);
let numMembers = ris ? ris[0].count : 0;
let numMembers = 0;
try {
numMembers = ris && tools.isArray(ris) ? ris[0].count : 0;
} catch (e) {
};
let paramstoupdate = {
numMembers: numMembers,
@@ -890,23 +914,38 @@ CircuitSchema.statics.setstrProvByIdCityCircuits = async function (idapp) {
};
CircuitSchema.statics.SetDefMinMaxCollettivi = async function (idapp, valmin, valmax) {
ris = await Circuit.updateMany({ idapp, contocom: { "$nin": [null, ""] } },
CircuitSchema.statics.AbilitaTuttiCircuiti = async function (idapp) {
const ris = await Circuit.updateMany({ idapp },
{
$set:
{
fido_scoperto_default: valmin,
qta_max_default: valmax,
transactionsEnabled: true
}
});
return ris;
};
CircuitSchema.statics.AzzeraRegolamentiTuttiCircuiti = async function (idapp) {
const ris = await Circuit.updateMany({ idapp },
{
$set:
{
regulation: '',
}
});
return ris;
};
// Imposta a tutti i Conti Personali, i seguenti minimi e massimi
CircuitSchema.statics.SetDefMinMaxPersonali = async function (idapp, valmin, valmax) {
CircuitSchema.statics.SetDefMinMaxPersonali = async function (idapp, valmin, valmax, circuitId) {
ris = await Circuit.updateMany({ idapp },
if (circuitId) {
const ris = await Circuit.updateOne({ _id: circuitId },
{
$set:
{
@@ -914,43 +953,51 @@ CircuitSchema.statics.SetDefMinMaxPersonali = async function (idapp, valmin, val
qta_max_default: valmax,
}
});
} else {
const ris = await Circuit.updateMany({ idapp },
{
$set:
{
fido_scoperto_default: valmin,
qta_max_default: valmax,
}
});
}
};
// Imposta a tutti i Conti Collettivi, i seguenti minimi e massimi
CircuitSchema.statics.replaceAllCircuits = async function (idapp) {
CircuitSchema.statics.getCircuitMyProvince = async function (idapp, username) {
const { User } = require('../models/user');
const globalTables = require('../tools/globalTables');
const myuser = await User.getUserByUsername(idapp, username);
const arrcircuit = await Circuit.find({ idapp }).lean();
try {
const circuit = await this.getCircuitByProvinceAndCard(idapp, myuser.profile.resid_province, myuser.profile.resid_card);
let num = 0;
for (const circuit of arrcircuit) {
if (circuit.strProv) {
let nomeprovincia = await Province.getStrProvinceByProv(circuit.strProv);
let newname = 'Circuito RIS ' + nomeprovincia;
if (newname !== circuit.name) {
ris = await globalTables.ReplaceCircuitName(idapp, circuit.name, newname);
if (ris)
num++;
if (circuit) {
if (await User.ifAlreadyInCircuit(idapp, username, circuit.name)) {
return circuit.name;
}
}
return '[nessun Circuito]';
} catch (e) {
console.error('Error', e);
}
console.log('*** Replaced Circuits ', num);
};
CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, province) {
// Imposta a tutti i Conti Collettivi, i seguenti minimi e massimi
CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, province, card) {
const { User } = require('../models/user');
const useradmin = tools.USER_ADMIN_CIRCUITS;
let myrec = null;
try {
const circuit = await this.getCircuitByProvince(idapp, province);
const circuit = await this.getCircuitByProvinceAndCard(idapp, province, card);
const nomeprovincia = await Province.getStrProvinceByProv(province);
@@ -960,11 +1007,12 @@ CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, prov
name: 'Circuito RIS ' + nomeprovincia,
path: 'ris' + tools.convertSpaces_ToUScore(nomeprovincia.toLowerCase()),
strProv: province,
card,
photos: [],
admins: [],
color: '#ff5500',
deperimento: false,
transactionsEnabled: false,
showAlways: false,
transactionsEnabled: true, // Abilita cmq il circuito dall'inizio
status: shared_consts.CIRCUIT_STATUS.FASE1_CREAZIONE_GRUPPO,
symbol: 'RIS',
fido_scoperto_default: 100,
@@ -1006,9 +1054,94 @@ CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, prov
return myrec;
};
CircuitSchema.statics.SetDefMinMaxCollettivi = async function (idapp, valmin, valmax) {
ris = await Circuit.updateMany({ idapp },
CircuitSchema.statics.getListAdmins = async function (idapp, circuitname) {
let arr = await Circuit.findOne({
idapp,
name: circuitname,
$or: [
{ deleted: { $exists: false } },
{ deleted: { $exists: true, $eq: false } }],
}, { admins: 1 }).lean();
let mystr = '';
if (arr) {
for (const admin of arr.admins) {
mystr += await tools.getAhref(admin.username, await tools.getLinkUserTelegram(idapp, admin.username)) + ', ';
}
}
return { str: mystr, num: arr ? arr.admins.length : 0 };
};
CircuitSchema.statics.isAdminCircuit = async function (idapp, circuitname, username) {
let arr = await Circuit.findOne({
idapp,
name: circuitname,
$or: [
{ deleted: { $exists: false } },
{ deleted: { $exists: true, $eq: false } }],
}, { admins: 1 }).lean();
if (arr) {
for (const admin of arr.admins) {
if (admin.username === username)
return true;
}
}
return false;
};
CircuitSchema.statics.getListCircuitsByUsername = async function (idapp, username, groupname) {
let mystr = '';
const { User } = require('../models/user');
const myuser = await User.getUserByUsername(idapp, username);
const useraccounts = await Account.getUserAccounts(idapp, username);
const groupsaccounts = await Account.getGroupAccounts(idapp, groupname);
for (let account of useraccounts) {
if (myuser.profile.mycircuits.find((rec) => (rec.circuitname === account.circuit.name))) {
if (account.groupname === '') {
mystr += '\n👉🏻 ' + account.circuit.name + '\n';
mystr += ' [Saldo: ' + account.saldo + ' RIS, ';
mystr += ' Fiducia: ' + account.fidoConcesso + ' RIS, ';
mystr += ' Transato: ' + account.totTransato + ' RIS]';
}
}
}
for (let account of groupsaccounts) {
if (myuser.profile.mycircuits.find((rec) => (rec.circuitname === account.circuit.name))) {
mystr += '\n GRUPPO: 👉🏻 <b>' + account.groupname + '</b> in ' + account.circuit.name + '\n';
mystr += ' [Saldo: ' + account.saldo + ' RIS, ';
mystr += ' Fiducia: ' + account.fidoConcesso + ' RIS, ';
mystr += ' Transato: ' + account.totTransato + ' RIS]';
}
}
if (!mystr) {
mystr = '[Nessun Circuito]';
}
return mystr;
};
CircuitSchema.statics.SetDefMinMaxCollettivi = async function (idapp, valmin, valmax, circuitId) {
if (circuitId) {
const ris = await Circuit.updateOne({ _id: circuitId },
{
$set:
{
@@ -1016,9 +1149,112 @@ CircuitSchema.statics.SetDefMinMaxCollettivi = async function (idapp, valmin, va
qta_max_default_grp: valmax,
}
});
} else {
const ris = await Circuit.updateMany({ idapp },
{
$set:
{
fido_scoperto_default_grp: valmin,
qta_max_default_grp: valmax,
}
});
}
};
CircuitSchema.statics.setFido = async function (idapp, username, circuitName, groupname) {
try {
mycircuit = await Circuit.findOne({ idapp, name: circuitName }).lean();
if (mycircuit) {
const circuitId = mycircuit._id;
let account = null;
let fido = 0;
let qtamax = 0;
let variato = false;
let variato2 = false;
if (mycircuit.showAlways) {
const { User } = require('../models/user');
const myuser = await User.getUserByUsername(idapp, username);
// Se è il circuito Nazionale, allora prende i valori dal proprio Circuito Locale:
const accountsuser = await Account.getUserAccounts(idapp, username);
if (accountsuser) {
// Se lo trovo della mia provincia, prendo quello
account = accountsuser.find((account) => account.circuit.strProv === myuser.profile.resid_province && ((account.circuit.card === myuser.profile.resid_card) || !myuser.profile.resid_card))
if (!account && accountsuser.length > 0) {
// Se non lo trovo, prendo il primo in cui sono entrato !
account = accountsuser[0];
}
if (account && account.circuit) {
if (groupname) {
qtamax = account.circuit.qta_max_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
fido = account.circuit.fido_scoperto_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
} else {
qtamax = account.circuit.qta_max_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
fido = account.circuit.fido_scoperto_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
}
}
} else {
// Se non ho Circuiti locali, non applico il Fido !
return null;
}
} else {
account = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, true, true, groupname, '');
if (groupname)
fido = mycircuit.fido_scoperto_default_grp;
else
fido = mycircuit.fido_scoperto_default;
}
if (account) {
if (qtamax > 0) {
variato = await Account.updateQtaMax(idapp, username, groupname, circuitId, qtamax);
}
const ris = await Account.updateFido(idapp, username, groupname, circuitId, fido);
if (ris) {
return { qta_maxConcessa: qtamax, fidoConcesso: fido, changed: variato || (ris && ris.nModified > 0) };
}
}
}
} catch (e) {
console.error('Err:', e);
}
return null;
};
CircuitSchema.statics.addMovementByOrdersCart = async function (ordersCart, usernameDest, groupDest) {
const { User } = require('../models/user');
const idapp = ordersCart.idapp;
let extrarec = {
causal: 'Pagato Ordine n.' + ordersCart.numorder,
circuitname: 'Euro',
idOrdersCart: ordersCart._id,
qty: ordersCart.totalPrice,
dest: usernameDest,
groupdest: groupDest,
contoComDest: '',
};
const usernameOrig = await User.getUsernameById(idapp, ordersCart.userId);
return this.sendCoins(false, idapp, usernameOrig, extrarec);
};
const Circuit = mongoose.model('Circuit', CircuitSchema);
Circuit.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Circuit };

View File

@@ -77,6 +77,17 @@ CitySchema.statics.getProvinceByIdCity = async function(idcity) {
return '';
}
CitySchema.statics.getCircuitNameBystrProv = async function(strProv) {
const { Circuit } = require('../models/circuit');
const myrec = await Circuit.findOne({strProv}).lean();
if (myrec) {
return myrec.name;
}
return '';
}
CitySchema.statics.getRegionByIdCity = async function(idcity) {
const myrec = await City.findOne({_id: idcity}).lean();
if (myrec) {
@@ -190,4 +201,8 @@ CitySchema.statics.findAllIdApp = async function(idapp) {
const City = mongoose.model('City', CitySchema);
City.createIndexes((err) => {
if (err) throw err;
});
module.exports = {City};

View File

@@ -52,4 +52,8 @@ ContribtypeSchema.statics.findAllIdApp = async function (idapp) {
const Contribtype = mongoose.model('Contribtype', ContribtypeSchema);
Contribtype.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Contribtype };

View File

@@ -26,6 +26,10 @@ const departmentSchema = new Schema({
var Department = module.exports = mongoose.model('Department', departmentSchema);
module.exports.createIndexes((err) => {
if (err) throw err;
});
module.exports.getFieldsForSearch = function () {
return [{ field: 'name', type: tools.FieldType.string },
{ field: 'username', type: tools.FieldType.string }

View File

@@ -106,4 +106,8 @@ DisciplineSchema.statics.DuplicateAllRecords = async function (idapporig, idappd
const Discipline = mongoose.model('Discipline', DisciplineSchema);
Discipline.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Discipline };

View File

@@ -332,6 +332,9 @@ ExtraListSchema.statics.ImportData = async function (locale, idapp, strdata) {
const ExtraList = mongoose.model('ExtraList', ExtraListSchema);
ExtraList.createIndexes((err) => {
if (err) throw err;
});
module.exports = { ExtraList };

View File

@@ -64,4 +64,8 @@ GallerySchema.statics.findAllIdApp = async function (idapp) {
const Gallery = mongoose.model('Gallery', GallerySchema);
Gallery.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Gallery };

80
src/server/models/gasordine.js Executable file
View File

@@ -0,0 +1,80 @@
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 gasordineSchema = new Schema({
active: {
type: Boolean,
},
idapp: {
type: String,
},
name: {
type: String,
},
description: {
type: String,
},
referente: {
type: String,
},
city: {
type: String,
},
img: {
type: String,
},
dataora_chiusura_ordini: {
type: Date,
},
data_arrivo_merce: {
type: Date,
},
dataora_ritiro: {
type: Date,
},
dataora_termine_pagamento: {
type: Date,
},
});
var Gasordine = module.exports = mongoose.model('Gasordine', gasordineSchema);
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.findAllIdApp = async function (idapp) {
const myfind = { idapp };
return await Gasordine.find(myfind);
};
module.exports.getGasordineByID = function (id, callback) {
Gasordine.findById(id, callback);
}
module.exports.createIndexes((err) => {
if (err) throw err;
});

View File

@@ -80,4 +80,8 @@ GoodSchema.statics.executeQueryTable = function (idapp, params) {
const Good = mongoose.model('Good', GoodSchema);
Good.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Good };

View File

@@ -415,4 +415,8 @@ GraduatoriaSchema.statics.getPosizioneInGraduatoria = async function (idapp, ind
const Graduatoria = mongoose.model('Graduatoria', GraduatoriaSchema);
Graduatoria.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Graduatoria };

View File

@@ -47,3 +47,6 @@ module.exports.findAllIdApp = async function (idapp) {
return await Group.find(myfind);
};
module.exports.createIndexes((err) => {
if (err) throw err;
});

View File

@@ -228,3 +228,6 @@ module.exports.calculateHoursTodo = async function (idtodo) {
};
module.exports.createIndexes((err) => {
if (err) throw err;
});

View File

@@ -0,0 +1,59 @@
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 inventariogmSchema = new Schema({
idapp: {
type: String,
},
});
var Inventariogm = module.exports = mongoose.model('Inventariogm', inventariogmSchema);
inventariogmSchema.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.getInventariogmByCode = function (idapp, code) {
return Inventariogm.findAllIdApp(idapp, code);
}
module.exports.getInventariogmById = async function (id) {
const arrris = await Inventariogm.findAllIdApp('', '', id);
return arrris && arrris.length > 0 ? arrris[0] : null
}
module.exports.findAllIdApp = async function (idapp) {
const Inventariogm = this;
const myfind = { idapp, deleted: false };
return await Inventariogm.find(myfind, (err, arrrec) => {
return arrrec;
});
};

View File

@@ -196,3 +196,7 @@ module.exports.findAllIdApp = async function(idapp) {
return arrrec;
});
};
module.exports.createIndexes((err) => {
if (err) throw err;
});

View File

@@ -196,3 +196,7 @@ module.exports.findAllIdApp = async function (idapp) {
return arrrec
});
};
module.exports.createIndexes((err) => {
if (err) throw err;
});

View File

@@ -73,4 +73,8 @@ LevelSchema.statics.executeQueryTable = function(idapp, params) {
const Level = mongoose.model('Level', LevelSchema);
Level.createIndexes((err) => {
if (err) throw err;
});
module.exports = {Level};

View File

@@ -121,4 +121,8 @@ MailingListSchema.statics.findByHash = function (idapp, hash) {
const MailingList = mongoose.model('MailingList', MailingListSchema);
MailingList.createIndexes((err) => {
if (err) throw err;
});
module.exports = { MailingList };

View File

@@ -36,6 +36,7 @@ const MovementSchema = new Schema({
accountToId: {
type: String,
},
idOrdersCart: { type: Schema.Types.ObjectId, ref: 'OrdersCart' },
causal_table: {
type: String,
},
@@ -47,13 +48,19 @@ const MovementSchema = new Schema({
},
causal: {
type: String,
default: '',
},
residual: {
type: Number,
default: 0,
},
expiringDate: {
type: Date,
},
confirmed: {
type: Boolean,
default: false,
},
});
MovementSchema.statics.findAllIdApp = async function (idapp) {
@@ -88,7 +95,7 @@ MovementSchema.statics.executeQueryTable = function (idapp, params) {
return tools.executeQueryTable(this, 0, params);
};
MovementSchema.statics.addMov = async function (idapp, accountFromIdTable, accountToIdTable, amount, causal, notifId) {
MovementSchema.statics.addMov = async function (idapp, accountFromIdTable, accountToIdTable, amount, causal, notifId, idOrdersCart) {
try {
// Only positive values
@@ -96,11 +103,11 @@ MovementSchema.statics.addMov = async function (idapp, accountFromIdTable, accou
let mymov = await Movement.create(
{
_id: new ObjectID().toString(),
idapp,
transactionDate: new Date(),
accountFromId: accountFromIdTable._id,
accountToId: accountToIdTable._id,
idOrdersCart,
amount,
causal,
residual: 0,
@@ -111,9 +118,9 @@ MovementSchema.statics.addMov = async function (idapp, accountFromIdTable, accou
if (mymov) {
// Update saldo dell'Account
await Account.addtoSaldo(accountToIdTable, amount);
await Account.addtoSaldo(accountToIdTable, amount, true);
await Account.addtoSaldo(accountFromIdTable, -amount);
await Account.addtoSaldo(accountFromIdTable, -amount, false);
return mymov;
}
@@ -128,7 +135,7 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function (idapp, username
if (!circuitId) {
return [];
}
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false, groupname, contocom);
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false, true, groupname, contocom);
if (myaccount) {
@@ -206,6 +213,7 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function (idapp, username
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: 'circuits',
@@ -678,7 +686,6 @@ MovementSchema.statics.checkIfCoinsAlreadySent = async function (notifId) {
try {
const rec = await MyMovement.findOne({ notifId }, { _id: 1 });
return !!rec;
} catch (e) {
@@ -691,4 +698,8 @@ MovementSchema.statics.checkIfCoinsAlreadySent = async function (notifId) {
const Movement = mongoose.model('Movement', MovementSchema);
Movement.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Movement };

View File

@@ -125,4 +125,8 @@ MsgTemplateSchema.statics.findAllIdApp = async function (idapp) {
const MsgTemplate = mongoose.model('MsgTemplate', MsgTemplateSchema);
MsgTemplate.createIndexes((err) => {
if (err) throw err;
});
module.exports = { MsgTemplate };

View File

@@ -7,6 +7,11 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const shared_consts = require('../tools/shared_nodejs');
const { Reaction } = require('./reaction');
const tableModel = shared_consts.TABLES_MYBACHECAS;
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
@@ -14,14 +19,19 @@ mongoose.plugin(schema => {
});
const MyBachecaSchema = new Schema({
...{
_id: {
type: Number,
type: String,
default: function () {
return new ObjectID().toString();
},
},
idapp: {
type: String,
required: true,
},
userId: { type: Schema.Types.ObjectId, ref: 'User' },
groupname: { type: String },
idSector: {
type: Number,
},
@@ -47,6 +57,30 @@ const MyBachecaSchema = new Schema({
dateTimeEnd: {
type: Date,
},
organisedBy: {
type: String
},
contact_phone: {
type: String
},
contact_telegram: {
type: String
},
address: {
type: String,
},
min_partecip: {
type: Number,
},
max_partecip: {
type: Number,
},
link_maplocation: {
type: String,
},
contribstr: {
type: String,
},
numLevel: {
type: Number,
default: 0,
@@ -79,26 +113,17 @@ const MyBachecaSchema = new Schema({
},
date_created: {
type: Date,
default: Date.now,
},
date_updated: {
type: Date,
},
},
...Reaction.getFieldsForReactions()
});
MyBachecaSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await MyBacheca.findOne().limit(1).sort({ _id: -1 });
if (!!myrec) {
if (myrec._doc._id === 0)
this._id = 1;
else
this._id = myrec._doc._id + 1;
} else {
this._id = 1;
}
if (!this.date_created)
this.date_created = new Date();
}
@@ -144,37 +169,7 @@ MyBachecaSchema.statics.executeQueryTable = function (idapp, params, user) {
lk_FF: '_id',
lk_as: 'user',
af_objId_tab: 'myId',
lk_proj: {
idSkill: 1,
idSubSkill: 1,
MyBacheca: 1,
idStatusSkill: 1,
idContribType: 1,
dateTimeStart: 1,
dateTimeEnd: 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
//**ADDFIELD_MYBACHECAS
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
lk_proj: shared_consts.getProjectForAll({}, tableModel),
},
};
@@ -186,28 +181,24 @@ MyBachecaSchema.statics.executeQueryTable = function (idapp, params, user) {
MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
const MyBacheca = this;
const query = [
let myparsid = {
'_id': id,
idapp,
};
let query = [
{
'$match': {
'$and': [
{
'_id': parseInt(id),
$match:
myparsid,
},
],
{
$sort: {
desc: 1,
},
},
{
'$match': {
'idapp': idapp,
},
},
{
'$sort': {
'desc': 1,
},
},
{
'$addFields': {
$addFields: {
'myId1': {
'$toObjectId': '$userId',
},
@@ -237,39 +228,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYBACHECAS
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
'$project': shared_consts.getProjectForAll({}, tableModel),
},
{
'$lookup': {
@@ -295,39 +254,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYBACHECAS
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
'$project': shared_consts.getProjectForAll({}, tableModel),
},
{
'$lookup': {
@@ -353,40 +280,22 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYBACHECAS
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
$lookup: {
'from': 'mygroups',
'localField': 'groupname',
'foreignField': 'groupname',
'as': 'mygrp',
},
},
{
$unwind: {
path: '$mygrp',
preserveNullAndEmptyArrays: true,
},
},
{
'$project': shared_consts.getProjectForAll({}, tableModel),
},
/*{
'$lookup': {
'from': 'subskills',
@@ -411,39 +320,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYBACHECAS
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
'$project': shared_consts.getProjectForAll({}, tableModel),
},
{
'$lookup': {
@@ -468,48 +345,29 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYBACHECAS
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
},
];
try {
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYBACHECAS);
let objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
query = [...query, ...objadd.query];
const toadd = {
$project: shared_consts.getProjectForAll(objadd.proj, tableModel),
};
query = [...query, { ...toadd }];
} catch (e) {
console.error('e', e);
}
return MyBacheca.aggregate(query).then((rec) => {
return rec ? rec[0] : null;
});
};
MyBachecaSchema.statics.getCompleteRecord = function (idapp, id) {
const MyBacheca = this;
@@ -520,4 +378,8 @@ MyBachecaSchema.statics.getCompleteRecord = function (idapp, id) {
const MyBacheca = mongoose.model('MyBacheca', MyBachecaSchema);
MyBacheca.createIndexes((err) => {
if (err) throw err;
});
module.exports = { MyBacheca };

View File

@@ -143,6 +143,7 @@ const MyElemSchema = new Schema({
anim: animation,
active: {
type: Boolean,
default: false,
},
class: {
type: String,
@@ -209,4 +210,8 @@ MyElemSchema.statics.findAllIdApp = async function (idapp) {
const MyElem = mongoose.model('MyElem', MyElemSchema);
MyElem.createIndexes((err) => {
if (err) throw err;
});
module.exports = { MyElem };

View File

@@ -276,4 +276,8 @@ if (tools.INITDB_FIRSTIME) {
const MyEvent = mongoose.model('MyEvent', MyEventSchema);
MyEvent.createIndexes((err) => {
if (err) throw err;
});
module.exports = {MyEvent};

View File

@@ -6,6 +6,10 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const { Reaction } = require('./reaction');
const shared_consts = require('../tools/shared_nodejs');
const { ObjectID } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
@@ -14,8 +18,9 @@ mongoose.plugin(schema => {
});
const MyGoodSchema = new Schema({
...{
_id: {
type: Number,
type: String,
},
idapp: {
type: String,
@@ -80,26 +85,17 @@ const MyGoodSchema = new Schema({
},
date_created: {
type: Date,
default: Date.now,
},
date_updated: {
type: Date,
},
},
...Reaction.getFieldsForReactions()
});
MyGoodSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await MyGood.findOne().limit(1).sort({_id: -1});
if (!!myrec) {
if (myrec._doc._id === 0)
this._id = 1;
else
this._id = myrec._doc._id + 1;
} else {
this._id = 1;
}
if (!this.date_created)
this.date_created = new Date();
}
@@ -145,35 +141,7 @@ MyGoodSchema.statics.executeQueryTable = function(idapp, params, user) {
lk_FF: '_id',
lk_as: 'user',
af_objId_tab: 'myId',
lk_proj: {
idGood: 1,
idShipping: 1,
MyGood: 1,
idStatusGood: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
otherfilters: 1,
photos: 1,
note: 1,
website: 1,
//**ADDFIELD_MyGood
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
lk_proj: this.getProject(),
},
};
@@ -185,20 +153,15 @@ MyGoodSchema.statics.executeQueryTable = function(idapp, params, user) {
MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
const MyGood = this;
const query = [
let myparsid = {
'_id': idGood,
idapp,
};
let query = [
{
'$match': {
'$and': [
{
'_id': parseInt(idGood),
},
],
},
},
{
'$match': {
'idapp': idapp,
},
'$match':
myparsid,
},
{
'$sort': {
@@ -236,38 +199,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
},
},
{
'$project': {
'recGood': 1,
'sectorGood': 1,
'idSectorGood': 1,
'idGood': 1,
'idShipping': 1,
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
'photos': 1,
note: 1,
website: 1,
//**ADDFIELD_MyGood
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -293,38 +225,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
},
},
{
'$project': {
'recGood': 1,
'sectorGood': 1,
'idSectorGood': 1,
'idGood': 1,
'idShipping': 1,
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MyGood
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -351,38 +252,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
},
},
{
'$project': {
'recGood': 1,
'sectorGood': 1,
'idSectorGood': 1,
'idGood': 1,
'idShipping': 1,
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MyGood
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -408,38 +278,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
},
},
{
'$project': {
'recGood': 1,
'sectorGood': 1,
'idSectorGood': 1,
'idGood': 1,
'idShipping': 1,
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MyGood
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -464,42 +303,19 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
},
},
},
{
'$project': {
'recGood': 1,
'sectorGood': 1,
'idSectorGood': 1,
'idGood': 1,
'idShipping': 1,
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MyGood
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
},
];
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYGOODS);
const objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
query = [...query, ...objadd.query];
const toadd = {
$project: this.getProject(objadd.proj),
};
query = [...query, { ...toadd }];
return MyGood.aggregate(query).then((rec) => {
return rec ? rec[0] : null;
});
@@ -512,7 +328,28 @@ MyGoodSchema.statics.getCompleteRecord = function(idapp, id) {
};
MyGoodSchema.statics.getProject = function () {
let proj = {
'recGood': 1,
'sectorGood': 1,
'idSectorGood': 1,
'idGood': 1,
'idShipping': 1,
'idStatusGood': 1,
//**ADDFIELD_MYGOOD
};
const proj_add = shared_consts.getProjectForAll()
return Object.assign({}, proj, proj_add);
}
const MyGood = mongoose.model('MyGood', MyGoodSchema);
MyGood.createIndexes((err) => {
if (err) throw err;
});
module.exports = { MyGood };

View File

@@ -15,7 +15,10 @@ mongoose.plugin(schema => {
const MyGroupSchema = new Schema({
_id: {
type: Number,
type: String,
default: function () {
return new ObjectID().toString();
},
},
idapp: {
type: String,
@@ -144,17 +147,7 @@ MyGroupSchema.statics.executeQueryTable = function (idapp, params, user) {
MyGroupSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await MyGroup.findOne().limit(1).sort({ _id: -1 });
if (!!myrec) {
if (myrec._doc._id === 0)
this._id = 1;
else
this._id = myrec._doc._id + 1;
} else {
this._id = 1;
}
if (!this.date_created)
this.date_created = new Date();
}
@@ -353,7 +346,7 @@ MyGroupSchema.statics.getInfoGroupByGroupname = async function (idapp, groupname
return null;
}
return ris;
return null;
};
@@ -514,9 +507,26 @@ MyGroupSchema.statics.addCircuitFromGroup = async function (idapp, groupname, ci
// Rimuovo il Circuito all'interno del Gruppo
MyGroupSchema.statics.removeCircuitFromGroup = async function (idapp, groupname, circuitname) {
return await this.updateOne({ idapp, groupname },
const ris = await this.updateOne({ idapp, groupname },
{ $pull: { 'mycircuits': { circuitname: { $in: [circuitname] } } } });
const circuitId = await Circuit.getCircuitIdByName(idapp, circuitname);
let remove = false;
// Se il mio account non è stato utilizzato, allora lo cancello anche questo
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false, false, groupname, '');
if (myaccount && myaccount.totTransato === 0) {
remove = true;
} else {
remove = true;
}
if (remove) {
await Account.removeAccount(myaccount._id);
}
};
MyGroupSchema.statics.getQueryReceiveRISGroups = function (idapp, hours) {
@@ -633,4 +643,8 @@ MyGroupSchema.statics.setReceiveRisGroup = async function (idapp, groupname) {
const MyGroup = mongoose.model('MyGroup', MyGroupSchema);
MyGroup.createIndexes((err) => {
if (err) throw err;
});
module.exports = { MyGroup };

View File

@@ -6,6 +6,9 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const { Reaction } = require('./reaction');
const shared_consts = require('../tools/shared_nodejs');
const { ObjectID } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
@@ -14,8 +17,9 @@ mongoose.plugin(schema => {
});
const MyHospSchema = new Schema({
...{
_id: {
type: Number,
type: String,
},
idapp: {
type: String,
@@ -85,26 +89,17 @@ const MyHospSchema = new Schema({
},
date_created: {
type: Date,
default: Date.now,
},
date_updated: {
type: Date,
},
},
...Reaction.getFieldsForReactions()
});
MyHospSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await MyHosp.findOne().limit(1).sort({_id: -1});
if (!!myrec) {
if (myrec._doc._id === 0)
this._id = 1;
else
this._id = myrec._doc._id + 1;
} else {
this._id = 1;
}
if (!this.date_created)
this.date_created = new Date();
}
@@ -147,34 +142,7 @@ MyHospSchema.statics.executeQueryTable = function(idapp, params, user) {
lk_FF: '_id',
lk_as: 'user',
af_objId_tab: 'myId',
lk_proj: {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'mycities': 1,
reported: 1,
},
lk_proj: this.getProject(),
},
};
@@ -186,20 +154,12 @@ MyHospSchema.statics.executeQueryTable = function(idapp, params, user) {
MyHospSchema.statics.getMyRecById = function (idapp, id) {
const MyHosp = this;
const query = [
const myparsid = { '_id': id, idapp };
let query = [
{
'$match': {
'$and': [
{
'_id': parseInt(id),
},
],
},
},
{
'$match': {
'idapp': idapp,
},
'$match':
myparsid,
},
{
'$sort': {
@@ -237,34 +197,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
},
},
{
'$project': {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
descr: 1,
date_created: 1,
date_updated: 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -290,34 +223,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
},
},
{
'$project': {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
descr: 1,
date_created: 1,
date_updated: 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -343,34 +249,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
},
},
{
'$project': {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
descr: 1,
date_created: 1,
date_updated: 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
/*{
'$lookup': {
@@ -396,34 +275,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
},
},
{
'$project': {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
descr: 1,
date_created: 1,
date_updated: 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -448,38 +300,19 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
},
},
},
{
'$project': {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
descr: 1,
date_created: 1,
date_updated: 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
},
];
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYHOSPS);
const objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
query = [...query, ...objadd.query];
const toadd = {
$project: this.getProject(objadd.proj),
};
query = [...query, { ...toadd }];
return MyHosp.aggregate(query).then((rec) => {
return rec ? rec[0] : null;
});
@@ -492,6 +325,31 @@ MyHospSchema.statics.getCompleteRecord = function(idapp, id) {
};
MyHospSchema.statics.getProject = function () {
let proj = {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
website: 1,
link_maplocation: 1,
//**ADDFIELD_MYHOSP
};
const proj_add = shared_consts.getProjectForAll()
return Object.assign({}, proj, proj_add);
}
const MyHosp = mongoose.model('MyHosp', MyHospSchema);
MyHosp.createIndexes((err) => {
if (err) throw err;
});
module.exports = { MyHosp };

View File

@@ -218,4 +218,8 @@ MyPageSchema.statics.findInternalPages = async function (idapp) {
const MyPage = mongoose.model('MyPage', MyPageSchema);
MyPage.createIndexes((err) => {
if (err) throw err;
});
module.exports = { MyPage };

View File

@@ -6,6 +6,10 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const { Reaction } = require('./reaction');
const shared_consts = require('../tools/shared_nodejs');
const { ObjectID } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
@@ -13,9 +17,14 @@ mongoose.plugin(schema => {
schema.options.usePushEach = true;
});
const MySkillSchema = new Schema({
const MySkillSchema = new Schema(
{
...{
_id: {
type: Number,
type: String,
default: function () {
return new ObjectID().toString();
},
},
idapp: {
type: String,
@@ -83,26 +92,20 @@ const MySkillSchema = new Schema({
},
date_created: {
type: Date,
default: Date.now,
},
date_updated: {
type: Date,
},
});
},
...Reaction.getFieldsForReactions()
}, { strict: false });
MySkillSchema.index({ 'idapp': 1 });
MySkillSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await MySkill.findOne().limit(1).sort({_id: -1});
if (!!myrec) {
if (myrec._doc._id === 0)
this._id = 1;
else
this._id = myrec._doc._id + 1;
} else {
this._id = 1;
}
if (!this.date_created)
this.date_created = new Date();
}
@@ -147,34 +150,7 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
lk_FF: '_id',
lk_as: 'user',
af_objId_tab: 'myId',
lk_proj: {
idSkill: 1,
// idSubSkill: 1,
myskill: 1,
idStatusSkill: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
//**ADDFIELD_MYSKILL
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
lk_proj: this.getProject(),
},
};
@@ -186,19 +162,10 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
MySkillSchema.statics.getMyRecById = function (idapp, idSkill) {
const MySkill = this;
const query = [
let query = [
{
'$match': {
'$and': [
{
'_id': parseInt(idSkill),
},
],
},
},
{
'$match': {
'idapp': idapp,
'_id': idSkill, idapp
},
},
{
@@ -237,37 +204,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
note: 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -293,37 +230,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -349,37 +256,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
//'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
/*{
'$lookup': {
@@ -407,37 +284,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -462,46 +309,42 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
},
];
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYSKILLS);
const objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
query = [...query, ...objadd.query];
const toadd = {
$project: this.getProject(objadd.proj),
};
query = [...query, { ...toadd }];
return MySkill.aggregate(query).then((rec) => {
return rec ? rec[0] : null;
});
};
MySkillSchema.statics.getProject = function (proj_add2) {
let proj = {
recSkill: 1,
sector: 1,
idSector: 1,
idSkill: 1,
idStatusSkill: 1,
website: 1,
'numLevel': 1,
//**ADDFIELD_MYSKILL
};
const proj_add = shared_consts.getProjectForAll(proj_add2)
return Object.assign({}, proj, proj_add);
}
MySkillSchema.statics.getCompleteRecord = function (idapp, id) {
const MySkill = this;
@@ -511,4 +354,8 @@ MySkillSchema.statics.getCompleteRecord = function(idapp, id) {
const MySkill = mongoose.model('MySkill', MySkillSchema);
MySkill.createIndexes((err) => {
if (err) throw err;
});
module.exports = { MySkill };

View File

@@ -170,4 +170,8 @@ NewstosentSchema.statics.isActivated = async function (_id) {
const Newstosent = mongoose.model('Newstosent', NewstosentSchema);
Newstosent.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Newstosent };

View File

@@ -118,4 +118,8 @@ OperatorSchema.statics.findAllIdApp = function (idapp) {
const Operator = mongoose.model('Operator', OperatorSchema);
Operator.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Operator };

View File

@@ -43,4 +43,8 @@ OpzEmailSchema.statics.findAllIdApp = async function (idapp) {
const OpzEmail = mongoose.model('OpzEmail', OpzEmailSchema);
OpzEmail.createIndexes((err) => {
if (err) throw err;
});
module.exports = { OpzEmail };

View File

@@ -1,7 +1,8 @@
const 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');
@@ -18,23 +19,19 @@ const orderSchema = new Schema({
idapp: {
type: String,
},
userId: {
type: String,
},
userId: { type: Schema.Types.ObjectId, ref: 'User' },
status: {
type: Number,
},
idProduct: {
type: String
},
idProducer: {
type: String
},
idStorehouse: {
type: String
},
idProduct: { type: Schema.Types.ObjectId, ref: 'Product' },
idProducer: { type: Schema.Types.ObjectId, ref: 'Producer' },
idStorehouse: { type: Schema.Types.ObjectId, ref: 'StoreHouse' },
idScontisticas: [{ type: Schema.Types.ObjectId, ref: 'Scontistica' }],
idProvider: { type: Schema.Types.ObjectId, ref: 'Provider' },
idGasordine: { type: Schema.Types.ObjectId, ref: 'Gasordine' },
price: {
type: Number
type: Number,
default: 0,
},
after_price: {
type: String
@@ -46,11 +43,62 @@ const orderSchema = new Schema({
type: String
},
quantity: {
type: Number
type: Number,
default: 0,
},
quantitypreordered: {
type: Number,
default: 0,
},
TotalPriceProduct: {
type: Number,
default: 0,
},
TotalPriceProductCalc: {
type: Number,
default: 0,
},
confermato: { // e quindi è stato tolto dal magazzino (aggiornando il campo stockQty)
type: Boolean,
default: false,
},
date_confermato: {
type: Date
},
pagato: {
type: Boolean,
default: false,
},
date_pagato: {
type: Date
},
consegnato: {
type: Boolean,
default: false,
},
date_consegnato: {
type: Date
},
spedito: {
type: Boolean,
default: false,
},
date_spedito: {
type: Date
},
ricevuto: {
type: Boolean,
default: false,
},
date_ricevuto: {
type: Date
},
weight: {
type: Number
},
unit: {
type: Number
},
stars: {
type: Number
},
@@ -69,18 +117,27 @@ const orderSchema = new Schema({
date_delivered: {
type: Date
},
notes: {
note: {
type: String
}
},
modify_at: {
type: Date
},
});
var Order = module.exports = mongoose.model('Order', orderSchema);
module.exports.createIndexes((err) => {
if (err) throw err;
});
module.exports.getFieldsForSearch = function () {
return []
};
module.exports.executeQueryTable = function (idapp, params) {
const tools = require('../tools/general');
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params);
};
@@ -89,26 +146,93 @@ module.exports.findAllIdApp = async function (idapp) {
const query = [
{ $match: { idapp } },
{ "$addFields": { "myidProd": { "$toObjectId": "$idProduct" } } },
{ "$addFields": { "myidProducer": { "$toObjectId": "$idProducer" } } },
{
$lookup: {
from: 'products',
localField: 'myidProd',
localField: 'idProduct',
foreignField: '_id',
as: 'product'
}
},
{
$lookup: {
from: 'productinfos',
localField: 'product.idProduct',
foreignField: '_id',
as: 'product.productInfo'
}
},
{
$unwind: {
path: '$product.productInfo',
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: 'producers',
localField: 'myidProducer',
localField: 'product.idProducer',
foreignField: '_id',
as: 'producer'
}
},
{ $unwind: '$product' },
{ $unwind: '$producer' },
{
$lookup: {
from: 'providers',
localField: 'product.idProvider',
foreignField: '_id',
as: 'provider'
}
},
{
$lookup: {
from: 'gasordines',
localField: 'idGasordine',
foreignField: '_id',
as: 'gasordine'
}
},
{
$unwind: {
path: '$gasordine',
preserveNullAndEmptyArrays: true,
},
},
{
$match: {
$or: [
{ 'gasordine': { $exists: false } },
{ 'gasordine.active': true }
]
}
},
{
$lookup: {
from: 'scontisticas',
localField: 'product.idScontisticas',
foreignField: '_id',
as: 'scontistica'
}
},
{
$unwind: {
path: '$product',
preserveNullAndEmptyArrays: true,
},
},
{
$unwind: {
path: '$producer',
preserveNullAndEmptyArrays: true,
},
},
{
$unwind: {
path: '$provider',
preserveNullAndEmptyArrays: true,
},
},
];
return await Order.aggregate(query)
@@ -129,34 +253,158 @@ module.exports.getOrderByID = function (id, callback) {
}
module.exports.createOrder = async function (order) {
const orderModel = new Order(order);
return await orderModel.save(order)
try {
if (order.idGasordine === '') {
order.idGasordine = undefined;
}
Order.updateTotals(order);
return await Order.create(order)
.then((ris) => {
if (!!ris)
return ris._id;
return null;
});
} catch (e) {
console.error('err', e);
}
}
module.exports.updateStatusOrders = async function (arrOrders, status) {
for (const order of arrOrders) {
let ret = await Order.updateOne({ _id: order.order._id }, { $set: { status } });
}
}
module.exports.updateStatusOrdersElements = async function (arrOrders, myelements) {
for (const order of arrOrders) {
const ret = await Order.findOneAndUpdate({ _id: order.order._id }, { $set: myelements });
}
}
module.exports.updateOrderByParams = async function (idOrder, paramstoupdate) {
const ris = await Order.findOneAndUpdate({ _id: idOrder }, { $set: paramstoupdate });
let myorder = await Order.findOne({ _id: idOrder }).lean();
if (paramstoupdate && !paramstoupdate.hasOwnProperty('TotalPriceProduct')) {
this.updateTotals(myorder);
await Order.findOneAndUpdate({ _id: idOrder }, { $set: myorder });
}
return myorder;
}
module.exports.updateTotals = function (order) {
try {
if (!order) {
return;
}
let mypricecalc = 0;
order.TotalPriceProduct = 0;
order.TotalPriceProductCalc = 0;
order.modify_at = new Date();
// Calcolo Sconto
let sconti_da_applicare = [];
if (order.scontisticas) {
let qtadascontare = order.quantity + order.quantitypreordered
let qtanonscontata = 0
while (qtadascontare > 0) {
let scontoapplicato = null
for (const sconto of order.scontisticas.filter((rec) => !rec.cumulativo)) {
if (qtadascontare >= sconto.qta) {
scontoapplicato = sconto
scontoapplicato.qtadascontare = sconto.qta
}
}
if (scontoapplicato && scontoapplicato.qtadascontare > 0) {
sconti_da_applicare.push(scontoapplicato)
qtadascontare -= scontoapplicato.qtadascontare
} else {
qtanonscontata = qtadascontare
qtadascontare = 0
}
}
/*for (const sconto of order.scontisticas.filter((rec) => rec.cumulativo)) {
if ((sconto.qta % order.quantity) === 0) {
sconti_da_applicare.push(sconto)
}
}*/
if (sconti_da_applicare.length > 0) {
for (const sconto of sconti_da_applicare) {
if (sconto.perc_sconto > 0) {
mypricecalc += (sconto.qtadascontare * order.price) * (1 - (sconto.perc_sconto / 100))
} else {
mypricecalc += sconto.price
}
}
}
if (qtanonscontata > 0) {
mypricecalc += order.price * qtanonscontata;
}
} else {
mypricecalc = (order.price * order.quantity) + (order.price * order.quantitypreordered);
}
order.TotalPriceProductCalc += mypricecalc;
order.TotalPriceProduct += mypricecalc;
return order;
} catch (e) {
console.error('Err:', e);
}
}
module.exports.getTotalOrderById = async function (id) {
const query = [
{ $match: { _id: ObjectID(id) } },
{ "$addFields": { "myidProd": { "$toObjectId": "$idProduct" } } },
{ "$addFields": { "myidProducer": { "$toObjectId": "$idProducer" } } },
{ "$addFields": { "myidStore": { "$toObjectId": "$idStorehouse" } } },
{
$lookup: {
from: 'products',
localField: 'myidProd',
localField: 'idProduct',
foreignField: '_id',
as: 'product'
}
},
{
$unwind: {
path: '$product',
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: 'productinfos',
localField: 'product.idProductInfo',
foreignField: '_id',
as: 'product.productInfo'
}
},
{
$unwind: {
path: '$product.productInfo',
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: 'producers',
localField: 'myidProducer',
localField: 'product.idProducer',
foreignField: '_id',
as: 'producer'
}
@@ -164,14 +412,192 @@ module.exports.getTotalOrderById = async function (id) {
{
$lookup: {
from: 'storehouses',
localField: 'myidStore',
localField: 'idStorehouse',
foreignField: '_id',
as: 'storehouse'
}
},
{ $unwind: '$product' },
{ $unwind: '$producer' },
{ $unwind: '$storehouse' },
{
$lookup: {
from: 'providers',
localField: 'product.idProvider',
foreignField: '_id',
as: 'provider'
}
},
{
$lookup: {
from: 'gasordines',
localField: 'idGasordine',
foreignField: '_id',
as: 'gasordine'
}
},
{
$unwind: {
path: '$gasordine',
preserveNullAndEmptyArrays: true,
},
},
{
$match: {
$or: [
{ 'gasordine': { $exists: false } },
{ 'gasordine.active': true }
]
}
},
{
$lookup: {
from: 'scontisticas',
localField: 'product.idScontisticas',
foreignField: '_id',
as: 'scontisticas'
}
},
{
$unwind: {
path: '$producer',
preserveNullAndEmptyArrays: true,
},
},
{
$unwind: {
path: '$storehouse',
preserveNullAndEmptyArrays: true,
},
},
{
$unwind: {
path: '$provider',
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: 'orders',
let: { productId: '$product._id' },
pipeline: [
{
$match: {
$expr: {
$and: [
{ $eq: ['$idProduct', '$$productId'] },
{
$or: [
{
$eq: ['$status', shared_consts.OrderStatus.CHECKOUT_SENT]
},
{
$and: [{ $lt: ['$status', shared_consts.OrderStatus.CHECKOUT_SENT] },
{
$gt: [
'$modify_at',
{ $subtract: [new Date(), 60 * 60 * 1000] } // 1 hour in milliseconds 60 * 60
]
}]
}
]
}
]
}
},
},
{
$group: {
_id: null,
totalQty: { $sum: '$quantity' },
}
}
],
as: 'productOrders'
}
},
{
$lookup: {
from: 'orders',
let: { productId: '$product._id' },
pipeline: [
{
$match: {
$expr: {
$and: [
{ $eq: ['$idProduct', '$$productId'] },
{
$or: [
{
$eq: ['$status', shared_consts.OrderStatus.CHECKOUT_SENT]
},
{
$and: [{ $lt: ['$status', shared_consts.OrderStatus.CHECKOUT_SENT] },
{
$gt: [
'$modify_at',
{ $subtract: [new Date(), 60 * 60 * 1000] } // 1 hour in milliseconds 60 * 60
]
}]
}
]
}
]
}
}
},
{
$group: {
_id: null,
totalQtyPreordered: { $sum: '$quantitypreordered' }
}
}
],
as: 'productPreOrders'
}
},
{
$addFields: {
'product.QuantitaOrdinateInAttesa': {
$ifNull: [
{
$cond: {
if: { $isArray: '$productOrders' },
then: { $arrayElemAt: ['$productOrders.totalQty', 0] },
else: 0
}
},
0
]
},
'product.QuantitaPrenotateInAttesa': {
$ifNull: [
{
$cond: {
if: { $isArray: '$productPreOrders' },
then: { $arrayElemAt: ['$productPreOrders.totalQtyPreordered', 0] },
else: 0
}
},
0
]
},
},
},
{
$addFields: {
'product.quantityAvailable': {
$subtract: ["$product.stockQty", "$product.QuantitaOrdinateInAttesa"],
},
'product.bookableAvailableQty': {
$subtract: ["$product.maxbookableGASQty", "$product.QuantitaPrenotateInAttesa"],
}
}
},
{
$unset: 'productOrders'
},
{
$unset: 'productPreOrders'
},
];
return await Order.aggregate(query);

View File

@@ -6,8 +6,20 @@ const shared_consts = require('../tools/shared_nodejs');
const Order = require('../models/order');
var { User } = require('../models/user');
const Storehouse = require('../models/storehouse');
const Provider = require('../models/provider');
const Gasordine = require('../models/gasordine');
const Product = require('../models/product');
const ProductInfo = require('../models/productInfo');
const { Circuit } = require('../models/circuit');
const CartClass = require('../modules/Cart')
const Cart = require('../models/cart');
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const OrdersCartSchema = new Schema({
@@ -15,9 +27,12 @@ const OrdersCartSchema = new Schema({
type: String
},
numorder: { type: Number },
numord_pers: { type: Number },
userId: { type: Schema.Types.ObjectId, ref: 'User' },
totalQty: { type: Number, default: 0 },
totalQtyPreordered: { type: Number, default: 0 },
totalPrice: { type: Number, default: 0 },
totalPriceCalc: { type: Number, default: 0 },
department: {
type: String, ref: 'Department'
},
@@ -31,24 +46,83 @@ const OrdersCartSchema = new Schema({
type: Number,
Default: 0,
},
confermato: { // e quindi è stato tolto dal magazzino (aggiornando il campo stockBloccatiQty)
type: Boolean,
default: false,
},
date_confermato: {
type: Date
},
pagato: {
type: Boolean,
default: false,
},
date_pagato: {
type: Date
},
spedito: {
type: Boolean,
default: false,
},
date_spedito: {
type: Date
},
consegnato: { // e quindi è stato tolto dal magazzino (aggiornando il campo stockQty e stockBloccatiQty)
type: Boolean,
default: false,
},
date_consegnato: {
type: Date
},
preparato: {
type: Boolean,
default: false,
},
date_preparato: {
type: Date
},
ricevuto: {
type: Boolean,
default: false,
},
date_ricevuto: {
type: Date
},
note: {
type: String
},
note_per_gestore: {
type: String
},
note_per_admin: {
type: String
},
modify_at: {
type: Date
},
created_at: {
type: Date
},
completed_at: {
type: Date
deleted: {
type: Boolean,
default: false,
},
});
var OrdersCart = module.exports = mongoose.model('OrdersCart', OrdersCartSchema);
function fixupdated(myrec) {
return myrec;
/*if (myrec) {
if (myrec.totalPriceCalc === undefined) {
myrec.totalPriceCalc = myrec.totalPrice;
}
}
return myrec;*/
}
module.exports.findAllIdApp = async function (idapp, userId) {
const myfind = { idapp, userId };
const myfind = { idapp, userId, deleted: false };
return await await OrdersCart.find(myfind);
};
@@ -63,20 +137,29 @@ module.exports.getFieldsForSearch = function () {
};
module.exports.getNewNumOrder = async function (uid, idapp) {
let query = { userId: uid, idapp }
let numorder = 1;
module.exports.getLastNumOrder = async function (idapp) {
let query = { idapp, deleted: false }
let numorder = 100;
let numorderrec = await OrdersCart.find(query).sort({ numorder: -1 }).limit(1);
if (numorderrec.length <= 0)
numorder = 1;
else
numorder = numorderrec[0].numorder;
if (numorder) {
numorder++
} else {
numorder = 1;
}
if (numorderrec && numorderrec.length > 0)
numorder = numorderrec[0].numorder;
else
numorder = 100;
return numorder;
};
module.exports.getLastNumOrdPers = async function (uid, idapp) {
let query = { userId: uid, idapp, deleted: false }
let numorder = 1;
let numorderrec = await OrdersCart.find(query).sort({ numord_pers: -1 }).limit(1);
if (numorderrec && numorderrec.length > 0)
numorder = numorderrec[0].numord_pers;
else
numorder = 0;
return numorder;
@@ -97,132 +180,182 @@ module.exports.getStatusCartByUserId = async function (uid, idapp, numorder) {
return shared_consts.OrderStatus.NONE
}
module.exports.getOrdersCartByUserId = async function (uid, idapp, numorder) {
let query = { idapp, status: { $gte: shared_consts.OrderStatus.CHECKOUT_SENT } }
module.exports.getRecCartByUserId = async function (uid, idapp, numorder) {
let query = { userId: uid, idapp, status: { $lt: shared_consts.OrderStatus.CHECKOUT_SENT } }
let myorderscart = null;
if (numorder > 0) {
query = { userId: uid, idapp, numorder, status: { $lt: shared_consts.OrderStatus.CHECKOUT_SENT } }
}
myorderscart = await OrdersCart.findOne(query).lean();
return myorderscart
}
module.exports.getOrdersCartById = async function (id) {
let query = { _id: ObjectID(id) };
const arrris = await OrdersCart.getOrdersCartByQuery(query);
let myrec = arrris && arrris.length > 0 ? arrris[0] : null;
myrec = fixupdated(myrec);
return myrec;
}
module.exports.getOrdersCartByQuery = async function (query) {
let myorderscart = await OrdersCart.find(query)
.populate('items.order')
.populate({
path: 'items.order',
populate: {
path: 'idProduct',
model: 'Product',
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 : '';
}
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);
return myorderscart;
}
module.exports.getOrdersCartByUserId = async function (uid, idapp, numorder, filterStatus) {
try {
let query = { idapp, deleted: false }
let myorderscart = null;
if (numorder > 0) {
query.numorder = numorder;
}
if (uid !== 'ALL') {
if (uid !== 'ALL' && !!uid) {
query.userId = uid;
}
myorderscart = await OrdersCart.find(query).lean();
for (let ind = 0; ind < myorderscart.length; ind++) {
for (const idkey in myorderscart[ind].items) {
try {
let idorder = myorderscart[ind].items[idkey]._id.toString();
const myorder = myorderscart[ind].items[idkey].order;
if (!!myorder) {
idorder = myorderscart[ind].items[idkey].order._id.toString();
}
myorderscart[ind].nameSurname = await User.getNameSurnameById(idapp, myorderscart[ind].userId);
const myord = await Order.getTotalOrderById(idorder);
if (myord.length > 0) {
myorderscart[ind].items[idkey].order = myord[0];
}
} catch (e) {
console.log('err', e);
}
}
if (filterStatus) {
query.status = { $gte: shared_consts.OrderStatus.CHECKOUT_SENT };
}
/* if (!!mycart) {
for (const idkey in mycart.items) {
try {
idorder = mycart.items[idkey]._id.toString();
const 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]._doc.order = myord[0];
}
} catch (e) {
console.log('err', e);
}
}
return mycart;
}*/
myorderscart = await OrdersCart.getOrdersCartByQuery(query);
/*transform: function(doc, populated) {
// Rinomina 'idProduct' a 'product' nei risultati della popolazione
populated.product = populated.idProduct;
delete populated.idProduct;
return populated;
},*/
return myorderscart
} catch (e) {
console.error('Err:', e);
}
// return null;
}
module.exports.getOrdersCartByDepartmentId = async function (depId, idapp) {
let query = { idapp, status: { $gte: shared_consts.OrderStatus.CHECKOUT_SENT } }
const myorderscart = await OrdersCart.find(query).lean();
for (let ind = 0; ind < myorderscart.length; ind++) {
for (const idkey in myorderscart[ind].items) {
try {
let idorder = myorderscart[ind].items[idkey]._id.toString();
const myorder = myorderscart[ind].items[idkey].order;
if (!!myorder) {
idorder = myorderscart[ind].items[idkey].order._id.toString();
}
myorderscart[ind].nameSurname = await User.getNameSurnameById(idapp, myorderscart[ind].userId);
const myord = await Order.getTotalOrderById(idorder);
if (myord.length > 0) {
myorderscart[ind].items[idkey].order = myord[0];
}
} catch (e) {
console.log('err', e);
}
}
}
return myorderscart
// return null;
}
module.exports.getOrderById = async function (Id, idapp) {
let query = { _id: Id, idapp, status: { $gte: shared_consts.OrderStatus.CHECKOUT_SENT } }
const myorderscart = await OrdersCart.find(query).lean();
for (let ind = 0; ind < myorderscart.length; ind++) {
for (const idkey in myorderscart[ind].items) {
try {
let idorder = myorderscart[ind].items[idkey]._id.toString();
const myorder = myorderscart[ind].items[idkey].order;
if (!!myorder) {
idorder = myorderscart[ind].items[idkey].order._id.toString();
}
myorderscart[ind].nameSurname = await User.getNameSurnameById(idapp, myorderscart[ind].userId);
const myord = await Order.getTotalOrderById(idorder);
if (myord.length > 0) {
myorderscart[ind].items[idkey].order = myord[0];
}
} catch (e) {
console.log('err', e);
}
}
}
return myorderscart
// return null;
}
module.exports.updateOrdersCartById = function (id, newOrdersCart, callback) {
let query = { id: id }
let query = {
id,
deleted: false,
}
OrdersCart.find(query, function (err, c) {
if (err) throw err
//exist cart in databse
if (c.length > 0) {
OrdersCart.findOneAndUpdate(
return OrdersCart.findOneAndUpdate(
{ _id: id },
{
$set: {
items: newOrdersCart.items,
totalQty: newOrdersCart.totalQty,
totalQtyPreordered: newOrdersCart.totalQtyPreordered,
totalPrice: newOrdersCart.totalPrice,
totalPriceCalc: newOrdersCart.totalPriceCalc ? newOrdersCart.totalPriceCalc : newOrdersCart.totalPrice,
userId: userId,
status: newOrdersCart.status,
numorder: newOrdersCart.numorder,
numord_pers: newOrdersCart.numord_pers,
note: newOrdersCart.note,
modify_at: new Date(),
}
@@ -232,15 +365,459 @@ module.exports.updateOrdersCartById = function (id, newOrdersCart, callback) {
)
} else {
//no cart in database
newOrdersCart.save(callback)
return newOrdersCart.save(callback)
}
})
}
module.exports.setFieldInOrdersById = async function (objtoset, myOrderCart) {
try {
let ris2 = null;
// Imposta su tutti i singoli prodotti ordinati (Order)
for (const recitem of myOrderCart.items) {
ris2 = await Order.findOneAndUpdate(
{ _id: recitem.order._id },
{
$set: objtoset
},
{ new: false }
)
// console.log('ris', ris2);
}
const ris = await OrdersCart.findOneAndUpdate(
{ _id: myOrderCart._id },
{
$set: objtoset
},
{ new: false }
)
} catch (e) {
console.log('Err', e);
}
}
module.exports.deleteRecsInOrdersById = async function (myOrderCart) {
try {
let ris2 = null;
// Imposta su tutti i singoli prodotti ordinati (Order)
for (const recitem of myOrderCart.items) {
ris2 = await Order.findOneAndRemove({ _id: recitem.order._id })
}
const ris = await OrdersCart.findOneAndRemove({ _id: myOrderCart._id })
} catch (e) {
console.log('Err', e);
}
}
module.exports.setConsegnatoById = async function (value, myOrderCart) {
let objtoset = {
consegnato: value,
date_consegnato: new Date(),
};
return await OrdersCart.setFieldInOrdersById(objtoset, myOrderCart);
}
module.exports.setPreparatoById = async function (value, myOrderCart) {
let objtoset = {
preparato: value,
date_preparato: new Date(),
};
return await OrdersCart.setFieldInOrdersById(objtoset, myOrderCart);
}
module.exports.setSpeditoById = async function (value, myOrderCart) {
let objtoset = {
spedito: value,
date_spedito: new Date(),
};
return await OrdersCart.setFieldInOrdersById(objtoset, myOrderCart);
}
module.exports.setPagatoById = async function (value, myOrderCart) {
let objtoset = {
pagato: value,
date_pagato: new Date(),
};
if (!value) {
objtoset.date_pagato = null;
}
return await OrdersCart.setFieldInOrdersById(objtoset, myOrderCart);
}
module.exports.setConsegnatoById = async function (value, myOrderCart) {
let objtoset = {
consegnato: value,
date_consegnato: new Date(),
};
return await OrdersCart.setFieldInOrdersById(objtoset, myOrderCart);
}
module.exports.setConfermatoById = async function (value, myOrderCart) {
let objtoset = {
confermato: value,
date_confermato: new Date(),
};
return await OrdersCart.setFieldInOrdersById(objtoset, myOrderCart);
}
module.exports.setRicevutoById = async function (value, myOrderCart) {
let objtoset = {
ricevuto: value,
date_ricevuto: new Date(),
};
return await OrdersCart.setFieldInOrdersById(objtoset, myOrderCart);
}
module.exports.deleteReally = async function (value, myOrderCart) {
return await OrdersCart.deleteRecsInOrdersById(myOrderCart);
}
module.exports.createOrdersCart = async function (newOrdersCart) {
return await newOrdersCart.save()
}
module.exports.addOrderToMovement = async function (myOrderCart, usernameStore, groupnameStore, req) {
try {
if (myOrderCart) {
const mymov = await Circuit.addMovementByOrdersCart(myOrderCart, usernameStore, groupnameStore);
return mymov;
}
return null;
} catch (e) {
console.error('Err', e);
}
}
module.exports.checkQtaIfIsLow_SendAlert = async function (idapp, idProduct) {
try {
const telegrambot = require('../telegram/telegrambot');
const isLow = await Product.isLowQuantityInStockById(idProduct);
const instock = await Product.getInStockById(idProduct);
const myprod = await Product.getProductById(idProduct);
if (isLow && myprod) {
let msg = `Il Prodotto '${myprod.productInfo.name}' è rimasto a ${instock} quantità !`;
await telegrambot.sendMsgTelegramToTheManagers(idapp, msg);
}
} catch (e) {
console.error('Err;', e);
}
}
module.exports.updateMagazzinoOrdineInLavorazione = async function (idorderscart) {
try {
const myorderscart = await OrdersCart.findOne({ _id: idorderscart }).populate('items.order').lean();
if (myorderscart) {
for (const idkey in myorderscart.items) {
let order = myorderscart.items[idkey].order;
if (!order.confermato) { // Se ancora non è stato confermato:
let update = {
$inc: {
bookedQtyOrdered: order.quantity,
}
};
await Product.findOneAndUpdate({ _id: order.idProduct }, update, { new: false });
update = {
$inc: {
bookedGASQtyOrdered: order.quantitypreordered,
}
};
await Product.findOneAndUpdate({ _id: order.idProduct }, update, { new: false });
await OrdersCart.checkQtaIfIsLow_SendAlert(myorderscart.idapp, order.idProduct)
}
}
}
} catch (e) {
console.error('Err', e);
}
}
module.exports.updateStockQtaDalMagazzinoOrdineConfermato = async function (idorderscart) {
try {
const myorderscart = await OrdersCart.findOne({ _id: idorderscart }).populate('items.order').lean();
if (myorderscart) {
for (const idkey in myorderscart.items) {
let order = myorderscart.items[idkey].order;
if (!order.confermato) { // Se ancora non è stato confermato:
let update = {
$inc: {
stockQty: -order.quantity,
stockBloccatiQty: order.quantity,
bookedQtyConfirmed: order.quantity,
}
};
await Product.findOneAndUpdate({ _id: order.idProduct }, update, { new: false });
update = {
$inc: {
maxbookableGASQty: -order.quantitypreordered,
bookableGASBloccatiQty: order.quantitypreordered,
bookedGASQtyConfirmed: order.quantitypreordered,
}
};
await Product.findOneAndUpdate({ _id: order.idProduct }, update, { new: false });
}
}
}
} catch (e) {
console.error('Err', e);
}
}
module.exports.updateStockBloccatiQtaDalMagazzinoOrdineConsegnato = async function (idorderscart) {
try {
const myorderscart = await OrdersCart.findOne({ _id: idorderscart }).populate('items.order').lean();
if (myorderscart) {
for (const idkey in myorderscart.items) {
let order = myorderscart.items[idkey].order;
if (!order.consegnato) {
let update = {
$inc: {
stockBloccatiQty: -order.quantity
}
};
await Product.findOneAndUpdate({ _id: order.idProduct }, update, { new: false });
update = {
$inc: {
bookableGASBloccatiQty: -order.quantitypreordered
}
};
await Product.findOneAndUpdate({ _id: order.idProduct }, update, { new: false });
}
}
}
} catch (e) {
console.error('Err', e);
}
}
module.exports.updateStockQtaPerCancellazioneOrdine = async function (idorderscart) {
try {
const myorderscart = await OrdersCart.findOne({ _id: idorderscart }).populate('items.order').lean();
if (myorderscart) {
for (const idkey in myorderscart.items) {
let order = myorderscart.items[idkey].order;
let update = {};
let fieldstoUpdate = {};
if (order.consegnato) {
// Se l'ordine era stato già Consegnato, allora non fare niente !
return false;
} else {
if (order.confermato) { // Se l'ordine era stato confermato, allora rimetti le Qta in Magazzino
fieldstoUpdate = {
...fieldstoUpdate,
stockQty: order.quantity,
stockBloccatiQty: -order.quantity,
bookedQtyConfirmed: -order.quantity,
}
}
fieldstoUpdate = {
...fieldstoUpdate,
bookedQtyOrdered: -order.quantity,
}
update = {
$inc: fieldstoUpdate,
};
await Product.findOneAndUpdate({ _id: order.idProduct }, update, { new: false });
// --------------
fieldstoUpdate = {};
if (order.confermato) { // Se l'ordine era stato confermato, allora rimetti le Qta in Magazzino
fieldstoUpdate = {
...fieldstoUpdate,
maxbookableGASQty: order.quantitypreordered,
bookableGASBloccatiQty: -order.quantitypreordered,
bookedGASQtyConfirmed: -order.quantitypreordered,
}
}
fieldstoUpdate = {
...fieldstoUpdate,
bookedGASQtyOrdered: -order.quantitypreordered,
}
update = {
$inc: fieldstoUpdate,
};
await Product.findOneAndUpdate({ _id: order.idProduct }, update, { new: false });
}
}
}
} catch (e) {
console.error('Err', e);
}
}
module.exports.getStorehouseByOrdersCart = function (ordersCart) {
return ordersCart && ordersCart.items && ordersCart.items.length > 0 && ordersCart.items[0].order.storehouse
? ordersCart.items[0].order.storehouse
: null
}
module.exports.getUsernameStorehouseActual = async function (ordersCart) {
const storehouse = OrdersCart.getStorehouseByOrdersCart(ordersCart);
return storehouse
? storehouse.username
: null
}
module.exports.getGroupnameStorehouseActual = async function (ordersCart) {
const storehouse = OrdersCart.getStorehouseByOrdersCart(ordersCart);
return storehouse
? storehouse.groupname
: null
}
module.exports.updateCmd = async function (ordersCart, status, value, req, options) {
let myOrderCart = await OrdersCart.getOrdersCartById(ordersCart._id);
// let myOrderCart = await OrdersCart.findOne({ _id: ordersCart._id })
// .populate('items.order').lean();
const usernameStore = await OrdersCart.getUsernameStorehouseActual(myOrderCart);
const groupnameStore = await OrdersCart.getGroupnameStorehouseActual(myOrderCart);
try {
if (!!myOrderCart) {
const id = myOrderCart._id;
if (status === shared_consts.OrderStatus.CHECKOUT_SENT) {
if (value) {
await OrdersCart.updateMagazzinoOrdineInLavorazione(id);
}
} else if (status === shared_consts.OrderStatus.ORDER_CONFIRMED) {
// Aggiorna anche il Magazzino, togliendo le quantità in Stock e aggiungendole su quelle bloccate
if (value) {
await OrdersCart.updateStockQtaDalMagazzinoOrdineConfermato(id);
}
ris = await OrdersCart.setConfermatoById(value, myOrderCart);
} else if (status === shared_consts.OrderStatus.PAYED) {
if (value) {
if (!myOrderCart.pagato) { // Se ancora non è stato confermato:
await OrdersCart.addOrderToMovement(myOrderCart, usernameStore, groupnameStore, req);
ris = await OrdersCart.setPagatoById(value, myOrderCart);
}
}
} else if (status === shared_consts.OrderStatus.PREPARED) {
ris = await OrdersCart.setPreparatoById(value, myOrderCart);
} else if (status === shared_consts.OrderStatus.DELIVERED) { // Consegnato
if (value) {
await OrdersCart.updateStockBloccatiQtaDalMagazzinoOrdineConsegnato(id);
}
ris = await OrdersCart.setConsegnatoById(value, myOrderCart);
} else if (status === shared_consts.OrderStatus.SHIPPED) {
ris = await OrdersCart.setSpeditoById(value, myOrderCart);
} else if (status === shared_consts.OrderStatus.RECEIVED) {
ris = await OrdersCart.setRicevutoById(value, myOrderCart);
} else if (status === shared_consts.OrderStatus.PREPARED) {
ris = await OrdersCart.setPreparatoById(value, myOrderCart);
} else if (status === shared_consts.OrderStatus.CANCELED) {
await OrdersCart.updateStockQtaPerCancellazioneOrdine(id)
} else if (status === shared_consts.OrderStatus.DELETE_REALLY) {
await OrdersCart.updateStockQtaPerCancellazioneOrdine(id)
ris = await OrdersCart.deleteReally(value, myOrderCart);
}
if (status !== shared_consts.OrderStatus.DELETE_REALLY) {
await OrdersCart.setFieldInOrdersById({ status }, myOrderCart);
myOrderCart = await OrdersCart.getOrdersCartById(ordersCart._id)
}
// myOrderCart = await OrdersCart.findOne({ _id: idorderscart });
return myOrderCart;
}
} catch (e) {
console.error('Err:', e)
}
}
OrdersCartSchema.pre('save', async function (next) {
try {
@@ -276,3 +853,95 @@ OrdersCartSchema.pre('save', async function (next) {
console.error(e.message);
}
});
module.exports.updateOrdersCartByParams = async function (idOrdersCart, paramstoupdate) {
const ris = await OrdersCart.findOneAndUpdate({ _id: idOrdersCart }, { $set: paramstoupdate });
let myorderscart = await OrdersCart.getOrdersCartById(idOrdersCart);
return myorderscart;
}
module.exports.updateOrdersCartTotals = async function (idOrdersCart, update) {
try {
let orderscart = await OrdersCart.getOrdersCartById(idOrdersCart);
if (orderscart) {
let newOrdersCart = CartClass.constructByCart(orderscart);
await newOrdersCart.updatecarttotals(false);
if (update) {
await OrdersCart.findOneAndUpdate({ _id: idOrdersCart }, {
$set: {
totalPrice: newOrdersCart.totalPrice,
totalPriceCalc: newOrdersCart.totalPriceCalc,
totalQty: newOrdersCart.totalQty,
note: newOrdersCart.note,
modify_at: new Date(),
},
}
)
}
orderscart = await OrdersCart.getOrdersCartById(idOrdersCart);
return orderscart;
}
} catch (e) {
console.error('err', e);
}
};
module.exports.getmsgorderTelegram = async function (ordersCart) {
try {
const statusstr = shared_consts.getStatusStr(ordersCart.status);
let msg = '🟢✍️ Ordine n. ' + ordersCart.numorder
msg += '<br>Stato: ' + statusstr;
msg += '<br>🙎🏻‍♂️ ' + tools.getNomeCognomeEUserNameByUser(ordersCart.user)
if (ordersCart.note)
msg += '<br>Note: ' + ordersCart.note;
msg += '<br><br>Lista Prodotti: (🍊🥑🍋)';
for (const ord of ordersCart.items) {
msg += '<br>';
let qtystr = ''
let qtynum = 0
if (ord.order.quantity > 0)
qtynum += ord.order.quantity;
if (ord.order.quantitypreordered > 0)
qtynum += ord.order.quantitypreordered;
qtystr += qtynum + ' ' + 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 += '<br>';
let totqta = ordersCart.totalQty + ordersCart.totalQtyPreordered;
msg += '<br>Totale Prodotti: ' + totqta;
msg += '<br>Totale Ordine: ' + ordersCart.totalPrice + ' € 💰';
return msg;
} catch (e) {
console.error('Err', e);
}
};
module.exports.createIndexes((err) => {
if (err) throw err;
});

View File

@@ -45,4 +45,8 @@ PaymentTypeSchema.statics.findAllIdApp = async function (idapp) {
const PaymentType = mongoose.model('Paymenttype', PaymentTypeSchema);
PaymentType.createIndexes((err) => {
if (err) throw err;
});
module.exports = { PaymentType };

View File

@@ -57,4 +57,8 @@ PermissionSchema.statics.findAllIdApp = async function () {
const Permission = mongoose.model('Permission', PermissionSchema);
Permission.createIndexes((err) => {
if (err) throw err;
});
module.exports = { Permission };

Some files were not shown because too many files have changed in this diff Show More