This repository has been archived by the owner on Jun 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
edit.php
76 lines (65 loc) · 2.81 KB
/
edit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php declare(strict_types=1);
use SwagLebk\Entity\WeeklyReportEntity;
require_once __DIR__.'/autoload.php';
$message = '';
$reportId = (int) $_GET['id'];
$report = $repository->readById($reportId);
if (isset($_POST['submit'])) {
foreach ($_POST as $key => $value) {
if (property_exists(WeeklyReportEntity::class, $key)) {
if (in_array($key, ['weeknumber', 'id'])) {
$value = (int) $value;
}
$report->{'set' . ucwords($key)}($value);
}
}
$result = $repository->update($report);
if ($result) {
$message = '<div class="alert alert-success" role="alert">
Weekly Report updated successfully!
</div>';
} else {
$message = '<div class="alert alert-primary" role="alert">
The Weekly Report cannot be updated!
</div>';
}
}
?>
<?php require_once __DIR__ . '/templates/head.html' ?>
<div class="container">
<h1><a href="index.php">Weekly Reports</a></h1>
<?= $message ?>
<div class="row">
<div class="col-sm">
<form method="post" action="edit.php?id=<?= $report->getId() ?>">
<div class="form-group row">
<label for="weeknumber" class="col-sm-2 col-form-label">Weeknumber</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="weeknumber" id="weeknumber"
value="<?= $report->getWeeknumber() ?>"/>
</div>
</div>
<div class="form-group row">
<label for="positive" class="col-sm-2 col-form-label">Positive</label>
<div class="col-sm-10">
<textarea class="form-control" id="positive" name="positive"><?= $report->getPositive() ?></textarea>
</div>
</div>
<div class="form-group row">
<label for="negative" class="col-sm-2 col-form-label">Negative</label>
<div class="col-sm-10">
<textarea class="form-control" id="negative" name="negative"><?= $report->getNegative() ?></textarea>
</div>
</div>
<div class="form-group row">
<label for="learned" class="col-sm-2 col-form-label">Learned</label>
<div class="col-sm-10">
<textarea class="form-control" id="learned" name="learned"><?= $report->getLearned() ?></textarea>
</div>
</div>
<button type="submit" name="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
</div>
<?php require_once __DIR__ . '/templates/footer.html' ?>