-
Notifications
You must be signed in to change notification settings - Fork 1
/
date_view.php
144 lines (129 loc) · 3.97 KB
/
date_view.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
<?php
include 'inc/header.php';
include 'lib/student.php';
//include 'lib/Database.php';
?>
<?php
$stu = new Student();
$db = new Database();
$cur_date = date('Y-m-d');
?>
<?php if (isset($_SESSION['user_id'])){ ?>
<div class="panel panel-default">
<div class="panel-heading text-center">
<p style="font-size: 20px;">
<strong>Date: </strong> <?php echo $cur_date; ?>
</p>
<div class="form-inline" style="margin-bottom: 10px;">
<select name="course_select" id="course_select" class="form-control md-2">
<option value='{"courseId":"0", "semester":"0"}' selected="selected">Select Course</option>
<?php
if($_SESSION['logintype']==0){
$getCourse = $stu->getCourse();
} else if($_SESSION['logintype']==1){
$getCourse = $db->select("SELECT T1.courseId, T2.courseTitle, T2.semester FROM (
SELECT * FROM tbl_courseallocteacher WHERE teacher_id=".$_SESSION['user_id']."
) T1 INNER JOIN tbl_course T2 ON T1.courseId = T2.courseId");
} else{
$getCourse = $db->select("SELECT T1.courseId, T2.courseTitle, T2.semester FROM (
SELECT * FROM tbl_courseallocstu WHERE stu_id=".$_SESSION['user_id']."
) T1 INNER JOIN tbl_course T2 ON T1.courseId = T2.courseId");
}
if($getCourse){
while($tmp = $getCourse->fetch_assoc()){
?>
<option value='{"courseId":"<?=$tmp['courseId']?>", "semester":"<?=$tmp['semester']?>"}'><?=$tmp['courseTitle']?></option>
<?php
}
}
?>
</select>
<select name="class_select" id="class_select" class="form-control md-2">
<option value="0" selected="selected">Select Class</option>
</select>
<?php
if($_SESSION['logintype']==2){
?>
<input type="hidden" name="student_select" id="student_select" value="<?=$_SESSION['user_id']?>" placeholder="Enter Student Id" class="form-control md-2">
<?php
} else{
?>
<input type="text" name="student_select" id="student_select" value="" placeholder="Enter Student Id" class="form-control md-2">
<?php
}
?>
<input type="text" name="date_picker" id="date_picker" placeholder="Select Date" class="form-control md-2">
<input type="button" name="filter" id="filter" value="filter" class="btn btn-primary md-2">
</div>
</div>
<div class="panel-body">
<div id="order_table">
<div class='alert alert-warning text-center'>Attendance Not Taken.</div>
</div>
</div>
</div>
<?php }else{ ?>
<div class="alert alert-danger" style="font-size: 20px">
Access Denied
</div>
<?php } ?>
<?php include 'inc/footer.php'; ?>
<script>
$(document).ready(function(){
$.datepicker.setDefaults({
dateFormat: 'yy-mm-dd'
});
$(function(){
$("#date_picker").datepicker();
})
$('#course_select').change(function(){
var value = $.parseJSON($(this).val());
//console.log(value['semester']);
if(value['semester']!='0' && value['courseId']!='0'){
$.ajax({
url: 'attn_req.php',
method: 'post',
data: (
{
semester : value['semester'],
courseId : value['courseId']
}),
dataType: 'text',
success:function(data){
$('#class_select').html(data);
}
});
}
});
$('#filter').click(function(){
var val = $.parseJSON($('#course_select').val());
var courseId = val['courseId'];
var classId = $('#class_select').val();
var stu_id = $('#student_select').val();
var selectDate = $('#date_picker').val();
if(courseId!="0" && classId!="0"){
if(stu_id!='' || selectDate!=''){
$.ajax({
url: 'attn_req.php',
method: 'post',
data: (
{
courseId : courseId,
classId : classId,
stu_id : stu_id,
curDate : selectDate
}),
dataType: 'text',
success:function(data){
$('#order_table').html(data);
}
});
} else{
alert('Please Enter Student ID or Select Date');
}
} else{
alert('Please Select Course and Class');
}
});
})
</script>