alsmanager_lib 3.0.219 → 3.0.221

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 +90 -18
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -1356,29 +1356,26 @@ function getUtentiCombo() {
1356
1356
  }
1357
1357
 
1358
1358
  function getUtentiByIdDeviceSQLite(id_device) {
1359
- var query = "select au.id, au.cognome_denominazione, au.nome, au.titolo from device_utenza du ";
1359
+ var query = "select au.id, au.cognome_denominazione, au.nome, au.titolo, du.date_start, du.date_end, du.note from device_utenza du ";
1360
1360
  query += "join anagrafica_utenze au on au.id = du.id_utenza ";
1361
1361
  query += "where du.id_device = " + id_device + " ";
1362
- query += "and du.date_start <= date('now') and du.date_end >= date('now') ";
1363
1362
  query += "order by titolo, cognome_denominazione ";
1364
1363
  return query;
1365
1364
  }
1366
1365
 
1367
1366
  function getUtentiByIdDeviceMySQL(id_device) {
1368
- var query = "select au.id, au.cognome_denominazione, au.nome, au.titolo from device_utenza du ";
1367
+ var query = "select au.id, au.cognome_denominazione, au.nome, au.titolo, du.date_start, du.date_end, du.note from device_utenza du ";
1369
1368
  query += "join anagrafica_utenze au on au.id = du.id_utenza ";
1370
1369
  query += "where du.id_device = :id_device ";
1371
- query += "and du.date_start <= CURDATE() and du.date_end >= CURDATE() ";
1372
1370
  query += "order by titolo, cognome_denominazione ";
1373
1371
  return query;
1374
1372
  }
1375
1373
 
1376
1374
 
1377
1375
  function getUtentiByIdDeviceMYSQL2(id_device) {
1378
- var query = "select au.id, au.cognome_denominazione, au.nome, au.titolo from device_utenza du ";
1376
+ var query = "select au.id, au.cognome_denominazione, au.nome, au.titolo, du.date_start, du.date_end, du.note from device_utenza du ";
1379
1377
  query += "join anagrafica_utenze au on au.id = du.id_utenza ";
1380
1378
  query += "where du.id_device = " + id_device + " ";
1381
- query += "and du.date_start <= CURDATE() and du.date_end >= CURDATE() ";
1382
1379
  query += "order by titolo, cognome_denominazione ";
1383
1380
  return query;
1384
1381
  }
@@ -1401,16 +1398,65 @@ function getUtentiByIdDevice(db_used, id_device) {
1401
1398
  return query;
1402
1399
  }
1403
1400
 
1404
- function insertUtentePerDevice(id_utente, id_device, note) {
1401
+ function getUtenteDeviceByIdSQLite(id_dev_user) {
1402
+ var query = "select du.id, du.id_utente, du.date_start, du.date_end, du.note from device_utenza du ";
1403
+ query += "where du.id = " + id_dev_user + " ";
1404
+ return query;
1405
+ }
1405
1406
 
1407
+ function getUtenteDeviceByIdMySQL(id_dev_user) {
1408
+ var query = "select du.id, du.id_utente, du.date_start, du.date_end, du.note from device_utenza du ";
1409
+ query += "where du.id = :id_dev_user ";
1410
+ return query;
1411
+ }
1412
+
1413
+
1414
+ function getUtenteDeviceById (db_used, id_dev_user) {
1415
+ var query = "";
1416
+ if (db_used) {
1417
+ switch (db_used) {
1418
+ case 'SQLITE':
1419
+ query = getUtenteDeviceByIdSQLite(id_dev_user);
1420
+ break;
1421
+ case 'MYSQL':
1422
+ query = getUtenteDeviceByIdMySQL(id_dev_user);
1423
+ break;
1424
+ case 'MYSQL2':
1425
+ query = getUtenteDeviceByIdSQLite(id_dev_user);
1426
+ break;
1427
+ }
1428
+ }
1429
+ return query;
1406
1430
  }
1407
-
1408
- function updateUtentePerDevice(id_dev_user, id_utente, id_device, note) {
1409
1431
 
1432
+ function insertUtentePerDevice(id_utente, id_device, date_start, date_end, note) {
1433
+ var date_start_str = convertDateToStringDB(date_start);
1434
+ var date_end_str = convertDateToStringDB(date_end);
1435
+ var query = "insert into device_utenza (id_utente, id_device, date_start, date_end, note) values (";
1436
+ query += id_utente + ", ";
1437
+ query += id_device + ", ";
1438
+ query += "'" + date_start_str + "', ";
1439
+ query += "'" + date_end_str + "', ";
1440
+ query += "'" + note + "'" ;
1441
+ query += ")";
1442
+ return query;
1443
+ }
1444
+
1445
+ function updateUtentePerDevice(id_dev_user, date_start, date_end, note) {
1446
+ var date_start_str = convertDateToStringDB(date_start);
1447
+ var date_end_str = convertDateToStringDB(date_end);
1448
+ var query = "update device_utenza set ";
1449
+ query += "date_start = '" + date_start_str + "', ";
1450
+ query += "date_end = '" + date_end_str + "', ";
1451
+ query += "note = '" + note + "'" ;
1452
+ query += "where id = " + id_dev_user;
1453
+ return query;
1410
1454
  }
1411
1455
 
1412
1456
  function removeUtentePerDevice(id_dev_user) {
1413
-
1457
+ var query = "delete from device_utenza ";
1458
+ query += "where id = " + id_dev_user;
1459
+ return query;
1414
1460
  }
1415
1461
 
1416
1462
  // End Anagrafica utenti
@@ -4640,7 +4686,7 @@ function insertDeviceSQLite(dev) {
4640
4686
  if (dev.peso_g)
4641
4687
  peso = dev.peso_g;
4642
4688
 
4643
- query = "insert into devices (inv_ict3_number, inv_tn_number, inv_pnrr_number, inv_tndigit_number, type, manifacturer, model, serial_no, note, num_objects, no_inventario, peso_g, part_of, is_unused) ";
4689
+ query = "insert into devices (inv_ict3_number, inv_tn_number, inv_pnrr_number, inv_tndigit_number, type, manifacturer, model, serial_no, note, num_objects, no_inventario, peso_g, part_of, is_unused, date_insert) ";
4644
4690
  query += "values (";
4645
4691
  query += "'" + String(inventario).trim() + "',";
4646
4692
  query += "'" + String(inv_comune).trim() + "',";
@@ -4655,13 +4701,14 @@ function insertDeviceSQLite(dev) {
4655
4701
  query += dev.no_inv + ", ";
4656
4702
  query += peso + ", ";
4657
4703
  query += "'" + dev.part_of + "', ";
4658
- query += dev.is_unused;
4704
+ query += dev.is_unused + ", ";
4705
+ query += "'" + convertDateToStringDB(new Date()) + "'";
4659
4706
  query += ")";
4660
4707
  }
4661
4708
  return query;
4662
4709
  }
4663
4710
  function insertDeviceMySQL() {
4664
- var query = "insert into devices (inv_ict3_number, inv_tn_number, inv_pnrr_number, inv_tndigit_number, type, manifacturer, model, serial_no, note, num_objects, no_inventario, peso_g, part_of, is_unused) ";
4711
+ query = "insert into devices (inv_ict3_number, inv_tn_number, inv_pnrr_number, inv_tndigit_number, type, manifacturer, model, serial_no, note, num_objects, no_inventario, peso_g, part_of, is_unused, date_insert) ";
4665
4712
  query += "values (";
4666
4713
  query += ":inventario, ";
4667
4714
  query += ":inv_comune, ";
@@ -4677,6 +4724,7 @@ function insertDeviceMySQL() {
4677
4724
  query += ":peso_g, ";
4678
4725
  query += ":part_of, ";
4679
4726
  query += ":is_unused, ";
4727
+ query += "'" + convertDateToStringDB(new Date()) + "'";
4680
4728
  query += ")";
4681
4729
  return query;
4682
4730
  }
@@ -4754,7 +4802,8 @@ function updateDeviceSQLite(deviceObj) {
4754
4802
  query += "no_inventario = " + dev.no_inv + ", ";
4755
4803
  query += "peso_g = " + peso + ", ";
4756
4804
  query += "part_of = '" + part_of + "', ";
4757
- query += "is_unused = " + dev.is_unused + " ";
4805
+ query += "is_unused = " + dev.is_unused + ", ";
4806
+ query += "date_last_update = '" + convertDateToStringDB(new Date()) + "' ";
4758
4807
  query += " where id = " + dev.id;
4759
4808
  }
4760
4809
  return query;
@@ -4775,7 +4824,8 @@ function updateDeviceMySQL() {
4775
4824
  query += "no_inventario = :no_inv, ";
4776
4825
  query += "peso_g = :peso_g, ";
4777
4826
  query += "part_of = :part_of, ";
4778
- query += "is_unused = :is_unused ";
4827
+ query += "is_unused = :is_unused, ";
4828
+ query += "date_last_update = '" + convertDateToStringDB(new Date()) + "' ";
4779
4829
  query += " where id = :id_device";
4780
4830
  return query;
4781
4831
  }
@@ -4868,13 +4918,15 @@ function getDeviceMySQLPayload(dev) {
4868
4918
  //End Update Device
4869
4919
  // Remove Device
4870
4920
  function removeDeviceSQLite(id_device) {
4871
- var query = "update devices set is_removed = 1 ";
4921
+ var query = "update devices set is_removed = 1, ";
4922
+ query += "date_removed = '" + convertDateToStringDB(new Date()) + "' ";
4872
4923
  query += "where id = " + id_device;
4873
4924
  return query;
4874
4925
  }
4875
4926
 
4876
4927
  function removeDeviceMySQL() {
4877
- var query = "update devices set is_removed = 1 ";
4928
+ var query = "update devices set is_removed = 1, ";
4929
+ query += "date_removed = '" + convertDateToStringDB(new Date()) + "' ";
4878
4930
  query += "where id = :id_device";
4879
4931
  return query;
4880
4932
  }
@@ -17010,6 +17062,23 @@ function deleteCountersPrinterRechargeUser(id_counteruser) {
17010
17062
 
17011
17063
 
17012
17064
  // End Printer management
17065
+ // Notes for devices
17066
+ function getNotesByIdDevice(id_device) {
17067
+ var query = "select CONCAT('DISPOSITIVO id. ', d2.id) as Tipo, d2.date_insert as Data, d2.note as note from devices d2 ";
17068
+ query += "where d2.id = " + id_device + " and d2.note is not null ";
17069
+ query += "UNION ";
17070
+ query += "select CONCAT('CONSEGNA n. ', cb.id_consegna), cb.data_consegna as Data, cb.note_consegna as note from consegna_beni cb ";
17071
+ query += "where cb.id_bene = " + id_device + " and cb.note_consegna is not null ";
17072
+ query += "UNION ";
17073
+ query += "select CONCAT('RESTITUZIONE n. ', cb2.id_consegna) as Tipo, cb2.data_restituzione as Data, cb2.note_restituzione as note from consegna_beni cb2 ";
17074
+ query += "where cb.id_bene = " + id_device + " and cb2.note_restituzione is not null ";
17075
+ query += "UNION ";
17076
+ query += "select CONCAT('INTERVENTO n. ', di.id) as Tipo, di.date_start as Data, di.note_intervento as note from device_interventi di ";
17077
+ query += "where di.id_device = " + id_device + " and di.note_intervento is not null ";
17078
+ return query;
17079
+ }
17080
+
17081
+ // End Notes for devices
17013
17082
  // Exports
17014
17083
 
17015
17084
  module.exports = {
@@ -17158,6 +17227,7 @@ module.exports = {
17158
17227
  getUtenti,
17159
17228
  getUtentiCombo,
17160
17229
  getUtentiByIdDevice,
17230
+ getUtenteDeviceById,
17161
17231
  insertUtentePerDevice,
17162
17232
  updateUtentePerDevice,
17163
17233
  removeUtentePerDevice,
@@ -17499,6 +17569,8 @@ module.exports = {
17499
17569
  readCountersPrinterRechargeUser,
17500
17570
  writeCountersPrinterRechargeUser,
17501
17571
  updateCountersPrinterRechargeUser,
17502
- deleteCountersPrinterRechargeUser
17572
+ deleteCountersPrinterRechargeUser,
17573
+ //
17574
+ getNotesByIdDevice
17503
17575
  };
17504
17576
  // end of source
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.219",
7
+ "version": "3.0.221",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",