-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComplete.php
More file actions
46 lines (43 loc) · 1.62 KB
/
Complete.php
File metadata and controls
46 lines (43 loc) · 1.62 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
<?php
/**
* Created by PhpStorm.
* User: Sariel Aki ~desu~
* Date: 14.05.2018
* Time: 22:03
*
*/
class Complete
{
public static function client(Base $f3)
{
if ($f3->get('SESSION.order_id') != null) {
$result = $f3->get('DB')->exec("UPDATE orders SET client_complete_check = 'true' WHERE id = ? AND status = 'taken'",
$f3->get('SESSION.order_id')
);
if($result != 0) {
echo json_encode(array("result" => "success", "what" => "Вы подтвердили выполнение заказа"));
} else {
http_response_code(405);
echo json_encode(array('result' => 'error', 'what' => 'Заказ уже подтвержден'));
}
}
}
public static function driver(Base $f3)
{
if ($f3->get('SESSION.order_id') != null) {
$result = $f3->get('DB')->exec("UPDATE orders SET driver_complete_check = 'true' WHERE id = ? AND status = 'taken'",
$f3->get('SESSION.order_id')
);
if($result != 0) {
echo json_encode(array("result" => "success", "what" => "Вы подтвердили выполнение заказа"));
} else {
http_response_code(405);
echo json_encode(array('result' => 'error', 'what' => 'Заказ уже подтвержден'));
}
}
}
static function afterroute(Base $f3)
{
$f3->get('DB')->exec("UPDATE orders SET status = 'complete' WHERE client_complete_check = 'true' AND driver_complete_check = 'true'");
}
}