struct DersBilgisi {
std::string dersAdi;
std::string kisaAdi;
int haftalikDersSaati;
std::string yerlestirmeBicimi;
};
struct GunlukDersSayisi {
int baslangicDersi;
int bitisDersi;
};
struct SinifBilgisi {
int id;
std::string originalSinif;
std::string sinifAdi;
bool sabahci;
GunlukDersSayisi gunler[5]; // Pazartesi-Cuma
};
struct DerslikBilgisi {
std::string originalDerslik;
std::string derslikAdi;
std::string kisaAdi;
};
struct OgretmenBilgisi {
std::string adSoyad;
std::string kisaAdi;
std::string bransi;
std::string sinifOgretmeni;
std::string sosyalKlubu;
std::string eMailAdresi;
};
struct OkutulanDers {
std::string sinif;
std::string dersAdi;
int hds;
std::string yerlestirmeBicimi;
};
// Add this struct to manage shared lessons
struct OrtakDers {
std::string dersAdi;
std::vector<std::string> siniflar;
};
std::vector<DersBilgisi> derslerListesi;
std::vector<SinifBilgisi> siniflarListesi;
std::vector<DerslikBilgisi> dersliklerListesi;
std::vector<OgretmenBilgisi> ogretmenlerListesi;
SinifBilgisi seciliSinif;
std::vector<OkutulanDers> okutulanDerslerListesi;
std::vector<OrtakDers> ortakDerslerListesi;
bool OgretmenlereDersExcelKaydet() {
if (mutexEnabled) {
std::lock_guard<std::mutex> lock(excelDosyasiMutex);
}
try {
OpenXLSX::XLDocument doc;
bool fileExists = std::filesystem::exists("ogretmenlerin_dersleri.xlsx");
if (fileExists) {
doc.open("ogretmenlerin_dersleri.xlsx");
}
else {
doc.create("ogretmenlerin_dersleri.xlsx");
}
auto wks = doc.workbook().worksheet("Sheet1");
// A-E sütunlarındaki verileri temizle
uint32_t maxRow = wks.rowCount();
for (uint32_t row = 2; row <= maxRow; ++row) {
for (uint32_t col = 1; col <= 5; ++col) {
wks.cell(row, col).value() = "";
}
}
// A-E sütunları için başlıkları yaz
wks.cell("A1").value() = "Öğretmen Adı Soyadı";
wks.cell("B1").value() = "Branşı";
wks.cell("C1").value() = "Sınıfı";
wks.cell("D1").value() = "Dersin Adı";
wks.cell("E1").value() = "Haftalık Ders Saati";
int rowOffset = 2; // Başlık satırından sonra başla
for (const auto& ogretmen : ogretmenlerListesi) {
for (const auto& okutulanDers : okutulanDerslerListesi) {
// Öğretmenin bu dersi okutup okutmadığını kontrol et
// Bu kontrolü, veri yapınıza göre uyarlamanız gerekebilir
if (ogretmen.bransi == okutulanDers.dersAdi) {
wks.cell(rowOffset, 1).value() = ogretmen.adSoyad;
wks.cell(rowOffset, 2).value() = ogretmen.bransi;
wks.cell(rowOffset, 3).value() = okutulanDers.sinif;
wks.cell(rowOffset, 4).value() = okutulanDers.dersAdi;
wks.cell(rowOffset, 5).value() = okutulanDers.hds;
rowOffset++;
}
}
}
doc.save();
doc.close();
std::cout << "Ogretmenlere ders atanmasi başarıyla kaydedildi." << std::endl;
return true;
}
catch (const OpenXLSX::XLException& e) {
std::cerr << "Excel dosyası kaydedilirken hata oluştu: " << e.what() << std::endl;
return false;
}
}
void Window7Content() {
static int selectedOgretmenIndex = -1;
static int selectedDersIndex = -1;
static std::vector<int> selectedSiniflarIndex;
ImVec4 blueColor = ImVec4(0.0f, 0.5f, 1.0f, 1.0f);
ImVec4 lightBlueColor = ImVec4(0.7f, 0.85f, 1.0f, 1.0f);
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
ImGui::BeginChild("OĞRETMENLERE DERS ATANMASI", ImVec2(0, 810), true);
ImGui::PushStyleColor(ImGuiCol_TableRowBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
ImGui::PushStyleColor(ImGuiCol_TableRowBgAlt, ImVec4(0.95f, 0.95f, 0.95f, 1.0f));
if (ImGui::BeginTable("MainTable", 3, ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_SizingStretchProp)) {
ImGui::TableSetupColumn("Öğretmenler", ImGuiTableColumnFlags_WidthStretch, 0.33f);
ImGui::TableSetupColumn("Dersler", ImGuiTableColumnFlags_WidthStretch, 0.33f);
ImGui::TableSetupColumn("Dersin Okutulduğu Sınıflar", ImGuiTableColumnFlags_WidthStretch, 0.33f);
ImGui::TableHeadersRow();
ImGui::TableNextRow();
// Öğretmenler Sütunu
ImGui::TableSetColumnIndex(0);
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
ImGui::BeginChild("##OgretmenlerChild", ImVec2(0, 320), true);
if (ImGui::BeginTable("##Öğretmenler", 4, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg)) {
ImGui::TableSetupColumn("No", ImGuiTableColumnFlags_WidthFixed, 20.0f);
ImGui::TableSetupColumn("Adı Soyadı", ImGuiTableColumnFlags_WidthFixed, 85.0f);
ImGui::TableSetupColumn("Branşı", ImGuiTableColumnFlags_WidthFixed,100.0f);
ImGui::TableSetupColumn("Toplam", ImGuiTableColumnFlags_WidthFixed, 70.0f);
ImGui::TableHeadersRow();
for (int i = 0; i < ogretmenlerListesi.size(); ++i) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text("%d", i + 1);
ImGui::TableNextColumn();
if (ImGui::Selectable(ogretmenlerListesi[i].adSoyad.c_str(), selectedOgretmenIndex == i, ImGuiSelectableFlags_SpanAllColumns)) {
selectedOgretmenIndex = i;
}
ImGui::TableNextColumn();
ImGui::Text("%s", ogretmenlerListesi[i].bransi.c_str());
ImGui::TableNextColumn();
// Toplam HDS hesapla
int toplamHDS = 0;
for (const auto& okutulanDers : okutulanDerslerListesi) {
if (ogretmenlerListesi[i].bransi == okutulanDers.dersAdi) {
toplamHDS += okutulanDers.hds;
}
}
ImGui::Text("%d", toplamHDS);
}
ImGui::EndTable();
}
ImGui::EndChild();
ImGui::PopStyleColor();
// Öğretmenin Okuttuğu Dersler Tablosu
if (selectedOgretmenIndex >= 0 && selectedOgretmenIndex < ogretmenlerListesi.size()) {
ImGui::BeginChild("##OgretmenDersleriChild", ImVec2(0, 320), true);
if (ImGui::BeginTable("##OgretmenDersleri", 4, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg)) {
ImGui::TableSetupColumn("Sınıf", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("Dersin Adı", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("Kısa Adı", ImGuiTableColumnFlags_WidthFixed, 70.0f);
ImGui::TableSetupColumn("HDS", ImGuiTableColumnFlags_WidthFixed, 70.0f);
ImGui::TableHeadersRow();
for (const auto& okutulanDers : okutulanDerslerListesi) {
if (ogretmenlerListesi[selectedOgretmenIndex].bransi == okutulanDers.dersAdi) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text("%s", okutulanDers.sinif.c_str());
ImGui::TableNextColumn();
ImGui::Text("%s", okutulanDers.dersAdi.c_str());
ImGui::TableNextColumn();
// Dersin kısa adını bul
auto it = std::find_if(derslerListesi.begin(), derslerListesi.end(),
[&okutulanDers](const DersBilgisi& ders) { return ders.dersAdi == okutulanDers.dersAdi; });
if (it != derslerListesi.end()) {
ImGui::Text("%s", it->kisaAdi.c_str());
}
ImGui::TableNextColumn();
ImGui::Text("%d", okutulanDers.hds);
}
}
ImGui::EndTable();
}
ImGui::EndChild();
if (ImGui::Button("Öğretmen Derslerini Kaydet")) {
OgretmenlereDersExcelKaydet();
}
}
// Dersler Sütunu
ImGui::TableSetColumnIndex(1);
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
ImGui::BeginChild("##DerslerChild", ImVec2(0, 320), true);
if (ImGui::BeginTable("##Dersler", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg)) {
ImGui::TableSetupColumn("Ders Adı", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("Haftalık Ders Saati", ImGuiTableColumnFlags_WidthFixed, 100.0f);
ImGui::TableHeadersRow();
for (int i = 0; i < derslerListesi.size(); ++i) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
if (ImGui::Selectable(derslerListesi[i].dersAdi.c_str(), selectedDersIndex == i, ImGuiSelectableFlags_SpanAllColumns)) {
selectedDersIndex = i;
}
ImGui::TableNextColumn();
ImGui::Text("%d", derslerListesi[i].haftalikDersSaati);
}
ImGui::EndTable();
}
ImGui::EndChild();
ImGui::PopStyleColor();
// Dersin Okutulduğu Sınıflar Sütunu
ImGui::TableSetColumnIndex(2);
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
ImGui::BeginChild("##SiniflarChild", ImVec2(0, 320), true);
if (ImGui::BeginTable("##Sınıflar", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg)) {
ImGui::TableSetupColumn("Sınıf Adı", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("Öğretmen", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("Seç", ImGuiTableColumnFlags_WidthFixed, 50.0f);
ImGui::TableHeadersRow();
if (selectedDersIndex >= 0 && selectedDersIndex < derslerListesi.size()) {
const auto& secilenDers = derslerListesi[selectedDersIndex];
for (const auto& okutulanDers : okutulanDerslerListesi) {
if (okutulanDers.dersAdi == secilenDers.dersAdi) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text("%s", okutulanDers.sinif.c_str());
ImGui::TableNextColumn();
// Öğretmeni bul
auto it = std::find_if(ogretmenlerListesi.begin(), ogretmenlerListesi.end(),
[&okutulanDers](const OgretmenBilgisi& ogretmen) { return ogretmen.bransi == okutulanDers.dersAdi; });
if (it != ogretmenlerListesi.end()) {
ImGui::Text("%s", it->adSoyad.c_str());
}
ImGui::TableNextColumn();
bool isSelected = std::find(selectedSiniflarIndex.begin(), selectedSiniflarIndex.end(), &okutulanDers - &okutulanDerslerListesi[0]) != selectedSiniflarIndex.end();
if (ImGui::Checkbox(("##" + okutulanDers.sinif).c_str(), &isSelected)) {
if (isSelected) {
selectedSiniflarIndex.push_back(&okutulanDers - &okutulanDerslerListesi[0]);
}
else {
selectedSiniflarIndex.erase(std::remove(selectedSiniflarIndex.begin(), selectedSiniflarIndex.end(), &okutulanDers - &okutulanDerslerListesi[0]), selectedSiniflarIndex.end());
}
}
}
}
}
ImGui::EndTable();
}
ImGui::EndChild();
ImGui::PopStyleColor();
ImGui::EndTable();
}
ImGui::EndChild();
ImGui::PopStyleColor(3);
}