名册每人一份 · 分组两层 · 拖动排序 · 表单合一 · 裁剪可缩放
按用户十点反馈逐条落地(v5,Schema::VERSION = 5): - 名册改成每人一份:新表 person_roster(owner_id, person_id, group_id, sort_order, source)。默认只看「我添加的 + 别人分享给我的」; source='seeded' 是升级时从老 persons.group_id 播进来的(先播数据再删列)。 - 排序不再手填:名册页直接拖动卡片(整版提交,一次 applyLayout 落库), 无 JS 时卡片上的「调整分组」表单照旧可用。 - 分组分两层:管理员在「系统设置」维护公共分组(owner_id=0), 用户在「个人设置」加自己的分组;显示顺序各人各定、互不影响。 - 名册可共享:把名片分享给别的用户(people/share);添加成员时若系统里 已有这个人,可直接复用(people/pick),不必重复录入。 - 「编辑成员」与「改我自己的资料」合并为同一张表(templates/people/form.php), 两个入口 href 完全相同,h1 按改谁切换文案;个人设置页只留 资料入口 + 称呼 + 我的分组三块,删除 templates/settings/_profile.php。 - 系统设置收进头像下拉,顶栏只剩 首页/家谱/名册。 - 裁剪器加缩放(滑块 1-4x、Ctrl+滚轮、还原):缩放只改视图大小, 落库的归一化矩形保持不变。 - 权限:管理员可以改任何人的权限(含自己),只拦「最后一位管理员」被降级。 - 去掉首页「我的一句话」后的链接、家谱说明段、以及「还没归到任何分组」提示。 迁移安全:数据回填(PersonRoster::seedFromPersons)先于删列执行、且不进 tryStep 容错;失败步骤记入 settings.schema_upgrade_warning 并在系统设置页提示。 线上已验证:schema_upgrade_warning 为空,person_roster/person_groups.owner_id 就位,persons.group_id / sort_order 已删。 验证:php -l 48 文件;本地 e2e 277/0、老库升级 81/0、桌面几何 108/0、 移动端几何 180/0、交互 96/0;反向验证 38 条注入 + 2 条缩放注入全部命中; 部署静态断言 53/0,站点自检 7/7(--resolve 锁本机走 443,探针真的进 PHP)。
This commit is contained in:
@@ -52,9 +52,6 @@ $shortKind = ['id' => '身份证生日', 'solar' => '阳历生日', 'lunar' => '
|
||||
<?php if ($mottoIsMine): ?>
|
||||
<span class="motto-from">我的一句话</span>
|
||||
<?php endif; ?>
|
||||
<?php if ($me): ?>
|
||||
<a class="motto-edit" href="<?= e(url('settings/me')) ?>#me-profile"><?= $mottoIsMine ? '改' : '写一句我自己的' ?></a>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="hero-stats">
|
||||
|
||||
@@ -26,7 +26,6 @@ $genWord = function (int $level): string {
|
||||
|
||||
<div class="page-head">
|
||||
<h1>我的家谱</h1>
|
||||
<span class="sub">以 <?= e(\App\Auth::name()) ?> 为中心 · 上下各三代</span>
|
||||
</div>
|
||||
|
||||
<?php if (!$nodes || count($nodes) <= 1): ?>
|
||||
@@ -42,7 +41,6 @@ $genWord = function (int $level): string {
|
||||
<div class="tree-gen">
|
||||
<div class="tree-gen-label">
|
||||
<span class="gname"><?= e($genWord((int)$level)) ?></span>
|
||||
<span class="gtag"><?= (int)$level === 0 ? '中心' : ((int)$level < 0 ? '上 ' . abs((int)$level) . ' 代' : '下 ' . (int)$level . ' 代') ?></span>
|
||||
</div>
|
||||
<div class="tree-row">
|
||||
<?php foreach ($ids as $id): $n = $nodes[$id]; ?>
|
||||
@@ -63,19 +61,6 @@ $genWord = function (int $level): string {
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<div class="card card-pad" style="margin-top:24px">
|
||||
<h2 class="section-title">这张图是怎么来的 <span class="hint">只存两代,其余推导</span></h2>
|
||||
<p class="small muted" style="margin:0 0 10px">
|
||||
系统里只记录**相邻两代之间**的关系:谁是谁的父母、谁和谁是配偶。
|
||||
至于「奶奶是谁」,是顺着「我的父亲 → 我父亲的母亲」两级边推出来的。
|
||||
这样每条关系只需维护一次,同一个人在每个人眼里还会自动变成不同的称呼。
|
||||
</p>
|
||||
<p class="small muted" style="margin:0">
|
||||
兄弟姐妹也不单独存档 —— 只要你们有同一对父母,系统就会把你们认成一家人,
|
||||
并按排行显示成哥哥/姐姐/弟弟/妹妹、长子/次女。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="btn-row">
|
||||
<a class="btn btn-ghost" href="<?= e(url('people/show', ['id' => $meId])) ?>">补充我的亲属关系</a>
|
||||
<a class="btn btn-ghost" href="<?= e(url('people')) ?>">看整个名册</a>
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
// ⚠️ 「系统设置」**不在**顶栏里(用户明确要求):它已经收进右上角头像下拉菜单里了,
|
||||
// 顶栏只留「首页 / 家谱 / 名册」三个日常入口,别再把管理入口顶出来。
|
||||
$navItems = [
|
||||
'home' => ['首页', 'home'],
|
||||
'kin' => ['家谱', 'kin'],
|
||||
'people' => ['名册', 'people'],
|
||||
];
|
||||
if (\App\Auth::isAdmin()) {
|
||||
$navItems['settings'] = ['设置', 'settings'];
|
||||
}
|
||||
// ⚠️ 变量名不要叫 $me:layout 是在 extract($data) **之后**被 require 的,
|
||||
// 这里再赋值会把页面传进来的 $me(当前登录者的完整记录)覆盖掉。
|
||||
// home.php 用 $me 画「补充亲属关系」链接,被覆盖成 true 之后
|
||||
|
||||
+32
-26
@@ -13,6 +13,11 @@
|
||||
*/
|
||||
$isEdit = !empty($person['id']);
|
||||
$avatarUrl = avatar_url($person['avatar'] ?? null);
|
||||
// 这张表单有**两个入口**(名册/详情页的「编辑资料」、个人设置里的「编辑我的资料」),
|
||||
// 但只有一套字段。改自己、且不是能写的人(访客)时,只给属于他自己的那些 ——
|
||||
// 见 index.php 的 people/update(那条分支调 Person::updateSelf)。
|
||||
$canEditAll = $canEditAll ?? \App\Auth::canWrite();
|
||||
$isSelf = $isSelf ?? false;
|
||||
|
||||
$bdSource = old('birthday_source', 'solar');
|
||||
// 库里这列叫 birthday、表单叫 birthday_solar,一律走 solarOf() 取,别直接下标
|
||||
@@ -27,7 +32,7 @@ $idBd = trim((string)($person['birthday_id_card'] ?? ''));
|
||||
?>
|
||||
|
||||
<div class="page-head">
|
||||
<h1><?= $isEdit ? '编辑成员' : '添加成员' ?></h1>
|
||||
<h1><?= $isEdit ? ($isSelf ? '我的资料' : '编辑成员') : '添加成员' ?></h1>
|
||||
<span class="sub"><?= $isEdit ? e($person['name']) : '填姓名就行,其他都可以以后再补' ?></span>
|
||||
</div>
|
||||
|
||||
@@ -57,6 +62,7 @@ $idBd = trim((string)($person['birthday_id_card'] ?? ''));
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<?php if ($canEditAll): ?>
|
||||
<div class="field">
|
||||
<label for="birth_rank">家中排行</label>
|
||||
<input class="input" id="birth_rank" name="birth_rank" type="number" min="1" max="99"
|
||||
@@ -64,31 +70,15 @@ $idBd = trim((string)($person['birthday_id_card'] ?? ''));
|
||||
<span class="tip">用来认兄弟姐妹的长幼:长子、次女、三弟…</span>
|
||||
<?php if (!empty($errors['birth_rank'])): ?><span class="err"><?= e($errors['birth_rank']) ?></span><?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="field">
|
||||
<label for="sort_order">排序号</label>
|
||||
<input class="input" id="sort_order" name="sort_order" type="number"
|
||||
value="<?= e(old('sort_order', $person['sort_order'] ?? 1000)) ?>">
|
||||
<span class="tip">小的排前面。</span>
|
||||
</div>
|
||||
|
||||
<?php /* 一个人只属于一个关系分组;分组是全家共用的一套(名册按它分栏显示),
|
||||
但「哪一组排前面」是各人自己的习惯,在「个人设置」里调。 */ ?>
|
||||
<div class="field">
|
||||
<label for="group_id">关系分组</label>
|
||||
<select class="select" id="group_id" name="group_id">
|
||||
<option value="">未分类</option>
|
||||
<?php foreach (($groups ?? []) as $g): $gid = (int)$g['id']; ?>
|
||||
<option value="<?= $gid ?>"
|
||||
<?= (int)old('group_id', $person['group_id'] ?? 0) === $gid ? 'selected' : '' ?>>
|
||||
<?= e((string)$g['name']) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<span class="tip">
|
||||
名册会按这个分组分栏显示。分组不够用就自己在「<a href="<?= e(url('settings/me')) ?>">个人设置</a>」里加。
|
||||
</span>
|
||||
</div>
|
||||
<?php /* ⚠️ 这里**没有**「排序号」,也**没有**「关系分组」:
|
||||
① 排序号已经彻底取消(用户原话:「排序号,不要让用户填写」),
|
||||
名册里的先后靠**拖动卡片**调,存在我自己的 person_roster.sort_order 上;
|
||||
② 分组是「我和他的关系」,写在我自己的名册条目上 ——
|
||||
只能在名册里拖到那一栏,或在那张卡片的「调整分组」里改。
|
||||
写进这张(全家人共用的)资料表单里是错的:我把他归成"同事"
|
||||
不该把妈妈那边的归类也改掉。 */ ?>
|
||||
|
||||
<!-- ==================== 三个生日 ==================== -->
|
||||
<div class="field full">
|
||||
@@ -153,6 +143,7 @@ $idBd = trim((string)($person['birthday_id_card'] ?? ''));
|
||||
<?php if (!empty($errors['slogan'])): ?><span class="err"><?= e($errors['slogan']) ?></span><?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($canEditAll): ?>
|
||||
<div class="field">
|
||||
<label for="phone">手机号</label>
|
||||
<input class="input" id="phone" name="phone" inputmode="numeric"
|
||||
@@ -160,6 +151,7 @@ $idBd = trim((string)($person['birthday_id_card'] ?? ''));
|
||||
<span class="tip">开通登录后用它登录;加密存储,列表里只显示部分。</span>
|
||||
<?php if (!empty($errors['phone'])): ?><span class="err"><?= e($errors['phone']) ?></span><?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="field">
|
||||
<label for="email">邮箱</label>
|
||||
@@ -168,6 +160,7 @@ $idBd = trim((string)($person['birthday_id_card'] ?? ''));
|
||||
<?php if (!empty($errors['email'])): ?><span class="err"><?= e($errors['email']) ?></span><?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($canEditAll): ?>
|
||||
<div class="field full">
|
||||
<label for="id_card">身份证号</label>
|
||||
<input class="input mono" id="id_card" name="id_card"
|
||||
@@ -179,6 +172,7 @@ $idBd = trim((string)($person['birthday_id_card'] ?? ''));
|
||||
</span>
|
||||
<?php if (!empty($errors['id_card'])): ?><span class="err"><?= e($errors['id_card']) ?></span><?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="field full">
|
||||
<label for="address">住址</label>
|
||||
@@ -215,6 +209,7 @@ $idBd = trim((string)($person['birthday_id_card'] ?? ''));
|
||||
style="width:88px;height:88px;border-radius:12px;object-fit:cover;border:1px solid var(--line)">
|
||||
</div>
|
||||
|
||||
<?php if ($canEditAll): ?>
|
||||
<div class="field full">
|
||||
<label class="check-item">
|
||||
<input type="checkbox" name="is_placeholder" value="1"
|
||||
@@ -228,12 +223,23 @@ $idBd = trim((string)($person['birthday_id_card'] ?? ''));
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="btn-row">
|
||||
<button class="btn" type="submit"><?= $isEdit ? '保存' : '加入名册' ?></button>
|
||||
<a class="btn btn-ghost" href="<?= e($isEdit ? url('people/show', ['id' => (int)$person['id']]) : url('people')) ?>">取消</a>
|
||||
<?php
|
||||
// 取消:改自己的话回「个人设置」更顺手(那是他来的地方),
|
||||
// 改别人 / 新增则回他的详情页 / 名册。
|
||||
$cancelUrl = $isEdit
|
||||
? ($isSelf ? url('settings/me') : url('people/show', ['id' => (int)$person['id']]))
|
||||
: url('people');
|
||||
?>
|
||||
<a class="btn btn-ghost" href="<?= e($cancelUrl) ?>">取消</a>
|
||||
<?php if ($isSelf): ?>
|
||||
<a class="btn btn-ghost" href="<?= e(url('people/show', ['id' => (int)$person['id']])) ?>">看我的详情页</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
+107
-52
@@ -1,20 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* 家庭名册 —— 按「关系分组」分栏显示。
|
||||
* 家庭名册 —— 按「关系分组」分栏显示,卡片可以拖动。
|
||||
*
|
||||
* 两个刻意的设计:
|
||||
* ① **分栏顺序由看的人自己定**($groups 已经是"按我的习惯排好"的顺序,
|
||||
* 见 App\PersonGroup::orderFor)—— 所以我看到的「家人」在第一栏,
|
||||
* 妈妈可以把「亲戚」挪到第一栏,两个人相安无事。
|
||||
* ② 分类是全家共用的一套,所以**改一个人的分组是全家的信息**,
|
||||
* 这里只有能写的人(管理员 / 家庭成员)才看得到那一行「调整分组」。
|
||||
* 三处刻意的设计:
|
||||
* ① **名册是每人一份的**(v5 起,见 App\PersonRoster):这里只显示"我加的人 +
|
||||
* 别人分享给我的",归到哪一组、排第几也都只影响我自己。所以"改分组"不再是
|
||||
* 改全家的信息,而是改我自己那份 —— 于是顺手就能做成拖动。
|
||||
* ② **拖动改分组、拖动改顺序**(需求原话:「拖动一个人的卡片进行排序…通过拖动
|
||||
* 改变分组」):拖动本身是 JS,但**每个分组栏也是空的时候照样存在**,
|
||||
* 拖动时统一露出来当落点,否则"想拖到一个现在没人的分组里"就没地方放。
|
||||
* ③ **没有 JS 也完全能用**:卡片上的 `<details>调整分组</details>` 还在,
|
||||
* 而且手机上的 HTML5 拖放本来就不生效,那套表单就是窄屏的正路。
|
||||
*
|
||||
* ⚠️ 卡片结构是 div > a + details,**不能写成 a > form**:
|
||||
* 表单套在链接里是非法 HTML,浏览器会把 DOM 拆开,表单里那个「移动」按钮
|
||||
* 可能连提交机会都没有(或者把整张卡片点成跳转)。
|
||||
*/
|
||||
$canMove = \App\Auth::canWrite();
|
||||
$total = 0;
|
||||
$canMove = \App\Auth::canWrite();
|
||||
$pickable = $pickable ?? 0;
|
||||
$total = 0;
|
||||
foreach ($grouped as $list) {
|
||||
$total += count($list);
|
||||
}
|
||||
@@ -22,11 +26,13 @@ foreach ($grouped as $list) {
|
||||
/**
|
||||
* 画一栏人。用闭包是因为"分好组的各栏"和"未分类"两处要画同一套卡片,
|
||||
* 复制一遍迟早会改漏一处。
|
||||
*
|
||||
* ⚠️ `$groups` 必须写进 `use (...)`:卡片里的「调整分组」下拉要列出我能用的分组。
|
||||
* 漏掉它的后果**不会报错**(PHP 8 只 warning 一句"未定义变量",
|
||||
* 而 foreach 拿到 null 就是零次循环)—— 于是每张卡片的那个下拉里
|
||||
* 只剩「未分类」一项,看着像"分组功能没做",其实是变量没传进来。
|
||||
*/
|
||||
$renderGrid = function (array $list) use ($groups, $meId, $canMove): void {
|
||||
if (!$list) {
|
||||
return;
|
||||
}
|
||||
$renderGrid = function (array $list) use ($meId, $canMove, $groups): void {
|
||||
?>
|
||||
<div class="people-grid">
|
||||
<?php foreach ($list as $p): ?>
|
||||
@@ -40,9 +46,14 @@ $renderGrid = function (array $list) use ($groups, $meId, $canMove): void {
|
||||
$pNick = (string)($p['my_nickname'] ?? '');
|
||||
$pid = (int)$p['id'];
|
||||
?>
|
||||
<div class="person">
|
||||
<a class="person-main" href="<?= e(url('people/show', ['id' => $pid])) ?>">
|
||||
<div class="ph"><img src="<?= e(avatar_url($p['avatar'])) ?>" alt=""></div>
|
||||
<div class="person" data-person="<?= $pid ?>" <?= $canMove ? 'draggable="true"' : '' ?>>
|
||||
<?php if ($canMove): ?>
|
||||
<span class="drag-handle" title="拖到我想要的位置 / 那一栏" aria-hidden="true">⠿</span>
|
||||
<?php endif; ?>
|
||||
<?php /* draggable="false" 很重要:链接与图片浏览器默认就是可拖的,
|
||||
不关掉的话拖起来会变成"拖一个网址",父卡片反而拿不到这次拖动。 */ ?>
|
||||
<a class="person-main" href="<?= e(url('people/show', ['id' => $pid])) ?>" draggable="false">
|
||||
<div class="ph"><img src="<?= e(avatar_url($p['avatar'])) ?>" alt="" draggable="false"></div>
|
||||
<div class="pb">
|
||||
<div class="pname">
|
||||
<?= e($pshow) ?>
|
||||
@@ -71,13 +82,13 @@ $renderGrid = function (array $list) use ($groups, $meId, $canMove): void {
|
||||
</div>
|
||||
</a>
|
||||
<?php if ($canMove): ?>
|
||||
<details class="person-more">
|
||||
<summary>调整分组</summary>
|
||||
<details class="person-more" data-no-drag>
|
||||
<summary aria-label="调整分组">⋯</summary>
|
||||
<form method="post" action="<?= e(url('people/group')) ?>" class="person-move">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="person_id" value="<?= $pid ?>">
|
||||
<label class="sr-only" for="pg<?= $pid ?>">分组</label>
|
||||
<select class="select" id="pg<?= $pid ?>" name="group_id">
|
||||
<select class="select" id="pg<?= $pid ?>" name="group_id" data-no-drag>
|
||||
<option value="">未分类</option>
|
||||
<?php foreach ($groups as $g): $gid = (int)$g['id']; ?>
|
||||
<option value="<?= $gid ?>"
|
||||
@@ -86,7 +97,12 @@ $renderGrid = function (array $list) use ($groups, $meId, $canMove): void {
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<button class="btn btn-ghost btn-sm" type="submit">移动</button>
|
||||
<button class="btn btn-ghost btn-sm" type="submit" data-no-drag>移动</button>
|
||||
</form>
|
||||
<form method="post" action="<?= e(url('people/forget')) ?>" class="person-move">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="person_id" value="<?= $pid ?>">
|
||||
<button class="btn btn-ghost btn-sm" type="submit" data-no-drag>从我的名册移走</button>
|
||||
</form>
|
||||
</details>
|
||||
<?php endif; ?>
|
||||
@@ -95,18 +111,46 @@ $renderGrid = function (array $list) use ($groups, $meId, $canMove): void {
|
||||
</div>
|
||||
<?php
|
||||
};
|
||||
|
||||
/** 一栏(含空栏)。空栏平时收起来,拖动时由 JS 加 is-dragging 露出来当落点。 */
|
||||
$renderBlock = function (int $gid, string $name, array $list) use ($renderGrid): void {
|
||||
?>
|
||||
<section class="group-block<?= $list ? '' : ' is-empty' ?>" data-group="<?= $gid ?>">
|
||||
<h2 class="group-head">
|
||||
<span class="group-title"><?= e($name) ?></span>
|
||||
<span class="group-n"><span class="n"><?= count($list) ?></span> 人</span>
|
||||
<span class="group-drop-hint">放到这里</span>
|
||||
</h2>
|
||||
<?php $renderGrid($list); ?>
|
||||
</section>
|
||||
<?php
|
||||
};
|
||||
?>
|
||||
|
||||
<div class="page-head">
|
||||
<h1>家庭名册</h1>
|
||||
<span class="sub">共 <?= $total ?> 人<?= $groups && $q === '' ? ',分 ' . count($groups) . ' 个关系分组' : '' ?></span>
|
||||
<span class="sub">
|
||||
共 <?= $total ?> 人<?= $groups && $q === '' ? ',分 ' . count($groups) . ' 个关系分组' : '' ?>
|
||||
</span>
|
||||
<div class="actions">
|
||||
<?php if ($canMove && $pickable > 0): ?>
|
||||
<a class="btn btn-ghost btn-sm" href="<?= e(url('people/pick')) ?>">
|
||||
从家里已有的人里挑(<?= $pickable ?>)
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if (\App\Auth::isAdmin()): ?>
|
||||
<a class="btn btn-sm" href="<?= e(url('people/new')) ?>">添加成员</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($canMove && $q === '' && $total > 0): ?>
|
||||
<p class="small muted roster-tip" style="margin:0 0 12px">
|
||||
拖动卡片(左边那个 <span class="drag-handle-inline">⠿</span>)就能改顺序,
|
||||
拖到别的一栏里就是改分组。改的是<b>你自己那份名册</b>,不影响家里其他人。
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<form class="search" method="get" action="index.php">
|
||||
<input type="hidden" name="r" value="people">
|
||||
<input class="input" name="q" value="<?= e($q) ?>" placeholder="按姓名、称呼或邮箱搜索">
|
||||
@@ -118,8 +162,29 @@ $renderGrid = function (array $list) use ($groups, $meId, $canMove): void {
|
||||
|
||||
<?php if (!$people): ?>
|
||||
<div class="empty">
|
||||
<b><?= $q !== '' ? '没有匹配的人' : '名册还是空的' ?></b>
|
||||
<?= $q !== '' ? '换个词试试。' : '把家里人加进来,之后观影、旅行的同行人就可以直接从名册里选。' ?>
|
||||
<?php if ($q !== ''): ?>
|
||||
<b>没有匹配的人</b>
|
||||
换个词试试。
|
||||
<?php elseif ($pickable > 0): ?>
|
||||
<b>你的名册还是空的</b>
|
||||
家里已经有 <?= (int)$pickable ?> 个人了 —— 直接挑过来就行,不用重新录一遍。
|
||||
<div class="btn-row" style="justify-content:center;margin-top:14px">
|
||||
<a class="btn" href="<?= e(url('people/pick')) ?>">从家里已有的人里挑</a>
|
||||
<?php if (\App\Auth::isAdmin()): ?>
|
||||
<a class="btn btn-ghost" href="<?= e(url('people/new')) ?>">添加一个新人</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<b>名册还是空的</b>
|
||||
<?php if (\App\Auth::isAdmin()): ?>
|
||||
把家里人加进来,之后观影、旅行的同行人就可以直接从名册里选。
|
||||
<div class="btn-row" style="justify-content:center;margin-top:14px">
|
||||
<a class="btn" href="<?= e(url('people/new')) ?>">添加成员</a>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
等家里人把你加进来,或者让管理员给你开个账号。
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php elseif ($q !== ''): ?>
|
||||
<?php /* 搜索时按"命中的人"平铺 —— 分栏会把一次搜索拆成一堆只有一两个人的碎块,反而更难看 */ ?>
|
||||
@@ -128,35 +193,25 @@ $renderGrid = function (array $list) use ($groups, $meId, $canMove): void {
|
||||
</p>
|
||||
<?php $renderGrid($people); ?>
|
||||
<?php else: ?>
|
||||
<?php foreach ($groups as $g): ?>
|
||||
<?php
|
||||
$gid = (int)$g['id'];
|
||||
$list = $grouped[$gid] ?? [];
|
||||
// 空分组不画 —— 七个预置分类里家里可能只用到三个,
|
||||
// 把空栏也摊出来会让名册看上去破破烂烂的
|
||||
if (!$list) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<section class="group-block">
|
||||
<h2 class="group-head">
|
||||
<span class="group-title"><?= e((string)$g['name']) ?></span>
|
||||
<span class="group-n"><?= count($list) ?> 人</span>
|
||||
</h2>
|
||||
<?php $renderGrid($list); ?>
|
||||
</section>
|
||||
<?php endforeach; ?>
|
||||
<div class="roster<?= $canMove ? ' is-droppable' : '' ?>"
|
||||
data-reorder="<?= e(url('people/reorder')) ?>"
|
||||
data-csrf="<?= e(csrf_token()) ?>">
|
||||
<?php foreach ($groups as $g): ?>
|
||||
<?php $gid = (int)$g['id']; ?>
|
||||
<?php $renderBlock($gid, (string)$g['name'], $grouped[$gid] ?? []); ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if (!empty($grouped[0])): ?>
|
||||
<section class="group-block">
|
||||
<h2 class="group-head">
|
||||
<span class="group-title">未分类</span>
|
||||
<span class="group-n"><?= count($grouped[0]) ?> 人</span>
|
||||
</h2>
|
||||
<p class="small muted" style="margin:-4px 0 12px">
|
||||
这些人还没归到任何分组里。管理员可以在卡片下面直接选一个分组(或去「编辑成员」里改)。
|
||||
<?php
|
||||
// 「未分类」栏永远画出来(哪怕是空的)—— 它是把卡片从某个分组里拖出来的落点。
|
||||
// 提示语按需求删掉了(用户原话:「这些人还没归到任何分组里…这些提示,都去掉」)。
|
||||
$renderBlock(0, '未分类', $grouped[0] ?? []);
|
||||
?>
|
||||
|
||||
<?php if (!$groups): ?>
|
||||
<p class="small muted" style="margin:0">
|
||||
还没有任何分组。管理员可以在「系统设置 → 公共分组」里建一套全家共用的,
|
||||
你也可以在「个人设置 → 我的分组」里加只给自己看的。
|
||||
</p>
|
||||
<?php $renderGrid($grouped[0]); ?>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* 「从家里已有的人里挑」—— 添加成员的第二个入口。
|
||||
*
|
||||
* 为什么要有这一页:同一个人不该被录两遍。
|
||||
* 如果张伟已经被妈妈录进名册了,我再走「添加成员」录一遍,
|
||||
* 系统里就会出现两条「张伟」—— 账号、亲属关系、生日各存一份,之后永远对不上。
|
||||
* 所以这里把「这个家庭里已经有的人」列出来(带账号徽标,好认出是谁),
|
||||
* 勾一个就把他**复用**进我的名册,一个字段都不用重填。
|
||||
*
|
||||
* 需求原话:「当一个用户添加一个名册的时候…如果这个人员信息在系统当中已经存在,
|
||||
* 那么他可以直接复用这个人的信息,就不需要再重新录入。」
|
||||
*/
|
||||
?>
|
||||
<div class="page-head">
|
||||
<h1>从家里已有的人里挑</h1>
|
||||
<span class="sub">选中的会进你的名册,资料共用一份,不会重复录入</span>
|
||||
<div class="actions">
|
||||
<a class="btn btn-ghost btn-sm" href="<?= e(url('people')) ?>">回名册</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (!$people): ?>
|
||||
<div class="empty">
|
||||
<b>没有可挑的人了</b>
|
||||
家里已经有的人,都在你的名册里了。要加新人就点「添加成员」。
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<form method="post" action="<?= e(url('people/pick')) ?>">
|
||||
<?= csrf_field() ?>
|
||||
<div class="card card-pad">
|
||||
<p class="small muted" style="margin:0 0 14px">
|
||||
这些人都已经在这个家庭里(可能是别人先录的)。勾上就会出现在你的名册里 ——
|
||||
<b>资料是共用的那一份</b>,你以后改的也是同一份。
|
||||
</p>
|
||||
|
||||
<div class="field" style="max-width:280px;margin-bottom:16px">
|
||||
<label for="pickGroup">加进哪一组</label>
|
||||
<select class="select" id="pickGroup" name="group_id">
|
||||
<option value="">先不分组(之后拖到那一栏也行)</option>
|
||||
<?php foreach ($groups as $g): $gid = (int)$g['id']; ?>
|
||||
<option value="<?= $gid ?>"><?= e((string)$g['name']) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<ul class="pick-list">
|
||||
<?php foreach ($people as $p): $pid = (int)$p['id']; ?>
|
||||
<?php
|
||||
// 显示名优先用「我怎么称呼他」:别人录的名字未必是我对他的叫法
|
||||
$shown = (string)($p['my_nickname'] ?? '');
|
||||
if ($shown === '') {
|
||||
$shown = (string)$p['name'];
|
||||
}
|
||||
?>
|
||||
<li class="pick-row">
|
||||
<label class="pick-item">
|
||||
<input type="checkbox" name="ids[]" value="<?= $pid ?>">
|
||||
<img class="pick-ph" src="<?= e(avatar_url($p['avatar'])) ?>" alt="">
|
||||
<span class="pick-name">
|
||||
<?= e($shown) ?>
|
||||
<?php if ($shown !== (string)$p['name']): ?>
|
||||
<span class="muted small">· 本名 <?= e((string)$p['name']) ?></span>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($p['is_placeholder'])): ?><span class="badge">待确认</span><?php endif; ?>
|
||||
<?php
|
||||
$r = (string)($p['account_role'] ?? '');
|
||||
if ($r === 'admin' && ($p['account_status'] ?? '') === 'active') {
|
||||
echo '<span class="badge badge-admin">管理员</span>';
|
||||
} elseif ($r === 'guest') {
|
||||
echo '<span class="badge">访客</span>';
|
||||
} elseif ($r !== '') {
|
||||
echo '<span class="badge badge-open">已开通</span>';
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
</label>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
<div class="btn-row">
|
||||
<button class="btn" type="submit">加进我的名册</button>
|
||||
<a class="btn btn-ghost" href="<?= e(url('people')) ?>">取消</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
+71
-20
@@ -40,9 +40,7 @@ $shortKind = ['id' => '身份证生日', 'solar' => '阳历生日', 'lunar' =
|
||||
<div class="page-head">
|
||||
<h1><?= e($pShown) ?></h1>
|
||||
<span class="sub">
|
||||
<?php if ($isSelf): ?>
|
||||
这是你自己
|
||||
<?php else: ?>
|
||||
<?php if (!$isSelf): ?>
|
||||
<span class="rel-label"><?= e($labelToMe) ?></span>
|
||||
<?php if ($isMyNick): ?>
|
||||
· 本名 <?= e((string)$p['name']) ?>
|
||||
@@ -51,11 +49,10 @@ $shortKind = ['id' => '身份证生日', 'solar' => '阳历生日', 'lunar' =
|
||||
<?php if (!empty($p['is_placeholder'])): ?><span class="badge">虚拟人物</span><?php endif; ?>
|
||||
</span>
|
||||
<div class="actions">
|
||||
<?php if ($isSelf): ?>
|
||||
<a class="btn btn-sm" href="<?= e(url('settings/me')) ?>#me-profile">改我自己的资料</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canW): ?>
|
||||
<a class="btn btn-ghost btn-sm" href="<?= e(url('people/edit', ['id' => $pid])) ?>">编辑资料</a>
|
||||
<?php if ($isSelf || $canW): ?>
|
||||
<a class="btn btn-ghost btn-sm" href="<?= e(url('people/edit', ['id' => $pid])) ?>">
|
||||
<?= $isSelf ? '编辑我的资料' : '编辑资料' ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($admin): ?>
|
||||
<form method="post" action="<?= e(url('people/destroy')) ?>" style="display:inline"
|
||||
@@ -362,6 +359,57 @@ $shortKind = ['id' => '身份证生日', 'solar' => '阳历生日', 'lunar' =
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- ============ 名册归属 / 分享名片 ============ -->
|
||||
<?php if (!$isSelf): ?>
|
||||
<div class="card card-pad" style="margin-top:16px">
|
||||
<h2 class="section-title">名册 <span class="hint">名册是每人一份的</span></h2>
|
||||
<p class="small muted" style="margin:0 0 14px">
|
||||
<?php if (!empty($inMyRoster)): ?>
|
||||
「<?= e($pShown) ?>」在你的名册里。归到哪一组、排第几,只影响你自己看到的名册 ——
|
||||
家里其他人各有一份,互不打搅。
|
||||
<?php else: ?>
|
||||
「<?= e($pShown) ?>」还不在你的名册里。你仍然能在家谱与首页看到他,
|
||||
但名册只列<b>你自己加的人</b>和<b>别人分享给你的名片</b>。
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
<div class="btn-row" style="margin-top:0;flex-wrap:wrap;align-items:center">
|
||||
<?php if (empty($inMyRoster) && $canW): ?>
|
||||
<form method="post" action="<?= e(url('people/pick')) ?>" style="display:inline">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="ids[]" value="<?= $pid ?>">
|
||||
<button class="btn btn-sm" type="submit">加进我的名册</button>
|
||||
</form>
|
||||
<?php elseif (!empty($inMyRoster) && $canW): ?>
|
||||
<form method="post" action="<?= e(url('people/forget')) ?>" style="display:inline">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="person_id" value="<?= $pid ?>">
|
||||
<button class="btn btn-ghost btn-sm" type="submit">从我的名册里移走</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($canW && !empty($options)): ?>
|
||||
<?php /* 需求原话:「我可以把一个人的名片,分享给一个用户,
|
||||
则这个名片,自动出现在这个用户的名册中」。 */ ?>
|
||||
<details class="share-wrap">
|
||||
<summary class="btn btn-ghost btn-sm">分享他的名片给…</summary>
|
||||
<form method="post" action="<?= e(url('people/share')) ?>" class="inline-form">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="person_id" value="<?= $pid ?>">
|
||||
<input type="hidden" name="back" value="<?= $pid ?>">
|
||||
<label class="sr-only" for="shareTo">分享给谁</label>
|
||||
<select class="select" id="shareTo" name="to_id">
|
||||
<?php foreach ($options as $o): $oid = (int)$o['id']; ?>
|
||||
<option value="<?= $oid ?>"><?= e((string)$o['name']) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<button class="btn btn-sm" type="submit">分享</button>
|
||||
</form>
|
||||
</details>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($admin): ?>
|
||||
<div class="card card-pad" style="margin-top:16px">
|
||||
<h2 class="section-title">登录账号</h2>
|
||||
@@ -396,17 +444,22 @@ $shortKind = ['id' => '身份证生日', 'solar' => '阳历生日', 'lunar' =
|
||||
<?= $role === 'guest' ? '—— 只能查看,不能新增或修改任何内容。' : '' ?>
|
||||
</p>
|
||||
<div class="btn-row" style="margin-top:0;flex-wrap:wrap">
|
||||
<form method="post" action="<?= e(url('accounts/role')) ?>" style="display:inline">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="person_id" value="<?= $pid ?>">
|
||||
<select class="select" name="role" style="width:auto;display:inline-block">
|
||||
<option value="member" <?= $role === 'member' ? 'selected' : '' ?>>家庭成员</option>
|
||||
<option value="admin" <?= $role === 'admin' ? 'selected' : '' ?>>管理员</option>
|
||||
<option value="guest" <?= $role === 'guest' ? 'selected' : '' ?>>访客</option>
|
||||
</select>
|
||||
<button class="btn btn-ghost btn-sm" type="submit">改角色</button>
|
||||
<?php if ($isSelf): ?>
|
||||
<?php /* 自己也能改自己的权限(哪怕给自己降级)—— 系统的家可能就一个人用,
|
||||
难道他还不能调自己的权限?唯一拦的是"降完一个管理员都不剩"。 */ ?>
|
||||
<span class="small muted">可以改自己的。只有「把最后一位管理员降级」会被拦下。</span>
|
||||
<?php endif; ?>
|
||||
</form>
|
||||
<?php if (!$isSelf): ?>
|
||||
<form method="post" action="<?= e(url('accounts/role')) ?>" style="display:inline">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="person_id" value="<?= $pid ?>">
|
||||
<select class="select" name="role" style="width:auto;display:inline-block">
|
||||
<option value="member" <?= $role === 'member' ? 'selected' : '' ?>>家庭成员</option>
|
||||
<option value="admin" <?= $role === 'admin' ? 'selected' : '' ?>>管理员</option>
|
||||
<option value="guest" <?= $role === 'guest' ? 'selected' : '' ?>>访客</option>
|
||||
</select>
|
||||
<button class="btn btn-ghost btn-sm" type="submit">改角色</button>
|
||||
</form>
|
||||
<form method="post" action="<?= e(url('accounts/status')) ?>" style="display:inline">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="person_id" value="<?= $pid ?>">
|
||||
@@ -415,8 +468,6 @@ $shortKind = ['id' => '身份证生日', 'solar' => '阳历生日', 'lunar' =
|
||||
<?= $p['account_status'] === 'active' ? '停用账号' : '启用账号' ?>
|
||||
</button>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<span class="small muted">这是你自己 —— 要改自己的权限,请让另一位管理员来操作。</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -31,6 +31,98 @@
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php if (($upgradeWarn ?? '') !== ''): ?>
|
||||
<div class="flash" style="margin-top:16px">
|
||||
<div class="flash-item err">
|
||||
<b>上次结构升级有步骤失败了</b>(其余步骤已经跑完,站点可用):<br>
|
||||
<?= e((string)$upgradeWarn) ?><br>
|
||||
<span class="muted small">修好之后可以清掉这条提示。</span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- ==================== 公共分组 ==================== -->
|
||||
<?php
|
||||
$pubGroups = $pubGroups ?? [];
|
||||
$pubCounts = $pubCounts ?? [];
|
||||
$pubTotal = count($pubGroups);
|
||||
?>
|
||||
<div class="card card-pad" style="margin-top:20px" id="public-groups">
|
||||
<h2 class="section-title">
|
||||
公共分组
|
||||
<span class="hint">全家人共用的一套</span>
|
||||
</h2>
|
||||
<p class="small muted" style="margin:0 0 16px">
|
||||
名册按「关系分组」分栏显示。这里维护的是<b>公共的那一套</b> ——
|
||||
建一次,全家每个人都能拿来用。
|
||||
<br>
|
||||
每个人还可以在「个人设置 → 我的分组」里<b>再加只给自己看的分组</b>,
|
||||
那部分不在这儿、也不会影响别人。挪顺序用 ▲ ▼(▲▼ 调的是"全家的默认顺序",
|
||||
各人仍可在个人设置里改成自己习惯的顺序)。
|
||||
<br>
|
||||
删掉一个分组<b>不会删掉人</b>:名册里归到那一组的人会变成「未分类」,
|
||||
各自重新归类即可。
|
||||
</p>
|
||||
|
||||
<?php if ($pubGroups): ?>
|
||||
<ol class="order-list">
|
||||
<?php foreach ($pubGroups as $i => $g): $gid = (int)$g['id']; ?>
|
||||
<li class="order-row">
|
||||
<span class="order-no"><?= $i + 1 ?></span>
|
||||
<span class="order-name"><?= e((string)$g['name']) ?></span>
|
||||
<span class="order-count"><?= (int)($pubCounts[$gid] ?? 0) ?> 人</span>
|
||||
<form method="post" action="<?= e(url('settings/groups/move')) ?>" class="order-move">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="id" value="<?= $gid ?>">
|
||||
<input type="hidden" name="scope" value="public">
|
||||
<button class="btn btn-ghost btn-sm" type="submit" name="dir" value="up"
|
||||
title="上移一组" <?= $i === 0 ? 'disabled' : '' ?>>▲</button>
|
||||
<button class="btn btn-ghost btn-sm" type="submit" name="dir" value="down"
|
||||
title="下移一组" <?= $i === $pubTotal - 1 ? 'disabled' : '' ?>>▼</button>
|
||||
</form>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="post" action="<?= e(url('settings/groups/add')) ?>" class="inline-form" style="margin-top:16px">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="scope" value="public">
|
||||
<label class="sr-only" for="newPubGroup">新分组名</label>
|
||||
<input class="input" id="newPubGroup" name="name" maxlength="20" placeholder="例如:邻居、亲家、老同事">
|
||||
<button class="btn btn-sm" type="submit">加一个公共分组</button>
|
||||
</form>
|
||||
|
||||
<?php if ($pubGroups): ?>
|
||||
<ul class="group-manage" style="margin-top:14px">
|
||||
<?php foreach ($pubGroups as $g): $gid = (int)$g['id']; ?>
|
||||
<li class="group-manage-row">
|
||||
<form method="post" action="<?= e(url('settings/groups/rename')) ?>" class="group-rename">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="id" value="<?= $gid ?>">
|
||||
<input type="hidden" name="scope" value="public">
|
||||
<label class="sr-only" for="pgname<?= $gid ?>">分组名</label>
|
||||
<input class="input" id="pgname<?= $gid ?>" name="name" maxlength="20"
|
||||
value="<?= e((string)$g['name']) ?>">
|
||||
<button class="btn btn-ghost btn-sm" type="submit">改名</button>
|
||||
</form>
|
||||
<span class="group-count muted small"><?= (int)($pubCounts[$gid] ?? 0) ?> 人</span>
|
||||
<details class="del-wrap">
|
||||
<summary class="btn btn-ghost btn-sm">删除</summary>
|
||||
<form method="post" action="<?= e(url('settings/groups/delete')) ?>" class="del-confirm">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="id" value="<?= $gid ?>">
|
||||
<input type="hidden" name="scope" value="public">
|
||||
<span class="small muted">这组的人会变成「未分类」,确定?</span>
|
||||
<button class="btn btn-ghost btn-sm danger" type="submit">确认删除</button>
|
||||
</form>
|
||||
</details>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- ==================== 附件存储 ==================== -->
|
||||
<form method="post" action="<?= e(url('settings/storage')) ?>" class="card card-pad" style="margin-top:20px">
|
||||
<?= csrf_field() ?>
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* 「我的资料」表单(个人设置的第一块)。
|
||||
*
|
||||
* 只放**属于我自己的**东西:
|
||||
* · 我的姓名、性别、头像、联系方式、备注
|
||||
* · 我的三个生日(身份证生日只读,由证件推导)
|
||||
* · 我的 slogan(没填就用家庭统一的那句)
|
||||
* 排行、排序号、虚拟人物标记、以及会牵动身份证生日的身份证号,
|
||||
* 都属于"管理员编名册",不在这里(这也是为了不让一次自助提交悄悄改掉这些)。
|
||||
*
|
||||
* 作为独立片段是因为「个人设置」页还要接上称呼、分组顺序、分类管理三块,
|
||||
* 全塞一个文件里会变成没人愿意读的六百行。
|
||||
*/
|
||||
$p = $person;
|
||||
$avatarUrl = avatar_url($p['avatar'] ?? null);
|
||||
$bdSource = old('birthday_source', 'solar');
|
||||
$idBd = trim((string)($p['birthday_id_card'] ?? ''));
|
||||
// 裁剪比例由「这个位置显示成什么形状」决定,前后端共用同一份配置(见 App\ImageSlot)
|
||||
$avSlot = \App\ImageSlot::get('avatar');
|
||||
?>
|
||||
|
||||
<form method="post" enctype="multipart/form-data" action="<?= e(url('settings/me_save')) ?>">
|
||||
<?= csrf_field() ?>
|
||||
<div class="card card-pad">
|
||||
<div class="form-grid">
|
||||
|
||||
<div class="field">
|
||||
<label for="name">姓名 *</label>
|
||||
<input class="input" id="name" name="name" value="<?= e(old('name', $p['name'])) ?>" required>
|
||||
<?php if (!empty($errors['name'])): ?><span class="err"><?= e($errors['name']) ?></span><?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="gender">性别</label>
|
||||
<select class="select" id="gender" name="gender">
|
||||
<?php $g = old('gender', $p['gender'] ?? ''); ?>
|
||||
<option value="" <?= $g === '' ? 'selected' : '' ?>>不填</option>
|
||||
<option value="m" <?= $g === 'm' ? 'selected' : '' ?>>男</option>
|
||||
<option value="f" <?= $g === 'f' ? 'selected' : '' ?>>女</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="field full">
|
||||
<label for="slogan">我的一句话</label>
|
||||
<input class="input" id="slogan" name="slogan" maxlength="200"
|
||||
value="<?= e(old('slogan', $p['slogan'] ?? '')) ?>"
|
||||
placeholder="留空就用家庭统一的那句:<?= e($familyMotto !== '' ? $familyMotto : '(还没设)') ?>">
|
||||
<span class="tip">显示在你自己的首页标题下面。</span>
|
||||
<?php if (!empty($errors['slogan'])): ?><span class="err"><?= e($errors['slogan']) ?></span><?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- ==================== 我的三个生日 ==================== -->
|
||||
<div class="field full">
|
||||
<label>我的生日</label>
|
||||
<p class="small muted" style="margin:0 0 12px">
|
||||
身份证上的那个由证件推导,<b>系统永远不会改它</b>;
|
||||
下面两个是"实际过的阳历生日"和"长辈记的农历生日"。
|
||||
改其中任意一个,另一个会自动跟着变。
|
||||
</p>
|
||||
|
||||
<div class="field" style="margin-bottom:12px">
|
||||
<label>身份证生日(只读)</label>
|
||||
<span class="bd-readonly"><?= $idBd !== '' ? e($idBd) : '名册里还没填身份证号' ?></span>
|
||||
</div>
|
||||
|
||||
<div class="bd-source">
|
||||
<label for="bdSource">我这次改的是</label>
|
||||
<select class="select" id="bdSource" name="birthday_source" style="width:auto">
|
||||
<option value="solar" <?= $bdSource === 'solar' ? 'selected' : '' ?>>阳历(公历)</option>
|
||||
<option value="lunar" <?= $bdSource === 'lunar' ? 'selected' : '' ?>>农历(阴历)</option>
|
||||
</select>
|
||||
<span class="small muted">选中的那一边为准,另一边自动算</span>
|
||||
</div>
|
||||
|
||||
<div class="bd-pane" id="bdSolarWrap">
|
||||
<p class="bd-pane-k">阳历生日</p>
|
||||
<?php
|
||||
$dtName = 'birthday_solar';
|
||||
$dtValue = old('birthday_solar', \App\Birthday::pretty(\App\Birthday::solarOf($p)));
|
||||
$dtId = 'birthday_solar_date';
|
||||
$dtRequired = false;
|
||||
require __DIR__ . '/../_datetime.php';
|
||||
?>
|
||||
<?php if (!empty($errors['birthday_solar'])): ?><span class="err"><?= e($errors['birthday_solar']) ?></span><?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="bd-pane" id="bdLunarWrap">
|
||||
<p class="bd-pane-k">农历生日</p>
|
||||
<?php
|
||||
$dtName = 'birthday_lunar';
|
||||
$dtValue = old('birthday_lunar', (string)($p['birthday_lunar'] ?? ''));
|
||||
$dtId = 'birthday_lunar_date';
|
||||
$dtRequired = false;
|
||||
require __DIR__ . '/../_datetime.php';
|
||||
?>
|
||||
<label class="check-item" style="margin-top:8px">
|
||||
<input type="checkbox" name="birthday_lunar_leap" value="1"
|
||||
<?= old('birthday_lunar_leap', $p['birthday_lunar_leap'] ?? 0) ? 'checked' : '' ?>>
|
||||
<span>这个月是<b>闰月</b>(如「闰六月」)</span>
|
||||
</label>
|
||||
<?php if (!empty($errors['birthday_lunar'])): ?><span class="err"><?= e($errors['birthday_lunar']) ?></span><?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="email">邮箱</label>
|
||||
<input class="input" id="email" name="email" type="email"
|
||||
value="<?= e(old('email', $p['email'] ?? '')) ?>">
|
||||
<?php if (!empty($errors['email'])): ?><span class="err"><?= e($errors['email']) ?></span><?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="address">住址</label>
|
||||
<input class="input" id="address" name="address"
|
||||
value="<?= e(old('address', $p['address'] ?? '')) ?>">
|
||||
</div>
|
||||
|
||||
<div class="field full">
|
||||
<label for="note">备注</label>
|
||||
<textarea class="input" id="note" name="note"><?= e(old('note', $p['note'] ?? '')) ?></textarea>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="avatar">换头像</label>
|
||||
<input class="input" id="avatar" name="avatar" type="file" accept="image/*"
|
||||
data-crop-ratio="<?= e((string)$avSlot['ratio']) ?>"
|
||||
data-crop-w="<?= (int)$avSlot['w'] ?>"
|
||||
data-crop-h="<?= (int)$avSlot['h'] ?>"
|
||||
data-crop-label="<?= e((string)$avSlot['label']) ?>"
|
||||
data-crop-hint="<?= e((string)$avSlot['hint']) ?>"
|
||||
data-crop-preview="#avatar-preview">
|
||||
<?php /* 用户挑的裁剪框(归一化 0..1,相对原图)。不裁/没 JS 就留空 = 居中裁切 */ ?>
|
||||
<input type="hidden" name="avatar_crop" value="">
|
||||
<span class="tip">
|
||||
选好图片后会弹出裁剪框,把要留的部分框住。<b>比例按它在页面上的形状定</b>
|
||||
(头像是 1:1 正方形)。上限 5MB。
|
||||
</span>
|
||||
<?php if (!empty($errors['avatar'])): ?><span class="err"><?= e($errors['avatar']) ?></span><?php endif; ?>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>当前头像</label>
|
||||
<img id="avatar-preview" src="<?= e($avatarUrl) ?>" alt=""
|
||||
style="width:88px;height:88px;border-radius:12px;object-fit:cover;border:1px solid var(--line)">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="btn-row">
|
||||
<button class="btn" type="submit">保存我的资料</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
+63
-43
@@ -3,23 +3,23 @@
|
||||
* 个人设置 —— 「我自己的」设置。
|
||||
*
|
||||
* 与「系统设置」(?r=settings,仅管理员)的分工:
|
||||
* · 系统设置改一次**全家都变**:家庭 slogan、附件存储、运行环境;
|
||||
* · 个人设置只影响**我自己看到的样子**:我的资料、我怎么称呼别人、
|
||||
* 名册里分组的先后顺序、以及关系分类的增删改名。
|
||||
* · 系统设置改一次**全家都变**:slogan 兜底、附件存储、运行环境、**公共分组**;
|
||||
* · 个人设置只影响**我自己看到的样子**:我怎么称呼家人、我自己的分组。
|
||||
*
|
||||
* ⚠️ 关于「顺序」与「分类」这两个都不在系统设置里,理由是:
|
||||
* 分类是全家共用的一套(老杨的同事,对全家来说都是同事),所以它写在共享的表里;
|
||||
* 但**哪一组排前面纯属个人习惯** —— 爸爸把「家人」排第一、妈妈把「亲戚」排第一,
|
||||
* 这种偏好存在 user_settings 里,跟 family 级的 settings 严格分开,
|
||||
* 免得"改一个人的偏好"误伤到全家。
|
||||
* ⚠️ 「我的资料」表单**不在这页**(用户明确要求合并):
|
||||
* 「编辑成员」和「改自己的资料」本来就是一件事,所以只剩
|
||||
* `templates/people/form.php` 那一张表单,两个入口都指过去 ——
|
||||
* 这页顶部那个按钮,和名册卡片上的「编辑资料」,落到的完全是同一个页面。
|
||||
*/
|
||||
$groupCounts = $groupCounts ?? [];
|
||||
$groupTotal = count($groups);
|
||||
$rosterCount = $rosterCount ?? 0;
|
||||
?>
|
||||
<div class="page-head">
|
||||
<h1>个人设置</h1>
|
||||
<span class="sub">只影响你自己看到的样子</span>
|
||||
<div class="actions">
|
||||
<a class="btn btn-sm" href="<?= e(url('people/edit', ['id' => (int)$person['id']])) ?>">编辑我的资料</a>
|
||||
<a class="btn btn-ghost btn-sm" href="<?= e(url('people/show', ['id' => (int)$person['id']])) ?>">看我的详情页</a>
|
||||
<?php if (\App\Auth::isAdmin()): ?>
|
||||
<a class="btn btn-ghost btn-sm" href="<?= e(url('settings')) ?>">系统设置</a>
|
||||
@@ -27,36 +27,58 @@ $groupTotal = count($groups);
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 class="section-title" id="me-profile">我的资料 <span class="hint">姓名、头像、生日、联系方式</span></h2>
|
||||
<?php require __DIR__ . '/_profile.php'; ?>
|
||||
<div class="card card-pad">
|
||||
<h2 class="section-title">我的资料 <span class="hint">姓名、头像、生日、联系方式</span></h2>
|
||||
<p class="small muted" style="margin:0 0 14px">
|
||||
<?= e((string)$person['name']) ?>
|
||||
<?php if (trim((string)($person['slogan'] ?? '')) !== ''): ?>
|
||||
· 「<?= e((string)$person['slogan']) ?>」
|
||||
<?php endif; ?>
|
||||
<br>
|
||||
资料的编辑表单只有一张,和「编辑成员」是同一个页面 —— 从这里进去改的就是你自己。
|
||||
</p>
|
||||
<div class="btn-row" style="margin-top:0">
|
||||
<a class="btn" href="<?= e(url('people/edit', ['id' => (int)$person['id']])) ?>">编辑我的资料</a>
|
||||
<a class="btn btn-ghost" href="<?= e(url('auth/password')) ?>">改登录密码</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stack-gap"></div>
|
||||
<?php require __DIR__ . '/_nicknames.php'; ?>
|
||||
|
||||
<!-- ==================== 名册分组的先后顺序 ==================== -->
|
||||
<!-- ==================== 我的分组 ==================== -->
|
||||
<div class="card card-pad" style="margin-top:20px">
|
||||
<h2 class="section-title">
|
||||
名册分组顺序
|
||||
<span class="hint">只影响你自己看到的顺序</span>
|
||||
我的分组
|
||||
<span class="hint">公共的 + 我自己加的</span>
|
||||
</h2>
|
||||
<p class="small muted" style="margin:0 0 16px">
|
||||
名册是按「关系分组」分栏显示的。分组本身是全家共用的一套,
|
||||
但<b>哪一组排前面是你自己的习惯</b> —— 你在这里调,别人看到的顺序不变。
|
||||
<?php if ($groupTotal > 1): ?><br>用 ▲ ▼ 把它挪到你要的位置,挪一下就存一次。<?php endif; ?>
|
||||
名册是按「关系分组」分栏显示的。这里有两层:
|
||||
<b>公共分组</b>由管理员在「系统设置」里维护(全家都能用);
|
||||
你要是觉得不够,就在下面<b>加只给自己看的分组</b>,别人看不到、也不受影响。
|
||||
<br>
|
||||
列表里 <b>{{ 公共 }}</b> 标的是大家共用的那几个。
|
||||
哪一组排前面也是你自己的习惯,用 ▲ ▼ 调 —— 别人看到的顺序不变。
|
||||
<br>
|
||||
你的名册现在有 <b><?= (int)$rosterCount ?></b> 人。
|
||||
</p>
|
||||
|
||||
<?php if (!$groups): ?>
|
||||
<p class="small muted" style="margin:0">还没有分组。</p>
|
||||
<p class="small muted" style="margin:0 0 14px">还没有分组。加一个吧。</p>
|
||||
<?php else: ?>
|
||||
<ol class="order-list">
|
||||
<?php foreach ($groups as $i => $g): $gid = (int)$g['id']; ?>
|
||||
<?php foreach ($groups as $i => $g): $gid = (int)$g['id']; $own = (int)$g['owner_id']; ?>
|
||||
<li class="order-row">
|
||||
<span class="order-no"><?= $i + 1 ?></span>
|
||||
<span class="order-name"><?= e((string)$g['name']) ?></span>
|
||||
<span class="order-name">
|
||||
<?= e((string)$g['name']) ?>
|
||||
<?php if ($own === 0): ?><span class="badge">公共</span><?php else: ?><span class="badge badge-open">我的</span><?php endif; ?>
|
||||
</span>
|
||||
<span class="order-count"><?= (int)($groupCounts[$gid] ?? 0) ?> 人</span>
|
||||
<form method="post" action="<?= e(url('settings/groups/move')) ?>" class="order-move">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="id" value="<?= $gid ?>">
|
||||
<input type="hidden" name="scope" value="me">
|
||||
<button class="btn btn-ghost btn-sm" type="submit" name="dir" value="up"
|
||||
title="上移一组" <?= $i === 0 ? 'disabled' : '' ?>>▲</button>
|
||||
<button class="btn btn-ghost btn-sm" type="submit" name="dir" value="down"
|
||||
@@ -66,38 +88,29 @@ $groupTotal = count($groups);
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- ==================== 关系分类的增删改名 ==================== -->
|
||||
<div class="card card-pad" style="margin-top:20px">
|
||||
<h2 class="section-title">
|
||||
关系分类管理
|
||||
<span class="hint">分类是全家共用的</span>
|
||||
</h2>
|
||||
<p class="small muted" style="margin:0 0 16px">
|
||||
预置了「家人 / 亲戚 / 同事 / 朋友 / 合作伙伴 / 认识 / 不熟」七个。
|
||||
<b>不够用就自己加</b>,叫法不合适就改名。
|
||||
分类是全家共用的一套(你加的,家里人都会看到)——
|
||||
因为「老杨的同事」对全家来说都是同事,各人各定一套会让名册没法看。
|
||||
<br>
|
||||
删掉一个分类<b>不会删掉人</b>:那一组人会变成「未分类」,在名册里提醒你重新归类。
|
||||
</p>
|
||||
|
||||
<form method="post" action="<?= e(url('settings/groups/add')) ?>" class="inline-form">
|
||||
<form method="post" action="<?= e(url('settings/groups/add')) ?>" class="inline-form" style="margin-top:16px">
|
||||
<?= csrf_field() ?>
|
||||
<label class="sr-only" for="newGroup">新分类名</label>
|
||||
<input class="input" id="newGroup" name="name" maxlength="20" placeholder="例如:邻居、球友、老同学">
|
||||
<button class="btn btn-sm" type="submit">加一个分类</button>
|
||||
<input type="hidden" name="scope" value="me">
|
||||
<label class="sr-only" for="newMyGroup">新分组名</label>
|
||||
<input class="input" id="newMyGroup" name="name" maxlength="20" placeholder="例如:球友、老同学">
|
||||
<button class="btn btn-sm" type="submit">加一个我自己的分组</button>
|
||||
</form>
|
||||
|
||||
<?php if ($groups): ?>
|
||||
<ul class="group-manage">
|
||||
<?php foreach ($groups as $g): $gid = (int)$g['id']; ?>
|
||||
<?php
|
||||
// 只有我自己建的分组才给改名 / 删除 —— 公共分组要在系统设置里改(那是管理员的事),
|
||||
// 免得有人在自己设置里把"家人"改成别的、影响全家。
|
||||
$mineGroups = array_values(array_filter($groups, fn($g) => (int)$g['owner_id'] > 0));
|
||||
?>
|
||||
<?php if ($mineGroups): ?>
|
||||
<ul class="group-manage" style="margin-top:14px">
|
||||
<?php foreach ($mineGroups as $g): $gid = (int)$g['id']; ?>
|
||||
<li class="group-manage-row">
|
||||
<form method="post" action="<?= e(url('settings/groups/rename')) ?>" class="group-rename">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="id" value="<?= $gid ?>">
|
||||
<label class="sr-only" for="gname<?= $gid ?>">分类名</label>
|
||||
<input type="hidden" name="scope" value="me">
|
||||
<label class="sr-only" for="gname<?= $gid ?>">分组名</label>
|
||||
<input class="input" id="gname<?= $gid ?>" name="name" maxlength="20"
|
||||
value="<?= e((string)$g['name']) ?>">
|
||||
<button class="btn btn-ghost btn-sm" type="submit">改名</button>
|
||||
@@ -109,6 +122,7 @@ $groupTotal = count($groups);
|
||||
<form method="post" action="<?= e(url('settings/groups/delete')) ?>" class="del-confirm">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="id" value="<?= $gid ?>">
|
||||
<input type="hidden" name="scope" value="me">
|
||||
<span class="small muted">这组的人会变成「未分类」,确定?</span>
|
||||
<button class="btn btn-ghost btn-sm danger" type="submit">确认删除</button>
|
||||
</form>
|
||||
@@ -117,4 +131,10 @@ $groupTotal = count($groups);
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (\App\Auth::isAdmin()): ?>
|
||||
<p class="small muted" style="margin:16px 0 0">
|
||||
公共分组在「<a href="<?= e(url('settings')) ?>#public-groups">系统设置</a>」里维护。
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user