/
bridgecover.php
146 lines (96 loc) · 4.25 KB
/
bridgecover.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
<?php include 'session.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php
include 'connection.php';
include 'functions.php';
include 'checkteamleader.php';
include 'header.php';
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
?>
</head>
<body>
<div class="bg">
<?php
include 'navback.php';
?>
<div class="container">
<h1>Bridge Cover</h1>
<div id="error">
<? echo $error; ?>
</div>
<form method="post" action="processbridgecover.php">
<?php
// go through all the slots
foreach ($slots as $name=>$text){
// $name would be 'eight' and $text would be '8:15 - 9:15' as definded in functions.php
?>
<div class="form-group row">
<label class="col-sm-3 col-form-label" for="<?php echo $name; ?>"><?php echo $text; ?></label>
<div class="col-sm-9">
<select class="form-control" id="<?php echo $name; ?>" name="<?php echo $name; ?>">
<!-- populate the drop down list with Partners allowed to do rotation spot checks -->
<?php
$query = "SELECT * FROM `partners` WHERE `canrotationcheck` = '1' ORDER BY `firstname`";
$result = mysqli_query($link, $query);
if (!$result) {
printf("Error: %s\n", mysqli_error($link));
exit();
}
// get the manager currently in this slot in the database
$bridgeQuery = "SELECT manager FROM `bridge` WHERE `slot` = '".$name."'";
$bridgeResult = mysqli_query($link, $bridgeQuery);
if (!$bridgeResult) {
printf("Error: %s\n", mysqli_error($link));
exit();
}
$bridgeRow = mysqli_fetch_array($bridgeResult);
$manager = $bridgeRow['manager'];
while($row = mysqli_fetch_array($result)){
$selected = '';
if($manager == $row['employee']){
$selected = 'selected="selected"';
}
echo '<option value="'.$row['employee'].'" '.$selected.'>'.$row['firstname'].' '.$row['surname'].'</option>';
}
?>
</select>
</div>
</div>
<?php
}
$disabled = ' disabled';
if($_SESSION['userData']['level'] < 10){
$disabled = '';
}
?>
<div class="row">
<div class="col-sm-9 offset-sm-3">
<button type="submit" class="btn btn-primary<?php echo $disabled ?>">Save Bridge Cover</button>
</div>
</div>
</form>
</div>
<?php
include 'footer.php';
?>
<script type="text/javascript">
$("form").submit(function(e) {
var error = "";
if ($("#team").val() == "tbd") {
error += "Please select a team.<br>"
}
if (error != "") {
$("#error").html('<div class="alert alert-danger" role="alert">' + error + '</div>');
return false;
} else {
return true;
}
})
</script>
</div>
</body>
</html>