<?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.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 = "editusers.php";

  if(strlen($_GET['dol_id'])>11) puterror2($TEXT['error-post9']);
  if(strlen($_GET['user_id'])>11) puterror2($TEXT['error-user1']);
  $_GET['dol_id'] = rep($_GET['dol_id']);
  $_GET['user_id'] = rep($_GET['user_id']);

  $old_user_id = $_GET['user_id'];
  $old_dol_id = $_GET['dol_id'];

  $query = "SELECT tbl_users.user_id, tbl_users.dol_id, tbl_users.familiya, tbl_users.name, tbl_users.otchestvo, tbl_dolzhnost.dol_id, tbl_dolzhnost.dolzhnost FROM tbl_users JOIN tbl_dolzhnost ON tbl_users.dol_id=tbl_dolzhnost.dol_id WHERE tbl_users.user_id='".$_GET['user_id']."' ";
  $result = mysql_query($query);
  if(!$result) puterror2($TEXT['error-tbl2']);
   $result2 = mysql_fetch_array($result,MYSQL_ASSOC);
         $familiya = $result2['familiya'];
         $name = $result2['name'];
         $otchestvo = $result2['otchestvo'];
         $res_dol = $result2['dolzhnost'];

?>
<p><h3><?php echo $TEXT['post-now']; ?><b><?php echo $res_dol?></b></h3></p>
<form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<table>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-lastname']; ?></td><td class="userassociation"><?php echo $familiya; ?></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-name']; ?></td><td class="userassociation"><?php echo $name; ?></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-otch']; ?></td><td class="userassociation"><?php echo $otchestvo; ?></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-post']; ?></td>
    <td class="useraddedit"><select class="inputmandatory" name="dol_id">
    <?php
        $query = "SELECT * FROM `tbl_dolzhnost` ORDER BY `position`";
        $dolzhnost_tmp = mysql_query($query);
          if(!$dolzhnost_tmp) puterror2($TEXT['error-tbl6']);
              while($dolzhnost = mysql_fetch_array($dolzhnost_tmp,MYSQL_ASSOC))
                {
                 $chk = "<option value=".$dolzhnost['dol_id'].">".$dolzhnost['dolzhnost']."";
                 echo $chk;
                }
    ?>
    </select></td></tr>
<tr><td></td><td>
<input class="button" type=submit value='<?php echo $button; ?>' />
<input type=hidden name=user_id value='<?php echo $old_user_id; ?>' />
<input type=hidden name=old_dol_id value='<?php echo $old_dol_id; ?>' />
</td></tr>
</table>
</form>
<?php
  require_once "../util/bottom.php";
?>