alsmanager_lib 3.0.120 → 3.0.122
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 +61 -11
- package/package.json +1 -1
package/lib/modules.js
CHANGED
|
@@ -10797,6 +10797,42 @@ function getBeneConsumoById(db_used, id_bene) {
|
|
|
10797
10797
|
return query;
|
|
10798
10798
|
}
|
|
10799
10799
|
//
|
|
10800
|
+
function insertBeneConsumo(tipo, marca, modello, quantitativo) {
|
|
10801
|
+
/*
|
|
10802
|
+
CREATE TABLE "beniconsumo" (
|
|
10803
|
+
"id" INTEGER,
|
|
10804
|
+
"Tipo" TEXT,
|
|
10805
|
+
"Marca" TEXT,
|
|
10806
|
+
"Modello" TEXT,
|
|
10807
|
+
"Quantitativo" INTEGER,
|
|
10808
|
+
"id_type" INTEGER,
|
|
10809
|
+
PRIMARY KEY("id" AUTOINCREMENT)
|
|
10810
|
+
)
|
|
10811
|
+
*/
|
|
10812
|
+
var query = "insert into beniconsumo (tipo, marca, modello, quantitativo) values (";
|
|
10813
|
+
query += "'" + tipo + "', ";
|
|
10814
|
+
query += "'" + marca + "', ";
|
|
10815
|
+
query += "'" + modello + "', ";
|
|
10816
|
+
query += quantitativo;
|
|
10817
|
+
query += ")";
|
|
10818
|
+
return query;
|
|
10819
|
+
}
|
|
10820
|
+
function updateBeneConsumo(id_bene, tipo, marca, modello, quantitativo) {
|
|
10821
|
+
var query = "update beniconsumo set ";
|
|
10822
|
+
query += "tipo = '" + tipo + "', ";
|
|
10823
|
+
query += "marca = '" + marca + "', ";
|
|
10824
|
+
query += "modello = '" + modello + "', ";
|
|
10825
|
+
query += "quantitativo = " + quantitativo + " ";
|
|
10826
|
+
query += "where id = " + id_bene;
|
|
10827
|
+
return query;
|
|
10828
|
+
|
|
10829
|
+
}
|
|
10830
|
+
function removeBeneConsumo(id_bene) {
|
|
10831
|
+
var query = "delete from beniconsumo ";
|
|
10832
|
+
query += "where id = " + id_bene;
|
|
10833
|
+
return query;
|
|
10834
|
+
}
|
|
10835
|
+
//
|
|
10800
10836
|
function insertBeneConsumoAbbinatoSQLite(id_device, id_bene, numero) {
|
|
10801
10837
|
var query = "insert into device_beniconsumo (id_device, id_bene, numero) values ";
|
|
10802
10838
|
query += "(" + id_device + ", " + id_bene + " ," + numero + ")";
|
|
@@ -11212,7 +11248,7 @@ function getLastSiteDestinationsByIdSite(id_site, id_place, date_ref) {
|
|
|
11212
11248
|
|
|
11213
11249
|
|
|
11214
11250
|
//Sites by devices
|
|
11215
|
-
function getSitesFromDeviceSQLite(id_device, prec_pos) {
|
|
11251
|
+
function getSitesFromDeviceSQLite(id_device, date_ref, prec_pos) {
|
|
11216
11252
|
var query = "SELECT DISTINCT p.mark as Sigla, p.name as Plesso, sd.name as Aula, sd.type as Funzione, s.floor as Piano from device_site ds ";
|
|
11217
11253
|
query += " JOIN sites s ON s.id = ds.id_site";
|
|
11218
11254
|
query += " JOIN site_destinations sd ON sd.id_site = ds.id_site";
|
|
@@ -11221,8 +11257,17 @@ function getSitesFromDeviceSQLite(id_device, prec_pos) {
|
|
|
11221
11257
|
query += " where ds.id_device = " + id_device;
|
|
11222
11258
|
}
|
|
11223
11259
|
else {
|
|
11224
|
-
|
|
11225
|
-
|
|
11260
|
+
if (date_ref) {
|
|
11261
|
+
var dt_ref = convertDateToStringDB(dt_ref);
|
|
11262
|
+
query += " where (dt_ref >= ds.date_in and dt_ref <= ds.date_out) ";
|
|
11263
|
+
query += "and (dt_ref >= sd.date_start and dt_ref <= ds.date_end) ";
|
|
11264
|
+
query += "and ds.id_device = " + id_device;
|
|
11265
|
+
}
|
|
11266
|
+
else {
|
|
11267
|
+
query += " where (date('now') >= ds.date_in and date('now') <= ds.date_out) ";
|
|
11268
|
+
query += "and (date('now') >= sd.date_start and date('now') <= ds.date_end) ";
|
|
11269
|
+
query += "and ds.id_device = " + id_device;
|
|
11270
|
+
}
|
|
11226
11271
|
}
|
|
11227
11272
|
query += " order by sd.name, s.floor";
|
|
11228
11273
|
return query;
|
|
@@ -11236,13 +11281,14 @@ function getSitesFromDeviceMySQL(id_device, prec_pos) {
|
|
|
11236
11281
|
query += " where ds.id_device = :id_device";
|
|
11237
11282
|
}
|
|
11238
11283
|
else {
|
|
11239
|
-
query += " where (CURDATE() >= ds.date_in and CURDATE() <= ds.date_out)
|
|
11240
|
-
query += " ds.
|
|
11284
|
+
query += " where (CURDATE() >= ds.date_in and CURDATE() <= ds.date_out) ";
|
|
11285
|
+
query += "and (CURDATE() >= sd.date_start and CURDATE() <= ds.date_end) ";
|
|
11286
|
+
query += "and ds.id_device = :id_device";
|
|
11241
11287
|
}
|
|
11242
11288
|
query += " order by sd.name, s.floor";
|
|
11243
11289
|
return query;
|
|
11244
11290
|
}
|
|
11245
|
-
function getSitesFromDeviceMySQL2(id_device, prec_pos) {
|
|
11291
|
+
function getSitesFromDeviceMySQL2(id_device, date_ref, prec_pos) {
|
|
11246
11292
|
var query = "SELECT DISTINCT p.mark as Sigla, p.name as Plesso, sd.name as Aula, sd.type as Funzione, s.floor as Piano from device_site ds ";
|
|
11247
11293
|
query += " JOIN sites s ON s.id = ds.id_site";
|
|
11248
11294
|
query += " JOIN site_destinations sd ON sd.id_site = ds.id_site";
|
|
@@ -11251,24 +11297,25 @@ function getSitesFromDeviceMySQL2(id_device, prec_pos) {
|
|
|
11251
11297
|
query += " where ds.id_device = " + id_device;
|
|
11252
11298
|
}
|
|
11253
11299
|
else {
|
|
11254
|
-
query += " where (CURDATE() >= ds.date_in and CURDATE() <= ds.date_out)
|
|
11255
|
-
query += "
|
|
11300
|
+
query += " where (CURDATE() >= ds.date_in and CURDATE() <= ds.date_out) ";
|
|
11301
|
+
query += "and (CURDATE() >= sd.date_start and CURDATE() <= ds.date_end) ";
|
|
11302
|
+
query += "and ds.id_device = " + id_device;
|
|
11256
11303
|
}
|
|
11257
11304
|
query += " order by sd.name, s.floor";
|
|
11258
11305
|
return query;
|
|
11259
11306
|
}
|
|
11260
|
-
function getSitesFromDevice(db_used, id_device, prec_pos) {
|
|
11307
|
+
function getSitesFromDevice(db_used, id_device, date_ref, prec_pos) {
|
|
11261
11308
|
var query = "";
|
|
11262
11309
|
if (db_used) {
|
|
11263
11310
|
switch (db_used) {
|
|
11264
11311
|
case 'SQLITE':
|
|
11265
|
-
query = getSitesFromDeviceSQLite(id_device, prec_pos);
|
|
11312
|
+
query = getSitesFromDeviceSQLite(id_device, date_ref, prec_pos);
|
|
11266
11313
|
break;
|
|
11267
11314
|
case 'MYSQL':
|
|
11268
11315
|
query = getSitesFromDeviceMySQL(id_device, prec_pos);
|
|
11269
11316
|
break;
|
|
11270
11317
|
case 'MYSQL2':
|
|
11271
|
-
query = getSitesFromDeviceMySQL2(id_device, prec_pos);
|
|
11318
|
+
query = getSitesFromDeviceMySQL2(id_device, date_ref, prec_pos);
|
|
11272
11319
|
break;
|
|
11273
11320
|
}
|
|
11274
11321
|
}
|
|
@@ -15060,6 +15107,9 @@ module.exports = {
|
|
|
15060
15107
|
getBeniConsumoNotNull,
|
|
15061
15108
|
getBeneConsumoUsato,
|
|
15062
15109
|
getBeneConsumoById,
|
|
15110
|
+
insertBeneConsumo,
|
|
15111
|
+
updateBeneConsumo,
|
|
15112
|
+
removeBeneConsumo,
|
|
15063
15113
|
existBeneAbbinato,
|
|
15064
15114
|
insertBeneConsumoAbbinato,
|
|
15065
15115
|
updateBeneConsumoAbbinato,
|