forked from jmueller17/Aixada
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactivate_all_roles.php
181 lines (148 loc) · 5.46 KB
/
activate_all_roles.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
<?php include "php/inc/header.inc.php" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?=$language;?>" lang="<?=$language;?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $Text['global_title'] . " - " . $Text['head_ti_active_roles']; ?></title>
<link rel="stylesheet" type="text/css" media="screen" href="css/aixada_main.css" />
<link rel="stylesheet" type="text/css" media="screen" href="js/fgmenu/fg.menu.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui-themes/<?=$default_theme;?>/jqueryui.css"/>
<script type="text/javascript" src="js/jquery/jquery.js"></script>
<script type="text/javascript" src="js/jqueryui/jqueryui.js"></script>
<?php echo aixada_js_src(); ?>
<script type="text/javascript">
$(function(){
$.ajaxSetup({ cache: false });
//init tabs
$("#tabs").tabs();
//init xml2html template stuff
$('#inactiveRoles').xml2html('init');
$('#activeRoles').xml2html('init');
$("#userSelect").xml2html("init", {
loadOnInit : true,
offSet : 1,
url : 'php/ctrl/ActivateRoles.php',
params : 'oper=listUsers'
}).change(function(){
//get the id of the role
var id = $("option:selected", this).val();
if (id < 0) return true;
$('#inactiveRoles').xml2html("reload",{
url : 'php/ctrl/ActivateRoles.php',
tpl : '<option value="{role}">{role}</option>',
params : 'oper=getDeactivatedRoles&user_id='+id
});
$('#activeRoles').xml2html("reload",{
url : 'php/ctrl/ActivateRoles.php',
tpl : '<option value="{role}">{role}</option>',
params : 'oper=getActivatedRoles&user_id='+id
});
});
$('#activate').button({
icons: { primary: "ui-icon-arrowthick-1-e"}
}).click(function(){
$("#inactiveRoles option:selected").each(function (){
$("#activeRoles").append($(this).detach());
});
});
$('#deactivate').button({
icons: {secondary: "ui-icon-arrowthick-1-w"}
}).click(function(){
$("#activeRoles option:selected").each(function (){
$("#inactiveRoles").append($(this).detach());
});
});
$("input:submit").button();
$("input:reset").button().click(function(){
$("#userSelect").children(':lt(2)').attr('selected',true);
$('#inactiveRoles').empty();
$('#activeRoles').empty();
});
$('#activeRolesForm').submit(function(){
$("input:submit").button( "option", "disabled", true );
$('#deactivate').button( "option", "disabled", true );
$('#activate').button( "option", "disabled", true );
var role_id = [];
var i=0;
$('#activeRoles option').each(function(){
if ($(this).val() == "{role}") return true;
role_id[i++] = $(this).val();
});
var dataSerial = "user_id="+$("#userSelect option:selected").val() +"&role_ids="+role_id;
$.ajax({
type: "GET",
url: "php/ctrl/ActivateRoles.php?oper=activateRoles",
data: dataSerial,
success: function(msg){
$.showMsg({
msg:"<?php echo $Text['msg_edit_success']; ?>",
type: 'success'});
//$("input:submit").button( "option", "disabled", false);
},
error : function(XMLHttpRequest, textStatus, errorThrown){
$.showMsg({
msg:XMLHttpRequest.responseText,
type: 'error'});
},
complete : function(){
$("input:submit").button( "option", "disabled", false );
$('#deactivate').button( "option", "disabled", false );
$('#activate').button( "option", "disabled", false );
}
}); //end ajax
return false;
});//end submit
/*$('form').submit(function() {
// submit the form
//$(this).ajaxSubmit();
// return false to prevent normal browser submit
return false;
});*/
}); //close document ready
</script>
</head>
<body>
<div id="wrap">
<div id="headwrap">
<?php include "php/inc/menu.inc.php" ?>
</div>
<!-- end of headwrap -->
<div id="stagewrap" class="ui-widget <?= negative_balances_stagewrap_class() ?>">
<div id="titlewrap">
<h1><?php echo $Text['ti_mng_activate_roles']; ?>
</div>
<form id="activeRolesForm">
<div class="wrapSelect">
<select id="userSelect" class="longSelect">
<option value="-1" selected="selected"><?php echo $Text['sel_user']; ?></option>
<option value="{id}">{id} {name}</option>
</select>
</div>
<div id="threeColWrap">
<div id="leftColumn">
<h4><?php echo $Text['mo_inact_role'];?></h4>
<select multiple="multiple" size="15" class="multipleSelect" id="inactiveRoles">
</select>
</div>
<div id="middleColumn">
<button id="activate"> <?php echo $Text['btn_activate']; ?> </button><br/><br/>
<button id="deactivate"><?php echo $Text['btn_deactivate']?></button>
</div>
<div id="rightColumn">
<h4><?php echo $Text['active_roles'];?></h4>
<select multiple="multiple" size="15" class="multipleSelect" id="activeRoles">
</select>
</div>
</div><!-- end role wrap -->
<!-- div id="mngOrderBtn">
<input type="reset" value="<?php echo $Text['btn_reset']; ?>"/>
<input type="submit" value="<?php echo $Text['btn_save']; ?>"/>
</div-->
</form>
</div>
<!-- end of stage wrap -->
</div>
<!-- end of wrap -->
<!-- / END -->
</body>
</html>