Files
CRM-IKZ/app/Views/admin/boards/source/edit.php
T
2026-07-14 08:19:56 +04:00

121 lines
5.4 KiB
PHP

<h1 class="h3 mb-3">Интеграция Google Sheets</h1>
<?php if (!empty($_SESSION['success'])): ?>
<div class="alert alert-success">
<?= htmlspecialchars($_SESSION['success']) ?>
</div>
<?php unset($_SESSION['success']); ?>
<?php endif; ?>
<?php if (!empty($_SESSION['error'])): ?>
<div class="alert alert-danger">
<?= htmlspecialchars($_SESSION['error']) ?>
</div>
<?php unset($_SESSION['error']); ?>
<?php endif; ?>
<div class="card shadow-sm mb-3">
<div class="card-body">
<div><strong>Доска:</strong> <?= htmlspecialchars((string)$board['name']) ?></div>
<div><strong>Код:</strong> <?= htmlspecialchars((string)$board['code']) ?></div>
</div>
</div>
<div class="card shadow-sm">
<div class="card-body">
<form method="post" action="/admin/boards/source/save">
<input type="hidden" name="board_id" value="<?= (int)$board['id'] ?>">
<div class="mb-3">
<label class="form-label">Ссылка на Google Sheets</label>
<input
type="text"
name="spreadsheet_url"
class="form-control"
value="<?= htmlspecialchars((string)($source['spreadsheet_url'] ?? '')) ?>"
placeholder="https://docs.google.com/spreadsheets/d/..."
required
>
</div>
<div class="mb-3">
<label class="form-label">Имя вкладки</label>
<input
type="text"
name="sheet_name"
class="form-control"
value="<?= htmlspecialchars((string)($source['sheet_name'] ?? '')) ?>"
placeholder="Лист1"
required
>
</div>
<div class="mb-3">
<label class="form-label">Режим синхронизации</label>
<select name="sync_mode" class="form-select">
<?php $mode = (string)($source['sync_mode'] ?? 'import_export'); ?>
<option value="import" <?= $mode === 'import' ? 'selected' : '' ?>>Только импорт</option>
<option value="export" <?= $mode === 'export' ? 'selected' : '' ?>>Только экспорт</option>
<option value="import_export" <?= $mode === 'import_export' ? 'selected' : '' ?>>Импорт + экспорт</option>
</select>
</div>
<div class="form-check mb-4">
<input class="form-check-input" type="checkbox" name="is_active" id="is_active" <?= (int)($source['is_active'] ?? 1) ? 'checked' : '' ?>>
<label class="form-check-label" for="is_active">Интеграция активна</label>
</div>
<hr class="my-4">
<h5 class="mb-3">Сопоставление базовых полей</h5>
<div class="row g-3 mb-4">
<?php foreach ($baseFields as $field): ?>
<?php $mapKey = 'base:' . $field['key']; ?>
<div class="col-md-6">
<label class="form-label"><?= htmlspecialchars((string)$field['name']) ?></label>
<input
type="text"
name="mapping_base[<?= htmlspecialchars((string)$field['key']) ?>]"
class="form-control"
value="<?= htmlspecialchars((string)($mappings[$mapKey] ?? '')) ?>"
placeholder="Название колонки в Google Sheets"
>
</div>
<?php endforeach; ?>
</div>
<h5 class="mb-3">Сопоставление кастомных полей</h5>
<?php if (empty($customFields)): ?>
<div class="alert alert-light border">
У доски пока нет кастомных полей.
</div>
<?php else: ?>
<div class="row g-3 mb-4">
<?php foreach ($customFields as $field): ?>
<?php $mapKey = 'custom:' . $field['code']; ?>
<div class="col-md-6">
<label class="form-label">
<?= htmlspecialchars((string)$field['name']) ?>
<span class="text-muted small">(<?= htmlspecialchars((string)$field['code']) ?>)</span>
</label>
<input
type="text"
name="mapping_custom[<?= htmlspecialchars((string)$field['code']) ?>]"
class="form-control"
value="<?= htmlspecialchars((string)($mappings[$mapKey] ?? '')) ?>"
placeholder="Название колонки в Google Sheets"
>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<div class="d-flex gap-2">
<button type="submit" class="btn btn-success">Сохранить</button>
<a href="/admin/boards" class="btn btn-secondary">Назад</a>
</div>
</form>
</div>
</div>