alsmanager_lib 1.0.31 → 1.0.33

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 +527 -8
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -2646,7 +2646,7 @@ function getDevicesSelectForInventarioRawByIdMySQL(id_device) {
2646
2646
  query += "from devices d ";
2647
2647
  query += "join device_site ds on ds.id_device = d.id "
2648
2648
  query += "where (CURDATE() >= ds.date_in and CURDATE() <= ds.date_out)";
2649
- query += " and id = " + id_device;
2649
+ query += " and id = :id_device";
2650
2650
  return query;
2651
2651
  }
2652
2652
 
@@ -2818,6 +2818,76 @@ function selectBeneDaInventario(db_used, table_name, inv_code, is_pnrr, is_dismi
2818
2818
  return query;
2819
2819
  }
2820
2820
 
2821
+ function selectTabelleInventariComboSQLite(only_dismiss, only_pnrr) {
2822
+ var query = "select name, description from table_inventari "
2823
+ if ((only_dismiss && only_dismiss == 1)|| (only_pnrr && only_pnrr == 1)) {
2824
+ query += "where ";
2825
+ if (only_dismiss && only_dismiss == 1) {
2826
+ query += "is_dismissione = 1";
2827
+ if (only_pnrr && only_pnrr == 1)
2828
+ query += " and ";
2829
+ }
2830
+ if (only_pnrr && only_pnrr == 1) {
2831
+ query += "is_pnrr = 1";
2832
+ }
2833
+ }
2834
+ return query;
2835
+ }
2836
+
2837
+ function selectTabelleInventariComboMySQL(only_dismiss, only_pnrr) {
2838
+ var query = "select name, description from table_inventari "
2839
+ if ((only_dismiss && only_dismiss == 1)|| (only_pnrr && only_pnrr == 1)) {
2840
+ query += "where ";
2841
+ if (only_dismiss && only_dismiss == 1) {
2842
+ query += "is_dismissione = 1";
2843
+ if (only_pnrr && only_pnrr == 1)
2844
+ query += " and ";
2845
+ }
2846
+ if (only_pnrr && only_pnrr == 1) {
2847
+ query += "is_pnrr = 1";
2848
+ }
2849
+ }
2850
+ return query;
2851
+ }
2852
+
2853
+ function selectTabelleInventariCombo(db_used, only_dismiss, only_pnrr) {
2854
+ var query = "";
2855
+ if (db_used) {
2856
+ switch (db_used) {
2857
+ case 'SQLITE':
2858
+ query = selectTabelleInventariComboSQLite(only_dismiss, only_pnrr);
2859
+ break;
2860
+ case 'MYSQL':
2861
+ query = selectTabelleInventariComboMySQL(only_dismiss, only_pnrr);
2862
+ break;
2863
+ }
2864
+ }
2865
+ return query;
2866
+ }
2867
+
2868
+ function selectTabellaInventarioByNameSQLite(tab_name) {
2869
+ return "select name, is_pnrr, is_dismissione from table_inventari where name = '" + tab_name + "'";
2870
+ }
2871
+
2872
+ function selectTabellaInventarioByNameMySQL(tab_name) {
2873
+ return "select name, is_pnrr, is_dismissione from table_inventari where name = :tab_name";
2874
+ }
2875
+
2876
+ function selectTabellaInventarioByName(db_used, tab_name) {
2877
+ var query = "";
2878
+ if (db_used) {
2879
+ switch (db_used) {
2880
+ case 'SQLITE':
2881
+ query = selectTabellaInventarioByNameSQLite(tab_name);
2882
+ break;
2883
+ case 'MYSQL':
2884
+ query = selectTabellaInventarioByNameMySQL(tab_name);
2885
+ break;
2886
+ }
2887
+ }
2888
+ return query;
2889
+ }
2890
+
2821
2891
 
2822
2892
  function queryCloseGestioneDeviceSQLite(id_gestione) {
2823
2893
  var query = "update device_gestioni ";
@@ -2858,6 +2928,33 @@ function queryFornitoriGestoriCombo()
2858
2928
  }
2859
2929
 
2860
2930
 
2931
+ function selectGestoreByIdSQLite(id_gestore) {
2932
+ var query = "select name from gestori_fornitori ";
2933
+ query += "where id = " + id_gestore;
2934
+ return query;
2935
+ }
2936
+
2937
+ function selectGestoreByIdMySQL(id_gestore) {
2938
+ var query = "select name from gestori_fornitori ";
2939
+ query += "where id = :id_gestore";
2940
+ return query;
2941
+ }
2942
+
2943
+ function selectGestoreById(db_used,id_gestore) {
2944
+ var query = "";
2945
+ if (db_used) {
2946
+ switch (db_used) {
2947
+ case 'SQLITE':
2948
+ query = selectGestoreByIdSQLite(id_gestore);
2949
+ break;
2950
+ case 'MYSQL':
2951
+ query = selectGestoreByIdMySQL(id_gestore);
2952
+ break;
2953
+ }
2954
+ }
2955
+ return query;
2956
+ }
2957
+
2861
2958
  function queryInsertGestioneDeviceSQLite(id_device, id_gestore) {
2862
2959
  var query = "insert into device_gestioni (id_device, id_gestione, date_start, date_end) ";
2863
2960
  query += "values (" + id_device + ", ";
@@ -3150,6 +3247,65 @@ function queryAllFunctions() {
3150
3247
  var query = "select f.id, f.name as func_name from functions f ";
3151
3248
  return query;
3152
3249
  }
3250
+ //
3251
+ function selectInterventiSQLite(data_da, data_a) {
3252
+ var query = "select id, data_inizio as Inizio, data_fine as Fine, description as Descrizione from interventi ";
3253
+ if (data_da || data_a) {
3254
+ query += " where ";
3255
+ if (data_da) {
3256
+ var d = new Date(data_da);
3257
+ var data_str = d.getFullYear() + "-" + String((d.getMonth() + 1)).padStart(2, '0') + "-" + String(d.getDate()).padStart(2, '0');
3258
+ query += "data_inizio >= '" + data_str + "'";
3259
+ }
3260
+ if (data_da && data_a) {
3261
+ query += " and ";
3262
+ }
3263
+ if (data_a) {
3264
+ var d = new Date(data_a);
3265
+ var data_str = d.getFullYear() + "-" + String((d.getMonth() + 1)).padStart(2, '0') + "-" + String(d.getDate()).padStart(2, '0');
3266
+ query += "data_fine <= '" + data_str + "'";
3267
+ }
3268
+ }
3269
+ query += " order by id desc";
3270
+ return query;
3271
+ }
3272
+
3273
+ function selectInterventiMySQL(data_da, data_a) {
3274
+ var query = "select id, data_inizio as Inizio, data_fine as Fine, description as Descrizione from interventi ";
3275
+ if (data_da || data_a) {
3276
+ query += " where ";
3277
+ if (data_da) {
3278
+ var d = new Date(data_da);
3279
+ var data_str = d.getFullYear() + "-" + String((d.getMonth() + 1)).padStart(2, '0') + "-" + String(d.getDate()).padStart(2, '0');
3280
+ query += "data_inizio >= '" + data_str + "'";
3281
+ }
3282
+ if (data_da && data_a) {
3283
+ query += " and ";
3284
+ }
3285
+ if (data_a) {
3286
+ var d = new Date(data_a);
3287
+ var data_str = d.getFullYear() + "-" + String((d.getMonth() + 1)).padStart(2, '0') + "-" + String(d.getDate()).padStart(2, '0');
3288
+ query += "data_fine <= '" + data_str + "'";
3289
+ }
3290
+ }
3291
+ query += " order by id desc";
3292
+ return query;
3293
+ }
3294
+
3295
+ function selectInterventi(db_used, data_da, data_a) {
3296
+ var query = "";
3297
+ if (db_used) {
3298
+ switch (db_used) {
3299
+ case 'SQLITE':
3300
+ query = selectInterventiSQLite(data_da, data_a);
3301
+ break;
3302
+ case 'MYSQL':
3303
+ query = selectInterventiMySQL(data_da, data_a);
3304
+ break;
3305
+ }
3306
+ }
3307
+ return query;
3308
+ }
3153
3309
 
3154
3310
  function queryInterventoByIdSQLite(id_interv) {
3155
3311
  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 +3327,112 @@ function queryInterventoById(db_used,id_interv) {
3171
3327
  query = queryInterventoByIdSQLite(id_interv);
3172
3328
  break;
3173
3329
  case 'MYSQL':
3174
- query = queryInterventoByIdSQLite(id_interv);
3330
+ query = queryInterventoByIdMySQL(id_interv);
3331
+ break;
3332
+ }
3333
+ }
3334
+ return query;
3335
+ }
3336
+
3337
+
3338
+ function insertInterventoSQLite(id_place, id_site, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione) {
3339
+ var query = "insert into interventi (id_place, id_site, data_inizio, data_fine, request_by, executed_by, id_executor, executor_type, tipo_risoluzione, description) ";
3340
+ query += " values ('" + id_place + "', ";
3341
+ query += id_site +", ";
3342
+ query += "'" + data_inizio.trim() + "', ";
3343
+ query += "'" + data_fine.trim() + "', ";
3344
+ query += "'" + richiedente.trim() + "', ";
3345
+ query += "'" + esecutore.trim() + "', ";
3346
+ query += id_esecutore + ", ";
3347
+ query += tipo_esecutore + ", ";
3348
+ query += tipo_risoluzione + ", ";
3349
+ query += "'" + descrizione.trim() + "')";
3350
+ return query;
3351
+ }
3352
+
3353
+ function insertInterventoMySQL(id_place, id_site, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione) {
3354
+ var query = "insert into interventi (id_place, id_site, data_inizio, data_fine, request_by, executed_by, id_executor, executor_type, tipo_risoluzione, description) ";
3355
+ query += " values ('" + id_place + "', ";
3356
+ query += id_site +", ";
3357
+ query += "'" + data_inizio.trim() + "', ";
3358
+ query += "'" + data_fine.trim() + "', ";
3359
+ query += "'" + richiedente.trim() + "', ";
3360
+ query += "'" + esecutore.trim() + "', ";
3361
+ query += id_esecutore + ", ";
3362
+ query += tipo_esecutore + ", ";
3363
+ query += tipo_risoluzione + ", ";
3364
+ query += "'" + descrizione.trim() + "')";
3365
+ return query;
3366
+ }
3367
+
3368
+ function insertIntervento(db_used, id_place, id_site, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione) {
3369
+ var query = "";
3370
+ if (db_used) {
3371
+ switch (db_used) {
3372
+ case 'SQLITE':
3373
+ query = insertInterventoSQLite(id_place, id_site, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione);
3374
+ break;
3375
+ case 'MYSQL':
3376
+ query = insertInterventoMySQL(id_place, id_site, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione);
3377
+ break;
3378
+ }
3379
+ }
3380
+ return query;
3381
+ }
3382
+
3383
+
3384
+ function updateInterventoSQLite(id_intervento, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione) {
3385
+ var query = "update interventi set ";
3386
+ query += "data_inizio = '" + data_inizio.trim() + "', ";
3387
+ query += "data_fine = '" + data_fine.trim() + "', ";
3388
+ query += "request_by = '" + richiedente.trim() + "', ";
3389
+ query += "executed_by = '" + esecutore.trim() + "', ";
3390
+ query += "id_executor = " + id_esecutore + ", ";
3391
+ query += "executor_type = " + tipo_esecutore + ", ";
3392
+ query += "tipo_risoluzione = " + tipo_risoluzione + ", ";
3393
+ query += "description = '" + descrizione.trim() + "' ";
3394
+ query += "where id = " + id_intervento;
3395
+ return query;
3396
+ }
3397
+ function updateInterventoMySQL(id_intervento, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione) {
3398
+
3399
+ }
3400
+ function updateIntervento(db_used, id_intervento, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione) {
3401
+ var query = "";
3402
+ if (db_used) {
3403
+ switch (db_used) {
3404
+ case 'SQLITE':
3405
+ query = updateInterventoSQLite(id_intervento, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione);
3406
+ break;
3407
+ case 'MYSQL':
3408
+ query = updateInterventoMySQL(id_intervento, data_inizio, data_fine, richiedente, esecutore, id_esecutore, tipo_esecutore, tipo_risoluzione, descrizione);
3409
+ break;
3410
+ }
3411
+ }
3412
+ return query;
3413
+ }
3414
+
3415
+ function removeInterventoSQLite(id_intervento) {
3416
+ var query = "delete from interventi ";
3417
+ query += " where id = " + id_intervento;
3418
+ return query;
3419
+ }
3420
+
3421
+ function removeInterventoMySQL(id_intervento) {
3422
+ var query = "delete from interventi ";
3423
+ query += " where id = :id_intervento";
3424
+ return query;
3425
+ }
3426
+
3427
+ function removeIntervento(db_used,id_intervento) {
3428
+ var query = "";
3429
+ if (db_used) {
3430
+ switch (db_used) {
3431
+ case 'SQLITE':
3432
+ query = removeInterventoSQLite(id_intervento);
3433
+ break;
3434
+ case 'MYSQL':
3435
+ query = removeInterventoMySQL(id_intervento);
3175
3436
  break;
3176
3437
  }
3177
3438
  }
@@ -3237,23 +3498,23 @@ function updateDeviceIntervento(db_used, id_dev_interv, id_device, note) {
3237
3498
  // Remove
3238
3499
  function removeDeviceInterventoSQLite(id_dev_interv) {
3239
3500
  var query = "delete from device_interventi ";
3240
- query += "where id = :id_dev_interv";
3501
+ query += "where id = " + id_dev_interv;
3241
3502
  return query;
3242
3503
  }
3243
3504
  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)";
3505
+ var query = "delete from device_interventi ";
3506
+ query += "where id = :id_dev_interv";
3246
3507
  return query;
3247
3508
  }
3248
- function removeDeviceIntervento(db_used, id_intervento, id_device, note) {
3509
+ function removeDeviceIntervento(db_used, id_dev_interv) {
3249
3510
  var query = "";
3250
3511
  if (db_used) {
3251
3512
  switch (db_used) {
3252
3513
  case 'SQLITE':
3253
- query = insertDeviceInterventoSQLite(id_intervento, id_device, note);
3514
+ query = removeDeviceInterventoSQLite(id_dev_interv);
3254
3515
  break;
3255
3516
  case 'MYSQL':
3256
- query = insertDeviceInterventoMySQL(id_intervento, id_device, note);
3517
+ query = removeDeviceInterventoMySQL(id_dev_interv);
3257
3518
  break;
3258
3519
  }
3259
3520
  }
@@ -3526,6 +3787,253 @@ function queryLastConsegnaId(db_used) {
3526
3787
  return query;
3527
3788
  }
3528
3789
 
3790
+ function insertConsegnaDeviceSQLite(id_consegna, id_device, note){
3791
+ var query = "insert into device_consegne (id_consegna, id_device, note) values ";
3792
+ query += "(" + id_consegna + ", ";
3793
+ query += id_device + ", ";
3794
+ query += "'" + note + "' ";
3795
+ return query;
3796
+ }
3797
+
3798
+ function insertConsegnaDeviceMySQL(id_consegna, id_device, note){
3799
+ var query = "insert into device_consegne (id_consegna, id_device, note) values ";
3800
+ query += "(:id_consegna, ";
3801
+ query += ":id_device, ";
3802
+ query += ":note ";
3803
+ return query;
3804
+ }
3805
+
3806
+ function insertConsegnaDevice(db_used, id_consegna, id_device, note) {
3807
+ var query = "";
3808
+ if (db_used) {
3809
+ switch (db_used) {
3810
+ case 'SQLITE':
3811
+ query = insertConsegnaDeviceSQLite(id_consegna, id_device, note);
3812
+ break;
3813
+ case 'MYSQL':
3814
+ query = insertConsegnaDeviceMySQL(id_consegna, id_device, note);
3815
+ break;
3816
+ }
3817
+ }
3818
+ return query;
3819
+ }
3820
+
3821
+ function updateConsegnaDeviceSQLite(id_devcons, id_consegna, id_device, note){
3822
+ var query = "update device_consegne set ";
3823
+ query += "id_consegna = " + id_consegna + ", ";
3824
+ query += "id_device = " + id_device + ", ";
3825
+ query += "note = '" + note + "' ";
3826
+ query += "where id = " + id_devcons;
3827
+ return query;
3828
+ }
3829
+
3830
+ function updateConsegnaDeviceMySQL(id_devcons, id_consegna, id_device, note){
3831
+ var query = "update device_consegne set ";
3832
+ query += "id_consegna = :id_consegna, ";
3833
+ query += "id_device = :id_device, ";
3834
+ query += "note = :note ";
3835
+ query += "where id = :id_devcons";
3836
+ return query;
3837
+ }
3838
+
3839
+ function updateConsegnaDevice(db_used, id_devcons, id_consegna, id_device, note) {
3840
+ var query = "";
3841
+ if (db_used) {
3842
+ switch (db_used) {
3843
+ case 'SQLITE':
3844
+ query = updateConsegnaDeviceSQLite(id_devcons, id_consegna, id_device, note);
3845
+ break;
3846
+ case 'MYSQL':
3847
+ query = updateConsegnaDeviceMySQL(id_devcons, id_consegna, id_device, note);
3848
+ break;
3849
+ }
3850
+ }
3851
+ return query;
3852
+ }
3853
+
3854
+ function removeConsegnaDeviceSQLite(id_consegna, id_device){
3855
+ var query = "DELETE from device_consegne ";
3856
+ query += "where id_consegna = " + id_consegna + " ";
3857
+ query += "and id_device = " + id_device;
3858
+ return query;
3859
+ }
3860
+ function removeConsegnaDeviceMySQL(id_devcons){
3861
+ var query = "DELETE from device_consegne ";
3862
+ query += "where id_consegna = :id_consegna ";
3863
+ query += "and id_device = :id_device";
3864
+ return query;
3865
+ }
3866
+ function removeConsegnaDevice(db_used, id_consegna, id_device) {
3867
+ var query = "";
3868
+ if (db_used) {
3869
+ switch (db_used) {
3870
+ case 'SQLITE':
3871
+ query = removeConsegnaDeviceSQLite(id_consegna, id_device);
3872
+ break;
3873
+ case 'MYSQL':
3874
+ query = removeConsegnaDeviceMySQL(id_consegna, id_device);
3875
+ break;
3876
+ }
3877
+ }
3878
+ return query;
3879
+ }
3880
+
3881
+ function selectDevicePerConsegnaSQLite(id_consegna) {
3882
+ var query = "select d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
3883
+ query += "case ";
3884
+ query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then d.inv_ict3_number ";
3885
+ query += "when d.inv_pnrr_number != '' and d.inv_pnrr_number is not null then d.inv_pnrr_number ";
3886
+ query += "when d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number,'(TN)') ";
3887
+ query += "when d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)') ";
3888
+ query += "when d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)') ";
3889
+ query += "end as Codice, ";
3890
+ query += "case ";
3891
+ query += "when trim(d.inv_pnrr_number) is null then '' ";
3892
+ query += "when trim(d.inv_pnrr_number) = '' then '' ";
3893
+ query += "else 'SI' ";
3894
+ query += "end as PNRR ";
3895
+ query += " from devices d";
3896
+ query += " left join device_consegne dc on dc.id_device = d.id";
3897
+ query += " where dc.id_consegna = " + id_consegna;
3898
+ return query;
3899
+ }
3900
+
3901
+ function selectDevicePerConsegnaMySQL(id_consegna) {
3902
+ var query = "select d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
3903
+ query += "case ";
3904
+ query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then d.inv_ict3_number ";
3905
+ query += "when d.inv_pnrr_number != '' and d.inv_pnrr_number is not null then d.inv_pnrr_number ";
3906
+ query += "when d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number,'(TN)') ";
3907
+ query += "when d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)') ";
3908
+ query += "when d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)') ";
3909
+ query += "end as Codice, ";
3910
+ query += "case ";
3911
+ query += "when trim(d.inv_pnrr_number) is null then '' ";
3912
+ query += "when trim(d.inv_pnrr_number) = '' then '' ";
3913
+ query += "else 'SI' ";
3914
+ query += "end as PNRR ";
3915
+ query += " from devices d";
3916
+ query += " left join device_consegne dc on dc.id_device = d.id";
3917
+ query += " where dc.id_consegna = :id_consegna";
3918
+ return query;
3919
+ }
3920
+ function selectDevicePerConsegna(db_used, id_consegna) {
3921
+ var query = "";
3922
+ if (db_used) {
3923
+ switch (db_used) {
3924
+ case 'SQLITE':
3925
+ query = selectDevicePerConsegnaSQLite(id_consegna);
3926
+ break;
3927
+ case 'MYSQL':
3928
+ query = selectDevicePerConsegnaMySQL(id_consegna);
3929
+ break;
3930
+ }
3931
+ }
3932
+ return query;
3933
+ }
3934
+
3935
+ function selectDeviceConsegnaSQLite(id_consegna, id_device) {
3936
+ var query = "select dc.id as id_dev_cons, d.id, d.type, d.manifacturer, d.model, ";
3937
+ query += "case ";
3938
+ query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then d.inv_ict3_number ";
3939
+ query += "when d.inv_pnrr_number != '' and d.inv_pnrr_number is not null then d.inv_pnrr_number ";
3940
+ query += "when d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number,'(TN)') ";
3941
+ query += "when d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)') ";
3942
+ query += "when d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)') ";
3943
+ query += "end as codice ";
3944
+ query += ", dc.note as note_cons from device_consegne dc";
3945
+ query += " join devices d on d.id = dc.id_device";
3946
+ query += " where dc.id_consegna = " + id_consegna;
3947
+ query += " and d.id = " + id_device;
3948
+ return query;
3949
+ }
3950
+
3951
+ function selectDeviceConsegnaMySQL(id_consegna, id_device) {
3952
+ var query = "select dc.id as id_dev_cons, d.id, d.type, d.manifacturer, d.model, ";
3953
+ query += "case ";
3954
+ query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then d.inv_ict3_number ";
3955
+ query += "when d.inv_pnrr_number != '' and d.inv_pnrr_number is not null then d.inv_pnrr_number ";
3956
+ query += "when d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number,'(TN)') ";
3957
+ query += "when d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)') ";
3958
+ query += "when d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)') ";
3959
+ query += "end as codice ";
3960
+ query += ", dc.note as note_cons from device_consegne dc";
3961
+ query += " join devices d on d.id = dc.id_device";
3962
+ query += " where dc.id_consegna = :id_consegna";
3963
+ query += " and d.id :id_device";
3964
+ return query;
3965
+ }
3966
+
3967
+
3968
+ function selectDeviceConsegna(db_used, id_consegna, id_device) {
3969
+ var query = "";
3970
+ if (db_used) {
3971
+ switch (db_used) {
3972
+ case 'SQLITE':
3973
+ query = selectDeviceConsegnaSQLite(id_consegna, id_device);
3974
+ break;
3975
+ case 'MYSQL':
3976
+ query = selectDeviceConsegnaMySQL(id_consegna, id_device);
3977
+ break;
3978
+ }
3979
+ }
3980
+ return query;
3981
+ }
3982
+
3983
+ function selectDeviceInDepositoSQLite(inv_code) {
3984
+ var query = "SELECT d.id, d.type, d.manifacturer, d.model, ";
3985
+ query += "case ";
3986
+ query += "when inv_ict3_number != '' and inv_ict3_number is not null then inv_ict3_number ";
3987
+ query += "when inv_pnrr_number != '' and inv_pnrr_number is not null then inv_pnrr_number ";
3988
+ query += "when inv_tn_number != '' and inv_tn_number is not null then concat(inv_tn_number,'(TN)') ";
3989
+ query += "when inv_tndigit_number != '' and inv_tndigit_number is not null then concat(inv_tndigit_number,'(TNDigit)') ";
3990
+ query += "when serial_no != '' and serial_no is not null then concat(serial_no,'(S/N)') ";
3991
+ query += "end as Codice ";
3992
+ query += " from devices d";
3993
+ query += " join device_site ds on ds.id_device = d.id"
3994
+ query += " join sites s on s.id = ds.id_site"
3995
+ query += " join site_destinations sd on sd.id_site = s.id"
3996
+ query += " where (inv_ict3_number = '" + inv_code + "' or ";
3997
+ query += "inv_tn_number = '" + inv_code + "' or ";
3998
+ query += "serial_no like '" + inv_code + "%' or ";
3999
+ query += "inv_pnrr_number = '" + inv_code + "') and ";
4000
+ query += "sd.type = 'MAGAZZINO'";
4001
+ return query;
4002
+ }
4003
+ function selectDeviceInDepositoMySQL(inv_code) {
4004
+ var query = "SELECT d.id, d.type, d.manifacturer, d.model, ";
4005
+ query += "case ";
4006
+ query += "when inv_ict3_number != '' and inv_ict3_number is not null then inv_ict3_number ";
4007
+ query += "when inv_pnrr_number != '' and inv_pnrr_number is not null then inv_pnrr_number ";
4008
+ query += "when inv_tn_number != '' and inv_tn_number is not null then concat(inv_tn_number,'(TN)') ";
4009
+ query += "when inv_tndigit_number != '' and inv_tndigit_number is not null then concat(inv_tndigit_number,'(TNDigit)') ";
4010
+ query += "when serial_no != '' and serial_no is not null then concat(serial_no,'(S/N)') ";
4011
+ query += "end as Codice ";
4012
+ query += " from devices d";
4013
+ query += " join device_site ds on ds.id_device = d.id"
4014
+ query += " join sites s on s.id = ds.id_site"
4015
+ query += " join site_destinations sd on sd.id_site = s.id"
4016
+ query += " where (inv_ict3_number = :inv_code or ";
4017
+ query += "inv_tn_number = :inv_code or ";
4018
+ query += "serial_no like ':inv_code%' or ";
4019
+ query += "inv_pnrr_number = :inv_code) and ";
4020
+ query += "sd.type = 'MAGAZZINO'";
4021
+ return query;
4022
+ }
4023
+ function selectDeviceInDeposito(db_used, inv_code) {
4024
+ var query = "";
4025
+ if (db_used) {
4026
+ switch (db_used) {
4027
+ case 'SQLITE':
4028
+ query = selectDeviceInDepositoSQLite(inv_code);
4029
+ break;
4030
+ case 'MYSQL':
4031
+ query = selectDeviceInDepositoMySQL(inv_code);
4032
+ break;
4033
+ }
4034
+ }
4035
+ return query;
4036
+ }
3529
4037
  //get connection types
3530
4038
  function getConnectionTypesSQLite() {
3531
4039
  var query = "select id, conn_type from connection_types";
@@ -6108,17 +6616,28 @@ module.exports = {
6108
6616
  getBeniConsumoByIdDevice,
6109
6617
  queryConsegneByIdDevice,
6110
6618
  queryFornitoriGestoriCombo,
6619
+ selectGestoreById,
6111
6620
  queryCloseGestioneDevice,
6112
6621
  queryInsertGestioneDevice,
6113
6622
  querySelectExistsGestioneDeviceByIds,
6114
6623
  querySelectGestioniDeviceByIdDevice,
6115
6624
  queryConsegne,
6116
6625
  queryConsegnaById,
6626
+ insertConsegnaDevice,
6627
+ updateConsegnaDevice,
6628
+ removeConsegnaDevice,
6629
+ selectDevicePerConsegna,
6630
+ selectDeviceConsegna,
6631
+ selectDeviceInDeposito,
6117
6632
  queryDeviceStatusCombo,
6118
6633
  queryUsers,
6119
6634
  queryFunctions,
6120
6635
  queryAllFunctions,
6636
+ selectInterventi,
6121
6637
  queryInterventoById,
6638
+ insertIntervento,
6639
+ updateIntervento,
6640
+ removeIntervento,
6122
6641
  insertDeviceIntervento,
6123
6642
  updateDeviceIntervento,
6124
6643
  removeDeviceIntervento,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alsmanager_lib",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "description": "Funzioni per ALSManager",
5
5
  "license": "ISC",
6
6
  "author": "Luca Cattani",