alsmanager_lib 3.0.178 → 3.0.180

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 +66 -24
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -4111,7 +4111,16 @@ function queryDeviceByIdSQLite(id_device) {
4111
4111
  query += "d.manifacturer as Marca, d.model as Modello, ";
4112
4112
  query += "d.inv_ict3_number as Inventario, d.serial_no, ";
4113
4113
  query += "d.inv_tn_number, d.inv_pnrr_number, d.inv_tndigit_number, ";
4114
- query += "d.note, d.num_objects, d.no_inventario, d.peso_g, d.part_of, d.is_unused from devices d ";
4114
+ query += "d.note, d.num_objects, d.no_inventario, d.peso_g, d.part_of, d.is_unused, ";
4115
+ query += "case ";
4116
+ query += "when d.no_inventario is not null and d.no_inventario > 0 then concat(d.id,'(ID)') ";
4117
+ query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then d.inv_ict3_number ";
4118
+ query += "when d.inv_pnrr_number != '' and d.inv_pnrr_number is not null then d.inv_pnrr_number ";
4119
+ query += "when d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number,'(TN)') ";
4120
+ query += "when d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)') ";
4121
+ query += "when d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)') ";
4122
+ query += "end as Codice ";
4123
+ query += "from devices d ";
4115
4124
  query += "where d.id = " + id_device;
4116
4125
  return query;
4117
4126
  }
@@ -4120,7 +4129,16 @@ function queryDeviceByIdMySQL(id_device) {
4120
4129
  query += "d.manifacturer as Marca, d.model as Modello, ";
4121
4130
  query += "d.inv_ict3_number as Inventario, d.serial_no, ";
4122
4131
  query += "d.inv_tn_number, d.inv_pnrr_number, d.inv_tndigit_number, ";
4123
- query += "d.note, d.num_objects, d.no_inventario, d.peso_g, d.part_of, d.is_unused from devices d ";
4132
+ query += "d.note, d.num_objects, d.no_inventario, d.peso_g, d.part_of, d.is_unused, ";
4133
+ query += "case ";
4134
+ query += "when d.no_inventario is not null and d.no_inventario > 0 then concat(d.id,'(ID)') ";
4135
+ query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then d.inv_ict3_number ";
4136
+ query += "when d.inv_pnrr_number != '' and d.inv_pnrr_number is not null then d.inv_pnrr_number ";
4137
+ query += "when d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number,'(TN)') ";
4138
+ query += "when d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)') ";
4139
+ query += "when d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)') ";
4140
+ query += "end as Codice ";
4141
+ query += "from devices d ";
4124
4142
  query += "where d.id = :id_device";
4125
4143
  return query;
4126
4144
  }
@@ -8307,60 +8325,84 @@ function removeIntervento(db_used,id_intervento) {
8307
8325
 
8308
8326
 
8309
8327
  // Device intervento
8310
- function insertDeviceInterventoSQLite(id_intervento, id_device, note) {
8311
- var query = "insert into device_interventi (id_intervento, id_device, note) ";
8312
- query += "values (" + id_intervento + ", " + id_device + ", '" + note + "')";
8328
+ function insertDeviceInterventoSQLite(id_intervento, id_device, dt_inizio, dt_fine, note, t_stima_min, t_effettivo_min) {
8329
+ /*CREATE TABLE "device_interventi" (
8330
+ "id" INTEGER,
8331
+ "id_device" INTEGER,
8332
+ "id_intervento" INTEGER,
8333
+ "date_start" TEXT,
8334
+ "date_end" TEXT,
8335
+ "note_intervento" TEXT,
8336
+ "tempo_stimato" INTEGER,
8337
+ "tempo_effettivo" INTEGER,
8338
+ PRIMARY KEY("id" AUTOINCREMENT)
8339
+ )
8340
+ */
8341
+ var dt_inizio_str = convertDateToStringDB(dt_inizio);
8342
+ var dt_fine_str = convertDateToStringDB(dt_fine);
8343
+
8344
+ var query = "insert into device_interventi (id_device, id_intervento, date_start, date_end, note_intervento, tempo_stimato_min, tempo_effettivo_min) ";
8345
+ query += "values (" + id_device + ", " + id_intervento + ", '" + dt_inizio_str + "', '" + dt_fine_str + "', '" + note + "', " + t_stima_min + ", " + t_effettivo_min + ")";
8313
8346
  return query;
8314
8347
  }
8315
- function insertDeviceInterventoMySQL(id_intervento, id_device, note) {
8316
- var query = "insert into device_interventi (id_intervento, id_device, note) ";
8317
- query += "values (:id_intervento, :id_device, :note)";
8348
+ function insertDeviceInterventoMySQL() {
8349
+ var query = "insert into device_interventi (id_device, id_intervento, date_start, date_end, note_intervento, tempo_stimato_min, tempo_effettivo_min) ";
8350
+ query += "values (:id_device, :id_intervento, :dt_inizio, :dt_fine, :note, :t_stima_min, :t_effettivo_min)";
8318
8351
  return query;
8319
8352
  }
8320
- function insertDeviceIntervento(db_used,id_intervento, id_device, note) {
8353
+ function insertDeviceIntervento(db_used, id_intervento, id_device, dt_inizio, dt_fine, note, t_stima_min, t_effettivo_min) {
8321
8354
  var query = "";
8322
8355
  if (db_used) {
8323
8356
  switch (db_used) {
8324
8357
  case 'SQLITE':
8325
- query = insertDeviceInterventoSQLite(id_intervento, id_device, note);
8358
+ query = insertDeviceInterventoSQLite(id_intervento, id_device, dt_inizio, dt_fine, note, t_stima_min, t_effettivo_min);
8326
8359
  break;
8327
8360
  case 'MYSQL':
8328
- query = insertDeviceInterventoMySQL(id_intervento, id_device, note);
8361
+ query = insertDeviceInterventoMySQL();
8329
8362
  break;
8330
8363
  case 'MYSQL2':
8331
- query = insertDeviceInterventoSQLite(id_intervento, id_device, note);
8364
+ query = insertDeviceInterventoSQLite(id_intervento, id_device, dt_inizio, dt_fine, note, t_stima_min, t_effettivo_min);
8332
8365
  break;
8333
8366
  }
8334
8367
  }
8335
8368
  return query;
8336
8369
  }
8337
8370
  // Update
8338
- function updateDeviceInterventoSQLite(id_dev_interv, id_device, note) {
8371
+ function updateDeviceInterventoSQLite(id_dev_interv, dt_inizio, dt_fine, note, t_stima_min, t_effettivo_min) {
8372
+ var dt_inizio_str = convertDateToStringDB(dt_inizio);
8373
+ var dt_fine_str = convertDateToStringDB(dt_fine);
8374
+
8339
8375
  var query = "update device_interventi set ";
8340
- query += "id_device = " + id_device + ", ";
8341
- query += "note = " + note + " ";
8376
+ query += "date_start = '" + dt_inizio_str + "', ";
8377
+ query += "date_end = '" + dt_fine_str + "', ";
8378
+ query += "note = '" + note + "', ";
8379
+ query += "tempo_stimato_min = " + t_stima_min + ", ";
8380
+ query += "tempo_effettivo_min = " + t_effettivo_min + " ";
8342
8381
  query += "where id = " + id_dev_interv;
8343
8382
  return query;
8344
8383
  }
8345
- function updateDeviceInterventoMySQL(id_dev_interv, id_device, note) {
8384
+ function updateDeviceInterventoMySQL() {
8346
8385
  var query = "update device_interventi set ";
8347
- query += "id_device = :id_device ";
8348
- query += "note = :note ";
8386
+ query += "date_start = :dt_inizio, ";
8387
+ query += "date_end = :dt_fine, ";
8388
+ query += "note = :note, ";
8389
+ query += "tempo_stimato_min = :t_stima_min, ";
8390
+ query += "tempo_effettivo_min = :t_effettivo_min ";
8349
8391
  query += "where id = :id_dev_interv";
8350
8392
  return query;
8351
8393
  }
8352
- function updateDeviceIntervento(db_used, id_dev_interv, id_device, note) {
8394
+ function updateDeviceIntervento(db_used, id_dev_interv, dt_inizio, dt_fine, note, t_stima_min, t_effettivo_min) {
8353
8395
  var query = "";
8354
8396
  if (db_used) {
8355
8397
  switch (db_used) {
8356
8398
  case 'SQLITE':
8357
- query = updateDeviceInterventoSQLite(id_dev_interv, id_device, note);
8399
+ query = updateDeviceInterventoSQLite(id_dev_interv, dt_inizio, dt_fine, note, t_stima_min, t_effettivo_min);
8358
8400
  break;
8359
8401
  case 'MYSQL':
8360
- query = updateDeviceInterventoMySQL(id_dev_interv, id_device, note);
8402
+ query = updateDeviceInterventoMySQL();
8361
8403
  break;
8362
8404
  case 'MYSQL2':
8363
- query = updateDeviceInterventoSQLite(id_dev_interv, id_device, note);
8405
+ query = updateDeviceInterventoSQLite(id_dev_interv, dt_inizio, dt_fine, note, t_stima_min, t_effettivo_min);
8364
8406
  break;
8365
8407
  }
8366
8408
  }
@@ -8372,7 +8414,7 @@ function removeDeviceInterventoSQLite(id_dev_interv) {
8372
8414
  query += "where id = " + id_dev_interv;
8373
8415
  return query;
8374
8416
  }
8375
- function removeDeviceInterventoMySQL(id_intervento, id_device, note) {
8417
+ function removeDeviceInterventoMySQL() {
8376
8418
  var query = "delete from device_interventi ";
8377
8419
  query += "where id = :id_dev_interv";
8378
8420
  return query;
@@ -8385,7 +8427,7 @@ function removeDeviceIntervento(db_used, id_dev_interv) {
8385
8427
  query = removeDeviceInterventoSQLite(id_dev_interv);
8386
8428
  break;
8387
8429
  case 'MYSQL':
8388
- query = removeDeviceInterventoMySQL(id_dev_interv);
8430
+ query = removeDeviceInterventoMySQL();
8389
8431
  break;
8390
8432
  case 'MYSQL2':
8391
8433
  query = removeDeviceInterventoSQLite(id_dev_interv);
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.178",
7
+ "version": "3.0.180",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",