alsmanager_lib 3.0.81 → 3.0.83

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 +55 -9
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -4288,13 +4288,15 @@ function writeDeviceProperties(db_used, id_device, raw_data) {
4288
4288
  //Read Device properties
4289
4289
  function readDevicePropertiesSQLite(id_device) {
4290
4290
  var query = "select raw_properties from device_properties ";
4291
- query += "where id_device = " + id_device;
4291
+ query += "where id_device = " + id_device + " ";
4292
+ query += "and (is_imported is null or is_imported = 0)"
4292
4293
  return query;
4293
4294
  }
4294
4295
 
4295
4296
  function readDevicePropertiesMySQL() {
4296
4297
  var query = "select raw_properties from device_properties ";
4297
- query += "where id_device = :id_device";
4298
+ query += "where id_device = :id_device ";
4299
+ query += "and (is_imported is null or is_imported = 0)"
4298
4300
  return query;
4299
4301
  }
4300
4302
  function readDeviceProperties(db_used, id_device) {
@@ -4315,7 +4317,44 @@ function readDeviceProperties(db_used, id_device) {
4315
4317
  return query;
4316
4318
  }
4317
4319
  //End Read Device properties
4320
+ //Update Device Properties after import
4321
+ function updateDevicePropertiesSQLite(id_prop, is_imported, id_config) {
4322
+ var query = "update device_properties set ";
4323
+ query += "is_imported " + is_imported + " ";
4324
+ if (id_config) {
4325
+ query += ", id_config = " + id_config + " ";
4326
+ }
4327
+ query += "where id = " + id_prop;
4328
+ return query;
4329
+ }
4318
4330
 
4331
+ function updateDevicePropertiesMySQL(id_prop, is_imported, id_config) {
4332
+ var query = "update device_properties set ";
4333
+ query += "is_imported :is_imported ";
4334
+ if (id_config) {
4335
+ query += ", id_config = :id_config ";
4336
+ }
4337
+ query += "where id = :id_prop";
4338
+ return query;
4339
+ }
4340
+ function updateDeviceProperties(db_used, id_prop, is_imported, id_config) {
4341
+ var query = "";
4342
+ if (db_used) {
4343
+ switch (db_used) {
4344
+ case 'SQLITE':
4345
+ query = updateDevicePropertiesSQLite(id_prop, is_imported, id_config);
4346
+ break;
4347
+ case 'MYSQL':
4348
+ query = updateDevicePropertiesMySQL(id_prop, is_imported, id_config);
4349
+ break;
4350
+ case 'MYSQL2':
4351
+ query = updateDevicePropertiesSQLite(id_prop, is_imported, id_config);
4352
+ break;
4353
+ }
4354
+ }
4355
+ return query;
4356
+ }
4357
+ //End Update Device Properties after import
4319
4358
  // Get Devices with properties
4320
4359
  function getDevicesWithPropertiesSQLite(id_device) {
4321
4360
  var query = "select ";
@@ -6777,8 +6816,8 @@ function getDatesRangeConsegne() {
6777
6816
  }
6778
6817
 
6779
6818
 
6780
- function queryConsegneSQLite(data_da, data_a, data_filter, adulto, alunno) {
6781
- var query = "SELECT id, data_richiesta as Richiesta, data_consegna as Consegna, richiedente_adulto as Adulto, richiedente_alunno as Alunno, richiedente_genitore as Genitore, is_home as Casa, note as Note, email_adulto, email_genitore from consegne ";
6819
+ function queryConsegneSQLite(data_da, data_a, data_filter, adulto, alunno, still_open) {
6820
+ var query = "SELECT c.id, c.data_richiesta as Richiesta, c.data_consegna as Consegna, c.richiedente_adulto as Adulto, c.richiedente_alunno as Alunno, c.richiedente_genitore as Genitore, c.is_home as Casa, c.note as Note, c.email_adulto, c.email_genitore from consegne c ";
6782
6821
  query += "where (removed is null or removed = 0) ";
6783
6822
  if (adulto && adulto.trim() != '') {
6784
6823
  query += "and richiedente_adulto = '" + adulto + "' ";
@@ -6807,6 +6846,9 @@ function queryConsegneSQLite(data_da, data_a, data_filter, adulto, alunno) {
6807
6846
  else
6808
6847
  query += "data_consegna <= '" + data_str + "'";
6809
6848
  }
6849
+ if (still_open) {
6850
+ query += " and (select count(*) from consegna_beni where id_consegna = c.id and stato_restituzione in(0,1)) > 0"
6851
+ }
6810
6852
  }
6811
6853
  if (data_filter == "RICHIESTA")
6812
6854
  query += " order by data_richiesta desc";
@@ -6815,7 +6857,7 @@ function queryConsegneSQLite(data_da, data_a, data_filter, adulto, alunno) {
6815
6857
  return query;
6816
6858
  }
6817
6859
 
6818
- function queryConsegneMySQL(data_da, data_a, data_filter, adulto, alunno) {
6860
+ function queryConsegneMySQL(data_da, data_a, data_filter, adulto, alunno, still_open) {
6819
6861
  var query = "SELECT id, data_richiesta as Richiesta, data_consegna as Consegna, richiedente_adulto as Adulto, richiedente_alunno as Alunno, richiedente_genitore as Genitore, is_home as Casa, note as Note, email_adulto, email_genitore from consegne ";
6820
6862
  query += "where (removed is null or removed = 0) ";
6821
6863
  if (adulto && adulto.trim() != '') {
@@ -6841,6 +6883,9 @@ function queryConsegneMySQL(data_da, data_a, data_filter, adulto, alunno) {
6841
6883
  else
6842
6884
  query += "data_consegna <= :data_a";
6843
6885
  }
6886
+ if (still_open) {
6887
+ query += " and (select count(*) from consegna_beni where id_consegna = c.id and stato_restituzione in(0,1)) > 0"
6888
+ }
6844
6889
  }
6845
6890
  if (data_filter == "RICHIESTA")
6846
6891
  query += " order by data_richiesta desc";
@@ -6849,18 +6894,18 @@ function queryConsegneMySQL(data_da, data_a, data_filter, adulto, alunno) {
6849
6894
 
6850
6895
  return query;
6851
6896
  }
6852
- function queryConsegne(db_used,data_da, data_a, data_filter, adulto, alunno) {
6897
+ function queryConsegne(db_used,data_da, data_a, data_filter, adulto, alunno, still_open) {
6853
6898
  var query = "";
6854
6899
  if (db_used) {
6855
6900
  switch (db_used) {
6856
6901
  case 'SQLITE':
6857
- query = queryConsegneSQLite(data_da, data_a, data_filter, adulto, alunno);
6902
+ query = queryConsegneSQLite(data_da, data_a, data_filter, adulto, alunno, still_open);
6858
6903
  break;
6859
6904
  case 'MYSQL':
6860
- query = queryConsegneMySQL(data_da, data_a, data_filter, adulto, alunno);
6905
+ query = queryConsegneMySQL(data_da, data_a, data_filter, adulto, alunno, still_open);
6861
6906
  break;
6862
6907
  case 'MYSQL2':
6863
- query = queryConsegneSQLite(data_da, data_a, data_filter, adulto, alunno);
6908
+ query = queryConsegneSQLite(data_da, data_a, data_filter, adulto, alunno, still_open);
6864
6909
  break;
6865
6910
  }
6866
6911
  }
@@ -14338,6 +14383,7 @@ module.exports = {
14338
14383
  getDeviceMySQLPayload,
14339
14384
  writeDeviceProperties,
14340
14385
  readDeviceProperties,
14386
+ updateDeviceProperties,
14341
14387
  //
14342
14388
  getDiskUsagesByIdStorage,
14343
14389
  getLastDiskUsagesByIdStorage,
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.81",
7
+ "version": "3.0.83",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",