alsmanager_lib 2.0.41 → 2.0.42

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 +57 -57
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -2235,7 +2235,7 @@ function getDevicesSelect(db_used, search_type, inv_code, dev_type, marca, is_PN
2235
2235
  // End Device select
2236
2236
  // Device Select by site
2237
2237
  function getDevicesSelectBySiteSQLite(id_site, dev_type) {
2238
- var query = "select distinct devices.id, devices.type as Tipo, devices.manifacturer as Marca, devices.model as modello, ";
2238
+ var query = "select distinct d.id, d.type as Tipo, d.manifacturer as Marca, d.model as modello, ";
2239
2239
  query += "case ";
2240
2240
  query += "when inv_ict3_number != '' and inv_ict3_number is not null then inv_ict3_number ";
2241
2241
  query += "when inv_pnrr_number != '' and inv_pnrr_number is not null then inv_pnrr_number ";
@@ -2248,21 +2248,21 @@ function getDevicesSelectBySiteSQLite(id_site, dev_type) {
2248
2248
  query += "when trim(inv_pnrr_number) = '' then '' ";
2249
2249
  query += "else 'SI' ";
2250
2250
  query += "end as PNRR ";
2251
- query += " from devices ";
2252
- query += "inner join device_site on device_site.id_device = devices.id ";
2253
- query += "inner join sites on sites.id = device_site.id_site ";
2254
- query += "where (date('now') >= device_site.date_in and date('now') <= device_site.date_out) ";
2255
- query += "and (devices.is_removed is null or devices.is_removed = 0) ";
2256
- query += "and sites.id = " + id_site + " ";
2251
+ query += " from devices d ";
2252
+ query += "inner join device_site ds on ds.id_device = d.id ";
2253
+ query += "inner join sites s on s.id = ds.id_site ";
2254
+ query += "where (date('now') >= ds.date_in and date('now') <= ds.date_out) ";
2255
+ query += "and (d.is_removed is null or d.is_removed = 0) ";
2256
+ query += "and s.id = " + id_site + " ";
2257
2257
  if (dev_type && dev_type != '') {
2258
- query += "and devices.type = '" + dev_type + "' ";
2258
+ query += "and d.type = '" + dev_type + "' ";
2259
2259
  }
2260
- query += "order by devices.type ";
2260
+ query += "order by d.type ";
2261
2261
  return query;
2262
2262
  }
2263
2263
 
2264
2264
  function getDevicesSelectBySiteMySQL(id_site, dev_type) {
2265
- var query = "select DISTINCT devices.id, devices.type as Tipo, devices.manifacturer as Marca, devices.model as modello, ";
2265
+ var query = "select DISTINCT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as modello, ";
2266
2266
  query += "case ";
2267
2267
  query += "when inv_ict3_number != '' and inv_ict3_number is not null then inv_ict3_number ";
2268
2268
  query += "when inv_pnrr_number != '' and inv_pnrr_number is not null then inv_pnrr_number ";
@@ -2275,16 +2275,16 @@ function getDevicesSelectBySiteMySQL(id_site, dev_type) {
2275
2275
  query += "when trim(inv_pnrr_number) = '' then '' ";
2276
2276
  query += "else 'SI' ";
2277
2277
  query += "end as PNRR ";
2278
- query += " from devices ";
2279
- query += "inner join device_site on device_site.id_device = devices.id ";
2280
- query += "inner join sites on sites.id = device_site.id_site ";
2281
- query += "where (CURDATE() >= device_site.date_in and CURDATE() <= device_site.date_out) ";
2282
- query += "and (devices.is_removed is null or devices.is_removed = 0) ";
2283
- query += "and sites.id = :id_site ";
2278
+ query += " from devices d ";
2279
+ query += "inner join device_site ds on ds.id_device = d.id ";
2280
+ query += "inner join sites s on s.id = ds.id_site ";
2281
+ query += "where (CURDATE() >= ds.date_in and CURDATE() <= ds.date_out) ";
2282
+ query += "and (d.is_removed is null or d.is_removed = 0) ";
2283
+ query += "and s.id = :id_site ";
2284
2284
  if (dev_type && dev_type != '') {
2285
- query += "and devices.type = :dev_type ";
2285
+ query += "and d.type = :dev_type ";
2286
2286
  }
2287
- query += "order by devices.type ";
2287
+ query += "order by d.type ";
2288
2288
 
2289
2289
  return query;
2290
2290
  }
@@ -2305,7 +2305,7 @@ function getDevicesSelectBySite(db_used, id_site, dev_type) {
2305
2305
  //End Device Select by site
2306
2306
  // Device per plesso
2307
2307
  function getDevicesSelectByPlaceSQLite(id_place, dev_type) {
2308
- var query = "select distinct devices.id, devices.type as Tipo, devices.manifacturer as Marca, devices.model as modello, ";
2308
+ var query = "select distinct d.id, d.type as Tipo, d.manifacturer as Marca, d.model as modello, ";
2309
2309
  query += "case ";
2310
2310
  query += "when inv_ict3_number != '' and inv_ict3_number is not null then inv_ict3_number ";
2311
2311
  query += "when inv_pnrr_number != '' and inv_pnrr_number is not null then inv_pnrr_number ";
@@ -2318,16 +2318,16 @@ function getDevicesSelectByPlaceSQLite(id_place, dev_type) {
2318
2318
  query += "when trim(inv_pnrr_number) = '' then '' ";
2319
2319
  query += "else 'SI' ";
2320
2320
  query += "end as PNRR ";
2321
- query += " from devices ";
2322
- query += "inner join device_site on device_site.id_device = devices.id ";
2323
- query += "inner join sites on sites.id = device_site.id_site ";
2324
- query += "where (date('now') >= device_site.date_in and date('now') <= device_site.date_out) ";
2325
- query += "and (devices.is_removed is null or devices.is_removed = 0) ";
2326
- query += "and sites.id_place = '" + id_place + "' ";
2321
+ query += " from devices d ";
2322
+ query += "inner join device_site ds on ds.id_device = d.id ";
2323
+ query += "inner join sites s on s.id = ds.id_site ";
2324
+ query += "where (date('now') >= ds.date_in and date('now') <= ds.date_out) ";
2325
+ query += "and (d.is_removed is null or d.is_removed = 0) ";
2326
+ query += "and s.id_place = '" + id_place + "' ";
2327
2327
  if (dev_type && dev_type != '') {
2328
- query += "and devices.type = '" + dev_type + "' ";
2328
+ query += "and d.type = '" + dev_type + "' ";
2329
2329
  }
2330
- query += "order by devices.type ";
2330
+ query += "order by d.type ";
2331
2331
  return query;
2332
2332
  }
2333
2333
 
@@ -7989,40 +7989,40 @@ function queryFunzioneByPlaceAndFloor(db_used, id_place, piano) {
7989
7989
 
7990
7990
 
7991
7991
  function querySitesSQLite(place, piano, funzione) {
7992
- var query = "SELECT site_destinations.id_site as id, sites.id_place as Plesso, site_destinations.name as Nome, sites.mark as Codice, sites.floor as Piano, site_destinations.type as Funzione from site_destinations";
7993
- query += " LEFT JOIN sites ON sites.id = site_destinations.id_site"
7994
- query += " where date('now') >= site_destinations.date_start and date('now') <= site_destinations.date_end";
7992
+ var query = "SELECT sd.id_site as id, s.id_place as Plesso, sd.name as Nome, s.mark as Codice, s.floor as Piano, sd.type as Funzione from site_destinations sd";
7993
+ query += " LEFT JOIN sites s ON s.id = sd.id_site"
7994
+ query += " where date('now') >= sd.date_start and date('now') <= sd.date_end";
7995
7995
 
7996
7996
  if (place) {
7997
- query += " and sites.id_place = '" + place + "'";
7997
+ query += " and s.id_place = '" + place + "'";
7998
7998
  }
7999
7999
  if (funzione) {
8000
- query += " and site_destinations.type = '" + funzione + "'";
8000
+ query += " and sd.type = '" + funzione + "'";
8001
8001
  }
8002
8002
 
8003
8003
  if (piano) {
8004
- query += " and sites.floor = '" + piano + "'";
8004
+ query += " and s.floor = '" + piano + "'";
8005
8005
  }
8006
- query += " order by sites.id_place, sites.floor";
8006
+ query += " order by s.id_place, s.floor";
8007
8007
  return query;
8008
8008
  }
8009
8009
 
8010
8010
  function querySitesMySQL(place, piano, funzione) {
8011
- var query = "SELECT DISTINCT site_destinations.id_site as id, sites.id_place as Plesso, site_destinations.name as Nome, sites.mark as Codice, sites.floor as Piano, site_destinations.type as Funzione from site_destinations";
8012
- query += " LEFT JOIN sites ON sites.id = site_destinations.id_site"
8013
- query += " where CURDATE() >= site_destinations.date_start and CURDATE() <= site_destinations.date_end";
8011
+ var query = "SELECT DISTINCT sd.id_site as id, s.id_place as Plesso, sd.name as Nome, s.mark as Codice, s.floor as Piano, sd.type as Funzione from site_destinations sd ";
8012
+ query += " LEFT JOIN sites s ON s.id = sd.id_site"
8013
+ query += " where CURDATE() >= sd.date_start and CURDATE() <= sd.date_end";
8014
8014
 
8015
8015
  if (place) {
8016
- query += " and sites.id_place = :id_place";
8016
+ query += " and s.id_place = :id_place";
8017
8017
  }
8018
8018
  if (funzione) {
8019
- query += " and site_destinations.type = :funzione";
8019
+ query += " and sd.type = :funzione";
8020
8020
  }
8021
8021
 
8022
8022
  if (piano) {
8023
- query += " and sites.floor = :piano";
8023
+ query += " and s.floor = :piano";
8024
8024
  }
8025
- query += " order by sites.id_place, sites.floor";
8025
+ query += " order by s.id_place, s.floor";
8026
8026
  return query;
8027
8027
  }
8028
8028
 
@@ -8044,33 +8044,33 @@ function querySites(db_used, place, piano, funzione) {
8044
8044
 
8045
8045
  //Sites by devices
8046
8046
  function getSitesFromDeviceSQLite(id_device, prec_pos) {
8047
- var query = "SELECT places.mark as Sigla, places.name as Plesso, site_destinations.name as Aula, site_destinations.type as Funzione, sites.floor as Piano from device_site";
8048
- query += " JOIN sites ON sites.id = device_site.id_site";
8049
- query += " JOIN site_destinations ON site_destinations.id_site = device_site.id_site";
8050
- query += " JOIN places ON places.mark = site_destinations.id_place";
8047
+ var query = "SELECT p.mark as Sigla, p.name as Plesso, sd.name as Aula, sd.type as Funzione, s.floor as Piano from device_site ds ";
8048
+ query += " JOIN sites s ON s.id = ds.id_site";
8049
+ query += " JOIN site_destinations sd ON sd.id_site = ds.id_site";
8050
+ query += " JOIN places p ON p.mark = sd.id_place";
8051
8051
  if (prec_pos == 1) {
8052
- query += " where device_site.id_device = " + id_device;
8052
+ query += " where ds.id_device = " + id_device;
8053
8053
  }
8054
8054
  else {
8055
- query += " where (date('now') >= device_site.date_in and date('now') <= device_site.date_out) and";
8056
- query += " device_site.id_device = " + id_device;
8055
+ query += " where (date('now') >= ds.date_in and date('now') <= ds.date_out) and";
8056
+ query += " ds.id_device = " + id_device;
8057
8057
  }
8058
- query += " order by site_destinations.name, sites.floor";
8058
+ query += " order by sd.name, s.floor";
8059
8059
  return query;
8060
8060
  }
8061
8061
  function getSitesFromDeviceMySQL(id_device, prec_pos) {
8062
- var query = "SELECT places.mark as Sigla, places.name as Plesso, site_destinations.name as Aula, site_destinations.type as Funzione, sites.floor as Piano from device_site";
8063
- query += " JOIN sites ON sites.id = device_site.id_site";
8064
- query += " JOIN site_destinations ON site_destinations.id_site = device_site.id_site";
8065
- query += " JOIN places ON places.mark = site_destinations.id_place";
8062
+ var query = "SELECT p.mark as Sigla, p.name as Plesso, sd.name as Aula, sd.type as Funzione, s.floor as Piano from device_site ds ";
8063
+ query += " JOIN sites s ON s.id = ds.id_site";
8064
+ query += " JOIN site_destinations sd ON sd.id_site = ds.id_site";
8065
+ query += " JOIN places p ON p.mark = sd.id_place";
8066
8066
  if (prec_pos == 1) {
8067
- query += " where device_site.id_device = :id_device";
8067
+ query += " where ds.id_device = :id_device";
8068
8068
  }
8069
8069
  else {
8070
- query += " where (CURDATE() >= device_site.date_in and CURDATE() <= device_site.date_out) and";
8071
- query += " device_site.id_device = :id_device";
8070
+ query += " where (CURDATE() >= ds.date_in and CURDATE() <= ds.date_out) and";
8071
+ query += " ds.id_device = :id_device";
8072
8072
  }
8073
- query += " order by site_destinations.name, sites.floor";
8073
+ query += " order by sd.name, s.floor";
8074
8074
  return query;
8075
8075
  }
8076
8076
  function getSitesFromDevice(db_used, id_device, prec_pos) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alsmanager_lib",
3
- "version": "2.0.41",
3
+ "version": "2.0.42",
4
4
  "description": "Funzioni per ALSManager",
5
5
  "license": "ISC",
6
6
  "author": "Luca Cattani",