alsmanager_lib 3.0.172 → 3.0.174

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 +124 -3
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -4243,7 +4243,7 @@ function queryDeviceByIdentificativo(db_used, identificativo) {
4243
4243
 
4244
4244
  //Get Device Status
4245
4245
  function queryDeviceStatusSQLite(id_device, date_ref) {
4246
- var query = "select case when status is null then 0 else status end as stato, date_status from device_usage du ";
4246
+ var query = "select case when status is null then 0 else status end as stato, date_start, date_end from device_usage du ";
4247
4247
  query += "where du.id_device = " + id_device + " ";
4248
4248
  if (date_ref) {
4249
4249
  switch (date_ref) {
@@ -4260,7 +4260,7 @@ function queryDeviceStatusSQLite(id_device, date_ref) {
4260
4260
  return query;
4261
4261
  }
4262
4262
  function queryDeviceStatusMySQL(id_device, date_ref) {
4263
- var query = "select case when status is null then 0 else status end as stato, date_status from device_usage du ";
4263
+ var query = "select case when status is null then 0 else status end as stato, date_start, date_end from device_usage du ";
4264
4264
  query += "where du.id_device = :id_device ";
4265
4265
  if (date_ref) {
4266
4266
  switch (date_ref) {
@@ -4277,7 +4277,7 @@ function queryDeviceStatusMySQL(id_device, date_ref) {
4277
4277
  return query;
4278
4278
  }
4279
4279
  function queryDeviceStatusMySQL2(id_device, date_ref) {
4280
- var query = "select case when status is null then 0 else status end as stato, date_status from device_usage du ";
4280
+ var query = "select case when status is null then 0 else status end as stato, date_start, date_end from device_usage du ";
4281
4281
  query += "where du.id_device = " + id_device + " ";
4282
4282
  if (date_ref) {
4283
4283
  switch (date_ref) {
@@ -12862,6 +12862,118 @@ function getSitesSelectCombo(db_used,id_place, tipo_aula) {
12862
12862
  return query;
12863
12863
  }
12864
12864
  //End get sites for combo
12865
+ // Gestione dati di ritiro devices
12866
+ function getRitiroByIdDevice(id_device) {
12867
+ var query = "select dr.id, dr.date_ritiro, ";
12868
+ query += "d.type, d.manifacturer, d.model, d.serial_no, "
12869
+ query += "case ";
12870
+ query += "when dr.id_esecutore > 0 then ag.name ";
12871
+ query += "else dr.denominazione_esecutore ";
12872
+ query += "end as Esecutore, "
12873
+ query += "note ";
12874
+ query += "from device_ritiro dr ";
12875
+ query += "join device d on d.id = dr.id_device ";
12876
+ query += "left join anagrafica_generale ag on dr.id_esecutore = ag.id ";
12877
+ query += "order by date_ritiro";
12878
+ return query;
12879
+ }
12880
+ function getRitiroByFilter(id_device, date_da, date_a, ritirante) {
12881
+ var query = "";
12882
+ if ((id_device && id_device > 0) || (date_da && date_da != '') || (date_a && date_a != '') || (id_esecutore || id_esecutore > 0)) {
12883
+ query = "select dr.id, dr.date_ritiro, ";
12884
+ query += "d.type, d.manifacturer, d.model, d.serial_no, "
12885
+ query += "case ";
12886
+ query += "when dr.id_esecutore > 0 then ag.name ";
12887
+ query += "else dr.denominazione_esecutore ";
12888
+ query += "end as Esecutore, "
12889
+ query += "note ";
12890
+ query += "from device_ritiro dr ";
12891
+ query += "join device d on d.id = dr.id_device ";
12892
+ query += "left join anagrafica_generale ag on dr.id_esecutore = ag.id ";
12893
+ query += "where ";
12894
+ if (id_device && id_device > 0) {
12895
+ query += "id_device = " + id_device + " ";
12896
+ if ((date_da && date_da != '') || (date_a && date_a != '') || (id_esecutore || id_esecutore > 0)) {
12897
+ query += "and ";
12898
+ }
12899
+ }
12900
+ if ((date_da && date_da != '') || (date_a && date_a != ''))) {
12901
+ query += "date_da >= '" + date_da + "' and date_a <= '" + date_a + "' ";
12902
+ if (id_esecutore || id_esecutore > 0) {
12903
+ query += "and ";
12904
+ }
12905
+ }
12906
+ if (id_esecutore || id_esecutore > 0) {
12907
+ query += "id_esecutore = " + id_esecutore + " ";
12908
+ }
12909
+ }
12910
+ return query;
12911
+ }
12912
+ function getRitiroById(id_ritiro) {
12913
+ var query = "select id, id_device, date_ritiro, id_esecutore, denominazione_esecutore, note from device_ritiro ";
12914
+ query += "where id = " + id_ritiro;
12915
+ return query;
12916
+ }
12917
+ function writeRitiro(id_device, data_ritiro, id_esecutore, denominazione_esecutore, note) {
12918
+ var query = "insert into device_ritiro (id_device, date_ritiro, id_esecutore, denominazione_esecutore, note) values (";
12919
+ query += id_device + ", '" + data_ritiro + "', ";
12920
+ if (id_escutore && id_esecutore > 0) {
12921
+ query += id_esecutore + ", ";
12922
+ query += "(select ";
12923
+ query += "case ";
12924
+ query += "when name is not null then name ";
12925
+ query += "else '' ";
12926
+ query += "end as denominazione ";
12927
+ query += "from anagrafica_generale where id = " + id_esecutore + "), ";
12928
+ }
12929
+ else {
12930
+ query += "0, ";
12931
+ query += "'" + denominazione_esecutore + "', ";
12932
+ }
12933
+ query += "'" + note + "'";
12934
+ query += ")";
12935
+ return query;
12936
+ }
12937
+ function updateRitiro(id_ritiro, data_ritiro, id_esecutore, denominazione_esecutore, note) {
12938
+ var query = "update device_ritiro set ";
12939
+ query += "id_device = " + id_device + ", ";
12940
+ query += "date_ritiro = '" + data_ritiro + "', ";
12941
+ query += "id_esecutore = " + id_esecutore + ", ";
12942
+ query += "denominazione_esecutore = '" + denominazione_esecutore + "', ";
12943
+ query += "note = '" + note + "' ";
12944
+ query += "where id = " + id_ritiro;
12945
+ return query;
12946
+ }
12947
+ function removeRitiroById(id_ritiro) {
12948
+ var query = "delete from device_ritiro ";
12949
+ query += "where id = " + id_ritiro;
12950
+ return query;
12951
+ }
12952
+ function removeRitiroByFilter(id_device, date_da, date_a, ritirante) {
12953
+ var query = "";
12954
+ if ((id_device && id_device > 0) || (date_da && date_da != '') || (date_a && date_a != '') || (id_esecutore || id_esecutore > 0)) {
12955
+ query = "delete from device_ritiro ";
12956
+ query += "where ";
12957
+ if (id_device && id_device > 0) {
12958
+ query += "id_device = " + id_device + " ";
12959
+ if ((date_da && date_da != '') || (date_a && date_a != '') || (id_esecutore || id_esecutore > 0)) {
12960
+ query += "and ";
12961
+ }
12962
+ }
12963
+ if ((date_da && date_da != '') || (date_a && date_a != ''))) {
12964
+ query += "date_da >= '" + date_da + "' and date_a <= '" + date_a + "' ";
12965
+ if (id_esecutore || id_esecutore > 0) {
12966
+ query += "and ";
12967
+ }
12968
+ }
12969
+ if (id_esecutore || id_esecutore > 0) {
12970
+ query += "id_esecutore = " + id_esecutore + " ";
12971
+ }
12972
+ }
12973
+ return query;
12974
+ }
12975
+
12976
+ // End Gestione dati di ritiro devices
12865
12977
  // Select Site in Combo Parziale
12866
12978
  function getSitesSelectComboByPlaceSQLite(id_place, floor, date_ref) {
12867
12979
  var query = "select s.id, concat(sd.name, ' - ', s.mark) as Descrizione from sites s ";
@@ -16216,6 +16328,15 @@ module.exports = {
16216
16328
  querySitesLab,
16217
16329
  getSiteById,
16218
16330
  getSitesSelectCombo,
16331
+ //
16332
+ getRitiroByIdDevice,
16333
+ getRitiroByFilter,
16334
+ getRitiroById,
16335
+ writeRitiro,
16336
+ updateRitiro,
16337
+ removeRitiroById,
16338
+ removeRitiroByFilter,
16339
+ //
16219
16340
  getSitesSelectComboByPlace,
16220
16341
  getSitesSelectComboExcludeId,
16221
16342
  verifyPrevDeviceSite,
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.172",
7
+ "version": "3.0.174",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",