-
Notifications
You must be signed in to change notification settings - Fork 0
/
engineer_update.php
130 lines (79 loc) · 4.53 KB
/
engineer_update.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
<?php
include 'connection.php';
$complaint_id = isset($_POST['complaint_id']) ? $_POST['complaint_id'] : '1';
$complete = isset($_POST['complete']) ? $_POST['complete'] : '';
$Date = isset($_POST['Date']) ? $_POST['Date'] : '';
$sql="UPDATE it SET engine_status = '$complete' ,engine_complete_time='$Date' WHERE complaint_id = '$complaint_id'";
$query_one = mysqli_query($connect, $sql);
$sql_biomedical="UPDATE biomedical SET engine_status = '$complete' ,engine_complete_time='$Date' WHERE complaint_id = '$complaint_id'";
$query_biomedical = mysqli_query($connect, $sql_biomedical);
$sql_facility="UPDATE facility SET engine_status = '$complete' ,engine_complete_time='$Date' WHERE complaint_id = '$complaint_id'";
$query_facility = mysqli_query($connect, $sql_facility);
$sql_maintenance="UPDATE maintainance SET engine_status = '$complete' ,engine_complete_time='$Date' WHERE complaint_id = '$complaint_id'";
$query_maintenance = mysqli_query($connect, $sql_maintenance);
// Calculate the time difference for T2
$sql_get_dates = "SELECT engine_complete_time, admin_assign_time FROM it WHERE complaint_id = $complaint_id";
$result_dates = mysqli_query($connect, $sql_get_dates);
if ($result_dates && mysqli_num_rows($result_dates) > 0) {
$row_dates = mysqli_fetch_assoc($result_dates);
$admin_assign_time = $row_dates['admin_assign_time'];
$engine_complete_time = $row_dates['engine_complete_time'];
$datetime1 = new DateTime($admin_assign_time);
$datetime2 = new DateTime($engine_complete_time);
$interval = $datetime1->diff($datetime2);
$time_difference = $interval->format('%H:%i:%s');
// Update the "T2" column in the database
$sql_update_t2 = "UPDATE it SET T2 = '$time_difference' WHERE complaint_id = $complaint_id";
$query_update_t2 = mysqli_query($connect, $sql_update_t2);
} else {
echo "No rows found for complaint_id = $complaint_id";
}
$sql_get_dates = "SELECT engine_complete_time, admin_assign_time FROM biomedical WHERE complaint_id = $complaint_id";
$result_dates = mysqli_query($connect, $sql_get_dates);
if ($result_dates && mysqli_num_rows($result_dates) > 0) {
$row_dates = mysqli_fetch_assoc($result_dates);
$admin_assign_time = $row_dates['admin_assign_time'];
$engine_complete_time = $row_dates['engine_complete_time'];
$datetime1 = new DateTime($admin_assign_time);
$datetime2 = new DateTime($engine_complete_time);
$interval = $datetime1->diff($datetime2);
$time_difference = $interval->format('%H:%i:%s');
// Update the "T2" column in the database
$sql_update_t2 = "UPDATE biomedical SET T2 = '$time_difference' WHERE complaint_id = $complaint_id";
$query_update_t2 = mysqli_query($connect, $sql_update_t2);
} else {
echo "No rows found for complaint_id = $complaint_id";
}
$sql_get_dates = "SELECT engine_complete_time, admin_assign_time FROM maintainance WHERE complaint_id = $complaint_id";
$result_dates = mysqli_query($connect, $sql_get_dates);
if ($result_dates && mysqli_num_rows($result_dates) > 0) {
$row_dates = mysqli_fetch_assoc($result_dates);
$admin_assign_time = $row_dates['admin_assign_time'];
$engine_complete_time = $row_dates['engine_complete_time'];
$datetime1 = new DateTime($admin_assign_time);
$datetime2 = new DateTime($engine_complete_time);
$interval = $datetime1->diff($datetime2);
$time_difference = $interval->format('%H:%i:%s');
// Update the "T2" column in the database
$sql_update_t2 = "UPDATE maintainance SET T2 = '$time_difference' WHERE complaint_id = $complaint_id";
$query_update_t2 = mysqli_query($connect, $sql_update_t2);
} else {
echo "No rows found for complaint_id = $complaint_id";
}
$sql_get_dates = "SELECT engine_complete_time, admin_assign_time FROM facility WHERE complaint_id = $complaint_id";
$result_dates = mysqli_query($connect, $sql_get_dates);
if ($result_dates && mysqli_num_rows($result_dates) > 0) {
$row_dates = mysqli_fetch_assoc($result_dates);
$admin_assign_time = $row_dates['admin_assign_time'];
$engine_complete_time = $row_dates['engine_complete_time'];
$datetime1 = new DateTime($admin_assign_time);
$datetime2 = new DateTime($engine_complete_time);
$interval = $datetime1->diff($datetime2);
$time_difference = $interval->format('%H:%i:%s');
// Update the "T2" column in the database
$sql_update_t2 = "UPDATE facility SET T2 = '$time_difference' WHERE complaint_id = $complaint_id";
$query_update_t2 = mysqli_query($connect, $sql_update_t2);
} else {
echo "No rows found for complaint_id = ";
}
?>