battles/tournament.php

55 lines
1.6 KiB
PHP
Raw Permalink Normal View History

<?php
use Battles\Database\Db;
use Battles\Template;
use Battles\User;
require_once "functions.php";
$Tournament = new Tournament();
Template::header('Турниры');
?>
<META HTTP-EQUIV="REFRESH" CONTENT="10">
<div style='color:#8F0000; font-weight:bold; font-size:16px; text-align:center; float:left;'>Турнирная</div>
<div style="float: right; padding-right: 6px;">
<input type="button" onclick="window.location='main.php?setch=1'" value="Вернуться">
</div>
<br>
<?php
if (!empty($_POST)) {
if ($_POST['newtournament']) {
$Tournament->CreateTournament("Еженедельные турниры");
}
if ($_POST['preptournament']) {
$Tournament->PrepearTournir();
}
if ($_POST['addzayvka']) {
$Tournament->AddUserInTournament($_POST['idtur']);
}
if ($_POST['dellzayvka']) {
$Tournament->DellUserInTournament($_POST['idtur']);
}
if ($_POST['expenemy']) {
$Tournament->expectationenemy((int)$_POST['expenemy']);
}
}
$dateD = Db::getInstance()->fetch('select datetime from turnament where old = 0 limit 1');
if (mktime() >= ($dateD['dt'] + 10)) {
$Tournament->UpdateTournir();
}
$Tournament->showAllTurnament();
if (mktime() >= ($dateD['dt'] + 10)) {
$Tournament->StartTournir();
}
$Tournament->ShowTournirFinaliats();
?>
<form method="post">
<?php if (User::getInstance()->getAdmin()) { ?>
<div>
<input type="submit" name="newtournament" value="Добавить новый турнир">
<input type="submit" name="preptournament" value="Приготовить турнир и запустить">
</div>
<?php } ?>
</form>