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 条线上探针全过。
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/**
|
||||
* 日程表单的字段块(新建与编辑共用一份 —— 复制一遍迟早改漏一处)。
|
||||
*
|
||||
* 字段按 **RFC 5545(iCalendar)/ RFC 4791(CalDAV)** 的 VEVENT 属性定:
|
||||
* 标题 = SUMMARY
|
||||
* 地点 = LOCATION
|
||||
* 开始/结束 = DTSTART / DTEND(DATETIME,精确到秒)
|
||||
* 全天 —— VEVENT 没有"全天"这个属性,约定俗成是把 DTSTART 写成 DATE 值;
|
||||
* 我们统一存 DATETIME,全天时时间部分为 00:00:00,导出 ics 时再落成 DATE 值。
|
||||
* 提醒 = VALARM 的 TRIGGER(提前多久);不提醒 = 不写 VALARM
|
||||
* 状态 = STATUS(CONFIRMED / TENTATIVE / CANCELLED)
|
||||
* 忙闲 = TRANSP(OPAQUE=忙 / TRANSPARENT=空闲)
|
||||
* 备注 = DESCRIPTION
|
||||
* 附件 = ATTACH
|
||||
*
|
||||
* 用法(include 前设好):
|
||||
* $evFields 正在编辑的日程(新建时传空数组)
|
||||
* $evAllDay 全天的默认值(新建默认**不勾**,用户 2026-10-02 第 6 条)
|
||||
*/
|
||||
$evF = is_array($evFields ?? null) ? $evFields : [];
|
||||
$evAllDayDefault = (bool)($evAllDay ?? false);
|
||||
$evIsAllDay = array_key_exists('all_day', $evF) ? !empty($evF['all_day']) : $evAllDayDefault;
|
||||
?>
|
||||
<div class="field full">
|
||||
<label for="ev-title">标题 *</label>
|
||||
<input class="input" id="ev-title" name="title" required
|
||||
value="<?= e((string)($evF['title'] ?? '')) ?>" placeholder="如:家长会">
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="ev-location">地点</label>
|
||||
<input class="input" id="ev-location" name="location"
|
||||
value="<?= e((string)($evF['location'] ?? '')) ?>" placeholder="如:学校三楼会议室">
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>提醒</label>
|
||||
<?php /* 不提醒 = NULL(导出 ics 时不写 VALARM);档位就是用户第 6 条列的那些。 */ ?>
|
||||
<select class="select" name="reminder_minutes" aria-label="提前多久提醒">
|
||||
<?php $cur = $evF['reminder_minutes'] ?? null; ?>
|
||||
<option value=""<?= $cur === null || $cur === '' ? ' selected' : '' ?>>不提醒</option>
|
||||
<?php foreach (\App\Calendar::REMINDERS as $mins => $word): ?>
|
||||
<option value="<?= (int)$mins ?>"<?= (string)$cur === (string)$mins ? ' selected' : '' ?>>
|
||||
<?= e($word) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<?php /* v24 第 5、6 条:起止各一个「日期 + 时分秒」合在一起的控件(全局统一),
|
||||
不再拆成"日期一格 + 时刻一格"。两个控件长得一样,扫一眼就知道哪个是开始。 */ ?>
|
||||
<div class="field ev-dt" data-dt>
|
||||
<label>开始 *</label>
|
||||
<?php $dtName = 'starts_at'; $dtId = 'ev-start';
|
||||
$dtValue = $evF['starts_at'] ?? null; $dtRequired = true; $dtSeconds = true;
|
||||
require __DIR__ . '/../_datetime.php'; ?>
|
||||
</div>
|
||||
<div class="field ev-dt" data-dt>
|
||||
<label>结束</label>
|
||||
<?php $dtName = 'ends_at'; $dtId = 'ev-end';
|
||||
$dtValue = $evF['ends_at'] ?? null; $dtRequired = false; $dtSeconds = true;
|
||||
require __DIR__ . '/../_datetime.php'; ?>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>
|
||||
<input type="checkbox" id="ev-allday" name="all_day" value="1"
|
||||
<?= $evIsAllDay ? 'checked' : '' ?>>
|
||||
全天
|
||||
</label>
|
||||
<span class="field-hint">勾上就不管具体几点,只占这一天</span>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="ev-status">状态</label>
|
||||
<select class="select" id="ev-status" name="status">
|
||||
<?php $st = (string)($evF['status'] ?? 'confirmed'); ?>
|
||||
<option value="confirmed"<?= $st === 'confirmed' ? ' selected' : '' ?>>确定</option>
|
||||
<option value="tentative"<?= $st === 'tentative' ? ' selected' : '' ?>>待定</option>
|
||||
<option value="cancelled"<?= $st === 'cancelled' ? ' selected' : '' ?>>取消</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="ev-transp">这段时间算</label>
|
||||
<select class="select" id="ev-transp" name="transp">
|
||||
<?php $tp = (int)($evF['transp'] ?? 0); ?>
|
||||
<option value="0"<?= $tp === 0 ? ' selected' : '' ?>>忙碌</option>
|
||||
<option value="1"<?= $tp === 1 ? ' selected' : '' ?>>空闲(别人还能约)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="field full">
|
||||
<label for="ev-note">备注</label>
|
||||
<textarea class="input" id="ev-note" name="note" rows="3"
|
||||
placeholder="要带什么、跟谁一起…"><?= e((string)($evF['note'] ?? '')) ?></textarea>
|
||||
</div>
|
||||
|
||||
<div class="field full">
|
||||
<label for="ev-attach">附件(可多选)</label>
|
||||
<input class="input" type="file" id="ev-attach" name="attach[]" multiple>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
/* 「全天」勾上就把两个时刻控件的**时间部分**收起来 —— 日期还得留着。
|
||||
只藏 .dt-time(时/分/秒那一段),.dt-date 是日期,藏了就没法选哪天了。 */
|
||||
var box = document.getElementById('ev-allday');
|
||||
if (!box) return;
|
||||
function sync() {
|
||||
Array.prototype.forEach.call(document.querySelectorAll('[data-dt] .dt-time'), function (el) {
|
||||
el.hidden = box.checked;
|
||||
});
|
||||
}
|
||||
box.addEventListener('change', sync);
|
||||
sync();
|
||||
})();
|
||||
</script>
|
||||
<?php unset($evF, $evAllDayDefault, $evIsAllDay, $evFields, $evAllDay); ?>
|
||||
@@ -102,12 +102,17 @@ $canWrite = \App\Auth::canWrite();
|
||||
<form class="inline-form" method="post" action="<?= e(url('calendar/cal_share')) ?>">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="id" value="<?= (int)$c['id'] ?>">
|
||||
<select class="select" name="person_id">
|
||||
<?php foreach ($people as $p): ?>
|
||||
<?php if ((int)$p['id'] === (int)\App\Auth::personId()) { continue; } ?>
|
||||
<option value="<?= (int)$p['id'] ?>"><?= e(person_name($p)) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php
|
||||
$ppName = 'person_id';
|
||||
$ppPeople = array_values(array_filter($people,
|
||||
fn($p) => (int)$p['id'] !== (int)\App\Auth::personId()));
|
||||
$ppSelected = [];
|
||||
$ppMode = 'single';
|
||||
$ppOpenBtn = '选择要共享给谁';
|
||||
$ppTitle = '共享给谁';
|
||||
$ppEmptyText = '未选择';
|
||||
require __DIR__ . '/../_person_picker.php';
|
||||
?>
|
||||
<select class="select" name="perm">
|
||||
<option value="read">只读</option>
|
||||
<option value="write">可写</option>
|
||||
@@ -129,6 +134,9 @@ $canWrite = \App\Auth::canWrite();
|
||||
<?php if ($canWrite): ?>
|
||||
<td>
|
||||
<div class="actions">
|
||||
<?php /* v24 第 7 条:每本都能导出 .ics(预置本也能 —— 导的是派生出来的内容)。 */ ?>
|
||||
<a class="btn btn-ghost btn-sm"
|
||||
href="<?= e(url('calendar/export', ['id' => (int)$c['id']])) ?>">导出 ics</a>
|
||||
<?php if (($c['kind'] ?? '') === 'custom'): ?>
|
||||
<a class="btn btn-ghost btn-sm"
|
||||
href="<?= e(url('calendar/calendars', ['edit' => (int)$c['id']])) ?>">编辑</a>
|
||||
@@ -152,6 +160,89 @@ $canWrite = \App\Auth::canWrite();
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($canWrite): ?>
|
||||
<?php /* v24 第 7 条:把一个 .ics 文件里的日程整批导进某一本。
|
||||
只能导进自定义本 —— 观影/旅行两本是派生的,塞进去就成了孤儿日程
|
||||
(日历里有、观影列表里没有)。 */ ?>
|
||||
<div class="card card-pad">
|
||||
<h2 class="cinema-h2">
|
||||
导入 ics
|
||||
<span class="hint">把别的日历导出的 .ics 文件整批装进来</span>
|
||||
</h2>
|
||||
<p class="small muted" style="margin:0 0 16px">
|
||||
同一个文件导两次也<b>不会重复</b>:每条日程有个全球唯一的 UID,
|
||||
已经导过的会被更新,而不是再插一条。
|
||||
</p>
|
||||
<form method="post" action="<?= e(url('calendar/import')) ?>" enctype="multipart/form-data">
|
||||
<?= csrf_field() ?>
|
||||
<div class="form-grid">
|
||||
<div class="field">
|
||||
<label for="im-cal">导进哪一本 *</label>
|
||||
<select class="select" id="im-cal" name="calendar_id">
|
||||
<?php foreach ($cals as $c): ?>
|
||||
<?php if (($c['kind'] ?? '') !== 'custom') { continue; } ?>
|
||||
<option value="<?= (int)$c['id'] ?>"><?= e((string)$c['name']) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="im-file">.ics 文件 *</label>
|
||||
<input class="input" type="file" id="im-file" name="ics" accept=".ics,text/calendar" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-row">
|
||||
<button class="btn btn-sm" type="submit">导入</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php /* v24 第 7 条后半:CalDAV —— 把我的日历本订阅到手机/别的日历程序里 */ ?>
|
||||
<div class="card card-pad">
|
||||
<h2 class="cinema-h2">
|
||||
CalDAV 订阅
|
||||
<span class="hint">在手机日历 / DAVx⁵ / Thunderbird 里订阅你的日历本</span>
|
||||
</h2>
|
||||
<p class="small muted" style="margin:0 0 12px">
|
||||
填下面这个地址 + 你的<b>姓名或手机号</b> + <b>CalDAV 口令</b>,就能把「我的日历本」
|
||||
同步到别的日历程序里。这是<b>只读</b>订阅的 —— 在手机上改日程请回到本站来改。
|
||||
<br>口令与登录密码是<b>分开的</b>:订阅凭据会被客户端长期存着,所以另发一个,
|
||||
随时可换、不影响登录。
|
||||
</p>
|
||||
<div class="field">
|
||||
<label>服务器地址</label>
|
||||
<input class="input mono" readonly
|
||||
value="<?= e(rtrim((string)fb_config('base_url', ''), '/') . '/dav/') ?>">
|
||||
<span class="tip">在日历客户端里填这一条即可,会列出你所有的日历本。</span>
|
||||
</div>
|
||||
<?php if (!empty($cdPlain)): ?>
|
||||
<p class="tip" style="background:#FFF6E5;border-color:#E8C98A;padding:8px 12px;border-radius:8px">
|
||||
<b>这是你的新口令,只显示这一次,请立刻复制走:</b>
|
||||
<br><code class="mono" style="font-size:15px"><?= e($cdPlain) ?></code>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<?php if ($canWrite): ?>
|
||||
<div class="btn-row">
|
||||
<form method="post" action="<?= e(url('calendar/caldav_token')) ?>" class="res-inline">
|
||||
<?= csrf_field() ?>
|
||||
<button class="btn btn-sm" type="submit">
|
||||
<?= !empty($cdHas) ? '重置 CalDAV 口令' : '生成 CalDAV 口令' ?>
|
||||
</button>
|
||||
</form>
|
||||
<?php if (!empty($cdHas)): ?>
|
||||
<form method="post" action="<?= e(url('calendar/caldav_revoke')) ?>" class="res-inline">
|
||||
<?= csrf_field() ?>
|
||||
<button class="btn btn-ghost btn-sm" type="submit"
|
||||
onclick="return confirm('撤销后所有已订阅的客户端都会失去访问。')">撤销口令</button>
|
||||
</form>
|
||||
<span class="node-badge">口令已配置</span>
|
||||
<?php else: ?>
|
||||
<span class="node-badge">还没配置口令</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($shared): ?>
|
||||
<div class="card card-pad">
|
||||
<h2 class="cinema-h2">别人共享给我的</h2>
|
||||
|
||||
@@ -16,61 +16,75 @@ $canWrite = \App\Auth::canWrite() && !empty($ev['_can_write']);
|
||||
</div>
|
||||
|
||||
<div class="card card-pad">
|
||||
<?php $ym = substr((string)$ev['starts_at'], 0, 7); ?>
|
||||
<?php if (!$canWrite): ?>
|
||||
<dl class="kv">
|
||||
<div class="kv-row"><dt>日期</dt><dd><?= e((string)$ev['starts_at']) ?></dd></div>
|
||||
<?php if (!empty($ev['ends_at'])): ?>
|
||||
<div class="kv-row"><dt>到</dt><dd><?= e((string)$ev['ends_at']) ?></dd></div>
|
||||
<?php endif; ?>
|
||||
<div class="kv-row"><dt>时间</dt>
|
||||
<dd><?= empty($ev['all_day']) ? e(substr((string)$ev['start_time'], 0, 5) . ' – ' . substr((string)$ev['end_time'], 0, 5)) : '全天' ?></dd>
|
||||
<div class="kv-row"><dt>开始</dt>
|
||||
<dd><?= e(empty($ev['all_day']) ? (string)$ev['starts_at'] : substr((string)$ev['starts_at'], 0, 10)) ?></dd>
|
||||
</div>
|
||||
<?php if (!empty($ev['ends_at'])): ?>
|
||||
<div class="kv-row"><dt>结束</dt>
|
||||
<dd><?= e(empty($ev['all_day']) ? (string)$ev['ends_at'] : substr((string)$ev['ends_at'], 0, 10)) ?></dd>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($ev['all_day'])): ?>
|
||||
<div class="kv-row"><dt></dt><dd>全天</dd></div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($ev['location'])): ?>
|
||||
<div class="kv-row"><dt>地点</dt><dd><?= e((string)$ev['location']) ?></dd></div>
|
||||
<?php endif; ?>
|
||||
<?php if (($ev['reminder_minutes'] ?? null) !== null): ?>
|
||||
<div class="kv-row"><dt>提醒</dt>
|
||||
<dd><?= e(\App\Calendar::REMINDERS[(int)$ev['reminder_minutes']] ?? '') ?></dd>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($ev['note'])): ?>
|
||||
<div class="kv-row"><dt>备注</dt><dd><?= nl2br(e((string)$ev['note'])) ?></dd></div>
|
||||
<?php endif; ?>
|
||||
<?php $roAs = \App\Attachment::list(\App\Calendar::ATTACH, (int)$ev['id']); ?>
|
||||
<?php if ($roAs): ?>
|
||||
<div class="kv-row"><dt>附件</dt>
|
||||
<dd class="attach-row">
|
||||
<?php foreach ($roAs as $a): ?>
|
||||
<span class="attach-item">
|
||||
<a href="<?= e(media_url((string)$a['key'])) ?>" target="_blank" rel="noopener">
|
||||
<?= (int)$a['is_image'] === 1 ? '🖼' : '📄' ?> <?= e((string)($a['name'] ?: '附件')) ?>
|
||||
</a>
|
||||
<a class="link-quiet" href="<?= e(media_url((string)$a['key'], ['dl' => 1])) ?>">下载</a>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
</dd>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</dl>
|
||||
<p class="empty-hint">这本日历你只有只读权限,看得到但不能改。</p>
|
||||
<?php else: ?>
|
||||
<form method="post" action="<?= e(url('calendar/event_update')) ?>">
|
||||
<form method="post" action="<?= e(url('calendar/event_update')) ?>" enctype="multipart/form-data">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="id" value="<?= (int)$ev['id'] ?>">
|
||||
<?php $ym = substr((string)$ev['starts_at'], 0, 7); ?>
|
||||
<input type="hidden" name="ym" value="<?= e($ym) ?>">
|
||||
<div class="form-grid">
|
||||
<div class="field full">
|
||||
<label for="ev-title">标题 *</label>
|
||||
<input class="input" id="ev-title" name="title" required value="<?= e((string)$ev['title']) ?>">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="ev-date">开始日期 *</label>
|
||||
<input class="input" type="date" id="ev-date" name="date" required
|
||||
value="<?= e((string)$ev['starts_at']) ?>">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="ev-end">结束日期(跨天时填)</label>
|
||||
<input class="input" type="date" id="ev-end" name="end_date" value="<?= e((string)($ev['ends_at'] ?? '')) ?>">
|
||||
</div>
|
||||
<div class="field full">
|
||||
<label><input type="checkbox" name="all_day" value="1" <?= empty($ev['all_day']) ? '' : 'checked' ?>> 全天(不填具体时分)</label>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="ev-st">开始时刻</label>
|
||||
<input class="input" type="time" id="ev-st" name="start_time" value="<?= e(substr((string)($ev['start_time'] ?? ''), 0, 5)) ?>">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="ev-et">结束时刻</label>
|
||||
<input class="input" type="time" id="ev-et" name="end_time" value="<?= e(substr((string)($ev['end_time'] ?? ''), 0, 5)) ?>">
|
||||
</div>
|
||||
<div class="field full">
|
||||
<label for="ev-note">备注</label>
|
||||
<textarea class="input" id="ev-note" name="note" rows="3"><?= e((string)($ev['note'] ?? '')) ?></textarea>
|
||||
</div>
|
||||
<?php $evFields = $ev; $evAllDay = false; require __DIR__ . '/_event_fields.php'; ?>
|
||||
</div>
|
||||
<div class="btn-row">
|
||||
<button class="btn" type="submit">保存</button>
|
||||
<a class="btn btn-ghost" href="<?= e(url('calendar', ['ym' => $ym])) ?>">取消</a>
|
||||
</div>
|
||||
</form>
|
||||
<?php $as = \App\Attachment::list(\App\Calendar::ATTACH, (int)$ev['id']); ?>
|
||||
<?php if ($as): ?>
|
||||
<div class="ev-attach-list">
|
||||
<span class="res-label">已有附件</span>
|
||||
<?php
|
||||
$attRows = $as;
|
||||
$attCanEdit = true;
|
||||
$attDelUrl = 'calendar/attach_del';
|
||||
$attDelField = 'attach_id';
|
||||
$attExtra = ['id' => (int)$ev['id']];
|
||||
require __DIR__ . '/../_attachments.php';
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php /* ⚠️ 删除表单必须放在上面那个表单**外面**:<form> 套 <form> 是非法 HTML,
|
||||
浏览器会把外层表单在嵌套处切开,"保存"按钮就失效了。 */ ?>
|
||||
<form method="post" action="<?= e(url('calendar/event_del')) ?>" class="ev-del"
|
||||
|
||||
+105
-46
@@ -17,19 +17,55 @@
|
||||
* @param array $people 名册(共享给别人时用)
|
||||
*/
|
||||
$canWrite = \App\Auth::canWrite();
|
||||
$view = (string)($view ?? 'month');
|
||||
$anchor = (string)($anchor ?? date('Y-m-d'));
|
||||
$ts = strtotime($ym . '-01') ?: time();
|
||||
$prevYm = date('Y-m', strtotime('-1 month', $ts));
|
||||
$nextYm = date('Y-m', strtotime('+1 month', $ts));
|
||||
$thisYm = date('Y-m');
|
||||
$writable = array_values(array_filter($cals, static fn($c) => \App\Calendar::canWrite($c, (int)\App\Auth::personId())));
|
||||
|
||||
// 三种看法各自的「上一段 / 下一段」:月按整月走,周按 7 天走,天按 1 天走
|
||||
$step = $view === 'week' ? 7 : ($view === 'day' ? 1 : 0);
|
||||
$prevD = date('Y-m-d', strtotime('-' . $step . ' days', strtotime($anchor)));
|
||||
$nextD = date('Y-m-d', strtotime('+' . $step . ' days', strtotime($anchor)));
|
||||
$todayD = date('Y-m-d');
|
||||
$headText = $view === 'month' ? date('Y 年 n 月', $ts)
|
||||
: ($view === 'week' ? date('Y 年 n 月 j 日', strtotime($anchor)) . ' 起这一周'
|
||||
: date('Y 年 n 月 j 日', strtotime($anchor)));
|
||||
$mkUrl = static function (string $v) use ($ym, $prevD, $nextD, $todayD, $prevYm, $nextYm, $thisYm) {
|
||||
if ($v === 'month') {
|
||||
return url('calendar', ['view' => 'month', 'ym' => $ym]);
|
||||
}
|
||||
return null; // 周/天要把具体哪天传进去,由调用方拼
|
||||
};
|
||||
?>
|
||||
<div class="page-head">
|
||||
<h1>日程</h1>
|
||||
<span class="sub"><?= e(date('Y 年 n 月', $ts)) ?></span>
|
||||
<span class="sub"><?= e($headText) ?></span>
|
||||
<div class="actions">
|
||||
<a class="btn btn-ghost" href="<?= e(url('calendar', ['ym' => $prevYm])) ?>">上一月</a>
|
||||
<a class="btn btn-ghost" href="<?= e(url('calendar', ['ym' => $thisYm])) ?>">今天</a>
|
||||
<a class="btn btn-ghost" href="<?= e(url('calendar', ['ym' => $nextYm])) ?>">下一月</a>
|
||||
<?php /* v24 第 4 条:月 / 周 / 天三选一 */ ?>
|
||||
<span class="seg" role="group" aria-label="看法">
|
||||
<a class="seg-btn<?= $view === 'month' ? ' is-on' : '' ?>"
|
||||
href="<?= e(url('calendar', ['view' => 'month', 'ym' => $ym])) ?>">月</a>
|
||||
<a class="seg-btn<?= $view === 'week' ? ' is-on' : '' ?>"
|
||||
href="<?= e(url('calendar', ['view' => 'week', 'd' => $anchor])) ?>">周</a>
|
||||
<a class="seg-btn<?= $view === 'day' ? ' is-on' : '' ?>"
|
||||
href="<?= e(url('calendar', ['view' => 'day', 'd' => $anchor])) ?>">天</a>
|
||||
</span>
|
||||
<?php if ($view === 'month'): ?>
|
||||
<a class="btn btn-ghost" href="<?= e(url('calendar', ['view' => 'month', 'ym' => $prevYm])) ?>">上一月</a>
|
||||
<a class="btn btn-ghost" href="<?= e(url('calendar', ['view' => 'month', 'ym' => $thisYm])) ?>">今天</a>
|
||||
<a class="btn btn-ghost" href="<?= e(url('calendar', ['view' => 'month', 'ym' => $nextYm])) ?>">下一月</a>
|
||||
<?php else: ?>
|
||||
<a class="btn btn-ghost" href="<?= e(url('calendar', ['view' => $view, 'd' => $prevD])) ?>">
|
||||
<?= $view === 'week' ? '上一周' : '前一天' ?>
|
||||
</a>
|
||||
<a class="btn btn-ghost" href="<?= e(url('calendar', ['view' => $view, 'd' => $todayD])) ?>">今天</a>
|
||||
<a class="btn btn-ghost" href="<?= e(url('calendar', ['view' => $view, 'd' => $nextD])) ?>">
|
||||
<?= $view === 'week' ? '下一周' : '后一天' ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<a class="btn btn-ghost" href="<?= e(url('calendar/calendars')) ?>">日历本</a>
|
||||
<?php if ($canWrite && $writable): ?>
|
||||
<button class="btn" type="button" id="calAddBtn">新建日程</button>
|
||||
@@ -68,7 +104,7 @@ $writable = array_values(array_filter($cals, static fn($c) => \App\Calendar::can
|
||||
<?php if ($canWrite && $writable): ?>
|
||||
<div class="card card-pad cal-add" id="calAddCard" hidden>
|
||||
<h2 class="cinema-h2">新建日程</h2>
|
||||
<form method="post" action="<?= e(url('calendar/event_add')) ?>">
|
||||
<form method="post" action="<?= e(url('calendar/event_add')) ?>" enctype="multipart/form-data">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="ym" value="<?= e($ym) ?>">
|
||||
<div class="form-grid">
|
||||
@@ -80,34 +116,14 @@ $writable = array_values(array_filter($cals, static fn($c) => \App\Calendar::can
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="ce-title">标题 *</label>
|
||||
<input class="input" id="ce-title" name="title" required placeholder="如:家长会">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="ce-date">日期 *</label>
|
||||
<input class="input" type="date" id="ce-date" name="date" required
|
||||
value="<?= e($ym === $thisYm ? date('Y-m-d') : $ym . '-01') ?>">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="ce-end">结束日期(跨天时填)</label>
|
||||
<input class="input" type="date" id="ce-end" name="end_date">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label><input type="checkbox" id="ce-allday" name="all_day" value="1" checked> 全天(不填具体时分)</label>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="ce-note">备注</label>
|
||||
<input class="input" id="ce-note" name="note">
|
||||
</div>
|
||||
<div class="field" id="ce-time-s">
|
||||
<label for="ce-st">开始时刻</label>
|
||||
<input class="input" type="time" id="ce-st" name="start_time">
|
||||
</div>
|
||||
<div class="field" id="ce-time-e">
|
||||
<label for="ce-et">结束时刻</label>
|
||||
<input class="input" type="time" id="ce-et" name="end_time">
|
||||
</div>
|
||||
<?php /* v24 第 6 条:字段按 iCalendar / CalDAV 的 VEVENT 定(见 _event_fields.php)。
|
||||
新建时「全天」默认**不勾**(用户原话),开始时间默认今天 09:00。 */ ?>
|
||||
<?php
|
||||
$evFields = ['starts_at' => ($ym === $thisYm ? date('Y-m-d') : $ym . '-01') . ' 09:00:00',
|
||||
'ends_at' => ($ym === $thisYm ? date('Y-m-d') : $ym . '-01') . ' 10:00:00'];
|
||||
$evAllDay = false;
|
||||
require __DIR__ . '/_event_fields.php';
|
||||
?>
|
||||
</div>
|
||||
<div class="btn-row">
|
||||
<button class="btn btn-sm" type="submit">加上</button>
|
||||
@@ -117,6 +133,60 @@ $writable = array_values(array_filter($cals, static fn($c) => \App\Calendar::can
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($view === 'week' || $view === 'day'): ?>
|
||||
<?php /* ===== 周 / 天:按小时铺的时间网格(全天日程单独挂顶上) ===== */ ?>
|
||||
<div class="card cal-tg-card">
|
||||
<div class="tg-head">
|
||||
<div class="tg-gutter"></div>
|
||||
<?php foreach (($cols ?? []) as $c): ?>
|
||||
<div class="tg-dayname<?= $c['is_today'] ? ' is-today' : '' ?>">
|
||||
<span class="tg-wd"><?= e(['日','一','二','三','四','五','六'][$c['w']]) ?></span>
|
||||
<span class="tg-dd"><?= (int)$c['day'] ?></span>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?php $tgAll = $tgrid['all_day'] ?? []; ?>
|
||||
<?php if (array_filter($tgAll)): ?>
|
||||
<div class="tg-allday">
|
||||
<div class="tg-gutter"><span class="tg-tag">全天</span></div>
|
||||
<?php foreach (($cols ?? []) as $i => $c): ?>
|
||||
<div class="tg-adcell">
|
||||
<?php foreach (($tgAll[$i] ?? []) as $ev): ?>
|
||||
<a class="cal-ev is-allday" data-cal="<?= (int)$ev['cal'] ?>"
|
||||
style="background: <?= e((string)$ev['color']) ?>;"
|
||||
href="<?= e((string)$ev['href']) ?>"
|
||||
title="<?= e((string)$ev['title']) ?>"><?= e((string)$ev['title']) ?></a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="tg-body">
|
||||
<div class="tg-gutter tg-hours">
|
||||
<?php for ($h = 0; $h < 24; $h++): ?>
|
||||
<span class="tg-hr"><?= sprintf('%02d', $h) ?></span>
|
||||
<?php endfor; ?>
|
||||
</div>
|
||||
<?php foreach (($cols ?? []) as $i => $c): ?>
|
||||
<div class="tg-col<?= $c['is_today'] ? ' is-today' : '' ?>">
|
||||
<?php for ($h = 0; $h < 24; $h++): ?>
|
||||
<span class="tg-line"></span>
|
||||
<?php endfor; ?>
|
||||
<?php foreach (($tgrid['timed'][$i] ?? []) as $ev): ?>
|
||||
<a class="tg-block" data-cal="<?= (int)$ev['cal'] ?>"
|
||||
style="background: <?= e((string)$ev['color']) ?>; top: <?= (float)$ev['top'] ?>%; height: <?= (float)$ev['height'] ?>%;"
|
||||
href="<?= e((string)$ev['href']) ?>"
|
||||
title="<?= e((string)$ev['title']) ?>">
|
||||
<b><?= e((string)$ev['time']) ?></b> <?= e((string)$ev['title']) ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="card cal-grid-card">
|
||||
<div class="cal-head">
|
||||
<?php foreach (['日', '一', '二', '三', '四', '五', '六'] as $wd): ?>
|
||||
@@ -150,6 +220,7 @@ $writable = array_values(array_filter($cals, static fn($c) => \App\Calendar::can
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -180,18 +251,6 @@ $writable = array_values(array_filter($cals, static fn($c) => \App\Calendar::can
|
||||
});
|
||||
}
|
||||
if (cancel && card) { cancel.addEventListener('click', function () { card.hidden = true; }); }
|
||||
|
||||
/* 「全天」勾上就把两个时刻输入框藏掉 —— 没有具体时分就是全天(用户第 7 条) */
|
||||
var allday = document.getElementById('ce-allday');
|
||||
var ts = document.getElementById('ce-time-s');
|
||||
var te = document.getElementById('ce-time-e');
|
||||
if (allday && ts && te) {
|
||||
function syncTime() {
|
||||
var hide = allday.checked;
|
||||
ts.hidden = hide; te.hidden = hide;
|
||||
}
|
||||
allday.addEventListener('change', syncTime);
|
||||
syncTime();
|
||||
}
|
||||
/* 「全天」勾上藏掉时刻那一段的逻辑在 _event_fields.php 里(两个页面共用一份) */
|
||||
})();
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user