tplExtrSection(tplLoadFile("pgs/dienstplaene/main.html"), "DIENSTPLAENE"), "plans" => "", "add" => "", "list" => "" ); addStyle("pgs/dienstplaene/main.css"); if ($userID = lgnCheckLogin($mysqli)) { // Lesezeichen zeigen $tpl["plans"] = tplExtrSection($tpl["main"], "###DIENSTPLAENE.PLANS###"); // Dienstpläne abrufen $res = $mysqli->query("SELECT d.*, a.Kürzel FROM Dienstpläne d LEFT JOIN Abteilungen a ON a.ID=d.Abteilung ORDER BY d.Jahr DESC, d.Name DESC, a.ID ASC"); $dp_select_tpl = tplExtrSection($tpl["plans"], "###DIENSTPLAENE.PLANS.PLAN###"); $dp_select = ""; while ($row = $res->fetch_assoc()) { $repl = array( "###DIENSTPLAENE.PLANS.PLAN.NAME###" => $row["Kürzel"].": ".$row["Jahr"]." - ".$row["Name"], "###DIENSTPLAENE.PLANS.PLAN.LINK###" => "#dienstplan_".$row["ID"] ); $dp_select.= tplReplMarkerArray($dp_select_tpl, $repl); } $tpl["plans"] = tplReplSection($tpl["plans"], "###DIENSTPLAENE.PLANS.PLAN###", $dp_select); // Dienstplan hinzufügen $res = $mysqli->query("SELECT * FROM Abteilungen"); $dp_addtp_tpl = tplExtrSection($tpl["plans"], "###DIENSTPLAENE.PLANS.ADD###"); $dp_addtp_select = ""; while ($row = $res->fetch_assoc()) { $repl = array( "###DIENSTPLAENE.PLANS.ADD.ABTEILUNG.ID###" => $row["ID"], "###DIENSTPLAENE.PLANS.ADD.ABTEILUNG.NAME###" => $row["Name"] ); $dp_addtp_select.= tplReplMarkerArray($dp_addtp_tpl, $repl); } $tpl["plans"] = tplReplSection($tpl["plans"], "###DIENSTPLAENE.PLANS.ADD###", $dp_addtp_select); // Termin(e) hinzufügen $tpl["add"] = tplExtrSection($tpl["main"], "###DIENSTPLAENE.ADD###"); // Termine auflisten und Anmeldestatus anzeigen $tpl["list"] = tplExtrSection($tpl["main"], "###DIENSTPLAENE.LIST###"); $dp_block_tpl = tplExtrSection($tpl["list"], "###DIENSTPLAENE.LIST.BLOCK###"); $dp_entry_tpl = tplExtrSection($dp_block_tpl, "###DIENSTPLAENE.LIST.ENTRY###"); $qry = "SELECT t.ID, t.Beginn, t.Ende, t.Thema, t.Ort, d.ID dID, d.Jahr, d.Name dName, " ."a.Name aName, ta.Name taName, b.Name bName, tpv.Name tpvName, pg.Name pgName, " ."GROUP_CONCAT(CONCAT(LEFT(p.Vornamen, 1), '. ', p.Nachnamen) SEPARATOR ', ') Verantwortliche " ."FROM Termine t " ."LEFT JOIN Dienstpläne d ON d.ID = t.Dienstplan " ."LEFT JOIN Abteilungen a ON a.ID = d.Abteilung " ."LEFT JOIN Terminarten ta ON ta.ID = t.Terminart " ."LEFT JOIN Berechtigungen b ON b.ID = ta.Verwaltungsrecht " ."LEFT JOIN Terminplatzvergabe tpv ON tpv.ID = t.Platzvergabe " ."LEFT JOIN Personalgruppen pg ON pg.ID = t.Personalgruppe " ."LEFT JOIN Terminteilnahmen tln ON tln.Termin = t.ID AND tln.Status >= 2 " ."LEFT JOIN Personal p ON p.ID = tln.Personal " ."GROUP BY t.ID " ."ORDER BY d.Jahr DESC, d.Abteilung ASC, d.Name DESC, t.Beginn ASC "; $res = $mysqli->query($qry); $lastdID = null; $dienstplaene = array(); $entries = array(); $current = null; while ($row = $res->fetch_assoc()) { if ($row["dID"]!=$lastdID) { $repl = array( "###DIENSTPLAENE.LIST.BLOCK.DID###" => $row["dID"], "###DIENSTPLAENE.LIST.BLOCK.ANAME###" => $row["aName"], "###DIENSTPLAENE.LIST.BLOCK.DJAHR###" => $row["Jahr"], "###DIENSTPLAENE.LIST.BLOCK.DNAME###" => $row["dName"] ); $current = &$dienstplaene[]; $current = array( "tpl" => tplReplMarkerArray($dp_block_tpl, $repl), "entries" => array() ); $lastdID = $row["dID"]; } $repl = array( "###DIENSTPLAENE.LIST.ENTRY.ID###" => $row["ID"], "###DIENSTPLAENE.LIST.ENTRY.BEGIN###" => $row["Beginn"], "###DIENSTPLAENE.LIST.ENTRY.BEGIN.DATE###" => strftime("%a, %d.%m.%Y", strtotime($row["Beginn"])), "###DIENSTPLAENE.LIST.ENTRY.BEGIN.TIME###" => strftime("%H:%M", strtotime($row["Beginn"])), "###DIENSTPLAENE.LIST.ENTRY.END###" => $row["Ende"], "###DIENSTPLAENE.LIST.ENTRY.END.DATE###" => strftime("%a, %d.%m.%Y", strtotime($row["Ende"])), "###DIENSTPLAENE.LIST.ENTRY.END.TIME###" => strftime("%H:%M", strtotime($row["Ende"])), "###DIENSTPLAENE.LIST.ENTRY.TOPIC###" => $row["Thema"], "###DIENSTPLAENE.LIST.ENTRY.PLACE###" => $row["Ort"], "###DIENSTPLAENE.LIST.ENTRY.TYPE###" => $row["taName"], "###DIENSTPLAENE.LIST.ENTRY.TPVNAME###" => $row["tpvName"], "###DIENSTPLAENE.LIST.ENTRY.PGNAME###" => $row["pgName"], "###DIENSTPLAENE.LIST.ENTRY.RESPONSIBLES###" => $row["Verantwortliche"] ); $current["entries"][] = tplReplMarkerArray($dp_entry_tpl, $repl); } $list = ""; foreach ($dienstplaene as $dp) { $list.= tplReplSection($dp["tpl"], "###DIENSTPLAENE.LIST.ENTRY###", implode("", $dp["entries"])); } $tpl["list"] = tplReplSection($tpl["list"], "###DIENSTPLAENE.LIST.BLOCK###", $list); } // Template füllen $tpl["main"] = tplReplSection($tpl["main"], "###DIENSTPLAENE.PLANS###", $tpl["plans"]); $tpl["main"] = tplReplSection($tpl["main"], "###DIENSTPLAENE.LIST###", $tpl["list"]); $tpl["main"] = tplReplSection($tpl["main"], "###DIENSTPLAENE.LIST###", $tpl["list"]); $tpl["main"] = tplReplSection($tpl["main"], "###DIENSTPLAENE.ADD###", $tpl["add"]); $output["main"] = $tpl["main"]; ?>