<?php
  ///////////////////////////////////////////////////
  //2007 (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['global-title'];
  require_once "config.php";
  require_once "utils/top.php";
?>
<table class="table" border="0" cellpadding="0" cellspacing="0" width="85%">
<tbody>
<?php
  $query1 = "SELECT DISTINCT `org_id` FROM `tbl_users` WHERE `org_id` != '0' ORDER BY org_pos ";
  $tmp_org = mysql_query($query1);
    if(!$tmp_org) puterror($TEXT['error-tbl2']);
        while($org_res = mysql_fetch_array($tmp_org,MYSQL_ASSOC))
         if(mysql_num_rows($tmp_org)==1) echo "<html><head><meta HTTP-EQUIV='Refresh' CONTENT='0; URL=upravlenie.php?org_id=".$org_res['org_id']."' /></head></html>";
          else
          {
          $query2 = "SELECT * FROM `tbl_organizaciya` WHERE `visible` = 'show' AND `org_id` = '".$org_res['org_id']."' ";
             $organizaciya = mysql_query($query2);
                if(!$organizaciya) puterror($TEXT['error-tbl7']);
                   while($org = mysql_fetch_array($organizaciya,MYSQL_ASSOC))
                    {
                    echo "<tr><td><a class='texttableusrtit' href='upravlenie.php?org_id=".$org['org_id']."'>".$org['organizaciya']."</a></td></tr>";
                    }
           }
?>
</tbody>
</table>
<?php
  require_once "utils/bottom.php";
?>