<?php
if(!defined('GAME')) {
	die();
}

$url = 'admin';
if(isset($_GET['light'])) { $url = 'light'; }
if(isset($_GET['dark'])) { $url = 'dark'; }

$pr = array(
	0 => 1, //молчанки
	1 => 0, //принять
	2 => 0, //выгнать
	3 => 0, //изменить звание
	4 => 0,	//редактирование новостной ленты
	5 => 0  //1 если является главой ордена
);

$align = $u->info['align'];
if( $u->info['admin'] > 0 ) {
	$i = 0;
	while( $i < count($pr) ) {
		$pr[$i] = 1;
		$i++;
	}	
}

//Покинуть ОМ
if( isset($_GET['exitsm']) ) {
	if( $pr[5] > 0 ) {
		$u->error = 'Вы являетесь Главой Ордена и не можете его покинуть.';
	}else{
		$align  = 0;
		if( $u->info['clan'] > 0 ) {
			$align = mysql_fetch_array(mysql_query('SELECT * FROM `clan` WHERE `id` = "'.$u->info['clan'].'" LIMIT 1'));
			$align = 0 + $align['align'];
		}
		$u->info['align'] = $align;
		unset($align);
		mysql_query('UPDATE `users` SET `align` = "'.$u->info['align'].'" WHERE `id` = "'.$u->info['id'].'" LIMIT 1');
		$u->error = 'Вы успешно покинули Орден Модераторов!';
		$fastend = true;
	}
}

//Сотрудники ОМ
$sx = 0;
$sh = '';
$sp = mysql_query('SELECT `id`,`align`,`login` FROM `users` WHERE (`align` > 1 AND `align` < 2) OR (`align` > 3 AND `align` < 4) ORDER BY `align` DESC');
while( $pl = mysql_fetch_array($sp) ) {
	$pr = '<img class="cp" src="//img.new-combats.tech/i/lock.gif" title="Написать" width="20" height="15" onClick="top.chat.addto(\''.$pl['login'].'\',\'private\');">';
	if( $pl['align'] == 1.99 ) {
		$sh .= '<div style="padding-bottom:5px;">'.$pr.' '.$u->microLogin($pl['id'],1).' <b style="color:red"> - Глава Ордена</b></div>';
	}else{
		$sh .= '<div>'.$pr.' '.$u->microLogin($pl['id'],1).'</div>';
	}
	$sx++;
}
if( $sh == '' ) {
	$sh= '<center>Сотрудников нет</center>';
}
?>
<script>
function mod1() {
	top.win.add(
		'mod1panel',
		'Принять в ОС &nbsp;',
		'<center>Введите логин нового сотрудника:<br><small>(можно щелкнуть по логину в чате)</small></center>',
		{
			'a1':'alert(top.$(\'#mod1v1\').val())',
			'usewin':'top.chat.inObj = top.$(\'#mod1v1\');top.$(\'#mod1v1\').focus()',
			'd':'<center><input style="width:96%; margin:5px;" id="mod1v1" class="inpt2" type="text" value=""></center>'
		},
		3,
		1,
		'min-width:300px;'
	);
	top.chat.inObj = top.$('#mod1v1');
}
</script>
<table width="100%" height="10" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td style="padding-left:55px; padding-bottom:5px; padding-top:6px; border:1px solid #a4a6a3;" bgcolor="#c7c7c7" align="left"><h3 style="text-align:left;margin:0;padding:0;">Орден Модераторов</h3></td>
    <td width="200" align="right">
    <input class="btn" onClick="location.href='/main.php?<?=$url?>';" type="button" value="Обновить">
    <input class="btn" onClick="location.href='/main.php';" type="button" value="Вернуться">
    </td>
  </tr>
</table>
<?php
if( $u->error != '' ) {
	echo '<div style="padding-top:10px;"><font color="red">'.$u->error.'</font></div>';	
	if(isset($fastend)) {
		die();
	}
}
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top">
        <fieldset style="border: 1px solid white; padding: 10px;margin-top:15px; padding-bottom:10px;">
            <legend style='font-weight:bold; color:#8F0000;'>Возможности</legend>
        
        </fieldset>
    </td>
    <td width="33%" valign="top">
        <fieldset style="border: 1px solid white; padding: 10px;margin-top:15px; padding-bottom:10px;">
            <legend style='font-weight:bold; color:#8F0000;'>Кнопки</legend>
        	<?php
			if( $pr[1] > 0 ) {
			?>
            <input onClick="mod1();" class="btn" type="button" value="Принять в ОМ">
            <?php
            }
			if( $pr[2] > 0 ) {
			?>
            <input class="btn" type="button" value="Выгнать из ОМ">
            <?php
            }
			if( $pr[3] > 0 ) {
			?>
            <input class="btn" type="button" value="Изменить звание">
            <?php
			}
			if( $pr[5] == 0 || $u->info['admin'] > 0 ) {
			?>
          <script>
			function btn5() {
				if(confirm('Вы действительно хотите покинуть Орден Модераторов?')){ top.frames['main'].location = '/main.php?<?=$url?>&exitsm'; }
			}
			</script>
          <input onclick="btn5()" class="btn" type="button" value="Покинуть Орден">
          <?php
			}
			?>
        </fieldset>
        <fieldset style="border: 1px solid white; padding: 10px;margin-top:15px; padding-bottom:10px;">
            <legend style='font-weight:bold; color:#8F0000;'>Абилки</legend>
        	Нет абилок
        </fieldset>
        <fieldset style="border: 1px solid white; padding: 10px;margin-top:15px; padding-bottom:10px;">
            <legend style='font-weight:bold; color:#8F0000;'>Сотрудники</legend>
        	<?=$sh?>
        </fieldset>
    </td>
  </tr>
</table>