alsmanager_lib 3.0.215 → 3.0.217

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 +118 -26
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -10111,7 +10111,7 @@ function getSoftwaresNotAllocatedComboSQLite() {
10111
10111
  query += "when s.serial_no != '' and s.serial_no is not null then concat(s.serial_no,'(S/N)', ' - ', s.platform, ' - ', s.maker, ' - ', s.model) ";
10112
10112
  query += "else '' "
10113
10113
  query += "end as Descrizione ";
10114
- query += "from Softwares s ";
10114
+ query += "from softwares s ";
10115
10115
  query += "left join consegna_beni cb on s.id = cb.id_bene "
10116
10116
  query += "where (s.is_removed is null or s.is_removed = 0) "
10117
10117
  query += "and (cb.id is null or (cb.tipo_bene = 'SOFTWARE' and cb.stato_restituzione = 2)) ";
@@ -10126,7 +10126,7 @@ function getSoftwaresNotAllocatedComboMySQL() {
10126
10126
  query += "when s.serial_no != '' and s.serial_no is not null then concat(s.serial_no,'(S/N)', ' - ', s.platform, ' - ', s.maker, ' - ', s.model) ";
10127
10127
  query += "else '' "
10128
10128
  query += "end as Descrizione ";
10129
- query += "from Softwares s ";
10129
+ query += "from softwares s ";
10130
10130
  query += "left join consegna_beni cb on s.id = cb.id_bene "
10131
10131
  query += "where (s.is_removed is null or s.is_removed = 0) "
10132
10132
  query += "and (cb.id is null or (cb.tipo_bene = 'SOFTWARE' and cb.stato_restituzione = 2)) ";
@@ -10141,7 +10141,7 @@ function getSoftwaresNotAllocatedComboMySQL2() {
10141
10141
  query += "when s.serial_no != '' and s.serial_no is not null then concat(s.serial_no,'(S/N)', ' - ', s.platform, ' - ', s.maker, ' - ', s.model) ";
10142
10142
  query += "else '' "
10143
10143
  query += "end as Descrizione ";
10144
- query += "from Softwares s ";
10144
+ query += "from softwares s ";
10145
10145
  query += "left join consegna_beni cb on s.id = cb.id_bene "
10146
10146
  query += "where (s.is_removed is null or s.is_removed = 0) "
10147
10147
  query += "and (cb.id is null or (cb.tipo_bene = 'SOFTWARE' and cb.stato_restituzione = 2)) ";
@@ -12064,12 +12064,12 @@ function queryHiddenGroupByType(db_used,dev_type) {
12064
12064
  //End Get hidden groups by id
12065
12065
  // Define getConnectionSetById
12066
12066
  function getConnectionSetByIdSQLite(id_conn_set) {
12067
- var query = "select id, id_set, id_conn, id_adapter, verse from set_connections ";
12067
+ var query = "select id, id_set, id_conn, id_adapter, verse, lunghezza_cm, in_canaletta from set_connections ";
12068
12068
  query += "where id = " + id_conn_set;
12069
12069
  return query;
12070
12070
  }
12071
12071
  function getConnectionSetByIdMySQL(id_conn_set) {
12072
- var query = "select id, id_set, id_conn, id_adapter, verse from set_connections ";
12072
+ var query = "select id, id_set, id_conn, id_adapter, verse, lunghezza_cm, in_canaletta from set_connections ";
12073
12073
  query += "where id = :id_conn_set";
12074
12074
  return query;
12075
12075
  }
@@ -12099,7 +12099,12 @@ function getConnectionByIdSetSQLite(id_set) {
12099
12099
  query += "when sc.id_adapter is not null and sc.id_adapter > 0 then concat(ac1.conn_type, ' -> ', ac2.conn_type) ";
12100
12100
  query += "else '' ";
12101
12101
  query += "end as Adattatore, ";
12102
- query += "sc.verse as Verso from set_connections sc ";
12102
+ query += "sc.verse as Verso, sc.lunghezza_cm as Lunghezza, ";
12103
+ query += "case ";
12104
+ query += "when sc.in_canaletta is not null and sc.in_canaletta > 0 then 'SI' ";
12105
+ query += "else 'NO' ";
12106
+ query += "end as Incanalato ";
12107
+ query += "from set_connections sc ";
12103
12108
  query += "join connection_types ct on ct.id = sc.id_conn ";
12104
12109
  query += "left join adapter_types at on sc.id_adapter = at.id ";
12105
12110
  query += "left join connection_types ac1 on at.adapt_type_in = ac1.id ";
@@ -12113,7 +12118,12 @@ function getConnectionByIdSetMySQL(id_set) {
12113
12118
  query += "when sc.id_adapter is not null and sc.id_adapter > 0 then concat(ac1.conn_type, ' -> ', ac2.conn_type) ";
12114
12119
  query += "else '' ";
12115
12120
  query += "end as Adattatore, ";
12116
- query += "sc.verse as Verso from set_connections sc ";
12121
+ query += "sc.verse as Verso, sc.lunghezza_cm as Lunghezza, ";
12122
+ query += "case ";
12123
+ query += "when sc.in_canaletta is not null and sc.in_canaletta > 0 then 'SI' ";
12124
+ query += "else 'NO' ";
12125
+ query += "end as Incanalato ";
12126
+ query += "from set_connections sc ";
12117
12127
  query += "join connection_types ct on ct.id = sc.id_conn ";
12118
12128
  query += "left join adapter_types at on sc.id_adapter = at.id ";
12119
12129
  query += "left join connection_types ac1 on at.adapt_type_in = ac1.id ";
@@ -12139,24 +12149,30 @@ function getConnectionByIdSet(db_used, id_set) {
12139
12149
  }
12140
12150
  //End Define getConnectionByIdSet
12141
12151
  // Define updateConnectionSet
12142
- function updateConnectionSetSQLite(id_set, id_conn_set, id_conn, verse, id_adapter) {
12152
+ function updateConnectionSetSQLite(id_set, id_conn_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta) {
12143
12153
  var query = "update set_connections set ";
12144
12154
  if (id_set && id_set > 0) {
12145
12155
  query += "id_set = " + id_set + ", ";
12146
12156
  }
12147
12157
  if (id_conn && id_conn > 0) {
12148
- query += "id_conn = " + id_conn + ", ";
12158
+ query += ", id_conn = " + id_conn;
12149
12159
  }
12150
12160
  if (id_adapter && id_adapter > 0) {
12151
- query += "id_adapter = " + id_adapter + ", ";
12161
+ query += ", id_adapter = " + id_adapter;
12152
12162
  }
12153
12163
  if (verse) {
12154
- query += "verse = '" + verse + "' ";
12164
+ query += ", verse = '" + verse;
12165
+ }
12166
+ if (lunghezza_cm) {
12167
+ query += ", lunghezza_cm = " + lunghezza_cm;
12168
+ }
12169
+ if (in_canaletta) {
12170
+ query += ", in_canaletta = " + in_canaletta;
12155
12171
  }
12156
12172
  query += "where id = " + id_conn_set;
12157
12173
  return query;
12158
12174
  }
12159
- function updateConnectionSetMySQL(id_set, id_conn_set, id_conn, verse, id_adapter) {
12175
+ function updateConnectionSetMySQL(id_set, id_conn_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta) {
12160
12176
  var query = "update set_connections set ";
12161
12177
  if (id_set && id_set > 0) {
12162
12178
  query += "id_set = :id_set, ";
@@ -12173,18 +12189,18 @@ function updateConnectionSetMySQL(id_set, id_conn_set, id_conn, verse, id_adapte
12173
12189
  query += "where id = :id_conn_set";
12174
12190
  return query;
12175
12191
  }
12176
- function updateConnectionSet(db_used, id_set, id_conn_set, id_conn, verse, id_adapter) {
12192
+ function updateConnectionSet(db_used, id_set, id_conn_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta) {
12177
12193
  var query = "";
12178
12194
  if (db_used) {
12179
12195
  switch (db_used) {
12180
12196
  case 'SQLITE':
12181
- query = updateConnectionSetSQLite(id_set, id_conn_set, id_conn, verse, id_adapter);
12197
+ query = updateConnectionSetSQLite(id_set, id_conn_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta);
12182
12198
  break;
12183
12199
  case 'MYSQL':
12184
- query = updateConnectionSetMySQL(id_set, id_conn_set, id_conn, verse, id_adapter);
12200
+ query = updateConnectionSetMySQL(id_set, id_conn_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta);
12185
12201
  break;
12186
12202
  case 'MYSQL2':
12187
- query = updateConnectionSetSQLite(id_set, id_conn_set, id_conn, verse, id_adapter);
12203
+ query = updateConnectionSetSQLite(id_set, id_conn_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta);
12188
12204
  break;
12189
12205
  }
12190
12206
  }
@@ -12192,34 +12208,48 @@ function updateConnectionSet(db_used, id_set, id_conn_set, id_conn, verse, id_ad
12192
12208
  }
12193
12209
  // end define updateConnectionSet
12194
12210
  // Define insertConnectionSet
12195
- function insertConnectionSetSQLite(id_set, id_conn, verse, id_adapter) {
12196
- var query = "insert into set_connections (id_set, id_conn, id_adapter, verse) values ";
12211
+ function insertConnectionSetSQLite(id_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta, date_start) {
12212
+ var dt_start_str = "2025-09-01";
12213
+ if (date_start) {
12214
+ dt_start_str = convertDateToStringDB(date_start);
12215
+ }
12216
+ var query = "insert into set_connections (id_set, id_conn, id_adapter, verse, lunghezza_cm, in_canaletta, date_start, date_end) values ";
12197
12217
  query += "(" + id_set + ", ";
12198
12218
  query += id_conn + ", ";
12199
12219
  query += id_adapter + ", ";
12200
- query += "'" + verse + "')";
12220
+ query += "'" + verse + "', ";
12221
+ query += "'" + dt_start_str + "', ";
12222
+ query += "'2999-12-31'"
12223
+ query += ")";
12201
12224
  return query;
12202
12225
  }
12203
- function insertConnectionSetMySQL(id_set, id_conn, verse, id_adapter) {
12204
- var query = "insert into set_connections (id_set, id_conn, id_adapter, verse) values ";
12226
+ function insertConnectionSetMySQL(id_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta, date_start) {
12227
+ var dt_start_str = "2025-09-01";
12228
+ if (date_start) {
12229
+ dt_start_str = convertDateToStringDB(date_start);
12230
+ }
12231
+ var query = "insert into set_connections (id_set, id_conn, id_adapter, verse, lunghezza_cm, in_canaletta, date_start, date_end) values ";
12205
12232
  query += "(:id_set, ";
12206
12233
  query += ":id_conn, ";
12207
12234
  query += ":id_adapter, ";
12208
- query += ":verse)";
12235
+ query += ":verse, ";
12236
+ query += "'" + dt_start_str + "', ";
12237
+ query += "'2999-12-31'"
12238
+ query += ")";
12209
12239
  return query;
12210
12240
  }
12211
- function insertConnectionSet(db_used, id_set, id_conn, verse, id_adapter) {
12241
+ function insertConnectionSet(db_used, id_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta) {
12212
12242
  var query = "";
12213
12243
  if (db_used) {
12214
12244
  switch (db_used) {
12215
12245
  case 'SQLITE':
12216
- query = insertConnectionSetSQLite(id_set, id_conn, verse, id_adapter);
12246
+ query = insertConnectionSetSQLite(id_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta);
12217
12247
  break;
12218
12248
  case 'MYSQL':
12219
- query = insertConnectionSetMySQL(id_set, id_conn, verse, id_adapter);
12249
+ query = insertConnectionSetMySQL(id_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta);
12220
12250
  break;
12221
12251
  case 'MYSQL2':
12222
- query = insertConnectionSetSQLite(id_set, id_conn, verse, id_adapter);
12252
+ query = insertConnectionSetSQLite(id_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta);
12223
12253
  break;
12224
12254
  }
12225
12255
  }
@@ -12257,6 +12287,66 @@ function removeConnectionSet(db_used, id_set, id_conn_set) {
12257
12287
  return query;
12258
12288
  }
12259
12289
 
12290
+ function updateConnectionSetAfterRemoveSQLite(id_set) {
12291
+ var query = "update set_connections set date_out = '2999-12-31' ";
12292
+ query += "where id_set = " + id_set + " and date_start = (select max(date_start) from set_connections where id_set = " + id_set + ")";
12293
+ return query;
12294
+ }
12295
+ function updateConnectionSetAfterRemoveMySQL(id_set) {
12296
+ var query = "update set_connections set date_out = '2999-12-31' ";
12297
+ query += "where id_set = :id_set and date_start = (select max(date_start) from set_connections where id_set = :id_set)";
12298
+ return query;
12299
+ }
12300
+ function updateConnectionSetAfterRemove(db_used, id_set) {
12301
+ var query = "";
12302
+ if (db_used) {
12303
+ switch (db_used) {
12304
+ case 'SQLITE':
12305
+ query = updateConnectionSetAfterRemoveSQLite(id_set);
12306
+ break;
12307
+ case 'MYSQL':
12308
+ query = updateConnectionSetAfterRemoveMySQL(id_set);
12309
+ break;
12310
+ case 'MYSQL2':
12311
+ query = updateConnectionSetAfterRemoveSQLite(id_set);
12312
+ break;
12313
+ }
12314
+ }
12315
+ return query;
12316
+ }
12317
+
12318
+ function updateConnectionSetDatesSQLite(id_set) {
12319
+ var query = "update set_connections set date_end = date('now','-1 day') ";
12320
+ query += "where id_set = " + id_set + " and date_start = (select max(date_start) from set_connections where id_set = " + id_set + ")";
12321
+ return query;
12322
+ }
12323
+ function updateConnectionSetDatesMySQL(id_device) {
12324
+ var query = "update set_connections set date_end = DATE_SUB(CURDATE(), INTERVAL 1 DAY) ";
12325
+ query += "where id_set = :id_set and date_start = (select max(date_start) from set_connections where id_set = :id_set)";
12326
+ return query;
12327
+ }
12328
+ function updateConnectionSetDatesMySQL2(id_device) {
12329
+ var query = "update set_connections set date_end = DATE_SUB(CURDATE(), INTERVAL 1 DAY) ";
12330
+ query += "where id_set = " + id_set + " and date_start = (select max(date_start) from set_connections where id_set = " + id_set + ")";
12331
+ return query;
12332
+ }
12333
+ function updateConnectionSetDates(db_used,id_set) {
12334
+ var query = "";
12335
+ if (db_used) {
12336
+ switch (db_used) {
12337
+ case 'SQLITE':
12338
+ query = updateConnectionSetDatesSQLite(id_device);
12339
+ break;
12340
+ case 'MYSQL':
12341
+ query = updateConnectionSetDatesMySQL(id_device);
12342
+ break;
12343
+ case 'MYSQL2':
12344
+ query = updateConnectionSetDatesMySQL2(id_device);
12345
+ break;
12346
+ }
12347
+ }
12348
+ return query;
12349
+ }
12260
12350
  // end define removeConnectionSet
12261
12351
 
12262
12352
  function getBeniConsumoTypes() {
@@ -17097,6 +17187,8 @@ module.exports = {
17097
17187
  insertConnectionSet,
17098
17188
  updateConnectionSet,
17099
17189
  removeConnectionSet,
17190
+ updateConnectionSetAfterRemove,
17191
+ updateConnectionSetDates,
17100
17192
  getConnectionByIdSet,
17101
17193
  getConnectionSetById,
17102
17194
  queryDetailsByIdDevice,
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.215",
7
+ "version": "3.0.217",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",