summaryrefslogtreecommitdiffstats
path: root/src/db.vala
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2013-02-05 23:46:11 +0100
committerSebastian Reichel <sre@ring0.de>2013-02-05 23:46:11 +0100
commit7c624f27af52dcaa2a64d9c6c098873e747ac279 (patch)
tree42b0c0cfcac84e50e12bb75732b0f21655cd4947 /src/db.vala
parent9ca296d963a1803a40e3b4761c85fb59673e96f1 (diff)
downloadserial-barcode-scanner-7c624f27af52dcaa2a64d9c6c098873e747ac279.tar.bz2
add system clock check
Diffstat (limited to 'src/db.vala')
-rw-r--r--src/db.vala12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/db.vala b/src/db.vala
index 344aa85..1e81aad 100644
--- a/src/db.vala
+++ b/src/db.vala
@@ -197,8 +197,9 @@ public class Database {
queries["total_profit"] = "SELECT SUM(price - (SELECT price FROM purchaseprices WHERE product = productid)) FROM invoice WHERE user >= 0 AND timestamp >= ?";
queries["user_get_ids"] = "SELECT id FROM users WHERE id > 0";
queries["user_replace"] = "INSERT OR REPLACE INTO users ('id', 'email', 'firstname', 'lastname', 'gender', 'street', 'plz', 'city', 'pgp') VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
- queries["user_auth_create"] = "INSERT OR IGNORE INTO authentication (user) VALUES (?)";
- queries["user_disable"] = "UPDATE authentication SET disabled = ? WHERE user = ?";
+ queries["user_auth_create"] = "INSERT OR IGNORE INTO authentication (user) VALUES (?)";
+ queries["user_disable"] = "UPDATE authentication SET disabled = ? WHERE user = ?";
+ queries["last_timestamp"] = "SELECT timestamp FROM sales ORDER BY timestamp DESC LIMIT 1";
/* compile queries into statements */
foreach(var entry in queries.entries) {
@@ -813,4 +814,11 @@ public class Database {
public bool user_is_disabled(int user) {
return get_user_auth(user).disabled;
}
+
+ public int64 get_timestamp_of_last_purchase() {
+ statements["last_timestamp"].reset();
+ if(statements["last_timestamp"].step() != Sqlite.ROW)
+ return 0;
+ return statements["last_timestamp"].column_int64(0);
+ }
}