fhiiqm/form/ma_ed_form.inc.php
changeset 34 fc60ef80a7ad
parent 33 f1a8785434e4
child 40 6f4b105daa24
equal deleted inserted replaced
33:f1a8785434e4 34:fc60ef80a7ad
     8  */
     8  */
     9 
     9 
    10 	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
    10 	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
    11 	if (!isset($dbc) || !$dbc) $dbc = new dbconnection();
    11 	if (!isset($dbc) || !$dbc) $dbc = new dbconnection();
    12     $okn = true;
    12     $okn = true;
    13     if (!$ma) $ma['geb'] = 'A';
    13     if (!$ma) 
       
    14     {
       
    15        $ma['geb'] = 'A';
       
    16        $ma['abt'][0] = $dbc -> querySingleItem("SELECT abt_ID FROM Abteilung ORDER BY abt_ID+0 LIMIT 0,1");
       
    17     }
    14 
    18 
    15 ?>
    19 ?>
    16 <div align="center">
    20 <div align="center">
    17 <h5>* - Felder sind erforderlich!</h5>
    21 <h5>* - Felder sind erforderlich!</h5>
    18 </div>
    22 </div>
    95             }
    99             }
    96             ?>
   100             ?>
    97             </select>
   101             </select>
    98         </td>
   102         </td>
    99     </tr>
   103     </tr>
   100     <tr>
   104 <?php
       
   105 /*  // deaktiviert am 08.01.2013, Kaendler, Schwarzer
       
   106     echo
       
   107     "<tr>
   101         <td>Arbeitsgruppe</td>
   108         <td>Arbeitsgruppe</td>
   102         <td><select name="ma[rag]">
   109         <td><select name=\"ma[rag]\">";
   103             <?php 
       
   104                 if ($ma['rag'] == -1) $select = " selected "; else $select = "";
   110                 if ($ma['rag'] == -1) $select = " selected "; else $select = "";
   105                 echo "<option $select value=\"-1\"></option>\n";
   111                 echo "<option $select value=\"-1\"></option>\n";
   106                 $sql = "SELECT rag_ID, rag_bez, abt_name FROM RaumArb_Gruppe g INNER JOIN Abteilung a 
   112                 $sql = "SELECT rag_ID, rag_bez, abt_name FROM RaumArb_Gruppe g INNER JOIN Abteilung a 
   107                         ON g.abt_ID = a.abt_ID ORDER BY g.abt_ID,rag_ID";
   113                         ON g.abt_ID = a.abt_ID ORDER BY g.abt_ID,rag_ID";
   108                 if ($result = $dbc->queryObjectArray($sql))
   114                 if ($result = $dbc->queryObjectArray($sql))
   115                         }  
   121                         }  
   116     				    else
   122     				    else
   117     					   echo "<option value=\"$row->rag_ID\">$row->abt_name: $row->rag_bez</option>\n";
   123     					   echo "<option value=\"$row->rag_ID\">$row->abt_name: $row->rag_bez</option>\n";
   118                     }
   124                     }
   119             }
   125             }
   120             ?>
   126     echo
   121             </select>
   127             "</select>
   122         </td>
   128         </td>
   123     </tr>
   129     </tr>";
       
   130 */
       
   131 ?>
   124     <tr>
   132     <tr>
   125         <td>Telefon</td>
   133         <td>Telefon</td>
   126         <td><div id="addtel">
   134         <td><div id="addtel">
   127         <select name="ma[tel][]" size="1">
   135         <select name="ma[tel][]" size="1">
   128             <?php
   136             <?php
   129                 $select = null;
   137                 $select = null;
   130                 $select = ( "-1"==$ma['tel'][0] ) ? ' selected' : null;
   138                 $select = ( "-1"==$ma['tel'][0] ) ? " selected='selected'" : "";
   131                 echo "<option $select value=\"-1\"></option>\n";
   139                 echo "<option $select value=\"-1\"></option>\n";
   132                 $sql = "SELECT telefon_nr,geb_ID,raum_nr, telefon_typ FROM fhiiqm.Telefon t
   140 /*                $sql = "SELECT telefon_nr,geb_ID,raum_nr, telefon_typ FROM fhiiqm.Telefon t
   133                         LEFT OUTER JOIN Raum r ON t.raum_ID=r.Raum_ID 
   141                         LEFT OUTER JOIN Raum r ON t.raum_ID=r.Raum_ID 
   134                         ORDER BY telefon_nr
   142                         ORDER BY telefon_nr";   */
   135 ";
   143                 $sql = "SELECT telefon_nr, telefon_typ FROM fhiiqm.Telefon 
       
   144                         ORDER BY telefon_nr";
   136                 if ($result = $dbc->queryObjectArray($sql))
   145                 if ($result = $dbc->queryObjectArray($sql))
   137                 {
   146                 {
   138                     foreach ($result as $row)
   147                     foreach ($result as $row)
   139                     {
   148                     {
   140                         if ($row->telefon_typ == "fax") $teln = $row->telefon_nr." FAX"; else $teln = $row->telefon_nr;
   149                         if ($row->telefon_typ == "fax") $teln = $row->telefon_nr." FAX"; else $teln = $row->telefon_nr;
   141                         if ($row->raum_nr) $telr = "[". $row->geb_ID. " ". $row->raum_nr . "]"; else $telr = "";
   150 //                        if ($row->raum_nr) $telr = "[". $row->geb_ID. " ". $row->raum_nr . "]"; else $telr = "";
   142                         $select = ( $row->telefon_nr==$ma['tel'][0] ) ? ' selected' : null;
   151                         $select = ( $row->telefon_nr==$ma['tel'][0] ) ? " selected='selected'" : "";
   143     					echo "<option $select value=\"$row->telefon_nr\">$teln&nbsp;&nbsp;&nbsp;$telr</option>\n";
   152     					echo "<option $select value=\"$row->telefon_nr\">$teln</option>\n";
   144                         $tel .= "'".$row->telefon_nr. "':'" . $teln ."&nbsp;&nbsp;&nbsp;". $telr. "',";
   153 //                        $tel .= "'".$row->telefon_nr. "':'" . $teln ."&nbsp;&nbsp;&nbsp;". $telr. "',";
       
   154                         $tel .= "'".$row->telefon_nr. "':'" . $teln . "',";
   145                     }
   155                     }
   146                 }
   156                 }
   147                 $tel = substr($tel,0,strlen($tel)-1);
   157                 $tel = substr($tel,0,strlen($tel)-1);
   148             ?>
   158             ?>
   149             </select>
   159             </select>
   151             <!--
   161             <!--
   152                 arr = {<?php echo ($tel); ?>}; // Ergebnis: {key:'value',key:'value',...} 
   162                 arr = {<?php echo ($tel); ?>}; // Ergebnis: {key:'value',key:'value',...} 
   153             //-->
   163             //-->
   154             </script>
   164             </script>
   155             &nbsp;&nbsp;&nbsp;oder neu&nbsp;&nbsp;&nbsp;<input name="ma[ntel][]" type="text" size="20" maxlength="20" value="<?php echo $ma['ntel'][0]; ?>" />
   165             &nbsp;&nbsp;&nbsp;oder neu&nbsp;&nbsp;&nbsp;<input name="ma[ntel][]" type="text" size="20" maxlength="20" value="<?php echo $ma['ntel'][0]; ?>" />
       
   166             &nbsp;&nbsp;&nbsp;Priorit&auml;t&nbsp;&nbsp;&nbsp;<select name="ma[so][]" size="1">
       
   167             <?php
       
   168             $select = ($ma["so"][0] == '-1')? " selected='selected'" : "";
       
   169             echo "<option$select value=-1></option>\n";
       
   170             for ($i=1; $i<10; $i++)
       
   171             {
       
   172                 $select=($ma["so"][0] == $i)? " selected='selected'" : "";
       
   173                 echo "<option$select value=$i>$i</option>\n";
       
   174             }
       
   175             ?>
       
   176             </select>
   156             &nbsp;&nbsp;&nbsp;&ouml;ffentlich&nbsp;&nbsp;&nbsp;<input name="ma[pub][]" type="checkbox" value="1" <?php if ($ma['pub'][0]) echo "checked"; ?> />
   177             &nbsp;&nbsp;&nbsp;&ouml;ffentlich&nbsp;&nbsp;&nbsp;<input name="ma[pub][]" type="checkbox" value="1" <?php if ($ma['pub'][0]) echo "checked"; ?> />
   157             &nbsp;&nbsp;&nbsp;<a href="<?php echo "javascript:addInput('addtel');" ?>" title="weitere Telefon-Nr."><img src="/fhiiqm/img/add.png" /></a>
   178             &nbsp;&nbsp;&nbsp;<a href="<?php echo "javascript:addInput('addtel');" ?>" title="weitere Telefon-Nr."><img src="/fhiiqm/img/add.png" /></a>
   158             &nbsp;&nbsp;&nbsp;<a href="<?php echo "javascript:delInput('addtel');" ?>" title="l&ouml;schen letzte Telefon-Nr."><img src="/fhiiqm/img/delete.png" /></a><br />
   179             &nbsp;&nbsp;&nbsp;<a href="<?php echo "javascript:delInput('addtel');" ?>" title="l&ouml;schen letzte Telefon-Nr."><img src="/fhiiqm/img/delete.png" /></a><br />
   159             <?php
   180             <?php
   160                 if (isset($ma) && (!$ok || $sub))
   181                 if (isset($ma) && (!$ok || $sub))
   164                         $i=0;
   185                         $i=0;
   165                         foreach ($ma['tel'] as $atel)
   186                         foreach ($ma['tel'] as $atel)
   166                         {
   187                         {
   167                             if ($i>0)
   188                             if ($i>0)
   168                             {
   189                             {
   169                                 echo "<select name=\"ma[tel][]\" size=\"1\">";
   190                                 echo "<span></span><select name=\"ma[tel][]\" size=\"1\">";
   170                 
   191                 
   171                                 $select = ( "-1" == $atel ) ? ' selected' : null;
   192                                 $select = ( "-1" == $atel ) ? ' selected' : null;
   172                                 echo "<option $select value=\"-1\"></option>\n";
   193                                 echo "<option $select value=\"-1\"></option>\n";
   173                                 foreach ($result as $row)
   194                                 foreach ($result as $row)
   174                                 {
   195                                 {
   175                                     if ($row->telefon_typ == "fax") $teln = $row->telefon_nr." FAX"; else $teln = $row->telefon_nr;
   196                                     if ($row->telefon_typ == "fax") $teln = $row->telefon_nr." FAX"; else $teln = $row->telefon_nr;
   176                                     if ($row->raum_nr) $telr = "[". $row->geb_ID. " ". $row->raum_nr . "]"; else $telr = "";
   197 //                                    if ($row->raum_nr) $telr = "[". $row->geb_ID. " ". $row->raum_nr . "]"; else $telr = "";
   177                                     $select = ( $row->telefon_nr == $atel ) ? ' selected' : null;
   198                                     $select = ( $row->telefon_nr == $atel ) ? ' selected' : null;
   178                 					echo "<option $select value=\"$row->telefon_nr\">$teln&nbsp;&nbsp;&nbsp;$telr</option>\n";
   199                 					echo "<option $select value=\"$row->telefon_nr\">$teln</option>\n";
   179                                 }
   200                                 }
   180                                 echo "</select>";
   201                                 echo "</select>";
   181                                 echo "&nbsp;&nbsp;&nbsp;&nbsp;oder neu&nbsp;&nbsp;&nbsp;<input name=\"ma[ntel][]\" type=\"text\" size=\"20\" maxlength=\"20\" value=\"".$ma['ntel'][$i]."\" />";
   202                                 echo "&nbsp;&nbsp;&nbsp;&nbsp;oder neu&nbsp;&nbsp;&nbsp;<input name=\"ma[ntel][]\" type=\"text\" size=\"20\" maxlength=\"20\" value=\"".$ma['ntel'][$i]."\" />";
   182                                 echo "&nbsp;&nbsp;&nbsp;&nbsp;&ouml;ffentlich&nbsp;&nbsp;&nbsp;<input name=\"ma[pub][$i]\" type=\"checkbox\" value=\"1\""; 
   203                                 echo "&nbsp;&nbsp;&nbsp;&nbsp;Priorit&auml;t&nbsp;&nbsp;&nbsp;<select name=\"ma[so][]\" size=\"1\">";
   183                                 $check = ($ma['pub'][$i]) ? " checked" : "" ;
   204                 
   184                                 echo "$check /><br />";
   205                                 $select = ( $ma["so"][$i] == "-1" ) ? " selected='selected'" : "";
       
   206                                 echo "<option$select value=\"-1\"></option>\n";
       
   207                                 for ($j=1; $j<10; $j++)
       
   208                                 {
       
   209                                     $select=($ma["so"][$i] == $j)? " selected='selected'" : "";
       
   210                                     echo "<option$select value=$j>$j</option>\n";
       
   211                                 }
       
   212                                 echo "</select>\n";
       
   213                                 echo "&nbsp;&nbsp;&nbsp;&ouml;ffentlich&nbsp;&nbsp;&nbsp;<input name=\"ma[pub][$i]\" type=\"checkbox\" value=\"1\""; 
       
   214                                 $check = ($ma['pub'][$i]) ? " checked='checked'" : "" ;
       
   215                                 echo "$check /><br />\n";
   185                             }
   216                             }
   186                             $i++;
   217                             $i++;
   187                         }
   218                         }
   188                     }
   219                     }
   189                 }
   220                 }
   196 	   <td>E-Mail</td>
   227 	   <td>E-Mail</td>
   197 	   <td><input name="ma[email]" type="text" size="30" maxlength="100" value="<?php echo $ma['email']; ?>" /></td>
   228 	   <td><input name="ma[email]" type="text" size="30" maxlength="100" value="<?php echo $ma['email']; ?>" /></td>
   198     </tr>
   229     </tr>
   199     <?php } ?>
   230     <?php } ?>
   200     <tr><td>Abteilung *</td>
   231     <tr><td>Abteilung *</td>
   201         <td valign="top">
   232         <td valign="top"><div id="addabt">
   202              <select name="ma[abt]">
   233              <select name="ma[abt][]" onchange="this.form.submit();">
   203             <?php 
   234             <?php 
   204                 $sql = "SELECT abt_ID, abt_name, abt_long FROM `fhiiqm`.`Abteilung` ORDER BY abt_ID+0";
   235                 $sql = "SELECT abt_ID, abt_name, abt_long FROM `fhiiqm`.`Abteilung` ORDER BY abt_ID+0";
   205                 if ($result = $dbc->queryObjectArray($sql))
   236                 if ($result = $dbc->queryObjectArray($sql))
   206                 {
   237                 {
   207                     foreach ($result as $row)
   238                     foreach ($result as $row)
   208                     {
   239                     {
   209                         if ($row->abt_ID == $ma['abt'])
   240                         if ($row->abt_ID == $ma['abt'][0])
   210     					   echo "<option selected value=\"$row->abt_ID\">$row->abt_name: $row->abt_long</option>\n";
   241     					   echo "<option selected value=\"$row->abt_ID\">$row->abt_name: $row->abt_long</option>\n";
   211     				    else
   242     				    else
   212     					   echo "<option value=\"$row->abt_ID\">$row->abt_name: $row->abt_long</option>\n";
   243     					   echo "<option value=\"$row->abt_ID\">$row->abt_name: $row->abt_long</option>\n";
   213                     }
   244                         $abt .= "'".$row->abt_ID. "':'" . $row->abt_name .": ". $row->abt_long . "',";
   214             }
   245                     }
   215             ?>
   246                     $abt = substr($abt,0,strlen($abt)-1);
   216             </select>
   247                 }
       
   248             ?>
       
   249             </select>
       
   250         &nbsp;&nbsp;&nbsp;   
       
   251         Arbeitsgruppe&nbsp;&nbsp;&nbsp;
       
   252              <select name="ma[rag][]">
       
   253             <?php 
       
   254                 if ($ma['rag'] == -1) $select = " selected "; else $select = "";
       
   255                 echo "<option $select value=\"-1\"></option>\n";
       
   256                 $sql = "SELECT rag_ID, rag_bez FROM `fhiiqm`.`RaumArb_Gruppe` WHERE abt_ID = " .$ma["abt"][0] . " ORDER BY rag_bez";
       
   257                 if ($resrag = $dbc->queryObjectArray($sql))
       
   258                 {
       
   259                     foreach ($resrag as $row)
       
   260                     {
       
   261                         if ($row->rag_ID == $ma['rag'][0])
       
   262     					   echo "<option selected value=\"$row->rag_ID\">$row->rag_bez</option>\n";
       
   263     				    else
       
   264     					   echo "<option value=\"$row->rag_ID\">$row->rag_bez</option>\n";
       
   265 //                        $rag .= "'".$row->rag_ID. "':'" . $row->rag_bez . "',";
       
   266                     }
       
   267 //                    $rag = substr($rag,0,strlen($rag)-1);
       
   268                 }
       
   269                 $sql = "SELECT rag_ID, rag_bez, abt_name FROM RaumArb_Gruppe g INNER JOIN Abteilung a 
       
   270                         ON g.abt_ID = a.abt_ID ORDER BY g.abt_ID,rag_ID";
       
   271                 if ($res = $dbc->queryObjectArray($sql))
       
   272                 {
       
   273                     foreach ($res as $row)
       
   274                         $rag .= "'".$row->rag_ID. "':'" . $row->abt_name . ": ". $row->rag_bez . "',";
       
   275                     $rag = substr($rag,0,strlen($rag)-1);
       
   276                 }
       
   277             ?>
       
   278             </select>
       
   279             <script type="text/javascript">
       
   280             <!--
       
   281                 arra = {<?php echo ($abt); ?>}; // Ergebnis: {key:'value',key:'value',...} 
       
   282                 arrg = {<?php echo ($rag); ?>}; // Ergebnis: {key:'value',key:'value',...} 
       
   283             //-->
       
   284             </script>
       
   285             &nbsp;&nbsp;&nbsp;<a href="<?php echo "javascript:addInput('addabt');" ?>" title="weitere Arbeitsgruppe"><img src="/fhiiqm/img/add.png" /></a>
       
   286             &nbsp;&nbsp;&nbsp;<a href="<?php echo "javascript:delInput('addabt');" ?>" title="l&ouml;schen letzte Arbeitsgruppe"><img src="/fhiiqm/img/delete.png" /></a><br />
       
   287             <?php
       
   288                 if (isset($ma) && (!$ok || $sub))
       
   289                 {
       
   290                     if (count($ma['abt'])>1 || count($ma['rag'])>1)
       
   291                     {
       
   292                         $i=0;
       
   293                         foreach ($ma['abt'] as $eabt)
       
   294                         {
       
   295                             if ($i>0)
       
   296                             {
       
   297                                 echo "<span></span><select name=\"ma[abt][]\" size=\"1\">";
       
   298                 
       
   299                                 foreach ($result as $row)
       
   300                                 {
       
   301                                     $select = ( $row->abt_ID == $eabt ) ? ' selected' : null;
       
   302                 					echo "<option $select value=\"$row->abt_ID\">$row->abt_name: $row->abt_long</option>\n";
       
   303                                 }
       
   304                                 echo "</select>";
       
   305                                 echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Arbeitsgruppe&nbsp;&nbsp;&nbsp;&nbsp;";
       
   306                                 echo "<select name='ma[rag][]' size=1>";
       
   307                                 $select = ( $ma["rag"][$i] == "-1" ) ? " selected='selected'" : "";
       
   308                                 echo "<option$select value=\"-1\"></option>\n";
       
   309                                 foreach ($res as $row)
       
   310                                 {
       
   311                                     $select = ( $row->rag_ID == $ma['rag'][$i] ) ? ' selected' : null;
       
   312                 					echo "<option $select value=\"$row->rag_ID\">$row->abt_name: $row->rag_bez</option>\n";
       
   313                                 }
       
   314                                 echo "</select><br />";
       
   315                             }
       
   316                             $i++;
       
   317                         }
       
   318                     }
       
   319                 }
       
   320             ?>
       
   321             </div>
       
   322         </td>   
       
   323     </tr>
       
   324             <input type="hidden" name="ma[abtm]" value="<?php echo $ma['abtm']; ?>" />
   217             <input type="hidden" name="okn" value="<?php echo $okn; ?>" />
   325             <input type="hidden" name="okn" value="<?php echo $okn; ?>" />
   218         </td>   
       
   219     </tr>
       
   220 <!--
   326 <!--
   221 </table>
   327 </table>
   222  </div>   
   328  </div>   
   223 </form>       
   329 </form>       
   224 -->
   330 -->