First cut of Add / Edit / Active / Answered pages
- Centralized UI between UI and Layout classes
This commit is contained in:
24
src/public/request/prayed.php
Normal file
24
src/public/request/prayed.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use MyPrayerJournal\{Auth, History, RecurrencePeriod, Request, RequestAction, Table, UI};
|
||||
use BitBadger\PDODocument\Patch;
|
||||
|
||||
require '../../start.php';
|
||||
if ($_SERVER['REQUEST_METHOD'] <> 'PATCH') not_found();
|
||||
|
||||
Auth::requireUser(false);
|
||||
|
||||
$req = Request::byId($_GET['id']);
|
||||
if (!$req) not_found();
|
||||
|
||||
$now = new DateTimeImmutable('now');
|
||||
|
||||
array_unshift($req->history, new History($now->format('c'), RequestAction::Prayed));
|
||||
$patch = ['history' => $req->history];
|
||||
|
||||
if ($req->recurrence->period <> RecurrencePeriod::Immediate) {
|
||||
$patch['showAfter'] = $now->add($req->recurrence->interval())->format('c');
|
||||
}
|
||||
Patch::byId(Table::REQUEST, $req->id, $patch);
|
||||
|
||||
UI::journal();
|
||||
Reference in New Issue
Block a user