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) ?>">
|
|
|
|
|
|
<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>
|