117 lines
4.0 KiB
PHP
117 lines
4.0 KiB
PHP
<?php
|
||
|
||
use Battles\Clan;
|
||
use Battles\GameConfigs;
|
||
use Battles\Nick;
|
||
use Battles\Rooms;
|
||
use Battles\Template;
|
||
|
||
session_start();
|
||
require_once 'functions.php';
|
||
|
||
if (!$user->getClan()) {
|
||
exit('Ошибка! Вы не состоите в клане!');
|
||
}
|
||
|
||
Clan::$current = new Clan($user, $db);
|
||
if ($user->getClan() != Clan::$current->getClanShortName()) {
|
||
exit('Ошибка! Клана ' . $user->getClan() . ' не существует!');
|
||
}
|
||
|
||
Template::header('clan');
|
||
?>
|
||
<style>
|
||
.row {
|
||
cursor: default;
|
||
}
|
||
.column {
|
||
padding: 10px;
|
||
}
|
||
|
||
.left {
|
||
width: 60%;
|
||
float: left;
|
||
}
|
||
|
||
.right {
|
||
width: 30%;
|
||
float: right;
|
||
}
|
||
|
||
.row:after {
|
||
content: "";
|
||
display: table;
|
||
clear: both;
|
||
}
|
||
</style>
|
||
<div>
|
||
<button onclick="location.href='main.php'">Вернуться</button>
|
||
<?php if (!empty($_POST['login']) && !empty($_POST['action'])): ?>
|
||
<span class="error">
|
||
<?php if ($_POST['action'] == 'add_member'): ?>
|
||
<?= Clan::$current->addMember($_POST['login']) ?>
|
||
<?php endif; ?>
|
||
<?php if ($_POST['action'] == 'remove_member'): ?>
|
||
<?= Clan::$current->removeMember($_POST['login']) ?>
|
||
<?php endif; ?>
|
||
<?php if ($_POST['action'] == 'change_owner'): ?>
|
||
<?= Clan::$current->changeOwner($_POST['login']) ?>
|
||
<?php endif; ?>
|
||
</span>
|
||
<?php endif; ?>
|
||
</div>
|
||
<div class="row">
|
||
<div class="column left">
|
||
<h3><img src="./i/clan/<?= Clan::$current->getClanShortName() ?>.png"
|
||
alt="<?= Clan::$current->getClanShortName() ?>"><?= Clan::$current->getClanName() ?></h3>
|
||
|
||
<?php if (Clan::$current->getClanOwnerId() === $user->getId()): ?>
|
||
<div>
|
||
<span id="add_member">
|
||
<input type="submit" onclick="use('add_member')" value="Принять в клан">
|
||
</span>
|
||
[стоимость: <?= GameConfigs::CLAN['add_member_cost'] ?>]
|
||
</div>
|
||
<div>
|
||
<span id="remove_member">
|
||
<input type="submit" onclick="use('remove_member')" value="Выгнать из клана">
|
||
</span>
|
||
[стоимость: <?= GameConfigs::CLAN['remove_member_cost'] ?>]
|
||
</div>
|
||
<div>
|
||
<span id="change_owner">
|
||
<input type="submit" onclick="use('change_owner')" value="Сменить главу клана">
|
||
</span>
|
||
(сложить с себя полномочия, назначив <strong style="color: teal;">Главой Клана</strong> другого
|
||
персонажа)
|
||
</div>
|
||
<?php endif; ?>
|
||
</div>
|
||
<div class="column right">
|
||
<table class='zebra' style='width: 100%;'>
|
||
<caption><h3>Соклановцы</h3></caption>
|
||
<tr>
|
||
<th id='c1'>Имя</th>
|
||
<th id='c2'>Местонахождение</th>
|
||
</tr>
|
||
<?php foreach (Clan::$current->getMemberlist() as $member): ?>
|
||
<tr>
|
||
<td>
|
||
<?php if ($member->clan_owner): ?>
|
||
👑
|
||
<?php endif; ?>
|
||
<?= Nick::id($member->id)->full() ?>
|
||
</td>
|
||
<td>
|
||
<em style='font-size: smaller;'><?= $member->room ? Rooms::$roomNames[$member->room] : 'Персонаж не в игре' ?></em>
|
||
</td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
<script type="text/javascript">
|
||
function use(option) {
|
||
document.getElementById(option).innerHTML = "<form method='post'><input placeholder='Имя персонажа' name='login'><button name='action' value='" + option + "' type='submit'>Ок</button><button>×</button></form>";
|
||
}
|
||
</script>
|