<?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['domain-title3'];
  $helppage = $TEXT['domain-help3'];

  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['domain-title3'];
  if(!isset($button)) $button = $TEXT['btn_del'];
  if(!isset($action)) $action = "delete.php";
  if(!isset($button2)) $button2 = $TEXT['btn_back'];
  if(!isset($action2)) $action2 = "index.php";
  if(empty($_GET['dom_id'])) $_GET['dom_id'] = "";
  if(empty($_POST['dom_id'])) $_POST['dom_id'] = "";
?>
<table class="table" border="0" cellpadding="2" cellspacing="0" width="40%" >
<?php
  if(strlen($_GET['dom_id'])>11) puterror2($TEXT['error-domain6']);
  if(strlen($_POST['dom_id'])>11) puterror2($TEXT['error-domain6']);
  $_GET['dom_id'] = rep($_GET['dom_id']);
  $_POST['dom_id'] = rep($_POST['dom_id']);

  $old_dom_id = $_GET['dom_id'];
  $old_user_dom_id = $_POST['dom_id'];

  if(empty($_GET['dom_id'])) $dom_id = $old_user_dom_id;
    else $dom_id = $old_dom_id;

  $query = "SELECT `domain` FROM `tbl_domain` WHERE `dom_id`='$dom_id'";
  $result = mysql_query($query);
  if (!$result) puterror2($TEXT['error-tbl5']);
       if (mysql_num_rows($result)>0);
         {
          $result_domain = mysql_fetch_array($result);
           echo "<tr class='delit'>
              <td>".$TEXT['domain-del'].$result_domain['domain']."</td>
              </tr>";
          }
?>
</table>
<?php
  $query2 = "SELECT tbl_users.user_id, tbl_users.dom_id, tbl_users.familiya, tbl_users.name, tbl_users.otchestvo, tbl_domain.dom_id, tbl_domain.domain FROM tbl_users JOIN tbl_domain ON tbl_users.dom_id=tbl_domain.dom_id WHERE tbl_users.dom_id='$dom_id'";
  $result2 = mysql_query($query2);
  if (!$result2) puterror2($TEXT['error-tbl2']);
          $num_rows = mysql_num_rows($result2);
          if ($num_rows>0)
          {
           echo "<p><u>".$TEXT['global-title3']."</u></p>
            <table class='table' border='1' cellpadding='3' cellspacing='0' width='40%' bordercolordark='white' bordercolorlight='black'>
            <tr class='tableheadercat'>
            <td>".$TEXT['tbl-lastname']."</td>
            <td>".$TEXT['tbl-name']."</td>
            <td>".$TEXT['tbl-otch']."</td>
            <td>".$TEXT['tbl-domain']."</td>
            <td colspan=3>".$TEXT['tbl-action']."</td>
                 </tr>";
           while($result_users = mysql_fetch_array($result2))
               {
              $res_dom = $result_users['domain'];
              $edit = "<a href=editusersform.php?dom_id=".$result_users['dom_id']."&user_id=".$result_users['user_id']." title='".$TEXT['tbl-edit2-tit']."'>".$TEXT['tbl-edit2']."</a>";
            ?>
           <tr class='tabledata' onmouseover="this.style.backgroundColor='#cccccc';" onmouseout="this.style.backgroundColor='#ffffff';">
            <td><?php echo $result_users['familiya']; ?></td>
            <td><?php echo $result_users['name']; ?></td>
            <td><?php echo $result_users['otchestvo']; ?></td>
            <td><b><i><?php echo $res_dom; ?></i></b></td>
            <td><?php echo $edit; ?></td>
                 </tr>
            <?php
               }
	?>
	</table>
	<?php
          }
          if($num_rows !== 0) $action_end = $action2;
          else $action_end = $action;

          if($num_rows !== 0) $button_end = $button2;
          else $button_end = $button;
?>
<form enctype='multipart/form-data' action=<?php echo $action_end; ?> method=post>
<table align='center'>
<tr><td></td><td>
<input class="button" type=submit value='<?php echo $button_end; ?>' />
<input type=hidden name=dom_id value='<?php echo $old_dom_id; ?>' />
</td></tr>
</table>
</form>
<?php
  require_once "../util/bottom.php";
?>