1146 lines
		
	
	
		
			49 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			1146 lines
		
	
	
		
			49 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| <%@ Page Title="" Language="C#" MasterPageFile="~/MachineDeviceManagement/DeviceManagementBase.master" AutoEventWireup="true" CodeFile="ShareMachines.aspx.cs" Inherits="ShareMachines" %>
 | |
| 
 | |
| 
 | |
| <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: 145px;
 | |
|                 text-align: right;
 | |
|                 padding-right: 10px;
 | |
|                 line-height: 24px;
 | |
|                 height: 24px;
 | |
|                 vertical-align: middle;
 | |
|             }
 | |
| 
 | |
|             .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;
 | |
|                     width: 13px;
 | |
|                 }
 | |
| 
 | |
|                 .dialog-content table td input[type="radio"] {
 | |
|                     border: none;
 | |
|                     width: unset;
 | |
|                 }
 | |
| 
 | |
|             .dialog-content table td textarea {
 | |
|                 height: 100px;
 | |
|             }
 | |
| 
 | |
|         #dialogdatatb td {
 | |
|             padding-top: 30px;
 | |
|         }
 | |
| 
 | |
|         .a {
 | |
|             text-decoration: none;
 | |
|             color: #2140fb;
 | |
|         }
 | |
| 
 | |
|         .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';
 | |
|         }
 | |
| 
 | |
|         .minus:before {
 | |
|             font-size: 10px;
 | |
|             font-weight: normal;
 | |
|             font-family: 'CalciteWebCoreIcons', 'Fontawesome';
 | |
|             content: '\e621';
 | |
|         }
 | |
| 
 | |
|         .dialogedit:before {
 | |
|             font-size: 14px;
 | |
|             font-weight: normal;
 | |
|             font-family: 'CalciteWebCoreIcons', 'Fontawesome';
 | |
|             content: '\e61b';
 | |
|             cursor: pointer;
 | |
|             background: rgb(249, 189, 117);
 | |
|             padding: 2px;
 | |
|         }
 | |
| 
 | |
|         .dialogok:before {
 | |
|             font-size: 14px;
 | |
|             font-weight: normal;
 | |
|             font-family: 'CalciteWebCoreIcons', 'Fontawesome';
 | |
|             content: '\e605';
 | |
|             cursor: pointer;
 | |
|             background: rgb(249, 189, 117);
 | |
|             padding: 2px;
 | |
|         }
 | |
| 
 | |
|         .dialogcancel:before {
 | |
|             font-size: 14px;
 | |
|             font-weight: normal;
 | |
|             font-family: 'CalciteWebCoreIcons', 'Fontawesome';
 | |
|             content: '\e600';
 | |
|             cursor: pointer;
 | |
|             background: rgb(249, 189, 117);
 | |
|             padding: 2px;
 | |
|         }
 | |
| 
 | |
|         .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;
 | |
|         }
 | |
| 
 | |
|         #machinelist {
 | |
|             height: 490px;
 | |
|             width: 100%;
 | |
|         }
 | |
| 
 | |
|         .dulpicatetd {
 | |
|             font-weight: 700;
 | |
|             width: 190px;
 | |
|             text-align: right;
 | |
|             padding-right: 20px;
 | |
|         }
 | |
|     </style>
 | |
|     <link href="<%=GetFileUrlWithVersion("../css/panel.css")%>" rel="stylesheet" />
 | |
|     <link href="<%=GetFileUrlWithVersion("../Security/css/controls.css")%>" rel="stylesheet" />
 | |
|     <link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" />
 | |
|     <link href="<%=GetFileUrlWithVersion("../css/tabcontrol.css")%>" rel="stylesheet" />
 | |
|     <script type="text/javascript" src="<%=GetFileUrlWithVersion("../js/vue.min.js")%>"></script>
 | |
|     <script>Vue.config.productionTip = false; Vue.config.silent = true;</script>
 | |
|     <script type="text/javascript" src="<%=GetFileUrlWithVersion("../js/components/datagrid.js")%>"></script>
 | |
|     <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("../js/controls.js")%>" type="text/javascript"></script>
 | |
|     <script src="<%=GetFileUrlWithVersion("../fic/js/utility.js")%>" type="text/javascript"></script>
 | |
|     <script src="<%=GetFileUrlWithVersion("../js/gridlayout.js")%>" type="text/javascript"></script>
 | |
|     <script src="<%=GetFileUrlWithVersion("js/mergeasset.js")%>"></script>
 | |
|     <script type="text/javascript">        
 | |
|         var IsDealer = <%=IsDealer ?"true":"false"%>;
 | |
|         var IsAdmin =<%=IsAdmin ?"true":"false"%>;
 | |
|         var IsSupperAdmin =<%=IsSupperAdmin ?"true":"false"%>;
 | |
|         var CheckRight =<%=CheckRight ?"true":"false"%>;
 | |
|         var IsReadOnly = <%=IsReadOnly ?"true":"false"%>;
 | |
|         var gridLayoutID = "ShareAssets";
 | |
|         var currentdate = "<%=CurrentDate %>";
 | |
| 
 | |
|         var machineID;
 | |
|         var indexInEdit = -1;
 | |
| 
 | |
|         function shareassetrequest(method, param, callback, error) {
 | |
|             _network.request("MachineDeviceManagement/ShareMachines.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 assetrequest(method, param, callback, error) {
 | |
|             _network.request("MachineDeviceManagement/AddMachine.aspx", -1, method, param, callback, error || function (e) {
 | |
|                 console.log(e);
 | |
|                 showmaskbg(false, true);
 | |
|                 showAlert(GetTextByKey('P_MA_PAGEERROR', 'An unknown error occurred.  Please refresh page.'), GetTextByKey('P_MA_QUERY', 'Query'));
 | |
|             });
 | |
|         }
 | |
| 
 | |
|         function devicerequest(method, param, callback, error) {
 | |
|             _network.request("MachineDeviceManagement/ManageMachines.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 CloseDialog(type) {
 | |
|             $('#dialog_machine1').hideDialog();
 | |
|             if (type == 1) {
 | |
|                 OnRefresh();
 | |
|             }
 | |
|             else {
 | |
|                 showmaskbg(false);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         function ShowMachineDialog(type) {
 | |
|             showmaskbg(true);
 | |
|             $('#dialog_machine1')
 | |
|                 .attr('act', type)
 | |
|                 .showDialogRight();
 | |
|         }
 | |
| 
 | |
|         function closePopupView(type) {
 | |
|             $('#dialog_assetview').hideDialog();
 | |
|             showmaskbg(false);
 | |
|         }
 | |
| 
 | |
|         function ShowAssetViewDialog() {
 | |
|             showmaskbg(true);
 | |
|             $('#dialog_assetview').showDialogRight();
 | |
|         }
 | |
| 
 | |
|         function OnAdd() {
 | |
|             var contractorid = htmlencode($.trim($('#sel_contractor').val()));
 | |
| 
 | |
|             ShowMachineDialog("add");
 | |
|             execIframeFunc("init", [contractorid], "iframemachine");
 | |
|         }
 | |
| 
 | |
|         function OnEdit() {
 | |
|             indexInEdit = grid_dt.selectedIndex;
 | |
|             if (indexInEdit < 0) {
 | |
|                 showAlert(GetTextByKey("P_MA_SELECTASSET", "Please select an Asset."), GetTextByKey("P_MA_EDITASSET", "Edit Asset"));
 | |
|                 return;
 | |
|             }
 | |
|             var machine = grid_dt.source[indexInEdit].Values;
 | |
|             if (!machine) {
 | |
|                 machineID = undefined;
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             var contractorid = htmlencode($.trim($('#sel_contractor').val()));
 | |
| 
 | |
|             ShowMachineDialog("edit");
 | |
|             execIframeFunc("init", [contractorid, grid_dt.source, indexInEdit], "iframemachine");
 | |
|             return;
 | |
|         }
 | |
| 
 | |
|         var lastContractorID = "-1";
 | |
|         function OnRefresh() {
 | |
|             var contractorid = htmlencode($.trim($('#sel_contractor').val()));
 | |
|             if (IsDealer && !contractorid)
 | |
|                 return;
 | |
|             var sharestatus = $('#selsharestatus').val();
 | |
|             var onroad = $('#selonroad').val();
 | |
| 
 | |
|             var searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
 | |
|             var showHidden = $('#chkShowHidden').prop("checked");
 | |
| 
 | |
|             var p = {
 | |
|                 CustomerId: contractorid,
 | |
|                 Shared: sharestatus,
 | |
|                 OnRoad: onroad,
 | |
|                 IncludeHidden: showHidden,
 | |
|                 Filter: searchtxt,
 | |
|             }
 | |
|             showloading(true);
 | |
| 
 | |
|             //var ps = [contractorid, sharestatus, onroad, JSON.stringify(models), JSON.stringify(years), JSON.stringify(assettypes), searchtxt, showHidden];
 | |
|             shareassetrequest("GETSHAREASSETLIST", JSON.stringify(p), function (data) {
 | |
|                 if (typeof (data) === "string") {
 | |
|                     showloading(false);
 | |
|                     showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
 | |
|                     return;
 | |
|                 }
 | |
| 
 | |
|                 showMachines(data);
 | |
| 
 | |
|                 showloading(false);
 | |
|             }, function (err) {
 | |
|                 showloading(false);
 | |
|             });
 | |
|         }
 | |
| 
 | |
|         //admin用户 获取所有contractor     
 | |
|         function getContractors() {
 | |
|             devicerequest('GetContractors', '', function (data) {
 | |
|                 if (typeof (data) === "string") {
 | |
|                     showAlert(data, GetTextByKey("P_MA_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);
 | |
|                     }
 | |
|                 }
 | |
|                 var contractorid = htmlencode($.trim($('#sel_contractor').val()));
 | |
|                 if (!contractorid || contractorid == "")
 | |
|                     $("#btnAdd").hide();
 | |
|                 $("#iframemachine").attr("src", "AddMachine.aspx?cid=" + contractorid);
 | |
|                 OnRefresh();
 | |
|             });
 | |
|         }
 | |
| 
 | |
|         //普通用户 获取可操作的contractor     
 | |
|         function GetContractorsByUser() {
 | |
|             devicerequest('GetContractorsByUser', '', function (data) {
 | |
|                 if (typeof (data) === "string") {
 | |
|                     showAlert(data, GetTextByKey("P_MA_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);
 | |
|                     }
 | |
|                 }
 | |
|                 var contractorid = htmlencode($.trim($('#sel_contractor').val()));
 | |
|                 if (!contractorid || contractorid == "")
 | |
|                     $("#btnAdd").hide();
 | |
|                 $("#iframemachine").attr("src", "AddMachine.aspx?cid=" + contractorid);
 | |
|                 OnRefresh();
 | |
|             });
 | |
|         }
 | |
| 
 | |
|         function showMachines(data) {
 | |
|             var rows = [];
 | |
|             for (var i = 0; i < data.length; i++) {
 | |
|                 var r = data[i];
 | |
|                 for (var j in r) {
 | |
|                     if (j === "EngineHoursDate")
 | |
|                         r[j] = { DisplayValue: r["EngineHoursDateStr"], Value: r[j] };
 | |
|                     else if (j === "MakeYear")
 | |
|                         r[j] = r[j] === 0 ? "" : r[j];
 | |
|                     else if (j === "StartDate") {
 | |
|                         r[j] = { DisplayValue: r["StartDateStr"], Value: r[j] };
 | |
|                     }
 | |
|                     else if (j === "ExpectedRetrievalDate") {
 | |
|                         r[j] = { DisplayValue: r["ExpectedRetrievalDateStr"], Value: r[j] };
 | |
|                     }
 | |
|                     else if (j === "RetrievalDate") {
 | |
|                         r[j] = { DisplayValue: r["RetrievalDateStr"], 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('#machinelist');
 | |
|             grid_dt.lang = {
 | |
|                 all: GetTextByKey("P_GRID_ALL", "(All)"),
 | |
|                 ok: GetTextByKey("P_GRID_OK", "OK"),
 | |
|                 reset: GetTextByKey("P_GRID_RESET", "Reset")
 | |
|             };
 | |
|             //grid_dt.lang.all;
 | |
|             //grid_dt.lang.ok = "Apply";
 | |
|             //grid_dt.lang.reset;
 | |
|             var list_columns = [
 | |
|                 { name: 'Selected', caption: "", valueIndex: 'Selected', alwaysshow: true, css: { 'width': 45, 'text-align': 'center' }, type: 3 },
 | |
|                 { name: 'VIN', caption: GetTextByKey("P_MA_VINSN", "SN/VIN"), valueIndex: 'VIN', css: { 'width': 180, 'text-align': 'left' } },
 | |
|                 { name: 'Name', caption: GetTextByKey("P_MA_ASSETNAME", "Asset Name"), valueIndex: 'AssetName', css: { 'width': 180, 'text-align': 'left' } },
 | |
|                 { name: 'Name2', caption: GetTextByKey("P_MA_ASSETNAME2", "Asset Name(Custom)"), valueIndex: 'AssetCustomerName', css: { 'width': 180, 'text-align': 'left' } },
 | |
|                 { name: 'SharedWith', caption: GetTextByKey("P_MA_XXXXXX", "Shared With"), valueIndex: 'ChildName', css: { 'width': 180, 'text-align': 'left' } },
 | |
|                 { name: 'StartDate', caption: GetTextByKey("P_MA_XXXXXX", "Start Date"), valueIndex: 'StartDate', css: { 'width': 150, 'text-align': 'left' } },
 | |
|                 { name: 'ExpectedRetrievalDate', caption: GetTextByKey("P_MA_XXXXXX", "Expected End Date"), valueIndex: 'ExpectedRetrievalDate', css: { 'width': 150, 'text-align': 'left' } },
 | |
|                 { name: 'MakeYear', caption: GetTextByKey("P_MA_YEAR", "Year"), valueIndex: 'MakeYear', allowFilter: true, css: { 'width': 80, 'text-align': 'left' } },
 | |
|                 { name: 'Make', caption: GetTextByKey("P_MA_MAKE", "Make"), valueIndex: 'MakeName', allowFilter: true, css: { 'width': 120, 'text-align': 'left' } },
 | |
|                 { name: 'Model', caption: GetTextByKey("P_MA_MODEL", "Model"), valueIndex: 'ModelName', allowFilter: true, css: { 'width': 120, 'text-align': 'left' } },
 | |
|                 { name: 'MachineType', caption: GetTextByKey("P_MA_TYPE", "Asset Type"), valueIndex: 'TypeName', allowFilter: true, css: { 'width': 120, 'text-align': 'left' } },
 | |
|                 { name: 'EngineHours', caption: GetTextByKey("P_MA_ENGINEHOURS", "Engine Hours"), valueIndex: 'EngineHoursValue', css: { 'width': 120, 'text-align': 'left' } },
 | |
|                 //{ name: 'EngineHoursDate', caption: GetTextByKey("P_MA_ENGINEHOURSDATE", "Engine Hours Date"), valueIndex: 'EngineHoursDate', css: { 'width': 150, 'text-align': 'left' } },
 | |
|                 { name: 'OnRoad', caption: GetTextByKey("P_MA_ONROAD", "On-Road"), valueIndex: 'OnRoad', type: 3, allowFilter: true, css: { 'width': 90, 'text-align': 'center' } },
 | |
|                 { name: 'Hide', caption: GetTextByKey("P_MA_HIDE", "Hide"), valueIndex: 'Hide', type: 3, allowFilter: true, css: { 'width': 70, 'text-align': 'center' } },
 | |
|                 { name: 'TelematicsEnabled', caption: GetTextByKey("P_MA_TELEMATICSENABLED", "Telematics Enabled"), valueIndex: 'TelematicsEnabled', allowFilter: true, type: 3, css: { 'width': 140, 'text-align': 'center' } },
 | |
|                 { name: 'Share', caption: "", alwaysshow: true, css: { 'width': 30, 'text-align': 'center' } },
 | |
|                 { name: 'UnShare', caption: "", alwaysshow: true, css: { 'width': 30, 'text-align': 'center' } },
 | |
|                 //{ name: 'Detail', caption: "", alwaysshow: true, css: { 'width': 30, 'text-align': 'center' } }
 | |
|             ];
 | |
|             var columns = [];
 | |
|             // head
 | |
|             for (var hd in list_columns) {
 | |
|                 var col = {};
 | |
|                 col.name = list_columns[hd].name;
 | |
|                 col.caption = list_columns[hd].caption;
 | |
|                 col.visible = true;
 | |
|                 col.sortable = true;
 | |
|                 col.width = list_columns[hd].css.width;
 | |
|                 col.align = list_columns[hd].css["text-align"]
 | |
|                 col.key = list_columns[hd].valueIndex;
 | |
|                 col.allowFilter = list_columns[hd].allowFilter;
 | |
| 
 | |
|                 col.alwaysshow = list_columns[hd].alwaysshow;
 | |
|                 if (list_columns[hd].type) {
 | |
|                     col.type = list_columns[hd].type;
 | |
|                 }
 | |
|                 if (col.name === "Selected") {
 | |
|                     col.allcheck = true;
 | |
|                     col.sortable = false;
 | |
|                 }
 | |
|                 else if (IsReadOnly && (col.name === "UploadAssetIcon" || col.name === "DeleteAssetIcon"))
 | |
|                     continue;
 | |
|                 if (col.name === "Hide" || col.name === "OnRoad" || col.name === "TelematicsEnabled" || col.name === "Attachment" || col.name === "Preloaded") {
 | |
|                     col.onchanged = function (e) {
 | |
|                         e.ValueChanged = true;
 | |
|                     }
 | |
|                     col.filterSource = [{ Value: true, DisplayValue: 'Yes' }, { Value: false, DisplayValue: 'No' }];
 | |
|                     col.events = {
 | |
|                         onchange: function () {
 | |
|                             if (grid_dt.selectedColumnIndex >= 0) {
 | |
|                                 var name = grid_dt.columns[grid_dt.selectedColumnIndex].name;
 | |
|                                 ChangeAssetProperty(this, name);
 | |
|                             }
 | |
|                         }
 | |
|                     };
 | |
|                     //if (IsReadOnly)
 | |
|                     col.enabled = false;
 | |
|                 }
 | |
|                 else if (col.name === "Share") {
 | |
|                     col.sortable = false;
 | |
|                     col.isurl = true;
 | |
|                     col.text = "\uf2b5";
 | |
|                     col.events = {
 | |
|                         onclick: function () {
 | |
|                             OnShare(this.AssetId, this.ChildId, this.ExpectedRetrievalDateStr);
 | |
|                         }
 | |
|                     };
 | |
|                     col.classFilter = function () {
 | |
|                         return 'icon-col';
 | |
|                     }
 | |
|                     col.attrs = { 'title': GetTextByKey("P_MA_XXXXXX", 'Share Asset') };
 | |
|                 }
 | |
|                 else if (col.name === "UnShare") {
 | |
|                     col.sortable = false;
 | |
|                     col.isurl = true;
 | |
|                     col.text = "\uf127";
 | |
|                     col.events = {
 | |
|                         onclick: function () {
 | |
|                             OnUnShare(this.AssetId);
 | |
|                         }
 | |
|                     };
 | |
|                     col.classFilter = function (e) {
 | |
|                         return "icon-col";
 | |
|                     };
 | |
|                     col.styleFilter = function (e) {
 | |
|                         return {
 | |
|                             display: e.MachineIconFileName === "" ? 'none' : ''
 | |
|                         };
 | |
|                     };
 | |
|                     col.attrs = { 'title': GetTextByKey("P_MA_XXXXXX", 'UnShare Asset') };
 | |
|                 }
 | |
|                 else if (col.name === "Detail") {
 | |
|                     col.isurl = true;
 | |
|                     col.text = "\uf05a";
 | |
|                     col.events = {
 | |
|                         onclick: function () {
 | |
|                             showMachineDetail(this.AssetId, this.VIN);
 | |
|                         }
 | |
|                     };
 | |
|                     col.classFilter = function (e) {
 | |
|                         return "icon-col";
 | |
|                     };
 | |
|                     col.attrs = { 'title': GetTextByKey("P_MA_SHOWASSETDETAIL", 'Show Asset Detail') };
 | |
|                 }
 | |
|                 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) {
 | |
|                     machineID = rowdata.Values.AssetId;
 | |
|                 }
 | |
|             }
 | |
|             grid_dt.allcolumns = columns;
 | |
|             getGridLayout(gridLayoutID, grid_dt, OnRefresh);
 | |
|         }
 | |
| 
 | |
|         function changeGridSelectIndex(index) {
 | |
|             grid_dt.selectedIndexes = [index];
 | |
|             grid_dt.scrollToIndex(index);
 | |
|         }
 | |
| 
 | |
|         function showMachineDetail(mid, vin) {
 | |
|             ShowAssetViewDialog();
 | |
|             var ctr = $("#sel_contractor").val();
 | |
|             if (!ctr) ctr = "";
 | |
| 
 | |
|             execIframeFunc("loadAsset", [ctr, mid, vin, 1], "iframeassetview");
 | |
|         }
 | |
| 
 | |
|         var sharableCustomers = null;
 | |
|         function GetSharableCustomers(v) {
 | |
|             var ctr = $("#sel_contractor").val();
 | |
|             if (!ctr) ctr = "";
 | |
|             $('#dialog_share').children(".maskbg").show();
 | |
|             shareassetrequest('GetShareWithCustomers', JSON.stringify([ctr, true]), function (data) {
 | |
|                 $('#dialog_share').children(".maskbg").hide();
 | |
|                 if (typeof (data) === "string") {
 | |
|                     return;
 | |
|                 }
 | |
|                 sharableCustomers = data;
 | |
|                 var sel = $('#dialog_sharewith').empty();
 | |
|                 if (sharableCustomers) {
 | |
|                     for (var i = 0; i < sharableCustomers.length; i++) {
 | |
|                         var c = sharableCustomers[i];
 | |
|                         sel.append($("<option></option>").val(c.CustomerId).text(c.CustomerName));
 | |
|                     }
 | |
|                     if (v)
 | |
|                         sel.val(v);
 | |
|                 }
 | |
|             }, function () {
 | |
|                 $('#dialog_share').children(".maskbg").hide();
 | |
|             });
 | |
|         }
 | |
| 
 | |
|         var selectedAssetId;
 | |
| 
 | |
|         function OnShare(id, childid, enddate) {
 | |
|             selectedAssetId = id;
 | |
|             if (id == null) {
 | |
|                 var aids = grid_dt.source
 | |
|                     .filter(function (a) { return a.Values.Selected })
 | |
|                     .map(function (a) { return a.Values.AssetId });
 | |
| 
 | |
|                 if (aids.length == 0) {
 | |
|                     showAlert("Please select an asset.", GetTextByKey('P_XXXXXX', "Share Assets"));
 | |
|                     return;
 | |
|                 }
 | |
|             }
 | |
|             if (!sharableCustomers)
 | |
|                 GetSharableCustomers(childid);
 | |
| 
 | |
|             showmaskbg(true);
 | |
|             $('#dialog_share').css({
 | |
|                 'top': (document.documentElement.clientHeight - $('#dialog_share').height()) / 3,
 | |
|                 'left': (document.documentElement.clientWidth - $('#dialog_share').width()) / 2
 | |
|             }).showDialogfixed(true);
 | |
|             $('#dialog_sharewith').val(childid || $('#dialog_sharewith').children(':first').val());
 | |
|             $('#dialog_enddate').val(enddate || '');
 | |
|             $('#dialog_hideasset').prop("checked", false);
 | |
|         }
 | |
| 
 | |
|         var shareProgressing;
 | |
|         var grid_progress;
 | |
| 
 | |
|         function StartSaveShareAsset() {
 | |
|             if (shareProgressing) {
 | |
|                 return;
 | |
|             }
 | |
|             var alerttitle = GetTextByKey('P_SA_SHAREASSETS', "Share Assets");
 | |
|             var custid = $('#dialog_sharewith').val();
 | |
|             var enddate = $('#dialog_enddate').val();
 | |
|             if (!custid || custid == null) {
 | |
|                 showAlert(GetTextByKey("P_XXXXXX", "Please select a customer."), alerttitle);
 | |
|                 return;
 | |
|             }
 | |
|             if (enddate != null && new Date(currentdate.replace("-", "/")) > new Date(enddate.replace("-", "/"))) {
 | |
|                 showAlert(GetTextByKey("P_XXXXXX", "Expected End Date must be later than today."), alerttitle);
 | |
|                 return;
 | |
|             }
 | |
|             var message;
 | |
|             if (selectedAssetId != null) {
 | |
|                 message = GetTextByKey('P_XXXXXX', 'Are you sure you want to share this asset?');
 | |
|             } else {
 | |
|                 message = GetTextByKey('P_XXXXXX', 'Are you sure you want to share selected asset(s)?');
 | |
|             }
 | |
|             $('#dialog_share').children(".maskbg").show();
 | |
|             showConfirm(message, GetTextByKey('P_XXXXXX', "Share Assets"), function () {
 | |
|                 SaveShareAsset();
 | |
|                 $('#dialog_share').children(".maskbg").hide();
 | |
|             }, function () {
 | |
|                 $('#dialog_share').children(".maskbg").hide();
 | |
|             }, true);
 | |
|         }
 | |
| 
 | |
|         function SaveShareAsset() {
 | |
|             shareProgressing = true;
 | |
|             var ctr = $("#sel_contractor").val();
 | |
|             if (!ctr) ctr = "";
 | |
| 
 | |
|             var custid = $('#dialog_sharewith').val();
 | |
|             var enddate = $('#dialog_enddate').val();
 | |
|             var hideasset = $('#dialog_hideasset').prop("checked");
 | |
| 
 | |
|             var assets;
 | |
|             if (selectedAssetId == null) {
 | |
|                 assets = grid_dt.source.filter(function (a) { return a.Values.Selected });
 | |
|             } else {
 | |
|                 assets = grid_dt.source.filter(function (a) { return a.Values.AssetId == selectedAssetId });
 | |
|             }
 | |
|             if (assets.length == 0) {
 | |
|                 shareProgressing = false;
 | |
|                 return;
 | |
|             }
 | |
|             var alerttitle = GetTextByKey('P_SA_SHAREASSETS', "Share Assets");
 | |
|             var p = {
 | |
|                 CustomerId: ctr,
 | |
|                 SharedWith: custid,
 | |
|                 EndDate: enddate,
 | |
|                 HideAsset: hideasset
 | |
|             };
 | |
|             if (assets.length == 1) {
 | |
|                 p.SharedIds = [assets[0].Values.AssetId];
 | |
|                 shareassetrequest('SaveShareAsset', JSON.stringify(p), function (data) {
 | |
|                     shareProgressing = false;
 | |
| 
 | |
|                     if (typeof (data) === "string") {
 | |
|                         showAlert(data, alerttitle);
 | |
|                         return;
 | |
|                     }
 | |
|                     if ($.isArray(data) && typeof data[0] === 'string') {
 | |
|                         showAlert(data[0], GetTextByKey('P_XXXXXX', "Share Assets"));
 | |
|                         return;
 | |
|                     }
 | |
|                     $('#dialog_share').hideDialog();
 | |
|                     showmaskbg(false);
 | |
|                     OnRefresh();
 | |
|                 });
 | |
|             } else {
 | |
|                 $('#dialog_share').hideDialog();
 | |
|                 $('#dialog_share_progress').css({
 | |
|                     'top': (document.documentElement.clientHeight - $('#dialog_share_progress').height()) / 3,
 | |
|                     'left': (document.documentElement.clientWidth - $('#dialog_share_progress').width()) / 2
 | |
|                 }).showDialogfixed(true);
 | |
|                 $('#dialog_share_progress .maskbg').show();
 | |
|                 $('#button_progress_retry').hide();
 | |
| 
 | |
|                 grid_progress = new GridView('#grid_progress');
 | |
|                 grid_progress.lang = {
 | |
|                     all: GetTextByKey("P_GRID_ALL", "(All)"),
 | |
|                     ok: GetTextByKey("P_GRID_OK", "OK"),
 | |
|                     reset: GetTextByKey("P_GRID_RESET", "Reset")
 | |
|                 };
 | |
|                 var styleFilter = function (item) {
 | |
|                     if (!$.nullOrEmpty(item.__progress_result)) {
 | |
|                         return { color: 'red' };
 | |
|                     }
 | |
|                     return null;
 | |
|                 }
 | |
|                 grid_progress.columns = [
 | |
|                     {
 | |
|                         key: 'Selected',
 | |
|                         type: 3,
 | |
|                         width: 45,
 | |
|                         align: 'center',
 | |
|                         allcheck: true,
 | |
|                         enabled: '__selectable'
 | |
|                     },
 | |
|                     { key: 'VIN', caption: GetTextByKey("P_MA_VINSN", "SN/VIN"), width: 180, styleFilter: styleFilter },
 | |
|                     { key: 'AssetName', caption: GetTextByKey("P_MA_ASSETNAME", "Asset Name"), width: 180, styleFilter: styleFilter },
 | |
|                     { key: 'AssetCustomerName', caption: GetTextByKey("P_MA_ASSETNAME2", "Asset Name(Custom)"), width: 180, styleFilter: styleFilter },
 | |
|                     { key: 'MakeName', caption: GetTextByKey("P_MA_MAKE", "Make"), width: 120, styleFilter: styleFilter },
 | |
|                     { key: 'ModelName', caption: GetTextByKey("P_MA_MODEL", "Model"), width: 120, styleFilter: styleFilter },
 | |
|                     { key: 'TypeName', caption: GetTextByKey("P_MA_TYPE", "Asset Type"), width: 120, styleFilter: styleFilter }
 | |
|                 ];
 | |
|                 grid_progress.canMultiSelect = false;
 | |
|                 grid_progress.init();
 | |
|                 for (var i = 0; i < assets.length; i++) {
 | |
|                     assets[i].Values.Selected = false;
 | |
|                     assets[i].Values.__progress_result = null;
 | |
|                     assets[i].Values.__selectable = false;
 | |
|                 }
 | |
|                 grid_progress.setData(assets);
 | |
| 
 | |
|                 DoSaveShareAsset(assets, p, 0);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         function DoSaveShareAsset(assets, p, offset) {
 | |
|             if (offset > assets.length) {
 | |
|                 shareProgressing = false;
 | |
|                 if (assets.filter(function (a) { return a != null }).length > 0) {
 | |
|                     $('#button_progress_retry').show();
 | |
|                     $('#dialog_share_progress .maskbg').hide();
 | |
|                 } else {
 | |
|                     $('#dialog_share_progress').hideDialog();
 | |
|                     showmaskbg(false);
 | |
|                     OnRefresh();
 | |
|                 }
 | |
|                 return;
 | |
|             }
 | |
|             p.SharedIds = assets.slice(offset, offset + 20).map(function (a) { return a.Values.AssetId });
 | |
|             shareassetrequest('SaveShareAsset', JSON.stringify(p), function (data) {
 | |
| 
 | |
|                 if (typeof (data) === "string") {
 | |
|                     showAlert(data, GetTextByKey('P_XXXXXX', "Share Assets"));
 | |
|                     return;
 | |
|                 }
 | |
|                 if ($.isArray(data)) {
 | |
|                     for (var i = 0; i < data.length; i++) {
 | |
|                         var msg = data[i];
 | |
|                         if (!$.nullOrEmpty(msg)) {
 | |
|                             var asset = assets[offset + i];
 | |
|                             asset.Values.Selected = true;
 | |
|                             asset.Values.__progress_result = msg;
 | |
|                             asset.Values.__selectable = true;
 | |
|                         } else {
 | |
|                             assets[offset + i] = null;
 | |
|                         }
 | |
|                     }
 | |
|                     grid_progress.setData(assets.filter(function (a) { return a != null }));
 | |
|                 }
 | |
| 
 | |
|                 DoSaveShareAsset(assets, p, offset + 20);
 | |
|             });
 | |
|         }
 | |
| 
 | |
|         function RetryShare() {
 | |
|             var assets = grid_progress.source.filter(function (a) { return a.Values.Selected });
 | |
|             if (assets == null || assets.length <= 0) {
 | |
|                 return;
 | |
|             }
 | |
|             $('#dialog_share_progress .maskbg').show();
 | |
|             $('#button_progress_retry').hide();
 | |
| 
 | |
|             var ctr = $("#sel_contractor").val();
 | |
|             if (!ctr) ctr = "";
 | |
| 
 | |
|             var custid = $('#dialog_sharewith').val();
 | |
|             var enddate = $('#dialog_enddate').val();
 | |
|             var hideasset = $('#dialog_hideasset').prop("checked");
 | |
| 
 | |
|             var p = {
 | |
|                 CustomerId: ctr,
 | |
|                 SharedWith: custid,
 | |
|                 EndDate: enddate,
 | |
|                 HideAsset: hideasset
 | |
|             };
 | |
|             DoSaveShareAsset(assets, p, 0);
 | |
|         }
 | |
| 
 | |
|         function OnUnShare(id) {
 | |
|             var ctr = $("#sel_contractor").val();
 | |
|             if (!ctr) ctr = "";
 | |
| 
 | |
|             var assets;
 | |
|             var message;
 | |
|             if (id == null) {
 | |
|                 assets = grid_dt.source.filter(function (a) { return a.Values.Selected && a.Values.ChildId });
 | |
|                 message = GetTextByKey('P_XXXXXX', 'Are you sure you want to unshare selected asset(s)?');
 | |
|             } else {
 | |
|                 assets = grid_dt.source.filter(function (a) { return a.Values.AssetId == id });
 | |
|                 message = GetTextByKey('P_XXXXXX', 'Are you sure you want to unshare this asset?');
 | |
|             }
 | |
|             if (assets.length <= 0) {
 | |
|                 return;
 | |
|             }
 | |
|             showConfirm(message, GetTextByKey('P_XXXXXX', "Share Assets"), function () {
 | |
|                 var p = {
 | |
|                     CustomerId: ctr,
 | |
|                     SharedIds: assets.map(function (a) { return a.Values.AssetId })
 | |
|                 };
 | |
|                 showmaskbg(true);
 | |
|                 shareassetrequest('UnShareAsset', JSON.stringify(p), function (data) {
 | |
| 
 | |
|                     if (typeof (data) === "string") {
 | |
|                         showAlert(data, GetTextByKey('P_XXXXXX', "Share Assets"));
 | |
|                         return;
 | |
|                     }
 | |
|                     if ($.isArray(data)) {
 | |
|                         var m = data.filter(function (r) { return !$.nullOrEmpty(r) });
 | |
|                         if (m.length > 0) {
 | |
|                             showAlert(m[0], GetTextByKey('P_XXXXXX', "Share Assets"));
 | |
|                             return;
 | |
|                         }
 | |
|                     }
 | |
|                     showmaskbg(false);
 | |
|                     OnRefresh();
 | |
|                 });
 | |
|             });
 | |
|         }
 | |
| 
 | |
|         /************************* Customer********************************/
 | |
|         var customerid;
 | |
|         var grid_dtcustomer;
 | |
|         function InitGridCustomers() {
 | |
|             grid_dtcustomer = new GridView('#customerlist');
 | |
|             grid_dtcustomer.lang = {
 | |
|                 all: GetTextByKey("P_GRID_ALL", "(All)"),
 | |
|                 ok: GetTextByKey("P_GRID_OK", "OK"),
 | |
|                 reset: GetTextByKey("P_GRID_RESET", "Reset")
 | |
|             };
 | |
|             var list_columns = [
 | |
|                 { name: 'Sharable', caption: "", valueIndex: 'Sharable', css: { 'width': 45, 'text-align': 'center' }, type: 3 },
 | |
|                 { name: 'CustomerId', caption: GetTextByKey("P_XXXXXX", "ID"), valueIndex: 'CustomerId', css: { 'width': 120, 'text-align': 'left' } },
 | |
|                 { name: 'CustomerName', caption: GetTextByKey("P_XXXXXX", "Name"), valueIndex: 'CustomerName', css: { 'width': 200, 'text-align': 'left' } },
 | |
|             ];
 | |
| 
 | |
|             var columns = [];
 | |
|             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;
 | |
| 
 | |
|                 if (list_columns[hd].type) {
 | |
|                     col.type = list_columns[hd].type;
 | |
|                 }
 | |
|                 if (col.name === "Sharable")
 | |
|                     col.allcheck = true;
 | |
| 
 | |
|                 col.width = list_columns[hd].css.width;
 | |
|                 col.align = list_columns[hd].css["text-align"]
 | |
|                 col.key = list_columns[hd].valueIndex;
 | |
|                 columns.push(col);
 | |
|             }
 | |
|             grid_dtcustomer.canMultiSelect = true;
 | |
|             grid_dtcustomer.columns = columns;
 | |
|             grid_dtcustomer.init();
 | |
|             grid_dtcustomer.rowdblclick = function (rowindex) {
 | |
|                 var rowdata = grid_dtcustomer.source[rowindex];
 | |
|                 if (rowdata) {
 | |
|                     //setCustomerData(rowdata.Values);
 | |
|                     OnSetSelectCustomer();
 | |
|                 }
 | |
|             };
 | |
|         }
 | |
| 
 | |
|         function showShareCustomerList(data) {
 | |
|             var rows = [];
 | |
|             for (var i = 0; i < data.length; i++) {
 | |
|                 var r = data[i];
 | |
|                 var fr = { Values: r };
 | |
|                 rows.push(fr);
 | |
|             }
 | |
| 
 | |
|             grid_dtcustomer.setData(rows);
 | |
|         }
 | |
| 
 | |
|         function openShareWithSetting() {
 | |
|             showmaskbg(true);
 | |
|             $('#dialog_sharewithcustomers').css({
 | |
|                 'top': (document.documentElement.clientHeight - $('#dialog_sharewithcustomers').height()) / 3,
 | |
|                 'left': (document.documentElement.clientWidth - $('#dialog_sharewithcustomers').width()) / 2
 | |
|             }).showDialogfixed();
 | |
| 
 | |
|             getShareWithCustomers();
 | |
|         }
 | |
| 
 | |
|         function getShareWithCustomers() {
 | |
|             $('#dialog_sharewithcustomers').children(".maskbg").show();
 | |
| 
 | |
|             var contractorid = htmlencode($.trim($('#sel_contractor').val()));
 | |
|             shareassetrequest('GetShareWithCustomers', JSON.stringify([contractorid, false]), function (data) {
 | |
|                 $('#dialog_sharewithcustomers').children(".maskbg").hide();
 | |
|                 if (typeof (data) === "string") {
 | |
|                     showAlert(data, GetTextByKey('P_XXXXXX', "Setting"));
 | |
|                     return;
 | |
|                 }
 | |
|                 showShareCustomerList(data);
 | |
|             }, function (err) {
 | |
|                 $('#dialog_sharewithcustomers').children(".maskbg").hide();
 | |
|             });
 | |
|         }
 | |
| 
 | |
|         function saveShareWithCustomers() {
 | |
|             var contractorid = htmlencode($.trim($('#sel_contractor').val()));
 | |
| 
 | |
|             var cids = [];
 | |
|             var delcids = [];
 | |
|             for (var i = 0; i < grid_dtcustomer.source.length; i++) {
 | |
|                 var c = grid_dtcustomer.source[i].Values;
 | |
|                 if (c.Sharable)
 | |
|                     cids.push(c.CustomerId);
 | |
|                 else
 | |
|                     delcids.push(c.CustomerId);
 | |
|             }
 | |
| 
 | |
|             shareassetrequest('SetShareWithCustomers', JSON.stringify([contractorid, JSON.stringify(cids), JSON.stringify(delcids)]), function (data) {
 | |
|                 if (data !== "") {
 | |
|                     showAlert(data, GetTextByKey('P_XXXXXX', "Setting"));
 | |
|                     return;
 | |
|                 }
 | |
|                 $('#dialog_sharewithcustomers').hideDialog();
 | |
|                 GetSharableCustomers("");
 | |
|                 showmaskbg(false);
 | |
|             }, function (err) {
 | |
|             });
 | |
|         }
 | |
| 
 | |
|         /************************* End Customer********************************/
 | |
| 
 | |
|         $(function () {
 | |
|             setPageTitle(GetTextByKey("P_XXXXXX", "Share Assets"), true);
 | |
|             $('.iconlayout').on('click', function (ev) {
 | |
|                 CreateLayoutMenus(ev.target, gridLayoutID, grid_dt);
 | |
|                 return false;
 | |
|             });
 | |
| 
 | |
|             InitGridData();
 | |
|             InitGridCustomers();
 | |
| 
 | |
|             if (IsDealer == true) {
 | |
|                 $('#span_contractor').css('display', '');
 | |
|                 if (IsAdmin)
 | |
|                     getContractors();
 | |
|                 else {
 | |
|                     GetContractorsByUser();
 | |
|                 }
 | |
|             }
 | |
|             else {
 | |
|                 $("#iframemachine").attr("src", "AddMachine.aspx");
 | |
|             }
 | |
| 
 | |
|             $('#dialog_enddate').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]);
 | |
|                 }
 | |
|             });
 | |
| 
 | |
|             $("#sel_contractor").change(function () {
 | |
|                 var contractorid = htmlencode($.trim($('#sel_contractor').val()));
 | |
|                 $("#iframemachine").attr("src", "AddMachine.aspx?cid=" + contractorid);
 | |
|                 OnRefresh();
 | |
|             });
 | |
| 
 | |
|             $('#searchinputtxt').keydown(searchEnter);
 | |
| 
 | |
|             $('#dialog_share').dialog(function () {
 | |
|                 showmaskbg(false);
 | |
|             });
 | |
| 
 | |
|             $('#dialog_sharewithcustomers').dialog(function () {
 | |
|                 showmaskbg(false);
 | |
|             });
 | |
| 
 | |
|             $('#dialog_share_progress').dialog(function () {
 | |
|                 showmaskbg(false);
 | |
|                 OnRefresh();
 | |
|             });
 | |
| 
 | |
|             $(window).resize(function () {
 | |
|                 $("#machinelist").css("height", $(window).height() - $("#machinelist").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 ChangeAssetProperty(asset, name, value) {
 | |
|             var contractorid = "";
 | |
|             if (IsDealer)
 | |
|                 contractorid = htmlencode($.trim($('#sel_contractor').val()));
 | |
| 
 | |
|             var ps = [];
 | |
|             ps.push(contractorid);
 | |
|             ps.push(asset.ID);
 | |
|             ps.push(name);
 | |
|             var value = asset.Hide;
 | |
|             if (name === "OnRoad")
 | |
|                 value = asset.OnRoad;
 | |
|             else if (name === "TelematicsEnabled")
 | |
|                 value = asset.TelematicsEnabled;
 | |
|             else if (name === "Attachment")
 | |
|                 value = asset.Attachment;
 | |
|             else if (name === "Preloaded")
 | |
|                 value = asset.Preloaded;
 | |
|             ps.push(value);
 | |
|             assetrequest('ChangeAssetProperty', JSON.stringify(ps), function (data) {
 | |
|                 if (data) {
 | |
|                     //showAlert('Saved successfully.', 'Save');
 | |
|                     if ((name == "Hide" && value && !$('#chkShowHidden').prop("checked"))
 | |
|                         || (name == "Attachment" && value && !$('#chkAttachment').prop("checked")))
 | |
|                         OnRefresh();
 | |
|                 } else {
 | |
|                     showAlert(data, GetTextByKey("P_MA_ERROR", 'Error'));
 | |
|                 }
 | |
|             });
 | |
|         }
 | |
| 
 | |
|         function OnExport() {
 | |
|             var contractorid = htmlencode($.trim($('#sel_contractor').val()));
 | |
|             var sharestatus = $('#selsharestatus').val();
 | |
|             var onroad = $('#selonroad').val();
 | |
| 
 | |
|             var searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
 | |
|             var showHidden = $('#chkShowHidden').prop("checked") ? 1 : 0;
 | |
| 
 | |
|             var ps = ["shareassets", contractorid, sharestatus, onroad, JSON.stringify(models), JSON.stringify(years), JSON.stringify(assettypes), searchtxt, showHidden, attachment];
 | |
| 
 | |
|             var data = new FormData();
 | |
|             data.append('type', 'set');
 | |
|             data.append('ClientData', JSON.stringify(ps));
 | |
|             $.ajax({
 | |
|                 url: "../ExportToFile.aspx",
 | |
|                 type: 'POST',
 | |
|                 dataType: 'json',
 | |
|                 processData: false,
 | |
|                 contentType: false,
 | |
|                 data: data,
 | |
|                 success: function (data) {
 | |
|                     if (data && data != "")
 | |
|                         window.open("../ExportToFile.aspx?type=exp&key=" + data);
 | |
|                 },
 | |
|                 error: function (err) {
 | |
|                 }
 | |
|             });
 | |
|         }
 | |
| 
 | |
|     </script>
 | |
| </asp:Content>
 | |
| <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
 | |
|     <div id="recordcontent" style="padding: 0px; margin: 0px;">
 | |
|         <div class="page_title">
 | |
|             <span data-lgid="P_SHAREASSETS">Share Assets</span>
 | |
|             <%if (IsSupperAdmin)
 | |
|                 {%>
 | |
|             <span class="sbutton iconcog" style="float: right; font-size: 14px; margin-right: 15px; cursor: pointer;" onclick="openShareWithSetting();">
 | |
|                 <label data-lgid="P_XXXXXX">Setting</label></span>
 | |
|             <%}%>
 | |
|             <div style="clear: both;"></div>
 | |
|         </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_MA_CONTRACTOR_COLON">Contractor:</span>
 | |
|                 <select id="sel_contractor"></select></span>
 | |
|             <select id="selsharestatus" style="width: unset;" onchange="OnRefresh();">
 | |
|                 <option value="-1">All</option>
 | |
|                 <option value="1">Shared</option>
 | |
|                 <option value="0">Not Shared</option>
 | |
|             </select>
 | |
|             <select id="selonroad" style="width: unset; margin-left: 5px;" onchange="OnRefresh();">
 | |
|                 <option value="-1">All</option>
 | |
|                 <option value="1">Onroad</option>
 | |
|                 <option value="0">Offroad</option>
 | |
|             </select>
 | |
|             <input id="searchinputtxt" type="text" autocomplete="off" style="margin-left: 5px;" />
 | |
|             <input class="search" type="button" onclick="OnRefresh();" style="margin-left: 5px;" value="" data-lgid="P_MA_SEARCH" />
 | |
|             <input id="chkShowHidden" type="checkbox" onclick="OnRefresh();" style="margin-left: 20px;" /><label for="chkShowHidden" data-lgid="P_MA_SHOWHIDDEN">Show Hidden</label>
 | |
|         </div>
 | |
|         <div class="function_title">
 | |
|             <span class="sbutton iconshare" onclick="OnShare();" data-lgid="P_MA_XXXXXX">Share</span>
 | |
|             <span class="sbutton iconunshare" onclick="OnUnShare();" data-lgid="P_MA_XXXXXX">UnShare</span>
 | |
|             <span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_MA_REFRESH">Refresh</span>
 | |
|             <span id="spExport" class="sbutton iconexport" onclick="OnExport();" style="display: none;" data-lgid="P_UTILITY_EXPORTTOEXCEL">Export to Excel</span>
 | |
|             <span class="sbutton iconlayout iconmenu" data-lgid="P_MR_LAYOUT">Layout</span>
 | |
|         </div>
 | |
|         <div class="clear"></div>
 | |
|         <div id="machinelist">
 | |
|         </div>
 | |
|     </div>
 | |
| 
 | |
|     <div id="mask_bg" style="display: none;">
 | |
|         <div class="loading c-spin"></div>
 | |
|     </div>
 | |
|     <div class="dialog" id="dialog_machine1" style="display: none; height: 100%; border-bottom: 0; border-top: 0; z-index: 2;">
 | |
|         <%--<div class="dialog-title"><span class="title">Add Work Order</span></div>--%>
 | |
|         <iframe id="iframemachine" style="width: 100%; height: 100%; display: block; border: none;"></iframe>
 | |
|         <div class="maskbg" style="display: none;"></div>
 | |
|     </div>
 | |
| 
 | |
|     <div class="dialog" id="dialog_assetview" style="display: none; height: 100%; border-bottom: 0; border-top: 0; z-index: 2;">
 | |
|         <%--<div class="dialog-title"><span class="title">Add Work Order</span></div>--%>
 | |
|         <iframe id="iframeassetview" src="../AssetView/SingleAssetView.aspx" style="width: 100%; height: 100%; display: block; border: none;"></iframe>
 | |
|         <div class="maskbg" style="display: none;"></div>
 | |
|     </div>
 | |
| 
 | |
|     <div class="dialog" id="dialog_share" style="display: none;">
 | |
|         <div class="dialog-title"><span class="title" data-lgid="P_XXXXXX">Share Assets</span><em class="dialog-close"></em></div>
 | |
|         <div class="dialog-content">
 | |
|             <table id="tab_assetinfo" style="line-height: 30px;">
 | |
|                 <tr>
 | |
|                     <td class="label" data-lgid="P_XXXXXX_COLON">Share Asset With:</td>
 | |
|                     <td>
 | |
|                         <select id="dialog_sharewith" style="width: 202px; height: 22px;"></select>
 | |
|                     </td>
 | |
|                 </tr>
 | |
|                 <tr>
 | |
|                     <td class="label" data-lgid="P_MR_XXXXXX_COLON">Expected End Date:</td>
 | |
|                     <td>
 | |
|                         <input type="text" id="dialog_enddate" maxlength="50" tabindex="10" autocomplete="off" /></td>
 | |
|                 </tr>
 | |
|                 <tr>
 | |
|                     <td class="label" data-lgid="P_XXXXXX_COLON">Hide Asset on this site:</td>
 | |
|                     <td>
 | |
|                         <input type="checkbox" id="dialog_hideasset" style="width: auto;" tabindex="10" /></td>
 | |
|                 </tr>
 | |
|             </table>
 | |
|             <div class="dialog-func">
 | |
|                 <input type="button" value="Cancel" data-lgid="P_MA_CANCEL" class="dialog-close" tabindex="500" />
 | |
|                 <input type="button" value="OK" data-lgid="P_MA_OK" onclick="StartSaveShareAsset();" tabindex="500" />
 | |
|                 <div class="clear"></div>
 | |
|             </div>
 | |
|         </div>
 | |
|         <div class="maskbg" style="display: none;"></div>
 | |
|     </div>
 | |
| 
 | |
|     <div class="dialog" id="dialog_sharewithcustomers" style="display: none;">
 | |
|         <div class="dialog-title"><span class="title" data-lgid="P_XXXXXX">Share With</span><em class="dialog-close"></em></div>
 | |
|         <div class="dialog-content">
 | |
|             <div id="customerlist" style="height: 400px; width: 400px; margin: 10px 0 4px;"></div>
 | |
|         </div>
 | |
|         <div class="dialog-func">
 | |
|             <input type="button" value="Cancel" data-lgid="P_UM_CANCEL" class="dialog-close" tabindex="18" style="height: unset;" />
 | |
|             <input type="button" onclick="saveShareWithCustomers();" value="OK" data-lgid="P_UM_OK" tabindex="17" />
 | |
|             <div style="clear: both;"></div>
 | |
|         </div>
 | |
|         <div class="maskbg" style="display: none;"></div>
 | |
|     </div>
 | |
| 
 | |
|     <div class="dialog" id="dialog_share_progress" style="display: none;">
 | |
|         <div class="dialog-title"><span class="title" data-lgid="P_XXXXXX">Share Assets Progress</span><em class="dialog-close"></em></div>
 | |
|         <div class="dialog-content">
 | |
|             <div id="grid_progress" style="width: 1000px; height: 400px"></div>
 | |
|             <div class="dialog-func">
 | |
|                 <input type="button" value="Cancel" data-lgid="P_MA_CANCEL" class="dialog-close" tabindex="500" />
 | |
|                 <input id="button_progress_retry" style="display: none" type="button" value="Retry" data-lgid="P_XXXXXX" onclick="RetryShare();" tabindex="500" />
 | |
|                 <div class="clear"></div>
 | |
|             </div>
 | |
|         </div>
 | |
|         <div class="maskbg" style="display: none;"></div>
 | |
|     </div>
 | |
| </asp:Content>
 |