-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstate_area.php
118 lines (111 loc) · 5.04 KB
/
state_area.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
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
<?php
include "header.php";
?>
<div class='p-6' x-data='exportTable'>
<div class="panel mt-2">
<div class='flex items-center justify-between mb-3'>
<h1 class='text-primary text-2xl font-semibold'>State Area</h1>
<div class="flex flex-wrap items-center">
<button type="button" class="p-2 btn btn-primary btn-sm m-1" onclick="location.href='add-statearea.php'">
<i class="ri-add-line"></i>Add State Area
</button>
<button type="button" class="p-2 btn btn-primary btn-sm m-1" @click="printTable">
<i class="ri-printer-line mr-1"></i> PRINT
</button>
<button type="button" class="p-2 btn btn-primary btn-sm m-1" @click="exportTable('csv')">
<i class="ri-file-line mr-1"></i> CSV
</button>
</div>
</div>
<table id="myTable" class="table-hover whitespace-nowrap"></table>
</div>
</div>
<!-- script -->
<script>
function getActions() {
return `<ul class="flex items-center gap-4">
<li>
<a href="javascript:;" class='text-xl' x-tooltip="View">
<i class="ri-eye-line text-primary"></i>
</a>
</li>
<li>
<a href="javascript:;" class='text-xl' x-tooltip="Edit">
<i class="ri-pencil-line text text-success"></i>
</a>
</li>
<li>
<a href="javascript:;" class='text-xl' x-tooltip="Delete">
<i class="ri-delete-bin-line text-danger"></i>
</a>
</li>
</ul>`
}
document.addEventListener('alpine:init', () => {
Alpine.data('exportTable', () => ({
datatable: null,
init() {
console.log('Initalizing datatable')
this.datatable = new simpleDatatables.DataTable('#myTable', {
data: {
headings: ['Sr.No.', 'Name', 'Action'],
data: [
[1, 'Test Area', getActions()],
[2, 'Gujarat', getActions()],
[3, 'Bhayander', getActions()],
[4, 'VIRAR NSP VASAI', getActions()],
[5, 'Thane', getActions()],
],
},
perPage: 10,
perPageSelect: [10, 20, 30, 50, 100],
columns: [{
select: 0,
sort: 'asc',
},
],
firstLast: true,
firstText: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="w-4.5 h-4.5 rtl:rotate-180"> <path d="M13 19L7 12L13 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/> <path opacity="0.5" d="M16.9998 19L10.9998 12L16.9998 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/> </svg>',
lastText: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="w-4.5 h-4.5 rtl:rotate-180"> <path d="M11 19L17 12L11 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/> <path opacity="0.5" d="M6.99976 19L12.9998 12L6.99976 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/> </svg>',
prevText: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="w-4.5 h-4.5 rtl:rotate-180"> <path d="M15 5L9 12L15 19" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/> </svg>',
nextText: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="w-4.5 h-4.5 rtl:rotate-180"> <path d="M9 5L15 12L9 19" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/> </svg>',
labels: {
perPage: '{select}',
},
layout: {
top: '{search}',
bottom: '{info}{select}{pager}',
},
});
},
exportTable(eType) {
var data = {
type: eType,
filename: 'table',
download: true,
};
if (data.type === 'csv') {
data.lineDelimiter = '\n';
data.columnDelimiter = ';';
}
this.datatable.export(data);
},
printTable() {
this.datatable.print();
},
formatDate(date) {
if (date) {
const dt = new Date(date);
const month = dt.getMonth() + 1 < 10 ? '0' + (dt.getMonth() + 1) : dt.getMonth() +
1;
const day = dt.getDate() < 10 ? '0' + dt.getDate() : dt.getDate();
return day + '/' + month + '/' + dt.getFullYear();
}
return '';
},
}));
})
</script>
<?php
include "footer.php";
?>