-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathadmin_category.php
More file actions
105 lines (88 loc) · 3.7 KB
/
admin_category.php
File metadata and controls
105 lines (88 loc) · 3.7 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
//Guard
require_once '_guards.php';
Guard::adminOnly();
//require_once 'api/category_controller.php';
$categories = Category::all();
$category = null;
if (get('action') === 'update') {
$category = Category::find(get('id'));
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Point of Sale System :: Categories</title>
<link rel="stylesheet" type="text/css" href="./css/main.css">
<link rel="stylesheet" type="text/css" href="./css/admin.css">
<link rel="stylesheet" type="text/css" href="./css/util.css">
</head>
<body>
<?php require 'templates/admin_header.php' ?>
<div class="flex">
<?php require 'templates/admin_navbar.php' ?>
<main>
<div class="flex">
<div class="category-form">
<span class="subtitle">
<?php if (get('action') === 'update') : ?>
Update Category
<?php else : ?>
New Category
<?php endif; ?>
</span>
<hr/>
<div class="card">
<div class="card-content">
<form method="POST" action="api/category_controller.php">
<input type="hidden" name="action" value="<?= get('action') === 'update' ? 'update' : 'add' ?>" />
<input type="hidden" name="id" value="<?= $category?->id ?>"/>
<div class="form-control">
<label>Category Name</label>
<input
value="<?= $category?->name ?>"
type="text"
name="name"
placeholder="Enter category name here"
required="true"
/>
</div>
<div class="mt-16">
<button class="btn btn-primary w-full" type="submit">Submit</button>
</div>
</form>
</div>
</div>
</div>
<div class="category-table">
<span class="subtitle">Category List</span>
<hr/>
<?php displayFlashMessage('add_category') ?>
<?php displayFlashMessage('delete_category') ?>
<?php displayFlashMessage('update_category') ?>
<table id="categoryTable">
<thead>
<tr>
<th>Name</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach($categories as $category) : ?>
<tr>
<td><?= $category->name ?></td>
<td>
<a class="text-primary" href="?action=update&id=<?= $category->id ?>">Update</a>
<a class="text-red-500 ml-16" href="api/category_controller.php?action=delete&id=<?= $category->id ?>">Delete</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</main>
</div>
</body>
</html>