-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathindex.php
More file actions
133 lines (114 loc) · 5.52 KB
/
Copy pathindex.php
File metadata and controls
133 lines (114 loc) · 5.52 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
//Guard
require_once '_guards.php';
Guard::cashierOnly();
$products = Product::all();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Point of Sale System :: Home</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/cashier.css">
<link rel="stylesheet" type="text/css" href="./css/util.css">
<script src="./js/main.js"></script>
<script src="./js/cashier.js"></script>
<!-- Datatables Library -->
<link rel="stylesheet" type="text/css" href="./css/datatable.css">
<script src="./js/datatable.js"></script>
<!-- AlpineJS Library -->
<script defer src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>
</head>
<body>
<?php require 'templates/admin_header.php' ?>
<div class="flex">
<?php require 'templates/admin_navbar.php' ?>
<main x-data='products(<?= json_encode($products) ?>)'>
<div class="flex h-full">
<div class="products">
<div class="subtitle">Products</div>
<hr/>
<?php displayFlashMessage('transaction') ?>
<table id="productsTable">
<thead>
<tr>
<th>Name</th>
<th>Category</th>
<th>Stocks</th>
<th>Price</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($products as $product) : ?>
<tr>
<td><?= $product->name ?></td>
<td><?= $product->category->name ?></td>
<td><?= $product->quantity ?></td>
<td><?= $product->price ?></td>
<td>
<a @click="addToCart(<?= $product->id ?>)" href="#" class="text-green-300">Add Product</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="forms">
<div class="flex flex-col h-full">
<div>
<div class="subtitle">Customer Orders</div>
<hr/>
</div>
<div id="cardItemsContainer" class="flex-grow" style="overflow-y: auto;">
<template x-for="cart in carts">
<div class="cart-item">
<span class="left" x-text="cart.product.name"></span>
<div class="middle">
<div class="cart-item-buttons">
<button @click="subtractQuantity(cart)">-</button>
<span x-text="cart.quantity"></span>
<button @click="addQuantity(cart)">+</button>
</div>
</div>
<span class="right" x-text="(cart.quantity * cart.product.price) + 'PHP'"></span>
</div>
</template>
</div>
<form action="api/cashier_controller.php" method="POST" @submit="validate">
<input type="hidden" name="action" value="proccess_order">
<template x-for="(cart,i) in carts" :key="cart.product.id">
<div>
<input type="hidden" :name="`cart_item[${i}][id]`" :value="cart.product.id">
<input type="hidden" :name="`cart_item[${i}][quantity]`" :value="cart.quantity">
</div>
</template>
<div>
<span>Total Price: </span>
<span class="font-bold" x-text="totalPrice + 'php'"></span>
</div>
<div class="flex align-center gap-16">
<span>Payment: </span>
<div class="form-control flex-grow">
<input type="number" x-model="payment" step="0.25" name=""/>
</div>
<button type="button" @click="calculateChange" class="btn btn-outlined">Calculate Change</button>
</div>
<div>
<span>Change: </span>
<span class="font-bold" x-ref="change">--</span>
</div>
<button class="btn btn-primary mt-16 w-full">Proccess Order</button>
</form>
</div>
</div>
</div>
</main>
</div>
<script type="text/javascript">
var dataTable = new simpleDatatables.DataTable("#productsTable")
</script>
</body>
</html>