-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
304 lines (291 loc) · 13.3 KB
/
index.html
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="alpine.js" defer></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.6.9/flatpickr.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.6.9/themes/airbnb.min.css">
<script type="text/javascript" src="custom.js"></script>
<style>
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
input[type="number"] {
-moz-appearance: textfield;
}
@page {
font-family:Helvetica Neue, Helvetica, Arial, sans-serif;
}
</style>
</head>
<body>
<div x-data="displayProducts" x-init="setLocalStorageProducts" class="main-contain">
<div id="pos-billing">
<div class="mt-5">
<h1 class="text-center text-3xl">Pos Billing</h1>
</div>
<div class="flex">
<button type="button" @click="exportLocalStorage"
class="bg-blue-500 hover:bg-blue-700 text-white text-sm font-bold py-2 px-4 rounded ml-3">
Export
</button>
<button type="button" @click="sampleLocalStorage"
class="bg-blue-500 hover:bg-blue-700 text-white text-sm font-bold py-2 px-4 rounded ml-3">
Sample
</button>
<input class="ml-4 block w-full text-sm text-slate-500
file:mr-4 file:py-2 file:px-4
file:rounded file:border-0
file:text-sm file:font-bold
file:bg-blue-500 file:text-white
hover:file:bg-blue-800" type="file" @change="importLocalStorage">
</div>
<form class="m-10">
<div class="flex flex-wrap -mx-3 mb-6">
<div class="w-full md:w-1/3 px-3">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2" for="title">
Title
</label>
<input x-model="title" x-on:input="localStorage.setItem('title', title)"
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
type="text">
<span class="text-red-700" x-text="error.title"></span>
</div>
<div class="w-full md:w-1/3 px-3">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2" for="invoice">
Invoice
</label>
<input x-model="invoice" x-on:input="localStorage.setItem('invoice', invoice)"
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
type="text">
<span class="text-red-700" x-text="error.invoice"></span>
</div>
<div class="w-full md:w-1/3 px-3">
<div x-data
x-init="flatpickr($refs.datetimewidget, {wrap: true, enableTime: true, dateFormat: 'M j, Y h:i K'});"
x-ref="datetimewidget" class="flatpickr container mx-auto col-span-6 sm:col-span-6">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2"
for="date and time">
Date and Time
</label>
<div class="flex align-middle align-content-center">
<input x-model="dateTime" x-on:input="localStorage.setItem('dateTime', dateTime)" x-ref="datetime" type="text" data-input placeholder="Select.."
class="block bg-gray-200 w-full px-2 border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:bg-white focus:ring-opacity-50 rounded-l-md shadow-sm">
<a class="h-11 w-10 input-button cursor-pointer rounded-r-md bg-transparent border-gray-300 border-t border-b border-r"
title="clear" data-clear>
<svg xmlns="http://www.w3.org/2000/svg" class="h-7 w-7 mt-2 ml-1"
viewBox="0 0 20 20" fill="#c53030">
<path fill-rule="evenodd"
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
clip-rule="evenodd" />
</svg>
</a>
</div>
<span class="text-red-700" x-text="error.dateTime"></span>
</div>
</div>
</div>
<div class="flex flex-wrap -mx-3 mb-6">
<div class="w-full px-3 md:w-1/3">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2" for="address">
Address
</label>
<textarea x-model="address" x-on:input="localStorage.setItem('address', address)"
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 mb-3 leading-tight focus:outline-none focus:bg-white focus:border-gray-500">
</textarea>
<span class="text-red-700" x-text="error.address"></span>
</div>
</div>
<template x-for="(array,index) in quantityArray" :key="index">
<div class="flex flex-wrap -mx-3 mb-6">
<div class="w-full md:w-1/4 px-3">
<input x-model="quantityArray[index]" @change="changeValue($event,index)"
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
type="number" name="quantity">
<span class="text-red-700" x-text="quantityError[index]"></span>
</div>
<div class="w-full md:w-1/4 px-3">
<input x-model="productNameArray[index]" @change="changeValue($event,index)"
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
type="text" name="productName">
<span class="text-red-700" x-text="productNameError[index]"></span>
</div>
<div class="w-full md:w-1/4 px-3">
<input x-model="amountArray[index]" @change="changeValue($event,index)"
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
type="number" name="amount">
<span class="text-red-700" x-text="amountError[index]"></span>
</div>
<div class="w-full md:w-1/4 px-3 mt-1 text-center">
<button type="button" @click="removeProduct(index)"
class="bg-orange-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
-
</button>
</div>
</div>
</template>
<div class="flex flex-wrap -mx-3 mb-6">
<div class="w-full md:w-1/4 px-3">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2"
for="quantity">
Quantity
</label>
<input x-model="quantity"
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
type="number">
<span class="text-red-700" x-text="error.quantity"></span>
</div>
<div class="w-full md:w-1/4 px-3">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2"
for="product-name">
Product Name
</label>
<input x-model="productName"
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
type="text">
<span class="text-red-700" x-text="error.productName"></span>
</div>
<div class="w-full md:w-1/4 px-3">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2" for="amount">
Amount
</label>
<input x-model="amount"
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
type="number">
<span class="text-red-700" x-text="error.amount"></span>
</div>
<div class="w-full md:w-1/4 px-3 mt-6 text-center">
<button type="button" @click="addProduct()"
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
+
</button>
</div>
</div>
<div class="flex flex-wrap -mx-3 mb-6 grid-cols-2" style="width:100%">
<div class="px-5 mt-5" style="width: inherit">
<div class="py-4 rounded-md shadow-lg">
<div class="px-4 flex justify-between">
<span class="font-semibold text-sm">Subtotal</span>
<span x-text="subtotal" class="font-bold">$0.00</span>
</div>
<div class="px-4 flex justify-between">
<span class="font-semibold text-sm">Tax</span>
<span x-text="totalTax" class="font-bold"> $0.00</span>
</div>
<div class="border-t-2 mt-3 py-2 px-4 flex items-center justify-between">
<span class="font-semibold text-2xl">Total</span>
<span x-text="grandTotal" class="font-bold text-2xl">$0.00</span>
</div>
</div>
</div>
</div>
<div class="flex flex-wrap -mx-3 mb-6 grid-cols-12">
<div class="w-full px-3 md:w-1/3">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2"
for="grid-last-name">
Tax (%)
</label>
<input x-model="tax" x-on:input="localStorage.setItem('tax', tax)" @change="changeTax($event)"
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
type="text">
<span class="text-red-700" x-text="error.tax"></span>
</div>
<div class="w-full md:w-1/3 px-3">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2" for="cash">
Cash
</label>
<input x-model="cash" x-on:input="localStorage.setItem('cash', cash)" @change="changeCash"
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
type="text">
</div>
<div class="w-full md:w-1/3 px-3">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2" for="change">
Change
</label>
<input disabled x-model="change" name="change"
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
type="text">
</div>
</div>
<div class="flex flex-wrap -mx-3 mb-6">
<div class="w-full md:w-1/2 px-3">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2" for="footer">
Footer
</label>
<textarea x-model="footer" x-on:input="localStorage.setItem('footer', footer)"
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-gray-500"></textarea>
</div>
</div>
<div class="w-full px-3 mt-6 mb-6 text-center">
<button type="button" @click="generatePDF"
class=" bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Generate PDF
</button>
</div>
</form>
</div>
<div id="print-pos-billing" class="w-full" style="display: none;">
<h1 class="font-bold text-center text-5xl" x-text="title"></h1>
<p class="text-center mt-4 text-3xl pl-20 pr-20" x-text="address"></p>
<table class="table-auto w-full mt-4 text-3xl">
<tbody>
<tr class="w-full">
<td class="md:w-1/3 text-left">Invoice : <span x-text="invoice"></span></td>
<td class="md:w-1/3 text-right" x-text="dateTime"></td>
</tr>
</tbody>
</table>
<table class="table-auto w-full mt-4 text-3xl">
<tbody>
<template x-for="(array,index) in quantityArray" :key="index">
<tr class="w-full">
<td class="text-left" x-text="quantityArray[index]"></td>
<td class="w-4/5 text-left" x-text="productNameArray[index]"></td>
<td class="text-right" x-text="amountArray[index]"></td>
</tr>
</template>
</tbody>
</table>
<table class="table-auto w-full mt-4 border-t-2 border-black text-3xl">
<tbody>
<tr class="w-full">
<td class="w-1/3"></td>
<td class="w-1/3 text-left">Subtotal</td>
<td class="w-1/3 text-right" x-text="subtotal"></td>
</tr>
<tr class="w-full">
<td class="w-1/3"></td>
<td class="w-1/3 text-left">Tax +<span x-text="tax"></span>%</td>
<td class="w-1/3 text-right" x-text="totalTax"></td>
</tr>
<tr class="w-full">
<td class="w-1/3"></td>
<td class="w-1/3 text-left border-t-2 border-black">Grand Total</td>
<td class="w-1/3 grid-cols-4 text-right border-t-2 border-black" x-text="grandTotal"></td>
</tr>
</tbody>
</table>
<table class="table-auto w-full mt-8 text-3xl">
<tbody>
<tr class="w-full">
<td class="text-right">Cash</td>
<td class="w-1/3 text-right" x-text="cash"></td>
</tr>
<tr class="w-full">
<td class="text-right">Change</td>
<td class="w-1/3 text-right" x-text="change"></td>
</tr>
</tbody>
</table>
<p class="text-center mt-8 text-3xl" x-text="footer"></p>
</div>
</div>
</body>
</html>