fix styling, refactor some variables, simplified some code
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -55,4 +55,4 @@ compile_commands.json
|
||||
|
||||
build
|
||||
debug
|
||||
build/CMakeFiles
|
||||
config.cfg
|
||||
|
||||
@@ -28,5 +28,6 @@ target_link_libraries(EinsatzplanQT PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Sql
|
||||
fmt
|
||||
pqxx
|
||||
stdc++fs
|
||||
)
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 472 B After Width: | Height: | Size: 4.8 KiB |
@@ -1,51 +1,36 @@
|
||||
# include "EinsatzplanFrameController.hpp"
|
||||
# include "../../Core/DBHandler/DBPlan.hpp"
|
||||
|
||||
EinsatzplanFrameController::EinsatzplanFrameController(QString id, bool admin)
|
||||
:id_m(id),admin_m(admin)
|
||||
{
|
||||
:m_id(id),
|
||||
m_admin(admin) {
|
||||
const std::map<std::string, std::string> config = load_config("../config.cfg");
|
||||
|
||||
m_connectionString = fmt::format(
|
||||
"host={} port={} dbname={} user={} password={}",
|
||||
config.at("DB_HOST"),
|
||||
config.at("DB_PORT"),
|
||||
config.at("DB_NAME"),
|
||||
config.at("DB_USER"),
|
||||
config.at("DB_PASSWORD")
|
||||
);
|
||||
}
|
||||
|
||||
void EinsatzplanFrameController::deleteMember(QString id) {
|
||||
DBPlan* db = new DBPlan();
|
||||
DBPlan* db = new DBPlan(m_connectionString);
|
||||
db->deleteVeranstalter(id.toStdString( ));
|
||||
|
||||
/*
|
||||
DatabaseHandler db = new DatabaseHandler();
|
||||
db.executeQuery("DELETE FROM ...")
|
||||
*/
|
||||
}
|
||||
|
||||
void EinsatzplanFrameController::deleteVeranstaltung(QString veranstaltungsname) {
|
||||
DBPlan* db = new DBPlan();
|
||||
DBPlan* db = new DBPlan(m_connectionString);
|
||||
db->deleteVeranstaltung(veranstaltungsname.toStdString( ));
|
||||
/*
|
||||
DatabaseHandler db = new DatabaseHandler();
|
||||
db.executeQuery()
|
||||
*/
|
||||
}
|
||||
|
||||
void EinsatzplanFrameController::createMember(QString name, QString email, QString passwort, bool admin) {
|
||||
DBPlan* db = new DBPlan();
|
||||
std::string temp;
|
||||
if (admin)
|
||||
temp = "TRUE";
|
||||
else
|
||||
temp = "FALSE";
|
||||
db->hinzufuegenVeranstalter(email.toStdString(),name.toStdString(),passwort.toStdString(),temp);
|
||||
/*
|
||||
DatabaseHandler db = new DatabaseHandler();
|
||||
db.executeQuery()
|
||||
*/
|
||||
DBPlan* db = new DBPlan(m_connectionString);
|
||||
db->hinzufuegenVeranstalter(email.toStdString( ), name.toStdString( ), passwort.toStdString( ), admin ? "TRUE" : "FALSE");
|
||||
}
|
||||
|
||||
void EinsatzplanFrameController::createVeranstaltung(QString name, QString raum, QString campus, QString time) {
|
||||
DBPlan* db = new DBPlan();
|
||||
DBPlan* db = new DBPlan(m_connectionString);
|
||||
db->hinzufuegenVeranstaltung(name.toStdString( ), time.toStdString( ), campus.toStdString( ), raum.toStdString( ));
|
||||
|
||||
/*
|
||||
DatabaseHandler db = new DatabaseHandler();
|
||||
db.executeQuery()
|
||||
*/
|
||||
}
|
||||
@@ -1,10 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "../../Core/DBHandler/DBPlan/DBPlan.hpp"
|
||||
#include "../../Core/config/config.hpp"
|
||||
|
||||
class EinsatzplanFrameController {
|
||||
private:
|
||||
std::string m_connectionString;
|
||||
|
||||
protected:
|
||||
QString id_m;
|
||||
bool admin_m;
|
||||
QString m_id;
|
||||
bool m_admin;
|
||||
|
||||
public:
|
||||
EinsatzplanFrameController(QString id = "0000000", bool admin = true);
|
||||
void deleteMember(QString id);
|
||||
|
||||
@@ -14,10 +14,21 @@ PlanGridController::PlanGridController(){
|
||||
times[4] = "16:00 - 18:00";
|
||||
|
||||
planMap = new QMap<QPair<QString, QString>, QLabel*>( );
|
||||
|
||||
const std::map<std::string, std::string> config = load_config("../config.cfg");
|
||||
|
||||
m_connectionString = fmt::format(
|
||||
"host={} port={} dbname={} user={} password={}",
|
||||
config.at("DB_HOST"),
|
||||
config.at("DB_PORT"),
|
||||
config.at("DB_NAME"),
|
||||
config.at("DB_USER"),
|
||||
config.at("DB_PASSWORD")
|
||||
);
|
||||
}
|
||||
|
||||
QMap<QPair<QString, QString>, QLabel*>* PlanGridController::getVeranstaltungen( ) {
|
||||
DBPlan* db = new DBPlan();
|
||||
DBPlan* db = new DBPlan(m_connectionString);
|
||||
|
||||
// stringFormat = tag , anfangszeit , Ort , Veranstaltung , Mitarbeiter , mitarbeiterID
|
||||
std::vector<std::string> planData = db->getPlan( );
|
||||
@@ -56,7 +67,4 @@ QMap<QPair<QString, QString>, QLabel*>* PlanGridController::getVeranstaltungen()
|
||||
}
|
||||
|
||||
return planMap;
|
||||
|
||||
//DatabaseHandler db = new DatabaseHandler();
|
||||
//db.ex
|
||||
}
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <QLabel>
|
||||
# include <iostream>
|
||||
#include <sstream>
|
||||
# include "../../Core/DBHandler/DBPlan.hpp"
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "../../Core/config/config.hpp"
|
||||
#include "../../Core/DBHandler/DBPlan/DBPlan.hpp"
|
||||
|
||||
class PlanGridController {
|
||||
private:
|
||||
std::string m_connectionString;
|
||||
|
||||
protected:
|
||||
QString weekdays[5];
|
||||
QString times[5];
|
||||
QMap<QPair<QString, QString>, QLabel*>* planMap;
|
||||
|
||||
public:
|
||||
PlanGridController( );
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#include "DBHandler.hpp"
|
||||
|
||||
#include <iostream>
|
||||
//"host = localhost port = 5432 dbname = postgres user = postgres password = AlbertBridge1?"
|
||||
|
||||
|
||||
DBHandler::DBHandler(std::string connStr) : connectionObject(connStr.c_str()) {
|
||||
try {
|
||||
if (connectionObject.is_open()) {
|
||||
std::cout << "Databased connected" << std::endl;
|
||||
}
|
||||
else
|
||||
std::cout << "Failed to connect to Databased" << std::endl;
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
14
src/Core/DBHandler/DBHandler/DBHandler.cpp
Normal file
14
src/Core/DBHandler/DBHandler/DBHandler.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "DBHandler.hpp"
|
||||
|
||||
DBHandler::DBHandler(std::string connStr) :
|
||||
connectionObject(connStr.c_str( )) {
|
||||
try {
|
||||
if (connectionObject.is_open( ))
|
||||
fmt::print("Databased connected");
|
||||
else
|
||||
fmt::print("Failed to connect to Databased");
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
};
|
||||
@@ -1,7 +1,8 @@
|
||||
#ifndef DBHANDLER_HPP_
|
||||
#define DBHANDLER_HPP_
|
||||
#pragma onc
|
||||
|
||||
#include <pqxx/pqxx>
|
||||
#include <string>
|
||||
#include <fmt/core.h>
|
||||
|
||||
class DBHandler {
|
||||
protected:
|
||||
@@ -10,5 +11,3 @@ protected:
|
||||
public:
|
||||
DBHandler(std::string connStr);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,40 +0,0 @@
|
||||
#include "DBLogin.hpp"
|
||||
#include <iostream>
|
||||
|
||||
DBLogin::DBLogin(std::string connStr) : DBHandler(connStr) {};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
return 1 if admin | 0 if not admin | -1 if failed
|
||||
|
||||
*/
|
||||
|
||||
int DBLogin::checkValidLogin(std::string id, std::string pw) {
|
||||
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
std::string query =
|
||||
"SELECT admin FROM studenten_veranstalter WHERE id = $1 AND passwort = $2";
|
||||
|
||||
pqxx::result response = worker.exec_params(query, id, pw);
|
||||
|
||||
if (response.affected_rows() > 0) {
|
||||
|
||||
|
||||
if (response[0][0].is_null())
|
||||
return 0;
|
||||
return response[0][0].as<bool>();
|
||||
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef _DBLOGIN_HPP_
|
||||
#define _DBLOGIN_HPP_
|
||||
#include "DBHandler.hpp"
|
||||
|
||||
class DBLogin : public DBHandler {
|
||||
public:
|
||||
DBLogin(std::string connStr);
|
||||
/*
|
||||
|
||||
return 1 if admin | 0 if not admin | -1 if failed
|
||||
|
||||
*/
|
||||
int checkValidLogin(std::string id, std::string pw);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
26
src/Core/DBHandler/DBLogin/DBLogin.cpp
Normal file
26
src/Core/DBHandler/DBLogin/DBLogin.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "DBLogin.hpp"
|
||||
|
||||
DBLogin::DBLogin(std::string connStr) : DBHandler(connStr) { };
|
||||
|
||||
int DBLogin::checkValidLogin(std::string id, std::string pw) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
std::string query =
|
||||
"SELECT admin FROM studenten_veranstalter WHERE id = $1 AND passwort = $2";
|
||||
|
||||
pqxx::result response = worker.exec_params(query, id, pw);
|
||||
|
||||
if (response.affected_rows( ) > 0) {
|
||||
if (response[0][0].is_null( ))
|
||||
return 0;
|
||||
return response[0][0].as<bool>( );
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::printf("ERROR: %s", e.what( ));
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
18
src/Core/DBHandler/DBLogin/DBLogin.hpp
Normal file
18
src/Core/DBHandler/DBLogin/DBLogin.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <fmt/printf.h>
|
||||
|
||||
#include "../DBHandler/DBHandler.hpp"
|
||||
|
||||
class DBLogin : public DBHandler {
|
||||
public:
|
||||
DBLogin(std::string connStr);
|
||||
|
||||
/**
|
||||
* @brief Tries to login the user
|
||||
* @param id user id
|
||||
* @param pw user password
|
||||
* @return returns 1 if admin and 0 if not
|
||||
*/
|
||||
int checkValidLogin(std::string id, std::string pw);
|
||||
};
|
||||
@@ -1,483 +0,0 @@
|
||||
#include "DBPlan.hpp"
|
||||
|
||||
DBPlan::DBPlan(std::string connStr) : DBHandler(connStr) {
|
||||
};
|
||||
|
||||
|
||||
void DBPlan::vertretung(std::string tag, std::string stunde, std::string dauer) {
|
||||
try {
|
||||
std::string prevStunde = std::to_string(std::stoi(stunde) - 1);
|
||||
std::string cap = std::to_string(18 - std::stoi(dauer));
|
||||
std::string nextStunde;
|
||||
std::string nextTag = tag;
|
||||
std::string prevTag = tag;
|
||||
if (dauer == "4") {
|
||||
|
||||
nextStunde = std::to_string(std::stoi(stunde) + 2);
|
||||
std::cout << nextStunde << std::endl;
|
||||
}
|
||||
else {
|
||||
nextStunde = std::to_string(std::stoi(stunde) + 1);
|
||||
std::cout << nextStunde << std::endl;
|
||||
}
|
||||
|
||||
if (prevStunde == "0") {
|
||||
prevStunde = "5";
|
||||
prevTag = std::to_string(std::stoi(tag) - 1);
|
||||
if (prevTag == "0") {
|
||||
prevTag = "5";
|
||||
}
|
||||
}
|
||||
|
||||
if (nextStunde == "6") {
|
||||
nextStunde = "1";
|
||||
nextTag = std::to_string(std::stoi(tag)+1);
|
||||
if (nextTag == "6") {
|
||||
nextTag = "1";
|
||||
}
|
||||
}
|
||||
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
|
||||
std::string query =
|
||||
"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) "
|
||||
"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);
|
||||
|
||||
worker.commit();
|
||||
|
||||
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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") {
|
||||
upperHour(tag, stunde);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void DBPlan::meldeKrank(std::string id, std::string tag, std::string stunde) {
|
||||
|
||||
try {
|
||||
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
"UPDATE Veranstalter SET krank = TRUE WHERE ID = $1";
|
||||
|
||||
pqxx::result response = worker.exec_params(query, id);
|
||||
worker.commit();
|
||||
|
||||
sucheVertretung(tag, stunde);
|
||||
meldeGesund(id);
|
||||
versendeEmails();
|
||||
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DBPlan::meldeGesund(std::string id) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
"UPDATE Veranstalter SET krank = FALSE WHERE ID = $1";
|
||||
|
||||
pqxx::result response = worker.exec_params(query, id);
|
||||
worker.commit();
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void DBPlan::deleteVeranstalterForeign(std::string id) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
"UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstalter_ID = NULL WHERE Veranstalter_ID = $1;";
|
||||
|
||||
pqxx::result response = worker.exec_params(query, id);
|
||||
worker.commit();
|
||||
versendeEmails();
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::deleteVeranstalter(std::string id) {
|
||||
|
||||
deleteVeranstalterForeign(id);
|
||||
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
"DELETE FROM Veranstalter WHERE ID = $1";
|
||||
|
||||
pqxx::result response = worker.exec_params(query, id);
|
||||
worker.commit();
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DBPlan::deleteVeranstaltungForeign(std::string id) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
"UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstaltung_ID = NULL WHERE Veranstalter_ID = $1;";
|
||||
|
||||
pqxx::result response = worker.exec_params(query, id);
|
||||
worker.commit();
|
||||
versendeEmails();
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::deleteVeranstaltung(std::string id) {
|
||||
deleteVeranstaltungForeign(id);
|
||||
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
"DELETE FROM Veranstaltung WHERE ID = $1";
|
||||
|
||||
pqxx::result response = worker.exec_params(query, id);
|
||||
worker.commit();
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DBPlan::hinzufuegenVeranstaltung(std::string name, std::string dauer, std::string ort, std::string raum) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
"INSERT INTO Veranstaltung (name, dauer, ort, raum) VALUES ($1, $2, $3, $4);";
|
||||
pqxx::result response = worker.exec_params(query, name, dauer, ort, raum);
|
||||
worker.commit();
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DBPlan::hinzufuegenVeranstalter(std::string email, std::string name, std::string pw, std::string admin) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
"INSERT INTO Veranstaltung (email, name, pw, admin) VALUES ($1, $2, $3, $4);";
|
||||
pqxx::result response = worker.exec_params(query, email, name, pw, admin);
|
||||
worker.commit();
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DBPlan::deleteStudent(std::string id) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
"DELETE FROM studenten WHERE ID = $1;";
|
||||
pqxx::result response = worker.exec_params(query, id);
|
||||
worker.commit();
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DBPlan::hinzufuegenStudent(std::string email, std::string name, std::string pw) {
|
||||
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
"INSERT INTO studenten (email, name, pw) VALUES ($1, $2, $3);";
|
||||
pqxx::result response = worker.exec_params(query, email, name, pw);
|
||||
worker.commit();
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string DBPlan::getDauer(std::string tag, std::string stunde) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
"SELECT dauer FROM Veranstaltung WHERE ID = (SELECT Veranstaltung_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2);";
|
||||
|
||||
pqxx::result response = worker.exec_params(query, stunde, tag);
|
||||
|
||||
worker.commit();
|
||||
|
||||
|
||||
return response[0][0].c_str();
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DBPlan::addFirstOfDayTwo(std::string tag) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
"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;";
|
||||
pqxx::result response = worker.exec_params(query, tag);
|
||||
worker.commit();
|
||||
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::addTwoHour(std::string tag, std::string stunde) {
|
||||
try {
|
||||
|
||||
std::string prevStunde = std::to_string(std::stoi(stunde) - 1);
|
||||
|
||||
std::cout << " prevStunde: " << prevStunde << " Tag: " << tag << " stunde " << stunde << std::endl;
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
"UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstalter_id = (SELECT ID FROM Veranstalter "
|
||||
"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 ID != (SELECT veranstalter_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2)) "
|
||||
"ORDER BY random() LIMIT 1) "
|
||||
"WHERE uhrzeit_id = $3 AND tag = $4;";
|
||||
pqxx::result response = worker.exec_params(query, prevStunde, tag, stunde, tag);
|
||||
worker.commit();
|
||||
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::addFirstOfDayFour(std::string tag) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
"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;";
|
||||
pqxx::result response = worker.exec_params(query, tag);
|
||||
worker.commit();
|
||||
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::addFourHour(std::string tag, std::string stunde) {
|
||||
try {
|
||||
|
||||
std::string prevStunde = std::to_string(std::stoi(stunde) - 1);
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
"UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstalter_id = (SELECT ID FROM Veranstalter "
|
||||
"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 ID != (SELECT veranstalter_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2)) "
|
||||
"ORDER BY random() LIMIT 1) "
|
||||
"WHERE uhrzeit_id = $3 AND tag = $4;";
|
||||
pqxx::result response = worker.exec_params(query, prevStunde, tag, stunde, tag);
|
||||
worker.commit();
|
||||
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::upperHour(std::string tag, std::string stunde) {
|
||||
try {
|
||||
|
||||
std::string nextStunde = std::to_string(std::stoi(stunde) + 1);
|
||||
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
"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;";
|
||||
pqxx::result response = worker.exec_params(query, stunde, tag, nextStunde);
|
||||
worker.commit();
|
||||
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DBPlan::updateStandort(std::string tag, std::string stunde) {
|
||||
try {
|
||||
|
||||
|
||||
pqxx::work worker(connectionObject);
|
||||
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);";
|
||||
pqxx::result response = worker.exec_params(query, stunde, tag);
|
||||
worker.commit();
|
||||
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::incarbeitszeit(std::string tag, std::string stunde, std::string amount) {
|
||||
try {
|
||||
|
||||
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
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);";
|
||||
|
||||
pqxx::result response = worker.exec_params(query,amount, stunde, tag);
|
||||
worker.commit();
|
||||
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::createPlan() {
|
||||
|
||||
|
||||
|
||||
try {
|
||||
for (int tag = 1; tag < 6; tag++) {
|
||||
std::string tagStr = std::to_string(tag);
|
||||
for (int stunde = 1; stunde < 6; stunde++) {
|
||||
std::string stundeStr = std::to_string(stunde);
|
||||
//get dauer of next class
|
||||
|
||||
if (std::stoi(getDauer(tagStr, stundeStr)) == 2) {
|
||||
if (stunde == 1) {
|
||||
addFirstOfDayTwo(tagStr);
|
||||
}
|
||||
else {
|
||||
addTwoHour(tagStr, stundeStr);
|
||||
}
|
||||
updateStandort(tagStr, stundeStr);
|
||||
incarbeitszeit(tagStr, stundeStr, "2");
|
||||
}
|
||||
else {
|
||||
if (stunde == 1) {
|
||||
addFirstOfDayFour(tagStr);
|
||||
|
||||
}
|
||||
else {
|
||||
addFourHour(tagStr, stundeStr);
|
||||
}
|
||||
upperHour(tagStr, stundeStr);
|
||||
incarbeitszeit(tagStr, stundeStr, "4");
|
||||
updateStandort(tagStr, stundeStr);
|
||||
stunde++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<std::string> DBPlan::getPlan() {
|
||||
try {
|
||||
|
||||
std::vector<std::string> plan;
|
||||
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
std::string query =
|
||||
"SELECT tag, u.anfangszeit, u.endzeit, o.ort, o.name, v.name, v.ID FROM Veranstalter_Veranstaltung_Uhrzeit LEFT JOIN Veranstalter v ON Veranstalter_Veranstaltung_Uhrzeit.veranstalter_ID = v.ID "
|
||||
"LEFT JOIN Uhrzeit u ON Veranstalter_Veranstaltung_Uhrzeit.uhrzeit_ID = u.ID "
|
||||
"LEFT JOIN Veranstaltung o ON Veranstalter_Veranstaltung_Uhrzeit.veranstaltung_ID = o.ID "
|
||||
"ORDER BY tag, uhrzeit_ID;";
|
||||
|
||||
pqxx::result response = worker.exec(query);
|
||||
worker.commit();
|
||||
|
||||
for (const auto& row : response) {
|
||||
std::string rowstring;
|
||||
for (const auto& col : row) {
|
||||
rowstring.append(col.c_str());
|
||||
rowstring.append(" , ");
|
||||
}
|
||||
plan.push_back(rowstring);
|
||||
|
||||
}
|
||||
|
||||
return plan;
|
||||
|
||||
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::versendeEmails() {
|
||||
std::cout << "Der Einsatzplan wurde geupdated" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
#ifndef _DBPLAN_HPP_
|
||||
#define _DBPLAN_HPP_
|
||||
|
||||
|
||||
#include "DBHandler.hpp"
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
class DBPlan : public DBHandler {
|
||||
private:
|
||||
//Functions needed for creation and updating of the plan
|
||||
std::string getDauer(std::string tag, std::string stunde);
|
||||
void addFirstOfDayTwo(std::string tag);
|
||||
void addTwoHour(std::string tag, std::string stunde);
|
||||
void addFirstOfDayFour(std::string tag);
|
||||
void upperHour(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, std::string dauer);
|
||||
void deleteVeranstalterForeign(std::string id);
|
||||
void deleteVeranstaltungForeign(std::string id);
|
||||
void updateStandort(std::string tag, std::string stunde);
|
||||
void incarbeitszeit(std::string tag, std::string stunde, std::string amount);
|
||||
void versendeEmails();
|
||||
public:
|
||||
DBPlan(std::string connStr);
|
||||
|
||||
//deletes prof from plan and searches new one
|
||||
void meldeKrank(std::string id, std::string tag, std::string stunde);
|
||||
//currently directly used after meldeKrank, so Mitarbeiter is only sick for specific hour
|
||||
void meldeGesund(std::string id);
|
||||
|
||||
//Deletes Veranstaltung from relation Veranstaltung and from Einsatzplan
|
||||
void deleteVeranstaltung(std::string id);
|
||||
//Adds Veranstaltung to relation Veranstaltung
|
||||
void hinzufuegenVeranstaltung(std::string name, std::string dauer, std::string ort, std::string raum);
|
||||
|
||||
//Deletes Veranstlater from relattion Veranstalter and from Einsatzplan
|
||||
void deleteVeranstalter(std::string id);
|
||||
//Add Veranstalter to relation Veranstalter
|
||||
void hinzufuegenVeranstalter(std::string email, std::string name, std::string pw, std::string admin);
|
||||
|
||||
|
||||
void deleteStudent(std::string id);
|
||||
void hinzufuegenStudent(std::string email, std::string name, std::string pw);
|
||||
|
||||
|
||||
void createPlan();
|
||||
|
||||
//Each string in form of (tag , anfangszeit , endzeit , Ort , Veranstaltung , Mitarbeiter , mitarbeiterID , )
|
||||
std::vector<std::string> getPlan();
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
376
src/Core/DBHandler/DBPlan/DBPlan.cpp
Normal file
376
src/Core/DBHandler/DBPlan/DBPlan.cpp
Normal file
@@ -0,0 +1,376 @@
|
||||
#include "DBPlan.hpp"
|
||||
|
||||
DBPlan::DBPlan(std::string connStr) : DBHandler(connStr) { };
|
||||
|
||||
void DBPlan::vertretung(std::string tag, std::string stunde, std::string dauer) {
|
||||
try {
|
||||
std::string prevStunde = std::to_string(std::stoi(stunde) - 1);
|
||||
std::string cap = std::to_string(18 - std::stoi(dauer));
|
||||
std::string nextStunde;
|
||||
std::string nextTag = tag;
|
||||
std::string prevTag = tag;
|
||||
if (dauer == "4")
|
||||
nextStunde = std::to_string(std::stoi(stunde) + 2);
|
||||
else
|
||||
nextStunde = std::to_string(std::stoi(stunde) + 1);
|
||||
fmt::print(nextStunde);
|
||||
|
||||
if (prevStunde == "0") {
|
||||
prevStunde = "5";
|
||||
prevTag = std::to_string(std::stoi(tag) - 1);
|
||||
if (prevTag == "0")
|
||||
prevTag = "5";
|
||||
}
|
||||
|
||||
if (nextStunde == "6") {
|
||||
nextStunde = "1";
|
||||
nextTag = std::to_string(std::stoi(tag) + 1);
|
||||
if (nextTag == "6")
|
||||
nextTag = "1";
|
||||
}
|
||||
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
std::string query = R"(
|
||||
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)
|
||||
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; )";
|
||||
|
||||
worker.exec_params(query, prevStunde, prevTag, nextStunde, nextTag, stunde, tag);
|
||||
worker.commit( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
}
|
||||
|
||||
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")
|
||||
upperHour(tag, stunde);
|
||||
}
|
||||
|
||||
void DBPlan::meldeKrank(std::string id, std::string tag, std::string stunde) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
worker.exec_params("UPDATE Veranstalter SET krank = TRUE WHERE ID = $1", id);
|
||||
worker.commit( );
|
||||
|
||||
sucheVertretung(tag, stunde);
|
||||
meldeGesund(id);
|
||||
versendeEmails( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::meldeGesund(std::string id) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
worker.exec_params("UPDATE Veranstalter SET krank = FALSE WHERE ID = $1", id);
|
||||
worker.commit( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::deleteVeranstalterForeign(std::string id) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
worker.exec_params("UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstalter_ID = NULL WHERE Veranstalter_ID = $1;", id);
|
||||
worker.commit( );
|
||||
versendeEmails( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::deleteVeranstalter(std::string id) {
|
||||
deleteVeranstalterForeign(id);
|
||||
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
worker.exec_params("DELETE FROM Veranstalter WHERE ID = $1", id);
|
||||
worker.commit( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::deleteVeranstaltungForeign(std::string id) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
worker.exec_params("UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstaltung_ID = NULL WHERE Veranstalter_ID = $1;", id);
|
||||
worker.commit( );
|
||||
versendeEmails( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::deleteVeranstaltung(std::string id) {
|
||||
deleteVeranstaltungForeign(id);
|
||||
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
worker.exec_params("DELETE FROM Veranstaltung WHERE ID = $1", id);
|
||||
worker.commit( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::hinzufuegenVeranstaltung(std::string name, std::string dauer, std::string ort, std::string raum) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
worker.exec_params("INSERT INTO Veranstaltung (name, dauer, ort, raum) VALUES ($1, $2, $3, $4);", name, dauer, ort, raum);
|
||||
worker.commit( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::hinzufuegenVeranstalter(std::string email, std::string name, std::string pw, std::string admin) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
worker.exec_params("INSERT INTO Veranstalter (email, name, passwort, admin) VALUES ($1, $2, $3, $4);", email, name, pw, admin);
|
||||
worker.commit( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::deleteStudent(std::string id) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
worker.exec_params("DELETE FROM studenten WHERE ID = $1;", id);
|
||||
worker.commit( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::hinzufuegenStudent(std::string email, std::string name, std::string pw) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
worker.exec_params("INSERT INTO studenten (email, name, pw) VALUES ($1, $2, $3);", email, name, pw);
|
||||
worker.commit( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
}
|
||||
|
||||
std::string DBPlan::getDauer(std::string tag, std::string stunde) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
pqxx::result response = worker.exec_params(
|
||||
"SELECT dauer FROM Veranstaltung WHERE ID = (SELECT Veranstaltung_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2);",
|
||||
stunde,
|
||||
tag
|
||||
);
|
||||
|
||||
worker.commit( );
|
||||
return response[0][0].c_str( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
|
||||
void DBPlan::addFirstOfDayTwo(std::string tag) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
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;)";
|
||||
worker.exec_params(query, tag);
|
||||
worker.commit( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::addTwoHour(std::string tag, std::string stunde) {
|
||||
try {
|
||||
std::string prevStunde = std::to_string(std::stoi(stunde) - 1);
|
||||
|
||||
fmt::printf("PrevStunde: %s\n Tag: %s\n Stunde: %s \n", prevStunde, tag, stunde);
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
R"(UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstalter_id = (SELECT ID FROM Veranstalter
|
||||
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 ID != (SELECT veranstalter_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2))
|
||||
ORDER BY random() LIMIT 1)
|
||||
WHERE uhrzeit_id = $3 AND tag = $4;)";
|
||||
worker.exec_params(query, prevStunde, tag, stunde, tag);
|
||||
worker.commit( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::addFirstOfDayFour(std::string tag) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
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;)";
|
||||
worker.exec_params(query, tag);
|
||||
worker.commit( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::addFourHour(std::string tag, std::string stunde) {
|
||||
try {
|
||||
std::string prevStunde = std::to_string(std::stoi(stunde) - 1);
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
R"(UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstalter_id = (SELECT ID FROM Veranstalter
|
||||
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 ID != (SELECT veranstalter_ID FROM Veranstalter_Veranstaltung_Uhrzeit WHERE uhrzeit_id = $1 AND tag = $2))
|
||||
ORDER BY random() LIMIT 1)
|
||||
WHERE uhrzeit_id = $3 AND tag = $4;)";
|
||||
worker.exec_params(query, prevStunde, tag, stunde, tag);
|
||||
worker.commit( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::upperHour(std::string tag, std::string stunde) {
|
||||
try {
|
||||
std::string nextStunde = std::to_string(std::stoi(stunde) + 1);
|
||||
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
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;)";
|
||||
worker.exec_params(query, stunde, tag, nextStunde);
|
||||
worker.commit( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::updateStandort(std::string tag, std::string stunde) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
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);";
|
||||
worker.exec_params(query, stunde, tag);
|
||||
worker.commit( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::incarbeitszeit(std::string tag, std::string stunde, std::string amount) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
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);";
|
||||
|
||||
worker.exec_params(query, amount, stunde, tag);
|
||||
worker.commit( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::createPlan( ) {
|
||||
try {
|
||||
for (int tag = 1; tag < 6; tag++) {
|
||||
std::string tagStr = std::to_string(tag);
|
||||
for (int stunde = 1; stunde < 6; stunde++) {
|
||||
std::string stundeStr = std::to_string(stunde);
|
||||
//get dauer of next class
|
||||
|
||||
if (std::stoi(getDauer(tagStr, stundeStr)) == 2) {
|
||||
stunde == 1 ? addFirstOfDayTwo(tagStr) : addTwoHour(tagStr, stundeStr);
|
||||
updateStandort(tagStr, stundeStr);
|
||||
incarbeitszeit(tagStr, stundeStr, "2");
|
||||
} else {
|
||||
stunde == 1 ? addFirstOfDayFour(tagStr) : addFourHour(tagStr, stundeStr);
|
||||
upperHour(tagStr, stundeStr);
|
||||
incarbeitszeit(tagStr, stundeStr, "4");
|
||||
updateStandort(tagStr, stundeStr);
|
||||
stunde++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> DBPlan::getPlan( ) {
|
||||
try {
|
||||
std::vector<std::string> plan;
|
||||
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
std::string query =
|
||||
R"(SELECT tag, u.anfangszeit, u.endzeit, o.ort, o.name, v.name, v.ID FROM Veranstalter_Veranstaltung_Uhrzeit LEFT JOIN Veranstalter v ON Veranstalter_Veranstaltung_Uhrzeit.veranstalter_ID = v.ID
|
||||
LEFT JOIN Uhrzeit u ON Veranstalter_Veranstaltung_Uhrzeit.uhrzeit_ID = u.ID
|
||||
LEFT JOIN Veranstaltung o ON Veranstalter_Veranstaltung_Uhrzeit.veranstaltung_ID = o.ID
|
||||
ORDER BY tag, uhrzeit_ID;)";
|
||||
|
||||
pqxx::result response = worker.exec(query);
|
||||
worker.commit( );
|
||||
|
||||
for (const auto& row : response) {
|
||||
std::string rowstring;
|
||||
for (const auto& col : row) {
|
||||
rowstring.append(col.c_str( ));
|
||||
rowstring.append(" , ");
|
||||
}
|
||||
plan.push_back(rowstring);
|
||||
}
|
||||
return plan;
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::print(e.what( ));
|
||||
}
|
||||
return std::vector<std::string>{ "" };
|
||||
}
|
||||
|
||||
void DBPlan::versendeEmails( ) {
|
||||
fmt::print("Der Einsatzplan wurde geändert");
|
||||
}
|
||||
107
src/Core/DBHandler/DBPlan/DBPlan.hpp
Normal file
107
src/Core/DBHandler/DBPlan/DBPlan.hpp
Normal file
@@ -0,0 +1,107 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <fmt/core.h>
|
||||
#include <fmt/printf.h>
|
||||
|
||||
#include "../DBHandler/DBHandler.hpp"
|
||||
|
||||
class DBPlan : public DBHandler {
|
||||
private:
|
||||
//Functions needed for creation and updating of the plan
|
||||
std::string getDauer(std::string tag, std::string stunde);
|
||||
void addFirstOfDayTwo(std::string tag);
|
||||
void addTwoHour(std::string tag, std::string stunde);
|
||||
void addFirstOfDayFour(std::string tag);
|
||||
void upperHour(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, std::string dauer);
|
||||
void deleteVeranstalterForeign(std::string id);
|
||||
void deleteVeranstaltungForeign(std::string id);
|
||||
void updateStandort(std::string tag, std::string stunde);
|
||||
void incarbeitszeit(std::string tag, std::string stunde, std::string amount);
|
||||
void versendeEmails( );
|
||||
|
||||
public:
|
||||
DBPlan(std::string connStr);
|
||||
|
||||
/**
|
||||
* @brief Deletes prof from plan and searches new one
|
||||
*
|
||||
* @param id
|
||||
* @param tag
|
||||
* @param stunde
|
||||
*/
|
||||
void meldeKrank(std::string id, std::string tag, std::string stunde);
|
||||
|
||||
/**
|
||||
* @brief Currently directly used after meldeKrank, so Mitarbeiter is only sick for specific hour
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void meldeGesund(std::string id);
|
||||
|
||||
/**
|
||||
* @brief Deletes Veranstaltung from relation Veranstaltung and from Einsatzplan
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void deleteVeranstaltung(std::string id);
|
||||
|
||||
/**
|
||||
* @brief Adds Veranstaltung to relation Veranstaltung
|
||||
*
|
||||
* @param name
|
||||
* @param dauer
|
||||
* @param ort
|
||||
* @param raum
|
||||
*/
|
||||
void hinzufuegenVeranstaltung(std::string name, std::string dauer, std::string ort, std::string raum);
|
||||
|
||||
/**
|
||||
* @brief Deletes Veranstlater from relattion Veranstalter and from Einsatzplan
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void deleteVeranstalter(std::string id);
|
||||
|
||||
/**
|
||||
* @brief Add Veranstalter to relation Veranstalter
|
||||
*
|
||||
* @param email
|
||||
* @param name
|
||||
* @param pw
|
||||
* @param admin
|
||||
*/
|
||||
void hinzufuegenVeranstalter(std::string email, std::string name, std::string pw, std::string admin);
|
||||
|
||||
/**
|
||||
* @brief Deletes a student from the database
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void deleteStudent(std::string id);
|
||||
|
||||
/**
|
||||
* @brief Adds a new student
|
||||
*
|
||||
* @param email
|
||||
* @param name
|
||||
* @param pw
|
||||
*/
|
||||
void hinzufuegenStudent(std::string email, std::string name, std::string pw);
|
||||
|
||||
/**
|
||||
* @brief Create a Plan object
|
||||
*
|
||||
*/
|
||||
void createPlan( );
|
||||
|
||||
/**
|
||||
* @brief Each string in form of (tag , anfangszeit , endzeit , Ort , Veranstaltung , Mitarbeiter , mitarbeiterID , )
|
||||
*
|
||||
* @return std::vector<std::string>
|
||||
*/
|
||||
std::vector<std::string> getPlan( );
|
||||
};
|
||||
32
src/Core/config/config.hpp
Normal file
32
src/Core/config/config.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
|
||||
inline static const std::map<std::string, std::string>& load_config(const std::string& filename) {
|
||||
static std::map<std::string, std::string> config;
|
||||
static bool is_loaded{ false };
|
||||
static std::string fn{ "" };
|
||||
|
||||
if (!is_loaded || fn != filename) {
|
||||
std::ifstream file(filename);
|
||||
std::string line;
|
||||
|
||||
while (std::getline(file, line)) {
|
||||
std::istringstream line_stream(line);
|
||||
std::string key;
|
||||
if (std::getline(line_stream, key, '=')) {
|
||||
std::string value;
|
||||
if (std::getline(line_stream, value)) {
|
||||
config[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is_loaded = true;
|
||||
fn = filename;
|
||||
}
|
||||
return config;
|
||||
}
|
||||
137
src/View/EinsatzplanFrame/Dialogs/CreateMember/CreateMember.cpp
Normal file
137
src/View/EinsatzplanFrame/Dialogs/CreateMember/CreateMember.cpp
Normal file
@@ -0,0 +1,137 @@
|
||||
#include "CreateMember.hpp"
|
||||
|
||||
CreateMemDialog::CreateMemDialog(QWidget* parent)
|
||||
:QDialog(parent) {
|
||||
setWindowTitle("Mitarbeiter Hinzufügen");
|
||||
setFixedSize(300, 400);
|
||||
setObjectName("CreateMemDialog");
|
||||
setStyleSheet(R"(
|
||||
#CreateMemDialog{
|
||||
background-color: #212121;
|
||||
border: none;
|
||||
}
|
||||
)");
|
||||
|
||||
m_name = new QLineEdit(this);
|
||||
m_name->setPlaceholderText("Name");
|
||||
m_name->setFixedSize(220, 40);
|
||||
m_name->setObjectName("name");
|
||||
m_name->setStyleSheet(R"(
|
||||
#name{
|
||||
color: #DADADA;
|
||||
font-size: 16px;
|
||||
background-color: #313131;
|
||||
border-radius: 10px;
|
||||
padding: 5px;
|
||||
border: 2px solid #414141;
|
||||
}
|
||||
)");
|
||||
m_name->show( );
|
||||
|
||||
|
||||
m_email = new QLineEdit(this);
|
||||
m_email->setPlaceholderText("Email");
|
||||
m_email->setFixedSize(220, 40);
|
||||
m_email->setObjectName("email");
|
||||
m_email->setStyleSheet(R"(
|
||||
#email{
|
||||
color: #DADADA;
|
||||
font-size: 16px;
|
||||
background-color: #313131;
|
||||
border-radius: 10px;
|
||||
padding: 5px;
|
||||
border: 2px solid #414141;
|
||||
}
|
||||
)");
|
||||
m_email->show( );
|
||||
|
||||
m_password = new QLineEdit(this);
|
||||
m_password->setPlaceholderText("Passwort");
|
||||
m_password->setEchoMode(QLineEdit::Password);
|
||||
m_password->setFixedSize(220, 40);
|
||||
m_password->setObjectName("password");
|
||||
m_password->setStyleSheet(R"(
|
||||
#password{
|
||||
color: #DADADA;
|
||||
font-size: 16px;
|
||||
background-color: #313131;
|
||||
border-radius: 10px;
|
||||
padding: 5px;
|
||||
border: 2px solid #414141;
|
||||
}
|
||||
)");
|
||||
m_password->show( );
|
||||
|
||||
m_admin = new QCheckBox("Admin", this);
|
||||
m_admin->setFixedSize(220, 40);
|
||||
m_admin->setObjectName("admin");
|
||||
m_admin->setStyleSheet(R"(
|
||||
#admin{
|
||||
color: #DADADA;
|
||||
font-size: 20px;
|
||||
border: none;
|
||||
}
|
||||
)");
|
||||
m_admin->show( );
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
|
||||
layout->setContentsMargins(30, 30, 30, 30);
|
||||
|
||||
layout->addWidget(m_name, 1, Qt::AlignCenter);
|
||||
layout->addWidget(m_email, 1, Qt::AlignCenter);
|
||||
layout->addWidget(m_password, 1, Qt::AlignCenter);
|
||||
layout->addWidget(m_admin, 1, Qt::AlignCenter);
|
||||
|
||||
QHBoxLayout* buttonLayout = new QHBoxLayout( );
|
||||
|
||||
m_okButton = new QPushButton("OK", this);
|
||||
m_okButton->setFixedSize(110, 40);
|
||||
m_okButton->setObjectName("okButton");
|
||||
m_okButton->setStyleSheet(R"(
|
||||
#okButton{
|
||||
color: #212121;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
background-color: #53EC87;
|
||||
border-radius: 10px;
|
||||
}
|
||||
)");
|
||||
|
||||
m_cancelButton = new QPushButton("Abbrechen", this);
|
||||
m_cancelButton->setFixedSize(110, 40);
|
||||
m_cancelButton->setObjectName("cancelButton");
|
||||
m_cancelButton->setStyleSheet(R"(
|
||||
#cancelButton{
|
||||
color: #212121;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
background-color: #FF5555;
|
||||
border-radius: 10px;
|
||||
}
|
||||
)");
|
||||
|
||||
buttonLayout->addWidget(m_okButton, 1, Qt::AlignCenter);
|
||||
buttonLayout->addWidget(m_cancelButton, 1, Qt::AlignCenter);
|
||||
|
||||
layout->addLayout(buttonLayout);
|
||||
|
||||
connect(m_okButton, &QPushButton::clicked, this, &QDialog::accept);
|
||||
connect(m_cancelButton, &QPushButton::clicked, this, &QDialog::reject);
|
||||
}
|
||||
|
||||
QString CreateMemDialog::getName( ) const {
|
||||
return m_name->text( );
|
||||
}
|
||||
|
||||
QString CreateMemDialog::getEmail( ) const {
|
||||
return m_email->text( );
|
||||
}
|
||||
|
||||
QString CreateMemDialog::getPassword( ) const {
|
||||
return m_password->text( );
|
||||
}
|
||||
|
||||
bool CreateMemDialog::isAdmin( ) const {
|
||||
return m_admin->isChecked( );
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QCheckBox>
|
||||
#include <QPushButton>
|
||||
#include <QLineEdit>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
class CreateMemDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
protected:
|
||||
QLineEdit* m_name;
|
||||
QLineEdit* m_email;
|
||||
QLineEdit* m_password;
|
||||
QCheckBox* m_admin;
|
||||
QPushButton* m_okButton;
|
||||
QPushButton* m_cancelButton;
|
||||
|
||||
public:
|
||||
CreateMemDialog(QWidget* parent = nullptr);
|
||||
|
||||
QString getName( ) const;
|
||||
QString getEmail( ) const;
|
||||
QString getPassword( ) const;
|
||||
bool isAdmin( ) const;
|
||||
};
|
||||
@@ -0,0 +1,141 @@
|
||||
#include "CreateVeranstaltung.hpp"
|
||||
|
||||
CreateVerDialog::CreateVerDialog(QWidget* parent)
|
||||
: QDialog(parent) {
|
||||
setWindowTitle("Veranstaltung Hinzufügen");
|
||||
setFixedSize(300, 400);
|
||||
setObjectName("createMemDialog");
|
||||
setStyleSheet(R"(
|
||||
#createMemDialog{
|
||||
background-color: #212121;
|
||||
border: none;
|
||||
}
|
||||
)");
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(30, 30, 30, 30);
|
||||
|
||||
m_name = new QLineEdit(this);
|
||||
m_name->setPlaceholderText("Veranstaltungskürzel");
|
||||
m_name->setFixedSize(220, 40);
|
||||
m_name->setObjectName("name");
|
||||
m_name->setStyleSheet(R"(
|
||||
#name{
|
||||
color: #DADADA;
|
||||
font-size: 16px;
|
||||
background-color: #313131;
|
||||
border-radius: 10px;
|
||||
padding: 5px;
|
||||
border: 2px solid #414141;
|
||||
}
|
||||
)");
|
||||
layout->addWidget(m_name, 1, Qt::AlignCenter);
|
||||
|
||||
m_raum = new QLineEdit(this);
|
||||
m_raum->setPlaceholderText("Raum");
|
||||
m_raum->setFixedSize(220, 40);
|
||||
m_raum->setObjectName("raum");
|
||||
m_raum->setStyleSheet(R"(
|
||||
#raum{
|
||||
color: #DADADA;
|
||||
font-size: 16px;
|
||||
background-color: #313131;
|
||||
border-radius: 10px;
|
||||
padding: 5px;
|
||||
border: 2px solid #414141;
|
||||
}
|
||||
)");
|
||||
layout->addWidget(m_raum, 1, Qt::AlignCenter);
|
||||
|
||||
m_campus = new QComboBox(this);
|
||||
m_campus->addItem("Campus A");
|
||||
m_campus->addItem("Campus B");
|
||||
m_campus->setFixedSize(220, 40);
|
||||
m_campus->setObjectName("campus");
|
||||
m_campus->setStyleSheet(R"(
|
||||
#campus{
|
||||
color: #DADADA;
|
||||
font-size: 16px;
|
||||
background-color: #313131;
|
||||
border-radius: 10px;
|
||||
padding: 5px;
|
||||
}
|
||||
#campus::Item{
|
||||
color: #DADADA;
|
||||
background-color: #313131;
|
||||
}
|
||||
)");
|
||||
layout->addWidget(m_campus, 1, Qt::AlignCenter);
|
||||
|
||||
m_time = new QComboBox(this);
|
||||
m_time->addItem("2h");
|
||||
m_time->addItem("4h");
|
||||
m_time->setFixedSize(220, 40);
|
||||
m_time->setObjectName("time");
|
||||
m_time->setStyleSheet(R"(
|
||||
#time{
|
||||
color: #DADADA;
|
||||
font-size: 16px;
|
||||
background-color: #313131;
|
||||
border-radius: 10px;
|
||||
padding: 5px;
|
||||
}
|
||||
#time::Item{
|
||||
color: #DADADA;
|
||||
background-color: #313131;
|
||||
}
|
||||
)");
|
||||
layout->addWidget(m_time, 1, Qt::AlignCenter);
|
||||
|
||||
QHBoxLayout* buttonLayout = new QHBoxLayout( );
|
||||
|
||||
m_okButton = new QPushButton("OK", this);
|
||||
m_okButton->setFixedSize(110, 40);
|
||||
m_okButton->setObjectName("okButton");
|
||||
m_okButton->setStyleSheet(R"(
|
||||
#okButton{
|
||||
color: #212121;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
background-color: #53EC87;
|
||||
border-radius: 10px;
|
||||
}
|
||||
)");
|
||||
|
||||
m_cancelButton = new QPushButton("Abbrechen", this);
|
||||
m_cancelButton->setFixedSize(110, 40);
|
||||
m_cancelButton->setObjectName("cancelButton");
|
||||
m_cancelButton->setStyleSheet(R"(
|
||||
#cancelButton{
|
||||
color: #212121;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
background-color: #FF5555;
|
||||
border-radius: 10px;
|
||||
}
|
||||
)");
|
||||
|
||||
buttonLayout->addWidget(m_okButton, 1, Qt::AlignCenter);
|
||||
buttonLayout->addWidget(m_cancelButton, 1, Qt::AlignCenter);
|
||||
|
||||
layout->addLayout(buttonLayout, 1);
|
||||
|
||||
connect(m_okButton, &QPushButton::clicked, this, &QDialog::accept);
|
||||
connect(m_cancelButton, &QPushButton::clicked, this, &QDialog::reject);
|
||||
}
|
||||
|
||||
QString CreateVerDialog::getName( ) const {
|
||||
return m_name->text( );
|
||||
}
|
||||
|
||||
QString CreateVerDialog::getRaum( ) const {
|
||||
return m_raum->text( );
|
||||
}
|
||||
|
||||
QString CreateVerDialog::getCampus( ) const {
|
||||
return m_campus->currentText( );
|
||||
}
|
||||
|
||||
QString CreateVerDialog::getTime( ) const {
|
||||
return m_time->currentText( );
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
class CreateVerDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
protected:
|
||||
QLineEdit* m_name;
|
||||
QLineEdit* m_raum;
|
||||
|
||||
QComboBox* m_campus;
|
||||
QComboBox* m_time;
|
||||
|
||||
QPushButton* m_okButton;
|
||||
QPushButton* m_cancelButton;
|
||||
|
||||
public:
|
||||
CreateVerDialog(QWidget* parent = nullptr);
|
||||
|
||||
QString getName( ) const;
|
||||
QString getRaum( ) const;
|
||||
QString getCampus( ) const;
|
||||
QString getTime( ) const;
|
||||
};
|
||||
@@ -11,37 +11,35 @@ EinsatzplanFrame::EinsatzplanFrame(QWidget* parent, QString id, bool admin)
|
||||
}
|
||||
)");
|
||||
|
||||
controller_m = new EinsatzplanFrameController(id, admin);
|
||||
m_controller = new EinsatzplanFrameController(id, admin);
|
||||
|
||||
profileImg_m = new QLabel(this);
|
||||
profileImg_m->setFixedSize(60, 60);
|
||||
profileImg_m->setPixmap(QPixmap(":account-box.png"));
|
||||
profileImg_m->setObjectName("profileImg");
|
||||
profileImg_m->setStyleSheet(R"(
|
||||
m_profileImg = new QLabel(this);
|
||||
m_profileImg->setFixedSize(60, 60);
|
||||
m_profileImg->setPixmap(QPixmap(":account-box.png"));
|
||||
m_profileImg->setObjectName("profileImg");
|
||||
m_profileImg->setStyleSheet(R"(
|
||||
#profileImg{
|
||||
|
||||
}
|
||||
)");
|
||||
profileImg_m->show( );
|
||||
m_profileImg->show( );
|
||||
|
||||
|
||||
id_m = new QLabel(id, this);
|
||||
id_m->setFixedSize(122, 80);
|
||||
id_m->setObjectName("id");
|
||||
id_m->setStyleSheet(R"(
|
||||
m_id = new QLabel(id, this);
|
||||
m_id->setFixedSize(122, 80);
|
||||
m_id->setObjectName("id");
|
||||
m_id->setStyleSheet(R"(
|
||||
#id{
|
||||
font-size: 24px;
|
||||
color: #d8d8d8;
|
||||
font-weight: bold;
|
||||
}
|
||||
)");
|
||||
id_m->show( );
|
||||
m_id->show( );
|
||||
|
||||
|
||||
abmeldenButton_m = new QPushButton("Abmelden", this);
|
||||
abmeldenButton_m->setFixedSize(150, 50);
|
||||
abmeldenButton_m->setObjectName("abmeldenButton");
|
||||
abmeldenButton_m->setStyleSheet(R"(
|
||||
m_abmeldenButton = new QPushButton("Abmelden", this);
|
||||
m_abmeldenButton->setFixedSize(150, 50);
|
||||
m_abmeldenButton->setObjectName("abmeldenButton");
|
||||
m_abmeldenButton->setStyleSheet(R"(
|
||||
#abmeldenButton{
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
@@ -53,58 +51,50 @@ EinsatzplanFrame::EinsatzplanFrame(QWidget* parent, QString id, bool admin)
|
||||
background-color: #D0793A;
|
||||
}
|
||||
)");
|
||||
abmeldenButton_m->show( );
|
||||
m_abmeldenButton->show( );
|
||||
|
||||
//implement logoutButton functionality
|
||||
connect(abmeldenButton_m, &QPushButton::clicked, this, &EinsatzplanFrame::abmelden);
|
||||
connect(m_abmeldenButton, &QPushButton::clicked, this, &EinsatzplanFrame::abmelden);
|
||||
|
||||
|
||||
einsatzplanLabel_m = new QLabel("Einsatzplan", this);
|
||||
einsatzplanLabel_m->setFixedSize(645, 80);
|
||||
einsatzplanLabel_m->setAlignment(Qt::AlignCenter);
|
||||
einsatzplanLabel_m->setObjectName("einsatzplanLabel");
|
||||
einsatzplanLabel_m->setStyleSheet(R"(
|
||||
m_einsatzplanLabel = new QLabel("Einsatzplan", this);
|
||||
m_einsatzplanLabel->setFixedSize(645, 80);
|
||||
m_einsatzplanLabel->setAlignment(Qt::AlignCenter);
|
||||
m_einsatzplanLabel->setObjectName("einsatzplanLabel");
|
||||
m_einsatzplanLabel->setStyleSheet(R"(
|
||||
#einsatzplanLabel{
|
||||
font-size:40px;
|
||||
color: #7FF;
|
||||
font-weight: bold;
|
||||
}
|
||||
)");
|
||||
einsatzplanLabel_m->show( );
|
||||
|
||||
|
||||
planGrid_m = new PlanGrid(this);
|
||||
planGrid_m->show( );
|
||||
|
||||
m_einsatzplanLabel->show( );
|
||||
|
||||
m_planGrid = new PlanGrid(this);
|
||||
m_planGrid->show( );
|
||||
|
||||
QVBoxLayout* totalLayout = new QVBoxLayout(this);
|
||||
totalLayout->setContentsMargins(30, 20, 30, 20);
|
||||
|
||||
QHBoxLayout* topLayout = new QHBoxLayout(this);
|
||||
topLayout->addWidget(profileImg_m, 0, Qt::AlignLeft);
|
||||
QHBoxLayout* topLayout = new QHBoxLayout( );
|
||||
topLayout->addWidget(m_profileImg, 0, Qt::AlignLeft);
|
||||
topLayout->addSpacing(10);
|
||||
topLayout->addWidget(id_m, 0, Qt::AlignLeft);
|
||||
topLayout->addWidget(einsatzplanLabel_m, 4, Qt::AlignCenter);
|
||||
topLayout->addWidget(abmeldenButton_m, 0, Qt::AlignRight);
|
||||
|
||||
|
||||
QHBoxLayout* bottomLayout = new QHBoxLayout(this);
|
||||
bottomLayout->addWidget(planGrid_m, 1, Qt::AlignCenter);
|
||||
topLayout->addWidget(m_id, 0, Qt::AlignLeft);
|
||||
topLayout->addWidget(m_einsatzplanLabel, 4, Qt::AlignCenter);
|
||||
topLayout->addWidget(m_abmeldenButton, 0, Qt::AlignRight);
|
||||
|
||||
QHBoxLayout* bottomLayout = new QHBoxLayout( );
|
||||
bottomLayout->addWidget(m_planGrid, 1, Qt::AlignCenter);
|
||||
|
||||
//make bottomLayout bigger then topLayout
|
||||
totalLayout->addLayout(topLayout, 1);
|
||||
totalLayout->addLayout(bottomLayout, 4);
|
||||
|
||||
if (!admin) { return; }
|
||||
|
||||
|
||||
if (admin) {
|
||||
|
||||
createMemberButton_m = new QPushButton("Mitarbeiter\nHinzufügen", this);
|
||||
createMemberButton_m->setFixedSize(200, 50);
|
||||
createMemberButton_m->setObjectName("createMember");
|
||||
createMemberButton_m->setStyleSheet(R"(
|
||||
m_createMemberButton = new QPushButton("Mitarbeiter\nHinzufügen", this);
|
||||
m_createMemberButton->setFixedSize(200, 50);
|
||||
m_createMemberButton->setObjectName("createMember");
|
||||
m_createMemberButton->setStyleSheet(R"(
|
||||
#createMember{
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
@@ -116,16 +106,15 @@ EinsatzplanFrame::EinsatzplanFrame(QWidget* parent, QString id, bool admin)
|
||||
background-color: #CCEF68;
|
||||
}
|
||||
)");
|
||||
createMemberButton_m->show( );
|
||||
m_createMemberButton->show( );
|
||||
|
||||
//implement createMemberButton functionality
|
||||
connect(createMemberButton_m, &QPushButton::clicked, this, &EinsatzplanFrame::createMember);
|
||||
connect(m_createMemberButton, &QPushButton::clicked, this, &EinsatzplanFrame::createMember);
|
||||
|
||||
|
||||
deleteMemberButton_m = new QPushButton("Mitarbeiter\nEntfernen", this);
|
||||
deleteMemberButton_m->setFixedSize(200, 50);
|
||||
deleteMemberButton_m->setObjectName("deleteMember");
|
||||
deleteMemberButton_m->setStyleSheet(R"(
|
||||
m_deleteMemberButton = new QPushButton("Mitarbeiter\nEntfernen", this);
|
||||
m_deleteMemberButton->setFixedSize(200, 50);
|
||||
m_deleteMemberButton->setObjectName("deleteMember");
|
||||
m_deleteMemberButton->setStyleSheet(R"(
|
||||
#deleteMember{
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
@@ -137,16 +126,15 @@ EinsatzplanFrame::EinsatzplanFrame(QWidget* parent, QString id, bool admin)
|
||||
background-color: #CCEF68;
|
||||
}
|
||||
)");
|
||||
deleteMemberButton_m->show( );
|
||||
m_deleteMemberButton->show( );
|
||||
|
||||
//implement deleteMemberButton functionality
|
||||
connect(deleteMemberButton_m, &QPushButton::clicked, this, &EinsatzplanFrame::deleteMember);
|
||||
connect(m_deleteMemberButton, &QPushButton::clicked, this, &EinsatzplanFrame::deleteMember);
|
||||
|
||||
|
||||
createVeranstaltungButton_m = new QPushButton("Veranstaltung\nHinzufügen", this);
|
||||
createVeranstaltungButton_m->setFixedSize(200, 50);
|
||||
createVeranstaltungButton_m->setObjectName("createVeranstaltung");
|
||||
createVeranstaltungButton_m->setStyleSheet(R"(
|
||||
m_createVeranstaltungButton = new QPushButton("Veranstaltung\nHinzufügen", this);
|
||||
m_createVeranstaltungButton->setFixedSize(200, 50);
|
||||
m_createVeranstaltungButton->setObjectName("createVeranstaltung");
|
||||
m_createVeranstaltungButton->setStyleSheet(R"(
|
||||
#createVeranstaltung{
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
@@ -158,16 +146,15 @@ EinsatzplanFrame::EinsatzplanFrame(QWidget* parent, QString id, bool admin)
|
||||
background-color: #CCEF68;
|
||||
}
|
||||
)");
|
||||
createVeranstaltungButton_m->show( );
|
||||
m_createVeranstaltungButton->show( );
|
||||
|
||||
//implement createVeranstaltungButton functionality
|
||||
connect(createVeranstaltungButton_m, &QPushButton::clicked, this, &EinsatzplanFrame::createVeranstaltung);
|
||||
connect(m_createVeranstaltungButton, &QPushButton::clicked, this, &EinsatzplanFrame::createVeranstaltung);
|
||||
|
||||
|
||||
deleteVeranstaltungButton_m = new QPushButton("Veranstaltung\nEntfernen", this);
|
||||
deleteVeranstaltungButton_m->setFixedSize(200, 50);
|
||||
deleteVeranstaltungButton_m->setObjectName("deleteVeranstaltung");
|
||||
deleteVeranstaltungButton_m->setStyleSheet(R"(
|
||||
m_deleteVeranstaltungButton = new QPushButton("Veranstaltung\nEntfernen", this);
|
||||
m_deleteVeranstaltungButton->setFixedSize(200, 50);
|
||||
m_deleteVeranstaltungButton->setObjectName("deleteVeranstaltung");
|
||||
m_deleteVeranstaltungButton->setStyleSheet(R"(
|
||||
#deleteVeranstaltung{
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
@@ -179,21 +166,19 @@ EinsatzplanFrame::EinsatzplanFrame(QWidget* parent, QString id, bool admin)
|
||||
background-color: #CCEF68;
|
||||
}
|
||||
)");
|
||||
deleteVeranstaltungButton_m->show( );
|
||||
m_deleteVeranstaltungButton->show( );
|
||||
|
||||
//implement deleteVeranstaltungButton functionality
|
||||
connect(deleteVeranstaltungButton_m, &QPushButton::clicked, this, &EinsatzplanFrame::deleteVeranstaltung);
|
||||
connect(m_deleteVeranstaltungButton, &QPushButton::clicked, this, &EinsatzplanFrame::deleteVeranstaltung);
|
||||
|
||||
QHBoxLayout* adminLayout = new QHBoxLayout(this);
|
||||
adminLayout->addWidget(createMemberButton_m, 1, Qt::AlignLeft);
|
||||
adminLayout->addWidget(deleteMemberButton_m, 1, Qt::AlignLeft);
|
||||
QHBoxLayout* adminLayout = new QHBoxLayout( );
|
||||
adminLayout->addWidget(m_createMemberButton, 1, Qt::AlignLeft);
|
||||
adminLayout->addWidget(m_deleteMemberButton, 1, Qt::AlignLeft);
|
||||
adminLayout->addStretch(1);
|
||||
adminLayout->addWidget(createVeranstaltungButton_m, 1, Qt::AlignRight);
|
||||
adminLayout->addWidget(deleteVeranstaltungButton_m, 1, Qt::AlignRight);
|
||||
adminLayout->addWidget(m_createVeranstaltungButton, 1, Qt::AlignRight);
|
||||
adminLayout->addWidget(m_deleteVeranstaltungButton, 1, Qt::AlignRight);
|
||||
|
||||
totalLayout->addLayout(adminLayout);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void EinsatzplanFrame::abmelden( ) {
|
||||
@@ -205,20 +190,19 @@ void EinsatzplanFrame::deleteVeranstaltung(){
|
||||
QString text = QInputDialog::getText(this, tr("Veranstaltung Entfernen"),
|
||||
tr("Bitte geben sie den Veranstaltungskürzel ein:"), QLineEdit::Normal,
|
||||
"", &ok);
|
||||
if (ok && text.size()!= 3)
|
||||
QMessageBox::information(this, "Veranstaltung Entfernen", "Veranstaltungskürzel besteht aus 3 Zeichen!");
|
||||
if (ok && text.size() == 3)
|
||||
(ok && text.size( ) == 3) ?
|
||||
QMessageBox::information(this, "Veranstaltung Entfernen", "Veranstaltungskürzel besteht aus 3 Zeichen!") :
|
||||
QMessageBox::information(this, "Veranstaltung entfernen", "Veranstaltung wird entfernt!");
|
||||
}
|
||||
|
||||
void EinsatzplanFrame::createVeranstaltung( ) {
|
||||
createVerDialog dialog(this);
|
||||
CreateVerDialog dialog(this);
|
||||
if (dialog.exec( ) == QDialog::Accepted) {
|
||||
QString name = dialog.getName( );
|
||||
QString raum = dialog.getRaum( );
|
||||
QString campus = dialog.getCampus( );
|
||||
QString time = dialog.getTime( );
|
||||
controller_m->createVeranstaltung(name,raum, campus, time);
|
||||
m_controller->createVeranstaltung(name, raum, campus, time);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,303 +211,19 @@ void EinsatzplanFrame::deleteMember(){
|
||||
QString text = QInputDialog::getText(this, tr("Mitarbeiter Entfernen"),
|
||||
tr("Bitte geben sie die Mitarbeiter ID ein:"), QLineEdit::Normal,
|
||||
"", &ok);
|
||||
if (ok && text.size()!= 7)
|
||||
|
||||
(ok && text.size( ) == 7) ?
|
||||
QMessageBox::information(this, "Mitarbeiter entfernen", "Mitarbeiter wird entfernt!") :
|
||||
QMessageBox::information(this, "Mitarbeiter Entfernen", "Mitarbeiter ID besteht aus 7 Zahlen!");
|
||||
if (ok && text.size() == 7)
|
||||
QMessageBox::information(this, "Mitarbeiter entfernen", "Mitarbeiter wird entfernt!");
|
||||
}
|
||||
|
||||
void EinsatzplanFrame::createMember( ) {
|
||||
createMemDialog dialog(this);
|
||||
CreateMemDialog dialog(this);
|
||||
if (dialog.exec( ) == QDialog::Accepted) {
|
||||
QString name = dialog.getName( );
|
||||
QString email = dialog.getEmail( );
|
||||
QString password = dialog.getPassword( );
|
||||
bool isAdmin = dialog.isAdmin( );
|
||||
controller_m->createMember(name, email, password, isAdmin);
|
||||
m_controller->createMember(name, email, password, isAdmin);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
createMemDialog::createMemDialog(QWidget* parent)
|
||||
:QDialog(parent)
|
||||
{
|
||||
setWindowTitle("Mitarbeiter Hinzufügen");
|
||||
setFixedSize(300,400);
|
||||
setObjectName("createMemDialog");
|
||||
setStyleSheet(R"(
|
||||
#createMemDialog{
|
||||
background-color: #212121;
|
||||
border: none;
|
||||
}
|
||||
)");
|
||||
|
||||
name_m = new QLineEdit(this);
|
||||
name_m->setPlaceholderText("Name");
|
||||
name_m->setFixedSize(220,40);
|
||||
name_m->setObjectName("name");
|
||||
name_m->setStyleSheet(R"(
|
||||
#name{
|
||||
color: #DADADA;
|
||||
font-size: 16px;
|
||||
background-color: #313131;
|
||||
border-radius: 10px;
|
||||
padding: 5px;
|
||||
border: 2px solid #414141;
|
||||
}
|
||||
)");
|
||||
name_m->show();
|
||||
|
||||
|
||||
email_m = new QLineEdit(this);
|
||||
email_m->setPlaceholderText("Email");
|
||||
email_m->setFixedSize(220,40);
|
||||
email_m->setObjectName("email");
|
||||
email_m->setStyleSheet(R"(
|
||||
#email{
|
||||
color: #DADADA;
|
||||
font-size: 16px;
|
||||
background-color: #313131;
|
||||
border-radius: 10px;
|
||||
padding: 5px;
|
||||
border: 2px solid #414141;
|
||||
}
|
||||
)");
|
||||
email_m->show();
|
||||
|
||||
password_m = new QLineEdit(this);
|
||||
password_m->setPlaceholderText("Passwort");
|
||||
password_m->setEchoMode(QLineEdit::Password);
|
||||
password_m->setFixedSize(220,40);
|
||||
password_m->setObjectName("password");
|
||||
password_m->setStyleSheet(R"(
|
||||
#password{
|
||||
color: #DADADA;
|
||||
font-size: 16px;
|
||||
background-color: #313131;
|
||||
border-radius: 10px;
|
||||
padding: 5px;
|
||||
border: 2px solid #414141;
|
||||
}
|
||||
)");
|
||||
password_m->show();
|
||||
|
||||
admin_m = new QCheckBox("Admin", this);
|
||||
admin_m->setFixedSize(220,40);
|
||||
admin_m->setObjectName("admin");
|
||||
admin_m->setStyleSheet(R"(
|
||||
#admin{
|
||||
color: #DADADA;
|
||||
font-size: 20px;
|
||||
border: none;
|
||||
}
|
||||
)");
|
||||
admin_m->show();
|
||||
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
|
||||
layout->setContentsMargins(30,30,30,30);
|
||||
|
||||
layout->addWidget(name_m,1,Qt::AlignCenter);
|
||||
layout->addWidget(email_m,1,Qt::AlignCenter);
|
||||
layout->addWidget(password_m,1,Qt::AlignCenter);
|
||||
layout->addWidget(admin_m,1, Qt::AlignCenter);
|
||||
|
||||
QHBoxLayout* buttonLayout = new QHBoxLayout();
|
||||
|
||||
okButton_m = new QPushButton("OK", this);
|
||||
okButton_m->setFixedSize(110,40);
|
||||
okButton_m->setObjectName("okButton");
|
||||
okButton_m->setStyleSheet(R"(
|
||||
#okButton{
|
||||
color: #212121;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
background-color: #53EC87;
|
||||
border-radius: 10px;
|
||||
}
|
||||
)");
|
||||
|
||||
cancelButton_m = new QPushButton("Abbrechen", this);
|
||||
cancelButton_m->setFixedSize(110,40);
|
||||
cancelButton_m->setObjectName("cancelButton");
|
||||
cancelButton_m->setStyleSheet(R"(
|
||||
#cancelButton{
|
||||
color: #212121;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
background-color: #FF5555;
|
||||
border-radius: 10px;
|
||||
}
|
||||
)");
|
||||
|
||||
buttonLayout->addWidget(okButton_m,1, Qt::AlignCenter);
|
||||
buttonLayout->addWidget(cancelButton_m,1,Qt::AlignCenter);
|
||||
|
||||
layout->addLayout(buttonLayout);
|
||||
|
||||
connect(okButton_m, &QPushButton::clicked, this, &QDialog::accept);
|
||||
connect(cancelButton_m, &QPushButton::clicked, this, &QDialog::reject);
|
||||
}
|
||||
|
||||
QString createMemDialog::getName() const {
|
||||
return name_m->text();
|
||||
}
|
||||
|
||||
QString createMemDialog::getEmail() const {
|
||||
return email_m->text();
|
||||
}
|
||||
|
||||
QString createMemDialog::getPassword() const {
|
||||
return password_m->text();
|
||||
}
|
||||
|
||||
bool createMemDialog::isAdmin() const {
|
||||
return admin_m->isChecked();
|
||||
}
|
||||
|
||||
|
||||
|
||||
createVerDialog::createVerDialog(QWidget* parent)
|
||||
: QDialog(parent) {
|
||||
setWindowTitle("Veranstaltung Hinzufügen");
|
||||
setFixedSize(300,400);
|
||||
setObjectName("createMemDialog");
|
||||
setStyleSheet(R"(
|
||||
#createMemDialog{
|
||||
background-color: #212121;
|
||||
border: none;
|
||||
}
|
||||
)");
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
|
||||
layout->setContentsMargins(30,30,30,30);
|
||||
|
||||
name_m = new QLineEdit(this);
|
||||
name_m->setPlaceholderText("Veranstaltungskürzel");
|
||||
name_m->setFixedSize(220,40);
|
||||
name_m->setObjectName("name");
|
||||
name_m->setStyleSheet(R"(
|
||||
#name{
|
||||
color: #DADADA;
|
||||
font-size: 16px;
|
||||
background-color: #313131;
|
||||
border-radius: 10px;
|
||||
padding: 5px;
|
||||
border: 2px solid #414141;
|
||||
}
|
||||
)");
|
||||
layout->addWidget(name_m,1,Qt::AlignCenter);
|
||||
|
||||
raum_m = new QLineEdit(this);
|
||||
raum_m->setPlaceholderText("Raum");
|
||||
raum_m->setFixedSize(220,40);
|
||||
raum_m->setObjectName("raum");
|
||||
raum_m->setStyleSheet(R"(
|
||||
#raum{
|
||||
color: #DADADA;
|
||||
font-size: 16px;
|
||||
background-color: #313131;
|
||||
border-radius: 10px;
|
||||
padding: 5px;
|
||||
border: 2px solid #414141;
|
||||
}
|
||||
)");
|
||||
layout->addWidget(raum_m,1,Qt::AlignCenter);
|
||||
|
||||
campus_m = new QComboBox(this);
|
||||
campus_m->addItem("Campus A");
|
||||
campus_m->addItem("Campus B");
|
||||
campus_m->setFixedSize(220,40);
|
||||
campus_m->setObjectName("campus");
|
||||
campus_m->setStyleSheet(R"(
|
||||
#campus{
|
||||
color: #DADADA;
|
||||
font-size: 16px;
|
||||
background-color: #313131;
|
||||
border-radius: 10px;
|
||||
padding: 5px;
|
||||
}
|
||||
#campus::Item{
|
||||
color: #DADADA;
|
||||
background-color: #313131;
|
||||
}
|
||||
)");
|
||||
layout->addWidget(campus_m,1,Qt::AlignCenter);
|
||||
|
||||
time_m = new QComboBox(this);
|
||||
time_m->addItem("2h");
|
||||
time_m->addItem("4h");
|
||||
time_m->setFixedSize(220,40);
|
||||
time_m->setObjectName("time");
|
||||
time_m->setStyleSheet(R"(
|
||||
#time{
|
||||
color: #DADADA;
|
||||
font-size: 16px;
|
||||
background-color: #313131;
|
||||
border-radius: 10px;
|
||||
padding: 5px;
|
||||
}
|
||||
#time::Item{
|
||||
color: #DADADA;
|
||||
background-color: #313131;
|
||||
}
|
||||
)");
|
||||
layout->addWidget(time_m,1,Qt::AlignCenter);
|
||||
|
||||
|
||||
QHBoxLayout* buttonLayout = new QHBoxLayout();
|
||||
|
||||
okButton_m = new QPushButton("OK", this);
|
||||
okButton_m->setFixedSize(110,40);
|
||||
okButton_m->setObjectName("okButton");
|
||||
okButton_m->setStyleSheet(R"(
|
||||
#okButton{
|
||||
color: #212121;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
background-color: #53EC87;
|
||||
border-radius: 10px;
|
||||
}
|
||||
)");
|
||||
|
||||
cancelButton_m = new QPushButton("Abbrechen", this);
|
||||
cancelButton_m->setFixedSize(110,40);
|
||||
cancelButton_m->setObjectName("cancelButton");
|
||||
cancelButton_m->setStyleSheet(R"(
|
||||
#cancelButton{
|
||||
color: #212121;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
background-color: #FF5555;
|
||||
border-radius: 10px;
|
||||
}
|
||||
)");
|
||||
|
||||
buttonLayout->addWidget(okButton_m,1,Qt::AlignCenter);
|
||||
buttonLayout->addWidget(cancelButton_m,1,Qt::AlignCenter);
|
||||
|
||||
layout->addLayout(buttonLayout,1);
|
||||
|
||||
connect(okButton_m, &QPushButton::clicked, this, &QDialog::accept);
|
||||
connect(cancelButton_m, &QPushButton::clicked, this, &QDialog::reject);
|
||||
}
|
||||
|
||||
QString createVerDialog::getName() const {
|
||||
return name_m->text();
|
||||
}
|
||||
|
||||
QString createVerDialog::getRaum() const {
|
||||
return raum_m->text();
|
||||
}
|
||||
|
||||
QString createVerDialog::getCampus() const {
|
||||
return campus_m->currentText();
|
||||
}
|
||||
|
||||
QString createVerDialog::getTime() const{
|
||||
return time_m->currentText();
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <QFrame>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
@@ -10,26 +11,29 @@
|
||||
#include <QInputDialog>
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
|
||||
#include "../PlanGrid/PlanGrid.hpp"
|
||||
#include "../../Controller/EinsatzplanFrameController/EinsatzplanFrameController.hpp"
|
||||
|
||||
#include "Dialogs/CreateMember/CreateMember.hpp"
|
||||
#include "Dialogs/CreateVeranstaltung/CreateVeranstaltung.hpp"
|
||||
|
||||
class EinsatzplanFrame : public QFrame {
|
||||
Q_OBJECT
|
||||
protected:
|
||||
EinsatzplanFrameController* controller_m;
|
||||
EinsatzplanFrameController* m_controller;
|
||||
|
||||
QLabel* profileImg_m;
|
||||
QLabel* id_m;
|
||||
QLabel* einsatzplanLabel_m;
|
||||
QLabel* m_profileImg;
|
||||
QLabel* m_id;
|
||||
QLabel* m_einsatzplanLabel;
|
||||
|
||||
PlanGrid* planGrid_m;
|
||||
PlanGrid* m_planGrid;
|
||||
|
||||
QPushButton* m_abmeldenButton;
|
||||
QPushButton* m_createMemberButton;
|
||||
QPushButton* m_deleteMemberButton;
|
||||
QPushButton* m_createVeranstaltungButton;
|
||||
QPushButton* m_deleteVeranstaltungButton;
|
||||
|
||||
QPushButton* abmeldenButton_m;
|
||||
QPushButton* createMemberButton_m;
|
||||
QPushButton* deleteMemberButton_m;
|
||||
QPushButton* createVeranstaltungButton_m;
|
||||
QPushButton* deleteVeranstaltungButton_m;
|
||||
public:
|
||||
EinsatzplanFrame(QWidget* parent = nullptr, QString id = "0000000", bool admin = true);
|
||||
|
||||
@@ -40,57 +44,4 @@ private slots:
|
||||
void createVeranstaltung( );
|
||||
void deleteMember( );
|
||||
void createMember( );
|
||||
|
||||
};
|
||||
|
||||
class createVerDialog : public QDialog{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
|
||||
QLineEdit* name_m;
|
||||
QLineEdit* raum_m;
|
||||
QComboBox* campus_m;
|
||||
QComboBox* time_m;
|
||||
QPushButton* okButton_m;
|
||||
QPushButton* cancelButton_m;
|
||||
|
||||
public:
|
||||
|
||||
createVerDialog(QWidget* parent = nullptr);
|
||||
|
||||
QString getName() const;
|
||||
QString getRaum() const;
|
||||
QString getCampus() const;
|
||||
QString getTime() const;
|
||||
};
|
||||
|
||||
class createMemDialog : public QDialog{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
QLineEdit* name_m;
|
||||
QLineEdit* email_m;
|
||||
QLineEdit* password_m;
|
||||
QCheckBox* admin_m;
|
||||
QPushButton* okButton_m;
|
||||
QPushButton* cancelButton_m;
|
||||
|
||||
public:
|
||||
|
||||
createMemDialog(QWidget* parent = nullptr);
|
||||
|
||||
QString getName() const;
|
||||
QString getEmail() const;
|
||||
QString getPassword() const;
|
||||
bool isAdmin() const;
|
||||
};
|
||||
|
||||
class deleteVerDialog : QDialog{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
QLineEdit* veranstaltung_m;
|
||||
QPushButton* okButton_m;
|
||||
QPushButton* cancleButton_m;
|
||||
|
||||
public:
|
||||
QString getVeranstaltung();
|
||||
};
|
||||
@@ -1,9 +1,8 @@
|
||||
#include "EinsatzplanWindow.hpp"
|
||||
|
||||
EinsatzplanWindow::EinsatzplanWindow(QWidget* parent, QString id, bool admin)
|
||||
:QMainWindow(parent)
|
||||
{
|
||||
frame_m = new EinsatzplanFrame(this, id, admin);
|
||||
:QMainWindow(parent) {
|
||||
m_frame = new EinsatzplanFrame(this, id, admin);
|
||||
setFixedSize(1400, 800);
|
||||
frame_m->setFixedSize(size());
|
||||
m_frame->setFixedSize(size( ));
|
||||
}
|
||||
@@ -5,8 +5,7 @@
|
||||
class EinsatzplanWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
private:
|
||||
EinsatzplanFrame* frame_m;
|
||||
|
||||
EinsatzplanFrame* m_frame;
|
||||
|
||||
public:
|
||||
EinsatzplanWindow(QWidget* parent = nullptr, QString id = "0000000", bool admin = true);
|
||||
|
||||
@@ -10,25 +10,23 @@ PlanGrid::PlanGrid(QWidget* parent)
|
||||
}
|
||||
)");
|
||||
|
||||
weekdays[0] = "Montag";
|
||||
weekdays[1] = "Dienstag";
|
||||
weekdays[2] = "Mittwoch";
|
||||
weekdays[3] = "Donnerstag";
|
||||
weekdays[4] = "Freitag";
|
||||
|
||||
times[0] = "8:00 - 10:00";
|
||||
times[1] = "10:00 - 12:00";
|
||||
times[2] = "12:00 - 14:00";
|
||||
times[3] = "14:00 - 16:00";
|
||||
times[4] = "16:00 - 18:00";
|
||||
|
||||
m_weekdays[0] = "Montag";
|
||||
m_weekdays[1] = "Dienstag";
|
||||
m_weekdays[2] = "Mittwoch";
|
||||
m_weekdays[3] = "Donnerstag";
|
||||
m_weekdays[4] = "Freitag";
|
||||
|
||||
m_times[0] = "8:00 - 10:00";
|
||||
m_times[1] = "10:00 - 12:00";
|
||||
m_times[2] = "12:00 - 14:00";
|
||||
m_times[3] = "14:00 - 16:00";
|
||||
m_times[4] = "16:00 - 18:00";
|
||||
|
||||
planMap = new QMap<QPair<QString, QString>, QLabel*>( );
|
||||
|
||||
gridLayout = new QGridLayout(this);
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
for (int i = 0; i < 5; ++i)
|
||||
for (int j = 0; j < 5; ++j) {
|
||||
QLabel* temp = new QLabel( );
|
||||
temp->setObjectName("temp");
|
||||
@@ -38,13 +36,11 @@ PlanGrid::PlanGrid(QWidget* parent)
|
||||
}
|
||||
)");
|
||||
temp->setFixedSize(240, 100);
|
||||
planMap->insert(qMakePair(weekdays[i], times[j]), temp);
|
||||
}
|
||||
planMap->insert(qMakePair(m_weekdays[i], m_times[j]), temp);
|
||||
}
|
||||
|
||||
populateGrid( );
|
||||
|
||||
|
||||
QLabel* temp = new QLabel( );
|
||||
temp->setObjectName("temp");
|
||||
temp->setStyleSheet(R"(
|
||||
@@ -56,7 +52,7 @@ PlanGrid::PlanGrid(QWidget* parent)
|
||||
gridLayout->addWidget(temp, 0, 0);
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
QLabel* temp = new QLabel(weekdays[i]);
|
||||
QLabel* temp = new QLabel(m_weekdays[i]);
|
||||
temp->setFixedSize(240, 80);
|
||||
temp->setObjectName("temp");
|
||||
if (i == 4) {
|
||||
@@ -68,7 +64,6 @@ PlanGrid::PlanGrid(QWidget* parent)
|
||||
color: #d8d8d8;
|
||||
}
|
||||
)");
|
||||
|
||||
} else {
|
||||
temp->setStyleSheet(R"(
|
||||
#temp{
|
||||
@@ -83,10 +78,10 @@ PlanGrid::PlanGrid(QWidget* parent)
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
QLabel* temp = new QLabel(times[i]);
|
||||
QLabel* temp = new QLabel(m_times[i]);
|
||||
temp->setFixedSize(130, 100);
|
||||
temp->setObjectName("temp");
|
||||
if (i == 9) {
|
||||
if (i == 4) {
|
||||
temp->setStyleSheet(R"(
|
||||
#temp{
|
||||
font-size: 16px;
|
||||
@@ -104,7 +99,7 @@ PlanGrid::PlanGrid(QWidget* parent)
|
||||
}
|
||||
)");
|
||||
}
|
||||
temp->setAlignment(Qt::AlignRight);
|
||||
temp->setAlignment(Qt::AlignCenter);
|
||||
gridLayout->addWidget(temp, i + 1, 0);
|
||||
}
|
||||
|
||||
@@ -115,9 +110,9 @@ PlanGrid::PlanGrid(QWidget* parent)
|
||||
void PlanGrid::populateGrid( ) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
for (int j = 0; j < 5; ++j) {
|
||||
gridLayout->addWidget(planMap->value(qMakePair(weekdays[i], times[j])), j + 1, i + 1);
|
||||
gridLayout->addWidget(planMap->value(qMakePair(m_weekdays[i], m_times[j])), j + 1, i + 1);
|
||||
if (i == 4 && j == 4) {
|
||||
(planMap->value(qMakePair(weekdays[i], times[j])))->setStyleSheet(R"(
|
||||
(planMap->value(qMakePair(m_weekdays[i], m_times[j])))->setStyleSheet(R"(
|
||||
border-bottom-right-radius:10px;
|
||||
)");
|
||||
}
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QDateTime>
|
||||
|
||||
#include "../../Controller/PlanGridController/PlanGridController.hpp"
|
||||
#include "../Widgets/GridItem.hpp"
|
||||
|
||||
class PlanGrid : public QWidget {
|
||||
Q_OBJECT
|
||||
private:
|
||||
QString weekdays[5];
|
||||
QString times[5];
|
||||
QString m_weekdays[5];
|
||||
QString m_times[5];
|
||||
|
||||
void populateGrid( );
|
||||
|
||||
protected:
|
||||
QGridLayout* gridLayout;
|
||||
QMap<QPair<QString, QString>, QLabel*>* planMap;
|
||||
|
||||
public:
|
||||
PlanGrid(QWidget* parent = nullptr);
|
||||
};
|
||||
@@ -1,8 +1,7 @@
|
||||
# include "GridItem.hpp"
|
||||
|
||||
GridItem::GridItem(QString text, QWidget* parent)
|
||||
:QLabel(parent)
|
||||
{
|
||||
:QLabel(parent) {
|
||||
//Fix later
|
||||
//text_m = new QLabel(text,this);
|
||||
//text_m->setAlignment(Qt::AlignCenter);
|
||||
|
||||
Reference in New Issue
Block a user