alsmanager_lib 3.0.226 → 3.0.228

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 +44 -7
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -9381,11 +9381,20 @@ function updateDataRientroConsegnaSQLite(consegna_id) {
9381
9381
  }
9382
9382
 
9383
9383
  function updateDataRientroConsegnaMySQL(consegna_id) {
9384
- var query = "update consegne ";
9385
- query += "set data_rientro = MAX(cb.data_restituzione) ";
9384
+ var query = "UPDATE consegne as c ";
9385
+ query += "SET c.data_rientro = (SELECT MAX(cb.data_restituzione) ";
9386
9386
  query += "from consegna_beni cb ";
9387
- query += "where consegne.id = :consegna_id ";
9388
- query += "and cb.id_consegna = :consegna_id ";
9387
+ query += "WHERE cb.id_consegna = :consegna_id) ";
9388
+ query += "WHERE c.id = :consegna_id";
9389
+ return query;
9390
+ }
9391
+
9392
+ function updateDataRientroConsegnaMySQL2(consegna_id) {
9393
+ var query = "UPDATE consegne as c ";
9394
+ query += "SET c.data_rientro = (SELECT MAX(cb.data_restituzione) ";
9395
+ query += "from consegna_beni cb ";
9396
+ query += "WHERE cb.id_consegna = " + consegna_id + ") ";
9397
+ query += "WHERE c.id = " + consegna_id;
9389
9398
  return query;
9390
9399
  }
9391
9400
 
@@ -9400,7 +9409,7 @@ function updateDataRientroConsegna(db_used, consegna_id) {
9400
9409
  query = updateDataRientroConsegnaMySQL(consegna_id);
9401
9410
  break;
9402
9411
  case 'MYSQL2':
9403
- query = updateDataRientroConsegnaSQLite(consegna_id);
9412
+ query = updateDataRientroConsegnaMySQL2(consegna_id);
9404
9413
  break;
9405
9414
  }
9406
9415
  }
@@ -13214,7 +13223,7 @@ function updateSiteDestination(id_site, id_place, date_start, date_end, name, fu
13214
13223
  return query;
13215
13224
  }
13216
13225
 
13217
- function updateSiteDestinationAfterMove(id_site, id_place, date_start, name, funzione, date_start_ref) {
13226
+ function updateSiteDestinationAfterMoveSQLite(id_site, id_place, date_start, name, funzione, date_start_ref) {
13218
13227
  var dt_end = convertDateToStringDB(date_start_ref);
13219
13228
  var dt_start = convertDateToStringDB(date_start);
13220
13229
  var query = "update site_destinations set ";
@@ -13225,6 +13234,34 @@ function updateSiteDestinationAfterMove(id_site, id_place, date_start, name, fun
13225
13234
  return query;
13226
13235
  }
13227
13236
 
13237
+ function updateSiteDestinationAfterMoveMySQL2(id_site, id_place, date_start, name, funzione, date_start_ref) {
13238
+ var dt_end = convertDateToStringDB(date_start_ref);
13239
+ var dt_start = convertDateToStringDB(date_start);
13240
+ var query = "update site_destinations set ";
13241
+ query += "date_end = DATE_SUB('" + dt_end + "', INTERVAL 1 DAY) ";
13242
+ query += "where id_site = " + id_site + " and id_place = '" + id_place + "' ";
13243
+ query += "and date_start = '" + dt_start + "' ";
13244
+ query += "and name = '" + name + "' and type = '" + funzione + "'";
13245
+ return query;
13246
+ }
13247
+
13248
+ function updateSiteDestinationAfterMove(db_used, id_site, id_place, date_start, name, funzione, date_start_ref) {
13249
+ var query = "";
13250
+ if (db_used) {
13251
+ switch (db_used) {
13252
+ case 'SQLITE':
13253
+ query = updateSiteDestinationAfterMoveSQLite(id_site, id_place, date_start, name, funzione, date_start_ref);
13254
+ break;
13255
+ case 'MYSQL':
13256
+ break;
13257
+ case 'MYSQL2':
13258
+ query = updateSiteDestinationAfterMoveMySQL2(id_site, id_place, date_start, name, funzione, date_start_ref);
13259
+ break;
13260
+ }
13261
+ }
13262
+ return query;
13263
+ }
13264
+
13228
13265
  function getSiteDestinationsByIdSite(id_site, id_place) {
13229
13266
  var query = "select date_start, date_end, name, type from site_destinations ";
13230
13267
  query += "where id_site = " + id_site + " and id_place = '" + id_place + "' ";
@@ -14379,7 +14416,7 @@ function updateSiteBySetMySQL(id_device) {
14379
14416
  return query;
14380
14417
  }
14381
14418
  function updateSiteBySetMySQL2(id_device) {
14382
- var query = "update device_site set date_out = date('now','-1 day'), date_in = date('now','-1 day') where id_device in "
14419
+ var query = "update device_site set date_out = DATE_SUB(CURDATE(), INTERVAL 1 DAY), date_in = DATE_SUB(CURDATE(), INTERVAL 1 DAY) where id_device in "
14383
14420
  query += "(select dt.id_relateddevice from device_set dt ";
14384
14421
  query += "where dt.id_maindevice = " + id_device + ") ";
14385
14422
  query += "and CURDATE() >= date_in and CURDATE() <= date_out"
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.226",
7
+ "version": "3.0.228",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",