<?php
/**
* @author Bettina Schwarzer, Fritz-Haber-Institut
* @copyright 08/2012
*
* Liste Infos
*/
error_reporting(E_ALL ^ E_NOTICE);
header('Content-type: text/html; charset="iso-8859-1',true);
session_start();
if (! isset($_SESSION["userid"]))
{
include_once ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
login($_SERVER["PHP_SELF"]);
exit;
}
if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("ir",$_SESSION["recht"]) && !in_array("ie",$_SESSION["recht"])))
{
header("Location: start.php");
exit;
}
echo " ";
echo "<div class=\"float-br smaller\" valign='top'>";
echo " user: " . $_SESSION["userid"];
echo " <a class='sc' href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n";
echo "<div class=\"float-r\"><img src=\"/fhiiqm/img/document_image_ver.png\" border=\"0\" alt=\"Infodaten\" title=\"Infodaten\"/></div>\n";
// Felder, nach denen gefiltert werden kann
$fields = array(2=>"Titel",4=>"Info-Typ",5=>"Produkt",6=>"Adressat", 7=>"Verantwortlicher");
$zeil = $_GET["z"];
if (!$zeil) $zeil = $_POST["z"];
if (!$zeil) $zeil = 9999; // Anzahl der gezeigten Zeilen
$start = $_GET["st"]; // Start bei DS $start+1
if (!$start) $start=0;
$sort = $_GET["s"]; // Sortierung nach Spalte
if (!isset($sort) && !$sort) $sort = $_POST["s"];
$dir = $_GET["d"]; // Sortierrichtung
if (!isset($dir) && !$dir) $dir = $_POST["d"];
$fnum = $_GET["f"]; // Spaltennummer, nach der aktuell gefiltert wird
if (!isset($fnum) && !$fnum) $fnum = $_POST["f"];
$filter = $_POST["filter"];
if (!isset($filter) && !$filter) $filter = $_GET["b"];
$subf = $_POST["subf"]; // submit
if (!isset($fnum) || !$fnum) $fnum = 1;
if (!isset($filter) || !$filter) $filter = "";
if (!isset($sort) || !$sort) $sort = 15; // Kennzeichen
if (!$dir || $dir < "!") $dir = "";
// print_r ($_GET); echo "<br /><br />";
include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
include_once ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
$dbc = new dbconnection();
$sql = "CALL info_flist($sort,'" . $dir . "',$fnum, '" . $filter . "',$start,$zeil,@anz);";
// Parameter: Nr. Sortfeld, Sortierrichtung, Nr. Filterfeld, Filterbegriff, (StartNr DS) -1, Anzahl Zeilen=DS, Anzahl gefundener Raeume
// liefert: info_ID, iname, ilong, ityp, prod, adressat, author, idate, bdate, edate, lang, doc, infrel, infsort, ityp_ID, raum_ID, geb_ID, al_bez
// echo "sql = $sql<br />";
$result = $dbc ->queryObjectArray($sql);
if ($result)
{
$bg1 = "#F8F8F8";
$bg2 = "#DEDFE1";
$bg = "#FFFFFF";
echo "<div align='center'>\n";
echo "<p><b>Liste der Informationen</b></p>\n";
/*
echo "<table border='0' cellspacing='0'>\n";
echo "<tr><td class='bigger'>Mittels '<img src='/fhiiqm/img/auf.gif' border='0' width='11' hight='11' />' / '<img src='/fhiiqm/img/ab.gif' border='0' width='11' hight='11' />'
können Sie nach bestimmten Spalten auf- bzw. absteigend sortieren</td></tr>
<tr><td class='bigger'>'<img src='/fhiiqm/img/filter.gif' border='0' width='14' hight='11' />' ermöglicht das Filtern nach ausgewählten Spalten der Liste</td></tr>
<tr><td class='bigger'>Klick auf '<img src='/fhiiqm/img/edit.gif' border='0' width='11' hight='11'>' - Bearbeiten ,
'<img src='/fhiiqm/img/duplicate.gif' border='0' hight='11'>' - Duplizieren der Infodaten
</td></tr>\n";
echo "</table>\n";
*/
$ianz = $dbc -> querySingleItem("SELECT @anz");
printf ("<p>Anzahl gefundener Informationen: %s</p>", $ianz);
if (isset($fnum) && $fnum>1 && !$filter && !$subf)
{
// Formular anzeigen fuer Filterbegriff
$text = $fields[$fnum];
$azeil = array(10=>'10',20=>'20',25=>'25',50=>'50',100=>'100',9999=>'alle'); // Anzahl gezeigter rows
echo "<form action='" . $_SERVER['PHP_SELF'] . "#tab_2' method='post' enctype='application/x-www-form-urlencoded' id='ffilter' name='ffilter' target='_self'>\n";
echo "<input type='hidden' name='s' value='$sort'>";
echo "<input type='hidden' name='d' value='$dir'>";
echo "<input type='hidden' name='f' value='$fnum'>";
echo "<table width=\"45%\" border=\"0\">\n";
echo "<tr><td>filtern nach $text: </td>";
echo "<td><input id='filter' name='filter' type=\"text\" size=\"30\" maxlength=\"30\" value=\"$filter\"/></td>";
echo "<td>Zeilen/Seite? <select name='z'>\n";
foreach ($azeil as $key=>$val)
{
if ($key == $zeil) $select = "selected"; else $select = "";
echo "<option $select value='$key'>$val</option>\n";
}
echo "</select></td>\n";
echo "<td><input class=\"button\" type=\"submit\" value=\"finden\" name=\"subf\" title=\"subf\" /></td></tr></table>\n";
echo "</form>\n";
echo "<p> </p>\n";
}
echo "<table width='99%'>\n";
if ($filter>'!') echo "<tr><td class='bigger' colspan=6>Filter: ". $fields["$fnum"] . " wie '$filter'</td><tr>\n";
// Listenkopf generieren
echo "<tr bgcolor='#68ACBF'>";
echo "<th>ID</th>";
echo "<th>Kz</th>";
echo "<th>Titel</th>";
echo "<th>Kurzinfo</th>";
echo "<th>Info-Typ</th>";
echo "<th>Produkt</th>";
echo "<th>Adressat</th>";
echo "<th>Verantw.</th>";
echo "<th>Ort</th>";
echo "<th>Autor</th>";
echo "<th>erst. am</th>";
echo "<th>gilt ab</th>";
echo "<th>gilt bis</th>";
echo "<th>Status</th>";
/* tab_column(15,"Kz",$sort,$dir,0,$fnum,$filter,$start,$zeil,"",0,"#ui-tabs-1","tabs_dyn_content.php");
tab_column(2,"Titel",$sort,$dir,0,$fnum,$filter,$start,$zeil,"",0,"#ui-tabs-1","tabs_dyn_content.php");
tab_column(3,"Kurzinfo",$sort,$dir,0,$fnum,$filter,$start,$zeil,"",0,"#ui-tabs-1","tabs_dyn_content.php");
tab_column(4,"Info-Typ",$sort,$dir,0,$fnum,$filter,$start,$zeil,"",0,"#ui-tabs-1","tabs_dyn_content.php");
tab_column(5,"Produkt",$sort,$dir,0,$fnum,$filter,$start,$zeil,"",0,"#ui-tabs-1","tabs_dyn_content.php");
tab_column(6,"Adressat",$sort,$dir,0,$fnum,$filter,$start,$zeil,"",0,"#ui-tabs-1","tabs_dyn_content.php");
tab_column(7,"Verantw.",$sort,$dir,0,$fnum,$filter,$start,$zeil,"",0,"#ui-tabs-1","tabs_dyn_content.php");
echo "<th>Ort</th>";
tab_column(8,"Autor",$sort,$dir,0,$fnum,$filter,$start,$zeil,"",0,"#ui-tabs-1","tabs_dyn_content.php");
tab_column(9,"erst. am",$sort,$dir,0,$fnum,$filter,$start,$zeil,"",0,"#ui-tabs-1","tabs_dyn_content.php");
tab_column(10,"gilt ab",$sort,$dir,0,$fnum,$filter,$start,$zeil,"",0,"#ui-tabs-1","tabs_dyn_content.php");
tab_column(11,"gilt bis",$sort,$dir,0,$fnum,$filter,$start,$zeil,"",0,"#ui-tabs-1","tabs_dyn_content.php");
*/
// echo "<th>Sprache</th>";
// tab_column(12,"Status",$sort,$dir,0,$fnum,$filter,$start,$zeil,"",0,"#ui-tabs-1","tabs_dyn_content.php");
echo "<th>Dokument</th>";
echo "<th>zu ID</th>";
echo "<th> </th></tr>\n";
// echo "<tr bgcolor='#68ACBF'><th>Raum-Nr.</th><th>Bezeichnung</th><th>Haus</th><th>Typ</th><th>Fläche (m<sup>2</sup>)</th><th>Raumplan</th><th> </th>
// </tr>\n";
// Format $row->prod: 'prod_name | prod_hier; prod_name | prod_hier; prod_name | prod_hier'
foreach ($result as $row)
{
if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
echo "<tr bgcolor='" . $bg . "'><td class=\"left\">$row->info_ID</td>";
echo "<td class=\"left\">$row->infsort</td>";
echo "<td class=\"left\">$row->iname</td>";
// if (strlen($row->ilong)>60) $row->ilong = substr($row->ilong,0,60)."...";
if ($row->ityp_ID == 81) $anl = " <b>→ '" . $row->al_bez . "'</b>"; else $anl="";
echo "<td class=\"left\">" . nl2br($row->ilong).$anl . "</td>";
echo "<td class=\"left\">$row->ityp</td>";
$prod = explode("; ",$row->prod);
$prods = "";
foreach ($prod as $val)
$prods .= "; " . substr($val,0,strpos($val,"|")-1);
$prods = substr($prods,2);
// echo "<td class=\"left\">" . str_replace(";",";<br />",$row->prod) . "</td>";
echo "<td class=\"left\">" . str_replace(";",";<br />",$prods) . "</td>";
echo "<td class=\"left\">" . str_replace(";","<br />",$row->adressat) . "</td>";
echo "<td class=\"left\">" . str_replace(";","<br />",$row->verantw);
if (isset($row->betrag) && $row->betrag)
echo "<br><i> max. Bestellwert: ".number_format($row->betrag,2,",",".")." €</i>";
echo "</td>";
if ($row->ityp_ID == 7 || substr($row->ityp_ID,0,1) == 8) // 7 = Betriebsstörung, 8 = Betriebsanweisung
{ if ($row->raum_ID)
{
$sql = "SELECT geb_ID, raum_nr FROM Raum WHERE raum_ID = $row->raum_ID";
$res = $dbc -> queryObjectArray($sql);
foreach ($res as $ro)
echo "<td>$ro->geb_ID, $ro->raum_nr</td>";
}
elseif ($row->geb_ID && !$row->raum_ID)
echo "<td>$row->geb_ID</td>";
else echo "<td> </td>";
}
else echo "<td> </td>";
echo "<td class=\"left\">$row->author</td>";
if ($row->idate)
{
$dat = new DateTime($row->idate);
echo "<td class=\"left\">" . $dat->format('d.m.Y')."</td>";
}
else echo "<td> </td>";
if ($row->bdate)
{
$dat = new DateTime($row->bdate);
echo "<td class=\"left\">" . $dat->format('d.m.Y')."</td>";
}
else echo "<td> </td>";
if ($row->edate)
{
$dat = new DateTime($row->edate);
echo "<td class=\"left\">" . $dat->format('d.m.Y')."</td>";
}
else echo "<td> </td>";
// echo "<td class=\"left\">$row->lang</td>";
echo "<td class=\"left\">$row->freigabe</td>";
if (file_exists($_SERVER['DOCUMENT_ROOT']."/fhiiqm/infos/".$row->doc))
{
$doc = substr($row->doc,strpos($row->doc,"_")+1);
echo "<td class=\"left\"><a href=\"/fhiiqm/infos/$row->doc\">$doc</td>";
}
else
echo "<td class=\"left\">$row->doc</td>";
echo "<td class=\"left\">$row->infrel</td>";
$ref = "?i=$row->info_ID";
echo "<td><a href='$ref' class='info_edit'><img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td>";
echo "</tr>\n";
}
echo "</table></div>\n";
echo "<br /> ";
// Sortierung und Filter aus $_GET fuer weitere Seiten
foreach ($_GET as $key=>$val)
{
if ($key != "st") $liste .= "&" . $key ."=".$val;
}
// Sortierung und Filter aus $_POST fuer weitere Seiten
if ($subf)
foreach ($_POST as $key=>$val)
{
if ($key != "st" && $key != "subf" && $key != "filter") $liste .= "&" . $key ."=".$val;
if ($key == "filter") $liste .= "&b=" . $val;
}
// Links auf andere Seiten generieren
liste_links($start,$zeil,$ianz,$liste,"#ui-tabs-1");
}
else
{
if ($dbc -> error)
echo "error: " . $dbc -> error . "<br />\n";
else
{
echo "<p class='red'> Leider nichts gefunden für ". $fields["$fnum"] . " wie '$filter'!</p><br />";
echo " <a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"Infoliste\" class=\"sc\">Infoliste</a></p>\n";
}
}
$dbc -> close();
if (!is_null($_SESSION["recht"]) && in_array("ie",$_SESSION["recht"]))
echo "<p> <a href=\"info_ed.php\" target=\"_self\" title=\"Info erfassen\" class=\"sc\">Weitere Info erfassen</a></p>\n";
?>