alsmanager_lib 3.0.205 → 3.0.206

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/modules.js +150 -4
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -7872,7 +7872,7 @@ function queryConsegneMySQL(data_da, data_a, data_filter, adulto, alunno, still_
7872
7872
  query += " and (select count(*) from consegna_beni where id_consegna = c.id and stato_restituzione in(0,1)) > 0"
7873
7873
  }
7874
7874
  if (only_outofdate && only_outofdate > 0) {
7875
- query += " and date('now') >= c.data_limite ";
7875
+ query += " and CURDATE() >= c.data_limite ";
7876
7876
  }
7877
7877
  }
7878
7878
  if (data_filter == "RICHIESTA")
@@ -7882,6 +7882,51 @@ function queryConsegneMySQL(data_da, data_a, data_filter, adulto, alunno, still_
7882
7882
 
7883
7883
  return query;
7884
7884
  }
7885
+
7886
+ function queryConsegneMySQL2(data_da, data_a, data_filter, adulto, alunno, still_open, only_outofdate) {
7887
+ var query = "SELECT c.id, c.data_richiesta as Richiesta, c.data_consegna as Consegna, c.richiedente_adulto as Adulto, c.richiedente_alunno as Alunno, c.richiedente_genitore as Genitore, c.is_home as Casa, c.note as Note, c.email_adulto, c.email_genitore from consegne c ";
7888
+ query += "where (removed is null or removed = 0) ";
7889
+ if (adulto && adulto.trim() != '') {
7890
+ query += "and richiedente_adulto = '" + adulto + "' ";
7891
+ }
7892
+ if (alunno && alunno.trim() != '') {
7893
+ query += "and richiedente_alunno = '" + alunno + "' ";
7894
+ }
7895
+ if (data_da || data_a) {
7896
+ query += " and ";
7897
+ if (data_da) {
7898
+ var d = new Date(data_da);
7899
+ var data_str = d.getFullYear() + "-" + String((d.getMonth() + 1)).padStart(2, '0') + "-" + String(d.getDate()).padStart(2, '0');
7900
+ if (data_filter == "RICHIESTA")
7901
+ query += "data_richiesta >= '" + data_str + "'";
7902
+ else
7903
+ query += "data_consegna >= '" + data_str + "'";
7904
+ }
7905
+ if (data_da && data_a) {
7906
+ query += " and ";
7907
+ }
7908
+ if (data_a) {
7909
+ var d = new Date(data_a);
7910
+ var data_str = d.getFullYear() + "-" + String((d.getMonth() + 1)).padStart(2, '0') + "-" + String(d.getDate()).padStart(2, '0');
7911
+ if (data_filter == "RICHIESTA")
7912
+ query += "data_richiesta <= '" + data_str + "'";
7913
+ else
7914
+ query += "data_consegna <= '" + data_str + "'";
7915
+ }
7916
+ if (still_open) {
7917
+ query += " and (select count(*) from consegna_beni where id_consegna = c.id and stato_restituzione in(0,1)) > 0"
7918
+ }
7919
+ if (only_outofdate && only_outofdate > 0) {
7920
+ query += " and CURDATE() >= c.data_limite ";
7921
+ }
7922
+ }
7923
+ if (data_filter == "RICHIESTA")
7924
+ query += " order by data_richiesta desc";
7925
+ else
7926
+ query += " order by data_consegna desc";
7927
+ return query;
7928
+ }
7929
+
7885
7930
  function queryConsegne(db_used,data_da, data_a, data_filter, adulto, alunno, still_open, only_outofdate) {
7886
7931
  var query = "";
7887
7932
  if (db_used) {
@@ -7893,7 +7938,7 @@ function queryConsegne(db_used,data_da, data_a, data_filter, adulto, alunno, sti
7893
7938
  query = queryConsegneMySQL(data_da, data_a, data_filter, adulto, alunno, still_open, only_outofdate);
7894
7939
  break;
7895
7940
  case 'MYSQL2':
7896
- query = queryConsegneSQLite(data_da, data_a, data_filter, adulto, alunno, still_open, only_outofdate);
7941
+ query = queryConsegneMySQL2(data_da, data_a, data_filter, adulto, alunno, still_open, only_outofdate);
7897
7942
  break;
7898
7943
  }
7899
7944
  }
@@ -7936,7 +7981,7 @@ function queryConsegnaById(db_used,id_consegna) {
7936
7981
  }
7937
7982
 
7938
7983
  //Creazione email sollecito consegna
7939
- function getDatiConsegneAttive() {
7984
+ function getDatiConsegneAttiveSQLite() {
7940
7985
  var query = "select c.id, c.richiedente_adulto as Nominativo, c.email_adulto as Email, concat('Consegna n.', c.id, ' del ', STRFTIME('%d/%m/%Y', c.data_consegna)) as Consegna, ";
7941
7986
  query += "case ";
7942
7987
  query += "when d.id is not null and d.inv_ict3_number is not null and trim(d.inv_ict3_number) <> '' then concat(d.manifacturer, ' - ', d.model, ' - Inv.', d.inv_ict3_number) ";
@@ -7958,6 +8003,47 @@ function getDatiConsegneAttive() {
7958
8003
  return query;
7959
8004
  }
7960
8005
 
8006
+ function getDatiConsegneAttiveMySQL() {
8007
+ var query = "select c.id, c.richiedente_adulto as Nominativo, c.email_adulto as Email, concat('Consegna n.', c.id, ' del ', DATE_FORMAT(c.data_consegna,'%d/%m/%Y')) as Consegna, ";
8008
+ query += "case ";
8009
+ query += "when d.id is not null and d.inv_ict3_number is not null and trim(d.inv_ict3_number) <> '' then concat(d.manifacturer, ' - ', d.model, ' - Inv.', d.inv_ict3_number) ";
8010
+ query += "when d.id is not null and d.serial_no is not null and trim(d.serial_no) <> '' then concat(d.manifacturer, ' - ', d.model, ' - S/N:', d.serial_no) ";
8011
+ query += "when s.id is not null and s.inv_ict3_number is not null and trim(s.inv_ict3_number) <> '' then concat(s.maker, ' - ', s.model, ' - Inv.', s.inv_ict3_number) ";
8012
+ query += "when s.id is not null and s.serial_no is not null and trim(s.serial_no) <> '' then concat(s.maker, ' - ', s.model, ' - S/N:', s.serial_no) ";
8013
+ query += "else '' ";
8014
+ query += "end as bene_consegnato, ";
8015
+ query += "case ";
8016
+ query += "when cie.id is not null then 'SI' ";
8017
+ query += "else 'NO' ";
8018
+ query += "end as invio_sollecito ";
8019
+ query += "from consegna_beni cb ";
8020
+ query += "join consegne c on c.id = cb.id_consegna ";
8021
+ query += "left join devices d on cb.id_bene = d.id ";
8022
+ query += "left join softwares s on cb.id_bene = s.id ";
8023
+ query += "left join consegna_invio_email cie on cb.id_consegna = cie.id_consegna ";
8024
+ query += "where cb.stato_restituzione = 0 ";
8025
+ return query;
8026
+ }
8027
+
8028
+
8029
+ function getDatiConsegneAttive(db_used) {
8030
+ var query = "";
8031
+ if (db_used) {
8032
+ switch (db_used) {
8033
+ case 'SQLITE':
8034
+ query = getDatiConsegneAttiveSQLite();
8035
+ break;
8036
+ case 'MYSQL':
8037
+ query = getDatiConsegneAttiveMySQL();
8038
+ break;
8039
+ case 'MYSQL2':
8040
+ query = getDatiConsegneAttiveMySQL();
8041
+ break;
8042
+ }
8043
+ }
8044
+ return query;
8045
+ }
8046
+
7961
8047
 
7962
8048
  function createPreparazioneMessageFromConsegna(consegna, listaBeni) {
7963
8049
  var dc = new Date(consegna.data_consegna);
@@ -8018,7 +8104,7 @@ function createConsegnaMessage(nominativo, nome_alunno, email, rif_consegna, lis
8018
8104
  return msgObj;
8019
8105
  }
8020
8106
 
8021
- function getInviiEmailConsegna(id_consegna) {
8107
+ function getInviiEmailConsegnaSQLite(id_consegna) {
8022
8108
  var query = "select STRFTIME('%d/%m/%Y', cie.data_invio) as Data_Invio, cie.esito as Esito_Invio, cie.email_destinatario as Email, ";
8023
8109
  query += "cb.tipo_bene as Tipo, ";
8024
8110
  query += "case ";
@@ -8038,6 +8124,66 @@ function getInviiEmailConsegna(id_consegna) {
8038
8124
  return query;
8039
8125
  }
8040
8126
 
8127
+ function getInviiEmailConsegnaMySQL(id_consegna) {
8128
+ var query = "select DATE_FORMAT(cie.data_invio, '%d/%m/%Y') as Data_Invio, cie.esito as Esito_Invio, cie.email_destinatario as Email, ";
8129
+ query += "cb.tipo_bene as Tipo, ";
8130
+ query += "case ";
8131
+ query += "when d.id is not null and d.inv_ict3_number is not null and trim(d.inv_ict3_number) <> '' then concat(d.manifacturer, ' - ', d.model, ' - Inv.', d.inv_ict3_number) ";
8132
+ query += "when d.id is not null and d.serial_no is not null and trim(d.serial_no) <> '' then concat(d.manifacturer, ' - ', d.model, ' - S/N:', d.serial_no) ";
8133
+ query += "when s.id is not null and s.inv_ict3_number is not null and trim(s.inv_ict3_number) <> '' then concat(s.maker, ' - ', s.model, ' - Inv.', s.inv_ict3_number) ";
8134
+ query += "when s.id is not null and s.serial_no is not null and trim(s.serial_no) <> '' then concat(s.maker, ' - ', s.model, ' - S/N:', s.serial_no) ";
8135
+ query += "else '' ";
8136
+ query += "end as Bene ";
8137
+ query += "from consegna_invio_email cie ";
8138
+ query += "left join consegna_beni cb on cie.id_bene = cb.id_bene ";
8139
+ query += "join consegne c on c.id = cie.id_consegna ";
8140
+ query += "left join devices d on cie.id_bene = d.id ";
8141
+ query += "left join softwares s on cie.id_bene = s.id ";
8142
+ query += "where cie.id_consegna = :id_consegna ";
8143
+ query += "order by cie.data_invio desc";
8144
+ return query;
8145
+ }
8146
+
8147
+ function getInviiEmailConsegnaMySQL2(id_consegna) {
8148
+ var query = "select DATE_FORMAT(cie.data_invio, '%d/%m/%Y') as Data_Invio, cie.esito as Esito_Invio, cie.email_destinatario as Email, ";
8149
+ query += "cb.tipo_bene as Tipo, ";
8150
+ query += "case ";
8151
+ query += "when d.id is not null and d.inv_ict3_number is not null and trim(d.inv_ict3_number) <> '' then concat(d.manifacturer, ' - ', d.model, ' - Inv.', d.inv_ict3_number) ";
8152
+ query += "when d.id is not null and d.serial_no is not null and trim(d.serial_no) <> '' then concat(d.manifacturer, ' - ', d.model, ' - S/N:', d.serial_no) ";
8153
+ query += "when s.id is not null and s.inv_ict3_number is not null and trim(s.inv_ict3_number) <> '' then concat(s.maker, ' - ', s.model, ' - Inv.', s.inv_ict3_number) ";
8154
+ query += "when s.id is not null and s.serial_no is not null and trim(s.serial_no) <> '' then concat(s.maker, ' - ', s.model, ' - S/N:', s.serial_no) ";
8155
+ query += "else '' ";
8156
+ query += "end as Bene ";
8157
+ query += "from consegna_invio_email cie ";
8158
+ query += "left join consegna_beni cb on cie.id_bene = cb.id_bene ";
8159
+ query += "join consegne c on c.id = cie.id_consegna ";
8160
+ query += "left join devices d on cie.id_bene = d.id ";
8161
+ query += "left join softwares s on cie.id_bene = s.id ";
8162
+ query += "where cie.id_consegna = " + id_consegna + " ";
8163
+ query += "order by cie.data_invio desc";
8164
+ return query;
8165
+ }
8166
+
8167
+ function getInviiEmailConsegna(db_used, id_consegna) {
8168
+ var query = "";
8169
+ if (db_used) {
8170
+ switch (db_used) {
8171
+ case 'SQLITE':
8172
+ query = getInviiEmailConsegnaSQLite(id_consegna);
8173
+ break;
8174
+ case 'MYSQL':
8175
+ query = getInviiEmailConsegnaMySQL(id_consegna);
8176
+ break;
8177
+ case 'MYSQL2':
8178
+ query = getInviiEmailConsegnaMySQL2(id_consegna);
8179
+ break;
8180
+ }
8181
+ }
8182
+ return query;
8183
+ }
8184
+
8185
+
8186
+
8041
8187
  function insertInvioEmailConsegnaByBene(id_consegna, id_bene, data_invio, email_invio, esito_invio) {
8042
8188
  var query = "insert into consegna_invio_email (id_consegna, id_bene, data_invio, email_destinatario, esito) values ";
8043
8189
  query += "(" + id_consegna + ", ";
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  ".": "./lib/modules.js",
5
5
  "./dbconn": "./lib/dbconn.js"
6
6
  },
7
- "version": "3.0.205",
7
+ "version": "3.0.206",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",