-
Notifications
You must be signed in to change notification settings - Fork 0
/
getdailyshift.php
165 lines (148 loc) · 7.87 KB
/
getdailyshift.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
<?php include('header.php'); ?>
<?php include('head.php'); ?>
<?php include('nav_bar.php'); ?>
<!-- begin::main-content -->
<main class="main-content">
<div class="container">
<!-- begin::page-header -->
<div class="page-header">
<!-- <h4>Responsive Tables</h4> -->
<!-- <nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<li class="breadcrumb-item active" aria-current="page">Home</li>
</li>
<li class="breadcrumb-item active" aria-current="page">Daily</li>
</li>
<li class="breadcrumb-item active" aria-current="page">Shift</li>
</ol>
</nav> -->
</div>
<!-- end::page-header -->
<!-- <div class="row">
<div class="col-md-12">
<label for="department" class="text-left"><h5>Select Department:</h5></label>
<select name="" id="">
<option value="">Accounting</option>
</select>
</div>
</div> -->
<table>
<tbody>
<!-- for all shift -->
<tr>
<td>
<!-- <label for="department" class="text-left"><h5>Select Department:</h5></label> -->
<form action="form.php" method="post">
<select name="department" id="">
<option value="disabled" selected disabled>--Select Shift--</option>
<?php $i=0;
foreach($all_shift as $shift): $i++; ?>
<option value="<?= $shift['id'] ?>"><?= $shift['name'] ?></option>
<?php endforeach ?>
</select>
<input type="submit" value="Search">
</form>
</td>
</tr>
<!-- shift ends here -->
<tr>
<td>
<!-- <label for="department" class="text-left"><h5>Select Department:</h5></label> -->
<form action="form.php" method="post">
<select name="department" id="">
<option value="disabled" selected disabled>--Select Department--</option>
<?php $i=0;
foreach($eachdept as $dept): $i++; ?>
<option value="<?= $dept['dept'] ?>"><?= $dept['dept'] ?></option>
<?php endforeach ?>
</select>
<input type="submit" value="Search">
</form>
</td>
</tr>
</tbody>
</table>
<!-- selection ends -->
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<!-- <h6 class="card-title">Shift A</h6> -->
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>S/N</th>
<th>Employee ID</th>
<th>Employee Name</th>
<th>Department</th>
<th>Status</th>
<th>Shift</th>
</tr>
</thead>
<tbody>
<?php
$dept_name = $_GET['dept_name']; //declare http method
$active = "SELECT * FROM tuser where dept='$dept_name' ORDER BY group_id"; //http get method from the form
$user_result = mysqli_query($dbc, $active) or die(mysql_error()); //sql
$i=0; //counter
foreach($user_result as $result): $i++; //declare loop
?>
<?php
$shift_name = $result["group_id"]; //get shift id above.
?>
<!-- test for shift -->
<?php
$shift_name = $_GET['shift_name']; //declare http method
$active = "SELECT * FROM tuser where dept='$dept_name' ORDER BY group_id"; //http get method from the form
$user_result = mysqli_query($dbc, $active) or die(mysql_error()); //sql
$i=0; //counter
foreach($user_result as $result): $i++; //declare loop
?>
<!-- test ends -->
<tr>
<td><?php echo $i ?></td>
<td><?php echo $result["id"] ?></td>
<td><?php echo $result["name"] ?></td>
<td><?php echo $result["dept"] ?></td>
<td><?php echo $result["PassiveType"] ?></td>
<td>
<?php
//here is the logic, run query inside table to be discoverable
//getting shift name
$sql = "SELECT * FROM tgroup WHERE id='$shift_name'";
$result = mysqli_query($dbc, $sql) or die('Bad Query: $sql');
while($row = $result->fetch_assoc()){
$id = $row["name"];
}
echo $id;
//ends here
?>
</td>
</tr>
<?php endforeach ?>
<!-- ends loop -->
</tbody>
<tfoot>
<tr>
<th>S/N</th>
<th>Employee ID</th>
<th>Employee Name</th>
<th>Department</th>
<th>Status</th>
<th>Shift</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!-- end::main-content -->
<?php include('scripts.php'); ?>
<!-- footer -->
<?php include('footer.php') ?>