alsmanager_lib 3.0.195 → 3.0.197

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 +188 -1
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -16371,7 +16371,179 @@ function getMapPointsById(id_point) {
16371
16371
  query += "where id = " + id_point;
16372
16372
  return query;
16373
16373
  }
16374
+ // Printer management
16375
+ /*
16376
+ CREATE TABLE "printer_cost_per_copy" (
16377
+ "id" INTEGER,
16378
+ "id_device" INTEGER,
16379
+ "id_gestore" INTEGER,
16380
+ "date_valid_start" TEXT,
16381
+ "date_valid_end" TEXT,
16382
+ "operation" TEXT,
16383
+ "print_color_bw" TEXT,
16384
+ "cost" REAL,
16385
+ PRIMARY KEY("id" AUTOINCREMENT)
16386
+ )
16387
+
16388
+ CREATE TABLE "printer_counters" (
16389
+ "id" INTEGER,
16390
+ "id_device" INTEGER,
16391
+ "date_read" TEXT,
16392
+ "operation" TEXT,
16393
+ "num_bw" INTEGER,
16394
+ "num_colors" INTEGER
16395
+ )
16396
+
16397
+ CREATE TABLE "printer_recharge_user" (
16398
+ "id" INTEGER,
16399
+ "id_user" INTEGER,
16400
+ "id_device" INTEGER,
16401
+ "operation" TEXT,
16402
+ "date_recharge" TEXT,
16403
+ "num_bw" INTEGER,
16404
+ "num_colors" INTEGER,
16405
+ PRIMARY KEY("id")
16406
+ )
16407
+
16408
+ CREATE TABLE "printer_stampe_user" (
16409
+ "id" INTEGER,
16410
+ "id_device" INTEGER,
16411
+ "id_user" INTEGER,
16412
+ "operation" TEXT,
16413
+ "date_read" TEXT,
16414
+ "num_bw" INTEGER,
16415
+ "num_colors" INTEGER,
16416
+ PRIMARY KEY("id" AUTOINCREMENT)
16417
+ )
16418
+ */
16419
+
16420
+ function selectPrinters(id_place, only_external) {
16421
+ var query = "select d.id, concat(d.manifacturer, ' - ', d.model, ' (', p.name, ' - ', sd.name, ' - p.no : ', s.floor, ')') as descrizione, ";
16422
+ query += "case ";
16423
+ query += "when dg.id is not null then gf.name ";
16424
+ query += "else 'Interno' ";
16425
+ query += "end as gestore ";
16426
+ query += "from devices d ";
16427
+ query += "join device_site ds on ds.id_device = d.id ";
16428
+ query += "join site_destinations sd on sd.id_site = ds.id_site ";
16429
+ query += "join sites s on s.id = ds.id_site ";
16430
+ query += "join places p on p.mark = sd.id_place ";
16431
+ query += "left join device_gestioni dg on d.id = dg.id_device ";
16432
+ query += "left join gestori_fornitori gf on dg.id_gestione = gf.id ";
16433
+ query += "where sd.date_start <= date('now') and sd.date_end >= date('now') ";
16434
+ query += "and d.type = 'STAMPANTE' ";
16435
+ query += "and (dg.id is null or (dg.date_start <= date('now') and dg.date_end >= date('now'))) ";
16436
+ if (only_external && only_external == 1)
16437
+ query += "and dg.id is not null ";
16438
+ if (id_place && id_place != "")
16439
+ query += "and s.id_place = '" + id_place + "' ";
16440
+ query += "order by ds.id_place, s.floor, dg.id_gestione ";
16441
+ return query;
16442
+ }
16443
+
16444
+
16445
+ function selectCountersPrinters(id_gestore) {
16446
+ var query = "select pc.id, concat(d.manifacturer, ' - ', d.model) as Stampante, from printer_counters pc ";
16447
+ query += "join devices d on d.id = pc.id_device ";
16448
+ query += "left join device_gestioni dg on pc.id_device = dg.id_gestione ";
16449
+ query += "left join device_site ds on pc.id_device "
16450
+ query += "where dg.date_start <= date('now') and dg.date_end >= date('now') ";
16451
+ return query;
16452
+ }
16453
+
16454
+ function readCountersPrinter(id_device) {
16455
+ var query = "select id, id_device, date_read, operation, num_bw, num_colors from printer_counters ";
16456
+ query += "where id_device = " + id_device + " ";
16457
+ query += "order by date_read desc limit 1";
16458
+ return query;
16459
+ }
16460
+
16461
+ function writeCountersPrinter(id_device, date_read, operation, num_bw, num_colors) {
16462
+ var dr_str = convertDateToStringDB(date_read);
16463
+ var query = "insert into printer_counters (id_device, date_read, operation, num_bw, num_colors) values (";
16464
+ query += id_device + ", '" + dr_str + "', '" + operation + "', " + num_bw + ", " + num_colors + ")";
16465
+ return query;
16466
+ }
16374
16467
 
16468
+ function updateCountersPrinter(id_prnread, id_device, date_read, operation, num_bw, num_colors, ) {
16469
+ var dr_str = convertDateToStringDB(date_read);
16470
+ var query = "update printer_counters set ";
16471
+ query += "id_device = " + id_device + ", ";
16472
+ query += "date_read = '" + dr_str + "',";
16473
+ query += "operation = '" + operation + "', ";
16474
+ query += "num_bw = " + num_bw + ", ";
16475
+ query += "num_colors = " + num_colors + " ";
16476
+ query += "where id = " + id_prnread;
16477
+ return query;
16478
+ }
16479
+
16480
+ function deleteCountersPrinter(id_prnread) {
16481
+ var query = "delete from printer_counters ";
16482
+ query += "where id = " + id_prnread;
16483
+ return query;
16484
+ }
16485
+
16486
+ function readCountersPrinterUser(id_user) {
16487
+ var query = "select id, id_user, id_device, operation, date_read, num_bw, num_colors from printer_stampe_user ";
16488
+ query += "where id_user = " + id_user;
16489
+ return query;
16490
+ }
16491
+
16492
+ function writeCountersPrinterUser(id_user, id_device, date_read, operation, num_bw, num_colors) {
16493
+ var dr_str = convertDateToStringDB(date_read);
16494
+ var query = "insert into printer_stampe_user (id, id_user, id_device, date_read, operation, num_bw, num_colors) values (";
16495
+ query += id_user + ", " + id_device + ", '" + dr_str + "', '" + operation + ", " + num_bw + ", " + num_colors + ")";
16496
+ return query;
16497
+ }
16498
+
16499
+ function updateCountersPrinterUser(id_counteruser, date_read, operation, num_bw, num_colors) {
16500
+ var dr_str = convertDateToStringDB(date_read);
16501
+ var query = "update printer_stampe_user set ";
16502
+ query += "date_read = '" + dr_str + "', ";
16503
+ query += "operation = '" + operation + "', ";
16504
+ query += "num_bw = " + num_bw + ", ";
16505
+ query += "num_colors = " + num_colors + " ";
16506
+ query += "where id = " + id_counteruser;
16507
+ return query;
16508
+ }
16509
+
16510
+ function deleteCountersPrinterUser(id_counteruser) {
16511
+ var query = "delete from printer_stampe_user ";
16512
+ query += "where id = " + id_counteruser;
16513
+ return query;
16514
+ }
16515
+
16516
+ function readCountersPrinterRechargeUser(id_user) {
16517
+ var query = "select id, id_user, id_device, operation, date_recharge, num_bw, num_colors from printer_recharge_user ";
16518
+ query += "where id_user = " + id_user;
16519
+ return query;
16520
+ }
16521
+
16522
+ function writeCountersPrinterRechargeUser(id_user, id_device, date_recharge, operation, num_bw, num_colors) {
16523
+ var dr_str = convertDateToStringDB(date_recharge);
16524
+ var query = "insert into printer_recharge_user (id, id_user, id_device, date_recharge, operation, num_bw, num_colors) values (";
16525
+ query += id_user + ", " + id_device + ", '" + dr_str + "', '" + operation + ", " + num_bw + ", " + num_colors + ")"; return query;
16526
+ }
16527
+
16528
+ function updateCountersPrinterRechargeUser(id_counteruser, date_recharge, operation, num_bw, num_colors) {
16529
+ var dr_str = convertDateToStringDB(date_recharge);
16530
+ var query = "update printer_recharge_user set ";
16531
+ query += "date_recharge = '" + dr_str + "', ";
16532
+ query += "operation = '" + operation + "', ";
16533
+ query += "num_bw = " + num_bw + ", ";
16534
+ query += "num_colors = " + num_colors + " ";
16535
+ query += "where id = " + id_counteruser;
16536
+ return query;
16537
+ }
16538
+
16539
+ function deleteCountersPrinterRechargeUser(id_counteruser) {
16540
+ var query = "delete from printer_recharge_user ";
16541
+ query += "where id = " + id_counteruser;
16542
+ return query;
16543
+ }
16544
+
16545
+
16546
+ // End Printer management
16375
16547
  // Exports
16376
16548
 
16377
16549
  module.exports = {
@@ -16843,6 +17015,21 @@ module.exports = {
16843
17015
  removeMapPoint,
16844
17016
  removeMapPointByPlace,
16845
17017
  queryMapPointsByPlaceAndFloor,
16846
- getMapPointsById
17018
+ getMapPointsById,
17019
+ //
17020
+ selectPrinters,
17021
+ selectCountersPrinters,
17022
+ readCountersPrinter,
17023
+ writeCountersPrinter,
17024
+ updateCountersPrinter,
17025
+ deleteCountersPrinter,
17026
+ readCountersPrinterUser,
17027
+ writeCountersPrinterUser,
17028
+ updateCountersPrinterUser,
17029
+ deleteCountersPrinterUser,
17030
+ readCountersPrinterRechargeUser,
17031
+ writeCountersPrinterRechargeUser,
17032
+ updateCountersPrinterRechargeUser,
17033
+ deleteCountersPrinterRechargeUser
16847
17034
  };
16848
17035
  // end of source
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.195",
7
+ "version": "3.0.197",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",