Repository navigation
Expand file tree
/
Copy pathadmin_groups.php
More file actions
219 lines (178 loc) · 10.3 KB
/
Copy pathadmin_groups.php
File metadata and controls
219 lines (178 loc) · 10.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
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
<?php
include ('authorisation.php');
//$main_page='admin_groups.php';
$item_id=0;
$type="";
//include ('sql_connect.php');
if (isset($_GET['type']) && $_GET['type']=='del' && isset($_GET['item_id']))
{
//echo '!!!!!!!del!!!!!!';
$query="delete from user_groups where id='".f_ri($_GET['item_id'])."'";
//echo $query;
$res=mysql_query($query);
//exit();
header('Location: '.$curpage);
}
include ('master_page_short.php');
?>
<style>
tr.title {font-size:13px; font-family:Arial; background-color:#E6E6FF; }
tr.main {font-size:11px; font-family:Arial; text-align:left; font-weight:normal;}
</style>
<script language="JavaScript">
var main_page='admin_groups.php'; //for redirect & links
function del_confirm(id,title,tasks_cnt,users_cnt)
{
if (tasks_cnt>0 || users_cnt>0) {alert('Задачу "'+title+'" удалить невозможно. \nСначала перенесите к другой задаче привязанных пользователей и задачи ?');}
else {
if (confirm('Удалить строку: "'+title+'"?'))
{window.location.href=main_page+'?item_id='+id+'&type=del';}
}
}
</script>
<?php
if (isset($_GET['item_id'])) {$item_id=$_GET['item_id'];}
//if (isset($_GET['type'])) {$user_id=$_GET['type'];} // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//добавление группы
echo '';
if (isset($_POST['item_name']))
{
$err=false;
if ($_POST['item_name']!="" && $_POST['item_comment']!="")
{
if ($_POST['all_user_select']=='on') {$_POST['all_user_select']=1;}
else {$_POST['all_user_select']=0;}
if ($_POST['blocked']=='on') {$_POST['blocked']=1;}
else {$_POST['blocked']=0;}
//обновление группы
$onEditRemain_text='';
if ($onEditRemain==false) {$onEditRemain_text=' автопереход к списку через 2 сек. или вручную <a href="'.$curpage.'">по ссылке</a>';}
if (isset($_GET['type']) & $_GET['type']=='edit' & isset($_GET['item_id']) & $item_id!='') {
//echo 'Правка группы.';
$query="update user_groups set name='".$_POST['item_name']."', all_user_select='".$_POST['all_user_select']."',
blocked='".$_POST['blocked']."', comment='".$_POST['item_comment']."',
color_mark='".$_POST['color_mark']."' where id='".$_GET["item_id"]."'";
//echo $query;//.$_POST['hidden_new'];
if ($res=mysql_query($query)) {echo '<div class=success>Группа обновлена успешно.'.$onEditRemain_text.'</div><p> ';}
else {echo '<div class="warning">Группа не обновлена. Возможно такая уже есть.<p> </div>';$err=true;}
}
//новое обновление
if (isset($_GET['type']) & $_GET['type']=='add') {
echo 'Добавление группы.';
$query="insert into user_groups(name,all_user_select,blocked,comment,color_mark)
values('".f_ri($_POST["item_name"])."','".f_ri($_POST["all_user_select"])."','".f_ri($_POST["blocked"])."',
'".f_ri($_POST["item_comment"])."','".f_ri($_POST["color_mark"])."')";
if ($res=mysql_query($query)) {echo '<div class=success>Группа добавлена успешно.'.$onEditRemain_text.'</div><p> ';}
else {echo '<div class="warning">Группа не добавлена.Возможно такая уже есть<p> </div>';$err=true;}
//echo $query;
}
}
else {echo '<div class="warning">Часть обязательных данных не заполнена .<br> </div>';$err=true;}
if (!$err && !$onEditRemain) {echo '<script language="Javascript">setTimeout("window.location.href=\"'.$curpage.'\"",2000);</script>';}
}
if ($item_id!=0 & isset($_GET['type']) & $_GET['type']=='edit')
{
if (isset($item_id) && $item_id!="")
{//echo '<h4>Правка группы</h4>';
$query="select * from user_groups where id='".$item_id."'";
$res=mysql_query($query);
$res_edit=mysql_fetch_array($res);
}
else {echo '<h4 class="warning">не выбрана группа для правки</h4>';}
}
//добавление группы
if (isset($_GET['type']) & $_GET['type']=='add' || $_GET['type']=='edit')
{
?>
<p><a href="<?php echo $curpage;?>" title="Просмотр групп портала"> Просмотр групп портала </a><p>
<h4> <?php if($_GET['type']=='add') {echo 'Добавление';} else {echo 'Правка';} ?> группы портала </h4>
<form name="new_form" method="post" action="">
<div class="forms_under_border" style="width:99%;">
<table border=0 cellspacing=10 cellpadding=10>
<tr><td>Наименование * </td><td><input type=text size=50 name=item_comment value='<?php if (isset($res_edit)) {echo f_ro($res_edit['comment']);}
else if (isset($_POST['item_comment'])) {echo $_POST['item_comment'];} ?>'> </td></tr>
<tr><td>Наименование анг* </td><td><input type=text size=50 name="item_name" value='<?php if (isset($res_edit)) {echo f_ro($res_edit['name']);}else if (isset($_POST['item_name'])) {echo $_POST['item_name'];} ?>'> </td></tr>
<tr><td>Цвет <br> <small>(в формате "#xxxxxx", например "#CCCC00")</small> </td><td><input type=text size=50 name="color_mark" value='<?php if (isset($res_edit)) {echo f_ro($res_edit['color_mark']);} else {echo '#CCCC00';} ?>'> </td></tr>
<tr><td>Отражение всех <br>пользователей </td><td><input type=checkbox name=all_user_select <?php if (isset($res_edit) && $res_edit['all_user_select']==1) {echo 'checked';} ?> > </td></tr>
<tr><td>Блокированная </td><td><input type=checkbox name=blocked <?php if (isset($res_edit) && $res_edit['blocked']==1) {echo 'checked';} ?> title="запрещает доступ"> </td></tr>
<tr><td colspan=2>
<input type=submit value="<?php if (isset($res_edit)) {echo 'Изменить';} else {echo 'Добавить';} ?>">
<input type=reset value=Очистить> </td></tr>
</table>
</div>
</form>
<?php
}
else
{
echo '<h4> Группы пользователей.</h4>
<div class=text>после создания группы пользователей, к ней можно привязать <a href="s_tasks.php">задачи портала</a> и <a href="admin_users.php">список пользователей </a>.<br> Распределение прав через задачу <a href="user_access.php"> права пользователей </a>.
</div>';
echo '<p><a href="'.$curpage.'?type=add"> Добавить группу </a><p>';
if (isset($_GET['sort'])) {$sort_id=$_GET['sort'];
if ($sort_id<1 || $sort_id>5) {$sort_id=1;}
}
else {$sort_id=1;}
$query="select user_groups.name,count(task_in_group.user_group_id) as task_cnt,
user_groups.all_user_select,user_groups.blocked,user_groups.comment,user_groups.id,user_groups.color_mark from user_groups
left join task_in_group on task_in_group.user_group_id=user_groups.id
group by user_groups.id
ORDER by ".$sort_id." ";
$res=mysql_query($query);
//echo $query;
echo '<form name=task_list>
<table name=tab1 bnew=1 cellpadding="1" cellspacing="1">
<tr align="center" class="title" height="30">';
echo '<td width="50"><img src="images/todelete.png" title="Удалить"> <img src="images/toupdate.png" title="Правка"></td>';
echo '<td width="20">#</td>';
echo '<td width="20">цвет</td>';
echo '<td width="60"><a href="?sort=1">наименование</a></td>';
echo '<td width="100"><a href="?sort=2">задач</a></td>';
echo '<td width="100"><a href="#">пользователей</a></td>';
echo '<td width="200"><a href="?sort=3" title="отражение всех пользователей в списке выбора задачи">все пользователи в списке</a></td>';
echo '<td width="100"><a href="?sort=4" title="отказ в доступе">блокированная</a></td>';
echo '<td width="200"><a href="?sort=5">примечание</a></td>';
$i=1;
while ($tmpval=mysql_fetch_array($res)) //вывод показателей
{
$query="select count(*)as users_cnt from user_in_group where group_id='".$tmpval['id']."'";
$res_=mysql_query($query);$tmpval_=mysql_fetch_array($res_);
echo '<tr align="left" class="main" bgcolor="#DFEFFF">';
//echo '<tr align="left" class="main">';
echo '<td align="center" height=40> <a href=javascript:del_confirm("'.f_ro($tmpval['id']).'","'.str_replace(' ','_',f_ro($tmpval['name'])).'","'.f_ro($tmpval['task_cnt']).'","'.f_ro($tmpval_['users_cnt']).'") title="Удалить"><img src="images/todelete.png" alt="Удалить" border="0"></a>
<a href="'.$curpage.'?item_id='.$tmpval['id'].'&type=edit" title="Правка">
<img src="images/toupdate.png" alt="Правка" border="0"></a></td>';
echo '<td>'.$i.'</td>';
echo '<td><font size="+3" color="'.$tmpval['color_mark'].'">*</font></td>';
echo '<td>'.$tmpval['comment'].'</td>';
echo '<td style="text-align:center;">'.$tmpval['task_cnt'].'</td>';
echo '<td style="text-align:center;">';
echo $tmpval_['users_cnt'];
echo '</td>';
echo '<td style="text-align:center;">';
if ($tmpval['all_user_select']==1) {echo '+';}
echo'</td>';
echo '<td style="text-align:center;">';
if ($tmpval['blocked']==1) {echo '+';}
echo'</td>';
echo '<td>'.$tmpval['name'].'</td>';
echo '</tr>';
$i++;
}
echo '</table></form>';
$query="select * from user_groups";
$res_=mysql_query($query);
/*echo '<div class="text">обозначения групп:';
while ($tmpval_=mysql_fetch_array($res_)) { echo color_mark($tmpval_['id']).'-'.$tmpval_['comment'].', ' ;}
echo '</div><p>';*/
//постраничный вывод списка обновлений (по 10 обновлений)
/*if (isset($_GET['filtr']) & $_GET['filtr']!=0) {$query='select id from develop_news where news_type="'.$_GET['filtr'].'"';}
else {$query='select id from develop_news';}
//echo $query;*/
//$res=mysql_query($query);
//--------------------------------------------------------
echo '<div align="left"> Всего групп: '.mysql_num_rows($res).'</div>';
}
show_footer();
?>
<?php include('footer.php'); ?>