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_V2.php
200 lines (150 loc) · 5.71 KB
/
load_data_page_V2.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
<?php
/*******************************************************************************
* Copyright 2016 Alan A. Zanotto
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
//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` ORDER BY senority";
//echo $sql;
$sql_results = $link->query($sql);
//Loop through employees
//List Begin
echo
'
<ul data-role="listview" data-inset="true" data-filter="true" data-split-icon="gear" data-split-theme="a">';
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'];
$posted_position = $row['posted_position'];
/* DEBUGGING INFO
echo $id_employee;
echo $available;
echo $shift;
echo $posted_position;
*/
/*<div>
<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></div>
*/
echo
'
<li><a>
<h2>'.$first_name.' '.$last_name.'</h2>';
echo '<div id="label_block"><p id="label_shift">Shift';
echo ' Available';
echo ' Posted Position</p></div>';
//echo '<a href="#popupInfo" data-rel="popup" data-transition="pop" class="my-tooltip-btn ui-btn ui-alt-icon ui-nodisc-icon ui-btn-inline ui-icon-info ui-btn-icon-notext" title="Learn more">Learn more</a>';
//************************SHIFT**************************
echo '<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 == 0)
{
//PRINT YES CASE
echo
'<option value="0" selected="">Day</option>
<option value="1">Night</option>';
}
else
{
//PRINT NO CASE
echo
'<option value="0">Day</option>
<option value="1" selected="">Night</option>';
}
echo '</select>';
//************************SHIFT END**********************
//************************AVAILABLE**********************
echo '<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>';
//************************AVAILABLE END******************
//************************POSTED POSITION****************
echo '<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_V2 = "SELECT * 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_ID = $row_posted_position_list['ID'];
$posted_position_name = $row_posted_position_list['name'];
//Echo the entry.
echo '<option value="' . $posted_position_ID . '" ';
//if selected make this the value.
if ($posted_position == $posted_position_ID)
{
echo 'selected=""';
}
echo '>' . $posted_position_name . '</option>';
}
//end Loop
echo '</select>';
//************************POSTED POSITION END************
echo '
</p>
</a>
<a data-rel="popup" data-position-to="window" data-transition="pop" href="#popupEditEmployee" onClick="update_edit_employee_popup('.$id_employee.', \'' .$first_name.'\' , \''.$last_name.'\')">Edit User</a>
</li>
';
}//end while loop
echo '</ul>';
//Include database Termination Script
include 'db_disconnect.php';
?>