alsmanager_lib 2.0.27 → 2.0.29

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 +39 -21
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -2229,7 +2229,7 @@ function getDevicesSelect(db_used, search_type, inv_code, dev_type, marca, is_PN
2229
2229
  }
2230
2230
  // End Device select
2231
2231
  // Device Select by site
2232
- function getDevicesSelectBySiteSQLite(id_site) {
2232
+ function getDevicesSelectBySiteSQLite(id_site, dev_type) {
2233
2233
  var query = "select distinct devices.id, devices.type as Tipo, devices.manifacturer as Marca, devices.model as modello, ";
2234
2234
  query += "case ";
2235
2235
  query += "when inv_ict3_number != '' and inv_ict3_number is not null then inv_ict3_number ";
@@ -2248,11 +2248,14 @@ function getDevicesSelectBySiteSQLite(id_site) {
2248
2248
  query += "inner join sites on sites.id = device_site.id_site ";
2249
2249
  query += "where (date('now') >= device_site.date_in and date('now') <= device_site.date_out) ";
2250
2250
  query += "and (devices.is_removed is null or devices.is_removed = 0) ";
2251
- query += "and sites.id = " + id_site;
2251
+ query += "and sites.id = " + id_site + " ";
2252
+ if (dev_type && dev_type != '') {
2253
+ query += "and devices.type = '" + dev_type + "' ";
2254
+ }
2252
2255
  return query;
2253
2256
  }
2254
2257
 
2255
- function getDevicesSelectBySiteMySQL(id_site) {
2258
+ function getDevicesSelectBySiteMySQL(id_site, dev_type) {
2256
2259
  var query = "select DISTINCT devices.id, devices.type as Tipo, devices.manifacturer as Marca, devices.model as modello, ";
2257
2260
  query += "case ";
2258
2261
  query += "when inv_ict3_number != '' and inv_ict3_number is not null then inv_ict3_number ";
@@ -2271,18 +2274,21 @@ function getDevicesSelectBySiteMySQL(id_site) {
2271
2274
  query += "inner join sites on sites.id = device_site.id_site ";
2272
2275
  query += "where (CURDATE() >= device_site.date_in and CURDATE() <= device_site.date_out) ";
2273
2276
  query += "and (devices.is_removed is null or devices.is_removed = 0) ";
2274
- query += "and sites.id = :id_site";
2277
+ query += "and sites.id = :id_site ";
2278
+ if (dev_type && dev_type != '') {
2279
+ query += "and devices.type = :dev_type ";
2280
+ }
2275
2281
  return query;
2276
2282
  }
2277
- function getDevicesSelectBySite(db_used, id_site) {
2283
+ function getDevicesSelectBySite(db_used, id_site, dev_type) {
2278
2284
  var query = "";
2279
2285
  if (db_used) {
2280
2286
  switch (db_used) {
2281
2287
  case 'SQLITE':
2282
- query = getDevicesSelectBySiteSQLite(id_site);
2288
+ query = getDevicesSelectBySiteSQLite(id_site, dev_type);
2283
2289
  break;
2284
2290
  case 'MYSQL':
2285
- query = getDevicesSelectBySiteMySQL(id_site);
2291
+ query = getDevicesSelectBySiteMySQL(id_site, dev_type);
2286
2292
  break;
2287
2293
  }
2288
2294
  }
@@ -2290,7 +2296,7 @@ function getDevicesSelectBySite(db_used, id_site) {
2290
2296
  }
2291
2297
  //End Device Select by site
2292
2298
  // Device per plesso
2293
- function getDevicesSelectByPlaceSQLite(id_place) {
2299
+ function getDevicesSelectByPlaceSQLite(id_place, dev_type) {
2294
2300
  var query = "select distinct devices.id, devices.type as Tipo, devices.manifacturer as Marca, devices.model as modello, ";
2295
2301
  query += "case ";
2296
2302
  query += "when inv_ict3_number != '' and inv_ict3_number is not null then inv_ict3_number ";
@@ -2309,11 +2315,14 @@ function getDevicesSelectByPlaceSQLite(id_place) {
2309
2315
  query += "inner join sites on sites.id = device_site.id_site ";
2310
2316
  query += "where (date('now') >= device_site.date_in and date('now') <= device_site.date_out) ";
2311
2317
  query += "and (devices.is_removed is null or devices.is_removed = 0) ";
2312
- query += "and sites.id_place = '" + id_place + "'";
2318
+ query += "and sites.id_place = '" + id_place + "' ";
2319
+ if (dev_type && dev_type != '') {
2320
+ query += "and devices.type = '" + dev_type + "' ";
2321
+ }
2313
2322
  return query;
2314
2323
  }
2315
2324
 
2316
- function getDevicesSelectByPlaceMySQL(id_place) {
2325
+ function getDevicesSelectByPlaceMySQL(id_place, dev_type) {
2317
2326
  var query = "select DISTINCT devices.id, devices.type as Tipo, devices.manifacturer as Marca, devices.model as modello, ";
2318
2327
  query += "case ";
2319
2328
  query += "when inv_ict3_number != '' and inv_ict3_number is not null then inv_ict3_number ";
@@ -2332,18 +2341,21 @@ function getDevicesSelectByPlaceMySQL(id_place) {
2332
2341
  query += "inner join sites on sites.id = device_site.id_site ";
2333
2342
  query += "where (CURDATE() >= device_site.date_in and CURDATE() <= device_site.date_out) ";
2334
2343
  query += "and (devices.is_removed is null or devices.is_removed = 0) ";
2335
- query += "and sites.id_place = :id_place";
2344
+ query += "and sites.id_place = :id_place ";
2345
+ if (dev_type && dev_type != '') {
2346
+ query += "and devices.type = :dev_type ";
2347
+ }
2336
2348
  return query;
2337
2349
  }
2338
- function getDevicesSelectByPlace(db_used, id_place) {
2350
+ function getDevicesSelectByPlace(db_used, id_place, dev_type) {
2339
2351
  var query = "";
2340
2352
  if (db_used) {
2341
2353
  switch (db_used) {
2342
2354
  case 'SQLITE':
2343
- query = getDevicesSelectByPlaceSQLite(id_place);
2355
+ query = getDevicesSelectByPlaceSQLite(id_place, dev_type);
2344
2356
  break;
2345
2357
  case 'MYSQL':
2346
- query = getDevicesSelectByPlaceMySQL(id_place);
2358
+ query = getDevicesSelectByPlaceMySQL(id_place, dev_type);
2347
2359
  break;
2348
2360
  }
2349
2361
  }
@@ -2358,8 +2370,8 @@ function getDevicesCounterBySiteSQLite(id_site) {
2358
2370
  query += "inner join device_site ds on ds.id_device = d.id ";
2359
2371
  query += "where (date('now') >= ds.date_in and date('now') <= ds.date_out) ";
2360
2372
  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";
2373
+ query += "and ds.id_site = " + id_site + " ";
2374
+ query += "group by d.type";
2363
2375
  return query;
2364
2376
  }
2365
2377
 
@@ -3020,7 +3032,7 @@ function getDevicesSelectCombo(db_used, categoria, id_dev_exclude, with_properti
3020
3032
  }
3021
3033
  //End get devices for combo
3022
3034
  // Get device by site combo
3023
- function getDevicesSelectBySiteComboSQLite(id_site) {
3035
+ function getDevicesSelectBySiteComboSQLite(id_site, dev_type) {
3024
3036
  var query = "SELECT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
3025
3037
  query += "case ";
3026
3038
  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 +3046,13 @@ function getDevicesSelectBySiteComboSQLite(id_site) {
3034
3046
  query += "where (d.is_removed is null or d.is_removed = 0) ";
3035
3047
  query += "and ds.id_site = " + id_site + " ";
3036
3048
  query += "and date('now') >= ds.date_in and date('now') <= ds.date_out ";
3049
+ if (dev_type && dev_type != '') {
3050
+ query += "and d.type = '" + dev_type + "' ";
3051
+ }
3037
3052
  query += "order by d.inv_ict3_number";
3038
3053
  return query;
3039
3054
  }
3040
- function getDevicesSelectBySiteComboMySQL(id_site) {
3055
+ function getDevicesSelectBySiteComboMySQL(id_site, dev_type) {
3041
3056
  var query = "SELECT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
3042
3057
  query += "case ";
3043
3058
  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 +3066,22 @@ function getDevicesSelectBySiteComboMySQL(id_site) {
3051
3066
  query += "where (d.is_removed is null or d.is_removed = 0) ";
3052
3067
  query += "and ds.id_site = :id_site ";
3053
3068
  query += "and CURDATE() >= ds.date_in and CURDATE() <= ds.date_out ";
3069
+ if (dev_type && dev_type != '') {
3070
+ query += "and d.type = :dev_type ";
3071
+ }
3054
3072
  query += "order by d.inv_ict3_number";
3055
3073
  return query;
3056
3074
  }
3057
3075
 
3058
- function getDevicesSelectBySiteCombo(db_used, id_site) {
3076
+ function getDevicesSelectBySiteCombo(db_used, id_site, dev_type) {
3059
3077
  var query = "";
3060
3078
  if (db_used) {
3061
3079
  switch (db_used) {
3062
3080
  case 'SQLITE':
3063
- query = getDevicesSelectBySiteComboSQLite(id_site);
3081
+ query = getDevicesSelectBySiteComboSQLite(id_site, dev_type);
3064
3082
  break;
3065
3083
  case 'MYSQL':
3066
- query = getDevicesSelectBySiteComboMySQL(id_site);
3084
+ query = getDevicesSelectBySiteComboMySQL(id_site, dev_type);
3067
3085
  break;
3068
3086
  }
3069
3087
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alsmanager_lib",
3
- "version": "2.0.27",
3
+ "version": "2.0.29",
4
4
  "description": "Funzioni per ALSManager",
5
5
  "license": "ISC",
6
6
  "author": "Luca Cattani",