-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_code.php
125 lines (84 loc) · 3.51 KB
/
test_code.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
<?php
if($purchase_package->approve_status == 'approved'){
if($purchase_package->buy_type == 'instantly'){
$total_days = $purchase_package->package->duration_days;
$now_time = date('Y-m-d');
$now_time = date('Y-m-d', strtotime($now_time. ' + 1 days'));
$datediff = strtotime($now_time) - strtotime($purchase_package->start_date);
$used_days = round($datediff / (60 * 60 * 24));
$remain_days = $total_days - $used_days;
if($remain_days < 0){
$remain_days = 0;
}
//
if($purchase_package->id == $last_record->id && $last_record->buy_type == 'instantly'){
if($now_time >= $purchase_package->start_date && $now_time <= $purchase_package->end_date){
$status = 'Active';
$color = 'text-success';
$active_package = $purchase_package->package_id;
}else{
$status = 'Inactive';
$color = 'text-danger';
}
}else{
// start i think this part not require
$now_time = date('Y-m-d');
$now_time = date('Y-m-d', strtotime($now_time. ' + 1 days'));
if($now_time >= $purchase_package->start_date && $now_time <= $purchase_package->end_date && $last_record->buy_type == 'buy_now'){
$status = 'Active';
$color = 'text-success';
// end i think this part not require
}else{
$status = 'Inactive';
$color = 'text-danger';
}
}
}
if($purchase_package->buy_type == 'buy_now'){
$now_time = date('Y-m-d');
$now_time = date('Y-m-d', strtotime($now_time. ' + 1 days'));
if($now_time >= $purchase_package->start_date && $now_time <= $purchase_package->end_date && $last_record->buy_type == 'buy_now'){
$total_days = $purchase_package->package->duration_days;
$datediff = strtotime($now_time) - strtotime($purchase_package->start_date);
$used_days = round($datediff / (60 * 60 * 24));
$remain_days = $total_days - $used_days;
if($remain_days < 0){
$remain_days = 0;
}
$active_package = $purchase_package->package_id;
$status = 'Active';
$color = 'text-success';
}else{
$remain_days = $purchase_package->package->duration_days;
$status = 'Inactive';
$color = 'text-danger';
}
}
}else{
if($purchase_package->payment_type == 'trial'){
$total_days = $purchase_package->package->trial_days;
$now_time = date('Y-m-d');
$now_time = date('Y-m-d', strtotime($now_time. ' + 1 days'));
$datediff = strtotime($now_time) - strtotime($purchase_package->start_date);
$used_days = round($datediff / (60 * 60 * 24));
$remain_days = $total_days - $used_days;
if($remain_days < 0){
$remain_days = 0;
}
if($purchase_packages->count() == 1){
$active_package = $purchase_package->package_id;
$status = 'Active/Trial';
$color = 'text-success';
}else{
$status = 'Inactive/Trial';
$color = 'text-danger';
}
}else{
$remain_days = $purchase_package->package->duration_days;
if($remain_days < 0){
$remain_days = 0;
}
$status = 'Inactive';
$color = 'text-danger';
}
}