<?php
  ///////////////////////////////////////////////////
  //2007 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////

  $lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0,2);
  if (is_file ("../lang/".$lang."/".$lang.".php")) include "../lang/".$lang."/".$lang.".php";
     else include "../lang/ru/ru.php";

  $title=$titlepage = $TEXT['global-title5'];
  $helppage = $TEXT['global-help'];

  require_once "../config.php";
  require_once "../util/top_layer1.php";

  if($result2['user'] == 1) puterror2($TEXT['error-loginform4']);
  if($result2['master'] == 1) puterror2($TEXT['error-loginform4']);
  if($result2['manager'] == 1) puterror2($TEXT['error-loginform4']);

  if(!isset($title)) $title = $TEXT['global-title5'];
  if(!isset($button)) $button = $TEXT['btn_edit'];
  if(!isset($action)) $action = "edittema.php";

  if(strlen($_GET['tema_id'])>11) puterror2($TEXT['error-tema4']);
  if(strlen($_GET['zay_id'])>11) puterror2($TEXT['error-inst7']);
  $_GET['tema_id'] = rep($_GET['tema_id']);
  $_GET['zay_id'] = rep($_GET['zay_id']);

  $old_zay_id = $_GET['zay_id'];
  $old_tema_id = $_GET['tema_id'];

  $query = "SELECT tbl_supp_zayavka.*, tbl_supp_tema.tema_id, tbl_supp_tema.tema FROM tbl_supp_zayavka JOIN tbl_supp_tema ON tbl_supp_zayavka.tema_id=tbl_supp_tema.tema_id WHERE tbl_supp_zayavka.zay_id='".$_GET['zay_id']."' ";
  $result = mysql_query($query);
  if (!$result) puterror2($TEXT['error-tbl26']);
   $result2 = mysql_fetch_array($result);
         $name = $result2['zay_id'];
         $res_tema = $result2['tema'];

?>
<p><h3><?php echo $TEXT['supp-tema-now2']; ?><b><?php echo $res_tema; ?></b></h3></p>
<form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<table>
<tr><td class="useraddedit"><?php echo $TEXT['supp-num-zay']; ?></td><td class=userassociation><?php echo $name; ?></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['analiz-msg-text']; ?></td>
    <td class="useraddedit"><select class="inputmandatory" name="tema_id">
    <?php
        $query = "SELECT * FROM `tbl_supp_tema` ORDER BY `position`";
        $tema_tmp = mysql_query($query);
          if(!$tema_tmp) puterror2($TEXT['error-tbl22']);
              while($tema = mysql_fetch_array($tema_tmp))
                {
                 if($tema['tema_id'] == $old_tema_id)
                   {
                   $chk = "<option selected value=".$tema['tema_id'].">".$tema['tema']."";
                   }
                 else $chk = "<option value=".$tema['tema_id'].">".$tema['tema']."";
                 echo $chk;
                }
    ?>
    </select></td></tr>
<tr><td></td><td>
<input class=button type=submit value='<?php echo $button; ?>' />
<input type=hidden name=zay_id value='<?php echo $old_zay_id; ?>' />
<input type=hidden name=old_tema_id value='<?php echo $old_tema_id; ?>' />
</td></tr>
</table>
</form>
<?php
  require_once "../util/bottom.php";
?>