alsmanager_lib 2.0.60 → 2.0.62

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 +23 -12
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -156,20 +156,20 @@ function removeConnector(db_used, id_device, conn_obj) {
156
156
  //End Manage connectors
157
157
  // Manage Storage
158
158
  function queryStorageManifactures() {
159
- var query = "SELECT DISTINCT upper(storage_manifacturer) as marca from device_storages order by storage_manifacturer";
159
+ var query = "SELECT DISTINCT upper(trim(storage_manifacturer)) as marca from device_storages order by storage_manifacturer";
160
160
  return query;
161
161
  }
162
162
 
163
163
  function queryStorageModelsSQLite(marca) {
164
- var query = "SELECT DISTINCT upper(storage_model) as modello from device_storages ";
165
- query += "where upper(storage_manifacturer) = " + marca + " ";
164
+ var query = "SELECT DISTINCT upper(trim(storage_model)) as modello from device_storages ";
165
+ query += "where upper(trim(storage_manifacturer)) = '" + marca + "' ";
166
166
  query += "order by storage_model";
167
167
  return query;
168
168
  }
169
169
 
170
170
  function queryStorageModelsMySQL(marca) {
171
- var query = "SELECT DISTINCT upper(storage_model) as modello from device_storages ";
172
- query += "where upper(storage_manifacturer) = :marca ";
171
+ var query = "SELECT DISTINCT upper(trim(storage_model)) as modello from device_storages ";
172
+ query += "where upper(trim(storage_manifacturer)) = :marca ";
173
173
  query += "order by storage_model";
174
174
  return query;
175
175
  }
@@ -2126,7 +2126,7 @@ function queryDeviceModels() {
2126
2126
  }
2127
2127
 
2128
2128
  // Device select
2129
- function getDevicesSelectSQLite(search_type, inv_code, dev_type, marca, is_PNRR, dev_status, id_dev_exclude) {
2129
+ function getDevicesSelectSQLite(search_type, inv_code, dev_type, marca, is_PNRR, dev_status, dev_gestione, id_dev_exclude) {
2130
2130
  var query = "SELECT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
2131
2131
  query += "case ";
2132
2132
  query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then d.inv_ict3_number ";
@@ -2138,9 +2138,11 @@ function getDevicesSelectSQLite(search_type, inv_code, dev_type, marca, is_PNRR,
2138
2138
  query += "from devices d ";
2139
2139
  if (dev_status)
2140
2140
  query += "left join device_usage du on d.id = du.id_device"
2141
+ if (dev_gestione)
2142
+ query += "left join device_gestioni dg on d.id = dg.id_device"
2141
2143
 
2142
2144
  var where_clause = " where (d.is_removed is null or d.is_removed = 0) ";
2143
- if (inv_code || dev_type || marca || (is_PNRR && is_PNRR > 0) || dev_status) {
2145
+ if (inv_code || dev_type || marca || (is_PNRR && is_PNRR > 0) || dev_status || dev_gestione) {
2144
2146
  if (inv_code) {
2145
2147
  if (search_type == "ESATTA") {
2146
2148
  where_clause += " and (d.inv_ict3_number = '" + inv_code + "' or ";
@@ -2180,6 +2182,9 @@ function getDevicesSelectSQLite(search_type, inv_code, dev_type, marca, is_PNRR,
2180
2182
  if (dev_status) {
2181
2183
  where_clause += " du.status = " + dev_status + " and date('now') >= du.date_status";
2182
2184
  }
2185
+ if (dev_gestione) {
2186
+ where_clause += " dg.id_gestione = " + dev_gestione + " and date('now') >= dg.date_start and date('now') <= dg.date_end";
2187
+ }
2183
2188
  }
2184
2189
  }
2185
2190
  else {
@@ -2191,7 +2196,7 @@ function getDevicesSelectSQLite(search_type, inv_code, dev_type, marca, is_PNRR,
2191
2196
  return query;
2192
2197
  }
2193
2198
 
2194
- function getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, is_PNRR, dev_status, id_dev_exclude) {
2199
+ function getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, is_PNRR, dev_status, dev_gestione, id_dev_exclude) {
2195
2200
  var query = "SELECT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
2196
2201
  query += "case ";
2197
2202
  query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then d.inv_ict3_number ";
@@ -2203,9 +2208,12 @@ function getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, is_PNRR,
2203
2208
  query += "from devices d ";
2204
2209
  if (dev_status)
2205
2210
  query += "left join device_usage du on d.id = du.id_device"
2211
+ if (dev_gestione)
2212
+ query += "left join device_gestioni dg on d.id = dg.id_device"
2213
+
2206
2214
 
2207
2215
  var where_clause = " where (d.is_removed is null or d.is_removed = 0) ";
2208
- if (inv_code || dev_type || marca || (is_PNRR && is_PNRR > 0)) {
2216
+ if (inv_code || dev_type || marca || (is_PNRR && is_PNRR > 0) || dev_gestione) {
2209
2217
  if (inv_code) {
2210
2218
  if (search_type == "ESATTA") {
2211
2219
  where_clause += " and (d.inv_ict3_number = :inv_code or ";
@@ -2245,6 +2253,9 @@ function getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, is_PNRR,
2245
2253
  if (dev_status) {
2246
2254
  where_clause += " du.status = :dev_status and CURRDATE() >= du.date_status";
2247
2255
  }
2256
+ if (dev_gestione) {
2257
+ where_clause += " dg.id_gestione = :dev_gestione and CURDATE() >= dg.date_start and CURDATE() <= dg.date_end";
2258
+ }
2248
2259
  }
2249
2260
  }
2250
2261
  else {
@@ -2257,15 +2268,15 @@ function getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, is_PNRR,
2257
2268
  query += " order by id";
2258
2269
  return query;
2259
2270
  }
2260
- function getDevicesSelect(db_used, search_type, inv_code, dev_type, marca, is_PNRR, dev_status, id_dev_exclude) {
2271
+ function getDevicesSelect(db_used, search_type, inv_code, dev_type, marca, is_PNRR, dev_status, dev_gestione, id_dev_exclude) {
2261
2272
  var query = "";
2262
2273
  if (db_used) {
2263
2274
  switch (db_used) {
2264
2275
  case 'SQLITE':
2265
- query = getDevicesSelectSQLite(search_type, inv_code, dev_type, marca, is_PNRR, dev_status, id_dev_exclude);
2276
+ query = getDevicesSelectSQLite(search_type, inv_code, dev_type, marca, is_PNRR, dev_status, dev_gestione, id_dev_exclude);
2266
2277
  break;
2267
2278
  case 'MYSQL':
2268
- query = getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, is_PNRR, dev_status, id_dev_exclude);
2279
+ query = getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, is_PNRR, dev_status, dev_gestione, id_dev_exclude);
2269
2280
  break;
2270
2281
  }
2271
2282
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  ".": "./lib/modules.js",
5
5
  "./dbconn": "./lib/dbconn.js"
6
6
  },
7
- "version": "2.0.60",
7
+ "version": "2.0.62",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",