<%@ Page Title="" Language="C#" MasterPageFile="~/Security/Security.master" AutoEventWireup="true" CodeFile="UserManage.aspx.cs" Inherits="Security_UserManage" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"> <style type="text/css"> .no_wrap th { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .max160 { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .dialog-content table { border-collapse: collapse; width: 100%; line-height: 32px; } .dialog-content table td.label { width: 130px; text-align: right; padding-right: 10px; line-height: 24px; height: 24px; vertical-align: top; } .dialog-content table td input, .dialog-content table td textarea { border: 1px solid #a9a9a9; width: 250px; height: 18px; padding: 1px; } #dialog_machines .dialog-content table td input { width: auto; } .dialog-content table td textarea { margin-top: 6px; } .dialog-content table td select { width: 254px; height: 24px; } .dialog-content table td input[type="checkbox"] { border: none; } .dialog-content table td textarea { height: 150px; width: 420px; max-width: 500px; } .ctl_button { font-family: 'CalciteWebCoreIcons'; display: block; margin: 6px auto; width: 60px; height: 22px; line-height: 21px; padding: 0; } #dialog_machinegroup { z-index: 500; width: 870px; top: 60px; left: 150px; } .inputbox { width: 500px; padding: 1px; } .group_table .main_table { table-layout: fixed; } .group_table .main_table thead tr { display: block; } .group_table .main_table tbody { height: 280px; display: block; overflow-y: auto; } .group_table .main_table th { width: 165px; } .group_table .main_table td { width: 165px; white-space: nowrap; word-break: keep-all; } .group_table .main_table td div { width: 165px; overflow: hidden; white-space: nowrap; word-break: keep-all; text-overflow: ellipsis; } .td_controller { vertical-align: middle; padding: 40px 8px; /*border-left: 1px solid #b0b0b0; border-right: 1px solid #b0b0b0;*/ } .ctl_button { font-family: 'CalciteWebCoreIcons'; display: block; margin: 6px auto; width: 60px; height: 22px; line-height: 21px; padding: 0; } .machine_maskbg { top: 0; left: 0; width: 100%; height: 100%; position: absolute; background: #000; opacity: 0.2; } </style> <link href="<%=GetFileUrlWithVersion("../css/panel.css")%>" rel="stylesheet" /> <script src="<%=GetFileUrlWithVersion("js/controls.js")%>" type="text/javascript"></script> <script src="<%=GetFileUrlWithVersion("../js/assetselector.js")%>" type="text/javascript"></script> <script type="text/javascript" src="<%=GetFileUrlWithVersion("../fic/fic/js/controls/editGridCtrl.js") %>"></script> <script src="<%=GetFileUrlWithVersion("../fic/js/utility.js")%>" type="text/javascript"></script> <script src="<%=GetFileUrlWithVersion("js/usermanage.js")%>" type="text/javascript"></script> <%--<script src="<%=GetFileUrlWithVersion("../js/lib/ui.min.js")%>" type="text/javascript"></script> <link rel="stylesheet" href="<%=GetFileUrlWithVersion("../js/lib/ui.min.css")%>" />--%> <script src="<%=GetFileUrlWithVersion("../js/gridlayout.js")%>" type="text/javascript"></script> <script type="text/javascript"> var gridLayoutID = "UserManage"; var IsDealer = <%=IsDealer ?"true":"false"%>; var IsAdmin =<%=IsAdmin ?"true":"false"%>; var WorkOrderLisence =<%=WorkOrderLisence ?"true":"false"%>; var CustomerRecordLisence =<%=CustomerRecordLisence ?"true":"false"%>; var users; function isMyself(uid) { return uid == '<%=IID%>'; } _network.userquery = function (method, param, callback, error) { _network.request("Security/UserManage.aspx", -1, method, param, callback, error); } function OnDelete(u) { if (!u) { return; } showConfirm(GetTextByKey("P_UM_DOYOUWANTTODELETE", 'Do you want to delete {0}?').replace('{0}', u.DisplayName), GetTextByKey("P_UM_DELETEUSER", 'Delete user'), function () { _network.userquery('DeleteUser', u.IID, function (data) { OnRefresh(); }, function (err) { showAlert('Failed to delete this user.', GetTextByKey("P_UM_DELETEUSER", 'Delete user')); }); }); } function CloseDialog(type, index) { $('#dialog_user').hideDialog(); newUserSelectIndex = index; OnRefresh(); } function changeGridSelectIndex(index) { grid_dt.selectedIndexes = [index]; grid_dt.scrollToIndex(index); } function OnAdd() { execIframeFunc("init", [], "iframeuser"); showmaskbg(true); $('#dialog_user') .attr('act', 'add') .showDialogRight(); } var uiid; var indexInEdit = -1; function OnEdit() { indexInEdit = grid_dt.selectedIndex; if (indexInEdit < 0) { showAlert(GetTextByKey("P_UM_PLEASESELECTUSER", "Please select user."), GetTextByKey("P_USER", "User")); return; } var user = grid_dt.source[indexInEdit].Values; if (!user) { uiid = undefined; return; } uiid = user.IID; execIframeFunc("init", [uiid, grid_dt.source, indexInEdit], "iframeuser"); showmaskbg(true); $('#dialog_user') .attr('act', 'edit') .showDialogRight(); } function OnDblClick(e) { OnEdit(); } function OnRefresh() { showloading(true); var searchtxt = ""; var active = $('#selactive').val(); searchtxt = htmlencode($.trim($('#searchinputtxt').val())); _network.userquery('GetUsers', JSON.stringify([active, searchtxt]), function (data) { showloading(false); if ($.nullOrEmpty(searchtxt)) { isalluser = true; } else { isalluser = false; } users = data; showUserList(users); }, function (err) { showloading(false); }); } var usertypesource = [ { value: 0, text: GetTextByKey('P_UM_READONLY', 'Read Only') }, { value: 1, text: GetTextByKey('P_UM_COMMON', 'Common') }, { value: 2, text: GetTextByKey('P_UM_ADMIN', 'Admin') } ]; var contacttypesource = [ { value: 7, text: GetTextByKey('P_UM_ADVISOR', 'Advisor') }, { value: 1, text: GetTextByKey('P_UM_DRIVER', 'Driver') }, { value: 5, text: GetTextByKey('P_UM_FLEETMANAGER', 'Fleet Manager') }, { value: 0, text: GetTextByKey('P_UM_FOREMAN', 'Foreman') }, { value: 2, text: GetTextByKey('P_UM_INVENTORYMANAGER', 'Inventory Manager') }, { value: 3, text: GetTextByKey('P_UM_RENTALMANAGER', 'Rental Manager') }, { value: 4, text: GetTextByKey('P_UM_SERVICEMANAGER', 'Service Manager') }, { value: 6, text: GetTextByKey('P_UM_TECHNICIAN', 'Technician') }, { value: 100, text: GetTextByKey('P_UM_OTHER', 'Other') } ]; var managersource = []; function getManagerList() { managersource = []; _network.userquery("GetUsers", JSON.stringify([-1, ""]), function (data) { if (data && data.length > 0) { var source = [{ value: '', text: ' ' }]; for (var i = 0; i < data.length; i++) { var s = data[i]; source.push({ value: s.IID, text: s.DisplayName }); } managersource = source; } }, function () { }); } var newUserSelectIndex = -1; function showUserList(data) { var rows = []; for (var i = 0; i < data.length; i++) { var r = data[i]; if (newuseriid != '' && r.IID == newuseriid) newUserSelectIndex = i; var distype = ""; if (r.UserType == 2) distype = 'Admin'; else if (r.UserType == 1) distype = 'Common'; else distype = 'Read Only'; for (var j in r) { if (j === "UserType") { r[j] = { DisplayValue: distype, Value: r[j] }; } else if (j === "Active") { r[j] = { DisplayValue: r.Active ? "Yes" : "No", Value: r[j] }; } else if (j === "IsUser") { r["IsUser"] = { DisplayValue: r.IsUser ? "Yes" : "No", Value: r[j] }; } else if (j === "AssignedWorkOrders") { r["AssignedWorkOrders"] = { DisplayValue: r.AssignedWorkOrders ? "Yes" : "No", Value: r[j] }; } if (j === "GroupNames") { r[j] = { DisplayValue: r["GroupNamesStr"], Value: r[j] }; } else if (j === "EmailOptOut") { r["EmailOptOut"] = { DisplayValue: r.EmailOptOut ? "Yes" : "No", Value: r[j] }; } } var fr = { Values: r }; rows.push(fr); } var top = grid_dt.scrollTop(); grid_dt.setData(rows); if (newUserSelectIndex > 0) { grid_dt.selectedIndexes = [newUserSelectIndex]; grid_dt.reload(); newUserSelectIndex = -1; newuseriid = ''; } grid_dt.scrollTop(top); } function getUserTypeText(usertype) { var distype = ""; if (usertype == 2) distype = 'Admin'; else if (usertype == 1) distype = 'Common'; else distype = 'Read Only'; return distype; } var grid_dt; function InitGridData() { grid_dt = new GridView('#userlist'); grid_dt.lang = { all: GetTextByKey("P_GRID_ALL", "(All)"), ok: GetTextByKey("P_GRID_OK", "OK"), reset: GetTextByKey("P_GRID_RESET", "Reset") }; grid_dt.isEditable = true; var list_columns = [ { name: 'ID', caption: GetTextByKey("P_UM_USERIDOREMAIL", "User ID/Email"), valueIndex: 'ID', css: { 'width': 130, 'text-align': 'left' } }, { name: 'DisplayName', caption: GetTextByKey("P_UM_USERNAME", "User Name"), valueIndex: 'DisplayName', css: { 'width': 100, 'text-align': 'left' } }, { name: 'UserType', caption: GetTextByKey("P_UM_USERTYPE", "User Type"), valueIndex: 'UserType', allowFilter: true, css: { 'width': 85, 'text-align': 'left' } }, { name: 'Active', caption: GetTextByKey("P_UM_ACTIVE", "Active"), valueIndex: 'Active', allowFilter: true, css: { 'width': 70, 'text-align': 'left' } }, { name: 'IsUser', caption: GetTextByKey("P_UM_ISUSER", "Is User"), valueIndex: 'IsUser', allowFilter: true, css: { 'width': 70, 'text-align': 'left' } }, { name: 'AssignedWorkOrders', caption: GetTextByKey("P_UM_ASSIGNEDWORKORDERS", "Assigned Work Orders"), valueIndex: 'AssignedWorkOrders', allowFilter: true, css: { 'width': 100, 'text-align': 'left' } }, { name: 'TextAddress', caption: GetTextByKey("P_UM_TEXTADDRESS", "Text Address"), valueIndex: 'TextAddress', css: { 'width': 130, 'text-align': 'left' } }, { name: 'Mobile', caption: GetTextByKey("P_UM_MOBILE", "Mobile"), valueIndex: 'Mobile', css: { 'width': 80, 'text-align': 'left' } }, { name: 'BusinessPhone', caption: GetTextByKey("P_UM_BUSINESSPHONE", "Business Phone"), valueIndex: 'BusinessPhone', css: { 'width': 80, 'text-align': 'left' } }, { name: 'ContactTypeName', caption: GetTextByKey("P_UM_CONTACTTYPE", "Contact Type"), valueIndex: 'ContactTypeName', allowFilter: true, css: { 'width': 105, 'text-align': 'left' } }, { name: 'FOB', caption: GetTextByKey("P_UM_EMPLOYEEIDORFOB", "Employee ID or FOB"), valueIndex: 'FOB', css: { 'width': 125, 'text-align': 'left' } }, { name: 'ManagerName', caption: GetTextByKey("P_UM_MANAGER", "Manager"), valueIndex: 'ManagerName', allowFilter: true, css: { 'width': 90, 'text-align': 'left' } }, { name: 'EmailOptOut', caption: GetTextByKey("P_UM_OPTOUTOFFICOMMUNICATIONS", "Opt Out of FI Communications?"), valueIndex: 'EmailOptOut', allowFilter: true, css: { 'width': 85, 'text-align': 'left' } }, { name: 'Notes', caption: GetTextByKey("P_UM_NOTES", "Notes"), valueIndex: 'Notes', css: { 'width': 130, 'text-align': 'left' } }, { name: 'GroupNames', caption: GetTextByKey("P_UM_GROUPNAME", "Group Name"), valueIndex: 'GroupNames', css: { 'width': 150, 'text-align': 'left' } }, { name: 'Edit', caption: "", alwaysshow: true, css: { 'width': 30, 'text-align': 'center' } }, { name: 'Copy', caption: "", alwaysshow: true, css: { 'width': 30, 'text-align': 'center' } }, { name: 'AssetAssignment', caption: "", alwaysshow: true, css: { 'width': 30, 'text-align': 'center' } }, { name: 'AssetGroupAssignment', caption: "", alwaysshow: true, css: { 'width': 30, 'text-align': 'center' } }, { name: 'AssetTypeAssignment', caption: "", alwaysshow: true, css: { 'width': 30, 'text-align': 'center' } }, { name: 'JobsiteAssignment', caption: "", alwaysshow: true, css: { 'width': 30, 'text-align': 'center' } }, { name: 'Delete', caption: "", alwaysshow: true, css: { 'width': 30, 'text-align': 'center' } }, { name: 'ResetPassword', caption: "", alwaysshow: true, css: { 'width': 30, 'text-align': 'center' } } ]; var columns = []; // head for (var hd in list_columns) { var col = {}; col.name = list_columns[hd].name; col.caption = list_columns[hd].caption; col.visible = true; col.sortable = true; col.width = list_columns[hd].css.width; col.align = list_columns[hd].css["text-align"] col.key = list_columns[hd].valueIndex; col.allowFilter = list_columns[hd].allowFilter; col.oldFilterValues = col.filterValues; col.alwaysshow = list_columns[hd].alwaysshow; if (col.name === "Active" || col.name === "IsUser" || col.name === "EmailOptOut") { col.filterSource = [{ Value: true, DisplayValue: 'Yes' }, { Value: false, DisplayValue: 'No' }]; } if (col.name === "DisplayName") { col.allowHtml = true; col.filterCustom = true; col.filter = function (item) { return $('<span class="margin-input-span status-cell"></span>').text(item.DisplayName); }; col.editFilter = function (item) { if (!item.IID) { return $('<span class="margin-input-span status-cell"></span>').text(item.DisplayName); } var ipt = $('<input type="text" class="input-cell" maxlength="200"/>'); ipt.val(item.DisplayName); ipt.on('input propertychange', function () { var v = $(this).val().trim(); if (v && v != "") { item.TempTextValue = v; item.__changed = { "DisplayName": true }; } }); ipt.on('change', function () { var v = $(this).val().trim(); if (v && v != "") { item.DisplayName = v; item.TempTextValue = null; item.__changed = null; updateUser(item); } }); return ipt; } col.styleFilter = function () { return { "width": "100%", 'padding': 0 }; } col.onchanged = function (item) { item.DisplayName = item.TempTextValue; item.TempTextValue = null; item.__changed = null; updateUser(item); } } else if (col.name === "TextAddress") { col.allowHtml = true; col.filterCustom = true; col.filter = function (item) { return $('<span class="margin-input-span status-cell"></span>').text(item.TextAddress); }; col.editFilter = function (item) { if (!item.IID) { return $('<span class="margin-input-span status-cell"></span>').text(item.TextAddress); } var ipt = $('<input type="text" class="input-cell" maxlength="100"/>'); ipt.val(item.TextAddress); ipt.on('input propertychange', function () { var v = $(this).val().trim(); if (v == "" || isEmail(v)) { item.TempTextValue = v; item.__changed = { "TextAddress": true }; } }); ipt.on('change', function () { var v = $(this).val().trim(); if (v == "" || isEmail(v)) { item.TextAddress = v; item.TempTextValue = null; item.__changed = null; updateUser(item); } }); return ipt; } col.styleFilter = function () { return { "width": "100%", 'padding': 0 }; } col.onchanged = function (item) { item.TextAddress = item.TempTextValue; item.TempTextValue = null; item.__changed = null; updateUser(item); } } else if (col.name === "Mobile") { col.allowHtml = true; col.filterCustom = true; col.filter = function (item) { return $('<span class="margin-input-span status-cell"></span>').text(item.MobilePhoneDisplayText); }; col.editFilter = function (item) { if (!item.IID) { return $('<span class="margin-input-span status-cell"></span>').text(item.MobilePhoneDisplayText); } var ipt = $('<input type="text" class="input-cell" maxlength="50"/>'); ipt.val(item.MobilePhoneDisplayText); ipt.on('input propertychange', function () { var v = $(this).val().trim(); item.TempTextValue = v; item.__changed = { "Mobile": true }; }); ipt.on('change', function () { var v = $(this).val().trim(); item.Mobile = v; item.MobilePhoneDisplayText = v; item.TempTextValue = null; item.__changed = null; updateUser(item); }); return ipt; } col.styleFilter = function () { return { "width": "100%", 'padding': 0 }; } col.onchanged = function (item) { item.Mobile = item.TempTextValue; item.MobilePhoneDisplayText = item.TempTextValue; item.TempTextValue = null; item.__changed = null; updateUser(item); } } else if (col.name === "BusinessPhone") { col.allowHtml = true; col.filterCustom = true; col.filter = function (item) { return $('<span class="margin-input-span status-cell"></span>').text(item.BusinessPhone); }; col.editFilter = function (item) { if (!item.IID) { return $('<span class="margin-input-span status-cell"></span>').text(item.BusinessPhone); } var ipt = $('<input type="text" class="input-cell" maxlength="50"/>'); ipt.val(item.BusinessPhone); ipt.on('input propertychange', function () { var v = $(this).val().trim(); item.TempTextValue = v; item.__changed = { "BusinessPhone": true }; }); ipt.on('change', function () { var v = $(this).val().trim(); item.BusinessPhone = v; item.TempTextValue = null; item.__changed = null; updateUser(item); }); return ipt; } col.styleFilter = function () { return { "width": "100%", 'padding': 0 }; } col.onchanged = function (item) { item.BusinessPhone = item.TempTextValue; item.TempTextValue = null; item.__changed = null; updateUser(item); } } else if (col.name === "FOB") { col.allowHtml = true; col.filterCustom = true; col.filter = function (item) { return $('<span class="margin-input-span status-cell"></span>').text(item.FOB); }; col.editFilter = function (item) { if (!item.IID) { return $('<span class="margin-input-span status-cell"></span>').text(item.FOB); } var ipt = $('<input type="text" class="input-cell" maxlength="50"/>'); ipt.val(item.FOB); ipt.on('input propertychange', function () { var v = $(this).val().trim(); item.TempTextValue = v; item.__changed = { "FOB": true }; }); ipt.on('change', function () { var v = $(this).val().trim(); item.FOB = v; item.TempTextValue = null; item.__changed = null; updateUser(item); }); return ipt; } col.styleFilter = function () { return { "width": "100%", 'padding': 0 }; } col.onchanged = function (item) { item.FOB = item.TempTextValue; item.TempTextValue = null; item.__changed = null; updateUser(item); } } if (col.name === "Active") { col.allowHtml = true; col.filterCustom = true; col.filter = function (item) { return $('<span class="margin-span"></span>').text(item.Active.DisplayValue); }; col.editFilter = function (item) { if (!item.IID) return ""; var ipt = $('<input type="checkbox"/>').change(function () { var checked = $(this).prop("checked"); item.Active.Value = checked; item.Active.DisplayValue = checked ? 'Yes' : 'No'; updateUser(item); }); ipt.prop('checked', item.Active.Value); return ipt; } col.styleFilter = function () { return { "width": "100%" }; } } else if (col.name === "IsUser") { col.allowHtml = true; col.filterCustom = true; col.filter = function (item) { return $('<span class="margin-span"></span>').text(item.IsUser.DisplayValue); }; col.editFilter = function (item) { if (!item.IID) return ""; var ipt = $('<input type="checkbox"/>').change(function () { var checked = $(this).prop("checked"); item.IsUser.Value = checked; item.IsUser.DisplayValue = checked ? 'Yes' : 'No'; updateUser(item); }); ipt.prop('checked', item.IsUser.Value); return ipt; } col.styleFilter = function () { return { "width": "100%" }; } } else if (col.name === "AssignedWorkOrders") { col.allowHtml = true; col.filterCustom = true; col.filter = function (item) { return $('<span class="margin-span"></span>').text(item.AssignedWorkOrders.DisplayValue); }; col.editFilter = function (item) { if (!item.IID) return ""; var ipt = $('<input type="checkbox"/>').change(function () { var checked = $(this).prop("checked"); item.AssignedWorkOrders.Value = checked; item.AssignedWorkOrders.DisplayValue = checked ? 'Yes' : 'No'; updateUser(item); }); ipt.prop('checked', item.AssignedWorkOrders.Value); return ipt; } col.styleFilter = function () { return { "width": "100%" }; } } else if (col.name === "EmailOptOut") { col.allowHtml = true; col.filterCustom = true; col.filter = function (item) { return $('<span class="margin-span"></span>').text(item.EmailOptOut.DisplayValue); }; col.editFilter = function (item) { if (!item.IID) return ""; var ipt = $('<input type="checkbox"/>').change(function () { var checked = $(this).prop("checked"); item.EmailOptOut.Value = checked; item.EmailOptOut.DisplayValue = checked ? 'Yes' : 'No'; updateUser(item); }); ipt.prop('checked', item.EmailOptOut.Value); return ipt; } col.styleFilter = function () { return { "width": "100%" }; } } else if (col.name === "UserType") { col.allowHtml = true; col.filterCustom = true; col.filter = function (item) { return $('<span class="margin-span"></span>').text(item.UserType.DisplayValue); }; col.editFilter = function (item) { if (!item.IID) return $('<span class="margin-span"></span>').text(item.UserType.DisplayValue); return $('<div class="dropdown"></div>').dropdown(usertypesource, { search: false, selected: item.UserType.Value }).on('select', function (_e, it) { item.UserType.Value = it.value; item.UserType.DisplayValue = it.text; updateUser(item); }); } col.styleFilter = function () { return { "width": "100%", 'padding': 0 }; } } else if (col.name === "ContactTypeName") { col.allowHtml = true; col.filterCustom = true; col.filter = function (item) { return $('<span class="margin-span"></span>').text(item.ContactTypeName || ''); }; col.editFilter = function (item) { if (!item.IID) return $('<span class="margin-span"></span>').text(item.ContactTypeName || ''); return $('<div class="dropdown"></div>').dropdown(contacttypesource, { search: false, selected: item.ContactType }).on('select', function (_e, it) { item.ContactType = it.value; item.ContactTypeName = it.text; updateUser(item); }); } col.styleFilter = function () { return { "width": "100%", 'padding': 0 }; } } else if (col.name === "ManagerName") { col.allowHtml = true; col.filterCustom = true; col.filter = function (item) { return $('<span class="margin-span"></span>').text(item.ManagerName || ''); }; col.editFilter = function (item) { if (!item.IID) return $('<span class="margin-span"></span>').text(item.ManagerName || ''); var source = []; var selected; if (item.Managers) { for (var i = 0; i < item.Managers.length; i++) { var u = item.Managers[i]; source.push(u); if (item.ManagerIID.toLowerCase() == u.IID.toLowerCase()) selected = u.IID; } } else { source.push({ IID: '', DisplayName: ' ' }); } var selector = $('<div class="dropdown"></div>'); selector.dropdown(source, { search: true, textKey: 'DisplayName', valueKey: 'IID', selected: selected }).on('select', function (_e, s) { if (s) { item.ManagerIID = s.IID; item.ManagerName = s.DisplayName; updateUser(item); } }).on('expand', function () { if (!item.ManagerLoaded) { item.ManagerLoaded = true; _network.userquery("GetUsers", JSON.stringify([-1, ""]), function (data) { if (data && data.length > 0) { var source = [ { IID: '', DisplayName: ' ' } ]; var sel = null; var exists = false; var selected; if (item.Managers && item.Managers.length == 1) sel = item.Managers[0]; else exists = true; for (var i = 0; i < data.length; i++) { var u = data[i]; source.push(u); if (item.ManagerIID.toUpperCase() == u.IID.toUpperCase()) selected = u.IID; if (sel && sel.IID.toUpperCase() == u.IID.toUpperCase()) exists = true; } if (!exists) { source.push(sel); } item.Managers = data; var dropdown = selector.data('dropdown'); dropdown.setSource(source); if (selected != null) { dropdown.select(selected); } } }, function () { }); } }); return selector; } col.styleFilter = function () { return { "width": "100%", 'padding': 0 }; } } else if (col.name === "Notes") { col.allowHtml = true; col.filterCustom = true; col.filter = function (item) { return $('<div class="cell-flex">').append( $('<span style="flex: 0 0 auto; width: 26px"></span>'), $('<span class="cell-flex-memo"></span>').text(item.Notes || '') ); }; col.editFilter = function (item) { if (!item.IID) return $('<div class="cell-flex">').append( $('<span style="flex: 0 0 auto; width: 26px"></span>'), $('<span class="cell-flex-memo"></span>').text(item.Notes || '') ); var flex = $('<div class="cell-flex">'); var iconedit = $('<span class="spanbtn iconpen cell-flex-icon"></span>'); iconedit.click(function () { onEditText(item, function () { flex.children('.cell-flex-memo').text(item.Notes); }); }); flex.append( iconedit, $('<span class="cell-flex-memo"></span>').text(item.Notes) ); return flex; } } else if (col.name === "Edit") { col.isurl = true; col.text = "\uf044"; col.sortable = false; col.events = { onclick: function () { OnEdit(); } }; col.classFilter = function (e) { return "icon-col"; } col.attrs = { 'title': GetTextByKey("P_UM_EDIT", 'Edit') }; } else if (col.name === "Copy") { col.isurl = true; col.text = "\uf0c5"; col.sortable = false; col.events = { onclick: function () { OnCopy(this); } }; col.classFilter = function (e) { return "icon-col"; } col.attrs = { 'title': 'Copy' }; } else if (col.name === "Delete") { col.isurl = true; col.text = "\uf00d"; col.sortable = false; col.events = { onclick: function () { OnDelete(this); } }; col.classFilter = function (e) { return "icon-col"; }; col.styleFilter = function (e) { return { display: isMyself(e.IID) ? 'none' : '' }; }; col.attrs = { 'title': GetTextByKey("P_UM_DELETE", 'Delete') }; } else if (col.name === "AssetAssignment") { col.visible = !IsDealer; col.isurl = true; col.text = "\uf63c"; col.sortable = false; col.events = { onclick: function () { OnManageMachine(this); } }; col.classFilter = function (e) { return "icon-col"; }; col.attrs = { 'title': GetTextByKey("P_UM_ASSETSASSIGNMENT", 'Assets Assignment') }; } else if (col.name === "AssetGroupAssignment") { col.visible = !IsDealer; col.isurl = true; col.text = "\uf4dc"; col.sortable = false; col.events = { onclick: function () { OnManageMachineGroup(this); } }; col.classFilter = function (e) { return "icon-col"; }; col.attrs = { 'title': GetTextByKey("P_UM_ASSETGROUPSASSIGNMENT", 'Asset Groups Assignment') }; } else if (col.name === "AssetTypeAssignment") { col.visible = !IsDealer; col.isurl = true; col.text = "\uf00a"; col.sortable = false; col.events = { onclick: function () { OnManageAssetType(this); } }; col.classFilter = function (e) { return "icon-col"; }; col.attrs = { 'title': GetTextByKey("P_UM_ASSETTYPEASSIGNMENT", 'Asset Types Assignment') }; } else if (col.name === "JobsiteAssignment") { col.visible = !IsDealer; col.isurl = true; col.text = "\uf312"; col.sortable = false; col.events = { onclick: function () { OnManageJobsite(this); } }; col.classFilter = function (e) { return "icon-col"; }; col.attrs = { 'title': GetTextByKey("P_UM_JOBSITESASSIGNMENT", 'Jobsites Assignment') }; } else if (col.name === "ResetPassword") { col.isurl = true; col.text = "\uf084"; col.sortable = false; col.events = { onclick: function () { OnResetPassword(this); } }; col.classFilter = function (e) { return "icon-col"; }; col.styleFilter = function (e) { return { display: (!e.Active || isMyself(e.IID) || !e.IsUser.Value) ? 'none' : '' }; }; col.attrs = { 'title': GetTextByKey("P_UM_RESETPASSWORD", 'Reset Password') }; } columns.push(col); } grid_dt.canMultiSelect = false; //grid_dt.columns = columns; //grid_dt.init(); grid_dt.allcolumns = columns; getGridLayout(gridLayoutID, grid_dt, OnRefresh); //grid_dt.rowdblclick = OnEdit; grid_dt.celldblclick = function (rowindex, colindex) { if (colindex >= 0) { var col = grid_dt.columns[colindex]; //if (!col.allowHtml) // OnEdit(); if (col.name != "UserType" && col.name != "ManagerName" && col.name != "ContactTypeName") { OnEdit(); } } }; grid_dt.selectedrowchanged = function (rowindex) { var rowdata = grid_dt.source[rowindex]; if (rowdata) { uiid = rowdata.Values.IID; } } } function onEditText(user, next) { showmaskbg(true); $('#dialog_edittext .dialog-title span.title').text(GetTextByKey("P_WO_EDITNOTES", 'Edit Notes')); $('#dialog_text').val(user.Notes); $('#dialog_edittext').data('user', user).data('next', next) .css({ 'top': (document.documentElement.clientHeight - $('#dialog_edittext').height()) / 3, 'left': (document.documentElement.clientWidth - $('#dialog_edittext').width()) / 2 }).showDialogfixed(); } function SaveText() { var text = $('#dialog_text').val(); var user = $('#dialog_edittext').data("user"); var next = $('#dialog_edittext').data("next"); user.Notes = text; if (next) next(); $('#dialog_edittext').hideDialog(); showmaskbg(false); updateUser(user); } function updateUser(user) { var item = { 'IID': user.IID, 'ID': user.ID, 'DisplayName': user.DisplayName, 'UserType': user.UserType.Value, 'Active': user.Active.Value, 'IsUser': user.IsUser.Value, 'AssignedWorkOrders': user.AssignedWorkOrders.Value, 'TextAddress': user.TextAddress, 'Mobile': user.Mobile, 'BusinessPhone': user.BusinessPhone, 'ContactType': user.ContactType, 'FOB': user.FOB, 'ManagerIID': user.ManagerIID, 'EmailOptOut': user.EmailOptOut.Value, 'Notes': user.Notes }; var alerttitle = GetTextByKey("P_UM_XXXX", "Save user"); if (!item.DisplayName || item.DisplayName.trim().length == 0) { showAlert(GetTextByKey("P_UM_USERNAMECANNOTBEEMPTY", 'User name cannot be empty.'), alerttitle); return; } if (item.TextAddress !== "" && !isEmail(item.TextAddress)) { showAlert(GetTextByKey("P_UM_TEXTADDRESSISNOTAVALID", 'Text Address is not a valid.'), alerttitle); return; } var param = htmlencode(JSON.stringify(item)); _network.userquery('UpdateUser', param, function (data) { if (typeof (data) === "string") { showAlert(data, alerttitle); return; } //grid_dt.refresh(); }, function (err) { }); } $(function () { setPageTitle(GetTextByKey("P_USERMANAGEMENT", 'User Management'), true); $('.iconlayout').on('click', function (ev) { CreateLayoutMenus(ev.target, gridLayoutID, grid_dt); return false; }); InitGridData(); $('#dialog_machinegroup').prop('iframe', true).dialog(function () { showmaskbg(false); }); $('#dialog_managemahchine').dialog(function () { showmaskbg(false); }); $('#dialog_managejobsite').dialog(function () { showmaskbg(false); }); $('#dialog_manageassettype').dialog(function () { showmaskbg(false); }); $('#dialog_password').dialog(function () { showmaskbg(false); }); $('#dialog_user_randompass').change(function (e) { $('#dialog_user_password').prop('disabled', $(this).prop('checked')); $('#dialog_user_password1').prop('disabled', $(this).prop('checked')); }); $('#dialog_user_randompass1').change(function (e) { $('#dialog_user_password2').prop('disabled', $(this).prop('checked')); $('#dialog_user_password3').prop('disabled', $(this).prop('checked')); }); $('#dialog_import').dialog(function () { showmaskbg(false); }); $('#dialog_edittext').dialog(function () { showmaskbg(false); }); $('#dialog_copy_user').dialog(function () { $('#dialog_user_id').val(''); $('#dialog_user_name').val(''); $('#dialog_user_randompass1').prop('checked', false); $('#dialog_user_password2').prop('disabled', false); $('#dialog_user_password3').prop('disabled', false); $('#dialog_user_password2').val(''); $('#dialog_user_password3').val(''); $('#dialog_copyuser').dropdownVal('-1'); $('#dialog_user_mobile').val(''); $('#dialog_user_fob').val(''); showmaskbg(false); }); $('#searchinputtxt').keydown(searchEnter); $(window).resize(function () { $("#userlist").css("height", $(window).height() - $("#userlist").offset().top - 4); grid_dt && grid_dt.resize(); }).resize(); $('#dialog_copyuser').dropdown([{ ID: '', Name: ' ' }], { search: true, valueKey: 'ID', textKey: 'Name' }); if (!canExport) { $('#spExport').hide(); } }); function searchEnter(e) { if (e.keyCode == 13 || e.keyCode == 9) { OnRefresh(); } } function OnExport() { var searchtxt = ""; searchtxt = htmlencode($.trim($('#searchinputtxt').val())); var layout = getLayoutOnGrid(grid_dt); var ps = ["users", searchtxt, JSON.stringify(layout)]; var data = new FormData(); data.append('type', 'set'); data.append('ClientData', JSON.stringify(ps)); $.ajax({ url: "../ExportToFile.aspx", type: 'POST', dataType: 'json', processData: false, contentType: false, data: data, success: function (data) { if (data && data != "") window.open("../ExportToFile.aspx?type=exp&key=" + data); }, error: function (err) { } }); //window.open("../ExportToFile.aspx?type=users&t=" + searchtxt); } var columnsdata = [ { Id: "ID", Name: GetTextByKey("P_UM_USERIDOREMAIL", "User ID/Email") }, { Id: "DisplayName", Name: GetTextByKey("P_UM_USERNAME", "User Name") }, { Id: "Password", Name: GetTextByKey("P_UM_PASSWORD", "Password") }, { Id: "UserType", Name: GetTextByKey("P_UM_USERTYPE", "User Type") }, { Id: "TextAddress", Name: GetTextByKey("P_UM_TEXTADDRESS", "Text Address") }, { Id: "Mobile", Name: GetTextByKey("P_UM_MOBILE", "Mobile") }, { Id: "BusinessPhone", Name: GetTextByKey("P_UM_BUSINESSPHONE", "Business Phone") }, { Id: "IsUser", Name: GetTextByKey("P_UM_ISUSER", "Is User") }, { Id: "WebBrowserAccess", Name: GetTextByKey("P_UM_WEBBROWSERACCESS", "Web Browser Access") }, { Id: "Inspect", Name: GetTextByKey("P_UM_INSPECTACCESS", "Inspect Access") }, { Id: "FleetApp", Name: GetTextByKey("P_UM_MOBILEAPPACCESS", "Mobile App Access") }, { Id: "MobileApp", Name: GetTextByKey("P_UM_MOBILEAPPBARCODESCANNER", "Mobile App: Barcode Scanner") }, { Id: "ContactType", Name: GetTextByKey("P_UM_CONTACTTYPE", "Contact Type") }, { Id: "AssignedWorkOrders", Name: GetTextByKey("P_UM_ASSIGNEDWORKORDERS", "Assigned Work Orders") }, { Id: "OptOutOfEmail", Name: GetTextByKey("P_UM_OPTOUTOFFICOMMUNICATIONS", "Opt Out of FI Communications?") }, { Id: "InspectEmail", Name: GetTextByKey("P_UM_INSPECTEMAIL", "Inspect Email") }, { Id: "TeamIntelligenceUser", Name: GetTextByKey("P_UM_TEAMINTELLIGENCEUSER", "Team Intelligence User") }, { Id: "FOB", Name: GetTextByKey("P_UM_EMPLOYEEIDORFOB", "Employee ID or FOB") }, { Id: "LandingPage", Name: GetTextByKey("P_UM_LANDINGPAGE", "Landing Page") }, { Id: "Department", Name: GetTextByKey("P_UM_DEPARTMENT", "Department") }, { Id: "Location", Name: GetTextByKey("P_UM_LOCATION", "Location") }, { Id: "UserGroup", Name: GetTextByKey("P_UM_USERSGROUP", "User's Group") }, { Id: "WorkOrderFollower", Name: GetTextByKey("P_UM_XXX", "Work Order Follower") }, { Id: "PreferredLanguage", Name: GetTextByKey("P_UM_XXX", "Languages") }, { Id: "TimeZone", Name: GetTextByKey("P_UM_XXX", "Time Zone") }, { Id: "ExcelExports", Name: GetTextByKey("P_UM_XXX", "Excel Exports") }, //{ Id: "100", Name: "Jobsites", Type: 1 }, //{ Id: "110", Name: "Auto-Creation Config", Type: 1 }, //{ Id: "120", Name: "Jobsite Requirements", Type: 1 }, //{ Id: "130", Name: "Dispatch Requests", Type: 1 }, //{ Id: "140", Name: "Scheduler", Type: 1 }, //{ Id: "200", Name: "Alerts Management", Type: 1 }, //{ Id: "210", Name: "Work Order", Type: 1 }, //{ Id: "253", Name: "Open WO:restrict work order view", Type: 1 }, //{ Id: "254", Name: "Closed WO:restrict work order view", Type: 1 }, //{ Id: "252", Name: "Delete Attachments from Work Orders", Type: 1 }, //{ Id: "255", Name: "Closed Work Orders", Type: 1 }, //{ Id: "256", Name: "Delete and Restore Work Orders", Type: 1 }, //{ Id: "239", Name: "Reopen Work Orders", Type: 1 }, //{ Id: "220", Name: "Preventative Maintenance Plan", Type: 1 }, //{ Id: "240", Name: "Maintenance Record", Type: 1 }, //{ Id: "230", Name: "Fuel Records", Type: 1 }, //{ Id: "235", Name: "Customer Record", Type: 1 }, //{ Id: "237", Name: "Work Order Configuration", Type: 1 }, //{ Id: "245", Name: "Communicate with Customer", Type: 1 }, //{ Id: "248", Name: "Work Order Surveys", Type: 1 }, //{ Id: "249", Name: "Work Order Generator", Type: 1 }, //{ Id: "250", Name: "Work Order History", Type: 1 }, //{ Id: "300", Name: "FilterQ", Type: 1 }, //{ Id: "600", Name: "Manage Assets", Type: 1 }, //{ Id: "601", Name: "Asset Pairing", Type: 1 }, //{ Id: "602", Name: "Asset Attribute Adjustments", Type: 1 }, //{ Id: "800", Name: "M3", Type: 1 }, //{ Id: "900", Name: "Over/Under Trucking Alerts", Type: 1 }, //{ Id: "1000", Name: "Manage Harsh Driving", Type: 1 }, //{ Id: "1100", Name: "Manage Templates", Type: 1 }, //{ Id: "1101", Name: "Inspection Reports", Type: 1 }, //{ Id: "1110", Name: "(Re)Assign Work Orders", Type: 1 }, //{ Id: "10", Name: "Estimate Approval/Rejection", Type: 2 }, //{ Id: "20", Name: "Customer Communication", Type: 2 }, //{ Id: "30", Name: "Internal Messages", Type: 2 }, //{ Id: "40", Name: "Invoice Paid", Type: 2 }, //{ Id: "50", Name: "Inspection Completed", Type: 2 }, //{ Id: "60", Name: "Status Update", Type: 2 }, //{ Id: "70", Name: "Attachment Added", Type: 2 }, //{ Id: "80", Name: "Attachment Deleted", Type: 2 } ]; var isloadimportuserpermission = false; function getImportUserPermissionItems(excelcolumns) { if (isloadimportuserpermission) CreateImportColumns(excelcolumns); else { _network.userquery("GetImportUserPermissionItems", "", function (data) { isloadimportuserpermission = true; if (data && data.length > 0) { for (var i = 0; i < data.length; i++) { columnsdata.push(data[i]); } } CreateImportColumns(excelcolumns); }, function () { }); } } function OnImportChange(index) { if (parseInt(index) === 0) { $('#tb_import').show(); $('#tb_import_security').hide(); $('#tb_import_smsmsg').hide(); $('#a_importusers').hide(); $('#a_importsecurity').text('Map Additional Fields').show(); $('#a_importsmsmsg').hide(); } else if (parseInt(index) === 1) { $('#tb_import').hide(); $('#tb_import_security').show(); $('#tb_import_smsmsg').hide(); $('#a_importusers').show(); $('#a_importsecurity').hide(); $('#a_importsmsmsg').show(); } else if (parseInt(index) === 2) { $('#tb_import').hide(); $('#tb_import_security').hide(); $('#tb_import_smsmsg').show(); $('#a_importusers').show(); $('#a_importsecurity').text('Return to Security').show(); $('#a_importsmsmsg').hide(); } if (!WorkOrderLisence || !CustomerRecordLisence) { $('#a_importsmsmsg').hide(); $('#tb_import_smsmsg').hide(); } } function CreateImportColumns(excelcolumns) { var tb = $('#tb_import'); tb.empty(); var tb_security = $('#tb_import_security'); tb_security.empty(); var tb_smsmsg = $('#tb_import_smsmsg'); tb_smsmsg.empty(); $('#tb_import_security').append('<tr style="line-height:24px;background:rgb(232, 232, 232);"><td colspan="2" ><div>Security</div></td></tr>'); $('#tb_import_smsmsg').append('<tr style="line-height:24px;background:rgb(232, 232, 232);"><td colspan="2" ><div>SMS Messages</div></td></tr>'); //var columnsdata = getcolumnsdata(); for (var i = 0; i < columnsdata.length; i++) { var col = columnsdata[i]; var tr = $('<tr></tr>'); if (col.Type == 1) { tb_security.append(tr); } else if (col.Type == 2) { tb_smsmsg.append(tr); } else { tb.append(tr); } var td = $('<td class="label" style="width:195px;">' + col.Name + '</td>'); tr.append(td); td = $('<td></td>'); tr.append(td); var sel = CreateSelect(excelcolumns, col.Id, col.Name); td.append(sel); } } function CreateSelect(excelcolumns, colid, colname) { var sel = $('<select style="width:180px;" name="sel_import"></select>').data('id', colid); sel.append('<option></option>'); if (excelcolumns && excelcolumns.length > 0) { for (var i = 0; i < excelcolumns.length; i++) { var op = $('<option></option>').text(excelcolumns[i]).val(excelcolumns[i]); sel.append(op); } sel.val(colname); } return sel; } function getcolumnsdata() {//Type:0.User Fields; 1.Security; 2.SMS Messages var columnsdata = [ { Id: "ID", Name: GetTextByKey("P_UM_USERIDOREMAIL", "User ID/Email") }, { Id: "DisplayName", Name: GetTextByKey("P_UM_USERNAME", "User Name") }, { Id: "Password", Name: GetTextByKey("P_UM_PASSWORD", "Password") }, { Id: "UserType", Name: GetTextByKey("P_UM_USERTYPE", "User Type") }, { Id: "TextAddress", Name: GetTextByKey("P_UM_TEXTADDRESS", "Text Address") }, { Id: "Mobile", Name: GetTextByKey("P_UM_MOBILE", "Mobile") }, { Id: "BusinessPhone", Name: GetTextByKey("P_UM_BUSINESSPHONE", "Business Phone") }, { Id: "IsUser", Name: GetTextByKey("P_UM_ISUSER", "Is User") }, { Id: "WebBrowserAccess", Name: GetTextByKey("P_UM_WEBBROWSERACCESS", "Web Browser Access") }, { Id: "Inspect", Name: GetTextByKey("P_UM_INSPECTACCESS", "Inspect Access") }, { Id: "FleetApp", Name: GetTextByKey("P_UM_MOBILEAPPACCESS", "Mobile App Access") }, { Id: "MobileApp", Name: GetTextByKey("P_UM_MOBILEAPPBARCODESCANNER", "Mobile App: Barcode Scanner") }, { Id: "ContactType", Name: GetTextByKey("P_UM_CONTACTTYPE", "Contact Type") }, { Id: "AssignedWorkOrders", Name: GetTextByKey("P_UM_ASSIGNEDWORKORDERS", "Assigned Work Orders") }, { Id: "OptOutOfEmail", Name: GetTextByKey("P_UM_OPTOUTOFFICOMMUNICATIONS", "Opt Out of FI Communications?") }, { Id: "InspectEmail", Name: GetTextByKey("P_UM_INSPECTEMAIL", "Inspect Email") }, { Id: "TeamIntelligenceUser", Name: GetTextByKey("P_UM_TEAMINTELLIGENCEUSER", "Team Intelligence User") }, { Id: "FOB", Name: GetTextByKey("P_UM_EMPLOYEEIDORFOB", "Employee ID or FOB") }, { Id: "LandingPage", Name: GetTextByKey("P_UM_LANDINGPAGE", "Landing Page") }, { Id: "Department", Name: GetTextByKey("P_UM_DEPARTMENT", "Department") }, { Id: "Location", Name: GetTextByKey("P_UM_LOCATION", "Location") }, { Id: "UserGroup", Name: GetTextByKey("P_UM_USERSGROUP", "User's Group") }, { Id: "WorkOrderFollower", Name: GetTextByKey("P_UM_XXX", "Work Order Follower") }, { Id: "PreferredLanguage", Name: GetTextByKey("P_UM_XXX", "Languages") }, { Id: "TimeZone", Name: GetTextByKey("P_UM_XXX", "Time Zone") }, { Id: "ExcelExports", Name: GetTextByKey("P_UM_XXX", "Excel Exports") }, //{ Id: "100", Name: "Jobsites", Type: 1 }, //{ Id: "110", Name: "Auto-Creation Config", Type: 1 }, //{ Id: "120", Name: "Jobsite Requirements", Type: 1 }, //{ Id: "130", Name: "Dispatch Requests", Type: 1 }, //{ Id: "140", Name: "Scheduler", Type: 1 }, //{ Id: "200", Name: "Alerts Management", Type: 1 }, //{ Id: "210", Name: "Work Order", Type: 1 }, //{ Id: "253", Name: "Open WO:restrict work order view", Type: 1 }, //{ Id: "254", Name: "Closed WO:restrict work order view", Type: 1 }, //{ Id: "252", Name: "Delete Attachments from Work Orders", Type: 1 }, //{ Id: "255", Name: "Closed Work Orders", Type: 1 }, //{ Id: "256", Name: "Delete and Restore Work Orders", Type: 1 }, //{ Id: "239", Name: "Reopen Work Orders", Type: 1 }, //{ Id: "220", Name: "Preventative Maintenance Plan", Type: 1 }, //{ Id: "240", Name: "Maintenance Record", Type: 1 }, //{ Id: "230", Name: "Fuel Records", Type: 1 }, //{ Id: "235", Name: "Customer Record", Type: 1 }, //{ Id: "237", Name: "Work Order Configuration", Type: 1 }, //{ Id: "245", Name: "Communicate with Customer", Type: 1 }, //{ Id: "248", Name: "Work Order Surveys", Type: 1 }, //{ Id: "249", Name: "Work Order Generator", Type: 1 }, //{ Id: "250", Name: "Work Order History", Type: 1 }, //{ Id: "300", Name: "FilterQ", Type: 1 }, //{ Id: "600", Name: "Manage Assets", Type: 1 }, //{ Id: "601", Name: "Asset Pairing", Type: 1 }, //{ Id: "602", Name: "Asset Attribute Adjustments", Type: 1 }, //{ Id: "800", Name: "M3", Type: 1 }, //{ Id: "900", Name: "Over/Under Trucking Alerts", Type: 1 }, //{ Id: "1000", Name: "Manage Harsh Driving", Type: 1 }, //{ Id: "1100", Name: "Manage Templates", Type: 1 }, //{ Id: "1101", Name: "Inspection Reports", Type: 1 }, //{ Id: "1110", Name: "(Re)Assign Work Orders", Type: 1 }, //{ Id: "10", Name: "Estimate Approval/Rejection", Type: 2 }, //{ Id: "20", Name: "Customer Communication", Type: 2 }, //{ Id: "30", Name: "Internal Messages", Type: 2 }, //{ Id: "40", Name: "Invoice Paid", Type: 2 }, //{ Id: "50", Name: "Inspection Completed", Type: 2 }, //{ Id: "60", Name: "Status Update", Type: 2 }, //{ Id: "70", Name: "Attachment Added", Type: 2 }, //{ Id: "80", Name: "Attachment Deleted", Type: 2 } ]; return columnsdata; } var importing = false; function OnImportUsers() { if (!fildata) return; if (importing) return; importing = true; var item = []; var sels = $("select[name='sel_import']"); for (var i = 0; i < sels.length; i++) { var sel = sels[i]; var kv = { Key: $(sel).data('id'), Value: $(sel).val() }; item.push(kv); } var param = JSON.stringify(item); param = htmlencode(param); var formData = new FormData(); formData.append("iconFile", fildata); formData.append("MethodName", "ImportUsers"); formData.append("ClientData", param); showloading(true); $.ajax({ url: 'UserManage.aspx', type: 'POST', dataType: 'json', processData: false, contentType: false, data: formData, async: true, success: function (data) { importing = false; if (typeof (data) === "string") { showAlert(data, GetTextByKey("P_JS_IMPORT", 'Import')); } else { showAlert(data + GetTextByKey("P_UM_USERSIMPORTEDSUCCESSFULLY", ' user(s) imported successfully.'), GetTextByKey("P_UM_IMPORT", 'Import Users')); $('#dialog_import').hideDialog(); if (data > 0) OnRefresh(); } showloading(false); }, error: function (err) { importing = false; showloading(false); showAlert(err.statusText, GetTextByKey("P_JS_IMPORT", 'Import')); } }); } var fildata; function OnImport() { OnImportChange(0); var file = $('<input type="file" style="display: none;" accept=".xlsx" />'); file.change(function () { fildata = this.files[0]; var formData = new FormData(); formData.append("iconFile", fildata); formData.append("MethodName", "GetImportUserColumns"); formData.append("ClientData", ''); showloading(true); $.ajax({ url: 'UserManage.aspx', type: 'POST', dataType: 'json', processData: false, contentType: false, data: formData, async: true, success: function (data) { showloading(false); if (typeof (data) === "string") { showAlert(data, GetTextByKey("P_JS_IMPORT", 'Import')); } else { getImportUserPermissionItems(data); //CreateImportColumns(data); $('#dialog_import') .attr('act', 'add') .css({ 'top': (document.documentElement.clientHeight - $('#dialog_import').height()) / 3, 'left': (document.documentElement.clientWidth - $('#dialog_import').width()) / 2 }) .showDialogfixed(); } }, error: function (err) { showloading(false); showAlert(err.statusText, GetTextByKey("P_JS_IMPORT", 'Import')); } }); }).click(); } function OnCopy(v) { if (v) { isSelect = true; copyuseriid = v.IID; $('#mask_bg').show(); $('#tr_copyuser').hide(); $('#dialog_copy_user') .css({ 'top': (document.documentElement.clientHeight - $('#dialog_copy_user').height()) / 3, 'left': (document.documentElement.clientWidth - $('#dialog_copy_user').width()) / 2 }) .showDialogfixed(); } else { isSelect = false; $('#mask_bg').show(); $('#tr_copyuser').show(); var source = []; if (isalluser) { if (users != null && users.length > 0) { for (var i = 0; i < users.length; i++) { var u = { ID: users[i].IID, Name: users[i].ID }; source.push(u); } } $('#dialog_copyuser').dropdownSource(source); $('#dialog_copy_user') .css({ 'top': (document.documentElement.clientHeight - $('#dialog_copy_user').height()) / 3, 'left': (document.documentElement.clientWidth - $('#dialog_copy_user').width()) / 2 }) .showDialogfixed(); } else { _network.userquery('GetUsers', JSON.stringify([-1, ""]), function (data) { var allusers = data; if (allusers != null && allusers.length > 0) { for (var i = 0; i < allusers.length; i++) { var u = { ID: allusers[i].IID, Name: allusers[i].ID }; source.push(u); } } $('#dialog_copyuser').dropdownSource(source); $('#dialog_copy_user') .css({ 'top': (document.documentElement.clientHeight - $('#dialog_copy_user').height()) / 3, 'left': (document.documentElement.clientWidth - $('#dialog_copy_user').width()) / 2 }) .showDialogfixed(); }, function (err) { $('#dialog_copyuser').dropdownSource([]); }); } } } var isalluser = false; var isSelect = false; var copyuseriid = ''; var newuseriid = ''; var incopy = false; function OnCopyUser() { if (incopy) { return; } incopy = true; var userID = $('#dialog_user_id').val(); var name = $('#dialog_user_name').val(); var mobile = $('#dialog_user_mobile').val(); var fob = $('#dialog_user_fob').val(); var pwd = $('#dialog_user_password2').val(); var title = GetTextByKey("P_UM_COPYUSER", 'Copy User'); if (!userID || userID.trim().length == 0) { showAlert(GetTextByKey("P_UM_USERIDOREMAILCANNOTBEEMPTY", 'User ID/Email cannot be empty.'), title, undefined, function () { $('#dialog_user_id').focus(); }); incopy = false; return; } if (!isEmail(userID)) { showAlert(GetTextByKey("P_UM_USERIDOREMAILISNOTAVALIDEMAILADDRESS", 'User ID/Email is not a valid email address.'), title, undefined, function () { $('#dialog_user_id').focus(); }); incopy = false; return; } if (!name || name.trim().length == 0) { showAlert(GetTextByKey("P_UM_USERNAMECANNOTBEEMPTY", 'User name cannot be empty.'), title, undefined, function () { $('#dialog_user_name').focus(); }); incopy = false; return; } if (!$('#dialog_user_randompass1').prop('checked')) { if (pwd.length < 8) { showAlert(GetTextByKey("P_UM_PASSWORDTIPS", 'The password must have at least 8 characters.'), title, undefined, function () { $('#dialog_user_password2').focus(); }); incopy = false; return; } if (getStrength(pwd) < 2) { showAlert(GetTextByKey("P_UM_PASSWORDTIPS1", 'The password must contain both uppercase and lowercase characters and at lease one number.'), title, undefined, function () { $('#dialog_user_password2').focus(); }); incopy = false; return; } var pass2 = $('#dialog_user_password3').val(); if (pwd !== pass2) { showAlert(GetTextByKey("P_UM_PASSWORDTIPS2", 'The two passwords are different. Please reenter.'), title, undefined, function () { $('#dialog_user_password3').focus(); }); incopy = false; return; } } else { pwd = ""; } if (!isSelect) { var tmp = $('#dialog_copyuser').dropdownVal(); if (tmp !== undefined) { copyuseriid = tmp; } else { var s = GetTextByKey("P_MA_NOTBEEMPTY", "{0} cannot be empty.").replace('{0}', title); showAlert(s, title); incopy = false; return; } } var formData = new FormData(); formData.append("MethodName", "CopyUserByIID"); formData.append("CopyUserIID", copyuseriid); formData.append("UserID", userID); formData.append("UserName", name); formData.append("PWD", pwd); formData.append("Mobile", mobile); formData.append("FOB", fob); showloading(true); $.ajax({ url: 'UserManage.aspx', type: 'POST', dataType: 'json', processData: false, contentType: false, data: formData, async: true, success: function (data) { showloading(false); incopy = false; if (typeof (data) === "string" && data.indexOf("@error@") >= 0) { var msg = data.replace("@error@", ""); showAlert(msg, title); } else { $('#dialog_user_id').val(''); $('#dialog_user_name').val(''); $('#dialog_user_randompass1').prop('checked', false); $('#dialog_user_password2').prop('disabled', false); $('#dialog_user_password3').prop('disabled', false); $('#dialog_user_password2').val(''); $('#dialog_user_password3').val(''); $('#dialog_copyuser').dropdownVal('-1'); $('#dialog_copy_user').hideDialog(); $('#dialog_user_mobile').val(''); $('#dialog_user_fob').val(''); newuseriid = data; OnRefresh(); } }, error: function (err) { showloading(false); showAlert(err.statusText, title); } }); } function OnResetPivots() { if (grid_dt && grid_dt.columns) { for (var i = 0; i < grid_dt.columns.length; i++) { if (grid_dt.columns[i].filterValues) grid_dt.columns[i].filterValues = null; } grid_dt.refreshGrid(); } } </script> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <div style="min-width: 400px;"> <div class="page_title" data-lgid="P_USERMANAGEMENT">User Management</div> <div class="search_bar"> <input type="password" autocomplete="new-password" style="display: none" /> <input type="text" id="searchinputtxt" autocomplete="off" /> <input class="search" type="button" onclick="OnRefresh();" value="Search" data-lgid="P_CM_SEARCH" style="margin-left: 5px;" /> <select id="selactive" onchange="OnRefresh();" style="width: 180px; margin-left: 10px;"> <option value="1" data-lgid="P_UM_XXXXXX">Active Users Only</option> <option value="0" data-lgid="P_UM_XXXXXX">Inactive Users Only</option> <option value="-1" data-lgid="P_UM_XXXXXX">Both Active and Inactive Users</option> </select> </div> <div class="function_title"> <span class="sbutton iconadd" onclick="OnAdd();" data-lgid="P_UM_ADD">Add</span> <span class="sbutton iconedit" onclick="OnEdit();" data-lgid="P_UM_EDIT">Edit</span> <span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_UM_REFRESH">Refresh</span> <span id="spExport" class="sbutton iconexport" onclick="OnExport();" data-lgid="P_MR_EXPORTTOEXCEL">Export to Excel</span> <span class="sbutton iconimport" onclick="OnImport();" data-lgid="P_JS_IMPORT">Import</span> <span class="sbutton iconcopy" onclick="OnCopy();" data-lgid="P_UM_COPYUSER">Copy User</span> <span class="sbutton iconlayout iconmenu" data-lgid="P_MR_LAYOUT">Layout</span> <span class="sbutton iconfilter" onclick="OnResetPivots();" data-lgid="P_JS_XXX">Reset Pivots</span> </div> <div class="clear"></div> <div id="userlist"></div> <div id="mask_bg" style="display: none;"> <div class="loading c-spin"></div> </div> <div class="dialog" id="dialog_managemahchine" style="display: none;"> <div id="dialogmask" class="maskbg" style="display: none;"> <div class="loading_icon icon c-spin"></div> </div> <div class="dialog-title"><span class="title" data-lgid="P_UM_ASSETASSIGNMENT">Asset Assignment</span><em class="dialog-close"></em></div> <div class="machine_filter" style="display: none"> <span data-lgid="P_UM_TYPE_COLON">Type: </span> <select id="sel_machine_type" tabindex="20"></select> <input type="text" id="txt_machine_key" tabindex="21" /> <input type="button" class="ybutton" id="button_machine_filter" value="Filter" data-lgid="P_UM_FILTER" tabindex="22" /> <span id="span_text_holder" style="display: none;"></span> </div> <div class="machine_filter" style="margin: 9px 6px 5px"> <span class="sbutton iconadd" onclick="OnMachineAdd()" data-lgid="P_UM_ADD">Add</span> <span class="sbutton icondelete" onclick="OnMachineDelete()" data-lgid="P_UM_DELETE">Delete</span> </div> <div class="div_machines"> <table class="table_holder"> <thead> <tr style="display: none"> <td data-lgid="P_UM_AVAILABLEASSETS">Available Assets</td> <td></td> <td><span data-lgid="P_UM_ASSIGNEDASSETS">Assigned Assets</span> <input type="checkbox" id="chk_showallassignedassets" title="When checked, all associated or linked items will display regardless of filter. " /><label for="chk_showallassignedassets">Show All Assigned</label> </td> </tr> </thead> <tbody> <tr> <td style="display: none"> <div id="availablemachinelist" style="height: 400px; width: 540px;"></div> </td> <td class="td_controller" style="display: none"> <input class="ctl_button" type="button" value="" onclick="OnEditorAdd();" tabindex="23" /> <input class="ctl_button" type="button" value="" onclick="OnEditorAddAll();" tabindex="24" /> <input class="ctl_button" type="button" value="" onclick="OnEditorRemove();" tabindex="25" /> <input class="ctl_button" type="button" value="" onclick="OnEditorRemoveAll();" tabindex="26" /> </td> <td style="padding: 2px 4px 4px"> <div id="selectedmachinelist" style="height: 500px; width: 780px;"></div> </td> </tr> </tbody> </table> </div> <div class="dialog-func"> <input type="button" value="Close" data-lgid="P_UM_CLOSE" class="dialog-close" tabindex="28" /> <input type="button" onclick="OnSaveMachines();" value="OK" data-lgid="P_UM_OK" tabindex="27" style="display: none" /> <div class="clear"></div> </div> </div> <div class="dialog" id="dialog_user" style="display: none; height: 100%; border-bottom: 0; border-top: 0;"> <iframe id="iframeuser" src="AddUser.aspx" style="width: 100%; height: 100%; display: block; border: none;"></iframe> <div class="maskbg" style="display: none;"></div> </div> <div class="dialog" id="dialog_machinegroup" style="display: none;"> <div class="dialog-title"><span class="title" data-lgid="P_UM_MANAGEASSETGROUPS">Manage Asset Groups</span><em class="dialog-close"></em></div> <div> <table> <thead> <tr> <td data-lgid="P_UM_AVAILABLEASSETGROUPS">Available Asset Groups</td> <td></td> <td data-lgid="P_UM_ASSIGNEDASSETGROUPS">Assigned Asset Groups</td> </tr> </thead> <tbody> <tr> <td> <div id="availableassetgrouplist" style="height: 400px; width: 380px;"></div> </td> <td class="td_controller"> <input class="ctl_button" type="button" value="" onclick="OnAssetGroupEditorAdd();" tabindex="23" /> <input class="ctl_button" type="button" value="" onclick="OnAssetGroupEditorAddAll();" tabindex="24" /> <input class="ctl_button" type="button" value="" onclick="OnAssetGroupEditorRemove();" tabindex="25" /> <input class="ctl_button" type="button" value="" onclick="OnAssetGroupEditorRemoveAll();" tabindex="26" /> </td> <td> <div id="selectedassetgrouplist" style="height: 400px; width: 380px;"></div> </td> </tr> </tbody> </table> </div> <div class="dialog-func"> <input type="button" value="Cancel" data-lgid="P_UM_CANCEL" class="dialog-close" tabindex="18" /> <input type="button" onclick="OnSaveUserMG();" value="OK" data-lgid="P_UM_OK" tabindex="17" /> <div class="clear"></div> </div> <div class="maskbg" style="display: none;"></div> </div> <div class="dialog" id="dialog_managejobsite" style="display: none;"> <div class="dialog-title"><span class="title" data-lgid="P_UM_JOBSITEASSIGNMENT">Jobsite Assignment</span><em class="dialog-close"></em></div> <div class="machine_filter" style="margin: 9px 6px 5px"> <input type="text" id="txt_jobsite_key" style="margin-left: 8px; width: 280px;" tabindex="40" /> <input type="button" class="ybutton" id="button_jobsite_filter" value="Filter" data-lgid="P_UM_FILTER" tabindex="42" /> </div> <div class="div_machines"> <table class="table_holder"> <thead> <tr> <td data-lgid="P_UM_AVAILABLEJOBSITES">Available Jobsites</td> <td></td> <td><span data-lgid="P_UM_ASSIGNEDJOBSITES">Assigned Jobsites </span> <input type="checkbox" id="chk_showallassignedjobsites" title="When checked, all associated or linked items will display regardless of filter. " /><label for="chk_showallassignedjobsites">Show All Assigned</label> </td> </tr> </thead> <tbody> <tr> <td> <div id="availablejobsitelist" style="height: 400px; width: 410px;"></div> </td> <td class="td_controller"> <input class="ctl_button" type="button" value="" onclick="OnJobsiteEditorAdd();" tabindex="42" /> <input class="ctl_button" type="button" value="" onclick="OnJobsiteEditorAddAll();" tabindex="43" /> <input class="ctl_button" type="button" value="" onclick="OnJobsiteEditorRemove();" tabindex="44" /> <input class="ctl_button" type="button" value="" onclick="OnJobsiteEditorRemoveAll();" tabindex="45" /> </td> <td> <div id="selectedjobsitelist" style="height: 400px; width: 410px;"></div> </td> </tr> </tbody> </table> </div> <div class="dialog-func"> <input type="button" value="Cancel" data-lgid="P_UM_CANCEL" class="dialog-close" tabindex="47" /> <input type="button" onclick="OnSaveJobsites();" value="OK" data-lgid="P_UM_OK" tabindex="46" /> <div class="clear"></div> </div> <div id="jobsitedialogmask" class="maskbg" style="display: none;"> <div class="loading_icon icon c-spin"></div> </div> </div> <div class="dialog" id="dialog_manageassettype" style="display: none;"> <div class="dialog-title"><span class="title" data-lgid="P_UM_ASSETTYPEASSIGNMENT">Asset Type Assignment</span><em class="dialog-close"></em></div> <div class="machine_filter" style="margin: 9px 6px 5px"> <input type="text" id="txt_assettype_key" style="margin-left: 8px; width: 280px;" tabindex="40" /> <input type="button" class="ybutton" id="button_assettype_filter" value="Filter" data-lgid="P_UM_FILTER" tabindex="42" /> </div> <div class="div_machines"> <table class="table_holder"> <thead> <tr> <td data-lgid="P_UM_AVAILABLEASSETTYPES">Available Asset Types</td> <td></td> <td><span data-lgid="P_UM_ASSIGNEDASSETTYPES">Assigned Asset Types</span> <input type="checkbox" id="chk_showallassignedassettypes" title="When checked, all associated or linked items will display regardless of filter. " /><label for="chk_showallassignedassettypes">Show All Assigned</label> </td> </tr> </thead> <tbody> <tr> <td> <div id="availableassettypelist" style="height: 400px; width: 410px;"></div> </td> <td class="td_controller"> <input class="ctl_button" type="button" value="" onclick="OnAssetTypeEditorAdd();" tabindex="42" /> <input class="ctl_button" type="button" value="" onclick="OnAssetTypeEditorAddAll();" tabindex="43" /> <input class="ctl_button" type="button" value="" onclick="OnAssetTypeEditorRemove();" tabindex="44" /> <input class="ctl_button" type="button" value="" onclick="OnAssetTypeEditorRemoveAll();" tabindex="45" /> </td> <td> <div id="selectedassettypelist" style="height: 400px; width: 410px;"></div> </td> </tr> </tbody> </table> </div> <div class="dialog-func"> <input type="button" value="Cancel" data-lgid="P_UM_CANCEL" class="dialog-close" tabindex="47" /> <input type="button" onclick="OnSaveAssetTypes();" value="OK" data-lgid="P_UM_OK" tabindex="46" /> <div class="clear"></div> </div> <div id="assettypedialogmask" class="maskbg" style="display: none;"> <div class="loading_icon icon c-spin"></div> </div> </div> <div class="dialog" id="dialog_password" style="display: none;"> <div class="dialog-title"><span class="title" data-lgid="P_UM_RESETPASSWORD">Reset Password</span><em class="dialog-close"></em></div> <div class="dialog-content"> <table style="line-height: 30px;"> <tr> <td style="width: 100px;"></td> <td> <input type="checkbox" id="dialog_user_randompass" tabindex="1" style="width: auto; height: 13px; margin-left: 0; margin-top: -2px; margin-bottom: 1px; vertical-align: middle;" /> <label for="dialog_user_randompass" data-lgid="P_UM_RANDOMPASSWORD">Random password</label></td> </tr> <tr> <td class="label" style="width: 100px;" data-lgid="P_UM_PASSWORD_COLON">Password:</td> <td> <input type="password" id="dialog_user_password" tabindex="2" maxlength="20" /> </td> </tr> <tr> <td class="label" style="width: 100px;" data-lgid="P_UM_CONFIRMPASSWORD_COLON">Confirm Password:</td> <td> <input type="password" id="dialog_user_password1" tabindex="3" maxlength="20" /></td> </tr> </table> </div> <div class="dialog-func"> <input type="button" value="Cancel" data-lgid="P_UM_CANCEL" class="dialog-close" tabindex="5" /> <input type="button" onclick="ResetPassword();" value="OK" data-lgid="P_UM_OK" tabindex="4" /> <div class="clear"></div> </div> </div> <div class="dialog" id="dialog_import" style="display: none;"> <div class="dialog-title"><span class="title" data-lgid="P_UM_IMPORTUSESFIELDMAPPING"></span><em class="dialog-close"></em></div> <div class="machine_filter" style="margin: 9px 6px 7px; display: none;"> <span class="sbutton iconimport" onclick="OnImport()" data-lgid="P_JS_IMPORT">Add</span> </div> <div class="dialog-content adjust-content" style="height: 400px; overflow: auto; padding: 6px 10px 0px 10px;"> <table id="tb_import" class="table_holder"> </table> <table id="tb_import_security" class="table_holder"> </table> <table id="tb_import_smsmsg" class="table_holder"> </table> </div> <div class="dialog-func"> <div style="line-height: 30px; text-align: right;"> <a id="a_importusers" href="#" onclick="OnImportChange(0)" data-lgid="P_UM_XXXX" style="display: none; padding-right: 20px;">Return to User Fields</a> <a id="a_importsecurity" href="#" onclick="OnImportChange(1)" data-lgid="P_UM_XXXX" style="padding-right: 20px;">Map Additional Fields</a> <a id="a_importsmsmsg" href="#" onclick="OnImportChange(2)" data-lgid="P_UM_XXXX" style="padding-right: 20px; display: none;">Next</a> </div> <div> <input type="button" value="Close" data-lgid="P_JS_CANCEL" class="dialog-close" tabindex="28" /> <input type="button" onclick="OnImportUsers();" value="OK" tabindex="27" /> <div class="clear"></div> </div> </div> </div> <div class="dialog" id="dialog_copy_user" style="display: none;"> <div class="dialog-title"><span class="title" data-lgid="P_UM_COPYUSER">Copy User</span><em class="dialog-close"></em></div> <div class="dialog-content adjust-content" style="min-height: 50px;"> <table style="line-height: 30px;"> <tr> <td class="label" style="width: 100px;" data-lgid="P_UM_USERIDOREMAIL_COLON">User ID/Email:</td> <td style="width: 220px;"> <input type="text" id="dialog_user_id" tabindex="1" maxlength="200" autocomplete="off" /></td> </tr> <tr> <td class="label" data-lgid="P_UM_USERNAME_COLON">User Name:</td> <td> <input type="text" id="dialog_user_name" tabindex="2" maxlength="200" autocomplete="off" /></td> </tr> <tr> <td class="label" data-lgid="P_UM_MOBILE_COLON">Mobile:</td> <td> <input type="text" id="dialog_user_mobile" tabindex="2" maxlength="50" autocomplete="off" /></td> </tr> <tr> <td class="label" data-lgid="P_UM_EMPLOYEEIDORFOB_COLON">Employee ID or FOB:</td> <td> <input type="text" id="dialog_user_fob" tabindex="2" maxlength="50" autocomplete="off" /></td> </tr> <tr> <td style="width: 100px;"></td> <td> <input type="checkbox" id="dialog_user_randompass1" tabindex="3" style="width: auto; height: 13px; margin-left: 0; margin-top: -2px; margin-bottom: 1px; vertical-align: middle;" /> <label for="dialog_user_randompass1" data-lgid="P_UM_RANDOMPASSWORD">Random password</label></td> </tr> <tr> <td class="label" data-lgid="P_UM_PASSWORD_COLON">Password:</td> <td> <input type="password" id="dialog_user_password2" style="width: 200px;" tabindex="4" maxlength="20" autocomplete="off" /> </td> <td></td> </tr> <tr> <td class="label" data-lgid="P_UM_CONFIRMPASSWORD_COLON">Confirm Password:</td> <td> <input type="password" id="dialog_user_password3" style="width: 200px;" tabindex="5" maxlength="20" autocomplete="off" /></td> <td></td> </tr> <tr id="tr_copyuser"> <td class="label" data-lgid="P_UM_COPYUSER_COLON">Copy User:</td> <td> <div id="dialog_copyuser" tabindex="6" style="width: 204px"></div> </td> <td></td> </tr> </table> </div> <div class="dialog-func"> <input type="button" value="Close" data-lgid="P_JS_CANCEL" class="dialog-close" tabindex="8" /> <input type="button" onclick="OnCopyUser();" value="OK" tabindex="7" /> <div class="clear"></div> </div> </div> <div class="dialog" id="dialog_edittext" style="display: none;"> <div class="dialog-title"><span class="title" data-lgid="P_WO_EDITNOTES">Edit Notes</span><em class="dialog-close"></em></div> <div class="dialog-content"> <table style="line-height: 30px;"> <tr> <td> <textarea id="dialog_text" tabindex="1" style="width: 480px; height: 200px; margin-top: 6px;" maxlength="2000"></textarea></td> </tr> </table> </div> <div class="dialog-func"> <input type="button" value="Cancel" data-lgid="P_WO_CANCEL" class="dialog-close" tabindex="18" /> <input type="button" onclick="SaveText();" value="Save" data-lgid="P_WO_SAVE" tabindex="17" /> <div class="clear"></div> </div> </div> </div> </asp:Content>