diff --git a/admin/mainwindow.cpp b/admin/mainwindow.cpp index 64ba4aef243ac188ce7d69d6f860684a56f308cb..f3b693e3f6fd08b7208340dd1f5a397f19eedc3c 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(); }