2026-09-22 22:03:08 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 节点参与人面板
|
|
|
|
|
|
* 依赖外部变量:$node、$members、$familyUsers、$roleTags(id=>name)、$emotions(emoji=>中文)
|
|
|
|
|
|
*/
|
|
|
|
|
|
$members = $members ?? [];
|
|
|
|
|
|
$familyUsers = $familyUsers ?? [];
|
|
|
|
|
|
$roleTags = $roleTags ?? [];
|
|
|
|
|
|
$emotions = $emotions ?? [];
|
|
|
|
|
|
|
|
|
|
|
|
$joinedIds = [];
|
|
|
|
|
|
foreach ($members as $m) {
|
|
|
|
|
|
$joinedIds[(int)$m['user_id']] = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
$notJoined = [];
|
|
|
|
|
|
foreach ($familyUsers as $u) {
|
|
|
|
|
|
if (!isset($joinedIds[(int)$u['id']])) $notJoined[] = $u;
|
|
|
|
|
|
}
|
|
|
|
|
|
?>
|
|
|
|
|
|
<section class="panel" id="members">
|
|
|
|
|
|
<h2 class="section-title">👥 参与人 (<?= count($members) ?>)</h2>
|
|
|
|
|
|
|
|
|
|
|
|
<?php if (empty($members)): ?>
|
|
|
|
|
|
<p class="muted">还没有添加参与人</p>
|
|
|
|
|
|
<?php else: ?>
|
|
|
|
|
|
<div class="member-list">
|
|
|
|
|
|
<?php foreach ($members as $m):
|
|
|
|
|
|
$mName = (string)($m['name'] ?? '');
|
|
|
|
|
|
if ($mName === '') $mName = '已注销用户';
|
|
|
|
|
|
?>
|
|
|
|
|
|
<div class="member-row">
|
|
|
|
|
|
<?php if (!empty($m['avatar'])): ?>
|
|
|
|
|
|
<img src="<?= e($m['avatar']) ?>" alt="" class="avatar-sm">
|
|
|
|
|
|
<?php else: ?>
|
|
|
|
|
|
<span class="avatar-sm avatar-placeholder"><?= e(mb_substr($mName, 0, 1)) ?></span>
|
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
<span class="member-name"><?= e($mName) ?></span>
|
|
|
|
|
|
|
|
|
|
|
|
<?php foreach ($m['role_tag_names'] as $tagName): ?>
|
|
|
|
|
|
<span class="member-role"><?= e($tagName) ?></span>
|
|
|
|
|
|
<?php endforeach; ?>
|
|
|
|
|
|
|
|
|
|
|
|
<?php if (!empty($m['emotion'])): ?>
|
|
|
|
|
|
<span class="member-emotion" title="<?= e($emotions[$m['emotion']] ?? '') ?>">
|
|
|
|
|
|
<?= e($m['emotion']) ?><?= e($emotions[$m['emotion']] ?? '') ?>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
<?php if (!empty($m['check_in_time'])): ?>
|
|
|
|
|
|
<span class="member-checkin">✓ 签到 <?= date('m-d H:i', strtotime((string)$m['check_in_time'])) ?></span>
|
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
<form method="post" action="<?= url('members/destroy') ?>" class="member-del-form"
|
|
|
|
|
|
onsubmit="return confirm('把 <?= e($mName) ?> 从本节点移出?');">
|
|
|
|
|
|
<input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
|
|
|
|
|
|
<input type="hidden" name="node_id" value="<?= (int)$node['id'] ?>">
|
|
|
|
|
|
<input type="hidden" name="user_id" value="<?= (int)$m['user_id'] ?>">
|
|
|
|
|
|
<button type="submit" class="comment-del">移出</button>
|
|
|
|
|
|
</form>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<?php endforeach; ?>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
<?php if (!empty($notJoined)): ?>
|
|
|
|
|
|
<form method="post" action="<?= url('members/addAll') ?>" style="display:inline"
|
|
|
|
|
|
onsubmit="return confirm('把家庭里的 <?= count($familyUsers) ?> 位成员全部加入这个节点?');">
|
|
|
|
|
|
<input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
|
|
|
|
|
|
<input type="hidden" name="node_id" value="<?= (int)$node['id'] ?>">
|
|
|
|
|
|
<button type="submit" class="btn-sm">+ 一键加入全家(<?= count($notJoined) ?> 人待加入)</button>
|
|
|
|
|
|
</form>
|
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
<details class="inline-panel">
|
|
|
|
|
|
<summary>+ 添加 / 修改参与人</summary>
|
2026-09-23 09:11:42 +08:00
|
|
|
|
<?php $mOldFilled = !empty($_SESSION['_old']); ?>
|
|
|
|
|
|
<form method="post" action="<?= url('members/store') ?>" class="form form-plain"
|
|
|
|
|
|
data-old="<?= $mOldFilled ? '1' : '0' ?>">
|
2026-09-22 22:03:08 +08:00
|
|
|
|
<input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
|
|
|
|
|
|
<input type="hidden" name="node_id" value="<?= (int)$node['id'] ?>">
|
|
|
|
|
|
|
|
|
|
|
|
<div class="form-row">
|
|
|
|
|
|
<label>成员 *</label>
|
|
|
|
|
|
<select name="user_id" required>
|
|
|
|
|
|
<option value="">— 请选择 —</option>
|
2026-09-23 09:11:42 +08:00
|
|
|
|
<?php $mSelUser = (string)old('user_id', ''); ?>
|
2026-09-22 22:03:08 +08:00
|
|
|
|
<?php foreach ($familyUsers as $u): ?>
|
2026-09-23 09:11:42 +08:00
|
|
|
|
<option value="<?= (int)$u['id'] ?>"<?= $mSelUser === (string)(int)$u['id'] ? ' selected' : '' ?>>
|
2026-09-22 22:03:08 +08:00
|
|
|
|
<?= e($u['name']) ?><?= isset($joinedIds[(int)$u['id']]) ? '(已加入,保存将覆盖)' : '' ?>
|
|
|
|
|
|
</option>
|
|
|
|
|
|
<?php endforeach; ?>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<?php if (!empty($roleTags)): ?>
|
|
|
|
|
|
<div class="form-row">
|
|
|
|
|
|
<label>角色标签(可多选)</label>
|
|
|
|
|
|
<div class="check-grid">
|
2026-09-23 09:11:42 +08:00
|
|
|
|
<?php $mSelTags = old_array('role_tag_ids'); ?>
|
2026-09-22 22:03:08 +08:00
|
|
|
|
<?php foreach ($roleTags as $tagId => $tagName): ?>
|
|
|
|
|
|
<label class="checkbox-label">
|
2026-09-23 09:11:42 +08:00
|
|
|
|
<input type="checkbox" name="role_tag_ids[]" value="<?= (int)$tagId ?>"
|
|
|
|
|
|
<?= in_array((string)(int)$tagId, $mSelTags, true) ? ' checked' : '' ?>>
|
2026-09-22 22:03:08 +08:00
|
|
|
|
<span><?= e($tagName) ?></span>
|
|
|
|
|
|
</label>
|
|
|
|
|
|
<?php endforeach; ?>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<?php else: ?>
|
|
|
|
|
|
<p class="muted" style="font-size:12px;">
|
|
|
|
|
|
还没有角色标签,去
|
|
|
|
|
|
<a href="<?= url('role_tags/index') ?>">角色标签管理</a>
|
|
|
|
|
|
先建几个(例如:司机 / 摄影师 / 记账员)
|
|
|
|
|
|
</p>
|
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="form-row">
|
|
|
|
|
|
<label>心情(可选)</label>
|
|
|
|
|
|
<div class="emotion-grid">
|
2026-09-23 09:11:42 +08:00
|
|
|
|
<?php $mSelEmotion = (string)old('emotion', ''); ?>
|
2026-09-22 22:03:08 +08:00
|
|
|
|
<label class="emotion-option">
|
2026-09-23 09:11:42 +08:00
|
|
|
|
<input type="radio" name="emotion" value=""<?= $mSelEmotion === '' ? ' checked' : '' ?>>
|
2026-09-22 22:03:08 +08:00
|
|
|
|
<span class="emotion-face">🚫</span>
|
|
|
|
|
|
<span class="emotion-text">不记录</span>
|
|
|
|
|
|
</label>
|
|
|
|
|
|
<?php foreach ($emotions as $emoji => $label): ?>
|
|
|
|
|
|
<label class="emotion-option" title="<?= e($label) ?>">
|
2026-09-23 09:11:42 +08:00
|
|
|
|
<input type="radio" name="emotion" value="<?= e($emoji) ?>"<?= $mSelEmotion === (string)$emoji ? ' checked' : '' ?>>
|
2026-09-22 22:03:08 +08:00
|
|
|
|
<span class="emotion-face"><?= e($emoji) ?></span>
|
|
|
|
|
|
<span class="emotion-text"><?= e($label) ?></span>
|
|
|
|
|
|
</label>
|
|
|
|
|
|
<?php endforeach; ?>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="form-row">
|
|
|
|
|
|
<label>签到时间(可选,留空表示未签到)</label>
|
2026-09-23 09:11:42 +08:00
|
|
|
|
<?php $dtName = 'check_in_time'; $dtValue = old_dt('check_in_time', null); $dtRequired = false; $dtId = 'check-in-date'; ?>
|
|
|
|
|
|
<?php require __DIR__ . '/../_datetime.php'; ?>
|
2026-09-22 22:03:08 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="form-actions">
|
|
|
|
|
|
<button type="submit" class="btn-primary">保存</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</form>
|
|
|
|
|
|
</details>
|
|
|
|
|
|
</section>
|