<!DOCTYPE HTML>
<html lang="la">
<head>
	<title>Index generalis Societatis Latinae – Index fasciculi</title>
	<meta name="author" content="Bernd Platzdasch"><!-- 1.10.2020 -->
	<meta charset="UTF-8">
	<link rel="stylesheet" type="text/css" href="css/main.css">
	<script src="js/store.js" type="text/javascript"></script>
	<style type="text/css">
		table { border-top: 1px solid lightgrey; border-collapse: collapse; margin-top: 0.5em; width: 100%; clear: both; }
		td { text-align: left; border-bottom: 1px solid lightgray; padding: 0.6em; }
		td.zaehler { text-align: right; vertical-align: top; color: gray; }
		td.stelle { vertical-align: middle; }
		h1#ix { padding: 29px 0 2em 0; float: left; }
		a.nav {border: 1px solid lightgrey; padding: 0 0.3em 0 0.3em;}
		a.nav:hover { text-decoration: none; background-color: gray; color: #fff; }
		span#erg { color: gray; font-weight: normal; }
		span.pointer { cursor: pointer; }
		div.vor_zur { text-align: right; margin: 29px 0 0 0; float: right; width: 200px; color: darkgray; }
		p#sursum { text-align: right; padding-top: 1.5em; clear: both; font-weight: bold; }
		p.tipp { font-size: smaller; color: gray; }
	</style>
</head>
<body onload="store_mnu();">
<?php
// Debugging:
// error_reporting(E_ALL);
// ini_set('display_errors', true);
	include("header.inc.php");	
	include("php/namen.inc.php");
	require_once $_SERVER['DOCUMENT_ROOT'] . '/db_connection.php';
?>
<div class="border">
	<div id="main">
		<?php
		
		// Fask.-Nr. einlesen
			$fasc = $_GET["f"];
			if (!strpos($fasc, ".")) {$fasc = $fasc . ".0";}
		// DB lesen
			$sql_select = "SELECT * FROM societaslatina WHERE Faszikel LIKE $fasc ORDER BY Objektzaehler";
			$sql_result = $db->query($sql_select);
		
		// Erg. Faszikelbeschreibung
			$erg = $sql_result->fetch_object();
			$annus = $erg->Jahr;
			$monat = $erg->Monat;
			$band = $erg->Band;
			$bandteil = $erg->Bandteil;
			$sql_result->data_seek(0);
		// Navigation definieren
			$arr_f = array();
			for ($x = 0; $x <= 48; $x++) {
				$arr_f[$x] = $x;
			}
			$pos = array_search($fasc, $arr_f);
			$zurueck = $arr_f[$pos-1];
			$vor = $arr_f[$pos+1];
			if (($fasc > 1) && ($fasc < 48)) {
				$navigation =	"<div class='vor_zur'>
									<a class='nav' href='contenta.php?f=$zurueck'>&#160;&#160;◄&#160;&#160;</a>&thinsp;<a class='nav' href='idx_fas.php'>&#160;Index&#160;</a>&thinsp;<a class='nav' href='contenta.php?f=$vor'>&#160;&#160;►&#160;&#160;</a>
								</div>";
			} else if ($fasc == 1) {
				$navigation = 	"<div class='vor_zur'>
									<a class='nav' href='idx_fas.php'>&#160;Index&#160;</a>&thinsp;<a class='nav' href='contenta.php?f=$vor'>&#160;&#160;►&#160;&#160;</a>
								</div>";
			} else {
				$navigation =	"<div class='vor_zur'>
									<a class='nav' href='contenta.php?f=$zurueck'>&#160;&#160;◄ &#160;&#160;</a>&thinsp;<a class='nav' href='idx_fas.php'>&#160;Index&#160;</a>
								</div>";
			}
			
		// Überschrift u. Navigation oben anzeigen
			if($fasc == "38") {$fasc = "38";$bandteil="2/3";}
			if($fasc == "43") {$fasc = "43";$bandteil="1/2";}
			$bdbt = "a. " . $band . ", " .$monat . " ". $annus . ", f. " . $bandteil;
			if ($bandteil == 0) {
				$bdbt = "a. " . $band . ", " . $annus;
			}
			$ueberschrift = "<h1 id='ix'>Index fasciculi: $bdbt</h1>";
			echo $ueberschrift . $navigation;
			$zaehler = 0;
			echo "<table>";
		// Ausgabeschleife
			while ($row = $sql_result->fetch_object()) {
				$zaehler++;
				$titel = $bis = $seite = $ort = $ort_ganz = $empfaenger = $empfaenger_ganz = $textgattung = $uebersetzung = $autor = $autor_ganz = $briefdatum = "";
				//
				$sql_select = "SELECT * FROM societaslatina_namen WHERE NameID = $row->AutorID";
				$sql_result_a = $db->query($sql_select);
				$rowAutor = $sql_result_a->fetch_object();
				//
				$sql_select = "SELECT * FROM societaslatina_namen WHERE NameID = $row->BriefempfaengerID";
				$sql_result_b = $db->query($sql_select);
				$rowBriefempfaenger = $sql_result_b->fetch_object();
				//
				$sql_select = "SELECT * FROM societaslatina_namen WHERE NameID = $row->OriginalautorID";
				$sql_result_o = $db->query($sql_select);
				$rowOriginalautor = $sql_result_o->fetch_object();
				//
				if (!empty($row->Titel)) {
					$titel = $row->Titel;
					$titel = "<span style='color: #333; font-weight: bold;'>" . $titel . "<br></span>";
				}
				if (!empty($row->Bis)) {
					$bis = $row->Bis;
					$bis = "-" . $bis;
				}
				if (!empty($row->Seite)) {
					$seite = $row->Seite;
				}
				if (!empty($rowBriefempfaenger->Name)) {
					$empfaenger_ganz = $rowBriefempfaenger->Name;
					$empfaenger = erster_name($empfaenger_ganz);
					$empfaenger = vorname_nachname($empfaenger);
					$empfaenger_ganz = alle_namen($empfaenger, $rowBriefempfaenger->Name);
				}
				if (!empty($row->Briefdatum)) {
					$briefdatum = str_replace("00.", "", $row->Briefdatum);
					$briefdatum = ", " . $briefdatum;
				}
				if (!empty($row->Textgattung)) {
					$textgattung = "[" . $row->Textgattung . "]";
				}
				if (!empty($row->Ort)) {
					$ort_ganz = $row->Ort;
					$ort = erster_name($row->Ort);
					$ort = ": ". $ort;
				}
				if ($row->Uebersetzung == "1") {
					if (!empty($rowOriginalautor->Name)) {
							$originalautor_ganz = $rowOriginalautor->Name;
							$originalautor = erster_name ($originalautor_ganz);
							$originalautor = vorname_nachname($originalautor);
							$originalautor_ganz = alle_namen($originalautor, $rowOriginalautor->Name);
					}
					if (!empty($rowOriginalautor->Name)) {
							$uebersetzung = " [Versio: " . "<span class='pointer' title='$originalautor_ganz'>" . $originalautor ." </span>]";
					}
					if ((!empty($rowOriginalautor->Name)) && (!empty($row->Originaltitel))) {
							$uebersetzung = " [Versio: " . "<span class='pointer' title='$originalautor_ganz'>" . $originalautor . "</span>: «" . $row->Originaltitel . "»]";
					}
					if ((empty($rowOriginalautor->Name)) && (!empty($row->Originaltitel))) {
								$uebersetzung = " [Versio: «" . $row->Originaltitel . "»]";
					}
				}
				if (!empty($rowAutor->Name)) {
					$autor_ganz = $rowAutor->Name;
					$autor = erster_name($autor_ganz);
					$autor = vorname_nachname($autor);
					$autor_ganz = alle_namen($autor, $rowAutor->Name);
					if ($empfaenger != "") {
						$autor = $autor . " &rarr; <span class='pointer' title='" . $empfaenger_ganz . "'>" . $empfaenger . "</span><br>";
					} else {
						$autor = $autor .":<br>";
					}
				}
				echo "<tr>
						<td class='zaehler'>" . $zaehler . ".</td>
						<td><span class='pointer' title='". $autor_ganz ." '>". $autor ."</span>" . $titel . $textgattung . $uebersetzung . "</td>	
						<td class='stelle'><span style='white-space: nowrap'>" . $seite . $bis . "</a></span></td>
					</tr>";
		// Ende Ausgabeschleife
			}
			echo "</table>";
			$db->close();
		// Navigation unten anzeigen
			echo $navigation;
		?>
		<p id="sursum"><a href="javascript: window.scrollTo(0, 0);">sursum</a></p>
		<p class="tipp">Si nomen auctoris indice muris tangis, omnia nomina eidem imposita offeruntur.</p>
	</div>
</div>
<?php include("footer.inc.php");?>
</body>
</html>
