Joywork/admin/import.php
2026-05-22 21:21:54 +03:00

63 lines
2.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
ini_set('display_errors', 1);
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
// закрываем доступ на выполнение запросов
if (!isset($_SESSION['superadmin'])) {
header("location:/index.php");
die("Доступ запрещён!");
}
include $_SERVER['DOCUMENT_ROOT'] . '/import/ImporterService.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/ImportReport.php';
if (isset($_GET['run']) && $_GET['run'] == 1) {
(new ImporterService())->setForceImport(1);
header("location:/admin/import.php");
}
$importerService = new ImporterService();
$willBeRun = $importerService->isForceStart();
$isImporterActive = $importerService->isActive();
require_once($_SERVER['DOCUMENT_ROOT'] . "/templates/header-admin.php");
?>
<div class="main-title">
<h1>Выгрузка</h1>
</div>
<br/>
<div class="users">
<?php if ($willBeRun && !$isImporterActive):?>
<div style="color: red;">Выгрузка будет запущена в ближайшие 5 минут.</div>
<?php endif; ?>
<?php if ($isImporterActive):?>
<div style="color: red;">В данный момент работает выгрузка.</div>
<?php endif; ?>
<?php if (!$willBeRun && !$isImporterActive) { ?>
<div>
<a href="/admin/import.php?run=1" class="medium-button runImport" >Запустить выгрузку</a>
</div>
<?php } ?>
<br/>
<br/>
<div>Логи за последние 2 недели:</div>
<br/>
<ul style="list-style: inside; line-height: 2;">
<?php foreach(ImportReport::getList() as $ts => $file): ?>
<li><a target="_blank" href="https://joywork.ru/import/reports/<?php echo $file; ?>"><?php echo date('H:i d-m-y', $ts); ?></a></li>
<?php endforeach; ?>
</ul>
</div>
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/templates/footer-admin.php");
?>