This repository has been archived by the owner on Aug 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_displayed_schedule_station.php
167 lines (127 loc) · 5.01 KB
/
update_displayed_schedule_station.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
//Retrieve POST Values
$new_schedule_value = $_POST["new_schedule_value"];
$new_station_value = $_POST["new_station_value"];
//Variables
$temp_category;
//Include database Connection Script
include 'db_connection.php';
//echo $new_shift_value;
//retrieve the schedule.
$sql_schedule =
"
SELECT *
FROM `".$db."`.`schedule_saved` ss, `".$db."`.`schedule_position` sp
WHERE ss.ID_schedule_position = sp.ID
AND ss.`ID_schedule` = ".$new_schedule_value."
AND sp.station = ".$new_station_value."
ORDER BY ss.ID_schedule_position ASC, ss.`ID_employee` ASC
";
$result_schedule = $link->query($sql_schedule);
//echo $sql_schedule;
/*
//basic
SELECT *
FROM `bctreeschedule`.`schedule_saved`
WHERE `ID_schedule` = 1
ORDER BY `schedule_saved`.`ID_schedule_position` ASC,
`schedule_saved`.`ID_employee` ASC
//basic + position info
SELECT *
FROM `bctreeschedule`.`schedule_saved` ss, `bctreeschedule`.`schedule_position` sp
WHERE ss.ID_schedule_position = sp.ID
AND `ID_schedule` = "1"
ORDER BY ss.ID_schedule_position ASC, ss.`ID_employee` ASC
//basic + position info + station filter
SELECT *
FROM `bctreeschedule`.`schedule_saved` ss, `bctreeschedule`.`schedule_position` sp
WHERE ss.ID_schedule_position = sp.ID
AND ss.`ID_schedule` = 1
AND sp.station = 8
ORDER BY ss.ID_schedule_position ASC, ss.`ID_employee` ASC
*/
//temp table column to expand when 9 people in a row.
$temp_table_column = 0;
//Loop through the people in the schedule
$temp_facility = "";
$temp_facility_name = "";
while ($row = $result_schedule->fetch_assoc())
{
//Setup Variables.
$employee_ID = $row['ID_employee'];
$schedule_position_ID = $row['ID_schedule_position'];
$shift = $row['shift'];
$current_facility = $row['facility'];
//setup or change of facility header.
if ($temp_facility == "" || $temp_facility != $current_facility)
{
//if facility hasn't been set. set and start.
if ($temp_facility == "")
{
$temp_facility = $current_facility;
$sql_facility_name = "SELECT * FROM `".$db."`.`schedule_facility` WHERE ID = ".$temp_facility;
$result_facility_name = $link->query($sql_facility_name);
$object_facility_name = $result_facility_name->fetch_assoc();
$temp_facility_name = $object_facility_name['name'];
echo "<div class=\"header_facility\">".$temp_facility_name."</div>";
}
//if facility is changing then close last one and start the new one.
elseif ($temp_facility != $current_facility)
{
$temp_facility = $current_facility;
$sql_facility_name = "SELECT * FROM `".$db."`.`schedule_facility` WHERE ID = ".$temp_facility;
$result_facility_name = $link->query($sql_facility_name);
$object_facility_name = $result_facility_name->fetch_assoc();
$temp_facility_name = $object_facility_name['name'];
echo "</div>";//close off the div of the category.
echo "<div class=\"header_facility\">".$temp_facility_name."</div>";
$temp_category = "new_facility";
}
}//if ($temp_facility == "" || $temp_facility != $current_facility)
//Retrieve extra information (employee information/ position information)
$sql_employee_information = "
SELECT senority, first_name, last_name
FROM `".$db."`.`employee`
WHERE ID = ".$employee_ID;
$result_employee_information = $link->query($sql_employee_information);
$object_employee_information = $result_employee_information->fetch_assoc();
$employee_senority = $object_employee_information['senority'];
$employee_first_name = $object_employee_information['first_name'];
$employee_last_name = $object_employee_information['last_name'];
//echo $employee_first_name . " ". $employee_last_name;
$sql_position_information = "
SELECT name
FROM `".$db."`.`schedule_position`
WHERE ID = ".$schedule_position_ID;
//echo $sql_position_information;
$result_position_information = $link->query($sql_position_information);
$object_position_information = $result_position_information->fetch_assoc();
$schedule_position_name = $object_position_information['name'];
//echo $schedule_position_name;
if ( !isset($temp_category) || $temp_category == "new_facility")
{
$temp_category = $schedule_position_name;
echo '<div class="schedule_list_block" id="schedule_list_block">
<h4>'.$temp_category.'</h4>';//start a fresh category
//echo "(".$employee_senority.") ". $employee_first_name . " ". $employee_last_name .'</br>';//OLIVER
echo "☐". $employee_first_name . " ". $employee_last_name .'</br>';//WINFIELD
}
elseif ($temp_category != $schedule_position_name)
{
echo '</div>';//close up last category
$temp_category = $schedule_position_name;//set new temp category
echo '<div class="schedule_list_block">
<h4>'.$temp_category.'</h4>';//start a fresh category
//echo "(".$employee_senority.") ". $employee_first_name . " ". $employee_last_name .'</br>';//OLIVER
echo "☐". $employee_first_name . " ". $employee_last_name .'</br>';//WINFIELD
//add a person to the list.
}
else
{
//echo "(".$employee_senority.") ". $employee_first_name . " ". $employee_last_name .'</br>';//OLIVER
echo "☐". $employee_first_name . " ". $employee_last_name .'</br>';//WINFIELD
}
}//while loop
//Include database Termination Script
include 'db_disconnect.php';
?>