-
Notifications
You must be signed in to change notification settings - Fork 0
/
teamassign.php
170 lines (147 loc) · 7.12 KB
/
teamassign.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
<?php
// **********************************************************************************
// ** **
// ** teamassign.php (c) Wolfram Plettscher 01/2016 **
// ** **
// **********************************************************************************
// Display page only, if authenticated, otherwise jump to login page
include ('auth.php');
echo "<h1>Assign Teammember to Groups</h1>";
include "mysql/credentials.inc";
$mysqli = new mysqli($host,$username,$password,$database);
// Verbindung prüfen
if (mysqli_connect_errno()) {
printf ("Verbindung fehlgeschlagen: %s\n", mysqli_connect_error());
exit();
}
//-----------------------------------------------------------------------------------
// set global variables and comments before doing the real things ---
// set values to '', if not previously set ---
//-----------------------------------------------------------------------------------
$myacc = $_SESSION['account'];
$myuser = $_SESSION['usershort'];
$myuserid = $_SESSION['userid'];
$myprojid = $_SESSION['projid'];
if (!isset ($_POST['r_groupid'])) $_POST['r_groupid'] = '';
if (!isset ($_POST['r_role'])) $_POST['r_role'] = '';
$myteamid = $_POST['r_teamid'];
$mygroupid = $_POST['r_groupid'];
$myfirstname = $_POST['r_firstname'];
$mylastname = $_POST['r_lastname'];
$myrole = $_POST['r_role'];
$myremarks = $_POST['r_remarks'];
echo "<h3>$myfirstname $mylastname</h3>";
//-----------------------------------------------------------------------------------
// react on previously pushed button to update mySQL database ---
//-----------------------------------------------------------------------------------
if (isset($_POST['delete']) || isset($_POST['delgroup']))
{
// Delete Group Assignment
$query = $mysqli->query ("DELETE FROM team2group
WHERE proj_uuid = '$myprojid'
AND teammember_uuid = '$myteamid'
AND projgroup_uuid = '$mygroupid' ");
}
if (isset($_POST['setgroup']))
{
// Set Group Assignment
$query = $mysqli->query (" INSERT INTO team2group (acc_uuid, proj_uuid, teammember_uuid, projgroup_uuid)
VALUES ('$myacc', '$myprojid', '$myteamid', '$mygroupid')");
}
//-----------------------------------------------------------------------------------
// show/edit team to group assignements ---
//-----------------------------------------------------------------------------------
$query = $mysqli->query ("SELECT projgroup.projgroup_uuid, projgroup.name, team2group.teammember_uuid, team2group.role, team2group.remarks
FROM projgroup
LEFT JOIN team2group
ON projgroup.projgroup_uuid = team2group.projgroup_uuid
AND team2group.teammember_uuid = '$myteamid'
WHERE projgroup.proj_uuid = '$myprojid'
ORDER by projgroup.prio ASC ");
echo "<table class='sqltable' border='0' cellspacing='0' cellpadding='2' >\n";
echo "<tr>
<th> Assigned </th>
<th> Project Group </th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>\n";
while ($result = $query->fetch_object())
{
echo "<tr>";
if ($result->teammember_uuid == $myteamid)
{
echo "<td>" . "<input type='checkbox' name='selected' disabled='disabled' checked>" . "</td>";
$my_ischecked = 1;
}
else
{
echo "<td>" . "<input type='checkbox' name='selected' disabled='disabled'>" . "</td>";
$my_ischecked = 0;
}
echo "<td>" . "{$result->name}" . "</td>";
echo "<form action='index.php?section=teamassign' method='post'>"
. "<td>" . "<input type='hidden' id='uid1' name='r_groupid' value=" . "'{$result->projgroup_uuid}'" . "></td>"
. "<td>" . "<input type='hidden' id='uid2' name='r_teamid' value=" . "'{$myteamid}'" . "></td>"
. "<td>" . "<input type='hidden' id='uid3' name='r_firstname' value=" . "'{$myfirstname}'" . "></td>"
. "<td>" . "<input type='hidden' id='uid4' name='r_lastname' value=" . "'{$mylastname}'" . "></td>"
. "<td>" . "<input type='hidden' id='uid5' name='r_ischecked' value=" . "'{$my_ischecked}'" . "></td>"
. "<td>" . "<input type='hidden' id='uid6' name='r_role' value=" . "'{$result->role}'" . "></td>"
. "<td>" . "<input type='hidden' id='uid7' name='r_remarks' value=" . "'{$result->remarks}'" . "></td>";
if ($my_ischecked == 0)
// just set the box on pushing the "change" button
echo "<td>" . "<input class='css_btn_class' name='setgroup' type='submit' value='change' />" . "</td>";
else
if (($result->role == "") && ($result->remarks == ""))
// as role and remarks are empty, we can delete the group assignment without any confirmation
echo "<td>" . "<input class='css_btn_class' name='delgroup' type='submit' value='change' />" . "</td>";
else
// show a modal box first to confirm deletion
echo "<td>" . "<input class='css_btn_class' name='openmodal' type='submit' value='change' />" . "</td>";
// echo "<td>" . "<a href='#modal'><button class= 'css_btn_class' type='button'>remove</button></a>" . "</td>";
echo "</form>";
echo "</tr>";
}
echo "</table><br /><br />";
$mysqli->close();
//<!-- ---------------------------------------------------------------------------- -->
//<!-- site specific modal boxes -->
//<!-- ---------------------------------------------------------------------------- -->
if (isset($_POST['openmodal']))
{
// open modal box for confirmation of record delete
echo "<div id='modal'>";
echo "<div class='modal-content'>";
echo "<div class='header'>";
echo "<h2>Remove Group Assignment</h2>";
echo "</div>";
echo "<div class='copy'>";
echo "<p>You are going to remove a group assignment for <b>$myfirstname $mylastname</b>." .
" Below shown are remarks and role descriptions belonging to this group assignment.</p>";
echo "<p><b>Role: </b>$myrole</p>";
echo "<p><b>Remarks: </b>$myremarks</p>";
echo "<p>Do you really want to delete all this information?</p>";
echo "</div>";
echo "<div class='cf footer'>";
echo "<form action='index.php?section=teamassign' method='post'>"
. "<table><tr>"
. "<td>" . "<input class='css_btn_class' name='cancel' type='submit' value='cancel' />" . "</td>"
. "<td>" . "<input class='css_btn_class' name='delete' type='submit' value='delete' />" . "</td>"
. "<td>" . "<input type='hidden' id='uid1' name='r_groupid' value=" . "'{$mygroupid}'" . "></td>"
. "<td>" . "<input type='hidden' id='uid2' name='r_teamid' value=" . "'{$myteamid}'" . "></td>"
. "<td>" . "<input type='hidden' id='uid3' name='r_firstname' value=" . "'{$myfirstname}'" . "></td>"
. "<td>" . "<input type='hidden' id='uid4' name='r_lastname' value=" . "'{$mylastname}'" . "></td>"
. "<td>" . "<input type='hidden' id='uid5' name='r_ischecked' value=" . "'{$my_ischecked}'" . "></td>"
. "</tr></table>"
. "</form>";
echo "</div>";
echo "</div>";
echo "<div class='overlay'></div>";
echo "</div>";
}
?>