alsmanager_lib 1.0.32 → 1.0.34

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 +746 -22
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -185,7 +185,7 @@ function getStorageByIdMySQL() {
185
185
  return query;
186
186
  }
187
187
 
188
- function getStorageById(db_user, id_storage) {
188
+ function getStorageById(db_used, id_storage) {
189
189
  var query = "";
190
190
  if (db_used) {
191
191
  switch (db_used) {
@@ -2033,6 +2033,263 @@ function getDevicesWithProperties(db_used, id_device) {
2033
2033
  }
2034
2034
 
2035
2035
  // End get devices with properties
2036
+ // Selezione dati da inventarii...
2037
+ function getBeniDaInventariSQLite(table_name, inv_code, include_imp, is_pnrr, is_dismissione) {
2038
+ var query = "";
2039
+ if (table_name && table_name != '') {
2040
+ if (table_name == "ImportRevisione2024") {
2041
+ query = "Select ";
2042
+ query += "inv_ict3 as Inventario, ";
2043
+ query += "ex_inv as Precedente, ";
2044
+ query += "descrizione_bene as Descrizione, ";
2045
+ query += "collocazione as Luogo, ";
2046
+ query += "sede as Plesso, ";
2047
+ query += "marca as 'Marca bene', ";
2048
+ query += "modello_serie as Modello, ";
2049
+ query += "targa_matricola as Matricola, ";
2050
+ query += "data_presa_in_carico as 'Data acq.', ";
2051
+ query += "prezzo as Costo, ";
2052
+ query += "data_scarico as 'Data scarico', ";
2053
+ query += "concat(imp.NOTE, ' ', NOTE_2, ' ', NOTE_3, ' ', NOTE_4, ' ', NOTE_5, ' ', NOTE_6, ' ', NOTE_7, ' ', NOTE_8) as 'Note bene' ";
2054
+ query += "from " + table_name + " imp ";
2055
+ query += "left join devices d on imp.inv_ict3 = d.inv_ict3_number "
2056
+ }
2057
+ else if (table_name == "devices") {
2058
+ query = getDevicesSelectForInventarioRawSQLite(inv_code);
2059
+ }
2060
+ else if (is_pnrr == 1) {
2061
+ query = "Select ";
2062
+ query += "inventario as Inventario, ";
2063
+ query += "Tipo, ";
2064
+ query += "marca as 'Marca bene', ";
2065
+ query += "Descrizione, ";
2066
+ query += "Plesso as Luogo ";
2067
+ query += "from " + table_name + " imp ";
2068
+ }
2069
+ else if (is_dismissione == 1) {
2070
+ query = "Select ";
2071
+ query += "inv_ict3 as Inventario, ";
2072
+ query += "Descrizione, ";
2073
+ query += "Plesso, ";
2074
+ query += "Costo, ";
2075
+ query += "Note as 'Note bene' ";
2076
+ query += "from " + table_name + " imp ";
2077
+ }
2078
+ else {
2079
+ query = "Select ";
2080
+ query += "inv_ict3 as Inventario, ";
2081
+ query += "ex_inventario as Precedente, ";
2082
+ query += "descrizione_bene as Descrizione, ";
2083
+ query += "collocazione as Luogo, ";
2084
+ query += "sede as Plesso, ";
2085
+ query += "marca as 'Marca bene', ";
2086
+ query += "modello_serie as Modello, ";
2087
+ query += "targa_matricola as Matricola, ";
2088
+ query += "data_presa_in_carico as 'Data acq.', ";
2089
+ query += "prezzo as Costo, ";
2090
+ query += "data_scarico as 'Data scarico', ";
2091
+ query += "concat(note, ' ', note_2, ' ', note_3) as 'Note bene' ";
2092
+ query += "from " + table_name + " imp ";
2093
+ }
2094
+ }
2095
+ if (inv_code && table_name) {
2096
+ if (table_name != "devices" && is_pnrr != 1 && is_dismissione != 1) {
2097
+ query += " where Inventario = '" + inv_code +"' or ";
2098
+ query += " Precedente = '" + inv_code +"' ";
2099
+ if (!include_imp || include_imp == 0) {
2100
+ query += "and d.id is null"
2101
+ }
2102
+ }
2103
+ }
2104
+ else {
2105
+ if (table_name != "devices" && is_pnrr != 1 && is_dismissione != 1) {
2106
+ if (!include_imp || include_imp == 0) {
2107
+ query += "where d.id is null"
2108
+ }
2109
+ }
2110
+ }
2111
+ return query;
2112
+ }
2113
+
2114
+ function getBeniDaInventariMySQL(table_name, inv_code, include_imp, is_pnrr, is_dismissione) {
2115
+ if (table_name && table_name != '') {
2116
+ if (table_name == "ImportRevisione2024") {
2117
+ query = "Select ";
2118
+ query += "inv_ict3 as Inventario, ";
2119
+ query += "ex_inv as Precedente, ";
2120
+ query += "descrizione_bene as Descrizione, ";
2121
+ query += "collocazione as Luogo, ";
2122
+ query += "sede as Plesso, ";
2123
+ query += "marca as 'Marca bene', ";
2124
+ query += "modello_serie as Modello, ";
2125
+ query += "targa_matricola as Matricola, ";
2126
+ query += "data_presa_in_carico as 'Data acq.', ";
2127
+ query += "prezzo as Costo, ";
2128
+ query += "data_scarico as 'Data scarico', ";
2129
+ query += "concat(imp.NOTE, ' ', NOTE_2, ' ', NOTE_3, ' ', NOTE_4, ' ', NOTE_5, ' ', NOTE_6, ' ', NOTE_7, ' ', NOTE_8) as 'Note bene' ";
2130
+ query += "from :table_name imp ";
2131
+ query += "left join devices d on imp.inv_ict3 = d.inv_ict3_number "
2132
+ }
2133
+ else if (table_name == "devices") {
2134
+ query = getDevicesSelectForInventarioRawMySQL(inv_code);
2135
+ }
2136
+ else if (is_pnrr == 1) {
2137
+ query = "Select ";
2138
+ query += "inventario as Inventario, ";
2139
+ query += "Tipo, ";
2140
+ query += "marca as 'Marca bene', ";
2141
+ query += "Descrizione, ";
2142
+ query += "Plesso as Luogo ";
2143
+ query += "from :table_name imp ";
2144
+ }
2145
+ else if (is_dismissione == 1) {
2146
+ query = "Select ";
2147
+ query += "inv_ict3 as Inventario, ";
2148
+ query += "Descrizione, ";
2149
+ query += "Plesso, ";
2150
+ query += "Costo, ";
2151
+ query += "Note as 'Note bene' ";
2152
+ query += "from :table_name imp ";
2153
+ }
2154
+ else {
2155
+ query = "Select ";
2156
+ query += "inv_ict3 as Inventario, ";
2157
+ query += "ex_inventario as Precedente, ";
2158
+ query += "descrizione_bene as Descrizione, ";
2159
+ query += "collocazione as Luogo, ";
2160
+ query += "sede as Plesso, ";
2161
+ query += "marca as 'Marca bene', ";
2162
+ query += "modello_serie as Modello, ";
2163
+ query += "targa_matricola as Matricola, ";
2164
+ query += "data_presa_in_carico as 'Data acq.', ";
2165
+ query += "prezzo as Costo, ";
2166
+ query += "data_scarico as 'Data scarico', ";
2167
+ query += "concat(note, ' ', note_2, ' ', note_3) as 'Note bene' ";
2168
+ query += "from :table_name imp ";
2169
+ }
2170
+ }
2171
+ if (inv_code && table_name) {
2172
+ if (table_name != "devices" && is_pnrr != 1 && is_dismissione != 1) {
2173
+ query += " where Inventario = '" + inv_code +"' or ";
2174
+ query += " Precedente = '" + inv_code +"' ";
2175
+ if (!include_imp || include_imp == 0) {
2176
+ query += "and d.id is null"
2177
+ }
2178
+ }
2179
+ }
2180
+ else {
2181
+ if (table_name != "devices" && is_pnrr != 1 && is_dismissione != 1) {
2182
+ if (!include_imp || include_imp == 0) {
2183
+ query += "where d.id is null"
2184
+ }
2185
+ }
2186
+ }
2187
+ return query;
2188
+ }
2189
+
2190
+ function getBeniDaInventari(db_used, table_name, inv_code, include_imp, is_pnrr, is_dismissione) {
2191
+ var query = "";
2192
+ if (db_used) {
2193
+ switch (db_used) {
2194
+ case 'SQLITE':
2195
+ query = getBeniDaInventariSQLite(table_name, inv_code, include_imp, is_pnrr, is_dismissione);
2196
+ break;
2197
+ case 'MYSQL':
2198
+ query = getBeniDaInventariMySQL(table_name, inv_code, include_imp, is_pnrr, is_dismissione);
2199
+ break;
2200
+ }
2201
+ }
2202
+ return query;
2203
+ }
2204
+ // Range..
2205
+ function selectInventariPerIntervalloSQLite(table_name, is_pnrr, is_dismissione, code_da, code_a) {
2206
+ var query = "";
2207
+ if (table_name && table_name != '') {
2208
+ if (table_name == "ImportRevisione2024") {
2209
+ query = "Select ";
2210
+ query += "inv_ict3 as Inventario, ";
2211
+ query += "concat(inv_ict3, ' - ', descrizione_bene, ' - ', marca, ' - ', modello_serie) as Descrizione ";
2212
+ query += "from " + table_name + " imp ";
2213
+ //query += "where instr(upper(imp.descrizione_bene), (select type from devices)) ";
2214
+ }
2215
+ else if (is_pnrr == 1) {
2216
+ query = "Select ";
2217
+ query += "inventario as Inventario, ";
2218
+ query += "concat(inv_ict3, ' - ', descrizione_bene, ' - ', marca, ' - ', modello_serie) as Descrizione ";
2219
+ query += "from " + table_name + " imp ";
2220
+ }
2221
+ else if (is_dismissione == 1) {
2222
+ query = "Select ";
2223
+ query += "inv_ict3 as Inventario, ";
2224
+ query += "concat(inv_ict3, ' - ', descrizione_bene, ' - ', marca, ' - ', modello_serie) as Descrizione ";
2225
+ query += "from " + table_name + " imp ";
2226
+ }
2227
+ else {
2228
+ query = "Select ";
2229
+ query += "inv_ict3 as Inventario, ";
2230
+ query += "concat(inv_ict3, ' - ', descrizione_bene, ' - ', marca, ' - ', modello_serie) as Descrizione ";
2231
+ query += "from " + table_name + " imp ";
2232
+ //query += "where instr(upper(imp.descrizione_bene), (select type from devices)) ";
2233
+ }
2234
+ }
2235
+ if (code_da && code_a && table_name) {
2236
+ query += " and Inventario >= '" + code_da + "' ";
2237
+ query += " and Inventario <= '" + code_a + "'";
2238
+ }
2239
+ return query;
2240
+ }
2241
+ function selectInventariPerIntervalloMySQL() {
2242
+ var query = "";
2243
+ if (table_name && table_name != '') {
2244
+ if (table_name == "ImportRevisione2024") {
2245
+ query = "Select ";
2246
+ query += "inv_ict3 as Inventario, ";
2247
+ query += "concat(inv_ict3, ' - ', descrizione_bene, ' - ', marca, ' - ', modello_serie) as Descrizione ";
2248
+ query += "from :table_name imp ";
2249
+ //query += "where instr(upper(imp.descrizione_bene), (select type from devices)) ";
2250
+ }
2251
+ else if (is_pnrr == 1) {
2252
+ query = "Select ";
2253
+ query += "inventario as Inventario, ";
2254
+ query += "concat(inv_ict3, ' - ', descrizione_bene, ' - ', marca, ' - ', modello_serie) as Descrizione ";
2255
+ query += "from :table_name imp ";
2256
+ }
2257
+ else if (is_dismissione == 1) {
2258
+ query = "Select ";
2259
+ query += "inv_ict3 as Inventario, ";
2260
+ query += "concat(inv_ict3, ' - ', descrizione_bene, ' - ', marca, ' - ', modello_serie) as Descrizione ";
2261
+ query += "from :table_name imp ";
2262
+ }
2263
+ else {
2264
+ query = "Select ";
2265
+ query += "inv_ict3 as Inventario, ";
2266
+ query += "concat(inv_ict3, ' - ', descrizione_bene, ' - ', marca, ' - ', modello_serie) as Descrizione ";
2267
+ query += "from :table_name imp ";
2268
+ //query += "where instr(upper(imp.descrizione_bene), (select type from devices)) ";
2269
+ }
2270
+ }
2271
+ if (code_da && code_a && table_name) {
2272
+ query += " and Inventario >= :code_da ";
2273
+ query += " and Inventario <= :code_a";
2274
+ }
2275
+ return query;
2276
+ }
2277
+ function selectInventariPerIntervallo(db_used,table_name, is_pnrr, is_dismissione, code_da, code_a) {
2278
+ var query = "";
2279
+ if (db_used) {
2280
+ switch (db_used) {
2281
+ case 'SQLITE':
2282
+ query = selectInventariPerIntervalloSQLite(table_name, is_pnrr, is_dismissione, code_da, code_a);
2283
+ break;
2284
+ case 'MYSQL':
2285
+ query = selectInventariPerIntervalloMySQL(table_name, is_pnrr, is_dismissione, code_da, code_a);
2286
+ break;
2287
+ }
2288
+ }
2289
+ return query;
2290
+ }
2291
+ //end range
2292
+
2036
2293
  // Get Beni Acquisiti...
2037
2294
  function getBeniAcquisitiSQLite(table_name, is_pnrr, is_dismissione) {
2038
2295
  var query = "";
@@ -2172,6 +2429,175 @@ function getBeniAcquisiti(db_used, tab_name, is_pnrr, is_dismissione) {
2172
2429
  return query;
2173
2430
  }
2174
2431
  //End get beni acquisiti
2432
+ // Insert massivo
2433
+ function insertDeviceMassivoSQLite(table_name,lista_inv) {
2434
+ var query = "";
2435
+ var insert_sql = "insert into devices (inv_ict3_number, inv_tn_number, manifacturer, model, note) "
2436
+ if (table_name && table_name != '') {
2437
+ if (inv_info.tabella == "ImportRevisione2024") {
2438
+ query = "Select ";
2439
+ query += "trim(inv_ict3) as Inventario, ";
2440
+ query += "trim(ex_inv) as ex_inventario, ";
2441
+ query += "marca, ";
2442
+ query += "modello_serie, ";
2443
+ query += "concat(imp.NOTE, ' ', NOTE_2, ' ', NOTE_3, ' ', NOTE_4, ' ', NOTE_5, ' ', NOTE_6, ' ', NOTE_7, ' ', NOTE_8) as note_bene ";
2444
+ query += "from " + table_name + " imp ";
2445
+ query += "left join devices d on Inventario = d.inv_ict3_number "
2446
+ query += "where d.id is null ";
2447
+ }
2448
+ else {
2449
+ query = "Select ";
2450
+ query += "trim(inv_ict3) as Inventario, ";
2451
+ query += "trim(ex_inv) as ex_inventario, ";
2452
+ query += "marca, ";
2453
+ query += "modello_serie, ";
2454
+ query += "concat(imp.note, ' ', note_2, ' ', note_3) as note_bene ";
2455
+ query += "from " + table_name + " imp ";
2456
+ query += "left join devices d on Inventario = d.inv_ict3_number "
2457
+ query += "where d.id is null ";
2458
+ }
2459
+ }
2460
+
2461
+ if (lista_inv && lista_inv.length > 0) {
2462
+ var list_clause = "and Inventario in (";
2463
+ for (let i = 0; i < lista_inv.length; i++) {
2464
+ list_clause += "'" + lista_inv[i] + "'";
2465
+ if (i < lista_inv.length - 1) {
2466
+ list_clause += ", ";
2467
+ }
2468
+ }
2469
+ list_clause += ") ";
2470
+ query += list_clause;
2471
+ }
2472
+ query += "group by Inventario";
2473
+ return insert_sql + query;
2474
+ }
2475
+ function insertDeviceMassivoMySQL(table_name,lista_inv) {
2476
+ var query = "";
2477
+ var insert_sql = "insert into devices (inv_ict3_number, inv_tn_number, manifacturer, model, note) "
2478
+ if (table_name && table_name != '') {
2479
+ if (inv_info.tabella == "ImportRevisione2024") {
2480
+ query = "Select ";
2481
+ query += "trim(inv_ict3) as Inventario, ";
2482
+ query += "trim(ex_inv) as ex_inventario, ";
2483
+ query += "marca, ";
2484
+ query += "modello_serie, ";
2485
+ query += "concat(imp.NOTE, ' ', NOTE_2, ' ', NOTE_3, ' ', NOTE_4, ' ', NOTE_5, ' ', NOTE_6, ' ', NOTE_7, ' ', NOTE_8) as note_bene ";
2486
+ query += "from :table_name imp ";
2487
+ query += "left join devices d on Inventario = d.inv_ict3_number "
2488
+ query += "where d.id is null ";
2489
+ }
2490
+ else {
2491
+ query = "Select ";
2492
+ query += "trim(inv_ict3) as Inventario, ";
2493
+ query += "trim(ex_inv) as ex_inventario, ";
2494
+ query += "marca, ";
2495
+ query += "modello_serie, ";
2496
+ query += "concat(imp.note, ' ', note_2, ' ', note_3) as note_bene ";
2497
+ query += "from :table_name imp ";
2498
+ query += "left join devices d on Inventario = d.inv_ict3_number "
2499
+ query += "where d.id is null ";
2500
+ }
2501
+ }
2502
+
2503
+ if (lista_inv && lista_inv.length > 0) {
2504
+ var list_clause = "and Inventario in (";
2505
+ for (let i = 0; i < lista_inv.length; i++) {
2506
+ list_clause += "'" + lista_inv[i] + "'";
2507
+ if (i < lista_inv.length - 1) {
2508
+ list_clause += ", ";
2509
+ }
2510
+ }
2511
+ list_clause += ") ";
2512
+ query += list_clause;
2513
+ }
2514
+ query += "group by Inventario";
2515
+ return insert_sql + query;
2516
+ }
2517
+ function insertDeviceMassivo(db_used,table_name,lista_inv) {
2518
+ var query = "";
2519
+ if (db_used) {
2520
+ switch (db_used) {
2521
+ case 'SQLITE':
2522
+ query = insertDeviceMassivoSQLite(table_name,lista_inv);
2523
+ break;
2524
+ case 'MYSQL':
2525
+ query = insertDeviceMassivoMySQL(table_name,lista_inv);
2526
+ break;
2527
+ }
2528
+ }
2529
+ return query;
2530
+ }
2531
+ //
2532
+ function updateDeviceFromInventarioSQLite(marca_sel, type_sel, lista_inv) {
2533
+ var query = "";
2534
+ var update_sql = "";
2535
+ if (marca_sel != '' || type_sel != '') {
2536
+ update_sql = "update devices set ";
2537
+ if (marca_sel != '') {
2538
+ update_sql += "manifacturer = '" + marca_sel + "'";
2539
+ if (type_sel != '') {
2540
+ update_sql += ", ";
2541
+ }
2542
+ }
2543
+ if (type_sel != '') {
2544
+ update_sql += "type = '" + type_sel + "'";
2545
+ }
2546
+ var list_clause = "where inv_ict3_number in (";
2547
+ for (let i = 0; i < lista_inv.length; i++) {
2548
+ list_clause += "'" + lista_inv[i] + "'";
2549
+ if (i < lista_inv.length - 1) {
2550
+ list_clause += ", ";
2551
+ }
2552
+ }
2553
+ list_clause += ") ";
2554
+ query += update_sql + list_clause;
2555
+ }
2556
+ return query;
2557
+ }
2558
+ function updateDeviceFromInventarioMySQL(marca_sel, type_sel, lista_inv) {
2559
+ var query = "";
2560
+ var update_sql = "";
2561
+ if (marca_sel != '' || type_sel != '') {
2562
+ update_sql = "update devices set ";
2563
+ if (marca_sel != '') {
2564
+ update_sql += "manifacturer = :marca_sel ";
2565
+ if (type_sel != '') {
2566
+ update_sql += ", ";
2567
+ }
2568
+ }
2569
+ if (type_sel != '') {
2570
+ update_sql += "type = :type_sel ";
2571
+ }
2572
+ var list_clause = "where inv_ict3_number in (";
2573
+ for (let i = 0; i < lista_inv.length; i++) {
2574
+ list_clause += "'" + lista_inv[i] + "'";
2575
+ if (i < lista_inv.length - 1) {
2576
+ list_clause += ", ";
2577
+ }
2578
+ }
2579
+ list_clause += ") ";
2580
+ query += update_sql + list_clause;
2581
+ }
2582
+ return query;
2583
+ }
2584
+ function updateDeviceFromInventario(db_used, marca_sel, type_sel, lista_inv) {
2585
+ var query = "";
2586
+ if (db_used) {
2587
+ switch (db_used) {
2588
+ case 'SQLITE':
2589
+ query = updateDeviceFromInventarioSQLite(marca_sel, type_sel, lista_inv);
2590
+ break;
2591
+ case 'MYSQL':
2592
+ query = updateDeviceFromInventarioMySQL(marca_sel, type_sel, lista_inv);
2593
+ break;
2594
+ }
2595
+ }
2596
+ return query;
2597
+
2598
+ }
2599
+
2600
+
2175
2601
  //Manage sets
2176
2602
  function getSetInfoByIdSetSQLite(id_Set) {
2177
2603
  var query = "";
@@ -2243,13 +2669,6 @@ function insertSetInfoMySQL(id_device, id_device_col) {
2243
2669
  }
2244
2670
 
2245
2671
 
2246
- function insertSetInfoInverseSQLite(id_device, id_device_col) {
2247
- return insertSetInfoSQLite(id_device_col, id_device);
2248
- }
2249
-
2250
- function insertSetInfoInverseMySQL(id_device, id_device_col) {
2251
- return insertSetInfoMySQL(id_device_col, id_device);
2252
- }
2253
2672
  function insertSetInfo(db_used, id_device, id_device_col) {
2254
2673
  var query = "";
2255
2674
  if (db_used) {
@@ -2818,6 +3237,105 @@ function selectBeneDaInventario(db_used, table_name, inv_code, is_pnrr, is_dismi
2818
3237
  return query;
2819
3238
  }
2820
3239
 
3240
+ function checkEsistenzaInInventarioSQLite(codice) {
3241
+ var query = "select id from devices ";
3242
+ query += "where inv_ict3_number = '" + codice + "' or ";
3243
+ query += "inv_tn_number = '" + codice +"'";
3244
+ return query;
3245
+ }
3246
+
3247
+ function checkEsistenzaInInventarioMySQL(codice) {
3248
+ var query = "select id from devices ";
3249
+ query += "where inv_ict3_number = '" + codice + "' or ";
3250
+ query += "inv_tn_number = '" + codice +"'";
3251
+ return query;
3252
+ }
3253
+
3254
+ function checkEsistenzaInInventario(db_used,codice) {
3255
+ var query = "";
3256
+ if (db_used) {
3257
+ switch (db_used) {
3258
+ case 'SQLITE':
3259
+ query = checkEsistenzaInInventarioSQLite(codice);
3260
+ break;
3261
+ case 'MYSQL':
3262
+ query = checkEsistenzaInInventarioMySQL(codice);
3263
+ break;
3264
+ }
3265
+ }
3266
+ return query;
3267
+ }
3268
+
3269
+ function selectTabelleInventariComboSQLite(only_dismiss, only_pnrr) {
3270
+ var query = "select name, description from table_inventari "
3271
+ if ((only_dismiss && only_dismiss == 1)|| (only_pnrr && only_pnrr == 1)) {
3272
+ query += "where ";
3273
+ if (only_dismiss && only_dismiss == 1) {
3274
+ query += "is_dismissione = 1";
3275
+ if (only_pnrr && only_pnrr == 1)
3276
+ query += " and ";
3277
+ }
3278
+ if (only_pnrr && only_pnrr == 1) {
3279
+ query += "is_pnrr = 1";
3280
+ }
3281
+ }
3282
+ return query;
3283
+ }
3284
+
3285
+ function selectTabelleInventariComboMySQL(only_dismiss, only_pnrr) {
3286
+ var query = "select name, description from table_inventari "
3287
+ if ((only_dismiss && only_dismiss == 1)|| (only_pnrr && only_pnrr == 1)) {
3288
+ query += "where ";
3289
+ if (only_dismiss && only_dismiss == 1) {
3290
+ query += "is_dismissione = 1";
3291
+ if (only_pnrr && only_pnrr == 1)
3292
+ query += " and ";
3293
+ }
3294
+ if (only_pnrr && only_pnrr == 1) {
3295
+ query += "is_pnrr = 1";
3296
+ }
3297
+ }
3298
+ return query;
3299
+ }
3300
+
3301
+ function selectTabelleInventariCombo(db_used, only_dismiss, only_pnrr) {
3302
+ var query = "";
3303
+ if (db_used) {
3304
+ switch (db_used) {
3305
+ case 'SQLITE':
3306
+ query = selectTabelleInventariComboSQLite(only_dismiss, only_pnrr);
3307
+ break;
3308
+ case 'MYSQL':
3309
+ query = selectTabelleInventariComboMySQL(only_dismiss, only_pnrr);
3310
+ break;
3311
+ }
3312
+ }
3313
+ return query;
3314
+ }
3315
+
3316
+ function selectTabellaInventarioByNameSQLite(tab_name) {
3317
+ return "select name, is_pnrr, is_dismissione from table_inventari where name = '" + tab_name + "'";
3318
+ }
3319
+
3320
+ function selectTabellaInventarioByNameMySQL(tab_name) {
3321
+ return "select name, is_pnrr, is_dismissione from table_inventari where name = :tab_name";
3322
+ }
3323
+
3324
+ function selectTabellaInventarioByName(db_used, tab_name) {
3325
+ var query = "";
3326
+ if (db_used) {
3327
+ switch (db_used) {
3328
+ case 'SQLITE':
3329
+ query = selectTabellaInventarioByNameSQLite(tab_name);
3330
+ break;
3331
+ case 'MYSQL':
3332
+ query = selectTabellaInventarioByNameMySQL(tab_name);
3333
+ break;
3334
+ }
3335
+ }
3336
+ return query;
3337
+ }
3338
+
2821
3339
 
2822
3340
  function queryCloseGestioneDeviceSQLite(id_gestione) {
2823
3341
  var query = "update device_gestioni ";
@@ -2858,6 +3376,33 @@ function queryFornitoriGestoriCombo()
2858
3376
  }
2859
3377
 
2860
3378
 
3379
+ function selectGestoreByIdSQLite(id_gestore) {
3380
+ var query = "select name from gestori_fornitori ";
3381
+ query += "where id = " + id_gestore;
3382
+ return query;
3383
+ }
3384
+
3385
+ function selectGestoreByIdMySQL(id_gestore) {
3386
+ var query = "select name from gestori_fornitori ";
3387
+ query += "where id = :id_gestore";
3388
+ return query;
3389
+ }
3390
+
3391
+ function selectGestoreById(db_used,id_gestore) {
3392
+ var query = "";
3393
+ if (db_used) {
3394
+ switch (db_used) {
3395
+ case 'SQLITE':
3396
+ query = selectGestoreByIdSQLite(id_gestore);
3397
+ break;
3398
+ case 'MYSQL':
3399
+ query = selectGestoreByIdMySQL(id_gestore);
3400
+ break;
3401
+ }
3402
+ }
3403
+ return query;
3404
+ }
3405
+
2861
3406
  function queryInsertGestioneDeviceSQLite(id_device, id_gestore) {
2862
3407
  var query = "insert into device_gestioni (id_device, id_gestione, date_start, date_end) ";
2863
3408
  query += "values (" + id_device + ", ";
@@ -3150,6 +3695,65 @@ function queryAllFunctions() {
3150
3695
  var query = "select f.id, f.name as func_name from functions f ";
3151
3696
  return query;
3152
3697
  }
3698
+ //
3699
+ function selectInterventiSQLite(data_da, data_a) {
3700
+ var query = "select id, data_inizio as Inizio, data_fine as Fine, description as Descrizione from interventi ";
3701
+ if (data_da || data_a) {
3702
+ query += " where ";
3703
+ if (data_da) {
3704
+ var d = new Date(data_da);
3705
+ var data_str = d.getFullYear() + "-" + String((d.getMonth() + 1)).padStart(2, '0') + "-" + String(d.getDate()).padStart(2, '0');
3706
+ query += "data_inizio >= '" + data_str + "'";
3707
+ }
3708
+ if (data_da && data_a) {
3709
+ query += " and ";
3710
+ }
3711
+ if (data_a) {
3712
+ var d = new Date(data_a);
3713
+ var data_str = d.getFullYear() + "-" + String((d.getMonth() + 1)).padStart(2, '0') + "-" + String(d.getDate()).padStart(2, '0');
3714
+ query += "data_fine <= '" + data_str + "'";
3715
+ }
3716
+ }
3717
+ query += " order by id desc";
3718
+ return query;
3719
+ }
3720
+
3721
+ function selectInterventiMySQL(data_da, data_a) {
3722
+ var query = "select id, data_inizio as Inizio, data_fine as Fine, description as Descrizione from interventi ";
3723
+ if (data_da || data_a) {
3724
+ query += " where ";
3725
+ if (data_da) {
3726
+ var d = new Date(data_da);
3727
+ var data_str = d.getFullYear() + "-" + String((d.getMonth() + 1)).padStart(2, '0') + "-" + String(d.getDate()).padStart(2, '0');
3728
+ query += "data_inizio >= '" + data_str + "'";
3729
+ }
3730
+ if (data_da && data_a) {
3731
+ query += " and ";
3732
+ }
3733
+ if (data_a) {
3734
+ var d = new Date(data_a);
3735
+ var data_str = d.getFullYear() + "-" + String((d.getMonth() + 1)).padStart(2, '0') + "-" + String(d.getDate()).padStart(2, '0');
3736
+ query += "data_fine <= '" + data_str + "'";
3737
+ }
3738
+ }
3739
+ query += " order by id desc";
3740
+ return query;
3741
+ }
3742
+
3743
+ function selectInterventi(db_used, data_da, data_a) {
3744
+ var query = "";
3745
+ if (db_used) {
3746
+ switch (db_used) {
3747
+ case 'SQLITE':
3748
+ query = selectInterventiSQLite(data_da, data_a);
3749
+ break;
3750
+ case 'MYSQL':
3751
+ query = selectInterventiMySQL(data_da, data_a);
3752
+ break;
3753
+ }
3754
+ }
3755
+ return query;
3756
+ }
3153
3757
 
3154
3758
  function queryInterventoByIdSQLite(id_interv) {
3155
3759
  var query = "select id, id_place, id_site, data_inizio, data_fine, tipo_risoluzione, executor_type, id_executor, executed_by, request_by, description, helpdesk_ref from interventi ";
@@ -3171,7 +3775,112 @@ function queryInterventoById(db_used,id_interv) {
3171
3775
  query = queryInterventoByIdSQLite(id_interv);
3172
3776
  break;
3173
3777
  case 'MYSQL':
3174
- query = queryInterventoByIdSQLite(id_interv);
3778
+ query = queryInterventoByIdMySQL(id_interv);
3779
+ break;
3780
+ }
3781
+ }
3782
+ return query;
3783
+ }
3784
+
3785
+
3786
+ function insertInterventoSQLite(id_place, id_site, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione) {
3787
+ var query = "insert into interventi (id_place, id_site, data_inizio, data_fine, request_by, executed_by, id_executor, executor_type, tipo_risoluzione, description) ";
3788
+ query += " values ('" + id_place + "', ";
3789
+ query += id_site +", ";
3790
+ query += "'" + data_inizio.trim() + "', ";
3791
+ query += "'" + data_fine.trim() + "', ";
3792
+ query += "'" + richiedente.trim() + "', ";
3793
+ query += "'" + esecutore.trim() + "', ";
3794
+ query += id_esecutore + ", ";
3795
+ query += tipo_esecutore + ", ";
3796
+ query += tipo_risoluzione + ", ";
3797
+ query += "'" + descrizione.trim() + "')";
3798
+ return query;
3799
+ }
3800
+
3801
+ function insertInterventoMySQL(id_place, id_site, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione) {
3802
+ var query = "insert into interventi (id_place, id_site, data_inizio, data_fine, request_by, executed_by, id_executor, executor_type, tipo_risoluzione, description) ";
3803
+ query += " values ('" + id_place + "', ";
3804
+ query += id_site +", ";
3805
+ query += "'" + data_inizio.trim() + "', ";
3806
+ query += "'" + data_fine.trim() + "', ";
3807
+ query += "'" + richiedente.trim() + "', ";
3808
+ query += "'" + esecutore.trim() + "', ";
3809
+ query += id_esecutore + ", ";
3810
+ query += tipo_esecutore + ", ";
3811
+ query += tipo_risoluzione + ", ";
3812
+ query += "'" + descrizione.trim() + "')";
3813
+ return query;
3814
+ }
3815
+
3816
+ function insertIntervento(db_used, id_place, id_site, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione) {
3817
+ var query = "";
3818
+ if (db_used) {
3819
+ switch (db_used) {
3820
+ case 'SQLITE':
3821
+ query = insertInterventoSQLite(id_place, id_site, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione);
3822
+ break;
3823
+ case 'MYSQL':
3824
+ query = insertInterventoMySQL(id_place, id_site, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione);
3825
+ break;
3826
+ }
3827
+ }
3828
+ return query;
3829
+ }
3830
+
3831
+
3832
+ function updateInterventoSQLite(id_intervento, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione) {
3833
+ var query = "update interventi set ";
3834
+ query += "data_inizio = '" + data_inizio.trim() + "', ";
3835
+ query += "data_fine = '" + data_fine.trim() + "', ";
3836
+ query += "request_by = '" + richiedente.trim() + "', ";
3837
+ query += "executed_by = '" + esecutore.trim() + "', ";
3838
+ query += "id_executor = " + id_esecutore + ", ";
3839
+ query += "executor_type = " + tipo_esecutore + ", ";
3840
+ query += "tipo_risoluzione = " + tipo_risoluzione + ", ";
3841
+ query += "description = '" + descrizione.trim() + "' ";
3842
+ query += "where id = " + id_intervento;
3843
+ return query;
3844
+ }
3845
+ function updateInterventoMySQL(id_intervento, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione) {
3846
+
3847
+ }
3848
+ function updateIntervento(db_used, id_intervento, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione) {
3849
+ var query = "";
3850
+ if (db_used) {
3851
+ switch (db_used) {
3852
+ case 'SQLITE':
3853
+ query = updateInterventoSQLite(id_intervento, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione);
3854
+ break;
3855
+ case 'MYSQL':
3856
+ query = updateInterventoMySQL(id_intervento, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione);
3857
+ break;
3858
+ }
3859
+ }
3860
+ return query;
3861
+ }
3862
+
3863
+ function removeInterventoSQLite(id_intervento) {
3864
+ var query = "delete from interventi ";
3865
+ query += " where id = " + id_intervento;
3866
+ return query;
3867
+ }
3868
+
3869
+ function removeInterventoMySQL(id_intervento) {
3870
+ var query = "delete from interventi ";
3871
+ query += " where id = :id_intervento";
3872
+ return query;
3873
+ }
3874
+
3875
+ function removeIntervento(db_used,id_intervento) {
3876
+ var query = "";
3877
+ if (db_used) {
3878
+ switch (db_used) {
3879
+ case 'SQLITE':
3880
+ query = removeInterventoSQLite(id_intervento);
3881
+ break;
3882
+ case 'MYSQL':
3883
+ query = removeInterventoMySQL(id_intervento);
3175
3884
  break;
3176
3885
  }
3177
3886
  }
@@ -3237,23 +3946,23 @@ function updateDeviceIntervento(db_used, id_dev_interv, id_device, note) {
3237
3946
  // Remove
3238
3947
  function removeDeviceInterventoSQLite(id_dev_interv) {
3239
3948
  var query = "delete from device_interventi ";
3240
- query += "where id = :id_dev_interv";
3949
+ query += "where id = " + id_dev_interv;
3241
3950
  return query;
3242
3951
  }
3243
3952
  function removeDeviceInterventoMySQL(id_intervento, id_device, note) {
3244
- var query = "insert into device_interventi (id_intervento, id_device, note) ";
3245
- query += "values (:id_intervento, :id_device, :note)";
3953
+ var query = "delete from device_interventi ";
3954
+ query += "where id = :id_dev_interv";
3246
3955
  return query;
3247
3956
  }
3248
- function removeDeviceIntervento(db_used, id_intervento, id_device, note) {
3957
+ function removeDeviceIntervento(db_used, id_dev_interv) {
3249
3958
  var query = "";
3250
3959
  if (db_used) {
3251
3960
  switch (db_used) {
3252
3961
  case 'SQLITE':
3253
- query = insertDeviceInterventoSQLite(id_intervento, id_device, note);
3962
+ query = removeDeviceInterventoSQLite(id_dev_interv);
3254
3963
  break;
3255
3964
  case 'MYSQL':
3256
- query = insertDeviceInterventoMySQL(id_intervento, id_device, note);
3965
+ query = removeDeviceInterventoMySQL(id_dev_interv);
3257
3966
  break;
3258
3967
  }
3259
3968
  }
@@ -3594,13 +4303,13 @@ function removeConsegnaDeviceSQLite(id_consegna, id_device){
3594
4303
  var query = "DELETE from device_consegne ";
3595
4304
  query += "where id_consegna = " + id_consegna + " ";
3596
4305
  query += "and id_device = " + id_device;
3597
- msg.topic = query;
4306
+ return query;
3598
4307
  }
3599
4308
  function removeConsegnaDeviceMySQL(id_devcons){
3600
4309
  var query = "DELETE from device_consegne ";
3601
4310
  query += "where id_consegna = :id_consegna ";
3602
4311
  query += "and id_device = :id_device";
3603
- msg.topic = query;
4312
+ return query;
3604
4313
  }
3605
4314
  function removeConsegnaDevice(db_used, id_consegna, id_device) {
3606
4315
  var query = "";
@@ -6260,6 +6969,10 @@ module.exports = {
6260
6969
  getDevicesSelectBySiteCombo,
6261
6970
  getDevicesWithProperties,
6262
6971
  getBeniAcquisiti,
6972
+ selectInventariPerIntervallo,
6973
+ insertDeviceMassivo,
6974
+ updateDeviceFromInventario,
6975
+ getBeniDaInventari,
6263
6976
  getNetworksOnDevice,
6264
6977
  getImportedPropertiesByIdDevice,
6265
6978
  getSetInfoByIdSet,
@@ -6307,9 +7020,14 @@ module.exports = {
6307
7020
  insertAddOn,
6308
7021
  updateAddOn,
6309
7022
  removeAddOn,
7023
+ //
6310
7024
  selectBeneDaInventario,
6311
7025
  getDevicesSelectForInventarioRaw,
6312
7026
  getDevicesSelectForInventarioRawById,
7027
+ selectTabelleInventariCombo,
7028
+ selectTabellaInventarioByName,
7029
+ checkEsistenzaInInventario,
7030
+ //
6313
7031
  getBeniConsumo,
6314
7032
  getBeniConsumoNotNull,
6315
7033
  getBeneConsumoUsato,
@@ -6355,23 +7073,34 @@ module.exports = {
6355
7073
  getBeniConsumoByIdDevice,
6356
7074
  queryConsegneByIdDevice,
6357
7075
  queryFornitoriGestoriCombo,
7076
+ selectGestoreById,
6358
7077
  queryCloseGestioneDevice,
6359
7078
  queryInsertGestioneDevice,
6360
7079
  querySelectExistsGestioneDeviceByIds,
6361
7080
  querySelectGestioniDeviceByIdDevice,
6362
7081
  queryConsegne,
6363
7082
  queryConsegnaById,
7083
+ createConsegnaMySQLObj,
7084
+ insertConsegna,
7085
+ updateConsegna,
7086
+ removeConsegna,
7087
+ queryLastConsegnaId,
6364
7088
  insertConsegnaDevice,
6365
7089
  updateConsegnaDevice,
6366
7090
  removeConsegnaDevice,
6367
7091
  selectDevicePerConsegna,
6368
7092
  selectDeviceConsegna,
7093
+ //
6369
7094
  selectDeviceInDeposito,
6370
7095
  queryDeviceStatusCombo,
6371
7096
  queryUsers,
6372
7097
  queryFunctions,
6373
7098
  queryAllFunctions,
7099
+ selectInterventi,
6374
7100
  queryInterventoById,
7101
+ insertIntervento,
7102
+ updateIntervento,
7103
+ removeIntervento,
6375
7104
  insertDeviceIntervento,
6376
7105
  updateDeviceIntervento,
6377
7106
  removeDeviceIntervento,
@@ -6383,11 +7112,6 @@ module.exports = {
6383
7112
  getLaboratorioByIdSite,
6384
7113
  getCategories,
6385
7114
  getCategoriesByIdDevice,
6386
- createConsegnaMySQLObj,
6387
- insertConsegna,
6388
- updateConsegna,
6389
- removeConsegna,
6390
- queryLastConsegnaId,
6391
7115
  //
6392
7116
  removeSiteBySet,
6393
7117
  updateSiteBySet,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alsmanager_lib",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "description": "Funzioni per ALSManager",
5
5
  "license": "ISC",
6
6
  "author": "Luca Cattani",