Files
FamilyBook/templates/trips/form.php
T
laoyang 8f80f3e835 v24 第 2 轮:19 条清单收尾(附件预览/CalDAV/任务分类看板/全局选人/家谱/纪念日/财务)
用户 2026-10-02 提的 19 条需求,本轮完成剩下的 8 条 + CalDAV 服务端:

- ③ 附件:图片/视频给缩略图,PDF/Word/Excel 给**同尺寸**图标;可预览的在本页
     弹层里看(不再新开标签页),渲染不了的点了直接下载;预览层右上角恒有下载按钮。
- ⑦b CalDAV:把「我的日历本」按 RFC 4791 只读子集分享出去(OPTIONS/PROPFIND/
     REPORT/GET,写方法一律 403)。用**专用口令**(库里只存 sha256),不是登录口令。
- ⑨⑩ 任务:分类与看板都由用户自建;已完成的任务从看板消失,改在「已完成」页
     按分类查看/搜索;设置入口在「新建任务」旁的 ☰。
- ⑪ 全局人员选择器:一个片段铺到观影/旅程/资源/日历共享/任务共享/财务共享;
     修掉了老组件「名字和拼音都搜不动」的 bug —— .att-item 自己声明了 display:flex,
     压过了浏览器 [hidden]{display:none},过滤根本没生效。
- ⑫ 家谱:头像改方形不再裁切;姻亲不在图上的卡片给「⇄ 姻亲」入口,
     以 TA 为中心重画 + 「返回我的家谱」。
- ⑬ 纪念日:阴历/阳历都能设且按对应历法重复;名册里每个人的生日默认可见
     (实时派生,不复制一份);全部作为全天日程进日历。
- ⑮ 财务:账本可共享,双方都能记账、都能看全部账目,资产−负债=净资产;
     金额一律以「分」存,不用浮点。

验证:端到端 724 项通过 / 0 失败;几何 368、交互 97、移动端 516、家谱 24、
升级 123 全绿;SQL 列名静态校验 0 处可疑;部署 11 条线上探针全过。
2026-10-03 08:18:05 +08:00

117 lines
4.6 KiB
PHP

<?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'] ?? '';
$dtId = 't-start'; $dtSeconds = true; require __DIR__ . '/../_datetime.php'; ?>
<?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>
<?php $dtName = 'ends_at'; $dtValue = $t['ends_at'] ?? ''; $dtId = 't-end'; $dtSeconds = true;
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>
<div class="field full">
<label>同行的人</label>
<?php /* v24 第 11 条:与全局选人组件统一(原来是平铺的 checkbox 网格,
名册一多就变成"在一长串里瞪眼找",也搜不了拼音) */ ?>
<?php if (!$people): ?>
<p class="empty-hint">名册里还没有人。</p>
<?php else: ?>
<?php
$ppName = 'attendees[]';
$ppPeople = $people;
$ppSelected = $selIds;
$ppMode = 'multi';
$ppOpenBtn = '+ 添加同行人';
$ppTitle = '选择同行的人';
$ppTip = '';
require __DIR__ . '/../_person_picker.php';
?>
<?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>