alsmanager_lib 3.0.55 → 3.0.57

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 +108 -42
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -6883,7 +6883,7 @@ function queryConsegnaById(db_used,id_consegna) {
6883
6883
 
6884
6884
  //Creazione email sollecito consegna
6885
6885
  function getDatiConsegneAttive() {
6886
- var query = "select 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, ";
6886
+ 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, ";
6887
6887
  query += "case ";
6888
6888
  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) ";
6889
6889
  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) ";
@@ -6900,13 +6900,15 @@ 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";
@@ -7002,34 +7004,32 @@ function queryConsegneByIdDevice(db_used, id_device) {
7002
7004
 
7003
7005
  //
7004
7006
  function queryConsegneByIdBeneSQLite(id_bene, tipo_bene) {
7005
- var query = "select c.data_consegna as Consegna, ";
7007
+ var query = "select cb.data_consegna as Consegna, ";
7006
7008
  query += "case ";
7007
- query += "when c.stato_restituzione = 0 then 'Prestito in corso' ";
7008
- query += "when c.stato_restituzione = 1 then 'Non restituito' ";
7009
- query += "when c.stato_restituzione = 2 then 'Restituito' ";
7010
- query += "when c.stato_restituzione = 3 then 'Danneggiato' ";
7011
- 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' ";
7012
7014
  query += "else '' ";
7013
7015
  query += "end as Stato, ";
7014
- query += "c.note as Note from consegna beni ";
7015
- query += "inner join consegne c on c.id = dc.id_consegna ";
7016
+ query += "cb.note as Note from consegna beni cb";
7016
7017
  query += "where cb.id_bene = " + id_bene + " ";
7017
7018
  query += "and cb.tipo_bene = '" + tipo_bene + "' ";
7018
7019
  return query;
7019
7020
  }
7020
7021
 
7021
7022
  function queryConsegneByIdBeneMySQL(id_bene, tipo_bene) {
7022
- var query = "select c.data_consegna as Consegna, ";
7023
+ var query = "select cb.data_consegna as Consegna, ";
7023
7024
  query += "case ";
7024
- query += "when c.stato_restituzione = 0 then 'Prestito in corso' ";
7025
- query += "when c.stato_restituzione = 1 then 'Non restituito' ";
7026
- query += "when c.stato_restituzione = 2 then 'Restituito' ";
7027
- query += "when c.stato_restituzione = 3 then 'Danneggiato' ";
7028
- 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' ";
7029
7030
  query += "else '' ";
7030
7031
  query += "end as Stato, ";
7031
- query += "c.note as Note from consegna_beni cb ";
7032
- query += "inner join consegne c on c.id = cb.id_consegna ";
7032
+ query += "cb.note as Note from consegna_beni cb ";
7033
7033
  query += "where cb.id_bene = :id_bene and cb.tipo_bene = :tipo_bene";
7034
7034
  return query;
7035
7035
  }
@@ -7825,19 +7825,20 @@ function insertConsegnaBene(db_used, id_consegna, id_bene, tipo_bene, data_conse
7825
7825
  return query;
7826
7826
  }
7827
7827
 
7828
- 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){
7829
7829
  var query = "update consegna_beni set ";
7830
7830
  query += "id_consegna = " + id_consegna + ", ";
7831
7831
  query += "id_bene = " + id_bene + ", ";
7832
7832
  query += "tipo_bene = '" + tipo_bene + "', ";
7833
7833
  query += "data_consegna = '" + data_consegna + "', ";
7834
7834
  query += "numero = " + numero + ", ";
7835
- query += "note = '" + note + "' ";
7835
+ query += "note = '" + note + "', ";
7836
+ query += "stato_restituzione = " + stato_restituzione + " ";
7836
7837
  query += "where id = " + id_benecons;
7837
7838
  return query;
7838
7839
  }
7839
7840
 
7840
- 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){
7841
7842
  var query = "update consegna_beni set ";
7842
7843
  query += "id_consegna = :id_consegna, ";
7843
7844
  query += "id_bene = :id_bene, ";
@@ -7845,22 +7846,23 @@ function updateConsegnaBeneMySQL(id_benecons, id_consegna, id_bene, tipo_bene, d
7845
7846
  query += "data_consegna = :data_consegna, ";
7846
7847
  query += "numero = :numero, ";
7847
7848
  query += "note = :note ";
7849
+ query += "stato_restituzione = :stato_restituzione ";
7848
7850
  query += "where id = :id_benecons";
7849
7851
  return query;
7850
7852
  }
7851
7853
 
7852
- 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) {
7853
7855
  var query = "";
7854
7856
  if (db_used) {
7855
7857
  switch (db_used) {
7856
7858
  case 'SQLITE':
7857
- 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);
7858
7860
  break;
7859
7861
  case 'MYSQL':
7860
- 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);
7861
7863
  break;
7862
7864
  case 'MYSQL2':
7863
- 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);
7864
7866
  break;
7865
7867
  }
7866
7868
  }
@@ -7894,7 +7896,7 @@ function removeConsegnaBene(db_used, id_benecons) {
7894
7896
  }
7895
7897
  return query;
7896
7898
  }
7897
- function selectBeniPerConsegnaSQLite(id_consegna) {
7899
+ function selectBeniPerConsegnaSQLite(id_consegna, solo_prestito_attivo) {
7898
7900
  var query = "select cb.id, cb.id_bene, cb.numero as Numero, cb.tipo_bene as Tipologia, ";
7899
7901
  query += "case ";
7900
7902
  query += "when cb.tipo_bene = 'DEVICE' then d.type ";
@@ -7939,7 +7941,18 @@ function selectBeniPerConsegnaSQLite(id_consegna) {
7939
7941
  query += "when cb.tipo_bene = 'DEVICE' and d.inv_pnrr_number is not null and trim(d.inv_pnrr_number) <> '' then 'SI' ";
7940
7942
  query += "when cb.tipo_bene = 'SOFTWARE' and s.is_pnrr is not null and s.is_pnrr = 0 then 'SI' ";
7941
7943
  query += "else 'NO' ";
7942
- 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 ";
7943
7956
  query += "from consegna_beni cb ";
7944
7957
  query += "left join devices d on cb.id_bene = d.id ";
7945
7958
  query += "left join softwares s on cb.id_bene = s.id ";
@@ -7947,40 +7960,93 @@ function selectBeniPerConsegnaSQLite(id_consegna) {
7947
7960
  query += "left join altri_beni a on cb.id_bene = a.id ";
7948
7961
  query += "left join altro_tipi atd on a.id_type = atd.id ";
7949
7962
  query += "where cb.id_consegna = " + id_consegna;
7963
+ if (solo_prestito_attivo) {
7964
+ query += " and cb.stato_restituzione = 0 ";
7965
+ }
7950
7966
  return query;
7951
7967
  }
7952
7968
 
7953
- function selectBeniPerConsegnaMySQL(id_consegna) {
7954
- 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, ";
7955
7971
  query += "case ";
7956
- query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then d.inv_ict3_number ";
7957
- query += "when d.inv_pnrr_number != '' and d.inv_pnrr_number is not null then d.inv_pnrr_number ";
7958
- query += "when d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number,'(TN)') ";
7959
- query += "when d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)') ";
7960
- 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
+ //
7961
8009
  query += "end as Codice, ";
7962
8010
  query += "case ";
7963
8011
  query += "when cb.tipo_bene = 'DEVICE' and d.inv_pnrr_number is not null and trim(d.inv_pnrr_number) <> '' then 'SI' ";
7964
8012
  query += "when cb.tipo_bene = 'SOFTWARE' and s.is_pnrr is not null and s.is_pnrr = 0 then 'SI' ";
7965
8013
  query += "else 'NO' ";
7966
- query += "end as PNRR, dc.note as Note_cons ";
7967
- query += " from devices d";
7968
- 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 ";
7969
8032
  query += " where dc.id_consegna = :id_consegna";
8033
+ if (solo_prestito_attivo) {
8034
+ query += " and cb.stato_restituzione = 0 ";
8035
+ }
7970
8036
  return query;
7971
8037
  }
7972
- function selectBeniPerConsegna(db_used, id_consegna) {
8038
+ function selectBeniPerConsegna(db_used, id_consegna, solo_prestito_attivo) {
7973
8039
  var query = "";
7974
8040
  if (db_used) {
7975
8041
  switch (db_used) {
7976
8042
  case 'SQLITE':
7977
- query = selectBeniPerConsegnaSQLite(id_consegna);
8043
+ query = selectBeniPerConsegnaSQLite(id_consegna, solo_prestito_attivo);
7978
8044
  break;
7979
8045
  case 'MYSQL':
7980
- query = selectBeniPerConsegnaMySQL(id_consegna);
8046
+ query = selectBeniPerConsegnaMySQL(id_consegna, solo_prestito_attivo);
7981
8047
  break;
7982
8048
  case 'MYSQL2':
7983
- query = selectBeniPerConsegnaSQLite(id_consegna);
8049
+ query = selectBeniPerConsegnaSQLite(id_consegna, solo_prestito_attivo);
7984
8050
  break;
7985
8051
  }
7986
8052
  }
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.55",
7
+ "version": "3.0.57",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",