This repository has been archived by the owner on Feb 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
admin.php
229 lines (205 loc) · 8.54 KB
/
admin.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
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
<?php
include 'header.php';
$_SESSION['page'] = 'admin';
// if (!isset($_SESSION['username']) || $_SESSION['username'] != 'admin') {
// header("Location: index.php");
// exit();
// }
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Admin</title>
</head>
<div class="banner">
<div class="container">
<h1>ADMIN</h1>
<p>You've got to love what you do to really make things happen!</p>
<a href="#content" class="button button-primary">View Pick Up Request</a>
</div>
</div>
</header>
<style>
.header-area {
background-image: url("assets/useradmin.jpg");
}
</style>
<script type="text/javascript">
function updateStatus(data) {
var resi = data.getAttribute("data-resi");
var statusbefore = data.getAttribute("data-status-before");
var statusafter = $(data).parent().parent().find("#status").val();
$.confirm({
title: 'Konfirmasi Pergantian Status',
type: 'green',
typeAnimated: true,
theme: 'modern',
columnClass: "col-md-5",
buttons: {
confirm: {
text: 'OK',
btnClass: 'btn-green',
action: function() {
$.ajax({
url: "phps/updatestatus.php",
method: "POST",
data: {
resi: resi,
status: statusafter,
},
success: function(res) {
window.location.reload();
}
});
}
},
cancel: {
text: 'Cancel',
btnClass: 'btn-red',
action: function() {}
}
},
content: "Apakah Anda yakin akan mengganti status dengan nomor resi <b>" + resi + "</b> dari <b>" + statusbefore + "</b> menjadi <b>" + statusafter + "</b>?"
});
}
function passStatus(data) {
//credits handrian
$(data).parent().parent().find("#confirm").removeAttr('disabled');
if ($(data).val() == "") {
$(data).parent().parent().find("#confirm").attr('disabled', 'disabled');
}
}
$(document).ready(function() {
show();
});
function Search(table) {
$("#filterstatus").on("change", function() {
table.columns(2).search(this.value).draw();
});
$("#filterservice").on("change", function() {
table.columns(3).search(this.value).draw();
});
}
var ajaxcall;
function show() {
$("#historyTableBody").html("<span>Harap tunggu...</span>");
if (ajaxcall != null) {
ajaxcall.abort();
}
$.ajax({
url: "phps/refreshdelivery.php",
type: "get",
dataType: "json",
success: function(result) {
var data = result;
var str = "";
var num = 1;
//loop dari data
for (var i = 0; i < data.length; i++) {
var d = data[i];
str += "<tr style='font-weight: 100;'>";
str += "<td>" + num + "</td>";
str += "<td>" + d.resi + "</td>";
if (d.delivery_status == 'DELIVERED') {
str += "<td style='font-weight: bold; color: #fc6203;'>" + d.delivery_status + "</td>";
} else {
str += "<td>" + d.delivery_status + "</td>";
}
str += "<td>" + d.delivery_type + "</td>";
str += "<td>" + d.delivery_date + "</td>";
str += "<td>" + d.sender_name + ", " + d.sender_origin_city + "</td>";
str += "<td>" + d.receiver_name + ", " + d.receiver_origin_city + "</td>";
str += "<td><a type='button' style='font-weight: bold; font-size: 12pt;' class='btn btn-warning' href='viewdata.php?resi=" + d.resi + "'>View</a></td>";
str += "<td><select class='form-control' id='status' onchange='passStatus(this)' style='height: 40px; font-size: 12pt;'><option value=''>Pilih status</option>";
if (d.delivery_status != 'PICKREQ') {
str += "<option value='PICKREQ'>PICKREQ</option>";
}
if (d.delivery_status != 'PICK') {
str += "<option value='PICK'>PICK</option>";
}
if (d.delivery_status != 'ON TRANSIT') {
str += "<option value='ON TRANSIT'>ON TRANSIT</option>";
}
if (d.delivery_status != 'ON DELIVERY') {
str += "<option value='ON DELIVERY'>ON DELIVERY</option>";
}
if (d.delivery_status != 'DELIVERED') {
str += "<option value='DELIVERED'>DELIVERED</option>";
}
str += "</select></td >";
str += "<td><button id='confirm' style='font-size: 12pt;' class='btn btn-primary' onclick='updateStatus(this)' data-status-before='" + d.delivery_status + "' data-resi='" + d.resi + "' disabled>CONFIRM</button></td>";
str += "</tr>";
num = num + 1;
}
$("#historyTableBody").html(str);
var table = $('#historyTable').DataTable({
"oLanguage": {
"sEmptyTable": "Belum ada Pick Up Request!"
}
});
Search(table);
},
error: function(result) {
//Error handling
alert("ERROR!");
console.log();
}
});
}
</script>
<main>
<section id="content" class="content">
<div class="container" id="aboutus">
<div class="row justify-content-center">
<h3 class="title">
PICK UP REQUEST
</h3>
</div>
<br>
<center>
<div>
<select class="form-control" id="filterstatus" style="width: 60%; height:40px; font-size: 12pt;">
<option value="">Lihat berdasarkan status</option>
<option value="PICKREQ">PICKREQ</option>
<option value="PICK">PICK</option>
<option value="ON TRANSIT">ON TRANSIT</option>
<option value="ON DELIVERY">ON DELIVERY</option>
<option value="DELIVERED">DELIVERED</option>
</select>
</div>
</center><br>
<center>
<div>
<select class="form-control" id="filterservice" style="width: 60%; height:40px; font-size: 12pt;">
<option value="">Lihat berdasarkan service</option>
<option value="ANDRE EKONOMIS">ANDRE EKONOMIS 💲</option>
<option value="ANDRE REGULAR">ANDRE REGULAR 🚚</option>
<option value="ANDRE HALILINTAR">ANDRE HALILINTAR ⚡</option>
</select>
</div>
</center>
<div class="row" style="margin-top: 20px;overflow-x: auto;">
<div class="col-12">
<table class="table table-hovered table-striped" id="historyTable" style="color: #412c27; text-align: center;">
<thead>
<tr style="font-weight: bold;">
<td>#</td>
<td>Nomor Resi</td>
<td>Status</td>
<td>Service</td>
<td>Dikirim tanggal</td>
<td>Dikirim oleh</td>
<td>Dikirim ke</td>
<td>Lihat data</td>
<td style="width: 15%;">Change Status</td>
<td>Confirmation</td>
</tr>
</thead>
<tbody id="historyTableBody">
</tbody>
</table>
</div>
</div>
</div>
</section>
<?php include 'footer.php' ?>