fhiiqm/alvtr_flist.php
changeset 21 97dba0fe820c
child 23 a382de56a8e4
equal deleted inserted replaced
20:5877137431e4 21:97dba0fe820c
       
     1 <?php
       
     2 
       
     3 /**
       
     4  * @author Bettina Schwarzer, Fritz-Haber-Institut
       
     5  * @copyright 12/2011
       
     6  * 
       
     7  * Liste Anlagen-Vertraege (sortieren, filtern)
       
     8  */
       
     9 
       
    10     error_reporting(E_ALL ^ E_NOTICE);
       
    11     
       
    12     session_start();
       
    13     if (! isset($_SESSION["userid"]))
       
    14     { 
       
    15         include_once ("inc/func_lib.inc.php");	
       
    16         login($_SERVER["PHP_SELF"]);
       
    17         exit;
       
    18     }
       
    19     
       
    20     if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("ar",$_SESSION["recht"]) && !in_array("ae",$_SESSION["recht"])))
       
    21     {
       
    22         header("Location: start.php");
       
    23         exit;
       
    24     }    
       
    25     
       
    26 ?>
       
    27 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
       
    28 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
       
    29 
       
    30 <head>
       
    31 	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
       
    32    	<link href="css/db.css" rel="STYLESHEET" type="TEXT/CSS" media="screen" /> 
       
    33    	<link href="css/db_print.css" rel="STYLESHEET" type="TEXT/CSS" media="print" /> 
       
    34 
       
    35 	<title>Liste Anlagen-Vertr&auml;ge</title>
       
    36 </head>
       
    37 
       
    38 <body onload="document.ffilter.filter.focus();">
       
    39     
       
    40 <?php
       
    41     echo "&nbsp;";  
       
    42     echo "<div class=\"float-br smaller\" valign='top'>";
       
    43     echo "&nbsp;&nbsp;&nbsp;user: " . $_SESSION["userid"];
       
    44     echo "&nbsp;&nbsp;&nbsp;<a class='sc' href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n";
       
    45     echo "<div class=\"float-r\"><img src=\"img/rotate_01.png\" border=\"0\" alt=\"Anlage\" title=\"Anlage\"/></div>\n";
       
    46 
       
    47     // Felder, nach denen gefiltert werden kann
       
    48     $fields = array(1=>"Anlage-ID",3=>"Anlage",4=>"Vertrag",5=>"Vertragtyp");
       
    49 
       
    50     $zeil = $_GET["z"];
       
    51     if (!$zeil) $zeil = $_POST["z"];
       
    52     if (!$zeil) $zeil = 25; // Anzahl der gezeigten Zeilen
       
    53     $start = $_GET["st"];
       
    54     if (!$start) $start=0;
       
    55     
       
    56 	$sort   = $_GET["s"];   // Sortierung nach Spalte
       
    57     if (!isset($sort) && !$sort) $sort = $_POST["s"];      
       
    58 
       
    59     $dir    = $_GET["d"];   // Sortierrichtung
       
    60     if (!isset($dir) && !$dir) $dir = $_POST["d"];
       
    61 
       
    62     $fnum   = $_GET["f"];   // Spaltennummer, nach der aktuell gefiltert wird
       
    63     if (!isset($fnum) && !$fnum) $fnum = $_POST["f"];
       
    64 
       
    65     $filter = $_POST["filter"];
       
    66     if (!isset($filter) && !$filter) $filter = $_GET["b"];   
       
    67 
       
    68     $subf   = $_POST["subf"]; // submit
       
    69     
       
    70     if (!isset($fnum) && !$fnum) $fnum = 1;
       
    71     if (!isset($filter) && !$filter) $filter = "";
       
    72     if (!isset($sort) && !$sort) $sort = 2;
       
    73     if (!isset($dir) && !$dir)  $dir = "";
       
    74 
       
    75     include ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
       
    76 	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
       
    77 	$dbc = new dbconnection();
       
    78 
       
    79     $sql = "CALL alvtr_flist($sort,'" . $dir . "',$fnum, '" . $filter . "',$start,$zeil,@anz);"; 
       
    80     // Parameter: Nr. Sortfeld, Sortierrichtung, Nr. Filterfeld, Filterbegriff, Anzahl gefundener Anlagen
       
    81     // liefert: al_ID,contract_ID,al_bez,contract_name,vtyp_kurz,contract_begin,contract_end,verl,doc
       
    82 //    echo "sql = $sql<br />";  
       
    83     $result = $dbc ->queryObjectArray($sql);
       
    84 
       
    85     if ($result)
       
    86     {
       
    87 		$bg1 = "#F8F8F8";
       
    88 		$bg2 = "#DEDFE1";
       
    89 		$bg = "#FFFFFF";
       
    90      
       
    91         echo "<div align='center'>\n";
       
    92         echo "<p><b>Liste Vertr&auml;ge zu Anlagen</b></p>\n";
       
    93         
       
    94         echo "<table border='0' cellspacing='0'>\n";
       
    95         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' />' 
       
    96             können Sie nach relevanten Spalten auf- bzw. absteigend sortieren</td></tr>
       
    97             <tr><td class='bigger'>'<img src='/fhiiqm/img/filter.gif' border='0' width='14' hight='11' />' erm&ouml;glicht das Filtern nach ausgew&auml;hlten Spalten der Liste</td></tr>
       
    98             <tr><td class='bigger'>Klick auf '<img src='/fhiiqm/img/edit.gif' border='0' width='11' hight='11'>' - Bearbeiten Anlage-Vertrag</td>
       
    99             </tr>\n";
       
   100         echo "</table>\n";
       
   101 
       
   102         $panz = $dbc -> querySingleItem("SELECT @anz");
       
   103         printf ("<p>Anzahl Zuordnungen Anlage-Vertrag: %s</p>", $panz);
       
   104         
       
   105         if (isset($fnum) && $fnum>1 && !$filter && !$subf)
       
   106         {
       
   107             // Formular anzeigen fuer Filterbegriff
       
   108             $text = $fields[$fnum];
       
   109             echo "<form action=" . $_SERVER['PHP_SELF'] . " method='post' enctype='application/x-www-form-urlencoded' id='ffilter' name='ffilter' target='_self'>\n";
       
   110             echo "<input type='hidden' name='s' value='$sort'>";
       
   111             echo "<input type='hidden' name='d' value='$dir'>";
       
   112             echo "<input type='hidden' name='f' value='$fnum'>";
       
   113             echo "<table width=\"25%\" border=\"0\">\n";
       
   114             echo "<tr><td>filtern nach $text: </td>";
       
   115             echo "<td><input id='filter' name='filter' type=\"text\" size=\"10\" maxlength=\"30\" value=\"$filter\"/></td>";
       
   116             
       
   117             echo "<td><input class=\"button\" type=\"submit\" value=\"finden\" name=\"subf\" title=\"subf\" /></td></tr></table>\n";
       
   118             echo "</form>\n";
       
   119             echo "<p>&nbsp;&nbsp;&nbsp;</p>\n";
       
   120         }
       
   121         echo "<table width='70%'>\n";
       
   122         
       
   123         if ($filter>'!') echo "<tr><td class='bigger' colspan=6>Filter: ". $fields["$fnum"] . " wie '$filter'</td><tr>\n";
       
   124 
       
   125         // Listenkopf generieren
       
   126         echo "<tr bgcolor='#68ACBF'>";
       
   127         tab_column(3,"Anlage",$sort,$dir,3,$fnum,$filter,$start,$zeil);
       
   128         tab_column(4,"Vertrag",$sort,$dir,4,$fnum,$filter,$start,$zeil);
       
   129         tab_column(5,"Vertragtyp",$sort,$dir,5,$fnum,$filter,$start,$zeil);
       
   130         tab_column(6,"VBeginn",$sort,$dir,0,$fnum,$filter,$start,$zeil);
       
   131         tab_column(7,"VEnde",$sort,$dir,0,$fnum,$filter,$start,$zeil);
       
   132         echo "<th>VVerl&auml;ng.</th>";
       
   133         echo "<th>VDokument</th>";
       
   134 
       
   135         echo "<th>&nbsp;</th></tr>\n";
       
   136         
       
   137         foreach ($result as $row)
       
   138         {
       
   139 			if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
       
   140             echo "<tr bgcolor='" . $bg . "'><td>$row->al_bez</td>";
       
   141             echo "<td>" .nl2br($row->contract_name)."</td>";    
       
   142             echo "<td>$row->vtyp_kurz</td>";
       
   143             if ($row->contract_begin)
       
   144             {
       
   145                 $cb = new DateTime($row->contract_begin);    
       
   146                 echo "<td>". $cb->format('d.m.Y')."</td>";
       
   147             }
       
   148             else  echo "<td>&nbsp;</td>";       
       
   149             if ($row->contract_end)
       
   150             {
       
   151                 $ce = new DateTime($row->contract_end);
       
   152                 echo "<td>".$ce->format('d.m.Y')."</td>";
       
   153             }    
       
   154             else  echo "<td>&nbsp;</td>";
       
   155             echo "<td>$row->verl</td>";       
       
   156             if (file_exists("documents/".$row->doc))
       
   157             {
       
   158                 $doc = substr($row->doc,strpos($row->doc,"_")+1); 
       
   159                 echo "<td><a href='documents/$row->doc'>$doc</a></td>";
       
   160             }    
       
   161             else    
       
   162                 echo "<td>$row->doc</td>";
       
   163 
       
   164             $alcid = $row->al_ID."_".$row->contract_ID;
       
   165             echo "<td><a href='/fhiiqm/alvtr_ed.php?i=$alcid'><img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td></tr>\n";
       
   166         }
       
   167         echo "</table></div>\n";
       
   168 
       
   169         echo "<br />&nbsp;&nbsp;&nbsp;";
       
   170         
       
   171         // Sortierung und Filter aus $_GET fuer weitere Seiten
       
   172         foreach ($_GET as $key=>$val)
       
   173         {
       
   174             if ($key != "st") $liste .= "&" . $key ."=".$val;
       
   175         }    
       
   176         // Sortierung und Filter aus $_POST fuer weitere Seiten
       
   177         if ($subf)
       
   178         foreach ($_POST as $key=>$val)
       
   179         {
       
   180             if ($key != "st" && $key != "subf" && $key != "filter") $liste .= "&" . $key ."=".$val;
       
   181             if ($key == "filter") $liste .= "&b=" . $val;
       
   182         }    
       
   183         
       
   184         // Links auf andere Seiten generieren
       
   185         liste_links($start,$zeil,$panz,$liste);
       
   186 
       
   187     }
       
   188     else
       
   189     {
       
   190         if ($dbc -> error)  
       
   191             echo "error: " . $dbc -> error . "<br />\n";
       
   192         else
       
   193         {
       
   194             echo "<p class='red'>&nbsp;&nbsp;&nbsp;Leider nichts gefunden f&uuml;r ". $fields["$fnum"] . " wie '$filter'!</p><br />";
       
   195             echo "&nbsp;&nbsp;&nbsp;<a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"Anlagen-Vertr&auml;ge\" class=\"sc\">Liste Anlagen-Vertr&auml;ge</a></p>\n";
       
   196         }
       
   197         
       
   198     }
       
   199     $dbc -> close();
       
   200     if (!is_null($_SESSION["recht"]) && in_array("ae",$_SESSION["recht"]))
       
   201         echo "<p>&nbsp;&nbsp;&nbsp;<a href=\"/fhiiqm/anlage_ed.php\" target=\"_self\" title=\"Anlage-Vertrag erfassen\" class=\"sc\">Vertrag zu Anlage erfassen</a></p>\n";    
       
   202     echo "<p>&nbsp;&nbsp;&nbsp;<a href=\"/fhiiqm/anlage_flist.php\" target=\"_self\" title=\"Anlagenliste\" class=\"sc\">Anlagenliste</a>";    
       
   203     echo "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href=\"/fhiiqm/vertrag_flist1.php\" target=\"_self\" title=\"Vertragsliste\" class=\"sc\">Vertragsliste</a></p>\n";    
       
   204 
       
   205 ?>
       
   206 </body>