alsmanager_lib 2.0.61 → 2.0.63

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 +27 -10
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -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 ";
@@ -2173,12 +2175,18 @@ function getDevicesSelectSQLite(search_type, inv_code, dev_type, marca, is_PNRR,
2173
2175
  }
2174
2176
  if (is_PNRR && is_PNRR > 0) {
2175
2177
  where_clause += " (d.inv_pnrr_number <> '' and inv_pnrr_number is not null) ";
2176
- if (dev_status) {
2178
+ if (dev_status || dev_gestione) {
2177
2179
  where_clause += " and ";
2178
2180
  }
2179
2181
  }
2180
2182
  if (dev_status) {
2181
2183
  where_clause += " du.status = " + dev_status + " and date('now') >= du.date_status";
2184
+ if (dev_gestione) {
2185
+ where_clause += " and ";
2186
+ }
2187
+ }
2188
+ if (dev_gestione) {
2189
+ where_clause += " dg.id_gestione = " + dev_gestione + " and date('now') >= dg.date_start and date('now') <= dg.date_end";
2182
2190
  }
2183
2191
  }
2184
2192
  }
@@ -2191,7 +2199,7 @@ function getDevicesSelectSQLite(search_type, inv_code, dev_type, marca, is_PNRR,
2191
2199
  return query;
2192
2200
  }
2193
2201
 
2194
- function getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, is_PNRR, dev_status, id_dev_exclude) {
2202
+ function getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, is_PNRR, dev_status, dev_gestione, id_dev_exclude) {
2195
2203
  var query = "SELECT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
2196
2204
  query += "case ";
2197
2205
  query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then d.inv_ict3_number ";
@@ -2203,9 +2211,12 @@ function getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, is_PNRR,
2203
2211
  query += "from devices d ";
2204
2212
  if (dev_status)
2205
2213
  query += "left join device_usage du on d.id = du.id_device"
2214
+ if (dev_gestione)
2215
+ query += "left join device_gestioni dg on d.id = dg.id_device"
2216
+
2206
2217
 
2207
2218
  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)) {
2219
+ if (inv_code || dev_type || marca || (is_PNRR && is_PNRR > 0) || dev_gestione) {
2209
2220
  if (inv_code) {
2210
2221
  if (search_type == "ESATTA") {
2211
2222
  where_clause += " and (d.inv_ict3_number = :inv_code or ";
@@ -2238,12 +2249,18 @@ function getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, is_PNRR,
2238
2249
  }
2239
2250
  if (is_PNRR && is_PNRR > 0) {
2240
2251
  where_clause += " (d.inv_pnrr_number <> '' and inv_pnrr_number is not null) ";
2241
- if (dev_status) {
2252
+ if (dev_status || dev_gestione) {
2242
2253
  where_clause += " and ";
2243
2254
  }
2244
2255
  }
2245
2256
  if (dev_status) {
2246
- where_clause += " du.status = :dev_status and CURRDATE() >= du.date_status";
2257
+ where_clause += " du.status = :dev_status and CURDATE() >= du.date_status";
2258
+ if (dev_gestione) {
2259
+ where_clause += " and ";
2260
+ }
2261
+ }
2262
+ if (dev_gestione) {
2263
+ where_clause += " dg.id_gestione = :dev_gestione and CURDATE() >= dg.date_start and CURDATE() <= dg.date_end";
2247
2264
  }
2248
2265
  }
2249
2266
  }
@@ -2257,15 +2274,15 @@ function getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, is_PNRR,
2257
2274
  query += " order by id";
2258
2275
  return query;
2259
2276
  }
2260
- function getDevicesSelect(db_used, search_type, inv_code, dev_type, marca, is_PNRR, dev_status, id_dev_exclude) {
2277
+ function getDevicesSelect(db_used, search_type, inv_code, dev_type, marca, is_PNRR, dev_status, dev_gestione, id_dev_exclude) {
2261
2278
  var query = "";
2262
2279
  if (db_used) {
2263
2280
  switch (db_used) {
2264
2281
  case 'SQLITE':
2265
- query = getDevicesSelectSQLite(search_type, inv_code, dev_type, marca, is_PNRR, dev_status, id_dev_exclude);
2282
+ query = getDevicesSelectSQLite(search_type, inv_code, dev_type, marca, is_PNRR, dev_status, dev_gestione, id_dev_exclude);
2266
2283
  break;
2267
2284
  case 'MYSQL':
2268
- query = getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, is_PNRR, dev_status, id_dev_exclude);
2285
+ query = getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, is_PNRR, dev_status, dev_gestione, id_dev_exclude);
2269
2286
  break;
2270
2287
  }
2271
2288
  }
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.61",
7
+ "version": "2.0.63",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",