fhiiqm/report/raum_info_as1_report.php
changeset 41 9c668cd391fa
equal deleted inserted replaced
40:6f4b105daa24 41:9c668cd391fa
       
     1 <?php
       
     2 
       
     3 /**
       
     4  * @author Bettina Schwarzer, Fritz-Haber-Institut
       
     5  * @copyright 10/2013
       
     6  *
       
     7  * Report Labor Info(portrait)
       
     8  * $_GET['s']=2 - Aufruf aus adm-fhi-Seite ohne Anmeldung
       
     9  * 
       
    10  */
       
    11 
       
    12     error_reporting(E_ALL ^ E_NOTICE);
       
    13     
       
    14     if (!isset($_GET['s']) || $_GET['s'] != 2 )
       
    15     {
       
    16         session_start();
       
    17         if (! isset($_SESSION["userid"]))
       
    18         { 
       
    19             include_once ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");	
       
    20             login($_SERVER["PHP_SELF"]);
       
    21             exit;
       
    22         }
       
    23         
       
    24         if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("ddr",$_SESSION["recht"]) && !in_array("dde",$_SESSION["recht"]) && 
       
    25             !in_array("rr",$_SESSION["recht"]) && !in_array("re",$_SESSION["recht"])))
       
    26         {
       
    27             header("Location: start.php");
       
    28             exit;
       
    29         }
       
    30     }        
       
    31 	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
       
    32 	if (!isset($dbc) || !$dbc) $dbc = new dbconnection();
       
    33     
       
    34 
       
    35 ?>
       
    36 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
       
    37 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
       
    38 
       
    39 <head>
       
    40 	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
       
    41    	<link href="/fhiiqm/css/db.css" rel="STYLESHEET" type="TEXT/CSS"  media="screen"/> 
       
    42    	<link href="/fhiiqm/css/db_print.css" rel="STYLESHEET" type="TEXT/CSS"  media="print"/> 
       
    43 	<title>Report Labor Info</title>
       
    44 </head>
       
    45 
       
    46 <body>
       
    47 <?php
       
    48     echo "&nbsp;";  
       
    49     if (!isset($_GET['s']) || $_GET['s'] != 2 )
       
    50     {
       
    51         echo "<div class=\"float-br smaller sc\" valign='top'>";
       
    52         echo "&nbsp;&nbsp;&nbsp;user: " . $_SESSION["userid"];
       
    53         echo "&nbsp;&nbsp;&nbsp;<a href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n";
       
    54         echo "<div class=\"float-r sc\"><img src=\"/fhiiqm/img/house.png\" border=\"0\" alt=\"Raum\" title=\"Raum\"/></div>\n";
       
    55     }
       
    56 
       
    57     $rag    = $_POST["rag"];    // Parameter aus Form
       
    58     $search = $_POST["search"];
       
    59     if (!$search) $search =  $_GET["s"];
       
    60 
       
    61     $zeil = $rag["z"];
       
    62     if (!$zeil) $zeil = $_GET["z"];
       
    63     if (!$zeil) $zeil = 9999; // Anzahl der gezeigten Zeilen
       
    64     $start = $_GET["st"];   // Start bei DS $start+1
       
    65     if (!$start) $start=0;
       
    66     
       
    67 
       
    68     if (!is_array($rag))
       
    69     {
       
    70         $rag["geb"]     = $_GET["g"];
       
    71         $rag["rnum"]   = $_GET["r"];
       
    72         $rag["rtyp"]   = $_GET["t"];
       
    73         $rag["bind"]    = $_GET["b"];
       
    74         $rag["sort1"]   = $_GET["s1"];
       
    75     }
       
    76 /*
       
    77     $_GET["g"] = $rag["geb"];
       
    78     $_GET["r"] = $rag["rnum"];
       
    79     $_GET["t"] = $rag["rtyp"];
       
    80     $_GET["b"] = $rag["bind"];
       
    81     $_GET["s1"] = $rag["sort1"];
       
    82     $_GET["z"]  = $zeil;
       
    83 */   
       
    84     if ($search && $_GET['s'] != 2)
       
    85     {    
       
    86         echo "<span class='sc'>";
       
    87         echo "<br />&nbsp;&nbsp;&nbsp;<a href=\"/fhiiqm/raum_report.php\" target=\"_self\" title=\"Berichte\" class='sc'>&laquo; zur Berichts&uuml;bersicht</a>";
       
    88         echo "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"Report Labor Info\" class='sc'>neuer Bericht Raum Information AS</a>\n";    
       
    89         echo "</span>";
       
    90     }
       
    91     echo "<div align='center'>\n";
       
    92     echo "<p class='sc'><b>Report Raum Informationen Arbeitssicherheit</b></p>\n";
       
    93     echo "</div>\n";
       
    94     
       
    95 
       
    96     if (!$search)
       
    97     {
       
    98 ?>
       
    99         <div align="center">
       
   100         <p>Bitte Kriterien f&uuml;r die Suche w&auml;hlen</p>
       
   101         <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" enctype="application/x-www-form-urlencoded" name="form_raum" target="_self">	
       
   102         <table width="50%" border="0" cellspacing="3" cellpadding="3">
       
   103             <tr>
       
   104                 <td>Haus</td>
       
   105                 <td>
       
   106                     <select name="rag[geb]" size="1" onchange="this.form.submit();">
       
   107                     <?php 
       
   108                         if ($rag["geb"] == "") $select = " selected "; else $select = "";
       
   109                         echo "<option $select value=\"\"></option>\n";
       
   110                         $sql = "SELECT geb_ID, geb_name FROM Haus ORDER BY 1";
       
   111                         if ($result = $dbc->queryObjectArray($sql))
       
   112                         {
       
   113                             foreach ($result as $row)
       
   114                             {
       
   115                                 if ($row->geb_ID == $rag['geb'])
       
   116             					   echo "<option selected value=\"$row->geb_ID\">$row->geb_ID - $row->geb_name</option>\n";
       
   117             				    else
       
   118             					   echo "<option value=\"$row->geb_ID\">$row->geb_ID - $row->geb_name</option>\n";
       
   119                             }
       
   120                         }
       
   121                     ?>
       
   122                     </select>
       
   123                 </td>
       
   124             </tr>
       
   125             <tr>
       
   126                 <td>Raum-Nummer</td>
       
   127                 <td><select name="rag[rnum]">
       
   128                     <?php 
       
   129                         if ($rag["rnum"] == "0") $select = " selected "; else $select = "";
       
   130                         echo "<option $select value=\"0\"></option>\n";
       
   131                         if (isset($rag["geb"]) && $rag["geb"] > "") $where = " WHERE geb_ID = '".$rag["geb"]."'"; else $where = "";
       
   132                         echo "Gebaeude: ".$rag["geb"]."<br />\n";
       
   133                         $sql = "SELECT geb_ID, raum_ID,raum_nr,raum_name FROM fhiiqm.Raum $where ORDER BY 1,3";
       
   134                         if ($result = $dbc->queryObjectArray($sql))
       
   135                         {
       
   136                             foreach ($result as $row)
       
   137                             {
       
   138                                 if ($row->raum_ID == $rag['rnum'])
       
   139             					   echo "<option selected value=\"$row->raum_ID\">$row->geb_ID - $row->raum_nr, $row->raum_name</option>\n";
       
   140             				    else
       
   141             					   echo "<option value=\"$row->raum_ID\">$row->geb_ID - $row->raum_nr, $row->raum_name</option>\n";
       
   142                             }
       
   143                         }
       
   144                     ?>
       
   145                     </select>
       
   146                 </td>
       
   147             </tr>
       
   148             <tr>
       
   149                 <td>Raumtyp</td>
       
   150                 <td><select name="rag[rtyp]">
       
   151                 <?php 
       
   152                     if ($rag["rtyp"] == "") $select = " selected "; else $select = "";
       
   153                     echo "<option $select value=\"\"></option>\n";
       
   154                     $sql = "SELECT raumtyp_ID,raumtyp_bez FROM fhiiqm.Raum_Typ WHERE raumtyp_ID IN ('LA', 'LC', 'T', 'WE') ORDER BY 1";
       
   155                     if ($result = $dbc->queryObjectArray($sql))
       
   156                     {
       
   157                         foreach ($result as $row)
       
   158                         {
       
   159                             if ($row->raumtyp_ID == $rag['rtyp'])
       
   160         					   echo "<option selected value=\"$row->raumtyp_ID\">$row->raumtyp_ID - $row->raumtyp_bez</option>\n";
       
   161         				    else
       
   162         					   echo "<option value=\"$row->raumtyp_ID\">$row->raumtyp_ID - $row->raumtyp_bez</option>\n";
       
   163                         }
       
   164                     }
       
   165                 ?>
       
   166                 </select></td>
       
   167             </tr>
       
   168             <tr> 
       
   169                   <td>Verkn&uuml;pfung</td>
       
   170                   <td>UND&nbsp;&nbsp;&nbsp;
       
   171                     <input type="radio" name="rag[bind]" value="AND" <?php if (isset($rag["bind"]) && $rag["bind"]=="AND") echo "checked"; else  echo "checked";?>>
       
   172                   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ODER&nbsp;&nbsp;&nbsp;
       
   173                     <input type="radio" name="rag[bind]" value="OR" <?php if (isset($rag["bind"]) && $rag["bind"]=="OR") echo "checked"; ?>></td>
       
   174             </tr>
       
   175             <tr>
       
   176                 <td>Sortierung nach<br />(in dieser Reihenfolge)</td><td>
       
   177             <?php
       
   178                 $sort = array(""=>"","1"=>"Geb&auml;ude, Raum-Nr.","2"=>"Raum-Nr., Geb&auml;ude","5"=>"Raum-Typ, Geb&auml;ude, Raum-Nr.");
       
   179                 for ($i=1; $i<2; $i++)
       
   180                 { 
       
   181                   echo "<select name='rag[sort$i]'>\n";
       
   182                   foreach ($sort as $key=>$val)
       
   183                   {
       
   184                     $rsort = "sort" . $i;
       
   185                     if ($rag[$rsort] == $val) $select= " selected"; else $select = "";
       
   186                     echo "<option$select value='$key'>$val</option>\n";
       
   187                   }
       
   188                   echo "</select>&nbsp;&nbsp;&nbsp;&nbsp;\n";
       
   189                 } 
       
   190                 echo "</td></tr>\n";
       
   191 /*        
       
   192                 $azeil = array(10=>'10',20=>'20',25=>'25',50=>'50',100=>'100',9999=>'alle'); // Anzahl gezeigter rows
       
   193                 echo "<tr><td>Zeilen/Seite?</td><td><select name='rag[z]'>\n";
       
   194                 if (!$rag['z']) $rag['z'] = 9999;
       
   195                 foreach ($azeil as $key=>$val)
       
   196                 {
       
   197                     if ($key == $rag['z']) $select = "selected"; else $select = "";
       
   198                     echo "<option $select value='$key'>$val</option>\n";
       
   199                 }
       
   200                 echo "</select></td></tr>\n";
       
   201 */        
       
   202             ?>
       
   203             <tr> 
       
   204                 <td>&nbsp;</td>
       
   205                 <td><input class="button" type="submit" name="search" value="Bericht erstellen"/></td>
       
   206             </tr> 
       
   207         </table>
       
   208         </div>
       
   209         </form>
       
   210 <?php
       
   211     }
       
   212     else
       
   213     {
       
   214         echo "<div align='center'>\n";
       
   215         
       
   216         if ($rag["geb"]>"!") $krit = " [Geb&auml;ude = '" . $rag["geb"] ."']";
       
   217         if ($krit) $bd = " ".$rag["bind"]; else $bd = "";
       
   218         if ($rag["rnum"])
       
   219         { 
       
   220             $rnr = $dbc -> querySingleItem("SELECT raum_nr FROM Raum WHERE raum_ID = ". $rag["rnum"]);    
       
   221             $krit .= $bd. " [Raum-Nr. = '$rnr']";
       
   222         }
       
   223         $bd = ($krit)? (" ".$rag["bind"]) : " ";
       
   224         if ($rag["rtyp"]) $krit .= $bd . " [Raumtyp = '".$rag["rtyp"]."']";
       
   225         
       
   226         $sql = "CALL raum_vma_tel_las_gefbgr_report('".$rag["sort1"]."','".$rag["bind"]."','".$rag["geb"]."','".$rag["rnum"]."','".$rag["rtyp"]."',$start,$zeil,@anz)";
       
   227         // mit gefaehrdungsbezeichnung und Gruppenbezeichnung    
       
   228         $result = $dbc -> queryObjectArray($sql);
       
   229         if ($result)
       
   230         {
       
   231 //            print_r ($result);   
       
   232             echo "<p class='sc'>$krit</p>";
       
   233             $begin = 0;
       
   234             foreach ($result as $row)
       
   235             {
       
   236     		$bg1 = "#F8F8F8";
       
   237     		$bg2 = "#DEDFE1";
       
   238     		$bg = "#FFFFFF";
       
   239                 if ($begin) echo "<p style=\"page-break-before:always\">&nbsp;</p>";
       
   240                 echo "<h2>Raum Information</h2>\n";
       
   241                 echo "<table width='90%' border='1' frame='box' rules='rows' cellspacing='2' cellpadding='5'>\n";
       
   242                 echo "<tr><td class='big' width='40%'><b>Geb&auml;ude: $row->geb_ID</b></td><td class='big' width='60%'><b>Raum-Nr.: $row->raum_nr
       
   243                         </b></td></tr>\n";
       
   244                 echo "<tr><td class='big'><b>Raumbezeichnung: </b></td><td class='big'><b>$row->raum_name</b></td></tr>\n";
       
   245                 echo "<tr><td class='big'><b>Arbeitsgruppe(n):</b></td><td class='big'>".str_replace(";","<br />",$row->ag)."</td></tr>\n";
       
   246     			if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
       
   247                 if ($row->las_anz || $row->al_anz)
       
   248                 {
       
   249                     echo "<tr bgcolor='$bg'><td class='big'><b>Gefährdungen Ger&auml;te:</b></td><td class='big'>";
       
   250                     if ($row->las_anz)
       
   251                         echo "Laser (Klassen 3A, 3B, 4), Anzahl: ".$row->las_anz. "<br />";
       
   252                     if ($row->al_anz)
       
   253                         echo "Anlagen: ".$row->al_anz. "<br />";
       
   254                     echo "</td></tr>\n";
       
   255                 }    
       
   256                 else
       
   257                     echo "<tr bgcolor='$bg'><td class='big' colspan='2'><b>Gefährdungen Ger&auml;te:</b></td></tr>\n";
       
   258     			if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
       
   259                 echo "<tr bgcolor='$bg'><td class='big' colspan='2'><b>Allgemeine Gefährdungen:</b></td></tr>";
       
   260                 if (isset($row->gef) && $row->gef)
       
   261                 {
       
   262                     $first = true;
       
   263                     $vgbez = "";
       
   264                     $agef = explode(";",$row->gef);
       
   265                     foreach ($agef as $gef)
       
   266                     {
       
   267                         list($gf,$gfb,$gbez) = explode("|",$gef);
       
   268                         if ($gbez != $vgbez) 
       
   269                         {    
       
   270                             if (!$first) echo "</td></tr>";
       
   271                             if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
       
   272                             echo "<tr bgcolor='$bg'><td class='big valignb'>&nbsp;&nbsp;&nbsp;$gbez</td><td class='big valignb'>";
       
   273                             $first = true;
       
   274                             $apbez = array();
       
   275                         }
       
   276                         $gid = urlencode(trim($gf));
       
   277                         echo "<img name='gefahr' width='30px' src=" . "'/fhiiqm/inc/show_img_gef.inc.php?gid=$gid' alt='$gf' title='$gf'>&nbsp;&nbsp;&nbsp;";
       
   278                         echo "$gfb<br />";
       
   279                         $vgbez = $gbez;
       
   280                         $first = false;
       
   281                     } 
       
   282                 }
       
   283                 if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
       
   284                 echo "<tr bgcolor='$bg'><td class='big' colspan='2'><b>Bei Störungen zu benachrichtigen:</b></td></tr>\n";
       
   285                 if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
       
   286                 echo "<tr bgcolor='$bg'><td class='big' colspan='2'><b>&nbsp;&nbsp;tagsüber</b></td></tr>\n";
       
   287                 if ($row->vmatel>"!")
       
   288                 {
       
   289                     $sp = "&nbsp;&nbsp;&nbsp;";
       
   290                     if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;                    
       
   291                     echo "<tr bgcolor='$bg'><td class='big'>".$sp."Notdienst</td><td class='big'>030 8413 - 9</td></tr>\n";                    $vpnr = 0;                    
       
   292                     $mat = explode(";",$row->vmatel);   //persknr:MA|tel
       
   293                     $first = true;
       
   294                     foreach ($mat as $ma)
       
   295                     {
       
   296                         $pnr = substr($ma,0,strpos($ma,":"));
       
   297                         $tel = substr($ma,strpos($ma,"|")+1);
       
   298                         $nam = substr($ma,strpos($ma,":")+1,strlen($ma)-strlen($pnr)-strlen($tel)-2);
       
   299                         if ($pnr != $vpnr)
       
   300                         {
       
   301                             if (!$first) echo "</td></tr>\n";
       
   302                             if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
       
   303                             echo "<tr bgcolor='$bg'><td class='big'>$sp$nam</td><td class='big'>030 8413 - $tel";
       
   304                         }
       
   305                         else echo ", 030 8413 - $tel";
       
   306                         $first = false;
       
   307                         $vpnr = $pnr;
       
   308                     }
       
   309                     echo "</td></tr>\n";
       
   310                 }
       
   311                 else
       
   312                 { 
       
   313                     if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
       
   314                     echo "<tr bgcolor='$bg'><td class='big' colspan='2'>&nbsp;</td></tr>\n";
       
   315                 }
       
   316                 if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
       
   317                 echo "<tr bgcolor='$bg'><td class='big' colspan='2'><b>&nbsp;&nbsp;ausserhalb der Arbeitszeit / Wochenende</b></td></tr>\n";
       
   318                 if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
       
   319                 echo "<tr bgcolor='$bg'><td class='big'>&nbsp;&nbsp;&nbsp;zentraler Service</td><td class='big'>030 8413 - 4444</td></tr>\n";
       
   320                 if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
       
   321                 echo "<tr bgcolor='$bg'><td class='big'><b>Bemerkungen:</b></td><td class='big'>".nl2br($row->raum_bem)."</td></tr>\n";
       
   322                 if ($row->raum_feuerl)
       
   323                 {
       
   324                     if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
       
   325                     echo "<tr bgcolor='$bg'><td class='big'><b>Feuerl&ouml;scher im Raum:</b></td><td class='big'>$row->raum_feuerl</td></tr>\n";
       
   326                 }
       
   327                 echo "</table>\n";
       
   328                 $begin = 1;
       
   329             }
       
   330 
       
   331             echo "<p></p><table width=99%><tr><td class='right'><a href=\"javascript:window.print()\" class='sc'>
       
   332                 <img src=\"/fhiiqm/img/printer.png\" alt=\"Bericht drucken\" border=\"0\" align=\"right\" title=\"Bericht drucken\"></a></td></tr></table>";
       
   333             
       
   334         }
       
   335         else echo "<p class='red'>&nbsp;&nbsp;&nbsp;Leider gibt es kein Ergebnis für die von Ihnen gewählten Kriterien!</p>";
       
   336         
       
   337         echo "</div>\n";
       
   338         if ($search != 2)
       
   339         {    
       
   340             echo "<span  class=\"sc\">";
       
   341             echo "<br />&nbsp;&nbsp;&nbsp;<a href=\"/fhiiqm/raum_report.php\" target=\"_self\" title=\"Berichte\" class='sc'>&laquo; zur Berichts&uuml;bersicht</a>";
       
   342             echo "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"Report Labor Info\" class='sc'>neuer Bericht Raum Information AS</a></span>\n";
       
   343         }
       
   344         else
       
   345             echo "<a class='sc' href='javascript:history.back();' onMouseOver=\"{window.status='Zur&uuml;ck'; return true;}\">&laquo; Zur&uuml;ck</a>";
       
   346     }
       
   347 
       
   348 ?>
       
   349 
       
   350 </body>
       
   351 </html>