add site
1144
Site/MachineDeviceManagement/AddDevice.aspx
Normal file
84
Site/MachineDeviceManagement/AddDevice.aspx.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor;
|
||||
using IronIntel.Contractor.Site;
|
||||
using IronIntel.Contractor.Site.Asset;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class AddDevice : MachineDeviceBasePage
|
||||
{
|
||||
|
||||
public bool IsDealer = SystemParams.IsDealer;
|
||||
public string ContractorID = "";
|
||||
public string MachineID = "";
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!CheckLoginSession())
|
||||
{
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
string methodName = Request.Form["MethodName"];
|
||||
if (!string.IsNullOrEmpty(methodName))
|
||||
{
|
||||
ProcessRequest(methodName);
|
||||
}
|
||||
else if (!IsPostBack)
|
||||
{
|
||||
this.Title = PageTitle;
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
if (!permission)
|
||||
RedirectToLoginPage();
|
||||
|
||||
ContractorID = Request.Params["cid"];
|
||||
MachineID = Request.Params["mid"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var user = GetCurrentUser();
|
||||
return user != null && user.UserType >= IronIntel.Contractor.Users.UserTypes.Common;
|
||||
}
|
||||
|
||||
public bool IsAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public bool IsSupperAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
return user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin;
|
||||
}
|
||||
}
|
||||
}
|
2927
Site/MachineDeviceManagement/AddMachine.aspx
Normal file
89
Site/MachineDeviceManagement/AddMachine.aspx.cs
Normal file
@ -0,0 +1,89 @@
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor;
|
||||
using IronIntel.Contractor.Site;
|
||||
using IronIntel.Contractor.Site.Asset;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class AddMachine : AssetBasePage
|
||||
{
|
||||
public string CurrentDate = "";
|
||||
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
|
||||
public string ContractorID = "";
|
||||
public string MachineID = "";
|
||||
public bool CanModifyVIN = SystemParams.HasLicense("VINSNModification");
|
||||
public bool IsReadOnly = false;
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
string methodName = Request.Form["MethodName"];
|
||||
if (!string.IsNullOrEmpty(methodName))
|
||||
{
|
||||
ProcessRequest(methodName);
|
||||
}
|
||||
else if (!IsPostBack)
|
||||
{
|
||||
if (!CheckLoginSession())
|
||||
{
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Title = PageTitle;
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
if (!permission)
|
||||
RedirectToLoginPage();
|
||||
|
||||
IsReadOnly = CheckReadonly(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
ContractorID = Request.Params["cid"];
|
||||
MachineID = Request.Params["mid"];
|
||||
}
|
||||
}
|
||||
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
|
||||
CurrentDate = userlocaldate.ToShortDateString();
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var user = GetCurrentUser();
|
||||
return user != null && user.UserType >= IronIntel.Contractor.Users.UserTypes.Common;
|
||||
}
|
||||
|
||||
public bool IsAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public bool IsSupperAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
return user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin;
|
||||
}
|
||||
}
|
||||
}
|
674
Site/MachineDeviceManagement/AddMachineGroup.aspx
Normal file
@ -0,0 +1,674 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/MachineDeviceManagement/DeviceManagementBase.master" AutoEventWireup="true" CodeFile="AddMachineGroup.aspx.cs" Inherits="AddMachineGroup" %>
|
||||
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
|
||||
<link href="<%=GetFileUrlWithVersion("../css/tabcontrol.css")%>" rel="stylesheet" />
|
||||
<link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" />
|
||||
<style type="text/css">
|
||||
::-ms-clear, ::-ms-reveal {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.edit-content table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.edit-content table td.label {
|
||||
width: 200px;
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
line-height: 24px;
|
||||
height: 24px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.edit-content table td input,
|
||||
.edit-content table td textarea {
|
||||
border: 1px solid #a9a9a9;
|
||||
width: 200px;
|
||||
height: 18px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
.edit-content table td input[type="checkbox"] {
|
||||
border: none;
|
||||
width: 13px;
|
||||
}
|
||||
|
||||
.edit-content table td textarea {
|
||||
height: 100px;
|
||||
resize: none;
|
||||
/*max-width: 200px;*/
|
||||
}
|
||||
|
||||
.edit-content table td select {
|
||||
height: 22px;
|
||||
width: 204px;
|
||||
}
|
||||
|
||||
.a {
|
||||
text-decoration: none;
|
||||
color: #2140fb;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
margin: 30px 40px 5px 0px;
|
||||
font-size: 16px;
|
||||
color: gray;
|
||||
}
|
||||
|
||||
.subtitle span {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.subtitle hr {
|
||||
background-color: #d8d8d8;
|
||||
border: none;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
|
||||
.categoryname {
|
||||
cursor: default;
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
.plus:before {
|
||||
font-size: 10px;
|
||||
font-weight: normal;
|
||||
font-family: 'CalciteWebCoreIcons', 'Fontawesome';
|
||||
content: '\e620';
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.minus:before {
|
||||
font-size: 10px;
|
||||
font-weight: normal;
|
||||
font-family: 'CalciteWebCoreIcons', 'Fontawesome';
|
||||
content: '\e621';
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.dialogspanbtn {
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
font-family: 'CalciteWebCoreIcons', 'Fontawesome';
|
||||
cursor: pointer;
|
||||
background: rgb(249, 189, 117);
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.dialogedit:before {
|
||||
content: '\e61b';
|
||||
}
|
||||
|
||||
.dialogok:before {
|
||||
content: '\e605';
|
||||
}
|
||||
|
||||
.dialogcancel:before {
|
||||
content: '\e600';
|
||||
}
|
||||
|
||||
.dialogbtn {
|
||||
height: 24px;
|
||||
cursor: pointer;
|
||||
background: rgb(249, 189, 117);
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.machinetd {
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.popus-close {
|
||||
float: right;
|
||||
margin-right: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.popus-close:before {
|
||||
content: '\e600';
|
||||
}
|
||||
|
||||
textarea {
|
||||
resize: none;
|
||||
}
|
||||
|
||||
.divtab {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.label {
|
||||
width: 184px;
|
||||
}
|
||||
|
||||
.assetcontent table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.assetcontent table td.label {
|
||||
width: 184px;
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
line-height: 24px;
|
||||
height: 24px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.assetcontent table td input,
|
||||
.assetcontent table td textarea {
|
||||
border: 1px solid #a9a9a9;
|
||||
width: 200px;
|
||||
height: 18px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
.assetcontent table td input[type="checkbox"] {
|
||||
border: none;
|
||||
width: 13px;
|
||||
}
|
||||
|
||||
.assetcontent table td textarea {
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.adjust-content table td.label {
|
||||
width: 130px;
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
line-height: 24px;
|
||||
height: 24px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.adjust-content table td input {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.adjust-content table td select {
|
||||
width: 204px;
|
||||
}
|
||||
|
||||
#divcontent {
|
||||
margin: 8px;
|
||||
}
|
||||
|
||||
.dialogflatbtn {
|
||||
background-color: rgb(235, 235, 235);
|
||||
border: none;
|
||||
padding-top: 5px;
|
||||
padding-bottom: 5px;
|
||||
cursor: pointer;
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
.dialogflatbtn:hover {
|
||||
background: rgb(225, 225, 225);
|
||||
}
|
||||
</style>
|
||||
<script src="<%=GetFileUrlWithVersion("../Maintenance/js/inputdatactr.js")%>" type="text/javascript"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/editableselect.js")%>"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/controls.js")%>" type="text/javascript"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/assetselector.js")%>" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
var IsDealer = <%=IsDealer ?"true":"false"%>;
|
||||
var IsAdmin =<%=IsAdmin ?"true":"false"%>;
|
||||
var IsSupperAdmin =<%=IsSupperAdmin ?"true":"false"%>;
|
||||
var isAllowed = false;
|
||||
|
||||
var machineGroupID = "<%=MachineID %>";
|
||||
var allMachineGroups;
|
||||
var indexInEdit;
|
||||
|
||||
var onsitejobsiteid;
|
||||
var contactids;
|
||||
var MachineAttributes = [];
|
||||
|
||||
var machines = [];
|
||||
var makes = [];
|
||||
var models = [];
|
||||
var machinetypes = [];
|
||||
|
||||
var editableSelectMake;
|
||||
var editableSelectModel;
|
||||
|
||||
var noneditwidth = 200;
|
||||
var editablewidth = 180;
|
||||
|
||||
//动态加载机器列表
|
||||
var displayCountPerPage = 30;//每页显示的机器条数
|
||||
var currentShownIndex = -1;//当前显示的机器索引
|
||||
var engineHoursBeforeChange = undefined;
|
||||
|
||||
var _selectedRental = null;
|
||||
var needRefreshDataOnCancel = false;//由于在Next和Previous时直接保存机器信息,在点Cancel时也需要刷新数据
|
||||
|
||||
var loadingCount = 0;
|
||||
var customertimezone;
|
||||
var customerdatetime;
|
||||
|
||||
function devicerequest(method, param, callback, error) {
|
||||
_network.request("MachineDeviceManagement/ManageMachines.aspx", -1, method, param, callback, error || function (e) {
|
||||
console.log(e);
|
||||
showmaskbg(false, true);
|
||||
showAlert(GetTextByKey('P_AG_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_AG_QUERY', 'Query'));
|
||||
});
|
||||
}
|
||||
|
||||
function init(cid, machineList, index) {
|
||||
allMachineGroups = machineList
|
||||
indexInEdit = index;
|
||||
|
||||
if (allMachineGroups) {
|
||||
OnEdit();
|
||||
} else {
|
||||
machineGroupID = undefined;
|
||||
if (grid_dtsm != null) {
|
||||
grid_dtsm.setData([]);
|
||||
}
|
||||
OnAdd();
|
||||
}
|
||||
}
|
||||
|
||||
function OnAdd() {
|
||||
machineGroupID = undefined;
|
||||
$('#dialog_groupname').val('');
|
||||
$('#dialog_description').val('');
|
||||
$('#dialog_groupcode').val('');
|
||||
|
||||
$("#btnPrevious").hide();
|
||||
$("#btnNext").hide();
|
||||
|
||||
$('#selectedmachinelist input[type="checkbox"]').prop('checked', false);
|
||||
|
||||
$('#dialog_groupname').focus();
|
||||
}
|
||||
|
||||
function OnEdit() {
|
||||
var group = allMachineGroups[indexInEdit].Values;
|
||||
if (!group) {
|
||||
return;
|
||||
}
|
||||
|
||||
machineGroupID = group.Id;
|
||||
|
||||
$('#dialog_groupname').val(group.Name);
|
||||
$('#dialog_description').val(group.Description);
|
||||
$('#dialog_groupcode').val(group.Code);
|
||||
grid_dtsm.setData([]);
|
||||
|
||||
$('#selectedmachinelist input[type="checkbox"]').prop('checked', false);
|
||||
|
||||
if (allMachineGroups.length <= 1) {
|
||||
$("#btnPrevious").hide();
|
||||
$("#btnNext").hide();
|
||||
}
|
||||
else {
|
||||
$("#btnPrevious").show();
|
||||
$("#btnNext").show();
|
||||
}
|
||||
|
||||
// 加载用户信息
|
||||
queryGroupMachines();
|
||||
}
|
||||
|
||||
function OnNext() {
|
||||
OnSave(0, gotoNext);
|
||||
}
|
||||
|
||||
function gotoNext() {
|
||||
if (++indexInEdit > allMachineGroups.length - 1)
|
||||
indexInEdit = 0;
|
||||
|
||||
OnEdit();
|
||||
window.parent.changeGridSelectIndex(indexInEdit);
|
||||
}
|
||||
|
||||
function OnPrevious() {
|
||||
OnSave(0, gotoPrevious);
|
||||
}
|
||||
|
||||
function gotoPrevious() {
|
||||
if (--indexInEdit < 0)
|
||||
indexInEdit = allMachineGroups.length - 1;
|
||||
|
||||
OnEdit();
|
||||
window.parent.changeGridSelectIndex(indexInEdit);
|
||||
}
|
||||
|
||||
|
||||
function OnSave(exit, callback) {
|
||||
var item = {
|
||||
'Name': $.trim($('#dialog_groupname').val()),
|
||||
'Description': $.trim($('#dialog_description').val()),
|
||||
'Code': $.trim($('#dialog_groupcode').val())
|
||||
};
|
||||
var alerttitle;
|
||||
if (machineGroupID) {
|
||||
item.Id = machineGroupID;
|
||||
alerttitle = GetTextByKey("P_AG_EDITASSETGROUP", "Edit Asset Group");
|
||||
} else {
|
||||
item.Id = "";
|
||||
alerttitle = GetTextByKey("P_AG_ADDASSETGROUP", "Add Asset Group");
|
||||
}
|
||||
|
||||
if (!item.Name || item.Name.length == 0) {
|
||||
showAlert(GetTextByKey("P_AG_GROUPNAMECANNOTBEEMPTY", 'Group Name cannot be empty.'), alerttitle);
|
||||
$('#dialog_groupname').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (allMachineGroups != null) {
|
||||
for (var i = 0; i < allMachineGroups.length; i++) {
|
||||
var group = allMachineGroups[i]
|
||||
if (group.Name === item.Name && group.Id !== item.Id) {
|
||||
showAlert(GetTextByKey("P_AG_NAMEALREADYEXISTS", 'Group Name already exists.'), alerttitle);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
item.Assets = [];
|
||||
if (grid_dtsm.innerSource != []) {
|
||||
for (var i = 0; i < grid_dtsm.innerSource.length; i++) {
|
||||
var mid = grid_dtsm.innerSource[i].Values.ID;
|
||||
if (mid) {
|
||||
item.Assets.push(mid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
showloading(true);
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
devicerequest("SaveAssetGroup", param, function (data) {
|
||||
showloading(false);
|
||||
if (data.substring(0, 6) === 'Failed') {
|
||||
showAlert(data, alerttitle);
|
||||
} else {
|
||||
needRefreshDataOnCancel = true;
|
||||
machineGroupID = data;
|
||||
|
||||
if (callback) {
|
||||
//showAlert("Saved successfully.", 'Save Asset');
|
||||
if (allMachineGroups != null) {
|
||||
allMachineGroups[indexInEdit].Values = item;
|
||||
}
|
||||
callback(item);
|
||||
} else {
|
||||
if (exit == 0)
|
||||
showAlert(GetTextByKey("P_AG_SAVSUCCESSFULLY", "Saved successfully."), GetTextByKey("P_AG_SAVASSETGROUP", 'Save Asset Group'));
|
||||
else if (exit == 1)
|
||||
OnExit(exit);
|
||||
}
|
||||
}
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
showAlert(GetTextByKey("P_AG_FAILEDTOSAVEASSETGROUP", 'Failed to save Asset Group.'), GetTextByKey("P_AG_SAVASSETGROUP", 'Save Asset Group'));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/************************** Machine********************************/
|
||||
/*************************************************************************/
|
||||
|
||||
//var _selectedMachines = [];
|
||||
|
||||
function queryGroupMachines() {
|
||||
devicerequest('GetAssetsByGroup', machineGroupID, function (data) {
|
||||
var grpMachines = data || [];
|
||||
|
||||
//_selectedMachines = grpMachines;
|
||||
showSelectedMachine(grpMachines);
|
||||
|
||||
$('#dialog_groupname').focus();
|
||||
}, function (err) {
|
||||
showAlert(GetTextByKey("P_AG_FAILEDLOADASSETS", 'Failed to load Asset(s).'), GetTextByKey("P_AG_EDITASSETGROUP", 'Edit Asset Group'));
|
||||
});
|
||||
}
|
||||
|
||||
function showSelectedMachine(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
|
||||
grid_dtsm.setData(rows);
|
||||
}
|
||||
|
||||
function OnDelete(item) {
|
||||
showConfirm(GetTextByKey("P_AG_REMOVETHISASSET", "Are you sure you want to remove this asset:{0}?").replace('{0}', item.Name), GetTextByKey("P_AG_EDITGROUPASSETS", 'Edit Group Assets'), function () {
|
||||
for (var i = 0; i < grid_dtsm.innerSource.length; i++) {
|
||||
var s = grid_dtsm.innerSource[i].Values;
|
||||
if (s.ID === item.ID) {
|
||||
grid_dtsm.innerSource.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (grid_dtsm.source != null) {
|
||||
for (var j = 0; j < grid_dtsm.source.length; j++) {
|
||||
if (item.ID === grid_dtsm.source[j].Values.ID) {
|
||||
grid_dtsm.source.splice(j, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
grid_dtsm.reload();
|
||||
});
|
||||
}
|
||||
|
||||
function OnGroupsDelete() {
|
||||
showConfirm(GetTextByKey("P_AG_REMOVESELECTEDASSETS", 'Are you sure you want to remove these selected assets?'), GetTextByKey("P_AG_EDITGROUPASSETS", 'Edit Group Assets'), function () {
|
||||
for (var i = grid_dtsm.innerSource.length - 1; i >= 0; i--) {
|
||||
var s = grid_dtsm.innerSource[i].Values;
|
||||
if (s.selected) {
|
||||
grid_dtsm.innerSource.splice(i, 1);
|
||||
}
|
||||
}
|
||||
if (grid_dtsm.source != null) {
|
||||
for (var j = grid_dtsm.source.length - 1; j >= 0; j--) {
|
||||
var l = grid_dtsm.source[j].Values;
|
||||
if (l.selected) {
|
||||
grid_dtsm.source.splice(j, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
grid_dtsm.reload();
|
||||
});
|
||||
}
|
||||
|
||||
function OnGroupsAdd() {
|
||||
showmaskbg(true);
|
||||
dialogAssets.exceptSource = grid_dtsm.innerSource.map(function (s) {
|
||||
return s.Values.ID;
|
||||
});
|
||||
dialogAssets.showSelector();
|
||||
$('#mask_bg').css('height', '100%');
|
||||
}
|
||||
|
||||
var grid_dtsm;
|
||||
function InitGridSelectedMachines() {
|
||||
grid_dtsm = new GridView('#selectedmachinelist');
|
||||
grid_dtsm.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'VIN', caption: GetTextByKey("P_AG_VIN", "VIN"), valueIndex: 'VIN', css: { 'width': 170, 'text-align': 'left' } },
|
||||
{ name: 'Name', caption: GetTextByKey("P_AG_NAME", "Name"), valueIndex: 'Name', css: { 'width': 170, 'text-align': 'left' } },
|
||||
{ name: 'TypeName', caption: GetTextByKey("P_AG_TYPE", "Type"), valueIndex: 'TypeName', css: { 'width': 170, 'text-align': 'left' } }
|
||||
];
|
||||
var columns = [
|
||||
{
|
||||
// checkbox
|
||||
name: 'check',
|
||||
key: 'selected',
|
||||
width: 30,
|
||||
align: 'center',
|
||||
sortable: false,
|
||||
allcheck: true,
|
||||
type: 3
|
||||
}
|
||||
];
|
||||
// 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 = col.name === 'TypeName';
|
||||
col.styleFilter = function (item) {
|
||||
if (item.Highlight)
|
||||
return { 'background-color': 'yellow' };
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
columns.push({
|
||||
name: 'delete',
|
||||
width: 30,
|
||||
align: 'center',
|
||||
sortable: false,
|
||||
isurl: true,
|
||||
text: '\uf00d',
|
||||
events: {
|
||||
onclick: function () {
|
||||
OnDelete(this);
|
||||
}
|
||||
},
|
||||
classFilter: function (e) {
|
||||
return "icon-col";
|
||||
},
|
||||
attrs: { 'title': GetTextByKey("P_AG_DELETE", 'Delete') }
|
||||
});
|
||||
grid_dtsm.canMultiSelect = true;
|
||||
grid_dtsm.columns = columns;
|
||||
grid_dtsm.init();
|
||||
|
||||
grid_dtsm.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_dtsm.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************End Machine********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
function OnExit(type) {
|
||||
if (type === 0) {
|
||||
if (needRefreshDataOnCancel) {
|
||||
type = 1;
|
||||
needRefreshDataOnCancel = false;
|
||||
}
|
||||
}
|
||||
window.parent.CloseDialog(type);
|
||||
}
|
||||
|
||||
var dialogAssets;
|
||||
$(function () {
|
||||
InitGridSelectedMachines();
|
||||
|
||||
dialogAssets = new $assetselector('dialog_machines');
|
||||
dialogAssets.allowhidden = false;
|
||||
dialogAssets.onDialogClosed = function () {
|
||||
showmaskbg(false);
|
||||
};
|
||||
dialogAssets.onOK = function (source) {
|
||||
var items = [];
|
||||
for (var i = 0; i < source.length; i++) {
|
||||
var it = source[i].Values;
|
||||
if (it.Selected) {
|
||||
items.push({
|
||||
Values: {
|
||||
ID: it.Id,
|
||||
VIN: it.VIN,
|
||||
Name: it.Name,
|
||||
TypeName: it.TypeName
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
showmaskbg(false);
|
||||
grid_dtsm.setData(grid_dtsm.innerSource.concat(items));
|
||||
};
|
||||
|
||||
window.parent.Opened();
|
||||
});
|
||||
|
||||
</script>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
||||
<div id="dialog_machinegroup">
|
||||
<div id="mask_bg1" style="display: none;">
|
||||
<div class="loading c-spin"></div>
|
||||
</div>
|
||||
<div id="div_content">
|
||||
<div id="dialogmask" class="maskbg" style="display: none; z-index: 500;">
|
||||
<div class="loading_icon icon c-spin"></div>
|
||||
</div>
|
||||
<div class="function_title">
|
||||
<span class="sbutton iconsave" onclick="OnSave(0);" data-lgid="P_AG_SAVE">Save</span>
|
||||
<span class="sbutton iconsave" onclick="OnSave(1);" data-lgid="P_AG_SAVE1">Save and Exit</span>
|
||||
<span class="sbutton iconexit" onclick="OnExit(0);" data-lgid="P_AG_SAVE2">Exit Without Saving</span>
|
||||
<%--<span class="sbutton iconprevious" id="btnNext" onclick="OnPrevious();">Previous</span>--%>
|
||||
<%--<span class="sbutton iconnext" id="btnPrevious" onclick="OnNext();">Next</span>--%>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<div id="divcontent" class="assetcontent">
|
||||
<table class="group_table">
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_AG_GROUPNAME_COLON">Group Name:</td>
|
||||
<td>
|
||||
<input type="text" id="dialog_groupname" class="inputbox" maxlength="200" tabindex="1" style="width: 300px;" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" style="width: 50px; text-align: right;" data-lgid="P_AG_CODE_COLON">Code:</td>
|
||||
<td>
|
||||
<input type="text" id="dialog_groupcode" class="inputbox" maxlength="50" tabindex="1" style="width: 300px;" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_AG_DESCRIPTION_COLON">Description:</td>
|
||||
<td>
|
||||
<textarea id="dialog_description" class="inputbox" maxlength="1000" tabindex="2" style="width: 300px"></textarea></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="dialog-subheader">
|
||||
<span data-lgid="P_AG_GROUPASSETS">Group Assets</span>
|
||||
<span class="sbutton icondelete" onclick="OnGroupsDelete()" style="float: right" data-lgid="P_AG_DELETE">Delete</span>
|
||||
<span class="sbutton iconadd" onclick="OnGroupsAdd()" style="float: right" data-lgid="P_AG_ADD">Add</span>
|
||||
</div>
|
||||
|
||||
<table id="tab_groupmachine" class="group_table" style="margin-top: 6px">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 380px;">
|
||||
<div id="selectedmachinelist" style="height: 484px; border-bottom: 1px solid #aaa;"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div id="mask_bg" style="display: none;">
|
||||
<div class="loading c-spin"></div>
|
||||
</div>
|
||||
</div>
|
||||
</asp:Content>
|
83
Site/MachineDeviceManagement/AddMachineGroup.aspx.cs
Normal file
@ -0,0 +1,83 @@
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor;
|
||||
using IronIntel.Contractor.Site;
|
||||
using IronIntel.Contractor.Site.Asset;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class AddMachineGroup : AssetBasePage
|
||||
{
|
||||
|
||||
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
|
||||
public string ContractorID = "";
|
||||
public string MachineID = "";
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!CheckLoginSession())
|
||||
{
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
string methodName = Request.Form["MethodName"];
|
||||
if (!string.IsNullOrEmpty(methodName))
|
||||
{
|
||||
ProcessRequest(methodName);
|
||||
}
|
||||
else if (!IsPostBack)
|
||||
{
|
||||
this.Title = PageTitle;
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
if (!permission)
|
||||
RedirectToLoginPage();
|
||||
ContractorID = Request.Params["cid"];
|
||||
MachineID = Request.Params["mid"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var user = GetCurrentUser();
|
||||
return user != null && user.UserType >= IronIntel.Contractor.Users.UserTypes.Common;
|
||||
}
|
||||
|
||||
public bool IsAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public bool IsSupperAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
return user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin;
|
||||
}
|
||||
}
|
||||
}
|
580
Site/MachineDeviceManagement/AddRental.aspx
Normal file
@ -0,0 +1,580 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/MachineDeviceManagement/DeviceManagementBase.master" AutoEventWireup="true" CodeFile="AddRental.aspx.cs" Inherits="AddRental" %>
|
||||
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
|
||||
<style type="text/css">
|
||||
::-ms-clear, ::-ms-reveal {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.edit-content table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.edit-content table td.label {
|
||||
width: 200px;
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
line-height: 24px;
|
||||
height: 24px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.edit-content table td input,
|
||||
.edit-content table td textarea {
|
||||
border: 1px solid #a9a9a9;
|
||||
width: 320px;
|
||||
height: 18px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
.edit-content table td input[type="checkbox"] {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.edit-content table td textarea {
|
||||
height: 100px;
|
||||
resize: none;
|
||||
/*max-width: 200px;*/
|
||||
}
|
||||
|
||||
.a {
|
||||
text-decoration: none;
|
||||
color: #2140fb;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
margin: 20px 40px 5px 0px;
|
||||
font-size: 16px;
|
||||
color: gray;
|
||||
}
|
||||
|
||||
.subtitle span {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.subtitle hr {
|
||||
background-color: #d8d8d8;
|
||||
border: none;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
|
||||
.machinetd {
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
<link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" />
|
||||
<script src="<%=GetFileUrlWithVersion("../Maintenance/js/inputdatactr.js")%>" type="text/javascript"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/editableselect.js")%>"></script>
|
||||
<script type="text/javascript">
|
||||
var IsDealer = <%=IsDealer ?"true":"false"%>;
|
||||
var IsAdmin =<%=IsAdmin ?"true":"false"%>;
|
||||
var contractorid = "<%=ContractorID %>";
|
||||
var rentalid = "<%=RentalID %>";
|
||||
var machineid = "<%=MachineID %>";
|
||||
|
||||
var rentalsdata = [];
|
||||
var machines;
|
||||
|
||||
function devicerequest(method, param, callback, error) {
|
||||
_network.request("MachineDeviceManagement/AddRental.aspx", -1, method, param, callback, error || function (e) {
|
||||
console.log(e);
|
||||
showmaskbg(false, true);
|
||||
showAlert(GetTextByKey('P_MR_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_MR_QUERY', 'Query'));
|
||||
});
|
||||
}
|
||||
|
||||
function OnAdd() {
|
||||
$('#dialog_machine').val('');
|
||||
$('#dialog_outside').val('');
|
||||
$('#dialog_vendor').val('');
|
||||
$('#dialog_rentalrate').val('');
|
||||
$('#dialog_term').val('');
|
||||
$('#dialog_termunit').val('');
|
||||
$('#dialog_rentaldata').val('');
|
||||
$('#dialog_projectreturndate').val('');
|
||||
$('#dialog_returndate').val('');
|
||||
$('#dialog_ponumber').val('');
|
||||
$('#dialog_comments').val('');
|
||||
$('#dialog_rentaltermbillingdate').val('');
|
||||
$('#dialog_billingcycledays').val('');
|
||||
$('#dialog_insuredvalue').val('');
|
||||
|
||||
$('#dialog_name').focus();
|
||||
}
|
||||
|
||||
function getRentalInfo() {
|
||||
showloading(true);
|
||||
devicerequest("GetRentalInfo", contractorid + String.fromCharCode(170) + rentalid, function (data) {
|
||||
showloading(false);
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MR_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
var rental = data;
|
||||
$('#dialog_machine').attr('disabled', true);
|
||||
$('#dialog_machine').val(rental.MachineID);
|
||||
setMachineInfo();
|
||||
$('#dialog_outside').val(rental.Outside);
|
||||
$('#dialog_vendor').val(rental.Vendor);
|
||||
$('#dialog_rentalrate').val(rental.RentalRate);
|
||||
$('#dialog_term').val(rental.Term);
|
||||
$('#dialog_termunit').val(rental.TermUnit);
|
||||
$('#dialog_rentaldata').val(rental.RentalDateStr);
|
||||
$('#dialog_projectreturndate').val(rental.ProjectReturnDateStr);
|
||||
$('#dialog_returndate').val(rental.ReturnDateStr);
|
||||
$('#dialog_ponumber').val(rental.PONumber);
|
||||
$('#dialog_comments').val(rental.Comments);
|
||||
$('#dialog_rentaltermbillingdate').val(rental.RentalTermBillingDateStr);
|
||||
$('#dialog_billingcycledays').val(rental.BillingCycleDays < 0 ? "" : rental.BillingCycleDays);
|
||||
$('#dialog_insuredvalue').val(rental.InsuredValue);
|
||||
}, function (err) {
|
||||
console.log(err);
|
||||
showloading(false);
|
||||
});
|
||||
}
|
||||
|
||||
function setMachineInfo() {
|
||||
var machineid = $('#dialog_machine').val();
|
||||
if (machineid) {
|
||||
var machine = $('#dialog_machine option:selected').data('machine');
|
||||
$('#dialog_vin').text(machine.VIN);
|
||||
$('#dialog_make').text(machine.Make);
|
||||
$('#dialog_model').text(machine.Model);
|
||||
$('#dialog_type').text(machine.MachineType);
|
||||
getRentals(machine.MachineID);
|
||||
}
|
||||
}
|
||||
|
||||
function OnEdit() {
|
||||
getRentalInfo();
|
||||
$('#dialog_name').focus();
|
||||
}
|
||||
|
||||
var IsInteger = /^[0-9]+$/;
|
||||
function OnSave(exit) {
|
||||
var item = {
|
||||
'Outside': $('#dialog_outside').val(),
|
||||
'Vendor': $('#dialog_vendor').val(),
|
||||
'RentalRate': $('#dialog_rentalrate').val(),
|
||||
'Term': $('#dialog_term').val(),
|
||||
'TermUnit': $('#dialog_termunit').val(),
|
||||
'RentalDate': $('#dialog_rentaldata').val(),
|
||||
'ProjectReturnDate': $('#dialog_projectreturndate').val(),
|
||||
'ReturnDate': $('#dialog_returndate').val(),
|
||||
'PONumber': $('#dialog_ponumber').val(),
|
||||
'Comments': $('#dialog_comments').val(),
|
||||
'MachineID': $('#dialog_machine').val(),
|
||||
'RentalTermBillingDate': $('#dialog_rentaltermbillingdate').val(),
|
||||
'BillingCycleDays': $('#dialog_billingcycledays').val(),
|
||||
'InsuredValue': $('#dialog_insuredvalue').val()
|
||||
};
|
||||
var alerttitle;
|
||||
if (rentalid) {
|
||||
item.RentalID = rentalid;
|
||||
alerttitle = GetTextByKey("P_MA_EDITRENTAL", "Edit Rental");
|
||||
} else {
|
||||
item.RentalID = -1;
|
||||
alerttitle = GetTextByKey("P_MA_ADDRENTAL", "Add Rental");
|
||||
}
|
||||
|
||||
if (item.MachineID === "") {
|
||||
showAlert(GetTextByKey("P_MR_ASSETNOTEMPTY", 'Asset cannot be empty.'), alerttitle);
|
||||
$('#dialog_machine').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.RentalRate !== "" && isNaN(item.RentalRate)) {
|
||||
showAlert(GetTextByKey("P_MR_RENTALRATEFORMATERROR", 'Rental Rate format error.'), alerttitle);
|
||||
return;
|
||||
}
|
||||
if (item.RentalRate === "") {
|
||||
item.RentalRate = 0;
|
||||
}
|
||||
if (item.Term === "") {
|
||||
item.Term = 0;
|
||||
}
|
||||
if (isNaN(item.Term) || !IsInteger.test(item.Term) || eval(item.Term) < 0) {
|
||||
showAlert(GetTextByKey("P_MR_RENTALTERMMUSTBEANINTEGEREQUALTOORGREATERTHAN0", 'Rental Term must be an integer equal to or greater than 0. '), alerttitle);
|
||||
return;
|
||||
}
|
||||
if (item.RentalDate.length <= 0) {
|
||||
showAlert(GetTextByKey("P_MR_RENTALDATECANNOTBEEMPTY", 'Rental Date cannot be empty.'), alerttitle);
|
||||
$('#dialog_rentaldata').focus();
|
||||
return;
|
||||
}
|
||||
if (item.BillingCycleDays !== "") {
|
||||
if (isNaN(item.BillingCycleDays) || !IsInteger.test(item.BillingCycleDays) || eval(item.BillingCycleDays) < 0) {
|
||||
showAlert(GetTextByKey("P_MR_THENUMBEROFDAYSINBILLINGCYCLEMUSTBEANINTEGEREQUALTOORGREATERTHAN0", 'The Number of Days in Billing Cycle must be an integer equal to or greater than 0.'), alerttitle);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
item.BillingCycleDays = -1;
|
||||
|
||||
if (item.InsuredValue !== "" && isNaN(item.InsuredValue)) {
|
||||
showAlert(GetTextByKey("P_MR_INSUREDVALUEFORMATERROR", 'Insured Value format error.'), alerttitle);
|
||||
return;
|
||||
}
|
||||
if (item.InsuredValue === "") {
|
||||
item.InsuredValue = 0;
|
||||
}
|
||||
|
||||
var rentaldate = new Date(item.RentalDate.replace("-", "/"));
|
||||
var pjdate = new Date(item.ProjectReturnDate.replace("-", "/"));
|
||||
var returndate = new Date(item.ReturnDate.replace("-", "/"));
|
||||
if (rentaldate > pjdate) {
|
||||
showAlert(GetTextByKey("P_MR_PROJRETURNDATEMUSTBELATERTHANRENTALDATE", "Proj. Return Date must be later than than Rental Date."), alerttitle);
|
||||
return false;
|
||||
}
|
||||
if (rentaldate > returndate) {
|
||||
showAlert(GetTextByKey("P_MR_RETURNDATEBELATERRENTALDATE", "Return Date must be later than Rental Date."), alerttitle);
|
||||
return false;
|
||||
}
|
||||
|
||||
showloading(true);
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
|
||||
var alerttitle = GetTextByKey("P_MR_SAVERENTAL", 'Save Rental');
|
||||
devicerequest("SaveRental", contractorid + String.fromCharCode(170) + param, function (data) {
|
||||
showloading(false);
|
||||
if (typeof (data) === "string") {
|
||||
if (data === "Rental dates entered overlap with another entry. Please adjust the dates.")
|
||||
data = GetTextByKey("P_MR_RENTALDATESENTEREDOVERLAPWITHANOTHERENTRY", "Rental dates entered overlap with another entry. Please adjust the dates.");
|
||||
showAlert(data, alerttitle);
|
||||
} else {
|
||||
rentalid = data;
|
||||
if (exit == 0) {
|
||||
showAlert(GetTextByKey("P_MR_SAVSUCCESSFULLY", "Saved successfully."), alerttitle);
|
||||
var machineid = $('#dialog_machine').val();
|
||||
if (machineid) {
|
||||
getRentals(machineid);
|
||||
}
|
||||
}
|
||||
if (exit == 1)
|
||||
OnExit(exit);
|
||||
else
|
||||
$('#dialog_machine').attr('disabled', true);
|
||||
}
|
||||
}, function (err) {
|
||||
console.log(err);
|
||||
showloading(false);
|
||||
showAlert(GetTextByKey("P_MR_FAILEDTOSAVERENTAL", 'Failed to save Rental.'), alerttitle);
|
||||
});
|
||||
}
|
||||
|
||||
function OnExit(type) {
|
||||
window.parent.CloseDialog(type);
|
||||
}
|
||||
|
||||
function GetMachines(next) {
|
||||
devicerequest("GetSelectMachinesByRental", contractorid, function (data) {
|
||||
if (data && data.length > 0) {
|
||||
machines = data;
|
||||
var sel_machine = $('#dialog_machine').empty();
|
||||
sel_machine.append('<option value=""></option>');
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var machine = data[i];
|
||||
var op = $('<option></option>').val(machine.MachineID).text(machine.DisplayName).data('machine', machine);
|
||||
sel_machine.append(op);
|
||||
}
|
||||
|
||||
if (machineid !== undefined) {
|
||||
$('#dialog_machine').val(machineid);
|
||||
setMachineInfo();
|
||||
}
|
||||
}
|
||||
if (next)
|
||||
next();
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
function init() {
|
||||
if (rentalid !== undefined && rentalid !== '') {
|
||||
GetMachines(OnEdit);
|
||||
}
|
||||
else {
|
||||
$('#span_a').css('display', 'none');
|
||||
GetMachines();
|
||||
OnAdd();
|
||||
$('#dialog_machine').attr('disabled', false);
|
||||
}
|
||||
}
|
||||
|
||||
$(function () {
|
||||
init();
|
||||
|
||||
$('#dialog_machine').change(function () {
|
||||
setMachineInfo();
|
||||
});
|
||||
|
||||
$('#dialog_rentaldata').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
$('#dialog_projectreturndate').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
$('#dialog_returndate').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
$('#dialog_rentaltermbillingdate').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
|
||||
function resizeContent() {
|
||||
$('#divcontent').css('height', $(window).height() - $('#divcontent').offset().top - 4);
|
||||
$('.content_main').css('min-height', 0);
|
||||
}
|
||||
|
||||
window.onresize = resizeContent;
|
||||
resizeContent();
|
||||
|
||||
//$("#rentalsDiv").scroll(null, function (e) {
|
||||
// var t = $(e.target);
|
||||
// $('#tbRentals').css('margin-left', - (t.scrollLeft()));
|
||||
//});
|
||||
});
|
||||
|
||||
function getRentals(mid) {
|
||||
$("#rentalListDiv").hide();
|
||||
$("#lblRentalHistory").hide();
|
||||
devicerequest("SearchRentals", contractorid + String.fromCharCode(170) + ""
|
||||
+ String.fromCharCode(170) + '1900-1-1' + String.fromCharCode(170) + '2099-1-1'
|
||||
+ String.fromCharCode(170) + mid, function (data) {
|
||||
$('#tbody_rentals').empty();
|
||||
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MR_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
if (data && data.length > 0) {
|
||||
rentalsdata = data;
|
||||
$("#rentalListDiv").show();
|
||||
$("#lblRentalHistory").show();
|
||||
}
|
||||
else
|
||||
rentalsdata = [];
|
||||
sortTableData($('#tbRentals'), rentalsdata);
|
||||
showRentals(rentalsdata);
|
||||
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
function showRentals(data) {
|
||||
var trs = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var rental = data[i];
|
||||
var tr = $('<tr></tr>').data('rental', rental);
|
||||
tr.append($('<td class="machinetd" style="width: 10%;""></td>').attr('title', rental.Comments).html(replaceHtmlText(rental.Outside)));
|
||||
tr.append($('<td class="machinetd" style="width: 10%;""></td>').html(replaceHtmlText(rental.Vendor)));
|
||||
tr.append($('<td class="machinetd" style="width: 8%;""></td>').text(rental.RentalRate));
|
||||
tr.append($('<td class="machinetd" style="width: 8%;""></td>').text(rental.Term));
|
||||
tr.append($('<td class="machinetd" style="width: 8%;""></td>').text(rental.TermUnit));
|
||||
tr.append($('<td class="machinetd" style="width: 8%;">"></td>').text(rental.RentalDateStr));
|
||||
tr.append($('<td class="machinetd" style="width: 8%;""></td>').text(rental.ProjectReturnDateStr));
|
||||
tr.append($('<td class="machinetd" style="width: 8%;""></td>').text(rental.ReturnDateStr));
|
||||
tr.append($('<td class="machinetd" style="width: 8%;""></td>').html(replaceHtmlText(rental.PONumber)));
|
||||
tr.append($('<td style="width: 24%;""></td>').attr('title', rental.Comments).html(replaceHtmlText(rental.Comments)));
|
||||
|
||||
trs.push(tr);
|
||||
}
|
||||
|
||||
$('#tbody_rentals').append(trs);
|
||||
}
|
||||
|
||||
function OnViewChangeHistory() {
|
||||
window.open("RentalChangeHistory.aspx?cid=" + contractorid + "&mid=" + machineid + "&rid=" + rentalid + "");
|
||||
}
|
||||
</script>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
||||
<div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div>
|
||||
<div>
|
||||
<div class="function_title">
|
||||
<span class="sbutton iconsave" onclick="OnSave(0);" data-lgid="P_MR_SAVE">Save</span>
|
||||
<span class="sbutton iconsave" onclick="OnSave(1);" data-lgid="P_MR_SAVE1">Save and Exit</span>
|
||||
<span class="sbutton iconexit" onclick="OnExit(0);" data-lgid="P_MR_SAVE2">Exit Without Saving</span>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<div id="divcontent" style="overflow: auto;">
|
||||
<div class="edit-content">
|
||||
<div class="subtitle">
|
||||
<span data-lgid="P_MR_ASSETINFORMATION">Asset Information</span>
|
||||
<hr />
|
||||
</div>
|
||||
<table>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MR_ASSET_COLON">Asset:</td>
|
||||
<td colspan="4">
|
||||
<select id="dialog_machine" style="width: 322px; height: 22px;" tabindex="1" disabled="disabled"></select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MR_VIN_COLON">VIN:</td>
|
||||
<td id="dialog_vin" style="width: 200px;"></td>
|
||||
<td class="label" style="width: 60px;" data-lgid="P_MR_ASSETTYPE_COLON">Type:</td>
|
||||
<td id="dialog_type" style="width: 200px;"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MR_MAKE_COLON">Make:</td>
|
||||
<td id="dialog_make" style="width: 200px;"></td>
|
||||
<td class="label" style="width: 60px;" data-lgid="P_MR_MODEL_COLON">Model:</td>
|
||||
<td id="dialog_model" style="width: 200px;"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="subtitle">
|
||||
<span data-lgid="P_MR_RENTALINFORMATION">Rental Information</span>
|
||||
<hr />
|
||||
</div>
|
||||
<table>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MR_OUTSIDEINTERNAL_COLON">Outside/Internal:</td>
|
||||
<td>
|
||||
<select id="dialog_outside" style="width: 324px; height: 22px;" tabindex="4">
|
||||
<option value=""></option>
|
||||
<option value="Inside" data-lgid="P_MR_INSIDE">Inside</option>
|
||||
<option value="Outside" data-lgid="P_MR_OUTSIDE">Outside</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MR_RENTALVENDOR_COLON">Rental Vendor:</td>
|
||||
<td>
|
||||
<input type="text" id="dialog_vendor" maxlength="200" tabindex="6" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MR_RENTALRATE_COLON">Rental Rate:</td>
|
||||
<td>
|
||||
<input type="text" id="dialog_rentalrate" maxlength="12" tabindex="7" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MR_RETURNTERM_COLON">Rental Term:</td>
|
||||
<td>
|
||||
<input type="text" id="dialog_term" maxlength="8" tabindex="8" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MR_RENTALTERMUNIT_COLON">Rental Term Unit:</td>
|
||||
<td>
|
||||
<select id="dialog_termunit" style="width: 324px; height: 22px;" tabindex="9">
|
||||
<option value="Hourly" data-lgid="P_MR_HOURLY">Hourly</option>
|
||||
<option value="Daily" data-lgid="P_MR_DAILY">Daily</option>
|
||||
<option value="Weekly" data-lgid="P_MR_WEEKLY">Weekly</option>
|
||||
<option value="Monthly" data-lgid="P_MR_MONTHLY">Monthly</option>
|
||||
<option value="Annually" data-lgid="P_MR_ANNUALLY">Annually</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MR_RTBILLINGDATE_COLON">Rental Term Billing Date:</td>
|
||||
<td>
|
||||
<input type="text" id="dialog_rentaltermbillingdate" maxlength="50" tabindex="9" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MR_DAYSBILLINGCYCLE_COLON">Number of Days in Billing Cycle:</td>
|
||||
<td>
|
||||
<input type="text" id="dialog_billingcycledays" maxlength="8" tabindex="9" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MR_RENTALDATEON_COLON">Rental Date On:</td>
|
||||
<td>
|
||||
<input type="text" id="dialog_rentaldata" maxlength="50" tabindex="10" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MR_PROJECTRETURNDATE_COLON">Proj.Return Date:</td>
|
||||
<td>
|
||||
<input type="text" id="dialog_projectreturndate" maxlength="50" tabindex="11" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MR_RETURNDATE_COLON">Return Date:</td>
|
||||
<td>
|
||||
<input type="text" id="dialog_returndate" maxlength="50" tabindex="12" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MR_PONUMBER_COLON">P.O.#:</td>
|
||||
<td>
|
||||
<input type="text" id="dialog_ponumber" maxlength="100" tabindex="13" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MR_INSUREDVALUE_COLON">Insured Value:</td>
|
||||
<td>
|
||||
<input type="text" id="dialog_insuredvalue" maxlength="13" tabindex="68" autocomplete="off" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MR_COMMENTS_COLON">Comments:</td>
|
||||
<td>
|
||||
<textarea id="dialog_comments" class="inputbox" maxlength="1000" tabindex="14" style="width: 540px; height: 120px;"></textarea>
|
||||
<span id="span_a" style="margin-left: 50px;"><a href="#" onclick="OnViewChangeHistory();" data-lgid="P_MR_VIEWCHANGEHIS">View Change History</a></span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="lblRentalHistory" class="subtitle" style="display: none;">
|
||||
<span data-lgid="P_MR_RENTALHISTORY">Rental History</span>
|
||||
</div>
|
||||
<div class="content_main" id="rentalListDiv" style="max-height: 500px; margin-top: 10px; display: none;">
|
||||
<div>
|
||||
<table id="tbRentals" class="main_table" style="width: 100%; table-layout: fixed;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 10%;" sort="Outside" data-lgid="P_MR_OUTSIDEINTERNAL">Outside/Internal</th>
|
||||
<th style="width: 10%;" sort="Vendor" data-lgid="P_MR_RENTALVENDOR">Rental Vendor</th>
|
||||
<th style="width: 8%;" sort="RentalRate" data-lgid="P_MR_RENTALRATE">Rental Rate</th>
|
||||
<th style="width: 8%;" sort="Term" data-lgid="P_MR_TERM">Term</th>
|
||||
<th style="width: 8%;" sort="TermUnit" data-lgid="P_MR_TERMUNIT">Term Unit</th>
|
||||
<th style="width: 8%;" sort="RentalDate" data-lgid="P_MR_RENTALDATEON">Rental Date On</th>
|
||||
<th style="width: 8%;" sort="ProjectReturnDate" data-lgid="P_MR_PROJECTEDRETURN">Projected Return</th>
|
||||
<th style="width: 8%;" sort="ReturnDate" data-lgid="P_MR_RETURNDATE">Return Date</th>
|
||||
<th style="width: 8%;" sort="PONumber" data-lgid="P_MR_PURCHASEORDERN">Purchase Order #</th>
|
||||
<th style="width: 24%;" sort="Comments" data-lgid="P_MR_COMMENTS">Comments</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="rentalsDiv" class="content_main">
|
||||
<table class="main_table" style="min-width: 200px; width: 100%; table-layout: fixed;">
|
||||
<tbody id="tbody_rentals">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</asp:Content>
|
76
Site/MachineDeviceManagement/AddRental.aspx.cs
Normal file
@ -0,0 +1,76 @@
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor;
|
||||
using IronIntel.Contractor.Site;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class AddRental : MachineDeviceBasePage
|
||||
{
|
||||
|
||||
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
|
||||
public string ContractorID = "";
|
||||
public string RentalID = "";
|
||||
public string MachineID = "";
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!CheckLoginSession())
|
||||
{
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
string methodName = Request.Form["MethodName"];
|
||||
if (!string.IsNullOrEmpty(methodName))
|
||||
{
|
||||
ProcessRequest(methodName);
|
||||
}
|
||||
else if (!IsPostBack)
|
||||
{
|
||||
this.Title = PageTitle;
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
if (!permission)
|
||||
RedirectToLoginPage();
|
||||
ContractorID = Request.Params["cid"];
|
||||
RentalID = Request.Params["rid"];
|
||||
MachineID = Request.Params["mid"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var user = GetCurrentUser();
|
||||
return user != null && user.UserType >= IronIntel.Contractor.Users.UserTypes.Common;
|
||||
}
|
||||
|
||||
public bool IsAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
222
Site/MachineDeviceManagement/AssetMergeHistory.aspx
Normal file
@ -0,0 +1,222 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/IronIntelMasterPage.master" AutoEventWireup="true" CodeFile="AssetMergeHistory.aspx.cs" Inherits="AssetMergeHistory" %>
|
||||
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="holder_head" runat="Server">
|
||||
<style type="text/css">
|
||||
::-ms-clear, ::-ms-reveal {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.selectinput {
|
||||
width: 150px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.dialog-content table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dialog-content table td.label {
|
||||
width: 160px;
|
||||
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: 200px;
|
||||
height: 18px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
.dialog-content table td input[type="checkbox"] {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.dialog-content table td textarea {
|
||||
height: 100px;
|
||||
max-width: 200px;
|
||||
}
|
||||
|
||||
#dialogdatatb td {
|
||||
padding-top: 30px;
|
||||
}
|
||||
|
||||
.a {
|
||||
text-decoration: none;
|
||||
color: #2140fb;
|
||||
}
|
||||
|
||||
.machinetd {
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
<link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" />
|
||||
<script src="<%=GetFileUrlWithVersion("../Maintenance/js/inputdatactr.js")%>" type="text/javascript"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/editableselect.js")%>"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function assetrequest(method, param, callback, error) {
|
||||
_network.request("MachineDeviceManagement/AssetMergeHistory.aspx", -1, method, param, callback, error || function (e) {
|
||||
showmaskbg(false, true);
|
||||
showAlert(GetTextByKey('P_MR_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_MR_QUERY', 'Query'));
|
||||
});
|
||||
}
|
||||
|
||||
function devicerequest(method, param, callback, error) {
|
||||
_network.request("MachineDeviceManagement/ManageRentals.aspx", -1, method, param, callback, error || function (e) {
|
||||
showmaskbg(false, true);
|
||||
showAlert(GetTextByKey('P_MR_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_MR_QUERY', 'Query'));
|
||||
});
|
||||
}
|
||||
|
||||
function OnRefresh() {
|
||||
showloading(true);
|
||||
var searchtxt = "";
|
||||
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
|
||||
|
||||
assetrequest("GetAssetMerges", searchtxt, function (data) {
|
||||
showloading(false);
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MR_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
showMerges(data);
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function showMerges(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
for (var j in r) {
|
||||
if (j === "CompletedOn")
|
||||
r[j] = { DisplayValue: r["CompletedOnStr"], Value: r[j] };
|
||||
else if (j === "MergeOn")
|
||||
r[j] = { DisplayValue: r["MergeOnStr"], Value: r[j] };
|
||||
else if (j === "Completed")
|
||||
r[j] = { DisplayValue: r["Completed"] ? "Yes" : "No", Value: r[j] };
|
||||
else if (j === "FromAsset") {
|
||||
r.FromAssetName = r["FromAsset"].Name;
|
||||
r.FromAssetName2 = r["FromAsset"].Name2;
|
||||
r.FromAssetVIN = r["FromAsset"].VIN;
|
||||
r.FromAssetMakeName = r["FromAsset"].MakeName;
|
||||
r.FromAssetModelName = r["FromAsset"].ModelName;
|
||||
r.FromAssetTypeName = r["FromAsset"].TypeName;
|
||||
r.FromAssetDisplayName = r["FromAsset"].DisplayName;
|
||||
}
|
||||
else if (j === "ToAsset") {
|
||||
r.ToAssetName = r["ToAsset"].Name;
|
||||
r.ToAssetName2 = r["ToAsset"].Name2;
|
||||
r.ToAssetVIN = r["ToAsset"].VIN;
|
||||
r.ToAssetMakeName = r["ToAsset"].MakeName;
|
||||
r.ToAssetModelName = r["ToAsset"].ModelName;
|
||||
r.ToAssetTypeName = r["ToAsset"].TypeName;
|
||||
r.ToAssetDisplayName = r["ToAsset"].DisplayName;
|
||||
}
|
||||
}
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
|
||||
grid_dt.setData(rows);
|
||||
}
|
||||
|
||||
var grid_dt;
|
||||
function InitGridData() {
|
||||
|
||||
grid_dt = new GridView('#mergelist');
|
||||
grid_dt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'FromAssetDisplayName', caption: GetTextByKey("P_MA_FROMASSETNAME", "From Asset Name"), valueIndex: 'FromAssetDisplayName', css: { 'width': 180, 'text-align': 'left' } },
|
||||
{ name: 'FromAssetVIN', caption: GetTextByKey("P_MA_FROMASSETVIN", "From Asset VIN"), valueIndex: 'FromAssetVIN', css: { 'width': 180, 'text-align': 'left' } },
|
||||
{ name: 'ToAssetDisplayName', caption: GetTextByKey("P_MA_TOSSETNAME", "To Asset Name"), valueIndex: 'ToAssetDisplayName', css: { 'width': 180, 'text-align': 'left' } },
|
||||
{ name: 'ToAssetVIN', caption: GetTextByKey("P_MA_TOASSETVIN", "To Asset VIN"), valueIndex: 'ToAssetVIN', css: { 'width': 180, 'text-align': 'left' } },
|
||||
{ name: 'MergeOn', caption: GetTextByKey("P_MA_MERGEDATE", "Merge Time"), valueIndex: 'MergeOn', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'MergeByName', caption: GetTextByKey("P_MA_MERGEBY", "Merge By"), valueIndex: 'MergeByName', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'Completed', caption: GetTextByKey("P_MA_COMPLETED", "Completed"), valueIndex: 'Completed', css: { 'width': 75, 'text-align': 'center' } },
|
||||
{ name: 'CompletedOn', caption: GetTextByKey("P_MA_COMPLETEDDATE", "Completed Date"), valueIndex: 'CompletedOn', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'Notes', caption: GetTextByKey("P_MA_NOTES", "Notes"), valueIndex: 'Notes', css: { 'width': 180, 'text-align': 'left' } }
|
||||
];
|
||||
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;
|
||||
columns.push(col);
|
||||
}
|
||||
grid_dt.canMultiSelect = false;
|
||||
grid_dt.columns = columns;
|
||||
grid_dt.init();
|
||||
|
||||
}
|
||||
|
||||
|
||||
$(function () {
|
||||
$("#content").applyFleetLanguageText();
|
||||
InitGridData();
|
||||
OnRefresh();
|
||||
|
||||
$('#searchinputtxt').keydown(searchEnter);
|
||||
|
||||
$(window).resize(function () {
|
||||
$("#mergelist").css("height", $(window).height() - $("#mergelist").offset().top - 4);
|
||||
grid_dt && grid_dt.resize();
|
||||
}).resize();
|
||||
|
||||
});
|
||||
|
||||
function searchEnter(e) {
|
||||
if (e.keyCode == 13 || e.keyCode == 9) {
|
||||
OnRefresh();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="holder_content" runat="Server">
|
||||
<div id="recordcontent" style="padding: 0px; margin: 0px;">
|
||||
<div class="page_title" data-lgid="P_MA_MERGEASSETHISTORY">Asset Merge History</div>
|
||||
<table style="width: 100%; border-collapse: collapse; line-height: 32px; min-width: 1200px;">
|
||||
<tr>
|
||||
<td>
|
||||
<input id="searchinputtxt" autocomplete="off" style="width: 300px; margin-left: 10px;" />
|
||||
<input class="search" type="button" onclick="OnRefresh();" value="Search" data-lgid="P_MR_SEARCH" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="function_title">
|
||||
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_MR_REFRESH">Refresh</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="clear"></div>
|
||||
<div id="mergelist"></div>
|
||||
</div>
|
||||
<div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div>
|
||||
|
||||
</asp:Content>
|
75
Site/MachineDeviceManagement/AssetMergeHistory.aspx.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor;
|
||||
using IronIntel.Contractor.Site;
|
||||
using IronIntel.Contractor.Site.Asset;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class AssetMergeHistory : AssetBasePage
|
||||
{
|
||||
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!CheckLoginSession())
|
||||
{
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
string methodName = Request.Form["MethodName"];
|
||||
if (!string.IsNullOrEmpty(methodName))
|
||||
{
|
||||
ProcessRequest(methodName);
|
||||
}
|
||||
else if (!IsPostBack)
|
||||
{
|
||||
this.Title = PageTitle;
|
||||
if ((int)GetCurrentUser().UserType != (int)UserTypes.SupperAdmin)
|
||||
RedirectToLoginPage();
|
||||
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
if (!permission)
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var user = GetCurrentUser();
|
||||
return user != null && user.UserType >= IronIntel.Contractor.Users.UserTypes.Common;
|
||||
}
|
||||
|
||||
public bool IsAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
124
Site/MachineDeviceManagement/DeviceManagementBase.master
Normal file
@ -0,0 +1,124 @@
|
||||
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="DeviceManagementBase.master.cs" Inherits="MachineDeviceManagement_DeviceManagementBase" %>
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head runat="server">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<title></title>
|
||||
<link rel="stylesheet" href="<%=GetUrl("css/default.css")%>" type="text/css" />
|
||||
<link rel="stylesheet" href="<%=GetUrl("css/split_sub.css")%>" type="text/css" />
|
||||
<style type="text/css">
|
||||
html, body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#search {
|
||||
background-color: rgb(235, 235, 235);
|
||||
border: none;
|
||||
padding-top: 5px;
|
||||
padding-bottom: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#search:hover {
|
||||
background: rgb(225, 225, 225);
|
||||
}
|
||||
</style>
|
||||
<style type="text/css">
|
||||
:root {
|
||||
<%=StyleVariables%>
|
||||
}
|
||||
|
||||
.data-grid {
|
||||
height: 100%;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
<link type="text/css" href="<%=GetUrl("js/components/css/gridview.css") %>" rel="stylesheet" />
|
||||
<link type="text/css" href="<%=GetUrl("css/override.css") %>" rel="stylesheet" />
|
||||
<script src="<%=GetUrl("js/jquery-3.6.0.min.js")%>" type="text/javascript"></script>
|
||||
<script src="<%=GetUrl("js/cookie.js")%>" type="text/javascript"></script>
|
||||
<script src="<%=GetUrl("js/utility.js")%>" type="text/javascript"></script>
|
||||
<script type="text/javascript" src="<%=GetUrl("js/components/gridview.js") %>"></script>
|
||||
<script type="text/javascript" src="<%=GetUrl("js/language.js") %>"></script>
|
||||
<script type="text/javascript">
|
||||
var canExport = <%= CanExportFile %>;
|
||||
_network.root = '<%=Page.ResolveUrl("~/")%>';
|
||||
var GridView = window.GridView || window['g5-gridview'];
|
||||
|
||||
function getText(s, flag) {
|
||||
return (s == null)
|
||||
? (flag ? '<i>null</i>' : '')
|
||||
: htmlencode(s, $('#div_text_holder')).replace(/ /g, ' ');
|
||||
}
|
||||
|
||||
function GetLanguageByCookie() {
|
||||
var lang = getCookie('<%=Common.LanguageCookieName%>');
|
||||
if (lang == null) {
|
||||
return "en-us";
|
||||
} else {
|
||||
return lang;
|
||||
}
|
||||
}
|
||||
|
||||
function systemrequest(method, param, callback, error) {
|
||||
_network.request("SystemSettings/SystemOptions.aspx", -1, method, param, callback, error || function (e) {
|
||||
console.log(e);
|
||||
showmaskbg(false, true);
|
||||
showAlert(GetTextByKey('P_WO_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_WO_QUERY', 'Query'));
|
||||
});
|
||||
}
|
||||
var systemunitofodometer;
|
||||
function GetSystemUnitOfOdometer() {
|
||||
systemrequest("GetSystemUnitOfOdometer", "", function (data) {
|
||||
systemunitofodometer = data;
|
||||
$('#dialogadd_sel_odometeruom').val(systemunitofodometer);
|
||||
$('#dialogadjust_sel_odometeruom').val(systemunitofodometer);
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
$(function () {
|
||||
_fleet.currentLang = GetLanguageByCookie();
|
||||
GetSystemUnitOfOdometer();
|
||||
$("#content1").applyFleetLanguageText(true);
|
||||
// 加载完毕后通知上级页面
|
||||
if (typeof window.parent.onsubpageloaded == 'function') {
|
||||
window.parent.onsubpageloaded();
|
||||
}
|
||||
if (typeof window.parent.ondocumentclick == 'function') {
|
||||
$(document.body).click(window.parent.ondocumentclick);
|
||||
}
|
||||
|
||||
function resizeContent() {
|
||||
if ($('.content_main').length > 0)
|
||||
$('.content_main').css('min-height', $(window).height() - $('.content_main').offset().top - 4);
|
||||
if ($('#machinesDiv').length > 0)
|
||||
$('#machinesDiv').css('min-height', $(window).height() - $('#machinesDiv').offset().top - 4);
|
||||
|
||||
$('#mask_bg').height($(document).outerHeight(false)).width($(document).outerWidth(false));
|
||||
}
|
||||
|
||||
$(window).resize(function () {
|
||||
resizeContent();
|
||||
});
|
||||
//window.onresize = resizeContent;
|
||||
resizeContent();
|
||||
|
||||
$(document.body).click(function (e) {
|
||||
if (typeof hidePanels === 'function')
|
||||
hidePanels();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content1">
|
||||
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
|
||||
</asp:ContentPlaceHolder>
|
||||
</div>
|
||||
<div id="div_text_holder"></div>
|
||||
</body>
|
||||
</html>
|
35
Site/MachineDeviceManagement/DeviceManagementBase.master.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using FI.FIC;
|
||||
using Foresight.Fleet.Services.Styles;
|
||||
using IronIntel.Contractor;
|
||||
using IronIntel.Contractor.iisitebase;
|
||||
using IronIntel.Contractor.Site;
|
||||
using IronIntel.Contractor.Users;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class MachineDeviceManagement_DeviceManagementBase : CommonBase
|
||||
{
|
||||
protected override bool ExportModule
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetUIStyle();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: errors when get the ui style.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
236
Site/MachineDeviceManagement/EngineHoursAdjustHistory.aspx
Normal file
@ -0,0 +1,236 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/IronIntelMasterPage.master" AutoEventWireup="true" CodeFile="EngineHoursAdjustHistory.aspx.cs" Inherits="EngineHoursAdjustHistory" %>
|
||||
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="holder_head" runat="Server">
|
||||
<style type="text/css">
|
||||
::-ms-clear, ::-ms-reveal {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.selectinput {
|
||||
width: 150px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.dialog-content table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dialog-content table td.label {
|
||||
width: 160px;
|
||||
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: 200px;
|
||||
height: 18px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
.dialog-content table td input[type="checkbox"] {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.dialog-content table td textarea {
|
||||
height: 100px;
|
||||
max-width: 200px;
|
||||
}
|
||||
|
||||
#dialogdatatb td {
|
||||
padding-top: 30px;
|
||||
}
|
||||
|
||||
.a {
|
||||
text-decoration: none;
|
||||
color: #2140fb;
|
||||
}
|
||||
|
||||
.machinetd {
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
<link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" />
|
||||
<script src="<%=GetFileUrlWithVersion("../Maintenance/js/inputdatactr.js")%>" type="text/javascript"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/editableselect.js")%>"></script>
|
||||
<script type="text/javascript">
|
||||
var IsDealer = <%=IsDealer ?"true":"false"%>;
|
||||
var IsAdmin =<%=IsAdmin ?"true":"false"%>;
|
||||
var contractorid = "<%=ContractorID %>";
|
||||
var MachineID = "<%=MachineID %>";
|
||||
|
||||
var machines;
|
||||
var editableSelectMachine;
|
||||
var listeditableSelectMachine;
|
||||
|
||||
function assetrequest(method, param, callback, error) {
|
||||
_network.request("MachineDeviceManagement/EngineHoursAdjustHistory.aspx", -1, method, param, callback, error || function (e) {
|
||||
showmaskbg(false, true);
|
||||
showAlert(GetTextByKey("P_MA_PAGEERROR", 'An unknown error occurred. Please refresh page.'), GetTextByKey("P_MA_QUERY", 'Query'));
|
||||
});
|
||||
}
|
||||
|
||||
function OnRefresh() {
|
||||
showloading(true);
|
||||
|
||||
var startdate = htmlencode($('#startdatetxt').val());
|
||||
var enddate = htmlencode($('#enddatetxt').val());
|
||||
assetrequest("GetEngineHoursAdjustmentHistory", contractorid + String.fromCharCode(170) + MachineID
|
||||
+ String.fromCharCode(170) + startdate + String.fromCharCode(170) + enddate
|
||||
, function (data) {
|
||||
showloading(false);
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
showEngineHoursHistory(data);
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
});
|
||||
}
|
||||
|
||||
function OnExport() {
|
||||
var from = htmlencode($('#startdatetxt').val());
|
||||
var to = htmlencode($('#enddatetxt').val());
|
||||
|
||||
var sortPath = grid_dt.sortKey;
|
||||
if (sortPath === undefined) sortPath = "";
|
||||
var desc = grid_dt.sortDirection !== 1;
|
||||
window.open("../ExportToFile.aspx?type=ehadjusthis&cid=" + contractorid + "&mid=" + MachineID
|
||||
+ "&from=" + from + "&to=" + to + "&sp=" + sortPath + "&desc=" + desc);
|
||||
}
|
||||
|
||||
|
||||
function showEngineHoursHistory(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
for (var j in r) {
|
||||
if (j === "AdjustmentLocalTime")
|
||||
r[j] = { DisplayValue: r["AdjustmentLocalTimeText"], Value: r[j] };
|
||||
else if (j === "EngineHoursLocalTime")
|
||||
r[j] = { DisplayValue: r["EngineHoursLocalTimeText"], Value: r[j] };
|
||||
}
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
|
||||
grid_dt.setData(rows);
|
||||
}
|
||||
|
||||
var grid_dt;
|
||||
function InitGridData() {
|
||||
grid_dt = new GridView('#enginehourslist');
|
||||
grid_dt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'AssetName', caption: GetTextByKey("P_MA_ASSETNAME", "Asset Name"), valueIndex: 'DisplayName', css: { 'width': 200, 'text-align': 'left' } },
|
||||
{ name: 'VIN', caption: GetTextByKey("P_MA_VIN", "VIN"), valueIndex: 'VIN', css: { 'width': 200, 'text-align': 'left' } },
|
||||
{ name: 'UserName', caption: GetTextByKey("P_MA_USERNAME", "User Name"), valueIndex: 'UserName', css: { 'width': 200, 'text-align': 'left' } },
|
||||
{ name: 'AdjustmentLocalTime', caption: GetTextByKey("P_MA_ADJUSTMENTTIME", "Adjustment Time"), valueIndex: 'AdjustmentLocalTime', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'EngineHours', caption: GetTextByKey("P_MA_ENGINEHOURNTERED", "Engine Hours Entered"), valueIndex: 'EngineHours', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'EngineHoursLocalTime', caption: GetTextByKey("P_MA_ENGINEHOURSTIME", "Engine Hours Time"), valueIndex: 'EngineHoursLocalTime', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'Notes', caption: GetTextByKey("P_MA_NOTES", "Notes"), valueIndex: 'Notes', css: { 'width': 300, 'text-align': 'left' } }
|
||||
];
|
||||
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;
|
||||
columns.push(col);
|
||||
}
|
||||
grid_dt.canMultiSelect = false;
|
||||
grid_dt.columns = columns;
|
||||
grid_dt.init();
|
||||
|
||||
}
|
||||
|
||||
|
||||
$(function () {
|
||||
InitGridData();
|
||||
OnRefresh();
|
||||
|
||||
$('#startdatetxt').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
|
||||
$('#enddatetxt').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
|
||||
$(window).resize(function () {
|
||||
$("#enginehourslist").css("height", $(window).height() - $("#enginehourslist").offset().top - 4);
|
||||
grid_dt && grid_dt.resize();
|
||||
}).resize();
|
||||
|
||||
});
|
||||
|
||||
function searchEnter(e) {
|
||||
if (e.keyCode == 13 || e.keyCode == 9) {
|
||||
OnRefresh();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="holder_content" runat="Server">
|
||||
<div id="recordcontent" style="padding: 0px; margin: 0px;">
|
||||
<div class="page_title" data-lgid="P_MA_ENGINEHOURSADJUSTMENTHISTORY">Engine Hours Adjustment History</div>
|
||||
<table style="width: 100%; border-collapse: collapse; line-height: 32px; min-width: 1200px;">
|
||||
<tr id="tr_search">
|
||||
<td>
|
||||
<span style="padding-left: 5px;" data-lgid="P_MA_STARTDATE_COLON">Start Date:</span>
|
||||
<span>
|
||||
<input id="startdatetxt" style="width: 100px;" value="<%=BeginDate %>" /></span>
|
||||
<span style="padding-left: 5px;" data-lgid="P_MA_ENDDATE_COLON">End Date:</span>
|
||||
<span>
|
||||
<input id="enddatetxt" style="width: 100px;" value="<%=EndDate %>" /></span>
|
||||
<input class="search" type="button" onclick="OnRefresh();" value="Search" data-lgid="P_MA_SEARCH" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="function_title">
|
||||
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_MA_REFRESH">Refresh</span>
|
||||
<span class="sbutton iconexport" onclick="OnExport();" data-lgid="P_MA_EXPORTTOEXCEL">Export to Excel</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="clear"></div>
|
||||
<div id="enginehourslist"></div>
|
||||
</div>
|
||||
<div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div>
|
||||
|
||||
</asp:Content>
|
@ -0,0 +1,81 @@
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor;
|
||||
using IronIntel.Contractor.Site;
|
||||
using IronIntel.Contractor.Site.Asset;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class EngineHoursAdjustHistory : AssetBasePage
|
||||
{
|
||||
public string BeginDate = "";
|
||||
public string EndDate = "";
|
||||
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
|
||||
public string MachineID = "";
|
||||
public string ContractorID = "";
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!CheckLoginSession())
|
||||
{
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
string methodName = Request.Form["MethodName"];
|
||||
if (!string.IsNullOrEmpty(methodName))
|
||||
{
|
||||
ProcessRequest(methodName);
|
||||
}
|
||||
else if (!IsPostBack)
|
||||
{
|
||||
this.Title = PageTitle;
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
if (!permission)
|
||||
RedirectToLoginPage();
|
||||
ContractorID = Request.Params["cid"];
|
||||
MachineID = Request.Params["mid"];
|
||||
}
|
||||
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
|
||||
BeginDate = userlocaldate.AddMonths(-1).ToShortDateString();
|
||||
EndDate = userlocaldate.ToShortDateString();
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var user = GetCurrentUser();
|
||||
return user != null && user.UserType >= IronIntel.Contractor.Users.UserTypes.Common;
|
||||
}
|
||||
|
||||
public bool IsAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
77
Site/MachineDeviceManagement/MachineDeviceManagement.aspx
Normal file
@ -0,0 +1,77 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/IronIntelMasterPage.master" AutoEventWireup="true" CodeFile="MachineDeviceManagement.aspx.cs" Inherits="MachineDeviceManagement_MachineDeviceManagement" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="holder_head" runat="Server">
|
||||
<link href="<%=GetFileUrlWithVersion("../css/split.css")%>" rel="stylesheet" type="text/css" />
|
||||
<script src="<%=GetFileUrlWithVersion("../js/split.js")%>"></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
setFavoriteDisplay(true);
|
||||
|
||||
window.changePage(old_hash);
|
||||
});
|
||||
|
||||
function afterpagechanged(hash, name) {
|
||||
setFavorateStyle(hash, name);
|
||||
};
|
||||
</script>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="holder_content" runat="Server">
|
||||
<div id="set_left">
|
||||
<ul class="ul_menu">
|
||||
<li id="nav_arrow">
|
||||
<div class="icn collapse"></div>
|
||||
</li>
|
||||
<%if (ManageMachinesDisplay)
|
||||
{%>
|
||||
<li class="nav_item" id="nav_managmachines" page="ManageMachines.aspx" title="Manage Assets" data-title-lgid="P_MANAGEASSETS"><a href="#nav_managmachines">
|
||||
<div>
|
||||
<button class="iconmanageasset"></button>
|
||||
</div>
|
||||
<span data-lgid="P_MANAGEASSETS">Manage Assets</span></a></li>
|
||||
<li class="nav_item" id="nav_managrentals" page="ManageRentals.aspx" title="View/Edit Rental Occurences. To add new assets use Manage Assets" data-title-lgid="P_MANAGERENTALS_TITLE"><a href="#nav_managrentals">
|
||||
<div>
|
||||
<button class="iconmanagerentals"></button>
|
||||
</div>
|
||||
<span data-lgid="P_MANAGERENTALS">Manage Rentals</span></a></li>
|
||||
<%} %>
|
||||
<%if (MachineGroupDisplay)
|
||||
{%>
|
||||
<li class="nav_item" id="nav_machinegroups" page="MachineGroups.aspx" title="Asset Groups" data-title-lgid="P_ASSETGROUPS"><a href="#nav_machinegroups">
|
||||
<div>
|
||||
<button class="iconassetgroups"></button>
|
||||
</div>
|
||||
<span data-lgid="P_ASSETGROUPS">Asset Groups</span></a></li>
|
||||
<%} %>
|
||||
<%if (ManageGPSDevicesDisplay)
|
||||
{%>
|
||||
<li class="nav_item" id="nav_managegpsdevices" page="ManageGPSDevices.aspx" title="Manage Devices" data-title-lgid="P_MANAGEDEVICES"><a href="#nav_managegpsdevices">
|
||||
<div>
|
||||
<button class="iconmanagegpsdevices"></button>
|
||||
</div>
|
||||
<span data-lgid="P_MANAGEDEVICES">Manage Devices</span></a></li>
|
||||
<%} %>
|
||||
<%if (ManageModelDisplay)
|
||||
{%>
|
||||
<li class="nav_item" id="nav_managmodels" page="ManageModels.aspx" title="Manage Models" data-title-lgid="P_MANAGEMODELS"><a href="#nav_managmodels">
|
||||
<div>
|
||||
<button class="iconmanagmodels"></button>
|
||||
</div>
|
||||
<span data-lgid="P_MANAGEMODELS">Manage Models</span></a></li>
|
||||
<%} %>
|
||||
<%if (ShareAssetDisplay)
|
||||
{%>
|
||||
<li class="nav_item" id="nav_shareasset" page="ShareMachines.aspx" title="Share Assets" data-title-lgid="P_SHAREASSETS"><a href="#nav_shareasset">
|
||||
<div>
|
||||
<button class="iconshare"></button>
|
||||
</div>
|
||||
<span data-lgid="P_SHAREASSETS">Share Assets</span></a></li>
|
||||
<%} %>
|
||||
</ul>
|
||||
<div class="hostmask maskbg" style="display: none;"></div>
|
||||
</div>
|
||||
<div id="set_right">
|
||||
<div class="loading_holder">
|
||||
<div class="loading_icon icn icn-spin"></div>
|
||||
</div>
|
||||
</div>
|
||||
</asp:Content>
|
75
Site/MachineDeviceManagement/MachineDeviceManagement.aspx.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor;
|
||||
using IronIntel.Contractor.Site;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class MachineDeviceManagement_MachineDeviceManagement : MachineDeviceBasePage
|
||||
{
|
||||
protected bool ManageGPSDevicesDisplay = false;
|
||||
protected bool ManageMachinesDisplay = false;
|
||||
protected bool ManageModelDisplay = false;
|
||||
protected bool MachineGroupDisplay = false;
|
||||
protected bool ShareAssetDisplay = false;
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!CheckLoginSession())
|
||||
{
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
string methodName = Request.Form["MethodName"];
|
||||
if (!string.IsNullOrEmpty(methodName))
|
||||
{
|
||||
ProcessRequest(methodName);
|
||||
}
|
||||
else if (!IsPostBack)
|
||||
{
|
||||
this.Title = PageTitle;
|
||||
|
||||
IronIntel.Contractor.Users.UserInfo user = GetCurrentUser();
|
||||
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin)
|
||||
{
|
||||
ManageMachinesDisplay = true;
|
||||
ManageGPSDevicesDisplay = true;
|
||||
ManageModelDisplay = true;
|
||||
if (!IronIntel.Contractor.SystemParams.IsDealer)
|
||||
MachineGroupDisplay = true;
|
||||
}
|
||||
else if (user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
|
||||
{
|
||||
ManageMachinesDisplay = true;
|
||||
ManageModelDisplay = true;
|
||||
if (!IronIntel.Contractor.SystemParams.IsDealer)
|
||||
MachineGroupDisplay = true;
|
||||
}
|
||||
|
||||
if (user.UserType < IronIntel.Contractor.Users.UserTypes.Admin)
|
||||
{
|
||||
if (CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS))
|
||||
{
|
||||
ManageMachinesDisplay = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (user.UserType < IronIntel.Contractor.Users.UserTypes.SupperAdmin)
|
||||
{
|
||||
if (CheckRight(SystemParams.CompanyID, Foresight.Fleet.Services.User.Feature.MANAGE_DEVICES))
|
||||
ManageGPSDevicesDisplay = true;
|
||||
}
|
||||
|
||||
bool license = SystemParams.HasLicense("ShareAsset");
|
||||
ShareAssetDisplay = ManageMachinesDisplay && license && !SystemParams.IsDealer;
|
||||
|
||||
if (!ManageMachinesDisplay && !ManageGPSDevicesDisplay)
|
||||
RedirectToEntryPage();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
410
Site/MachineDeviceManagement/MachineGroups.aspx
Normal file
@ -0,0 +1,410 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/MachineDeviceManagement/DeviceManagementBase.master" AutoEventWireup="true" CodeFile="MachineGroups.aspx.cs" Inherits="MachineDeviceManagement_MachineGroups" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
|
||||
<style type="text/css">
|
||||
::-ms-clear, ::-ms-reveal {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.selectinput {
|
||||
width: 150px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.a {
|
||||
text-decoration: none;
|
||||
color: #2140fb;
|
||||
}
|
||||
|
||||
.ctl_button {
|
||||
font-family: 'CalciteWebCoreIcons';
|
||||
display: block;
|
||||
margin: 6px auto;
|
||||
width: 60px;
|
||||
height: 22px;
|
||||
line-height: 21px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#dialog_machinegroup {
|
||||
width: 860px;
|
||||
top: 60px;
|
||||
left: 150px;
|
||||
}
|
||||
|
||||
.inputbox {
|
||||
width: 564px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
#dialog_description {
|
||||
padding: 2px;
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
.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: 160px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.group_table .main_table td {
|
||||
width: 160px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.group_table .main_table td div {
|
||||
width: 160px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
word-break: keep-all;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="<%=GetFileUrlWithVersion("../Security/js/controls.js")%>" type="text/javascript"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../Maintenance/js/inputdatactr.js")%>" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
var machineGroups = [];
|
||||
|
||||
function devicerequest(method, param, callback, error) {
|
||||
_network.request("MachineDeviceManagement/ManageMachines.aspx", -1, method, param, callback, error || function (e) {
|
||||
console.log(e);
|
||||
showmaskbg(false, true);
|
||||
showAlert(GetTextByKey('P_AG_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_AG_QUERY', 'Query'));
|
||||
});
|
||||
}
|
||||
|
||||
function CloseDialog(type) {
|
||||
$('#dialog_machinegroup1').hideDialog();
|
||||
if (type == 1) {
|
||||
OnRefresh();
|
||||
}
|
||||
else {
|
||||
showmaskbg(false);
|
||||
}
|
||||
}
|
||||
|
||||
function ShowMachineGroupDialog(type) {
|
||||
showmaskbg(true);
|
||||
$('#dialog_machinegroup1')
|
||||
.attr('act', type)
|
||||
.showDialogRight();
|
||||
}
|
||||
|
||||
function OnDelete(group) {
|
||||
if (!group) {
|
||||
return;
|
||||
}
|
||||
var alerttitle = GetTextByKey("P_AG_DELETEASSETGROUP", 'Delete Asset Group');
|
||||
showConfirm(GetTextByKey("P_AG_DOYOUWANTTODELETETHEASSETGROUP", 'Do you want to delete the Asset Group?'), alerttitle, function () {
|
||||
showmaskbg(true);
|
||||
devicerequest("DeleteAssetGroup", group.Id, function (data) {
|
||||
if (data !== "OK") {
|
||||
showAlert(GetTextByKey("P_AG_NOTDELETEASSETGROUP", 'Asset Group can not be deleted because it is in use.'), alerttitle);
|
||||
} else
|
||||
OnRefresh();
|
||||
}, function (err) {
|
||||
showAlert(GetTextByKey("P_AG_DELETEASSETGROUPFAILED", 'Failed to delete this Asset Group.'), alerttitle);
|
||||
showmaskbg(false);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function OnAdd() {
|
||||
machineGroupID = undefined;
|
||||
|
||||
ShowMachineGroupDialog('add');
|
||||
execIframeFunc("init", [], "iframe_machinegroup");
|
||||
return;
|
||||
}
|
||||
|
||||
var machineGroupID;
|
||||
var indexInEdit = -1;
|
||||
function OnEdit() {
|
||||
indexInEdit = grid_dt.selectedIndex;
|
||||
if (indexInEdit < 0) {
|
||||
showAlert(GetTextByKey("P_AG_PLEASESELECTAMACHINEGROUP", "Please select a Machine Group."), GetTextByKey("P_AG_EDITMACHINEGROUP", "Edit Machine Group"));
|
||||
return;
|
||||
}
|
||||
var group = grid_dt.source[indexInEdit].Values;
|
||||
if (!group) {
|
||||
machineGroupID = undefined;
|
||||
return;
|
||||
}
|
||||
|
||||
machineGroupID = group.Id;
|
||||
|
||||
ShowMachineGroupDialog('edit');
|
||||
execIframeFunc("init", [machineGroupID, grid_dt.source, indexInEdit], "iframe_machinegroup");
|
||||
return;
|
||||
}
|
||||
|
||||
function OnDblClick(e) {
|
||||
OnEdit();
|
||||
}
|
||||
|
||||
var opened = false;
|
||||
var refreshed = false;
|
||||
|
||||
function Opened() {
|
||||
opened = true;
|
||||
if (refreshed) {
|
||||
showmaskbg(false);
|
||||
}
|
||||
}
|
||||
|
||||
function OnRefresh() {
|
||||
showloading(true);
|
||||
|
||||
var searchtxt = "";
|
||||
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
|
||||
devicerequest("GetAssetGroups", "" + String.fromCharCode(170) + searchtxt, function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_AG_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
if (data && data.length > 0)
|
||||
machineGroups = data;
|
||||
else
|
||||
machineGroups = [];
|
||||
showMachineGroups(data);
|
||||
|
||||
refreshed = true;
|
||||
if (opened) {
|
||||
showloading(false);
|
||||
}
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
});
|
||||
}
|
||||
|
||||
function showMachineGroups(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
|
||||
grid_dt.setData(rows);
|
||||
}
|
||||
|
||||
var grid_dt;
|
||||
function InitGridData() {
|
||||
$('#btnEdit').attr("disabled", "disabled");
|
||||
|
||||
grid_dt = new GridView('#grouplist');
|
||||
grid_dt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'Name', caption: GetTextByKey("P_AG_GROUPNAME", "Group Name"), valueIndex: 'Name', css: { 'width': 360, 'text-align': 'left' } },
|
||||
{ name: 'Description', caption: GetTextByKey("P_AG_DESCRIPTION", "Description"), valueIndex: 'Description', css: { 'width': 360, 'text-align': 'left' } },
|
||||
{ name: 'Code', caption: GetTextByKey("P_AG_CODE", "Code"), valueIndex: 'Code', css: { 'width': 200, 'text-align': 'left' } },
|
||||
{ name: 'Edit', caption: "", css: { 'width': 30, 'text-align': 'center' } },
|
||||
{ name: 'Delete', caption: "", 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;
|
||||
if (col.name === "Edit") {
|
||||
col.isurl = true;
|
||||
col.text = "\uf044";
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
OnEdit();
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
}
|
||||
col.attrs = { 'title': GetTextByKey("P_AG_EDIT", 'Edit') };
|
||||
}
|
||||
else if (col.name === "Delete") {
|
||||
col.isurl = true;
|
||||
col.text = "\uf00d";
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
OnDelete(this);
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
};
|
||||
col.attrs = { 'title': GetTextByKey("P_AG_DELETE", 'Delete') };
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_dt.canMultiSelect = false;
|
||||
grid_dt.columns = columns;
|
||||
grid_dt.init();
|
||||
grid_dt.rowdblclick = OnEdit;
|
||||
|
||||
grid_dt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_dt.source[rowindex];
|
||||
if (rowdata) {
|
||||
machineGroupID = rowdata.Values.ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function changeGridSelectIndex(index) {
|
||||
grid_dt.selectedIndexes = [index];
|
||||
grid_dt.scrollToIndex(index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$(function () {
|
||||
setPageTitle(GetTextByKey("P_ASSETGROUPS", "Asset Groups"), true);
|
||||
$("#iframe_machinegroup").attr("src", "AddMachineGroup.aspx");
|
||||
InitGridData();
|
||||
OnRefresh();
|
||||
|
||||
$('#dialog_machinegroup').prop('iframe', true).dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
|
||||
$('#dialog_machinegroup').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
|
||||
$('#searchinputtxt').keydown(searchEnter);
|
||||
|
||||
$(window).resize(function () {
|
||||
$("#grouplist").css("height", $(window).height() - $("#grouplist").offset().top - 4);
|
||||
grid_dt && grid_dt.resize();
|
||||
}).resize();
|
||||
|
||||
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 param = htmlencode(searchtxt);
|
||||
window.open("../ExportToFile.aspx?type=assetgroups¶m=" + param);
|
||||
}
|
||||
</script>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
||||
<div id="recordcontent" style="padding: 0px; margin: 0px;">
|
||||
<div class="page_title" data-lgid="P_ASSETGROUPS">Asset Groups</div>
|
||||
<div class="search_bar">
|
||||
<input type="password" autocomplete="new-password" style="display: none" />
|
||||
<input type="text" id="searchinputtxt" autocomplete="off" />
|
||||
<input id="search" type="button" onclick="OnRefresh();" value="Search" data-lgid="P_AG_SEARCH" style="margin-left: 5px;"/>
|
||||
</div>
|
||||
<div class="function_title">
|
||||
<span class="sbutton iconadd" onclick="OnAdd();" data-lgid="P_AG_ADD">Add</span>
|
||||
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_AG_REFRESH">Refresh</span>
|
||||
<span id="spExport" class="sbutton iconexport" onclick="OnExport();" data-lgid="P_UTILITY_EXPORTTOEXCEL">Export to Excel</span>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<div id="grouplist"></div>
|
||||
</div>
|
||||
<div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div>
|
||||
|
||||
<div class="dialog" id="dialog_machinegroup" style="display: none;">
|
||||
<div class="dialog-title"><span class="title">Add Asset Group</span><em class="dialog-close"></em></div>
|
||||
<div class="dialog-content">
|
||||
<div class="dialog-subheader">Asset Group Properties</div>
|
||||
<table class="group_table">
|
||||
<tr>
|
||||
<td class="label">Group Name:</td>
|
||||
<td>
|
||||
<input type="text" id="dialog_groupname" class="inputbox" maxlength="200" tabindex="1" style="width: 300px;" />
|
||||
</td>
|
||||
<td class="label" style="width: 50px; text-align: right;">Code:</td>
|
||||
<td>
|
||||
<input type="text" id="dialog_groupcode" class="inputbox" maxlength="50" tabindex="1" style="width: 200px;" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Description:</td>
|
||||
<td colspan="3">
|
||||
<textarea id="dialog_description" class="inputbox" maxlength="1000" tabindex="2"></textarea></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="dialog-subheader">Group Assets</div>
|
||||
|
||||
<div style="margin-top: 5px; margin-bottom: 5px;">
|
||||
<span>Type: </span>
|
||||
<select id="sel_machine_type" style="min-width: 120px;"></select>
|
||||
<input type="text" id="txt_machine_key" />
|
||||
<input type="button" class="ybutton" id="button_machine_filter" value="Filter" />
|
||||
</div>
|
||||
<table id="tab_groupmachine" class="group_table" style="min-height: 300px;">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Available Assets</td>
|
||||
<td></td>
|
||||
<td>Assigned Group Assets
|
||||
<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="width: 380px;">
|
||||
<div id="availablemachinelist" style="height: 300px;"></div>
|
||||
</td>
|
||||
<td style="text-align: center; vertical-align: middle; width: 80px;">
|
||||
<input class="ctl_button" type="button" value="" tabindex="3" onclick="OnEditorAdd();" />
|
||||
<input class="ctl_button" type="button" value="" tabindex="4" onclick="OnEditorAddAll();" />
|
||||
<input class="ctl_button" type="button" value="" tabindex="5" onclick="OnEditorRemove();" />
|
||||
<input class="ctl_button" type="button" value="" tabindex="6" onclick="OnEditorRemoveAll();" />
|
||||
</td>
|
||||
<td style="width: 380px;">
|
||||
<div id="selectedmachinelist" style="height: 300px;"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="dialog-func">
|
||||
<input type="button" value="Cancel" class="dialog-close" tabindex="18" />
|
||||
<input type="button" onclick="OnDialogOK();" value="OK" tabindex="17" />
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div class="maskbg" style="display: none;"></div>
|
||||
</div>
|
||||
|
||||
<div class="dialog" id="dialog_machinegroup1" style="display: none; height: 100%; border-bottom: 0; border-top: 0; z-index: 2">
|
||||
<iframe id="iframe_machinegroup" style="width: 100%; height: 100%; display: block; border: none"></iframe>
|
||||
<div class="maskbg" style="display: none"></div>
|
||||
</div>
|
||||
</asp:Content>
|
||||
|
42
Site/MachineDeviceManagement/MachineGroups.aspx.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor;
|
||||
using IronIntel.Contractor.Site;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class MachineDeviceManagement_MachineGroups : MachineDeviceBasePage
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!CheckLoginSession())
|
||||
{
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Title = PageTitle;
|
||||
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
if (!permission)
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
}
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
if (IronIntel.Contractor.SystemParams.IsDealer)
|
||||
return false;
|
||||
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var user = GetCurrentUser();
|
||||
return user != null && user.UserType >= IronIntel.Contractor.Users.UserTypes.Admin;
|
||||
}
|
||||
}
|
899
Site/MachineDeviceManagement/ManageGPSDevices.aspx
Normal file
@ -0,0 +1,899 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/MachineDeviceManagement/DeviceManagementBase.master" AutoEventWireup="true" CodeFile="ManageGPSDevices.aspx.cs" Inherits="ManageGPSDevices" %>
|
||||
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
|
||||
<style type="text/css">
|
||||
::-ms-clear, ::-ms-reveal {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.selectinput {
|
||||
width: 150px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.dialog-content table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dialog-content table td.label {
|
||||
width: 100px;
|
||||
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: 200px;
|
||||
height: 18px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
.dialog-content table td input[type="checkbox"] {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.dialog-content table td textarea {
|
||||
height: 100px;
|
||||
/*max-width: 200px;*/
|
||||
width: 350px;
|
||||
}
|
||||
|
||||
#dialogdatatb td {
|
||||
padding-top: 30px;
|
||||
}
|
||||
|
||||
.a {
|
||||
text-decoration: none;
|
||||
color: #2140fb;
|
||||
}
|
||||
</style>
|
||||
|
||||
<link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" />
|
||||
<script src="<%=GetFileUrlWithVersion("../Maintenance/js/inputdatactr.js")%>" type="text/javascript"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/editableselect.js")%>" type="text/javascript"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../fic/js/utility.js")%>" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
var IsSuperAdmin =<%=IsSuperAdmin ?"true":"false"%>;
|
||||
var IsAdmin =<%=IsAdmin ?"true":"false"%>;
|
||||
var IsDealer = <%=IsDealer ?"true":"false"%>;
|
||||
|
||||
var contractors = [];
|
||||
|
||||
function devicerequest(method, param, callback, error) {
|
||||
_network.request("MachineDeviceManagement/ManageGPSDevices.aspx", -1, method, param, callback, error || function (e) {
|
||||
showmaskbg(false, true);
|
||||
showAlert(GetTextByKey('P_MD_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_MD_QUERY', 'Query'));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function OnExportInImport() {
|
||||
var d = JSON.stringify(errordata);
|
||||
var data = new FormData();
|
||||
data.append('type', 'set');
|
||||
data.append('ClientData', d);
|
||||
$.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=devicesexcel&key=" + data);
|
||||
},
|
||||
error: function (err) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function CloseDialog(type) {
|
||||
$('#dialog_gpsdevice1').hideDialog();
|
||||
if (type == 1) {
|
||||
OnRefresh();
|
||||
}
|
||||
else {
|
||||
showmaskbg(false);
|
||||
}
|
||||
}
|
||||
|
||||
function ShowDeviceDialog(type) {
|
||||
showmaskbg(true);
|
||||
$('#dialog_gpsdevice1')
|
||||
.attr('act', type)
|
||||
.showDialogRight();
|
||||
}
|
||||
|
||||
function OnAdd() {
|
||||
gpsDeviceID = undefined;
|
||||
gpsdata = undefined;
|
||||
|
||||
var cid = $('#sel_contractor').val();
|
||||
ShowDeviceDialog('add');
|
||||
execIframeFunc("init", [cid], "iframe_gpsdevice");
|
||||
}
|
||||
|
||||
var gpsDeviceID;
|
||||
var gpsdata;
|
||||
function OnEdit(type) {
|
||||
var gps = grid_dt.source[grid_dt.selectedIndex].Values;
|
||||
if (!gps) {
|
||||
gpsDeviceID = undefined;
|
||||
return;
|
||||
}
|
||||
|
||||
gpsdata = gps;
|
||||
gpsDeviceID = gps.Id;
|
||||
|
||||
var cid = $('#sel_contractor').val();
|
||||
ShowDeviceDialog('edit');
|
||||
execIframeFunc("init", [cid, gps, type], "iframe_gpsdevice");
|
||||
}
|
||||
|
||||
function OnDblClick(e) {
|
||||
OnEdit(0);
|
||||
}
|
||||
|
||||
function OnRefresh() {
|
||||
showloading(true);
|
||||
var cid = $('#sel_contractor').val();
|
||||
var searchtxt = "";
|
||||
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
|
||||
devicerequest("GetGPSDevices", JSON.stringify([cid, searchtxt]), function (data) {
|
||||
showDevices(data);
|
||||
|
||||
showloading(false);
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
});
|
||||
}
|
||||
var errordata;
|
||||
function showDevices(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
if (r.PairedAsset) {
|
||||
r.MachineID = r.PairedAsset.Id;
|
||||
r.VIN = r.PairedAsset.VIN;
|
||||
r.Name = r.PairedAsset.Name;
|
||||
r.Year = r.PairedAsset.Year;
|
||||
r.Make = r.PairedAsset.MakeName;
|
||||
r.Model = r.PairedAsset.ModelName;
|
||||
r.MachineType = r.PairedAsset.TypeName;
|
||||
r.EngineHours = r.PairedAsset.EngineHours;
|
||||
r.EngineHoursDate = r.PairedAsset.EngineHoursDate;
|
||||
r.EngineHoursDateStr = r.PairedAsset.EngineHoursDateStr;
|
||||
}
|
||||
|
||||
for (var j in r) {
|
||||
if (j === "Status")
|
||||
r[j] = { DisplayValue: r["Status"] === 1 ? "Active" : "Inactive", Value: r[j] };
|
||||
else if (j === "AddDate")
|
||||
r[j] = { DisplayValue: r["AddDateStr"], Value: r["AddDateStr1"] };
|
||||
else if (j === "InvoiceDate")
|
||||
r[j] = { DisplayValue: r["InvoiceDateStr"], Value: r[j] };
|
||||
else if (j === "ServiceStartDate")
|
||||
r[j] = { DisplayValue: r["ServiceStartDateStr"], Value: r["ServiceStartDateStr1"] };
|
||||
else if (j === "EngineHoursDate")
|
||||
r[j] = { DisplayValue: r["EngineHoursDateStr"], Value: r[j] };
|
||||
else if (j === "EngineHours")
|
||||
r[j] = r[j] === 0 ? "" : r[j];
|
||||
else if (j === "Year")
|
||||
r[j] = r[j] === 0 ? "" : r[j];
|
||||
else if (j === "Name")
|
||||
r[j] = r[j] === "0" ? "" : r[j];
|
||||
else if (j == "FIInstalltion") {
|
||||
r[j] = { DisplayValue: r[j] == 1 ? "Yes" : "No", Value: r[j] };
|
||||
}
|
||||
}
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
|
||||
grid_dt.setData(rows);
|
||||
}
|
||||
|
||||
var grid_dt;
|
||||
function InitGridData() {
|
||||
grid_dt = new GridView('#devicelist');
|
||||
grid_dt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'SN', caption: GetTextByKey("P_MD_SN", "Air ID or SN"), valueIndex: 'SerialNumber', css: { 'width': 120, 'text-align': 'left' } },
|
||||
{ name: 'AlternativeSerialNumber', caption: GetTextByKey("P_MD_ESN", "ESN"), valueIndex: 'AlternativeSerialNumber', css: { 'width': 120, 'text-align': 'left' } },
|
||||
{ name: 'DeviceType', caption: GetTextByKey("P_MD_DEVICETYPE", "Device Type"), valueIndex: 'DeviceType', allowFilter: true, css: { 'width': 120, 'text-align': 'left' } },
|
||||
{ name: 'Source', caption: GetTextByKey("P_MD_SOURCE", "Source"), valueIndex: 'SourceName', allowFilter: true, css: { 'width': 120, 'text-align': 'left' } },
|
||||
{ name: 'Status', caption: GetTextByKey("P_MD_STATUS", "Status"), valueIndex: 'Status', allowFilter: true, css: { 'width': 80, 'text-align': 'left' } },
|
||||
{ name: 'AddDate', caption: GetTextByKey("P_MD_ADDDATE", "Add Date"), valueIndex: 'AddDate', allowFilter: true, css: { 'width': 100, 'text-align': 'left' } },
|
||||
{ name: 'FIInstalltion', caption: GetTextByKey("P_MD_FIINSTALL", "FI Install"), valueIndex: 'FIInstalltion', allowFilter: true, css: { 'width': 100, 'text-align': 'left' } },
|
||||
{ name: 'Installer', caption: GetTextByKey("P_MD_INSTALLER", "Installer"), valueIndex: 'Installer', allowFilter: true, css: { 'width': 100, 'text-align': 'left' } },
|
||||
{ name: 'Notes', caption: GetTextByKey("P_MD_NOTES", "Notes"), valueIndex: 'Notes', css: { 'width': 200, 'text-align': 'left' } },
|
||||
{ name: 'ServiceStartDate', caption: GetTextByKey("P_MD_SERVICESTATDATE", "Service Start Date"), valueIndex: 'ServiceStartDate', allowFilter: true, css: { 'width': 110, 'text-align': 'left' } },
|
||||
{ name: 'VIN', caption: GetTextByKey("P_MD_ASSETVINSN", "Asset VIN/SN"), valueIndex: 'VIN', allowFilter: true, css: { 'width': 200, 'text-align': 'left' } },
|
||||
{ name: 'Name', caption: GetTextByKey("P_MD_ASSETNAME", "Asset Name"), valueIndex: 'Name', allowFilter: true, css: { 'width': 200, 'text-align': 'left' } },
|
||||
{ name: 'Year', caption: GetTextByKey("P_MD_YEAR", "Year"), valueIndex: 'Year', allowFilter: true, css: { 'width': 80, 'text-align': 'left' } },
|
||||
{ name: 'Make', caption: GetTextByKey("P_MD_MAKE", "Make"), valueIndex: 'Make', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'Model', caption: GetTextByKey("P_MD_MODEL", "Model"), valueIndex: 'Model', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'MachineType', caption: GetTextByKey("P_MD_TYPE", "Type"), valueIndex: 'MachineType', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'EngineHours', caption: GetTextByKey("P_MD_ENGINEHOURS", "Engine Hours"), valueIndex: 'EngineHours', css: { 'width': 90, 'text-align': 'left' } },
|
||||
{ name: 'EngineHoursDate', caption: GetTextByKey("P_MD_ENGINEHOURSDATE", "Engine Hours Date"), valueIndex: 'EngineHoursDate', css: { 'width': 120, 'text-align': 'left' } },
|
||||
{ name: 'InvoiceDate', caption: GetTextByKey("P_MD_INVOICEDATE", "Invoice Date"), valueIndex: 'InvoiceDate', css: { 'width': 100, 'text-align': 'left' } },
|
||||
{ name: 'InvoiceNumber', caption: GetTextByKey("P_MD_INVOICENUMBER", "Invoice #"), valueIndex: 'InvoiceNumber', css: { 'width': 120, 'text-align': 'left' } },
|
||||
{ name: 'SalesOrderNumber', caption: GetTextByKey("P_MD_XXXXXX", "Sales Order #"), valueIndex: 'SalesOrderNumber', css: { 'width': 120, 'text-align': 'left' } },
|
||||
{ name: 'Edit', caption: "", css: { 'width': 30, 'text-align': 'center' } },
|
||||
{ name: 'ONotes', caption: "", css: { 'width': 30, 'text-align': 'center' } },
|
||||
{ name: 'ChangeContractor', caption: "", 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;
|
||||
if (col.name === "Edit") {
|
||||
col.isurl = true;
|
||||
col.text = "\uf044";
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
OnEdit(0);
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
}
|
||||
col.attrs = { 'title': GetTextByKey("P_MD_EDIT", 'Edit') };
|
||||
}
|
||||
else if (col.name === "ONotes") {
|
||||
col.isurl = true;
|
||||
col.text = "\uf075";
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
OnEdit(1);
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
}
|
||||
col.attrs = { 'title': GetTextByKey("P_MD_NOTES", 'Notes') };
|
||||
}
|
||||
else if (col.name === "ChangeContractor") {
|
||||
if (!IsDealer)
|
||||
continue;
|
||||
col.isurl = true;
|
||||
col.text = "\uf0ec";
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
OnChangeContractor(1);
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
}
|
||||
col.attrs = { 'title': GetTextByKey("P_MD_CHANGECONTRACTOR", 'Change Contractor') };
|
||||
}
|
||||
else if (col.name === "FIInstalltion" || col.name === "Installer" || col.name === "SalesOrderNumber") {
|
||||
if (!IsSuperAdmin)
|
||||
continue;
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_dt.canMultiSelect = false;
|
||||
grid_dt.columns = columns;
|
||||
grid_dt.init();
|
||||
grid_dt.rowdblclick = function () { OnEdit(0) };
|
||||
|
||||
grid_dt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_dt.source[rowindex];
|
||||
if (rowdata) {
|
||||
gpsDeviceID = rowdata.Values.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function OnChangeContractor() {
|
||||
var gps = grid_dt.source[grid_dt.selectedIndex].Values;
|
||||
if (!gps) {
|
||||
gpsDeviceID = undefined;
|
||||
return;
|
||||
}
|
||||
var sel_con = $("#dialog_contractor").empty();
|
||||
//sel_con.append($('<option></option>').val("-1").text(" "));
|
||||
for (var i = 0; i < contractors.length; i++) {
|
||||
var kv = contractors[i];
|
||||
if ($('#sel_contractor').val() != kv.Key) {
|
||||
op_search = $('<option></option>').val(kv.Key).text(kv.Value);
|
||||
sel_con.append(op_search);
|
||||
}
|
||||
}
|
||||
$("#txtChangeConNotes").val("");
|
||||
//$("#dialog_contractor").val("");
|
||||
showmaskbg(true);
|
||||
$('#dialog_changecon').data("gps", gps)
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_changecon').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_changecon').width()) / 2
|
||||
}).showDialogfixed();
|
||||
}
|
||||
|
||||
function ChangeContractor() {
|
||||
var gps = $('#dialog_changecon').data("gps");
|
||||
if (!gps)
|
||||
return;
|
||||
var ps = [];
|
||||
ps.push(gps.Id);
|
||||
ps.push($("#dialog_contractor").val());
|
||||
ps.push(htmlencode($("#txtChangeConNotes").val()));
|
||||
devicerequest('ChangeGPSContractor', JSON.stringify(ps), function (data) {
|
||||
if (data !== "OK") {
|
||||
showAlert(data, GetTextByKey("P_MD_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
$('#dialog_changecon').hideDialog();
|
||||
OnRefresh();
|
||||
});
|
||||
}
|
||||
|
||||
//admin用户 获取所有contractor
|
||||
function getContractors() {
|
||||
devicerequest('GetContractors', '', function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MD_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
if (data && data.length > 0) {
|
||||
var sel_search = $('#sel_contractor').empty();
|
||||
var sel_con = $("#dialog_contractor").empty();
|
||||
sel_con.append($('<option></option>').val("-1").text(" "));
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var kv = data[i];
|
||||
var op_search = $('<option></option>').val(kv.Key).text(kv.Value);
|
||||
sel_search.append(op_search);
|
||||
op_search = $('<option></option>').val(kv.Key).text(kv.Value);
|
||||
sel_con.append(op_search);
|
||||
}
|
||||
contractors = data;
|
||||
}
|
||||
else
|
||||
contractors = [];
|
||||
|
||||
var contractorid = htmlencode($.trim($('#sel_contractor').val()));
|
||||
if (contractorid || contractorid == "")
|
||||
$("#btnAdd").hide();
|
||||
|
||||
OnRefresh();
|
||||
});
|
||||
}
|
||||
|
||||
//普通用户 获取可操作的contractor
|
||||
function GetContractorsByUser() {
|
||||
devicerequest('GetContractorsByUser', '', function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MD_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
if (data && data.length > 0) {
|
||||
var sel_search = $('#sel_contractor').empty();
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var kv = data[i];
|
||||
var op_search = $('<option></option>').val(kv.Key).text(kv.Value);
|
||||
sel_search.append(op_search);
|
||||
}
|
||||
contractors = data;
|
||||
}
|
||||
else
|
||||
contractors = [];
|
||||
var contractorid = htmlencode($.trim($('#sel_contractor').val()));
|
||||
if (contractorid || contractorid == "")
|
||||
$("#btnAdd").hide();
|
||||
|
||||
OnRefresh();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$(function () {
|
||||
setPageTitle(GetTextByKey("P_MANAGEDEVICES", "Manage Devices"), true);
|
||||
//$("#iframe_gpsdevice").attr("src", "AddDevice.aspx");
|
||||
InitGridData();
|
||||
|
||||
$('#dialog_gpsdevice').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
|
||||
$('#dialog_changecon').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
|
||||
if (IsDealer == true) {
|
||||
$('#span_contractor').css('display', '');
|
||||
if (IsAdmin)
|
||||
getContractors();
|
||||
else {
|
||||
GetContractorsByUser();
|
||||
}
|
||||
}
|
||||
else {
|
||||
OnRefresh();
|
||||
}
|
||||
|
||||
$('#dialog_import').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
|
||||
$('#dialog_import_result').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
|
||||
$("#sel_contractor").change(function () {
|
||||
OnRefresh();
|
||||
});
|
||||
|
||||
$('#searchinputtxt').keydown(searchEnter);
|
||||
|
||||
$(window).resize(function () {
|
||||
$("#devicelist").css("height", $(window).height() - $("#devicelist").offset().top - 4);
|
||||
grid_dt && grid_dt.resize();
|
||||
}).resize();
|
||||
|
||||
if (!canExport) {
|
||||
$('#spExport').hide();
|
||||
}
|
||||
});
|
||||
|
||||
function searchEnter(e) {
|
||||
if (e.keyCode == 13 || e.keyCode == 9) {
|
||||
OnRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
function OnExport() {
|
||||
var cid = $('#sel_contractor').val();
|
||||
var searchtxt = "";
|
||||
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
|
||||
|
||||
var p = [cid, searchtxt];
|
||||
var param = htmlencode(JSON.stringify(p));
|
||||
window.open("../ExportToFile.aspx?type=managedevices¶m=" + param);
|
||||
}
|
||||
|
||||
function getcolumnsdata() {
|
||||
var columnsdata = [];
|
||||
|
||||
columnsdata.push({ Id: "Source", Name: GetTextByKey("P_MD_SOURCE", "Source"), Width: 120, Key: 'SourceName' });
|
||||
columnsdata.push({ Id: "SN", Name: GetTextByKey("P_MD_SN", "SN"), Width: 120, Key: 'SerialNumber' });
|
||||
columnsdata.push({ Id: "ESN", Name: GetTextByKey("P_MD_ESN", "ESN"), Width: 120, Key: 'AlternativeSerialNumber' });
|
||||
columnsdata.push({ Id: "DeviceType", Name: GetTextByKey("P_MD_DEVICETYPE", "Device Type"), Width: 120, Key: 'DeviceType' });
|
||||
columnsdata.push({ Id: "Status", Name: GetTextByKey("P_MD_STATUS", "Status"), Width: 50, Key: 'Status' });
|
||||
columnsdata.push({ Id: "InvoiceDate", Name: GetTextByKey("P_MD_INVOICEDATE", "Invoice Date"), Width: 120, Key: 'InvoiceDate' });
|
||||
columnsdata.push({ Id: "InvoiceNumber", Name: GetTextByKey("P_MD_INVOICENUMBER", "Invoice #"), Width: 120, Key: 'InvoiceNumber' });
|
||||
if (IsSuperAdmin) {
|
||||
columnsdata.push({ Id: "SalesOrderNumber", Name: GetTextByKey("P_MD_XXXXXX", "Sales Order #"), Width: 120, Key: 'SalesOrderNumber' });
|
||||
}
|
||||
columnsdata.push({ Id: "ServiceStartDate", Name: GetTextByKey("P_MD_SERVICESTATDATE", "Service Start Date"), Width: 120, Key: 'ServiceStartDate' });
|
||||
columnsdata.push({ Id: "VIN/SN", Name: GetTextByKey("P_MA_VINSN", "VIN/SN"), Width: 120, Key: 'VIN' });
|
||||
columnsdata.push({ Id: "TamperAlerts", Name: GetTextByKey("P_MD_TAMPERALERTS", "Tamper Alerts"), Width: 120, Key: 'Tamper' });
|
||||
columnsdata.push({ Id: "Utilization", Name: GetTextByKey("P_MD_UTILIZATION", "Utilization"), Width: 120, Key: 'Utilization' });
|
||||
if (IsSuperAdmin) {
|
||||
columnsdata.push({ Id: "FIInstallation", Name: GetTextByKey("P_MD_FIINSTALLATION", "FI Installation"), Width: 120, Key: 'FIInstalltion' });
|
||||
columnsdata.push({ Id: "Installer", Name: GetTextByKey("P_MD_INSTALLER", "Installer"), Width: 120, Key: 'Installer' });
|
||||
}
|
||||
columnsdata.push({ Id: "Notes", Name: GetTextByKey("P_MD_NOTES", "Notes"), Width: 120, Key: 'Notes' });
|
||||
return columnsdata;
|
||||
}
|
||||
|
||||
function CreateSelect(excelcolumns, colid) {
|
||||
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(colid);
|
||||
}
|
||||
return sel;
|
||||
}
|
||||
|
||||
function CreateImportColumns(excelcolumns) {
|
||||
var tb = $('#tb_import');
|
||||
tb.empty();
|
||||
var columnsdata = getcolumnsdata();
|
||||
for (var i = 0; i < columnsdata.length; i++) {
|
||||
var col = columnsdata[i];
|
||||
var tr = $('<tr></tr>');
|
||||
tb.append(tr);
|
||||
var td = $('<td class="label" style="width:150px;">' + col.Name + '</td>');
|
||||
if (i < 2) {
|
||||
var sp = $('<span style="color:red;">*</span>');
|
||||
td.append(sp);
|
||||
}
|
||||
tr.append(td);
|
||||
td = $('<td></td>');
|
||||
tr.append(td);
|
||||
var sel = CreateSelect(excelcolumns, col.Id);
|
||||
td.append(sel);
|
||||
}
|
||||
}
|
||||
var grid_import_result = null;
|
||||
function CreateImportResultGrid(data, t) {
|
||||
if (grid_import_result == null) {
|
||||
grid_import_result = new GridView('#div_import_grid');
|
||||
}
|
||||
|
||||
if (t == 0 && data.length == 0) {
|
||||
$('#btnOk').hide();
|
||||
}
|
||||
var columnsdata = getcolumnsdata();
|
||||
var columns = [];
|
||||
if (t == 0) {
|
||||
columns.push({
|
||||
type: 3,
|
||||
key: 'checked',
|
||||
allcheck: true,
|
||||
width: 30,
|
||||
align: 'center'
|
||||
});
|
||||
}
|
||||
var styleFilter = function (item) {
|
||||
if ($.nullOrEmpty(item.SourceName) || $.nullOrEmpty(item.SerialNumber)) {
|
||||
return { 'color': 'red' };
|
||||
}
|
||||
if ((item.Source == 'NimbeLink' || item.Source == 'DigitalMatter') && $.nullOrEmpty(item.DeviceType)) {
|
||||
return { 'color': 'red' };
|
||||
}
|
||||
};
|
||||
for (var i = 0; i < columnsdata.length; i++) {
|
||||
var col = {};
|
||||
col.name = columnsdata[i].Id;
|
||||
col.caption = columnsdata[i].Name;
|
||||
col.visible = true;
|
||||
col.sortable = false;
|
||||
col.width = columnsdata[i].Width;
|
||||
col.key = columnsdata[i].Key;
|
||||
col.allowFilter = false;
|
||||
if (t == 0) {
|
||||
col.styleFilter = styleFilter;
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_import_result.canMultiSelect = false;
|
||||
grid_import_result.columns = columns;
|
||||
grid_import_result.init();
|
||||
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
r.checked = true;
|
||||
if (r.PairedAsset) {
|
||||
r.VIN = r.PairedAsset.VIN;
|
||||
}
|
||||
|
||||
for (var j in r) {
|
||||
|
||||
if (j === "Status")
|
||||
r[j] = { DisplayValue: r["Status"] === 1 ? "Active" : "Inactive", Value: r[j] };
|
||||
else if (j === "InvoiceDate")
|
||||
r[j] = { DisplayValue: r["InvoiceDateStr"], Value: r[j] };
|
||||
else if (j === "ServiceStartDate")
|
||||
r[j] = { DisplayValue: r["ServiceStartDateStr"], Value: r[j] };
|
||||
else if (j == "Tamper") {
|
||||
r[j] = { DisplayValue: r[j] == 1 ? "Yes" : "No", Value: r[j] };
|
||||
}
|
||||
else if (j == "FIInstalltion") {
|
||||
r[j] = { DisplayValue: r[j] == 1 ? "Yes" : "No", Value: r[j] };
|
||||
}
|
||||
else if (j == "Utilization") {
|
||||
r[j] = { DisplayValue: r[j] == 1 ? "Yes" : "No", Value: r[j] };
|
||||
}
|
||||
}
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
|
||||
grid_import_result.setData(rows);
|
||||
grid_import_result.resize();
|
||||
|
||||
}
|
||||
|
||||
var fildata;
|
||||
function OnImport() {
|
||||
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", "GetImportDevicesColumns");
|
||||
formData.append("ClientData", '');
|
||||
showloading(true);
|
||||
$.ajax({
|
||||
url: 'ManageGPSDevices.aspx',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
data: formData,
|
||||
async: true,
|
||||
success: function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_JS_IMPORT", 'Import'));
|
||||
showloading(false);
|
||||
} else {
|
||||
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();
|
||||
}
|
||||
|
||||
var importing = false;
|
||||
var importCount = 0;
|
||||
function OnImportDevices(t) {
|
||||
if (!fildata)
|
||||
return;
|
||||
|
||||
if (importing)
|
||||
return;
|
||||
importing = true;
|
||||
var item = [];
|
||||
var sels = $("select[name='sel_import']");
|
||||
var tmp = '';
|
||||
for (var i = 0; i < sels.length; i++) {
|
||||
var sel = sels[i];
|
||||
var id = $(sel).data('id');
|
||||
var value = $(sel).val();
|
||||
switch (id) {
|
||||
case "Source":
|
||||
if ($.nullOrEmpty(value)) {
|
||||
tmp += GetTextByKey("P_MD_SOURCE", "Source");
|
||||
}
|
||||
break;
|
||||
case "SN":
|
||||
if ($.nullOrEmpty(value)) {
|
||||
if (tmp.length > 0) {
|
||||
tmp += ('/' + GetTextByKey("P_MD_SN", "SN"));
|
||||
}
|
||||
else {
|
||||
tmp += GetTextByKey("P_MD_SN", "SN");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
var kv = { Key: id, Value: value };
|
||||
item.push(kv);
|
||||
}
|
||||
if (tmp.length > 0) {
|
||||
var s = GetTextByKey("P_MA_NOTBEEMPTY", "{0} cannot be empty.").replace('{0}', tmp);
|
||||
showAlert(s, GetTextByKey("P_JS_IMPORT", 'Import'));
|
||||
importing = false;
|
||||
return;
|
||||
}
|
||||
var selected = [];
|
||||
if (t == 1) {
|
||||
for (var i in grid_import_result.source) {
|
||||
selected.push(grid_import_result.source[i].Values.checked);
|
||||
}
|
||||
grid_import_result.setData([]);
|
||||
}
|
||||
$('#dialog_import_result').hideDialog();
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
var contractorid = htmlencode($.trim($('#sel_contractor').val()));
|
||||
var formData = new FormData();
|
||||
formData.append("iconFile", fildata);
|
||||
formData.append("MethodName", "ImportDevices");
|
||||
formData.append("ContractorID", contractorid);
|
||||
formData.append("Get", t == 1 ? false : true);
|
||||
if (t == 1) {
|
||||
formData.append("SelectedData", selected.join(','));
|
||||
}
|
||||
formData.append("ClientData", param);
|
||||
showloading(true);
|
||||
$.ajax({
|
||||
url: 'ManageGPSDevices.aspx',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
data: formData,
|
||||
async: true,
|
||||
success: function (data) {
|
||||
importing = false;
|
||||
try {
|
||||
var d = JSON.parse(data);
|
||||
$('#dialog_import').hideDialog();
|
||||
errordata = [];
|
||||
if (d.Count != -1) {
|
||||
grid_import_result.setData([]);
|
||||
$('#sp_import_result').show();
|
||||
$('#sp_import_f').show();
|
||||
$('#btnClose').show();
|
||||
$('#btnOk').hide();
|
||||
$('#btnCancel').hide();
|
||||
var str = d.Count + GetTextByKey("P_MD_DEVICESIMPORTEDSUCCESSFULLY", ' Device(s) imported successfully.');
|
||||
if (d.Datas.length > 0 || (d.Count == 0 && d.Datas.length == 0)) {
|
||||
importCount = d.Count;
|
||||
if (d.Datas.length > 0) {
|
||||
errordata = $.cloneObject(d.Datas);
|
||||
$('#div_import_export').show();
|
||||
}
|
||||
else {
|
||||
$('#div_import_export').hide();
|
||||
}
|
||||
$('#sp_import_result').text(str);
|
||||
$('#sp_import_f').text(d.Datas.length + " Failed.");
|
||||
$('#dialog_import_result')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_import_result').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_import_result').width()) / 2
|
||||
})
|
||||
.showDialogfixed();
|
||||
CreateImportResultGrid(d.Datas, t);
|
||||
}
|
||||
else {
|
||||
showAlert(str, GetTextByKey("P_JS_IMPORT", 'Import'), null, function () {
|
||||
if (d.Count > 0) {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
showloading(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$('#dialog_import_result')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_import_result').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_import_result').width()) / 2
|
||||
})
|
||||
.showDialogfixed();
|
||||
$('#sp_import_result').hide();
|
||||
$('#div_import_export').hide();
|
||||
$('#sp_import_f').show();
|
||||
$('#btnClose').hide();
|
||||
$('#btnOk').show();
|
||||
$('#btnCancel').show();
|
||||
CreateImportResultGrid(d.Datas, t);
|
||||
$('#sp_import_f').text(GetTextByKey("P_WO_COUNT", 'Count') + ": " + d.Datas.length);
|
||||
}
|
||||
|
||||
}
|
||||
catch (e) {
|
||||
showAlert(data, GetTextByKey("P_JS_IMPORT", 'Import'));
|
||||
showloading(false);
|
||||
}
|
||||
},
|
||||
error: function (err) {
|
||||
importing = false;
|
||||
showloading(false);
|
||||
showAlert(err.statusText, GetTextByKey("P_JS_IMPORT", 'Import'));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function EndImportDevices() {
|
||||
$('#dialog_import_result').hideDialog();
|
||||
if (importCount > 0) {
|
||||
window.location.reload();
|
||||
}
|
||||
showloading(false);
|
||||
}
|
||||
|
||||
</script>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
||||
<div id="recordcontent" style="padding: 0px; margin: 0px;">
|
||||
<div class="page_title" data-lgid="P_MANAGEDEVICES">Manage Devices</div>
|
||||
<div class="search_bar">
|
||||
<input type="password" autocomplete="new-password" style="display: none" />
|
||||
<span id="span_contractor" style="display: none;">
|
||||
<span data-lgid="P_MD_CONTRACTOR_COLON">Contractor:</span>
|
||||
<select id="sel_contractor"></select></span>
|
||||
<input type="text" id="searchinputtxt" autocomplete="off" />
|
||||
<input class="search" type="button" onclick="OnRefresh();" value="Search" data-lgid="P_MD_SEARCH" style="margin-left: 5px;" />
|
||||
</div>
|
||||
<div class="function_title">
|
||||
<span class="sbutton iconadd" onclick="OnAdd();" data-lgid="P_MD_ADD">Add</span>
|
||||
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_MD_REFRESH">Refresh</span>
|
||||
<span id="spExport" class="sbutton iconexport" onclick="OnExport();" data-lgid="P_UTILITY_EXPORTTOEXCEL">Export to Excel</span>
|
||||
<span class="sbutton iconimport" onclick="OnImport();" data-lgid="P_JS_IMPORT">Import</span>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<div id="devicelist"></div>
|
||||
</div>
|
||||
<div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div>
|
||||
<div class="dialog" id="dialog_gpsdevice1" style="display: none; height: 100%; border-bottom: 0; border-top: 0; z-index: 2">
|
||||
<iframe id="iframe_gpsdevice" style="width: 100%; height: 100%; display: block; border: none" src="AddDevice.aspx"></iframe>
|
||||
<div class="maskbg" style="display: none"></div>
|
||||
</div>
|
||||
|
||||
<div class="dialog" id="dialog_changecon" style="display: none; width: 360px;">
|
||||
<div class="dialog-title"><span class="title" data-lgid="P_MD_CHANGECONTRACTOR">Change Contractor</span><em class="dialog-close"></em></div>
|
||||
<div class="dialog-content">
|
||||
<table style="line-height: 25px; width: 100%;">
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MD_CONTRACTOR_COLON">Contractor:</td>
|
||||
<td>
|
||||
<select id="dialog_contractor" tabindex="1" style="width: 204px;"></select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MD_NOTES_COLON">Notes:</td>
|
||||
<td>
|
||||
<textarea id="txtChangeConNotes" style="display: block; width: 240px; box-sizing: border-box; margin-top: 5px; height: 80px"></textarea></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="dialog-func">
|
||||
<input type="button" value="Cancel" class="dialog-close" tabindex="5" data-lgid="P_MD_CANCEL" />
|
||||
<input type="button" onclick="ChangeContractor();" value="OK" tabindex="4" data-lgid="P_MD_OK" />
|
||||
<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_MD_IMPORTDEVICEFIELDMAPPING"></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="overflow: auto;">
|
||||
<table id="tb_import" class="table_holder">
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="dialog-func">
|
||||
<input type="button" value="Close" data-lgid="P_JS_CANCEL" class="dialog-close" tabindex="28" />
|
||||
<input type="button" onclick="OnImportDevices(0);" value="OK" tabindex="27" />
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dialog" id="dialog_import_result" style="display: none;">
|
||||
<div class="dialog-title"><span class="title" data-lgid="P_JS_IMPORT"></span></div>
|
||||
|
||||
<div id="div_import_export" class="machine_filter" style="margin: 9px 6px 7px; display: none;">
|
||||
<span class="sbutton iconexport" onclick="OnExportInImport()" data-lgid="P_UTILITY_EXPORTTOEXCEL">Export to Excel</span>
|
||||
</div>
|
||||
<div style="margin: 9px 6px 7px; padding-left: 20px">
|
||||
<div id="sp_import_result" style="font-weight: bold;"></div>
|
||||
</div>
|
||||
<div id="sp_import_f" style="margin: 9px 6px 7px; padding-left: 20px; font-weight: bold;">Failed</div>
|
||||
<div id="div_import_grid" style="padding-left: 20px; padding-right: 20px; height: 400px; width: 700px">
|
||||
</div>
|
||||
<div class="dialog-func">
|
||||
<input id="btnCancel" type="button" value="Close" data-lgid="P_JS_CANCEL" class="dialog-close" tabindex="28" />
|
||||
<input id="btnOk" type="button" onclick="OnImportDevices(1);" data-lgid="P_JS_IMPORT" tabindex="27" />
|
||||
<input id="btnClose" type="button" onclick="EndImportDevices();" data-lgid="P_FR_CLOSE" tabindex="27" />
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
</asp:Content>
|
74
Site/MachineDeviceManagement/ManageGPSDevices.aspx.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor;
|
||||
using IronIntel.Contractor.Site;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class ManageGPSDevices : MachineDeviceBasePage
|
||||
{
|
||||
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!CheckLoginSession())
|
||||
{
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
string methodName = Request.Form["MethodName"];
|
||||
if (!string.IsNullOrEmpty(methodName))
|
||||
{
|
||||
ProcessRequest(methodName);
|
||||
}
|
||||
else if (!IsPostBack)
|
||||
{
|
||||
this.Title = PageTitle;
|
||||
//bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
//if (!permission)
|
||||
// RedirectToLoginPage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var user = GetCurrentUser();
|
||||
bool isallowed = CheckRight(SystemParams.CompanyID, Foresight.Fleet.Services.User.Feature.MANAGE_DEVICES);
|
||||
//bool isallowed = IronIntel.Contractor.Users.UserManagement.CheckUserPermission(GetCurrentLoginSession().SessionID, user.IID, 10);
|
||||
return isallowed || (user != null && user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin);
|
||||
}
|
||||
|
||||
public bool IsAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public bool IsSuperAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
1540
Site/MachineDeviceManagement/ManageMachines.aspx
Normal file
90
Site/MachineDeviceManagement/ManageMachines.aspx.cs
Normal file
@ -0,0 +1,90 @@
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor;
|
||||
using IronIntel.Contractor.Site;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class ManageMachines : MachineDeviceBasePage
|
||||
{
|
||||
|
||||
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
|
||||
public bool IsReadOnly = false;
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
string methodName = Request.Form["MethodName"];
|
||||
if (!string.IsNullOrEmpty(methodName))
|
||||
{
|
||||
ProcessRequest(methodName);
|
||||
}
|
||||
else if (!IsPostBack)
|
||||
{
|
||||
if (!CheckLoginSession())
|
||||
{
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Title = PageTitle;
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
if (!permission)
|
||||
RedirectToLoginPage();
|
||||
|
||||
IsReadOnly = CheckReadonly(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var user = GetCurrentUser();
|
||||
return user != null && user.UserType >= IronIntel.Contractor.Users.UserTypes.Common;
|
||||
}
|
||||
|
||||
public bool IsAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSupperAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
return user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin;
|
||||
}
|
||||
}
|
||||
public bool CheckRight
|
||||
{
|
||||
get
|
||||
{
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
return permission;
|
||||
}
|
||||
}
|
||||
}
|
355
Site/MachineDeviceManagement/ManageMakes.aspx
Normal file
@ -0,0 +1,355 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/MachineDeviceManagement/DeviceManagementBase.master" AutoEventWireup="true" CodeFile="ManageMakes.aspx.cs" Inherits="ManageMakes" %>
|
||||
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
|
||||
<style type="text/css">
|
||||
::-ms-clear, ::-ms-reveal {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.selectinput {
|
||||
width: 150px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.dialog-content table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dialog-content table td.label {
|
||||
width: 100px;
|
||||
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: 200px;
|
||||
height: 18px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
.dialog-content table td input[type="checkbox"] {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.dialog-content table td textarea {
|
||||
height: 100px;
|
||||
max-width: 200px;
|
||||
}
|
||||
|
||||
#dialogdatatb td {
|
||||
padding-top: 30px;
|
||||
}
|
||||
|
||||
.a {
|
||||
text-decoration: none;
|
||||
color: #2140fb;
|
||||
}
|
||||
</style>
|
||||
|
||||
<link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" />
|
||||
<script src="<%=GetFileUrlWithVersion("../Maintenance/js/inputdatactr.js")%>" type="text/javascript"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script>
|
||||
<script type="text/javascript">
|
||||
var IsSuperAdmin =<%=IsSuperAdmin ?"true":"false"%>;
|
||||
|
||||
function devicerequest(method, param, callback, error) {
|
||||
_network.request("MachineDeviceManagement/ManageMakes.aspx", -1, method, param, callback, error || function (e) {
|
||||
showmaskbg(false, true);
|
||||
showAlert('An unknown error occurred. Please refresh page.', 'Query');
|
||||
});
|
||||
}
|
||||
|
||||
function OnAdd() {
|
||||
makeID = undefined;
|
||||
|
||||
$('#dialog_name').val('');
|
||||
$('#dialog_make .dialog-title span.title').text('Add Make');
|
||||
|
||||
showmaskbg(true);
|
||||
$('#dialog_make')
|
||||
.attr('act', 'add')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_make').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_make').width()) / 2
|
||||
})
|
||||
.showDialog();
|
||||
$('#dialog_name').focus();
|
||||
}
|
||||
|
||||
var makeID;
|
||||
function OnEdit() {
|
||||
var make = grid_dt.source[grid_dt.selectedIndex].Values;
|
||||
if (!make) {
|
||||
makeID = undefined;
|
||||
return;
|
||||
}
|
||||
if (!make.CanEdit)
|
||||
return;
|
||||
|
||||
makeID = make.ID;
|
||||
$('#dialog_name').val(make.Name);
|
||||
|
||||
$('#dialog_make .dialog-title span.title').text('Edit Make');
|
||||
showmaskbg(true);
|
||||
$('#dialog_make')
|
||||
.attr('act', 'edit')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_make').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_make').width()) / 2
|
||||
})
|
||||
.showDialog();
|
||||
$('#dialog_name').focus();
|
||||
}
|
||||
|
||||
function OnDblClick(e) {
|
||||
OnEdit();
|
||||
}
|
||||
|
||||
function OnDelete(make) {
|
||||
if (!make) {
|
||||
return;
|
||||
}
|
||||
showConfirm('Are you sure you want to delete this Make?', 'Delete Make', function () {
|
||||
devicerequest("DELETEMACHINEMAKE", make.ID, function (data) {
|
||||
if (data !== 'OK')
|
||||
showAlert(data, 'Delete Make');
|
||||
else
|
||||
OnRefresh();
|
||||
}, function (err) {
|
||||
showAlert('Failed to delete this Make.', 'Delete Make');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function OnRefresh() {
|
||||
showloading(true);
|
||||
|
||||
var contractorid = "";
|
||||
contractorid = htmlencode($.trim($('#sel_contractor').val()));
|
||||
|
||||
var searchtxt = "";
|
||||
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
|
||||
devicerequest("GETMACHINEMAKELIST", searchtxt, function (data) {
|
||||
$('#tbody_makes').empty();
|
||||
currentShownIndex = -1;
|
||||
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, 'Error');
|
||||
}
|
||||
else
|
||||
showMakes(data);
|
||||
|
||||
showloading(false);
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
});
|
||||
}
|
||||
|
||||
function showMakes(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
|
||||
grid_dt.setData(rows);
|
||||
}
|
||||
|
||||
var grid_dt;
|
||||
function InitGridData() {
|
||||
grid_dt = new GridView('#makelist');
|
||||
grid_dt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'Name', caption: "Make Name", valueIndex: 'Name', css: { 'width': 360, 'text-align': 'left' } },
|
||||
{ name: 'Edit', caption: "", css: { 'width': 30, 'text-align': 'center' } },
|
||||
{ name: 'Delete', caption: "", 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;
|
||||
if (col.name === "Edit") {
|
||||
if (!IsSuperAdmin) continue;
|
||||
col.isurl = true;
|
||||
col.text = "\uf044";
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
if (this.CanEdit)
|
||||
OnEdit()
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
}
|
||||
col.styleFilter = function (e) {
|
||||
return {
|
||||
display: !e.CanEdit ? 'none' : ''
|
||||
};
|
||||
};
|
||||
col.attrs = { 'title': 'Edit' };
|
||||
}
|
||||
else if (col.name === "Delete") {
|
||||
if (!IsSuperAdmin) continue;
|
||||
col.isurl = true;
|
||||
col.text = "\uf00d";
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
if (this.CanEdit)
|
||||
OnDelete(this);
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
};
|
||||
col.styleFilter = function (e) {
|
||||
return {
|
||||
display: !e.CanEdit ? 'none' : ''
|
||||
};
|
||||
};
|
||||
col.attrs = { 'title': 'Delete' };
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_dt.canMultiSelect = false;
|
||||
grid_dt.columns = columns;
|
||||
grid_dt.init();
|
||||
grid_dt.rowdblclick = OnEdit;
|
||||
|
||||
grid_dt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_dt.source[rowindex];
|
||||
if (rowdata) {
|
||||
makeID = rowdata.Values.ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function OnDialogOK() {
|
||||
var item = {
|
||||
'Name': $.trim($('#dialog_name').val()),
|
||||
'AlterActiveName': $.trim($('#dialog_name').val())
|
||||
};
|
||||
var alerttitle;
|
||||
if (makeID) {
|
||||
item.ID = makeID;
|
||||
alerttitle = "Edit Make";
|
||||
} else {
|
||||
item.ID = -1;
|
||||
alerttitle = "Add Make";
|
||||
}
|
||||
|
||||
if (!item.Name || item.Name.length == 0) {
|
||||
showAlert('Make name cannot be empty.', alerttitle);
|
||||
$('#dialog_name').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
showloading(true);
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
devicerequest("SaveMachineMake", param, function (data) {
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, 'Save Make');
|
||||
showloading(false);
|
||||
} else {
|
||||
$('#dialog_make').hideDialog();
|
||||
OnRefresh();
|
||||
}
|
||||
}, function (err) {
|
||||
showAlert('Failed to save Make.', 'Save Make');
|
||||
showloading(false);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$(function () {
|
||||
InitGridData();
|
||||
OnRefresh();
|
||||
|
||||
$('#tbody_makes').click(function (e) {
|
||||
var target = $(e.target);
|
||||
if (!target.is('tr')) {
|
||||
target = target.parents('tr');
|
||||
}
|
||||
$('#tbody_makes tr').removeClass('selected');
|
||||
target.addClass('selected');
|
||||
});
|
||||
|
||||
$('#dialog_make').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
|
||||
$('#searchinputtxt').keydown(searchEnter);
|
||||
|
||||
$(window).resize(function () {
|
||||
$("#makelist").css("height", $(window).height() - $("#makelist").offset().top - 4);
|
||||
grid_dt && grid_dt.resize();
|
||||
}).resize();
|
||||
});
|
||||
|
||||
function searchEnter(e) {
|
||||
if (e.keyCode == 13 || e.keyCode == 9) {
|
||||
OnRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
||||
<div id="recordcontent" style="padding: 0px; margin: 0px;">
|
||||
<div class="page_title">Manage Makes</div>
|
||||
<div class="search_bar">
|
||||
<input type="password" autocomplete="new-password" style="display: none" />
|
||||
<span id="span_contractor" style="display: none;">Contractor:
|
||||
<select id="sel_contractor"></select></span>
|
||||
<input type="text" id="searchinputtxt" autocomplete="off" />
|
||||
<input class="search" type="button" onclick="OnRefresh();" value="Search" />
|
||||
</div>
|
||||
<div class="function_title">
|
||||
<span class="sbutton iconadd" onclick="OnAdd();">Add</span>
|
||||
<span class="sbutton iconrefresh" onclick="OnRefresh();">Refresh</span>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<div id="makelist">
|
||||
</div>
|
||||
</div>
|
||||
<div id="mask_bg" style="display: none;">
|
||||
<div class="loading c-spin"></div>
|
||||
</div>
|
||||
|
||||
<div class="dialog" id="dialog_make" style="display: none; width: 360px;">
|
||||
<div class="dialog-title"><span class="title">Add Make</span><em class="dialog-close"></em></div>
|
||||
<div class="dialog-content">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="label">Make:</td>
|
||||
<td>
|
||||
<input type="text" id="dialog_name" style="width: 220px;" maxlength="100" tabindex="1" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="dialog-func">
|
||||
<input type="button" value="Cancel" class="dialog-close" tabindex="3" />
|
||||
<input type="button" onclick="OnDialogOK();" value="OK" tabindex="2" />
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
</asp:Content>
|
65
Site/MachineDeviceManagement/ManageMakes.aspx.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor;
|
||||
using IronIntel.Contractor.Site;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class ManageMakes : MachineDeviceBasePage
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!CheckLoginSession())
|
||||
{
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
string methodName = Request.Form["MethodName"];
|
||||
if (!string.IsNullOrEmpty(methodName))
|
||||
{
|
||||
ProcessRequest(methodName);
|
||||
}
|
||||
else if (!IsPostBack)
|
||||
{
|
||||
this.Title = PageTitle;
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
if (!permission)
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var user = GetCurrentUser();
|
||||
return user != null && user.UserType >= IronIntel.Contractor.Users.UserTypes.Admin;
|
||||
}
|
||||
|
||||
public bool IsSuperAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
return user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
722
Site/MachineDeviceManagement/ManageModels.aspx
Normal file
@ -0,0 +1,722 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/MachineDeviceManagement/DeviceManagementBase.master" AutoEventWireup="true" CodeFile="ManageModels.aspx.cs" Inherits="ManageModels" %>
|
||||
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
|
||||
<style type="text/css">
|
||||
::-ms-clear, ::-ms-reveal {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.selectinput {
|
||||
width: 150px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.dialog-content table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dialog-content table td.label {
|
||||
width: 100px;
|
||||
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: 200px;
|
||||
height: 18px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
.dialog-content table td input[type="checkbox"] {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.dialog-content table td textarea {
|
||||
height: 100px;
|
||||
max-width: 200px;
|
||||
}
|
||||
|
||||
#dialogdatatb td {
|
||||
padding-top: 30px;
|
||||
}
|
||||
|
||||
.a {
|
||||
text-decoration: none;
|
||||
color: #2140fb;
|
||||
}
|
||||
|
||||
.selected {
|
||||
background-color: #cccccc;
|
||||
}
|
||||
|
||||
.makeitem {
|
||||
padding-left: 5px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
.makeitem:hover {
|
||||
background-color: #e1e1e1;
|
||||
}
|
||||
|
||||
.sbtn {
|
||||
padding: 6px;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
/*margin-left: 8px;*/
|
||||
}
|
||||
|
||||
.sbtn:hover {
|
||||
background: #ccc;
|
||||
}
|
||||
|
||||
.sbtn:before {
|
||||
font-family: 'FontAwesome';
|
||||
color: rgb(123,28,33);
|
||||
}
|
||||
|
||||
.sbtnhide {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" />
|
||||
<script src="<%=GetFileUrlWithVersion("../Maintenance/js/inputdatactr.js")%>" type="text/javascript"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/vue.min.js")%>"></script>
|
||||
<script>Vue.config.productionTip = false; Vue.config.silent = true;</script>
|
||||
<script type="text/javascript">
|
||||
var IsSuperAdmin =<%=IsSuperAdmin ?"true":"false"%>;
|
||||
var typessdata = [];
|
||||
|
||||
function devicerequest(method, param, callback, error) {
|
||||
_network.request("MachineDeviceManagement/ManageModels.aspx", -1, method, param, callback, error || function (e) {
|
||||
showmaskbg(false, true);
|
||||
showAlert(GetTextByKey('P_MM_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_MM_QUERY', 'Query'));
|
||||
});
|
||||
}
|
||||
|
||||
function GetMakes() {
|
||||
selectedMake = null;
|
||||
showloading(true);
|
||||
|
||||
var searchtxt = htmlencode($.trim($('#txtMakeSearch').val()));
|
||||
devicerequest("GetAssetMakes", searchtxt, function (data) {
|
||||
$('#tbody_makes').empty();
|
||||
currentShownIndex = -1;
|
||||
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MM_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
|
||||
$("#dialog_make").empty();
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var kv = data[i];
|
||||
op = $("<option></option>").val(kv.ID).text(kv.Name);
|
||||
$("#dialog_make").append(op);
|
||||
}
|
||||
|
||||
showMakes(data);
|
||||
showloading(false);
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
});
|
||||
}
|
||||
|
||||
function showMakes(data) {
|
||||
_MakeObject.showMakes(data);
|
||||
}
|
||||
|
||||
function OnAddMake() {
|
||||
makeID = undefined;
|
||||
|
||||
$('#dialog_makename').val('');
|
||||
$('#dialog_addmake .dialog-title span.title').text(GetTextByKey("P_MA_ADDMAKE", 'Add Make'));
|
||||
|
||||
showmaskbg(true);
|
||||
$('#dialog_addmake')
|
||||
.attr('act', 'add')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_addmake').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_addmake').width()) / 2
|
||||
})
|
||||
.showDialogfixed();
|
||||
$('#dialog_name').focus();
|
||||
}
|
||||
|
||||
var makeID;
|
||||
function OnEditMake(make) {
|
||||
if (!make) {
|
||||
makeID = undefined;
|
||||
return;
|
||||
}
|
||||
//if (!make.CanEdit)
|
||||
// return;
|
||||
|
||||
makeID = make.ID;
|
||||
$('#dialog_makename').val(make.Name);
|
||||
|
||||
$('#dialog_addmake .dialog-title span.title').text(GetTextByKey("P_MM_EDITMAKE", 'Edit Make'));
|
||||
showmaskbg(true);
|
||||
$('#dialog_addmake')
|
||||
.attr('act', 'edit')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_addmake').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_addmake').width()) / 2
|
||||
})
|
||||
.showDialogfixed();
|
||||
$('#dialog_makename').focus();
|
||||
}
|
||||
|
||||
function OnSaveMake() {
|
||||
var item = {
|
||||
'Name': $.trim($('#dialog_makename').val()),
|
||||
};
|
||||
var alerttitle;
|
||||
if (makeID) {
|
||||
item.ID = makeID;
|
||||
alerttitle = GetTextByKey("P_MM_EDITMAKE", "Edit Make");
|
||||
} else {
|
||||
item.ID = -1;
|
||||
alerttitle = GetTextByKey("P_MM_ADDMAKE", "Add Make");
|
||||
}
|
||||
|
||||
if (!item.Name || item.Name.length == 0) {
|
||||
showAlert(GetTextByKey("P_MM_MAKENAMEEMPTY", 'Make name cannot be empty.'), alerttitle);
|
||||
$('#dialog_name').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
devicerequest("SaveMachineMake", param, function (data) {
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, GetTextByKey("P_MM_SAVEMAKE", 'Save Make'));
|
||||
} else {
|
||||
$('#dialog_addmake').hideDialog();
|
||||
GetMakes();
|
||||
}
|
||||
}, function (err) {
|
||||
showAlert(GetTextByKey("P_MM_FAILEDSAVEMAKE", 'Failed to save Make.'), GetTextByKey("P_MM_SAVEMAKE", 'Save Make'));
|
||||
});
|
||||
}
|
||||
|
||||
function OnDeleteMake(make) {
|
||||
if (!make) {
|
||||
return;
|
||||
}
|
||||
showConfirm(GetTextByKey("P_MM_AREYOUSUREYOUWANTTODELETETHISMAKE", 'Are you sure you want to delete this Make?'), GetTextByKey("P_MM_DELETEMAKE", 'Delete Make'), function () {
|
||||
devicerequest("DELETEMACHINEMAKE", make.ID, function (data) {
|
||||
if (data !== 'OK')
|
||||
showAlert(data, GetTextByKey("P_MM_DELETEMAKE", 'Delete Make'));
|
||||
else
|
||||
GetMakes();
|
||||
}, function (err) {
|
||||
showAlert(GetTextByKey("P_MM_FAILEDTODELETETHISMAKE", 'Failed to delete this Make.'), GetTextByKey("P_MM_DELETEMAKE", 'Delete Make'));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function OnAddModel() {
|
||||
modelID = undefined;
|
||||
$('#dialog_name').val('');
|
||||
if (selectedMake)
|
||||
$('#dialog_make').val(selectedMake.ID);
|
||||
else
|
||||
$('#dialog_make').find("option:first").prop("selected", "selected");
|
||||
$('#dialog_type').dropdownVal("");
|
||||
|
||||
$('#dialog_addmodel .dialog-title span.title').text(GetTextByKey("P_MM_ADDMODEL", "Add Model"));
|
||||
showmaskbg(true);
|
||||
$('#dialog_addmodel')
|
||||
.attr('act', 'add')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_addmodel').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_addmodel').width()) / 2
|
||||
})
|
||||
.showDialogfixed();
|
||||
$('#dialog_name').focus();
|
||||
}
|
||||
|
||||
var modelID;
|
||||
function OnEditModel(e) {
|
||||
if (!IsSuperAdmin)
|
||||
return;
|
||||
var model = grid_dtmodel.source[grid_dtmodel.selectedIndex].Values;
|
||||
if (!model) {
|
||||
modelID = undefined;
|
||||
return;
|
||||
}
|
||||
//if (!model.CanEdit)
|
||||
// return;
|
||||
|
||||
modelID = model.ID;
|
||||
$('#dialog_name').val(model.Name);
|
||||
$('#dialog_make').val(model.MakeID);
|
||||
$('#dialog_type').dropdownVal(model.TypeID);
|
||||
|
||||
$('#dialog_addmodel .dialog-title span.title').text(GetTextByKey("P_MM_EDITMODEL", 'Edit Model'));
|
||||
showmaskbg(true);
|
||||
$('#dialog_addmodel')
|
||||
.attr('act', 'edit')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_addmodel').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_addmodel').width()) / 2
|
||||
})
|
||||
.showDialogfixed();
|
||||
$('#dialog_name').focus();
|
||||
}
|
||||
|
||||
function OnDeleteModel(model) {
|
||||
if (!model) {
|
||||
return;
|
||||
}
|
||||
var alerttitle = GetTextByKey("P_MM_DELETEMODEL", "Delete Model");
|
||||
showConfirm(GetTextByKey("P_MM_DOYOUWANTTODELETETHEMODEL", 'Do you want to delete the Model?'), alerttitle, function () {
|
||||
devicerequest("DELETEMACHINEMODEL", model.ID, function (data) {
|
||||
if (data !== 'OK')
|
||||
showAlert(data, alerttitle);
|
||||
else
|
||||
GetModels();
|
||||
|
||||
}, function (err) {
|
||||
showAlert(GetTextByKey("P_MM_FAILEDTODELETETHISMODEL", 'Failed to delete this Model.'), alerttitle);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function GetModels() {
|
||||
var make = selectedMake;
|
||||
if (!make) return;
|
||||
|
||||
showloading(true);
|
||||
var makeid = make.ID;
|
||||
var searchtxt = htmlencode($.trim($('#txtModelSearch').val()));
|
||||
var ps = [makeid, searchtxt]
|
||||
devicerequest("GetAssetModels", JSON.stringify(ps), function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MM_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
|
||||
showModels(data);
|
||||
|
||||
showloading(false);
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function showModels(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
grid_dtmodel.setData(rows);
|
||||
}
|
||||
|
||||
|
||||
var grid_dtmodel;
|
||||
function InitModelGridData() {
|
||||
$('#btnEdit').attr("disabled", "disabled");
|
||||
|
||||
grid_dtmodel = new GridView('#modellist');
|
||||
grid_dtmodel.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'Name', caption: GetTextByKey("P_MM_MODEL", "Model"), valueIndex: 'Name', css: { 'width': 300, 'text-align': 'left' } },
|
||||
{ name: 'TypeName', caption: GetTextByKey("P_MM_TYPE", "Type"), valueIndex: 'TypeName', allowFilter: true, css: { 'width': 300, 'text-align': 'left' } },
|
||||
//{ name: 'Edit', caption: "", css: { 'width': 30, 'text-align': 'center' } },
|
||||
//{ name: 'Delete', caption: "", 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;
|
||||
if (col.name === "Edit") {
|
||||
if (!IsSuperAdmin) continue;
|
||||
col.isurl = true;
|
||||
col.text = "\uf044";
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
//if (this.CanEdit)
|
||||
OnEditModel()
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
}
|
||||
col.styleFilter = function (e) {
|
||||
//return {
|
||||
// display: !e.CanEdit ? 'none' : ''
|
||||
//};
|
||||
};
|
||||
col.attrs = { 'title': GetTextByKey("P_MM_EDIT", 'Edit') };
|
||||
}
|
||||
else if (col.name === "Delete") {
|
||||
if (!IsSuperAdmin) continue;
|
||||
col.isurl = true;
|
||||
col.text = "\uf00d";
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
//if (this.CanEdit)
|
||||
OnDeleteModel(this);
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
};
|
||||
col.styleFilter = function (e) {
|
||||
//return {
|
||||
// display: !e.CanEdit ? 'none' : ''
|
||||
//};
|
||||
};
|
||||
col.attrs = { 'title': GetTextByKey("P_MM_DELETE", 'Delete') };
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_dtmodel.canMultiSelect = false;
|
||||
grid_dtmodel.columns = columns;
|
||||
grid_dtmodel.init();
|
||||
//grid_dtmodel.rowdblclick = OnEditModel;
|
||||
|
||||
grid_dtmodel.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_dtmodel.source[rowindex];
|
||||
if (rowdata) {
|
||||
modelID = rowdata.Values.ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function OnSaveModel() {
|
||||
var item = {
|
||||
'Name': $.trim($('#dialog_name').val()),
|
||||
'MakeID': $.trim($('#dialog_make').val()),
|
||||
'TypeID': $.trim($('#dialog_type').dropdownVal())
|
||||
};
|
||||
var alerttitle;
|
||||
if (modelID) {
|
||||
item.ID = modelID;
|
||||
alerttitle = GetTextByKey("P_MM_EDITMODEL", "Edit Model");
|
||||
} else {
|
||||
item.ID = -1;
|
||||
alerttitle = GetTextByKey("P_MM_ADDMODEL", "Add Model");
|
||||
}
|
||||
|
||||
if (!item.Name || item.Name.length == 0) {
|
||||
showAlert(GetTextByKey("P_MM_MODELNAMEEMPTY", 'Model name cannot be empty.'), alerttitle);
|
||||
$('#dialog_name').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
showloading(true);
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
devicerequest("SAVEMACHINEMODEL", param, function (data) {
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, GetTextByKey("P_MM_SAVEMAKE", 'Save Make'));
|
||||
} else {
|
||||
$('#dialog_addmodel').hideDialog();
|
||||
showloading(false);
|
||||
GetModels();
|
||||
}
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
showAlert(GetTextByKey("P_MM_FAILEDSAVEMAKE", 'Failed to save Make.'), GetTextByKey("P_MM_SAVEMAKE", 'Save Make'));
|
||||
});
|
||||
}
|
||||
|
||||
var _MakeObject = undefined;
|
||||
$(function () {
|
||||
setPageTitle(GetTextByKey("P_MANAGEMODELS", "Manage Models"), true);
|
||||
_MakeObject = new MakeObject();
|
||||
//InitMakeGridData();
|
||||
InitModelGridData();
|
||||
|
||||
GetMakes();
|
||||
GetMachineTypes();
|
||||
|
||||
$('#dialog_type').dropdown([
|
||||
], {
|
||||
search: true,
|
||||
valueKey: 'Key',
|
||||
textKey: 'Value'
|
||||
});
|
||||
|
||||
$('#dialog_addmake').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
|
||||
$('#dialog_addmodel').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
|
||||
$('#txtMakeSearch').keydown(searchMake);
|
||||
$('#txtModelSearch').keydown(searchModel);
|
||||
|
||||
$(window).resize(function () {
|
||||
$("#modellist").css("height", $(window).height() - $("#modellist").offset().top - 4);
|
||||
grid_dtmodel && grid_dtmodel.resize();
|
||||
}).resize();
|
||||
|
||||
document.getElementById('leftdiv').addEventListener('scroll', onscrollMakes, { passive: true });
|
||||
});
|
||||
|
||||
function searchMake(e) {
|
||||
if (e.keyCode == 13 || e.keyCode == 9) {
|
||||
GetMakes();
|
||||
}
|
||||
}
|
||||
|
||||
function searchModel(e) {
|
||||
if (e.keyCode == 13 || e.keyCode == 9) {
|
||||
GetModels();
|
||||
}
|
||||
}
|
||||
|
||||
function GetMachineTypes() {
|
||||
devicerequest("GetMachineTypes", '', function (data) {
|
||||
if (data && data.length > 0) {
|
||||
typessdata = data;
|
||||
//$("#dialog_type").empty();
|
||||
//for (var i = 0; i < data.length; i++) {
|
||||
// var kv = data[i];
|
||||
// op = $("<option></option>").val(kv.Key).text(kv.Value);
|
||||
// $("#dialog_type").append(op);
|
||||
//}
|
||||
|
||||
var dropdown = $('#dialog_type').data('dropdown');
|
||||
dropdown.setSource(typessdata);
|
||||
}
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
function onscrollMakes(e) {
|
||||
_MakeObject && _MakeObject.onscrollAssets(e);
|
||||
}
|
||||
|
||||
var selectedMake = undefined;
|
||||
if (typeof (MakeObject) != "function") {
|
||||
MakeObject = function () {
|
||||
var REDUN = 2;
|
||||
var ROW_HEIGHT = 24;
|
||||
var MIN_LENGTH = 40;
|
||||
var trunc = function (val) {
|
||||
return (val > 0 ? Math.floor : Math.ceil)(val);
|
||||
};
|
||||
|
||||
var makes = [];
|
||||
var vm = new Vue({
|
||||
el: '#makelist',
|
||||
data: {
|
||||
startIndex: 0,
|
||||
bodyContentStyle: { top: null },
|
||||
bodyContainerHeight: 0,
|
||||
bodyContainerStyle: { height: null },
|
||||
scrollTop: 0
|
||||
},
|
||||
computed: {
|
||||
bodyClientRowCount: function () {
|
||||
var height = document.getElementById('leftdiv').clientHeight;
|
||||
return trunc((height - 1) / ROW_HEIGHT) + 1;
|
||||
},
|
||||
innerMakes: function () {
|
||||
var start = this.startIndex;
|
||||
if (start < 0) {
|
||||
start = 0;
|
||||
}
|
||||
if (makes == null || makes.length < MIN_LENGTH) {
|
||||
return makes.slice();
|
||||
}
|
||||
var end = this.bodyClientRowCount + start + (REDUN * 2) + 1;
|
||||
if (end > makes.length) {
|
||||
end = makes.length;
|
||||
}
|
||||
return makes.slice(start, end);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
reload: function (data) {
|
||||
makes = data;
|
||||
|
||||
var height = data && data.length * ROW_HEIGHT;
|
||||
this.bodyContainerHeight = height;
|
||||
this.bodyContainerStyle.height = height && (height + 'px');
|
||||
if (data.length < MIN_LENGTH) {
|
||||
this.startIndex = -1;
|
||||
this.startIndex = 0;
|
||||
this.bodyContentStyle.top = '0px';
|
||||
} else {
|
||||
var index = this.startIndex;
|
||||
var lastIndex = data.length - this.bodyClientRowCount;
|
||||
if (index > lastIndex) {
|
||||
index = lastIndex;
|
||||
}
|
||||
this.startIndex = -1;
|
||||
this.startIndex = index;
|
||||
}
|
||||
},
|
||||
refresh: function () {
|
||||
var index = this.startIndex;
|
||||
this.startIndex = -1;
|
||||
this.startIndex = index;
|
||||
},
|
||||
makeClick: function (make, ev) {
|
||||
if (selectedMake && selectedMake.ID == make.ID)
|
||||
return;
|
||||
if (selectedMake)
|
||||
selectedMake.Highlight = false;
|
||||
make.Highlight = true;
|
||||
selectedMake = make;
|
||||
vm.refresh();
|
||||
|
||||
GetModels();
|
||||
},
|
||||
makeEdit: function (make, ev) {
|
||||
OnEditMake(make);
|
||||
},
|
||||
makeDelete: function (make, ev) {
|
||||
OnDeleteMake(make);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.onscrollAssets = function (e) {
|
||||
if (makes == null || makes.length < MIN_LENGTH) {
|
||||
return;
|
||||
}
|
||||
var top = e == null ? 0 : e.target.scrollTop;
|
||||
top -= (top % ROW_HEIGHT) + (REDUN * ROW_HEIGHT);
|
||||
if (top < 0) {
|
||||
top = 0;
|
||||
} else {
|
||||
var bottomTop = vm.bodyContainerHeight - ((vm.bodyClientRowCount + (REDUN * 2) + 1) * ROW_HEIGHT);
|
||||
if (top > bottomTop) {
|
||||
top = bottomTop;
|
||||
}
|
||||
}
|
||||
if (vm.scrollTop !== top) {
|
||||
vm.scrollTop = top;
|
||||
vm.startIndex = top / ROW_HEIGHT;
|
||||
vm.bodyContentStyle.top = top && (top + 'px');
|
||||
}
|
||||
};
|
||||
|
||||
this.showMakes = function (data) {
|
||||
vm.reload(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
||||
<div id="recordcontent" style="padding: 0px; margin: 0px; min-width: 800px;">
|
||||
<div class="page_title" data-lgid="P_MANAGEMODELS">Manage Models</div>
|
||||
<div class="search_bar" style="position: relative;">
|
||||
<input type="text" id="txtMakeSearch" autocomplete="off" style="width: 145px;" />
|
||||
<input class="search" type="button" onclick="GetMakes();" value="Search" data-lgid="P_MM_SEARCH" style="margin-left: 5px;" />
|
||||
<span class="sbutton iconadd" onclick="OnAddMake();" style="margin-right: 30px; padding: 0px 10px 0px 10px;" data-lgid="P_MM_ADD">Add</span>
|
||||
|
||||
<div style="position: absolute; left: 345px; top: 0;">
|
||||
<input type="text" id="txtModelSearch" autocomplete="off" style="width: 145px;" />
|
||||
<input class="search" type="button" onclick="GetModels();" value="Search" data-lgid="P_MM_SEARCH" />
|
||||
<span class="sbutton iconadd" onclick="OnAddModel();" data-lgid="P_MM_ADD">Add</span>
|
||||
</div>
|
||||
<%--<span class="sbutton iconrefresh" onclick="OnRefresh();">Refresh</span>--%>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<div id="leftdiv" style="position: absolute; width: 320px; top: 75px; left: 0px; bottom: 4px; overflow: auto; border: 1px solid #9a9a9a;">
|
||||
<div id="makelist" v-bind:style="bodyContainerStyle" style="position: relative">
|
||||
<div v-bind:style="bodyContentStyle" style="position: absolute; width: 100%;">
|
||||
<div class='makeitem' v-for="make in innerMakes" v-bind:class="make.Highlight ?'selected': ''">
|
||||
<table style="border-spacing: 0; width: 100%; height: 30px;">
|
||||
<tr>
|
||||
<td v-on:click="makeClick(make,$event)">{{make.Name}}</td>
|
||||
<td style="width: 20px;"><span class="sbtn iconedit" style="display: none;" v-bind:class="IsSuperAdmin ?'': 'sbtnhide'" v-on:click="makeEdit(make,$event)"></span></td>
|
||||
<td style="width: 20px;"><span class="sbtn icondelete" style="display: none;" v-bind:class="IsSuperAdmin ?'': 'sbtnhide'" v-on:click="makeDelete(make,$event)"></span></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="position: absolute; top: 40px; left: 330px; bottom: 2px; border-left: 1px solid #9a9a9a;"></div>
|
||||
<div style="position: absolute; top: 75px; left: 340px; bottom: 0; right: 0px; overflow: auto;">
|
||||
<div id="modellist"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="mask_bg" style="display: none;">
|
||||
<div class="loading c-spin"></div>
|
||||
</div>
|
||||
|
||||
<div class="dialog" id="dialog_addmake" style="display: none; width: 360px;">
|
||||
<div class="dialog-title"><span class="title" data-lgid="P_MM_ADDMAKE">Add Make</span><em class="dialog-close"></em></div>
|
||||
<div class="dialog-content">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MM_MAKE_COLON">Make:</td>
|
||||
<td>
|
||||
<input type="text" id="dialog_makename" style="width: 220px;" maxlength="100" tabindex="1" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="dialog-func">
|
||||
<input type="button" value="Cancel" data-lgid="P_MM_CANCEL" class="dialog-close" tabindex="3" />
|
||||
<input type="button" onclick="OnSaveMake();" value="OK" data-lgid="P_MM_OK" tabindex="2" />
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dialog" id="dialog_addmodel" style="display: none; width: 360px;">
|
||||
<div class="dialog-title"><span class="title" data-lgid="P_MM_ADDMODEL">Add Model</span><em class="dialog-close"></em></div>
|
||||
<div class="dialog-content">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MM_MAKE_COLON">Make:</td>
|
||||
<td>
|
||||
<select id="dialog_make" tabindex="1" style="width: 224px; height: 22px;"></select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MM_MODEL_COLON">Model:</td>
|
||||
<td>
|
||||
<input type="text" id="dialog_name" maxlength="100" style="width: 220px; height: 22px;" tabindex="2" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" data-lgid="P_MM_TYPE_COLON">Type:</td>
|
||||
<td>
|
||||
<div id="dialog_type" tabindex="3" style="width: 224px; height: 22px;"></div>
|
||||
<%--<select id="dialog_type" tabindex="3" style="width: 224px; height: 22px;"></select>--%>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="dialog-func">
|
||||
<input type="button" value="Cancel" data-lgid="P_MM_CANCEL" class="dialog-close" tabindex="5" />
|
||||
<input type="button" onclick="OnSaveModel();" value="OK" data-lgid="P_MM_OK" tabindex="4" />
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
</asp:Content>
|
64
Site/MachineDeviceManagement/ManageModels.aspx.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor;
|
||||
using IronIntel.Contractor.Site;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class ManageModels : MachineDeviceBasePage
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!CheckLoginSession())
|
||||
{
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
string methodName = Request.Form["MethodName"];
|
||||
if (!string.IsNullOrEmpty(methodName))
|
||||
{
|
||||
ProcessRequest(methodName);
|
||||
}
|
||||
else if (!IsPostBack)
|
||||
{
|
||||
this.Title = PageTitle;
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
if (!permission)
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var user = GetCurrentUser();
|
||||
return user != null && user.UserType >= IronIntel.Contractor.Users.UserTypes.Admin;
|
||||
}
|
||||
|
||||
public bool IsSuperAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
return user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin;
|
||||
}
|
||||
}
|
||||
}
|
619
Site/MachineDeviceManagement/ManageRentals.aspx
Normal file
@ -0,0 +1,619 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/MachineDeviceManagement/DeviceManagementBase.master" AutoEventWireup="true" CodeFile="ManageRentals.aspx.cs" Inherits="ManageRentals" %>
|
||||
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
|
||||
<style type="text/css">
|
||||
::-ms-clear, ::-ms-reveal {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.selectinput {
|
||||
width: 150px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.dialog-content table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dialog-content table td.label {
|
||||
width: 160px;
|
||||
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: 200px;
|
||||
height: 18px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
.dialog-content table td input[type="checkbox"] {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.dialog-content table td textarea {
|
||||
height: 100px;
|
||||
max-width: 200px;
|
||||
}
|
||||
|
||||
#dialogdatatb td {
|
||||
padding-top: 30px;
|
||||
}
|
||||
|
||||
.a {
|
||||
text-decoration: none;
|
||||
color: #2140fb;
|
||||
}
|
||||
|
||||
.machinetd {
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
<link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" />
|
||||
<script src="<%=GetFileUrlWithVersion("../Maintenance/js/inputdatactr.js")%>" type="text/javascript"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/editableselect.js")%>"></script>
|
||||
<script type="text/javascript">
|
||||
var IsDealer = <%=IsDealer ?"true":"false"%>;
|
||||
var IsAdmin =<%=IsAdmin ?"true":"false"%>;
|
||||
var contractorid = "<%=ContractorID %>";
|
||||
var MachineID = "<%=MachineID %>";
|
||||
|
||||
var machines;
|
||||
var editableSelectMachine;
|
||||
var listeditableSelectMachine;
|
||||
|
||||
|
||||
|
||||
function devicerequest(method, param, callback, error) {
|
||||
_network.request("MachineDeviceManagement/ManageRentals.aspx", -1, method, param, callback, error || function (e) {
|
||||
showmaskbg(false, true);
|
||||
showAlert(GetTextByKey('P_MR_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_MR_QUERY', 'Query'));
|
||||
});
|
||||
}
|
||||
|
||||
//admin用户 获取所有contractor
|
||||
function getContractors() {
|
||||
devicerequest('GetContractors', '', function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MR_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
if (data && data.length > 0) {
|
||||
var sel_search = $('#sel_contractor').empty();
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var kv = data[i];
|
||||
var op_search = $('<option></option>').val(kv.Key).text(kv.Value);
|
||||
if (kv.Key == contractorid)
|
||||
op_search.prop('selected', true);
|
||||
sel_search.append(op_search);
|
||||
}
|
||||
if (contractorid !== "")
|
||||
sel_search.val(contractorid);
|
||||
else
|
||||
$("#btnAdd").hide();
|
||||
}
|
||||
else
|
||||
$("#btnAdd").hide();
|
||||
|
||||
GetMachines();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
//普通用户 获取可操作的contractor
|
||||
function GetContractorsByUser() {
|
||||
devicerequest('GetContractorsByUser', '', function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MR_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
if (data && data.length > 0) {
|
||||
var sel_search = $('#sel_contractor').empty();
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var kv = data[i];
|
||||
var op_search = $('<option></option>').val(kv.Key).text(kv.Value);
|
||||
sel_search.append(op_search);
|
||||
}
|
||||
|
||||
if (contractorid !== "")
|
||||
sel_search.val(contractorid);
|
||||
else
|
||||
$("#btnAdd").hide();
|
||||
}
|
||||
else
|
||||
$("#btnAdd").hide();
|
||||
GetMachines();
|
||||
});
|
||||
}
|
||||
|
||||
function CloseDialog(type) {
|
||||
$('#dialog_rental').hideDialog();
|
||||
if (type == 1) {
|
||||
OnRefresh();
|
||||
}
|
||||
else {
|
||||
showmaskbg(false);
|
||||
}
|
||||
}
|
||||
|
||||
function ShowRentalDialog(type) {
|
||||
//$('#dialog_rental .dialog-title span.title').text(type === "add" ? "Add Rental" : "Edit Rental");
|
||||
showmaskbg(true);
|
||||
$('#dialog_rental')
|
||||
.attr('act', type)
|
||||
.showDialogRight();
|
||||
}
|
||||
|
||||
function OnAdd() {
|
||||
contractorid = htmlencode($.trim($('#sel_contractor').val()));
|
||||
$('#iframerental').attr('src', 'AddRental.aspx?cid=' + contractorid);
|
||||
|
||||
ShowRentalDialog("add");
|
||||
}
|
||||
|
||||
|
||||
var rentalID;
|
||||
function OnEdit() {
|
||||
var index = grid_dt.selectedIndex;
|
||||
if (index < 0) {
|
||||
showAlert(GetTextByKey("P_MR_PLEASESELECTARENTAL", "Please select a Rental."), GetTextByKey("P_MR_EDITRENTAL", 'Edit Rental')); return;
|
||||
}
|
||||
var rental = grid_dt.source[index].Values;
|
||||
if (!rental) {
|
||||
rentalID = undefined;
|
||||
return;
|
||||
}
|
||||
if (rental.Hide) {
|
||||
showAlert(GetTextByKey("P_MR_ASSETHIDDEN", "That asset has been hidden or is no longer available."), GetTextByKey("P_MR_EDITRENTAL", 'Edit Rental'));
|
||||
return;
|
||||
}
|
||||
rentalID = rental.RentalID;
|
||||
contractorid = htmlencode($.trim($('#sel_contractor').val()));
|
||||
$('#iframerental').attr('src', 'AddRental.aspx?cid=' + contractorid + "&rid=" + rentalID);
|
||||
ShowRentalDialog("edit");
|
||||
}
|
||||
|
||||
function OnDblClick(e) {
|
||||
OnEdit();
|
||||
}
|
||||
|
||||
function OnDelete(rental) {
|
||||
if (!rental) {
|
||||
return;
|
||||
}
|
||||
|
||||
contractorid = htmlencode($.trim($('#sel_contractor').val()));
|
||||
var alerttitle = GetTextByKey("P_MR_DELETERENTAL", 'Delete Rental');
|
||||
showConfirm(GetTextByKey("P_MR_DOYOUWANTTODELETETHERENTALOCCURENCE", 'Do you want to delete the rental occurence?'), alerttitle, function () {
|
||||
devicerequest("DeleteRental", contractorid + String.fromCharCode(170) + rental.RentalID, function (data) {
|
||||
if (data !== 'OK')
|
||||
showAlert(data, alerttitle);
|
||||
else
|
||||
OnRefresh();
|
||||
}, function (err) {
|
||||
showAlert(GetTextByKey("P_MR_DELETERENTALFAILED", 'Failed to delete this rental occurence.'), alerttitle);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function GetMachines() {
|
||||
contractorid = htmlencode($.trim($('#sel_contractor').val()));
|
||||
|
||||
devicerequest("GetSelectMachinesByCompany", contractorid, function (data) {
|
||||
if (data && data.length > 0) {
|
||||
machines = data;
|
||||
editableSelectMachine.datasource = machines;
|
||||
editableSelectMachine.valuepath = "MachineID"
|
||||
editableSelectMachine.displaypath = "DisplayName";
|
||||
|
||||
listeditableSelectMachine.datasource = machines;
|
||||
listeditableSelectMachine.valuepath = "MachineID"
|
||||
listeditableSelectMachine.displaypath = "DisplayName";
|
||||
//if (MachineID !== "")//暂时不过滤机器
|
||||
// listeditableSelectMachine.val(MachineID);
|
||||
}
|
||||
|
||||
OnRefresh();
|
||||
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
function OnRefresh() {
|
||||
showloading(true);
|
||||
|
||||
contractorid = htmlencode($.trim($('#sel_contractor').val()));
|
||||
var searchtxt = "";
|
||||
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
|
||||
var startdate = htmlencode($('#startdatetxt').val());
|
||||
var enddate = htmlencode($('#enddatetxt').val());
|
||||
|
||||
var machine = listeditableSelectMachine.selecteditem();
|
||||
if (machine != null)
|
||||
MachineID = machine.MachineID;
|
||||
|
||||
devicerequest("SearchRentals", contractorid + String.fromCharCode(170) + searchtxt
|
||||
+ String.fromCharCode(170) + startdate + String.fromCharCode(170) + enddate
|
||||
+ String.fromCharCode(170) + "", function (data) {
|
||||
$('#tbody_rentals').empty();
|
||||
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MR_ERROR", 'Error'));
|
||||
showloading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
showRentals(data);
|
||||
|
||||
showloading(false);
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
});
|
||||
}
|
||||
|
||||
function getLangTermUnit(text) {
|
||||
var langtext = text;
|
||||
if (text === "Hourly")
|
||||
langtext = GetTextByKey("P_MR_HOURLY", "Hourly");
|
||||
else if (text === "Daily")
|
||||
langtext = GetTextByKey("P_MR_DAILY", "Daily");
|
||||
else if (text === "Weekly")
|
||||
langtext = GetTextByKey("P_MR_WEEKLY", "Weekly");
|
||||
else if (text === "Monthly")
|
||||
langtext = GetTextByKey("P_MR_MONTHLY", "Monthly");
|
||||
else if (text === "Annually")
|
||||
langtext = GetTextByKey("P_MR_ANNUALLY", "Annually");
|
||||
return langtext;
|
||||
}
|
||||
|
||||
function getLangOutside(text) {
|
||||
var langtext = text;
|
||||
if (text === "Inside")
|
||||
langtext = GetTextByKey("P_MR_INSIDE", "Inside");
|
||||
else if (text === "Outside")
|
||||
langtext = GetTextByKey("P_MR_OUTSIDE", "Outside");
|
||||
return langtext;
|
||||
}
|
||||
|
||||
function showRentals(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
for (var j in r) {
|
||||
if (j === "RentalDate")
|
||||
r[j] = { DisplayValue: r["RentalDateStr"], Value: r[j] };
|
||||
else if (j === "ProjectReturnDate")
|
||||
r[j] = { DisplayValue: r["ProjectReturnDateStr"], Value: r[j] };
|
||||
else if (j === "ReturnDate")
|
||||
r[j] = { DisplayValue: r["ReturnDateStr"], Value: r[j] };
|
||||
else if (j === "TermUnit")
|
||||
r[j] = { DisplayValue: getLangTermUnit(r["TermUnit"]), Value: r[j] };
|
||||
else if (j === "Outside")
|
||||
r[j] = { DisplayValue: getLangOutside(r["Outside"]), Value: r[j] };
|
||||
}
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
|
||||
grid_dt.setData(rows);
|
||||
}
|
||||
|
||||
var grid_dt;
|
||||
function InitGridData() {
|
||||
$('#btnEdit').attr("disabled", "disabled");
|
||||
|
||||
grid_dt = new GridView('#rentallist');
|
||||
grid_dt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'VIN', caption: GetTextByKey("P_MR_VINSN", "VIN/SN"), valueIndex: 'VIN', css: { 'width': 180, 'text-align': 'left' } },
|
||||
{ name: 'DisplayName', caption: GetTextByKey("P_MR_ASSETNAME", "Asset Name"), valueIndex: 'DisplayName', css: { 'width': 180, 'text-align': 'left' } },
|
||||
{ name: 'AquisitionType', caption: GetTextByKey("P_MR_ACQUISITIONTYPE", "Acquisition Type"), valueIndex: 'AquisitionType', css: { 'width': 120, 'text-align': 'left' } },
|
||||
{ name: 'Outside', caption: GetTextByKey("P_MR_OUTSIDEINTERNAL", "Outside/Internal"), valueIndex: 'Outside', allowFilter: true, css: { 'width': 180, 'text-align': 'left' } },
|
||||
{ name: 'Vendor', caption: GetTextByKey("P_MR_RENTALVENDOR", "Rental Vendor"), valueIndex: 'Vendor', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'RentalRate', caption: GetTextByKey("P_MR_RENTALRATE", "Rental Rate"), valueIndex: 'RentalRate', css: { 'width': 150, 'text-align': 'right' } },
|
||||
{ name: 'Term', caption: GetTextByKey("P_MR_TERM", "Term"), valueIndex: 'Term', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'TermUnit', caption: GetTextByKey("P_MR_TERMUNIT", "Term Unit"), valueIndex: 'TermUnit', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'RentalDate', caption: GetTextByKey("P_MR_RENTALDATEON", "Rental Date On"), valueIndex: 'RentalDate', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'ProjectReturnDate', caption: GetTextByKey("P_MR_PROJECTRETURN", "Project Return"), valueIndex: 'ProjectReturnDate', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'ReturnDate', caption: GetTextByKey("P_MR_RETURNDATE", "Return Date"), valueIndex: 'ReturnDate', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'PONumber', caption: GetTextByKey("P_MR_PURCHASEORDERN", "Purchase Order #"), valueIndex: 'PONumber', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'InsuredValue', caption: GetTextByKey("P_MR_INSUREDVALUE", "Insured Value"), valueIndex: 'InsuredValue', css: { 'width': 150, 'text-align': 'right' } },
|
||||
{ name: 'Comments', caption: GetTextByKey("P_MR_COMMENTS", "Comments"), valueIndex: 'Comments', css: { 'width': 200, 'text-align': 'left' } },
|
||||
{ name: 'Edit', caption: "", css: { 'width': 30, 'text-align': 'center' } },
|
||||
{ name: 'Delete', caption: "", css: { 'width': 30, 'text-align': 'center' } },
|
||||
{ name: 'ViewChangeHistory', caption: "", 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;
|
||||
if (col.name === "Edit") {
|
||||
col.isurl = true;
|
||||
col.text = "\uf044";
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
OnEdit();
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
}
|
||||
col.attrs = { 'title': GetTextByKey("P_MR_EDIT", 'Edit') };
|
||||
}
|
||||
else if (col.name === "Delete") {
|
||||
col.isurl = true;
|
||||
col.text = "\uf00d";
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
OnDelete(this);
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
};
|
||||
col.attrs = { 'title': GetTextByKey("P_MR_DELETE", 'Delete') };
|
||||
}
|
||||
else if (col.name === "ViewChangeHistory") {
|
||||
col.isurl = true;
|
||||
col.text = "\uf06e";
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
OnViewChangeHistory(this);
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
};
|
||||
col.attrs = { 'title': GetTextByKey("P_MR_VIEWCHANGEHIS", 'View Change History') };
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_dt.canMultiSelect = false;
|
||||
grid_dt.columns = columns;
|
||||
grid_dt.init();
|
||||
grid_dt.rowdblclick = OnEdit;
|
||||
|
||||
grid_dt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_dt.source[rowindex];
|
||||
if (rowdata) {
|
||||
rentalID = rowdata.Values.ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function OnExport() {
|
||||
contractorid = htmlencode($.trim($('#sel_contractor').val()));
|
||||
var searchtxt = "";
|
||||
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
|
||||
var from = htmlencode($('#startdatetxt').val());
|
||||
var to = htmlencode($('#enddatetxt').val());
|
||||
|
||||
mid = listeditableSelectMachine.val();
|
||||
if (mid === undefined) mid = "";
|
||||
|
||||
var sortPath = $("#tbRentals").data("sortPath");
|
||||
if (sortPath === undefined) sortPath = "";
|
||||
var desc = $("#tbRentals").data("desc");
|
||||
if (desc === undefined) desc = false;
|
||||
window.open("../ExportToFile.aspx?type=rentals&cid=" + contractorid + "&mid=" + mid
|
||||
+ "&from=" + from + "&to=" + to + "&t=" + searchtxt + "&sp=" + sortPath + "&desc=" + desc);
|
||||
}
|
||||
|
||||
function OnPrint() {
|
||||
contractorid = htmlencode($.trim($('#sel_contractor').val()));
|
||||
var searchtxt = "";
|
||||
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
|
||||
var from = htmlencode($('#startdatetxt').val());
|
||||
var to = htmlencode($('#enddatetxt').val());
|
||||
|
||||
mid = listeditableSelectMachine.val();
|
||||
if (mid === undefined) mid = "";
|
||||
|
||||
var sortPath = $("#tbRentals").data("sortPath");
|
||||
if (sortPath === undefined) sortPath = "";
|
||||
var desc = $("#tbRentals").data("desc");
|
||||
if (desc === undefined) desc = false;
|
||||
window.open("PrintRentals.aspx?cid=" + contractorid + "&mid=" + mid + "&from=" + from + "&to=" + to
|
||||
+ "&t=" + searchtxt + "&sp=" + sortPath + "&desc=" + desc);
|
||||
}
|
||||
|
||||
$(function () {
|
||||
setPageTitle(GetTextByKey("P_MANAGERENTALS", "Manage Rentals"), true);
|
||||
InitGridData();
|
||||
|
||||
editableSelectMachine = new $editableselect($("#dialog_machine"));
|
||||
editableSelectMachine.tabIndex(1);
|
||||
listeditableSelectMachine = new $editableselect($("#sel_machine"));
|
||||
|
||||
if (IsDealer == true) {
|
||||
$('#span_contractor').css('display', '');
|
||||
$('#span_contractor').parent().css('display', '');
|
||||
if (IsAdmin)
|
||||
getContractors();
|
||||
else {
|
||||
GetContractorsByUser();
|
||||
}
|
||||
}
|
||||
else
|
||||
GetMachines();
|
||||
|
||||
$("#sel_contractor").change(function () {
|
||||
GetMachines();
|
||||
});
|
||||
|
||||
|
||||
$('#searchinputtxt').keydown(searchEnter);
|
||||
|
||||
$('#startdatetxt').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
|
||||
$('#enddatetxt').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
|
||||
$('#dialog_rentaldata').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
|
||||
$('#dialog_projectreturndate').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
$('#dialog_returndate').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
|
||||
$(window).resize(function () {
|
||||
$("#rentallist").css("height", $(window).height() - $("#rentallist").offset().top - 4);
|
||||
grid_dt && grid_dt.resize();
|
||||
}).resize();
|
||||
if (!canExport) {
|
||||
$('#spExport').hide();
|
||||
}
|
||||
});
|
||||
|
||||
function searchEnter(e) {
|
||||
if (e.keyCode == 13 || e.keyCode == 9) {
|
||||
OnRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
function OnViewHistory() {
|
||||
var cid = "";
|
||||
cid = htmlencode($.trim($('#sel_contractor').val()));
|
||||
var machineID = "";
|
||||
var machine = listeditableSelectMachine.selecteditem();
|
||||
if (machine != null)
|
||||
machineID = machine.MachineID;
|
||||
else
|
||||
machineID = "";
|
||||
window.open("RentalChangeHistory.aspx?cid=" + cid + "&mid=" + machineID + "");
|
||||
}
|
||||
|
||||
function OnViewChangeHistory(rental) {
|
||||
if (!rental) {
|
||||
return;
|
||||
}
|
||||
var cid = "";
|
||||
cid = htmlencode($.trim($('#sel_contractor').val()));
|
||||
var machineID = "";
|
||||
var machine = listeditableSelectMachine.selecteditem();
|
||||
if (machine != null)
|
||||
machineID = machine.MachineID;
|
||||
else
|
||||
machineID = "";
|
||||
|
||||
window.open("RentalChangeHistory.aspx?cid=" + cid + "&mid=" + machineID + "&rid=" + rental.RentalID + "");
|
||||
}
|
||||
|
||||
</script>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
||||
<div id="recordcontent" style="padding: 0px; margin: 0px;">
|
||||
<div class="page_title" data-lgid="P_MANAGERENTALS">Manage Rentals</div>
|
||||
<table style="width: 100%; border-collapse: collapse; line-height: 32px; min-width: 1280px;">
|
||||
<tr>
|
||||
<td style="display: none; width: 260px;">
|
||||
<span id="span_contractor" style="padding-left: 5px; display: none; float: left;">
|
||||
<span data-lgid="P_MR_CONTRACTOR_COLON">Contractor: </span>
|
||||
<select style="width: 180px;" id="sel_contractor"></select>
|
||||
</span>
|
||||
</td>
|
||||
<td style="width: 60px; display: none;">
|
||||
<span style="padding-left: 5px;" data-lgid="P_MR_ASSET_COLON">Asset: </span>
|
||||
</td>
|
||||
<td style="width: 180px; display: none;">
|
||||
<div id="sel_machine" style="width: 182px; height: 22px; line-height: normal;"></div>
|
||||
</td>
|
||||
<td style="text-align: left;">
|
||||
<span style="padding-left: 5px;" data-lgid="P_MR_RENTALDATEFROM_COLON">Rental Date From: </span>
|
||||
<span>
|
||||
<input id="startdatetxt" style="width: 100px;" value="<%=BeginDate %>" /></span>
|
||||
<span style="padding-left: 5px;" data-lgid="P_MR_TO_COLON">To: </span>
|
||||
<span>
|
||||
<input id="enddatetxt" value="<%=EndDate %>" style="width: 100px;" /></span>
|
||||
<input id="searchinputtxt" autocomplete="off" style="width: 180px; margin-left: 10px;" />
|
||||
<input class="search" type="button" onclick="OnRefresh();" value="Search" data-lgid="P_MR_SEARCH" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6">
|
||||
<div class="function_title">
|
||||
<span class="sbutton iconadd" id="btnAdd" onclick="OnAdd();" data-lgid="P_MR_ADD">Add</span>
|
||||
<span class="sbutton iconedit" onclick="OnEdit();" data-lgid="P_MR_EDIT">Edit</span>
|
||||
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_MR_REFRESH">Refresh</span>
|
||||
<span class="sbutton iconprint" onclick="OnPrint();" style="display: none;" data-lgid="P_MR_PRINT">Print</span>
|
||||
<span id="spExport" class="sbutton iconexport" onclick="OnExport();" data-lgid="P_MR_EXPORTTOEXCEL">Export to Excel</span>
|
||||
<%--<input id="btnhistory" type="button" onclick="OnViewHistory();" value="View Change History" style="width: 150px;" />--%>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="clear"></div>
|
||||
<div id="rentallist">
|
||||
</div>
|
||||
</div>
|
||||
<div id="mask_bg" style="display: none;">
|
||||
<div class="loading c-spin"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="dialog" id="dialog_rental" style="display: none; height: 100%; border-bottom: 0; border-top: 0;">
|
||||
<%--<div class="dialog-title"><span class="title">Add Work Order</span></div>--%>
|
||||
<iframe id="iframerental" style="width: 100%; height: 100%; display: block; border: none;"></iframe>
|
||||
<div class="maskbg" style="display: none;"></div>
|
||||
</div>
|
||||
</asp:Content>
|
81
Site/MachineDeviceManagement/ManageRentals.aspx.cs
Normal file
@ -0,0 +1,81 @@
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor;
|
||||
using IronIntel.Contractor.Site;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class ManageRentals : MachineDeviceBasePage
|
||||
{
|
||||
|
||||
public string BeginDate = "";
|
||||
public string EndDate = "";
|
||||
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
|
||||
public string MachineID = "";
|
||||
public string ContractorID = "";
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!CheckLoginSession())
|
||||
{
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
string methodName = Request.Form["MethodName"];
|
||||
if (!string.IsNullOrEmpty(methodName))
|
||||
{
|
||||
ProcessRequest(methodName);
|
||||
}
|
||||
else if (!IsPostBack)
|
||||
{
|
||||
this.Title = PageTitle;
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
if (!permission)
|
||||
RedirectToLoginPage();
|
||||
ContractorID = Request.Params["cid"];
|
||||
MachineID = Request.Params["mid"];
|
||||
}
|
||||
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
|
||||
BeginDate = userlocaldate.AddMonths(-1).ToShortDateString();
|
||||
EndDate = userlocaldate.ToShortDateString();
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var user = GetCurrentUser();
|
||||
return user != null && user.UserType >= IronIntel.Contractor.Users.UserTypes.Common;
|
||||
}
|
||||
|
||||
public bool IsAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
243
Site/MachineDeviceManagement/OdometerAdjustHistory.aspx
Normal file
@ -0,0 +1,243 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/IronIntelMasterPage.master" AutoEventWireup="true" CodeFile="OdometerAdjustHistory.aspx.cs" Inherits="OdometerAdjustHistory" %>
|
||||
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="holder_head" runat="Server">
|
||||
<style type="text/css">
|
||||
::-ms-clear, ::-ms-reveal {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.selectinput {
|
||||
width: 150px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.dialog-content table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dialog-content table td.label {
|
||||
width: 160px;
|
||||
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: 200px;
|
||||
height: 18px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
.dialog-content table td input[type="checkbox"] {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.dialog-content table td textarea {
|
||||
height: 100px;
|
||||
max-width: 200px;
|
||||
}
|
||||
|
||||
#dialogdatatb td {
|
||||
padding-top: 30px;
|
||||
}
|
||||
|
||||
.a {
|
||||
text-decoration: none;
|
||||
color: #2140fb;
|
||||
}
|
||||
|
||||
.machinetd {
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
<link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" />
|
||||
<script src="<%=GetFileUrlWithVersion("../Maintenance/js/inputdatactr.js")%>" type="text/javascript"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/editableselect.js")%>"></script>
|
||||
<script type="text/javascript">
|
||||
var IsDealer = <%=IsDealer ?"true":"false"%>;
|
||||
var IsAdmin =<%=IsAdmin ?"true":"false"%>;
|
||||
var contractorid = "<%=ContractorID %>";
|
||||
var MachineID = "<%=MachineID %>";
|
||||
|
||||
var machines;
|
||||
var editableSelectMachine;
|
||||
var listeditableSelectMachine;
|
||||
|
||||
function assetrequest(method, param, callback, error) {
|
||||
_network.request("MachineDeviceManagement/OdometerAdjustHistory.aspx", -1, method, param, callback, error || function (e) {
|
||||
showmaskbg(false, true);
|
||||
showAlert(GetTextByKey('P_MA_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_MA_QUERY', 'Query'));
|
||||
});
|
||||
}
|
||||
|
||||
function OnRefresh() {
|
||||
showloading(true);
|
||||
|
||||
var startdate = htmlencode($('#startdatetxt').val());
|
||||
var enddate = htmlencode($('#enddatetxt').val());
|
||||
|
||||
assetrequest("GetOdometerAdjustmentHistory", contractorid + String.fromCharCode(170) + MachineID
|
||||
+ String.fromCharCode(170) + startdate + String.fromCharCode(170) + enddate
|
||||
, function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showloading(false);
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
showOdometerHistory(data);
|
||||
|
||||
showloading(false);
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
});
|
||||
}
|
||||
|
||||
function OnExport() {
|
||||
var from = htmlencode($('#startdatetxt').val());
|
||||
var to = htmlencode($('#enddatetxt').val());
|
||||
|
||||
var sortPath = grid_dt.sortKey;
|
||||
if (sortPath === undefined) sortPath = "";
|
||||
var desc = grid_dt.sortDirection !== 1;
|
||||
window.open("../ExportToFile.aspx?type=odoadjusthis&cid=" + contractorid + "&mid=" + MachineID
|
||||
+ "&from=" + from + "&to=" + to + "&sp=" + sortPath + "&desc=" + desc);
|
||||
}
|
||||
|
||||
|
||||
function showOdometerHistory(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
for (var j in r) {
|
||||
if (j === "AdjustmentLocalTime")
|
||||
r[j] = { DisplayValue: r["AdjustmentLocalTimeText"], Value: r[j] };
|
||||
else if (j === "OdometerLocalTime")
|
||||
r[j] = { DisplayValue: r["OdometerLocalTimeText"], Value: r[j] };
|
||||
}
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
|
||||
grid_dt.setData(rows);
|
||||
}
|
||||
|
||||
var grid_dt;
|
||||
function InitGridData() {
|
||||
grid_dt = new GridView('#odometerlist');
|
||||
grid_dt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'AssetName', caption: GetTextByKey("P_MA_ASSETNAME", "Asset Name"), valueIndex: 'DisplayName', css: { 'width': 200, 'text-align': 'left' } },
|
||||
{ name: 'VIN', caption: GetTextByKey("P_MA_VIN", "VIN"), valueIndex: 'VIN', css: { 'width': 200, 'text-align': 'left' } },
|
||||
{ name: 'UserName', caption: GetTextByKey("P_MA_USERNAME", "User Name"), valueIndex: 'UserName', css: { 'width': 200, 'text-align': 'left' } },
|
||||
{ name: 'AdjustmentLocalTime', caption: GetTextByKey("P_MA_ADJUSTMENTTIME", "Adjustment Time"), valueIndex: 'AdjustmentLocalTime', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'Odometer', caption: GetTextByKey("P_MA_ODOMETERENTERED", "Odometer Entered"), valueIndex: 'Odometer', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'UOM', caption: GetTextByKey("P_MA_ODOMETERUOM", "Odometer Uom"), valueIndex: 'UOM', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'OdometerLocalTime', caption: GetTextByKey("P_MA_ODOMETERTIME", "Odometer Time"), valueIndex: 'OdometerLocalTime', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'Notes', caption: GetTextByKey("P_MA_NOTES", "Notes"), valueIndex: 'Notes', css: { 'width': 300, 'text-align': 'left' } }
|
||||
];
|
||||
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;
|
||||
columns.push(col);
|
||||
}
|
||||
grid_dt.canMultiSelect = false;
|
||||
grid_dt.columns = columns;
|
||||
grid_dt.init();
|
||||
|
||||
}
|
||||
|
||||
|
||||
$(function () {
|
||||
InitGridData();
|
||||
|
||||
OnRefresh();
|
||||
|
||||
$('#startdatetxt').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
|
||||
$('#enddatetxt').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
|
||||
$(window).resize(function () {
|
||||
$("#odometerlist").css("height", $(window).height() - $("#odometerlist").offset().top - 4);
|
||||
grid_dt && grid_dt.resize();
|
||||
}).resize();
|
||||
|
||||
});
|
||||
|
||||
function searchEnter(e) {
|
||||
if (e.keyCode == 13 || e.keyCode == 9) {
|
||||
OnRefresh();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="holder_content" runat="Server">
|
||||
<div id="recordcontent" style="padding: 0px; margin: 0px;">
|
||||
<div class="page_title" data-lgid="P_MA_ODOMETERADJUSTMENTHISTORY">Odometer Adjustment History</div>
|
||||
<table style="width: 100%; border-collapse: collapse; line-height: 32px; min-width: 1200px;">
|
||||
<tr id="tr_search">
|
||||
<td>
|
||||
<span style="padding-left: 5px;" data-lgid="P_MA_STARTDATE_COLON">Start Date:</span>
|
||||
<span>
|
||||
<input id="startdatetxt" style="width: 100px;" value="<%=BeginDate %>" /></span>
|
||||
<span style="padding-left: 5px;" data-lgid="P_MA_ENDDATE_COLON">End Date:</span>
|
||||
<span>
|
||||
<input id="enddatetxt" style="width: 100px;" value="<%=EndDate %>" /></span>
|
||||
<input class="search" type="button" onclick="OnRefresh();" value="Search" data-lgid="P_MA_SEARCH" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="function_title">
|
||||
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_MA_REFRESH">Refresh</span>
|
||||
<span class="sbutton iconexport" onclick="OnExport();" data-lgid="P_MA_EXPORTTOEXCEL">Export to Excel</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="clear"></div>
|
||||
<div id="odometerlist"></div>
|
||||
</div>
|
||||
<div id="mask_bg" style="display: none;">
|
||||
<div class="loading c-spin"></div>
|
||||
</div>
|
||||
|
||||
</asp:Content>
|
82
Site/MachineDeviceManagement/OdometerAdjustHistory.aspx.cs
Normal file
@ -0,0 +1,82 @@
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor;
|
||||
using IronIntel.Contractor.Site;
|
||||
using IronIntel.Contractor.Site.Asset;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class OdometerAdjustHistory : AssetBasePage
|
||||
{
|
||||
public string BeginDate = "";
|
||||
public string EndDate = "";
|
||||
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
|
||||
public string MachineID = "";
|
||||
public string ContractorID = "";
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!CheckLoginSession())
|
||||
{
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
string methodName = Request.Form["MethodName"];
|
||||
if (!string.IsNullOrEmpty(methodName))
|
||||
{
|
||||
ProcessRequest(methodName);
|
||||
}
|
||||
else if (!IsPostBack)
|
||||
{
|
||||
this.Title = PageTitle;
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
if (!permission)
|
||||
RedirectToLoginPage();
|
||||
ContractorID = Request.Params["cid"];
|
||||
MachineID = Request.Params["mid"];
|
||||
}
|
||||
}
|
||||
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
|
||||
BeginDate = userlocaldate.AddMonths(-1).ToShortDateString();
|
||||
EndDate = userlocaldate.ToShortDateString();
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var user = GetCurrentUser();
|
||||
return user != null && user.UserType >= IronIntel.Contractor.Users.UserTypes.Common;
|
||||
}
|
||||
|
||||
public bool IsAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
134
Site/MachineDeviceManagement/PrintRentalChanges.aspx
Normal file
@ -0,0 +1,134 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PrintRentalChanges.aspx.cs" Inherits="PrintRentalChanges" %>
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head runat="server">
|
||||
<title></title>
|
||||
<link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/default.css")%>" type="text/css" />
|
||||
<link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/split_sub.css")%>" type="text/css" />
|
||||
<script src="<%=GetFileUrlWithVersion("../js/jquery-3.6.0.min.js")%>" type="text/javascript"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/utility.js")%>" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
var contractorid = "<%=CompanyID %>";
|
||||
var machineID = "<%=MachineID %>";
|
||||
var rentalID = "<%=RentalID %>";
|
||||
var startdate = "<%=FromDate %>";
|
||||
var enddate = "<%=ToDate %>";
|
||||
var searchtxt = "<%=SearchText %>";
|
||||
var sortpath = "<%=SortPath %>";
|
||||
var desc = <%=DESC %>;
|
||||
|
||||
var rentalsdata = [];
|
||||
|
||||
function devicerequest(method, param, callback, error) {
|
||||
_network.request("MachineDeviceManagement/ManageRentals.aspx", -1, method, param, callback, error || function (e) {
|
||||
console.log(e);
|
||||
showAlert('An unknown error occurred. Please refresh page.', 'Query');
|
||||
});
|
||||
}
|
||||
|
||||
function getRentals() {
|
||||
devicerequest("SearchRentalChangeHistory", contractorid + String.fromCharCode(170) + searchtxt
|
||||
+ String.fromCharCode(170) + startdate + String.fromCharCode(170) + enddate
|
||||
+ String.fromCharCode(170) + machineID + String.fromCharCode(170) + rentalID, function (data) {
|
||||
$('#tbody_rentals').empty();
|
||||
currentShownIndex = -1;
|
||||
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, 'Error');
|
||||
return;
|
||||
}
|
||||
if (data && data.length > 0)
|
||||
rentalsdata = data;
|
||||
else
|
||||
rentalsdata = [];
|
||||
rentalsdata = rentalsdata.sort(dataSort(sortpath, desc));
|
||||
|
||||
showRentals(rentalsdata);
|
||||
|
||||
window.print();
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
function showRentals(data) {
|
||||
var trs = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var rental = data[i];
|
||||
var tr = $('<tr></tr>').data('rental', rental);
|
||||
tr.append($('<td style="width: 120px;"></td>').text(rental.RentalID));
|
||||
tr.append($('<td style="width: 150px;"></td>').html(replaceHtmlText(rental.LastUpdateUserName)));
|
||||
tr.append($('<td style="width: 150px;>"></td>').text(rental.LastUpdateDateStr));
|
||||
tr.append($('<td style="width: 120px;"></td>').html(replaceHtmlText(rental.OperateType)));
|
||||
tr.append($('<td style="width: 180px;"></td>').attr('title', rental.VIN).html(replaceHtmlText(rental.VIN)));
|
||||
tr.append($('<td style="width: 180px;"></td>').attr('title', rental.DisplayName).html(replaceHtmlText(rental.DisplayName)));
|
||||
tr.append($('<td style="width: 180px;"></td>').html(replaceHtmlText(rental.Outside)));
|
||||
tr.append($('<td style="width: 150px;"></td>').html(replaceHtmlText(rental.Vendor)));
|
||||
tr.append($('<td style="width: 150px;"></td>').text(rental.RentalRate));
|
||||
tr.append($('<td style="width: 150px;"></td>').text(rental.Term));
|
||||
tr.append($('<td style="width: 150px;"></td>').text(rental.TermUnit));
|
||||
tr.append($('<td style="width: 150px;>"></td>').text(rental.RentalDateStr));
|
||||
tr.append($('<td style="width: 150px;"></td>').text(rental.ProjectReturnDateStr));
|
||||
tr.append($('<td style="width: 150px;"></td>').text(rental.ReturnDateStr));
|
||||
tr.append($('<td style="width: 150px;"></td>').html(replaceHtmlText(rental.PONumber)));
|
||||
tr.append($('<td style="width: 200px;"></td>').attr('title', rental.Comments).html(replaceHtmlText(rental.Comments)));
|
||||
|
||||
trs.push(tr);
|
||||
}
|
||||
|
||||
$('#tbody_rentals').append(trs);
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$('#tbody_rentals').click(function (e) {
|
||||
var target = $(e.target);
|
||||
if (!target.is('tr')) {
|
||||
target = target.parents('tr');
|
||||
}
|
||||
$('#tbody_rentals tr').removeClass('selected');
|
||||
target.addClass('selected');
|
||||
});
|
||||
|
||||
getRentals();
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<form id="form1" runat="server">
|
||||
<div>
|
||||
<div id="recordcontent" style="padding: 0px; margin: 0px;">
|
||||
<div class="content_main" id="rentalListDiv" style="border-top: 1px solid #5c5c5c; padding: 0px; min-width: 1160px;">
|
||||
<div id="machinesDiv" class="content_main" style="padding: 0px;">
|
||||
<table class="main_table" id="tbRentals" style="min-width: 200px; border-top: none; width: 1500px; table-layout: fixed;">
|
||||
<thead>
|
||||
<tr style="border-width: 0px;">
|
||||
<th style="width: 120px;" sort="RentalID">Rental ID</th>
|
||||
<th style="width: 150px;" sort="LastUpdateUserName">User Name</th>
|
||||
<th style="width: 150px;" sort="LastUpdateDate">Last Update Date</th>
|
||||
<th style="width: 120px;" sort="OperateType">Operate Type</th>
|
||||
<th style="width: 180px;" sort="VIN">VIN/SN</th>
|
||||
<th style="width: 180px;" sort="DisplayName">Machine Name</th>
|
||||
<th style="width: 180px;" sort="Outside">Outside/Internal</th>
|
||||
<th style="width: 150px;" sort="Vendor">Rental Vendor</th>
|
||||
<th style="width: 150px;" sort="RentalRate">Rental Rate</th>
|
||||
<th style="width: 150px;" sort="Term">Term</th>
|
||||
<th style="width: 150px;" sort="TermUnit">Term</th>
|
||||
<th style="width: 150px;" sort="RentalDate">Rental Date On</th>
|
||||
<th style="width: 150px;" sort="ProjectReturnDate">Project Return Date</th>
|
||||
<th style="width: 150px;" sort="ReturnDate">Return Date</th>
|
||||
<th style="width: 150px;" sort="PONumber">Purchase Order #</th>
|
||||
<th style="width: 200px;" sort="Comments">Comments</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbody_rentals">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
40
Site/MachineDeviceManagement/PrintRentalChanges.aspx.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor;
|
||||
using IronIntel.Contractor.Site;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class PrintRentalChanges : MachineDeviceBasePage
|
||||
{
|
||||
public string CompanyID = "";
|
||||
public string MachineID = "";
|
||||
public string RentalID = "";
|
||||
public string FromDate = "";
|
||||
public string ToDate = "";
|
||||
public string SearchText = "";
|
||||
public string SortPath = "";
|
||||
public string DESC = "";
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
this.Title = PageTitle;
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
if (!permission)
|
||||
RedirectToLoginPage();
|
||||
|
||||
CompanyID = Request.Params["cid"];
|
||||
MachineID = Request.Params["mid"];
|
||||
RentalID = Request.Params["rid"];
|
||||
FromDate = Request.Params["from"];
|
||||
ToDate = Request.Params["to"];
|
||||
SearchText = Request.Params["t"];//传过来的参数为HTMLEcode编码
|
||||
SortPath = Request.Params["sp"];
|
||||
DESC = Request.Params["desc"].ToLower();
|
||||
}
|
||||
}
|
||||
}
|
124
Site/MachineDeviceManagement/PrintRentals.aspx
Normal file
@ -0,0 +1,124 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PrintRentals.aspx.cs" Inherits="PrintRentals" %>
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head runat="server">
|
||||
<title></title>
|
||||
<link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/default.css")%>" type="text/css" />
|
||||
<link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/split_sub.css")%>" type="text/css" />
|
||||
<script src="<%=GetFileUrlWithVersion("../js/jquery-3.6.0.min.js")%>" type="text/javascript"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/utility.js")%>" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
var contractorid = "<%=CompanyID %>";
|
||||
var machineID = "<%=MachineID %>";
|
||||
var startdate = "<%=FromDate %>";
|
||||
var enddate = "<%=ToDate %>";
|
||||
var searchtxt = "<%=SearchText %>";
|
||||
var sortpath = "<%=SortPath %>";
|
||||
var desc = <%=DESC %>;
|
||||
|
||||
var rentalsdata = [];
|
||||
|
||||
function devicerequest(method, param, callback, error) {
|
||||
_network.request("MachineDeviceManagement/ManageRentals.aspx", -1, method, param, callback, error || function (e) {
|
||||
console.log(e);
|
||||
showAlert('An unknown error occurred. Please refresh page.', 'Query');
|
||||
});
|
||||
}
|
||||
|
||||
function getRentals() {
|
||||
devicerequest("SearchRentals", contractorid + String.fromCharCode(170) + searchtxt
|
||||
+ String.fromCharCode(170) + startdate + String.fromCharCode(170) + enddate
|
||||
+ String.fromCharCode(170) + machineID, function (data) {
|
||||
$('#tbody_rentals').empty();
|
||||
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, 'Error');
|
||||
return;
|
||||
}
|
||||
if (data && data.length > 0)
|
||||
rentalsdata = data;
|
||||
else
|
||||
rentalsdata = [];
|
||||
rentalsdata = rentalsdata.sort(dataSort(sortpath, desc));
|
||||
|
||||
showRentals(rentalsdata);
|
||||
|
||||
window.print();
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
function showRentals(data) {
|
||||
var trs = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var rental = data[i];
|
||||
var tr = $('<tr></tr>').data('rental', rental);
|
||||
tr.append($('<td style="width: 180px;"></td>').attr('title', rental.VIN).html(replaceHtmlText(rental.VIN)));
|
||||
tr.append($('<td style="width: 180px;"></td>').attr('title', rental.DisplayName).html(replaceHtmlText(rental.DisplayName)));
|
||||
tr.append($('<td style="width: 180px;"></td>').html(replaceHtmlText(rental.Outside)));
|
||||
tr.append($('<td style="width: 150px;"></td>').html(replaceHtmlText(rental.Vendor)));
|
||||
tr.append($('<td style="width: 150px;"></td>').text(rental.RentalRate));
|
||||
tr.append($('<td style="width: 150px;"></td>').text(rental.Term));
|
||||
tr.append($('<td style="width: 150px;"></td>').text(rental.TermUnit));
|
||||
tr.append($('<td style="width: 150px;>"></td>').text(rental.RentalDateStr));
|
||||
tr.append($('<td style="width: 150px;"></td>').text(rental.ProjectReturnDateStr));
|
||||
tr.append($('<td style="width: 150px;"></td>').text(rental.ReturnDateStr));
|
||||
tr.append($('<td style="width: 150px;"></td>').html(replaceHtmlText(rental.PONumber)));
|
||||
tr.append($('<td style="width: 200px;"></td>').attr('title', rental.Comments).html(replaceHtmlText(rental.Comments)));
|
||||
|
||||
trs.push(tr);
|
||||
}
|
||||
|
||||
$('#tbody_rentals').append(trs);
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$('#tbody_rentals').click(function (e) {
|
||||
var target = $(e.target);
|
||||
if (!target.is('tr')) {
|
||||
target = target.parents('tr');
|
||||
}
|
||||
$('#tbody_rentals tr').removeClass('selected');
|
||||
target.addClass('selected');
|
||||
});
|
||||
|
||||
getRentals();
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<form id="form1" runat="server">
|
||||
<div>
|
||||
<div id="recordcontent" style="padding: 0px; margin: 0px;">
|
||||
<div class="content_main" id="rentalListDiv" style="border-top: 1px solid #5c5c5c; padding: 0px; min-width: 1160px;">
|
||||
<div id="machinesDiv" class="content_main" style="padding: 0px;">
|
||||
<table class="main_table" id="tbRentals" style="min-width: 200px; border-top: none; width: 1500px; table-layout: fixed;">
|
||||
<thead>
|
||||
<tr style="border-width: 0px;">
|
||||
<th style="width: 180px;" sort="VIN">VIN/SN</th>
|
||||
<th style="width: 180px;" sort="DisplayName">Machine Name</th>
|
||||
<th style="width: 180px;" sort="Outside">Outside/Internal</th>
|
||||
<th style="width: 150px;" sort="Vendor">Rental Vendor</th>
|
||||
<th style="width: 150px;" sort="RentalRate">Rental Rate</th>
|
||||
<th style="width: 150px;" sort="Term">Term</th>
|
||||
<th style="width: 150px;" sort="TermUnit">Term</th>
|
||||
<th style="width: 150px;" sort="RentalDate">Rental Date On</th>
|
||||
<th style="width: 150px;" sort="ProjectReturnDate">Project Return Date</th>
|
||||
<th style="width: 150px;" sort="ReturnDate">Return Date</th>
|
||||
<th style="width: 150px;" sort="PONumber">Purchase Order #</th>
|
||||
<th style="width: 200px;" sort="Comments">Comments</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbody_rentals">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
38
Site/MachineDeviceManagement/PrintRentals.aspx.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor;
|
||||
using IronIntel.Contractor.Site;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class PrintRentals : MachineDeviceBasePage
|
||||
{
|
||||
public string CompanyID = "";
|
||||
public string MachineID = "";
|
||||
public string FromDate = "";
|
||||
public string ToDate = "";
|
||||
public string SearchText = "";
|
||||
public string SortPath = "";
|
||||
public string DESC = "";
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
this.Title = PageTitle;
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
if (!permission)
|
||||
RedirectToLoginPage();
|
||||
|
||||
CompanyID = Request.Params["cid"];
|
||||
MachineID = Request.Params["mid"];
|
||||
FromDate = Request.Params["from"];
|
||||
ToDate = Request.Params["to"];
|
||||
SearchText = Request.Params["t"];//传过来的参数为HTMLEcode编码
|
||||
SortPath = Request.Params["sp"];
|
||||
DESC = Request.Params["desc"].ToLower();
|
||||
}
|
||||
}
|
||||
}
|
406
Site/MachineDeviceManagement/RentalChangeHistory.aspx
Normal file
@ -0,0 +1,406 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/IronIntelMasterPage.master" AutoEventWireup="true" CodeFile="RentalChangeHistory.aspx.cs" Inherits="RentalChangeHistory" %>
|
||||
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="holder_head" runat="Server">
|
||||
<style type="text/css">
|
||||
::-ms-clear, ::-ms-reveal {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.selectinput {
|
||||
width: 150px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.dialog-content table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dialog-content table td.label {
|
||||
width: 160px;
|
||||
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: 200px;
|
||||
height: 18px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
.dialog-content table td input[type="checkbox"] {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.dialog-content table td textarea {
|
||||
height: 100px;
|
||||
max-width: 200px;
|
||||
}
|
||||
|
||||
#dialogdatatb td {
|
||||
padding-top: 30px;
|
||||
}
|
||||
|
||||
.a {
|
||||
text-decoration: none;
|
||||
color: #2140fb;
|
||||
}
|
||||
|
||||
.machinetd {
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
<link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" />
|
||||
<script src="<%=GetFileUrlWithVersion("../Maintenance/js/inputdatactr.js")%>" type="text/javascript"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script>
|
||||
<script src="<%=GetFileUrlWithVersion("../js/editableselect.js")%>"></script>
|
||||
<script type="text/javascript">
|
||||
var IsDealer = <%=IsDealer ?"true":"false"%>;
|
||||
var IsAdmin =<%=IsAdmin ?"true":"false"%>;
|
||||
var contractorid = "<%=ContractorID %>";
|
||||
var MachineID = "<%=MachineID %>";
|
||||
var RentalID = "<%=RentalID %>";
|
||||
var machines;
|
||||
var editableSelectMachine;
|
||||
var listeditableSelectMachine;
|
||||
|
||||
function devicerequest(method, param, callback, error) {
|
||||
_network.request("MachineDeviceManagement/ManageRentals.aspx", -1, method, param, callback, error || function (e) {
|
||||
showmaskbg(false, true);
|
||||
showAlert(GetTextByKey('P_MR_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_MR_QUERY', 'Query'));
|
||||
});
|
||||
}
|
||||
|
||||
//admin用户 获取所有contractor
|
||||
function getContractors() {
|
||||
devicerequest('GetContractors', '', function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MR_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
if (data && data.length > 0) {
|
||||
var sel_search = $('#sel_contractor').empty();
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var kv = data[i];
|
||||
var op_search = $('<option></option>').val(kv.Key).text(kv.Value);
|
||||
if (kv.Key == contractorid)
|
||||
op_search.prop('selected', true);
|
||||
sel_search.append(op_search);
|
||||
}
|
||||
if (contractorid !== "")
|
||||
sel_search.val(contractorid);
|
||||
}
|
||||
|
||||
GetMachines();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
//普通用户 获取可操作的contractor
|
||||
function GetContractorsByUser() {
|
||||
devicerequest('GetContractorsByUser', '', function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MR_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
if (data && data.length > 0) {
|
||||
var sel_search = $('#sel_contractor').empty();
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var kv = data[i];
|
||||
var op_search = $('<option></option>').val(kv.Key).text(kv.Value);
|
||||
sel_search.append(op_search);
|
||||
}
|
||||
|
||||
if (contractorid !== "")
|
||||
sel_search.val(contractorid);
|
||||
}
|
||||
GetMachines();
|
||||
});
|
||||
}
|
||||
|
||||
function GetMachines() {
|
||||
contractorid = htmlencode($.trim($('#sel_contractor').val()));
|
||||
|
||||
devicerequest("GetSelectMachinesByCompany", contractorid, function (data) {
|
||||
if (data && data.length > 0) {
|
||||
machines = data;
|
||||
listeditableSelectMachine.datasource = machines;
|
||||
listeditableSelectMachine.valuepath = "MachineID"
|
||||
listeditableSelectMachine.displaypath = "DisplayName";
|
||||
//if (MachineID !== "")//暂时不过滤机器
|
||||
//listeditableSelectMachine.val(MachineID);
|
||||
}
|
||||
|
||||
OnRefresh();
|
||||
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
function OnRefresh() {
|
||||
showloading(true);
|
||||
|
||||
var cid = htmlencode($.trim($('#sel_contractor').val()));
|
||||
if (cid && cid != '')
|
||||
contractorid = cid;
|
||||
var searchtxt = "";
|
||||
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
|
||||
var startdate = htmlencode($('#startdatetxt').val());
|
||||
var enddate = htmlencode($('#enddatetxt').val());
|
||||
|
||||
var machine = listeditableSelectMachine.selecteditem();
|
||||
if (machine != null)
|
||||
MachineID = machine.MachineID;
|
||||
else
|
||||
MachineID = "";
|
||||
|
||||
|
||||
devicerequest("SearchRentalChangeHistory", contractorid + String.fromCharCode(170) + searchtxt
|
||||
+ String.fromCharCode(170) + startdate + String.fromCharCode(170) + enddate
|
||||
+ String.fromCharCode(170) + MachineID + String.fromCharCode(170) + RentalID, function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showloading(false);
|
||||
showAlert(data, GetTextByKey("P_MR_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
showRentals(data);
|
||||
|
||||
showloading(false);
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
});
|
||||
}
|
||||
|
||||
function OnExport() {
|
||||
var cid = htmlencode($.trim($('#sel_contractor').val()));
|
||||
if (cid && cid != '')
|
||||
contractorid = cid;
|
||||
var searchtxt = "";
|
||||
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
|
||||
var from = htmlencode($('#startdatetxt').val());
|
||||
var to = htmlencode($('#enddatetxt').val());
|
||||
|
||||
mid = listeditableSelectMachine.val();
|
||||
if (mid === undefined) mid = "";
|
||||
|
||||
var sortPath = grid_dt.sortKey;
|
||||
if (sortPath === undefined) sortPath = "";
|
||||
var desc = grid_dt.sortDirection !== 1;
|
||||
window.open("../ExportToFile.aspx?type=rentalchg&cid=" + contractorid + "&mid=" + mid + "&rid=" + RentalID
|
||||
+ "&from=" + from + "&to=" + to + "&t=" + searchtxt + "&sp=" + sortPath + "&desc=" + desc);
|
||||
}
|
||||
|
||||
function OnPrint() {
|
||||
var cid = htmlencode($.trim($('#sel_contractor').val()));
|
||||
if (cid && cid != '')
|
||||
contractorid = cid;
|
||||
var searchtxt = "";
|
||||
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
|
||||
var from = htmlencode($('#startdatetxt').val());
|
||||
var to = htmlencode($('#enddatetxt').val());
|
||||
|
||||
mid = listeditableSelectMachine.val();
|
||||
if (mid === undefined) mid = "";
|
||||
|
||||
var sortPath = grid_dt.sortKey;
|
||||
if (sortPath === undefined) sortPath = "";
|
||||
var desc = grid_dt.sortDirection !== 1;
|
||||
window.open("PrintRentalChanges.aspx?cid=" + contractorid + "&mid=" + mid + "&rid=" + RentalID
|
||||
+ "&from=" + from + "&to=" + to + "&t=" + searchtxt + "&sp=" + sortPath + "&desc=" + desc);
|
||||
}
|
||||
|
||||
function showRentals(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
for (var j in r) {
|
||||
if (j === "LastUpdateDate")
|
||||
r[j] = { DisplayValue: r["LastUpdateDateStr"], Value: r[j] };
|
||||
else if (j === "RentalDate")
|
||||
r[j] = { DisplayValue: r["RentalDateStr"], Value: r[j] };
|
||||
else if (j === "ProjectReturnDate")
|
||||
r[j] = { DisplayValue: r["ProjectReturnDateStr"], Value: r[j] };
|
||||
else if (j === "ReturnDate")
|
||||
r[j] = { DisplayValue: r["ReturnDateStr"], Value: r[j] };
|
||||
}
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
|
||||
grid_dt.setData(rows);
|
||||
}
|
||||
|
||||
var grid_dt;
|
||||
function InitGridData() {
|
||||
$('#btnEdit').attr("disabled", "disabled");
|
||||
|
||||
grid_dt = new GridView('#rentallist');
|
||||
grid_dt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'RentalID', caption: GetTextByKey("P_MR_RENTALID", "Rental ID"), valueIndex: 'RentalID', css: { 'width': 120, 'text-align': 'left' } },
|
||||
{ name: 'LastUpdateUserName', caption: GetTextByKey("P_MR_USERNAME", "User Name"), valueIndex: 'LastUpdateUserName', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'LastUpdateDate', caption: GetTextByKey("P_MR_LASTUPDATEDATE", "Last Update Date"), valueIndex: 'LastUpdateDate', css: { 'width': 150, 'text-align': 'left' } },
|
||||
//{ name: 'OperateType', caption: "Operate Type", valueIndex: 'OperateType',allowFilter:true, css: { 'width': 120, 'text-align': 'left' } },
|
||||
{ name: 'VIN', caption: GetTextByKey("P_MR_VINSN", "VIN/SN"), valueIndex: 'VIN', css: { 'width': 180, 'text-align': 'left' } },
|
||||
{ name: 'DisplayName', caption: GetTextByKey("P_MR_ASSETNAME", "Asset Name"), valueIndex: 'DisplayName', css: { 'width': 180, 'text-align': 'left' } },
|
||||
{ name: 'Outside', caption: GetTextByKey("P_MR_OUTSIDEINTERNAL", "Outside/Internal"), valueIndex: 'Outside', allowFilter: true, css: { 'width': 180, 'text-align': 'left' } },
|
||||
{ name: 'Vendor', caption: GetTextByKey("P_MR_RENTALVENDOR", "Rental Vendor"), valueIndex: 'Vendor', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'RentalRate', caption: GetTextByKey("P_MR_RENTALRATE", "Rental Rate"), valueIndex: 'RentalRate', css: { 'width': 150, 'text-align': 'right' } },
|
||||
{ name: 'Term', caption: GetTextByKey("P_MR_TERM", "Term"), valueIndex: 'Term', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'TermUnit', caption: GetTextByKey("P_MR_TERMUNIT", "Term Unit"), valueIndex: 'TermUnit', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'RentalDate', caption: GetTextByKey("P_MR_RENTALDATEON", "Rental Date On"), valueIndex: 'RentalDate', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'ProjectReturnDate', caption: GetTextByKey("P_MR_PROJECTRETURN", "Project Return"), valueIndex: 'ProjectReturnDate', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'ReturnDate', caption: GetTextByKey("P_MR_RETURNDATE", "Return Date"), valueIndex: 'ReturnDate', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'PONumber', caption: GetTextByKey("P_MR_PURCHASEORDERN", "Purchase Order #"), valueIndex: 'PONumber', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'InsuredValue', caption: GetTextByKey("P_MR_INSUREDVALUE", "Insured Value"), valueIndex: 'InsuredValue', css: { 'width': 150, 'text-align': 'right' } },
|
||||
{ name: 'Comments', caption: GetTextByKey("P_MR_COMMENTS", "Comments"), valueIndex: 'Comments', css: { 'width': 200, 'text-align': 'left' } }
|
||||
];
|
||||
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;
|
||||
columns.push(col);
|
||||
}
|
||||
grid_dt.canMultiSelect = false;
|
||||
grid_dt.columns = columns;
|
||||
grid_dt.init();
|
||||
|
||||
}
|
||||
|
||||
|
||||
$(function () {
|
||||
$("#content").applyFleetLanguageText();
|
||||
InitGridData();
|
||||
listeditableSelectMachine = new $editableselect($("#sel_machine"));
|
||||
|
||||
if (RentalID !== "") {
|
||||
$('#tr_search').css('display', 'none');
|
||||
}
|
||||
|
||||
//if (IsDealer == true) {
|
||||
// $('#span_contractor').css('display', '');
|
||||
// $('#span_contractor').parent().css('display', '');
|
||||
// if (IsAdmin)
|
||||
// getContractors();
|
||||
// else {
|
||||
// GetContractorsByUser();
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
// GetMachines();
|
||||
|
||||
//$("#sel_contractor").change(function () {
|
||||
// GetMachines();
|
||||
//});
|
||||
|
||||
OnRefresh();
|
||||
|
||||
$('#searchinputtxt').keydown(searchEnter);
|
||||
|
||||
$('#startdatetxt').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
|
||||
$('#enddatetxt').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
|
||||
$(window).resize(function () {
|
||||
$("#rentallist").css("height", $(window).height() - $("#rentallist").offset().top - 4);
|
||||
grid_dt && grid_dt.resize();
|
||||
}).resize();
|
||||
|
||||
if (!canExport) {
|
||||
$('#spExport').hide();
|
||||
}
|
||||
});
|
||||
|
||||
function searchEnter(e) {
|
||||
if (e.keyCode == 13 || e.keyCode == 9) {
|
||||
OnRefresh();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="holder_content" runat="Server">
|
||||
<div id="recordcontent" style="padding: 0px; margin: 0px;">
|
||||
<div class="page_title" data-lgid="P_MR_RENTALCHANGEHISTORY">Rental Change History</div>
|
||||
<table style="width: 100%; border-collapse: collapse; line-height: 32px; min-width: 1200px;">
|
||||
<tr id="tr_search">
|
||||
<td style="display: none; width: 260px;">
|
||||
<span id="span_contractor" style="padding-left: 5px; display: none; float: left;">
|
||||
<span data-lgid="P_MR_CONTRACTOR_COLON">Contractor:</span>
|
||||
<select style="width: 180px;" id="sel_contractor"></select>
|
||||
</span>
|
||||
</td>
|
||||
<td style="width: 60px; display: none;">
|
||||
<span style="padding-left: 5px;" data-lgid="P_MR_ASSET_COLON">Asset:</span>
|
||||
</td>
|
||||
<td style="width: 180px; display: none;">
|
||||
<div id="sel_machine" style="width: 182px; height: 22px; line-height: normal;"></div>
|
||||
</td>
|
||||
<td style="width: 360px;">
|
||||
<span style="padding-left: 5px;" data-lgid="P_MR_RENTALDATEFROM_COLON">Rental Date From:</span>
|
||||
<span>
|
||||
<input id="startdatetxt" type="text" style="width: 100px;" /></span>
|
||||
<span style="padding-left: 5px;" data-lgid="P_MR_TO_COLON">To</span>
|
||||
<span>
|
||||
<input id="enddatetxt" type="text" style="width: 100px;" /></span>
|
||||
</td>
|
||||
<td style="width: 320px;">
|
||||
<input id="searchinputtxt" type="text" autocomplete="off" style="width: 180px; margin-left: 10px;" />
|
||||
<input class="search" type="button" onclick="OnRefresh();" value="Search" data-lgid="P_MR_SEARCH" />
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6">
|
||||
<div class="function_title">
|
||||
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_MR_REFRESH">Refresh</span>
|
||||
<span class="sbutton iconprint" onclick="OnPrint();" style="display: none;" data-lgid="P_MR_PRINT">Print</span>
|
||||
<span id="spExport" class="sbutton iconexport" onclick="OnExport();" data-lgid="P_MR_EXPORTTOEXCEL">Export to Excel</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="clear"></div>
|
||||
<div id="rentallist"></div>
|
||||
</div>
|
||||
<div id="mask_bg" style="display: none;">
|
||||
<div class="loading c-spin"></div>
|
||||
</div>
|
||||
|
||||
</asp:Content>
|
78
Site/MachineDeviceManagement/RentalChangeHistory.aspx.cs
Normal file
@ -0,0 +1,78 @@
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor;
|
||||
using IronIntel.Contractor.Site;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class RentalChangeHistory : MachineDeviceBasePage
|
||||
{
|
||||
|
||||
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
|
||||
public string MachineID = "";
|
||||
public string ContractorID = "";
|
||||
public string RentalID = "";
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!CheckLoginSession())
|
||||
{
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
string methodName = Request.Form["MethodName"];
|
||||
if (!string.IsNullOrEmpty(methodName))
|
||||
{
|
||||
ProcessRequest(methodName);
|
||||
}
|
||||
else if (!IsPostBack)
|
||||
{
|
||||
this.Title = PageTitle;
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
if (!permission)
|
||||
RedirectToLoginPage();
|
||||
ContractorID = Request.Params["cid"];
|
||||
MachineID = Request.Params["mid"];
|
||||
RentalID = Request.Params["rid"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var user = GetCurrentUser();
|
||||
return user != null && user.UserType >= IronIntel.Contractor.Users.UserTypes.Common;
|
||||
}
|
||||
|
||||
public bool IsAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
1145
Site/MachineDeviceManagement/ShareMachines.aspx
Normal file
88
Site/MachineDeviceManagement/ShareMachines.aspx.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor;
|
||||
using IronIntel.Contractor.Site.Asset;
|
||||
using System;
|
||||
|
||||
public partial class ShareMachines : ShareAssetBasePage
|
||||
{
|
||||
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
|
||||
public bool IsReadOnly = false;
|
||||
public string CurrentDate = "";
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
string methodName = Request.Form["MethodName"];
|
||||
if (!string.IsNullOrEmpty(methodName))
|
||||
{
|
||||
ProcessRequest(methodName);
|
||||
}
|
||||
else if (!IsPostBack)
|
||||
{
|
||||
if (!CheckLoginSession())
|
||||
{
|
||||
RedirectToLoginPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Title = PageTitle;
|
||||
bool license = SystemParams.HasLicense("ShareAsset");
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
if (!permission || !license)
|
||||
RedirectToLoginPage();
|
||||
|
||||
IsReadOnly = CheckReadonly(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
}
|
||||
}
|
||||
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
|
||||
CurrentDate = userlocaldate.ToShortDateString();
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var user = GetCurrentUser();
|
||||
return user != null && user.UserType >= IronIntel.Contractor.Users.UserTypes.Common;
|
||||
}
|
||||
|
||||
public bool IsAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSupperAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
return user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin;
|
||||
}
|
||||
}
|
||||
public bool CheckRight
|
||||
{
|
||||
get
|
||||
{
|
||||
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
|
||||
return permission;
|
||||
}
|
||||
}
|
||||
}
|
BIN
Site/MachineDeviceManagement/img/del.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
Site/MachineDeviceManagement/img/deviceassign.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
Site/MachineDeviceManagement/img/devices.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
Site/MachineDeviceManagement/img/machinegroups.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
Site/MachineDeviceManagement/img/machines.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
Site/MachineDeviceManagement/img/make.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
Site/MachineDeviceManagement/img/model.png
Normal file
After Width: | Height: | Size: 1000 B |
BIN
Site/MachineDeviceManagement/img/rental.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
682
Site/MachineDeviceManagement/js/adj_enginehours.js
Normal file
@ -0,0 +1,682 @@
|
||||
$(function () {
|
||||
InitEnginehoursGridData();
|
||||
InitMostRecentEnginehoursGridData();
|
||||
InitEnginehoursHisGridData();
|
||||
});
|
||||
|
||||
var grid_enginehoursdt;
|
||||
var grid_enginehoursmostrecentdt;
|
||||
var grid_enginehourshisdt;
|
||||
var isCalampEH = false;
|
||||
var isPedigreeEH = false;
|
||||
var isOEMDD2EH = false;
|
||||
var primarydatadourcenameEH;
|
||||
var primarydatadourceEH;
|
||||
|
||||
function ShowEngineHours(data) {
|
||||
var rows = [];
|
||||
isCalampEH = false;
|
||||
isPedigreeEH = false;
|
||||
isOEMDD2EH = false;
|
||||
primarydatadourcenameEH = undefined;
|
||||
primarydatadourceEH = undefined;
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
for (var j in r) {
|
||||
if (j === "IsPrimary")
|
||||
r[j] = r[j] === true ? "Yes" : "";
|
||||
else if (j === "UOM")
|
||||
r[j] = "Hour";
|
||||
}
|
||||
r.Hours = r.Hours.toFixed(2);
|
||||
r.Corrected = r.Corrected.toFixed(2);
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
|
||||
if (r.DataSource.toLowerCase() == "calamp" && r.IsPrimary.toLowerCase() == "yes")
|
||||
isCalampEH = true;
|
||||
else if (r.DataSource.toLowerCase() == "pedigree") {
|
||||
if (r.IsPrimary.toLowerCase() == "yes" && r.SubSource.toLowerCase() != "totalenginehours")//10471
|
||||
isPedigreeEH = true;
|
||||
if (r.SubSource.toLowerCase() == "totalenginehours")
|
||||
r.DataSourceName = "HOS";
|
||||
}
|
||||
else if (r.DataSource.toLowerCase() == "oemdd2" && r.IsPrimary.toLowerCase() == "yes")
|
||||
isOEMDD2EH = true;
|
||||
if (r.IsPrimary.toLowerCase() == "yes") {
|
||||
primarydatadourcenameEH = r.DataSourceName;
|
||||
primarydatadourceEH = r.DataSource;
|
||||
}
|
||||
}
|
||||
grid_enginehoursdt.sortIndex = 0;
|
||||
grid_enginehoursdt.sortDirection = -1;
|
||||
grid_enginehoursdt.setData(rows);
|
||||
|
||||
$("#enginehourslist").css("height", autoheight(grid_enginehoursdt));
|
||||
grid_enginehoursdt && grid_enginehoursdt.resize();
|
||||
|
||||
if ((IsSupperAdmin || isAllowed) && (isCalampEH || isPedigreeEH || isOEMDD2EH)) {
|
||||
$('#btnenginehoursadjust').css("display", '');
|
||||
$('#btnenginehourshistory').css("display", '');
|
||||
}
|
||||
else {
|
||||
$('#btnenginehoursadjust').css("display", 'none');
|
||||
$('#btnenginehourshistory').css("display", 'none');
|
||||
}
|
||||
|
||||
if (primarydatadourcenameEH) {
|
||||
$('#span_adjustenginehours').text(primarydatadourcenameEH);
|
||||
$('#span_addenginehours').text(primarydatadourcenameEH);
|
||||
}
|
||||
else {
|
||||
$('#span_adjustenginehours').text(GetTextByKey("P_MA_EMPTY", 'empty'));
|
||||
$('#span_addenginehours').text(GetTextByKey("P_MA_EMPTY", 'empty'));
|
||||
}
|
||||
}
|
||||
|
||||
function InitEnginehoursGridData() {
|
||||
grid_enginehoursdt = new GridView('#enginehourslist');
|
||||
grid_enginehoursdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'IsPrimary', caption: GetTextByKey("P_MA_ISPRIMARY", "Is Primary"), valueIndex: 'IsPrimary', css: { 'width': 80, 'text-align': 'left' } },
|
||||
{ name: 'DataSourceName', caption: GetTextByKey("P_MA_DATASOURCE", "Data Source"), valueIndex: 'DataSourceName', css: { 'width': 120, 'text-align': 'left' } },
|
||||
{ name: 'Hours', caption: GetTextByKey("P_MA_ENGINEHOURS", "Engine Hours"), valueIndex: 'Hours', css: { 'width': 90, 'text-align': 'left' } },
|
||||
{ name: 'Corrected', caption: GetTextByKey("P_MA_ADJUSTED", "Adjusted"), valueIndex: 'Corrected', css: { 'width': 75, 'text-align': 'left' } },
|
||||
{ name: 'UOM', caption: GetTextByKey("P_MA_UNITS", "Units"), valueIndex: 'UOM', css: { 'width': 60, 'text-align': 'left' } },
|
||||
{ name: 'ReceivedDate', caption: GetTextByKey("P_MA_RECEIVEDDATE", "Received Date"), valueIndex: 'ReceivedDateStr', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'SetPrmary', caption: "", css: { 'width': 100, 'text-align': 'left' } }
|
||||
];
|
||||
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 = false;
|
||||
col.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
if (col.name === "SetPrmary") {
|
||||
col.isurl = true;
|
||||
col.text = GetTextByKey("P_MA_SETASPRIMARY", 'Set As Primary');
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
openSetPrimary(1, this);
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
};
|
||||
col.styleFilter = function (e) {
|
||||
return {
|
||||
display: e.IsPrimary === "Yes" || (!IsSupperAdmin && !isAllowed) ? 'none' : ''
|
||||
};
|
||||
};
|
||||
col.attrs = { 'title': GetTextByKey("P_MA_SETASPRIMARY", 'Set As Primary') };
|
||||
col.resizable = false;
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_enginehoursdt.canMultiSelect = false;
|
||||
grid_enginehoursdt.columns = columns;
|
||||
grid_enginehoursdt.init();
|
||||
|
||||
grid_enginehoursdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_enginehoursdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function InitMostRecentEnginehoursGridData() {
|
||||
grid_enginehoursmostrecentdt = new GridView('#enginehoursmostrecent');
|
||||
grid_enginehoursmostrecentdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'DeviceAirId', caption: GetTextByKey("P_MA_DEVICEAIRID", "Device Air ID"), valueIndex: 'DeviceAirId', css: { 'width': 140, 'text-align': 'left' } },
|
||||
{ name: 'DeviceSN', caption: GetTextByKey("P_MA_DEVICESN", "Device SN"), valueIndex: 'DeviceSN', css: { 'width': 140, 'text-align': 'left' } },
|
||||
{ name: 'SN', caption: GetTextByKey("P_MA_SN", "SN"), valueIndex: 'SN', css: { 'width': 140, 'text-align': 'left' } },
|
||||
{ name: 'AsofTime', caption: GetTextByKey("P_MA_EVENTDATEUTC", "Event Date(UTC)"), valueIndex: 'EventTimeText', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'AsofTimeLocal', caption: GetTextByKey("P_MA_EVENTDATE", "Event Date"), valueIndex: 'EventTimeLocalText', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'VBUS', caption: GetTextByKey("P_MA_VBUSRAW", "VBUS(Raw)"), valueIndex: 'VBUS', css: { 'width': 110, 'text-align': 'right' } },
|
||||
{ name: 'VBUS_Calc', caption: GetTextByKey("P_MA_VBUSCALC", "VBUS(Calc)"), valueIndex: 'VBUS_Calc', css: { 'width': 120, 'text-align': 'right' } },
|
||||
{ name: 'Gps', caption: GetTextByKey("P_MA_GPSRAW", "GPS(Raw)"), valueIndex: 'Gps', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Gps_Calc', caption: GetTextByKey("P_MA_GPSCALC", "GPS(Calc)"), valueIndex: 'Gps_Calc', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Raw', caption: GetTextByKey("P_MA_RAW", "Raw"), valueIndex: 'Raw', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Calculated', caption: GetTextByKey("P_MA_CALCULATED", "Calculated"), valueIndex: 'Calculated', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Unit', caption: GetTextByKey("P_MA_UNIT", "Unit"), valueIndex: 'UOM', css: { 'width': 60, 'text-align': 'right' } }
|
||||
];
|
||||
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 = false;
|
||||
col.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_enginehoursmostrecentdt.canMultiSelect = false;
|
||||
grid_enginehoursmostrecentdt.columns = columns;
|
||||
grid_enginehoursmostrecentdt.init();
|
||||
}
|
||||
|
||||
|
||||
function InitEnginehoursHisGridData() {
|
||||
grid_enginehourshisdt = new GridView('#enginehourshislist');
|
||||
grid_enginehourshisdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'DeviceAirId', caption: GetTextByKey("P_MA_DEVICEAIRID", "Device Air ID"), valueIndex: 'DeviceAirId', css: { 'width': 140, 'text-align': 'left' } },
|
||||
{ name: 'DeviceSN', caption: GetTextByKey("P_MA_DEVICESN", "Device SN"), valueIndex: 'DeviceSN', css: { 'width': 140, 'text-align': 'left' } },
|
||||
{ name: 'SN', caption: GetTextByKey("P_MA_SN", "SN"), valueIndex: 'SN', css: { 'width': 140, 'text-align': 'left' } },
|
||||
{ name: 'AsofTime', caption: GetTextByKey("P_MA_EVENTDATEUTC", "Event Date(UTC)"), valueIndex: 'EventTimeText', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'AsofTimeLocal', caption: GetTextByKey("P_MA_EVENTDATE", "Event Date"), valueIndex: 'EventTimeLocalText', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'VBUS', caption: GetTextByKey("P_MA_VBUSRAW", "VBUS(Raw)"), valueIndex: 'VBUS', css: { 'width': 110, 'text-align': 'right' } },
|
||||
{ name: 'VBUS_Calc', caption: GetTextByKey("P_MA_VBUSCALC", "VBUS(Calc)"), valueIndex: 'VBUS_Calc', css: { 'width': 120, 'text-align': 'right' } },
|
||||
{ name: 'Gps', caption: GetTextByKey("P_MA_GPSRAW", "GPS(Raw)"), valueIndex: 'Gps', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Gps_Calc', caption: GetTextByKey("P_MA_GPSCALC", "GPS(Calc)"), valueIndex: 'Gps_Calc', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Raw', caption: GetTextByKey("P_MA_RAW", "Raw"), valueIndex: 'Raw', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Calculated', caption: GetTextByKey("P_MA_CALCULATED", "Calculated"), valueIndex: 'Calculated', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Unit', caption: GetTextByKey("P_MA_UNIT", "Unit"), valueIndex: 'UOM', css: { 'width': 60, 'text-align': 'right' } }
|
||||
];
|
||||
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 = false;
|
||||
col.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_enginehourshisdt.canMultiSelect = false;
|
||||
grid_enginehourshisdt.columns = columns;
|
||||
grid_enginehourshisdt.init();
|
||||
|
||||
grid_enginehourshisdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_enginehourshisdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getEnineHours() {
|
||||
showLoading();
|
||||
grid_enginehoursdt.setData([]);
|
||||
|
||||
devicerequest("GetAssetCurrentEngineHours", contractorid + String.fromCharCode(170) + machineid, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
ShowEngineHours(data);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function getEngineHoursHis() {
|
||||
grid_enginehoursmostrecentdt.setData([]);
|
||||
grid_enginehourshisdt.setData([]);
|
||||
showLoading();
|
||||
var methodname = "GetCalampEngineHoursHistory";
|
||||
if (isPedigreeEH)
|
||||
methodname = "GetPedigreeEngineHoursHistory";
|
||||
if (isOEMDD2EH)
|
||||
methodname = "GetOEMDD2EngineHoursHistory";
|
||||
|
||||
devicerequest(methodname, contractorid + String.fromCharCode(170) + machineid, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
ShowEngineHoursHis(data);
|
||||
ShowMostRecentEngineHours(data);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function getEngineHoursHisPreview() {
|
||||
var item = {
|
||||
'CustomerID': contractorid,
|
||||
'AssetID': machineid,
|
||||
'EngineHours': $('#dialogenginehours_enginehours').val(),
|
||||
'EngineHoursDate': $('#dialogenginehours_date').val(),
|
||||
'Notes': $('#dialogenginehours_Notes').val()
|
||||
};
|
||||
|
||||
var alerttitle = GetTextByKey("P_MA_ADJUSTENGINEHOURS", 'Adjust Engine Hours');
|
||||
var enginehourstxt = GetTextByKey("P_MA_ENGINEHOURS", "Engine Hours");
|
||||
if (item.EngineHours !== "") {
|
||||
if (isNaN(item.EngineHours)) {
|
||||
showAlert(GetTextByKey("P_MA_FORMATERROR", '{0} format error.').replace('{0}', enginehourstxt), alerttitle);
|
||||
$('#adjustenginehoursmask').hide();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (item.EngineHours <= 0) {
|
||||
showAlert(GetTextByKey("P_MA_MUSTBEGREATERTHAN0", '{0} must be greater than 0.').replace('{0}', enginehourstxt), alerttitle);
|
||||
$('#adjustenginehoursmask').hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
showAlert(GetTextByKey("P_MA_NOTBEEMPTY", '{0} cannot be empty.').replace('{0}', enginehourstxt), alerttitle);
|
||||
$('#adjustenginehoursmask').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (item.EngineHoursDate === "") {
|
||||
showAlert(GetTextByKey("P_MA_NOTBEEMPTY", '{0} cannot be empty.').replace('{0}', enginehourstxt), alerttitle);
|
||||
$('#adjustenginehoursmask').hide();
|
||||
return;
|
||||
}
|
||||
var offset = $('#dialogadjust_enginehourstimezone').find("option:selected").attr("offset");
|
||||
item.OffsetMinute = offset;
|
||||
|
||||
var hour = $('#dialogenginehours_timehour').val();
|
||||
var minute = $('#dialogenginehours_timeminute').val();
|
||||
|
||||
item.EngineHoursDate = item.EngineHoursDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00";
|
||||
|
||||
CheckEngineHourMinimumTime(item, "preview");
|
||||
}
|
||||
|
||||
|
||||
function GetCalampEngineHoursHistoryPreview(item) {
|
||||
grid_enginehourshisdt.setData([]);
|
||||
showLoading();
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
|
||||
var methodname = "GetCalampEngineHoursHistoryPreview";
|
||||
if (isPedigreeEH)
|
||||
methodname = "GetPedigreeEngineHoursHistoryPreview";
|
||||
if (isOEMDD2EH)
|
||||
methodname = "GetOEMDD2EngineHoursHistoryPreview";
|
||||
devicerequest(methodname, param, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
ShowEngineHoursHis(data);
|
||||
ShowMostRecentEngineHoursPreview(data);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
var mostrecentrecord;
|
||||
function ShowMostRecentEngineHours(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
mostrecentrecord = data[i];
|
||||
var fr = { Values: mostrecentrecord };
|
||||
rows.push(fr);
|
||||
break;// Display the most recent reading
|
||||
}
|
||||
grid_enginehoursmostrecentdt.sortIndex = -1;
|
||||
grid_enginehoursmostrecentdt.sortDirection = -1;
|
||||
grid_enginehoursmostrecentdt.setData(rows);
|
||||
}
|
||||
|
||||
function ShowMostRecentEngineHoursPreview(data) {
|
||||
if (!mostrecentrecord) return;
|
||||
|
||||
var offsetVBUS = 0;
|
||||
var offsetGPS = 0;
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
offsetVBUS = r.VBUS - r.VBUS_Calc;
|
||||
offsetGPS = r.Gps - r.Gps_Calc;
|
||||
break;
|
||||
}
|
||||
|
||||
var rows = [];
|
||||
var r = $.extend(true, {}, mostrecentrecord);
|
||||
r.VBUS_Calc = r.VBUS - offsetVBUS;
|
||||
r.VBUS_Calc = r.VBUS_Calc.toFixed(2);
|
||||
r.Gps_Calc = r.Gps - offsetGPS;
|
||||
r.Gps_Calc = r.Gps_Calc.toFixed(2);
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
|
||||
grid_enginehoursmostrecentdt.sortIndex = -1;
|
||||
grid_enginehoursmostrecentdt.sortDirection = -1;
|
||||
grid_enginehoursmostrecentdt.setData(rows);
|
||||
}
|
||||
|
||||
|
||||
function ShowEngineHoursHis(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
r.VBUS = r.VBUS.toFixed(2);
|
||||
r.VBUS_Calc = r.VBUS_Calc.toFixed(2);
|
||||
r.Gps = r.Gps.toFixed(2);
|
||||
r.Gps_Calc = r.Gps_Calc.toFixed(2);
|
||||
for (var j in r) {
|
||||
if (j === "EventTimeText")
|
||||
r[j] = { DisplayValue: r["EventTimeText"], Value: r["AsofTime"] };
|
||||
if (j === "EventTimeLocalText")
|
||||
r[j] = { DisplayValue: r["EventTimeLocalText"], Value: r["AsofTimeLocal"] };
|
||||
}
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
grid_enginehourshisdt.sortIndex = -1;
|
||||
grid_enginehourshisdt.sortDirection = -1;
|
||||
grid_enginehourshisdt.setData(rows);
|
||||
}
|
||||
|
||||
|
||||
//************************Adjust Engine Hours**************************************//
|
||||
|
||||
function openAdjustEngineHours() {
|
||||
grid_enginehoursmostrecentdt.columns[0].visible = isCalampEH;
|
||||
grid_enginehoursmostrecentdt.columns[1].visible = isPedigreeEH;
|
||||
grid_enginehoursmostrecentdt.columns[2].visible = isOEMDD2EH;
|
||||
grid_enginehoursmostrecentdt.columns[5].caption = isCalampEH ? GetTextByKey("P_MA_VBUSRAW", "VBUS(Raw)") : GetTextByKey("P_MA_PEDIGREERAW", "Pedigree(Raw)");
|
||||
grid_enginehoursmostrecentdt.columns[6].caption = isCalampEH ? GetTextByKey("P_MA_VBUSCALC", "VBUS(Calc)") : GetTextByKey("P_MA_PEDIGREEADJUSTED", "Pedigree(Adjusted)");
|
||||
grid_enginehoursmostrecentdt.columns[5].visible = isCalampEH || isPedigreeEH;
|
||||
grid_enginehoursmostrecentdt.columns[6].visible = isCalampEH || isPedigreeEH;
|
||||
grid_enginehoursmostrecentdt.columns[7].visible = isCalampEH;
|
||||
grid_enginehoursmostrecentdt.columns[8].visible = isCalampEH;
|
||||
grid_enginehoursmostrecentdt.columns[9].visible = isOEMDD2EH;
|
||||
grid_enginehoursmostrecentdt.columns[10].visible = isOEMDD2EH;
|
||||
grid_enginehoursmostrecentdt.init();
|
||||
|
||||
grid_enginehourshisdt.columns[0].visible = isCalampEH;
|
||||
grid_enginehourshisdt.columns[1].visible = isPedigreeEH;
|
||||
grid_enginehourshisdt.columns[2].visible = isOEMDD2EH;
|
||||
grid_enginehourshisdt.columns[5].caption = isCalampEH ? GetTextByKey("P_MA_VBUSRAW", "VBUS(Raw)") : GetTextByKey("P_MA_PEDIGREERAW", "Pedigree(Raw)");
|
||||
grid_enginehourshisdt.columns[6].caption = isCalampEH ? GetTextByKey("P_MA_VBUSCALC", "VBUS(Calc)") : GetTextByKey("P_MA_PEDIGREEADJUSTED", "Pedigree(Adjusted)");
|
||||
grid_enginehourshisdt.columns[5].visible = isCalampEH || isPedigreeEH;
|
||||
grid_enginehourshisdt.columns[6].visible = isCalampEH || isPedigreeEH;
|
||||
grid_enginehourshisdt.columns[7].visible = isCalampEH;
|
||||
grid_enginehourshisdt.columns[8].visible = isCalampEH;
|
||||
grid_enginehourshisdt.columns[9].visible = isOEMDD2EH;
|
||||
grid_enginehourshisdt.columns[10].visible = isOEMDD2EH;
|
||||
grid_enginehourshisdt.init();
|
||||
|
||||
var datetime = customerdatetime.split(' ');
|
||||
var time = datetime[0];
|
||||
var st = datetime[1].split(':');
|
||||
var hours = st[0].length == 1 ? "0" + st[0] : st[0];
|
||||
var minutes = st[1];
|
||||
$('#dialogenginehours_enginehours').val('');
|
||||
$('#dialogadjust_enginehourstimezone').val(customertimezone ? customertimezone : "UTC");
|
||||
$('#dialogenginehours_date').val(time);
|
||||
$('#dialogenginehours_timehour').val(hours);
|
||||
$('#dialogenginehours_timeminute').val(minutes);
|
||||
$('#dialogenginehours_Notes').val('');
|
||||
$('#dialog_adjustenginehours .dialog-title span.title').text(GetTextByKey("P_MA_ADJUSTENGINEHOURS", 'Adjust Engine Hours'));
|
||||
showmaskbg(true);
|
||||
$('#dialog_adjustenginehours')
|
||||
.attr('act', 'add')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_adjustenginehours').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_adjustenginehours').width()) / 2
|
||||
})
|
||||
.showDialogfixed();
|
||||
$('#dialogenginehours_enginehours').focus();
|
||||
|
||||
getEngineHoursHis();
|
||||
}
|
||||
|
||||
|
||||
function OnAdjustEngineHours() {
|
||||
$('#adjustenginehoursmask').show();
|
||||
var alerttitle = GetTextByKey("P_MA_ADJUSTENGINEHOURS", 'Adjust Engine Hours');
|
||||
var enginehourstxt = GetTextByKey("P_MA_ENGINEHOURS", "Engine Hours");
|
||||
showConfirm('Do you want to adjust the engine hours?', alerttitle, function () {
|
||||
$('#adjustodomask').hide();
|
||||
var item = {
|
||||
'CustomerID': contractorid,
|
||||
'AssetID': machineid,
|
||||
'EngineHours': $('#dialogenginehours_enginehours').val(),
|
||||
'EngineHoursDate': $('#dialogenginehours_date').val(),
|
||||
'Notes': $('#dialogenginehours_Notes').val(),
|
||||
'DataSource': primarydatadourceEH
|
||||
};
|
||||
|
||||
if (item.EngineHours !== "") {
|
||||
if (isNaN(item.EngineHours)) {
|
||||
showAlert(GetTextByKey("P_MA_FORMATERROR", '{0} format error.').replace('{0}', enginehourstxt), alerttitle);
|
||||
$('#adjustenginehoursmask').hide();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (item.EngineHours <= 0) {
|
||||
showAlert(GetTextByKey("P_MA_MUSTBEGREATERTHAN0", '{0} must be greater than 0.').replace('{0}', enginehourstxt), alerttitle);
|
||||
$('#adjustenginehoursmask').hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
showAlert(GetTextByKey("P_MA_NOTBEEMPTY", '{0} cannot be empty.').replace('{0}', enginehourstxt), alerttitle);
|
||||
$('#adjustenginehoursmask').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.EngineHoursDate === "") {
|
||||
showAlert(GetTextByKey("P_MA_NOTBEEMPTY", '{0} cannot be empty.').replace('{0}', enginehourstxt), alerttitle);
|
||||
$('#adjustenginehoursmask').hide();
|
||||
return;
|
||||
}
|
||||
var offset = $('#dialogadjust_enginehourstimezone').find("option:selected").attr("offset");
|
||||
item.OffsetMinute = offset;
|
||||
|
||||
var hour = $('#dialogenginehours_timehour').val();
|
||||
var minute = $('#dialogenginehours_timeminute').val();
|
||||
|
||||
item.EngineHoursDate = item.EngineHoursDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00";
|
||||
|
||||
CheckEngineHourMinimumTime(item, "submit");
|
||||
}, function () {
|
||||
$('#adjustenginehoursmask').hide();
|
||||
});
|
||||
}
|
||||
|
||||
function CheckEngineHourMinimumTime(item, type) {
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
devicerequest("CheckEngineHourMinimumTime", param, function (data) {
|
||||
if (data > 0) {
|
||||
if (data == 1)
|
||||
showAlert(GetTextByKey("P_MA_CHECKENGINEHOURSMINNIMUMTIME", "The adjustment cannot be completed as provided. The engine hours reading date provided cannot be prior to initial telematic data available for the asset."), GetTextByKey("P_MA_ADJUSTENGINEHOURS", 'Adjust Engine Hours'));
|
||||
else
|
||||
showAlert(GetTextByKey("P_MA_CHECKENGINEHOURSMINNIMUMTIME1", "The adjustment cannot be completed as provided. The engine hours reading date provided must be prior to or equal to the latest telematic data available for the asset."), GetTextByKey("P_MA_ADJUSTENGINEHOURS", 'Adjust Engine Hours'));
|
||||
$('#adjustenginehoursmask').hide();
|
||||
return;
|
||||
} else {
|
||||
if (type === "submit")
|
||||
SaveAdjustEngineHours(item);
|
||||
else if (type === "preview")
|
||||
GetCalampEngineHoursHistoryPreview(item);
|
||||
}
|
||||
}, function (err) {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function SaveAdjustEngineHours(item) {
|
||||
showloading(true);
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
|
||||
var alerttitle = GetTextByKey("P_MA_ADJUSTENGINEHOURS", GetTextByKey("P_MA_ADJUSTENGINEHOURS", 'Adjust Engine Hours'));
|
||||
devicerequest("SaveAdjustEngineHours", param, function (data) {
|
||||
showloading(false);
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, alerttitle);
|
||||
} else {
|
||||
getEnineHours();
|
||||
getMachineInfo();
|
||||
showAlert(GetTextByKey("P_MA_SUCCESSFULLY", "{0} Successfully.").replace('{0}', alerttitle), alerttitle);
|
||||
}
|
||||
|
||||
$('#dialog_adjustenginehours').hideDialog();
|
||||
$('#adjustenginehoursmask').hide();
|
||||
}, function (err) {
|
||||
console.log(err);
|
||||
showloading(false);
|
||||
showAlert(GetTextByKey("P_MA_FAILEDTO", "Failed to {0}.").replace('{0}', alerttitle), alerttitle);
|
||||
$('#adjustenginehoursmask').hide();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function OnPreviewEngineHours() {
|
||||
getEngineHoursHisPreview();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//************************Add Engine Hours**************************************//
|
||||
|
||||
function openAddEnginHours() {
|
||||
var datetime = customerdatetime.split(' ');
|
||||
var time = datetime[0];
|
||||
var st = datetime[1].split(':');
|
||||
var hours = st[0].length == 1 ? "0" + st[0] : st[0];
|
||||
var minutes = st[1];
|
||||
$('#dialogaddgenginehours_enginehours').val('');
|
||||
$('#dialogadd_enginehourstimezone').val(customertimezone ? customertimezone : "UTC");
|
||||
$('#dialogaddenginehours_date').val(time);
|
||||
$('#dialogaddenginehours_timehour').val(hours);
|
||||
$('#dialogaddenginehours_timeminute').val(minutes);
|
||||
$('#dialogaddenginehours_Notes').val('');
|
||||
$('#dialog_addenginehours .dialog-title span.title').text(GetTextByKey("P_MA_ADDENGINEHOURS", 'Add Engine Hours'));
|
||||
showmaskbg(true);
|
||||
$('#dialog_addenginehours')
|
||||
.attr('act', 'add')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_addenginehours').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_addenginehours').width()) / 2
|
||||
})
|
||||
.showDialogfixed();
|
||||
$('#dialogaddgenginehours_enginehours').focus();
|
||||
}
|
||||
|
||||
|
||||
function OnAddEngineHours() {
|
||||
$('#addenginehoursmask').show();
|
||||
var alerttitle = GetTextByKey("P_MA_ADDENGINEHOURS", 'Add Engine Hours');
|
||||
var enginehourstxt = GetTextByKey("P_MA_ENGINEHOURS", "Engine Hours");
|
||||
showConfirm(GetTextByKey("P_MA_DOYOUWANTTOADDTHEENGINEHOURS", 'Do you want to add the engine hours?'), alerttitle, function () {
|
||||
$('#adjustodomask').hide();
|
||||
var item = {
|
||||
'CustomerID': contractorid,
|
||||
'AssetID': machineid,
|
||||
'EngineHours': $('#dialogaddgenginehours_enginehours').val(),
|
||||
'EngineHoursDate': $('#dialogaddenginehours_date').val(),
|
||||
'Notes': $('#dialogaddenginehours_Notes').val()
|
||||
};
|
||||
|
||||
if (item.EngineHours !== "") {
|
||||
if (isNaN(item.EngineHours)) {
|
||||
showAlert(GetTextByKey("P_MA_FORMATERROR", '{0} format error.').replace('{0}', enginehourstxt), alerttitle);
|
||||
$('#addenginehoursmask').hide();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (item.EngineHours <= 0) {
|
||||
showAlert(GetTextByKey("P_MA_MUSTBEGREATERTHAN0", '{0} must be greater than 0.').replace('{0}', enginehourstxt), alerttitle);
|
||||
$('#addenginehoursmask').hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
showAlert(GetTextByKey("P_MA_NOTBEEMPTY", '{0} cannot be empty.').replace('{0}', enginehourstxt), alerttitle);
|
||||
$('#addenginehoursmask').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.EngineHoursDate === "") {
|
||||
showAlert(GetTextByKey("P_MA_NOTBEEMPTY", '{0} cannot be empty.').replace('{0}', enginehourstxt), alerttitle);
|
||||
$('#addenginehoursmask').hide();
|
||||
return;
|
||||
}
|
||||
var offset = $('#dialogadd_enginehourstimezone').find("option:selected").attr("offset");
|
||||
item.OffsetMinute = offset;
|
||||
|
||||
var hour = $('#dialogaddenginehours_timehour').val();
|
||||
var minute = $('#dialogaddenginehours_timeminute').val();
|
||||
|
||||
item.EngineHoursDate = item.EngineHoursDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00";
|
||||
|
||||
showloading(true);
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
|
||||
devicerequest("AddManuallyInputEngineHours", param, function (data) {
|
||||
showloading(false);
|
||||
if (data !== 'OK') {
|
||||
if (data === "Failed")
|
||||
data = GetTextByKey("P_MA_FAILED", "Failed");
|
||||
showAlert(data, alerttitle);
|
||||
} else {
|
||||
getEnineHours();
|
||||
getMachineInfo();
|
||||
showAlert(GetTextByKey("P_MA_SUCCESSFULLY", "{0} Successfully.").replace('{0}', GetTextByKey("P_MA_ADDENGINEHOURS", "Add Engine Hours")), alerttitle);
|
||||
}
|
||||
|
||||
$('#dialog_addenginehours').hideDialog();
|
||||
$('#addenginehoursmask').hide();
|
||||
}, function (err) {
|
||||
console.log(err);
|
||||
showloading(false);
|
||||
showAlert(GetTextByKey("P_MA_FAILEDTO", "Failed to {0}.").replace('{0}', GetTextByKey("P_MA_ADDENGINEHOURS", "Add Engine Hours")), alerttitle);
|
||||
$('#addenginehoursmask').hide();
|
||||
});
|
||||
|
||||
}, function () {
|
||||
$('#addenginehoursmask').hide();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/********************Adjustment History****************************************/
|
||||
|
||||
function openEngineHoursAdjustHistory() {
|
||||
window.open("EngineHoursAdjustHistory.aspx?cid=" + contractorid + "&mid=" + machineid);
|
||||
}
|
359
Site/MachineDeviceManagement/js/adj_fuelremaining.js
Normal file
@ -0,0 +1,359 @@
|
||||
$(function () {
|
||||
InitFuelRemainingGridData();
|
||||
});
|
||||
|
||||
var grid_fuelremainingdt;
|
||||
var grid_fuelremaininghisdt;
|
||||
|
||||
function ShowFuelRemainings(data) {
|
||||
var rows = [];
|
||||
var hasCalamp = false;
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
for (var j in r) {
|
||||
if (j === "IsPrimary")
|
||||
r[j] = r[j] === true ? "Yes" : "";
|
||||
else if (j === "Amount")
|
||||
r[j] = { DisplayValue: r["PercentText"], Value: r["Amount"] };
|
||||
}
|
||||
//r.Amount = r.Amount.toFixed(2);
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
|
||||
//if (r.DataSource.toLowerCase() == "calamp")
|
||||
// hasCalamp = true;
|
||||
}
|
||||
grid_fuelremainingdt.sortIndex = -1;
|
||||
grid_fuelremainingdt.sortDirection = -1;
|
||||
grid_fuelremainingdt.setData(rows);
|
||||
|
||||
$("#fuelremaininglist").css("height", autoheight(grid_fuelremainingdt));
|
||||
grid_fuelremainingdt && grid_fuelremainingdt.resize();
|
||||
|
||||
if (IsSupperAdmin && hasCalamp) {
|
||||
$('#btnfuelremainingadjust').css("display", '');
|
||||
}
|
||||
else
|
||||
$('#btnfuelremainingadjust').css("display", 'none');
|
||||
}
|
||||
|
||||
function InitFuelRemainingGridData() {
|
||||
grid_fuelremainingdt = new GridView('#fuelremaininglist');
|
||||
grid_fuelremainingdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'IsPrimary', caption: GetTextByKey("P_MA_ISPRIMARY", "Is Primary"), valueIndex: 'IsPrimary', css: { 'width': 80, 'text-align': 'left' } },
|
||||
{ name: 'DataSourceName', caption: GetTextByKey("P_MA_DATASOURCE", "Data Source"), valueIndex: 'DataSourceName', css: { 'width': 120, 'text-align': 'left' } },
|
||||
{ name: 'Amount', caption: GetTextByKey("P_MA_FUELREMAINING", "Fuel Remaining"), valueIndex: 'Amount', css: { 'width': 100, 'text-align': 'left' } },
|
||||
//{ name: 'Units', caption: GetTextByKey("P_MA_UNITS", "Units"), valueIndex: 'UOM', css: { 'width': 80, 'text-align': 'left' } },
|
||||
{ name: 'ReceivedDate', caption: GetTextByKey("P_MA_RECEIVEDDATE", "Received Date"), valueIndex: 'ReceivedDateStr', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'SetPrmary', caption: "", css: { 'width': 100, 'text-align': 'left' } }
|
||||
];
|
||||
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;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
if (col.name === "SetPrmary") {
|
||||
col.isurl = true;
|
||||
col.text = GetTextByKey("P_MA_SETASPRIMARY", 'Set As Primary');
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
openSetPrimary(5, this);
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
};
|
||||
col.styleFilter = function (e) {
|
||||
return {
|
||||
display: e.IsPrimary === "Yes" ? 'none' : ''
|
||||
};
|
||||
};
|
||||
col.attrs = { 'title': GetTextByKey("P_MA_SETASPRIMARY", 'Set As Primary') };
|
||||
col.visible = IsSupperAdmin;
|
||||
col.resizable = false;
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_fuelremainingdt.canMultiSelect = false;
|
||||
grid_fuelremainingdt.columns = columns;
|
||||
grid_fuelremainingdt.init();
|
||||
|
||||
grid_fuelremainingdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_fuelremainingdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function InitFuelRemainingHisGridData() {
|
||||
grid_fuelremaininghisdt = new GridView('#fuelremaininghislist');
|
||||
grid_fuelremaininghisdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'DeviceAirId', caption: GetTextByKey("P_MA_DEVICEAIRID", "Device Air ID"), valueIndex: 'DeviceAirId', css: { 'width': 140, 'text-align': 'left' } },
|
||||
{ name: 'AsofTime', caption: GetTextByKey("P_MA_EVENTDATEUTC", "Event Date(UTC)"), valueIndex: 'EventTimeText', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'AsofTime_local', caption: GetTextByKey("P_MA_EVENTDATE", "Event Date"), valueIndex: 'EventTimeLocalText', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'VBUS', caption: GetTextByKey("P_MA_VBUSRAW", "VBUS(Raw)"), valueIndex: 'VBUS', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'VBUS_Calc', caption: GetTextByKey("P_MA_VBUSCALC", "VBUS(Calc)"), valueIndex: 'VBUS_Calc', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Gps', caption: GetTextByKey("P_MA_GPSRAW", "GPS(Raw)"), valueIndex: 'Gps', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Gps_Calc', caption: GetTextByKey("P_MA_GPSCALC", "GPS(Calc)"), valueIndex: 'Gps_Calc', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Unit', caption: GetTextByKey("P_MA_UNIT", "Unit"), valueIndex: 'UOM', css: { 'width': 60, 'text-align': 'right' } }
|
||||
];
|
||||
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;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_fuelremaininghisdt.canMultiSelect = false;
|
||||
grid_fuelremaininghisdt.columns = columns;
|
||||
grid_fuelremaininghisdt.init();
|
||||
|
||||
grid_fuelremaininghisdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_fuelremaininghisdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getFuelRemainings() {
|
||||
grid_fuelremainingdt.setData([]);
|
||||
showLoading();
|
||||
|
||||
devicerequest("GetAssetCurrentFuelRemaining", contractorid + String.fromCharCode(170) + machineid, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
ShowFuelRemainings(data);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function getFuelRemainingHis() {
|
||||
grid_fuelremaininghisdt.setData([]);
|
||||
showLoading();
|
||||
|
||||
devicerequest("GetCalampFuelRemainingHistory", contractorid + String.fromCharCode(170) + machineid, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
ShowFuelRemainingHis(data);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function getFuelRemainingHisPreview() {
|
||||
var item = {
|
||||
'CustomerID': contractorid,
|
||||
'AssetID': machineid,
|
||||
'FuelRemaining': $('#dialogadjust_fuelremaining').val(),
|
||||
'UOM': $('#dialogadjust_sel_fuelremaininguom').val(),
|
||||
'FuelRemainingDate': $('#dialogadjust_fuelremainingdate').val(),
|
||||
'Notes': $('#dialogadjust_notes').val()
|
||||
};
|
||||
|
||||
var alerttitle = GetTextByKey("P_MA_ADJUSTFUELREMAINING", "Adjust FuelRemaining");
|
||||
if (item.FuelRemaining !== "") {
|
||||
if (isNaN(item.FuelRemaining)) {
|
||||
showAlert(GetTextByKey("P_MA_FUELREMAININGFORMATERROR", 'FuelRemaining format error.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (item.FuelRemaining <= 0) {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETERMUSTBEGREATERTHAN0", 'ODOMeter must be greater than 0.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
showAlert(GetTextByKey("P_MA_FUELREMAININGCANNOTBEEMPTY", "FuelRemaining cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
grid_fuelremaininghisdt.setData([]);
|
||||
showLoading();
|
||||
|
||||
if (item.FuelRemainingDate === "") {
|
||||
showAlert(GetTextByKey("P_MA_FUELREMAININGDATACANNOTBEEMPTY", "FuelRemaining date cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
hideLoading();
|
||||
return;
|
||||
}
|
||||
var offset = $('#dialogadjust_fuelremainingtimezone').find("option:selected").attr("offset");
|
||||
item.OffsetMinute = offset;
|
||||
|
||||
var hour = $('#dialogadjust_timehour').val();
|
||||
var minute = $('#dialogadjust_timeminute').val();
|
||||
|
||||
item.FuelRemainingDate = item.FuelRemainingDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00";
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
|
||||
devicerequest("GetCalampFuelRemainingHistoryPreview", param, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
ShowFuelRemainingHis(data);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function ShowFuelRemainingHis(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
for (var j in r) {
|
||||
if (j === "EventTimeText")
|
||||
r[j] = { DisplayValue: r["EventTimeText"], Value: r["AsofTime"] };
|
||||
if (j === "EventTimeLocalText")
|
||||
r[j] = { DisplayValue: r["EventTimeLocalText"], Value: r["AsofTime_Local"] };
|
||||
}
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
grid_fuelremaininghisdt.sortIndex = -1;
|
||||
grid_fuelremaininghisdt.sortDirection = -1;
|
||||
grid_fuelremaininghisdt.setData(rows);
|
||||
}
|
||||
|
||||
|
||||
//************************Adjust FuelRemaining**************************************//
|
||||
|
||||
function openAdjustFuelRemaining() {
|
||||
$('#dialogadjust_fuelremaining').val('');
|
||||
$('#dialogadjust_sel_fuelremaininguom').val('Mile');
|
||||
$('#dialogadjust_fuelremainingtimezone').val("UTC");
|
||||
$('#dialogadjust_fuelremainingdate').val(currentdate);
|
||||
$('#dialogadjust_timehour').val('00');
|
||||
$('#dialogadjust_timeminute').val('00');
|
||||
$('#dialogadjust_notes').val('');
|
||||
$('#dialog_adjustfuelremaining .dialog-title span.title').text(GetTextByKey("P_MA_ADJUSTFUELREMAINING", "Adjust FuelRemaining"));
|
||||
showmaskbg(true);
|
||||
$('#dialog_adjustfuelremaining')
|
||||
.attr('act', 'add')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_adjustfuelremaining').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_adjustfuelremaining').width()) / 2
|
||||
})
|
||||
.showDialog();
|
||||
$('#dialogadjust_fuelremaining').focus();
|
||||
|
||||
getFuelRemainingHis();
|
||||
}
|
||||
|
||||
function OnAdjustFuelRemaining() {
|
||||
$('#adjustodomask').show();
|
||||
var alerttitle = GetTextByKey("P_MA_ADJUSTFUELREMAINING", "Adjust FuelRemaining");
|
||||
showConfirm(GetTextByKey("P_MA_DOYOUWANTTOADJUSTTHEFUELREMAINING", 'Do you want to adjust the fuelremaining?'), alerttitle, function () {
|
||||
var item = {
|
||||
'CustomerID': contractorid,
|
||||
'AssetID': machineid,
|
||||
'FuelRemaining': $('#dialogadjust_fuelremaining').val(),
|
||||
'UOM': $('#dialogadjust_sel_fuelremaininguom').val(),
|
||||
'FuelRemainingDate': $('#dialogadjust_fuelremainingdate').val(),
|
||||
'Notes': $('#dialogadjust_notes').val()
|
||||
};
|
||||
|
||||
if (item.FuelRemaining !== "") {
|
||||
if (isNaN(item.FuelRemaining)) {
|
||||
showAlert(GetTextByKey("P_MA_FUELREMAININGFORMATERROR", 'FuelRemaining format error.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (item.FuelRemaining <= 0) {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETERMUSTBEGREATERTHAN0", 'ODOMeter must be greater than 0.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
showAlert(GetTextByKey("P_MA_FUELREMAININGCANNOTBEEMPTY", "FuelRemaining cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.FuelRemainingDate === "") {
|
||||
showAlert(GetTextByKey("P_MA_FUELREMAININGDATACANNOTBEEMPTY", "FuelRemaining cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
var offset = $('#dialogadjust_fuelremainingtimezone').find("option:selected").attr("offset");
|
||||
item.OffsetMinute = offset;
|
||||
|
||||
var hour = $('#dialogadjust_timehour').val();
|
||||
var minute = $('#dialogadjust_timeminute').val();
|
||||
|
||||
item.FuelRemainingDate = item.FuelRemainingDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00";
|
||||
|
||||
showloading(true);
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
|
||||
devicerequest("SaveAdjustFuelRemaining", param, function (data) {
|
||||
showloading(false);
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, alerttitle);
|
||||
} else {
|
||||
getFuelRemainings();
|
||||
showAlert(GetTextByKey("P_MA_ADJUSTFUELREMAININGSUCCESSFULLY", "Adjust FuelRemaining Successfully."), alerttitle);
|
||||
}
|
||||
|
||||
$('#dialog_adjustfuelremaining').hideDialog();
|
||||
$('#adjustodomask').hide();
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
showAlert(GetTextByKey("P_MA_FAILEDTOADJUSTFUELREMAINING", 'Failed to adjust FuelRemaining.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
});
|
||||
}, function () {
|
||||
$('#adjustodomask').hide();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
function OnPreviewFuelRemaining() {
|
||||
getFuelRemainingHisPreview();
|
||||
}
|
358
Site/MachineDeviceManagement/js/adj_fuelused.js
Normal file
@ -0,0 +1,358 @@
|
||||
$(function () {
|
||||
InitFuelusedGridData();
|
||||
//InitFuelusedHisGridData();
|
||||
});
|
||||
|
||||
var grid_fueluseddt;
|
||||
var grid_fuelusedhisdt;
|
||||
|
||||
function ShowFueluseds(data) {
|
||||
var rows = [];
|
||||
var hasCalamp = false;
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
for (var j in r) {
|
||||
if (j === "IsPrimary")
|
||||
r[j] = r[j] === true ? "Yes" : "";
|
||||
}
|
||||
r.Amount = r.Amount.toFixed(2);
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
|
||||
//if (r.DataSource.toLowerCase() == "calamp")
|
||||
// hasCalamp = true;
|
||||
}
|
||||
grid_fueluseddt.sortIndex = -1;
|
||||
grid_fueluseddt.sortDirection = -1;
|
||||
grid_fueluseddt.setData(rows);
|
||||
|
||||
$("#fuelusedlist").css("height", autoheight(grid_fueluseddt));
|
||||
grid_fueluseddt && grid_fueluseddt.resize();
|
||||
|
||||
if (IsSupperAdmin && hasCalamp) {
|
||||
$('#btnfuelusedadjust').css("display", '');
|
||||
}
|
||||
else
|
||||
$('#btnfuelusedadjust').css("display", 'none');
|
||||
}
|
||||
|
||||
function InitFuelusedGridData() {
|
||||
grid_fueluseddt = new GridView('#fuelusedlist');
|
||||
grid_fueluseddt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'IsPrimary', caption: GetTextByKey("P_MA_ISPRIMARY", "Is Primary"), valueIndex: 'IsPrimary', css: { 'width': 80, 'text-align': 'left' } },
|
||||
{ name: 'DataSourceName', caption: GetTextByKey("P_MA_DATASOURCE", "Data Source"), valueIndex: 'DataSourceName', css: { 'width': 120, 'text-align': 'left' } },
|
||||
{ name: 'Amount', caption: GetTextByKey("P_MA_FUELUSED", "Fuel Used"), valueIndex: 'Amount', css: { 'width': 100, 'text-align': 'left' } },
|
||||
{ name: 'Units', caption: GetTextByKey("P_MA_UNITS", "Units"), valueIndex: 'UOM', css: { 'width': 80, 'text-align': 'left' } },
|
||||
{ name: 'ReceivedDate', caption: GetTextByKey("P_MA_RECEIVEDDATE", "Received Date"), valueIndex: 'ReceivedDateStr', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'SetPrmary', caption: "", css: { 'width': 100, 'text-align': 'left' } }
|
||||
];
|
||||
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;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
if (col.name === "SetPrmary") {
|
||||
col.isurl = true;
|
||||
col.text = GetTextByKey("P_MA_SETASPRIMARY", 'Set As Primary');
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
openSetPrimary(4, this);
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
};
|
||||
col.styleFilter = function (e) {
|
||||
return {
|
||||
display: e.IsPrimary === "Yes" ? 'none' : ''
|
||||
};
|
||||
};
|
||||
col.attrs = { 'title': GetTextByKey("P_MA_SETASPRIMARY", 'Set As Primary') };
|
||||
col.visible = IsSupperAdmin;
|
||||
col.resizable = false;
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_fueluseddt.canMultiSelect = false;
|
||||
grid_fueluseddt.columns = columns;
|
||||
grid_fueluseddt.init();
|
||||
|
||||
grid_fueluseddt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_fueluseddt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function InitFuelusedHisGridData() {
|
||||
grid_fuelusedhisdt = new GridView('#fuelusedhislist');
|
||||
grid_fuelusedhisdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'DeviceAirId', caption: GetTextByKey("P_MA_DEVICEAIRID", "Device Air ID"), valueIndex: 'DeviceAirId', css: { 'width': 140, 'text-align': 'left' } },
|
||||
{ name: 'AsofTime', caption: GetTextByKey("P_MA_EVENTDATEUTC", "Event Date(UTC)"), valueIndex: 'EventTimeText', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'AsofTime_local', caption: GetTextByKey("P_MA_EVENTDATE", "Event Date"), valueIndex: 'EventTimeLocalText', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'VBUS', caption: GetTextByKey("P_MA_VBUSRAW", "VBUS(Raw)"), valueIndex: 'VBUS', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'VBUS_Calc', caption: GetTextByKey("P_MA_VBUSCALC", "VBUS(Calc)"), valueIndex: 'VBUS_Calc', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Gps', caption: GetTextByKey("P_MA_GPSRAW", "GPS(Raw)"), valueIndex: 'Gps', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Gps_Calc', caption: GetTextByKey("P_MA_GPSCALC", "GPS(Calc)"), valueIndex: 'Gps_Calc', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Unit', caption: GetTextByKey("P_MA_UNIT", "Unit"), valueIndex: 'UOM', css: { 'width': 60, 'text-align': 'right' } }
|
||||
];
|
||||
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;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_fuelusedhisdt.canMultiSelect = false;
|
||||
grid_fuelusedhisdt.columns = columns;
|
||||
grid_fuelusedhisdt.init();
|
||||
|
||||
grid_fuelusedhisdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_fuelusedhisdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getFueluseds() {
|
||||
grid_fueluseddt.setData([]);
|
||||
showLoading();
|
||||
|
||||
devicerequest("GetAssetCurrentFuelused", contractorid + String.fromCharCode(170) + machineid, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
ShowFueluseds(data);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function getFuelusedHis() {
|
||||
grid_fuelusedhisdt.setData([]);
|
||||
showLoading();
|
||||
|
||||
devicerequest("GetCalampFuelusedHistory", contractorid + String.fromCharCode(170) + machineid, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
ShowFuelusedHis(data);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function getFuelusedHisPreview() {
|
||||
var item = {
|
||||
'CustomerID': contractorid,
|
||||
'AssetID': machineid,
|
||||
'Fuelused': $('#dialogadjust_fuelused').val(),
|
||||
'UOM': $('#dialogadjust_sel_fueluseduom').val(),
|
||||
'FuelusedDate': $('#dialogadjust_fueluseddate').val(),
|
||||
'Notes': $('#dialogadjust_notes').val()
|
||||
};
|
||||
|
||||
var alerttitle = GetTextByKey("P_MA_ADJUSTFUELUSED", "Adjust Fuelused");
|
||||
if (item.Fuelused !== "") {
|
||||
if (isNaN(item.Fuelused)) {
|
||||
showAlert(GetTextByKey("P_MA_FUELUSEDFORMATERROR", 'Fuelused format error.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (item.Fuelused <= 0) {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETERMUSTBEGREATERTHAN0", 'ODOMeter must be greater than 0.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
showAlert(GetTextByKey("P_MA_FUELUSEDCANNOTBEEMPTY", "Fuelused cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
grid_fuelusedhisdt.setData([]);
|
||||
showLoading();
|
||||
|
||||
if (item.FuelusedDate === "") {
|
||||
showAlert(GetTextByKey("P_MA_FUELUSEDDATACANNOTBEEMPTY", "Fuelused date cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
hideLoading();
|
||||
return;
|
||||
}
|
||||
var offset = $('#dialogadjust_fuelusedtimezone').find("option:selected").attr("offset");
|
||||
item.OffsetMinute = offset;
|
||||
|
||||
var hour = $('#dialogadjust_timehour').val();
|
||||
var minute = $('#dialogadjust_timeminute').val();
|
||||
|
||||
item.FuelusedDate = item.FuelusedDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00";
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
|
||||
devicerequest("GetCalampFuelusedHistoryPreview", param, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
ShowFuelusedHis(data);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function ShowFuelusedHis(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
for (var j in r) {
|
||||
if (j === "EventTimeText")
|
||||
r[j] = { DisplayValue: r["EventTimeText"], Value: r["AsofTime"] };
|
||||
if (j === "EventTimeLocalText")
|
||||
r[j] = { DisplayValue: r["EventTimeLocalText"], Value: r["AsofTime_Local"] };
|
||||
}
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
grid_fuelusedhisdt.sortIndex = -1;
|
||||
grid_fuelusedhisdt.sortDirection = -1;
|
||||
grid_fuelusedhisdt.setData(rows);
|
||||
}
|
||||
|
||||
|
||||
//************************Adjust Fuelused**************************************//
|
||||
|
||||
function openAdjustFuelused() {
|
||||
$('#dialogadjust_fuelused').val('');
|
||||
$('#dialogadjust_sel_fueluseduom').val('Mile');
|
||||
$('#dialogadjust_fuelusedtimezone').val("UTC");
|
||||
$('#dialogadjust_fueluseddate').val(currentdate);
|
||||
$('#dialogadjust_timehour').val('00');
|
||||
$('#dialogadjust_timeminute').val('00');
|
||||
$('#dialogadjust_notes').val('');
|
||||
$('#dialog_adjustfuelused .dialog-title span.title').text(GetTextByKey("P_MA_ADJUSTFUELUSED", "Adjust Fuelused"));
|
||||
showmaskbg(true);
|
||||
$('#dialog_adjustfuelused')
|
||||
.attr('act', 'add')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_adjustfuelused').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_adjustfuelused').width()) / 2
|
||||
})
|
||||
.showDialog();
|
||||
$('#dialogadjust_fuelused').focus();
|
||||
|
||||
getFuelusedHis();
|
||||
}
|
||||
|
||||
function OnAdjustFuelused() {
|
||||
$('#adjustodomask').show();
|
||||
var alerttitle = GetTextByKey("P_MA_ADJUSTFUELUSED", "Adjust Fuelused");
|
||||
showConfirm(GetTextByKey("P_MA_DOYOUWANTTOADJUSTTHEFUELUSED", 'Do you want to adjust the fuelused?'), alerttitle, function () {
|
||||
var item = {
|
||||
'CustomerID': contractorid,
|
||||
'AssetID': machineid,
|
||||
'Fuelused': $('#dialogadjust_fuelused').val(),
|
||||
'UOM': $('#dialogadjust_sel_fueluseduom').val(),
|
||||
'FuelusedDate': $('#dialogadjust_fueluseddate').val(),
|
||||
'Notes': $('#dialogadjust_notes').val()
|
||||
};
|
||||
|
||||
if (item.Fuelused !== "") {
|
||||
if (isNaN(item.Fuelused)) {
|
||||
showAlert(GetTextByKey("P_MA_FUELUSEDFORMATERROR", 'Fuelused format error.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (item.Fuelused <= 0) {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETERMUSTBEGREATERTHAN0", 'ODOMeter must be greater than 0.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
showAlert(GetTextByKey("P_MA_FUELUSEDCANNOTBEEMPTY", "Fuelused cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.FuelusedDate === "") {
|
||||
showAlert(GetTextByKey("P_MA_FUELUSEDDATACANNOTBEEMPTY", "Fuelused cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
var offset = $('#dialogadjust_fuelusedtimezone').find("option:selected").attr("offset");
|
||||
item.OffsetMinute = offset;
|
||||
|
||||
var hour = $('#dialogadjust_timehour').val();
|
||||
var minute = $('#dialogadjust_timeminute').val();
|
||||
|
||||
item.FuelusedDate = item.FuelusedDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00";
|
||||
|
||||
showloading(true);
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
|
||||
devicerequest("SaveAdjustFuelused", param, function (data) {
|
||||
showloading(false);
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, alerttitle);
|
||||
} else {
|
||||
getFueluseds();
|
||||
showAlert(GetTextByKey("P_MA_ADJUSTFUELUSEDSUCCESSFULLY", "Adjust Fuelused Successfully."), alerttitle);
|
||||
}
|
||||
|
||||
$('#dialog_adjustfuelused').hideDialog();
|
||||
$('#adjustodomask').hide();
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
showAlert(GetTextByKey("P_MA_FAILEDTOADJUSTFUELUSED", 'Failed to adjust Fuelused.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
});
|
||||
}, function () {
|
||||
$('#adjustodomask').hide();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
function OnPreviewFuelused() {
|
||||
getFuelusedHisPreview();
|
||||
}
|
359
Site/MachineDeviceManagement/js/adj_idlehours.js
Normal file
@ -0,0 +1,359 @@
|
||||
$(function () {
|
||||
InitIdlehourGridData();
|
||||
//InitIdlehourHisGridData();
|
||||
});
|
||||
|
||||
var grid_idlehourdt;
|
||||
var grid_idlehourhisdt;
|
||||
|
||||
function ShowIdlehours(data) {
|
||||
var rows = [];
|
||||
var hasCalamp = false;
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
for (var j in r) {
|
||||
if (j === "IsPrimary")
|
||||
r[j] = r[j] === true ? "Yes" : "";
|
||||
else if (j === "UOM")
|
||||
r[j] = "Hour";
|
||||
}
|
||||
r.Hours = r.Hours.toFixed(2);
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
|
||||
//if (r.DataSource.toLowerCase() == "calamp")
|
||||
// hasCalamp = true;
|
||||
}
|
||||
grid_idlehourdt.sortIndex = -1;
|
||||
grid_idlehourdt.sortDirection = -1;
|
||||
grid_idlehourdt.setData(rows);
|
||||
|
||||
$("#idlehourlist").css("height", autoheight(grid_idlehourdt));
|
||||
grid_idlehourdt && grid_idlehourdt.resize();
|
||||
|
||||
if (IsSupperAdmin && hasCalamp) {
|
||||
$('#btnidlehouradjust').css("display", '');
|
||||
}
|
||||
else
|
||||
$('#btnidlehouradjust').css("display", 'none');
|
||||
}
|
||||
|
||||
function InitIdlehourGridData() {
|
||||
grid_idlehourdt = new GridView('#idlehourlist');
|
||||
grid_idlehourdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'IsPrimary', caption: GetTextByKey("P_MA_ISPRIMARY", "Is Primary"), valueIndex: 'IsPrimary', css: { 'width': 80, 'text-align': 'left' } },
|
||||
{ name: 'DataSourceName', caption: GetTextByKey("P_MA_DATASOURCE", "Data Source"), valueIndex: 'DataSourceName', css: { 'width': 120, 'text-align': 'left' } },
|
||||
{ name: 'Hours', caption: GetTextByKey("P_MA_IDLEHOURS", "Idle Hours"), valueIndex: 'Hours', css: { 'width': 80, 'text-align': 'left' } },
|
||||
{ name: 'Units', caption: GetTextByKey("P_MA_UNITS", "Units"), valueIndex: 'UOM', css: { 'width': 80, 'text-align': 'left' } },
|
||||
{ name: 'ReceivedDate', caption: GetTextByKey("P_MA_RECEIVEDDATE", "Received Date"), valueIndex: 'ReceivedDateStr', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'SetPrmary', caption: "", css: { 'width': 100, 'text-align': 'left' } }
|
||||
];
|
||||
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;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
if (col.name === "SetPrmary") {
|
||||
col.isurl = true;
|
||||
col.text = GetTextByKey("P_MA_SETASPRIMARY", 'Set As Primary');
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
openSetPrimary(3, this);
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
};
|
||||
col.styleFilter = function (e) {
|
||||
return {
|
||||
display: e.IsPrimary === "Yes" ? 'none' : ''
|
||||
};
|
||||
};
|
||||
col.attrs = { 'title': GetTextByKey("P_MA_SETASPRIMARY", 'Set As Primary') };
|
||||
col.visible = IsSupperAdmin;
|
||||
col.resizable = false;
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_idlehourdt.canMultiSelect = false;
|
||||
grid_idlehourdt.columns = columns;
|
||||
grid_idlehourdt.init();
|
||||
|
||||
grid_idlehourdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_idlehourdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function InitIdlehourHisGridData() {
|
||||
grid_idlehourhisdt = new GridView('#idlehourhislist');
|
||||
grid_idlehourhisdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'DeviceAirId', caption: GetTextByKey("P_MA_DEVICEAIRID", "Device Air ID"), valueIndex: 'DeviceAirId', css: { 'width': 140, 'text-align': 'left' } },
|
||||
{ name: 'AsofTime', caption: GetTextByKey("P_MA_EVENTDATEUTC", "Event Date(UTC)"), valueIndex: 'EventTimeText', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'AsofTime_local', caption: GetTextByKey("P_MA_EVENTDATE", "Event Date"), valueIndex: 'EventTimeLocalText', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'VBUS', caption: GetTextByKey("P_MA_VBUSRAW", "VBUS(Raw)"), valueIndex: 'VBUS', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'VBUS_Calc', caption: GetTextByKey("P_MA_VBUSCALC", "VBUS(Calc)"), valueIndex: 'VBUS_Calc', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Gps', caption: GetTextByKey("P_MA_GPSRAW", "GPS(Raw)"), valueIndex: 'Gps', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Gps_Calc', caption: GetTextByKey("P_MA_GPSCALC", "GPS(Calc)"), valueIndex: 'Gps_Calc', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Unit', caption: GetTextByKey("P_MA_UNIT", "Unit"), valueIndex: 'UOM', css: { 'width': 60, 'text-align': 'right' } }
|
||||
];
|
||||
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;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_idlehourhisdt.canMultiSelect = false;
|
||||
grid_idlehourhisdt.columns = columns;
|
||||
grid_idlehourhisdt.init();
|
||||
|
||||
grid_idlehourhisdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_idlehourhisdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getIdlehours() {
|
||||
grid_idlehourdt.setData([]);
|
||||
showLoading();
|
||||
|
||||
devicerequest("GetAssetCurrentIdlehours", contractorid + String.fromCharCode(170) + machineid, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
ShowIdlehours(data);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function getIdlehourHis() {
|
||||
grid_idlehourhisdt.setData([]);
|
||||
showLoading();
|
||||
|
||||
devicerequest("GetCalampIdlehourHistory", contractorid + String.fromCharCode(170) + machineid, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
ShowIdlehourHis(data);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function getIdlehourHisPreview() {
|
||||
var item = {
|
||||
'CustomerID': contractorid,
|
||||
'AssetID': machineid,
|
||||
'Idlehour': $('#dialogadjust_idlehour').val(),
|
||||
'UOM': $('#dialogadjust_sel_idlehouruom').val(),
|
||||
'IdlehourDate': $('#dialogadjust_idlehourdate').val(),
|
||||
'Notes': $('#dialogadjust_notes').val()
|
||||
};
|
||||
var alerttitle = GetTextByKey("P_MA_ADJUSTIDLEHOUR", 'Adjust Idlehour');
|
||||
if (item.Idlehour !== "") {
|
||||
if (isNaN(item.Idlehour)) {
|
||||
showAlert(GetTextByKey("P_MA_IDLEHOURFORMAERROR", 'Idlehour format error.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (item.Idlehour <= 0) {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETERMUSTBEGREATERTHAN0", 'ODOMeter must be greater than 0.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
showAlert(GetTextByKey("P_MA_IDLEHOURCANNOTBEEMPTY", "Idlehour cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
grid_idlehourhisdt.setData([]);
|
||||
showLoading();
|
||||
|
||||
if (item.IdlehourDate === "") {
|
||||
showAlert(GetTextByKey("P_MA_IDLEHOURDATACANNOTBEEMPTY", "Idlehour date cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
hideLoading();
|
||||
return;
|
||||
}
|
||||
var offset = $('#dialogadjust_idlehourtimezone').find("option:selected").attr("offset");
|
||||
item.OffsetMinute = offset;
|
||||
|
||||
var hour = $('#dialogadjust_timehour').val();
|
||||
var minute = $('#dialogadjust_timeminute').val();
|
||||
|
||||
item.IdlehourDate = item.IdlehourDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00";
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
|
||||
devicerequest("GetCalampIdlehourHistoryPreview", param, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
ShowIdlehourHis(data);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function ShowIdlehourHis(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
for (var j in r) {
|
||||
if (j === "EventTimeText")
|
||||
r[j] = { DisplayValue: r["EventTimeText"], Value: r["AsofTime"] };
|
||||
if (j === "EventTimeLocalText")
|
||||
r[j] = { DisplayValue: r["EventTimeLocalText"], Value: r["AsofTime_Local"] };
|
||||
}
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
grid_idlehourhisdt.sortIndex = -1;
|
||||
grid_idlehourhisdt.sortDirection = -1;
|
||||
grid_idlehourhisdt.setData(rows);
|
||||
}
|
||||
|
||||
|
||||
//************************Adjust Idlehour**************************************//
|
||||
|
||||
function openAdjustIdlehour() {
|
||||
$('#dialogadjust_idlehour').val('');
|
||||
$('#dialogadjust_sel_idlehouruom').val('Mile');
|
||||
$('#dialogadjust_idlehourtimezone').val("UTC");
|
||||
$('#dialogadjust_idlehourdate').val(currentdate);
|
||||
$('#dialogadjust_timehour').val('00');
|
||||
$('#dialogadjust_timeminute').val('00');
|
||||
$('#dialogadjust_notes').val('');
|
||||
$('#dialog_adjustidlehour .dialog-title span.title').text(GetTextByKey("P_MA_ADJUSTIDLEHOUR", 'Adjust Idlehour'));
|
||||
showmaskbg(true);
|
||||
$('#dialog_adjustidlehour')
|
||||
.attr('act', 'add')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_adjustidlehour').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_adjustidlehour').width()) / 2
|
||||
})
|
||||
.showDialog();
|
||||
$('#dialogadjust_idlehour').focus();
|
||||
|
||||
getIdlehourHis();
|
||||
}
|
||||
|
||||
function OnAdjustIdlehour() {
|
||||
var alerttitle = GetTextByKey("P_MA_ADJUSTIDLEHOUR", 'Adjust Idlehour');
|
||||
$('#adjustodomask').show();
|
||||
showConfirm('Do you want to adjust the idlehour?', alerttitle, function () {
|
||||
var item = {
|
||||
'CustomerID': contractorid,
|
||||
'AssetID': machineid,
|
||||
'Idlehour': $('#dialogadjust_idlehour').val(),
|
||||
'UOM': $('#dialogadjust_sel_idlehouruom').val(),
|
||||
'IdlehourDate': $('#dialogadjust_idlehourdate').val(),
|
||||
'Notes': $('#dialogadjust_notes').val()
|
||||
};
|
||||
|
||||
if (item.Idlehour !== "") {
|
||||
if (isNaN(item.Idlehour)) {
|
||||
showAlert(GetTextByKey("P_MA_IDLEHOURFORMAERROR", 'Idlehour format error.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (item.Idlehour <= 0) {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETERMUSTBEGREATERTHAN0", 'ODOMeter must be greater than 0.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
showAlert(GetTextByKey("P_MA_IDLEHOURCANNOTBEEMPTY", "Idlehour cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.IdlehourDate === "") {
|
||||
showAlert(GetTextByKey("P_MA_IDLEHOURDATACANNOTBEEMPTY", "Idlehour date cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
var offset = $('#dialogadjust_idlehourtimezone').find("option:selected").attr("offset");
|
||||
item.OffsetMinute = offset;
|
||||
|
||||
var hour = $('#dialogadjust_timehour').val();
|
||||
var minute = $('#dialogadjust_timeminute').val();
|
||||
|
||||
item.IdlehourDate = item.IdlehourDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00";
|
||||
|
||||
showloading(true);
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
|
||||
devicerequest("SaveAdjustIdlehour", param, function (data) {
|
||||
showloading(false);
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, alerttitle);
|
||||
} else {
|
||||
getIdlehours();
|
||||
showAlert(GetTextByKey("P_MA_ADJUSTIDLEHOURSUCCESSFULLY", "Adjust Idlehour Successfully."), alerttitle);
|
||||
}
|
||||
|
||||
$('#dialog_adjustidlehour').hideDialog();
|
||||
$('#adjustodomask').hide();
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
showAlert(GetTextByKey("P_MA_FAILEDTOADJUSTIDLEHOUR", 'Failed to adjust Idlehour.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
});
|
||||
}, function () {
|
||||
$('#adjustodomask').hide();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
function OnPreviewIdlehour() {
|
||||
getIdlehourHisPreview();
|
||||
}
|
356
Site/MachineDeviceManagement/js/adj_location.js
Normal file
@ -0,0 +1,356 @@
|
||||
$(function () {
|
||||
InitLocationGridData();
|
||||
//InitLocationHisGridData();
|
||||
});
|
||||
|
||||
var grid_locationdt;
|
||||
var grid_locationhisdt;
|
||||
|
||||
function ShowLocations(data) {
|
||||
var rows = [];
|
||||
var hasCalamp = false;
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
for (var j in r) {
|
||||
if (j === "IsPrimary")
|
||||
r[j] = r[j] === true ? "Yes" : "";
|
||||
}
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
|
||||
//if (r.DataSource.toLowerCase() == "calamp")
|
||||
// hasCalamp = true;
|
||||
}
|
||||
grid_locationdt.sortIndex = -1;
|
||||
grid_locationdt.sortDirection = -1;
|
||||
grid_locationdt.setData(rows);
|
||||
|
||||
$("#locationlist").css("height", autoheight(grid_locationdt));
|
||||
grid_locationdt && grid_locationdt.resize();
|
||||
|
||||
if (IsSupperAdmin && hasCalamp) {
|
||||
$('#btnlocationadjust').css("display", '');
|
||||
}
|
||||
else
|
||||
$('#btnlocationadjust').css("display", 'none');
|
||||
}
|
||||
|
||||
function InitLocationGridData() {
|
||||
grid_locationdt = new GridView('#locationlist');
|
||||
grid_locationdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'IsPrimary', caption: GetTextByKey("P_MA_ISPRIMARY", "Is Primary"), valueIndex: 'IsPrimary', css: { 'width': 80, 'text-align': 'left' } },
|
||||
{ name: 'DataSourceName', caption: GetTextByKey("P_MA_DATASOURCE", "Data Source"), valueIndex: 'DataSourceName', css: { 'width': 120, 'text-align': 'left' } },
|
||||
{ name: 'Longitude', caption: GetTextByKey("P_MA_LONGITUDE", "Longitude"), valueIndex: 'Longitude', css: { 'width': 90, 'text-align': 'left' } },
|
||||
{ name: 'Latitude', caption: GetTextByKey("P_MA_LATITUDE", "Latitude"), valueIndex: 'Latitude', css: { 'width': 90, 'text-align': 'left' } },
|
||||
{ name: 'ReceivedDate', caption: GetTextByKey("P_MA_RECEIVEDDATE", "Received Date"), valueIndex: 'ReceivedDateStr', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'SetPrmary', caption: "", css: { 'width': 100, 'text-align': 'left' } }
|
||||
];
|
||||
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;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
if (col.name === "SetPrmary") {
|
||||
col.isurl = true;
|
||||
col.text = GetTextByKey("P_MA_SETASPRIMARY", 'Set As Primary');
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
openSetPrimary(2, this);
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
};
|
||||
col.styleFilter = function (e) {
|
||||
return {
|
||||
display: e.IsPrimary === "Yes" ? 'none' : ''
|
||||
};
|
||||
};
|
||||
col.attrs = { 'title': GetTextByKey("P_MA_SETASPRIMARY", 'Set As Primary') };
|
||||
col.visible = IsSupperAdmin;
|
||||
col.resizable = false;
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_locationdt.canMultiSelect = false;
|
||||
grid_locationdt.columns = columns;
|
||||
grid_locationdt.init();
|
||||
|
||||
grid_locationdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_locationdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function InitLocationHisGridData() {
|
||||
grid_locationhisdt = new GridView('#locationhislist');
|
||||
grid_locationhisdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'DeviceAirId', caption: GetTextByKey("P_MA_DEVICEAIRID", "Device Air ID"), valueIndex: 'DeviceAirId', css: { 'width': 140, 'text-align': 'left' } },
|
||||
{ name: 'AsofTime', caption: GetTextByKey("P_MA_EVENTDATEUTC", "Event Date(UTC)"), valueIndex: 'EventTimeText', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'AsofTime_local', caption: GetTextByKey("P_MA_EVENTDATE", "Event Date"), valueIndex: 'EventTimeLocalText', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'VBUS', caption: GetTextByKey("P_MA_VBUSRAW", "VBUS(Raw)"), valueIndex: 'VBUS', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'VBUS_Calc', caption: GetTextByKey("P_MA_VBUSCALC", "VBUS(Calc)"), valueIndex: 'VBUS_Calc', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Gps', caption: GetTextByKey("P_MA_GPSRAW", "GPS(Raw)"), valueIndex: 'Gps', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Gps_Calc', caption: GetTextByKey("P_MA_GPSCALC", "GPS(Calc)"), valueIndex: 'Gps_Calc', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'Unit', caption: GetTextByKey("P_MA_UNIT", "Unit"), valueIndex: 'UOM', css: { 'width': 60, 'text-align': 'right' } }
|
||||
];
|
||||
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;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_locationhisdt.canMultiSelect = false;
|
||||
grid_locationhisdt.columns = columns;
|
||||
grid_locationhisdt.init();
|
||||
|
||||
grid_locationhisdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_locationhisdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getLocations() {
|
||||
grid_locationdt.setData([]);
|
||||
showLoading();
|
||||
|
||||
devicerequest("GetAssetCurrentLocation", contractorid + String.fromCharCode(170) + machineid, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
ShowLocations(data);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function getLocationHis() {
|
||||
grid_locationhisdt.setData([]);
|
||||
showLoading();
|
||||
|
||||
devicerequest("GetCalampLocationHistory", contractorid + String.fromCharCode(170) + machineid, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
ShowLocationHis(data);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function getLocationHisPreview() {
|
||||
var item = {
|
||||
'CustomerID': contractorid,
|
||||
'AssetID': machineid,
|
||||
'Location': $('#dialogadjust_location').val(),
|
||||
'UOM': $('#dialogadjust_sel_locationuom').val(),
|
||||
'LocationDate': $('#dialogadjust_locationdate').val(),
|
||||
'Notes': $('#dialogadjust_notes').val()
|
||||
};
|
||||
var alerttitle = GetTextByKey("P_MA_ADJUSTLOCATION", "Adjust Location");
|
||||
if (item.Location !== "") {
|
||||
if (isNaN(item.Location)) {
|
||||
showAlert(GetTextByKey("P_MA_LOCATIONFORMAERROR", 'Location format error.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (item.Location <= 0) {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETERMUSTBEGREATERTHAN0", 'ODOMeter must be greater than 0.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
showAlert(GetTextByKey("P_MA_LOCATIONCANNOTBEEMPTY", "Location cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
grid_locationhisdt.setData([]);
|
||||
showLoading();
|
||||
|
||||
if (item.LocationDate === "") {
|
||||
showAlert(GetTextByKey("P_MA_LOCATIONDATACANNOTBEEMPTY", "Location date cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
hideLoading();
|
||||
return;
|
||||
}
|
||||
var offset = $('#dialogadjust_locationtimezone').find("option:selected").attr("offset");
|
||||
item.OffsetMinute = offset;
|
||||
|
||||
var hour = $('#dialogadjust_timehour').val();
|
||||
var minute = $('#dialogadjust_timeminute').val();
|
||||
|
||||
item.LocationDate = item.LocationDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00";
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
|
||||
devicerequest("GetCalampLocationHistoryPreview", param, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
ShowLocationHis(data);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function ShowLocationHis(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
for (var j in r) {
|
||||
if (j === "EventTimeText")
|
||||
r[j] = { DisplayValue: r["EventTimeText"], Value: r["AsofTime"] };
|
||||
if (j === "EventTimeLocalText")
|
||||
r[j] = { DisplayValue: r["EventTimeLocalText"], Value: r["AsofTime_Local"] };
|
||||
}
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
grid_locationhisdt.sortIndex = -1;
|
||||
grid_locationhisdt.sortDirection = -1;
|
||||
grid_locationhisdt.setData(rows);
|
||||
}
|
||||
|
||||
|
||||
//************************Adjust Location**************************************//
|
||||
|
||||
function openAdjustLocation() {
|
||||
$('#dialogadjust_location').val('');
|
||||
$('#dialogadjust_sel_locationuom').val('Mile');
|
||||
$('#dialogadjust_locationtimezone').val("UTC");
|
||||
$('#dialogadjust_locationdate').val(currentdate);
|
||||
$('#dialogadjust_timehour').val('00');
|
||||
$('#dialogadjust_timeminute').val('00');
|
||||
$('#dialogadjust_notes').val('');
|
||||
$('#dialog_adjustlocation .dialog-title span.title').text(GetTextByKey("P_MA_ADJUSTLOCATION", "Adjust Location"));
|
||||
showmaskbg(true);
|
||||
$('#dialog_adjustlocation')
|
||||
.attr('act', 'add')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_adjustlocation').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_adjustlocation').width()) / 2
|
||||
})
|
||||
.showDialog();
|
||||
$('#dialogadjust_location').focus();
|
||||
|
||||
getLocationHis();
|
||||
}
|
||||
|
||||
function OnAdjustLocation() {
|
||||
$('#adjustodomask').show();
|
||||
var alerttitle = GetTextByKey("P_MA_ADJUSTLOCATION", "Adjust Location");
|
||||
showConfirm('Do you want to adjust the location?', alerttitle, function () {
|
||||
var item = {
|
||||
'CustomerID': contractorid,
|
||||
'AssetID': machineid,
|
||||
'Location': $('#dialogadjust_location').val(),
|
||||
'UOM': $('#dialogadjust_sel_locationuom').val(),
|
||||
'LocationDate': $('#dialogadjust_locationdate').val(),
|
||||
'Notes': $('#dialogadjust_notes').val()
|
||||
};
|
||||
|
||||
if (item.Location !== "") {
|
||||
if (isNaN(item.Location)) {
|
||||
showAlert(GetTextByKey("P_MA_LOCATIONFORMAERROR", 'Location format error.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (item.Location <= 0) {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETERMUSTBEGREATERTHAN0", 'ODOMeter must be greater than 0.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
showAlert(GetTextByKey("P_MA_LOCATIONCANNOTBEEMPTY", "Location cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.LocationDate === "") {
|
||||
showAlert(GetTextByKey("P_MA_LOCATIONDATACANNOTBEEMPTY", "Location date cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
var offset = $('#dialogadjust_locationtimezone').find("option:selected").attr("offset");
|
||||
item.OffsetMinute = offset;
|
||||
|
||||
var hour = $('#dialogadjust_timehour').val();
|
||||
var minute = $('#dialogadjust_timeminute').val();
|
||||
|
||||
item.LocationDate = item.LocationDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00";
|
||||
|
||||
showloading(true);
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
|
||||
devicerequest("SaveAdjustLocation", param, function (data) {
|
||||
showloading(false);
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, alerttitle);
|
||||
} else {
|
||||
getLocations();
|
||||
showAlert(GetTextByKey("P_MA_ADJUSTLOCATIONSUCCESSFULLY", "Adjust Location Successfully."), alerttitle);
|
||||
}
|
||||
|
||||
$('#dialog_adjustlocation').hideDialog();
|
||||
$('#adjustodomask').hide();
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
showAlert(GetTextByKey("P_MA_FAILEDTOADJUSTLOCATION", 'Failed to adjust Location.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
});
|
||||
}, function () {
|
||||
$('#adjustodomask').hide();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
function OnPreviewLocation() {
|
||||
getLocationHisPreview();
|
||||
}
|
659
Site/MachineDeviceManagement/js/adj_odometer.js
Normal file
@ -0,0 +1,659 @@
|
||||
$(function () {
|
||||
InitOdometerGridData();
|
||||
InitOdometerMostRecentGridData();
|
||||
InitOdometerHisGridData();
|
||||
});
|
||||
|
||||
var grid_odometerdt;
|
||||
var grid_odometermostrecentdt;
|
||||
var grid_odometerhisdt;
|
||||
var isCalampOdo = false;
|
||||
var isPedigreeOdo = false;
|
||||
var primarydatadourcenameOdo;
|
||||
var primarydatadourceOdo;
|
||||
|
||||
function ShowOdometers(data) {
|
||||
var rows = [];
|
||||
isCalampOdo = false;
|
||||
isPedigreeOdo = false;
|
||||
isSmartWitness = false;
|
||||
primarydatadourcenameOdo = undefined;
|
||||
primarydatadourceOdo = undefined;
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
for (var j in r) {
|
||||
if (j === "IsPrimary")
|
||||
r[j] = r[j] === true ? "Yes" : "";
|
||||
}
|
||||
r.Odometer = r.Odometer.toFixed(2);
|
||||
r.Corrected = r.Corrected.toFixed(2);
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
if (r.DataSource.toLowerCase() == "calamp" && r.IsPrimary.toLowerCase() == "yes")
|
||||
isCalampOdo = true;
|
||||
else if (r.DataSource.toLowerCase() == "pedigree") {
|
||||
if (r.IsPrimary.toLowerCase() == "yes" && r.SubSource.toLowerCase() != "odometer")//10471
|
||||
isPedigreeOdo = true;
|
||||
if (r.SubSource.toLowerCase() == "odometer")
|
||||
r.DataSourceName = "HOS";
|
||||
}
|
||||
else if (r.DataSource.toLowerCase() == "smartwitness" && r.IsPrimary.toLowerCase() == "yes")
|
||||
isSmartWitness = true;
|
||||
if (r.IsPrimary.toLowerCase() == "yes") {
|
||||
primarydatadourcenameOdo = r.DataSourceName;
|
||||
primarydatadourceOdo = r.DataSource;
|
||||
}
|
||||
}
|
||||
grid_odometerdt.sortIndex = -1;
|
||||
grid_odometerdt.sortDirection = -1;
|
||||
grid_odometerdt.setData(rows);
|
||||
|
||||
$("#odometerlist").css("height", autoheight(grid_odometerdt));
|
||||
grid_odometerdt && grid_odometerdt.resize();
|
||||
|
||||
if ((IsSupperAdmin || isAllowed) && (isCalampOdo || isPedigreeOdo || isSmartWitness)) {
|
||||
$('#btnodometeradjust').css("display", '');
|
||||
$('#btnodometerhistory').css("display", '');
|
||||
}
|
||||
else {
|
||||
$('#btnodometeradjust').css("display", 'none');
|
||||
$('#btnodometerhistory').css("display", 'none');
|
||||
}
|
||||
|
||||
if (primarydatadourcenameOdo) {
|
||||
$('#span_adjustodometer').text(primarydatadourcenameOdo);
|
||||
$('#span_addodometer').text(primarydatadourcenameOdo);
|
||||
}
|
||||
else {
|
||||
$('#span_adjustodometer').text('empty');
|
||||
$('#span_addodometer').text('empty');
|
||||
}
|
||||
}
|
||||
|
||||
function InitOdometerGridData() {
|
||||
grid_odometerdt = new GridView('#odometerlist');
|
||||
grid_odometerdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'IsPrimary', caption: GetTextByKey("P_MA_ISPRIMARY", "Is Primary"), valueIndex: 'IsPrimary', css: { 'width': 80, 'text-align': 'left' } },
|
||||
{ name: 'DataSourceName', caption: GetTextByKey("P_MA_DATASOURCE", "Data Source"), valueIndex: 'DataSourceName', css: { 'width': 120, 'text-align': 'left' } },
|
||||
{ name: 'Odometer', caption: GetTextByKey("P_MA_ODOMETER", "Odometer"), valueIndex: 'Odometer', css: { 'width': 80, 'text-align': 'left' } },
|
||||
{ name: 'Corrected', caption: GetTextByKey("P_MA_ADJUSTED", "Adjusted"), valueIndex: 'Corrected', css: { 'width': 75, 'text-align': 'left' } },
|
||||
{ name: 'UOM', caption: GetTextByKey("P_MA_UNITS", "Units"), valueIndex: 'UOM', css: { 'width': 60, 'text-align': 'left' } },
|
||||
{ name: 'ReceivedDate', caption: GetTextByKey("P_MA_RECEIVEDDATE", "Received Date"), valueIndex: 'ReceivedDateStr', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'SetPrmary', caption: "", css: { 'width': 100, 'text-align': 'left' } }
|
||||
];
|
||||
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 = false;
|
||||
col.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
if (col.name === "SetPrmary") {
|
||||
col.isurl = true;
|
||||
col.text = GetTextByKey("P_MA_SETASPRIMARY", 'Set As Primary');
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
openSetPrimary(0, this);
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
};
|
||||
col.styleFilter = function (e) {
|
||||
return {
|
||||
display: e.IsPrimary === "Yes" || (!IsSupperAdmin && !isAllowed) ? 'none' : ''
|
||||
};
|
||||
};
|
||||
col.attrs = { 'title': GetTextByKey("P_MA_SETASPRIMARY", 'Set As Primary') };
|
||||
col.resizable = false;
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_odometerdt.canMultiSelect = false;
|
||||
grid_odometerdt.columns = columns;
|
||||
grid_odometerdt.init();
|
||||
|
||||
grid_odometerdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_odometerdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function InitOdometerMostRecentGridData() {
|
||||
grid_odometermostrecentdt = new GridView('#odometermostrecent');
|
||||
grid_odometermostrecentdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'DeviceAirId', caption: GetTextByKey("P_MA_DEVICEAIRID", "Device Air ID"), valueIndex: 'DeviceAirId', css: { 'width': 140, 'text-align': 'left' } },
|
||||
{ name: 'DeviceSN', caption: GetTextByKey("P_MA_DEVICESN", "Device SN"), valueIndex: 'DeviceSN', css: { 'width': 140, 'text-align': 'left' } },
|
||||
{ name: 'AsofTime', caption: GetTextByKey("P_MA_EVENTDATEUTC", "Event Date(UTC)"), valueIndex: 'EventTimeText', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'AsofTime_local', caption: GetTextByKey("P_MA_EVENTDATE", "Event Date"), valueIndex: 'EventTimeLocalText', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'VBUS', caption: GetTextByKey("P_MA_VBUSRAW", "VBUS(Raw)"), valueIndex: 'VBUS', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'VBUS_Calc', caption: GetTextByKey("P_MA_VBUSCALC", "VBUS(Calc)"), valueIndex: 'VBUS_Calc', css: { 'width': 110, 'text-align': 'right' } },
|
||||
{ name: 'Gps', caption: GetTextByKey("P_MA_GPSRAW", "GPS(Raw)"), valueIndex: 'Gps', css: { 'width': 110, 'text-align': 'right' } },
|
||||
{ name: 'Gps_Calc', caption: GetTextByKey("P_MA_GPSCALC", "GPS(Calc)"), valueIndex: 'Gps_Calc', css: { 'width': 130, 'text-align': 'right' } },
|
||||
{ name: 'Unit', caption: GetTextByKey("P_MA_UNIT", "Unit"), valueIndex: 'UOM', css: { 'width': 60, 'text-align': 'left' } }
|
||||
];
|
||||
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 = false;
|
||||
col.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_odometermostrecentdt.canMultiSelect = false;
|
||||
grid_odometermostrecentdt.columns = columns;
|
||||
grid_odometermostrecentdt.init();
|
||||
}
|
||||
|
||||
function InitOdometerHisGridData() {
|
||||
grid_odometerhisdt = new GridView('#odometerhislist');
|
||||
grid_odometerhisdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'DeviceAirId', caption: GetTextByKey("P_MA_DEVICEAIRID", "Device Air ID"), valueIndex: 'DeviceAirId', css: { 'width': 140, 'text-align': 'left' } },
|
||||
{ name: 'DeviceSN', caption: GetTextByKey("P_MA_DEVICESN", "Device SN"), valueIndex: 'DeviceSN', css: { 'width': 140, 'text-align': 'left' } },
|
||||
{ name: 'AsofTime', caption: GetTextByKey("P_MA_EVENTDATEUTC", "Event Date(UTC)"), valueIndex: 'EventTimeText', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'AsofTime_local', caption: GetTextByKey("P_MA_EVENTDATE", "Event Date"), valueIndex: 'EventTimeLocalText', css: { 'width': 130, 'text-align': 'left' } },
|
||||
{ name: 'VBUS', caption: GetTextByKey("P_MA_VBUSRAW", "VBUS(Raw)"), valueIndex: 'VBUS', css: { 'width': 90, 'text-align': 'right' } },
|
||||
{ name: 'VBUS_Calc', caption: GetTextByKey("P_MA_VBUSCALC", "VBUS(Calc)"), valueIndex: 'VBUS_Calc', css: { 'width': 110, 'text-align': 'right' } },
|
||||
{ name: 'Gps', caption: GetTextByKey("P_MA_GPSRAW", "GPS(Raw)"), valueIndex: 'Gps', css: { 'width': 110, 'text-align': 'right' } },
|
||||
{ name: 'Gps_Calc', caption: GetTextByKey("P_MA_GPSCALC", "GPS(Calc)"), valueIndex: 'Gps_Calc', css: { 'width': 130, 'text-align': 'right' } },
|
||||
{ name: 'Unit', caption: GetTextByKey("P_MA_UNIT", "Unit"), valueIndex: 'UOM', css: { 'width': 60, 'text-align': 'left' } }
|
||||
];
|
||||
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 = false;
|
||||
col.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_odometerhisdt.canMultiSelect = false;
|
||||
grid_odometerhisdt.columns = columns;
|
||||
grid_odometerhisdt.init();
|
||||
|
||||
grid_odometerhisdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_odometerhisdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getOdometers() {
|
||||
grid_odometerdt.setData([]);
|
||||
showLoading();
|
||||
devicerequest("GetAssetCurrentOdometer", contractorid + String.fromCharCode(170) + machineid, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
ShowOdometers(data);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function getOdometerHis() {
|
||||
grid_odometermostrecentdt.setData([]);
|
||||
grid_odometerhisdt.setData([]);
|
||||
showLoading();
|
||||
|
||||
var methodname = "";
|
||||
if (isCalampOdo)
|
||||
methodname = "GetCalampOdometerHistory";
|
||||
else if (isPedigreeOdo)
|
||||
methodname = "GetPedigreeOdometerHistory";
|
||||
else if (isSmartWitness)
|
||||
methodname = "GetSmartWitnessOdometerHistory";
|
||||
|
||||
devicerequest(methodname, contractorid + String.fromCharCode(170) + machineid, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
ShowOdometerHis(data);
|
||||
ShowMostRecentOdometer(data);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function getOdometerHisPreview() {
|
||||
var item = {
|
||||
'CustomerID': contractorid,
|
||||
'AssetID': machineid,
|
||||
'Odometer': $('#dialogadjust_odometer').val(),
|
||||
'UOM': $('#dialogadjust_sel_odometeruom').val(),
|
||||
'OdometerDate': $('#dialogadjust_odometerdate').val(),
|
||||
'Notes': $('#dialogadjust_notes').val()
|
||||
};
|
||||
var alerttitle = GetTextByKey("P_MA_ADJUSTODOMETER", "Adjust Odometer");
|
||||
if (item.Odometer !== "") {
|
||||
if (isNaN(item.Odometer)) {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETERFORMATERROR", 'Odometer format error.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (item.Odometer <= 0) {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETERMUSTBEGREATERTHAN0", 'ODOMeter must be greater than 0.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETRCANNOTBEEMPTY", "Odometer cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (item.OdometerDate === "") {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETRDATACANNOTBEEMPTY", "Odometer date cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
hideLoading();
|
||||
return;
|
||||
}
|
||||
var offset = $('#dialogadjust_odometertimezone').find("option:selected").attr("offset");
|
||||
item.OffsetMinute = offset;
|
||||
|
||||
var hour = $('#dialogadjust_timehour').val();
|
||||
var minute = $('#dialogadjust_timeminute').val();
|
||||
|
||||
item.OdometerDate = item.OdometerDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00";
|
||||
|
||||
CheckOdometerMinnimumTime(item, "preview");
|
||||
}
|
||||
|
||||
|
||||
function GetOdometerHistoryPreview(item) {
|
||||
grid_odometerhisdt.setData([]);
|
||||
showLoading();
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
if (isCalampOdo)
|
||||
methodname = "GetCalampOdometerHistoryPreview";
|
||||
else if (isPedigreeOdo)
|
||||
methodname = "GetPedigreeOdometerHistoryPreview";
|
||||
else if (isSmartWitness)
|
||||
methodname = "GetSmartWitnessOdometerHistoryPreview";
|
||||
|
||||
devicerequest(methodname, param, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
ShowOdometerHis(data);
|
||||
ShowMostRecentOdometerPreview(data);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
var mostrecentrecord
|
||||
function ShowMostRecentOdometer(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
mostrecentrecord = data[i];
|
||||
var fr = { Values: mostrecentrecord };
|
||||
rows.push(fr);
|
||||
break;// Display the most recent reading
|
||||
}
|
||||
grid_odometermostrecentdt.sortIndex = -1;
|
||||
grid_odometermostrecentdt.sortDirection = -1;
|
||||
grid_odometermostrecentdt.setData(rows);
|
||||
}
|
||||
|
||||
function ShowMostRecentOdometerPreview(data) {
|
||||
if (!mostrecentrecord) return;
|
||||
|
||||
var offsetVBUS = 0;
|
||||
var offsetGPS = 0;
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
offsetVBUS = r.VBUS - r.VBUS_Calc;
|
||||
offsetGPS = r.Gps - r.Gps_Calc;
|
||||
break;
|
||||
}
|
||||
|
||||
var rows = [];
|
||||
var r = $.extend(true, {}, mostrecentrecord);
|
||||
r.VBUS_Calc = r.VBUS - offsetVBUS;
|
||||
r.VBUS_Calc = r.VBUS_Calc.toFixed(2);
|
||||
r.Gps_Calc = r.Gps - offsetGPS;
|
||||
r.Gps_Calc = r.Gps_Calc.toFixed(2);
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
|
||||
grid_odometermostrecentdt.sortIndex = -1;
|
||||
grid_odometermostrecentdt.sortDirection = -1;
|
||||
grid_odometermostrecentdt.setData(rows);
|
||||
}
|
||||
|
||||
function ShowOdometerHis(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
r.VBUS = r.VBUS.toFixed(2);
|
||||
r.VBUS_Calc = r.VBUS_Calc.toFixed(2);
|
||||
r.Gps = r.Gps.toFixed(2);
|
||||
r.Gps_Calc = r.Gps_Calc.toFixed(2);
|
||||
for (var j in r) {
|
||||
if (j === "EventTimeText")
|
||||
r[j] = { DisplayValue: r["EventTimeText"], Value: r["AsofTime"] };
|
||||
if (j === "EventTimeLocalText")
|
||||
r[j] = { DisplayValue: r["EventTimeLocalText"], Value: r["AsofTime_Local"] };
|
||||
}
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
grid_odometerhisdt.sortIndex = -1;
|
||||
grid_odometerhisdt.sortDirection = -1;
|
||||
grid_odometerhisdt.setData(rows);
|
||||
}
|
||||
|
||||
|
||||
//************************Adjust Odometer**************************************//
|
||||
|
||||
function openAdjustOdometer() {
|
||||
grid_odometermostrecentdt.columns[0].visible = isCalampOdo;
|
||||
grid_odometermostrecentdt.columns[1].visible = isPedigreeOdo || isSmartWitness;
|
||||
grid_odometermostrecentdt.columns[4].visible = !isSmartWitness;
|
||||
grid_odometermostrecentdt.columns[4].caption = isCalampOdo ? GetTextByKey("P_MA_VBUSRAW", "VBUS(Raw)") : GetTextByKey("P_MA_RAWRAW", "Raw(Raw)");
|
||||
grid_odometermostrecentdt.columns[5].visible = !isSmartWitness;
|
||||
grid_odometermostrecentdt.columns[5].caption = isCalampOdo ? GetTextByKey("P_MA_VBUSCALC", "VBUS(Calc)") : "Raw(Adjusted)";
|
||||
grid_odometermostrecentdt.columns[6].caption = isCalampOdo ? "GPS(Raw)" : "Odometer(Raw)";
|
||||
grid_odometermostrecentdt.columns[7].caption = isCalampOdo ? "GPS(Calc)" : "Odometer(Adjusted)";
|
||||
grid_odometermostrecentdt.init();
|
||||
|
||||
grid_odometerhisdt.columns[0].visible = isCalampOdo;
|
||||
grid_odometerhisdt.columns[1].visible = isPedigreeOdo || isSmartWitness;
|
||||
grid_odometerhisdt.columns[4].visible = !isSmartWitness;
|
||||
grid_odometerhisdt.columns[4].caption = isCalampOdo ? GetTextByKey("P_MA_VBUSRAW", "VBUS(Raw)") : GetTextByKey("P_MA_RAWRAW", "Raw(Raw)");
|
||||
grid_odometerhisdt.columns[5].visible = !isSmartWitness;
|
||||
grid_odometerhisdt.columns[5].caption = isCalampOdo ? GetTextByKey("P_MA_VBUSCALC", "VBUS(Calc)") : "Raw(Adjusted)";
|
||||
grid_odometerhisdt.columns[6].caption = isCalampOdo ? "GPS(Raw)" : "Odometer(Raw)";
|
||||
grid_odometerhisdt.columns[7].caption = isCalampOdo ? "GPS(Calc)" : "Odometer(Adjusted)";
|
||||
grid_odometerhisdt.init();
|
||||
|
||||
var datetime = customerdatetime.split(' ');
|
||||
var time = datetime[0];
|
||||
var st = datetime[1].split(':');
|
||||
var hours = st[0].length == 1 ? "0" + st[0] : st[0];
|
||||
var minutes = st[1];
|
||||
|
||||
$('#dialogadjust_odometer').val('');
|
||||
$('#dialogadjust_sel_odometeruom').val(systemunitofodometer);
|
||||
$('#dialogadjust_odometertimezone').val(customertimezone ? customertimezone : "UTC");
|
||||
$('#dialogadjust_odometerdate').val(time);
|
||||
$('#dialogadjust_timehour').val(hours);
|
||||
$('#dialogadjust_timeminute').val(minutes);
|
||||
$('#dialogadjust_notes').val('');
|
||||
$('#dialog_adjustodometer .dialog-title span.title').text(GetTextByKey("P_MA_ADJUSTODOMETER", 'Adjust Odometer'));
|
||||
showmaskbg(true);
|
||||
$('#dialog_adjustodometer')
|
||||
.attr('act', 'add')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_adjustodometer').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_adjustodometer').width()) / 2
|
||||
})
|
||||
.showDialogfixed();
|
||||
$('#dialogadjust_odometer').focus();
|
||||
|
||||
getOdometerHis();
|
||||
}
|
||||
|
||||
function OnAdjustOdometer() {
|
||||
$('#adjustodomask').show();
|
||||
var alerttitle = GetTextByKey("P_MA_ADJUSTODOMETER", "Adjust Odometer");
|
||||
showConfirm(GetTextByKey("P_MA_DOYOUWANTTOADJUSTTHEODOMETER", 'Do you want to adjust the odometer?'), alerttitle, function () {
|
||||
var item = {
|
||||
'CustomerID': contractorid,
|
||||
'AssetID': machineid,
|
||||
'Odometer': $('#dialogadjust_odometer').val(),
|
||||
'UOM': $('#dialogadjust_sel_odometeruom').val(),
|
||||
'OdometerDate': $('#dialogadjust_odometerdate').val(),
|
||||
'Notes': $('#dialogadjust_notes').val(),
|
||||
'DataSource': primarydatadourceOdo
|
||||
};
|
||||
|
||||
if (item.Odometer !== "") {
|
||||
if (isNaN(item.Odometer)) {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETERFORMATERROR", 'Odometer format error.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (item.Odometer <= 0) {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETERMUSTBEGREATERTHAN0", 'ODOMeter must be greater than 0.'), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETRCANNOTBEEMPTY", "Odometer cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.OdometerDate === "") {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETRDATACANNOTBEEMPTY", "Odometer date cannot be empty."), alerttitle);
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
}
|
||||
var offset = $('#dialogadjust_odometertimezone').find("option:selected").attr("offset");
|
||||
item.OffsetMinute = offset;
|
||||
|
||||
var hour = $('#dialogadjust_timehour').val();
|
||||
var minute = $('#dialogadjust_timeminute').val();
|
||||
|
||||
item.OdometerDate = item.OdometerDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00";
|
||||
|
||||
CheckOdometerMinnimumTime(item, "submit");
|
||||
|
||||
}, function () {
|
||||
$('#adjustodomask').hide();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
function CheckOdometerMinnimumTime(item, type) {
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
devicerequest("CheckOdometerMinnimumTime", param, function (data) {
|
||||
if (data > 0) {
|
||||
if (data == 1)
|
||||
showAlert(GetTextByKey("P_MA_CHECKODOMETERMINNIMUMTIME1", "The adjustment cannot be completed as provided. The odometer reading date provided cannot be prior to initial telematic data available for the asset."), GetTextByKey("P_MA_ADJUSTODOMETER", "Adjust Odometer"));
|
||||
else
|
||||
showAlert(GetTextByKey("P_MA_CHECKODOMETERMINNIMUMTIME", "The adjustment cannot be completed as provided. The odometer reading date provided must be prior to or equal to the latest telematic data available for the asset."), GetTextByKey("P_MA_ADJUSTODOMETER", "Adjust Odometer"));
|
||||
$('#adjustodomask').hide();
|
||||
return;
|
||||
} else {
|
||||
if (type === "submit")
|
||||
SaveAdjustOdometer(item);
|
||||
else if (type === "preview")
|
||||
GetOdometerHistoryPreview(item);
|
||||
}
|
||||
}, function (err) {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function SaveAdjustOdometer(item) {
|
||||
showloading(true);
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
devicerequest("SaveAdjustOdometer", param, function (data) {
|
||||
showloading(false);
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, GetTextByKey("P_MA_ADJUSTODOMETER", "Adjust Odometer"));
|
||||
} else {
|
||||
getOdometers();
|
||||
getMachineInfo();
|
||||
showAlert(GetTextByKey("P_MA_ADJUSTODOMETERSUCCESSFULLY", "Adjust Odometer Successfully."), GetTextByKey("P_MA_ADJUSTODOMETER", "Adjust Odometer"));
|
||||
}
|
||||
|
||||
$('#dialog_adjustodometer').hideDialog();
|
||||
$('#adjustodomask').hide();
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
showAlert(GetTextByKey("P_MA_FAILEDTOADJUSTDOMETER", 'Failed to adjust Odometer.'), GetTextByKey("P_MA_ADJUSTODOMETER", "Adjust Odometer"));
|
||||
$('#adjustodomask').hide();
|
||||
});
|
||||
}
|
||||
|
||||
function OnPreviewOdometer() {
|
||||
getOdometerHisPreview();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//************************Add Odometer**************************************//
|
||||
|
||||
function openAddOdometer() {
|
||||
var datetime = customerdatetime.split(' ');
|
||||
var time = datetime[0];
|
||||
var st = datetime[1].split(':');
|
||||
var hours = st[0].length == 1 ? "0" + st[0] : st[0];
|
||||
var minutes = st[1];
|
||||
$('#dialogadd_odometer').val('');
|
||||
$('#dialogadd_sel_odometeruom').val(systemunitofodometer);
|
||||
$('#dialogadd_odometertimezone').val(customertimezone ? customertimezone : "UTC");
|
||||
$('#dialogadd_odometerdate').val(time);
|
||||
$('#dialogadd_timehour').val(hours);
|
||||
$('#dialogadd_timeminute').val(minutes);
|
||||
$('#dialogadd_notes').val('');
|
||||
$('#dialog_addodometer .dialog-title span.title').text(GetTextByKey("P_MA_ADDODOMETER", 'Add Odometer'));
|
||||
showmaskbg(true);
|
||||
$('#dialog_addodometer')
|
||||
.attr('act', 'add')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_addodometer').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_addodometer').width()) / 2
|
||||
})
|
||||
.showDialogfixed();
|
||||
$('#dialogadd_odometer').focus();
|
||||
}
|
||||
|
||||
function OnAddOdometer() {
|
||||
$('#addodomask').show();
|
||||
var alerttile = GetTextByKey("P_MA_ADDODOMETER", 'Add Odometer');
|
||||
showConfirm(GetTextByKey("P_MA_DOYOUWANTTOADDTHEODOMETER", 'Do you want to add the odometer?'), alerttile, function () {
|
||||
var item = {
|
||||
'CustomerID': contractorid,
|
||||
'AssetID': machineid,
|
||||
'Odometer': $('#dialogadd_odometer').val(),
|
||||
'UOM': $('#dialogadd_sel_odometeruom').val(),
|
||||
'OdometerDate': $('#dialogadd_odometerdate').val(),
|
||||
'Notes': $('#dialogadd_notes').val()
|
||||
};
|
||||
|
||||
if (item.Odometer !== "") {
|
||||
if (isNaN(item.Odometer)) {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETERFORMATERROR", 'Odometer format error.'), alerttile);
|
||||
$('#addodomask').hide();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (item.Odometer <= 0) {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETERMUSTBEGREATERTHAN0", 'ODOMeter must be greater than 0.'), alerttile);
|
||||
$('#addodomask').hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETRCANNOTBEEMPTY", "Odometer cannot be empty."), alerttile);
|
||||
$('#addodomask').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.OdometerDate === "") {
|
||||
showAlert(GetTextByKey("P_MA_ODOMETRDATACANNOTBEEMPTY", "Odometer date cannot be empty."), alerttile);
|
||||
$('#addodomask').hide();
|
||||
return;
|
||||
}
|
||||
var offset = $('#dialogadd_odometertimezone').find("option:selected").attr("offset");
|
||||
item.OffsetMinute = offset;
|
||||
|
||||
var hour = $('#dialogadd_timehour').val();
|
||||
var minute = $('#dialogadd_timeminute').val();
|
||||
|
||||
item.OdometerDate = item.OdometerDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00";
|
||||
showloading(true);
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
devicerequest("AddManuallyInputOdometer", param, function (data) {
|
||||
showloading(false);
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, alerttile);
|
||||
} else {
|
||||
getOdometers();
|
||||
getMachineInfo();
|
||||
showAlert("Add Odometer Successfully.", alerttile);
|
||||
}
|
||||
|
||||
$('#dialog_addodometer').hideDialog();
|
||||
$('#addodomask').hide();
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
showAlert('Failed to add Odometer.', alerttile);
|
||||
$('#addodomask').hide();
|
||||
});
|
||||
|
||||
}, function () {
|
||||
$('#addodomask').hide();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/********************Adjustment History****************************************/
|
||||
|
||||
function openOdometerAdjustHistory() {
|
||||
window.open("OdometerAdjustHistory.aspx?cid=" + contractorid + "&mid=" + machineid);
|
||||
}
|
275
Site/MachineDeviceManagement/js/adjustment.js
Normal file
@ -0,0 +1,275 @@
|
||||
$(function () {
|
||||
initTime();
|
||||
initTimeZone();
|
||||
|
||||
$('#dialog_adjustodometer').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
|
||||
$('#dialog_addodometer').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
|
||||
$('#dialog_adjustenginehours').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
|
||||
$('#dialog_addenginehours').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
|
||||
$('#dialog_setprimary').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
|
||||
$('#dialogadjust_odometerdate').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
|
||||
$('#dialogadd_odometerdate').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
$('#dialogaddenginehours_date').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
|
||||
$('#dialogenginehours_date').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
|
||||
$("#tdAuditEngineHours").click(auditHide);
|
||||
$("#tdAuditOdometers").click(auditHide);
|
||||
$("#tdAuditLocation").click(auditHide);
|
||||
$("#tdAuditIdlehour").click(auditHide);
|
||||
$("#tdAuditFuelused").click(auditHide);
|
||||
$("#tdAuditFuelRemaining").click(auditHide);
|
||||
});
|
||||
|
||||
function auditHide(e) {
|
||||
var target = $(e.target);
|
||||
if (target.data("hide") == 1) {
|
||||
target.data("hide", 0);
|
||||
var p = target.parent();
|
||||
p.next().show();
|
||||
p.next().next().show();
|
||||
target.removeClass("plus").addClass("minus");
|
||||
}
|
||||
else {
|
||||
target.data("hide", 1);
|
||||
var p = target.parent();
|
||||
p.next().hide();
|
||||
p.next().next().hide();
|
||||
target.removeClass("minus").addClass("plus");
|
||||
}
|
||||
}
|
||||
|
||||
function initTime() {
|
||||
var c = $('#dialogadjust_timehour');
|
||||
for (var i = 0; i < 24; i++) {
|
||||
if (i < 10)
|
||||
c.append($("<option></option>").val("0" + i).text("0" + i))
|
||||
else
|
||||
c.append($("<option></option>").val(i).text(i))
|
||||
}
|
||||
c = $('#dialogadjust_timeminute');
|
||||
for (var i = 0; i < 60; i++) {
|
||||
if (i < 10)
|
||||
c.append($("<option></option>").val("0" + i).text("0" + i))
|
||||
else
|
||||
c.append($("<option></option>").val(i).text(i))
|
||||
}
|
||||
c = $('#dialogadd_timehour');
|
||||
for (var i = 0; i < 24; i++) {
|
||||
if (i < 10)
|
||||
c.append($("<option></option>").val("0" + i).text("0" + i))
|
||||
else
|
||||
c.append($("<option></option>").val(i).text(i))
|
||||
}
|
||||
c = $('#dialogadd_timeminute');
|
||||
for (var i = 0; i < 60; i++) {
|
||||
if (i < 10)
|
||||
c.append($("<option></option>").val("0" + i).text("0" + i))
|
||||
else
|
||||
c.append($("<option></option>").val(i).text(i))
|
||||
}
|
||||
c = $('#dialogenginehours_timehour');
|
||||
for (var i = 0; i < 24; i++) {
|
||||
if (i < 10)
|
||||
c.append($("<option></option>").val("0" + i).text("0" + i))
|
||||
else
|
||||
c.append($("<option></option>").val(i).text(i))
|
||||
}
|
||||
c = $('#dialogenginehours_timeminute');
|
||||
for (var i = 0; i < 60; i++) {
|
||||
if (i < 10)
|
||||
c.append($("<option></option>").val("0" + i).text("0" + i))
|
||||
else
|
||||
c.append($("<option></option>").val(i).text(i))
|
||||
}
|
||||
c = $('#dialogaddenginehours_timehour');
|
||||
for (var i = 0; i < 24; i++) {
|
||||
if (i < 10)
|
||||
c.append($("<option></option>").val("0" + i).text("0" + i))
|
||||
else
|
||||
c.append($("<option></option>").val(i).text(i))
|
||||
}
|
||||
c = $('#dialogaddenginehours_timeminute');
|
||||
for (var i = 0; i < 60; i++) {
|
||||
if (i < 10)
|
||||
c.append($("<option></option>").val("0" + i).text("0" + i))
|
||||
else
|
||||
c.append($("<option></option>").val(i).text(i))
|
||||
}
|
||||
}
|
||||
|
||||
function initTimeZone() {
|
||||
devicerequest("GetTimeZones", "", function (data) {
|
||||
if (data) {
|
||||
var sel = $("#dialogadjust_odometertimezone");
|
||||
sel.empty();
|
||||
var sel1 = $("#dialogadjust_enginehourstimezone");
|
||||
sel1.empty();
|
||||
var sel2 = $("#dialogadd_odometertimezone");
|
||||
sel2.empty();
|
||||
var sel3 = $("#dialogadd_enginehourstimezone");
|
||||
sel3.empty();
|
||||
if (data && data.length > 0) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
sel.append($("<option></option>").val(data[i].Key).text("(" + data[i].Value + ")" + data[i].Key).attr("offset", data[i].Tag1));
|
||||
sel1.append($("<option></option>").val(data[i].Key).text("(" + data[i].Value + ")" + data[i].Key).attr("offset", data[i].Tag1));
|
||||
sel2.append($("<option></option>").val(data[i].Key).text("(" + data[i].Value + ")" + data[i].Key).attr("offset", data[i].Tag1));
|
||||
sel3.append($("<option></option>").val(data[i].Key).text("(" + data[i].Value + ")" + data[i].Key).attr("offset", data[i].Tag1));
|
||||
}
|
||||
}
|
||||
sel.val("UTC");
|
||||
sel1.val("UTC");
|
||||
sel2.val("UTC");
|
||||
sel3.val("UTC");
|
||||
}
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
function getCustomerTimeZone() {
|
||||
assetrequest("GetCustomerTimeZone", contractorid, function (data) {
|
||||
if (data) {
|
||||
customertimezone = data.Key;
|
||||
customerdatetime = data.Value;
|
||||
|
||||
var datetime = customerdatetime.split(' ');
|
||||
var time = datetime[0];
|
||||
var st = datetime[1].split(':');
|
||||
var hours = st[0].length == 1 ? "0" + st[0] : st[0];
|
||||
var minutes = st[1];
|
||||
|
||||
$("#dialogadjust_odometertimezone").val(customertimezone);
|
||||
$("#dialogadd_odometertimezone").val(customertimezone);
|
||||
$('#dialogadjust_odometerdate').val(time);
|
||||
$('#dialogadjust_timehour').val(hours);
|
||||
$('#dialogadjust_timeminute').val(minutes);
|
||||
$('#dialogadd_odometerdate').val(time);
|
||||
$('#dialogadd_timehour').val(hours);
|
||||
$('#dialogadd_timeminute').val(minutes);
|
||||
|
||||
$("#dialogadjust_enginehourstimezone").val(customertimezone);
|
||||
$("#dialogadd_enginehourstimezone").val(customertimezone);
|
||||
$('#dialogenginehours_date').val(time);
|
||||
$('#dialogenginehours_timehour').val(hours);
|
||||
$('#dialogenginehours_timeminute').val(minutes);
|
||||
$('#dialogaddenginehours_date').val(time);
|
||||
$('#dialogaddenginehours_timehour').val(hours);
|
||||
$('#dialogaddenginehours_timeminute').val(minutes);
|
||||
}
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
/************************Set As Primary**************************************/
|
||||
var selectedDataSource = undefined;
|
||||
var selectedType;
|
||||
function openSetPrimary(type, datasource) {
|
||||
selectedDataSource = datasource;
|
||||
selectedType = type;
|
||||
|
||||
$('#dialogprimary_notes').val('');
|
||||
$('#dialog_setprimary .dialog-title span.title').text('Set As Primary');
|
||||
showmaskbg(true);
|
||||
$('#dialog_setprimary')
|
||||
.attr('act', 'add')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_setprimary').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_setprimary').width()) / 2
|
||||
})
|
||||
.showDialogfixed();
|
||||
$('#dialogprimary_notes').focus();
|
||||
}
|
||||
|
||||
function OnSetPrimary() {
|
||||
if (!selectedDataSource)
|
||||
return;
|
||||
|
||||
var item = {
|
||||
'Type': selectedType,
|
||||
'CustomerID': contractorid,
|
||||
'AssetID': machineid,
|
||||
'DataSource': selectedDataSource.DataSource,
|
||||
'SubSource': selectedDataSource.SubSource,
|
||||
'Notes': $('#dialogprimary_notes').val()
|
||||
};
|
||||
|
||||
showloading(true);
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
|
||||
devicerequest("ChangePrimaryDataSource", param, function (data) {
|
||||
showloading(false);
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, GetTextByKey("P_MA_SETASPRIMARY", 'Set As Primary'));
|
||||
} else {
|
||||
if (selectedType == 0) {
|
||||
getOdometers();
|
||||
getMachineInfo();
|
||||
}
|
||||
else if (selectedType == 1) {
|
||||
getEnineHours();
|
||||
getMachineInfo();
|
||||
}
|
||||
else if (selectedType == 2)
|
||||
getLocations();
|
||||
else if (selectedType == 3)
|
||||
getIdlehours();
|
||||
else if (selectedType == 4)
|
||||
getFueluseds();
|
||||
}
|
||||
|
||||
$('#dialog_setprimary').hideDialog();
|
||||
}, function (err) {
|
||||
console.log(err);
|
||||
showloading(false);
|
||||
showAlert(GetTextByKey("P_MA_FAILEDTOADJUSTDOMETERSETASPRIMARY", 'Failed to set as primary.'), GetTextByKey("P_MA_SETASPRIMARY", 'Set As Primary'));
|
||||
});
|
||||
}
|
444
Site/MachineDeviceManagement/js/assetother.js
Normal file
@ -0,0 +1,444 @@
|
||||
$(function () {
|
||||
InitJobSiteGridData();
|
||||
InitContactGridData();
|
||||
InitAssetGroupGridData();
|
||||
|
||||
$('#dialog_addmake').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
|
||||
$('#dialog_addmodel').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
|
||||
$('#dialog_assetduplicates').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
|
||||
$('#dialog_mergeasset').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
});
|
||||
|
||||
var activejobsitedata;
|
||||
function GetActiveJobsites() {
|
||||
devicerequest('GetActiveJobsites', contractorid, function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
if (data && data.length > 0) {
|
||||
activejobsitedata = data;
|
||||
SetJobSites(jobsitsata);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var contactdata;
|
||||
function GetContacts() {
|
||||
devicerequest('GetContacts', contractorid, function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
if (data && data.length > 0) {
|
||||
contactdata = data;
|
||||
SetContacts(contactids);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function SetJobSites(data) {
|
||||
if (!activejobsitedata)
|
||||
return;
|
||||
for (var i = 0; i < activejobsitedata.length; i++) {
|
||||
var js = activejobsitedata[i];
|
||||
js.OnSite = false;
|
||||
js.InJobSite = false;
|
||||
js.Sugguested = false;
|
||||
js.StatusText = "";
|
||||
if (data && data.length > 0) {
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var js1 = data[j];
|
||||
if (js.ID == js1.JobSiteID) {
|
||||
js.OnSite = js1.OnSite;
|
||||
js.InJobSite = js1.InJobSite;
|
||||
js.Sugguested = js1.Sugguested;
|
||||
if (js.InJobSite && !js.OnSite)
|
||||
js.StatusText = "Auto-Assigned";
|
||||
if (js.OnSite)
|
||||
js.StatusText = "Manually-Assigned";
|
||||
if (js.Sugguested && !js.InJobSite)
|
||||
js.StatusText = "Current Location";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ShowActiveJobSites(activejobsitedata);
|
||||
}
|
||||
|
||||
function SetContacts(ids) {
|
||||
if (!contactdata)
|
||||
return;
|
||||
for (var i = 0; i < contactdata.length; i++) {
|
||||
var contact = contactdata[i];
|
||||
contact.Assigned = false;
|
||||
if (ids && ids.length > 0) {
|
||||
for (var j = 0; j < ids.length; j++) {
|
||||
if (contact.IID == ids[j]) {
|
||||
contact.Assigned = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ShowContacts(contactdata);
|
||||
}
|
||||
|
||||
function ShowActiveJobSites(data) {
|
||||
var onsiterows = [];
|
||||
var injobsiterows = [];
|
||||
var sugguestedrows = [];
|
||||
var otherrows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
var fr = { Values: r };
|
||||
if (r.OnSite)
|
||||
onsiterows.push(fr)
|
||||
else if (r.InJobSite)
|
||||
injobsiterows.push(fr);
|
||||
else if (r.Sugguested)
|
||||
sugguestedrows.push(fr);
|
||||
else
|
||||
otherrows.push(fr);
|
||||
}
|
||||
|
||||
var rows = [];
|
||||
for (var i = 0; i < onsiterows.length; i++) {
|
||||
rows.push(onsiterows[i]);
|
||||
}
|
||||
for (var i = 0; i < injobsiterows.length; i++) {
|
||||
rows.push(injobsiterows[i]);
|
||||
}
|
||||
for (var i = 0; i < sugguestedrows.length; i++) {
|
||||
rows.push(sugguestedrows[i]);
|
||||
}
|
||||
for (var i = 0; i < otherrows.length; i++) {
|
||||
rows.push(otherrows[i]);
|
||||
}
|
||||
|
||||
grid_jobsitedt.sortDirection = -1;
|
||||
grid_jobsitedt.setData(rows);
|
||||
}
|
||||
|
||||
var grid_jobsitedt;
|
||||
function InitJobSiteGridData() {
|
||||
grid_jobsitedt = new GridView('#jobsitelist');
|
||||
grid_jobsitedt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'OnSite', caption: GetTextByKey("P_MA_ONSITE", "On Site"), valueIndex: 'OnSite', type: 3, css: { 'width': 60, 'text-align': 'center' } },
|
||||
{ name: 'Name', caption: GetTextByKey("P_MA_JOBSITENAME", "Jobsite Name"), valueIndex: 'Name', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'StatusText', caption: GetTextByKey("P_MA_ASSIGNMENT", "Assignment"), valueIndex: 'StatusText', css: { 'width': 120, 'text-align': 'left' } }
|
||||
];
|
||||
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.bgFilter = function (item) {
|
||||
if (item.OnSite || item.InJobSite || item.Sugguested)
|
||||
return 'silver';
|
||||
}
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
if (col.name === "OnSite") {
|
||||
col.events = {
|
||||
onchange: function () {
|
||||
inputChanged = true;
|
||||
jobsiteinputChanged = true;
|
||||
}
|
||||
};
|
||||
col.tooltip = GetTextByKey("P_MA_ONSITETITLE", "The On Site box should only be checked if the asset has a permanent assignment not based on location. Geofence and Jobsite Add/Remove will not be triggered if checked.");
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_jobsitedt.canMultiSelect = true;
|
||||
grid_jobsitedt.columns = columns;
|
||||
grid_jobsitedt.init();
|
||||
|
||||
grid_jobsitedt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_jobsitedt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ShowContacts(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
grid_contactdt.sortIndex = 0;//已选默认拍在前面
|
||||
grid_contactdt.sortDirection = -1;
|
||||
grid_contactdt.setData(rows);
|
||||
}
|
||||
|
||||
var grid_contactdt;
|
||||
function InitContactGridData() {
|
||||
grid_contactdt = new GridView('#contactlist');
|
||||
grid_contactdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'Assigned', caption: GetTextByKey("P_MA_ASSIGNED", "Assigned"), valueIndex: 'Assigned', type: 3, css: { 'width': 75, 'text-align': 'center' } },
|
||||
{ name: 'DisplayName', caption: GetTextByKey("P_MA_CONTACTNAME", "Contact Name"), valueIndex: 'DisplayName', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'ContactTypeName', caption: GetTextByKey("P_MA_CONTACTTYPE", "Contact Type"), valueIndex: 'ContactTypeName', css: { 'width': 100, 'text-align': 'left' } }
|
||||
];
|
||||
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;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
if (col.name === "Assigned") {
|
||||
col.events = {
|
||||
onchange: function () {
|
||||
inputChanged = true;
|
||||
}
|
||||
};
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_contactdt.canMultiSelect = false;
|
||||
grid_contactdt.columns = columns;
|
||||
grid_contactdt.init();
|
||||
|
||||
grid_contactdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_contactdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function reshowgrid() {
|
||||
setTimeout(function () {
|
||||
$("#jobsitelist").css("height", $(window).height() - $("#jobsitelist").offset().top - 10);
|
||||
grid_jobsitedt && grid_jobsitedt.resize();
|
||||
$("#contactlist").css("height", $(window).height() - $("#contactlist").offset().top - 10);
|
||||
grid_contactdt && grid_contactdt.resize();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/****** Groups******/
|
||||
var assetgroups
|
||||
var grid_assetgroups;
|
||||
function InitAssetGroupGridData() {
|
||||
grid_assetgroups = new GridView('#assetgrouplist');
|
||||
grid_assetgroups.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'Selected', caption: "", valueIndex: 'Selected', type: 3, css: { 'width': 30, 'text-align': 'center' } },
|
||||
{ name: 'GroupName', caption: GetTextByKey("P_MA_GROUPNAME", "Group Name"), valueIndex: 'GroupName', css: { 'width': 300, 'text-align': 'left' } }
|
||||
];
|
||||
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;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
if (col.name === "Selected") {
|
||||
col.events = {
|
||||
onchange: function () {
|
||||
inputChanged = true;
|
||||
}
|
||||
};
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_assetgroups.canMultiSelect = false;
|
||||
grid_assetgroups.columns = columns;
|
||||
grid_assetgroups.init();
|
||||
}
|
||||
|
||||
function GetMachineGroups() {
|
||||
$('#tbodymachinegroup').empty();
|
||||
devicerequest('GetMachineGroups', contractorid + String.fromCharCode(170) + "", function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
if (data && data.length > 0) {
|
||||
assetgroups = data;
|
||||
ShowMachineGroups(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function ShowMachineGroups() {
|
||||
var rows = [];
|
||||
for (var i = 0; i < assetgroups.length; i++) {
|
||||
var r = assetgroups[i];
|
||||
r.Selected = false
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
grid_assetgroups.setData(rows);
|
||||
}
|
||||
|
||||
function SetMachineGroups(ids) {
|
||||
if (!assetgroups)
|
||||
return;
|
||||
for (var i = 0; i < assetgroups.length; i++) {
|
||||
var group = assetgroups[i];
|
||||
group.Selected = false;
|
||||
if (ids && ids.length > 0) {
|
||||
for (var j = 0; j < ids.length; j++) {
|
||||
if (ids[j].toLowerCase() == group.GroupID.toLowerCase()) {
|
||||
group.Selected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
grid_assetgroups.reload();
|
||||
}
|
||||
|
||||
function reshowgroupgrid() {
|
||||
setTimeout(function () {
|
||||
$("#assetgrouplist").css("height", $(window).height() - $("#assetgrouplist").offset().top - 10);
|
||||
grid_assetgroups && grid_assetgroups.resize();
|
||||
});
|
||||
}
|
||||
|
||||
function OnAddMake() {
|
||||
showmaskbg(true);
|
||||
$('#dialog_addmake')
|
||||
.attr('act', 'add')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_addmake').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_addmake').width()) / 2
|
||||
})
|
||||
.showDialog();
|
||||
$('#dialog_makename').focus();
|
||||
}
|
||||
|
||||
function OnSaveMake() {
|
||||
var item = {
|
||||
'Name': $.trim($('#dialog_makename').val()),
|
||||
'AlterActiveName': $.trim($('#dialog_makename').val())
|
||||
};
|
||||
|
||||
var alerttitle = GetTextByKey("P_MA_ADDMAKE", "Add Make");
|
||||
item.ID = -1;
|
||||
|
||||
if (!item.Name || item.Name.length == 0) {
|
||||
showAlert(GetTextByKey("P_MA_MAKENAMEEMPTY", 'Make name cannot be empty.'), alerttitle);
|
||||
$('#dialog_makename').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
$("#addmakemask").show();
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
devicerequest("SaveMachineMake", param, function (data) {
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, alerttitle);
|
||||
$("#addmakemask").hide();
|
||||
} else {
|
||||
GetMachineMakes(item.Name);
|
||||
|
||||
$('#dialog_addmake').hideDialog();
|
||||
showmaskbg(false);
|
||||
$("#addmakemask").hide();
|
||||
}
|
||||
}, function (err) {
|
||||
showAlert(GetTextByKey("P_MA_FAILEDTOSAVEMAKE", 'Failed to save Make.'), alerttitle);
|
||||
$("#addmakemask").hide();
|
||||
});
|
||||
}
|
||||
|
||||
function OnAddModel() {
|
||||
showmaskbg(true);
|
||||
$('#dialog_addmodel')
|
||||
.attr('act', 'add')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_addmodel').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_addmodel').width()) / 2
|
||||
})
|
||||
.showDialog();
|
||||
$('#dialog_modelname').val("");
|
||||
$('#dialog_modelname').focus();
|
||||
$('#dialog_makeforaddmodel').val($('#dialog_make').val());
|
||||
$('#dialog_typeforaddmodel').dropdownVal("");
|
||||
}
|
||||
|
||||
function OnSaveModel() {
|
||||
var item = {
|
||||
'Name': $.trim($('#dialog_modelname').val()),
|
||||
'MakeID': $.trim($('#dialog_makeforaddmodel').val()),
|
||||
'TypeID': $.trim($('#dialog_typeforaddmodel').dropdownVal())
|
||||
};
|
||||
|
||||
var alerttitle = "Add Model";
|
||||
item.ID = -1;
|
||||
|
||||
if (!item.Name || item.Name.length == 0) {
|
||||
showAlert(GetTextByKey("P_MA_MODELNAMECANNOTBEEMPTY", 'Model name cannot be empty.'), alerttitle);
|
||||
$('#dialog_modelname').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
$("#addmodelmask").show();
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
devicerequest("SAVEMACHINEMODEL", param, function (data) {
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, alerttitle);
|
||||
$("#addmodelmask").hide();
|
||||
} else {
|
||||
GetMachineModels(item.MakeID, item.Name);
|
||||
$('#dialog_addmodel').hideDialog();
|
||||
$("#addmodelmask").hide();
|
||||
showmaskbg(false);
|
||||
}
|
||||
}, function (err) {
|
||||
showAlert(GetTextByKey("P_MA_FAILEDTOSAVEMODEL", 'Failed to save model.'), alerttitle);
|
||||
$("#addmodelmask").hide();
|
||||
});
|
||||
}
|
549
Site/MachineDeviceManagement/js/assetpm.js
Normal file
@ -0,0 +1,549 @@
|
||||
$(function () {
|
||||
InitPMGridData();
|
||||
|
||||
$('#dialog_pm').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function SetAssetItem(asset) {
|
||||
$("#dialog_pm").data("asset", asset);
|
||||
}
|
||||
|
||||
function showConfirmOKCancel(msg, title, fok, fcancel) {
|
||||
showmaskbg(true);
|
||||
_dialog.showConfirmOKCancel(msg, title, function (e) {
|
||||
showmaskbg(false);
|
||||
if (typeof fok === 'function') {
|
||||
fok(e);
|
||||
}
|
||||
}, function () {
|
||||
if (fcancel)
|
||||
fcancel();
|
||||
showmaskbg(false);
|
||||
});
|
||||
}
|
||||
|
||||
/****** PM******/
|
||||
var pmschedules
|
||||
var grid_pmschedules;
|
||||
function InitPMGridData() {
|
||||
grid_pmschedules = new GridView('#pmschedulelist');
|
||||
grid_pmschedules.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'Selected', caption: "", valueIndex: 'Selected', type: 3, css: { 'width': 30, 'text-align': 'center' } },
|
||||
{ name: 'PmScheduleName', caption: GetTextByKey("P_MA_SCHEDULENAME", "Schedule Name"), valueIndex: 'PmScheduleName', css: { 'width': 200, 'text-align': 'left' } },
|
||||
{ name: 'StartValue', caption: GetTextByKey("P_MA_INITIALSERVICEVALUE", "Initial Service Value"), valueIndex: 'StartValue', css: { 'width': 120, 'text-align': 'right' } },
|
||||
{ name: 'LastAlertTimeString', caption: GetTextByKey("P_MA_LASTSERVICEDATE", "Last Service Date"), valueIndex: 'LastAlertTimeString', css: { 'width': 120, 'text-align': 'left' } },
|
||||
{ name: 'ServiceName', caption: GetTextByKey("P_MA_LASTSERVICEPERFORMED", "Last Service Performed"), valueIndex: 'ServiceName', css: { 'width': 140, 'text-align': 'left' } }
|
||||
];
|
||||
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;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
if (col.name === "Selected") {
|
||||
col.events = {
|
||||
onchange: function () {
|
||||
if (this.Selected) {
|
||||
showSetPMDialog(this);
|
||||
this.Selected = false;//弹出对话框并取消勾选,因为此时机器并没有真正加入到计划,在对话框OK刷新列表
|
||||
grid_pmschedules.reload();
|
||||
}
|
||||
else {
|
||||
var item = this;
|
||||
var msg = GetTextByKey("P_MA_REMOVEASSETFROMSCHEDULE", "Do you want to remove this asset from the schedule?");
|
||||
if (item.UnMaintainedAlert && item.UnMaintainedAlert > 0) {
|
||||
var msg = GetTextByKey("P_MA_REMOVEASSETFROMSCHEDULE_TIPS", "Select OK below will result in the deletion of existing unassigned PM alerts for this asset.<br/> If you do not want those alerts deleted, select CANCEL and assign appropriate alerts to a maintenance record or work order in asset health prior to deletion/removal.");
|
||||
}
|
||||
showConfirmOKCancel(msg, GetTextByKey("P_MA_REMOVEASSET", 'Remove Asset'), function () {
|
||||
removeAssetFromPMSchedule(item);
|
||||
}, function () {
|
||||
item.Selected = true;
|
||||
grid_pmschedules.reload();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_pmschedules.canMultiSelect = false;
|
||||
grid_pmschedules.columns = columns;
|
||||
grid_pmschedules.init();
|
||||
}
|
||||
|
||||
function getAssetPMSchedules() {
|
||||
showLoading();
|
||||
assetrequest('GetPMSchedulesByAsset', machineid, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
if (data && data.length > 0) {
|
||||
pmschedules = data;
|
||||
ShowPMSchedules(data);
|
||||
}
|
||||
}, function () {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function ShowPMSchedules() {
|
||||
var rows = [];
|
||||
for (var i = 0; i < pmschedules.length; i++) {
|
||||
var r = pmschedules[i];
|
||||
if (r.PmScheduleType === "HM" || r.PmScheduleType === "PM")
|
||||
r.StartValue = r.StartHours;
|
||||
else if (r.PmScheduleType === "ADM" || r.PmScheduleType === "RDM")
|
||||
r.StartValue = r.StartOdometer;
|
||||
else
|
||||
r.StartValue = r.StartDateString;
|
||||
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
grid_pmschedules.setData(rows);
|
||||
}
|
||||
|
||||
function reshowpmgrid() {
|
||||
setTimeout(function () {
|
||||
$("#pmschedulelist").css("height", $(window).height() - $("#pmschedulelist").offset().top - 10);
|
||||
grid_pmschedules && grid_pmschedules.resize();
|
||||
});
|
||||
}
|
||||
|
||||
function addAssetToPMSchedule(item) {
|
||||
showLoading();
|
||||
assetrequest('AddAssetToPMSchedule', JSON.stringify(item), function (data) {
|
||||
hideLoading();
|
||||
if (data === "OK") {
|
||||
$('#dialog_pm').hideDialog();
|
||||
showmaskbg(false);
|
||||
getAssetPMSchedules();
|
||||
}
|
||||
else
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
}, function () {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function removeAssetFromPMSchedule(schedule) {
|
||||
var assetid = $("#dialog_pm").data("asset").ID;
|
||||
var scheduleid = schedule.PmScheduleID;
|
||||
showLoading();
|
||||
assetrequest('RemoveAssetFromPMSchedule', JSON.stringify([assetid, scheduleid]), function (data) {
|
||||
hideLoading();
|
||||
if (data === "OK") {
|
||||
//showAlert(data, 'Removed Successfully.');
|
||||
getAssetPMSchedules();
|
||||
}
|
||||
else
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
}, function () {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function showSetPMDialog(pmschedule) {
|
||||
showmaskbg(true);
|
||||
//$('#dialog_pm .dialog-title span.title').text('Set PM Schedule');
|
||||
if (pmschedule) {
|
||||
var contentctrl = $("#dialog_pm .dialog-content");
|
||||
contentctrl.empty();
|
||||
//scheduletype === "HM" || scheduletype === "RDM" || scheduletype === "TBM"
|
||||
if (pmschedule.PmScheduleType === "PM" || pmschedule.PmScheduleType === "ADM") {
|
||||
createAbsoluteContent(contentctrl, pmschedule);
|
||||
}
|
||||
else if (pmschedule.PmScheduleType === "HM" || pmschedule.PmScheduleType === "RDM") {
|
||||
createRelativeContent(contentctrl, pmschedule);
|
||||
}
|
||||
else if (pmschedule.PmScheduleType === "TBM") {
|
||||
createTBMContent(contentctrl, pmschedule);
|
||||
}
|
||||
}
|
||||
|
||||
$('#dialog_pm').css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_adjustenginehours').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_adjustenginehours').width()) / 2
|
||||
}).showDialogfixed();
|
||||
}
|
||||
|
||||
function createAbsoluteContent(contentctrl, pmschedule) {
|
||||
var text = GetTextByKey("P_MA_WHENWOULDYOULIKETHEFIRSTALERT", "When would you like the first alert?");
|
||||
contentctrl.append($("<span></span><br />").text(text));
|
||||
|
||||
var radio1 = $("<input type='radio' name='pm' checked='checked' />");
|
||||
contentctrl.append(radio1);
|
||||
|
||||
var tag = hasAvailableIntervals(pmschedule);
|
||||
if (tag)
|
||||
text = getFirstLineText(pmschedule);
|
||||
else
|
||||
text = GetTextByKey("P_MA_NOAVAILABLEINTERVALS", "No available intervals.");
|
||||
contentctrl.append($("<span></span><br />").text(text));
|
||||
|
||||
if (tag) {
|
||||
var radio2 = $("<input type='radio' name='pm' />");
|
||||
contentctrl.append(radio2);
|
||||
text = GetTextByKey("P_MA_ONEORMORESERVICESWASMISSEDALERTMEFOR", "One or more services was missed. Alert me for ");
|
||||
contentctrl.append($("<span></span>").text(text));
|
||||
var selInterval = $("<select></select>").prop("disabled", true);
|
||||
contentctrl.append(selInterval);
|
||||
contentctrl.append($("<span> </span>").text(GetTextByKey("P_MA_NOW", " now.")));
|
||||
|
||||
if (pmschedule.Intervals) {
|
||||
for (var i = 0; i < pmschedule.Intervals.length; i++) {
|
||||
var interval = pmschedule.Intervals[i];
|
||||
if (!interval.Recurring) continue;//暂不考虑非周期性Service
|
||||
selInterval.append($("<option></option>").val(interval.PmIntervalID).text(interval.ServiceName));
|
||||
}
|
||||
}
|
||||
|
||||
radio1.change(enableInput);
|
||||
radio2.change(enableInput);
|
||||
function enableInput() {
|
||||
if (radio1.prop("checked"))
|
||||
selInterval.prop("disabled", true);
|
||||
else
|
||||
selInterval.prop("disabled", false);
|
||||
}
|
||||
}
|
||||
|
||||
$("#btnSetPMSchedule").unbind().click(function () {
|
||||
var asset = $("#dialog_pm").data("asset");
|
||||
var item = {};
|
||||
item.AssetID = asset.ID;
|
||||
item.PmScheduleID = pmschedule.PmScheduleID;
|
||||
//item.PMType = pmschedule.PmScheduleType;
|
||||
|
||||
if (pmschedule.PmScheduleType === "PM")
|
||||
item.StartHours = asset.EngineHours;
|
||||
else {
|
||||
var unit = pmschedule.PmScheduleUom;
|
||||
var value = asset.Odometer;
|
||||
if (value > 0 && unit && asset.OdometerUnits
|
||||
&& unit.toLowerCase().charAt(0) != asset.OdometerUnits.toLowerCase().charAt(0)) {
|
||||
if (unit.toLowerCase().startsWith("m"))
|
||||
value = value * 0.6213712;
|
||||
else
|
||||
value = value / 0.6213712;
|
||||
}
|
||||
item.StartOdometer = Math.round(value);
|
||||
}
|
||||
|
||||
if (radio2 && radio2.prop("checked")) {
|
||||
item.SelectedIntervalID = selInterval.val();
|
||||
}
|
||||
|
||||
addAssetToPMSchedule(item);
|
||||
});
|
||||
}
|
||||
|
||||
function createRelativeContent(contentctrl, pmschedule) {
|
||||
var text = GetTextByKey("P_MA_WHENWOULDYOULIKETHEFIRSTALERT", "When would you like the first alert?");
|
||||
contentctrl.append($("<span></span><br />").text(text));
|
||||
|
||||
var radio1 = $("<input type='radio' name='pm' checked='checked' />");
|
||||
contentctrl.append(radio1);
|
||||
|
||||
var tag = hasAvailableIntervals(pmschedule);
|
||||
if (tag)
|
||||
text = getFirstLineText(pmschedule);
|
||||
else
|
||||
text = GetTextByKey("P_MA_NOAVAILABLEINTERVALS", "No available intervals.");
|
||||
contentctrl.append($("<span></span><br />").text(text));
|
||||
|
||||
if (tag) {
|
||||
var radio2 = $("<input type='radio' name='pm' />");
|
||||
contentctrl.append(radio2);
|
||||
text = GetTextByKey("P_MA_CALCULATEBASEDUPONLASTSERVICETHE", "Calculate based upon last service. The ");
|
||||
contentctrl.append($("<span></span>").text(text));
|
||||
var selInterval = $("<select></select>").prop("disabled", true);
|
||||
contentctrl.append(selInterval);
|
||||
contentctrl.append($("<span></span>").text(GetTextByKey("P_MA_SERVICEWASPERFORMEDAT", " service was performed at ")));
|
||||
var txtStartValue = $("<input type='text' style='width:80px;' />").prop("disabled", true);
|
||||
contentctrl.append(txtStartValue);
|
||||
|
||||
if (pmschedule.AllIntervals) {
|
||||
var asset = $("#dialog_pm").data("asset");
|
||||
var value = 0;
|
||||
if (pmschedule.PmScheduleType === "HM")
|
||||
value = Math.round(asset.EngineHours);
|
||||
else
|
||||
value = Math.round(asset.Odometer);
|
||||
if (isNaN(value))
|
||||
value = 0;
|
||||
|
||||
var tempIntervals = getIntervalValues(value, pmschedule.AllIntervals);
|
||||
for (var i = 0; i < tempIntervals.length; i++) {
|
||||
var interval = tempIntervals[i];
|
||||
selInterval.append($("<option></option>").val(interval).text(interval));
|
||||
}
|
||||
//for (var i = 0; i < pmschedule.AllIntervals.length; i++) {
|
||||
// var interval = pmschedule.AllIntervals[i];
|
||||
// selInterval.append($("<option></option>").val(interval).text(interval));
|
||||
//}
|
||||
}
|
||||
|
||||
radio1.change(enableInput);
|
||||
radio2.change(enableInput);
|
||||
function enableInput() {
|
||||
if (radio1.prop("checked")) {
|
||||
txtStartValue.prop("disabled", true);
|
||||
selInterval.prop("disabled", true);
|
||||
}
|
||||
else {
|
||||
txtStartValue.prop("disabled", false);
|
||||
selInterval.prop("disabled", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$("#btnSetPMSchedule").unbind().click(function () {
|
||||
var asset = $("#dialog_pm").data("asset");
|
||||
var item = {};
|
||||
item.AssetID = asset.ID;
|
||||
item.PmScheduleID = pmschedule.PmScheduleID;
|
||||
//item.PMType = pmschedule.PmScheduleType;
|
||||
if (radio1.prop("checked")) {
|
||||
if (pmschedule.PmScheduleType === "HM")
|
||||
item.StartHours = asset.EngineHours;
|
||||
else {
|
||||
var unit = pmschedule.PmScheduleUom;
|
||||
var value = asset.Odometer;
|
||||
if (value > 0 && unit && asset.OdometerUnits
|
||||
&& unit.toLowerCase().charAt(0) != asset.OdometerUnits.toLowerCase().charAt(0)) {
|
||||
if (unit.toLowerCase().startsWith("m"))
|
||||
value = value * 0.6213712;
|
||||
else
|
||||
value = value / 0.6213712;
|
||||
}
|
||||
item.StartOdometer = Math.round(value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (pmschedule.PmScheduleType === "HM") {
|
||||
item.StartHours = txtStartValue.val();
|
||||
if (item.StartHours === "" || isNaN(item.StartHours))
|
||||
item.StartHours = asset.EngineHours;
|
||||
}
|
||||
else {
|
||||
item.StartOdometer = txtStartValue.val();
|
||||
if (item.StartOdometer === "" || isNaN(item.StartOdometer)) {
|
||||
var unit = pmschedule.PmScheduleUom;
|
||||
var value = asset.Odometer;
|
||||
if (value > 0 && unit && asset.OdometerUnits
|
||||
&& unit.toLowerCase().charAt(0) != asset.OdometerUnits.toLowerCase().charAt(0)) {
|
||||
if (unit.toLowerCase().startsWith("m"))
|
||||
value = value * 0.6213712;
|
||||
else
|
||||
value = value / 0.6213712;
|
||||
}
|
||||
item.StartOdometer = Math.round(value);
|
||||
}
|
||||
}
|
||||
|
||||
item.StartIntervalValue = selInterval.val();
|
||||
}
|
||||
|
||||
addAssetToPMSchedule(item);
|
||||
});
|
||||
}
|
||||
|
||||
function createTBMContent(contentctrl, pmschedule) {
|
||||
var text = GetTextByKey("P_MA_WHENWOULDYOULIKETHEFIRSTALERT", "When would you like the first alert?");
|
||||
contentctrl.append($("<span></span><br />").text(text));
|
||||
|
||||
var radio1 = $("<input type='radio' name='pm' checked='checked' />");
|
||||
contentctrl.append(radio1);
|
||||
|
||||
var tag = hasAvailableIntervals(pmschedule);
|
||||
if (tag)
|
||||
text = GetTextByKey("P_MA_TRIGGERANALERTASIFSERVICEISDUETODAY", "Trigger an alert as if service is due today.");
|
||||
else
|
||||
text = GetTextByKey("P_MA_NOAVAILABLEINTERVALS", "No available intervals.");
|
||||
contentctrl.append($("<span></span><br />").text(text));
|
||||
|
||||
if (tag) {
|
||||
var radio2 = $("<input type='radio' name='pm' />");
|
||||
contentctrl.append(radio2);
|
||||
text = GetTextByKey("P_MA_CALCULATEBASEDUPONLASTSERVICETHELASTSERVICEDATAWAS", "Calculate based upon last service. The last service date was ");
|
||||
contentctrl.append($("<span></span>").text(text));
|
||||
|
||||
var dateparent = $("<span></span>");
|
||||
contentctrl.append(dateparent);
|
||||
var txtLastServiceDate = $("<input type='text' style='width:80px;' />").prop("disabled", true);
|
||||
txtLastServiceDate.datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false
|
||||
}).text(currentdate);
|
||||
dateparent.append(txtLastServiceDate);
|
||||
|
||||
contentctrl.append($("<span></span>").text(GetTextByKey("P_MA_FOR", " for ")));
|
||||
var selInterval = $("<select></select>").prop("disabled", true);
|
||||
contentctrl.append(selInterval);
|
||||
|
||||
if (pmschedule.Intervals) {
|
||||
for (var i = 0; i < pmschedule.AllIntervals.length; i++) {
|
||||
var interval = pmschedule.AllIntervals[i];
|
||||
selInterval.append($("<option></option>").val(interval).text(interval));
|
||||
}
|
||||
}
|
||||
|
||||
radio1.change(enableInput);
|
||||
radio2.change(enableInput);
|
||||
function enableInput() {
|
||||
if (radio1.prop("checked")) {
|
||||
txtLastServiceDate.prop("disabled", true);
|
||||
selInterval.prop("disabled", true);
|
||||
}
|
||||
else {
|
||||
txtLastServiceDate.prop("disabled", false);
|
||||
selInterval.prop("disabled", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$("#btnSetPMSchedule").unbind().click(function () {
|
||||
var asset = $("#dialog_pm").data("asset");
|
||||
var item = {};
|
||||
item.AssetId = asset.ID;
|
||||
item.PmScheduleID = pmschedule.PmScheduleID;
|
||||
//item.PMType = pmschedule.PmScheduleType;
|
||||
if (radio1.prop("checked")) {
|
||||
item.StartDate = nowdate;
|
||||
}
|
||||
else {
|
||||
item.StartDate = txtLastServiceDate.val();
|
||||
item.StartIntervalValue = selInterval.val();
|
||||
if (item.StartDate == "")
|
||||
item.StartDate = "1900-01-01";
|
||||
}
|
||||
|
||||
addAssetToPMSchedule(item);
|
||||
});
|
||||
}
|
||||
|
||||
function hasAvailableIntervals(pmschedule) {
|
||||
if (!pmschedule.Intervals || pmschedule.Intervals.length == 0)
|
||||
return false;
|
||||
|
||||
for (var i = 0; i < pmschedule.Intervals.length; i++) {
|
||||
var ii = pmschedule.Intervals[i];
|
||||
if (ii.Recurring)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getIntervalValues(currentValue, allIntervals) {
|
||||
var result = [];//取当前值的前两个和后10个Interval
|
||||
if (allIntervals && allIntervals.length > 0) {
|
||||
var maxInterval = allIntervals[allIntervals.length - 1];
|
||||
var pervoid = parseInt(currentValue / maxInterval);
|
||||
var remain = currentValue % maxInterval;
|
||||
if (remain > 0)
|
||||
pervoid++;
|
||||
var maxpervoid = pervoid + 1;
|
||||
var minpervoid = pervoid - Math.ceil(10 / allIntervals.length) - 1;//10表示向后取10
|
||||
if (minpervoid < 0)
|
||||
minpervoid = 0;
|
||||
|
||||
for (var pi = maxpervoid; pi >= minpervoid; pi--) {
|
||||
for (var i = allIntervals.length - 1; i >= 0; i--) {
|
||||
var interval = allIntervals[i];
|
||||
var tempinterval = pi * maxInterval + interval;
|
||||
result.push(tempinterval);
|
||||
if (tempinterval >= currentValue) {
|
||||
if (result.length > 2)
|
||||
result.splice(0, 1);
|
||||
}
|
||||
else if (result.length == 12)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function getFirstLineText(pmschedule) {
|
||||
var text = "";
|
||||
if (pmschedule.Intervals && pmschedule.Intervals.length > 0) {
|
||||
var asset = $("#dialog_pm").data("asset");
|
||||
var unit = "";
|
||||
var value = 0;
|
||||
if (pmschedule.PmScheduleType === "PM" || pmschedule.PmScheduleType === "HM") {
|
||||
unit = "hours";
|
||||
value = Math.round(asset.EngineHours);
|
||||
}
|
||||
else {
|
||||
unit = pmschedule.PmScheduleUom;
|
||||
value = asset.Odometer;
|
||||
if (value > 0 && unit && asset.OdometerUnits
|
||||
&& unit.toLowerCase().charAt(0) != asset.OdometerUnits.toLowerCase().charAt(0)) {
|
||||
if (unit.toLowerCase().startsWith("m"))
|
||||
value = value * 0.6213712;
|
||||
else
|
||||
value = value / 0.6213712;
|
||||
value = Math.round(value);
|
||||
}
|
||||
}
|
||||
if (isNaN(value))
|
||||
value = 0;
|
||||
|
||||
var minoffset = null;
|
||||
var nextInterval = null;
|
||||
for (var i = 0; i < pmschedule.Intervals.length; i++) {
|
||||
var ii = pmschedule.Intervals[i];
|
||||
if (!ii.Recurring) continue;//暂不考虑非周期性Service
|
||||
|
||||
var offset = 0;
|
||||
if (value == 0)
|
||||
offset = ii.Interval;
|
||||
else if (value % ii.Interval > 0)
|
||||
offset = ii.Interval - value % ii.Interval;
|
||||
|
||||
if (!nextInterval || offset < minoffset) {
|
||||
nextInterval = ii;
|
||||
minoffset = offset;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (offset == minoffset && (ii.Priority < nextInterval.Priority
|
||||
|| (ii.Priority == nextInterval.Priority && ii.Interval > nextInterval.Interval)))
|
||||
nextInterval = ii;
|
||||
}
|
||||
|
||||
if (nextInterval) {
|
||||
text = GetTextByKey("P_MA_THEFIRSTALERTWILLBE", "The first alert will be ");
|
||||
text += nextInterval.NotificationPeriod + " " + unit;
|
||||
if (value != 0 && value % nextInterval.Interval == 0)
|
||||
parseInt(value / nextInterval.Interval) * nextInterval.Interval
|
||||
else
|
||||
value = (parseInt(value / nextInterval.Interval) + 1) * nextInterval.Interval;
|
||||
|
||||
text += GetTextByKey("P_MA_BEFORETHEASSETREADING", " before the asset reading ") + value + " " + unit;
|
||||
text += GetTextByKey("P_MA_FOR", " for ") + nextInterval.ServiceName + ".";
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
303
Site/MachineDeviceManagement/js/attachment.js
Normal file
@ -0,0 +1,303 @@
|
||||
$(function () {
|
||||
$('#dialog_adddocument').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
});
|
||||
|
||||
function setPreviewAttachment() {
|
||||
filedata = undefined;
|
||||
$("#tbAssetAttas").empty();
|
||||
$('#tr_document_file').hide();
|
||||
$('#browseattfile').hide();
|
||||
}
|
||||
|
||||
function getAttachments(machineid) {
|
||||
$('#tbody_documents').empty();
|
||||
if (!machineid) return;
|
||||
|
||||
showLoading();
|
||||
|
||||
devicerequest("GetAttachments", contractorid + String.fromCharCode(170) + machineid, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
var attdata = [];
|
||||
if (data && data.length > 0) {
|
||||
attdata = data;
|
||||
}
|
||||
else
|
||||
attdata = [];
|
||||
|
||||
sortTableData($('#tbdocuments'), attdata);
|
||||
showAttachments(attdata);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function onEditDocument() {
|
||||
var doc = $(this).data('document');
|
||||
if (!doc)
|
||||
doc = $(this).parents("tr").data('document');
|
||||
openAddDocument(doc);
|
||||
}
|
||||
|
||||
function openDocumentUrl() {
|
||||
var doc = $(this).parents("tr").data('document');
|
||||
window.open(doc.Url);
|
||||
}
|
||||
|
||||
|
||||
function showAttachments(data) {
|
||||
var trs = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var doc = data[i];
|
||||
var tr = $('<tr></tr>').data('document', doc).dblclick(onEditDocument);
|
||||
var span = $('<span style="cursor:pointer;"></span>').text(doc.Name).attr('title', doc.Name).click(openDocumentUrl);
|
||||
tr.append($('<td class="machinetd" style="width: 120px;"></td>').append(span));
|
||||
tr.append($('<td class="machinetd" style="width: 100px;"></td>').text(doc.AddedBy).attr('title', doc.AddedBy));
|
||||
tr.append($('<td class="machinetd" style="width: 80px;"></td>').text(doc.VisibleOnWorkOrder ? "Yes" : "No"));
|
||||
tr.append($('<td class="machinetd" style="width: 80px;"></td>').text(doc.VisibleOnMap ? "Yes" : "No"));
|
||||
tr.append($('<td class="machinetd" style="width: 80px;"></td>').text(doc.VisibleOnMobile ? "Yes" : "No"));
|
||||
tr.append($('<td class="machinetd" style="width: 100px;"></td>').text(doc.AddedOnLocalStr).attr('title', doc.AddedOnLocalStr));
|
||||
tr.append($('<td class="machinetd" style="width: 200px;"></td>').html(replaceHtmlText(doc.Description)).attr('title', doc.Description));
|
||||
var spview = $('<span class="button_document iconview" title="' + GetTextByKey('P_MA_VIEW', 'View') + '"></span>').click(openDocumentUrl);
|
||||
var spedit = $('<span class="button_document iconedit" title="' + GetTextByKey('P_MA_EDIT', 'Edit') + '"></span>').click(onEditDocument);
|
||||
var spdel = $('<span class="button_document icondelete" title="' + GetTextByKey('P_MA_DELETE', 'Delete') + '"></span>').click(onDeleteDocument);;
|
||||
tr.append($('<td class="machinetd" style="width: 80px;"></td>').append(spview).append(spedit).append(spdel));
|
||||
|
||||
trs.push(tr);
|
||||
}
|
||||
|
||||
$('#tbody_documents').append(trs);
|
||||
}
|
||||
|
||||
var assetdocumentid;
|
||||
function openAddDocument(doc) {
|
||||
setPreviewAttachment();
|
||||
if (doc) {
|
||||
assetdocumentid = doc.Id;
|
||||
$('#tr_document_radio').hide();
|
||||
$('#dialog_adddoc_name').val(doc.Name);
|
||||
$('#dialog_adddoc_desc').val(doc.Description);
|
||||
$('#dialog_visibleonwo').prop('checked', doc.VisibleOnWorkOrder);
|
||||
$('#dialog_visibleonmap').prop('checked', doc.VisibleOnMap);
|
||||
$('#dialog_visibleonmobile').prop('checked', doc.VisibleOnMobile);
|
||||
if (doc.FileType.toLowerCase() === "url") {
|
||||
$('#dialog_rdourl').prop('checked', true);
|
||||
$('#dialog_adddoc_url').attr("disabled", true);
|
||||
$('#dialog_adddoc_url').val(doc.Url);
|
||||
$('#tr_document_url').show();
|
||||
|
||||
} else {
|
||||
$('#dialog_rdofile').prop('checked', true);
|
||||
$('#tr_document_url').hide();
|
||||
}
|
||||
}
|
||||
else {
|
||||
assetdocumentid = undefined;
|
||||
$('#dialog_adddoc_url').attr("disabled", false);
|
||||
$('#tr_document_url').show();
|
||||
$('#tr_document_radio').show();
|
||||
|
||||
$('#dialog_adddoc_name').val('');
|
||||
$('#dialog_adddoc_url').val('');
|
||||
$('#dialog_adddoc_desc').val('');
|
||||
$('#dialog_rdourl').prop('checked', true);
|
||||
$('#dialog_visibleonwo').attr("checked", false);
|
||||
$('#dialog_visibleonmap').attr("checked", false);
|
||||
$('#dialog_visibleonmobile').attr("checked", false);
|
||||
}
|
||||
$('#dialog_adddocument .dialog-title span.title').text(GetTextByKey("P_MA_ADDITIONALDOCUMENTATION", 'Additional Documentation'));
|
||||
showmaskbg(true);
|
||||
$('#dialog_adddocument')
|
||||
.attr('act', 'add')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_adddocument').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_adddocument').width()) / 2
|
||||
})
|
||||
.showDialogfixed();
|
||||
$('#dialog_adddoc_name').focus();
|
||||
}
|
||||
|
||||
var filedata;
|
||||
function BrowseAssetDocument() {
|
||||
var file = $('<input type="file" style="display: none;" multiple="multiple" />');
|
||||
file.change(function () {
|
||||
var files = this.files;
|
||||
var file = files[0];
|
||||
if (file.size == 0) {
|
||||
alert(GetTextByKey("P_MA_DOCUMENTTIPS", "Document size is 0kb, uploading failed."));
|
||||
return false;
|
||||
}
|
||||
if (file.size > 50 * 1024 * 1024) {
|
||||
alert(GetTextByKey("P_MA_DOCUMENTTIPS1", "Document is too large. Maximum file size is 50 MB."));
|
||||
return false;
|
||||
}
|
||||
filedata = file;
|
||||
if ($('#dialog_adddoc_name').val() === "")
|
||||
$('#dialog_adddoc_name').val(file.name);
|
||||
|
||||
$('#tbAssetAttas').empty();
|
||||
var trrecoard = $('<tr></tr>').data('file', file);
|
||||
var tdfile = $('<td style=""></td>');
|
||||
var filename = $("<label style='border-bottom: 1px solid;cursor:pointer;word-break: break-all;'></label>").text(file.name).click(function () {
|
||||
//window.open("../filesvc.ashx?attchid=" + this.parentElement.parentElement.id + "&sourceType=assetattachment");
|
||||
});
|
||||
var imgDom = $('<span class="sbutton icondelete" style="padding:0;margin-left:5px;" ></span>').click(function () {
|
||||
deletePreviewAssetAttachment(this);
|
||||
});
|
||||
|
||||
tdfile.append(filename, imgDom);
|
||||
trrecoard.append(tdfile).appendTo($('#tbAssetAttas'));
|
||||
|
||||
}).click();
|
||||
}
|
||||
|
||||
function deletePreviewAssetAttachment(e) {
|
||||
filedata = undefined;
|
||||
var tr = $(e).parent().parent();
|
||||
$(tr).remove();
|
||||
}
|
||||
|
||||
function OnSaveDocument() {
|
||||
if (!machineid) {
|
||||
OnSave(0, false, function () {
|
||||
SaveAssetDocument(filedata);
|
||||
});
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (!assetdocumentid)
|
||||
SaveAssetDocument(filedata);
|
||||
else
|
||||
UpdateAssetDocument();
|
||||
}
|
||||
}
|
||||
|
||||
function SaveAssetDocument(file) {
|
||||
$('#adddocumentmask').show();
|
||||
var alerttitle = GetTextByKey("P_MA_ADDITIONALDOCUMENTATION", 'Additional Documentation');
|
||||
var item = {
|
||||
'CustomerID': contractorid,
|
||||
'AssetID': machineid,
|
||||
'Name': $('#dialog_adddoc_name').val(),
|
||||
'VisibleOnWorkOrder': $('#dialog_visibleonwo').is(':checked'),
|
||||
'VisibleOnMap': $('#dialog_visibleonmap').is(':checked'),
|
||||
'VisibleOnMobile': $('#dialog_visibleonmobile').is(':checked'),
|
||||
'Description': $('#dialog_adddoc_desc').val()
|
||||
};
|
||||
|
||||
if (item.Name === "") {
|
||||
showAlert(GetTextByKey("P_MA_NAMECANNOTBEEMPTY", 'Name cannot be empty.'), alerttitle);
|
||||
$('#adddocumentmask').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
var type = $('input[name="rdoattachmentmode"]:checked').val();
|
||||
if (type === "0") {
|
||||
item.FileType = "URL";
|
||||
item.Url = $('#dialog_adddoc_url').val();
|
||||
if (item.Url === "") {
|
||||
showAlert(GetTextByKey("P_MA_URLCANNOTBEEMPTY", 'Url cannot be empty.'), alerttitle);
|
||||
$('#adddocumentmask').hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!file) {
|
||||
showAlert(GetTextByKey("P_MA_FILECANNOTBEEMPTY", 'File cannot be empty.'), alerttitle);
|
||||
$('#adddocumentmask').hide();
|
||||
return;
|
||||
}
|
||||
item.FileType = file.name.substring(file.name.lastIndexOf("."));
|
||||
}
|
||||
|
||||
showloading(true);
|
||||
var formData = new FormData();
|
||||
formData.append("iconFile", file);
|
||||
formData.append("MethodName", "UploadAssetDocument");
|
||||
formData.append("ClientData", htmlencode(JSON.stringify(item)));
|
||||
$.ajax({
|
||||
url: 'ManageMachines.aspx',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
data: formData,
|
||||
async: true,
|
||||
success: function (data) {
|
||||
showloading(false);
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, alerttitle);
|
||||
} else {
|
||||
getAttachments(machineid);
|
||||
}
|
||||
$('#dialog_adddocument').hideDialog();
|
||||
$('#adddocumentmask').hide();
|
||||
},
|
||||
error: function (err) {
|
||||
showloading(false);
|
||||
showAlert(err.statusText, alerttitle);
|
||||
$('#adddocumentmask').hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function UpdateAssetDocument() {
|
||||
$('#adddocumentmask').show();
|
||||
var item = {
|
||||
'Id': assetdocumentid,
|
||||
'CustomerID': contractorid,
|
||||
'Name': $('#dialog_adddoc_name').val(),
|
||||
'VisibleOnWorkOrder': $('#dialog_visibleonwo').is(':checked'),
|
||||
'VisibleOnMap': $('#dialog_visibleonmap').is(':checked'),
|
||||
'VisibleOnMobile': $('#dialog_visibleonmobile').is(':checked'),
|
||||
'Description': $('#dialog_adddoc_desc').val()
|
||||
};
|
||||
|
||||
if (item.Name === "") {
|
||||
showAlert(GetTextByKey("P_MA_NAMECANNOTBEEMPTY", 'Name cannot be empty.'), alerttitle);
|
||||
$('#adddocumentmask').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
showloading(true);
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
devicerequest("UpdateAssetDocument", param, function (data) {
|
||||
showloading(false);
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, GetTextByKey("P_MA_ADDITIONALDOCUMENTATION", 'Additional Documentation'));
|
||||
} else {
|
||||
getAttachments(machineid);
|
||||
}
|
||||
$('#dialog_adddocument').hideDialog();
|
||||
$('#adddocumentmask').hide();
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
showAlert(err.statusText, GetTextByKey("P_MA_ADDITIONALDOCUMENTATION", 'Additional Documentation'));
|
||||
$('#adddocumentmask').hide();
|
||||
});
|
||||
}
|
||||
|
||||
function onDeleteDocument() {
|
||||
var alerttitle = GetTextByKey("P_MA_DELETEDOCUMENTATION", "Delete Documentation");
|
||||
var doc = $(this).parents("tr").data('document');
|
||||
showConfirm(GetTextByKey("P_MA_DELETEDOCUMENTTTIPS", 'Are you sure you want to delete the document?'), alerttitle, function () {
|
||||
devicerequest("DeleteAttachment", contractorid + String.fromCharCode(170) + doc.Id, function (data) {
|
||||
if (data !== 'OK')
|
||||
showAlert(data, alerttitle);
|
||||
else
|
||||
getAttachments(machineid);
|
||||
}, function (err) {
|
||||
showAlert(GetTextByKey("P_MA_FAILEDDELETEDOCUMENT", 'Failed to delete this document.'), alerttitle);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function viewAttachment(attid) {
|
||||
window.open("../filesvc.ashx?attchid=" + attid + "&custid=" + contractorid + "&sourceType=assetattachment");
|
||||
}
|
114
Site/MachineDeviceManagement/js/attachmentInfo.js
Normal file
@ -0,0 +1,114 @@
|
||||
|
||||
var dialogAttachToAssets;
|
||||
$(function () {
|
||||
dialogAttachToAssets = new $assetselector('dialog_machines');
|
||||
dialogAttachToAssets.forceSingle = true;
|
||||
dialogAttachToAssets.onDialogClosed = function () {
|
||||
showmaskbg(false);
|
||||
};
|
||||
dialogAttachToAssets.onOK = function (source, selectedIndex) {
|
||||
var selectedAsset = null;
|
||||
if (selectedIndex >= 0)
|
||||
selectedAsset = source[selectedIndex].Values;
|
||||
|
||||
$("#dialog_attachtoasset").val(selectedAsset.Name).data("AttachedtoAssetId", selectedAsset.MachineID ? selectedAsset.MachineID : selectedAsset.Id);
|
||||
inputChanged = true;
|
||||
showmaskbg(false);
|
||||
};
|
||||
$("#btnSelectAttachToAsset").click(function () {
|
||||
showmaskbg(true);
|
||||
dialogAttachToAssets.companyId = $('#sel_contractor').val();
|
||||
dialogAttachToAssets.showSelector(3, true);//与mergeasset中的showSelector冲突,需设置force
|
||||
});
|
||||
|
||||
$("#btnUnattach").click(function () {
|
||||
$("#dialog_attachtoasset").val("").data("AttachedtoAssetId", null);
|
||||
inputChanged = true;
|
||||
});
|
||||
});
|
||||
|
||||
function getAssetAttachmentInfo(machineid) {
|
||||
showAssetAttachmentInfo(null);
|
||||
if (!machineid) return;
|
||||
|
||||
showLoading();
|
||||
assetrequest("GetAssetAttachmentInfo", contractorid + String.fromCharCode(170) + machineid, function (data) {
|
||||
hideLoading();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
|
||||
showAssetAttachmentInfo(data);
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function showAssetAttachmentInfo(attachinfo) {
|
||||
if (attachinfo) {
|
||||
$("#dialog_assettypetoattachto").val(attachinfo.AssetTypeToAttachTo);
|
||||
$("#dialog_attachstyle").val(attachinfo.Style);
|
||||
$("#dialog_attachcapacitycyd").val(attachinfo.Capacity_CYD);
|
||||
$("#dialog_attachcapacityweight").val(attachinfo.Capacity_Weight);
|
||||
$("#dialog_attachdimension1").val(attachinfo.Dimension1);
|
||||
$("#dialog_attachdimension2").val(attachinfo.Dimension2);
|
||||
$("#dialog_attacholdnumber").val(attachinfo.OldNumber);
|
||||
$("#dialog_attachtomake").val(attachinfo.AttachToMake);
|
||||
$("#dialog_attachtomodel").val(attachinfo.AttachToModel);
|
||||
$("#dialog_attachedtoanasset").val(attachinfo.AttachedtoAsset ? "1" : "0");
|
||||
$("#dialog_attachtoasset").val(attachinfo.AttachedtoAssetName).data("AttachedtoAssetId", attachinfo.AttachedtoAssetId);
|
||||
}
|
||||
else {
|
||||
$("#dialog_assettypetoattachto").val("");
|
||||
$("#dialog_attachstyle").val("");
|
||||
$("#dialog_attachcapacitycyd").val("");
|
||||
$("#dialog_attachcapacityweight").val("");
|
||||
$("#dialog_attachdimension1").val("");
|
||||
$("#dialog_attachdimension2").val("");
|
||||
$("#dialog_attacholdnumber").val("");
|
||||
$("#dialog_attachtomake").val("");
|
||||
$("#dialog_attachtomodel").val("");
|
||||
$("#dialog_attachedtoanasset").val("");
|
||||
$("#dialog_attachtoasset").val("").data("AttachedtoAssetId", null);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function getAssetAttachmentInfoInput(alerttitle) {
|
||||
var attachinfo = {};
|
||||
attachinfo.AssetTypeToAttachTo = $("#dialog_assettypetoattachto").val();
|
||||
attachinfo.Style = $("#dialog_attachstyle").val();
|
||||
attachinfo.Capacity_CYD = $("#dialog_attachcapacitycyd").val();
|
||||
var formattedcorrectly = GetTextByKey("P_MA_ISNOTFORMATTEDCORRECTLY", ' is not formatted correctly.');
|
||||
if (attachinfo.Capacity_CYD !== "" && (isNaN(attachinfo.Capacity_CYD) || !IsNumber.test(attachinfo.Capacity_CYD))) {
|
||||
showAlert(GetTextByKey("P_MA_CAPACITYCYD", 'Capacity (CYD)') + formattedcorrectly, alerttitle);
|
||||
return false;
|
||||
}
|
||||
attachinfo.Capacity_Weight = $("#dialog_attachcapacityweight").val();
|
||||
if (attachinfo.Capacity_Weight !== "" && (isNaN(attachinfo.Capacity_Weight) || !IsNumber.test(attachinfo.Capacity_Weight))) {
|
||||
showAlert(GetTextByKey("P_MA_CAPACITYWEIGHT", 'Capacity (Weight)') + formattedcorrectly, alerttitle);
|
||||
return false;
|
||||
}
|
||||
attachinfo.Dimension1 = $("#dialog_attachdimension1").val();
|
||||
if (attachinfo.Dimension1 !== "" && (isNaN(attachinfo.Dimension1) || !IsNumber.test(attachinfo.Dimension1))) {
|
||||
showAlert(GetTextByKey("P_MA_DIMENSION1INCM", 'Dimension #1 (in/cm)') + formattedcorrectly, alerttitle);
|
||||
return false;
|
||||
}
|
||||
attachinfo.Dimension2 = $("#dialog_attachdimension2").val();
|
||||
if (attachinfo.Dimension2 !== "" && (isNaN(attachinfo.Dimension2) || !IsNumber.test(attachinfo.Dimension2))) {
|
||||
showAlert(GetTextByKey("P_MA_WIDTH", 'Width') + formattedcorrectly, alerttitle);
|
||||
return false;
|
||||
}
|
||||
attachinfo.OldNumber = $("#dialog_attacholdnumber").val();
|
||||
if (attachinfo.OldNumber !== "" && (isNaN(attachinfo.OldNumber) || !IsNumber.test(attachinfo.OldNumber))) {
|
||||
showAlert(GetTextByKey("P_MA_OLDNUMBER", 'Old Number') + formattedcorrectly, alerttitle);
|
||||
return false;
|
||||
}
|
||||
attachinfo.AttachToMake = $("#dialog_attachtomake").val();
|
||||
attachinfo.AttachToModel = $("#dialog_attachtomodel").val();
|
||||
attachinfo.AttachedtoAsset = $("#dialog_attachedtoanasset").val() == "1";
|
||||
attachinfo.AttachedtoAssetId = $("#dialog_attachtoasset").data("AttachedtoAssetId");
|
||||
|
||||
return attachinfo;
|
||||
}
|
188
Site/MachineDeviceManagement/js/attribute.js
Normal file
@ -0,0 +1,188 @@
|
||||
|
||||
|
||||
var MachineAttributes = [];
|
||||
|
||||
|
||||
|
||||
function GetMachineAttributes(machineid) {
|
||||
if (!contractorid)
|
||||
contractorid = "";
|
||||
assetrequest('GetMachineAttributes', contractorid + String.fromCharCode(170) + machineid, function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
if (data && data.length > 0) {
|
||||
MachineAttributes = data;
|
||||
ShowMachineAttributes(data);
|
||||
}
|
||||
else
|
||||
MachineAttributes = [];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function ShowMachineAttributes(categorys) {
|
||||
//$('.li_attribute').remove();
|
||||
//$('.divtab').remove();
|
||||
$('.divtab').empty();
|
||||
|
||||
var ulcontainer = $('#ul_container');
|
||||
var divbefore = $('#tab_pm');
|
||||
var libefore = $('#li_attachmentinfo');
|
||||
|
||||
for (var j = 0; j < categorys.length; j++) {
|
||||
var cate = categorys[j];
|
||||
if (cate.TabID == 3) continue;//屏蔽Attachment Info
|
||||
var cateid = "category" + j;
|
||||
var tabid = "tab" + cate.TabID;
|
||||
|
||||
var divpage = $("#" + tabid);
|
||||
var tab = null;
|
||||
if (divpage.length == 0) {
|
||||
var li = $('<li class="li_attribute"></li>').text(cate.TabName).attr('data-href', tabid);
|
||||
libefore.after(li);
|
||||
divpage = $('<div class="divtab"></div>').attr('id', tabid).attr('data-page', tabid);
|
||||
divbefore.after(divpage);
|
||||
}
|
||||
|
||||
var tab = divpage.children().eq(0);
|
||||
if (tab.length == 0) {
|
||||
tab = $('<table></table>');
|
||||
divpage.append(tab);
|
||||
}
|
||||
|
||||
var tr = $("<tr></tr>");
|
||||
var tdcate = $('<td class="categoryname minus" colspan="2"></td>').text(" " + cate.DisplayText).data("cid", cateid).data("hide", 0);
|
||||
tdcate.click(tab, function (e) {
|
||||
var target = $(e.target);
|
||||
if (target.data("hide") == 0) {
|
||||
target.data("hide", 1);
|
||||
e.data.find("." + target.data("cid")).hide();
|
||||
target.removeClass("minus").addClass("plus");
|
||||
}
|
||||
else {
|
||||
target.data("hide", 0);
|
||||
e.data.find("." + target.data("cid")).show();
|
||||
target.removeClass("plus").addClass("minus");
|
||||
}
|
||||
});
|
||||
tr.append(tdcate);
|
||||
tab.append(tr);
|
||||
|
||||
var atts = cate.MachineAttributes;
|
||||
if (atts.length > 0) {
|
||||
for (var i = 0; i < atts.length; i++) {
|
||||
var att = atts[i];
|
||||
var tr = $("<tr></tr>").addClass(cateid);
|
||||
tr.append($('<td class="label"></td>').text(att.DisplayText + ":").attr("title", att.Description));
|
||||
var attributeid = "attributeid_" + att.ID;
|
||||
var input = $('<input type="text" />');
|
||||
if (att.DataType == 0) {
|
||||
if (att.Multiline)
|
||||
input = $('<textarea></textarea>');
|
||||
else if (att.Dropdown) {
|
||||
input = $('<select style="width:204px;"></select>');
|
||||
if (att.DataSource) {
|
||||
var sources = att.DataSource.split(';');
|
||||
for (var si in sources) {
|
||||
input.append($("<option value='" + sources[si] + "'>" + sources[si] + "</option >"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (att.DataType == 4) {
|
||||
$(input).datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
else if (att.DataType == 5)
|
||||
input = $('<select><option value="Yes">Yes</option ><option value="No">No</option></select>');
|
||||
|
||||
$(input).attr('id', 'attributeid_' + att.ID).attr('maxlength', att.Length);
|
||||
$(input).val(att.Value);
|
||||
$(input).change(function () {
|
||||
inputChanged = true;
|
||||
})
|
||||
var td1 = $('<td></td>');
|
||||
td1.append(input);
|
||||
tr.append(td1);
|
||||
tab.append(tr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$('#div_container').data("tabed")) {
|
||||
ulcontainer.append($('<li style="clear: both;"></li>'));
|
||||
$('#div_container').data("tabed", true);
|
||||
$('#div_container').tab();
|
||||
$(window).resize();
|
||||
|
||||
ulcontainer.find("li").click(function (e) {
|
||||
setRightMask($(e.target).attr("data-href"));
|
||||
});
|
||||
}
|
||||
setRightMask();
|
||||
}
|
||||
|
||||
function ClearMachineAttributeValue() {
|
||||
if (MachineAttributes) {
|
||||
for (var i = 0; i < MachineAttributes.length; i++) {
|
||||
var ma = MachineAttributes[i];
|
||||
if (ma && ma.MachineAttributes) {
|
||||
for (var j = 0; j < ma.MachineAttributes.length; j++) {
|
||||
var att = ma.MachineAttributes[j];
|
||||
$('#attributeid_' + att.ID).val("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getAttributeInput(alerttitle) {
|
||||
var attributedata = [];
|
||||
if (MachineAttributes.length > 0) {
|
||||
for (var j = 0; j < MachineAttributes.length; j++) {
|
||||
var atts = MachineAttributes[j].MachineAttributes;
|
||||
for (var i = 0; i < atts.length; i++) {
|
||||
var att = atts[i];
|
||||
var attvalue = $('#attributeid_' + att.ID).val();
|
||||
if (att.DataType == 1 || att.DataType == 2 || att.DataType == 3) {
|
||||
if (attvalue !== "") {
|
||||
if (isNaN(attvalue) || !IsNumber.test(attvalue)) {
|
||||
showAlert(att.DisplayText + ' is not formatted correctly.', alerttitle);
|
||||
return false;
|
||||
}
|
||||
if (att.DataType == 1 && attvalue.indexOf(".") != -1) {
|
||||
showAlert(att.DisplayText + ' is not formatted correctly.', alerttitle);
|
||||
return false;
|
||||
}
|
||||
else if (att.DataType == 3)
|
||||
attvalue = parseFloat(attvalue).toFixed(att.Precision);
|
||||
}
|
||||
}
|
||||
else if (att.DataType == 4) {
|
||||
if (attvalue.length > 0) {
|
||||
if (!checkDate(attvalue)) {
|
||||
showAlert(att.DisplayText + ' is not formatted correctly.', alerttitle);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
attvalue = "";
|
||||
}
|
||||
}
|
||||
att.Value = attvalue;
|
||||
attributedata.push(att);
|
||||
}
|
||||
}
|
||||
}
|
||||
return attributedata;
|
||||
}
|
302
Site/MachineDeviceManagement/js/deviceparinglogs.js
Normal file
@ -0,0 +1,302 @@
|
||||
|
||||
//****************************设备管理和机器管理共用*****************************************/
|
||||
function getDevicePairingLogsByDevice() {
|
||||
$('#div_attlarge').empty();
|
||||
if (deviceid) {
|
||||
var cid = $('#sel_contractor').val();
|
||||
devicerequest('GetDevicePairingLogsByDevice', JSON.stringify([cid, deviceid, ""]), function (data) {
|
||||
if (data && typeof data != "string") {
|
||||
showDevicePairingLogs(data, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function getDevicePairingLogsByAsset() {
|
||||
$('#div_attlarge').empty();
|
||||
if (machineid) {
|
||||
devicerequest('GetDevicePairingLogsByAsset', JSON.stringify([contractorid, machineid, ""]), function (data) {
|
||||
if (data && typeof data != "string") {
|
||||
showDevicePairingLogs(data, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function OnExpendParingInfo(e) {
|
||||
var t = $(e);
|
||||
var tid = t.attr("target");
|
||||
if (t.hasClass("iconchevrondown")) {
|
||||
t.removeClass("iconchevrondown").addClass("iconchevronright");
|
||||
$("#" + tid).hide();
|
||||
}
|
||||
else {
|
||||
t.removeClass("iconchevronright").addClass("iconchevrondown");
|
||||
$("#" + tid).show();
|
||||
if (!t.data("loaded")) {
|
||||
getPairingAttachments(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showDevicePairingLogs(logs, type) {//0.device,1.asset
|
||||
$('#div_attlarge').empty();
|
||||
if (logs && logs.length > 0) {
|
||||
for (var i = 0; i < logs.length; i++) {
|
||||
var log = logs[i];
|
||||
var trid = "paringinfo_tr" + log.Id;
|
||||
var tab = $('<table class="main_table maintenance"></table>');
|
||||
$('#div_attlarge').append(tab);
|
||||
var tr = $('<tr style="line-height: 35px;"></tr>');
|
||||
tab.append(tr);
|
||||
var td = $('<td class="subtitle"></td>');
|
||||
tr.append(td);
|
||||
var spanexpend = $('<span class="sbutton iconchevronright woattafoldicon" target="' + trid + '" onclick="OnExpendParingInfo(this)" style="margin-left: 0; padding-right: 5px;"></span>').data('log', log).data('type', type);
|
||||
td.append(spanexpend);
|
||||
var spantitle = $('<span></span>').text(("Paired to {0} on {1} by {2}").replace('{0}', type === 0 ? log.AssetName : (log.SourceName + " " + log.SerialNumber)).replace('{1}', log.InstallTime_LocalStr).replace('{2}', log.InstallerName));
|
||||
td.append(spantitle);
|
||||
|
||||
tr = $('<tr id="' + trid + '" class="tr_intervals woattafoldtr"></tr>').hide();
|
||||
tab.append(tr);
|
||||
td = $('<td id="paringinfo_td' + log.Id + '"></td>');
|
||||
tr.append(td);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getPairingAttachments(t) {
|
||||
var cid = $('#sel_contractor').val();
|
||||
var pairinglog = $(t).data('log');
|
||||
var type = $(t).data('type');
|
||||
devicerequest('GetPairingAttachments', JSON.stringify([cid, pairinglog.Id]), function (data) {
|
||||
if (data && typeof data != "string") {
|
||||
$(t).data('loaded', true);
|
||||
showPairingAttachments(pairinglog, data, type);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function arrayBufferToBase64(buffer) {
|
||||
var binary = '';
|
||||
var bytes = new Uint8Array(buffer);
|
||||
var len = bytes.byteLength;
|
||||
for (var i = 0; i < len; i++) {
|
||||
binary += String.fromCharCode(bytes[i]);
|
||||
}
|
||||
return window.btoa(binary);
|
||||
}
|
||||
|
||||
function getPairingSignature(pairinglogid, logtab) {
|
||||
devicerequest('GetPairingSignature', JSON.stringify(pairinglogid), function (data) {
|
||||
if (data && data != null && data.length > 0) {
|
||||
var logtr = $('<tr></tr>');
|
||||
logtab.append(logtr);
|
||||
var logtd = $('<td class="label"></td>').text(GetTextByKey('P_XXXX', 'Signature: '));
|
||||
logtr.append(logtd);
|
||||
logtd = $('<td colspan="3"></td>');
|
||||
logtr.append(logtd);
|
||||
|
||||
var jpeg = data;
|
||||
if (typeof (data) !== "string") {
|
||||
jpeg = arrayBufferToBase64(data);
|
||||
}
|
||||
var imgsig = $('<img style="height: 110px;" />').attr('src', 'data:image/png;base64,' + jpeg);
|
||||
$(logtd).append(imgsig);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getPairingAttachmentCategory(key) {
|
||||
switch (key) {
|
||||
case "Odometer":
|
||||
return GetTextByKey("P_XXXX", "Odometer");
|
||||
case "Engine Hours":
|
||||
return GetTextByKey("P_XXXX", "Engine Hours");
|
||||
case "Mounting Location":
|
||||
return GetTextByKey("P_XXXX", "Mounting Location");
|
||||
case "Power Connection":
|
||||
return GetTextByKey("P_XXXX", "Power Connection");
|
||||
case "Ground Connection":
|
||||
return GetTextByKey("P_XXXX", "Ground Connection");
|
||||
case "Ignition Connection":
|
||||
return GetTextByKey("P_XXXX", "Ignition Connection");
|
||||
case "Asset Number":
|
||||
return GetTextByKey("P_XXXX", "Asset Number");
|
||||
case "Left Front of Asset":
|
||||
return GetTextByKey("P_XXXX", "Left Front of Asset");
|
||||
case "Right Rear of Asset":
|
||||
return GetTextByKey("P_XXXX", "Right Rear of Asset");
|
||||
case "VIN":
|
||||
return GetTextByKey("P_XXXX", "VIN");
|
||||
case "ESN of GPS Device":
|
||||
return GetTextByKey("P_XXXX", "ESN of GPS Device");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
var imgTypes = [".jfif", ".jpg", ".jpeg", ".bmp", ".png", ".tiff", ".gif"];
|
||||
var printTypes = ['.pdf', ".jfif", ".jpg", ".jpeg", ".bmp", ".png", ".tiff", ".gif"];//types to be loaded to print
|
||||
function showPairingAttachments(pairinglog, attas, type) {//0.device,1.asset
|
||||
var ptd = $('#paringinfo_td' + pairinglog.Id);
|
||||
ptd.empty();
|
||||
var log = pairinglog;
|
||||
//Mountion Location,EngineHours,Odometer
|
||||
var divinfo = $('<div class="edit-content"></div>');
|
||||
var logtab = $('<table class="tab_deviceparing"></table>');
|
||||
divinfo.append(logtab);
|
||||
var logtr = $('<tr></tr>');
|
||||
logtab.append(logtr);
|
||||
var logtd = $('<td class="label" style="width:130px;"></td>').text(GetTextByKey('P_XXXX', 'Date Time:'));
|
||||
logtr.append(logtd);
|
||||
logtd = $('<td style="width:300px;"></td>').text(log.InstallTime_LocalStr);
|
||||
logtr.append(logtd);
|
||||
logtd = $('<td class="label" style="width:130px;"></td>').text(GetTextByKey('P_XXXX', 'Installer:'));
|
||||
logtr.append(logtd);
|
||||
logtd = $('<td></td>').text(log.InstallerName);
|
||||
logtr.append(logtd);
|
||||
|
||||
logtr = $('<tr></tr>');
|
||||
logtab.append(logtr);
|
||||
if (type == 0) {
|
||||
logtd = $('<td class="label" style="width:130px;"></td>').text(GetTextByKey('P_XXXX', 'VIN:'));
|
||||
logtr.append(logtd);
|
||||
logtd = $('<td></td>').text(log.AssetVIN);
|
||||
logtr.append(logtd);
|
||||
logtd = $('<td class="label" style="width:130px;"></td>').text(GetTextByKey('P_XXXX', 'Asset Name:'));
|
||||
logtr.append(logtd);
|
||||
logtd = $('<td></td>').text(log.AssetName);
|
||||
logtr.append(logtd);
|
||||
}
|
||||
else {
|
||||
logtd = $('<td class="label" style="width:130px;"></td>').text(GetTextByKey('P_XXXX', 'Device SN:'));
|
||||
logtr.append(logtd);
|
||||
logtd = $('<td></td>').text(log.SerialNumber);
|
||||
logtr.append(logtd);
|
||||
logtd = $('<td class="label" style="width:130px;"></td>').text(GetTextByKey('P_XXXX', 'Source:'));
|
||||
logtr.append(logtd);
|
||||
logtd = $('<td></td>').text(log.SourceName);
|
||||
logtr.append(logtd);
|
||||
}
|
||||
|
||||
logtr = $('<tr></tr>');
|
||||
logtab.append(logtr);
|
||||
logtd = $('<td class="label"></td>').text(GetTextByKey('P_XXXX', 'Engine Hours: '));
|
||||
logtr.append(logtd);
|
||||
logtd = $('<td></td>').text(log.EngineHours < 0 ? '' : log.EngineHours.toLocaleString());
|
||||
logtr.append(logtd);
|
||||
logtd = $('<td class="label"></td>').text(GetTextByKey('P_XXXX', 'Odometer: '));
|
||||
logtr.append(logtd);
|
||||
logtd = $('<td></td>').text(log.Odometer < 0 ? '' : (log.Odometer.toLocaleString() + " " + log.OdometerUnit));
|
||||
logtr.append(logtd);
|
||||
|
||||
logtr = $('<tr></tr>');
|
||||
logtab.append(logtr);
|
||||
logtd = $('<td class="label"></td>').text(GetTextByKey('P_XXXX', 'Mounting Location:'));
|
||||
logtr.append(logtd);
|
||||
logtd = $('<td colspan="3"></td>').text(log.MountionLocation);
|
||||
logtr.append(logtd);
|
||||
|
||||
logtr = $('<tr></tr>');
|
||||
logtab.append(logtr);
|
||||
logtd = $('<td class="label"></td>').text(GetTextByKey('P_XXXX', 'Notes: '));
|
||||
logtr.append(logtd);
|
||||
logtd = $('<td colspan="3"></td>').text(log.Notes);
|
||||
logtr.append(logtd);
|
||||
|
||||
getPairingSignature(log.Id, logtab);
|
||||
|
||||
ptd.append(divinfo);
|
||||
if (attas && attas.length > 0) {
|
||||
for (var i = 0; i < attas.length; i++) {
|
||||
var att = attas[i];
|
||||
var category_str = att.Category.replace(/\s+/g, '').toLowerCase();
|
||||
var div_atts = $('#divatt_' + pairinglog.Id + "_" + category_str);
|
||||
if (div_atts.length == 0) {
|
||||
div_atts = $('<div id="divatt_' + pairinglog.Id + "_" + category_str + '" style="min-height: 80px; overflow: auto; padding-left: 20px;"></div>');
|
||||
ptd.append(div_atts);
|
||||
var div1 = $('<div style=" margin-top: 15px;margin-bottom:5px;"></div>');
|
||||
var ext_span = $('<span style="font-weight:500;font-size:16px;"></span>').text(getPairingAttachmentCategory(att.Category));
|
||||
div1.append(ext_span);
|
||||
div_atts.append(div1);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < attas.length; i++) {
|
||||
var att = attas[i];
|
||||
var category_str = att.Category.replace(/\s+/g, '').toLowerCase();
|
||||
var div_atts = $('#divatt_' + pairinglog.Id + "_" + category_str);
|
||||
var pdiv = $('<div class="divattp"></div>');
|
||||
var div = createAttaDiv(att, true);
|
||||
var div1 = $('<div style=" margin-top: 15px;"></div>');
|
||||
|
||||
var sdownload = $('<span class="attadownload"></span>').attr('title', GetTextByKey("P_WO_DOWNLOAD", 'Download')).click(att, function (e) {
|
||||
openDownloadFrame(e.data.FullSizeUrl + "&d=1");
|
||||
});
|
||||
div.append(sdownload);
|
||||
pdiv.append(div);
|
||||
|
||||
var caption = att.FileName;
|
||||
var div3 = $('<div style="text-align:center;clear:both;"></div>');
|
||||
var iptcaption = $('<input type="text" style="width: 196px;height:24px;border:1px solid #fff;" class="inp_name" maxlength="200"/>').attr('data-ori', caption).val(caption);
|
||||
iptcaption.data('attdata', att);
|
||||
div3.append(iptcaption);
|
||||
pdiv.append(div3);
|
||||
div_atts.append(pdiv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createAttaDiv(att) {
|
||||
var div = $('<div class="divatt"></div>').attr('title', att.FileName).attr('title', att.Notes === "" ? att.FileName : att.Notes)
|
||||
if (!att.FileType || att.FileType == "") att.FileType = ".jpg";
|
||||
if (imgTypes.indexOf(att.FileType.toLowerCase()) >= 0) {
|
||||
var pic = $('<img class="picture"></img>').attr('src', att.ThumbnailUrl);
|
||||
pic.click(att, function (e) {
|
||||
window.open(e.data.FullSizeUrl, "_blank")
|
||||
});
|
||||
div.append(pic);
|
||||
}
|
||||
else {
|
||||
var sdown = $('<img class="picture" />').click(att, function (e) {
|
||||
window.open(e.data.FullSizeUrl);
|
||||
});
|
||||
setAttachemntIcon(att.FileType, sdown);
|
||||
div.append(sdown);
|
||||
}
|
||||
return div
|
||||
}
|
||||
|
||||
function openPrintFrame(attatype, id) {
|
||||
var frame = $("<iframe style='display:none;'></iframe>");
|
||||
$(document.body).after(frame);
|
||||
//frame.attr("src", url);
|
||||
frame.attr("src", _network.root + "Print.aspx?pt=3&at=" + attatype + "&id=" + id);
|
||||
|
||||
frame.on('load', function () {
|
||||
setTimeout(function () {
|
||||
frame.contents().find("body").css("text-align", "center");
|
||||
//frame.contents().find("img").css("max-height", window.screen.availHeight).css("max-width", window.screen.availWidth);
|
||||
frame.contents().find("img").css("max-height", "98%").css("max-width", "98%");
|
||||
frame[0].contentWindow.print();
|
||||
});
|
||||
setTimeout(function () {
|
||||
frame.remove();
|
||||
}, 60000);
|
||||
});
|
||||
}
|
||||
|
||||
function openDownloadFrame(url) {
|
||||
var frame = $("<iframe style='display:none;'></iframe>");
|
||||
$(document.body).after(frame);
|
||||
frame.attr("src", url);
|
||||
|
||||
var timer = setInterval(function () {
|
||||
if (frame[0].contentDocument && (frame[0].contentDocument.readyState == "complete" || frame[0].contentDocument.readyState == 4)) {
|
||||
frame.remove();
|
||||
clearInterval(timer);
|
||||
}
|
||||
}, 5000);
|
||||
}
|
393
Site/MachineDeviceManagement/js/mergeasset.js
Normal file
@ -0,0 +1,393 @@
|
||||
|
||||
var allassets;
|
||||
function GetMachines() {
|
||||
worequest("GetMachines", "", function (data) {
|
||||
if (data && data.length > 0) {
|
||||
allassets = data;
|
||||
editableSelectFromAsset.setEnable(true);
|
||||
editableSelectToAsset.setEnable(true);
|
||||
|
||||
editableSelectFromAsset.datasource = data;
|
||||
editableSelectFromAsset.valuepath = "Id"
|
||||
editableSelectFromAsset.displaypath = "DisplayName";
|
||||
|
||||
editableSelectToAsset.datasource = data;
|
||||
editableSelectToAsset.valuepath = "Id"
|
||||
editableSelectToAsset.displaypath = "DisplayName";
|
||||
}
|
||||
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
function openMergeAssets() {
|
||||
ClearAssetDetail();
|
||||
if (!allassets)
|
||||
GetMachines();
|
||||
|
||||
showmaskbg(true);
|
||||
$('#dialog_mergeassets').css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_mergeassets').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_mergeassets').width()) / 2
|
||||
}).showDialogfixed();
|
||||
}
|
||||
|
||||
function ClearAssetDetail() {
|
||||
$('#tab_assetinfo').show();
|
||||
$('#tab_mergeassets').hide();
|
||||
$('#btn_mergenext').show();
|
||||
$('#btn_mergeprevious').hide();
|
||||
editableSelectFromAsset.val('');
|
||||
editableSelectToAsset.val('');
|
||||
$('#dialog_newhide').attr("checked", false);
|
||||
$('#dialog_newonroad').attr("checked", false);
|
||||
$('#dialog_newtelematics').attr("checked", false);
|
||||
$('#dialog_newattachment').attr("checked", false);
|
||||
$('#dialog_newpreloaded').attr("checked", false);
|
||||
$('#dialog_newsn').text("");
|
||||
$('#dialog_newname').text("");
|
||||
$('#dialog_newname2').text("");
|
||||
$('#dialog_newdevicesn').text("");
|
||||
$('#dialog_newyear').text("");
|
||||
$('#dialog_newmake').text("");
|
||||
$('#dialog_newmodel').text("");
|
||||
$('#dialog_neweqclass').text("");
|
||||
$('#dialog_newtype').text("");
|
||||
$('#dialog_newdescription').val("");
|
||||
$('#dialog_newenginehours').text("");
|
||||
$('#dialog_newodometer').text("");
|
||||
$('#dialog_newaddedon').text("");
|
||||
$('#dialog_newaddedby').text("");
|
||||
|
||||
$('#dialog_oldhide').attr("checked", false);
|
||||
$('#dialog_oldonroad').attr("checked", false);
|
||||
$('#dialog_oldtelematics').attr("checked", false);
|
||||
$('#dialog_oldAttachment').attr("checked", false);
|
||||
$('#dialog_oldpreloaded').attr("checked", false);
|
||||
$('#dialog_oldsn').text("");
|
||||
$('#dialog_oldname').text("");
|
||||
$('#dialog_oldname2').text("");
|
||||
$('#dialog_olddevicesn').text("");
|
||||
$('#dialog_oldyear').text("");
|
||||
$('#dialog_oldmake').text("");
|
||||
$('#dialog_oldmodel').text("");
|
||||
$('#dialog_oldeqclass').text("");
|
||||
$('#dialog_oldtype').text("");
|
||||
$('#dialog_olddescription').val("");
|
||||
$('#dialog_oldenginehours').text("");
|
||||
$('#dialog_oldodometer').text("");
|
||||
$('#dialog_oldaddedon').text("");
|
||||
$('#dialog_oldaddedby').text("");
|
||||
$('.radio_both').prop('checked', true);
|
||||
$('#dialog_mergenotes').val('');
|
||||
}
|
||||
|
||||
function showAssetDetail(assetid, type) {
|
||||
var contractorid = "";
|
||||
if (IsDealer)
|
||||
contractorid = htmlencode($.trim($('#sel_contractor').val()));
|
||||
assetrequest("GetMachineInfo", contractorid + String.fromCharCode(170) + assetid, function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
var asset = data;
|
||||
if (type === 1) {
|
||||
$('#dialog_newhide').attr("checked", asset.Hidden);
|
||||
$('#dialog_newonroad').attr("checked", asset.OnRoad);
|
||||
$('#dialog_newtelematics').attr("checked", asset.TelematicsEnabled);
|
||||
$('#dialog_newattachment').attr("checked", asset.Attachment);
|
||||
$('#dialog_newpreloaded').attr("checked", asset.Preloaded);
|
||||
$('#dialog_newsn').text(asset.VIN);
|
||||
$('#dialog_newname').text(asset.Name);
|
||||
$('#dialog_newname2').text(asset.Name2);
|
||||
$('#dialog_newdevicesn').text(asset.PairedDeviceSN);
|
||||
$('#dialog_newyear').text(eval(asset.MakeYear) > 0 ? asset.MakeYear : "");
|
||||
$('#dialog_newmake').text(asset.MakeName);
|
||||
$('#dialog_newmodel').text(asset.ModelName);
|
||||
$('#dialog_neweqclass').text(asset.EQClass);
|
||||
$('#dialog_newtype').text(asset.TypeName);
|
||||
$('#dialog_newdescription').val(asset.Description);
|
||||
$('#dialog_newenginehours').text(asset.EngineHours ? asset.EngineHours : "");
|
||||
$('#dialog_newodometer').text(asset.Odometer ? asset.Odometer : "");
|
||||
$('#dialog_newaddedon').text(asset.AddedOnStr);
|
||||
$('#dialog_newaddedby').text(asset.AddedByUserName);
|
||||
}
|
||||
else {
|
||||
$('#dialog_oldhide').attr("checked", asset.Hidden);
|
||||
$('#dialog_oldonroad').attr("checked", asset.OnRoad);
|
||||
$('#dialog_oldtelematics').attr("checked", asset.TelematicsEnabled);
|
||||
$('#dialog_oldAttachment').attr("checked", asset.Attachment);
|
||||
$('#dialog_oldpreloaded').attr("checked", asset.Preloaded);
|
||||
$('#dialog_oldsn').text(asset.VIN);
|
||||
$('#dialog_oldname').text(asset.Name);
|
||||
$('#dialog_oldname2').text(asset.Name2);
|
||||
$('#dialog_olddevicesn').text(asset.PairedDeviceSN);
|
||||
$('#dialog_oldyear').text(eval(asset.MakeYear) > 0 ? asset.MakeYear : "");
|
||||
$('#dialog_oldmake').text(asset.MakeName);
|
||||
$('#dialog_oldmodel').text(asset.ModelName);
|
||||
$('#dialog_oldeqclass').text(asset.EQClass);
|
||||
$('#dialog_oldtype').text(asset.TypeName);
|
||||
$('#dialog_olddescription').val(asset.Description);
|
||||
$('#dialog_oldenginehours').text(asset.EngineHours ? asset.EngineHours : "");
|
||||
$('#dialog_oldodometer').text(asset.Odometer ? asset.Odometer : "");
|
||||
$('#dialog_oldaddedon').text(asset.AddedOnStr);
|
||||
$('#dialog_oldaddedby').text(asset.AddedByUserName);
|
||||
}
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
function OnNext() {
|
||||
var fromasset = editableSelectFromAsset.selecteditem();
|
||||
var toasset = editableSelectToAsset.selecteditem();
|
||||
if (!fromasset || !toasset) {
|
||||
showAlert(GetTextByKey("P_MA_SELECTANASSETTOMERGE", "Please select two assets to merge."), GetTextByKey("P_MA_MERGEASSET", "Merge Asset"));
|
||||
return;
|
||||
}
|
||||
var tips = GetTextByKey('P_MA_MERGEASSETTIPS', 'Merge asset {0} to asset {1}, please select the data to be retained:').replace('{0}', fromasset.DisplayName).replace('{1}', toasset.DisplayName);
|
||||
$('#span_mergetips').text(tips);
|
||||
$('.span_asseta').text(fromasset.DisplayName);
|
||||
$('.span_assetb').text(toasset.DisplayName);
|
||||
$('#tab_assetinfo').hide();
|
||||
$('#tab_mergeassets').show();
|
||||
$('#btn_mergenext').hide();
|
||||
$('#btn_mergeprevious').show();
|
||||
}
|
||||
|
||||
function OnPrevious() {
|
||||
$('#tab_mergeassets').hide();
|
||||
$('#tab_assetinfo').show();
|
||||
$('#btn_mergenext').show();
|
||||
$('#btn_mergeprevious').hide();
|
||||
}
|
||||
|
||||
function SaveMergeAsset() {
|
||||
var fromasset = editableSelectFromAsset.selecteditem();
|
||||
var toasset = editableSelectToAsset.selecteditem();
|
||||
if (!fromasset || !toasset) {
|
||||
showAlert(GetTextByKey("P_MA_SELECTANASSETTOMERGE", "Please select two assets to merge."), GetTextByKey("P_MA_MERGEASSET", "Merge Asset"));
|
||||
return;
|
||||
}
|
||||
|
||||
var contractorid = "";
|
||||
if (IsDealer)
|
||||
contractorid = htmlencode($.trim($('#sel_contractor').val()));
|
||||
var notes = $('#dialog_mergenotes').val();
|
||||
var fromassetid = fromasset.Id;
|
||||
var toassetid = toasset.Id;
|
||||
|
||||
var items = [];
|
||||
items.push({ 'Key': 0, 'Tag': 'Odometer', 'Value': $('input[name="radio_odometer"]:checked').val() });
|
||||
items.push({ 'Key': 1, 'Tag': 'Engine Hours', 'Value': $('input[name="radio_enginehours"]:checked').val() });
|
||||
items.push({ 'Key': 2, 'Tag': 'Location', 'Value': $('input[name="radio_location"]:checked').val() });
|
||||
items.push({ 'Key': 3, 'Tag': 'Idle Hours', 'Value': $('input[name="radio_idlehours"]:checked').val() });
|
||||
items.push({ 'Key': 4, 'Tag': 'Fuel Used', 'Value': $('input[name="radio_fuelused"]:checked').val() });
|
||||
items.push({ 'Key': 5, 'Tag': 'Fuel Remaining', 'Value': $('input[name="radio_fuelremaining"]:checked').val() });
|
||||
items.push({ 'Key': 6, 'Tag': 'Attribute', 'Value': $('input[name="radio_attribute"]:checked').val() });
|
||||
items.push({ 'Key': 7, 'Tag': 'Battery', 'Value': $('input[name="radio_battery"]:checked').val() });
|
||||
items.push({ 'Key': 8, 'Tag': 'Preventative Maintenance', 'Value': $('input[name="radio_pmplans"]:checked').val() });
|
||||
items.push({ 'Key': 9, 'Tag': 'Jobsite', 'Value': $('input[name="radio_jobsite"]:checked').val() });
|
||||
var p = [
|
||||
contractorid,
|
||||
fromassetid,
|
||||
toassetid,
|
||||
notes,
|
||||
JSON.stringify(items)
|
||||
];
|
||||
var param = JSON.stringify(p);
|
||||
|
||||
$("#dialogmask").show();
|
||||
assetrequest('SaveMergeAsset', param, function (data) {
|
||||
if (data === "") {
|
||||
showAlert(GetTextByKey('P_MA_MERGESUCCESSFULLY', 'Merge successfully.'), GetTextByKey('P_MA_MERGEASSET', 'Merge Asset'));
|
||||
} else {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
}
|
||||
$('#dialog_mergeassets').hideDialog();
|
||||
showmaskbg(false);
|
||||
$("#dialogmask").hide();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function openAssetMergeHistory() {
|
||||
window.open("AssetMergeHistory.aspx");
|
||||
}
|
||||
|
||||
|
||||
//************************Begin Merge Asset(New)*********************************//
|
||||
|
||||
function OnMergeAsset() {
|
||||
showmaskbg(true);
|
||||
dialogSelectMergeAssets.exceptShareAsset = true;
|
||||
dialogSelectMergeAssets.exceptSource = [machineid];
|
||||
dialogSelectMergeAssets.showSelector(3, true);//与attachmentInfo中的showSelector冲突,需设置force
|
||||
$('#mask_bg').css('height', '100%');
|
||||
}
|
||||
|
||||
var mergeassetid;
|
||||
var mergeasset;
|
||||
function showMergeAsset() {
|
||||
showmaskbg(true);
|
||||
$('#dialog_mergeasset').css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_mergeasset').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_mergeasset').width()) / 2
|
||||
}).showDialogfixed();
|
||||
|
||||
var asset = assetinfo;
|
||||
$('#dialog_merge_newhide').attr("checked", asset.Hidden);
|
||||
$('#dialog_merge_newonroad').attr("checked", asset.OnRoad);
|
||||
$('#dialog_merge_newtelematics').attr("checked", asset.TelematicsEnabled);
|
||||
$('#dialog_merge_newattachment').attr("checked", asset.Attachment);
|
||||
$('#dialog_merge_newpreloaded').attr("checked", asset.Preloaded);
|
||||
$('#dialog_merge_newsn').text(asset.VIN);
|
||||
$('#dialog_merge_newname').text(asset.Name);
|
||||
$('#dialog_merge_newname2').text(asset.Name2);
|
||||
$('#dialog_merge_newdevicesn').text(asset.PairedDeviceSN);
|
||||
$('#dialog_merge_newyear').text(eval(asset.MakeYear) > 0 ? asset.MakeYear : "");
|
||||
$('#dialog_merge_newmake').text(asset.MakeName);
|
||||
$('#dialog_merge_newmodel').text(asset.ModelName);
|
||||
$('#dialog_merge_neweqclass').text(asset.EQClass);
|
||||
$('#dialog_merge_newtype').text($("#dialog_type").find("option:selected").text());
|
||||
$('#dialog_merge_newdescription').val(asset.Description);
|
||||
$('#dialog_merge_newenginehours').text(asset.EngineHours);
|
||||
$('#dialog_merge_newodometer').text(asset.Odometer);
|
||||
$('#dialog_merge_newaddedon').text(asset.AddedOnStr);
|
||||
$('#dialog_merge_newaddedby').text(asset.AddedByUserName);
|
||||
|
||||
GetAssetDatasources(asset.Id, false);
|
||||
|
||||
showMergeOldAsset();
|
||||
GetAssetDatasources(mergeassetid, true);
|
||||
}
|
||||
|
||||
function showMergeOldAsset() {
|
||||
$("#mergeassetmask").show();
|
||||
assetrequest("GetMachineInfo", contractorid + String.fromCharCode(170) + mergeassetid, function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
$("#mergeassetmask").hide();
|
||||
return;
|
||||
}
|
||||
mergeasset = data;
|
||||
var asset = mergeasset;
|
||||
$('#dialog_merge_oldhide').attr("checked", asset.Hidden);
|
||||
$('#dialog_merge_oldonroad').attr("checked", asset.OnRoad);
|
||||
$('#dialog_merge_oldtelematics').attr("checked", asset.TelematicsEnabled);
|
||||
$('#dialog_merge_oldAttachment').attr("checked", asset.Attachment);
|
||||
$('#dialog_merge_oldpreloaded').attr("checked", asset.Preloaded);
|
||||
$('#dialog_merge_oldsn').text(asset.VIN);
|
||||
$('#dialog_merge_oldname').text(asset.Name);
|
||||
$('#dialog_merge_oldname2').text(asset.Name2);
|
||||
$('#dialog_merge_olddevicesn').text(asset.PairedDeviceSN);
|
||||
$('#dialog_merge_oldyear').text(eval(asset.MakeYear) > 0 ? asset.MakeYear : "");
|
||||
$('#dialog_merge_oldmake').text(asset.MakeName);
|
||||
$('#dialog_merge_oldmodel').text(asset.ModelName);
|
||||
$('#dialog_merge_oldeqclass').text(asset.EQClass);
|
||||
$('#dialog_merge_oldtype').text(asset.Type);
|
||||
$('#dialog_merge_olddescription').val(asset.Description);
|
||||
$('#dialog_merge_oldenginehours').text(asset.EngineHours ? asset.EngineHours : "");
|
||||
$('#dialog_merge_oldodometer').text(asset.Odometer ? asset.Odometer : "");
|
||||
$('#dialog_merge_oldaddedon').text(asset.AddedOnStr);
|
||||
$('#dialog_merge_oldaddedby').text(asset.AddedByUserName);
|
||||
|
||||
$("#mergeassetmask").hide();
|
||||
}, function (err) {
|
||||
$("#mergeassetmask").hide();
|
||||
});
|
||||
}
|
||||
|
||||
function onMergeUseAsset(mergetype) {
|
||||
$('#dialog_mergeasset').hideDialog();
|
||||
$("#mergeassetmask").hide();
|
||||
DoMergeAsset(mergetype);
|
||||
}
|
||||
|
||||
function DoMergeAsset(mergetype) {
|
||||
if (mergetype == -1 || !machineid)
|
||||
return;
|
||||
|
||||
var mid = -1;
|
||||
var tomid = -1;
|
||||
var msg = "";
|
||||
var alerttile = "";
|
||||
if (mergetype === 0) {
|
||||
mid = mergeassetid;
|
||||
tomid = machineid;
|
||||
alerttile = GetTextByKey("P_MA_XXXXX", 'Merge Asset');
|
||||
msg = GetTextByKey("P_MA_XXXXXX", 'WARNING: The merge process will strictly hide the Orphaned Asset and re-assign telematic data sources to the Master Asset for future incoming data. Existing data within the platform will not be assigned to the Master Asset. Are you sure you want to proceed?');
|
||||
}
|
||||
else if (mergetype === 1) {
|
||||
mid = machineid;
|
||||
tomid = mergeassetid;
|
||||
alerttile = GetTextByKey("P_MA_XXXXX", 'Merge Asset');
|
||||
msg = GetTextByKey("P_MA_XXXXXX", 'WARNING: The merge process will strictly hide the Orphaned Asset and re-assign telematic data sources to the Master Asset for future incoming data. Existing data within the platform will not be assigned to the Master Asset. Are you sure you want to proceed?');
|
||||
}
|
||||
|
||||
showConfirm(msg, alerttile, function (e) {
|
||||
MergeAsset(mid, tomid, mergetype);
|
||||
});
|
||||
}
|
||||
|
||||
function MergeAsset(mid, tomid, mergetype) {
|
||||
showmaskbg(true);
|
||||
assetrequest("MergeAsset", htmlencode(JSON.stringify([contractorid, mid, tomid, ""])), function (data) {
|
||||
showmaskbg(false);
|
||||
if (data != "") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
}
|
||||
else {
|
||||
needRefreshDataOnCancel = true;
|
||||
if (mergetype === 1)
|
||||
OnExit(1);
|
||||
else
|
||||
OnEdit();
|
||||
}
|
||||
}, function (err) {
|
||||
showmaskbg(false);
|
||||
});
|
||||
}
|
||||
|
||||
function OnDeleteAsset() {
|
||||
if (!machineid)
|
||||
return;
|
||||
|
||||
var mid = machineid;
|
||||
var alerttile = GetTextByKey("P_MA_XXXXX", 'Delete Asset');
|
||||
var msg = GetTextByKey("P_MA_XXXXXX", 'WARNING: This will delete the Asset. Are you sure you want to proceed?');
|
||||
|
||||
showConfirm(msg, alerttile, function (e) {
|
||||
DeleteAsset(mid);
|
||||
});
|
||||
}
|
||||
|
||||
function DeleteAsset(mid) {
|
||||
showmaskbg(true);
|
||||
assetrequest("DeleteAssets", htmlencode(JSON.stringify([contractorid, JSON.stringify([mid]), ""])), function (data) {
|
||||
showmaskbg(false);
|
||||
if (data != "") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
}
|
||||
else {
|
||||
needRefreshDataOnCancel = true;
|
||||
OnExit(1);
|
||||
}
|
||||
}, function (err) {
|
||||
showmaskbg(false);
|
||||
});
|
||||
}
|
||||
|
||||
function GetAssetDatasources(mid, isold) {
|
||||
assetrequest("GetAssetDatasources", htmlencode(JSON.stringify([contractorid, mid])), function (data) {
|
||||
if (data && data.length > 0) {
|
||||
var target = isold ? $("#dialog_merge_olddatasource") : $("#dialog_merge_newdatasource");
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
target.append($("<div></div>").text(data[i]));
|
||||
}
|
||||
}
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
//**************************End Merge Asset(New)*******************************//
|
324
Site/MachineDeviceManagement/js/rental.js
Normal file
@ -0,0 +1,324 @@
|
||||
|
||||
var _selectedRental = null;
|
||||
|
||||
$(function () {
|
||||
$('#dialog_rentaldate').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
|
||||
$('#dialog_projectreturndate').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
|
||||
$('#dialog_returndate').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
|
||||
$('#dialog_rentaltermbillingdate').datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function SetMachineRental(rental) {
|
||||
//if (IsAdmin)
|
||||
// $('#btnManageRentalHistory').css('display', '');
|
||||
//else
|
||||
// $('#btnManageRentalHistory').css('display', 'none');
|
||||
//if (rental != null) {
|
||||
// $('#tab_rentalconnect :input[type="text"]').attr('disabled', false);
|
||||
// $('#dialog_outside').attr('disabled', false);
|
||||
// $('#dialog_termunit').attr('disabled', false);
|
||||
// $('#dialog_comments').attr('disabled', false);
|
||||
//}
|
||||
//else {
|
||||
// $('#tab_rentalconnect :input[type="text"]').attr('disabled', true);
|
||||
// $('#dialog_outside').attr('disabled', true);
|
||||
// $('#dialog_termunit').attr('disabled', true);
|
||||
// $('#dialog_comments').attr('disabled', true);
|
||||
// $('#btnManageRentalHistory').css('display', 'none');
|
||||
//}
|
||||
if (rental != null) {
|
||||
//if (rental.data)
|
||||
// rental = rental.data;
|
||||
$('#tab_rentalconnect').data('rentalid', rental.RentalID);
|
||||
$('#dialog_outside').val(rental.Outside);
|
||||
$('#dialog_vendor').val(rental.Vendor);
|
||||
$('#dialog_rentalrate').val(rental.RentalRate);
|
||||
$('#dialog_term').val(rental.Term);
|
||||
$('#dialog_termunit').val(rental.TermUnit);
|
||||
$('#dialog_rentaldate').val(rental.RentalDateStr);
|
||||
$('#dialog_projectreturndate').val(rental.ProjectReturnDateStr);
|
||||
$('#dialog_returndate').val(rental.ReturnDateStr);
|
||||
$('#dialog_ponumber').val(rental.PONumber);
|
||||
$('#dialog_comments').val(rental.Comments);
|
||||
$('#dialog_rentaltermbillingdate').val(rental.RentalTermBillingDateStr);
|
||||
$('#dialog_billingcycledays').val(rental.BillingCycleDays < 0 ? "" : rental.BillingCycleDays);
|
||||
$('#dialog_insuredvalue').val(rental.InsuredValue);
|
||||
}
|
||||
else {
|
||||
$('#tab_rentalconnect').data('rentalid', '');
|
||||
$('#dialog_outside').val('');
|
||||
$('#dialog_vendor').val('');
|
||||
$('#dialog_rentalrate').val('');
|
||||
$('#dialog_term').val('');
|
||||
$('#dialog_termunit').val('');
|
||||
$('#dialog_rentaldate').val('');
|
||||
$('#dialog_projectreturndate').val('');
|
||||
$('#dialog_returndate').val('');
|
||||
$('#dialog_ponumber').val('');
|
||||
$('#dialog_comments').val('');
|
||||
$('#dialog_rentaltermbillingdate').val('');
|
||||
$('#dialog_billingcycledays').val('');
|
||||
$('#dialog_insuredvalue').val('');
|
||||
}
|
||||
}
|
||||
|
||||
function getRentalInput(alerttitle) {
|
||||
var rentalid = $('#tab_rentalconnect').data('rentalid');
|
||||
if (rentalid === "")
|
||||
rentalid = -1;
|
||||
var rental = {
|
||||
'RentalID': rentalid,
|
||||
'MachineID': machineid,
|
||||
'Outside': $('#dialog_outside').val(),
|
||||
'Vendor': $('#dialog_vendor').val(),
|
||||
'RentalRate': $('#dialog_rentalrate').val(),
|
||||
'Term': $('#dialog_term').val(),
|
||||
'TermUnit': $('#dialog_termunit').val(),
|
||||
'RentalDate': $('#dialog_rentaldate').val(),
|
||||
'RentalDateStr': $('#dialog_rentaldate').val(),
|
||||
'ProjectReturnDate': $('#dialog_projectreturndate').val(),
|
||||
'ProjectReturnDateStr': $('#dialog_projectreturndate').val(),
|
||||
'ReturnDate': $('#dialog_returndate').val(),
|
||||
'ReturnDateStr': $('#dialog_returndate').val(),
|
||||
'PONumber': $('#dialog_ponumber').val(),
|
||||
'Comments': $('#dialog_comments').val(),
|
||||
'RentalTermBillingDate': $('#dialog_rentaltermbillingdate').val(),
|
||||
'BillingCycleDays': $('#dialog_billingcycledays').val(),
|
||||
'InsuredValue': $('#dialog_insuredvalue').val()
|
||||
};
|
||||
|
||||
if (rental.RentalRate !== "" && isNaN(rental.RentalRate)) {
|
||||
showAlert(GetTextByKey("P_MA_RENTALRATEFORMATERROR", 'Rental Rate format error.'), alerttitle);
|
||||
return false;
|
||||
}
|
||||
if (rental.RentalRate === "") {
|
||||
rental.RentalRate = 0;
|
||||
}
|
||||
if (rental.Term === "") {
|
||||
rental.Term = 0;
|
||||
}
|
||||
if (isNaN(rental.Term) || !IsInteger.test(rental.Term) || eval(rental.Term) < 0) {
|
||||
showAlert(GetTextByKey("P_MA_RENTALTERMMUSTBEANINTEGEREQUALTOORGREATERTHAN0", 'Rental Term must be an integer equal to or greater than 0. '), alerttitle);
|
||||
return false;
|
||||
}
|
||||
if (rental.RentalDate.length <= 0) {
|
||||
showAlert(GetTextByKey("P_MA_RENTALDATECANNOTBEEMPTY", 'Rental Date cannot be empty.'), alerttitle);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rental.BillingCycleDays !== "") {
|
||||
if (isNaN(rental.BillingCycleDays) || !IsInteger.test(rental.BillingCycleDays) || eval(rental.BillingCycleDays) < 0) {
|
||||
showAlert(GetTextByKey("P_MA_THENUMBEROFDAYSINBILLINGCYCLEMUSTBEANINTEGEREQUALTOORGREATERTHAN0", 'The Number of Days in Billing Cycle must be an integer equal to or greater than 0.'), alerttitle);
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
rental.BillingCycleDays = -1;
|
||||
|
||||
if (rental.InsuredValue !== "" && isNaN(rental.InsuredValue)) {
|
||||
showAlert(GetTextByKey("P_MR_INSUREDVALUEFORMATERROR", 'Insured Value format error.'), alerttitle);
|
||||
return false;
|
||||
}
|
||||
if (rental.InsuredValue === "") {
|
||||
rental.InsuredValue = 0;
|
||||
}
|
||||
|
||||
return rental;
|
||||
}
|
||||
|
||||
var IsInteger = /^[0-9]+$/;
|
||||
function SaveRental() {
|
||||
if (!rentalChanged) return;
|
||||
var alerttitle = "";
|
||||
var rentalid = $('#tab_rentalconnect').data('rentalid');
|
||||
if (rentalid === "")
|
||||
rentalid = -1;
|
||||
if (rentalid > 0)
|
||||
alerttitle = GetTextByKey("P_MA_EDITRENTAL", "Edit Rental");
|
||||
else
|
||||
alerttitle = GetTextByKey("P_MA_ADDRENTAL", "Add Rental");
|
||||
var rental = getRentalInput(alerttitle);
|
||||
if (!rental) return;
|
||||
if (!machineid) {
|
||||
OnSave(0, false, function () {
|
||||
getRentals(machineid);
|
||||
});
|
||||
return;
|
||||
}
|
||||
else {
|
||||
DoSaveRental(rental, alerttitle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function DoSaveRental(item, alerttitle) {
|
||||
var rentaldate = new Date(item.RentalDate.replace("-", "/"));
|
||||
var pjdate = new Date(item.ProjectReturnDate.replace("-", "/"));
|
||||
var returndate = new Date(item.ReturnDate.replace("-", "/"));
|
||||
if (rentaldate > pjdate) {
|
||||
showAlert(GetTextByKey("P_MA_PROJRETURNDATEMUSTBELATERTHANRENTALDATE", "Proj. Return Date must be later than than Rental Date."), alerttitle);
|
||||
return false;
|
||||
}
|
||||
if (rentaldate > returndate) {
|
||||
showAlert(GetTextByKey("P_MA_RETURNDATEMUSTBELATERTHANRENTALDATE", "Return Date must be later than Rental Date."), alerttitle);
|
||||
return false;
|
||||
}
|
||||
|
||||
showloading(true);
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
|
||||
devicerequest("SaveRental", contractorid + String.fromCharCode(170) + param, function (data) {
|
||||
showloading(false);
|
||||
if (typeof (data) === "string") {
|
||||
if (data === "Rental dates entered overlap with another entry. Please adjust the dates.")
|
||||
data = GetTextByKey("P_MA_RENTALDATESENTEREDOVERLAPWITHANOTHERENTRY", "Rental dates entered overlap with another entry. Please adjust the dates.");
|
||||
showAlert(data, GetTextByKey("P_MA_SAVERENTAL", 'Save Rental'));
|
||||
} else {
|
||||
rentalChanged = false;
|
||||
item.RentalID = data;
|
||||
$('#tab_rentalconnect').data('rentalid', item.RentalID);
|
||||
showAlert(GetTextByKey("P_MA_SAVSUCCESSFULLY", 'Saved successfully.'), GetTextByKey("P_MA_SAVERENTAL", 'Save Rental'));
|
||||
getRentals(machineid);
|
||||
}
|
||||
}, function (err) {
|
||||
console.log(err);
|
||||
showloading(false);
|
||||
showAlert(GetTextByKey("P_MA_FAILEDTOSAVERENTAL", 'Failed to save Rental.'), GetTextByKey("P_MA_SAVERENTAL", 'Save Rental'));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function CancelRental() {
|
||||
SetMachineRental(_selectedRental);
|
||||
}
|
||||
|
||||
function jumpToAddRental() {
|
||||
window.open("AddRental.aspx?cid=" + contractorid + "&mid=" + machineid);
|
||||
}
|
||||
|
||||
|
||||
function getRentals(machineid) {
|
||||
if (!machineid)
|
||||
return;
|
||||
_selectedRental = null;
|
||||
$("#rentalListDiv").hide();
|
||||
showLoading();
|
||||
devicerequest("SearchRentalsByAsset", JSON.stringify([contractorid, machineid]), function (data) {
|
||||
$('#tbody_rentals').empty();
|
||||
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
if (data && data.length > 0) {
|
||||
rentalsdata = data;
|
||||
$("#rentalListDiv").show();
|
||||
}
|
||||
else
|
||||
rentalsdata = [];
|
||||
sortTableData($('#tbRentals'), rentalsdata);
|
||||
showRentals(rentalsdata);
|
||||
SetMachineRental(_selectedRental);
|
||||
hideLoading();
|
||||
}, function (err) {
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function rentalsTrClick() {
|
||||
var rental = $(this).data('rental');
|
||||
SetMachineRental(rental);
|
||||
_selectedRental = rental;
|
||||
$('#tbody_rentals tr').removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
}
|
||||
|
||||
function showRentals(data) {
|
||||
var trs = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var rental = data[i];
|
||||
var tr = $('<tr></tr>').data('rental', rental).click(rentalsTrClick);
|
||||
if (rental.Selected) {
|
||||
_selectedRental = rental;
|
||||
tr.addClass('selected');
|
||||
}
|
||||
tr.append($('<td class="machinetd" style="width: 10%;"></td>').text(rental.RentalDateStr));
|
||||
tr.append($('<td class="machinetd" style="width: 12%;"></td>').text(rental.ProjectReturnDateStr));
|
||||
tr.append($('<td class="machinetd" style="width: 12%;"></td>').text(rental.ReturnDateStr));
|
||||
//tr.append($('<td class="machinetd" style="width: 10%;"></td>').html(replaceHtmlText(rental.Outside)));
|
||||
tr.append($('<td class="machinetd" style="width: 12%;"></td>').html(replaceHtmlText(rental.Vendor)));
|
||||
tr.append($('<td class="machinetd" style="width: 10%;"></td>').text(rental.RentalRate));
|
||||
tr.append($('<td class="machinetd" style="width: 10%;"></td>').text(rental.Term));
|
||||
tr.append($('<td class="machinetd" style="width: 10%;"></td>').text(getLangTermUnit(rental.TermUnit)));
|
||||
//tr.append($('<td style="width: 24%;"></td>').attr('title', rental.Comments).html(replaceHtmlText(rental.Comments)));
|
||||
|
||||
trs.push(tr);
|
||||
}
|
||||
|
||||
$('#tbody_rentals').append(trs);
|
||||
}
|
||||
|
||||
function getLangTermUnit(unit) {
|
||||
var langunit = unit
|
||||
if (unit === "Hourly")
|
||||
langunit = GetTextByKey("P_MA_HOURLY", "Hourly");
|
||||
else if (unit === "Daily")
|
||||
langunit = GetTextByKey("P_MA_DAILY", "Daily");
|
||||
else if (unit === "Weekly")
|
||||
langunit = GetTextByKey("P_MA_WEEKLY", "Weekly");
|
||||
else if (unit === "Monthly")
|
||||
langunit = GetTextByKey("P_MA_MONTHLY", "Monthly");
|
||||
else if (unit === "Annually")
|
||||
langunit = GetTextByKey("P_MA_ANNUALLY", "Annually");
|
||||
return langunit;
|
||||
}
|
||||
|
||||
function ManageRentalHistory() {
|
||||
window.open("MachineDeviceManagement.aspx?cid=" + contractorid + "&mid=" + machineid + "#nav_managrentals");
|
||||
}
|
||||
|
||||
function AddRental() {
|
||||
showRentalConfirm(GetTextByKey("P_MA_WOULDSAVECHANGES", 'Would you like to save changes?'), GetTextByKey("P_MA_RENTAL", 'Rental'),
|
||||
function () {
|
||||
SaveRental();//Edit
|
||||
}, function () {
|
||||
$('#tab_rentalconnect').data('rentalid', '');
|
||||
SaveRental(); //Add
|
||||
}, null);
|
||||
}
|