2026-09-30 13:24:26 +08:00
|
|
|
<?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>
|
|
|
|
|
|
2026-10-03 15:01:38 +08:00
|
|
|
<?php /* 用户 2026-10-03 第 2 条:所有"找个人"的地方都要**输入即筛选**。
|
|
|
|
|
这一页也是找人的地方(家里已有的人可能有几十个),
|
|
|
|
|
所以同样挂上 filter.js —— 行上带 data-search / data-initials。 */ ?>
|
|
|
|
|
<div class="search pick-search">
|
|
|
|
|
<label class="sr-only" for="pickFilter">筛选</label>
|
|
|
|
|
<input class="input" id="pickFilter" type="text" autocomplete="off"
|
|
|
|
|
data-filter="#pickList" data-filter-empty="#pickEmpty"
|
|
|
|
|
placeholder="输入名字或拼音首字母筛选,如 yyq">
|
|
|
|
|
</div>
|
|
|
|
|
<p class="small muted" id="pickEmpty" hidden>没有匹配的人。</p>
|
|
|
|
|
|
|
|
|
|
<ul class="pick-list" id="pickList">
|
2026-09-30 13:24:26 +08:00
|
|
|
<?php foreach ($people as $p): $pid = (int)$p['id']; ?>
|
|
|
|
|
<?php
|
|
|
|
|
// 显示名优先用「我怎么称呼他」:别人录的名字未必是我对他的叫法
|
|
|
|
|
$shown = (string)($p['my_nickname'] ?? '');
|
|
|
|
|
if ($shown === '') {
|
|
|
|
|
$shown = (string)$p['name'];
|
|
|
|
|
}
|
2026-10-03 15:01:38 +08:00
|
|
|
$pReal = (string)$p['name'];
|
2026-09-30 13:24:26 +08:00
|
|
|
?>
|
2026-10-03 15:01:38 +08:00
|
|
|
<li class="pick-row"
|
|
|
|
|
data-search="<?= e($shown . ' ' . $pReal . ' ' . (string)($p['email'] ?? '')) ?>"
|
|
|
|
|
data-initials="<?= e(\App\Pinyin::initials($pReal)) ?>">
|
2026-09-30 13:24:26 +08:00
|
|
|
<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; ?>
|