alsmanager_lib 1.0.99 → 1.0.100

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.
@@ -0,0 +1,97 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <script>
5
+ function getReturnDate() {
6
+ document.currentScript.parentNode.textContent = "15 giugno 2025";
7
+ }
8
+
9
+ const items1 = [
10
+ { num: "1", name: "PC Notebook" },
11
+ { num: "1", name: "Tablet" },
12
+ ];
13
+ const items2 = [
14
+ { num: "2", name: "USB Stick" },
15
+ { num: "1", name: "Modem" },
16
+ ];
17
+ function loadTableData(items) {
18
+ const table = document.getElementById("tabellaDevice");
19
+ items.forEach( item => {
20
+ let row = table.insertRow();
21
+ let num = row.insertCell(0);
22
+ num.innerHTML = item.num;
23
+ let name = row.insertCell(1);
24
+ name.innerHTML = item.name;
25
+ });
26
+ }
27
+ </script>
28
+
29
+ <title>Modulo consegna</title>
30
+ <style>
31
+ /*
32
+ body { font: 76%/150% Arial, sans-serif; }
33
+ body { font: 76%/1.5em Arial, sans-serif; }
34
+ */
35
+ body { font: 90%/1.5 Arial, sans-serif; }
36
+ h4:after {
37
+ content: "";
38
+ display: inline-block;
39
+ height: 0.5em;
40
+ vertical-align: bottom;
41
+ width: 20%;
42
+ margin-right: 100%;
43
+ margin-left: 700px;
44
+ border-top: 1px solid black;
45
+ }
46
+ table, th, td {
47
+ border:1px solid black;
48
+ }
49
+ </style>
50
+ </head>
51
+ <body>
52
+
53
+ <h3 style="text-align: center">Istituto Comprensivo di Scuola Primaria e Secondaria Trento 3</h4>
54
+ <p style="text-align: center">Via Vittorio Veneto, 61 - 38122 Trento - Tel. 0461/934977 </p>
55
+ <p style="text-align: center">www.ictrento3.it - mail: segr.ic.tn3@scuole.provincia.tn.it</p>
56
+ <p style="text-align: center">Pec: ic.trento3@pec.provincia.tn.it - Cod.Fisc. 800 1317 0222</p>
57
+ <br>
58
+ <br>
59
+ <br>
60
+ <p style="margin-left: 700px">Trento</p>
61
+ <p style="margin-left: 700px">CONSEGNATO A:</p>
62
+ <h4 style="text-align: right"></h4>
63
+ <br>
64
+ <p style="margin-left: 700px">Scuola:</p>
65
+ <h4 style="text-align: right"></h4>
66
+ <br>
67
+ <h3 style="text-align: left">Oggetto: Consegna</h3>
68
+ <p style="text-align: left">Si consegna il seguente materiale :</p>
69
+ <table style="width:900px;table-layout: fixed;">
70
+ <thead>
71
+ <tr>
72
+ <th style="width:10%;">Quantità</th><th style="width:90%;">Descrizione</th>
73
+ </tr>
74
+ </thead>
75
+ <tbody id="tabellaDevice"></tbody>
76
+ <script>
77
+ loadTableData(items1);
78
+ loadTableData(items2);
79
+ loadTableData([]);
80
+ </script>
81
+ </table>
82
+
83
+ <br>
84
+ <div>
85
+ <ul>
86
+ <li>Il materiale deve essere riconsegnato entro il <label><script>getReturnDate()</script></label> salvo diversa indicazione, e mantenuto con cura e rispetto</li>
87
+ <li>Tutti i dati sul dispositivo, alla riconsegna, saranno cancellati.</li>
88
+ <li>Scatola/borsa, cavi, alimentatore e tutto quanto consegnato, devono essere restituiti integri e funzionanti.</li>
89
+ </ul>
90
+ </div>
91
+ <br>
92
+ <p style="text-align: left">Per ricezione:</p>
93
+ <p style="text-align: left">Data: </p>
94
+ <br>
95
+ <p style="text-align: left">Firma: </p>
96
+ </body>
97
+ </html>
package/lib/modules.js CHANGED
@@ -3146,7 +3146,22 @@ function getDevicesWithPropertiesSQLite(id_device) {
3146
3146
  return query;
3147
3147
  }
3148
3148
  function getDevicesWithPropertiesMySQL(id_device) {
3149
-
3149
+ var query = "select ";
3150
+ query += "case ";
3151
+ query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then d.inv_ict3_number ";
3152
+ query += "when d.inv_pnrr_number != '' and d.inv_pnrr_number is not null then d.inv_pnrr_number ";
3153
+ query += "when d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number,'(TN)') ";
3154
+ query += "when d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)') ";
3155
+ query += "when d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)') ";
3156
+ query += "end as Codice, ";
3157
+ query += "d.manifacturer as Marca, d.model as Modello, d.id as Id from devices d ";
3158
+ query += "left join device_properties dp on d.id = dp.id_device ";
3159
+ query += "where dp.id_device is not null ";
3160
+ if (id_device > 0) {
3161
+ query += "and d.id = :id_device ";
3162
+ }
3163
+ query += "order by d.id";
3164
+ return query;
3150
3165
  }
3151
3166
  function getDevicesWithProperties(db_used, id_device) {
3152
3167
  var query = "";
@@ -3953,7 +3968,57 @@ function insertDeviceSiteFromInventarioSQLite(table_name, data_in, id_place, id_
3953
3968
  return insert_sql + query;
3954
3969
  }
3955
3970
  function insertDeviceSiteFromInventarioMySQL() {
3971
+ var query = "";
3972
+ var insert_sql = "";
3973
+ if (table_name && id_site > 0 && id_place != '' && lista_inv.length > 0) {
3974
+ insert_sql = "insert into device_site (id_device, id_place, id_site, date_in, date_out) "
3975
+ var dp_str = "2024-09-01";
3976
+ var dp = data_in;
3977
+ if (dp) {
3978
+ var d = new Date(dp);
3979
+ dp_str = d.getFullYear() + "-" + String((d.getMonth() + 1)).padStart(2, '0') + "-" + String(d.getDate()).padStart(2, '0');
3980
+ }
3981
+
3982
+ if (inv_info.tabella == "ImportRevisione2024") {
3983
+ query = "Select ";
3984
+ query += "d.id, ";
3985
+ query += ":id_place, ";
3986
+ query += ":id_site, ";
3987
+ query += "'" + dp_str + "', ";
3988
+ query += "'2999-12-31' ";
3989
+ query += "from :table_name imp ";
3990
+ query += "join devices d on d.inv_ict3_number = trim(imp.inv_ict3) ";
3991
+ query += "left join device_site ds on d.id = ds.id_device ";
3992
+ query += "where ds.id_device is null ";
3993
+
3994
+ }
3995
+ else {
3996
+ query = "Select ";
3997
+ query += "d.id, ";
3998
+ query += ":id_place, ";
3999
+ query += ":id_site, ";
4000
+ query += "'" + dp_str + "', ";
4001
+ query += "'2999-12-31' ";
4002
+ query += "from :table_name imp ";
4003
+ query += "join devices d on d.inv_ict3_number = trim(imp.inv_ict3) ";
4004
+ query += "left join device_site ds on d.id = ds.id_device ";
4005
+ query += "where ds.id_device is null ";
4006
+ }
4007
+ if (lista_inv && lista_inv.length > 0) {
4008
+ var list_clause = "and imp.inv_ict3 in (";
4009
+ for (let i = 0; i < lista_inv.length; i++) {
4010
+ list_clause += "'" + lista_inv[i] + "'";
4011
+ if (i < lista_inv.length - 1) {
4012
+ list_clause += ", ";
4013
+ }
4014
+ }
4015
+ list_clause += ") ";
4016
+ query += list_clause;
4017
+ }
4018
+ query += "group by imp.inv_ict3";
4019
+ }
3956
4020
 
4021
+ return insert_sql + query;
3957
4022
  }
3958
4023
  function insertDeviceSiteFromInventario(db_used, table_name, data_in, id_place, id_site, lista_inv) {
3959
4024
  var query = "";
@@ -4826,9 +4891,6 @@ function queryInsertGestioneDevice(db_used, id_device, id_gestore) {
4826
4891
  return query;
4827
4892
  }
4828
4893
 
4829
- function querySelectExistsGestioneDeviceByIdsMySQL(id_device, id_gestione, date_ref) {
4830
-
4831
- }
4832
4894
 
4833
4895
  function querySelectExistsGestioneDeviceByIdsSQLite(id_device, id_gestione, date_ref) {
4834
4896
  var query = "select count(*) from device_gestioni "
@@ -4837,6 +4899,13 @@ function querySelectExistsGestioneDeviceByIdsSQLite(id_device, id_gestione, date
4837
4899
  return query;
4838
4900
  }
4839
4901
 
4902
+ function querySelectExistsGestioneDeviceByIdsMySQL(id_device, id_gestione, date_ref) {
4903
+ var query = "select count(*) from device_gestioni "
4904
+ query += "where id_device = :id_device and ";
4905
+ query += "id_gestione = :id_gestione";
4906
+ return query;
4907
+ }
4908
+
4840
4909
 
4841
4910
  function querySelectExistsGestioneDeviceByIds(db_used,id_device, id_gestione) {
4842
4911
  var query = "";
@@ -5235,7 +5304,17 @@ function updateInterventoSQLite(id_intervento, data_inizio, data_fine, richieden
5235
5304
  return query;
5236
5305
  }
5237
5306
  function updateInterventoMySQL(id_intervento, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione) {
5238
-
5307
+ var query = "update interventi set ";
5308
+ query += "data_inizio = '" + data_inizio.trim() + "', ";
5309
+ query += "data_fine = '" + data_fine.trim() + "', ";
5310
+ query += "request_by = '" + richiedente.trim() + "', ";
5311
+ query += "executed_by = '" + esecutore.trim() + "', ";
5312
+ query += "id_executor = " + id_esecutore + ", ";
5313
+ query += "executor_type = " + tipo_esecutore + ", ";
5314
+ query += "tipo_risoluzione = " + tipo_risoluzione + ", ";
5315
+ query += "description = '" + descrizione.trim() + "' ";
5316
+ query += "where id = " + id_intervento;
5317
+ return query;
5239
5318
  }
5240
5319
  function updateIntervento(db_used, id_intervento, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione) {
5241
5320
  var query = "";
@@ -7247,7 +7326,9 @@ function getConnectionSetByIdSQLite(id_conn_set) {
7247
7326
  return query;
7248
7327
  }
7249
7328
  function getConnectionSetByIdMySQL(id_conn_set) {
7250
-
7329
+ var query = "select id, id_set, id_conn, id_adapter, verse from set_connections ";
7330
+ query += "where id = :id_conn_set";
7331
+ return query;
7251
7332
  }
7252
7333
  function getConnectionSetById(db_used, id_conn_set) {
7253
7334
  var query = "";
@@ -7327,7 +7408,21 @@ function updateConnectionSetSQLite(id_set, id_conn_set, id_conn, verse, id_adapt
7327
7408
  return query;
7328
7409
  }
7329
7410
  function updateConnectionSetMySQL(id_set, id_conn_set, id_conn, verse, id_adapter) {
7330
-
7411
+ var query = "update set_connections set ";
7412
+ if (id_set && id_set > 0) {
7413
+ query += "id_set = :id_set, ";
7414
+ }
7415
+ if (id_conn && id_conn > 0) {
7416
+ query += "id_conn = :id_conn, ";
7417
+ }
7418
+ if (id_adapter && id_adapter > 0) {
7419
+ query += "id_adapter = :id_adapter, ";
7420
+ }
7421
+ if (verse) {
7422
+ query += "verse = :verse ";
7423
+ }
7424
+ query += "where id = :id_conn_set";
7425
+ return query;
7331
7426
  }
7332
7427
  function updateConnectionSet(db_used, id_set, id_conn_set, id_conn, verse, id_adapter) {
7333
7428
  var query = "";
@@ -7354,7 +7449,12 @@ function insertConnectionSetSQLite(id_set, id_conn, verse, id_adapter) {
7354
7449
  return query;
7355
7450
  }
7356
7451
  function insertConnectionSetMySQL(id_set, id_conn, verse, id_adapter) {
7357
-
7452
+ var query = "insert into set_connections (id_set, id_conn, id_adapter, verse) values ";
7453
+ query += "(:id_set, ";
7454
+ query += ":id_conn, ";
7455
+ query += ":id_adapter, ";
7456
+ query += ":verse)";
7457
+ return query;
7358
7458
  }
7359
7459
  function insertConnectionSet(db_used, id_set, id_conn, verse, id_adapter) {
7360
7460
  var query = "";
@@ -7379,7 +7479,10 @@ function removeConnectionSetSQLite(id_set, id_conn_set) {
7379
7479
  return query;
7380
7480
  }
7381
7481
  function removeConnectionSetMySQL(id_set, id_conn_set, id_conn, id_adapter, verse) {
7382
-
7482
+ var query = "delete from set_connections ";
7483
+ query += "where id = :id_conn_set ";
7484
+ query += "and id_set = :id_set";
7485
+ return query;
7383
7486
  }
7384
7487
  function removeConnectionSet(db_used, id_set, id_conn_set) {
7385
7488
  var query = "";
@@ -7435,10 +7538,10 @@ function getBeneConsumoUsato(db_used, id_device, id_bene) {
7435
7538
  if (db_used) {
7436
7539
  switch (db_used) {
7437
7540
  case 'SQLITE':
7438
- query = removeConnectionSetSQLite(id_device, id_bene);
7541
+ query = getBeneConsumoUsatoSQLite(id_device, id_bene);
7439
7542
  break;
7440
7543
  case 'MYSQL':
7441
- query = removeConnectionSetMySQL(id_device, id_bene);
7544
+ query = getBeneConsumoUsatoMySQL(id_device, id_bene);
7442
7545
  break;
7443
7546
  }
7444
7547
  }
@@ -8197,7 +8300,7 @@ function removeSiteBySet(db_used, id_device) {
8197
8300
  query = removeSiteBySetSQLite(id_device);
8198
8301
  break;
8199
8302
  case 'MYSQL':
8200
- query = emoveSiteBySetMySQL(id_device);
8303
+ query = removeSiteBySetMySQL(id_device);
8201
8304
  break;
8202
8305
  }
8203
8306
  }
@@ -8884,6 +8987,145 @@ function getPackageJsVersion() {
8884
8987
  return pjson.version;
8885
8988
  }
8886
8989
 
8990
+ function createConsegnaDoc(consegna_obj, scuola_obj, listaDispositivi) {
8991
+ // see http://pdfmake.org/playground.html
8992
+
8993
+ var d = new Date();
8994
+ var data_consegna_str = "";
8995
+ var curr_year = d.getFullYear();
8996
+ if (d.getMonth() > 5) {
8997
+ curr_year++;
8998
+ }
8999
+ data_consegna_str = "10/06/" + curr_year;
9000
+ var data_corr_str = ("0" + d.getDate()).slice(-2) + '/' + ("0"+(d.getMonth()+1)).slice(-2) + '/' + d.getFullYear();
9001
+ var consegnatoA_str = "";
9002
+ if (consegna_obj.ric_adulto && consegna_obj.ric_adulto != '') {
9003
+ consegnatoA_str = consegna_obj.ric_adulto;
9004
+ }
9005
+ if (consegna_obj.ric_alunno && consegna_obj.ric_alunno != '') {
9006
+ consegnatoA_str += '\nAlunno : ' + consegna_obj.ric_alunno;
9007
+ }
9008
+ if (consegna_obj.ric_genitore && consegna_obj.ric_genitore != '') {
9009
+ consegnatoA_str += '\nGenitore : ' + consegna_obj.ric_genitore;
9010
+ }
9011
+ var uso_casa_str = "";
9012
+ if (consegna_obj.uso_casa && consegna_obj.uso_casa == 1) {
9013
+ uso_casa_str = "(UTILIZZO A CASA)";
9014
+ }
9015
+ //
9016
+ var scuola_str = "";
9017
+ if (scuola_obj && scuola_obj != null) {
9018
+ scuola_str = scuola_obj.name;
9019
+ if (scuola_obj.classe && scuola_obj.classe != '') {
9020
+ scuola_str += " - Classe : " + scuola_obj.classe;
9021
+ }
9022
+ }
9023
+
9024
+ // Build table...
9025
+ var tabObj = {
9026
+ table: {
9027
+ widths: [100, 400],
9028
+ body: [
9029
+ [{text: 'Quantità', bold: true}, {text: 'Descrizione', bold: true}],
9030
+ ]
9031
+ }
9032
+ };
9033
+ // Tabella dispositivi
9034
+ let j = 1;
9035
+ for (let i = 0; i < listaDispositivi.length; i++) {
9036
+ const element = array[index];
9037
+ tabObj.table.body[j++] = [{text: listaDispositivi.num, bold: false}, {text: listaDispositivi.descrizione, bold: false}];
9038
+ }
9039
+
9040
+ var dd = {
9041
+
9042
+ content: [
9043
+ {
9044
+ text: 'Istituto Comprensivo di Scuola Primaria e Secondaria Trento 3',
9045
+ style: 'header',
9046
+ alignment: 'center'
9047
+ },
9048
+ {
9049
+ text: [
9050
+ 'Via V ittorio Veneto, 61 - 38122 Trento - Tel. 0461/934977\n',
9051
+ 'www.ictrento3.it - mail: segr.ic.tn3@scuole.provincia.tn.it\n',
9052
+ 'Pec: ic.trento3@pec.provincia.tn.it - Cod.Fisc. 800 1317 0222.\n\n\n\n'
9053
+ ],
9054
+ style: 'header',
9055
+ alignment: 'center',
9056
+ bold: false
9057
+ },
9058
+ {
9059
+ alignment: 'justify',
9060
+ columns: [
9061
+ {
9062
+ },
9063
+ {
9064
+ text: [
9065
+ 'Trento, ' + data_corr_str + '\n\n',
9066
+ 'CONSEGNATO A:\n' + consegnatoA_str + '\n\n',
9067
+ 'Scuola:\n' + scuola_str + '\n\n'
9068
+ ],
9069
+ style: 'header',
9070
+ alignment: 'left',
9071
+ bold: false
9072
+ }
9073
+ ]
9074
+ },
9075
+ {
9076
+ text: [
9077
+ {text: '\n\n\nOggetto : ', bold: true},
9078
+ {text: 'Consegna _____________________________ ', bold: false},
9079
+ {text: uso_Casa_str, bold: true},
9080
+ {text: '\n\n', bold: false}
9081
+ ]
9082
+ },
9083
+ {
9084
+ text: 'Si consegna il seguente materiale:\n ',
9085
+ style: 'header',
9086
+ bold: false
9087
+ },
9088
+ {
9089
+ style: 'tableStyle',
9090
+ table: tabObj.table
9091
+ },
9092
+ '\n\n',
9093
+ {
9094
+ ul: [
9095
+ 'Il materiale deve essere riconsegnato entro il ' + data_consegna_str + ',salvo diversa indicazione, e mantenuto con cura e rispetto',
9096
+ 'Tutti i dati sul dispositivo, alla riconsegna, saranno cancellati.',
9097
+ 'Scatola/borsa, cavi, alimentatore e tutto quanto consegnato, devono essere restituiti integri e funzionanti.'
9098
+ ]
9099
+ },
9100
+ {
9101
+ text: [
9102
+ {text: '\n\nPer ricezione: \n\n', bold: true},
9103
+ {text: 'Data: ' + data_corr_str + '\n\n', bold: false},
9104
+ {text: 'Firma:__________________', bold: false}
9105
+ ]
9106
+ }
9107
+ ],
9108
+ styles: {
9109
+ header: {
9110
+ fontSize: 12,
9111
+ bold: true,
9112
+ alignment: 'justify'
9113
+ },
9114
+ tableStyle: {
9115
+ margin: [0, 5, 0, 15]
9116
+ }
9117
+ },
9118
+ defaultStyle: {
9119
+ columnGap: 90
9120
+ }
9121
+ }
9122
+ //dd.content[0][2].text[0] = "Trento, " + new Date();
9123
+
9124
+ return dd;
9125
+ }
9126
+
9127
+
9128
+
8887
9129
  // Export DB
8888
9130
 
8889
9131
  function exportDBSQLSQLite(db_path, dump_path, dump_filename) {
@@ -9204,6 +9446,7 @@ module.exports = {
9204
9446
  getDatiAcquistoDevice,
9205
9447
  //
9206
9448
  getPackageJsVersion,
9449
+ createConsegnaDoc,
9207
9450
  exportDBSQL
9208
9451
  };
9209
9452
  // end of source
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alsmanager_lib",
3
- "version": "1.0.99",
3
+ "version": "1.0.100",
4
4
  "description": "Funzioni per ALSManager",
5
5
  "license": "ISC",
6
6
  "author": "Luca Cattani",