2026-10-02 09:28:07 +08:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* 记一趟旅程 / 编辑旅程(v12)。
|
|
|
|
|
*
|
|
|
|
|
* 字段分两组:
|
|
|
|
|
* · 骨架(落在 events 上):标题 / 出发 / 回来 / 目的地 / 备注 —— 与观影同一套原语;
|
|
|
|
|
* · 旅程特有(落在 trip_details 上):封面图 + 一段话小结。
|
|
|
|
|
*
|
|
|
|
|
* ⚠️ 同行的人用多选框(人不多,一次性列全比"搜索+联想"快);
|
|
|
|
|
* 显示名一律是「我叫他什么」(person_name),提交的是 person_id。
|
|
|
|
|
*/
|
|
|
|
|
$isEdit = !empty($t);
|
|
|
|
|
$canWrite = \App\Auth::canWrite();
|
|
|
|
|
$selIds = [];
|
|
|
|
|
if ($isEdit) {
|
|
|
|
|
foreach ((array)($t['attendees'] ?? []) as $a) {
|
|
|
|
|
$selIds[] = (int)$a['id'];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$selIds = array_map('intval', (array)($presetAttendees ?? []));
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
<div class="page-head">
|
|
|
|
|
<h1><?= $isEdit ? '编辑旅程' : '记一趟旅程' ?></h1>
|
|
|
|
|
<div class="actions">
|
|
|
|
|
<a class="btn btn-ghost"
|
|
|
|
|
href="<?= e($isEdit ? url('trips/show', ['id' => (int)$t['id']]) : url('trips')) ?>">返回旅程</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="card card-pad">
|
|
|
|
|
<form method="post" enctype="multipart/form-data"
|
|
|
|
|
action="<?= e(url($isEdit ? 'trips/update' : 'trips/create')) ?>">
|
|
|
|
|
<?= csrf_field() ?>
|
|
|
|
|
<?php if ($isEdit): ?>
|
|
|
|
|
<input type="hidden" name="id" value="<?= (int)$t['id'] ?>">
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
<div class="form-grid">
|
|
|
|
|
<div class="field full">
|
|
|
|
|
<label for="t-title">这趟旅程叫什么 *</label>
|
|
|
|
|
<input class="input" id="t-title" name="title" required
|
|
|
|
|
value="<?= e(old('title', $t['title'] ?? '')) ?>" placeholder="如:青岛三日 · 暑假">
|
|
|
|
|
<?php if (!empty($errors['title'])): ?><span class="err"><?= e($errors['title']) ?></span><?php endif; ?>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
|
<label for="t-start">出发</label>
|
|
|
|
|
<?php $dtName = 'starts_at'; $dtValue = $t['starts_at'] ?? '';
|
2026-10-03 08:18:05 +08:00
|
|
|
$dtId = 't-start'; $dtSeconds = true; require __DIR__ . '/../_datetime.php'; ?>
|
2026-10-02 09:28:07 +08:00
|
|
|
<?php if (!empty($errors['starts_at'])): ?><span class="err"><?= e($errors['starts_at']) ?></span><?php endif; ?>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
|
<label for="t-end">回来</label>
|
2026-10-03 08:18:05 +08:00
|
|
|
<?php $dtName = 'ends_at'; $dtValue = $t['ends_at'] ?? ''; $dtId = 't-end'; $dtSeconds = true;
|
2026-10-02 09:28:07 +08:00
|
|
|
require __DIR__ . '/../_datetime.php'; ?>
|
|
|
|
|
<?php if (!empty($errors['ends_at'])): ?><span class="err"><?= e($errors['ends_at']) ?></span><?php endif; ?>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="field full">
|
|
|
|
|
<label for="t-loc">目的地</label>
|
|
|
|
|
<input class="input" id="t-loc" name="location"
|
|
|
|
|
value="<?= e(old('location', $t['location'] ?? '')) ?>" placeholder="如:青岛">
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="field full">
|
|
|
|
|
<label for="t-sum">一句话小结</label>
|
|
|
|
|
<textarea class="input" id="t-sum" name="summary" rows="3"
|
|
|
|
|
placeholder="回看时最能勾起记忆的那一句"><?= e(old('summary', $t['summary'] ?? '')) ?></textarea>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="field full">
|
|
|
|
|
<label for="t-note">备注</label>
|
|
|
|
|
<textarea class="input" id="t-note" name="note" rows="3"><?= e(old('note', $t['note'] ?? '')) ?></textarea>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-10-03 11:30:48 +08:00
|
|
|
<?php /* 用户 2026-10-03 第 4 条:旅程列表只显示公开的(is_public=1)。
|
|
|
|
|
默认**勾上**(公开)—— 新建一趟行程却默认藏起来是反直觉的;
|
|
|
|
|
编辑时按库里的值回填,老数据 COALESCE 成 1 也是勾上。
|
|
|
|
|
⚠️ 提交的是 `is_public=1`,不勾则完全不提交这个键,
|
|
|
|
|
saveDetails 里 `!empty($d['is_public'])` 自然得到 0。 */ ?>
|
|
|
|
|
<?php $isPub = old('is_public', (string)($t['is_public'] ?? 1)) !== '0'; ?>
|
|
|
|
|
<div class="field full">
|
|
|
|
|
<label>公开</label>
|
|
|
|
|
<label class="chk-inline">
|
|
|
|
|
<?php /* ⚠️ 先放一个 hidden=0:不勾选时提交的就是"明确的不公开",
|
|
|
|
|
而不是"这个字段没出现" —— 后者会被当成"没传"而默认公开,
|
|
|
|
|
于是"取消勾选"看起来毫无作用(经典 checkbox 陷阱)。 */ ?>
|
|
|
|
|
<input type="hidden" name="is_public" value="0">
|
|
|
|
|
<input type="checkbox" name="is_public" value="1" <?= $isPub ? 'checked' : '' ?>>
|
|
|
|
|
<span>在旅程列表与日历里显示这趟行程</span>
|
|
|
|
|
</label>
|
|
|
|
|
<span class="tip">不勾 = 只留着自己看:不进列表、不上日历,但有链接仍能打开。</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-10-02 09:28:07 +08:00
|
|
|
<div class="field full">
|
|
|
|
|
<label>同行的人</label>
|
2026-10-03 08:18:05 +08:00
|
|
|
<?php /* v24 第 11 条:与全局选人组件统一(原来是平铺的 checkbox 网格,
|
|
|
|
|
名册一多就变成"在一长串里瞪眼找",也搜不了拼音) */ ?>
|
2026-10-02 09:28:07 +08:00
|
|
|
<?php if (!$people): ?>
|
|
|
|
|
<p class="empty-hint">名册里还没有人。</p>
|
|
|
|
|
<?php else: ?>
|
2026-10-03 08:18:05 +08:00
|
|
|
<?php
|
|
|
|
|
$ppName = 'attendees[]';
|
|
|
|
|
$ppPeople = $people;
|
|
|
|
|
$ppSelected = $selIds;
|
|
|
|
|
$ppMode = 'multi';
|
|
|
|
|
$ppOpenBtn = '+ 添加同行人';
|
|
|
|
|
$ppTitle = '选择同行的人';
|
|
|
|
|
$ppTip = '';
|
|
|
|
|
require __DIR__ . '/../_person_picker.php';
|
|
|
|
|
?>
|
2026-10-02 09:28:07 +08:00
|
|
|
<?php endif; ?>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="field full">
|
|
|
|
|
<label for="t-cover">封面图</label>
|
|
|
|
|
<?php if ($isEdit && !empty($t['cover_key'])): ?>
|
|
|
|
|
<div class="cover-now">
|
|
|
|
|
<img src="<?= e(media_url((string)$t['cover_key'])) ?>" alt="">
|
|
|
|
|
<span class="tip">不换图就不用管这里;选一张新图会替换它。</span>
|
|
|
|
|
</div>
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
<input class="input" type="file" id="t-cover" name="cover" accept="image/*">
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="btn-row">
|
|
|
|
|
<button class="btn" type="submit"><?= $isEdit ? '保存' : '记下来' ?></button>
|
|
|
|
|
<a class="btn btn-ghost"
|
|
|
|
|
href="<?= e($isEdit ? url('trips/show', ['id' => (int)$t['id']]) : url('trips')) ?>">取消</a>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|