alsmanager_lib 3.0.39 → 3.0.41

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 -33
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -2761,7 +2761,7 @@ function queryDeviceModelsByFilter(db_used, manifacturer, dev_type) {
2761
2761
  //end of Manage models
2762
2762
 
2763
2763
  // Device select
2764
- function getDevicesSelectSQLite(search_type, inv_code, dev_type, marca, dev_model, is_PNRR, dev_status, dev_gestione, no_inv, id_dev_exclude) {
2764
+ function getDevicesSelectSQLite(search_type, inv_code, dev_type, marca, dev_model, is_PNRR, dev_status, dev_gestione, no_inv, in_consegna, id_dev_exclude) {
2765
2765
  var query = "SELECT DISTINCT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
2766
2766
  query += "case ";
2767
2767
  query += "when d.no_inventario is not null and d.no_inventario > 0 then concat(d.id,'(ID)') ";
@@ -2776,9 +2776,11 @@ function getDevicesSelectSQLite(search_type, inv_code, dev_type, marca, dev_mode
2776
2776
  query += "left join device_usage du on d.id = du.id_device"
2777
2777
  if (dev_gestione)
2778
2778
  query += "left join device_gestioni dg on d.id = dg.id_device"
2779
+ if (in_consegna)
2780
+ query += "left join consegna_beni cb on d.id = cb.id_bene"
2779
2781
 
2780
2782
  var where_clause = " where (d.is_removed is null or d.is_removed = 0) ";
2781
- if (inv_code || dev_type || marca || dev_model || (is_PNRR && is_PNRR > 0) || dev_status || dev_gestione || no_inv) {
2783
+ if (inv_code || dev_type || marca || dev_model || (is_PNRR && is_PNRR > 0) || dev_status || dev_gestione || no_inv || in_consegna) {
2782
2784
  if (inv_code) {
2783
2785
  if (search_type == "ESATTA") {
2784
2786
  where_clause += " and (d.inv_ict3_number = '" + inv_code + "' or ";
@@ -2799,42 +2801,48 @@ function getDevicesSelectSQLite(search_type, inv_code, dev_type, marca, dev_mode
2799
2801
  where_clause += " and ";
2800
2802
  if (dev_type) {
2801
2803
  where_clause += "d.type = '" + dev_type + "'";
2802
- if (marca || (is_PNRR && is_PNRR > 0) || dev_status || dev_model || dev_gestione || no_inv) {
2804
+ if (marca || (is_PNRR && is_PNRR > 0) || dev_status || dev_model || dev_gestione || no_inv || in_consegna) {
2803
2805
  where_clause += " and ";
2804
2806
  }
2805
2807
  }
2806
2808
  if (marca) {
2807
2809
  where_clause += " d.manifacturer = '" + marca + "'";
2808
- if ((is_PNRR && is_PNRR > 0) || dev_status || dev_model || dev_gestione || no_inv) {
2810
+ if ((is_PNRR && is_PNRR > 0) || dev_status || dev_model || dev_gestione || no_inv || in_consegna) {
2809
2811
  where_clause += " and ";
2810
2812
  }
2811
2813
  }
2812
2814
  if (is_PNRR && is_PNRR > 0) {
2813
2815
  where_clause += " (d.inv_pnrr_number <> '' and inv_pnrr_number is not null) ";
2814
- if (dev_status || dev_gestione || dev_model || no_inv) {
2816
+ if (dev_status || dev_gestione || dev_model || no_inv || in_consegna) {
2815
2817
  where_clause += " and ";
2816
2818
  }
2817
2819
  }
2818
2820
  if (dev_model) {
2819
2821
  where_clause += " d.model = '" + dev_model + "'";
2820
- if (dev_status || dev_gestione || no_inv) {
2822
+ if (dev_status || dev_gestione || no_inv || in_consegna) {
2821
2823
  where_clause += " and ";
2822
2824
  }
2823
2825
  }
2824
2826
  if (dev_status) {
2825
2827
  where_clause += " du.status = " + dev_status + " and date('now') >= du.date_status";
2826
- if (dev_gestione || no_inv) {
2828
+ if (dev_gestione || no_inv || in_consegna) {
2827
2829
  where_clause += " and ";
2828
2830
  }
2829
2831
  }
2830
2832
  if (dev_gestione) {
2831
2833
  where_clause += " dg.id_gestione = " + dev_gestione + " and date('now') >= dg.date_start and date('now') <= dg.date_end";
2832
- if (no_inv) {
2834
+ if (no_inv || in_consegna) {
2833
2835
  where_clause += " and ";
2834
2836
  }
2835
2837
  }
2836
2838
  if (no_inv) {
2837
2839
  where_clause += " d.no_inventario = 1";
2840
+ if (in_consegna) {
2841
+ where_clause += " and ";
2842
+ }
2843
+ }
2844
+ if (in_consegna) {
2845
+ query += " (cb.id_consegna is not null and cb.tipo_bene = 'DEVICE' and cb.stato_restituzione = 0)"
2838
2846
  }
2839
2847
  }
2840
2848
  }
@@ -2845,7 +2853,7 @@ function getDevicesSelectSQLite(search_type, inv_code, dev_type, marca, dev_mode
2845
2853
  return query;
2846
2854
  }
2847
2855
 
2848
- function getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, dev_model, is_PNRR, dev_status, dev_gestione, no_inv, id_dev_exclude) {
2856
+ function getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, dev_model, is_PNRR, dev_status, dev_gestione, no_inv, in_consegna, id_dev_exclude) {
2849
2857
  var query = "SELECT DISTINCT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
2850
2858
  query += "case ";
2851
2859
  query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then d.inv_ict3_number ";
@@ -2859,10 +2867,12 @@ function getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, dev_model
2859
2867
  query += "left join device_usage du on d.id = du.id_device"
2860
2868
  if (dev_gestione)
2861
2869
  query += "left join device_gestioni dg on d.id = dg.id_device"
2870
+ if (in_consegna)
2871
+ query += "left join consegna_beni cb on d.id = cb.id_bene"
2862
2872
 
2863
2873
 
2864
2874
  var where_clause = " where (d.is_removed is null or d.is_removed = 0) ";
2865
- if (inv_code || dev_type || marca || dev_model || (is_PNRR && is_PNRR > 0) || dev_status || dev_gestione || no_inv) {
2875
+ if (inv_code || dev_type || marca || dev_model || (is_PNRR && is_PNRR > 0) || dev_status || dev_gestione || no_inv || in_consegna) {
2866
2876
  if (inv_code) {
2867
2877
  if (search_type == "ESATTA") {
2868
2878
  where_clause += " and (d.inv_ict3_number = :inv_code or ";
@@ -2883,25 +2893,25 @@ function getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, dev_model
2883
2893
  where_clause += " and ";
2884
2894
  if (dev_type) {
2885
2895
  where_clause += " d.type = :dev_type";
2886
- if (marca || dev_model || (is_PNRR && is_PNRR > 0 || dev_status || dev_gestione || no_inv)) {
2896
+ if (marca || dev_model || (is_PNRR && is_PNRR > 0 || dev_status || dev_gestione || no_inv || in_consegna)) {
2887
2897
  where_clause += " and ";
2888
2898
  }
2889
2899
  }
2890
2900
  if (marca) {
2891
2901
  where_clause += " d.manifacturer = :marca";
2892
- if (dev_model || is_PNRR && is_PNRR > 0 || dev_status || dev_gestione|| no_inv) {
2902
+ if (dev_model || is_PNRR && is_PNRR > 0 || dev_status || dev_gestione|| no_inv || in_consegna) {
2893
2903
  where_clause += " and ";
2894
2904
  }
2895
2905
  }
2896
2906
  if (is_PNRR && is_PNRR > 0) {
2897
2907
  where_clause += " (d.inv_pnrr_number <> '' and inv_pnrr_number is not null) ";
2898
- if (dev_model || dev_status || dev_gestione || no_inv ) {
2908
+ if (dev_model || dev_status || dev_gestione || no_inv || in_consegna) {
2899
2909
  where_clause += " and ";
2900
2910
  }
2901
2911
  }
2902
2912
  if (dev_model) {
2903
2913
  where_clause += " d.model = :dev_model ";
2904
- if (dev_status || dev_gestione || no_inv) {
2914
+ if (dev_status || dev_gestione || no_inv || in_consegna) {
2905
2915
  where_clause += " and ";
2906
2916
  }
2907
2917
  }
@@ -2913,12 +2923,18 @@ function getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, dev_model
2913
2923
  }
2914
2924
  if (dev_gestione) {
2915
2925
  where_clause += " dg.id_gestione = :dev_gestione and CURDATE() >= dg.date_start and CURDATE() <= dg.date_end";
2916
- if (no_inv) {
2926
+ if (no_inv || in_consegna) {
2917
2927
  where_clause += " and ";
2918
2928
  }
2919
2929
  }
2920
2930
  if (no_inv) {
2921
2931
  where_clause += " d.no_inventario = 1";
2932
+ if (in_consegna) {
2933
+ where_clause += " and ";
2934
+ }
2935
+ }
2936
+ if (in_consegna) {
2937
+ query += " (cb.id_consegna is not null and cb.tipo_bene = 'DEVICE' and cb.stato_restituzione = 0)"
2922
2938
  }
2923
2939
  }
2924
2940
  }
@@ -2931,7 +2947,7 @@ function getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, dev_model
2931
2947
  return query;
2932
2948
  }
2933
2949
 
2934
- function getDevicesSelectMySQL2(search_type, inv_code, dev_type, marca, dev_model, is_PNRR, dev_status, dev_gestione, no_inv, id_dev_exclude) {
2950
+ function getDevicesSelectMySQL2(search_type, inv_code, dev_type, marca, dev_model, is_PNRR, dev_status, dev_gestione, no_inv, in_consegna, id_dev_exclude) {
2935
2951
  var query = "SELECT DISTINCT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
2936
2952
  query += "case ";
2937
2953
  query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then d.inv_ict3_number ";
@@ -2945,9 +2961,11 @@ function getDevicesSelectMySQL2(search_type, inv_code, dev_type, marca, dev_mode
2945
2961
  query += "left join device_usage du on d.id = du.id_device"
2946
2962
  if (dev_gestione)
2947
2963
  query += "left join device_gestioni dg on d.id = dg.id_device"
2964
+ if (in_consegna)
2965
+ query += "left join consegna_beni cb on d.id = cb.id_bene"
2948
2966
 
2949
2967
  var where_clause = " where (d.is_removed is null or d.is_removed = 0) ";
2950
- if (inv_code || dev_type || marca || dev_model || (is_PNRR && is_PNRR > 0) || dev_status || dev_gestione || no_inv) {
2968
+ if (inv_code || dev_type || marca || dev_model || (is_PNRR && is_PNRR > 0) || dev_status || dev_gestione || no_inv || in_consegna) {
2951
2969
  if (inv_code) {
2952
2970
  if (search_type == "ESATTA") {
2953
2971
  where_clause += " and (d.inv_ict3_number = '" + inv_code + "' or ";
@@ -2968,42 +2986,48 @@ function getDevicesSelectMySQL2(search_type, inv_code, dev_type, marca, dev_mode
2968
2986
  where_clause += " and ";
2969
2987
  if (dev_type) {
2970
2988
  where_clause += "d.type = '" + dev_type + "'";
2971
- if (marca || (is_PNRR && is_PNRR > 0) || dev_status || dev_model || dev_gestione || no_inv) {
2989
+ if (marca || (is_PNRR && is_PNRR > 0) || dev_status || dev_model || dev_gestione || no_inv || in_consegna) {
2972
2990
  where_clause += " and ";
2973
2991
  }
2974
2992
  }
2975
2993
  if (marca) {
2976
2994
  where_clause += " d.manifacturer = '" + marca + "'";
2977
- if ((is_PNRR && is_PNRR > 0) || dev_status || dev_model || dev_gestione || no_inv) {
2995
+ if ((is_PNRR && is_PNRR > 0) || dev_status || dev_model || dev_gestione || no_inv || in_consegna) {
2978
2996
  where_clause += " and ";
2979
2997
  }
2980
2998
  }
2981
2999
  if (is_PNRR && is_PNRR > 0) {
2982
3000
  where_clause += " (d.inv_pnrr_number <> '' and inv_pnrr_number is not null) ";
2983
- if (dev_status || dev_model || dev_gestione || no_inv) {
3001
+ if (dev_status || dev_model || dev_gestione || no_inv || in_consegna) {
2984
3002
  where_clause += " and ";
2985
3003
  }
2986
3004
  }
2987
3005
  if (dev_model) {
2988
3006
  where_clause += " d.model = '" + dev_model + "'";
2989
- if (dev_status || dev_gestione || no_inv) {
3007
+ if (dev_status || dev_gestione || no_inv || in_consegna) {
2990
3008
  where_clause += " and ";
2991
3009
  }
2992
3010
  }
2993
3011
  if (dev_status) {
2994
3012
  where_clause += " du.status = " + dev_status + " and CURDATE() >= du.date_status";
2995
- if (dev_gestione || no_inv) {
3013
+ if (dev_gestione || no_inv || in_consegna) {
2996
3014
  where_clause += " and ";
2997
3015
  }
2998
3016
  }
2999
3017
  if (dev_gestione) {
3000
3018
  where_clause += " dg.id_gestione = " + dev_gestione + " and CURDATE() >= dg.date_start and CURDATE() <= dg.date_end";
3001
- if (no_inv) {
3019
+ if (no_inv || in_consegna) {
3002
3020
  where_clause += " and ";
3003
3021
  }
3004
3022
  }
3005
3023
  if (no_inv) {
3006
3024
  where_clause += " d.no_inventario = 1";
3025
+ if (in_consegna) {
3026
+ where_clause += " and ";
3027
+ }
3028
+ }
3029
+ if (in_consegna) {
3030
+ query += " (cb.id_consegna is not null and cb.tipo_bene = 'DEVICE' and cb.stato_restituzione = 0)"
3007
3031
  }
3008
3032
  }
3009
3033
  }
@@ -3014,18 +3038,18 @@ function getDevicesSelectMySQL2(search_type, inv_code, dev_type, marca, dev_mode
3014
3038
  return query;
3015
3039
  }
3016
3040
 
3017
- function getDevicesSelect(db_used, search_type, inv_code, dev_type, marca, dev_model, is_PNRR, dev_status, dev_gestione, no_inv,id_dev_exclude) {
3041
+ function getDevicesSelect(db_used, search_type, inv_code, dev_type, marca, dev_model, is_PNRR, dev_status, dev_gestione, no_inv, in_consegna, id_dev_exclude) {
3018
3042
  var query = "";
3019
3043
  if (db_used) {
3020
3044
  switch (db_used) {
3021
3045
  case 'SQLITE':
3022
- query = getDevicesSelectSQLite(search_type, inv_code, dev_type, marca, dev_model, is_PNRR, dev_status, dev_gestione, no_inv, id_dev_exclude);
3046
+ query = getDevicesSelectSQLite(search_type, inv_code, dev_type, marca, dev_model, is_PNRR, dev_status, dev_gestione, no_inv, in_consegna, id_dev_exclude);
3023
3047
  break;
3024
3048
  case 'MYSQL':
3025
- query = getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, dev_model, is_PNRR, dev_status, dev_gestione, no_inv, id_dev_exclude);
3049
+ query = getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, dev_model, is_PNRR, dev_status, dev_gestione, no_inv, in_consegna, id_dev_exclude);
3026
3050
  break;
3027
3051
  case 'MYSQL2':
3028
- query = getDevicesSelectMySQL2(search_type, inv_code, dev_type, marca, dev_model, is_PNRR, dev_status, dev_gestione, no_inv, id_dev_exclude);
3052
+ query = getDevicesSelectMySQL2(search_type, inv_code, dev_type, marca, dev_model, is_PNRR, dev_status, dev_gestione, no_inv, in_consegna, id_dev_exclude);
3029
3053
  break;
3030
3054
  }
3031
3055
  }
@@ -7818,9 +7842,9 @@ function selectBeniPerConsegnaSQLite(id_consegna) {
7818
7842
  //
7819
7843
  query += "end as Codice, ";
7820
7844
  query += "case ";
7821
- query += "when cb.tipo_bene = 'DEVICE' and trim(d.inv_pnrr_number) is null then '' ";
7822
- query += "when cb.tipo_bene = 'DEVICE' and trim(d.inv_pnrr_number) = '' then '' ";
7823
- query += "else 'SI' ";
7845
+ query += "when cb.tipo_bene = 'DEVICE' and d.inv_pnrr_number is not null and trim(d.inv_pnrr_number) <> '' then 'SI' ";
7846
+ query += "when cb.tipo_bene = 'SOFTWARE' and s.is_pnrr is not null and s.is_pnrr = 0 then 'SI' ";
7847
+ query += "else 'NO' ";
7824
7848
  query += "end as PNRR, cb.note_consegna as Note_cons ";
7825
7849
  query += "from consegna_beni cb ";
7826
7850
  query += "left join devices d on cb.id_bene = d.id ";
@@ -7842,9 +7866,9 @@ function selectBeniPerConsegnaMySQL(id_consegna) {
7842
7866
  query += "when d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)') ";
7843
7867
  query += "end as Codice, ";
7844
7868
  query += "case ";
7845
- query += "when trim(d.inv_pnrr_number) is null then '' ";
7846
- query += "when trim(d.inv_pnrr_number) = '' then '' ";
7847
- query += "else 'SI' ";
7869
+ query += "when cb.tipo_bene = 'DEVICE' and d.inv_pnrr_number is not null and trim(d.inv_pnrr_number) <> '' then 'SI' ";
7870
+ query += "when cb.tipo_bene = 'SOFTWARE' and s.is_pnrr is not null and s.is_pnrr = 0 then 'SI' ";
7871
+ query += "else 'NO' ";
7848
7872
  query += "end as PNRR, dc.note as Note_cons ";
7849
7873
  query += " from devices d";
7850
7874
  query += " left join device_consegne dc on dc.id_device = d.id";
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  ".": "./lib/modules.js",
5
5
  "./dbconn": "./lib/dbconn.js"
6
6
  },
7
- "version": "3.0.39",
7
+ "version": "3.0.41",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",