-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproject.php
More file actions
134 lines (105 loc) · 4.3 KB
/
project.php
File metadata and controls
134 lines (105 loc) · 4.3 KB
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
<html>
<head>
<title>COURSE</title>
<link rel="stylesheet" type="text/css" href="project.css">
</head>
<body>
<?php
include ("header.php");
if (isset($_GET['pid'])) $pid=$_GET['pid'];
include("database.php");
$qry = "SELECT * FROM projects where pid='$pid'";
$res = mysqli_query ($db, $qry);
$row = $res->fetch_assoc();
$uid = $_SESSION['userid'];
$qry = "SELECT * FROM enrolledprojects WHERE pid='$pid' and userid='$uid'";
$res = mysqli_query ($db, $qry);
$encount = mysqli_num_rows($res);
$qry = "SELECT * FROM enrolledprojects WHERE pid='$pid'";
$res = mysqli_query ($db, $qry);
$memcount = mysqli_num_rows($res);
$ec = $res->fetch_assoc();
//user Joined the project or not
$qry = "SELECT * FROM enrolledprojects WHERE pid='$pid' and userid='$uid'";
$res = mysqli_query ($db, $qry);
$project_joined = mysqli_num_rows($res);
if (isset ($_GET['per']) and $row['percomp']<100)
{
$inc=$row['percomp']+1;
$qry = "UPDATE projects SET percomp='$inc' WHERE pid='$pid'";
$res = mysqli_query ($db, $qry);
?> <script type="text/javascript">window.location.replace("project.php?pid=<?php echo $pid; ?>");</script> <?php
}
if (isset($_GET['join']))
{
$qry = "INSERT INTO `enrolledprojects`(`userid`, `pid`) VALUES ('$uid', '$pid')";
$res = mysqli_query ($db, $qry);
?> <script type="text/javascript">window.location.replace("project.php?pid=<?php echo $pid; ?>");</script> <?php
}
if (isset($_GET['send']) and $project_joined!=0)
{
$msg = $_GET['msg'];
$time = date("Y-m-d H:i:s");
$qry = "INSERT INTO `projectchat2`(`pid`, `userid`, `time`, `message`) VALUES ('$pid', '$uid', '$time', '$msg')";
mysqli_query ($db, $qry);
?> <script type="text/javascript">window.location.replace("project.php?pid=<?php echo $pid; ?>");</script> <?php
}
?>
<div class="container">
<div class="row">
<div class="col-sm-7">
<div class="chead"><p><?php echo $row['phead']; ?></p></div>
<div class="cdetails">
<p><?php echo $row['pdesc']; ?></p>
</div>
<h3>Chat with your Colleagues</h3>
<div class="projectchat">
<div class="chat"></div>
</div>
<div class="msgbox">
<input type="text" class="msg" name="msg">
<button class="send">Send</button>
<script>
$('.send').click(()=>{
var app = $('.msg').val();
window.location.replace("project.php?pid=<?php echo $pid; ?>"+"&msg="+app+"&send=true");
});
</script>
</div>
</div>
<div class="col-sm-1"></div>
<div class="col-sm-4">
<div class="card">
<div class="card-head">Course Status</div>
<div class="blueround"><div class="whiteround"><div class="percentage"><?php echo $row['percomp']; ?>%</div></div></div>
<div class="members">Members : <?php echo $memcount."/".$row['members']; ?></div>
<?php
if ($encount!=0)
{
if ($row['percomp']==100)
{ ?>
<div class="certificate-btn">Project Completed</div>
<?php }
else
{ ?>
<div class="certificate-btn"><a href="project.php?pid=<?php echo $ec['pid']; ?>&per=inc"><button>Today task</button></a></div>
<?php }
}
else
{ ?>
<div class="certificate-btn"><a href="project.php?pid=<?php echo $pid; ?>&join=true"><button <?php if ($memcount==$row['members'] or $row['percomp']==100) echo "disabled style='background-color: red;'" ?>>Join</button></a></div>
<?php } ?>
</div>
</div>
</div>
<script type="text/javascript">
var down = 1;
$('.chat').load("loadchat.php?pid=<?php echo $pid; ?>");
var chat_refresh = setInterval(() =>
{
if (down==1) {down=0; $('.projectchat').scrollTop($('.projectchat')[0].scrollHeight);}
$('.chat').load("loadchat.php?pid=<?php echo $pid; ?>");
},1000);
</script>
</body>
</html>