alsmanager_lib 3.0.113 → 3.0.115

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 +33 -6
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -11150,30 +11150,44 @@ function updateSite(id_site, id_place, mark, floor, size) {
11150
11150
  }
11151
11151
 
11152
11152
  function writeSiteDestination(id_site, id_place, date_start, date_end, name, funzione) {
11153
+ var dt_start = convertDateToStringDB(date_start);
11154
+ var dt_end = '2999-12-31';
11155
+
11153
11156
  var query = "insert into site_destinations (id_site, id_place, date_start, date_end, name, type) values ";
11154
11157
  query += "(" + id_site + ", ";
11155
11158
  query += "'" + id_place + "', ";
11156
- query += "'" + date_start + "', ";
11157
- query += "'" + date_end + "', ";
11159
+ query += "'" + dt_start + "', ";
11160
+ query += "'" + dt_end + "', ";
11158
11161
  query += "'" + name + "', ";
11159
11162
  query += "'" + funzione + "' ";
11160
11163
  return query;
11161
11164
  }
11162
11165
 
11163
11166
  function updateSiteDestination(id_site, id_place, date_start, date_end, name, funzione) {
11167
+ var dt_start = convertDateToStringDB(date_start);
11168
+ var dt_end = convertDateToStringDB(date_end);
11169
+
11164
11170
  var query = "update site_destinations set ";
11165
- query += "'" + date_start + "', ";
11166
- query += "'" + date_end + "', ";
11171
+ query += "date_start = '" + dt_start + "', ";
11172
+ query += "date_end = '" + dt_end + "' ";
11167
11173
  if (name) {
11168
- query += "name = '" + name + "', ";
11174
+ query += ", name = '" + name + "', ";
11169
11175
  }
11170
11176
  if (funzione) {
11171
- query += "type = '" + funzione + "' ";
11177
+ query += ", type = '" + funzione + "' ";
11172
11178
  }
11173
11179
  query += "where id_site = " + id_site + " and id_place = '" + id_place + "'";
11174
11180
  return query;
11175
11181
  }
11176
11182
 
11183
+ function updateSiteDestinationAfterMove(id_site, id_place, date_start_ref) {
11184
+ var dt_end = convertDateToStringDB(date_start_ref);
11185
+ var query = "update site_destinations set ";
11186
+ query += "date_end = date('" + dt_end + "', '-1 day') ";
11187
+ query += "where id_site = " + id_site + " and id_place = '" + id_place + "'";
11188
+ return query;
11189
+ }
11190
+
11177
11191
  function getSiteDestinationsByIdSite(id_site, id_place) {
11178
11192
  var query = "select date_start, date_end, name, type from site_destinations ";
11179
11193
  query += "where id_site = " + id_site + " and id_place = '" + id_place + "' ";
@@ -11181,6 +11195,17 @@ function getSiteDestinationsByIdSite(id_site, id_place) {
11181
11195
  return query;
11182
11196
  }
11183
11197
 
11198
+ function getLastSiteDestinationsByIdSite(id_site, id_place, date_ref) {
11199
+ var dt_ref = convertDateToStringDB(date_ref);
11200
+ var query = "select date_start, date_end, name, type from site_destinations ";
11201
+ query += "where id_site = " + id_site + " and id_place = '" + id_place + "' ";
11202
+ if (date_ref) {
11203
+ query += "and date('" + dt_ref + "') >= date_start and date('" + dt_ref + "') <= date_end ";
11204
+ }
11205
+ query += "order by date_start desc LIMIT 1";
11206
+ return query;
11207
+ }
11208
+
11184
11209
 
11185
11210
  //Sites by devices
11186
11211
  function getSitesFromDeviceSQLite(id_device, prec_pos) {
@@ -15179,7 +15204,9 @@ module.exports = {
15179
15204
  updateSite,
15180
15205
  writeSiteDestination,
15181
15206
  updateSiteDestination,
15207
+ updateSiteDestinationAfterMove,
15182
15208
  getSiteDestinationsByIdSite,
15209
+ getLastSiteDestinationsByIdSite,
15183
15210
  getSitesFromDevice,
15184
15211
  getSitesWithDatesFromDevice,
15185
15212
  querySitesWithDefaults,
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.113",
7
+ "version": "3.0.115",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",