2026-10-02 09:28:07 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 一条自定义日程:查看 / 改 / 删。
|
|
|
|
|
|
*
|
|
|
|
|
|
* ⚠️ 从月视图点**观影 / 旅程 / 任务**那些条会直接跳到对应模块(它们的"编辑页"在那里),
|
|
|
|
|
|
* 这里只处理 calendar_events 里真正属于某本日历的自定义日程。
|
|
|
|
|
|
*/
|
|
|
|
|
|
$canWrite = \App\Auth::canWrite() && !empty($ev['_can_write']);
|
|
|
|
|
|
?>
|
|
|
|
|
|
<div class="page-head">
|
|
|
|
|
|
<h1><?= e((string)$ev['title']) ?></h1>
|
|
|
|
|
|
<span class="sub"><?= e((string)($ev['starts_at'] ?? '')) ?></span>
|
|
|
|
|
|
<div class="actions">
|
|
|
|
|
|
<a class="btn btn-ghost" href="<?= e(url('calendar', ['ym' => substr((string)$ev['starts_at'], 0, 7)])) ?>">返回日程</a>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="card card-pad">
|
2026-10-03 08:18:05 +08:00
|
|
|
|
<?php $ym = substr((string)$ev['starts_at'], 0, 7); ?>
|
2026-10-02 09:28:07 +08:00
|
|
|
|
<?php if (!$canWrite): ?>
|
|
|
|
|
|
<dl class="kv">
|
2026-10-03 08:18:05 +08:00
|
|
|
|
<div class="kv-row"><dt>开始</dt>
|
|
|
|
|
|
<dd><?= e(empty($ev['all_day']) ? (string)$ev['starts_at'] : substr((string)$ev['starts_at'], 0, 10)) ?></dd>
|
2026-10-02 09:28:07 +08:00
|
|
|
|
</div>
|
2026-10-03 08:18:05 +08:00
|
|
|
|
<?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; ?>
|
2026-10-02 09:28:07 +08:00
|
|
|
|
<?php if (!empty($ev['note'])): ?>
|
|
|
|
|
|
<div class="kv-row"><dt>备注</dt><dd><?= nl2br(e((string)$ev['note'])) ?></dd></div>
|
|
|
|
|
|
<?php endif; ?>
|
2026-10-03 08:18:05 +08:00
|
|
|
|
<?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; ?>
|
2026-10-02 09:28:07 +08:00
|
|
|
|
</dl>
|
|
|
|
|
|
<p class="empty-hint">这本日历你只有只读权限,看得到但不能改。</p>
|
|
|
|
|
|
<?php else: ?>
|
2026-10-03 08:18:05 +08:00
|
|
|
|
<form method="post" action="<?= e(url('calendar/event_update')) ?>" enctype="multipart/form-data">
|
2026-10-02 09:28:07 +08:00
|
|
|
|
<?= csrf_field() ?>
|
|
|
|
|
|
<input type="hidden" name="id" value="<?= (int)$ev['id'] ?>">
|
|
|
|
|
|
<input type="hidden" name="ym" value="<?= e($ym) ?>">
|
2026-10-03 11:30:48 +08:00
|
|
|
|
<?php /* 这一次是哪一天:从日历点进来时 URL 带 ?d=YYYY-MM-DD。
|
|
|
|
|
|
"仅此一次 / 这一次及以后"都要靠它定位。 */ ?>
|
|
|
|
|
|
<input type="hidden" name="occ" value="<?= e($occ ?? '') ?>">
|
|
|
|
|
|
|
|
|
|
|
|
<?php /* 用户 2026-10-03 第 5 条:改一条**重复**日程时,先选"改哪些"。
|
|
|
|
|
|
只在它真的重复时才出现 —— 不重复的日程问这个是多余的。 */ ?>
|
|
|
|
|
|
<?php if (trim((string)($ev['rrule'] ?? '')) !== ''): ?>
|
|
|
|
|
|
<div class="card card-pad ev-scope">
|
|
|
|
|
|
<b>这是一条重复日程</b>
|
|
|
|
|
|
<p class="small muted" style="margin:6px 0 10px">
|
|
|
|
|
|
<?= e(\App\Repeat::describe((string)$ev['rrule'])) ?>
|
|
|
|
|
|
<?php if (!empty($occ)): ?>
|
|
|
|
|
|
<br>你打开的是 <b><?= e($occ) ?></b> 那一次。
|
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
</p>
|
|
|
|
|
|
<label class="chk-inline"><input type="radio" name="scope" value="all" checked>
|
|
|
|
|
|
<span>改<b>全部</b>(整条系列)</span></label>
|
|
|
|
|
|
<?php if (!empty($occ)): ?>
|
|
|
|
|
|
<label class="chk-inline"><input type="radio" name="scope" value="future">
|
|
|
|
|
|
<span>改<b>这一次及以后</b>(<?= e($occ) ?> 起,过去的保持不变)</span></label>
|
|
|
|
|
|
<label class="chk-inline"><input type="radio" name="scope" value="once">
|
|
|
|
|
|
<span>只改<b>这一次</b>(<?= e($occ) ?>)</span></label>
|
|
|
|
|
|
<?php else: ?>
|
|
|
|
|
|
<p class="small muted" style="margin:6px 0 0">
|
|
|
|
|
|
(从日历点某一天的日程进来,才能选「只改这一次 / 这一次及以后」。)
|
|
|
|
|
|
</p>
|
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
2026-10-02 09:28:07 +08:00
|
|
|
|
<div class="form-grid">
|
2026-10-03 08:18:05 +08:00
|
|
|
|
<?php $evFields = $ev; $evAllDay = false; require __DIR__ . '/_event_fields.php'; ?>
|
2026-10-02 09:28:07 +08:00
|
|
|
|
</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>
|
2026-10-03 08:18:05 +08:00
|
|
|
|
<?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; ?>
|
2026-10-02 09:28:07 +08:00
|
|
|
|
<?php /* ⚠️ 删除表单必须放在上面那个表单**外面**:<form> 套 <form> 是非法 HTML,
|
|
|
|
|
|
浏览器会把外层表单在嵌套处切开,"保存"按钮就失效了。 */ ?>
|
|
|
|
|
|
<form method="post" action="<?= e(url('calendar/event_del')) ?>" class="ev-del"
|
|
|
|
|
|
onsubmit="return confirm('删除这条日程?')">
|
|
|
|
|
|
<?= csrf_field() ?>
|
|
|
|
|
|
<input type="hidden" name="id" value="<?= (int)$ev['id'] ?>">
|
|
|
|
|
|
<input type="hidden" name="ym" value="<?= e($ym) ?>">
|
|
|
|
|
|
<button class="btn btn-danger btn-sm" type="submit">删除这条日程</button>
|
|
|
|
|
|
</form>
|
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
</div>
|