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

  if(strlen($_GET['org_id'])>11) puterror2($TEXT['error-org1']);
  if(strlen($_GET['res_id'])>11) puterror2($TEXT['error-res11']);
  $_GET['org_id'] = rep($_GET['org_id']);
  $_GET['res_id'] = rep($_GET['res_id']);

  $old_res_id = $_GET['res_id'];
  $old_org_id = $_GET['org_id'];

  $query = "SELECT tbl_resource.*, tbl_organizaciya.org_id, tbl_organizaciya.organizaciya FROM tbl_resource JOIN tbl_organizaciya ON tbl_resource.org_id=tbl_organizaciya.org_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);
         $res = $result2['resource'];
         $res_org = $result2['organizaciya'];

?>
<p><h3><?php echo $TEXT['org-now2']; ?><b><?php echo $res_org ?></b></h3></p>
<form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<table>
<tr><td class="useraddedit"><?php echo $TEXT['res-field3']; ?></td><td class="userassociation"><?php echo $res; ?></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-org']; ?></td>
    <td class="useraddedit"><select class="inputmandatory" name="org_id">
    <?php
        $query = "SELECT `org_id`, `organizaciya` FROM `tbl_organizaciya` ORDER BY `position`";
        $organizaciya_tmp = mysql_query($query);
          if(!$organizaciya_tmp) puterror2($TEXT['error-tbl7']);
              while($organizaciya = mysql_fetch_array($organizaciya_tmp,MYSQL_ASSOC))
                {
                 $chk = "<option value=".$organizaciya['org_id'].">".$organizaciya['organizaciya']."";
                 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_org_id value='<?php echo $old_org_id; ?>' />
</td></tr>
</table>
</form>
<?php
  require_once "../util/bottom.php";
?>