alsmanager_lib 2.0.44 → 2.0.46

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/dbconn.js ADDED
@@ -0,0 +1,28 @@
1
+ var mysql = require('mysql');
2
+
3
+
4
+
5
+
6
+
7
+ function dbtest(query) {
8
+ var con = mysql.createConnection({
9
+ host: "localhost",
10
+ user: "root",
11
+ password: "rootdb"
12
+ });
13
+
14
+ con.connect(function(err) {
15
+ if (err) throw err;
16
+ console.log("Connected!");
17
+ con.query(query, function (err, result) {
18
+ if (err) throw err;
19
+ console.log("Result: " + result);
20
+ return result;
21
+ });
22
+ });
23
+
24
+ }
25
+
26
+ module.exports = {
27
+ dbtest
28
+ }
package/lib/modules.js CHANGED
@@ -7762,7 +7762,7 @@ function getBeniConsumo() {
7762
7762
  return query;
7763
7763
  }
7764
7764
 
7765
- function getBeniConsumoNotNull() {
7765
+ function getBeniConsumoNotNullSQLite() {
7766
7766
  var query = "select id, Tipo, Marca, Modello, Quantitativo, "
7767
7767
  query += " (select count() from device_beniconsumo where id_bene = bc.id) as Usati"
7768
7768
  query += " from beniconsumo bc";
@@ -7770,6 +7770,30 @@ function getBeniConsumoNotNull() {
7770
7770
  query += " order by Tipo";
7771
7771
  return query;
7772
7772
  }
7773
+
7774
+ function getBeniConsumoNotNullMySQL() {
7775
+ var query = "select id, Tipo, Marca, Modello, Quantitativo, "
7776
+ query += " (select count() from device_beniconsumo where id_bene = bc.id) as Usati"
7777
+ query += " from beniconsumo bc";
7778
+ query += " where bc.Quantitativo - Usati > 0"
7779
+ query += " order by Tipo";
7780
+ return query;
7781
+ }
7782
+
7783
+ function getBeniConsumoNotNull(db_used) {
7784
+ var query = "";
7785
+ if (db_used) {
7786
+ switch (db_used) {
7787
+ case 'SQLITE':
7788
+ query = getBeniConsumoNotNullSQLite();
7789
+ break;
7790
+ case 'MYSQL':
7791
+ query = getBeniConsumoNotNullMySQL();
7792
+ break;
7793
+ }
7794
+ }
7795
+ return query;
7796
+ }
7773
7797
  //
7774
7798
  function getBeneConsumoUsatoSQLite(id_device, id_bene) {
7775
7799
  var query = "select b.id, b.tipo, b.marca, b.modello, db.numero from device_beniconsumo db ";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alsmanager_lib",
3
- "version": "2.0.44",
3
+ "version": "2.0.46",
4
4
  "description": "Funzioni per ALSManager",
5
5
  "license": "ISC",
6
6
  "author": "Luca Cattani",