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

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

  $title=$titlepage=$TEXT['support33'];

  require_once "../config.php";
  require_once "top_man_zay.php";
  ?>
  <title><?php echo $title; ?></title>
  <link rel="StyleSheet" type="text/css" href="../utils/reader.css" />
  </head>
  <body leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0" bottommargin="0" topmargin="0" >
  <?php
  if($result2['user'] == 1) puterror2($TEXT['error-supp11']);
  if($result2['master'] == 1 && $result2['administrator'] == 0) puterror2($TEXT['error-supp11']);

  if(!isset($button)) $button = $TEXT['support16'];
  if(!isset($action)) $action = "zayavka_man_add.php";
?>
<form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
  <table align='center' border='0' width='90%' cellpadding='0' cellspacing='0'>
    <tr>
      <td>
         <fieldset class='zayavka' >
         <legend align="left" title="<?php echo $TEXT['support3']; ?>"><?php echo $TEXT['support12']; ?></legend>
          <table align='center' border='0' width='100%' cellpadding='0' cellspacing='0'>
             <tr><td align="right" width="30%" class="support">&nbsp;</td><td class="support" width="80%" align="left">&nbsp;</td></tr>
             <tr><td align="right" width="20%" class="support"><?php echo $TEXT['support13']; ?>:&nbsp;</td>
                 <td width="70%" class="support" align="left">
                   <select class="support" name="tema_id" onchange=window.location.href=this.options[this.selectedIndex].value;>
                   <?php
                   $query = "SELECT * FROM `tbl_supp_tema` WHERE `visible` = 'show' ORDER BY position ";
                    $tema_tmp = mysql_query($query);
                     if(!$tema_tmp) puterror2($TEXT['error-tbl22']);
                      while($tema = mysql_fetch_array($tema_tmp,MYSQL_ASSOC))
                       {
                       if($tema['tema_id'] == $_GET['tema_id'])
                        {
                       $chk = "<option selected value=zayavka_man.php?tema_id=".$tema['tema_id'].">".$tema['tema']."</option>";
                       if(!empty($_GET['tema_id'])) {$tema_id_tmp=$_GET['tema_id'];} else {$tema_id_tmp=$tema['tema_id'];}
                       $query_sh = "SELECT shablon FROM `tbl_supp_tema` WHERE tema_id='".$_GET['tema_id']."' ";
                        $tema_tmp_sh = mysql_query($query_sh);
                         if(!$tema_tmp_sh) puterror2($TEXT['error-tbl22']);
                         $tema_sh = mysql_fetch_array($tema_tmp_sh,MYSQL_ASSOC);
                          $shablon = $tema_sh['shablon'];
                        }
                        else
                        {
                        $chk = "<option value=zayavka_man.php?tema_id=".$tema['tema_id'].">".$tema['tema']."</option>";
                       if(!empty($_GET['tema_id'])) 
                         {
                       $query_sh = "SELECT shablon FROM `tbl_supp_tema` WHERE tema_id='".$_GET['tema_id']."' ";
                        $tema_tmp_sh = mysql_query($query_sh);
                         if(!$tema_tmp_sh) puterror2($TEXT['error-tbl22']);
                         $tema_sh = mysql_fetch_array($tema_tmp_sh,MYSQL_ASSOC);
                          $shablon = $tema_sh['shablon'];
                         }
                         else 
                         {
                       $query_sh = "SELECT shablon FROM `tbl_supp_tema` ORDER BY position ";
                        $tema_tmp_sh = mysql_query($query_sh);
                         if(!$tema_tmp_sh) puterror2($TEXT['error-tbl22']);
                         $tema_sh = mysql_fetch_array($tema_tmp_sh,MYSQL_ASSOC);
                          $shablon = $tema_sh['shablon'];
                         }
                        }
                       echo $chk;
                       }
                   ?>
                 </select>
               </td>
             </tr>
             <tr><td align="right" width="20%" class="support"><?php echo $TEXT['support41']; ?>:&nbsp;</td>
                 <td width="70%" class="support" align="left">
                   <select class="support" name="sroch_id">
                   <?php
                   $query_sr = "SELECT * FROM `tbl_supp_srochnost` ORDER BY position ";
                    $sroch_tmp = mysql_query($query_sr);
                     if(!$sroch_tmp) puterror2($TEXT['error-tbl24']);
                      while($sroch = mysql_fetch_array($sroch_tmp,MYSQL_ASSOC))
                       {
                       $chk = "<option value=".$sroch['sroch_id'].">".$sroch['srochnost']."</option>";
                       echo $chk;
                       }
                   ?>
                 </select>
               </td>
             </tr>
             <tr><td align="right" width="20%" class="support"><?php echo $TEXT['support40']; ?>:&nbsp;</td>
                 <td width="70%" class="support" align="left">
                   <select class="support" name="sost_id">
                   <?php
                   $query_st = "SELECT * FROM `tbl_supp_sostoyanie` ORDER BY position ";
                    $sost_tmp = mysql_query($query_st);
                     if(!$sost_tmp) puterror2($TEXT['error-tbl23']);
                      while($sost = mysql_fetch_array($sost_tmp,MYSQL_ASSOC))
                       {
                       if($sost['sost_id'] == $zayavka['sost_id'])
                       {
                       $chk = "<option selected value=".$sost['sost_id'].">".$sost['sostoyanie']."";
                       }
                       else $chk = "<option value=".$sost['sost_id'].">".$sost['sostoyanie']."";
                       echo $chk;
                       }
                   ?>
                 </select>
               </td>
             </tr>
             <tr><td align="right" width="20%" class="support"><?php echo $TEXT['support119']; ?>:&nbsp;</td>
                 <td width="70%" class="support" align="left">
                   <select class="support" name="user_id">
                   <?php
                   $query_usr = "SELECT `user_id`, `familiya`, `name`, `otchestvo` FROM `tbl_users` ORDER BY familiya, name, otchestvo";
                    $usr_tmp = mysql_query($query_usr);
                     if(!$usr_tmp) puterror2($TEXT['error-tbl2']);
                      while($usr = mysql_fetch_array($usr_tmp,MYSQL_ASSOC))
                       {
                       $chk = "<option value=".$usr['user_id'].">".$usr['familiya']." ".$usr['name']." ".$usr['otchestvo']."</option>";
                       echo $chk;
                       }
                   ?>
                 </select>
                 <input type="checkbox" name="usr_chb" />
               </td>
             </tr>
             <tr>
               <td align="right" width="20%" class="support"><?php echo $TEXT['support43']; ?>:&nbsp;</td>
               <td class="support" width="70%" align="left">
                   <select class="support" name="mast_id">
                   <?php
                   $query_mast2 = "SELECT * FROM `tbl_logins` WHERE `master`='1' ORDER BY fullname ";
                    $mast_tmp = mysql_query($query_mast2);
                     if(!$mast_tmp) puterror2($TEXT['error-tbl20']);
                      while($mast = mysql_fetch_array($mast_tmp,MYSQL_ASSOC))
                       {
                       if($mast['login_id'] == $zayavka['mast_id']) $chk = "<option selected value=".$mast['login_id'].">".$mast['fullname']."";
                        else $chk = "<option value=".$mast['login_id'].">".$mast['fullname']."";
                       echo $chk;
                       }
                   ?>
                 </select>
                 <input type="checkbox" name="mast_chb" />
               </td>
             </tr>
             <tr>
               <td align="right" width="30%" class="support">&nbsp;<?php echo $TEXT['support14']; ?>:&nbsp;</td>
               <td class="support" width="70%" align="left"><textarea cols="70" rows="5" name=description ><?php echo $shablon; ?></textarea></td>
             </tr>
             <tr>
               <td align="right" width="30%" class="support">&nbsp;<?php echo $TEXT['support15']; ?>:&nbsp;</td>
               <td class="support" width="70%" align="left"><input class="support" type=file name=image ></td>
             </tr>
             <tr>
               <td align="right" width="30%" class="support">&nbsp;<?php echo $TEXT['support53']; ?>:&nbsp;</td>
               <td class="support" width="70%" align="left"><input class="support" size=20 maxlength=19 type=text name=data_post >&nbsp;(2012-08-08 01:32:46,&nbsp;<?php echo $TEXT['support122']; ?>)</td>
             </tr>
             <tr>
               <td align="right" width="30%" class="support">&nbsp;<?php echo $TEXT['support20']; ?>&nbsp;</td>
               <td class="support" width="70%" align="left"><input class="support" size=20 maxlength=100 type=password name=kod >&nbsp;(<?php echo $TEXT['support122']; ?>)</td>
             </tr>
             <tr><td align="right" width="30%" class="support">&nbsp;</td><td class="support" width="80%" align="left">&nbsp;</td></tr>
             <tr>
               <td align="right" width="30%" class="support">&nbsp;</td>
               <td class="support" width="70%" align="left"><input class=button type=submit value='<?php echo $button; ?>'></td></tr>
             </tr>
             <tr><td align="right" width="30%" class="support">&nbsp;</td><td class="support" width="80%" align="left">&nbsp;
               <input type=hidden name=org_id value='<?php echo $org_id; ?>'>
               </td></tr>
          </table>
       </fieldset>
      </td>
     </tr>
   </table>
</form>
</body>
</html>