nativegallery/views/pages/Contests/VotingSendPretend.php

186 lines
7.8 KiB
PHP
Raw Normal View History

2025-02-15 04:54:12 +03:00
<?php
use \App\Services\{Auth, DB, Date};
use \App\Models\{Vehicle, User};
2025-02-16 06:18:52 +03:00
function convertUnixToRussianDateTime($unixTime)
{
2025-02-15 04:54:12 +03:00
// Создаем объект DateTime из Unix-времени
$dateTime = new DateTime("@$unixTime");
2025-02-16 06:18:52 +03:00
2025-02-15 04:54:12 +03:00
// Устанавливаем временную зону (можно изменить на нужную)
$dateTime->setTimezone(new DateTimeZone('Europe/Moscow'));
2025-02-16 06:18:52 +03:00
2025-02-15 04:54:12 +03:00
// Форматируем дату и время с использованием IntlDateFormatter
$formatter = new IntlDateFormatter(
2025-02-16 06:18:52 +03:00
'ru_RU',
IntlDateFormatter::LONG,
2025-02-15 04:54:12 +03:00
IntlDateFormatter::NONE,
'Europe/Moscow',
IntlDateFormatter::GREGORIAN,
'd MMMM yyyy года в H:mm'
);
2025-02-16 06:18:52 +03:00
2025-02-15 04:54:12 +03:00
return $formatter->format($dateTime);
}
?>
<!DOCTYPE html>
<html lang="ru">
<head>
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/LoadHead.php'); ?>
</head>
<body>
<div id="backgr"></div>
<table class="tmain">
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/Navbar.php'); ?>
<tr>
<td class="main">
<h1>Принять участие в Фотоконкурсе</h1>
<script src="/js/jquery-ui.js?1633005526"></script>
<script src="/js/selector.js?1730197663"></script>
2025-02-16 06:18:52 +03:00
<form id="sendForm" method="post" id="mform">
2025-02-15 04:54:12 +03:00
<h4>В каком Фотоконкурсе вы хотите принять участие?</h4>
<div class="p20w">
<table>
<tbody>
<tr>
<th></th>
<th>Тематика</th>
<th>Старт набора претендентов</th>
<th>Закрытие набора претендентов</th>
<th>Начало проведения</th>
<th>Итоги и победители</th>
</tr>
2025-02-16 06:18:52 +03:00
2025-02-15 04:54:12 +03:00
<?php
2025-02-16 06:18:52 +03:00
$entities = DB::query('SELECT * FROM contests WHERE closepretendsdate>=:id', array(':id' => time()));
2025-02-15 04:54:12 +03:00
foreach ($entities as $e) {
2025-02-16 06:18:52 +03:00
$theme = DB::query('SELECT * FROM contests_themes WHERE id=:id', array(':id' => $e['themeid']))[0];
2025-02-15 04:54:12 +03:00
echo '<tr>
2025-02-16 06:18:52 +03:00
<td class="ds"><input type="radio" name="cid" id="n' . $e['id'] . '" value="' . $e['id'] . '" onclick="fillFields(' . $e['id'] . ')"></td>
<td class="n">' . $theme['title'] . '</td>
<td class="ds">' . convertUnixToRussianDateTime($e['openpretendsdate']) . '</td>
<td class="ds">' . convertUnixToRussianDateTime($e['closepretendsdate']) . '</td>
<td class="ds">' . convertUnixToRussianDateTime($e['opendate']) . '</td>
<td class="ds">' . convertUnixToRussianDateTime($e['closedate']) . '</td>
2025-02-15 04:54:12 +03:00
</tr>';
}
?>
2025-02-16 06:18:52 +03:00
2025-02-15 04:54:12 +03:00
</tbody>
</table>
</div>
<br clear="all"><br>
<div class="p20" style="padding-left:5px; margin-bottom:15px">
<table class="nospaces" width="100%">
<tbody>
<?php
$vehicle = DB::query('SELECT * FROM entities WHERE id=:id', array(':id' => $_GET['type']))[0];
$data = json_decode($vehicle['sampledata'], true);
$count = 1;
foreach ($data as $d) {
2025-02-16 06:18:52 +03:00
2025-02-15 04:54:12 +03:00
if ($d['important'] === "1") {
$imp = 'required';
}
echo '
<tr>
<td class="lcol">' . $d['name'] . '</td>
2025-02-16 06:18:52 +03:00
<td style="padding-bottom:15px"><input type="text" name="modelinput_' . $count . '" id="num" style="width:80px" maxlength="21" value=""></td>
2025-02-15 04:54:12 +03:00
</tr>';
2025-02-16 06:18:52 +03:00
$count++;
2025-02-15 04:54:12 +03:00
}
?>
<tr>
<td style="width: 10%"></td>
2025-02-16 06:18:52 +03:00
2025-02-15 04:54:12 +03:00
</tr>
<tr>
2025-02-16 06:18:52 +03:00
<tr>
<td class="lcol">Фотография, которую вы хотите отправить на Фотоконкурс</td>
<td style="padding-bottom:15px">
<select id="photoId" name="photo_id">
<option value="'.$p['id'].'" disabled selected>Выберите фотографию</option>
<?php
$photos = DB::query('SELECT * FROM photos WHERE user_id=:uid AND on_contest=0', array(':uid' => Auth::userid()));
foreach ($photos as $p) {
$content = json_decode($p['content'], true);
if ($content['video'] === null) {
echo '<option photourl="/api/photo/compress?url=' . $p['photourl'] . '" value="' . $p['id'] . '">[ID: ' . $p['id'] . '] ' . $p['place'] . '</option>';
}
}
?>
</select>
2025-02-15 04:54:12 +03:00
</td>
</tr>
2025-02-16 06:18:52 +03:00
<td>
<div id="result"></div>
</td>
<td>
<br>
<input type="submit" value="&nbsp; &nbsp; &nbsp; Отправить &nbsp; &nbsp; &nbsp;">
</td>
2025-02-15 04:54:12 +03:00
</tr>
2025-02-16 06:18:52 +03:00
</tbody>
</table>
</div>
</form>
</td>
</tr>
<script>
$('#sendForm').submit(function(e) {
e.preventDefault();
$.ajax({
type: "POST",
url: '/api/photo/contests/sendpretend',
data: $(this).serialize(),
success: function(response) {
var jsonData = JSON.parse(response);
}
});
});
document.getElementById('photoId').addEventListener('change', function() {
const selectedOption = this.options[this.selectedIndex];
const photoUrl = selectedOption.getAttribute('photourl');
if (photoUrl) {
const imgElement = document.createElement('img');
imgElement.src = photoUrl;
imgElement.alt = 'Изображение';
imgElement.style.maxWidth = '500px';
const resultDiv = document.getElementById('result');
resultDiv.innerHTML = '';
resultDiv.appendChild(imgElement);
}
});
</script>
<tr>
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/Footer.php'); ?>
</tr>
2025-02-15 04:54:12 +03:00
</table>
</body>
</html>