From 83ab36fe75b405d72a61cce6128048cc85e3a1ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= <hugo@hornquist.se>
Date: Sat, 14 Apr 2018 17:30:45 +0200
Subject: [PATCH] Add dialog popup with desired information.

The reason this isn't on master is that it locks up the main thread,
something which is less than desirable.
---
 admin/mainwindow.cpp | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/admin/mainwindow.cpp b/admin/mainwindow.cpp
index 64ba4ae..f3b693e 100644
--- a/admin/mainwindow.cpp
+++ b/admin/mainwindow.cpp
@@ -545,6 +545,25 @@ void MainWindow::on_submitBuyButton_clicked()
     updateMoneyString();
     ((QSqlRelationalTableModel*) ui->stockView->model())->select();
 
+
+    QSqlQuery query("SELECT datetime(time, 'localtime') as time, "
+                    "sum(item_price * amount) AS money "
+                    "FROM acquisitions "
+                    "GROUP BY time "
+                    "ORDER BY time DESC "
+                    "LIMIT 1");
+    if (query.next()) {
+        QString str = QString("%1\n%2 kr")
+                .arg(query.value("time").toString())
+                .arg(query.value("money").toDouble() / 100.0, 0, 'f', 2);
+        // TODO this locks the current thread until the dialog is closed.
+        // This is BAD, and should be placed into a thread of it's own before
+        // it's shipped.
+        QMessageBox::information(this, "Skriv upp", str);
+    } else {
+        qDebug() << query.lastError();
+    }
+
     open_till();
 }
 
-- 
GitLab