alsmanager_lib 3.0.203 → 3.0.205

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 +71 -9
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -1374,7 +1374,7 @@ function getUtentiByIdDeviceMySQL(id_device) {
1374
1374
  }
1375
1375
 
1376
1376
 
1377
- function getUtentiByIdDeviceSQLiteMYSQL2(id_device) {
1377
+ function getUtentiByIdDeviceMYSQL2(id_device) {
1378
1378
  var query = "select au.id, au.cognome_denominazione, au.nome, au.titolo from device_utenza du ";
1379
1379
  query += "join anagrafica_utenze au on au.id = du.id_utenza ";
1380
1380
  query += "where du.id_device = " + id_device + " ";
@@ -1394,7 +1394,7 @@ function getUtentiByIdDevice(db_used, id_device) {
1394
1394
  query = getUtentiByIdDeviceMySQL(id_device);
1395
1395
  break;
1396
1396
  case 'MYSQL2':
1397
- query = getUtentiByIdDeviceSQLiteMYSQL2(id_device);
1397
+ query = getUtentiByIdDeviceMYSQL2(id_device);
1398
1398
  break;
1399
1399
  }
1400
1400
  }
@@ -1415,8 +1415,26 @@ function removeUtentePerDevice(id_dev_user) {
1415
1415
 
1416
1416
  // End Anagrafica utenti
1417
1417
  //Anagrafica docenti
1418
- function getDocentiCombo(db_used, id_place, ordine_scuola, ruolo) {
1419
- var query = "select id, concat(cognome, ' ', nome, ' - ', ordine, ' - ', ruolo) as nominativo from anagrafica_docenti ";
1418
+ function getDocentiComboSQLite(id_place, ordine_scuola, ruolo) {
1419
+ var query = "select id, concat(cognome, ' ', nome, iif(ordine is not null, concat(' - ', ordine), ' '), iif(ruolo is not null, concat(' - ', ruolo), ' ')) as nominativo from anagrafica_docenti ";
1420
+ query += "where is_attivo = 1 "
1421
+ if (ordine_scuola && ordine_scuola.trim() != '') {
1422
+ query += "and (ordine = '" + ordine_scuola + "' or ruolo <> 'DOCENTE') ";
1423
+ }
1424
+ if (id_place && id_place.trim() != '') {
1425
+ query += "and (id_place = '" + id_place + "' or id_place is null) ";
1426
+ }
1427
+ if (ruolo && ruolo.trim() != '') {
1428
+ query += "and ruolo = '" + ruolo + "' ";
1429
+ }
1430
+ query += "order by cognome, nome";
1431
+ return query;
1432
+ }
1433
+
1434
+
1435
+
1436
+ function getDocentiComboMySQL(id_place, ordine_scuola, ruolo) {
1437
+ var query = "select id, concat(cognome, ' ', nome, if(ordine is not null, concat(' - ', ordine), ' '), if(ruolo is not null, concat(' - ', ruolo), ' ')) as nominativo from anagrafica_docenti ";
1420
1438
  query += "where is_attivo = 1 "
1421
1439
  if (ordine_scuola && ordine_scuola.trim() != '') {
1422
1440
  query += "and (ordine = '" + ordine_scuola + "' or ruolo <> 'DOCENTE') ";
@@ -1431,6 +1449,40 @@ function getDocentiCombo(db_used, id_place, ordine_scuola, ruolo) {
1431
1449
  return query;
1432
1450
  }
1433
1451
 
1452
+ function getDocentiComboMySQL2(id_place, ordine_scuola, ruolo) {
1453
+ var query = "select id, concat(cognome, ' ', nome, if(ordine is not null, concat(' - ', ordine), ' '), if(ruolo is not null, concat(' - ', ruolo), ' ')) as nominativo from anagrafica_docenti ";
1454
+ query += "where is_attivo = 1 "
1455
+ if (ordine_scuola && ordine_scuola.trim() != '') {
1456
+ query += "and (ordine = '" + ordine_scuola + "' or ruolo <> 'DOCENTE') ";
1457
+ }
1458
+ if (id_place && id_place.trim() != '') {
1459
+ query += "and (id_place = '" + id_place + "' or id_place is null) ";
1460
+ }
1461
+ if (ruolo && ruolo.trim() != '') {
1462
+ query += "and ruolo = '" + ruolo + "' ";
1463
+ }
1464
+ query += "order by cognome, nome";
1465
+ return query;
1466
+ }
1467
+
1468
+ function getDocentiCombo(db_used, id_place, ordine_scuola, ruolo) {
1469
+ var query = "";
1470
+ if (db_used) {
1471
+ switch (db_used) {
1472
+ case 'SQLITE':
1473
+ query = getDocentiComboSQLite(id_place, ordine_scuola, ruolo);
1474
+ break;
1475
+ case 'MYSQL':
1476
+ query = getDocentiComboMySQL(id_place, ordine_scuola, ruolo);
1477
+ break;
1478
+ case 'MYSQL2':
1479
+ query = getDocentiComboMySQL2(id_place, ordine_scuola, ruolo);
1480
+ break;
1481
+ }
1482
+ }
1483
+ return query;
1484
+ }
1485
+
1434
1486
  function getDocenteById(db_used, id_docente) {
1435
1487
  var query = "select id, cognome, nome, email, id_place, ordine, ruolo, is_attivo from anagrafica_docenti ";
1436
1488
  query += "where id = " + id_docente;
@@ -9021,11 +9073,21 @@ function updateDateConsegnaSQLite(consegna_id) {
9021
9073
  }
9022
9074
 
9023
9075
  function updateDateConsegnaMySQL(consegna_id) {
9024
- var query = "update consegne ";
9025
- query += "set data_consegna = MIN(cb.data_consegna) ";
9076
+ var query = "UPDATE consegne as c ";
9077
+ query += "SET c.data_consegna = (SELECT MIN(cb.data_consegna) ";
9026
9078
  query += "from consegna_beni cb ";
9027
- query += "where consegne.id = :consegna_id ";
9028
- query += "and cb.id_consegna = :consegna_id ";
9079
+ query += "WHERE cb.id_consegna = :consegna_id) ";
9080
+ query += "WHERE c.id = :consegna_id";
9081
+ return query;
9082
+ }
9083
+
9084
+ // UPDATE consegne as c SET c.data_consegna = (SELECT MIN(cb.data_consegna) FROM consegna_beni cb WHERE cb.id_consegna = 86) WHERE c.id = 86;
9085
+ function updateDateConsegnaMySQL2(consegna_id) {
9086
+ var query = "UPDATE consegne as c ";
9087
+ query += "SET c.data_consegna = (SELECT MIN(cb.data_consegna) ";
9088
+ query += "from consegna_beni cb ";
9089
+ query += "WHERE cb.id_consegna = " + consegna_id + ") ";
9090
+ query += "WHERE c.id = " + consegna_id;
9029
9091
  return query;
9030
9092
  }
9031
9093
 
@@ -9040,7 +9102,7 @@ function updateDateConsegna(db_used, consegna_id) {
9040
9102
  query = updateDateConsegnaMySQL(consegna_id);
9041
9103
  break;
9042
9104
  case 'MYSQL2':
9043
- query = updateDateConsegnaSQLite(consegna_id);
9105
+ query = updateDateConsegnaMySQL2(consegna_id);
9044
9106
  break;
9045
9107
  }
9046
9108
  }
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.203",
7
+ "version": "3.0.205",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",