alsmanager_lib 1.0.61 → 1.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.
- package/lib/modules.js +118 -31
- package/package.json +1 -1
package/lib/modules.js
CHANGED
|
@@ -1126,6 +1126,12 @@ function getDevicesSelectMySQL(search_type, inv_code, dev_type, marca, is_PNRR,
|
|
|
1126
1126
|
}
|
|
1127
1127
|
if (is_PNRR && is_PNRR > 0) {
|
|
1128
1128
|
where_clause += " (d.inv_pnrr_number <> '' and inv_pnrr_number is not null) ";
|
|
1129
|
+
if (dev_status) {
|
|
1130
|
+
where_clause += " and ";
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
if (dev_status) {
|
|
1134
|
+
where_clause += " du.status = :dev_status and CURRDATE() >= du.date_status";
|
|
1129
1135
|
}
|
|
1130
1136
|
}
|
|
1131
1137
|
}
|
|
@@ -1491,12 +1497,10 @@ function queryDeviceStatusSQLite(id_device, date_ref) {
|
|
|
1491
1497
|
if (date_ref) {
|
|
1492
1498
|
switch (date_ref) {
|
|
1493
1499
|
case "current":
|
|
1494
|
-
query += "
|
|
1495
|
-
query += " (date('now') >= du.date_status and date('now') <= du.date_end)";
|
|
1500
|
+
query += "and date('now') >= du.date_status";
|
|
1496
1501
|
break;
|
|
1497
1502
|
default:
|
|
1498
|
-
query += "
|
|
1499
|
-
query += " ('" + date_ref + "' >= du.date_status and '" + date_ref + "' <= du.date_end)";
|
|
1503
|
+
query += "and '" + date_ref + "' >= du.date_status";
|
|
1500
1504
|
break;
|
|
1501
1505
|
|
|
1502
1506
|
}
|
|
@@ -1509,12 +1513,10 @@ function queryDeviceStatusMySQL(id_device, date_ref) {
|
|
|
1509
1513
|
if (date_ref) {
|
|
1510
1514
|
switch (date_ref) {
|
|
1511
1515
|
case "current":
|
|
1512
|
-
query += "
|
|
1513
|
-
query += " (CURDATE() >= du.date_status and CURDATE() <= du.date_end)";
|
|
1516
|
+
query += "and (CURDATE() >= du.date_status";
|
|
1514
1517
|
break;
|
|
1515
1518
|
default:
|
|
1516
|
-
query += "
|
|
1517
|
-
query += " (:date_ref >= du.date_status and :date_ref <= du.date_end)";
|
|
1519
|
+
query += "and :date_ref >= du.date_status";
|
|
1518
1520
|
break;
|
|
1519
1521
|
|
|
1520
1522
|
}
|
|
@@ -1538,12 +1540,12 @@ function queryDeviceStatus(db_used, id_device, date_ref) {
|
|
|
1538
1540
|
//End Get Device Status
|
|
1539
1541
|
// Insert device status
|
|
1540
1542
|
function updateDeviceStatusSQLite(id_device) {
|
|
1541
|
-
var query = "update device_usage set date_end = date('now'
|
|
1542
|
-
query += "where id_device = " + id_device + " and
|
|
1543
|
+
var query = "update device_usage set date_end = date('now') ";
|
|
1544
|
+
query += "where id_device = " + id_device + " and date_status = (select max(date_status) from device_usage where id_device = " + id_device + ")";
|
|
1543
1545
|
return query;
|
|
1544
1546
|
}
|
|
1545
1547
|
function updateDeviceStatusMySQL(id_device) {
|
|
1546
|
-
var query = "update device_usage set date_end =
|
|
1548
|
+
var query = "update device_usage set date_end = CURDATE() ";
|
|
1547
1549
|
query += "where id_device = :id_device and date_status = (select max(date_status) from device_usage where id_device = :id_device)";
|
|
1548
1550
|
return query;
|
|
1549
1551
|
}
|
|
@@ -1565,7 +1567,7 @@ function updateDeviceStatus(db_used, id_device) {
|
|
|
1565
1567
|
// end manage updateDevicesStatus
|
|
1566
1568
|
// Manage insertDeviceStatus
|
|
1567
1569
|
function insertDeviceStatusSQLite(id_device, dev_status, start_date) {
|
|
1568
|
-
var query = "insert into device_usage (date_status,
|
|
1570
|
+
var query = "insert into device_usage (date_status, id_device, status) ";
|
|
1569
1571
|
query += "values (";
|
|
1570
1572
|
if ((!start_date || start_date == '') || start_date == "TODAY") {
|
|
1571
1573
|
query += "date('now'),";
|
|
@@ -1573,14 +1575,13 @@ function insertDeviceStatusSQLite(id_device, dev_status, start_date) {
|
|
|
1573
1575
|
else {
|
|
1574
1576
|
query += "'" + start_date + "',";
|
|
1575
1577
|
}
|
|
1576
|
-
query += "'2999-12-31',";
|
|
1577
1578
|
query += id_device + ",";
|
|
1578
1579
|
query += dev_status;
|
|
1579
1580
|
query += ")";
|
|
1580
1581
|
return query;
|
|
1581
1582
|
}
|
|
1582
1583
|
function insertDeviceStatusMySQL(id_device, dev_status, start_date) {
|
|
1583
|
-
var query = "insert into device_usage (date_status,
|
|
1584
|
+
var query = "insert into device_usage (date_status, id_device, status) ";
|
|
1584
1585
|
query += "values (";
|
|
1585
1586
|
if ((!start_date || start_date == '') || start_date == "TODAY") {
|
|
1586
1587
|
query += "CURDATE(),";
|
|
@@ -1588,7 +1589,6 @@ function insertDeviceStatusMySQL(id_device, dev_status, start_date) {
|
|
|
1588
1589
|
else {
|
|
1589
1590
|
query += ":start_date,";
|
|
1590
1591
|
}
|
|
1591
|
-
query += "'2999-12-31',";
|
|
1592
1592
|
query += ":id_device,";
|
|
1593
1593
|
query += ":dev_status";
|
|
1594
1594
|
query += ")";
|
|
@@ -3183,7 +3183,7 @@ function queryDeviceTypes() {
|
|
|
3183
3183
|
return query;
|
|
3184
3184
|
}
|
|
3185
3185
|
// Define getDevicesNotAllocatedCombo
|
|
3186
|
-
function getDevicesNotAllocatedComboSQLite() {
|
|
3186
|
+
function getDevicesNotAllocatedComboSQLite(ordered_by) {
|
|
3187
3187
|
var query = "SELECT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
|
|
3188
3188
|
query += "case ";
|
|
3189
3189
|
query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then concat(d.inv_ict3_number, ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
|
|
@@ -3198,11 +3198,16 @@ function getDevicesNotAllocatedComboSQLite() {
|
|
|
3198
3198
|
query += "where (d.is_removed is null or d.is_removed = 0) "
|
|
3199
3199
|
query += "and (ds.id_place is null ";
|
|
3200
3200
|
query += "or (ds.date_in <= date('now') and ds.date_out >= date('now') and sd.type = 'MAGAZZINO')) ";
|
|
3201
|
-
|
|
3201
|
+
if (ordered_by && ordered_by == "ID") {
|
|
3202
|
+
query += "order by d.id desc";
|
|
3203
|
+
}
|
|
3204
|
+
else {
|
|
3205
|
+
query += "order by d.inv_ict3_number";
|
|
3206
|
+
}
|
|
3202
3207
|
return query;
|
|
3203
3208
|
}
|
|
3204
3209
|
|
|
3205
|
-
function getDevicesNotAllocatedComboMySQL() {
|
|
3210
|
+
function getDevicesNotAllocatedComboMySQL(ordered_by) {
|
|
3206
3211
|
var query = "SELECT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
|
|
3207
3212
|
query += "case ";
|
|
3208
3213
|
query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then concat(d.inv_ict3_number, ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
|
|
@@ -3217,18 +3222,23 @@ function getDevicesNotAllocatedComboMySQL() {
|
|
|
3217
3222
|
query += "where (d.is_removed is null or d.is_removed = 0) "
|
|
3218
3223
|
query += "and (ds.id_place is null ";
|
|
3219
3224
|
query += "or (ds.date_in <= CURDATE() and ds.date_out >= CURDATE() and sd.type = 'MAGAZZINO')) ";
|
|
3220
|
-
|
|
3225
|
+
if (ordered_by && ordered_by == "ID") {
|
|
3226
|
+
query += "order by d.id desc";
|
|
3227
|
+
}
|
|
3228
|
+
else {
|
|
3229
|
+
query += "order by d.inv_ict3_number";
|
|
3230
|
+
}
|
|
3221
3231
|
return query;
|
|
3222
3232
|
}
|
|
3223
|
-
function getDevicesNotAllocatedCombo(db_used) {
|
|
3233
|
+
function getDevicesNotAllocatedCombo(db_used,ordered_by) {
|
|
3224
3234
|
var query = "";
|
|
3225
3235
|
if (db_used) {
|
|
3226
3236
|
switch (db_used) {
|
|
3227
3237
|
case 'SQLITE':
|
|
3228
|
-
query = getDevicesNotAllocatedComboSQLite();
|
|
3238
|
+
query = getDevicesNotAllocatedComboSQLite(ordered_by);
|
|
3229
3239
|
break;
|
|
3230
3240
|
case 'MYSQL':
|
|
3231
|
-
query = getDevicesNotAllocatedComboMySQL();
|
|
3241
|
+
query = getDevicesNotAllocatedComboMySQL(ordered_by);
|
|
3232
3242
|
break;
|
|
3233
3243
|
}
|
|
3234
3244
|
}
|
|
@@ -3236,7 +3246,7 @@ function getDevicesNotAllocatedCombo(db_used) {
|
|
|
3236
3246
|
}
|
|
3237
3247
|
// End getDevicesNotAllocatedCombo
|
|
3238
3248
|
// Define getDevicesAllocatedCombo
|
|
3239
|
-
function getDevicesAllocatedComboSQLite(id_site, id_place) {
|
|
3249
|
+
function getDevicesAllocatedComboSQLite(id_site, id_place, ordered_by) {
|
|
3240
3250
|
var query = "SELECT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
|
|
3241
3251
|
query += "case ";
|
|
3242
3252
|
query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then concat(d.inv_ict3_number, ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
|
|
@@ -3251,10 +3261,15 @@ function getDevicesAllocatedComboSQLite(id_site, id_place) {
|
|
|
3251
3261
|
query += "where (d.is_removed is null or d.is_removed = 0) "
|
|
3252
3262
|
query += "and (ds.id_place is not null ";
|
|
3253
3263
|
query += "or (ds.date_in <= date('now') and ds.date_out >= date('now') and ds.id_site <> " + id_site + " and ds.id_place <> '" + id_place + "')) ";
|
|
3254
|
-
|
|
3264
|
+
if (ordered_by && ordered_by == "ID") {
|
|
3265
|
+
query += "order by d.id desc";
|
|
3266
|
+
}
|
|
3267
|
+
else {
|
|
3268
|
+
query += "order by d.inv_ict3_number";
|
|
3269
|
+
}
|
|
3255
3270
|
return query;
|
|
3256
3271
|
}
|
|
3257
|
-
function getDevicesAllocatedComboMySQL(id_site, id_place) {
|
|
3272
|
+
function getDevicesAllocatedComboMySQL(id_site, id_place, ordered_by) {
|
|
3258
3273
|
var query = "SELECT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
|
|
3259
3274
|
query += "case ";
|
|
3260
3275
|
query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then concat(d.inv_ict3_number, ' - ', d.type, ' - ', d.manifacturer, ' - ', d.model) ";
|
|
@@ -3269,18 +3284,23 @@ function getDevicesAllocatedComboMySQL(id_site, id_place) {
|
|
|
3269
3284
|
query += "where (d.is_removed is null or d.is_removed = 0) "
|
|
3270
3285
|
query += "and (ds.id_place is not null ";
|
|
3271
3286
|
query += "or (ds.date_in <= CURDATE() and ds.date_out >= CURDATE() and ds.id_site <> :id_site and ds.id_place <> :id_place)) ";
|
|
3272
|
-
|
|
3287
|
+
if (ordered_by && ordered_by == "ID") {
|
|
3288
|
+
query += "order by d.id desc";
|
|
3289
|
+
}
|
|
3290
|
+
else {
|
|
3291
|
+
query += "order by d.inv_ict3_number";
|
|
3292
|
+
}
|
|
3273
3293
|
return query;
|
|
3274
3294
|
}
|
|
3275
|
-
function getDevicesAllocatedCombo(db_used, id_site, id_place) {
|
|
3295
|
+
function getDevicesAllocatedCombo(db_used, id_site, id_place, ordered_by) {
|
|
3276
3296
|
var query = "";
|
|
3277
3297
|
if (db_used) {
|
|
3278
3298
|
switch (db_used) {
|
|
3279
3299
|
case 'SQLITE':
|
|
3280
|
-
query = getDevicesAllocatedComboSQLite(id_site, id_place);
|
|
3300
|
+
query = getDevicesAllocatedComboSQLite(id_site, id_place, ordered_by);
|
|
3281
3301
|
break;
|
|
3282
3302
|
case 'MYSQL':
|
|
3283
|
-
query = getDevicesAllocatedComboMySQL(id_site, id_place);
|
|
3303
|
+
query = getDevicesAllocatedComboMySQL(id_site, id_place, ordered_by);
|
|
3284
3304
|
break;
|
|
3285
3305
|
}
|
|
3286
3306
|
}
|
|
@@ -6808,10 +6828,14 @@ function verifyPrevDeviceSite(db_used, id_device) {
|
|
|
6808
6828
|
}
|
|
6809
6829
|
|
|
6810
6830
|
function removeDeviceSiteSQLite(id_site, id_place, id_device) {
|
|
6811
|
-
|
|
6831
|
+
var query = "delete from device_site ";
|
|
6832
|
+
query += "where id_device = " + id_device + " and date_in = (select max(date_in) from device_site where id_device = " + id_device + ")";
|
|
6833
|
+
return query;
|
|
6812
6834
|
}
|
|
6813
6835
|
function removeDeviceSiteMySQL(id_site, id_place, id_device) {
|
|
6814
|
-
|
|
6836
|
+
var query = "delete from device_site ";
|
|
6837
|
+
query += "where id_device = :id_device and date_in = (select max(date_in) from device_site where id_device = :id_device)";
|
|
6838
|
+
return query;
|
|
6815
6839
|
}
|
|
6816
6840
|
function removeDeviceSite(db_used,id_site, id_place, id_device) {
|
|
6817
6841
|
var query = "";
|
|
@@ -6828,6 +6852,32 @@ function removeDeviceSite(db_used,id_site, id_place, id_device) {
|
|
|
6828
6852
|
return query;
|
|
6829
6853
|
}
|
|
6830
6854
|
|
|
6855
|
+
function updateDeviceSiteAfterRemoveSQLite(id_device) {
|
|
6856
|
+
var query = "update device_site set date_out = '2999-12-31' ";
|
|
6857
|
+
query += "where id_device = " + id_device + " and date_in = (select max(date_in) from device_site where id_device = " + id_device + ")";
|
|
6858
|
+
return query;
|
|
6859
|
+
}
|
|
6860
|
+
function updateDeviceSiteAfterRemoveMySQL(id_device) {
|
|
6861
|
+
var query = "update device_site set date_out = '2999-12-31' ";
|
|
6862
|
+
query += "where id_device = :id_device and date_in = (select max(date_in) from device_site where id_device = :id_device)";
|
|
6863
|
+
return query;
|
|
6864
|
+
}
|
|
6865
|
+
function updateDeviceSiteAfterRemove(db_used,id_device) {
|
|
6866
|
+
var query = "";
|
|
6867
|
+
if (db_used) {
|
|
6868
|
+
switch (db_used) {
|
|
6869
|
+
case 'SQLITE':
|
|
6870
|
+
query = updateDeviceSiteAfterRemoveSQLite(id_device);
|
|
6871
|
+
break;
|
|
6872
|
+
case 'MYSQL':
|
|
6873
|
+
query = updateDeviceSiteAfterRemoveMySQL(id_device);
|
|
6874
|
+
break;
|
|
6875
|
+
}
|
|
6876
|
+
}
|
|
6877
|
+
return query;
|
|
6878
|
+
}
|
|
6879
|
+
|
|
6880
|
+
|
|
6831
6881
|
function updateDeviceSiteSQLite(id_device) {
|
|
6832
6882
|
var query = "update device_site set date_out = date('now','-1 day') ";
|
|
6833
6883
|
query += "where id_device = " + id_device + " and date_in = (select max(date_in) from device_site where id_device = " + id_device + ")";
|
|
@@ -6901,6 +6951,34 @@ function insertDeviceSite(db_used,id_device, id_place, id_site, start_date) {
|
|
|
6901
6951
|
return query;
|
|
6902
6952
|
}
|
|
6903
6953
|
// end manage updateDevicesSite
|
|
6954
|
+
//
|
|
6955
|
+
function removeDeviceFromAllSitesSQLite(id_device) {
|
|
6956
|
+
var query = "delete from device_site ";
|
|
6957
|
+
query += "where id_device = " + id_device;
|
|
6958
|
+
return query;
|
|
6959
|
+
}
|
|
6960
|
+
function removeDeviceFromAllSitesMySQL(id_device) {
|
|
6961
|
+
var query = "delete from device_site ";
|
|
6962
|
+
query += "where id_device = :id_device";
|
|
6963
|
+
return query;
|
|
6964
|
+
}
|
|
6965
|
+
function removeDeviceFromAllSites(db_used, id_device) {
|
|
6966
|
+
var query = "";
|
|
6967
|
+
if (db_used) {
|
|
6968
|
+
switch (db_used) {
|
|
6969
|
+
case 'SQLITE':
|
|
6970
|
+
query = removeDeviceFromAllSitesSQLite(id_device);
|
|
6971
|
+
break;
|
|
6972
|
+
case 'MYSQL':
|
|
6973
|
+
query = removeDeviceFromAllSitesMySQL(id_device);
|
|
6974
|
+
break;
|
|
6975
|
+
}
|
|
6976
|
+
}
|
|
6977
|
+
return query;
|
|
6978
|
+
}
|
|
6979
|
+
|
|
6980
|
+
|
|
6981
|
+
|
|
6904
6982
|
//Get Sites for Combo
|
|
6905
6983
|
function getSitesSelectComboSQLite(id_place, tipo_aula) {
|
|
6906
6984
|
var query = "select s.id, concat(p.name, ' - ', sd.name, ' - ', s.mark) as Descrizione from sites s ";
|
|
@@ -7433,6 +7511,13 @@ function queryStatisticsDeviceStatusSQLite() {
|
|
|
7433
7511
|
return query;
|
|
7434
7512
|
}
|
|
7435
7513
|
function queryStatisticsDeviceStatusMySQL() {
|
|
7514
|
+
var query = "select case when ds.status is null then 0 else ds.status end as Stato, sd.name as Descrizione, count(*) as Numero from devices d ";
|
|
7515
|
+
query += "left join device_usage ds on d.id = ds.id_device ";
|
|
7516
|
+
query += "join status_description sd on sd.id = Stato "
|
|
7517
|
+
query += "where CURDATE() >= ds.date_status or Stato = 0 ";
|
|
7518
|
+
query += "and (is_removed is null or is_removed = 0) ";
|
|
7519
|
+
query += "group by Stato";
|
|
7520
|
+
return query;
|
|
7436
7521
|
}
|
|
7437
7522
|
function queryStatisticsDeviceStatus(db_used) {
|
|
7438
7523
|
var query = "";
|
|
@@ -7931,6 +8016,8 @@ module.exports = {
|
|
|
7931
8016
|
insertDeviceSite,
|
|
7932
8017
|
updateDeviceSite,
|
|
7933
8018
|
removeDeviceSite,
|
|
8019
|
+
updateDeviceSiteAfterRemove,
|
|
8020
|
+
removeDeviceFromAllSites,
|
|
7934
8021
|
queryPlaces,
|
|
7935
8022
|
queryFloorsByPlace,
|
|
7936
8023
|
queryFunzioneByPlaceAndFloor,
|