88 lines
4.5 KiB
PHP
88 lines
4.5 KiB
PHP
|
|
<?php
|
||
|
|
$pageTitle = 'Cron Jobs';
|
||
|
|
$storeEnabled = (bool)($store_enabled ?? false);
|
||
|
|
$supportEnabled = (bool)($support_enabled ?? false);
|
||
|
|
$storeCron = is_array($store_cron ?? null) ? $store_cron : null;
|
||
|
|
$supportCron = is_array($support_cron ?? null) ? $support_cron : null;
|
||
|
|
ob_start();
|
||
|
|
?>
|
||
|
|
<section class="admin-card">
|
||
|
|
<div class="badge">Automation</div>
|
||
|
|
<div style="display:flex; align-items:flex-end; justify-content:space-between; gap:14px; margin-top:14px;">
|
||
|
|
<div>
|
||
|
|
<h1 style="margin:0; font-size:30px;">Cron Jobs</h1>
|
||
|
|
<p style="margin:8px 0 0; color:var(--muted); max-width:780px;">Cron jobs run server tasks in the background. Use them when tasks must run reliably without waiting for page visits.</p>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="admin-card" style="margin-top:14px; padding:12px 14px; border-radius:12px;">
|
||
|
|
<div style="display:grid; gap:6px; font-size:13px; color:var(--muted);">
|
||
|
|
<div><strong style="color:#f5f7ff;">Support IMAP Sync:</strong> <span style="color:#ffcf9a;">Required</span> if you want email replies imported into tickets.</div>
|
||
|
|
<div><strong style="color:#f5f7ff;">Store Sales Chart:</strong> <span style="color:#9ff8d8;">Recommended</span> for predictable chart refresh and lower request-time work.</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<?php if (!$storeEnabled && !$supportEnabled): ?>
|
||
|
|
<article class="admin-card" style="margin-top:14px; padding:12px 14px; border-radius:12px;">
|
||
|
|
<div style="font-size:13px; color:var(--muted);">Enable Store and/or Support plugin to show cron commands here.</div>
|
||
|
|
</article>
|
||
|
|
<?php else: ?>
|
||
|
|
<div style="display:grid; gap:12px; margin-top:14px;">
|
||
|
|
<?php foreach ([$storeCron, $supportCron] as $job): ?>
|
||
|
|
<?php if (!is_array($job)) { continue; } ?>
|
||
|
|
<article class="admin-card" style="padding:12px 14px; border-radius:12px; display:grid; gap:10px;">
|
||
|
|
<div style="display:flex; align-items:center; justify-content:space-between; gap:10px;">
|
||
|
|
<div>
|
||
|
|
<div style="font-size:11px; letter-spacing:0.2em; text-transform:uppercase; color:var(--muted);"><?= htmlspecialchars((string)($job['title'] ?? ''), ENT_QUOTES, 'UTF-8') ?></div>
|
||
|
|
<div style="color:var(--muted); font-size:13px; margin-top:6px;"><?= htmlspecialchars((string)($job['description'] ?? ''), ENT_QUOTES, 'UTF-8') ?></div>
|
||
|
|
</div>
|
||
|
|
<span class="pill"><?= htmlspecialchars((string)($job['interval'] ?? ''), ENT_QUOTES, 'UTF-8') ?></span>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div style="display:grid; grid-template-columns:1fr auto; gap:8px; align-items:center;">
|
||
|
|
<input class="input" value="<?= htmlspecialchars((string)($job['key'] ?? ''), ENT_QUOTES, 'UTF-8') ?>" readonly>
|
||
|
|
<form method="post" action="<?= htmlspecialchars((string)($job['regen_action'] ?? ''), ENT_QUOTES, 'UTF-8') ?>">
|
||
|
|
<?php foreach ((array)($job['regen_fields'] ?? []) as $k => $v): ?>
|
||
|
|
<input type="hidden" name="<?= htmlspecialchars((string)$k, ENT_QUOTES, 'UTF-8') ?>" value="<?= htmlspecialchars((string)$v, ENT_QUOTES, 'UTF-8') ?>">
|
||
|
|
<?php endforeach; ?>
|
||
|
|
<button class="btn outline small" type="submit">Regenerate Key</button>
|
||
|
|
</form>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<input class="input cron-url" value="<?= htmlspecialchars((string)($job['url'] ?? ''), ENT_QUOTES, 'UTF-8') ?>" readonly>
|
||
|
|
|
||
|
|
<div style="display:grid; grid-template-columns:1fr auto; gap:8px; align-items:start;">
|
||
|
|
<textarea class="input cron-command" rows="2" style="resize:vertical; font-family:'IBM Plex Mono', monospace; font-size:12px; line-height:1.5;" readonly><?= htmlspecialchars((string)($job['command'] ?? ''), ENT_QUOTES, 'UTF-8') ?></textarea>
|
||
|
|
<button class="btn outline small copy-cron-btn" type="button">Copy</button>
|
||
|
|
</div>
|
||
|
|
</article>
|
||
|
|
<?php endforeach; ?>
|
||
|
|
</div>
|
||
|
|
<?php endif; ?>
|
||
|
|
</section>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
(function(){
|
||
|
|
const buttons = Array.from(document.querySelectorAll('.copy-cron-btn'));
|
||
|
|
buttons.forEach((btn) => {
|
||
|
|
btn.addEventListener('click', async () => {
|
||
|
|
const wrap = btn.closest('article');
|
||
|
|
const input = wrap ? wrap.querySelector('.cron-command') : null;
|
||
|
|
if (!input) return;
|
||
|
|
try {
|
||
|
|
await navigator.clipboard.writeText(input.value);
|
||
|
|
const prev = btn.textContent;
|
||
|
|
btn.textContent = 'Copied';
|
||
|
|
setTimeout(() => { btn.textContent = prev; }, 1200);
|
||
|
|
} catch (e) {
|
||
|
|
input.focus();
|
||
|
|
input.select();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
});
|
||
|
|
})();
|
||
|
|
</script>
|
||
|
|
<?php
|
||
|
|
$content = ob_get_clean();
|
||
|
|
require __DIR__ . '/layout.php';
|