alsmanager_lib 3.0.54 → 3.0.56

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 +141 -41
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -6900,19 +6900,53 @@ function getDatiConsegneAttive() {
6900
6900
  }
6901
6901
 
6902
6902
 
6903
- function createConsegnaMessage(nominativo, email, rif_consegna, bene, data_limite) {
6903
+ function createConsegnaMessage(nominativo, email, rif_consegna, listaBeni, data_limite) {
6904
6904
  var msgObj = {};
6905
6905
  msgObj.email_to = email;
6906
6906
  msgObj.subject = rif_consegna;
6907
6907
  msgObj.message = "Gentile/Egregio ins." + nominativo + "\n\n";
6908
6908
  msgObj.message += "Si ricorda di effettuare entro la data " + data_limite + " la consegna dei seguenti beni : \n\n";
6909
- msgObj.message += "n. 1 " + bene + "\n";
6909
+ listaBeni.forEach(element => {
6910
+ msgObj.message += "n. " + element.Numero + " - " + element.Tipo + " - " + element.Marca + " - " + element.Modello + " - Cod. " + element.Codice + "\n";
6911
+ });
6910
6912
  msgObj.message += "\n\nSi richiede che la consegna venga effettuata ad un tecnico dell'Istituto per le verifiche del caso.\n";
6911
6913
  msgObj.message += "Se per eventuali esigenze fosse necessario prolungare l'utilizzo del bene, si prega di contattare l'Ufficio Tecnico.\n ";
6912
6914
  msgObj.message += "\n\nCordiali saluti\n\nI tecnici dell'I.C. Trento 3";
6913
6915
  return msgObj;
6914
6916
  }
6915
6917
 
6918
+ function getInviiEmailConsegna(id_consegna) {
6919
+ var query = "select STRFTIME('%d/%m/%Y', cie.data_invio) as Data_Invio, cie.esito as Esito_Invio, cie.email_destinatario as Email, ";
6920
+ query += "cb.tipo_bene as Tipo, ";
6921
+ query += "case ";
6922
+ 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) ";
6923
+ 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) ";
6924
+ 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) ";
6925
+ 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) ";
6926
+ query += "else '' ";
6927
+ query += "end as Bene ";
6928
+ query += "from consegna_invio_email cie ";
6929
+ query += "left join consegna_beni cb on cie.id_bene = cb.id_bene ";
6930
+ query += "join consegne c on c.id = cie.id_consegna ";
6931
+ query += "left join devices d on cie.id_bene = d.id ";
6932
+ query += "left join softwares s on cie.id_bene = s.id ";
6933
+ query += "where cie.id_consegna = " + id_consegna + " ";
6934
+ query += "order by cie.data_invio desc";
6935
+ return query;
6936
+ }
6937
+
6938
+ function insertInvioEmailConsegna(id_consegna, id_bene, data_invio, email_invio, esito_invio) {
6939
+ var query = "insert into consegna_invio_email (id_consegna, id_bene, data_invio, email_destinatario, esito) values ";
6940
+ query += "(" + id_consegna + ", ";
6941
+ query += id_bene + ", ";
6942
+ query += "'" + data_invio + "', ";
6943
+ query += "'" + email_invio + "', ";
6944
+ query += "'" + esito_invio + "' ";
6945
+ query += ")";
6946
+ return query;
6947
+ }
6948
+
6949
+
6916
6950
 
6917
6951
  //End Creazione email sollecito consegna
6918
6952
 
@@ -6970,34 +7004,32 @@ function queryConsegneByIdDevice(db_used, id_device) {
6970
7004
 
6971
7005
  //
6972
7006
  function queryConsegneByIdBeneSQLite(id_bene, tipo_bene) {
6973
- var query = "select c.data_consegna as Consegna, ";
7007
+ var query = "select cb.data_consegna as Consegna, ";
6974
7008
  query += "case ";
6975
- query += "when c.stato_restituzione = 0 then 'Prestito in corso' ";
6976
- query += "when c.stato_restituzione = 1 then 'Non restituito' ";
6977
- query += "when c.stato_restituzione = 2 then 'Restituito' ";
6978
- query += "when c.stato_restituzione = 3 then 'Danneggiato' ";
6979
- query += "when c.stato_restituzione = 4 then 'Parti mancanti' ";
7009
+ query += "when cb.stato_restituzione = 0 then 'Prestito in corso' ";
7010
+ query += "when cb.stato_restituzione = 1 then 'Non restituito' ";
7011
+ query += "when cb.stato_restituzione = 2 then 'Restituito' ";
7012
+ query += "when cb.stato_restituzione = 3 then 'Danneggiato' ";
7013
+ query += "when cb.stato_restituzione = 4 then 'Parti mancanti' ";
6980
7014
  query += "else '' ";
6981
7015
  query += "end as Stato, ";
6982
- query += "c.note as Note from consegna beni ";
6983
- query += "inner join consegne c on c.id = dc.id_consegna ";
7016
+ query += "cb.note as Note from consegna beni cb";
6984
7017
  query += "where cb.id_bene = " + id_bene + " ";
6985
7018
  query += "and cb.tipo_bene = '" + tipo_bene + "' ";
6986
7019
  return query;
6987
7020
  }
6988
7021
 
6989
7022
  function queryConsegneByIdBeneMySQL(id_bene, tipo_bene) {
6990
- var query = "select c.data_consegna as Consegna, ";
7023
+ var query = "select cb.data_consegna as Consegna, ";
6991
7024
  query += "case ";
6992
- query += "when c.stato_restituzione = 0 then 'Prestito in corso' ";
6993
- query += "when c.stato_restituzione = 1 then 'Non restituito' ";
6994
- query += "when c.stato_restituzione = 2 then 'Restituito' ";
6995
- query += "when c.stato_restituzione = 3 then 'Danneggiato' ";
6996
- query += "when c.stato_restituzione = 4 then 'Parti mancanti' ";
7025
+ query += "when cb.stato_restituzione = 0 then 'Prestito in corso' ";
7026
+ query += "when cb.stato_restituzione = 1 then 'Non restituito' ";
7027
+ query += "when cb.stato_restituzione = 2 then 'Restituito' ";
7028
+ query += "when cb.stato_restituzione = 3 then 'Danneggiato' ";
7029
+ query += "when cb.stato_restituzione = 4 then 'Parti mancanti' ";
6997
7030
  query += "else '' ";
6998
7031
  query += "end as Stato, ";
6999
- query += "c.note as Note from consegna_beni cb ";
7000
- query += "inner join consegne c on c.id = cb.id_consegna ";
7032
+ query += "cb.note as Note from consegna_beni cb ";
7001
7033
  query += "where cb.id_bene = :id_bene and cb.tipo_bene = :tipo_bene";
7002
7034
  return query;
7003
7035
  }
@@ -7793,19 +7825,20 @@ function insertConsegnaBene(db_used, id_consegna, id_bene, tipo_bene, data_conse
7793
7825
  return query;
7794
7826
  }
7795
7827
 
7796
- function updateConsegnaBeneSQLite(id_benecons, id_consegna, id_bene, tipo_bene, data_consegna, numero, note){
7828
+ function updateConsegnaBeneSQLite(id_benecons, id_consegna, id_bene, tipo_bene, data_consegna, numero, stato_restituzione, note){
7797
7829
  var query = "update consegna_beni set ";
7798
7830
  query += "id_consegna = " + id_consegna + ", ";
7799
7831
  query += "id_bene = " + id_bene + ", ";
7800
7832
  query += "tipo_bene = '" + tipo_bene + "', ";
7801
7833
  query += "data_consegna = '" + data_consegna + "', ";
7802
7834
  query += "numero = " + numero + ", ";
7803
- query += "note = '" + note + "' ";
7835
+ query += "note = '" + note + "', ";
7836
+ query += "stato_restituzione = " + stato_restituzione + " ";
7804
7837
  query += "where id = " + id_benecons;
7805
7838
  return query;
7806
7839
  }
7807
7840
 
7808
- function updateConsegnaBeneMySQL(id_benecons, id_consegna, id_bene, tipo_bene, data_consegna, numero, note){
7841
+ function updateConsegnaBeneMySQL(id_benecons, id_consegna, id_bene, tipo_bene, data_consegna, numero, stato_restituzione, note){
7809
7842
  var query = "update consegna_beni set ";
7810
7843
  query += "id_consegna = :id_consegna, ";
7811
7844
  query += "id_bene = :id_bene, ";
@@ -7813,22 +7846,23 @@ function updateConsegnaBeneMySQL(id_benecons, id_consegna, id_bene, tipo_bene, d
7813
7846
  query += "data_consegna = :data_consegna, ";
7814
7847
  query += "numero = :numero, ";
7815
7848
  query += "note = :note ";
7849
+ query += "stato_restituzione = :stato_restituzione ";
7816
7850
  query += "where id = :id_benecons";
7817
7851
  return query;
7818
7852
  }
7819
7853
 
7820
- function updateConsegnaBene(db_used, id_benecons, id_consegna, id_bene, tipo_bene, data_consegna, numero, note) {
7854
+ function updateConsegnaBene(db_used, id_benecons, id_consegna, id_bene, tipo_bene, data_consegna, numero, stato_restituzione, note) {
7821
7855
  var query = "";
7822
7856
  if (db_used) {
7823
7857
  switch (db_used) {
7824
7858
  case 'SQLITE':
7825
- query = updateConsegnaBeneSQLite(id_benecons, id_consegna, id_bene, tipo_bene, data_consegna, numero, note);
7859
+ query = updateConsegnaBeneSQLite(id_benecons, id_consegna, id_bene, tipo_bene, data_consegna, numero, stato_restituzione, note);
7826
7860
  break;
7827
7861
  case 'MYSQL':
7828
- query = updateConsegnaBeneMySQL(id_benecons, id_consegna, id_bene, tipo_bene, data_consegna, numero, note);
7862
+ query = updateConsegnaBeneMySQL(id_benecons, id_consegna, id_bene, tipo_bene, data_consegna, numero, stato_restituzione, note);
7829
7863
  break;
7830
7864
  case 'MYSQL2':
7831
- query = updateConsegnaBeneSQLite(id_benecons, id_consegna, id_bene, tipo_bene, data_consegna, numero, note);
7865
+ query = updateConsegnaBeneSQLite(id_benecons, id_consegna, id_bene, tipo_bene, data_consegna, numero, stato_restituzione, note);
7832
7866
  break;
7833
7867
  }
7834
7868
  }
@@ -7862,7 +7896,7 @@ function removeConsegnaBene(db_used, id_benecons) {
7862
7896
  }
7863
7897
  return query;
7864
7898
  }
7865
- function selectBeniPerConsegnaSQLite(id_consegna) {
7899
+ function selectBeniPerConsegnaSQLite(id_consegna, solo_prestito_attivo) {
7866
7900
  var query = "select cb.id, cb.id_bene, cb.numero as Numero, cb.tipo_bene as Tipologia, ";
7867
7901
  query += "case ";
7868
7902
  query += "when cb.tipo_bene = 'DEVICE' then d.type ";
@@ -7907,7 +7941,18 @@ function selectBeniPerConsegnaSQLite(id_consegna) {
7907
7941
  query += "when cb.tipo_bene = 'DEVICE' and d.inv_pnrr_number is not null and trim(d.inv_pnrr_number) <> '' then 'SI' ";
7908
7942
  query += "when cb.tipo_bene = 'SOFTWARE' and s.is_pnrr is not null and s.is_pnrr = 0 then 'SI' ";
7909
7943
  query += "else 'NO' ";
7910
- query += "end as PNRR, cb.note_consegna as Note_cons ";
7944
+ query += "end as PNRR, ";
7945
+
7946
+ query += "case ";
7947
+ query += "when cb.stato_restituzione = 0 then 'Prestito in corso' ";
7948
+ query += "when cb.stato_restituzione = 1 then 'Non restituito' ";
7949
+ query += "when cb.stato_restituzione = 2 then 'Restituito' ";
7950
+ query += "when cb.stato_restituzione = 3 then 'Danneggiato' ";
7951
+ query += "when cb.stato_restituzione = 4 then 'Parti mancanti' ";
7952
+ query += "else '' ";
7953
+ query += "end as Stato, ";
7954
+
7955
+ query += "cb.note_consegna as Note_cons ";
7911
7956
  query += "from consegna_beni cb ";
7912
7957
  query += "left join devices d on cb.id_bene = d.id ";
7913
7958
  query += "left join softwares s on cb.id_bene = s.id ";
@@ -7915,40 +7960,93 @@ function selectBeniPerConsegnaSQLite(id_consegna) {
7915
7960
  query += "left join altri_beni a on cb.id_bene = a.id ";
7916
7961
  query += "left join altro_tipi atd on a.id_type = atd.id ";
7917
7962
  query += "where cb.id_consegna = " + id_consegna;
7963
+ if (solo_prestito_attivo) {
7964
+ query += " and cb.stato_restituzione = 0 ";
7965
+ }
7918
7966
  return query;
7919
7967
  }
7920
7968
 
7921
- function selectBeniPerConsegnaMySQL(id_consegna) {
7922
- var query = "select d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
7969
+ function selectBeniPerConsegnaMySQL(id_consegna, solo_prestito_attivo) {
7970
+ var query = "select cb.id, cb.id_bene, cb.numero as Numero, cb.tipo_bene as Tipologia, ";
7923
7971
  query += "case ";
7924
- query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then d.inv_ict3_number ";
7925
- query += "when d.inv_pnrr_number != '' and d.inv_pnrr_number is not null then d.inv_pnrr_number ";
7926
- query += "when d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number,'(TN)') ";
7927
- query += "when d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)') ";
7928
- query += "when d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)') ";
7972
+ query += "when cb.tipo_bene = 'DEVICE' then d.type ";
7973
+ query += "when cb.tipo_bene = 'SOFTWARE' then s.support ";
7974
+ query += "when cb.tipo_bene = 'BENE_CONSUMO' then bc.Tipo ";
7975
+ query += "when cb.tipo_bene = 'ALTRO' then atd.name ";
7976
+ query += "else '' "
7977
+ query += "end as Tipo, ";
7978
+ query += "case ";
7979
+ query += "when cb.tipo_bene = 'DEVICE' then d.manifacturer ";
7980
+ query += "when cb.tipo_bene = 'SOFTWARE' then s.maker ";
7981
+ query += "when cb.tipo_bene = 'BENE_CONSUMO' then bc.Marca ";
7982
+ query += "when cb.tipo_bene = 'ALTRO' then a.manifacturer ";
7983
+ query += "else '' "
7984
+ query += "end as Marca, ";
7985
+ query += "case ";
7986
+ query += "when cb.tipo_bene = 'DEVICE' then d.model ";
7987
+ query += "when cb.tipo_bene = 'SOFTWARE' then s.model ";
7988
+ query += "when cb.tipo_bene = 'BENE_CONSUMO' then bc.Modello ";
7989
+ query += "when cb.tipo_bene = 'ALTRO' then a.model ";
7990
+ query += "else '' "
7991
+ query += "end as Modello, ";
7992
+ query += "case ";
7993
+ query += "when cb.tipo_bene = 'DEVICE' and d.inv_ict3_number != '' and d.inv_ict3_number is not null then d.inv_ict3_number ";
7994
+ query += "when cb.tipo_bene = 'DEVICE' and d.inv_pnrr_number != '' and d.inv_pnrr_number is not null then d.inv_pnrr_number ";
7995
+ query += "when cb.tipo_bene = 'DEVICE' and d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number,'(TN)') ";
7996
+ query += "when cb.tipo_bene = 'DEVICE' and d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)') ";
7997
+ query += "when cb.tipo_bene = 'DEVICE' and d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)') ";
7998
+ //
7999
+ query += "when cb.tipo_bene = 'SOFTWARE' and s.inv_ict3_number != '' and s.inv_ict3_number is not null then s.inv_ict3_number ";
8000
+ query += "when cb.tipo_bene = 'SOFTWARE' and s.serial_no != '' and s.serial_no is not null then concat(s.serial_no,'(S/N)') ";
8001
+ //
8002
+ // Temporaneamente non considerato
8003
+ //query += "when cd.tipo_bene = 'BENE_CONSUMO' and d.inv_ict3_number != '' and d.inv_ict3_number is not null then d.inv_ict3_number ";
8004
+ //query += "when cd.tipo_bene = 'BENE_CONSUMO' and d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)') ";
8005
+ //
8006
+ //query += "when cd.tipo_bene = 'SOFTWARE' and d.inv_ict3_number != '' and d.inv_ict3_number is not null then d.inv_ict3_number ";
8007
+ //query += "when cd.tipo_bene = 'SOFTWARE' and d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)') ";
8008
+ //
7929
8009
  query += "end as Codice, ";
7930
8010
  query += "case ";
7931
8011
  query += "when cb.tipo_bene = 'DEVICE' and d.inv_pnrr_number is not null and trim(d.inv_pnrr_number) <> '' then 'SI' ";
7932
8012
  query += "when cb.tipo_bene = 'SOFTWARE' and s.is_pnrr is not null and s.is_pnrr = 0 then 'SI' ";
7933
8013
  query += "else 'NO' ";
7934
- query += "end as PNRR, dc.note as Note_cons ";
7935
- query += " from devices d";
7936
- query += " left join device_consegne dc on dc.id_device = d.id";
8014
+ query += "end as PNRR, ";
8015
+
8016
+ query += "case ";
8017
+ query += "when cb.stato_restituzione = 0 then 'Prestito in corso' ";
8018
+ query += "when cb.stato_restituzione = 1 then 'Non restituito' ";
8019
+ query += "when cb.stato_restituzione = 2 then 'Restituito' ";
8020
+ query += "when cb.stato_restituzione = 3 then 'Danneggiato' ";
8021
+ query += "when cb.stato_restituzione = 4 then 'Parti mancanti' ";
8022
+ query += "else '' ";
8023
+ query += "end as Stato, ";
8024
+
8025
+ query += "cb.note_consegna as Note_cons ";
8026
+ query += "from consegna_beni cb ";
8027
+ query += "left join devices d on cb.id_bene = d.id ";
8028
+ query += "left join softwares s on cb.id_bene = s.id ";
8029
+ query += "left join beniconsumo bc on cb.id_bene = bc.id ";
8030
+ query += "left join altri_beni a on cb.id_bene = a.id ";
8031
+ query += "left join altro_tipi atd on a.id_type = atd.id ";
7937
8032
  query += " where dc.id_consegna = :id_consegna";
8033
+ if (solo_prestito_attivo) {
8034
+ query += " and cb.stato_restituzione = 0 ";
8035
+ }
7938
8036
  return query;
7939
8037
  }
7940
- function selectBeniPerConsegna(db_used, id_consegna) {
8038
+ function selectBeniPerConsegna(db_used, id_consegna, solo_prestito_attivo) {
7941
8039
  var query = "";
7942
8040
  if (db_used) {
7943
8041
  switch (db_used) {
7944
8042
  case 'SQLITE':
7945
- query = selectBeniPerConsegnaSQLite(id_consegna);
8043
+ query = selectBeniPerConsegnaSQLite(id_consegna, solo_prestito_attivo);
7946
8044
  break;
7947
8045
  case 'MYSQL':
7948
- query = selectBeniPerConsegnaMySQL(id_consegna);
8046
+ query = selectBeniPerConsegnaMySQL(id_consegna, solo_prestito_attivo);
7949
8047
  break;
7950
8048
  case 'MYSQL2':
7951
- query = selectBeniPerConsegnaSQLite(id_consegna);
8049
+ query = selectBeniPerConsegnaSQLite(id_consegna, solo_prestito_attivo);
7952
8050
  break;
7953
8051
  }
7954
8052
  }
@@ -14268,6 +14366,8 @@ module.exports = {
14268
14366
  queryConsegnaById,
14269
14367
  getDatiConsegneAttive,
14270
14368
  createConsegnaMessage,
14369
+ getInviiEmailConsegna,
14370
+ insertInvioEmailConsegna,
14271
14371
  createConsegnaMySQLObj,
14272
14372
  insertConsegna,
14273
14373
  updateConsegna,
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.54",
7
+ "version": "3.0.56",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",