alsmanager_lib 2.0.26 → 2.0.28

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 +93 -24
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -2290,7 +2290,7 @@ function getDevicesSelectBySite(db_used, id_site) {
2290
2290
  }
2291
2291
  //End Device Select by site
2292
2292
  // Device per plesso
2293
- function getDevicesSelectByPlaceSQLite(id_place) {
2293
+ function getDevicesSelectByPlaceSQLite(id_place, dev_type) {
2294
2294
  var query = "select distinct devices.id, devices.type as Tipo, devices.manifacturer as Marca, devices.model as modello, ";
2295
2295
  query += "case ";
2296
2296
  query += "when inv_ict3_number != '' and inv_ict3_number is not null then inv_ict3_number ";
@@ -2309,11 +2309,14 @@ function getDevicesSelectByPlaceSQLite(id_place) {
2309
2309
  query += "inner join sites on sites.id = device_site.id_site ";
2310
2310
  query += "where (date('now') >= device_site.date_in and date('now') <= device_site.date_out) ";
2311
2311
  query += "and (devices.is_removed is null or devices.is_removed = 0) ";
2312
- query += "and sites.id_place = '" + id_place + "'";
2312
+ query += "and sites.id_place = '" + id_place + "' ";
2313
+ if (dev_type && dev_type != '') {
2314
+ query += "and devices.type = '" + dev_type + "' ";
2315
+ }
2313
2316
  return query;
2314
2317
  }
2315
2318
 
2316
- function getDevicesSelectByPlaceMySQL(id_place) {
2319
+ function getDevicesSelectByPlaceMySQL(id_place, dev_type) {
2317
2320
  var query = "select DISTINCT devices.id, devices.type as Tipo, devices.manifacturer as Marca, devices.model as modello, ";
2318
2321
  query += "case ";
2319
2322
  query += "when inv_ict3_number != '' and inv_ict3_number is not null then inv_ict3_number ";
@@ -2332,18 +2335,21 @@ function getDevicesSelectByPlaceMySQL(id_place) {
2332
2335
  query += "inner join sites on sites.id = device_site.id_site ";
2333
2336
  query += "where (CURDATE() >= device_site.date_in and CURDATE() <= device_site.date_out) ";
2334
2337
  query += "and (devices.is_removed is null or devices.is_removed = 0) ";
2335
- query += "and sites.id_place = :id_place";
2338
+ query += "and sites.id_place = :id_place ";
2339
+ if (dev_type && dev_type != '') {
2340
+ query += "and devices.type = :dev_type ";
2341
+ }
2336
2342
  return query;
2337
2343
  }
2338
- function getDevicesSelectByPlace(db_used, id_place) {
2344
+ function getDevicesSelectByPlace(db_used, id_place, dev_type) {
2339
2345
  var query = "";
2340
2346
  if (db_used) {
2341
2347
  switch (db_used) {
2342
2348
  case 'SQLITE':
2343
- query = getDevicesSelectByPlaceSQLite(id_place);
2349
+ query = getDevicesSelectByPlaceSQLite(id_place, dev_type);
2344
2350
  break;
2345
2351
  case 'MYSQL':
2346
- query = getDevicesSelectByPlaceMySQL(id_place);
2352
+ query = getDevicesSelectByPlaceMySQL(id_place, dev_type);
2347
2353
  break;
2348
2354
  }
2349
2355
  }
@@ -2358,8 +2364,8 @@ function getDevicesCounterBySiteSQLite(id_site) {
2358
2364
  query += "inner join device_site ds on ds.id_device = d.id ";
2359
2365
  query += "where (date('now') >= ds.date_in and date('now') <= ds.date_out) ";
2360
2366
  query += "and (d.is_removed is null or d.is_removed = 0) ";
2361
- query += "and ds.id_site = " + id_site;
2362
- query += " group by d.type";
2367
+ query += "and ds.id_site = " + id_site + " ";
2368
+ query += "group by d.type";
2363
2369
  return query;
2364
2370
  }
2365
2371
 
@@ -3020,7 +3026,7 @@ function getDevicesSelectCombo(db_used, categoria, id_dev_exclude, with_properti
3020
3026
  }
3021
3027
  //End get devices for combo
3022
3028
  // Get device by site combo
3023
- function getDevicesSelectBySiteComboSQLite(id_site) {
3029
+ function getDevicesSelectBySiteComboSQLite(id_site, dev_type) {
3024
3030
  var query = "SELECT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
3025
3031
  query += "case ";
3026
3032
  query += "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) ";
@@ -3034,10 +3040,13 @@ function getDevicesSelectBySiteComboSQLite(id_site) {
3034
3040
  query += "where (d.is_removed is null or d.is_removed = 0) ";
3035
3041
  query += "and ds.id_site = " + id_site + " ";
3036
3042
  query += "and date('now') >= ds.date_in and date('now') <= ds.date_out ";
3043
+ if (dev_type && dev_type != '') {
3044
+ query += "and d.type = '" + dev_type + "' ";
3045
+ }
3037
3046
  query += "order by d.inv_ict3_number";
3038
3047
  return query;
3039
3048
  }
3040
- function getDevicesSelectBySiteComboMySQL(id_site) {
3049
+ function getDevicesSelectBySiteComboMySQL(id_site, dev_type) {
3041
3050
  var query = "SELECT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
3042
3051
  query += "case ";
3043
3052
  query += "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) ";
@@ -3051,19 +3060,22 @@ function getDevicesSelectBySiteComboMySQL(id_site) {
3051
3060
  query += "where (d.is_removed is null or d.is_removed = 0) ";
3052
3061
  query += "and ds.id_site = :id_site ";
3053
3062
  query += "and CURDATE() >= ds.date_in and CURDATE() <= ds.date_out ";
3063
+ if (dev_type && dev_type != '') {
3064
+ query += "and d.type = :dev_type ";
3065
+ }
3054
3066
  query += "order by d.inv_ict3_number";
3055
3067
  return query;
3056
3068
  }
3057
3069
 
3058
- function getDevicesSelectBySiteCombo(db_used, id_site) {
3070
+ function getDevicesSelectBySiteCombo(db_used, id_site, dev_type) {
3059
3071
  var query = "";
3060
3072
  if (db_used) {
3061
3073
  switch (db_used) {
3062
3074
  case 'SQLITE':
3063
- query = getDevicesSelectBySiteComboSQLite(id_site);
3075
+ query = getDevicesSelectBySiteComboSQLite(id_site, dev_type);
3064
3076
  break;
3065
3077
  case 'MYSQL':
3066
- query = getDevicesSelectBySiteComboMySQL(id_site);
3078
+ query = getDevicesSelectBySiteComboMySQL(id_site, dev_type);
3067
3079
  break;
3068
3080
  }
3069
3081
  }
@@ -4479,7 +4491,15 @@ function queryDeviceTypes() {
4479
4491
  return query;
4480
4492
  }
4481
4493
  // Define getDevicesNotAllocatedCombo
4482
- function getDevicesNotAllocatedComboSQLite(ordered_by) {
4494
+ function getDevicesNotAllocatedComboSQLite(sel_type, sel_maker, ordered_by) {
4495
+ var sel_type_str = "";
4496
+ if (sel_type) {
4497
+ sel_type_str = sel_type;
4498
+ }
4499
+ var sel_maker_str = "";
4500
+ if (sel_maker) {
4501
+ sel_maker_str = sel_maker;
4502
+ }
4483
4503
  var query = "SELECT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
4484
4504
  query += "case ";
4485
4505
  query += "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) ";
@@ -4494,6 +4514,12 @@ function getDevicesNotAllocatedComboSQLite(ordered_by) {
4494
4514
  query += "where (d.is_removed is null or d.is_removed = 0) "
4495
4515
  query += "and (ds.id_place is null ";
4496
4516
  query += "or (ds.date_in <= date('now') and ds.date_out >= date('now') and sd.type = 'MAGAZZINO')) ";
4517
+ if (sel_type_str.trim() != '') {
4518
+ query += "and d.type = '" + sel_type_str.trim() + "' ";
4519
+ }
4520
+ if (sel_maker_str.trim() != '') {
4521
+ query += "and d.manifacturer = '" + sel_maker_str.trim() + "' ";
4522
+ }
4497
4523
  if (ordered_by && ordered_by == "ID") {
4498
4524
  query += "order by d.id desc";
4499
4525
  }
@@ -4503,7 +4529,15 @@ function getDevicesNotAllocatedComboSQLite(ordered_by) {
4503
4529
  return query;
4504
4530
  }
4505
4531
 
4506
- function getDevicesNotAllocatedComboMySQL(ordered_by) {
4532
+ function getDevicesNotAllocatedComboMySQL(sel_type, sel_maker,ordered_by) {
4533
+ var sel_type_str = "";
4534
+ if (sel_type) {
4535
+ sel_type_str = sel_type;
4536
+ }
4537
+ var sel_maker_str = "";
4538
+ if (sel_maker) {
4539
+ sel_maker_str = sel_maker;
4540
+ }
4507
4541
  var query = "SELECT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
4508
4542
  query += "case ";
4509
4543
  query += "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) ";
@@ -4518,6 +4552,12 @@ function getDevicesNotAllocatedComboMySQL(ordered_by) {
4518
4552
  query += "where (d.is_removed is null or d.is_removed = 0) "
4519
4553
  query += "and (ds.id_place is null ";
4520
4554
  query += "or (ds.date_in <= CURDATE() and ds.date_out >= CURDATE() and sd.type = 'MAGAZZINO')) ";
4555
+ if (sel_type_str.trim() != '') {
4556
+ query += "and d.type = :dev_type ";
4557
+ }
4558
+ if (sel_maker_str.trim() != '') {
4559
+ query += "and d.manifacturer = :dev_manifacturer ";
4560
+ }
4521
4561
  if (ordered_by && ordered_by == "ID") {
4522
4562
  query += "order by d.id desc";
4523
4563
  }
@@ -4526,15 +4566,15 @@ function getDevicesNotAllocatedComboMySQL(ordered_by) {
4526
4566
  }
4527
4567
  return query;
4528
4568
  }
4529
- function getDevicesNotAllocatedCombo(db_used,ordered_by) {
4569
+ function getDevicesNotAllocatedCombo(db_used, sel_type, sel_maker, ordered_by) {
4530
4570
  var query = "";
4531
4571
  if (db_used) {
4532
4572
  switch (db_used) {
4533
4573
  case 'SQLITE':
4534
- query = getDevicesNotAllocatedComboSQLite(ordered_by);
4574
+ query = getDevicesNotAllocatedComboSQLite(sel_type, sel_maker, ordered_by);
4535
4575
  break;
4536
4576
  case 'MYSQL':
4537
- query = getDevicesNotAllocatedComboMySQL(ordered_by);
4577
+ query = getDevicesNotAllocatedComboMySQL(sel_type, sel_maker, ordered_by);
4538
4578
  break;
4539
4579
  }
4540
4580
  }
@@ -4542,7 +4582,16 @@ function getDevicesNotAllocatedCombo(db_used,ordered_by) {
4542
4582
  }
4543
4583
  // End getDevicesNotAllocatedCombo
4544
4584
  // Define getDevicesAllocatedCombo
4545
- function getDevicesAllocatedComboSQLite(id_site, id_place, ordered_by) {
4585
+ function getDevicesAllocatedComboSQLite(id_site, id_place, sel_type, sel_maker, ordered_by) {
4586
+ var sel_type_str = "";
4587
+ if (sel_type) {
4588
+ sel_type_str = sel_type;
4589
+ }
4590
+ var sel_maker_str = "";
4591
+ if (sel_maker) {
4592
+ sel_maker_str = sel_maker;
4593
+ }
4594
+
4546
4595
  var query = "SELECT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
4547
4596
  query += "case ";
4548
4597
  query += "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) ";
@@ -4557,6 +4606,12 @@ function getDevicesAllocatedComboSQLite(id_site, id_place, ordered_by) {
4557
4606
  query += "where (d.is_removed is null or d.is_removed = 0) "
4558
4607
  query += "and (ds.id_place is not null ";
4559
4608
  query += "or (ds.date_in <= date('now') and ds.date_out >= date('now') and ds.id_site <> " + id_site + " and ds.id_place <> '" + id_place + "')) ";
4609
+ if (sel_type_str.trim() != '') {
4610
+ query += "and d.type = '" + sel_type_str.trim() + "' ";
4611
+ }
4612
+ if (sel_maker_str.trim() != '') {
4613
+ query += "and d.manifacturer = '" + sel_maker_str.trim() + "' ";
4614
+ }
4560
4615
  if (ordered_by && ordered_by == "ID") {
4561
4616
  query += "order by d.id desc";
4562
4617
  }
@@ -4565,7 +4620,15 @@ function getDevicesAllocatedComboSQLite(id_site, id_place, ordered_by) {
4565
4620
  }
4566
4621
  return query;
4567
4622
  }
4568
- function getDevicesAllocatedComboMySQL(id_site, id_place, ordered_by) {
4623
+ function getDevicesAllocatedComboMySQL(id_site, id_place, sel_type, sel_maker, ordered_by) {
4624
+ var sel_type_str = "";
4625
+ if (sel_type) {
4626
+ sel_type_str = sel_type;
4627
+ }
4628
+ var sel_maker_str = "";
4629
+ if (sel_maker) {
4630
+ sel_maker_str = sel_maker;
4631
+ }
4569
4632
  var query = "SELECT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
4570
4633
  query += "case ";
4571
4634
  query += "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) ";
@@ -4580,6 +4643,12 @@ function getDevicesAllocatedComboMySQL(id_site, id_place, ordered_by) {
4580
4643
  query += "where (d.is_removed is null or d.is_removed = 0) "
4581
4644
  query += "and (ds.id_place is not null ";
4582
4645
  query += "or (ds.date_in <= CURDATE() and ds.date_out >= CURDATE() and ds.id_site <> :id_site and ds.id_place <> :id_place)) ";
4646
+ if (sel_type_str.trim() != '') {
4647
+ query += "and d.type = :dev_type ";
4648
+ }
4649
+ if (sel_maker_str.trim() != '') {
4650
+ query += "and d.manifacturer = :dev_manifacturer ";
4651
+ }
4583
4652
  if (ordered_by && ordered_by == "ID") {
4584
4653
  query += "order by d.id desc";
4585
4654
  }
@@ -4588,15 +4657,15 @@ function getDevicesAllocatedComboMySQL(id_site, id_place, ordered_by) {
4588
4657
  }
4589
4658
  return query;
4590
4659
  }
4591
- function getDevicesAllocatedCombo(db_used, id_site, id_place, ordered_by) {
4660
+ function getDevicesAllocatedCombo(db_used, id_site, id_place, sel_type, sel_maker, ordered_by) {
4592
4661
  var query = "";
4593
4662
  if (db_used) {
4594
4663
  switch (db_used) {
4595
4664
  case 'SQLITE':
4596
- query = getDevicesAllocatedComboSQLite(id_site, id_place, ordered_by);
4665
+ query = getDevicesAllocatedComboSQLite(id_site, id_place, sel_type, sel_maker, ordered_by);
4597
4666
  break;
4598
4667
  case 'MYSQL':
4599
- query = getDevicesAllocatedComboMySQL(id_site, id_place, ordered_by);
4668
+ query = getDevicesAllocatedComboMySQL(id_site, id_place, sel_type, sel_maker, ordered_by);
4600
4669
  break;
4601
4670
  }
4602
4671
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alsmanager_lib",
3
- "version": "2.0.26",
3
+ "version": "2.0.28",
4
4
  "description": "Funzioni per ALSManager",
5
5
  "license": "ISC",
6
6
  "author": "Luca Cattani",