-
Notifications
You must be signed in to change notification settings - Fork 0
/
groupchat.php
229 lines (216 loc) · 7.1 KB
/
groupchat.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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<?php
include("header.php");
?>
<section id="contentSection">
<div class="row">
<link href="bootstrap-chat-example/assets/css/bootstrap.css" rel="stylesheet" />
<div >
<div class="row">
<h3 class="text-center" >Group Chat </h3>
<center>
<form action="" class="contact_form" method="get" name="frmsubject" onsubmit="return validateform()">
<table id="example" class="table table-striped table-bordered" cellspacing="0" >
<tbody>
<tr>
<th scope="col">
Course :<font color=red size=4><strong>*</strong></font>
<select name="coursetitle" id="coursetitle" class="form-control">
<option value="">Select Course</option>
<?php
$sqlcourse = "SELECT * FROM course WHERE status=Active";
$qsqlcourse = mysqli_query($con,$sqlcourse);
while($rscourse = mysqli_fetch_array($qsqlcourse))
{
if($rscourse[course_id] == $_GET[coursetitle])
{
echo "<option value=$rscourse[course_id] selected>$rscourse[course]</option>";
}
else
{
echo "<option value=$rscourse[course_id]>$rscourse[course]</option>";
}
}
?>
</select>
</th>
<th scope="col">
Semester:<font color=red size=4><strong>*</strong></font>
<select name="semester" id="semester" class="form-control">
<option value="">Select semester</option>
<?php
$arr = array("First Semester","Second Semester","Third Semester","Fourth Semester","Fifth Semester","Sixth Semester");
foreach($arr as $val)
{
if($val == $_GET[semester])
{
echo "<option value=$val selected>$val</option>";
}
else
{
echo "<option value=$val>$val</option>";
}
}
?>
</select></th>
<th scope="col"><br><input name="submit" type="submit" value="Submit"></th>
</tr>
</tbody>
</table>
</form>
</center>
<br>
<?php
if(isset($_GET[submit]))
{
?>
<div class="col-md-8">
<div class="panel panel-info">
<div class="panel-heading">
CHAT MESSAGES
</div>
<div class="panel-body" style="height: 450px;overflow-y: scroll;" id="divchatmsg">
<?php
include("groupchatmsg.php");
?>
</div>
<div class="panel-footer">
<div class="input-group">
<input type="text" class="form-control" placeholder="Enter Message" name="grptextmsg" id="grptextmsg" onKeyUp="submitgroupchat(coursetitle.value,semester.value,grptextmsg.value,event)" />
<span class="input-group-btn">
<button class="btn btn-info" type="button" onClick="submitgroupchatbtn(coursetitle.value,semester.value)">SMILE</button>
</span>
</div>
</div>
</div>
</div>
<div class="col-md-4" >
<div class="panel panel-primary">
<div class="panel-heading">
STUDENTS
</div>
<div class="panel-body" style="height: 500px;overflow: scroll;">
<ul class="media-list">
<?php
$sqlstudentchat ="SELECT * FROM student WHERE status=Active AND course_id=$_GET[coursetitle] AND semester=$_GET[semester]";
$qsqlstudentchat = mysqli_query($con,$sqlstudentchat);
while($rsstudentchat = mysqli_fetch_array($qsqlstudentchat))
{
?>
<li class="media">
<div class="media-body">
<div class="media">
<a class="pull-left" href="#">
<img src="studentimages/<?php echo $rsstudentchat[student_img]; ?>" style="width: 50px;height:50px;" class="img-circle" />
</a>
<div class="media-body" >
<h5><?php echo $rsstudentchat[student_name]; ?> </h5>
<?php
$sqlchat_message = "SELECT date,time from chat_message WHERE student_id=$rsstudentchat[student_id] ";
$qsqlchat_message = mysqli_query($con,$sqlchat_message);
$rschat_message = mysqli_fetch_array($qsqlchat_message);
if(mysqli_num_rows($qsqlchat_message) >= 1)
{
echo <small class="text-muted">Last Active on ;
echo $rschat_message[date] . " " . $rschat_message[time];
echo </small>;
}
?>
</div>
</div>
</div>
</li>
<?php
}
?>
</ul>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>
</section>
<?php
include("footer.php")
?>
<script type="application/javascript">
function deleteconfirm()
{
if(confirm("Are you sure want to delete this record?") == true)
{
return true;
}
else
{
return false;
}
}
</script>
<?php
include("datatables.php");
?>
<script type="application/javascript">
// Chat insert message code semester
function submitgroupchat(coursetitle,semester,textmsg,e)
{
if(textmsg != "")
{
var code = (e.keyCode ? e.keyCode : e.which);
if(code == 13) //Enter keycode
{
//alert(coursetitle + semester + textmsg);
document.getElementById("grptextmsg").value="";
$.post("jsgroupchatmsg.php", { coursetitle: coursetitle, semester: semester, textmsg: textmsg});
}
}
}
function submitgroupchatbtn(coursetitle,semester,smiley)
{
var smiley = "<?php
$arrsmile = array("smile1.gif","smile2.gif","smile3.gif","smile4.gif","smile5.gif");
//$k = array_rand($arrsmile);
echo "<img src=smile/".$arrsmile[rand(0,4)]." style=/max-height:250px;max-width:230px;/ >";
?>";
$.post("jsgroupchatmsg.php", { coursetitle: coursetitle, semester: semester, textmsg: smiley});
}
//##################Chat message ends here
var chatdata1 = "";
function loadgroupchat()
{
var coursetitle = "<?php echo $_GET[coursetitle]; ?>";
var semester = "<?php echo $_GET[semester]; ?>";
//alert(localStorage[visiblechat1]);
//Load message to chat box 1
$.post("groupchatmsg.php", { coursetitle: coursetitle,semester: semester},
function(data)
{
//alert(data);
if(data == chatdata1)
{
}
else
{
chatdata1 = data;
$("#divchatmsg").html(data);
$(#divchatmsg).animate({ scrollTop: $(#divchatmsg).prop(scrollHeight)}, 1000);
//document.getElementById("sound").innerHTML ="<audio autoplay ><source src=onlinechat/mp3/surprise.mp3 type=audio/mp3 >";
}
});
}
$(document).ready(function(){
loadgroupchat();
/*
loadchatuserlist(); // Users list
load_chat123box(); // 1st, 2nd, 3rd chat panel
auto_load(); //Call auto_load() function when DOM is Ready
chat1toggle();
chat2toggle();
chat3toggle();
*/
});
//Refresh auto_load() function after 10000 milliseconds
setInterval(loadgroupchat,1000);
</script>