名册每人一份 · 分组两层 · 拖动排序 · 表单合一 · 裁剪可缩放
按用户十点反馈逐条落地(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:
+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; ?>
|
||||
|
||||
Reference in New Issue
Block a user