a lot of stuff
This commit is contained in:
@@ -9,6 +9,13 @@ set(CMAKE_AUTORCC ON)
|
|||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
|
||||||
|
CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
|
add_compile_options(-Wall -Wextra -pedantic)
|
||||||
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
add_compile_options(/W4)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Widgets Svg Core Sql)
|
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Widgets Svg Core Sql)
|
||||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Svg Core Sql)
|
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Svg Core Sql)
|
||||||
|
|
||||||
@@ -31,3 +38,18 @@ target_link_libraries(EinsatzplanQT PRIVATE
|
|||||||
pqxx
|
pqxx
|
||||||
stdc++fs
|
stdc++fs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
install(TARGETS EinsatzplanQT DESTINATION /usr/bin)
|
||||||
|
|
||||||
|
set(DESKTOP_FILE_CONTENT "
|
||||||
|
[Desktop Entry]
|
||||||
|
Name=EinsatzplanQT
|
||||||
|
Exec=/usr/bin/EinsatzplanQT
|
||||||
|
Icon=calendar
|
||||||
|
Type=Application
|
||||||
|
Categories=Utility
|
||||||
|
;")
|
||||||
|
|
||||||
|
set(DESKTOP_FILE_PATH "${CMAKE_BINARY_DIR}/EinsatzplanQT.desktop")
|
||||||
|
file(WRITE ${DESKTOP_FILE_PATH} ${DESKTOP_FILE_CONTENT})
|
||||||
|
install(FILES ${DESKTOP_FILE_PATH} DESTINATION /usr/share/applications)
|
||||||
|
|||||||
24
script.sql
24
script.sql
@@ -92,18 +92,18 @@ CREATE TABLE Veranstalter (
|
|||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO Veranstalter (name, email, passwort, admin) VALUES
|
INSERT INTO Veranstalter (name, email, passwort, admin) VALUES
|
||||||
('tech_guru', 'admin@example.com', 'password123', TRUE),
|
('Davids', 'admin@example.com', 'password123', TRUE),
|
||||||
('code_master', 'user1@example.com', 'password1', FALSE),
|
('Dalitz', 'user1@example.com', 'password1', FALSE),
|
||||||
('binary_hero', 'user2@example.com', 'password2', FALSE),
|
('Tipp', 'user2@example.com', 'password2', FALSE),
|
||||||
('debug_ninja', 'user3@example.com', 'password3', FALSE),
|
('Quix', 'user3@example.com', 'password3', FALSE),
|
||||||
('data_wizard', 'user4@example.com', 'password4', FALSE),
|
('Nietsche', 'user4@example.com', 'password4', FALSE),
|
||||||
('script_samurai', 'user5@example.com', 'password5', FALSE),
|
('Ueberholz', 'user5@example.com', 'password5', FALSE),
|
||||||
('dev_genius', 'user6@example.com', 'password6', FALSE),
|
('Rethmann', 'user6@example.com', 'password6', FALSE),
|
||||||
('cyber_maven', 'user7@example.com', 'password7', FALSE),
|
('Pohle-Fröhlich', 'user7@example.com', 'password7', FALSE),
|
||||||
('net_knight', 'user8@example.com', 'password8', FALSE),
|
('Stockmann', 'user8@example.com', 'password8', FALSE),
|
||||||
('bit_boss', 'user9@example.com', 'password9', FALSE),
|
('Gref', 'user9@example.com', 'password9', FALSE),
|
||||||
('sys_sensei', 'user10@example.com', 'password10', FALSE),
|
('Naroska', 'user10@example.com', 'password10', FALSE),
|
||||||
('crypto_champ', 'user11@example.com', 'password11', FALSE);
|
('Grothe', 'user11@example.com', 'supersicherespasswort123', FALSE);
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO Veranstaltung (ort, raum, name, dauer) VALUES
|
INSERT INTO Veranstaltung (ort, raum, name, dauer) VALUES
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
EinsatzplanFrameController::EinsatzplanFrameController(QString id, bool admin)
|
EinsatzplanFrameController::EinsatzplanFrameController(QString id, bool admin)
|
||||||
:m_id(id),
|
:m_id(id),
|
||||||
m_admin(admin) {
|
m_admin(admin) {
|
||||||
const std::map<std::string, std::string> config = load_config("../config.cfg");
|
const std::map<std::string, std::string> config = load_config( );
|
||||||
|
|
||||||
m_connectionString = fmt::format(
|
m_connectionString = fmt::format(
|
||||||
"host={} port={} dbname={} user={} password={}",
|
"host={} port={} dbname={} user={} password={}",
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "../../Core/DBHandler/DBPlan/DBPlan.hpp"
|
#include "../../Core/DBHandler/DBPlan/DBPlan.hpp"
|
||||||
#include "../../Core/config/config.hpp"
|
#include "../../Core/config/config.hpp"
|
||||||
|
#include "../PlanGridController/PlanGridController.hpp"
|
||||||
|
|
||||||
class EinsatzplanFrameController {
|
class EinsatzplanFrameController {
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "LoginFrameController.hpp"
|
#include "LoginFrameController.hpp"
|
||||||
|
|
||||||
LoginFrameController::LoginFrameController( ) {
|
LoginFrameController::LoginFrameController( ) {
|
||||||
auto config = load_config("../config.cfg");
|
auto config = load_config( );
|
||||||
|
|
||||||
m_connectionString = fmt::format(
|
m_connectionString = fmt::format(
|
||||||
"host={} port={} dbname={} user={} password={}",
|
"host={} port={} dbname={} user={} password={}",
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ PlanGridController::PlanGridController( ) {
|
|||||||
|
|
||||||
planMap = new QMap<QPair<QString, QString>, QWidget*>( );
|
planMap = new QMap<QPair<QString, QString>, QWidget*>( );
|
||||||
|
|
||||||
const std::map<std::string, std::string> config = load_config("../config.cfg");
|
const std::map<std::string, std::string> config = load_config( );
|
||||||
|
|
||||||
m_connectionString = fmt::format(
|
m_connectionString = fmt::format(
|
||||||
"host={} port={} dbname={} user={} password={}",
|
"host={} port={} dbname={} user={} password={}",
|
||||||
@@ -30,7 +30,6 @@ PlanGridController::PlanGridController( ) {
|
|||||||
QMap<QPair<QString, QString>, QWidget*>* PlanGridController::getVeranstaltungen( ) {
|
QMap<QPair<QString, QString>, QWidget*>* PlanGridController::getVeranstaltungen( ) {
|
||||||
DBPlan* db = new DBPlan(m_connectionString);
|
DBPlan* db = new DBPlan(m_connectionString);
|
||||||
|
|
||||||
// stringFormat = tag , anfangszeit , Ort , Veranstaltung , Mitarbeiter , mitarbeiterID
|
|
||||||
std::vector<std::string> planData = db->getPlan( );
|
std::vector<std::string> planData = db->getPlan( );
|
||||||
|
|
||||||
for (int i = 0; i < 5; ++i)
|
for (int i = 0; i < 5; ++i)
|
||||||
@@ -57,7 +56,7 @@ QMap<QPair<QString, QString>, QWidget*>* PlanGridController::getVeranstaltungen(
|
|||||||
while (std::getline(ss, str, ','))
|
while (std::getline(ss, str, ','))
|
||||||
infoVector.push_back(str);
|
infoVector.push_back(str);
|
||||||
|
|
||||||
//Wochentag, Uhrzeit,Uhrzeitende, Campus, Veranstaltung, ProfName,raum, veranstaltungs dauer
|
//Wochentag, Uhrzeit,Uhrzeitende, Campus, Veranstaltung, ProfName,raum, prof id
|
||||||
QFrame* container = new QFrame( );
|
QFrame* container = new QFrame( );
|
||||||
|
|
||||||
container->setObjectName("container");
|
container->setObjectName("container");
|
||||||
@@ -71,13 +70,13 @@ QMap<QPair<QString, QString>, QWidget*>* PlanGridController::getVeranstaltungen(
|
|||||||
|
|
||||||
QPushButton* widget = new QPushButton(QString::fromStdString(infoVector.at(4) + " - " + infoVector.at(5) + "\n" + infoVector.at(3) + infoVector.at(6)));
|
QPushButton* widget = new QPushButton(QString::fromStdString(infoVector.at(4) + " - " + infoVector.at(5) + "\n" + infoVector.at(3) + infoVector.at(6)));
|
||||||
layout->addWidget(widget);
|
layout->addWidget(widget);
|
||||||
//widget->setAlignment(Qt::AlignCenter);
|
widget->setProperty("MitarbeiterName", QString::fromStdString(infoVector.at(5)));
|
||||||
widget->setObjectName("widget");
|
widget->setProperty("MitarbeiterID", QString::fromStdString(infoVector.at(7)));
|
||||||
|
widget->setObjectName("eintragung");
|
||||||
widget->setFixedSize(210, 70);
|
widget->setFixedSize(210, 70);
|
||||||
|
widget->setToolTip(QString::fromStdString(infoVector.at(7)));
|
||||||
|
widget->setCursor(Qt::PointingHandCursor);
|
||||||
layout->setAlignment(Qt::AlignCenter);
|
layout->setAlignment(Qt::AlignCenter);
|
||||||
connect(widget, &QPushButton::clicked, this, [infoVector]( ) {
|
|
||||||
fmt::print("clicked on " + infoVector.at(4) + '\n');
|
|
||||||
});
|
|
||||||
|
|
||||||
if (infoVector.at(4) == "THI") {
|
if (infoVector.at(4) == "THI") {
|
||||||
color = "#9FA8DA";
|
color = "#9FA8DA";
|
||||||
@@ -99,12 +98,16 @@ QMap<QPair<QString, QString>, QWidget*>* PlanGridController::getVeranstaltungen(
|
|||||||
color = "#80CBC4";
|
color = "#80CBC4";
|
||||||
} else if (infoVector.at(4) == "SWE") {
|
} else if (infoVector.at(4) == "SWE") {
|
||||||
color = "#80DEEA";
|
color = "#80DEEA";
|
||||||
|
} else if (infoVector.at(4) == "MA1") {
|
||||||
|
color = "#B39DDB";
|
||||||
|
} else if (infoVector.at(4) == "PE1") {
|
||||||
|
color = "#FFAB91";
|
||||||
} else {
|
} else {
|
||||||
color = "#313131";
|
color = "#D8D8D8";
|
||||||
}
|
}
|
||||||
|
|
||||||
widget->setStyleSheet(QString::fromStdString(R"(
|
widget->setStyleSheet(QString::fromStdString(R"(
|
||||||
#widget{
|
#eintragung{
|
||||||
border: 0px solid #313131;
|
border: 0px solid #313131;
|
||||||
background-color: )" + color + R"(;
|
background-color: )" + color + R"(;
|
||||||
color: #212121;
|
color: #212121;
|
||||||
@@ -123,3 +126,9 @@ QMap<QPair<QString, QString>, QWidget*>* PlanGridController::getVeranstaltungen(
|
|||||||
|
|
||||||
return planMap;
|
return planMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlanGridController::Krankmelden(const int id, int tag, int stunde) {
|
||||||
|
DBPlan db(m_connectionString);
|
||||||
|
|
||||||
|
db.meldeKrank(std::to_string(id), std::to_string(tag), std::to_string(stunde));
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ class PlanGridController : public QObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
std::string m_connectionString;
|
std::string m_connectionString;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString weekdays[5];
|
QString weekdays[5];
|
||||||
QString times[5];
|
QString times[5];
|
||||||
@@ -23,4 +22,5 @@ public:
|
|||||||
PlanGridController( );
|
PlanGridController( );
|
||||||
|
|
||||||
QMap<QPair<QString, QString>, QWidget*>* getVeranstaltungen( );
|
QMap<QPair<QString, QString>, QWidget*>* getVeranstaltungen( );
|
||||||
|
void Krankmelden(const int id, const int tag, const int stunde);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,77 +2,66 @@
|
|||||||
|
|
||||||
DBPlan::DBPlan(std::string connStr) : DBHandler(connStr) { };
|
DBPlan::DBPlan(std::string connStr) : DBHandler(connStr) { };
|
||||||
|
|
||||||
void DBPlan::vertretung(std::string tag, std::string stunde, std::string dauer) {
|
void DBPlan::vertretung(std::string tag, std::string stunde) {
|
||||||
try {
|
try {
|
||||||
|
std::string dauer = getDauer(tag, stunde);
|
||||||
std::string prevStunde = std::to_string(std::stoi(stunde) - 1);
|
std::string prevStunde = std::to_string(std::stoi(stunde) - 1);
|
||||||
std::string cap = std::to_string(18 - std::stoi(dauer));
|
std::string cap = std::to_string(18 - std::stoi(dauer));
|
||||||
std::string nextStunde;
|
std::string nextStunde;
|
||||||
std::string nextTag = tag;
|
std::string nextTag = tag;
|
||||||
std::string prevTag = tag;
|
std::string prevTag = tag;
|
||||||
if (dauer == "4") {
|
(dauer == "4") ? nextStunde = std::to_string(std::stoi(stunde) + 2) :
|
||||||
|
|
||||||
nextStunde = std::to_string(std::stoi(stunde) + 2);
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
nextStunde = std::to_string(std::stoi(stunde) + 1);
|
nextStunde = std::to_string(std::stoi(stunde) + 1);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prevStunde == "0") {
|
if (prevStunde == "0") {
|
||||||
prevStunde = "5";
|
prevStunde = "5";
|
||||||
prevTag = std::to_string(std::stoi(tag) - 1);
|
prevTag = std::to_string(std::stoi(tag) - 1);
|
||||||
if (prevTag == "0") {
|
if (prevTag == "0")
|
||||||
prevTag = "5";
|
prevTag = "5";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (nextStunde == "6") {
|
if (nextStunde == "6") {
|
||||||
nextStunde = "1";
|
nextStunde = "1";
|
||||||
nextTag = std::to_string(std::stoi(tag) + 1);
|
nextTag = std::to_string(std::stoi(tag) + 1);
|
||||||
if (nextTag == "6") {
|
if (nextTag == "6")
|
||||||
nextTag = "1";
|
nextTag = "1";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
|
|
||||||
|
|
||||||
std::string query =
|
std::string query =
|
||||||
"UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstalter_ID = "
|
"UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstalter_ID = "
|
||||||
"(SELECT ID FROM Veranstalter WHERE ID != (SELECT Veranstalter_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2) "
|
"(SELECT ID FROM Veranstalter WHERE ID != (SELECT Veranstalter_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2) "
|
||||||
"AND ID != (SELECT Veranstalter_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $3 AND tag = $4) LIMIT 1) WHERE uhrzeit_id = $5 AND tag = $6; ";
|
"AND ID != (SELECT Veranstalter_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $3 AND tag = $4) LIMIT 1) WHERE uhrzeit_id = $5 AND tag = $6; ";
|
||||||
|
|
||||||
|
|
||||||
pqxx::result response = worker.exec_params(query, prevStunde, prevTag, nextStunde, nextTag, stunde, tag);
|
pqxx::result response = worker.exec_params(query, prevStunde, prevTag, nextStunde, nextTag, stunde, tag);
|
||||||
|
|
||||||
worker.commit( );
|
worker.commit( );
|
||||||
|
if (response.affected_rows( ) == 0) {
|
||||||
|
std::string query2 =
|
||||||
}
|
"DELETE FROM Veranstalter_Veranstaltung_Uhrzeit WHERE tag = $1 and uhrzeit_id = $2";
|
||||||
catch (const std::exception& e) {
|
worker.exec_params(query2, tag, stunde);
|
||||||
fmt::print(e.what());
|
worker.commit( );
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DBPlan::sucheVertretung(std::string tag, std::string stunde) {
|
|
||||||
std::string dauer = getDauer(tag, stunde);
|
|
||||||
vertretung(tag, stunde, dauer);
|
|
||||||
incarbeitszeit(tag, stunde, dauer);
|
|
||||||
|
|
||||||
if (dauer == "4") {
|
if (dauer == "4") {
|
||||||
|
std::string query3 =
|
||||||
|
"DELETE FROM Veranstalter_Veranstaltung_Uhrzeit WHERE tag = $1 and uhrzeit_id = $2";
|
||||||
|
worker.exec_params(query3, tag, nextStunde);
|
||||||
|
worker.commit( );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
incarbeitszeit(tag, stunde, dauer);
|
||||||
|
if (dauer == "4")
|
||||||
upperHour(tag, stunde);
|
upperHour(tag, stunde);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception& e) {
|
||||||
|
fmt::println(e.what( ));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBPlan::meldeKrank(std::string id, std::string tag, std::string stunde) {
|
void DBPlan::meldeKrank(std::string id, std::string tag, std::string stunde) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
std::string query =
|
std::string query =
|
||||||
"UPDATE Veranstalter SET krank = TRUE WHERE ID = $1;";
|
"UPDATE Veranstalter SET krank = TRUE WHERE ID = $1;";
|
||||||
@@ -80,40 +69,32 @@ void DBPlan::meldeKrank(std::string id, std::string tag, std::string stunde) {
|
|||||||
pqxx::result response = worker.exec_params(query, id);
|
pqxx::result response = worker.exec_params(query, id);
|
||||||
worker.commit( );
|
worker.commit( );
|
||||||
|
|
||||||
sucheVertretung(tag, stunde);
|
vertretung(tag, stunde);
|
||||||
meldeGesund(id);
|
meldeGesund(id);
|
||||||
versendeEmails( );
|
versendeEmails( );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DBPlan::meldeGesund(std::string id) {
|
void DBPlan::meldeGesund(std::string id) {
|
||||||
try {
|
try {
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
std::string query =
|
std::string query = "UPDATE Veranstalter SET krank = FALSE WHERE ID = $1;";
|
||||||
"UPDATE Veranstalter SET krank = FALSE WHERE ID = $1;";
|
|
||||||
|
|
||||||
pqxx::result response = worker.exec_params(query, id);
|
worker.exec_params(query, id);
|
||||||
worker.commit( );
|
worker.commit( );
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DBPlan::deleteVeranstalterForeign(std::string id) {
|
void DBPlan::deleteVeranstalterForeign(std::string id) {
|
||||||
try {
|
try {
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
std::string query =
|
std::string query = "SELECT tag, uhrzeit_id FROM Veranstalter_Veranstaltung_Uhrzeit WHERE Veranstalter_ID = $1; ";
|
||||||
"SELECT tag, uhrzeit_id FROM Veranstalter_Veranstaltung_Uhrzeit WHERE Veranstalter_ID = $1; ";
|
|
||||||
|
|
||||||
//get times where id in plan
|
//get times where id in plan
|
||||||
//for each search vertretung
|
//for each search vertretung
|
||||||
@@ -126,117 +107,97 @@ void DBPlan::deleteVeranstalterForeign(std::string id) {
|
|||||||
for (int i = 0; i < response.affected_rows( ); i++) {
|
for (int i = 0; i < response.affected_rows( ); i++) {
|
||||||
tag = response[i][0].c_str( );
|
tag = response[i][0].c_str( );
|
||||||
stunde = response[i][1].c_str( );
|
stunde = response[i][1].c_str( );
|
||||||
sucheVertretung(tag, stunde);
|
vertretung(tag, stunde);
|
||||||
if (getDauer(tag, stunde) == "4")
|
if (getDauer(tag, stunde) == "4")
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBPlan::deleteVeranstalter(std::string id) {
|
void DBPlan::deleteVeranstalter(std::string id) {
|
||||||
|
|
||||||
deleteVeranstalterForeign(id);
|
deleteVeranstalterForeign(id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
std::string query =
|
std::string query = "DELETE FROM Veranstalter WHERE ID = $1;";
|
||||||
"DELETE FROM Veranstalter WHERE ID = $1;";
|
|
||||||
|
|
||||||
pqxx::result response = worker.exec_params(query, id);
|
worker.exec_params(query, id);
|
||||||
worker.commit( );
|
worker.commit( );
|
||||||
versendeEmails( );
|
versendeEmails( );
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DBPlan::deleteVeranstaltung(std::string name) {
|
void DBPlan::deleteVeranstaltung(std::string name) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
std::string query =
|
std::string query = "DELETE FROM Veranstaltung WHERE name = $1;";
|
||||||
"DELETE FROM Veranstaltung WHERE name = $1;";
|
|
||||||
|
|
||||||
pqxx::result response = worker.exec_params(query, name);
|
worker.exec_params(query, name);
|
||||||
worker.commit( );
|
worker.commit( );
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DBPlan::hinzufuegenVeranstaltung(std::string name, std::string dauer, std::string ort, std::string raum) {
|
void DBPlan::hinzufuegenVeranstaltung(std::string name, std::string dauer, std::string ort, std::string raum) {
|
||||||
try {
|
try {
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
std::string query =
|
std::string query =
|
||||||
"INSERT INTO Veranstaltung (name, dauer, ort, raum) VALUES ($1, $2, $3, $4);";
|
"INSERT INTO Veranstaltung (name, dauer, ort, raum) VALUES ($1, $2, $3, $4);";
|
||||||
pqxx::result response = worker.exec_params(query, name, dauer, ort, raum);
|
worker.exec_params(query, name, dauer, ort, raum);
|
||||||
worker.commit( );
|
worker.commit( );
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DBPlan::hinzufuegenVeranstalter(std::string email, std::string name, std::string pw, std::string admin) {
|
void DBPlan::hinzufuegenVeranstalter(std::string email, std::string name, std::string pw, std::string admin) {
|
||||||
try {
|
try {
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
std::string query =
|
std::string query =
|
||||||
"INSERT INTO Veranstaltung (email, name, pw, admin) VALUES ($1, $2, $3, $4);";
|
"INSERT INTO Veranstaltung (email, name, pw, admin) VALUES ($1, $2, $3, $4);";
|
||||||
pqxx::result response = worker.exec_params(query, email, name, pw, admin);
|
worker.exec_params(query, email, name, pw, admin);
|
||||||
worker.commit( );
|
worker.commit( );
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DBPlan::deleteStudent(std::string id) {
|
void DBPlan::deleteStudent(std::string id) {
|
||||||
try {
|
try {
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
std::string query =
|
std::string query =
|
||||||
"DELETE FROM studenten WHERE ID = $1;";
|
"DELETE FROM studenten WHERE ID = $1;";
|
||||||
pqxx::result response = worker.exec_params(query, id);
|
worker.exec_params(query, id);
|
||||||
worker.commit( );
|
worker.commit( );
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DBPlan::hinzufuegenStudent(std::string email, std::string name, std::string pw) {
|
void DBPlan::hinzufuegenStudent(std::string email, std::string name, std::string pw) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
std::string query =
|
std::string query =
|
||||||
"INSERT INTO studenten (email, name, pw) VALUES ($1, $2, $3);";
|
"INSERT INTO studenten (email, name, pw) VALUES ($1, $2, $3);";
|
||||||
pqxx::result response = worker.exec_params(query, email, name, pw);
|
worker.exec_params(query, email, name, pw);
|
||||||
worker.commit( );
|
worker.commit( );
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::string DBPlan::getDauer(std::string tag, std::string stunde) {
|
std::string DBPlan::getDauer(std::string tag, std::string stunde) {
|
||||||
try {
|
try {
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
@@ -247,52 +208,45 @@ std::string DBPlan::getDauer(std::string tag, std::string stunde) {
|
|||||||
|
|
||||||
worker.commit( );
|
worker.commit( );
|
||||||
|
|
||||||
|
|
||||||
return response[0][0].c_str( );
|
return response[0][0].c_str( );
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DBPlan::addFirstOfDayTwo(std::string tag) {
|
void DBPlan::addFirstOfDayTwo(std::string tag) {
|
||||||
try {
|
try {
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
std::string query =
|
std::string query =
|
||||||
"UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstalter_ID = (SELECT ID FROM Veranstalter WHERE arbeitszeit <= 16 AND krank = FALSE LIMIT 1) "
|
R"(UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstalter_ID = (SELECT ID FROM Veranstalter WHERE arbeitszeit <= 16 AND krank = FALSE LIMIT 1)
|
||||||
"WHERE uhrzeit_id = 1 AND tag = $1;";
|
WHERE uhrzeit_id = 1 AND tag = $1;)";
|
||||||
pqxx::result response = worker.exec_params(query, tag);
|
worker.exec_params(query, tag);
|
||||||
worker.commit( );
|
worker.commit( );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBPlan::addTwoHour(std::string tag, std::string stunde) {
|
void DBPlan::addTwoHour(std::string tag, std::string stunde) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
std::string prevStunde = std::to_string(std::stoi(stunde) - 1);
|
std::string prevStunde = std::to_string(std::stoi(stunde) - 1);
|
||||||
|
|
||||||
|
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
std::string query =
|
std::string query =
|
||||||
"UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstalter_id = (SELECT ID FROM Veranstalter "
|
R"(UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstalter_id = (SELECT ID FROM Veranstalter
|
||||||
"WHERE arbeitszeit <= 16 AND krank = FALSE "
|
WHERE arbeitszeit <= 16 AND krank = FALSE
|
||||||
"AND(standort = (SELECT ort FROM Veranstaltung WHERE ID = (SELECT veranstaltung_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2)) "
|
AND(standort = (SELECT ort FROM Veranstaltung WHERE ID = (SELECT veranstaltung_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2))
|
||||||
"AND ID != (SELECT veranstalter_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2)) "
|
AND ID != (SELECT veranstalter_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2))
|
||||||
"ORDER BY random() LIMIT 1) "
|
ORDER BY random() LIMIT 1)
|
||||||
"WHERE uhrzeit_id = $3 AND tag = $4;";
|
WHERE uhrzeit_id = $3 AND tag = $4;)";
|
||||||
pqxx::result response = worker.exec_params(query, prevStunde, tag, stunde, tag);
|
worker.exec_params(query, prevStunde, tag, stunde, tag);
|
||||||
worker.commit( );
|
worker.commit( );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,97 +254,81 @@ void DBPlan::addFirstOfDayFour(std::string tag) {
|
|||||||
try {
|
try {
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
std::string query =
|
std::string query =
|
||||||
"UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstalter_ID = (SELECT ID FROM Veranstalter WHERE arbeitszeit <= 14 AND krank = FALSE LIMIT 1) "
|
R"(UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstalter_ID = (SELECT ID FROM Veranstalter WHERE arbeitszeit <= 14 AND krank = FALSE LIMIT 1)
|
||||||
"WHERE uhrzeit_id = 1 AND tag = $1;";
|
WHERE uhrzeit_id = 1 AND tag = $1;)";
|
||||||
pqxx::result response = worker.exec_params(query, tag);
|
worker.exec_params(query, tag);
|
||||||
worker.commit( );
|
worker.commit( );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBPlan::addFourHour(std::string tag, std::string stunde) {
|
void DBPlan::addFourHour(std::string tag, std::string stunde) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
std::string prevStunde = std::to_string(std::stoi(stunde) - 1);
|
std::string prevStunde = std::to_string(std::stoi(stunde) - 1);
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
std::string query =
|
std::string query =
|
||||||
"UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstalter_id = (SELECT ID FROM Veranstalter "
|
R"(UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstalter_id = (SELECT ID FROM Veranstalter
|
||||||
"WHERE arbeitszeit <= 14 AND krank = FALSE "
|
WHERE arbeitszeit <= 14 AND krank = FALSE
|
||||||
"AND(standort = (SELECT ort FROM Veranstaltung WHERE ID = (SELECT veranstaltung_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2)) "
|
AND(standort = (SELECT ort FROM Veranstaltung WHERE ID = (SELECT veranstaltung_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2))
|
||||||
"AND ID != (SELECT veranstalter_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2)) "
|
AND ID != (SELECT veranstalter_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2))
|
||||||
"ORDER BY random() LIMIT 1) "
|
ORDER BY random() LIMIT 1)
|
||||||
"WHERE uhrzeit_id = $3 AND tag = $4;";
|
WHERE uhrzeit_id = $3 AND tag = $4;)";
|
||||||
pqxx::result response = worker.exec_params(query, prevStunde, tag, stunde, tag);
|
worker.exec_params(query, prevStunde, tag, stunde, tag);
|
||||||
worker.commit( );
|
worker.commit( );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBPlan::upperHour(std::string tag, std::string stunde) {
|
void DBPlan::upperHour(std::string tag, std::string stunde) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
std::string nextStunde = std::to_string(std::stoi(stunde) + 1);
|
std::string nextStunde = std::to_string(std::stoi(stunde) + 1);
|
||||||
|
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
std::string query =
|
std::string query =
|
||||||
"UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstalter_ID = (SELECT Veranstalter_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2)"
|
R"(UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstalter_ID = (SELECT Veranstalter_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2)
|
||||||
"WHERE uhrzeit_id = $3 AND tag = $2;";
|
WHERE uhrzeit_id = $3 AND tag = $2;)";
|
||||||
pqxx::result response = worker.exec_params(query, stunde, tag, nextStunde);
|
worker.exec_params(query, stunde, tag, nextStunde);
|
||||||
worker.commit( );
|
worker.commit( );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DBPlan::updateStandort(std::string tag, std::string stunde) {
|
void DBPlan::updateStandort(std::string tag, std::string stunde) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
std::string query =
|
std::string query =
|
||||||
"UPDATE Veranstalter SET standort = (SELECT ort FROM Veranstaltung WHERE ID = (SELECT Veranstaltung_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2)) WHERE ID = (SELECT Veranstalter_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2);";
|
R"(UPDATE Veranstalter SET standort = (SELECT ort FROM Veranstaltung WHERE ID = (SELECT Veranstaltung_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2)) WHERE ID = (SELECT Veranstalter_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2);)";
|
||||||
pqxx::result response = worker.exec_params(query, stunde, tag);
|
worker.exec_params(query, stunde, tag);
|
||||||
worker.commit( );
|
worker.commit( );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBPlan::incarbeitszeit(std::string tag, std::string stunde, std::string amount) {
|
void DBPlan::incarbeitszeit(std::string tag, std::string stunde, std::string amount) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
|
|
||||||
std::string query =
|
std::string query =
|
||||||
"UPDATE Veranstalter SET arbeitszeit = arbeitszeit + $1 WHERE ID = (SELECT Veranstalter_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $2 AND tag = $3);";
|
"UPDATE Veranstalter SET arbeitszeit = arbeitszeit + $1 WHERE ID = (SELECT Veranstalter_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $2 AND tag = $3);";
|
||||||
|
|
||||||
pqxx::result response = worker.exec_params(query,amount, stunde, tag);
|
worker.exec_params(query, amount, stunde, tag);
|
||||||
worker.commit( );
|
worker.commit( );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DBPlan::insertVeranstaltungenIntoPlan(std::string cap, std::string tag, std::string stunde) {
|
void DBPlan::insertVeranstaltungenIntoPlan(std::string cap, std::string tag, std::string stunde) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
std::string query =
|
std::string query =
|
||||||
R"(INSERT INTO Veranstalter_Veranstaltung_Uhrzeit (Veranstaltung_ID, tag, uhrzeit_ID)
|
R"(INSERT INTO Veranstalter_Veranstaltung_Uhrzeit (Veranstaltung_ID, tag, uhrzeit_ID)
|
||||||
@@ -409,7 +347,7 @@ void DBPlan::insertVeranstaltungenIntoPlan(std::string cap, std::string tag, std
|
|||||||
worker.commit( );
|
worker.commit( );
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,7 +366,7 @@ void DBPlan::insertAgain(std::string tag, std::string stunde) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -441,17 +379,14 @@ void DBPlan::insertVeranstaltungIntoPlanHandler() {
|
|||||||
while (timeDay <= 5) {
|
while (timeDay <= 5) {
|
||||||
std::string tagStr = std::to_string(i);
|
std::string tagStr = std::to_string(i);
|
||||||
std::string stundeStr = std::to_string(timeDay);
|
std::string stundeStr = std::to_string(timeDay);
|
||||||
if (timeDay == 5) {
|
if (timeDay == 5)
|
||||||
insertVeranstaltungenIntoPlan("2", tagStr, stundeStr);
|
insertVeranstaltungenIntoPlan("2", tagStr, stundeStr);
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
insertVeranstaltungenIntoPlan("4", tagStr, stundeStr);
|
insertVeranstaltungenIntoPlan("4", tagStr, stundeStr);
|
||||||
|
|
||||||
if (getDauer(tagStr, stundeStr) == "4") {
|
if (getDauer(tagStr, stundeStr) == "4") {
|
||||||
insertAgain(tagStr, stundeStr);
|
insertAgain(tagStr, stundeStr);
|
||||||
timeDay++;
|
timeDay++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
timeDay++;
|
timeDay++;
|
||||||
}
|
}
|
||||||
@@ -459,80 +394,54 @@ void DBPlan::insertVeranstaltungIntoPlanHandler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DBPlan::createPlan( ) {
|
void DBPlan::createPlan( ) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
insertVeranstaltungIntoPlanHandler( );
|
insertVeranstaltungIntoPlanHandler( );
|
||||||
for (int tag = 1; tag < 6; tag++) {
|
for (int tag = 1; tag < 6; tag++) {
|
||||||
std::string tagStr = std::to_string(tag);
|
std::string tagStr = std::to_string(tag);
|
||||||
for (int stunde = 1; stunde < 6; stunde++) {
|
for (int stunde = 1; stunde < 6; stunde++) {
|
||||||
std::string stundeStr = std::to_string(stunde);
|
std::string stundeStr = std::to_string(stunde);
|
||||||
//get dauer of next class
|
//get dauer of next class
|
||||||
|
|
||||||
if (std::stoi(getDauer(tagStr, stundeStr)) == 2) {
|
if (std::stoi(getDauer(tagStr, stundeStr)) == 2) {
|
||||||
if (stunde == 1) {
|
stunde == 1 ? addFirstOfDayTwo(tagStr) : addTwoHour(tagStr, stundeStr);
|
||||||
addFirstOfDayTwo(tagStr);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
addTwoHour(tagStr, stundeStr);
|
|
||||||
}
|
|
||||||
updateStandort(tagStr, stundeStr);
|
updateStandort(tagStr, stundeStr);
|
||||||
incarbeitszeit(tagStr, stundeStr, "2");
|
incarbeitszeit(tagStr, stundeStr, "2");
|
||||||
}
|
} else {
|
||||||
else {
|
stunde == 1 ? addFirstOfDayFour(tagStr) : addFourHour(tagStr, stundeStr);
|
||||||
if (stunde == 1) {
|
|
||||||
addFirstOfDayFour(tagStr);
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
addFourHour(tagStr, stundeStr);
|
|
||||||
}
|
|
||||||
upperHour(tagStr, stundeStr);
|
upperHour(tagStr, stundeStr);
|
||||||
incarbeitszeit(tagStr, stundeStr, "4");
|
incarbeitszeit(tagStr, stundeStr, "4");
|
||||||
updateStandort(tagStr, stundeStr);
|
updateStandort(tagStr, stundeStr);
|
||||||
stunde++;
|
stunde++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DBPlan::checkPlanSize( ) {
|
std::string DBPlan::checkPlanSize( ) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
|
|
||||||
std::string query =
|
std::string query =
|
||||||
"SELECT count(*) FROM Veranstalter_Veranstaltung_Uhrzeit;";
|
"SELECT count(*) FROM Veranstalter_Veranstaltung_Uhrzeit;";
|
||||||
|
|
||||||
pqxx::result response = worker.exec(query);
|
pqxx::result response = worker.exec(query);
|
||||||
worker.commit( );
|
worker.commit( );
|
||||||
|
|
||||||
return response[0][0].c_str( );
|
return response[0][0].c_str( );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> DBPlan::getPlan( ) {
|
std::vector<std::string> DBPlan::getPlan( ) {
|
||||||
try {
|
std::vector<std::string> plan;
|
||||||
|
|
||||||
|
try {
|
||||||
if (checkPlanSize( ) == "0")
|
if (checkPlanSize( ) == "0")
|
||||||
createPlan( );
|
createPlan( );
|
||||||
|
|
||||||
std::vector<std::string> plan;
|
|
||||||
|
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
|
|
||||||
std::string query =
|
std::string query =
|
||||||
@@ -552,20 +461,15 @@ std::vector<std::string> DBPlan::getPlan() {
|
|||||||
rowstring.append(",");
|
rowstring.append(",");
|
||||||
}
|
}
|
||||||
plan.push_back(rowstring);
|
plan.push_back(rowstring);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return plan;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
fmt::print(e.what());
|
fmt::println(e.what( ));
|
||||||
}
|
}
|
||||||
|
return plan;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBPlan::versendeEmails( ) {
|
void DBPlan::versendeEmails( ) {
|
||||||
//Email an alle Nutzer
|
//Email an alle Nutzer
|
||||||
fmt::print("Der Einsatzplan wurde geupdated");
|
fmt::println("Der Einsatzplan wurde geupdated");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ private:
|
|||||||
void addFirstOfDayFour(std::string tag);
|
void addFirstOfDayFour(std::string tag);
|
||||||
void upperHour(std::string tag, std::string stunde);
|
void upperHour(std::string tag, std::string stunde);
|
||||||
void addFourHour(std::string tag, std::string stunde);
|
void addFourHour(std::string tag, std::string stunde);
|
||||||
void sucheVertretung(std::string tag, std::string stunde);
|
void vertretung(std::string tag, std::string stunde);
|
||||||
void vertretung(std::string tag, std::string stunde, std::string dauer);
|
|
||||||
void deleteVeranstalterForeign(std::string id);
|
void deleteVeranstalterForeign(std::string id);
|
||||||
void updateStandort(std::string tag, std::string stunde);
|
void updateStandort(std::string tag, std::string stunde);
|
||||||
void incarbeitszeit(std::string tag, std::string stunde, std::string amount);
|
void incarbeitszeit(std::string tag, std::string stunde, std::string amount);
|
||||||
|
|||||||
@@ -5,11 +5,13 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
inline static const std::map<std::string, std::string>& load_config(const std::string& filename) {
|
inline static const std::map<std::string, std::string>& load_config( ) {
|
||||||
static std::map<std::string, std::string> config;
|
static std::map<std::string, std::string> config;
|
||||||
static bool is_loaded{ false };
|
static bool is_loaded{ false };
|
||||||
static std::string fn{ "" };
|
static std::string fn{ "" };
|
||||||
|
|
||||||
|
std::string filename = std::string(std::getenv("HOME")) + "/Dokumente/git/EinsatzplanQT/config.cfg";
|
||||||
|
|
||||||
if (!is_loaded || fn != filename) {
|
if (!is_loaded || fn != filename) {
|
||||||
std::ifstream file(filename);
|
std::ifstream file(filename);
|
||||||
std::string line;
|
std::string line;
|
||||||
@@ -19,11 +21,10 @@ inline static const std::map<std::string, std::string>& load_config(const std::s
|
|||||||
std::string key;
|
std::string key;
|
||||||
if (std::getline(line_stream, key, '=')) {
|
if (std::getline(line_stream, key, '=')) {
|
||||||
std::string value;
|
std::string value;
|
||||||
if (std::getline(line_stream, value)) {
|
if (std::getline(line_stream, value))
|
||||||
config[key] = value;
|
config[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
is_loaded = true;
|
is_loaded = true;
|
||||||
fn = filename;
|
fn = filename;
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ CreateMemDialog::CreateMemDialog(QWidget* parent)
|
|||||||
color: #212121;
|
color: #212121;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
background-color: #53EC87;
|
background-color: #A5D6A7;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
)");
|
)");
|
||||||
@@ -106,7 +106,7 @@ CreateMemDialog::CreateMemDialog(QWidget* parent)
|
|||||||
color: #212121;
|
color: #212121;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
background-color: #FF5555;
|
background-color: #EF9A9A;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
)");
|
)");
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
#include "Krankmelden.hpp"
|
||||||
|
|
||||||
|
Krankmelden::Krankmelden(const QString& mitarbeiterName, QWidget* parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
m_text(new QLabel(QString::fromStdString(mitarbeiterName.toStdString( ) + " krankmelden?"))) {
|
||||||
|
setWindowTitle("Mitarbeiter Krankmelden?");
|
||||||
|
setFixedSize(350, 150);
|
||||||
|
setObjectName("Krankmelden");
|
||||||
|
setStyleSheet(R"(
|
||||||
|
#Krankmelden{
|
||||||
|
background-color: #212121;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
|
||||||
|
m_accept = new QPushButton("Ja", this);
|
||||||
|
m_accept->setFixedSize(110, 40);
|
||||||
|
m_accept->setObjectName("acceptButton");
|
||||||
|
m_accept->setStyleSheet(R"(
|
||||||
|
#acceptButton{
|
||||||
|
color: #212121;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
background-color: #A5D6A7;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
m_decline = new QPushButton("Nein", this);
|
||||||
|
m_decline->setFixedSize(110, 40);
|
||||||
|
m_decline->setObjectName("declineButton");
|
||||||
|
m_decline->setStyleSheet(R"(
|
||||||
|
#declineButton{
|
||||||
|
color: #212121;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
background-color: #EF9A9A;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
|
||||||
|
m_text->setObjectName("mitarbeiterName");
|
||||||
|
m_text->setStyleSheet(R"(
|
||||||
|
#mitarbeiterName{
|
||||||
|
background-color: none;
|
||||||
|
border:none;
|
||||||
|
color: #D8D8D8;
|
||||||
|
font-size:18px;
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
|
||||||
|
QVBoxLayout* mainLayout = new QVBoxLayout(this);
|
||||||
|
mainLayout->addWidget(m_text, 0, Qt::AlignCenter);
|
||||||
|
|
||||||
|
QHBoxLayout* layout = new QHBoxLayout( );
|
||||||
|
mainLayout->addLayout(layout, 1);
|
||||||
|
|
||||||
|
layout->addWidget(m_accept, 1, Qt::AlignCenter);
|
||||||
|
layout->addWidget(m_decline, 1, Qt::AlignCenter);
|
||||||
|
|
||||||
|
connect(m_accept, &QPushButton::clicked, this, &QDialog::accept);
|
||||||
|
connect(m_decline, &QPushButton::clicked, this, &QDialog::reject);
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
class Krankmelden : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
protected:
|
||||||
|
QPushButton* m_accept;
|
||||||
|
QPushButton* m_decline;
|
||||||
|
QLabel* m_text;
|
||||||
|
public:
|
||||||
|
Krankmelden(const QString& mitarbeiterName, QWidget* parent = nullptr);
|
||||||
|
};
|
||||||
@@ -11,17 +11,10 @@ EinsatzplanFrame::EinsatzplanFrame(QWidget* parent, QString id, bool admin)
|
|||||||
}
|
}
|
||||||
)");
|
)");
|
||||||
|
|
||||||
m_controller = new EinsatzplanFrameController(id, admin);
|
|
||||||
|
|
||||||
m_profileImg = new QLabel(this);
|
m_profileImg = new QLabel(this);
|
||||||
m_profileImg->setFixedSize(60, 60);
|
m_profileImg->setFixedSize(60, 60);
|
||||||
m_profileImg->setPixmap(QPixmap(":account-box.png"));
|
m_profileImg->setPixmap(QPixmap(":account-box.png"));
|
||||||
m_profileImg->setObjectName("profileImg");
|
m_profileImg->setObjectName("profileImg");
|
||||||
m_profileImg->setStyleSheet(R"(
|
|
||||||
#profileImg{
|
|
||||||
|
|
||||||
}
|
|
||||||
)");
|
|
||||||
m_profileImg->show( );
|
m_profileImg->show( );
|
||||||
|
|
||||||
m_id = new QLabel(id, this);
|
m_id = new QLabel(id, this);
|
||||||
@@ -39,6 +32,7 @@ EinsatzplanFrame::EinsatzplanFrame(QWidget* parent, QString id, bool admin)
|
|||||||
m_abmeldenButton = new QPushButton("Abmelden", this);
|
m_abmeldenButton = new QPushButton("Abmelden", this);
|
||||||
m_abmeldenButton->setFixedSize(150, 50);
|
m_abmeldenButton->setFixedSize(150, 50);
|
||||||
m_abmeldenButton->setObjectName("abmeldenButton");
|
m_abmeldenButton->setObjectName("abmeldenButton");
|
||||||
|
m_abmeldenButton->setCursor(Qt::PointingHandCursor);
|
||||||
m_abmeldenButton->setStyleSheet(R"(
|
m_abmeldenButton->setStyleSheet(R"(
|
||||||
#abmeldenButton{
|
#abmeldenButton{
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
@@ -72,6 +66,8 @@ EinsatzplanFrame::EinsatzplanFrame(QWidget* parent, QString id, bool admin)
|
|||||||
m_planGrid = new PlanGrid(this);
|
m_planGrid = new PlanGrid(this);
|
||||||
m_planGrid->show( );
|
m_planGrid->show( );
|
||||||
|
|
||||||
|
m_controller = new EinsatzplanFrameController(id, admin);
|
||||||
|
|
||||||
QVBoxLayout* totalLayout = new QVBoxLayout(this);
|
QVBoxLayout* totalLayout = new QVBoxLayout(this);
|
||||||
totalLayout->setContentsMargins(30, 20, 30, 20);
|
totalLayout->setContentsMargins(30, 20, 30, 20);
|
||||||
|
|
||||||
@@ -94,6 +90,7 @@ EinsatzplanFrame::EinsatzplanFrame(QWidget* parent, QString id, bool admin)
|
|||||||
m_createMemberButton = new QPushButton("Mitarbeiter\nHinzufügen", this);
|
m_createMemberButton = new QPushButton("Mitarbeiter\nHinzufügen", this);
|
||||||
m_createMemberButton->setFixedSize(200, 50);
|
m_createMemberButton->setFixedSize(200, 50);
|
||||||
m_createMemberButton->setObjectName("createMember");
|
m_createMemberButton->setObjectName("createMember");
|
||||||
|
m_createMemberButton->setCursor(Qt::PointingHandCursor);
|
||||||
m_createMemberButton->setStyleSheet(R"(
|
m_createMemberButton->setStyleSheet(R"(
|
||||||
#createMember{
|
#createMember{
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
@@ -114,6 +111,7 @@ EinsatzplanFrame::EinsatzplanFrame(QWidget* parent, QString id, bool admin)
|
|||||||
m_deleteMemberButton = new QPushButton("Mitarbeiter\nEntfernen", this);
|
m_deleteMemberButton = new QPushButton("Mitarbeiter\nEntfernen", this);
|
||||||
m_deleteMemberButton->setFixedSize(200, 50);
|
m_deleteMemberButton->setFixedSize(200, 50);
|
||||||
m_deleteMemberButton->setObjectName("deleteMember");
|
m_deleteMemberButton->setObjectName("deleteMember");
|
||||||
|
m_deleteMemberButton->setCursor(Qt::PointingHandCursor);
|
||||||
m_deleteMemberButton->setStyleSheet(R"(
|
m_deleteMemberButton->setStyleSheet(R"(
|
||||||
#deleteMember{
|
#deleteMember{
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
@@ -134,6 +132,7 @@ EinsatzplanFrame::EinsatzplanFrame(QWidget* parent, QString id, bool admin)
|
|||||||
m_createVeranstaltungButton = new QPushButton("Veranstaltung\nHinzufügen", this);
|
m_createVeranstaltungButton = new QPushButton("Veranstaltung\nHinzufügen", this);
|
||||||
m_createVeranstaltungButton->setFixedSize(200, 50);
|
m_createVeranstaltungButton->setFixedSize(200, 50);
|
||||||
m_createVeranstaltungButton->setObjectName("createVeranstaltung");
|
m_createVeranstaltungButton->setObjectName("createVeranstaltung");
|
||||||
|
m_createVeranstaltungButton->setCursor(Qt::PointingHandCursor);
|
||||||
m_createVeranstaltungButton->setStyleSheet(R"(
|
m_createVeranstaltungButton->setStyleSheet(R"(
|
||||||
#createVeranstaltung{
|
#createVeranstaltung{
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
@@ -154,6 +153,7 @@ EinsatzplanFrame::EinsatzplanFrame(QWidget* parent, QString id, bool admin)
|
|||||||
m_deleteVeranstaltungButton = new QPushButton("Veranstaltung\nEntfernen", this);
|
m_deleteVeranstaltungButton = new QPushButton("Veranstaltung\nEntfernen", this);
|
||||||
m_deleteVeranstaltungButton->setFixedSize(200, 50);
|
m_deleteVeranstaltungButton->setFixedSize(200, 50);
|
||||||
m_deleteVeranstaltungButton->setObjectName("deleteVeranstaltung");
|
m_deleteVeranstaltungButton->setObjectName("deleteVeranstaltung");
|
||||||
|
m_deleteVeranstaltungButton->setCursor(Qt::PointingHandCursor);
|
||||||
m_deleteVeranstaltungButton->setStyleSheet(R"(
|
m_deleteVeranstaltungButton->setStyleSheet(R"(
|
||||||
#deleteVeranstaltung{
|
#deleteVeranstaltung{
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
@@ -182,7 +182,11 @@ EinsatzplanFrame::EinsatzplanFrame(QWidget* parent, QString id, bool admin)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EinsatzplanFrame::abmelden( ) {
|
void EinsatzplanFrame::abmelden( ) {
|
||||||
static_cast<QApplication*>(parent( )->parent( ))->exit( );
|
QString program = QApplication::applicationFilePath( );
|
||||||
|
|
||||||
|
QProcess::startDetached(program);
|
||||||
|
|
||||||
|
QApplication::quit( );
|
||||||
}
|
}
|
||||||
|
|
||||||
void EinsatzplanFrame::deleteVeranstaltung( ) {
|
void EinsatzplanFrame::deleteVeranstaltung( ) {
|
||||||
@@ -193,6 +197,9 @@ void EinsatzplanFrame::deleteVeranstaltung( ) {
|
|||||||
if (ok && text.size( ) == 3) {
|
if (ok && text.size( ) == 3) {
|
||||||
m_controller->deleteVeranstaltung(text);
|
m_controller->deleteVeranstaltung(text);
|
||||||
QMessageBox::information(this, "Veranstaltung entfernen", "Veranstaltung wird entfernt!");
|
QMessageBox::information(this, "Veranstaltung entfernen", "Veranstaltung wird entfernt!");
|
||||||
|
|
||||||
|
m_planGrid->setPlanMap(m_planGrid->planGridController->getVeranstaltungen( ));
|
||||||
|
m_planGrid->populateGrid( );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
#include "../PlanGrid/PlanGrid.hpp"
|
#include "../PlanGrid/PlanGrid.hpp"
|
||||||
#include "../../Controller/EinsatzplanFrameController/EinsatzplanFrameController.hpp"
|
#include "../../Controller/EinsatzplanFrameController/EinsatzplanFrameController.hpp"
|
||||||
@@ -38,7 +39,6 @@ public:
|
|||||||
EinsatzplanFrame(QWidget* parent = nullptr, QString id = "0000000", bool admin = true);
|
EinsatzplanFrame(QWidget* parent = nullptr, QString id = "0000000", bool admin = true);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void abmelden( );
|
void abmelden( );
|
||||||
void deleteVeranstaltung( );
|
void deleteVeranstaltung( );
|
||||||
void createVeranstaltung( );
|
void createVeranstaltung( );
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ PlanGrid::PlanGrid(QWidget* parent)
|
|||||||
m_times[2] = "12:00";
|
m_times[2] = "12:00";
|
||||||
m_times[3] = "14:00";
|
m_times[3] = "14:00";
|
||||||
m_times[4] = "16:00";
|
m_times[4] = "16:00";
|
||||||
|
m_times[5] = "18:00";
|
||||||
|
|
||||||
planMap = new QMap<QPair<QString, QString>, QWidget*>( );
|
planMap = new QMap<QPair<QString, QString>, QWidget*>( );
|
||||||
|
|
||||||
@@ -67,7 +68,7 @@ PlanGrid::PlanGrid(QWidget* parent)
|
|||||||
|
|
||||||
// Add times left to plan
|
// Add times left to plan
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
QLabel* temp = new QLabel(m_times[i]);
|
QLabel* temp = new QLabel(QString::fromStdString(m_times[i].toStdString( ) + " - " + m_times[i + 1].toStdString( )));
|
||||||
temp->setFixedSize(130, 100);
|
temp->setFixedSize(130, 100);
|
||||||
temp->setObjectName("temp");
|
temp->setObjectName("temp");
|
||||||
if (i == 4) {
|
if (i == 4) {
|
||||||
@@ -102,7 +103,25 @@ PlanGrid::PlanGrid(QWidget* parent)
|
|||||||
void PlanGrid::populateGrid( ) {
|
void PlanGrid::populateGrid( ) {
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
for (int j = 0; j < 5; ++j) {
|
for (int j = 0; j < 5; ++j) {
|
||||||
gridLayout->addWidget(planMap->value(qMakePair(m_weekdays[i], m_times[j])), j + 1, i + 1);
|
auto widget = planMap->value(qMakePair(m_weekdays[i], m_times[j]));
|
||||||
|
gridLayout->addWidget(widget, j + 1, i + 1);
|
||||||
|
auto pb = widget->findChild<QPushButton*>("eintragung");
|
||||||
|
if (pb != nullptr) {
|
||||||
|
connect(pb, &QPushButton::clicked, this, [this, pb, i, j]( ) {
|
||||||
|
auto name = pb->property("MitarbeiterName").toString( );
|
||||||
|
Krankmelden dialog(name, this);
|
||||||
|
if (dialog.exec( ) == QDialog::Accepted) {
|
||||||
|
auto id = pb->property("MitarbeiterID").toInt( );
|
||||||
|
planGridController->Krankmelden(
|
||||||
|
id,
|
||||||
|
i + 1,
|
||||||
|
j + 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
planMap = planGridController->getVeranstaltungen( );
|
||||||
|
populateGrid( );
|
||||||
|
});
|
||||||
|
}
|
||||||
if (i == 4 && j == 4) {
|
if (i == 4 && j == 4) {
|
||||||
(planMap->value(qMakePair(m_weekdays[i], m_times[j])))->setStyleSheet(R"(
|
(planMap->value(qMakePair(m_weekdays[i], m_times[j])))->setStyleSheet(R"(
|
||||||
border-bottom-right-radius:10px;
|
border-bottom-right-radius:10px;
|
||||||
|
|||||||
@@ -6,21 +6,30 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
#include "../../Controller/PlanGridController/PlanGridController.hpp"
|
#include "../../Controller/PlanGridController/PlanGridController.hpp"
|
||||||
#include "../Widgets/GridItem.hpp"
|
#include "../EinsatzplanFrame/Dialogs/Krankmelden/Krankmelden.hpp"
|
||||||
|
#include "../EinsatzplanFrame/Dialogs/CreateMember/CreateMember.hpp"
|
||||||
|
|
||||||
class PlanGrid : public QWidget {
|
class PlanGrid : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
QString m_weekdays[5];
|
QString m_weekdays[5];
|
||||||
QString m_times[5];
|
QString m_times[6];
|
||||||
|
|
||||||
void populateGrid( );
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QGridLayout* gridLayout;
|
QGridLayout* gridLayout;
|
||||||
QMap<QPair<QString, QString>, QWidget*>* planMap;
|
QMap<QPair<QString, QString>, QWidget*>* planMap;
|
||||||
PlanGridController* planGridController;
|
|
||||||
|
void KrankmeldenDialog( );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PlanGrid(QWidget* parent = nullptr);
|
PlanGrid(QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
PlanGridController* planGridController;
|
||||||
|
|
||||||
|
void populateGrid( );
|
||||||
|
|
||||||
|
inline void setPlanMap(QMap<QPair<QString, QString>, QWidget*>* planMap) {
|
||||||
|
this->planMap = planMap;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
# include "GridItem.hpp"
|
|
||||||
|
|
||||||
GridItem::GridItem(QString text, QWidget* parent)
|
|
||||||
:QLabel(parent) {
|
|
||||||
//Fix later
|
|
||||||
//text_m = new QLabel(text,this);
|
|
||||||
//text_m->setAlignment(Qt::AlignCenter);
|
|
||||||
setText(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GridItem::mousePressEvent(QMouseEvent* event) {
|
|
||||||
if (event->button( ) == Qt::RightButton)
|
|
||||||
emit clicked( );
|
|
||||||
QWidget::mousePressEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GridItem::paintEvent(QPaintEvent* event) {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
# pragma once
|
|
||||||
# include <QLabel>
|
|
||||||
# include <QMouseEvent>
|
|
||||||
# include <QPainter>
|
|
||||||
|
|
||||||
class GridItem : public QLabel {
|
|
||||||
Q_OBJECT
|
|
||||||
protected:
|
|
||||||
//QLabel* text_m;
|
|
||||||
|
|
||||||
void mousePressEvent(QMouseEvent* event) override;
|
|
||||||
void paintEvent(QPaintEvent* event) override;
|
|
||||||
public:
|
|
||||||
GridItem(QString text = "", QWidget* parent = nullptr);
|
|
||||||
signals:
|
|
||||||
void clicked( );
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user