fhiiqm/form/info_betrst_form.inc.php
author Bettina Schwarzer <schwarzer@fhi-berlin.mpg.de>
Fri, 16 Nov 2012 10:39:25 +0100
changeset 31 0a1eb975fbd9
parent 29 72f79dab938e
child 36 4411d3239444
permissions -rw-r--r--
+ Raumverantwortliche + Mitarbeiter - Telefon

<?php

/**
 * @author Bettina Schwarzer, Fritz-Haber-Institut
 * @copyright 07/2012
 *
 * Form Info Betriebsstoerung
 */

	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
	if (!isset($dbc) || !$dbc) $dbc = new dbconnection();
    $okn = true;

?>
<div align="center">
<h5>* - Felder sind erforderlich!</h5>
</div>
<!-- <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" enctype="application/x-www-form-urlencoded" name="form_svc"> -->	
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data" name="form_info" target="_self"> 	
<div align="center">
<table width="60%" border="0" cellspacing="3" cellpadding="3">
    <tr>
        <td>Titel *<br/><br />
            &nbsp;&nbsp;&nbsp;max. 300 Zeichen m&ouml;glich</td>
        <td><textarea name="inf[iname]" id="titel" cols="50" rows="2"><?php echo $inf['iname']; ?></textarea>
            <?php 
			     if (isset($inf['iname']) && $inf['iname']<'!')
				{
					echo "<br><span class=\"red\">Titel ist erforderlich!</span>\n";
					$okn = false;
				}
                if ($infid)
                { 
                    echo "&nbsp;&nbsp;&nbsp;Info-ID";
                    echo "&nbsp;&nbsp;&nbsp;<input class='read right' name='inf[infid]' type='text' size='5' value='" .$inf['infid']."' readonly='readonly' />"; 
                }
             ?>
        </td>
    </tr>
    <tr>
        <td>Kurzinformation<br/><br />
            &nbsp;&nbsp;&nbsp;max. 8000 Zeichen m&ouml;glich
        </td>
        <td><textarea name="inf[ilong]" cols="80" rows="6"><?php echo $inf['ilong']; ?></textarea>
        </td>
    </tr>
	<?php if (substr($ityp,0,1) != 8)
    {                       
        if ($ityp == 71) $inf['sort'] = "BSI_7_" . substr($inf['sort'],6);
    ?>
    <tr>
	   <td>Kennzeichen(Sort.)</td>
	   <td><input name="inf[sort]" type="text" size="10" maxlength="10" value="<?php echo $inf['sort']; ?>" />
       <?php if ($ityp==7) echo "&nbsp;&nbsp;&nbsp;BSI_... "; ?></td>
    </tr>
    <?php 
    }                       ?>      
    <tr><td>geh&ouml;rt zu Info</td>
        <td><select name="inf[infrel]">
            <?php
                if ($inf['infid'] == -1) $select = " selected "; else $select = "";
                echo "<option $select value=\"-1\"></option>\n";
                if (isset($inf["infid"]) && $inf["infid"]>0) $where = " WHERE info_ID != " . $inf["infid"]; else $where=""; 
                $sql = "SELECT info_ID, LEFT(info_name_s,50) AS iname FROM Info $where ORDER BY 2";
                if ($result = $dbc -> queryObjectArray($sql))
                {
                    foreach ($result as $row)
                    {
                        if ($row->info_ID == $inf['infrel'])
    					   echo "<option selected value=\"$row->info_ID\">$row->info_ID - $row->iname</option>\n";
    				    else
    					   echo "<option value=\"$row->info_ID\">$row->info_ID - $row->iname</option>\n";
                    }
                }
            ?>
        </select>
        </td>
    </tr>
    <tr>
        <td>Info-Typ</td>
        <td><select name="inf[ityp]">
            <?php 
                if (!$ityp)
                { 
                    $wher = "";
                    if ($inf['ityp'] == -1) $select = " selected "; else $select = "";
                    echo "<option $select value=\"-1\"></option>\n";
                }
                else $wher = " WHERE infotyp_ID = $ityp";
                $sql = "SELECT infotyp_ID, infotyp_bez FROM Info_Typ $wher ORDER BY 2";
                if ($result = $dbc->queryObjectArray($sql))
                {
                    foreach ($result as $row)
                    {
                        if ($row->infotyp_ID == $inf['ityp'])
    					   echo "<option selected value=\"$row->infotyp_ID\">$row->infotyp_bez</option>\n";
    				    else
    					   echo "<option value=\"$row->infotyp_ID\">$row->infotyp_bez</option>\n";
                    }
            }
            ?>
            </select>
        </td>
    </tr>
        <tr><td>Ort</td>
            <td valign="top">Haus&nbsp;
                 <select name="inf[geb]" onchange="this.form.submit();">
                <?php 
                    if ($inf['geb'] == -1) $select = " selected "; else $select = "";
                    echo "<option $select value=\"-1\"></option>\n";
                    $sql = "SELECT geb_ID, geb_name FROM `fhiiqm`.`Haus` ORDER BY 1";
                    if ($result = $dbc->queryObjectArray($sql))
                    {
                        foreach ($result as $row)
                        {
                            if ($row->geb_ID == $inf['geb'])
        					   echo "<option selected value=\"$row->geb_ID\">$row->geb_ID: $row->geb_name</option>\n";
        				    else
        					   echo "<option value=\"$row->geb_ID\">$row->geb_ID: $row->geb_name</option>\n";
                        }
                }
                ?>
                </select>
                &nbsp;&nbsp;Raum&nbsp;            
                 <select name="inf[raum]">
                <?php 
                    if (!$inf['geb']) $wher = ""; else $wher = " WHERE geb_ID = '".$inf['geb']."'";
                    if ($inf['raum'] == -1) $select = " selected "; else $select = "";
                    echo "<option $select value=\"-1\"></option>\n";
                    $sql = "SELECT raum_ID, raum_nr, raum_name, geb_ID FROM `fhiiqm`.`Raum` $wher  ORDER BY 4,2";
                    if ($result = $dbc->queryObjectArray($sql))
                    {
                        foreach ($result as $row)
                        {
                            if ($row->raum_ID == $inf['raum'])
        					   echo "<option selected value=\"$row->raum_ID\">$row->geb_ID: $row->raum_nr $row->raum_name</option>\n";
        				    else
        					   echo "<option value=\"$row->raum_ID\">$row->geb_ID: $row->raum_nr $row->raum_name</option>\n";
                        }
                }
                ?>
                </select>
            </td>
        </tr>
    <tr>
        <td>Erstellungsdatum *</td>
        <?php if (!$sub && !$del && !$dup && !$infid) $inf['cdat'] = date('Y-m-d');
        ?>
        <td><input class="long10" name="inf[cdat]" id="cdat"  value="<?php echo $inf['cdat']; ?>" />
            <?php
                if (isset($inf['cdat']) && $inf['cdat']< "!")
                { 
                    echo "<br><span class=\"red\">Erstellungsdatum ist erforderlich!</span>\n";
                    $okn = false;
                }    
            ?>
        </td>
    </tr>
    <tr>
        <td>g&uuml;ltig ab</td>
        <td><input class="long10" name="inf[vdat]" id="vdat"  value="<?php echo $inf['vdat']; ?>" /></td>
    </tr>
     <tr>
        <td>g&uuml;ltig bis</td>
        <td><input class="long10" name="inf[bdat]" id="bdat"  value="<?php echo $inf['bdat']; ?>" /></td>
    </tr>
    <tr><td>Status Freigabe</td>
        <td><select name="inf[fg]" size="1">
            <?php
                if (!isset($inf["fg"]))
                {
                    if ($ityp == 71) $inf["fg"] = 3; else  $inf["fg"] = 1;
                } 
                if ($inf['fg']) $select = ( "-1" == $inf['fg'] ) ? ' selected' : null;
                echo "<option $select value=\"-1\"></option>\n";
                if ($ityp == 71) $wher = " WHERE info_freigabe_ID=3 "; else $wher="";
                $sql = "SELECT info_freigabe_ID, info_freigabe_bez FROM Info_Freigabe $wher ORDER BY 2";
                if ($result = $dbc -> queryObjectArray($sql))
                {
                    foreach ($result as $row)
                    {
                        if ($inf['fg']) $select = ( $row->info_freigabe_ID == $inf['fg'] ) ? ' selected' : null;
       					echo "<option $select value=\"$row->info_freigabe_ID\">$row->info_freigabe_bez</option>\n";
                    }
                }
            ?>
        </select>
        </td>
    </tr>
    <tr>
        <td>Autor</td>
        <td><input class="long20" type="text" name="inf[persknr]" id="persknr" value="<?php echo $inf['persknr']; ?>"/>
        &nbsp;&nbsp;&nbsp;Eingabe von mind. 2 Zeichen -&gt; Namensliste
        </td>
    </tr>
    <tr><td>Sprache</td>
        <td><select name="inf[lang]">
        <?php
                if (!$sub && !$del && !$dup && !$infid) $inf['lang'] = 'de';
                if ($inf['lang'] == -1) $select = " selected "; else $select = "";
                echo "<option $select value=\"-1\"></option>\n";
                $alang = array("de"=>"deutsch","en"=>"englisch");
                foreach ($alang as $key=>$value)
                {
                    if ($inf['lang'] == $key) $select = " selected "; else $select = "";
                    echo "<option $select value=\"$key\">$value</option>\n";
                }
        ?>
        </select></td>
    </tr>
    <tr>
        <td>zugeordnet zu Produkt<br /><br />
            <?php
                if ($ityp != 71)
                echo 
            "&nbsp;&nbsp;&nbsp;Mehrfachauswahl m&ouml;glich:<br />
            &nbsp;&nbsp;&nbsp;[Strg]-Taste + Anklicken der<br /> 
            &nbsp;&nbsp;&nbsp;gewünschten Listeneinträge";
            ?>
        </td>
        <td>
            <?php
                if ($ityp != 71)
                    echo "<select name=\"inf[prid][]\" size=\"9\" multiple=\"multiple\">\n";
                else
                {   // Betriebsstörung dezentrale Technik
                    echo "<select name=\"inf[prid][]\" size=\"3\">\n";
                    $inf['prid'][0] = "4108"; // Branschutz- und Steuerungstechnik
                }   
                if (is_array($inf['prid'])) $select = in_array( "-1", $inf['prid'] ) ? ' selected' : null;
                echo "<option $select value=\"-1\"></option>\n";
//                $sql = "SELECT produkt_ID, LEFT(prod_name,70) AS prod, LENGTH(prod_name) AS lenp FROM Produkt ORDER BY 2";
                if (substr($ityp,0,1) == 7) $sql = "CALL prod_hiera_all(4,41)"; 
                elseif (substr($ityp,0,1) == 8) $sql = "CALL prod_hiera_all(1,15)";  
                if ($result = $dbc->queryObjectArray($sql))
                {
                    foreach ($result as $row)
                    {
                        if (strlen($row->bez) > 70) 
                            $prod=str_replace(" ","&nbsp;",htmlentities(substr($row->bez,0,70))) ."..."; 
                        else 
                            $prod=str_replace(" ","&nbsp;",htmlentities($row->bez));
                        if ($row->prid >0) $color=" class='green'"; else $color="";
                        if (is_array($inf['prid'])) $select = in_array($row->prid, $inf['prid']) ? ' selected' : null;
                        if ($ityp != 71)
                        {
                            echo "<option $color $select value=\"$row->prid\">$prod</option>\n";
                        }
                        else
                        {
                            if ($row->prid == $inf['prid'][0] || $row->prid == 0)
                                echo "<option $color $select value=\"$row->prid\">$prod</option>\n";
                        }
                    }
                }
                unset($result);
            ?>
            </select>
            <br />bitte nur die <font color="green">gr&uuml;nen</font> Eintr&auml;ge w&auml;hlen
        </td>
    </tr>
	<?php if (substr($ityp,0,1) != 8)  // 8 - Betriebsanweisung
    {                       ?>
    <tr><td>Adressat (Beauftragte)<br />
    <?php
        if ($ityp != 71)
        {
    ?>
            &nbsp;&nbsp;&nbsp;leeres Feld = L&ouml;schen</td>
        <td>
            <div id="add">
            <select name="inf[adr][]" size="1">
            <?php
                $select = ( "-1" == $inf['adr'][0] ) ? ' selected' : null;
                echo "<option $select value=\"-1\"></option>\n";
                $sql = "SELECT fkt_ID, fkt_bez FROM Funktion ORDER BY 2";
                if ($result = $dbc -> queryObjectArray($sql))
                {
                    foreach ($result as $row)
                    {
                        $select = ( $row->fkt_ID == $inf['adr'][0] ) ? ' selected' : null;
       					echo "<option $select value=\"$row->fkt_ID\">$row->fkt_ID - $row->fkt_bez</option>\n";
                        $sf .= "'".$row->fkt_ID."':'".$row->fkt_bez."',";
                    }
                }
                $sf = substr($sf,0,strlen($sgf)-1);
            ?>
            </select>
            <script type="text/javascript">
            <!--
                arr = {<?php echo ($sf); ?>}; // Ergebnis: {'key':'value','key':'value',...} 
            //-->
            </script>

            &nbsp;&nbsp;&nbsp;<a href="<?php echo "javascript:addInput('add');" ?>" title="weiterer Adressat"><img src="/fhiiqm/img/add.png" /></a>
            &nbsp;&nbsp;&nbsp;<a href="<?php echo "javascript:delInput('add');" ?>" title="l&ouml;schen letzter Adressat"><img src="/fhiiqm/img/delete.png" /></a><br />
            <?php
                if ($infid || ($sub && isset($inf) && !$ok))
                {
                    if (count($inf['adr'])>1)
                    {
                        $i=0;
                        foreach ($inf['adr'] as $fe)
                        {
                            if ($i>0)
                            {
                                echo "<select name=\"inf[adr][]\" size=\"1\">";
                
                                $select = ( "-1" == $fe ) ? ' selected' : null;
                                echo "<option $select value=\"-1\"></option>\n";
                                foreach ($result as $row)
                                {
                                    $select = ( $row->fkt_ID == $fe ) ? ' selected' : null;
                					echo "<option $select value=\"$row->fkt_ID\">$row->fkt_ID - $row->fkt_bez</option>\n";
                                }
                                echo "</select><br/>\n";
                            }
                            $i++;
                        }
                    }
                }
            ?>
            </div>
        </td>
    <?php
    }
    else
    {
        echo "</td>";
        echo "<td><select name='inf[adr][]' size='1'>";
        echo "<option selected value='LV'>LV - Laborverantwortlicher</option></select></td>";
    }
    ?>
    </tr>
    <?php 
    }                       
        if ($ityp == 81)    // Betriebsanweisung Anlage
        {
            echo "<tr>
                    <td>geh&ouml;rt zu Anlage</td>";
            echo "  <td>
                        <select name=\"inf[anl]\" size=\"1\">";
            $sql = "SELECT al_ID,al_bez,al_kat_bez FROM fhiiqm.Anlage a
                        LEFT JOIN A_Kategorie k ON a.al_kat_ID=k.al_kat_ID WHERE a.al_kat_ID < 6";
            $select = ( "-1" == $inf['adr'][0] ) ? ' selected' : null;
            echo "<option $select value=\"-1\"></option>\n";
            if ($result = $dbc -> queryObjectArray($sql))
            {
                foreach ($result as $row)
                {
                    $select = ( $row->al_ID == $inf['anl']) ? ' selected' : null;
   					echo "<option $select value=\"$row->al_ID\">$row->al_bez ($row->al_kat_bez)</option>\n";
                }
            }
            echo "      </select>
                    </td>
                </tr>\n";
        }
    ?>
       
	<tr>
	   <td>Dateibezeichnung Dokument (*)</td>
	   <td><input name="inf[ifname]" type="text" size="50" maxlength="50" value="<?php echo $inf['ifname']; ?>" />
	   <?php
            echo "<br />bitte <u>keine</u> Umlaute im Dateinamen angeben!";   
			if (isset($inf['ifname']) && $upd && is_uploaded_file($_FILES["ifile"]["tmp_name"]) && $inf['ifname']<'!')
				{
					echo "<br><span class=\"red\">Dateiname ist erforderlich!</span>\n";
					$okn = false;
				}
				else
				{
                    if ($inf['ifname']>='!' && file_exists("infos/".$inf['ifname']))
                        echo "<br />Dokument anschauen:&nbsp;<a href='infos/" . $inf['ifname'] ."'>" . $inf['ifname'] . "</a>";
//                    if ($okn) $okn = true; else $okn=false;
                }
		?>
		</td>
    </tr>

    <input type="hidden" name="inf[pers]" id="pid" value="<?php echo $inf['pers']; // Author ?>"/> 
    <input type="hidden" name="MAX_FILE_SIZE" value="32000000"/>    
    <input type="hidden" name="inf[okn]" value="<?php echo $okn; ?>"/>
<!--  </table>
 </div>   
</form> -->