-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrack.php
More file actions
82 lines (81 loc) · 2.34 KB
/
track.php
File metadata and controls
82 lines (81 loc) · 2.34 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
<?php include 'db_connect.php' ?>
<div class="col-lg-12">
<div class="card card-outline card-primary">
<div class="card-body">
<div class="d-flex w-100 px-1 py-2 justify-content-center align-items-center">
<label for="">Enter Tracking Number</label>
<div class="input-group col-sm-5">
<input type="search" id="ref_no" class="form-control form-control-sm" placeholder="Type the tracking number here">
<div class="input-group-append">
<button type="button" id="track-btn" class="btn btn-sm btn-primary btn-gradient-primary">
<i class="fa fa-search"></i>
</button>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8 offset-md-2">
<div class="timeline" id="parcel_history">
</div>
</div>
</div>
</div>
<div id="clone_timeline-item" class="d-none">
<div class="iitem">
<i class="fas fa-box bg-blue"></i>
<div class="timeline-item">
<span class="time"><i class="fas fa-clock"></i> <span class="dtime">12:05</span></span>
<div class="timeline-body">
asdasd
</div>
</div>
</div>
</div>
<script>
function track_now(){
start_load()
var tracking_num = $('#ref_no').val()
if(tracking_num == ''){
$('#parcel_history').html('')
end_load()
}else{
$.ajax({
url:'ajax.php?action=get_parcel_heistory',
method:'POST',
data:{ref_no:tracking_num},
error:err=>{
console.log(err)
alert_toast("An error occured",'error')
end_load()
},
success:function(resp){
if(typeof resp === 'object' || Array.isArray(resp) || typeof JSON.parse(resp) === 'object'){
resp = JSON.parse(resp)
if(Object.keys(resp).length > 0){
$('#parcel_history').html('')
Object.keys(resp).map(function(k){
var tl = $('#clone_timeline-item .iitem').clone()
tl.find('.dtime').text(resp[k].date_created)
tl.find('.timeline-body').text(resp[k].status)
$('#parcel_history').append(tl)
})
}
}else if(resp == 2){
alert_toast('Unkown Tracking Number.',"error")
}
}
,complete:function(){
end_load()
}
})
}
}
$('#track-btn').click(function(){
track_now()
})
$('#ref_no').on('search',function(){
track_now()
})
</script>