<?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['size_id'])>2) puterror2($TEXT['error-size6']);
  if(strlen($_GET['res_id'])>11) puterror2($TEXT['error-res11']);
  $_GET['size_id'] = rep($_GET['size_id']);
  $_GET['res_id'] = rep($_GET['res_id']);

  $old_res_id = $_GET['res_id'];
  $old_size_id = $_GET['size_id'];

  $query = "SELECT 
  tbl_resource.res_id, 
  tbl_resource.size_id, 
  tbl_resource.resource, 
  tbl_size.size_id, 
  tbl_size.size_name 
  FROM tbl_resource
  JOIN tbl_sizes ON tbl_resource.size_id=tbl_sizes.size_id 
  WHERE tbl_resource.res_id='".$_GET['res_id']."' ";
  $result = mysql_query($query);
  if(!$result) puterror2($TEXT['error-tbl16']);
   $result2 = mysql_fetch_array($result,MYSQL_ASSOC);
         $resource = $result2['resource'];
         $res_size = $result2['size_name'];

?>
<p><h3><?php echo $TEXT['size-now']; ?><b><?php echo $res_size; ?></b></h3></p>
<form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<table>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-resource']; ?></td><td class="userassociation"><?php echo $resource; ?></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-size']; ?></td>
    <td class="useraddedit"><select class="inputmandatory" name="size_id">
    <?php
        $query = "SELECT * FROM `tbl_sizes` ORDER BY `size_id`";
        $size_tmp = mysql_query($query);
          if(!$size_tmp) puterror2($TEXT['error-tbl35']);
              while($size = mysql_fetch_array($size_tmp,MYSQL_ASSOC))
                {
                 $chk = "<option value=".$size['size_id'].">".$size['size_name']."";
                 echo $chk;
                }
    ?>
    </select></td></tr>
<tr><td></td><td>
<input class="button" type=submit value='<?php echo $button; ?>' />
<input type=hidden name=res_id value='<?php echo $old_res_id; ?>' />
<input type=hidden name=old_size_id value='<?php echo $old_size_id; ?>' />
</td></tr>
</table>
</form>
<?php
  require_once "../util/bottom.php";
?>