198 lines
5.8 KiB
PHP
198 lines
5.8 KiB
PHP
|
|
<?php
|
||
|
|
$pageTitle = $title ?? 'Contact';
|
||
|
|
$error = (string)($error ?? '');
|
||
|
|
$ok = (string)($ok ?? '');
|
||
|
|
$supportTypes = is_array($support_types ?? null) ? $support_types : [];
|
||
|
|
$supportTypes = $supportTypes ?: [['key' => 'general', 'label' => 'General', 'fields' => []]];
|
||
|
|
$supportTypesJson = json_encode($supportTypes, JSON_UNESCAPED_SLASHES) ?: '[]';
|
||
|
|
ob_start();
|
||
|
|
?>
|
||
|
|
<section class="card" style="display:grid; gap:14px;">
|
||
|
|
<div class="badge">Support</div>
|
||
|
|
<h1 style="margin:0; font-size:34px;">Contact</h1>
|
||
|
|
<p style="margin:0; color:var(--muted);">Send us a message and we will open a support ticket.</p>
|
||
|
|
|
||
|
|
<?php if ($error !== ''): ?>
|
||
|
|
<div class="support-alert support-alert-error"><?= htmlspecialchars($error, ENT_QUOTES, 'UTF-8') ?></div>
|
||
|
|
<?php endif; ?>
|
||
|
|
<?php if ($ok !== ''): ?>
|
||
|
|
<div class="support-alert support-alert-ok"><?= htmlspecialchars($ok, ENT_QUOTES, 'UTF-8') ?></div>
|
||
|
|
<?php endif; ?>
|
||
|
|
|
||
|
|
<form method="post" action="/contact" class="support-form">
|
||
|
|
<div class="support-grid-2">
|
||
|
|
<div class="support-field">
|
||
|
|
<label class="label support-label">Name</label>
|
||
|
|
<input class="support-input" name="name" required>
|
||
|
|
</div>
|
||
|
|
<div class="support-field">
|
||
|
|
<label class="label support-label">Email</label>
|
||
|
|
<input class="support-input" type="email" name="email" required>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="support-field">
|
||
|
|
<label class="label support-label">Support Type</label>
|
||
|
|
<select class="support-input" id="supportType" name="support_type">
|
||
|
|
<?php foreach ($supportTypes as $i => $type): ?>
|
||
|
|
<option value="<?= htmlspecialchars((string)$type['key'], ENT_QUOTES, 'UTF-8') ?>" <?= $i === 0 ? 'selected' : '' ?>>
|
||
|
|
<?= htmlspecialchars((string)$type['label'], ENT_QUOTES, 'UTF-8') ?>
|
||
|
|
</option>
|
||
|
|
<?php endforeach; ?>
|
||
|
|
</select>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div id="supportExtraFields" class="support-extra-fields"></div>
|
||
|
|
|
||
|
|
<div class="support-field">
|
||
|
|
<label class="label support-label">Subject</label>
|
||
|
|
<input class="support-input" name="subject" required>
|
||
|
|
</div>
|
||
|
|
<div class="support-field">
|
||
|
|
<label class="label support-label">Message</label>
|
||
|
|
<textarea class="support-input support-textarea" name="message" rows="7" required></textarea>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="support-actions">
|
||
|
|
<button class="support-btn" type="submit">Create Ticket</button>
|
||
|
|
</div>
|
||
|
|
</form>
|
||
|
|
</section>
|
||
|
|
|
||
|
|
<style>
|
||
|
|
.support-form {
|
||
|
|
display: grid;
|
||
|
|
gap: 18px;
|
||
|
|
margin-top: 10px;
|
||
|
|
padding: 18px;
|
||
|
|
border-radius: 16px;
|
||
|
|
border: 1px solid rgba(255,255,255,0.08);
|
||
|
|
background: rgba(8,10,16,0.38);
|
||
|
|
}
|
||
|
|
.support-field {
|
||
|
|
display: grid;
|
||
|
|
gap: 8px;
|
||
|
|
}
|
||
|
|
.support-label {
|
||
|
|
display: inline-block;
|
||
|
|
margin: 0;
|
||
|
|
font-size: 11px;
|
||
|
|
letter-spacing: .18em;
|
||
|
|
text-transform: uppercase;
|
||
|
|
color: rgba(236, 242, 255, 0.78);
|
||
|
|
}
|
||
|
|
.support-grid-2 {
|
||
|
|
display: grid;
|
||
|
|
grid-template-columns: 1fr 1fr;
|
||
|
|
gap: 14px;
|
||
|
|
}
|
||
|
|
.support-input {
|
||
|
|
width: 100%;
|
||
|
|
height: 42px;
|
||
|
|
border-radius: 11px;
|
||
|
|
border: 1px solid rgba(255,255,255,0.14);
|
||
|
|
background: rgba(7,10,16,0.72);
|
||
|
|
color: #ecf1ff;
|
||
|
|
padding: 0 12px;
|
||
|
|
font-size: 14px;
|
||
|
|
outline: none;
|
||
|
|
transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
|
||
|
|
}
|
||
|
|
.support-input:focus {
|
||
|
|
border-color: rgba(34,242,165,.55);
|
||
|
|
box-shadow: 0 0 0 2px rgba(34,242,165,.14);
|
||
|
|
background: rgba(9,13,20,0.9);
|
||
|
|
}
|
||
|
|
.support-textarea {
|
||
|
|
min-height: 180px;
|
||
|
|
height: auto;
|
||
|
|
resize: vertical;
|
||
|
|
padding: 11px 12px;
|
||
|
|
line-height: 1.6;
|
||
|
|
}
|
||
|
|
.support-actions {
|
||
|
|
display: flex;
|
||
|
|
justify-content: flex-end;
|
||
|
|
}
|
||
|
|
.support-extra-fields {
|
||
|
|
display: grid;
|
||
|
|
gap: 14px;
|
||
|
|
}
|
||
|
|
.support-btn {
|
||
|
|
height: 42px;
|
||
|
|
border-radius: 999px;
|
||
|
|
border: 1px solid rgba(34,242,165,.85);
|
||
|
|
background: linear-gradient(180deg, #2df5ae, #1ddf98);
|
||
|
|
color: #08150f;
|
||
|
|
padding: 0 20px;
|
||
|
|
font-size: 12px;
|
||
|
|
text-transform: uppercase;
|
||
|
|
letter-spacing: .18em;
|
||
|
|
font-weight: 700;
|
||
|
|
cursor: pointer;
|
||
|
|
}
|
||
|
|
.support-btn:hover { filter: brightness(1.04); }
|
||
|
|
.support-alert {
|
||
|
|
padding: 12px 14px;
|
||
|
|
border-radius: 12px;
|
||
|
|
font-size: 13px;
|
||
|
|
}
|
||
|
|
.support-alert-error {
|
||
|
|
border: 1px solid rgba(255,120,120,.4);
|
||
|
|
color: #f3b0b0;
|
||
|
|
background: rgba(80,20,20,.2);
|
||
|
|
}
|
||
|
|
.support-alert-ok {
|
||
|
|
border: 1px solid rgba(34,242,165,.4);
|
||
|
|
color: #9be7c6;
|
||
|
|
background: rgba(16,64,52,.3);
|
||
|
|
}
|
||
|
|
@media (max-width: 760px) {
|
||
|
|
.support-grid-2 {
|
||
|
|
grid-template-columns: 1fr;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</style>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
(function () {
|
||
|
|
const supportTypes = <?= $supportTypesJson ?>;
|
||
|
|
const typeSelect = document.getElementById('supportType');
|
||
|
|
const extraWrap = document.getElementById('supportExtraFields');
|
||
|
|
if (!typeSelect || !extraWrap) return;
|
||
|
|
|
||
|
|
const map = {};
|
||
|
|
supportTypes.forEach((type) => {
|
||
|
|
map[type.key] = type;
|
||
|
|
});
|
||
|
|
|
||
|
|
const esc = (v) => String(v || '').replace(/[&<>"']/g, (m) => ({
|
||
|
|
'&': '&', '<': '<', '>': '>', '"': '"', "'": '''
|
||
|
|
}[m]));
|
||
|
|
|
||
|
|
const sync = () => {
|
||
|
|
const selectedType = map[typeSelect.value] || { fields: [], field_labels: [] };
|
||
|
|
const labels = {};
|
||
|
|
(selectedType.field_labels || []).forEach((row) => {
|
||
|
|
if (!row || !row.key) return;
|
||
|
|
labels[row.key] = row.label || row.key;
|
||
|
|
});
|
||
|
|
const html = (selectedType.fields || []).map((fieldKey) => {
|
||
|
|
const label = labels[fieldKey] || fieldKey;
|
||
|
|
return `
|
||
|
|
<div class="support-field">
|
||
|
|
<label class="label support-label">${esc(label)}</label>
|
||
|
|
<input class="support-input" name="support_extra[${esc(fieldKey)}]" placeholder="${esc(label)}" required>
|
||
|
|
</div>
|
||
|
|
`;
|
||
|
|
}).join('');
|
||
|
|
extraWrap.innerHTML = html;
|
||
|
|
};
|
||
|
|
typeSelect.addEventListener('change', sync);
|
||
|
|
sync();
|
||
|
|
})();
|
||
|
|
</script>
|
||
|
|
<?php
|
||
|
|
$content = ob_get_clean();
|
||
|
|
require __DIR__ . '/../../../../views/site/layout.php';
|