878 lines
32 KiB
HTML
878 lines
32 KiB
HTML
<div style="height:480px;background-color:#f2f2f2;">
|
|
<table id="user_list" class="table table-classic">
|
|
<thead>
|
|
<tr>
|
|
<th width="110">ID</th>
|
|
<th width="110" id="user_list_name">>Name</th>
|
|
<th width="120" id="user_list_department">Department</th>
|
|
<th width="*" id="user_list_title">Title</th>
|
|
<th width="100" id="user_list_level">Level</th>
|
|
<th width="100" id="user_list_status">Status</th>
|
|
<th width="150" id="user_list_email">Email</th>
|
|
<th width="60" id="user_list_alarm_notice">Alarm Notice</th>
|
|
<th width="100" id="user_list_mobile">Mobile</th>
|
|
<th width="150" id="user_list_last_time">Last Access Time</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody></tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<script data-jui="#user_list" data-tpl="row" type="text/template">
|
|
<tr style="text-align:center;cursor:pointer;">
|
|
<td><!=userid !></td>
|
|
<td><!=name !></td>
|
|
<td><!=department !></td>
|
|
<td style="text-align:left;"><!=title !></td>
|
|
<td><!=level !></td>
|
|
<td><!=status !></td>
|
|
<td><!=email !></td>
|
|
<td><!=alarm_noti_checkbox !></td>
|
|
<td><!=mobile !></td>
|
|
<td><!=t_last !></td>
|
|
</tr>
|
|
</script>
|
|
|
|
<script data-jui="#user_list" data-tpl="expand" type="text/template">
|
|
<div class="row" style="padding: 3px 0 0 3px;">
|
|
<div class="group">
|
|
<label class="label label-small" style="width:140px;" id="user_list_disp_alarm_receive">Alarm Receive</label>
|
|
<!=alarm_noti_bat25_checkbox !> <label id="user_list_disp_alarm_noti_battery_25">Battery less 25%</label>
|
|
<!=alarm_noti_bat50_checkbox !> <label id="user_list_disp_alarm_noti_battery_50">Battery less 50%</label>
|
|
<!=alarm_noti_gw_checkbox !> <label id="user_list_disp_alarm_disconnected_gw">Gateway Disconnected</label>
|
|
<!=alarm_noti_tag_checkbox !> <label id="user_list_disp_alarm_disconnected_tag">Tag Disconnected</label>
|
|
<!=alarm_noti_posfile_checkbox !> <label id="user_list_disp_alarm_pos_import">POS Import Fail</label>
|
|
</div>
|
|
</div>
|
|
</script>
|
|
|
|
<script data-jui="#user_list" data-tpl="none" type="text/template">
|
|
<tr>
|
|
<td colspan="5" style="text-align:center;height:440px;width:1280px;">Data does not exist.</td>
|
|
</tr>
|
|
</script>
|
|
<div style="position:relative;left:0px;top:10px;"><i class="icon-help" style="color:gray;font-size: 20px; float:left; vertical-align:middle;" id="icon_user_list"></i></div>
|
|
<div>
|
|
<p style="text-align:right; padding-top:0px;">
|
|
<div class="" style="text-align:right;padding-top:5px;float:right">
|
|
<a class="btn btn-gray" id="btn_user_passwd_reset">Reset Password</a>
|
|
<a class="btn btn-gray" id="btn_user_passwd">Change Password</a>
|
|
<a class="btn btn-gray" id="btn_user_add">Add</a>
|
|
<a class="btn btn-gray" id="btn_user_edit">Edit</a>
|
|
<a class="btn btn-gray" id="btn_user_delete">Delete</a>
|
|
<a class="btn btn-gray" id="btn_user_refresh">Refresh</a>
|
|
</div>
|
|
</p>
|
|
</div>
|
|
<div id="user_window" class="window window-white">
|
|
<div class="head">
|
|
<div class="left" id="win_user_head"></div>
|
|
<div class="right">
|
|
<a href="#" class="close"><i class="icon-exit"></i></a>
|
|
</div>
|
|
</div>
|
|
<div class="body">
|
|
<form name="frmUserReg" id="frmUserReg">
|
|
<input type="hidden" name="mode" id="mode" value="" />
|
|
<input type="hidden" name="row_id" id="row_id" value="" />
|
|
<div style="padding-bottom:5px;">
|
|
<label class="label label-small" style="width:100px;" id="user_frm_id">ID</label>
|
|
<input type="text" name="userid" id="userid" value="" maxlength="20" class="input input-small input-rect" style="width:200px;" /><br />
|
|
</div>
|
|
<div style="padding-bottom:5px;">
|
|
<label class="label label-small" style="width:100px;" id="user_frm_name">Name</label>
|
|
<input type="text" name="name" id="name" value="" maxlength="20" class="input input-small input-rect" style="width:200px;" /><br />
|
|
</div>
|
|
<div style="padding-bottom:5px;" id="passwdHidden">
|
|
<label class="label label-small" style="width:100px;" id="user_frm_pwd">Password</label>
|
|
<input type="password" name="passwd" id="passwd" value="" maxlength="20" class="input input-small input-rect" style="width:200px;" /><br />
|
|
</div>
|
|
|
|
<div style="padding-bottom:5px;">
|
|
<label class="label label-small" style="width:100px;" id="user_frm_dept">Department</label>
|
|
<input type="text" name="department" id="department" value="" maxlength="100" class="input input-small input-rect" style="width:200px;" /><br />
|
|
</div>
|
|
|
|
<div style="padding-bottom:5px;">
|
|
<label class="label label-small" style="width:100px;" id="user_frm_title">title</label>
|
|
<input type="text" name="title" id="title" value="" maxlength="100" class="input input-small input-rect" style="width:200px;" /><br />
|
|
</div>
|
|
|
|
<div style="padding-bottom:5px;">
|
|
<label class="label label-small" style="width:100px;" id="user_frm_level">Level</label>
|
|
<select name="level_code" id="level_code" class="input-mini input-rect" style="width:200px;">
|
|
<option value="3" id="opt_user">User</option>
|
|
<option value="2" id="opt_manager">Manager</option>
|
|
<option value="1" id="opt_admin">Administrator</option>
|
|
</select>
|
|
</div>
|
|
|
|
|
|
<div style="padding-bottom:5px;">
|
|
<label class="label label-small" style="width:100px;" id="user_frm_email">Email</label>
|
|
<input type="text" name="email" id="email" value="" maxlength="100" class="input input-small input-rect" style="width:200px;" /><br />
|
|
</div>
|
|
<div style="padding-bottom:5px;">
|
|
<label class="label label-small" style="width:100px;" id="user_frm_mobile">Mobile</label>
|
|
<input type="text" name="mobile" id="mobile" value="" maxlength="20" class="input input-small input-rect" style="width:200px;" /><br />
|
|
</div>
|
|
<div style="padding-bottom:5px;">
|
|
<label class="label label-small" style="width:100px;" id="user_frm_alarm_noti">Alarm Notice</label>
|
|
<input type="checkbox" name="alarm_noti" id="alarm_noti" value="true" class="input input-small input-rect" /><br />
|
|
</div>
|
|
<div class="group" style="padding-bottom:5px;">
|
|
<div class="group" style="float:left;">
|
|
<label class="label label-small" style="width:100px;" id="user_alarm_receive">Alarm Receive</label>
|
|
</div>
|
|
<div class="group" style="float:left;">
|
|
<input type="checkbox" name="user_alarm_noti_bat25" id="user_alarm_noti_bat25" style="width:25px;margin-left:-7px;" /> <label id="disp_alarm_noti_battery_25">Battery less 25%</label>
|
|
<br><input type="checkbox" name="user_alarm_noti_bat50" id="user_alarm_noti_bat50" style="width:25px" /> <label id="disp_alarm_noti_battery_50">Battery less 50%</label>
|
|
<br><input type="checkbox" name="user_alarm_noti_gw" id="user_alarm_noti_gw" style="width:25px" /> <label id="disp_alarm_disconnected_gw">Gateway Disconnected</label>
|
|
<br><input type="checkbox" name="user_alarm_noti_tag" id="user_alarm_noti_tag" style="width:25px" /> <label id="disp_alarm_disconnected_tag">Tag Disconnected</label>
|
|
<br><input type="checkbox" name="user_alarm_noti_posfile" id="user_alarm_noti_posfile" style="width:25px" /> <label id="disp_alarm_pos_import">POS Import Fail</label>
|
|
</div>
|
|
</div>
|
|
|
|
</form>
|
|
</div>
|
|
<div class="foot" align="center">
|
|
<a href="#" class="btn btn-gray" id="btn_user_save">Save</a>
|
|
<a href="#" class="btn btn-gray" id="btn_user_close">Close</a>
|
|
</div>
|
|
</div>
|
|
<div id="user_passwd_window" class="window window-white">
|
|
<div class="head">
|
|
<div class="left"><label id="frm_password">Password</label></div>
|
|
<div class="right">
|
|
<a href="#" class="close"><i class="icon-exit"></i></a>
|
|
</div>
|
|
</div>
|
|
<div class="body">
|
|
<form name="frmUserPasswd" id="frmUserPasswd">
|
|
<input type="hidden" name="row_id" id="row_id" value="" />
|
|
|
|
|
|
<div style="padding-bottom:5px;" id="passwdHidden">
|
|
<label class="label label-small" style="width:160px;" id="chg_pwd">Password</label>
|
|
<input type="password" name="old_passwd" id="old_passwd" value="" maxlength="20" class="input input-small input-rect" style="width:200px;" /><br />
|
|
</div>
|
|
|
|
<div style="padding-bottom:5px;" id="passwdHidden">
|
|
<label class="label label-small" style="width:160px;" id="chg_pwd_new">New Password</label>
|
|
<input type="password" name="new_passwd" id="new_passwd" value="" maxlength="20" class="input input-small input-rect" style="width:200px;" /><br />
|
|
</div>
|
|
|
|
<div style="padding-bottom:5px;" id="passwdHidden">
|
|
<label class="label label-small" style="width:160px;" id="chg_pwd_confirm">Confirm Password</label>
|
|
<input type="password" name="new_passwd2" id="new_passwd2" value="" maxlength="20" class="input input-small input-rect" style="width:200px;" /><br />
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="foot" align="center">
|
|
<a href="#" class="btn btn-gray" id="btn_passwd_save">Save</a>
|
|
<a href="#" class="btn btn-gray" id="btn_passwd_close">Close</a>
|
|
</div>
|
|
</div>
|
|
<div id="user_reset_passwd_window" class="window window-white">
|
|
<div class="head">
|
|
<div class="left"><label id="frm_reset_password">Reset Password</label></div>
|
|
<div class="right">
|
|
<a href="#" class="close"><i class="icon-exit"></i></a>
|
|
</div>
|
|
</div>
|
|
<div class="body">
|
|
<div style="padding-bottom:5px;" id="passwdHidden">
|
|
<label class="label label-small" style="width:160px;" id="reset_pwd_new">New Password</label>
|
|
<input type="text" name="new_reset_passwd" id="new_reset_passwd" value="" class="input input-small input-rect" style="width:200px;" readonly="readonly"/><br />
|
|
</div>
|
|
</div>
|
|
<div class="foot" align="center">
|
|
<a href="#" class="btn btn-gray" id="btn_reset_passwd_close">Close</a>
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
var user_window
|
|
, user_passwd_window
|
|
, user_list
|
|
, user_loading
|
|
, user_reset_passwd_window;
|
|
|
|
jui.ready([ "ui.modal" ], function(modal) {
|
|
user_loading = modal('#loading', {
|
|
target: '#user_list',
|
|
opacity: 0.1,
|
|
autoHide: false,
|
|
});
|
|
});
|
|
jui.ready([ "ui.tooltip" ], function(tooltip) {
|
|
tooltip_icon_user_list = tooltip("#icon_user_list", {
|
|
position: "top",
|
|
width: 400,
|
|
align: "left",
|
|
title: locale.tooltip_icon_user_list
|
|
});
|
|
tooltip_btn_user_passwd = tooltip("#btn_user_passwd", {
|
|
position: "top",
|
|
width: 400,
|
|
align: "left",
|
|
title: locale.tooltip_btn_user_passwd
|
|
});
|
|
tooltip_btn_user_passwd = tooltip("#btn_user_passwd_reset", {
|
|
position: "top",
|
|
width: 400,
|
|
align: "left",
|
|
title: locale.tooltip_btn_user_passwd_reset
|
|
});
|
|
tooltip_btn_user_add = tooltip("#btn_user_add", {
|
|
position: "top",
|
|
width: 400,
|
|
align: "left",
|
|
title: locale.tooltip_btn_user_add
|
|
});
|
|
tooltip_btn_user_edit = tooltip("#btn_user_edit", {
|
|
position: "top",
|
|
width: 400,
|
|
align: "left",
|
|
title: locale.tooltip_btn_user_edit
|
|
});
|
|
tooltip_btn_user_delete = tooltip("#btn_user_delete", {
|
|
position: "top",
|
|
width: 400,
|
|
align: "left",
|
|
title: locale.tooltip_btn_user_delete
|
|
});
|
|
tooltip_btn_user_refresh = tooltip("#btn_user_refresh", {
|
|
position: "top",
|
|
width: 400,
|
|
align: "left",
|
|
title: locale.tooltip_btn_user_refresh
|
|
});
|
|
});
|
|
function fnGetUserList() {
|
|
user_loading.show();
|
|
$.ajax({
|
|
url : '/restapi/user/get_user'
|
|
, type: 'POST'
|
|
, data : {
|
|
}, success : function(json) {
|
|
var user_level_code
|
|
, alarm_noti;
|
|
|
|
user_list.uncheckAll();
|
|
var add_users = [];
|
|
var add_index = 0;
|
|
|
|
if(json.result.toLowerCase() == "invalid_token") {
|
|
document.location.replace('./index.html');
|
|
}else if(json.result.toLowerCase() == "success") {
|
|
json = json.data;
|
|
|
|
$.each(json, function(i, v) {
|
|
user_level_code = json[i].level_code;
|
|
alarm_noti = json[i].alarm_noti;
|
|
alarm_noti_bat25 = json[i].noti_bat25;
|
|
alarm_noti_bat50 = json[i].noti_bat50;
|
|
alarm_noti_gw = json[i].noti_gw;
|
|
alarm_noti_tag = json[i].noti_tag;
|
|
alarm_noti_posfile = json[i].noti_posfile;
|
|
|
|
if(json[i].t_last == null || json[i].t_last == 'null') {
|
|
json[i].t_last = '-';
|
|
}
|
|
|
|
switch(user_level_code) {
|
|
case 0:
|
|
json[i]['level'] = locale.level_develop;
|
|
break;
|
|
case 1:
|
|
json[i]['level'] = locale.level_admin;
|
|
break;
|
|
case 2:
|
|
json[i]['level'] = locale.level_manager;
|
|
break;
|
|
case 3:
|
|
json[i]['level'] = locale.level_user;
|
|
break;
|
|
default:
|
|
json[i]['level'] = '';
|
|
break;
|
|
}
|
|
|
|
switch(json[i].status) {
|
|
case 'user_id_locked':
|
|
json[i]['status'] = '<span style="color:#FF0000;">'+ locale.locked_id +'</span>';
|
|
break;
|
|
case 'user_id_expired':
|
|
json[i]['status'] = '<span style="color:#FF0000;">'+ locale.expired_id +'</span>';
|
|
break;
|
|
default:
|
|
json[i]['status'] = '';
|
|
break;
|
|
}
|
|
|
|
if(alarm_noti == true || alarm_noti == 'true') {
|
|
json[i]['alarm_noti_checkbox'] = '<input type="checkbox" value="true" checked="checked" class="input input-small input-rect" onclick="return false;" />';
|
|
} else {
|
|
json[i]['alarm_noti_checkbox'] = '<input type="checkbox" value="false" class="input input-small input-rect" readonly="readonly" onclick="return false;" />';
|
|
}
|
|
if(alarm_noti_bat25 == true || alarm_noti_bat25 == 'true') {
|
|
json[i]['alarm_noti_bat25_checkbox'] = '<input type="checkbox" value="true" checked="checked" class="input input-small input-rect" onclick="return false;" />';
|
|
} else {
|
|
json[i]['alarm_noti_bat25_checkbox'] = '<input type="checkbox" value="false" class="input input-small input-rect" readonly="readonly" onclick="return false;" />';
|
|
}
|
|
if(alarm_noti_bat50 == true || alarm_noti_bat50 == 'true') {
|
|
json[i]['alarm_noti_bat50_checkbox'] = '<input type="checkbox" value="true" checked="checked" class="input input-small input-rect" onclick="return false;" />';
|
|
} else {
|
|
json[i]['alarm_noti_bat50_checkbox'] = '<input type="checkbox" value="false" class="input input-small input-rect" readonly="readonly" onclick="return false;" />';
|
|
}
|
|
if(alarm_noti_gw == true || alarm_noti_gw == 'true') {
|
|
json[i]['alarm_noti_gw_checkbox'] = '<input type="checkbox" value="true" checked="checked" class="input input-small input-rect" onclick="return false;" />';
|
|
} else {
|
|
json[i]['alarm_noti_gw_checkbox'] = '<input type="checkbox" value="false" class="input input-small input-rect" readonly="readonly" onclick="return false;" />';
|
|
}
|
|
if(alarm_noti_tag == true || alarm_noti_tag == 'true') {
|
|
json[i]['alarm_noti_tag_checkbox'] = '<input type="checkbox" value="true" checked="checked" class="input input-small input-rect" onclick="return false;" />';
|
|
} else {
|
|
json[i]['alarm_noti_tag_checkbox'] = '<input type="checkbox" value="false" class="input input-small input-rect" readonly="readonly" onclick="return false;" />';
|
|
}
|
|
if(alarm_noti_posfile == true || alarm_noti_posfile == 'true') {
|
|
json[i]['alarm_noti_posfile_checkbox'] = '<input type="checkbox" value="true" checked="checked" class="input input-small input-rect" onclick="return false;" />';
|
|
} else {
|
|
json[i]['alarm_noti_posfile_checkbox'] = '<input type="checkbox" value="false" class="input input-small input-rect" readonly="readonly" onclick="return false;" />';
|
|
}
|
|
if(userlevCode == 0){
|
|
if(userlevCode == user_level_code)
|
|
add_users[add_index++]=json[i];
|
|
}
|
|
else{
|
|
if(user_level_code != 0)
|
|
add_users[add_index++]=json[i];
|
|
}
|
|
});
|
|
//user_list.update(json);
|
|
user_list.update(add_users);
|
|
user_loading.hide();
|
|
}
|
|
}, error:function(request,status,err){
|
|
user_loading.hide();
|
|
if (request.status == 0) {
|
|
alertify.error(locale.server_not_run);
|
|
} else {
|
|
// alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+err);
|
|
alert(locale.service_error + "(" + request.status + ")");
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
jui.ready(['uix.table'], function(table) {
|
|
user_list = table('#user_list', {
|
|
fields: ['userid','department','title','level','status','t_last']
|
|
, scroll: true
|
|
, scrollHeight: 450
|
|
, resize: true
|
|
, expand: false
|
|
, sort: [0,1,2,3,4,5]
|
|
, animate: true
|
|
, event: {
|
|
click: function(row, e) {
|
|
user_window.hide();
|
|
if($(row.element).hasClass("checked")) {
|
|
}
|
|
else
|
|
{
|
|
this.uncheckAll();
|
|
this.check(row.index);
|
|
}
|
|
},
|
|
sort: function(column, e) {
|
|
var className = {
|
|
"desc": "icon-arrow1",
|
|
"asc": "icon-arrow3"
|
|
}[column.order];
|
|
|
|
$(column.element).children("i").remove();
|
|
$(column.element).append("<i class='" + className + "'></i>");
|
|
},
|
|
expand: function(row, e) {
|
|
$('#user_list_disp_alarm_receive').text(locale.alarm_receive);
|
|
$('#user_list_disp_alarm_noti_battery_25').text(locale.battery_less_25);
|
|
$('#user_list_disp_alarm_noti_battery_50').text(locale.battery_less_50);
|
|
$('#user_list_disp_alarm_disconnected_gw').text(locale.gateway + " " + locale.disconnected);
|
|
$('#user_list_disp_alarm_disconnected_tag').text(locale.tag + " " + locale.disconnected);
|
|
$('#user_list_disp_alarm_pos_import').text("POS " + locale.import + " " + locale.fail);
|
|
}
|
|
}
|
|
});
|
|
|
|
fnGetUserList();
|
|
});
|
|
|
|
jui.ready(['uix.window'], function(win) {
|
|
user_window = win('#user_window', {
|
|
width: 360
|
|
, height: 480
|
|
, modal: false
|
|
, move: true
|
|
, resize: false
|
|
, left: '40%'
|
|
, top: 165
|
|
});
|
|
});
|
|
jui.ready(['uix.window'], function(win) {
|
|
user_passwd_window = win('#user_passwd_window', {
|
|
width: 430
|
|
, height: 200
|
|
, modal: false
|
|
, move: true
|
|
, resize: false
|
|
, left: '40%'
|
|
, top: 260
|
|
});
|
|
});
|
|
jui.ready(['uix.window'], function(win) {
|
|
user_reset_passwd_window = win('#user_reset_passwd_window', {
|
|
width: 430
|
|
, height: 140
|
|
, modal: false
|
|
, move: true
|
|
, resize: false
|
|
, left: '40%'
|
|
, top: 260
|
|
});
|
|
});
|
|
$(function() {
|
|
$('#frmUserReg').validate({
|
|
rules: {
|
|
userid: 'required'
|
|
, name: 'required'
|
|
}, messages: {
|
|
userid: 'Invalid ID.'
|
|
, name: 'Invalid Name.'
|
|
}
|
|
});
|
|
|
|
$('#btn_user_refresh').click(function() {
|
|
user_window.hide();
|
|
fnGetUserList();
|
|
})
|
|
|
|
$('#btn_user_add').click(function() {
|
|
user_window.hide();
|
|
var max_user = 50
|
|
, user_count = user_list.count();
|
|
if(user_count >= 50) {
|
|
alertify.alert('Error','Max User Number is '+ max_user +'.');
|
|
//alert('Max User Number is '+ max_user +'.');
|
|
return;
|
|
}
|
|
|
|
|
|
//$('#win_user_head').html('User Add');
|
|
$('#win_user_head').html(locale.user_add);
|
|
$('#mode').val('add');
|
|
$('#row_id').val('0');
|
|
$('#userid').val('').removeAttr('readonly');
|
|
$('#name').val('');
|
|
document.getElementById('passwdHidden').style.display = "inherit";
|
|
$('#passwd').val('');
|
|
$('#department').val('');
|
|
$('#title').val('');
|
|
$('#level_code').removeAttr('disabled');
|
|
$('#level_code').val('3');
|
|
$('#email').val('');
|
|
$('#mobile').val('');
|
|
$('#alarm_noti').removeAttr('checked');
|
|
user_window.show();
|
|
$('#userid').focus();
|
|
$('#user_alarm_noti_bat25').removeAttr('checked');
|
|
$('#user_alarm_noti_battery_50').removeAttr('checked');
|
|
$('#user_alarm_noti_gw').removeAttr('checked');
|
|
$('#user_alarm_noti_tag').removeAttr('checked');
|
|
$('#user_alarm_noti_posfile').removeAttr('checked');
|
|
});
|
|
|
|
$('#btn_user_save').click(function() {
|
|
if($('#frmUserReg').valid()) {
|
|
var mode = $('#mode').val()
|
|
, url = (mode == 'add') ? '/restapi/user/add_user' : '/restapi/user/edit_user'
|
|
, level_code = $('#level_code').val();
|
|
var b_develop = false;
|
|
|
|
if(mode == 'add')
|
|
{
|
|
if($('#passwd').val().length < 10) {
|
|
//user_window.hide();
|
|
alertify.alert(locale.error,locale.invalid_password_length);
|
|
//set({onshow:null, onclose:function(){ user_window.show();}});
|
|
//alert('Enter your password at least 6 characters.');
|
|
return;
|
|
}
|
|
//alert($('#passwd').val());
|
|
var password_chk = $('#passwd').val();
|
|
if(!fnCheckUserPWD(password_chk)){
|
|
alertify.alert(locale.error,locale.invalid_password_val);
|
|
return;
|
|
}
|
|
//alert("Check");
|
|
|
|
}
|
|
if(mode == 'add') {
|
|
if (level_code == '1') {
|
|
//alert('An administrator can not be added.');
|
|
//user_window.hide();
|
|
alertify.alert('Error','An administrator can not be added.');
|
|
//set({onshow:null, onclose:function(){ user_window.show();}});
|
|
return;
|
|
}
|
|
} else {
|
|
var obj = user_list.listChecked()[0].data;
|
|
if(obj.level_code == 1) {
|
|
if(level_code != '1') {
|
|
//user_window.hide();
|
|
alertify.alert('Error','The administrator can not change the level.');
|
|
//set({onshow:null, onclose:function(){ user_window.show();}});
|
|
//alert('The administrator can not change the level.');
|
|
$('#level_code').val('1');
|
|
return;
|
|
}
|
|
}
|
|
if(obj.level_code == 0) {
|
|
b_develop = true;
|
|
}
|
|
}
|
|
|
|
$.ajax({
|
|
url: url
|
|
, type: 'POST'
|
|
, data: {
|
|
'row_id': $('#row_id').val()
|
|
, 'userid': $('#userid').val()
|
|
, 'name': $('#name').val()
|
|
, 'passwd': $('#passwd').val()
|
|
, 'department': $('#department').val()
|
|
, 'title': $('#title').val()
|
|
, 'level_code': b_develop == false ? $('#level_code').val() : 0
|
|
, 'email': $('#email').val()
|
|
, 'mobile': $('#mobile').val()
|
|
, 'alarm_noti': $('#alarm_noti').is(':checked')
|
|
, 'noti_bat25': $('#user_alarm_noti_bat25').is(':checked')
|
|
, 'noti_bat50': $('#user_alarm_noti_bat50').is(':checked')
|
|
, 'noti_gw': $('#user_alarm_noti_gw').is(':checked')
|
|
, 'noti_tag': $('#user_alarm_noti_tag').is(':checked')
|
|
, 'noti_posfile': $('#user_alarm_noti_posfile').is(':checked')
|
|
}, success : function(json) {
|
|
if(json.result.toLowerCase() == "invalid_token") {
|
|
document.location.replace('./index.html');
|
|
}else if(json.result.toLowerCase() == "success") {
|
|
fnGetUserList();
|
|
user_window.hide();
|
|
alertify.success(locale[json.result.toLowerCase()]);
|
|
}else if(json.result.toLowerCase() == "name_already_registered") {
|
|
alertify.alert(locale.add_fail, locale.already_name);
|
|
}else if(json.result.toLowerCase() == "id_already_registered") {
|
|
alertify.alert(locale.add_fail, locale.already_id);
|
|
}else {
|
|
alert(json.result);
|
|
//alertify.error(locale[json[0].result.toLowerCase()]);
|
|
}
|
|
}, error:function(request,status,err){
|
|
if (request.status == 0) {
|
|
alertify.error(locale.server_not_run);
|
|
} else {
|
|
// alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+err);
|
|
alert(locale.service_error + "(" + request.status + ")");
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
$('#btn_passwd_save').click(function() {
|
|
if($('#frmUserPasswd').valid()) {
|
|
if($('#new_passwd').val().length < 10) {
|
|
|
|
alertify.alert(locale.error,locale.invalid_password_length).set('label',locale.ok);
|
|
//user_window.hide();
|
|
//alertify.alert('Error','Enter your password at least 6 characters.');
|
|
//set({onshow:null, onclose:function(){ user_window.show();}});
|
|
//alert('Enter your password at least 6 characters.');
|
|
return;
|
|
}
|
|
if($('#new_passwd').val() != $('#new_passwd2').val()) {
|
|
//user_window.hide();
|
|
alertify.alert(locale.error,locale.invalid_new_password).set('label',locale.ok);
|
|
//alertify.alert('Error','Check the new password.');
|
|
//set({onshow:null, onclose:function(){ user_window.show();}});
|
|
//alert('Enter your password at least 6 characters.');
|
|
return;
|
|
}
|
|
var password_chk = $('#new_passwd').val();
|
|
if(!fnCheckUserPWD(password_chk)){
|
|
alertify.alert(locale.error,locale.invalid_password_val);
|
|
return;
|
|
}
|
|
$.ajax({
|
|
url: '/restapi/user/change_user_pw'
|
|
, type: 'POST'
|
|
, data: {
|
|
'row_id': $('#row_id').val()
|
|
, 'old_passwd': $('#old_passwd').val()
|
|
, 'new_passwd': $('#new_passwd').val()
|
|
}, success : function(json) {
|
|
if(json.result.toLowerCase() == "invalid_token") {
|
|
document.location.replace('./index.html');
|
|
}else if(json.result.toLowerCase() == "success") {
|
|
user_passwd_window.hide();
|
|
alertify.success(locale[json.result.toLowerCase()]);
|
|
}else {
|
|
alertify.error(locale[json.result.toLowerCase()]);
|
|
}
|
|
}, error:function(request,status,err){
|
|
if (request.status == 0) {
|
|
alertify.error(locale.server_not_run);
|
|
} else {
|
|
// alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+err);
|
|
alert(locale.service_error + "(" + request.status + ")");
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
$('#btn_user_passwd').click(function() {
|
|
user_passwd_window.hide();
|
|
if(user_list.listChecked().length <= 0) {
|
|
alertify.error(locale.no_selected);
|
|
return;
|
|
}
|
|
|
|
//본인 계정만 수정 가능
|
|
var obj = user_list.listChecked()[0].data;
|
|
if(!authObj.isUserEditAuth(obj.userid)){
|
|
return;
|
|
}
|
|
|
|
$('#row_id').val(obj.row_id);
|
|
$('#old_passwd').val('');
|
|
$('#new_passwd').val('');
|
|
$('#new_passwd2').val('');
|
|
|
|
user_passwd_window.show();
|
|
});
|
|
|
|
$('#btn_user_passwd_reset').click(function() {
|
|
user_reset_passwd_window.hide();
|
|
if(user_list.listChecked().length <= 0) {
|
|
alertify.error(locale.no_selected);
|
|
return;
|
|
}
|
|
|
|
var obj = user_list.listChecked()[0].data;
|
|
|
|
alertify.confirm(locale.confirm, locale.confirm_pwd_reset, function (e) {
|
|
if (e) {
|
|
$.ajax({
|
|
url: '/restapi/user/reset_user_pw'
|
|
, type: 'POST'
|
|
, data: {
|
|
'row_id': obj.row_id
|
|
}, success : function(json) {
|
|
if(json.result.toLowerCase() == "invalid_token") {
|
|
document.location.replace('./index.html');
|
|
}else if(json.result.toLowerCase() == "success") {
|
|
$('#new_reset_passwd').val(json.data[0].new_passwd);
|
|
user_reset_passwd_window.show();
|
|
}else {
|
|
alertify.error(locale[json.result.toLowerCase()]);
|
|
}
|
|
}, error:function(request,status,err){
|
|
if (request.status == 0) {
|
|
alertify.error(locale.server_not_run);
|
|
} else {
|
|
// alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+err);
|
|
alert(locale.service_error + "(" + request.status + ")");
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
return;
|
|
}
|
|
}, null).set('labels', {ok:locale.ok, cancel:locale.cancel});
|
|
|
|
});
|
|
|
|
|
|
$('#btn_user_edit').click(function() {
|
|
user_window.hide();
|
|
if(user_list.listChecked().length <= 0) {
|
|
alertify.error(locale.no_selected);
|
|
return;
|
|
}
|
|
|
|
//본인 계정만 수정 가능
|
|
var obj = user_list.listChecked()[0].data;
|
|
if(!authObj.isUserEditAuth(obj.userid)){
|
|
return;
|
|
}
|
|
|
|
//$('#win_user_head').html('User Edit');
|
|
$('#win_user_head').html(locale.user_edit);
|
|
$('#row_id').val(obj.row_id);
|
|
$('#mode').val('edit');
|
|
$('#userid').val(obj.userid).attr('readonly', 'readonly');
|
|
$('#name').val(obj.name);
|
|
|
|
//$('#passwd').attr('type','hidden');
|
|
document.getElementById('passwdHidden').style.display = "none";
|
|
$('#department').val(obj.department);
|
|
$('#title').val(obj.title);
|
|
//document.getElementById('level_code').style.display = "none";
|
|
$('#level_code').attr('disabled', 'true');
|
|
$('#level_code').val(obj.level_code);
|
|
$('#email').val(obj.email);
|
|
$('#mobile').val(obj.mobile);
|
|
|
|
if(obj.alarm_noti == true || obj.alarm_noti == 'true') {
|
|
$('#alarm_noti').attr('checked', 'checked');
|
|
} else {
|
|
$('#alarm_noti').removeAttr('checked');
|
|
}
|
|
if(obj.noti_bat25 == true || obj.noti_bat25 == 'true') {
|
|
$('#user_alarm_noti_bat25').attr('checked', 'checked');
|
|
} else {
|
|
$('#user_alarm_noti_bat25').removeAttr('checked');
|
|
}
|
|
if(obj.noti_bat50 == true || obj.noti_bat50 == 'true') {
|
|
$('#user_alarm_noti_bat50').attr('checked', 'checked');
|
|
} else {
|
|
$('#user_alarm_noti_bat50').removeAttr('checked');
|
|
}
|
|
if(obj.noti_gw == true || obj.noti_gw == 'true') {
|
|
$('#user_alarm_noti_gw').attr('checked', 'checked');
|
|
} else {
|
|
$('#user_alarm_noti_gw').removeAttr('checked');
|
|
}
|
|
if(obj.noti_tag == true || obj.noti_tag == 'true') {
|
|
$('#user_alarm_noti_tag').attr('checked', 'checked');
|
|
} else {
|
|
$('#user_alarm_noti_tag').removeAttr('checked');
|
|
}
|
|
if(obj.noti_posfile == true || obj.noti_posfile == 'true') {
|
|
$('#user_alarm_noti_posfile').attr('checked', 'checked');
|
|
} else {
|
|
$('#user_alarm_noti_posfile').removeAttr('checked');
|
|
}
|
|
|
|
user_window.show();
|
|
});
|
|
|
|
$('#btn_user_close').click(function() {
|
|
user_window.hide();
|
|
});
|
|
$('#btn_passwd_close').click(function() {
|
|
user_passwd_window.hide();
|
|
});
|
|
$('#btn_reset_passwd_close').click(function() {
|
|
user_reset_passwd_window.hide();
|
|
});
|
|
|
|
$('#btn_user_delete').click(function() {
|
|
user_window.hide();
|
|
|
|
var obj = user_list.listChecked()[0].data;
|
|
if(obj.level_code == 1 || obj.level_code == '1') {
|
|
alertify.alert(locale.error,locale.cant_delete_admin);
|
|
return;
|
|
}
|
|
alertify.confirm(locale.confirm, locale.confirm_delete, function (e) {
|
|
if (e) {
|
|
$.ajax({
|
|
url: '/restapi/user/delete_user'
|
|
, type: 'POST'
|
|
, data: {
|
|
'row_id': obj.row_id
|
|
}, success : function(json) {
|
|
if(json.result.toLowerCase() == "invalid_token") {
|
|
document.location.replace('./index.html');
|
|
}else if(json.result.toLowerCase() == "success") {
|
|
fnGetUserList();
|
|
alertify.success(locale[json.result]);
|
|
}else {
|
|
alertify.error(locale[json.result]);
|
|
}
|
|
}, error:function(request,status,err){
|
|
if (request.status == 0) {
|
|
alertify.error(locale.server_not_run);
|
|
} else {
|
|
// alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+err);
|
|
alert(locale.service_error + "(" + request.status + ")");
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
return;
|
|
}
|
|
}, null).set('labels', {ok:locale.ok, cancel:locale.cancel});
|
|
|
|
|
|
});
|
|
});
|
|
// if(level_code == 0){
|
|
// document.getElementById("btn_user_add").style.display = "none";
|
|
// //document.getElementById("btn_user_edit").style.display = "none";
|
|
// document.getElementById("btn_user_delete").style.display = "none";
|
|
// }
|
|
// if(level_code > 1) {
|
|
// document.getElementById("btn_user_master_passwd").style.display = "none";
|
|
// document.getElementById("btn_user_passwd_reset").style.display = "none";
|
|
// }
|
|
|
|
$('#user_list_name').text(locale.name_user);
|
|
$('#user_list_department').text(locale.department);
|
|
$('#user_list_title').text(locale.title);
|
|
$('#user_list_level').text(locale.level);
|
|
$('#user_list_status').text(locale.status);
|
|
$('#user_list_email').text(locale.email);
|
|
$('#user_list_alarm_notice').text(locale.alarm_notice);
|
|
$('#user_list_mobile').text(locale.mobile);
|
|
$('#user_list_last_time').text(locale.pos_last_time);
|
|
$('#btn_user_passwd').text(locale.change_pwd);
|
|
$('#btn_user_master_passwd').text(locale.change_master_pwd);
|
|
$('#btn_user_passwd_reset').text(locale.reset_pwd);
|
|
$('#btn_user_add').text(locale.user_add);
|
|
$('#btn_user_edit').text(locale.user_edit);
|
|
$('#btn_user_delete').text(locale.user_delete);
|
|
$('#btn_user_refresh').text(locale.refresh);
|
|
//$('#user_frm_id').text(locale.id);
|
|
$('#user_frm_name').text(locale.name_user);
|
|
$('#user_frm_pwd').text(locale.password);
|
|
$('#user_frm_dept').text(locale.department);
|
|
$('#user_frm_title').text(locale.title);
|
|
$('#user_frm_level').text(locale.level);
|
|
$('#opt_user').text(locale.level_user);
|
|
$('#opt_manager').text(locale.level_manager);
|
|
$('#opt_admin').text(locale.level_admin);
|
|
$('#user_frm_email').text(locale.email);
|
|
$('#user_frm_mobile').text(locale.mobile);
|
|
$('#user_frm_alarm_noti').text(locale.alarm_notice);
|
|
$('#chg_pwd').text(locale.password);
|
|
$('#chg_pwd_new').text(locale.new_password);
|
|
$('#chg_pwd_confirm').text(locale.confirm_password);
|
|
$('#reset_pwd_new').text(locale.new_password);
|
|
$('#frm_password').text(locale.password);
|
|
$('#frm_reset_password').text(locale.reset_pwd);
|
|
$('#btn_passwd_save').text(locale.save);
|
|
$('#btn_passwd_close').text(locale.close);
|
|
$('#btn_reset_passwd_close').text(locale.close);
|
|
$('#btn_user_save').text(locale.save);
|
|
$('#btn_user_close').text(locale.close);
|
|
$('#user_alarm_receive').text(locale.alarm_receive);
|
|
$('#disp_alarm_noti_battery_25').text(locale.battery_less_25);
|
|
$('#disp_alarm_noti_battery_50').text(locale.battery_less_50);
|
|
$('#disp_alarm_disconnected_gw').text(locale.gateway + " " + locale.disconnected);
|
|
$('#disp_alarm_disconnected_tag').text(locale.tag + " " + locale.disconnected);
|
|
$('#disp_alarm_pos_import').text("POS " + locale.import + " " + locale.fail);
|
|
|
|
// 메뉴 권한 설정
|
|
authObj.authMenuSet('management/user.html');
|
|
</script>
|