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

  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(strlen($_POST['otd_id'])>11) puterror2($TEXT['error-otd9']);
  if(strlen($_POST['user_id'])>11) puterror2($TEXT['error-user1']);
  if(strlen($_POST['old_otd_id'])>11) puterror2($TEXT['error-otd12']);
  $_POST['otd_id'] = rep($_POST['otd_id']);
  $_POST['user_id'] = rep($_POST['user_id']);
  $_POST['old_otd_id'] = rep($_POST['old_otd_id']);

  $query1 = "SELECT * FROM `tbl_otdel` WHERE `otd_id` = '".$_POST['otd_id']."'";
   $res = mysql_query($query1);
    if (!$result) puterror2($TEXT['error-tbl8']);
    $result = mysql_fetch_array($res);

    $query = "UPDATE `tbl_users` SET `otd_id` = '".$_POST['otd_id']."', `otd_pos` = '".$result['position']."' WHERE `user_id`='".$_POST['user_id']."' ";
       if(mysql_query($query))
         {
         echo "<html><head>
               <meta HTTP-EQUIV='Refresh' CONTENT='0; URL=deleteform.php?otd_id=".$_POST['old_otd_id']."' />
               </head></html>";
         } else puterror2($TEXT['error-association']);
  require_once "../util/bottom.php";
?>
