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
/
load_data_page.php
209 lines (173 loc) · 5.01 KB
/
load_data_page.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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?php
//Include database Connection Script
include 'db_connection.php';
//Loop Through Employees table 1 by 1 and add there information to the page.
//sql to select * from employees. sort by ID ASC
$sql = "SELECT * FROM `".$db."`.`employee`";
//echo $sql;
$sql_results = $link->query($sql);
//Loop through employees
while($row = $sql_results->fetch_assoc())
{
//load variables from current entry.
$id = $row['ID'];
$senority = $row['senority'];
$first_name = $row['first_name'];
$last_name = $row['last_name'];
/* DEBUGGING INFO
echo $id;
echo $senority;
echo $first_name;
echo $last_name;
*/
//Retrieve the shift preference settings for the user.
$sql_shift_preference =
"
SELECT *
FROM `".$db."`.`employee_shift_preference`
WHERE `employee_shift_preference`.`ID_employee` = ". $id;
$results_shift_preference_results = $link->query($sql_shift_preference);
$row = $results_shift_preference_results->fetch_assoc();
$id_employee = $row['ID_employee'];
$available = $row['available'];
$shift = $row['shift'];
$non_rotational = $row['non_rotational'];
$posted_position = $row['posted_position'];
/* DEBUGGING INFO
echo $id_employee;
echo $available;
echo $shift;
echo $posted_position;
*/
//echo "the data entry page information for the current user.
echo
'
<div class="ui-grid-e">
<div class="ui-block-a">
<div class="ui-bar ui-bar-a " style="height:60px" >
<a class="ui-shadow ui-btn ui-corner-all ui-icon-delete ui-btn-icon-notext ui-btn-inline" data-rel="popup" data-position-to="window" data-transition="pop" href="#popupDeleteEmployee"
onClick="update_delete_employee_popup('.$id_employee.', \'' .$first_name.'\' , \''.$last_name.'\')"></a>
'. $first_name . ' '. $last_name .'
</div>
</div>
<div class="ui-block-b">
<div class="ui-bar ui-bar-a" style="height:60px">Shift</br>
<select name="flip-shift" id="flip-shift" data-role="flipswitch" data-mini="true" onchange="update_shift('. $id .',this.value)">';
//if statement will setup the input field to be correct based of database entry.
//write shift
//if else to add "selected"
//..repeat with available, posted position, and non rotational.
if ($shift == "day")
{
//PRINT YES CASE
echo
'<option value="day" selected="">Day</option>
<option value="night">Night</option>';
}
else
{
//PRINT NO CASE
echo
'<option value="day">Day</option>
<option value="night" selected="">Night</option>';
}
echo
'
</select>
</div>
</div>
<div class="ui-block-c">
<div class="ui-bar ui-bar-a" style="height:60px">Available</br>
<select name="flip-availability" id="flip-availability" data-role="flipswitch" data-mini="true" onchange="update_available('. $id .',this.value)">';
if ($available == "1")
{
//PRINT YES CASE
echo
'
<option value="0">No</option>
<option value="1" selected="">Yes</option>
';
}
else
{
//PRINT NO CASE
echo
'
<option value="0" selected="">No</option>
<option value="1">Yes</option>
';
}
echo
'
</select>
</div>
</div>
<div class="ui-block-d">
<div class="ui-bar ui-bar-a" style="height:60px">Posted Position</br>
<select name="select-postedPosition" id="select-postedPosition" data-mini="true" data-inline="true" onchange="update_posted_position('. $id .',this.value)">';
//loop through posted positions and add to select input. Add special case if for the selected value.
//sql Select all Posted Positions. For use later in the loop.
$sql_posted_positions_list =
'
SELECT DISTINCT `employee_shift_preference`.`posted_position`
FROM `'.$db.'`.`employee_shift_preference`
';
$sql_posted_positions_list_V2 =
"
SELECT posted_position, name
FROM `".$db."`.`posted_positions`
";
echo $sql_posted_positions_list_V2;
$result_posted_positions_list_results = $link->query($sql_posted_positions_list_V2);
while ($row_posted_position_list = $result_posted_positions_list_results->fetch_assoc())
{
//load current posted position value.
$posted_position_list = $row_posted_position_list['posted_position'];
$posted_position_name = $row_posted_position_list['name'];
//Echo the entry.
echo '<option value="' . $posted_position_list . '" ';
//if selected make this the value.
if ($posted_position == $posted_position_list)
{
echo 'selected=""';
}
echo '>' . $posted_position_name . '</option>';
}
//end Loop
echo '
</select>
</div>
</div>
<div class="ui-block-e">
<div class="ui-bar ui-bar-a" style="height:60px">Non-Rotational</br>
<select name="flip-nonrotational" id="flip-nonrotational" data-role="flipswitch" data-mini="true" onchange="update_non_rotational('. $id .',this.value)">';
if ($non_rotational == "1")
{
//PRINT YES CASE
echo
'
<option value="0">No</option>
<option value="1" selected="">Yes</option>
';
}
else
{
//PRINT NO CASE
echo
'
<option value="0" selected="">No</option>
<option value="1">Yes</option>
';
}
echo
'
</select>
</div>
</div>
</div><!-- Grid e -->
';
//next person...
}//end while loop
//Include database Termination Script
include 'db_disconnect.php';
?>