alsmanager_lib 3.0.202 → 3.0.203

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 +137 -10
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -4943,7 +4943,7 @@ function getDevicesSelectComboMySQL(categoria, id_dev_exclude, with_properties)
4943
4943
  var query = "SELECT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
4944
4944
  query += "case ";
4945
4945
  query += "when d.no_inventario is not null and d.no_inventario > 0 then concat(d.id, '(ID)', ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
4946
- query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then concat(d.inv_ict3_number,iif(d.part_of is not null and trim(d.part_of) <> '', concat('/',d.part_of),''), ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
4946
+ query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then concat(d.inv_ict3_number,if(d.part_of is not null and trim(d.part_of) <> '', concat('/',d.part_of),''), ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
4947
4947
  query += "when d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number, '(TN)', ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
4948
4948
  query += "when d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)', ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
4949
4949
  query += "when d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)', ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
@@ -4966,6 +4966,44 @@ function getDevicesSelectComboMySQL(categoria, id_dev_exclude, with_properties)
4966
4966
  query += "order by d.inv_ict3_number";
4967
4967
  return query;
4968
4968
  }
4969
+
4970
+ function getDevicesSelectComboMySQL2(categoria, id_dev_exclude, with_properties) {
4971
+ var query = "SELECT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
4972
+ /*
4973
+ (case
4974
+ when d.inv_ict3_number != '' and d.inv_ict3_number is not null then concat(d.inv_ict3_number, ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model )
4975
+ when d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number, '(TN)', ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model )
4976
+ when d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)', ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model )
4977
+ when d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)', ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model )
4978
+ end) as Descrizione
4979
+ */
4980
+ query += "case ";
4981
+ query += "when d.no_inventario is not null and d.no_inventario > 0 then concat(d.id, '(ID)', ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
4982
+ query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then concat(d.inv_ict3_number,if(d.part_of is not null and trim(d.part_of) <> '', concat('/',d.part_of),''), ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
4983
+ query += "when d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number, '(TN)', ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
4984
+ query += "when d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)', ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
4985
+ query += "when d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)', ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
4986
+ query += "else '' ";
4987
+ query += "end as Descrizione ";
4988
+ query += "from devices d ";
4989
+ if (with_properties && with_properties > 0) {
4990
+ query += "left join device_properties dp on d.id = dp.id_device ";
4991
+ }
4992
+ query += "where (d.is_removed is null or d.is_removed = 0) "
4993
+ if (categoria && categoria.trim() != '') {
4994
+ query += "and d.type in (select tipo from categorie_device where categoria = '" + categoria +"') ";
4995
+ }
4996
+ if (id_dev_exclude && id_dev_exclude > 0) {
4997
+ query += "and d.id <> " + id_dev_exclude + " ";
4998
+ }
4999
+ if (with_properties) {
5000
+ query += "and dp.raw_properties is not null ";
5001
+ }
5002
+ query += "order by d.inv_ict3_number";
5003
+ return query;
5004
+ }
5005
+
5006
+
4969
5007
  function getDevicesSelectCombo(db_used, categoria, id_dev_exclude, with_properties) {
4970
5008
  var query = "";
4971
5009
  if (db_used) {
@@ -4977,7 +5015,7 @@ function getDevicesSelectCombo(db_used, categoria, id_dev_exclude, with_properti
4977
5015
  query = getDevicesSelectComboMySQL(categoria, id_dev_exclude, with_properties);
4978
5016
  break;
4979
5017
  case 'MYSQL2':
4980
- query = getDevicesSelectComboSQLite(categoria, id_dev_exclude, with_properties);
5018
+ query = getDevicesSelectComboMySQL2(categoria, id_dev_exclude, with_properties);
4981
5019
  break;
4982
5020
  }
4983
5021
  }
@@ -5010,7 +5048,7 @@ function getDevicesSelectBySiteComboMySQL(id_site, dev_type) {
5010
5048
  var query = "SELECT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
5011
5049
  query += "case ";
5012
5050
  query += "when d.no_inventario is not null and d.no_inventario > 0 then concat(d.id, '(ID)', ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
5013
- query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then concat(d.inv_ict3_number,iif(d.part_of is not null and trim(d.part_of) <> '', concat('/',d.part_of),''), ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
5051
+ query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then concat(d.inv_ict3_number,if(d.part_of is not null and trim(d.part_of) <> '', concat('/',d.part_of),''), ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
5014
5052
  query += "when d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number, '(TN)', ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
5015
5053
  query += "when d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)', ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
5016
5054
  query += "when d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)', ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
@@ -5193,7 +5231,7 @@ function getDevicesWithPropertiesMySQL(id_device) {
5193
5231
  var query = "select ";
5194
5232
  query += "case ";
5195
5233
  query += "when d.no_inventario is not null and d.no_inventario > 0 then concat(d.id, '(ID)') ";
5196
- query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then concat(d.inv_ict3_number, iif(d.part_of is not null and trim(d.part_of) <> '', concat('/',d.part_of),'')) ";
5234
+ query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then concat(d.inv_ict3_number, if(d.part_of is not null and trim(d.part_of) <> '', concat('/',d.part_of),'')) ";
5197
5235
  query += "when d.inv_pnrr_number != '' and d.inv_pnrr_number is not null then d.inv_pnrr_number ";
5198
5236
  query += "when d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number,'(TN)') ";
5199
5237
  query += "when d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)') ";
@@ -5208,6 +5246,25 @@ function getDevicesWithPropertiesMySQL(id_device) {
5208
5246
  query += "order by d.id";
5209
5247
  return query;
5210
5248
  }
5249
+ function getDevicesWithPropertiesMySQL2(id_device) {
5250
+ var query = "select ";
5251
+ query += "case ";
5252
+ query += "when d.no_inventario is not null and d.no_inventario > 0 then concat(d.id, '(ID)') ";
5253
+ query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then concat(d.inv_ict3_number, if(d.part_of is not null and trim(d.part_of) <> '', concat('/',d.part_of),'')) ";
5254
+ query += "when d.inv_pnrr_number != '' and d.inv_pnrr_number is not null then d.inv_pnrr_number ";
5255
+ query += "when d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number,'(TN)') ";
5256
+ query += "when d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)') ";
5257
+ query += "when d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)') ";
5258
+ query += "end as Codice, ";
5259
+ query += "d.manifacturer as Marca, d.model as Modello, d.id as Id from devices d ";
5260
+ query += "left join device_properties dp on d.id = dp.id_device ";
5261
+ query += "where dp.id_device is not null ";
5262
+ if (id_device > 0) {
5263
+ query += "and d.id = " + id_device + " ";
5264
+ }
5265
+ query += "order by d.id";
5266
+ return query;
5267
+ }
5211
5268
  function getDevicesWithProperties(db_used, id_device) {
5212
5269
  var query = "";
5213
5270
  if (db_used) {
@@ -5219,7 +5276,7 @@ function getDevicesWithProperties(db_used, id_device) {
5219
5276
  query = getDevicesWithPropertiesMySQL(id_device);
5220
5277
  break;
5221
5278
  case 'MYSQL2':
5222
- query = getDevicesWithPropertiesSQLite(id_device);
5279
+ query = getDevicesWithPropertiesMySQL2(id_device);
5223
5280
  break;
5224
5281
  }
5225
5282
  }
@@ -10380,7 +10437,7 @@ function selectDismissioneDevicesByIdDismissSQLite(id_dismiss) {
10380
10437
  function selectDismissioneDevicesByIdDismissMySQL(id_dismiss) {
10381
10438
  var query = "select dm.id, ";
10382
10439
  query += "case ";
10383
- query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then concat(d.inv_ict3_number,iif(d.part_of is not null and trim(d.part_of) <> '', concat('/',d.part_of),'')) ";
10440
+ query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then concat(d.inv_ict3_number,if(d.part_of is not null and trim(d.part_of) <> '', concat('/',d.part_of),'')) ";
10384
10441
  query += "when d.inv_pnrr_number != '' and d.inv_pnrr_number is not null then d.inv_pnrr_number ";
10385
10442
  query += "when d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number,'(TN)') ";
10386
10443
  query += "when d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)') ";
@@ -10397,6 +10454,26 @@ function selectDismissioneDevicesByIdDismissMySQL(id_dismiss) {
10397
10454
  return query;
10398
10455
  }
10399
10456
 
10457
+ function selectDismissioneDevicesByIdDismissMySQL2(id_dismiss) {
10458
+ var query = "select dm.id, ";
10459
+ query += "case ";
10460
+ query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then concat(d.inv_ict3_number,if(d.part_of is not null and trim(d.part_of) <> '', concat('/',d.part_of),'')) ";
10461
+ query += "when d.inv_pnrr_number != '' and d.inv_pnrr_number is not null then d.inv_pnrr_number ";
10462
+ query += "when d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number,'(TN)') ";
10463
+ query += "when d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)') ";
10464
+ query += "when d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)') ";
10465
+ query += "end as Codice, ";
10466
+ query += "d.type as Tipo, d.manifacturer as Marca, d.model as Modello from device_dismissioni dm ";
10467
+ query += "join devices d on d.id = dm.id_device ";
10468
+ if (!id_dismiss || id_dismiss == 0) {
10469
+ query += "where dm.id_dismissione is null or dm.id_dismissione = 0";
10470
+ }
10471
+ else {
10472
+ query += "where dm.id_dismissione = " + id_dismiss;
10473
+ }
10474
+ return query;
10475
+ }
10476
+
10400
10477
  function selectDismissioneDevicesByIdDismiss(db_used, id_dismiss) {
10401
10478
  var query = "";
10402
10479
  if (db_used) {
@@ -10408,7 +10485,7 @@ function selectDismissioneDevicesByIdDismiss(db_used, id_dismiss) {
10408
10485
  query = selectDismissioneDevicesByIdDismissMySQL(id_dismiss);
10409
10486
  break;
10410
10487
  case 'MYSQL2':
10411
- query = selectDismissioneDevicesByIdDismissSQLite(id_dismiss);
10488
+ query = selectDismissioneDevicesByIdDismissMySQL2(id_dismiss);
10412
10489
  break;
10413
10490
  }
10414
10491
  }
@@ -12839,7 +12916,7 @@ function deletePortPerSite(id_port) {
12839
12916
  return query;
12840
12917
  }
12841
12918
 
12842
- function getSwitches(id_place) {
12919
+ function getSwitchesSQLite(id_place) {
12843
12920
  var query = "select d.id, dw.rete_appartenenza, concat(d.manifacturer, ' - ', d.model, ' - ', dw.rete_appartenenza) as description from devices d ";
12844
12921
  query += "join device_site ds on ds.id_device = d.id ";
12845
12922
  query += "join device_switch dw on dw.id_device = d.id ";
@@ -12851,6 +12928,50 @@ function getSwitches(id_place) {
12851
12928
  return query;
12852
12929
  }
12853
12930
 
12931
+ function getSwitchesMySQL() {
12932
+ var query = "select d.id, dw.rete_appartenenza, concat(d.manifacturer, ' - ', d.model, ' - ', dw.rete_appartenenza) as description from devices d ";
12933
+ query += "join device_site ds on ds.id_device = d.id ";
12934
+ query += "join device_switch dw on dw.id_device = d.id ";
12935
+ query += "join site_destinations sd on sd.id_site = ds.id_site ";
12936
+ query += "where sd.type = 'SERVER' and CURDATE() >= sd.date_start and CURDATE() <= sd.date_end ";
12937
+ query += "and CURDATE() >= ds.date_in and CURDATE() <= ds.date_out ";
12938
+ query += "and d.type = 'SWITCH' ";
12939
+ query += "and sd.id_place = :id_place ";
12940
+ return query;
12941
+ }
12942
+
12943
+ function getSwitchesMySQL2(id_place) {
12944
+ var query = "select d.id, dw.rete_appartenenza, concat(d.manifacturer, ' - ', d.model, ' - ', dw.rete_appartenenza) as description from devices d ";
12945
+ query += "join device_site ds on ds.id_device = d.id ";
12946
+ query += "join device_switch dw on dw.id_device = d.id ";
12947
+ query += "join site_destinations sd on sd.id_site = ds.id_site ";
12948
+ query += "where sd.type = 'SERVER' and CURDATE() >= sd.date_start and CURDATE() <= sd.date_end ";
12949
+ query += "and CURDATE() >= ds.date_in and CURDATE() <= ds.date_out ";
12950
+ query += "and d.type = 'SWITCH' ";
12951
+ query += "and sd.id_place = '" + id_place + "' ";
12952
+ return query;
12953
+ }
12954
+
12955
+
12956
+ function getSwitches(db_used, id_place) {
12957
+ var query = "";
12958
+ if (db_used) {
12959
+ switch (db_used) {
12960
+ case 'SQLITE':
12961
+ query = getSwitchesSQLite(id_place);
12962
+ break;
12963
+ case 'MYSQL':
12964
+ query = getSwitchesMySQL();
12965
+ break;
12966
+ case 'MYSQL2':
12967
+ query = getSwitchesMySQL2(id_place);
12968
+ break;
12969
+ }
12970
+ }
12971
+ return query;
12972
+ }
12973
+
12974
+
12854
12975
  function getTipiPorta() {
12855
12976
  var query = "select DISTINCT port_type from site_ports ";
12856
12977
  query += "order by port_type";
@@ -13844,10 +13965,16 @@ function queryStatisticInventarySQLite() {
13844
13965
  return query;
13845
13966
  }
13846
13967
  function queryStatisticInventaryMySQL() {
13847
- var query = "select COUNT(IIF(d.inv_ict3_number is not null and round(d.inv_ict3_number) > 0, 1, NULL)) as Con_Inventario, COUNT(IIF(d.inv_ict3_number is null or trim(d.inv_ict3_number) = '' or round(d.inv_ict3_number) > 0, 1, NULL)) as Senza_Inventario from devices d ";
13968
+ var query = "select COUNT(IF(d.inv_ict3_number is not null and round(d.inv_ict3_number) > 0, 1, NULL)) as Con_Inventario, COUNT(IF(d.inv_ict3_number is null or trim(d.inv_ict3_number) = '' or round(d.inv_ict3_number) > 0, 1, NULL)) as Senza_Inventario from devices d ";
13848
13969
  query += "where (is_removed is null or is_removed = 0) ";
13849
13970
  return query;
13850
13971
  }
13972
+ function queryStatisticInventaryMySQL2() {
13973
+ var query = "select COUNT(IF(d.inv_ict3_number is not null and round(d.inv_ict3_number) > 0, 1, NULL)) as Con_Inventario, COUNT(IF(d.inv_ict3_number is null or trim(d.inv_ict3_number) = '' or round(d.inv_ict3_number) > 0, 1, NULL)) as Senza_Inventario from devices d ";
13974
+ query += "where (is_removed is null or is_removed = 0) ";
13975
+ return query;
13976
+ }
13977
+
13851
13978
  function queryStatisticInventary(db_used) {
13852
13979
  var query = "";
13853
13980
  if (db_used) {
@@ -13859,7 +13986,7 @@ function queryStatisticInventary(db_used) {
13859
13986
  query = queryStatisticInventaryMySQL();
13860
13987
  break;
13861
13988
  case 'MYSQL2':
13862
- query = queryStatisticInventarySQLite();
13989
+ query = queryStatisticInventaryMySQL2();
13863
13990
  break;
13864
13991
  }
13865
13992
  }
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.202",
7
+ "version": "3.0.203",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",