-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_procedure.php
50 lines (45 loc) · 2.57 KB
/
test_procedure.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
<?php
require('./libs/database/connect-db.php');
require('./libs/utils/date_thai.php');
require('./libs/utils/date_utils.php');
$access_token = 'QPUPUnMzGhO//A8J2Qi1nmBXgEW89hciaaxNExeLVgxa8cjYtvnF9TZQF3TEjEOVA5HhS6dTRT2Tp4F0I3JhC0QWrQdmlBiL/6bhuazJI/juOxmvFx31NX7RWv9z19gbUZAdPIEuAURaHPy7TnDNkQdB04t89/1O/w1cDnyilFU=';
//C43891afa8280759911833f4c071a1190
$todaytime = strtotime('today');
$todaydate = date('Y-m-d', $todaytime);
$fetch_holiday = "SELECT * FROM tbl_holiday WHERE status = 'A' AND holiday_date = '$todaydate'";
$holiday_list = mysqli_query($conn, $fetch_holiday);
if(isWeekend($todaydate) || mysqli_num_rows($holiday_list) > 0){
return;
}
$fetch_group_list = "SELECT group_id FROM tbl_line_group WHERE status = 'A'";
$group_list = mysqli_query($conn, $fetch_group_list);
$fetch_existing_complaint = "SELECT * FROM tbl_complaint WHERE number_of_day>='100' AND complaint_status <> 'ปิด'";
$complaint_list = mysqli_query($conn, $fetch_existing_complaint);
if(mysqli_num_rows($complaint_list) > 0){
$messages = [
"type"=> "text",
"text"=> "Daily Alert :\n\nรายงานข้อร้องเรียนสถานะรอและกำลังดำเนินการมากกว่าเท่ากับ 10 วัน\n\nประจำวันที่ ".DateThai(date("Y-m-d"))." \n\nhttps://voc-bot.herokuapp.com/south.php?NUMBER=@10"
];
} else {
$messages = [
"type"=> "text",
"text"=> "Daily Alert :\n\nไม่มีข้อร้องเรียนสถานะกำลังดำเนินการหรือรอดำเนินการที่มากกว่าเท่ากับ 10 วัน ในวันที่ ".DateThai(date("Y-m-d"))
];
}
// while($group = $group_list->fetch_assoc()){
$url = 'https://api.line.me/v2/bot/message/push';
$data = [
'to' => 'C43891afa8280759911833f4c071a1190',
'messages' => [$messages]
];
$post = json_encode($data);
$headers = array('Content-Type: application/json', 'Authorization: Bearer ' . $access_token);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
curl_close($ch);
// }