diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index ed2143d..7df4118 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -2,6 +2,8 @@ set(Boost_USE_STATIC_LIBS ON) find_package(Boost 1.62 COMPONENTS date_time REQUIRED) find_package(SQLite3 REQUIRED) +find_package(PkgConfig REQUIRED) +pkg_check_modules(XLNT REQUIRED xlnt) set(CORE_SOURCES database.cpp @@ -10,13 +12,12 @@ set(CORE_SOURCES article.cpp sale.cpp marketplace.cpp + excelreader.cpp ) add_library(core STATIC ${CORE_SOURCES}) -target_link_libraries(core Boost::boost Boost::date_time) +target_link_libraries(core Boost::boost Boost::date_time sqlite3 ${XLNT_LIBRARIES}) if (WIN32) - target_link_libraries(core sqlite3 bcrypt) -else() - target_link_libraries(core sqlite3) + target_link_libraries(core bcrypt) endif() target_include_directories(core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) \ No newline at end of file diff --git a/src/core/excelreader.cpp b/src/core/excelreader.cpp new file mode 100644 index 0000000..c485a38 --- /dev/null +++ b/src/core/excelreader.cpp @@ -0,0 +1,18 @@ +#include "excelreader.h" + +#include + +void ExcelReader::readSellersFromFile(const std::string& filename, Marketplace* market) +{ + xlnt::workbook wb; + wb.load(filename); + auto ws = wb.sheet_by_index(0); + + const int START_ROW = 6; + const int END_ROW = 349; + + for (const auto& row : ws.rows(false)) { + //auto test = row[0].value(); + //std::cout << test << "\n"; + } +} \ No newline at end of file diff --git a/src/core/excelreader.h b/src/core/excelreader.h new file mode 100644 index 0000000..9278441 --- /dev/null +++ b/src/core/excelreader.h @@ -0,0 +1,18 @@ +#ifndef EXCEL_READER_H +#define EXCEL_READER_H + +#include "seller.h" +#include "marketplace.h" + +#include +#include +#include + +class ExcelReader +{ + public: + static void readSellersFromFile(const std::string& filename, + Marketplace* market); +}; + +#endif \ No newline at end of file diff --git a/src/core/marketplace.h b/src/core/marketplace.h index 98ec978..0751b04 100644 --- a/src/core/marketplace.h +++ b/src/core/marketplace.h @@ -7,6 +7,8 @@ #include +class ExcelReader; + namespace { using SellersVec = std::vector>; @@ -49,6 +51,8 @@ class Marketplace void exportReportToCSV(const std::string& filename, int feeInPercent, int maxFeeInEuro); + friend class ExcelReader; + private: SellersVec sellers_; SalesVec sales_; diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 6bc842b..de48a3b 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -8,8 +8,11 @@ #include "sellerdialog.h" #include "settingsdialog.h" +#include + #include +#include #include #include @@ -58,6 +61,8 @@ MainWindow::MainWindow() this->setWindowTitle("KIMA2 - Kasse Nr. " + QSettings().value("global/cashPointNo").toString()); }); + connect(ui_.importExcelAction, &QAction::triggered, this, + &MainWindow::onImportExcelActionTriggered); } void MainWindow::onActionEditSellerTriggered() @@ -232,4 +237,20 @@ void MainWindow::onAbout() "

KIMA2 ist ein kleines Kassenprogramm für Kindersachenmärkte.

" "

Copyright © Martin Brodbeck <info@rustysoft.de>

"); +} + +void MainWindow::onImportExcelActionTriggered() +{ + if (!marketplace_->getSales().empty()) { + QMessageBox(QMessageBox::Icon::Information, "Import nicht möglich", + "Der Import ist nicht möglich, da schon Verkäufe getätigt wurden.", + QMessageBox::StandardButton::Ok, this) + .exec(); + return; + } + + auto filename = QFileDialog::getOpenFileName(this, "Verkäufer importieren", QString(), + "Excel Dateien (*.xlsx *.xls)"); + + ExcelReader::readSellersFromFile(filename.toStdString(), marketplace_.get()); } \ No newline at end of file diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index da01814..8c87f91 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -32,6 +32,7 @@ class MainWindow : public QMainWindow void onActionEditSellerTriggered(); void onSellerNoEditCheckSellerNo(); void onPaidButtonTriggered(); + void onImportExcelActionTriggered(); void setSaleModel(); Ui::MainWindow ui_; diff --git a/src/gui/mainwindow.ui b/src/gui/mainwindow.ui index 4b29ccd..56c493c 100644 --- a/src/gui/mainwindow.ui +++ b/src/gui/mainwindow.ui @@ -404,6 +404,7 @@ drucken
&Verkäufer + @@ -458,6 +459,11 @@ drucken Auswertung + + + Importieren (Excel) + +