alsmanager_lib 2.0.27 → 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 +26 -14
  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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alsmanager_lib",
3
- "version": "2.0.27",
3
+ "version": "2.0.28",
4
4
  "description": "Funzioni per ALSManager",
5
5
  "license": "ISC",
6
6
  "author": "Luca Cattani",