add site
This commit is contained in:
		
							
								
								
									
										1
									
								
								Site
									
									
									
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										1
									
								
								Site
									
									
									
									
									
								
							 Submodule Site deleted from 52722c5b42
									
								
							
							
								
								
									
										2
									
								
								Site/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								Site/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| Bin/iicontractorbl.dll | ||||
| Bin/iicontractorsitelib.dll | ||||
							
								
								
									
										463
									
								
								Site/AssetView/AssetLocationHis.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										463
									
								
								Site/AssetView/AssetLocationHis.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,463 @@ | ||||
| <%@ Page Language="C#" AutoEventWireup="true" CodeFile="AssetLocationHis.aspx.cs" Inherits="AssetLocationHis" %> | ||||
|  | ||||
| <!DOCTYPE html> | ||||
|  | ||||
| <html xmlns="http://www.w3.org/1999/xhtml"> | ||||
| <head runat="server"> | ||||
|     <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||||
|     <title></title> | ||||
|     <style> | ||||
|         html, | ||||
|         body { | ||||
|             /*font-family: sans-serif;*/ | ||||
|             padding: 0; | ||||
|             margin: 0; | ||||
|             height: 100%; | ||||
|             width: 100%; | ||||
|         } | ||||
|  | ||||
|         #layout { | ||||
|             position: absolute; | ||||
|             right: 320px; | ||||
|             left: 0; | ||||
|             top: 0; | ||||
|             bottom: 0; | ||||
|         } | ||||
|  | ||||
|         #divsetting { | ||||
|             position: absolute; | ||||
|             width: 320px; | ||||
|             height: 35%; | ||||
|             right: 0; | ||||
|             top: 0; | ||||
|             bottom: 0; | ||||
|         } | ||||
|  | ||||
|         #content { | ||||
|             width: 100%; | ||||
|             top: 0px; | ||||
|             bottom: 0; | ||||
|             margin: 0; | ||||
|             position: fixed; | ||||
|             /*color: #6b6b6b;*/ | ||||
|             overflow: auto; | ||||
|         } | ||||
|  | ||||
|         #parameter_left { | ||||
|             background: #f4f4f4; | ||||
|             height: 100%; | ||||
|             width: 200px; | ||||
|             float: left; | ||||
|             color: #000; | ||||
|             position: relative; | ||||
|         } | ||||
|  | ||||
|         div { | ||||
|             cursor: default; | ||||
|         } | ||||
|     </style> | ||||
|     <style type="text/css"> | ||||
|         .data-grid { | ||||
|             height: 100%; | ||||
|             font-size: 12px !important; | ||||
|             font-family: "Segoe UI","Segoe UI Web (West European)","Segoe UI",-apple-system,BlinkMacSystemFont,"Roboto","Helvetica Neue",sans-serif !important; | ||||
|         } | ||||
|     </style> | ||||
|     <link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/default.css")%>" type="text/css" /> | ||||
|     <link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/split_sub.css")%>" type="text/css" /> | ||||
|     <link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/split_sub.css")%>" /> | ||||
|     <link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/mapview.css")%>" /> | ||||
|     <link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/editmultiselect.css")%>" /> | ||||
|     <link rel="stylesheet" href="https://js.arcgis.com/3.40/esri/css/esri.css" /> | ||||
|     <link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" /> | ||||
|     <link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/playbar.css")%>" /> | ||||
|     <link type="text/css" href="<%=GetFileUrlWithVersion("../js/components/css/gridview.css") %>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=GetFileUrlWithVersion("../css/override.css") %>" rel="stylesheet" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("../css/panel.css")%>" rel="stylesheet" type="text/css" /> | ||||
|     <link rel="stylesheet" href="<%=GetFileUrlWithVersion("../fic/fic/css/form.css")%>" /> | ||||
|  | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/jquery-" + (JQueryVersion ?? "3.6.0") + ".min.js")%>" type="text/javascript"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/utility.js")%>" type="text/javascript"></script> | ||||
|     <script type="text/javascript" src="<%=GetFileUrlWithVersion("../js/components/gridview.js") %>"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("../fic/js/utility.js")%>" type="text/javascript"></script> | ||||
|     <script type="text/javascript" src="<%=GetFileUrlWithVersion("../fic/fic/js/controls/form.js") %>"></script> | ||||
|  | ||||
|     <script> | ||||
|         var GridView = window.GridView || window['g5-gridview']; | ||||
|         //必须放在地图js之前 | ||||
|         var dojoConfig = { | ||||
|             paths: { | ||||
|                 extras1: location.pathname.replace(/\/[^/]+$/, "") + "/../js/mapview" | ||||
|             }, | ||||
|             cacheBust: true | ||||
|         }; | ||||
|     </script> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/cookie.js")%>"></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 src="https://js.arcgis.com/3.40"></script> | ||||
|     <%--<script src="<%=GetFileUrlWithVersion("js/mapinit3.19.js")%>"></script>--%> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/language.js")%>"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/mapview/asset.js")%>"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/mapview/maphelper.js")%>"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/mapview/mapview.js")%>"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/mapview/playbar.js")%>"></script> | ||||
|     <script type="text/javascript"> | ||||
|         _network.root = '<%=Page.ResolveUrl("~/")%>'; | ||||
|         var currentdate = "<%=CurrentDate %>"; | ||||
|         var MachineID; | ||||
|  | ||||
|         var isMapLoaded = false; | ||||
|         var leftCtrlWidth = 390; | ||||
|         var rightCtrlWidth = 280; | ||||
|         var mapHelper; | ||||
|         var machineAlert; | ||||
|         var userParams = undefined; | ||||
|         var assetObject = undefined; | ||||
|  | ||||
|         var notShowDetail = true; | ||||
|         var notShowIcons = true; | ||||
|         //enableInfoWindow = false; | ||||
|         var Datasource = ""; | ||||
|  | ||||
|         var PopupViewShowing = false; | ||||
|  | ||||
|         var serVersion = ""; | ||||
|         var enableSmartWitness = <%=EnableSmartWitness?"true":"false"%>; | ||||
|  | ||||
|         _network.assetmapviewquery = function (method, param, callback, error, nolog) { | ||||
|             _network.request("AssetView/AssetMapView.aspx?tp=ashx", -1, method, param, callback, error, nolog); | ||||
|         } | ||||
|  | ||||
|         function init() { | ||||
|             loadMap(); | ||||
|         } | ||||
|  | ||||
|         function loadMap() { | ||||
|             mapHelper = new MapHelper(onMapInitialized); | ||||
|             mapHelper.notShowInfoWindow = true; | ||||
|             assetObject = new AssetObject(mapHelper); | ||||
|         } | ||||
|  | ||||
|         function onMapInitialized() { | ||||
|             isMapLoaded = true; | ||||
|             initData(onDataInitialized); | ||||
|         } | ||||
|  | ||||
|         function initData(callback) { | ||||
|             $("#historyCtrl").show();//所有类型站点都显示Show History | ||||
|             //$("#contentCtrl").css("bottom", "184px"); | ||||
|  | ||||
|             $("#autoRecenterDiv").show(); | ||||
|  | ||||
|             //assetObject.getContractor(callback); | ||||
|             if (callback) | ||||
|                 callback(); | ||||
|         } | ||||
|  | ||||
|         function onDataInitialized() { | ||||
|             isMapLoaded = true; | ||||
|             refreshData(); | ||||
|         } | ||||
|  | ||||
|         function refreshData() { | ||||
|             try { | ||||
|                 assetObject.getCompanyLocations(); | ||||
|                 getJobSites(); | ||||
|             } | ||||
|             catch (e) { | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function getJobSites() { | ||||
|             var ctr = $("#selContractor").val(); | ||||
|             if (!ctr) ctr = ""; | ||||
|  | ||||
|             var item = { | ||||
|                 'IsAutoRefresh': false, | ||||
|                 'ContractorID': ctr, | ||||
|                 'SearchText': '', | ||||
|                 'Onroad': '-1', | ||||
|             }; | ||||
|             _network.mapviewquery("GetJobSites", JSON.stringify(item), function (data) { | ||||
|                 if (data != "-1") { | ||||
|                     for (var i = 0; i < data.length; i++) { | ||||
|                         var js = data[i]; | ||||
|                         mapHelper.showJobSite(js); | ||||
|                     } | ||||
|                 } | ||||
|             }, function () { | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function getlocationhis(cid, aid, name) { | ||||
|             var lcid = $("#selContractor").val(); | ||||
|             if (lcid != cid) | ||||
|                 getJobSites(); | ||||
|  | ||||
|             $("#selContractor").val(cid); | ||||
|             MachineID = aid; | ||||
|             var e = { | ||||
|                 data: { CompanyID: cid, ID: aid, DisplayName: name } | ||||
|             }; | ||||
|             locationHistoryClick(e); | ||||
|         } | ||||
|  | ||||
|         function GetLanguageByCookie() { | ||||
|             var lang = getCookie('<%=Common.LanguageCookieName%>'); | ||||
|             if (lang == null) { | ||||
|                 return "en-us"; | ||||
|             } else { | ||||
|                 return lang; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $(function () { | ||||
|             _fleet.currentLang = GetLanguageByCookie(); | ||||
|             $("#content").applyFleetLanguageText(true); | ||||
|             init(); | ||||
|             initPlayBar(); | ||||
|  | ||||
|             $("#btnLoadLocationHistory").click(null, function (e) { | ||||
|                 //locationHistoryClick(); | ||||
|                 getLocationHistory(); | ||||
|             }); | ||||
|             $('#btnQuickLoadLocationHistory').click(null, function () { | ||||
|                 getLocationHistory(true); | ||||
|             }); | ||||
|  | ||||
|             $("#btnClearLocationHistory").click(null, function (e) { | ||||
|                 clearLocationHistory(); | ||||
|                 $("#locationhistoryDiv").hide(); | ||||
|                 $("#tripDiv").hide(); | ||||
|             }); | ||||
|  | ||||
|             $('#btnLoadTrip').click(null, function () { | ||||
|                 getLocationHistory(true); | ||||
|                 openTrips(true); | ||||
|             }); | ||||
|  | ||||
|             $("#btnClearTrip").click(null, function (e) { | ||||
|                 $("#tripDiv").hide(); | ||||
|                 $("#tbTrips").empty(); | ||||
|             }); | ||||
|  | ||||
|  | ||||
|             $("#showDealerLocationsDiv").click(null, function (e) { | ||||
|                 if ($("#showDealerLocationsDiv").attr("state") == "0") { | ||||
|                     assetObject.showLocations(); | ||||
|                     $("#showDealerLocationsDiv").attr("state", "1").attr("title", GetTextByKey("P_MV_TURNOFFDEALERLOCATIONS", "Turn Off Dealer Locations")); | ||||
|                 } | ||||
|                 else { | ||||
|                     assetObject.clearLocations(); | ||||
|                     $("#showDealerLocationsDiv").attr("state", "0").attr("title", GetTextByKey("P_MV_TURNONDEALERLOCATIONS", "Turn On Dealer Locations")); | ||||
|                 } | ||||
|             }); | ||||
|  | ||||
|             $("#basemapgalleryDiv").click(null, function (e) { | ||||
|                 $("#basemapGallery").show(); | ||||
|             }); | ||||
|  | ||||
|             $("#dateTo").datetimepicker({ | ||||
|                 timepicker: false, | ||||
|                 format: 'm/d/Y', | ||||
|                 scrollMonth: false, | ||||
|                 scrollTime: false, | ||||
|                 scrollInput: false, | ||||
|             }); | ||||
|             $("#dateFrom").datetimepicker({ | ||||
|                 timepicker: false, | ||||
|                 format: 'm/d/Y', | ||||
|                 scrollMonth: false, | ||||
|                 scrollTime: false, | ||||
|                 scrollInput: false, | ||||
|             }); | ||||
|  | ||||
|             $("#dialog_timeperiod").change(null, function (e) { | ||||
|                 currentdate = getCurrentDate(); | ||||
|                 var timeperiod = $("#dialog_timeperiod").val(); | ||||
|                 var disabled = false; | ||||
|  | ||||
|                 if (timeperiod !== "4") { | ||||
|                     disabled = true; | ||||
|                     var time = new Date(currentdate); | ||||
|                     var nowtime = new Date(currentdate); | ||||
|                     var hours = nowtime.getHours(); | ||||
|                     var minutes = nowtime.getMinutes(); | ||||
|                     if (timeperiod === "2") { | ||||
|                         time.setDate(time.getDate() - 1); | ||||
|                         nowtime.setDate(nowtime.getDate() - 1); | ||||
|                     } | ||||
|                     else if (timeperiod === "3") { | ||||
|                         time.setDate(time.getDate() - 6); | ||||
|                     } | ||||
|                     else if (timeperiod === "5") { | ||||
|                         time.setDate(time.getDate() - 1); | ||||
|                     } | ||||
|  | ||||
|                     time = time.getMonth() + 1 + "/" + time.getDate() + "/" + time.getFullYear(); | ||||
|                     nowtime = nowtime.getMonth() + 1 + "/" + nowtime.getDate() + "/" + nowtime.getFullYear(); | ||||
|                     $('#dateFrom').val(time); | ||||
|                     $('#dateTo').val(nowtime); | ||||
|                     $('#dialog_starttimehour').val('00'); | ||||
|                     $('#dialog_starttimeminute').val('00'); | ||||
|                     $('#dialog_endtimehour').val('23'); | ||||
|                     $('#dialog_endtimeminute').val('59'); | ||||
|  | ||||
|                     if (timeperiod === "5") { | ||||
|                         var s_minutes = minutes + 1; | ||||
|                         var s_hours = hours; | ||||
|  | ||||
|                         if (minutes == 59) { | ||||
|                             s_hours = s_hours + 1; | ||||
|                             s_minutes = 0; | ||||
|                         } | ||||
|  | ||||
|                         $('#dialog_starttimehour').val(setTimeSelect(s_hours)); | ||||
|                         $('#dialog_starttimeminute').val(setTimeSelect(s_minutes)); | ||||
|                         $('#dialog_endtimehour').val(setTimeSelect(hours)); | ||||
|                         $('#dialog_endtimeminute').val(setTimeSelect(minutes)); | ||||
|                     } | ||||
|                 } | ||||
|             }); | ||||
|             //$("#splitIcon").click(); | ||||
|             initTime(); | ||||
|             var time = new Date(currentdate); | ||||
|             time = (time.getMonth() + 1) + "/" + time.getDate() + "/" + time.getFullYear(); | ||||
|             $('#dateFrom').val(time); | ||||
|             $('#dateTo').val(time); | ||||
|             $('#dialog_starttimehour').val('00'); | ||||
|             $('#dialog_starttimeminute').val('00'); | ||||
|             $('#dialog_endtimehour').val('23'); | ||||
|             $('#dialog_endtimeminute').val('59'); | ||||
|         }); | ||||
|  | ||||
|         function setTimeSelect(time) { | ||||
|             if (time.toString().length == 1) | ||||
|                 return "0" + time; | ||||
|             else | ||||
|                 return time.toString(); | ||||
|         } | ||||
|  | ||||
|         function initTime() { | ||||
|             var c = $('#dialog_starttimehour'); | ||||
|             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 = $('#dialog_starttimeminute'); | ||||
|             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 = $('#dialog_endtimehour'); | ||||
|             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 = $('#dialog_endtimeminute'); | ||||
|             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)) | ||||
|             } | ||||
|         } | ||||
|     </script> | ||||
| </head> | ||||
| <body> | ||||
|     <form id="form1" runat="server"> | ||||
|         <div id="content" style="margin-top: 2px;"> | ||||
|             <input id="selContractor" type="hidden" /> | ||||
|             <div id="layout"> | ||||
|                 <div> | ||||
|                     <div id="mapView"> | ||||
|                     </div> | ||||
|                     <div id="basemapgalleryDiv"> | ||||
|                         <div id="basemapImg"></div> | ||||
|                         <div id="basemapTitle"></div> | ||||
|                     </div> | ||||
|                     <div id="basemapGallery"></div> | ||||
|                 </div> | ||||
|                 <div id="showDealerLocationsDiv" style="display: none; top: 90px;" state="1" title="Turn Off Dealer Locations" data-title-lgid="P_MV_TURNOFFDEALERLOCATIONS"> | ||||
|                     <%=Logo1 %> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div id="divsetting"> | ||||
|                 <table style="line-height: 25px;"> | ||||
|                     <tr> | ||||
|                         <td style="padding-left: 5px;" data-lgid="P_MV_ASSET_COLON">Asset:</td> | ||||
|                         <td><span id="spMachineName" data-lgid="P_MV_NOASSETSELECTED">No asset selected.</span></td> | ||||
|                     </tr> | ||||
|                     <tr> | ||||
|                         <td style="padding-left: 5px;" data-lgid="P_MV_TIMEPERIOD_COLON">Time Period:</td> | ||||
|                         <td> | ||||
|                             <select id="dialog_timeperiod" tabindex="12" style="width: 90px; height: 22px;"> | ||||
|                                 <option value="1" selected="selected" data-lgid="P_MV_TODAY">Today</option> | ||||
|                                 <option value="5" data-lgid="P_MV_LAST24HOURS">Last 24 Hours</option> | ||||
|                                 <option value="2" data-lgid="P_MV_PRIORDAY">Prior Day</option> | ||||
|                                 <option value="3" data-lgid="P_MV_LAST7DAYS">Last 7 Days</option> | ||||
|                                 <option value="4" data-lgid="P_MV_CUSTOM">Custom</option> | ||||
|                             </select></td> | ||||
|                     </tr> | ||||
|                     <tr> | ||||
|                         <td style="padding-left: 5px;" data-lgid="P_MV_FROM_COLON">From:</td> | ||||
|                         <td> | ||||
|                             <input type="text" id="dateFrom" maxlength="12" tabindex="27" style="width: 70px;" /> | ||||
|                             <select id="dialog_starttimehour" style="width: 48px; margin-left: 3px;" tabindex="3"></select><span style="font-weight: bold;"> : </span> | ||||
|                             <select id="dialog_starttimeminute" style="width: 48px; margin-left: 0;" tabindex="4"></select> | ||||
|                         </td> | ||||
|  | ||||
|                     </tr> | ||||
|                     <tr> | ||||
|                         <td style="padding-left: 5px;" data-lgid="P_MV_TO_COLON">To:</td> | ||||
|                         <td> | ||||
|                             <input type="text" id="dateTo" maxlength="12" tabindex="27" style="width: 70px;" /> | ||||
|                             <select id="dialog_endtimehour" style="width: 48px; margin-left: 3px;" tabindex="5"></select><span style="font-weight: bold;"> : </span> | ||||
|                             <select id="dialog_endtimeminute" style="width: 48px; margin-left: 0;" tabindex="6"></select> | ||||
|                         </td> | ||||
|                     </tr> | ||||
|                     <tr> | ||||
|                         <td colspan="2" style="text-align: center; width: 180px;"> | ||||
|                             <div id="divPlayBar" style="background-color: #C0C0C0;"></div> | ||||
|                         </td> | ||||
|                     </tr> | ||||
|                     <tr> | ||||
|                         <td colspan="2" style="text-align: right;"> | ||||
|                             <input id="chkExclude00Loc" style="display: none" checked="checked" type="checkbox" /><span style="margin-right: 10px; display: none" data-lgid="P_MV_TO_EXCLUDE00LOCATIONS">Exclude 0,0 Locations</span> | ||||
|                             <%--<input type="button" value="Quick Load" data-lgid="P_MV_QUICKLOAD" id="btnQuickLoadLocationHistory" />--%> | ||||
|                             <%--<input type="button" value="Playback" data-lgid="P_MV_PLAYBACK" id="btnLoadLocationHistory" />--%> | ||||
|                             <%--<span class="clearbtn" id="btnClearLocationHistory" style="margin-left: 5px;"></span>--%> | ||||
|                             <%--<input type="button" value="Clear" data-lgid="P_MV_CLEAR" id="btnClearLocationHistory" /> | ||||
|                             <input type="button" value="Trip" data-lgid="P_MV_TRIP" id="btnLoadTrip" style="display: none;" />--%> | ||||
|                             <%--<span id="btnQuickLoadLocationHistory" class="QuickLoad" style="margin-left: 6px;" title="Quick Load/Skip to End" data-title-lgid="P_MV_QUICKLOADSKIPTOEND"></span>--%> | ||||
|                             <span id="btnHisLoading" class="QuickLoading" style="margin-left: 6px; display: none;"></span> | ||||
|                             <span id="btnLoadTrip" class="TripReport" style="margin-left: 6px;" title="Trip Report" data-title-lgid="P_MV_TRIPREPORT"></span> | ||||
|                             <span class="clearbtn" id="btnClearLocationHistory" style="margin-left: 6px;" title="Clear" data-title-lgid="P_MV_CLEAR"></span> | ||||
|  | ||||
|                         </td> | ||||
|                     </tr> | ||||
|                 </table> | ||||
|             </div> | ||||
|             <div id="tripDiv" style="display: none;"> | ||||
|                 <div> | ||||
|                     <span class="clearbtn" id="btnClearTrip" style="float: right; padding: 5px;"></span> | ||||
|                 </div> | ||||
|                 <div style="position: absolute; top: 30px; bottom: 0; right: 0; overflow: auto; width: 100%;"> | ||||
|                     <table id="tbTrips" style="line-height: 24px; border-collapse: collapse; border-spacing: 0; width: 100%;"> | ||||
|                     </table> | ||||
|                 </div> | ||||
|             </div> | ||||
|  | ||||
|             <div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div> | ||||
|         </div> | ||||
|     </form> | ||||
| </body> | ||||
| </html> | ||||
							
								
								
									
										111
									
								
								Site/AssetView/AssetLocationHis.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										111
									
								
								Site/AssetView/AssetLocationHis.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,111 @@ | ||||
| using DocumentFormat.OpenXml.Wordprocessing; | ||||
| using Foresight.Fleet.Services.Asset; | ||||
| using Foresight.Fleet.Services.Customer; | ||||
| using IronIntel.Contractor; | ||||
| using IronIntel.Contractor.Machines; | ||||
| using IronIntel.Contractor.MapView; | ||||
| using IronIntel.Contractor.Site; | ||||
| using Newtonsoft.Json; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Web; | ||||
| using System.Web.UI; | ||||
| using System.Web.UI.WebControls; | ||||
|  | ||||
| public partial class AssetLocationHis : ContractorBasePage | ||||
| { | ||||
|     public string LocationHistoryDateFrom = DateTime.Now.Date.AddMonths(-2).ToShortDateString(); | ||||
|     public string LocationHistoryDateTo = DateTime.Now.Date.ToShortDateString(); | ||||
|  | ||||
|     private string Logo1html = "<img class=\"logo\" src=\"{0}\" style=\"width:24px;height:24px; \" />"; | ||||
|     protected string Logo1 = ""; | ||||
|     public string CurrentDate = ""; | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     { | ||||
|         string tp = Request.Params["tp"]; | ||||
|         if (string.Compare(tp, "ashx", true) == 0) | ||||
|         { | ||||
|             ProcessRequest(); | ||||
|         } | ||||
|         else if (!IsPostBack) | ||||
|         { | ||||
|             Title = PageTitle; | ||||
|             if (CheckLoginSession()) | ||||
|             { | ||||
|                 var cmp = SystemParams.GetCompanyInfo(); | ||||
|                 GetLogoHtml(cmp); | ||||
|             } | ||||
|         } | ||||
|         DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow); | ||||
|         CurrentDate = userlocaldate.ToShortDateString(); | ||||
|     } | ||||
|  | ||||
|     private void GetLogoHtml(CustomerInfo cmp) | ||||
|     { | ||||
|         var root = ResolveUrl("~/"); | ||||
|         if (cmp.IsContractor) | ||||
|         {//Logo1 Dealer; | ||||
|             CustomerInfo dealer = SystemParams.GetFirstDealerInfo(); | ||||
|             if (dealer != null) | ||||
|             { | ||||
|                 if (SystemParams.HasLOGO(dealer.ID))//Dealer | ||||
|                 { | ||||
|                     Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?tp=dealer&cmpid=" + dealer.ID); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     Logo1 = string.Format("<div class=\"logo\">{0}</div>", dealer.Name); | ||||
|                 } | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 Logo1 = string.Empty; | ||||
|             } | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             if (SystemParams.HasLOGO(cmp.ID))//Dealer | ||||
|             { | ||||
|                 Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?tp=dealer&cmpid=" + cmp.ID); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 Logo1 = string.Format("<div class=\"logo\">{0}</div>", cmp.Name); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     protected void ProcessRequest() | ||||
|     { | ||||
|         object result = null; | ||||
|  | ||||
|         string methodName = Request.Form["MethodName"]; | ||||
|         try | ||||
|         { | ||||
|             if (methodName != null) | ||||
|             { | ||||
|             } | ||||
|         } | ||||
|         catch (System.Threading.ThreadAbortException) | ||||
|         { | ||||
|             throw; | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         { | ||||
|             SystemParams.WriteLog("error", "MapViewChart." + methodName, ex.Message, ex.ToString()); | ||||
|         } | ||||
|         string json = JsonConvert.SerializeObject(result); | ||||
|         Response.Write(json); | ||||
|         Response.End(); | ||||
|     } | ||||
|  | ||||
|     public bool EnableSmartWitness | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             bool lic = SystemParams.HasLicense("SmartWitness"); | ||||
|             return lic; | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										269
									
								
								Site/AssetView/AssetMapView.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										269
									
								
								Site/AssetView/AssetMapView.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,269 @@ | ||||
| <%@ Page Language="C#" AutoEventWireup="true" CodeFile="AssetMapView.aspx.cs" Inherits="AssetMapView" %> | ||||
|  | ||||
| <!DOCTYPE html> | ||||
|  | ||||
| <html xmlns="http://www.w3.org/1999/xhtml"> | ||||
| <head runat="server"> | ||||
|     <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||||
|     <title></title> | ||||
|     <style> | ||||
|         html, | ||||
|         body { | ||||
|             /*font-family: sans-serif;*/ | ||||
|             padding: 0; | ||||
|             margin: 0; | ||||
|             height: 100%; | ||||
|             width: 100%; | ||||
|         } | ||||
|  | ||||
|         #content { | ||||
|             width: 100%; | ||||
|             top: 0px; | ||||
|             bottom: 0; | ||||
|             margin: 0; | ||||
|             position: fixed; | ||||
|             /*color: #6b6b6b;*/ | ||||
|             overflow: auto; | ||||
|         } | ||||
|  | ||||
|         #parameter_left { | ||||
|             background: #f4f4f4; | ||||
|             height: 100%; | ||||
|             width: 200px; | ||||
|             float: left; | ||||
|             color: #000; | ||||
|             position: relative; | ||||
|         } | ||||
|  | ||||
|         div { | ||||
|             cursor: default; | ||||
|         } | ||||
|     </style> | ||||
|     <style type="text/css"> | ||||
|         .data-grid { | ||||
|             height: 100%; | ||||
|             font-size: 12px !important; | ||||
|             font-family: "Segoe UI","Segoe UI Web (West European)","Segoe UI",-apple-system,BlinkMacSystemFont,"Roboto","Helvetica Neue",sans-serif !important; | ||||
|         } | ||||
|     </style> | ||||
|     <link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/default.css")%>" type="text/css" /> | ||||
|     <link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/split_sub.css")%>" type="text/css" /> | ||||
|     <link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/split_sub.css")%>" /> | ||||
|     <link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/mapview.css")%>" /> | ||||
|     <link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/editmultiselect.css")%>" /> | ||||
|     <link rel="stylesheet" href="https://js.arcgis.com/3.40/esri/css/esri.css" /> | ||||
|     <link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" /> | ||||
|     <link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/playbar.css")%>" /> | ||||
|     <link type="text/css" href="<%=GetFileUrlWithVersion("../js/components/css/gridview.css") %>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=GetFileUrlWithVersion("../css/override.css") %>" rel="stylesheet" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("../css/panel.css")%>" rel="stylesheet" type="text/css" /> | ||||
|  | ||||
|  | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/jquery-" + (JQueryVersion ?? "3.6.0") + ".min.js")%>" type="text/javascript"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/cookie.js")%>"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/utility.js")%>" type="text/javascript"></script> | ||||
|     <script type="text/javascript" src="<%=GetFileUrlWithVersion("../js/components/gridview.js") %>"></script> | ||||
|     <script> | ||||
|         var GridView = window.GridView || window['g5-gridview']; | ||||
|         //必须放在地图js之前 | ||||
|         var dojoConfig = { | ||||
|             paths: { | ||||
|                 extras1: location.pathname.replace(/\/[^/]+$/, "") + "/../js/mapview" | ||||
|             }, | ||||
|             cacheBust: true | ||||
|         }; | ||||
|     </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 src="https://js.arcgis.com/3.40"></script> | ||||
|     <%--<script src="<%=GetFileUrlWithVersion("js/mapinit3.19.js")%>"></script>--%> | ||||
|     <%--<script src="<%=GetFileUrlWithVersion("../js/mapview.js")%>"></script>--%> | ||||
|     <%--<script src="<%=GetFileUrlWithVersion("../js/playbar.js")%>"></script>--%> | ||||
|  | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/language.js")%>"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/mapview/asset.js")%>"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/mapview/maphelper.js")%>"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/mapview/mapview.js")%>"></script> | ||||
|     <script type="text/javascript"> | ||||
|         _network.root = '<%=Page.ResolveUrl("~/")%>'; | ||||
|         var MachineID = "<%=MachineID %>"; | ||||
|         var VIN = '<%=VIN.Replace("'","\\'") %>'; | ||||
|         var Datasource = "<%=Datasource %>"; | ||||
|         var currentdate = "<%=CurrentDate %>"; | ||||
|  | ||||
|         var isMapLoaded = false; | ||||
|         var leftCtrlWidth = 390; | ||||
|         var rightCtrlWidth = 280; | ||||
|         var mapHelper; | ||||
|         var machineAlert; | ||||
|         var userParams = undefined; | ||||
|         var assetObject = undefined; | ||||
|  | ||||
|         var notShowDetail = true; | ||||
|         var notShowIcons = true; | ||||
|         enableInfoWindow = false; | ||||
|         var canEditAsset = false; | ||||
|         var canViewWorkOrder = false; | ||||
|         var canViewMR = false; | ||||
|         showMapSlider = false; | ||||
|         var showTooltipIcons = false; | ||||
|  | ||||
|         var serVersion = ""; | ||||
|  | ||||
|         _network.assetmapviewquery = function (method, param, callback, error, nolog) { | ||||
|             _network.request("AssetView/AssetMapView.aspx?tp=ashx", -1, method, param, callback, error, nolog); | ||||
|         } | ||||
|  | ||||
|         function init() { | ||||
|             loadMap(); | ||||
|         } | ||||
|  | ||||
|         function loadMap() { | ||||
|             mapHelper = new MapHelper(onMapInitialized); | ||||
|             mapHelper.notShowInfoWindow = true; | ||||
|             assetObject = new AssetObject(mapHelper); | ||||
|         } | ||||
|  | ||||
|         function onMapInitialized() { | ||||
|             isMapLoaded = true; | ||||
|             initData(onDataInitialized); | ||||
|         } | ||||
|  | ||||
|         function initData(callback) { | ||||
|             $("#historyCtrl").show();//所有类型站点都显示Show History | ||||
|             //$("#contentCtrl").css("bottom", "184px"); | ||||
|  | ||||
|             $("#autoRecenterDiv").show(); | ||||
|  | ||||
|             //assetObject.getContractor(callback); | ||||
|             if (callback) | ||||
|                 callback(); | ||||
|         } | ||||
|  | ||||
|         function onDataInitialized() { | ||||
|             isMapLoaded = true; | ||||
|             refreshData(); | ||||
|             setInterval(refreshData, 60 * 1000);//开启定时刷新 | ||||
|         } | ||||
|  | ||||
|         function refreshData() { | ||||
|             try { | ||||
|                 getMachineItem(); | ||||
|                 //assetObject.getCompanyLocations(); | ||||
|             } | ||||
|             catch (e) { | ||||
|                 machineAlert = _dialog.showAlert(GetTextByKey("P_MV_UNABLETOOBTAINASSETDATAATTEMPTINGTORECONNECT", 'Unable to obtain asset data.  Attempting to reconnect...'), GetTextByKey("P_MV_REFRESHASSETDATA", 'Refresh asset data')); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function getMachineItem() { | ||||
|             _network.assetmapviewquery("GetMachineItem", htmlencode(JSON.stringify([MachineID, VIN, Datasource])), function (data) { | ||||
|                 if (data && typeof (data) !== "string") { | ||||
|                     if (data.Location) { | ||||
|                         data.Latitude = data.Location.Latitude; | ||||
|                         data.Longitude = data.Location.Longitude; | ||||
|                     } | ||||
|  | ||||
|                     mapHelper.clearMachine(); | ||||
|                     mapHelper.showMachine(data); | ||||
|                     mapHelper.locateMachine(data, true, 14); | ||||
|                     currentLocationHistoryMachine = data; | ||||
|  | ||||
|                     //$("#refreshTimeDiv").text(GetTextByKey("P_MV_LASTREFRESHED", "Last Refreshed: ") + getNowFormatDate()); | ||||
|                 } else | ||||
|                     mapHelper.clearMachine(); | ||||
|                 $('#loadingDiv').hide(); | ||||
|             }, function () { | ||||
|                 $('#loadingDiv').hide(); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function showOtherIcons() { | ||||
|             var leftCtrl = $("#leftCtrl"); | ||||
|             $("#mapMeunDiv").css("left", leftCtrl.width() + 25); | ||||
|         } | ||||
|  | ||||
|         function reloaddata(machineid, vin) { | ||||
|             MachineID = machineid; | ||||
|             VIN = vin; | ||||
|             if (isMapLoaded) { | ||||
|                 bm = getCookie("basemap"); | ||||
|                 if (currentbasemap != bm) { | ||||
|                     currentbasemap = bm; | ||||
|                     mapHelper.changeBaseMap(currentbasemap); | ||||
|                 } | ||||
|                 if ((MachineID && MachineID > 0) | ||||
|                     || (VIN && VIN !== "")) | ||||
|                     refreshData(); | ||||
|                 else | ||||
|                     mapHelper.clearMachine(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function GetLanguageByCookie() { | ||||
|             var lang = getCookie('<%=Common.LanguageCookieName%>'); | ||||
|             if (lang == null) { | ||||
|                 return "en-us"; | ||||
|             } else { | ||||
|                 return lang; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $(function () { | ||||
|             _fleet.currentLang = GetLanguageByCookie(); | ||||
|             currentbasemap = getCookie("basemap"); | ||||
|             $("#content").applyFleetLanguageText(true); | ||||
|             init(); | ||||
|  | ||||
|             $("#showDealerLocationsDiv").click(null, function (e) { | ||||
|                 if ($("#showDealerLocationsDiv").attr("state") == "0") { | ||||
|                     assetObject.showLocations(); | ||||
|                     $("#showDealerLocationsDiv").attr("state", "1").attr("title", GetTextByKey("P_MV_TURNOFFDEALERLOCATIONS", "Turn Off Dealer Locations")); | ||||
|                 } | ||||
|                 else { | ||||
|                     assetObject.clearLocations(); | ||||
|                     $("#showDealerLocationsDiv").attr("state", "0").attr("title", GetTextByKey("P_MV_TURNONDEALERLOCATIONS", "Turn On Dealer Locations")); | ||||
|                 } | ||||
|             }); | ||||
|  | ||||
|             $("#basemapgalleryDiv").click(null, function (e) { | ||||
|                 $("#basemapGallery").show(); | ||||
|             }); | ||||
|  | ||||
|             if (typeof window.parent.ondocumentclick == 'function') { | ||||
|                 $(document.body).click(window.parent.ondocumentclick); | ||||
|             } | ||||
|         }); | ||||
|     </script> | ||||
| </head> | ||||
| <body> | ||||
|     <form id="form1" runat="server"> | ||||
|         <div id="content" style="margin-top: 2px;"> | ||||
|             <input id="selContractor" type="hidden" value="<%=CompanyID %>" /> | ||||
|             <div id="layout"> | ||||
|                 <div> | ||||
|                     <div id="mapView"> | ||||
|                     </div> | ||||
|                     <div id="basemapgalleryDiv" style="display: none;"> | ||||
|                         <div id="basemapImg"></div> | ||||
|                         <div id="basemapTitle"></div> | ||||
|                     </div> | ||||
|                     <div id="basemapGallery"></div> | ||||
|                 </div> | ||||
|                 <div id="mapMeunDiv" style="position: absolute; top: 90px; left: 20px; z-index: 50;"> | ||||
|                     <div id="showDealerLocationsDiv" style="display: none; top: 90px;" state="1" title="Turn Off Dealer Locations"> | ||||
|                         <%=Logo1 %> | ||||
|                     </div> | ||||
|                 </div> | ||||
|                 <div id="loadingDiv" style="display: none;"> | ||||
|                     <div class="loadingmach icnmach icn-spinmach"></div> | ||||
|                 </div> | ||||
|                 <%--<div id="refreshTimeDiv"></div>--%> | ||||
|             </div> | ||||
|  | ||||
|             <div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div> | ||||
|         </div> | ||||
|     </form> | ||||
| </body> | ||||
| </html> | ||||
							
								
								
									
										214
									
								
								Site/AssetView/AssetMapView.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										214
									
								
								Site/AssetView/AssetMapView.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,214 @@ | ||||
| using Foresight.Fleet.Services.Asset; | ||||
| using Foresight.Fleet.Services.Customer; | ||||
| using Foresight.ServiceModel; | ||||
| using IronIntel.Contractor; | ||||
| using IronIntel.Contractor.iisitebase; | ||||
| using IronIntel.Contractor.Machines; | ||||
| using IronIntel.Contractor.MapView; | ||||
| using IronIntel.Contractor.Site; | ||||
| using IronIntel.Contractor.Users; | ||||
| using Newtonsoft.Json; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Web; | ||||
| using System.Web.UI; | ||||
| using System.Web.UI.WebControls; | ||||
|  | ||||
| public partial class AssetMapView : ContractorBasePage | ||||
| { | ||||
|     public string LocationHistoryDateFrom = DateTime.Now.Date.AddMonths(-2).ToShortDateString(); | ||||
|     public string LocationHistoryDateTo = DateTime.Now.Date.ToShortDateString(); | ||||
|  | ||||
|     private string Logo1html = "<img class=\"logo\" src=\"{0}\" style=\"width:24px;height:24px; \" />"; | ||||
|     protected string Logo1 = ""; | ||||
|  | ||||
|     protected string MachineID = ""; | ||||
|     protected string VIN = ""; | ||||
|     protected string Datasource = ""; | ||||
|     protected string CompanyID = ""; | ||||
|     public string CurrentDate = ""; | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     { | ||||
|         string tp = Request.Params["tp"]; | ||||
|         if (string.Compare(tp, "ashx", true) == 0) | ||||
|         { | ||||
|             ProcessRequest(); | ||||
|         } | ||||
|         else if (!IsPostBack) | ||||
|         { | ||||
|             Title = PageTitle; | ||||
|             if (CheckLoginSession()) | ||||
|             { | ||||
|                 var cmp = SystemParams.GetCompanyInfo(); | ||||
|                 GetLogoHtml(cmp); | ||||
|             } | ||||
|  | ||||
|             MachineID = Request.Params["machineid"] ?? ""; | ||||
|             VIN = Request.Params["vin"] ?? ""; | ||||
|             Datasource = Request.Params["ds"] ?? ""; | ||||
|             CompanyID = GetCompanyID(MachineID, VIN); | ||||
|         } | ||||
|  | ||||
|         DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow); | ||||
|         CurrentDate = userlocaldate.ToShortDateString(); | ||||
|     } | ||||
|  | ||||
|     private void GetLogoHtml(CustomerInfo cmp) | ||||
|     { | ||||
|         var root = ResolveUrl("~/"); | ||||
|  | ||||
|         var sessionid = GetLoginSessionID(Request); | ||||
|         StringKeyValue kv = UserManagement.GetSiteHederStyleLogo(sessionid); | ||||
|         string styleid = "-1"; | ||||
|         bool hasDealerLogo = false; | ||||
|         if (kv != null) | ||||
|         { | ||||
|             styleid = kv.Key; | ||||
|             hasDealerLogo = Helper.IsTrue(kv.Tag2); | ||||
|         } | ||||
|  | ||||
|         if (cmp.IsContractor) | ||||
|         {//Logo1 Dealer; | ||||
|             CustomerInfo dealer = SystemParams.GetFirstDealerInfo(); | ||||
|             if (dealer != null) | ||||
|             { | ||||
|                 if (hasDealerLogo)//user Dealer | ||||
|                 { | ||||
|                     Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?tp=dealer&cmpid=" + dealer.ID + "&styid=" + styleid); | ||||
|                 } | ||||
|                 else if (SystemParams.HasLOGO(dealer.ID))//Dealer | ||||
|                 { | ||||
|                     Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?tp=dealer&cmpid=" + dealer.ID); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     Logo1 = string.Format("<div class=\"logo\">{0}</div>", dealer.Name); | ||||
|                 } | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 Logo1 = string.Empty; | ||||
|             } | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             if (hasDealerLogo)//user Dealer | ||||
|             { | ||||
|                 Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?tp=dealer&cmpid=" + cmp.ID + "&styid=" + styleid); | ||||
|             } | ||||
|             else if (SystemParams.HasLOGO(cmp.ID))//Dealer | ||||
|             { | ||||
|                 Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?tp=dealer&cmpid=" + cmp.ID); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 Logo1 = string.Format("<div class=\"logo\">{0}</div>", cmp.Name); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     protected void ProcessRequest() | ||||
|     { | ||||
|         object result = null; | ||||
|  | ||||
|         string methodName = Request.Form["MethodName"]; | ||||
|         try | ||||
|         { | ||||
|             if (methodName != null) | ||||
|             { | ||||
|                 switch (methodName.ToUpper()) | ||||
|                 { | ||||
|                     case "GETMACHINEITEM": | ||||
|                         result = GetMachineItem(); | ||||
|                         break; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         catch (System.Threading.ThreadAbortException) | ||||
|         { | ||||
|             throw; | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         { | ||||
|             SystemParams.WriteLog("error", "MapViewChart." + methodName, ex.Message, ex.ToString()); | ||||
|         } | ||||
|         string json = JsonConvert.SerializeObject(result); | ||||
|         Response.Write(json); | ||||
|         Response.End(); | ||||
|     } | ||||
|  | ||||
|     private object GetMachineItem() | ||||
|     { | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         if (session == null) | ||||
|             return null; | ||||
|         var clientdata = Request.Form["ClientData"]; | ||||
|         clientdata = HttpUtility.HtmlDecode(clientdata); | ||||
|         string[] MachinIDOrVIN = JsonConvert.DeserializeObject<string[]>(clientdata); | ||||
|         if (MachinIDOrVIN != null && MachinIDOrVIN.Length == 3) | ||||
|         { | ||||
|             string machineids = MachinIDOrVIN[0]; | ||||
|             string vins = MachinIDOrVIN[1]; | ||||
|             string datasource = MachinIDOrVIN[2]; | ||||
|             if (string.IsNullOrEmpty(machineids) && string.IsNullOrEmpty(vins)) | ||||
|                 return null; | ||||
|  | ||||
|             string machineid = machineids.Split(',')[0]; | ||||
|             string vin = vins.Split(',')[0]; | ||||
|  | ||||
|             string companyid = ""; | ||||
|             if (SystemParams.IsDealer) | ||||
|             { | ||||
|                 AssetBasicInfo m = null; | ||||
|                 var client = FleetServiceClientHelper.CreateClient<AssetQueryClient>(); | ||||
|                 if (string.IsNullOrEmpty(machineid)) | ||||
|                 { | ||||
|                     m = client.FromAdminAssetBasicInfoByVin(vin); | ||||
|                     machineid = m.ID.ToString(); | ||||
|                 } | ||||
|                 else | ||||
|                     m = client.FromAdminAssetBasicInfoById(long.Parse(machineid)); | ||||
|                 if (m != null) | ||||
|                     companyid = m.ContractorID; | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(companyid)) | ||||
|                     companyid = SystemParams.CompanyID; | ||||
|             } | ||||
|             else if (string.IsNullOrEmpty(machineid)) | ||||
|             { | ||||
|                 machineid = MachineManagement.GetMachineIDByVIN(vin); | ||||
|             } | ||||
|             if (string.IsNullOrEmpty(companyid)) | ||||
|                 companyid = SystemParams.CompanyID; | ||||
|  | ||||
|             var md = AssetMapViewManagement.GetAssetDetailItem(session.SessionID, companyid, long.Parse(machineid), datasource); | ||||
|             return md; | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     private string GetCompanyID(string machineid, string vin) | ||||
|     { | ||||
|         string companyid = ""; | ||||
|         if (SystemParams.IsDealer) | ||||
|         { | ||||
|             AssetBasicInfo m = null; | ||||
|             var client = FleetServiceClientHelper.CreateClient<AssetQueryClient>(); | ||||
|             if (string.IsNullOrEmpty(machineid)) | ||||
|             { | ||||
|                 m = client.FromAdminAssetBasicInfoByVin(vin); | ||||
|                 machineid = m.ID.ToString(); | ||||
|             } | ||||
|             else | ||||
|                 m = client.FromAdminAssetBasicInfoById(long.Parse(machineid)); | ||||
|             if (m != null) | ||||
|                 companyid = m.ContractorID; | ||||
|  | ||||
|             if (string.IsNullOrEmpty(companyid)) | ||||
|                 companyid = SystemParams.CompanyID; | ||||
|         } | ||||
|  | ||||
|         return companyid; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										368
									
								
								Site/AssetView/AssetSingleWorkspace.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										368
									
								
								Site/AssetView/AssetSingleWorkspace.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,368 @@ | ||||
| <%@ Page Language="C#" AutoEventWireup="true" CodeFile="AssetSingleWorkspace.aspx.cs" Inherits="MapView_AssetSingleView" %> | ||||
|  | ||||
| <!DOCTYPE html> | ||||
|  | ||||
| <html xmlns="http://www.w3.org/1999/xhtml"> | ||||
| <head runat="server"> | ||||
|     <meta charset="utf-8" /> | ||||
|     <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||||
|     <meta name="format-detection" content="telephone=no" /> | ||||
|     <title>Single Workspace</title> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("js/jquery-1.11.3.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("js/lib/vue.min.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("js/promise.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/components/modal.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("js/utility.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("js/cookie.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/dialog.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/additionalFilter.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/editGridCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/workspace.js") %>"></script> | ||||
|  | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/css/workspace.css") %>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/js/components/css/override.css")%>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/js/components/css/gridview.css")%>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/js/components/css/datagrid.css") %>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/js/components/css/design-grid.min.css") %>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/css/chart.css")%>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/css/pivot.css")%>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/js/components/css/vue-ctrls.css") %>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/css/form.css") %>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/css/wizardctrl.css") %>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/css/Grid.css")%>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("css/datepicker.min.css")%>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/css/JsTreeCss/style.min.css")%>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/css/tabcontrol.css") %>" rel="stylesheet" /> | ||||
|  | ||||
|     <style type="text/css"> | ||||
|         body { | ||||
|             /* 禁止选中 */ | ||||
|             -moz-user-select: none; /*火狐*/ | ||||
|             -webkit-user-select: none; /*webkit浏览器*/ | ||||
|             -ms-user-select: none; /*IE10*/ | ||||
|             -khtml-user-select: none; /*早期浏览器*/ | ||||
|             user-select: none; | ||||
|             overflow: hidden; | ||||
|             padding: 0; | ||||
|             margin: 0; | ||||
|             border: 0; | ||||
|             font-family: Verdana; | ||||
|             font-size: 13px; | ||||
|         } | ||||
|  | ||||
|         table { | ||||
|             font-size: 13px; | ||||
|         } | ||||
|  | ||||
|         input[type='checkbox'] { | ||||
|             vertical-align: -3px; | ||||
|         } | ||||
|  | ||||
|         input[type='radio'] { | ||||
|             vertical-align: -3px; | ||||
|         } | ||||
|  | ||||
|         input[type='text'] { | ||||
|             height: 20px; | ||||
|         } | ||||
|  | ||||
|         select { | ||||
|             height: 21px; | ||||
|         } | ||||
|  | ||||
|         .smaller { | ||||
|             font-size: 0.9em; | ||||
|         } | ||||
|  | ||||
|         a { | ||||
|             text-decoration: none; | ||||
|             color: #2140fb; | ||||
|         } | ||||
|  | ||||
|             a:hover { | ||||
|                 text-decoration: underline; | ||||
|             } | ||||
|  | ||||
|             a:visited { | ||||
|                 color: #2140fb; | ||||
|             } | ||||
|  | ||||
|         #content { | ||||
|             width: 100%; | ||||
|             top: 0; | ||||
|             bottom: 0; | ||||
|             margin: 0; | ||||
|             position: fixed; | ||||
|         } | ||||
|  | ||||
|         .clear { | ||||
|             display: block; | ||||
|             clear: both; | ||||
|             height: 0; | ||||
|         } | ||||
|  | ||||
|         .wsp_pivot_panel { | ||||
|             display: none; | ||||
|         } | ||||
|  | ||||
|         .boardContainer { | ||||
|             overflow: hidden; | ||||
|         } | ||||
|     </style> | ||||
|  | ||||
|     <script type="text/javascript"> | ||||
|  | ||||
|         var param = {}; | ||||
|  | ||||
|         _utility.loginedUser = {}; | ||||
|         _utility.isReadOnly = true; | ||||
|  | ||||
|         // get the parameter | ||||
|         var search = location.search; | ||||
|         if (search[0] === '?') { | ||||
|             search = search.substring(1); | ||||
|             var s = search.split('&'); | ||||
|             for (var i = 0; i < s.length; i++) { | ||||
|                 var kv = s[i].split('='); | ||||
|                 param[kv[0]] = decodeURIComponent(kv[1]); | ||||
|             } | ||||
|         } | ||||
|         _utility.currentLang = param.lgid; | ||||
|  | ||||
|         var sitePath = "<%=this.ResolveUrl("~/fic/") %>"; | ||||
|         _utility.rootPath ="<%=this.ResolveUrl("~/") %>"; | ||||
|         ApplicationPath = sitePath; | ||||
|         var appPath = "<%=this.ResolveUrl("~/") %>"; | ||||
|  | ||||
|         function resizeBoard(charts) { | ||||
|             var maxWidth = 0, maxHeight = 0; | ||||
|             var docWidth = $(window.parent.document.body).width(); | ||||
|             for (var i = 0; i < charts.length; i++) { | ||||
|                 var c = charts[i]; | ||||
|                 var right = c.Left + c.Width + 16; | ||||
|                 var bottom = c.Top + c.Height + 36; | ||||
|                 if (right > maxWidth) { | ||||
|                     maxWidth = right; | ||||
|                 } | ||||
|                 if (bottom > maxHeight) { | ||||
|                     maxHeight = bottom; | ||||
|                 } | ||||
|             } | ||||
|             if (maxWidth < docWidth) { | ||||
|                 maxWidth = '100%'; | ||||
|             } | ||||
|             window.parent.resizeBoard(maxWidth, maxHeight); | ||||
|         } | ||||
|  | ||||
|         function resetPivot(pivots) { | ||||
|             var s = encodeURIComponent(JSON.stringify(pivots)); | ||||
|             _utility.loadWspPivots('?wspivots=' + s); | ||||
|         } | ||||
|  | ||||
|     </script> | ||||
|  | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("js/echarts.min.js")%>"></script> | ||||
|     <%--<script type="text/javascript" src="//cdn.jsdelivr.net/npm/echarts@4.8.0/dist/echarts.js"></script>--%> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("js/datepicker.min.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("js/lib/vue-color.min.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/components/gridview.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/about.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/menu.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/pivot.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/controls.js") %>"></script> | ||||
|     <%--<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/editGridCtrl.js") %>"></script>--%> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/components/datagrid.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/components/vue-ctrls.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/components/design-grid.min.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/form.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/wizardctrl.js") %>"></script> | ||||
|  | ||||
|     <%-- 覆盖fic定义 --%> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/override.js")%>"></script> | ||||
|     <%--<script type="text/javascript" src="<%=Common.GenerateUrl("fic/g5masterjs.js")%>"></script>--%> | ||||
|  | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/wsp_pivot.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/board.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chart.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/gauge.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/scorecard.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/gridctrl.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/grid.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/graph.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/simplechart.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/favorites.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/fifrs.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/jstree.min.js")%>"></script> | ||||
|  | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartTypeWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/Management/alertMessageWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/commonOp.js") %>"></script> | ||||
|  | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/Management/boardFilters.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/Management/workspaceFilters.js") %>"></script> | ||||
|  | ||||
|     <script type="text/javascript"> | ||||
|         // register the plugin | ||||
|         Vue.use(window['g5-vue-ctrls'].directives); | ||||
|  | ||||
|         function GetUserParamter() { | ||||
|             return new Promise(function (resolve, reject) { | ||||
|                 _network.query('GetUserParameters', [], function (data) { | ||||
|                     if (data.Result) { | ||||
|                         _utility.loginedUser.userIId = data.Result.LoginUserIID; | ||||
|                         _utility.loginedUser.userId = data.Result.UserID; | ||||
|                         _utility.loginedUser.useName = data.Result.UserName; | ||||
|                         _utility.loginedUser.CanAccessPublic = data.Result.CanAccessPublic; | ||||
|                         _utility.loginedUser.CanAccessSave = data.Result.CanAccessSave; | ||||
|                         _utility.loginedUser.UserType = data.Result.UserType; | ||||
|                         _utility.loginedUser.UserParameters = data.Result; | ||||
|                         _utility.loginedUser.CanExportFile = data.Result.CanExportFile; | ||||
|                         _workspace.displayLevel = _utility.loginedUser.UserParameters.DefaultDisplayLevels; | ||||
|                         _workspace.displayRefreshTime = _utility.loginedUser.UserParameters.DefaultShowRefreshTime; | ||||
|                         _workspace.setDisplayLevel(_workspace.displayLevel); | ||||
|                         _workspace.pivotpinned = _utility.loginedUser.UserParameters.DefaultPinPivot; | ||||
|                         _workspace.borderpinned = _utility.loginedUser.UserParameters.DefaultPinBorder; | ||||
|  | ||||
|                         //if (_utility.loginedUser.UserParameters.AutoRotateBoards) { | ||||
|                         //    _workspace.rotaBoardsTimer = setInterval(_workspace.RunRotaBoards, _utility.loginedUser.UserParameters.AutoRotateBoardsInterval * 1000); | ||||
|                         //} | ||||
|                         if (typeof _utility.startRotate === 'function') { | ||||
|                             _utility.startRotate(); | ||||
|                         } | ||||
|  | ||||
|                         if (_utility.themes && _utility.themes[0]) { | ||||
|                             var defaultSkin = _utility.themes[0].ID; | ||||
|                             for (var i = 0; i < _utility.themes.length; i++) { | ||||
|                                 var t = _utility.themes[i]; | ||||
|                                 if (_utility.loginedUser.UserParameters.DefaultSkin == t.ID) { | ||||
|                                     defaultSkin = t.ID; | ||||
|                                     break; | ||||
|                                 } | ||||
|                             } | ||||
|                             _workspace.onchangetheme(defaultSkin); | ||||
|                         } | ||||
|  | ||||
|                         resolve(); | ||||
|                     } else { | ||||
|                         //throw new Error('GetUserParamter error.'); | ||||
|                         alert(DEFAULT_LANG.not_signed); | ||||
|                         window.location = sitePath + 'Logout.ashx'; | ||||
|                     } | ||||
|                 }, reject); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function initLanguage() { | ||||
|             $("a,span,label,td").filter("[data-langKey]").each( | ||||
|                 function () { | ||||
|                     var thisElement = $(this); | ||||
|                     thisElement.text(GetLanguageByKey(thisElement.data("langkey"), thisElement.data("defaultlang"))); | ||||
|                 } | ||||
|             ); | ||||
|             DEFAULT_LANG.unknown_error = GetLanguageByKey("LHBIS_EXCEPTION_E0X65028018", DEFAULT_LANG.unknown_error); | ||||
|             DEFAULT_LANG.cannot_be_public = GetLanguageByKey("LHBIS_FIC_CLIENT_DIALOGS_RBOARDSAVEDIALOG_A010", DEFAULT_LANG.cannot_be_public); | ||||
|             DEFAULT_LANG.newboard = GetLanguageByKey("LHBIS_FIC_SILVERLIGHT_WSP_WORKSPACEPAGE_A006", DEFAULT_LANG.newboard); | ||||
|             DEFAULT_LANG.must_select_one = GetLanguageByKey("ERROR_LHBIS_FIC_BLC_COMMON_A0004", DEFAULT_LANG.must_select_one); | ||||
|             DEFAULT_LANG.filter = GetLanguageByKey("LHBIS_FIC_CHARTS_CHARTCLIENT_A015", DEFAULT_LANG.filter); | ||||
|             DEFAULT_LANG.multi = GetLanguageByKey("LHBIS_FIC_CHARTS_COMMONCHART_A009", DEFAULT_LANG.multi); | ||||
|             DEFAULT_LANG.ok = GetLanguageByKey('LHBIS_FIC_CLIENT_MODULES_RSUBSCRIBEMESSAGEDIALOG_A007', DEFAULT_LANG.ok); | ||||
|             DEFAULT_LANG.cancel = GetLanguageByKey('LHBIS_FIC_CLIENT_MODULES_RSUBSCRIBEMESSAGEDIALOG_A008', DEFAULT_LANG.cancel); | ||||
|             DEFAULT_LANG.save = GetLanguageByKey('LHBIS_FIC_CLIENT_MODULES_SNAPSHOTCTRL_LIST_A009', DEFAULT_LANG.save); | ||||
|             DEFAULT_LANG.no = GetLanguageByKey('LHBIS_FIC_CLIENT_MODULES_SYSTEMOPTIONSCTRL_A010', DEFAULT_LANG.no); | ||||
|             DEFAULT_LANG.yes = GetLanguageByKey('LHBIS_FIC_CLIENT_MODULES_SYSTEMOPTIONSCTRL_A009', DEFAULT_LANG.yes); | ||||
|             DEFAULT_LANG.all = GetLanguageByKey('LHBIS_FIC_CHARTS_COMMONCHART_A007', DEFAULT_LANG.all); | ||||
|             DEFAULT_LANG.level = GetLanguageByKey('LHBIS_MULTILANGUAGE_COMMON_A027', DEFAULT_LANG.level); | ||||
|             PIVOTVAL.ALL.text = GetLanguageByKey('LHBIS_FIC_CHARTS_COMMONCHART_A007', DEFAULT_LANG.all); | ||||
|         } | ||||
|  | ||||
|         function init() { | ||||
|             // chart comments | ||||
|             var iframe = $('<iframe id="chart_comments_container" style="display:none;margin-right:-420px"></iframe>'); | ||||
|             var email_iframe = $('<iframe id="email_subscription_container" style="display:none;margin-right:-900px"></iframe>'); | ||||
|             var bg = $('<div id="chart_comments_bg" class="maskbg" style="display:none"></div>').click(function () { | ||||
|                 iframe.stop().animate({ 'margin-right': -420 }, ANIMATE_FAST_SPEED, function () { | ||||
|                     iframe.hide(); | ||||
|                     bg.hide(); | ||||
|                 }); | ||||
|                 email_iframe.stop().animate({ 'margin-right': -900 }, ANIMATE_FAST_SPEED, function () { | ||||
|                     iframe.hide(); | ||||
|                     bg.hide(); | ||||
|                 }); | ||||
|             }); | ||||
|             $(document.body).append(bg, iframe); | ||||
|             $(document.body).append(bg, email_iframe); | ||||
|         } | ||||
|  | ||||
|         function catchError(err) { | ||||
|             var msg = err; | ||||
|             if (msg != null && msg.message != null) { | ||||
|                 msg = msg.message; | ||||
|             } | ||||
|             _utility.showMessage(msg, DEFAULT_LANG.FIC, null, function () { | ||||
|                 window.location = sitePath + 'Logout.ashx'; | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function GetWorkspace(iid) { | ||||
|             return new Promise(function (resolve, reject) { | ||||
|                 if (iid) { | ||||
|                     _network.query('GetWorkspaceByIID', [iid], function (data) { | ||||
|                         if (data.Result) { | ||||
|                             if (_utility.workspaces == null || _utility.workspaces.length === 0) { | ||||
|                                 _utility.workspaces = [data.Result]; | ||||
|                             } | ||||
|                             changeWorkspace(data.Result.IID, data.Result.WSPName, data.Result.Level, data.Result.Creater, data.Result.SecretType, data.Result.IsMyCreate, data.Result.WSPDescription); | ||||
|                         } | ||||
|  | ||||
|                         resolve(); | ||||
|                     }); | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function changeWorkspace(iid, name, level, Creater, secrettype, IsMyCreate, WSPDescription) { | ||||
|             _network.query('GetWorkspacePersonalCheck', [iid], function (data) { | ||||
|                 if (!data.Result && data.ErrorMessage) { | ||||
|                     writelog("changeWorkspace", data.ErrorMessage, data.ErrorMessage); | ||||
|                 } else { | ||||
|                     var personalChecked = data.Result; | ||||
|                     if (_workspace.changed && _utility.CanSaveAccessByPersonalIsVisableWhenLogout()) { | ||||
|                         $alertdialog.showConfirm(DEFAULT_LANG.FIC, | ||||
|                             GetLanguageByKey("LHBIS_FIC_SILVERLIGHT_WSP_WORKSPACEPAGE_A004", 'The Workspace setting defaults have changed, do you want to save the changes?'), [ | ||||
|                             [DEFAULT_LANG.cancel], | ||||
|                             [DEFAULT_LANG.no, function () { _workspace.onchangewsp(iid, name, level, Creater, secrettype, personalChecked, IsMyCreate, WSPDescription); }], | ||||
|                             [DEFAULT_LANG.yes, function () { _utility.doSaveWorkspace(function () { _workspace.onchangewsp(iid, name, level, Creater, secrettype, personalChecked, IsMyCreate, WSPDescription); }); }] | ||||
|                         ]); | ||||
|                     } else { | ||||
|                         _workspace.onchangewsp(iid, name, level, Creater, secrettype, personalChecked, IsMyCreate, WSPDescription); | ||||
|                     } | ||||
|  | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         $(function () { | ||||
|             GetUserParamter() | ||||
|                 .then(function () { | ||||
|                     GetWorkspace(param.iid).then(init); | ||||
|                 }) | ||||
|                 .catch(catchError); | ||||
|  | ||||
|             if (typeof window.parent.ondocumentclick == 'function') { | ||||
|                 $(document.body).click(window.parent.ondocumentclick); | ||||
|             } | ||||
|  | ||||
|             initLanguage(); | ||||
|  | ||||
|             // 初始化workspace | ||||
|             _workspace.container = '#content'; | ||||
|             _workspace.init(); | ||||
|         }); | ||||
|     </script> | ||||
| </head> | ||||
| <body> | ||||
|     <div id="content"> | ||||
|         Loading... | ||||
|     </div> | ||||
| </body> | ||||
| </html> | ||||
							
								
								
									
										14
									
								
								Site/AssetView/AssetSingleWorkspace.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								Site/AssetView/AssetSingleWorkspace.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Web; | ||||
| using System.Web.UI; | ||||
| using System.Web.UI.WebControls; | ||||
|  | ||||
| public partial class MapView_AssetSingleView : System.Web.UI.Page | ||||
| { | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     { | ||||
|  | ||||
|     } | ||||
| } | ||||
							
								
								
									
										195
									
								
								Site/AssetView/AssetTimeline.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										195
									
								
								Site/AssetView/AssetTimeline.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,195 @@ | ||||
| <%@ Page Title="" Language="C#" MasterPageFile="~/AssetView/AssetViewBase.master" AutoEventWireup="true" CodeFile="AssetTimeline.aspx.cs" Inherits="AssetView_AssetTimeline" %> | ||||
|  | ||||
| <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> | ||||
|     <link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" /> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script> | ||||
|     <style type="text/css"> | ||||
|         .table-container { | ||||
|             margin: 4px 10px 0 26px; | ||||
|         } | ||||
|         .table-timeline { | ||||
|             width: 100%; | ||||
|             border-spacing: 0; | ||||
|             table-layout: fixed; | ||||
|         } | ||||
|         .table-timeline th { | ||||
|             width: 4.17%; | ||||
|             border-right: 1px solid white; | ||||
|             background: #444; | ||||
|             color: white; | ||||
|             font-weight: normal; | ||||
|             font-size: 13px; | ||||
|             height: 26px; | ||||
|         } | ||||
|         .table-timeline th, | ||||
|         .table-timeline td { | ||||
|             padding: 0; | ||||
|         } | ||||
|         #td-timeline { | ||||
|             height: 30px; | ||||
|             position: relative; | ||||
|         } | ||||
|         #td-timeline div { | ||||
|             height: 26px; | ||||
|             position: absolute; | ||||
|             background: #64965a; | ||||
|             top: 2px; | ||||
|             border-radius: 6px; | ||||
|         } | ||||
|         #td-timeline div.no-start { | ||||
|             border-radius: 0 6px 6px 0; | ||||
|         } | ||||
|         #td-timeline div.no-end { | ||||
|             border-radius: 6px 0 0 6px; | ||||
|         } | ||||
|     </style> | ||||
|     <script type="text/javascript"> | ||||
|         _network.root = '<%=Page.ResolveUrl("~/")%>'; | ||||
|         var wids = []; | ||||
|         var dict; | ||||
|  | ||||
|         function assetrequest(method, param, callback, error) { | ||||
|             _network.request("AssetView/SingleAssetView.aspx", -1, method, param, callback, error || function (e) { | ||||
|                 console.log(e); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function fillWidths() { | ||||
|             var ths = $('#tr-header').children(); | ||||
|             for (var i = 0; i < ths.length; i++) { | ||||
|                 wids[i] = $(ths[i]).outerWidth(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $(function () { | ||||
|             fillWidths(); | ||||
|             dict = {}; | ||||
|             try { | ||||
|                 var search = location.search.substring(1).split('&'); | ||||
|                 if (search) { | ||||
|                     for (var i = 0; i < search.length; i++) { | ||||
|                         var ss = search[i].split('='); | ||||
|                         dict[ss[0]] = decodeURIComponent(ss[1]); | ||||
|                     } | ||||
|                 } | ||||
|             } catch (e) { | ||||
|                 // failed to load the params, ignore | ||||
|             } | ||||
|  | ||||
|             $(window).resize(function () { | ||||
|                 fillWidths(); | ||||
|                 var ds = $('#td-timeline').children(); | ||||
|                 for (var i = 0; i < ds.length; i++) { | ||||
|                     var div = $(ds[i]); | ||||
|                     var start = parseFloat(div.attr('start')); | ||||
|                     var end = parseFloat(div.attr('end')); | ||||
|                     var left = getOffset(start, wids); | ||||
|                     var right = getOffset(end, wids); | ||||
|                     var w = right - left - 1; | ||||
|                     if (w < 1) { w = 1; } | ||||
|                     div.css({ | ||||
|                         left: left, | ||||
|                         width: w | ||||
|                     }); | ||||
|                 } | ||||
|             }); | ||||
|         }); | ||||
|  | ||||
|         function getAssetTimeline(id, date) { | ||||
|             var params = [dict.cid || '', id, date]; | ||||
|             assetrequest('GetAssetOnOffTimeline', params.join(String.fromCharCode(170)), function (data) { | ||||
|                 var parent = $('#td-timeline').empty(); | ||||
|                 for (var i = 0; i < data.length; i++) { | ||||
|                     var div = $('<div></div>'); | ||||
|                     var startSeconds = data[i].Start; | ||||
|                     var endSeconds = data[i].End; | ||||
|                     var start = startSeconds / 3600; | ||||
|                     var end = endSeconds / 3600; | ||||
|                     var title = []; | ||||
|                     if (data[i].HasOn) { | ||||
|                         title.push('On: ' + hoursToString(startSeconds)); | ||||
|                     } else { | ||||
|                         div.addClass('no-start'); | ||||
|                     } | ||||
|                     if (data[i].HasOff) { | ||||
|                         title.push('Off: ' + hoursToString(endSeconds)); | ||||
|                     } else { | ||||
|                         div.addClass('no-end'); | ||||
|                     } | ||||
|                     div.attr({ | ||||
|                         start: start, | ||||
|                         end: end, | ||||
|                         title: title.join('\n') | ||||
|                     }); | ||||
|                     var left = getOffset(start, wids); | ||||
|                     var right = getOffset(end, wids); | ||||
|                     var w = right - left - 1; | ||||
|                     if (w < 1) { w = 1; } | ||||
|                     div.css({ | ||||
|                         left: left, | ||||
|                         width: w | ||||
|                     }); | ||||
|                     parent.append(div); | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function hoursToString(seconds) { | ||||
|             var s = Math.floor(seconds % 60); | ||||
|             seconds = Math.floor(seconds / 60); | ||||
|             var m = seconds % 60; | ||||
|             var h = Math.floor(seconds / 60); | ||||
|             return (h < 10 ? '0' : '') + h + ':' + (m < 10 ? '0' : '') + m + ':' + (s < 10 ? '0' : '') + s; | ||||
|         } | ||||
|  | ||||
|         function OnRefresh(dt) { | ||||
|             if (dict.id != null) { | ||||
|                 getAssetTimeline(dict.id, dt); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function getOffset(pos, wids) { | ||||
|             var n = Math.floor(pos); | ||||
|             var p = 0; | ||||
|             for (var i = 0; i < n; i++) { | ||||
|                 p += wids[i]; | ||||
|             } | ||||
|             p += wids[n] * (pos - n); | ||||
|             return p; | ||||
|         } | ||||
|     </script> | ||||
| </asp:Content> | ||||
| <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> | ||||
|     <div class="table-container"> | ||||
|         <div style="width: 100px; float: left"> | ||||
|             <table class="table-timeline"> | ||||
|                 <thead> | ||||
|                     <tr><th data-lgid="P_MV_TYPE">Type</th></tr> | ||||
|                 </thead> | ||||
|                 <tbody> | ||||
|                     <tr><td style="height: 30px" data-lgid="P_MV_ONOFFEVENTS">On/Off Events</td></tr> | ||||
|                 </tbody> | ||||
|             </table> | ||||
|         </div> | ||||
|         <div style="margin-left: 100px"> | ||||
|             <table class="table-timeline"> | ||||
|                 <thead> | ||||
|                     <tr id="tr-header"> | ||||
|                         <th>0:00</th><th>1:00</th><th>2:00</th><th>3:00</th> | ||||
|                         <th>4:00</th><th>5:00</th><th>6:00</th><th>7:00</th> | ||||
|                         <th>8:00</th><th>9:00</th><th>10:00</th><th>11:00</th> | ||||
|                         <th>12:00</th><th>13:00</th><th>14:00</th><th>15:00</th> | ||||
|                         <th>16:00</th><th>17:00</th><th>18:00</th><th>19:00</th> | ||||
|                         <th>20:00</th><th>21:00</th><th>22:00</th><th>23:00</th> | ||||
|                     </tr> | ||||
|                 </thead> | ||||
|                 <tbody> | ||||
|                     <tr> | ||||
|                         <td colspan="24" id="td-timeline"></td> | ||||
|                     </tr> | ||||
|                 </tbody> | ||||
|             </table> | ||||
|         </div> | ||||
|     </div> | ||||
| </asp:Content> | ||||
|  | ||||
							
								
								
									
										16
									
								
								Site/AssetView/AssetTimeline.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								Site/AssetView/AssetTimeline.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| using IronIntel.Contractor; | ||||
| using IronIntel.Contractor.Site; | ||||
| using Newtonsoft.Json; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Web; | ||||
| using System.Web.UI; | ||||
| using System.Web.UI.WebControls; | ||||
|  | ||||
| public partial class AssetView_AssetTimeline : ContractorBasePage | ||||
| { | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     { | ||||
|     } | ||||
| } | ||||
							
								
								
									
										116
									
								
								Site/AssetView/AssetViewBase.master
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										116
									
								
								Site/AssetView/AssetViewBase.master
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,116 @@ | ||||
| <%@ Master Language="C#" AutoEventWireup="true" CodeFile="AssetViewBase.master.cs" Inherits="AssetViewBaseBase" %> | ||||
|  | ||||
| <!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"> | ||||
|         #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: 12px !important; | ||||
|             font-family: "Segoe UI","Segoe UI Web (West European)","Segoe UI",-apple-system,BlinkMacSystemFont,"Roboto","Helvetica Neue",sans-serif !important; | ||||
|         } | ||||
|     </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 src="<%=GetUrl("js/language.js")%>" type="text/javascript"></script> | ||||
|     <script type="text/javascript"> | ||||
|  | ||||
|       <%--  _net.root = '<%=Page.ResolveUrl("~/")%>';--%> | ||||
|         var GridView = window.GridView || window['g5-gridview']; | ||||
|         var canExport = <%= CanExportFile %>; | ||||
|  | ||||
|         function getText(s, flag) { | ||||
|             return (s == null) | ||||
|                 ? (flag ? '<i>null</i>' : '') | ||||
|                 : htmlencode(s, $('#div_text_holder')).replace(/ /g, ' '); | ||||
|         } | ||||
|  | ||||
|         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 GetLanguageByCookie() { | ||||
|             var lang = getCookie('<%=Common.LanguageCookieName%>'); | ||||
|             if (lang == null) { | ||||
|                 return "en-us"; | ||||
|             } else { | ||||
|                 return lang; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $(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() { | ||||
|                 $('#mask_bg').height($(document).outerHeight(false)).width($(document).outerWidth(false)); | ||||
|             } | ||||
|  | ||||
|             $(window).resize(function () { | ||||
|                 resizeContent(); | ||||
|             }); | ||||
|             //window.onresize = resizeContent; | ||||
|             resizeContent(); | ||||
|  | ||||
|             window.ondocumentclick = function (e) { | ||||
|                 $(document.body).click(); | ||||
|             }; | ||||
|             if (typeof window.parent.ondocumentclick == 'function') { | ||||
|                 $(document.body).click(window.parent.ondocumentclick); | ||||
|             } | ||||
|         }); | ||||
|     </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/AssetView/AssetViewBase.master.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								Site/AssetView/AssetViewBase.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 AssetViewBaseBase : 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. | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										542
									
								
								Site/AssetView/AssetsTimeline.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										542
									
								
								Site/AssetView/AssetsTimeline.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,542 @@ | ||||
| <%@ Page Title="" Language="C#" MasterPageFile="~/AssetView/AssetViewBase.master" AutoEventWireup="true" CodeFile="AssetsTimeline.aspx.cs" Inherits="AssetView_AssetsTimeline" %> | ||||
|  | ||||
| <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"> | ||||
|     <link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" /> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script> | ||||
|     <link href="<%=Common.GenerateUrl("../css/tabcontrol.css") %>" rel="stylesheet" /> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/controls.js")%>" type="text/javascript"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("../Maintenance/js/inputdatactr.js")%>" type="text/javascript"></script> | ||||
|     <style type="text/css"> | ||||
|         html { | ||||
|             overflow-x: hidden; | ||||
|         } | ||||
|  | ||||
|         .titlePane { | ||||
|             background-color: #444444; | ||||
|             color: #FFFFFF; | ||||
|             line-height: 24px; | ||||
|             padding-left: 6px; | ||||
|             border-radius: 5px 5px 0px 0px; | ||||
|             -webkit-border-radius: 5px 5px 0px 0px; | ||||
|             cursor: default; | ||||
|         } | ||||
|  | ||||
|         .titleButton { | ||||
|             position: absolute; | ||||
|             top: 2px; | ||||
|             cursor: pointer; | ||||
|         } | ||||
|  | ||||
|             .titleButton:before { | ||||
|                 padding-right: 8px; | ||||
|                 font-family: 'FontAwesome'; | ||||
|             } | ||||
|  | ||||
|             .titleButton.close { | ||||
|                 right: 3px; | ||||
|                 background-position: 0 0; | ||||
|                 width: 12px; | ||||
|                 height: 17px; | ||||
|                 font-size: 15px; | ||||
|             } | ||||
|  | ||||
|         .table-container { | ||||
|             margin: 4px 10px 0 26px; | ||||
|         } | ||||
|  | ||||
|         .table-timeline { | ||||
|             width: 100%; | ||||
|             border-spacing: 0; | ||||
|             table-layout: fixed; | ||||
|         } | ||||
|  | ||||
|             .table-timeline th { | ||||
|                 width: 4.17%; | ||||
|                 border-right: 1px solid white; | ||||
|                 background: #444; | ||||
|                 color: white; | ||||
|                 font-weight: normal; | ||||
|                 font-size: 13px; | ||||
|                 height: 26px; | ||||
|             } | ||||
|  | ||||
|             .table-timeline th, | ||||
|             .table-timeline td { | ||||
|                 padding: 0; | ||||
|                 white-space: nowrap; | ||||
|                 overflow: hidden; | ||||
|                 text-overflow: ellipsis; | ||||
|             } | ||||
|  | ||||
|         #tds-timeline td { | ||||
|             height: 30px; | ||||
|             position: relative; | ||||
|         } | ||||
|  | ||||
|         #tds-timeline div { | ||||
|             height: 26px; | ||||
|             position: absolute; | ||||
|             background: #64965a; | ||||
|             top: 2px; | ||||
|             border-radius: 6px; | ||||
|         } | ||||
|  | ||||
|             #tds-timeline div.no-start { | ||||
|                 border-radius: 0 6px 6px 0; | ||||
|             } | ||||
|  | ||||
|             #tds-timeline div.no-end { | ||||
|                 border-radius: 6px 0 0 6px; | ||||
|             } | ||||
|  | ||||
|         #tab_timeline { | ||||
|             overflow-y: auto; | ||||
|         } | ||||
|     </style> | ||||
|     <script type="text/javascript"> | ||||
|         _network.root = '<%=Page.ResolveUrl("~/")%>'; | ||||
|         var wids = []; | ||||
|         var grid; | ||||
|         var currentdate = "<%=CurrentDate %>"; | ||||
|  | ||||
|         function assetrequest(method, param, callback, error) { | ||||
|             _network.request("AssetView/SingleAssetView.aspx", -1, method, param, callback, error || function (e) { | ||||
|                 console.log(e); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function fillWidths() { | ||||
|             var ths = $('#tr-header').children(); | ||||
|             for (var i = 0; i < ths.length; i++) { | ||||
|                 wids[i] = $(ths[i]).outerWidth(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $(function () { | ||||
|             fillWidths(); | ||||
|  | ||||
|             var resizeTimeline = function () { | ||||
|                 fillWidths(); | ||||
|                 var trs = $('#tds-timeline').children('tr'); | ||||
|                 for (var n = 0; n < trs.length; n++) { | ||||
|                     var ds = $(trs[n]).children('td').children(); | ||||
|                     for (var i = 0; i < ds.length; i++) { | ||||
|                         var div = $(ds[i]); | ||||
|                         var start = parseFloat(div.attr('start')); | ||||
|                         var end = parseFloat(div.attr('end')); | ||||
|                         var left = getOffset(start, wids); | ||||
|                         var right = getOffset(end, wids); | ||||
|                         var w = right - left - 1; | ||||
|                         if (w < 1) { w = 1; } | ||||
|                         div.css({ | ||||
|                             left: left, | ||||
|                             width: w | ||||
|                         }); | ||||
|                     } | ||||
|                 } | ||||
|             }; | ||||
|  | ||||
|             $(window).resize(function () { | ||||
|                 resizeTimeline(); | ||||
|  | ||||
|                 var height = $(window).height() - 70; | ||||
|                 $('#tab_timeline').css('height', height); | ||||
|                 $('#tab_grid').css('height', height); | ||||
|                 grid.resize(); | ||||
|             }); | ||||
|  | ||||
|             $('#date-selector').datetimepicker({ | ||||
|                 timepicker: false, | ||||
|                 format: 'm/d/Y', | ||||
|                 scrollMonth: false, | ||||
|                 scrollTime: false, | ||||
|                 scrollInput: false, | ||||
|             }).val(new DateFormatter().formatDate(new Date(currentdate), 'm/d/Y')); | ||||
|  | ||||
|             $('#tab_container').tab({ | ||||
|                 onclick: function (t, n) { | ||||
|                     n(); | ||||
|                     var key = t.attr('data-href') | ||||
|                     $('#' + key).css('height', $(window).height() - 70); | ||||
|                     if (key === 'tab_grid') { | ||||
|                         grid.resize(); | ||||
|                     } else { | ||||
|                         resizeTimeline(); | ||||
|                     } | ||||
|                 } | ||||
|             }); | ||||
|  | ||||
|             grid = new GridView('#tab_grid'); | ||||
|             grid.columns = [ | ||||
|                 { | ||||
|                     key: 'name', | ||||
|                     caption: GetTextByKey('P_MA_ASSETNAME', 'Asset Name'), | ||||
|                     width: 180 | ||||
|                 }, | ||||
|                 { | ||||
|                     key: 'vin', | ||||
|                     caption: GetTextByKey('P_MA_VIN', 'VIN/SN'), | ||||
|                     width: 160 | ||||
|                 }, | ||||
|                 { | ||||
|                     key: 'make', | ||||
|                     caption: GetTextByKey('P_MA_MAKENAME', 'Make Name'), | ||||
|                     width: 100 | ||||
|                 }, | ||||
|                 { | ||||
|                     key: 'model', | ||||
|                     caption: GetTextByKey('P_MA_MODELNAME', 'Model Name'), | ||||
|                     width: 100 | ||||
|                 }, | ||||
|                 { key: 'h0', caption: '12AM-1AM', width: 94, align: 'right' }, | ||||
|                 { key: 'h1', caption: '1AM-2AM', width: 94, align: 'right' }, | ||||
|                 { key: 'h2', caption: '2AM-3AM', width: 94, align: 'right' }, | ||||
|                 { key: 'h3', caption: '3AM-4AM', width: 94, align: 'right' }, | ||||
|                 { key: 'h4', caption: '4AM-5AM', width: 94, align: 'right' }, | ||||
|                 { key: 'h5', caption: '5AM-6AM', width: 94, align: 'right' }, | ||||
|                 { key: 'h6', caption: '6AM-7AM', width: 94, align: 'right' }, | ||||
|                 { key: 'h7', caption: '7AM-8AM', width: 94, align: 'right' }, | ||||
|                 { key: 'h8', caption: '8AM-9AM', width: 94, align: 'right' }, | ||||
|                 { key: 'h9', caption: '9AM-10AM', width: 94, align: 'right' }, | ||||
|                 { key: 'h10', caption: '10AM-11AM', width: 94, align: 'right' }, | ||||
|                 { key: 'h11', caption: '11AM-12PM', width: 94, align: 'right' }, | ||||
|                 { key: 'h12', caption: '12PM-1PM', width: 94, align: 'right' }, | ||||
|                 { key: 'h13', caption: '1PM-2PM', width: 94, align: 'right' }, | ||||
|                 { key: 'h14', caption: '2PM-3PM', width: 94, align: 'right' }, | ||||
|                 { key: 'h15', caption: '3PM-4PM', width: 94, align: 'right' }, | ||||
|                 { key: 'h16', caption: '4PM-5PM', width: 94, align: 'right' }, | ||||
|                 { key: 'h17', caption: '5PM-6PM', width: 94, align: 'right' }, | ||||
|                 { key: 'h18', caption: '6PM-7PM', width: 94, align: 'right' }, | ||||
|                 { key: 'h19', caption: '7PM-8PM', width: 94, align: 'right' }, | ||||
|                 { key: 'h20', caption: '8PM-9PM', width: 94, align: 'right' }, | ||||
|                 { key: 'h21', caption: '9PM-10PM', width: 94, align: 'right' }, | ||||
|                 { key: 'h22', caption: '10PM-11PM', width: 94, align: 'right' }, | ||||
|                 { key: 'h23', caption: '11PM-12AM', width: 94, align: 'right' } | ||||
|             ]; | ||||
|             grid.canMultiSelect = false; | ||||
|             grid.init(); | ||||
|         }); | ||||
|  | ||||
|         var pcid; | ||||
|         var loading; | ||||
|         function getAssetTimeline(cid, date) { | ||||
|             if (loading) { | ||||
|                 return; | ||||
|             } | ||||
|             pcid = cid || ''; | ||||
|             var assets = window.parent.allAssets; | ||||
|             if (assets == null) { | ||||
|                 return; | ||||
|             } | ||||
|             var selecteds = assets.filter(function (a) { return a.State.Selected }).sort(function (a, b) { | ||||
|                 if (a.DisplayName == b.DisplayName) { | ||||
|                     return 0; | ||||
|                 } | ||||
|                 return a.DisplayName > b.DisplayName ? 1 : -1; | ||||
|             }); | ||||
|             var parent = $('#tds-timeline').empty(); | ||||
|             var idsparent = $('#asset-ids').empty(); | ||||
|             loading = true; | ||||
|             $('.maskbg').fadeIn(100); | ||||
|             grid.setData([]); | ||||
|             doGetAssetTimeline(selecteds, 0, parent, idsparent, date); | ||||
|         } | ||||
|  | ||||
|         function doGetAssetTimeline(selecteds, start, parent, idsparent, date) { | ||||
|             var endIndex = start + 10000; | ||||
|             var ids = selecteds.slice(start, endIndex).map(function (a) { return a.ID }); | ||||
|             if (ids.length <= 0) { | ||||
|                 var source = grid.source; | ||||
|                 var total = { | ||||
|                     name: GetTextByKey('P_MA_TOTALCOLON', 'Total:') + ' ' + source.length, | ||||
|                     model: $('<span></span>').css('float', 'right').text(GetTextByKey('P_MA_TOTALRUNTIMECOLON', 'Total Runtime:'))[0].outerHTML | ||||
|                 }; | ||||
|                 for (var h = 0; h < 24; h++) { | ||||
|                     var seconds = source.reduce(function (current, s) { | ||||
|                         var n = s.Values['s' + h]; | ||||
|                         return isNaN(n) ? current : current + n; | ||||
|                     }, 0); | ||||
|                     if (seconds > 0) { | ||||
|                         var run = | ||||
|                             String(Math.floor(seconds / 3600)).padStart(2, '0') + ':' + | ||||
|                             String(Math.floor((seconds % 3600) / 60)).padStart(2, '0') + ':' + | ||||
|                             String(Math.round(seconds % 60)).padStart(2, '0'); | ||||
|                         total['h' + h] = run; | ||||
|                     } | ||||
|                 } | ||||
|                 grid.total = total; | ||||
|                 grid.init(); | ||||
|  | ||||
|                 loading = false; | ||||
|                 $('.maskbg').fadeOut(100); | ||||
|                 return; | ||||
|             } | ||||
|             var params = [pcid, ids, date]; | ||||
|             assetrequest('GetAssetsOnOffTimeline', params.join(String.fromCharCode(170)), function (data) { | ||||
|                 var source = []; | ||||
|                 for (var n = 0; n < data.length; n++) { | ||||
|                     var item = $('<td colspan="24"></td>'); | ||||
|                     var onoff = data[n]; | ||||
|                     var a = selecteds.filter(function (a) { return a.ID == onoff.AssetId })[0]; | ||||
|                     var name = (a && a.DisplayName) || onoff.AssetId; | ||||
|                     var it = { | ||||
|                         name: name, | ||||
|                         vin: a.VIN, | ||||
|                         make: a.Make, | ||||
|                         model: a.Model | ||||
|                     }; | ||||
|                     var idtd = $('<td style="height: 30px"></td>').text(name).attr('title', name); | ||||
|                     idsparent.append($('<tr></tr>').append(idtd)); | ||||
|                     for (var i = 0; i < onoff.Items.length; i++) { | ||||
|                         var div = $('<div></div>'); | ||||
|                         var startSeconds = onoff.Items[i].Start; | ||||
|                         var endSeconds = onoff.Items[i].End; | ||||
|                         var start = startSeconds / 3600; | ||||
|                         var end = endSeconds / 3600; | ||||
|                         if (endSeconds > startSeconds) { | ||||
|                             var startHour = Math.floor(start); | ||||
|                             var endHour = Math.ceil(end); | ||||
|                             for (var h = startHour; h < endHour; h++) { | ||||
|                                 var hourStartSeconds = h * 3600; | ||||
|                                 var hourEndSeconds = (h + 1) * 3600; | ||||
|                                 if (startSeconds > hourStartSeconds) { | ||||
|                                     hourStartSeconds = startSeconds; | ||||
|                                 } | ||||
|                                 if (hourEndSeconds - endSeconds >= 1) { | ||||
|                                     hourEndSeconds = endSeconds; | ||||
|                                 } | ||||
|                                 var totalSeconds = hourEndSeconds - hourStartSeconds; | ||||
|                                 if (it['s' + h] == null) { | ||||
|                                     it['s' + h] = totalSeconds; | ||||
|                                 } else { | ||||
|                                     it['s' + h] += totalSeconds; | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|                         var title = []; | ||||
|                         if (onoff.Items[i].HasOn) { | ||||
|                             title.push('On: ' + hoursToString(startSeconds)); | ||||
|                         } else { | ||||
|                             div.addClass('no-start'); | ||||
|                         } | ||||
|                         if (onoff.Items[i].HasOff) { | ||||
|                             title.push('Off: ' + hoursToString(endSeconds)); | ||||
|                         } else { | ||||
|                             div.addClass('no-end'); | ||||
|                         } | ||||
|                         div.attr({ | ||||
|                             start: start, | ||||
|                             end: end, | ||||
|                             title: title.join('\n') | ||||
|                         }); | ||||
|                         var left = getOffset(start, wids); | ||||
|                         var right = getOffset(end, wids); | ||||
|                         var w = right - left - 1; | ||||
|                         if (w < 1) { w = 1; } | ||||
|                         div.css({ | ||||
|                             left: left, | ||||
|                             width: w | ||||
|                         }); | ||||
|                         item.append(div); | ||||
|                     } | ||||
|                     for (var h = 0; h < 24; h++) { | ||||
|                         var totalSeconds = it['s' + h]; | ||||
|                         if (totalSeconds == null) { | ||||
|                             continue; | ||||
|                         } | ||||
|                         var text; | ||||
|                         if (totalSeconds >= 3600) { | ||||
|                             text = '01:00:00'; | ||||
|                         } else { | ||||
|                             text = | ||||
|                                 '00:' + | ||||
|                                 String(Math.floor(totalSeconds / 60)).padStart(2, '0') + ':' + | ||||
|                                 String(Math.round(totalSeconds % 60)).padStart(2, '0'); | ||||
|                         } | ||||
|                         it['h' + h] = text; | ||||
|                     } | ||||
|  | ||||
|                     source.push({ Values: it }); | ||||
|                     parent.append($('<tr></tr>').append(item)); | ||||
|                 } | ||||
|                 source = grid.source.concat(source); | ||||
|                 grid.setData(source); | ||||
|  | ||||
|                 setTimeout(function () { | ||||
|                     doGetAssetTimeline(selecteds, endIndex, parent, idsparent, date); | ||||
|                 }, 0); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function hoursToString(seconds) { | ||||
|             var s = Math.floor(seconds % 60); | ||||
|             seconds = Math.floor(seconds / 60); | ||||
|             var m = Math.round(seconds % 60); | ||||
|             var h = Math.floor(seconds / 60); | ||||
|             return (h < 10 ? '0' : '') + h + ':' + (m < 10 ? '0' : '') + m + ':' + (s < 10 ? '0' : '') + s; | ||||
|         } | ||||
|  | ||||
|         function OnRefresh(cid, dt) { | ||||
|             //getAssetTimeline(cid, dt || $('#date-selector').val()); | ||||
|             pcid = cid; | ||||
|             $('#tds-timeline').empty(); | ||||
|             $('#asset-ids').empty(); | ||||
|         } | ||||
|  | ||||
|         function OnClose() { | ||||
|             window.parent.closePopupView(); | ||||
|         } | ||||
|  | ||||
|         function OnDateChanged() { | ||||
|             var date = $('#date-selector').val(); | ||||
|             if (date == "") { | ||||
|                 showAlert(GetTextByKey("P_WO_XXXXXX", "The date is required."), alerttitle); | ||||
|                 return false; | ||||
|             } | ||||
|             if (!checkDate(date)) { | ||||
|                 showAlert(GetTextByKey("P_WO_XXXXXX", "The date is incorrect."), alerttitle); | ||||
|                 return false; | ||||
|             } | ||||
|             getAssetTimeline(pcid, date); | ||||
|         } | ||||
|  | ||||
|         function getOffset(pos, wids) { | ||||
|             var n = Math.floor(pos); | ||||
|             var p = 0; | ||||
|             for (var i = 0; i < n; i++) { | ||||
|                 p += wids[i]; | ||||
|             } | ||||
|             p += wids[n] * (pos - n); | ||||
|             return p; | ||||
|         } | ||||
|  | ||||
|         function OnExport() { | ||||
|             var date = $('#date-selector').val(); | ||||
|             if (date == "") { | ||||
|                 showAlert(GetTextByKey("P_WO_XXXXXX", "The date is required."), alerttitle); | ||||
|                 return false; | ||||
|             } | ||||
|             if (!checkDate(date)) { | ||||
|                 showAlert(GetTextByKey("P_WO_XXXXXX", "The date is incorrect."), alerttitle); | ||||
|                 return false; | ||||
|             } | ||||
|  | ||||
|             var assets = window.parent.allAssets; | ||||
|             if (assets == null) { | ||||
|                 return; | ||||
|             } | ||||
|             var selecteds = assets.filter(function (a) { return a.State.Selected }).sort(function (a, b) { | ||||
|                 if (a.DisplayName == b.DisplayName) { | ||||
|                     return 0; | ||||
|                 } | ||||
|                 return a.DisplayName > b.DisplayName ? 1 : -1; | ||||
|             }); | ||||
|             var ids = selecteds.map(function (a) { return a.ID }); | ||||
|  | ||||
|             var params = ["timeline", pcid, JSON.stringify(ids), date]; | ||||
|             var data = new FormData(); | ||||
|             data.append('type', 'set'); | ||||
|             data.append('ClientData', JSON.stringify(params)); | ||||
|             $.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) { | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function tabchange(index) { | ||||
|             if (index == 0) { | ||||
|                 $("#btnexporttimelineexcel").hide(); | ||||
|             } | ||||
|             else if (index == 1) { | ||||
|                 if (!canExport) { | ||||
|                     $("#btnexporttimelineexcel").hide(); | ||||
|                 } | ||||
|                 else { | ||||
|                     $("#btnexporttimelineexcel").show(); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     </script> | ||||
| </asp:Content> | ||||
| <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> | ||||
|     <div class="titlePane"> | ||||
|         <span> </span> | ||||
|         <span class="iconclose titleButton close" onclick="OnClose();" style="z-index: 600"></span> | ||||
|     </div> | ||||
|     <div id="tab_container" style="position: relative"> | ||||
|         <ul class="tab_header" style="padding-top: 8px"> | ||||
|             <li data-href="tab_timeline" class="selected" onclick="tabchange(0)" data-lgid="P_MV_TIMELINE">Timeline</li> | ||||
|             <li data-href="tab_grid" onclick="tabchange(1)" data-lgid="P_GRID_TITLE">Utilization by Hour</li> | ||||
|             <li style="clear: both"></li> | ||||
|         </ul> | ||||
|         <div id="tab_timeline" data-page="tab_timeline"> | ||||
|             <div class="table-container"> | ||||
|                 <div style="width: 100px; float: left"> | ||||
|                     <table class="table-timeline"> | ||||
|                         <thead> | ||||
|                             <tr> | ||||
|                                 <th> </th> | ||||
|                             </tr> | ||||
|                         </thead> | ||||
|                         <tbody id="asset-ids"> | ||||
|                             <%--<tr><td style="height: 30px" data-lgid="P_MV_ONOFFEVENTS">On/Off Events</td></tr>--%> | ||||
|                         </tbody> | ||||
|                     </table> | ||||
|                 </div> | ||||
|                 <div style="margin-left: 100px"> | ||||
|                     <table class="table-timeline"> | ||||
|                         <thead> | ||||
|                             <tr id="tr-header"> | ||||
|                                 <th>0:00</th> | ||||
|                                 <th>1:00</th> | ||||
|                                 <th>2:00</th> | ||||
|                                 <th>3:00</th> | ||||
|                                 <th>4:00</th> | ||||
|                                 <th>5:00</th> | ||||
|                                 <th>6:00</th> | ||||
|                                 <th>7:00</th> | ||||
|                                 <th>8:00</th> | ||||
|                                 <th>9:00</th> | ||||
|                                 <th>10:00</th> | ||||
|                                 <th>11:00</th> | ||||
|                                 <th>12:00</th> | ||||
|                                 <th>13:00</th> | ||||
|                                 <th>14:00</th> | ||||
|                                 <th>15:00</th> | ||||
|                                 <th>16:00</th> | ||||
|                                 <th>17:00</th> | ||||
|                                 <th>18:00</th> | ||||
|                                 <th>19:00</th> | ||||
|                                 <th>20:00</th> | ||||
|                                 <th>21:00</th> | ||||
|                                 <th>22:00</th> | ||||
|                                 <th>23:00</th> | ||||
|                             </tr> | ||||
|                         </thead> | ||||
|                         <tbody id="tds-timeline"></tbody> | ||||
|                     </table> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|         <div id="tab_grid" data-page="tab_grid" style="box-sizing: border-box"></div> | ||||
|     </div> | ||||
|     <div style="position: absolute; right: 6px; top: 30px"> | ||||
|         <input type="text" id="date-selector" style="height: 26px; box-sizing: border-box" autocomplete="off" /> | ||||
|         <span class="sbutton iconrefresh" onclick="OnDateChanged();" data-lgid="P_APICRE_REFRESH">Refresh</span> | ||||
|         <span id="btnexporttimelineexcel" class="sbutton iconexport" onclick="OnExport();" style="display: none;" data-lgid="P_MR_EXPORTTOEXCEL">Export to Excel</span> | ||||
|     </div> | ||||
|     <div id="mask_bg" class="maskbg" style="display: none; z-index: 550;"> | ||||
|         <div class="loading c-spin"></div> | ||||
|     </div> | ||||
| </asp:Content> | ||||
|  | ||||
							
								
								
									
										13
									
								
								Site/AssetView/AssetsTimeline.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								Site/AssetView/AssetsTimeline.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| using IronIntel.Contractor; | ||||
| using IronIntel.Contractor.Site; | ||||
| using System; | ||||
|  | ||||
| public partial class AssetView_AssetsTimeline : ContractorBasePage | ||||
| { | ||||
|     public string CurrentDate = ""; | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     { | ||||
|         DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow); | ||||
|         CurrentDate = userlocaldate.ToShortDateString(); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										1843
									
								
								Site/AssetView/SingleAssetView.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1843
									
								
								Site/AssetView/SingleAssetView.aspx
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										166
									
								
								Site/AssetView/SingleAssetView.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										166
									
								
								Site/AssetView/SingleAssetView.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,166 @@ | ||||
| using Foresight.Fleet.Services.Styles; | ||||
| using Foresight.Fleet.Services.User; | ||||
| 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 SingleAssetView : SingleAssetViewBasePage | ||||
| { | ||||
|     public string CurrentDate = ""; | ||||
|     public bool IsDealer = SystemParams.IsDealer; | ||||
|     protected string MenuBackgroundColor = "#D7690E"; | ||||
|  | ||||
|     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; | ||||
|                 GetUIStyle(); | ||||
|             } | ||||
|         } | ||||
|         DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow); | ||||
|         CurrentDate = userlocaldate.ToShortDateString(); | ||||
|     } | ||||
|     private void GetUIStyle() | ||||
|     { | ||||
|         var sessionid = IronIntelBasePage.GetLoginSessionID(Request); | ||||
|         var user = UserManagement.GetUserBySessionID(sessionid); | ||||
|         if (user != null) | ||||
|         { | ||||
|             CustUIStyle style = SystemParams.GetUIStyle(user.IID); | ||||
|             if (style != null) | ||||
|             { | ||||
|                 if (!string.IsNullOrEmpty(style.MenuBackgroundColor)) | ||||
|                 {//目前Menu和Module背景色使用同一个颜色,在有设置的情况下 | ||||
|                     MenuBackgroundColor = style.MenuBackgroundColor; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     protected override bool ThrowIfNotAllowed | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             return true; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public bool CanEditAsset | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             string canEdit = Request.Params["canedit"]; | ||||
|             var user = GetCurrentUser(); | ||||
|             bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS); | ||||
|             return canEdit == "1" && permission; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public bool CanViewWorkOrder | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             bool wolic = SystemParams.HasLicense("WorkOrder"); | ||||
|             bool permission = CheckRight(SystemParams.CompanyID, Feature.WORK_ORDER); | ||||
|             return !SystemParams.IsDealer && wolic && permission; | ||||
|         } | ||||
|     } | ||||
|     public bool CanViewMR | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             bool license = SystemParams.HasLicense("PreventativeMaintenance"); | ||||
|             bool mrlicense = SystemParams.HasLicense("MaintenanceRecord"); | ||||
|             bool permission = CheckRight(SystemParams.CompanyID, Feature.PREVENTATIVE_MAINTENANCE); | ||||
|             return !SystemParams.IsDealer && license && mrlicense && permission && !CanViewWorkOrder;//10486 WorkOrder和Maintenance Record只显示一个 | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public bool CanViewPM | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             bool license = SystemParams.HasLicense("PreventativeMaintenance"); | ||||
|             bool permission = CheckRight(SystemParams.CompanyID, Feature.PREVENTATIVE_MAINTENANCE); | ||||
|             return !SystemParams.IsDealer && license && permission; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public bool CanViewAlertsManagement | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             bool lic = SystemParams.HasLicense("AlertsManagement"); | ||||
|             bool permission = CheckRight(SystemParams.CompanyID, Feature.ALERTS_MANAGEMENT); | ||||
|             return !SystemParams.IsDealer && lic && permission; | ||||
|         } | ||||
|     } | ||||
|     public bool CanViewFuelRecords | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             bool lic = SystemParams.HasLicense("FuelRecords"); | ||||
|             bool permission = CheckRight(SystemParams.CompanyID, Feature.FUEL_RECORDS); | ||||
|             return !SystemParams.IsDealer && lic && permission; | ||||
|         } | ||||
|     } | ||||
|     public bool EnableSmartWitness | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             bool lic = SystemParams.HasLicense("SmartWitness"); | ||||
|             return lic; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public bool CanEditPM | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             string canEdit = Request.Params["canedit"]; | ||||
|             var user = GetCurrentUser(); | ||||
|  | ||||
|             bool license = SystemParams.HasLicense("PreventativeMaintenance"); | ||||
|             bool permission = CheckRight(SystemParams.CompanyID, Feature.PREVENTATIVE_MAINTENANCE); | ||||
|             return canEdit == "1" && license && permission; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public bool IsSupperAdmin | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             var user = GetCurrentUser(); | ||||
|             return user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin; | ||||
|         } | ||||
|     } | ||||
|     public bool CanViewInspection | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             bool lic = SystemParams.HasLicense("Inspection"); | ||||
|             bool permission = CheckRight(SystemParams.CompanyID, Feature.INSPECTION_TEMPLATES); | ||||
|             return !SystemParams.IsDealer && lic && permission; | ||||
|         } | ||||
|     } | ||||
|  | ||||
| } | ||||
							
								
								
									
										171
									
								
								Site/AssetView/js/adj_enginehours.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										171
									
								
								Site/AssetView/js/adj_enginehours.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,171 @@ | ||||
|  | ||||
| //************************Add Engine Hours**************************************// | ||||
| var isAddEH = true; | ||||
| var primarydatadourceADEH; | ||||
| function openAddEnginHours() { | ||||
|     primarydatadourceADEH = undefined; | ||||
|     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(''); | ||||
|     if (assetdata.TelematicsEnabled && !assetdata.CurrentHours.IsEmpty && | ||||
|         (assetdata.CurrentHours.DataSource.toLowerCase() == "calamp" || assetdata.CurrentHours.DataSource.toLowerCase() == "pedigree")) { | ||||
|         isAddEH = false; | ||||
|         primarydatadourceADEH = assetdata.CurrentHours.DataSource; | ||||
|     } | ||||
|     else | ||||
|         isAddEH = true; | ||||
|  | ||||
|     $('#dialog_addenginehours .dialog-title span.title').text(isAddEH ? GetTextByKey("P_MV_ADDENGINEHOURS", 'Add Engine Hours') : GetTextByKey("P_MV_ADJUSTENGINEHOURS", 'Adjust 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 = isAddEH ? GetTextByKey("P_MV_ADDENGINEHOURS", 'Add Engine Hours') : GetTextByKey("P_MV_ADJUSTENGINEHOURS", 'Adjust Engine Hours'); | ||||
|     var item = { | ||||
|         'CustomerID': contractorid, | ||||
|         'AssetID': assetid, | ||||
|         'EngineHours': $('#dialogaddgenginehours_enginehours').val(), | ||||
|         'EngineHoursDate': $('#dialogaddenginehours_date').val(), | ||||
|         'Notes': $('#dialogaddenginehours_Notes').val(), | ||||
|         'DataSource': primarydatadourceADEH | ||||
|     }; | ||||
|     if (item.EngineHours !== "") { | ||||
|         if (isNaN(item.EngineHours)) { | ||||
|             showAlert(GetTextByKey("P_MV_ENGINEHOURSFORMATERROR", 'Engine Hours format error.'), alerttitle); | ||||
|             $('#addenginehoursmask').hide(); | ||||
|             return; | ||||
|         } | ||||
|         else { | ||||
|             if (item.EngineHours <= 0) { | ||||
|                 showAlert(GetTextByKey("P_MV_ENGINEHOURSMUSTBEGREATERTHAN0", 'Engine Hours must be greater than 0.'), alerttitle); | ||||
|                 $('#addenginehoursmask').hide(); | ||||
|                 return; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     else { | ||||
|         showAlert(GetTextByKey("P_MV_ENGINEHOURSCANNOTBEEMPTY", "Engine Hours cannot be empty."), alerttitle); | ||||
|         $('#addenginehoursmask').hide(); | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     if (item.EngineHoursDate === "") { | ||||
|         showAlert(GetTextByKey("P_MV_ENGINEHOURSDATECANNOTBEEMPTY", "Engine Hours Date cannot be empty."), alerttitle); | ||||
|         $('#addenginehoursmask').hide(); | ||||
|         return; | ||||
|     } | ||||
|     var offset = $('#dialogadd_enginehourstimezone').find("option:selected").attr("offset"); | ||||
|     item.OffsetMinute = offset; | ||||
|     var timezonetext = $('#dialogadd_enginehourstimezone').find("option:selected").text(); | ||||
|     var hour = $('#dialogaddenginehours_timehour').val(); | ||||
|     var minute = $('#dialogaddenginehours_timeminute').val(); | ||||
|     item.EngineHoursDate = item.EngineHoursDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00"; | ||||
|  | ||||
|     var time = hour + ":" + minute | ||||
|     var alertmsg = ""; | ||||
|     if (isAddEH) { | ||||
|         alertmsg = GetTextByKey("P_MV_UPDATEENGINEHOURS", "Do you want to update the engine hours to reflect: {0} hours at {1} {2}?").replace('{0}', item.EngineHours).replace('{1}', time).replace('{2}', timezonetext); | ||||
|     } | ||||
|     else { | ||||
|         alertmsg = GetTextByKey("P_MV_UPDATEENGINEHOURS1", "If you proceed, engine hours will be updated to reflect: {0} hours at {1} <br/>" + | ||||
|             " {2}. <br/><br/>Note that this asset is telematic enabled and the primary data source is {3}." + | ||||
|             "<br/><br/> Would you like to proceed?").replace('{0}', item.EngineHours).replace('{1}', time).replace('{2}', timezonetext).replace('{3}', assetdata.CurrentHours.DataSourceName); | ||||
|     } | ||||
|  | ||||
|     showConfirm1(alertmsg, alerttitle, function () { | ||||
|         $('#addenginehoursmask').hide(); | ||||
|         if (isAddEH) | ||||
|             AddManuallyInputEngineHours(item, alerttitle); | ||||
|         else | ||||
|             CheckEngineHourMinimumTime(item, alerttitle); | ||||
|  | ||||
|     }, function () { | ||||
|         $('#addenginehoursmask').hide(); | ||||
|     }); | ||||
| } | ||||
|  | ||||
|  | ||||
| function AddManuallyInputEngineHours(item, alerttitle) { | ||||
|     showloading(true); | ||||
|     var param = JSON.stringify(item); | ||||
|     param = htmlencode(param); | ||||
|  | ||||
|     devicerequest("AddManuallyInputEngineHours", param, function (data) { | ||||
|         showloading(false); | ||||
|         if (data !== 'OK') { | ||||
|             showAlert(data, alerttitle); | ||||
|         } else { | ||||
|             loadAssetInfo(); | ||||
|             showAlert(GetTextByKey("P_MV_ENGINEHOURSUPDATESUCCESSFUL", "Engine Hours Update Successful."), alerttitle); | ||||
|         } | ||||
|  | ||||
|         $('#dialog_addenginehours').hideDialog(); | ||||
|         $('#addenginehoursmask').hide(); | ||||
|     }, function (err) { | ||||
|         console.log(err); | ||||
|         showloading(false); | ||||
|         showAlert(GetTextByKey("P_MV_FAILEDTOADDENGINEHOURS", 'Failed to add Engine Hours.'), alerttitle); | ||||
|         $('#addenginehoursmask').hide(); | ||||
|     }); | ||||
| } | ||||
|  | ||||
| function CheckEngineHourMinimumTime(item, alerttitle) { | ||||
|     var param = JSON.stringify(item); | ||||
|     param = htmlencode(param); | ||||
|     devicerequest("CheckEngineHourMinimumTime", param, function (data) { | ||||
|         if (data > 0) { | ||||
|             if (data == 1) | ||||
|                 showAlert(GetTextByKey("P_MV_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."), alerttitle); | ||||
|             else | ||||
|                 showAlert(GetTextByKey("P_MV_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."), alerttitle); | ||||
|             $('#addenginehoursmask').hide(); | ||||
|             return; | ||||
|         } else { | ||||
|             SaveAdjustEngineHours(item, alerttitle); | ||||
|         } | ||||
|     }, function (err) { | ||||
|     }); | ||||
| } | ||||
|  | ||||
| function SaveAdjustEngineHours(item, alerttitle) { | ||||
|     showloading(true); | ||||
|     var param = JSON.stringify(item); | ||||
|     param = htmlencode(param); | ||||
|  | ||||
|     devicerequest("SaveAdjustEngineHours", param, function (data) { | ||||
|         showloading(false); | ||||
|         if (data !== 'OK') { | ||||
|             showAlert(data, alerttitle); | ||||
|         } else { | ||||
|             loadAssetInfo(); | ||||
|             showAlert(GetTextByKey("P_MV_ENGINEHOURSUPDATESUCCESSFUL", "Engine Hours Update Successful."), alerttitle); | ||||
|         } | ||||
|  | ||||
|         $('#dialog_addenginehours').hideDialog(); | ||||
|         $('#addenginehoursmask').hide(); | ||||
|     }, function (err) { | ||||
|         console.log(err); | ||||
|         showloading(false); | ||||
|         showAlert(GetTextByKey("P_MV_FAILEDTOADJUSTENGINEHOURS", 'Failed to adjust Engine Hours.'), alerttitle); | ||||
|         $('#addenginehoursmask').hide(); | ||||
|     }); | ||||
| } | ||||
							
								
								
									
										167
									
								
								Site/AssetView/js/adj_odometer.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										167
									
								
								Site/AssetView/js/adj_odometer.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,167 @@ | ||||
|  | ||||
| //************************Add Odometer**************************************// | ||||
| var isAddOdo = true; | ||||
| var primarydatadourceADOdo; | ||||
| function openAddOdometer() { | ||||
|     primarydatadourceADOdo = undefined; | ||||
|     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(''); | ||||
|     if (assetdata.TelematicsEnabled && !assetdata.CurrentOdometer.IsEmpty && | ||||
|         (assetdata.CurrentOdometer.DataSource.toLowerCase() == "calamp" || assetdata.CurrentOdometer.DataSource.toLowerCase() == "pedigree")) { | ||||
|         isAddOdo = false; | ||||
|         primarydatadourceADOdo = assetdata.CurrentOdometer.DataSource; | ||||
|     } | ||||
|     else | ||||
|         isAddOdo = true; | ||||
|  | ||||
|     $('#dialog_addodometer .dialog-title span.title').text(isAddOdo ? GetTextByKey("P_MV_ADDODOMETER", 'Add Odometer') : GetTextByKey("P_MV_ADJUSTODOMETER", 'Adjust 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 alerttitle = isAddOdo ? GetTextByKey("P_MV_ADDODOMETER", 'Add Odometer') : GetTextByKey("P_MV_ADJUSTODOMETER", 'Adjust Odometer'); | ||||
|     var item = { | ||||
|         'CustomerID': contractorid, | ||||
|         'AssetID': assetid, | ||||
|         'Odometer': $('#dialogadd_odometer').val(), | ||||
|         'UOM': $('#dialogadd_sel_odometeruom').val(), | ||||
|         'OdometerDate': $('#dialogadd_odometerdate').val(), | ||||
|         'Notes': $('#dialogadd_notes').val(), | ||||
|         'DataSource': primarydatadourceADOdo | ||||
|     }; | ||||
|     if (item.Odometer !== "") { | ||||
|         if (isNaN(item.Odometer)) { | ||||
|             showAlert(GetTextByKey("P_MV_ODOMETERFORMATERROR", 'Odometer format error.'), alerttitle); | ||||
|             $('#addodomask').hide(); | ||||
|             return; | ||||
|         } | ||||
|         else { | ||||
|             if (item.Odometer <= 0) { | ||||
|                 showAlert(GetTextByKey("P_MV_ODOMETERMUSTBEGREATERTHAN0", 'ODOMeter must be greater than 0.'), alerttitle); | ||||
|                 $('#addodomask').hide(); | ||||
|                 return; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     else { | ||||
|         showAlert(GetTextByKey("P_MV_ODOMETRCANNOTBEEMPTY", "Odometer cannot be empty."), alerttitle); | ||||
|         $('#addodomask').hide(); | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     if (item.OdometerDate === "") { | ||||
|         showAlert(GetTextByKey("P_MV_ODOMETRDATACANNOTBEEMPTY", "Odometer date cannot be empty."), alerttitle); | ||||
|         $('#addodomask').hide(); | ||||
|         return; | ||||
|     } | ||||
|     var offset = $('#dialogadd_odometertimezone').find("option:selected").attr("offset"); | ||||
|     item.OffsetMinute = offset; | ||||
|     var timezonetext = $('#dialogadd_enginehourstimezone').find("option:selected").text(); | ||||
|  | ||||
|     var hour = $('#dialogadd_timehour').val(); | ||||
|     var minute = $('#dialogadd_timeminute').val(); | ||||
|  | ||||
|     item.OdometerDate = item.OdometerDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00"; | ||||
|  | ||||
|     var time = hour + ":" + minute | ||||
|     var alertmsg = ""; | ||||
|     if (isAddOdo) { | ||||
|         alertmsg = GetTextByKey("P_MV_UPDATETHEODOMETER", "Do you want to update the odometer to reflect: {0} {1} at {2} {3}?").replace('{0}', item.Odometer).replace('{1}', item.UOM).replace('{2}', time).replace('{3}', timezonetext); | ||||
|     } | ||||
|     else { | ||||
|         alertmsg = GetTextByKey("P_MV_UPDATETHEODOMETER1", "If you proceed, odometer will be updated to reflect: {0} {1} at {2} <br/> {3}.<br/><br/> Note that this asset is telematic enabled and the primary data source is {4}.<br/><br/>Would you like to proceed?").replace('{0}', item.Odometer).replace('{1}', item.UOM).replace('{2}', time).replace('{3}', timezonetext).replace('{4}', assetdata.CurrentOdometer.DataSourceName); | ||||
|     } | ||||
|  | ||||
|     showConfirm1(alertmsg, alerttitle, function () { | ||||
|         $('#addodomask').hide(); | ||||
|         if (isAddOdo) | ||||
|             AddManuallyInputOdometer(item, alerttitle); | ||||
|         else | ||||
|             CheckOdometerMinnimumTime(item, alerttitle); | ||||
|  | ||||
|     }, function () { | ||||
|         $('#addodomask').hide(); | ||||
|     }); | ||||
| } | ||||
|  | ||||
|  | ||||
| function AddManuallyInputOdometer(item, alerttitle) { | ||||
|     showloading(true); | ||||
|     var param = JSON.stringify(item); | ||||
|     param = htmlencode(param); | ||||
|     devicerequest("AddManuallyInputOdometer", param, function (data) { | ||||
|         showloading(false); | ||||
|         if (data !== 'OK') { | ||||
|             showAlert(data, alerttitle); | ||||
|         } else { | ||||
|             loadAssetInfo(); | ||||
|             showAlert(GetTextByKey("P_MV_ODOMETERUPDATESUCCESSFUL", "Odometer Update Successful."), alerttitle); | ||||
|         } | ||||
|  | ||||
|         $('#dialog_addodometer').hideDialog(); | ||||
|         $('#addodomask').hide(); | ||||
|     }, function (err) { | ||||
|         showloading(false); | ||||
|         showAlert(GetTextByKey("P_MV_FAILEDTOADDODOMETER", 'Failed to add Odometer.'), alerttitle); | ||||
|         $('#addodomask').hide(); | ||||
|     }); | ||||
| } | ||||
|  | ||||
| function CheckOdometerMinnimumTime(item, alerttitle) { | ||||
|     var param = JSON.stringify(item); | ||||
|     param = htmlencode(param); | ||||
|     devicerequest("CheckOdometerMinnimumTime", param, function (data) { | ||||
|         if (data > 0) { | ||||
|             if (data == 1) | ||||
|                 showAlert(GetTextByKey("P_MA_CHECKODOMETERMINNIMUMTIME", "The adjustment cannot be completed as provided. The odometer reading date provided cannot be prior to initial telematic data available for the asset."), alerttitle); | ||||
|             else | ||||
|                 showAlert(GetTextByKey("P_MA_CHECKODOMETERMINNIMUMTIME1", "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."), alerttitle); | ||||
|             $('#addodomask').hide(); | ||||
|             return; | ||||
|         } else { | ||||
|             SaveAdjustOdometer(item, alerttitle); | ||||
|         } | ||||
|     }, function (err) { | ||||
|     }); | ||||
| } | ||||
|  | ||||
| function SaveAdjustOdometer(item, alerttitle) { | ||||
|     showloading(true); | ||||
|     var param = JSON.stringify(item); | ||||
|     param = htmlencode(param); | ||||
|     devicerequest("SaveAdjustOdometer", param, function (data) { | ||||
|         showloading(false); | ||||
|         if (data !== 'OK') { | ||||
|             showAlert(data, alerttitle); | ||||
|         } else { | ||||
|             loadAssetInfo(); | ||||
|             showAlert(GetTextByKey("P_MV_ODOMETERUPDATESUCCESSFUL", "Odometer Update Successful."), alerttitle); | ||||
|         } | ||||
|  | ||||
|         $('#dialog_addodometer').hideDialog(); | ||||
|         $('#addodomask').hide(); | ||||
|     }, function (err) { | ||||
|         showloading(false); | ||||
|         showAlert(GetTextByKey("P_MV_FAILEDTOADJUSTODOMETER", 'Failed to adjust Odometer.'), alerttitle); | ||||
|         $('#addodomask').hide(); | ||||
|     }); | ||||
| } | ||||
							
								
								
									
										574
									
								
								Site/AssetView/js/assetpm.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										574
									
								
								Site/AssetView/js/assetpm.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,574 @@ | ||||
| $(function () { | ||||
|     InitPMGridData(); | ||||
|  | ||||
|     $('#dialog_pm').dialog(function () { | ||||
|         $("#pmschedulelistmask").hide(); | ||||
|     }); | ||||
|  | ||||
|     $('#dialog_pmschedulelist').dialog(function () { | ||||
|         showmaskbg(false); | ||||
|         GetPMInfo(); | ||||
|     }); | ||||
|  | ||||
|  | ||||
|     if (!IsDealer && CanEditPM) | ||||
|         $("#btnaddplan").show(); | ||||
| }); | ||||
|  | ||||
| function showPMSchedules() { | ||||
|     showmaskbg(true); | ||||
|     $('#dialog_pmschedulelist').css({ | ||||
|         'top': (document.documentElement.clientHeight - $('#dialog_pmschedulelist').height()) / 3, | ||||
|         'left': (document.documentElement.clientWidth - $('#dialog_pmschedulelist').width()) / 2 | ||||
|     }).showDialogfixed(); | ||||
|  | ||||
|     SetAssetItem(assetdata); | ||||
|     getAssetPMSchedules(); | ||||
| } | ||||
|  | ||||
| function SetAssetItem(asset) { | ||||
|     if (isNaN(asset.EngineHours)) | ||||
|         asset.EngineHours = asset.CurrentHours.Corrected | ||||
|     if (isNaN(asset.Odometer)) { | ||||
|         asset.Odometer = asset.CurrentOdometer.Corrected; | ||||
|         asset.OdometerUnits = asset.CurrentOdometer.UOM; | ||||
|     } | ||||
|     $("#dialog_pm").data("asset", asset); | ||||
| } | ||||
|  | ||||
| function showConfirmsub(msg, title, fok, fcancel) { | ||||
|     $("#pmschedulelistmask").show(); | ||||
|     _dialog.showConfirmOKCancel(msg, title, function (e) { | ||||
|         $("#pmschedulelistmask").hide(); | ||||
|         if (typeof fok === 'function') { | ||||
|             fok(e); | ||||
|         } | ||||
|     }, function () { | ||||
|         if (fcancel) | ||||
|             fcancel(); | ||||
|         $("#pmschedulelistmask").hide(); | ||||
|     }); | ||||
| } | ||||
|  | ||||
| /****** 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_MV_SCHEDULENAME", "Schedule Name"), valueIndex: 'PmScheduleName', css: { 'width': 200, 'text-align': 'left' } }, | ||||
|         { name: 'StartValue', caption: GetTextByKey("P_MV_INITIALSERVICEVALUE", "Initial Service Value"), valueIndex: 'StartValue', css: { 'width': 120, 'text-align': 'right' } }, | ||||
|         { name: 'LastAlertTimeString', caption: GetTextByKey("P_MV_LASTSERVICEDATE", "Last Service Date"), valueIndex: 'LastAlertTimeString', css: { 'width': 120, 'text-align': 'left' } }, | ||||
|         { name: 'ServiceName', caption: GetTextByKey("P_MV_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_MV_REMOVEASSETFROMSCHEDULE", "Do you want to remove this asset from the schedule?"); | ||||
|                         if (item.UnMaintainedAlert && item.UnMaintainedAlert > 0) { | ||||
|                             var msg = GetTextByKey("P_MV_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."); | ||||
|                         } | ||||
|                         showConfirmsub(msg, GetTextByKey("P_MV_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() { | ||||
|     $("#pmschedulelistmask").show(); | ||||
|     assetrequest1('GetPMSchedulesByAsset', assetid, function (data) { | ||||
|         $("#pmschedulelistmask").hide(); | ||||
|         if (typeof (data) === "string") { | ||||
|             showAlert(data, GetTextByKey("P_MV_ERROR", 'Error')); | ||||
|             return; | ||||
|         } | ||||
|         if (data && data.length > 0) { | ||||
|             pmschedules = data; | ||||
|             ShowPMSchedules(data); | ||||
|         } | ||||
|     }, function () { | ||||
|         $("#pmschedulelistmask").hide(); | ||||
|     }); | ||||
| } | ||||
|  | ||||
| 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) { | ||||
|     $("#pmschedulelistmask").show(); | ||||
|     assetrequest1('AddAssetToPMSchedule', JSON.stringify(item), function (data) { | ||||
|         if (data === "OK") { | ||||
|             $("#pmschedulelistmask").hide(); | ||||
|             $('#dialog_pm').hideDialog(); | ||||
|             //showAlert(data, 'Saved Successfully.'); | ||||
|             getAssetPMSchedules(); | ||||
|         } | ||||
|         else | ||||
|             showAlert(data, GetTextByKey("P_MV_ERROR", 'Error')); | ||||
|     }, function () { | ||||
|         $("#pmschedulelistmask").hide(); | ||||
|     }); | ||||
| } | ||||
|  | ||||
| function removeAssetFromPMSchedule(schedule) { | ||||
|     var assetid = $("#dialog_pm").data("asset").ID; | ||||
|     var scheduleid = schedule.PmScheduleID; | ||||
|     $("#pmschedulelistmask").show(); | ||||
|     assetrequest1('RemoveAssetFromPMSchedule', JSON.stringify([assetid, scheduleid]), function (data) { | ||||
|         $("#pmschedulelistmask").hide(); | ||||
|         if (data === "OK") { | ||||
|             //showAlert(data, 'Removed Successfully.'); | ||||
|             getAssetPMSchedules(); | ||||
|         } | ||||
|         else | ||||
|             showAlert(data, GetTextByKey("P_MV_ERROR", 'Error')); | ||||
|     }, function () { | ||||
|         $("#pmschedulelistmask").hide(); | ||||
|     }); | ||||
| } | ||||
|  | ||||
| function showSetPMDialog(pmschedule) { | ||||
|     $("#pmschedulelistmask").show(); | ||||
|     //$('#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_MV_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_MV_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_MV_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>" + GetTextByKey("P_MV_NOW", " now.") + "</span>")); | ||||
|  | ||||
|         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_MV_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_MV_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_MV_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>" + GetTextByKey("P_MV_SERVICEWASPERFORMEDAT", " service was performed at ") + "</span>")); | ||||
|         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_MV_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_MV_TRIGGERANALERTASIFSERVICEISDUETODAY", "Trigger an alert as if service is due today."); | ||||
|     else | ||||
|         text = GetTextByKey("P_MV_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_MV_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>" + GetTextByKey("P_MV_FOR", " for ") + "</span>")); | ||||
|         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_MV_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_MV_BEFORETHEASSETREADING", " before the asset reading ") + value + " " + unit; | ||||
|             text += GetTextByKey("P_MV_FOR", " for ") + nextInterval.ServiceName + "."; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     return text; | ||||
| } | ||||
							
								
								
									
										294
									
								
								Site/ChangePassword.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										294
									
								
								Site/ChangePassword.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,294 @@ | ||||
| <%@ Page Title="" Language="C#" MasterPageFile="~/IronIntelMasterPage.master" AutoEventWireup="true" CodeFile="ChangePassword.aspx.cs" Inherits="ChangePassword" %> | ||||
|  | ||||
| <asp:Content ID="Content1" ContentPlaceHolderID="holder_head" runat="Server"> | ||||
|     <style type="text/css"> | ||||
|         body { | ||||
|             overflow-x: hidden; | ||||
|         } | ||||
|  | ||||
|         .cp_body { | ||||
|             width: 960px; | ||||
|             margin: 40px 240px; | ||||
|             color: #666; | ||||
|         } | ||||
|  | ||||
|         .cp_header { | ||||
|             line-height: 40px; | ||||
|             font-size: 1.8em; | ||||
|         } | ||||
|  | ||||
|         .cp_form { | ||||
|             margin-top: 20px; | ||||
|             height: 340px; | ||||
|         } | ||||
|  | ||||
|         .cp_button { | ||||
|             margin-top: 30px; | ||||
|         } | ||||
|  | ||||
|             .cp_button input { | ||||
|                 border: none; | ||||
|                 background: #e7790E; | ||||
|                 cursor: pointer; | ||||
|                 padding: 6px; | ||||
|                 width: 80px; | ||||
|             } | ||||
|  | ||||
|                 .cp_button input:hover { | ||||
|                     background: #d7690E; | ||||
|                 } | ||||
|  | ||||
|         .item_header { | ||||
|             font-family: Arial; | ||||
|             font-size: 1.1em; | ||||
|             font-weight: bold; | ||||
|             line-height: 24px; | ||||
|             margin-top: 8px; | ||||
|         } | ||||
|  | ||||
|         .item_label { | ||||
|             line-height: 18px; | ||||
|         } | ||||
|  | ||||
|         .item_text { | ||||
|             line-height: 22px; | ||||
|         } | ||||
|  | ||||
|             .item_text input { | ||||
|                 width: 286px; | ||||
|                 border: 1px solid #a9a9a9; | ||||
|                 padding: 2px; | ||||
|             } | ||||
|  | ||||
|         .item_error { | ||||
|             padding: 5px; | ||||
|             margin-top: 5px; | ||||
|             border: 1px solid #f00; | ||||
|             color: #f00; | ||||
|             width: 280px; | ||||
|         } | ||||
|  | ||||
|         .item_strong { | ||||
|             width: 292px; | ||||
|             line-height: 17px; | ||||
|         } | ||||
|  | ||||
|         #pass_progress label { | ||||
|             margin: 2px 4px; | ||||
|         } | ||||
|  | ||||
|         .non { | ||||
|             background: none; | ||||
|             color: rgb(115, 124, 133); | ||||
|         } | ||||
|  | ||||
|         .weak { | ||||
|             background: #f00; | ||||
|             color: white; | ||||
|             width: 33%; | ||||
|         } | ||||
|  | ||||
|         .normal { | ||||
|             background: #ec6b00; | ||||
|             color: white; | ||||
|             width: 66%; | ||||
|         } | ||||
|  | ||||
|         .strong { | ||||
|             background: #579705; | ||||
|             color: white; | ||||
|             width: 100%; | ||||
|         } | ||||
|  | ||||
|         #content { | ||||
|             overflow-y: auto; | ||||
|             overflow-x: hidden; | ||||
|         } | ||||
|     </style> | ||||
|     <script type="text/javascript"> | ||||
|         $(function () { | ||||
|             var iswrong = false; | ||||
|  | ||||
|             // ChangePassword | ||||
|             function changepassQuery(method, param, callback, error) { | ||||
|                 _network.request("ChangePassword.aspx?tp=ashx", -1, method, param, callback, error); | ||||
|             } | ||||
|  | ||||
|             function CheckIfEmpty(val, errid) { | ||||
|                 if (typeof val !== 'string' || val.length == 0) { | ||||
|                     $(errid).text(GetTextByKey("P_CP_PLEASEENTERTHEPASSWORD", 'Please enter the password.')).show(); | ||||
|                     iswrong = true; | ||||
|                     return false; | ||||
|                 } else if (val[0] == ' ' || val[val.length - 1] == ' ') { | ||||
|                     $(errid).text(GetTextByKey("P_CP_THEHEADANDTAILOFTHEPASSWORDCANNOTBESPACES", 'The head and tail of the password cannot be spaces.')).show(); | ||||
|                     iswrong = true; | ||||
|                     return false; | ||||
|                 } else { | ||||
|                     $(errid).hide(); | ||||
|                 } | ||||
|                 iswrong = false; | ||||
|                 return true; | ||||
|             } | ||||
|  | ||||
|             function CheckIfEmptyOrDismatch(val, v, errid) { | ||||
|                 if (typeof val !== 'string' || val.length == 0) { | ||||
|                     $(errid).text(GetTextByKey("P_CP_PLEASEENTERTHEPASSWORD", 'Please enter the password.')).show(); | ||||
|                     iswrong = true; | ||||
|                     return false; | ||||
|                 } else if (val != v) { | ||||
|                     $(errid).text(GetTextByKey("P_CP_THEPASSWORDSYOUENTEREDDONOTMATCHCHECKYOURTYPINGANDTRYAGAIN", 'The passwords you entered do not match. Check your typing and try again.')).show(); | ||||
|                     iswrong = true; | ||||
|                     return false; | ||||
|                 } else { | ||||
|                     $(errid).hide(); | ||||
|                 } | ||||
|                 iswrong = false; | ||||
|                 return true; | ||||
|             } | ||||
|  | ||||
|             function CheckInfo(e) { | ||||
|                 if (iswrong) { | ||||
|                     // has errors; | ||||
|                     return; | ||||
|                 } | ||||
|  | ||||
|                 var oldpass = $('#txt_old_pass').val(); | ||||
|                 if (oldpass.length == 0) { | ||||
|                     $('#old_pass_error').show(); | ||||
|                     $('#txt_old_pass').focus(); | ||||
|                     return false; | ||||
|                 } else { | ||||
|                     $('#old_pass_error').hide(); | ||||
|                 } | ||||
|  | ||||
|                 var newpass = $('#txt_new_pass').val(); | ||||
|                 if (!CheckIfEmpty(newpass, '#pass_error')) { | ||||
|                     $('#txt_new_pass').focus(); | ||||
|                     return false; | ||||
|                 } | ||||
|  | ||||
|                 var newpass2 = $('#txt_new_pass2').val(); | ||||
|                 if (!CheckIfEmptyOrDismatch(newpass2, newpass, '#pass_error2')) { | ||||
|                     $('#txt_new_pass2').focus(); | ||||
|                     return false; | ||||
|                 } | ||||
|                 // strong test | ||||
|                 if (newpass.length < 8) { | ||||
|                     $('#pass_error').text(GetTextByKey("P_CP_PASSWORDTIPS", 'The password must be at least 8 characters.')).show(); | ||||
|                     iswrong = true; | ||||
|                 } | ||||
|                 if (!iswrong && getStrength(newpass) < 2) { | ||||
|                     $('#pass_error').text(GetTextByKey("P_CP_PASSWORDTIPS1", 'The password must contain both uppercase and lowercase characters and at lease one number.')).show(); | ||||
|                     iswrong = true; | ||||
|                 } | ||||
|  | ||||
|                 if (iswrong) { | ||||
|                     $('#txt_new_pass').focus(); | ||||
|                     return false; | ||||
|                 } | ||||
|  | ||||
|  | ||||
|                 DoChangePassword(htmlencode(oldpass), htmlencode(newpass)); | ||||
|                 return true; | ||||
|             } | ||||
|  | ||||
|             function enableUI(flag) { | ||||
|                 $('#txt_old_pass').prop('disabled', !flag); | ||||
|                 $('#txt_new_pass').prop('disabled', !flag); | ||||
|                 $('#txt_new_pass2').prop('disabled', !flag); | ||||
|                 $('#button_submit').prop('disabled', !flag); | ||||
|             } | ||||
|  | ||||
|             function DoChangePassword(oldpass, newpass) { | ||||
|                 enableUI(false); | ||||
|  | ||||
|                 changepassQuery('ChangePassword', oldpass + String.fromCharCode(170) + newpass, function (data) { | ||||
|                     if (!data || data.length == 0) { | ||||
|                         $('#old_pass_error').hide(); | ||||
|                         $('#txt_old_pass').val(''); | ||||
|                         $('#txt_new_pass').val(''); | ||||
|                         $('#txt_new_pass2').val(''); | ||||
|                         $('#pass_progress').attr('class', 'non').children('label').text(GetTextByKey("P_CP_PASSWORDSTRENGTH", 'Password strength')); | ||||
|                         alert(GetTextByKey("P_CP_PASSWORDSUCCESSFULLYCHANGED", 'Password successfully changed.')); | ||||
|                         enableUI(true); | ||||
|                     } else { | ||||
|                         enableUI(true); | ||||
|                         //$('#pass_error2').text(data).show(); | ||||
|                         $('#old_pass_error').show(); | ||||
|                         $('#txt_old_pass').focus(); | ||||
|                     } | ||||
|                 }, function (err) { | ||||
|                     $('#pass_error2').text(GetTextByKey("P_CP_UNKNOWNERROROCCURS", 'Unknown error occurs.')).show(); | ||||
|                     enableUI(true); | ||||
|                 }); | ||||
|             } | ||||
|  | ||||
|             function ChangeStrength() { | ||||
|                 var pass = $(this).val(); | ||||
|                 if (typeof pass !== 'string' || pass.length == 0) { | ||||
|                     $('#pass_progress').attr('class', 'non').children('label').text(GetTextByKey("P_CP_PASSWORDSTRENGTH", 'Password strength')); | ||||
|                 } else if (pass.length < 6) { | ||||
|                     $('#pass_progress').attr('class', 'weak').children('label').text(GetTextByKey("P_CP_WEAK", 'weak')); | ||||
|                 } else { | ||||
|                     var strength = getStrength(pass); | ||||
|                     if (strength == 2) { | ||||
|                         $('#pass_progress').attr('class', 'strong').children('label').text(GetTextByKey("P_CP_STRONG", 'strong')); | ||||
|                     } else if (strength == 1) { | ||||
|                         $('#pass_progress').attr('class', 'normal').children('label').text(GetTextByKey("P_CP_MEDIUM", 'medium')); | ||||
|                     } else { | ||||
|                         $('#pass_progress').attr('class', 'weak').children('label').text(GetTextByKey("P_CP_WEAK", 'weak')); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             $('#txt_new_pass') | ||||
|                 .bind('propertychange', ChangeStrength) | ||||
|                 .bind('input', ChangeStrength) | ||||
|                 .blur(function () { | ||||
|                     var newpass = $(this).val(); | ||||
|                     CheckIfEmpty(newpass, '#pass_error'); | ||||
|                 }); | ||||
|             $('#txt_new_pass2').blur(function () { | ||||
|                 var newpass = $('#txt_new_pass').val(); | ||||
|                 var newpass2 = $(this).val(); | ||||
|                 CheckIfEmptyOrDismatch(newpass2, newpass, '#pass_error2'); | ||||
|             }); | ||||
|             $('#button_submit').click(CheckInfo); | ||||
|  | ||||
|             $('#txt_old_pass').val(''); | ||||
|         }); | ||||
|     </script> | ||||
| </asp:Content> | ||||
| <asp:Content ID="Content2" ContentPlaceHolderID="holder_content" runat="Server"> | ||||
|     <div class="cp_body"> | ||||
|         <div class="cp_header" data-lgid="P_CHANGEPASSWORD">Change Password</div> | ||||
|         <div class="cp_form"> | ||||
|             <div class="item_header" data-lgid="P_CP_USERID">User ID</div> | ||||
|             <div class="item_label"><%=HttpUtility.HtmlEncode(UserID)%></div> | ||||
|             <div class="item_header" data-lgid="P_CP_OLDPASSWORD">Old Password</div> | ||||
|             <div class="item_text"> | ||||
|                 <input type="password" id="txt_old_pass" name="oldpass" autocomplete="off" /> | ||||
|             </div> | ||||
|             <div id="old_pass_error" class="item_error" style="display: none;" data-lgid="P_CP_THEOLDPASSWORDISWRONG">The old password is wrong.</div> | ||||
|             <div class="item_header" data-lgid="P_CP_NEWPASSWORD">New Password</div> | ||||
|             <div class="item_text"> | ||||
|                 <input type="password" id="txt_new_pass" name="newpass" autocomplete="off" /> | ||||
|             </div> | ||||
|             <div class="item_strong"> | ||||
|                 <div id="pass_progress" class="non"> | ||||
|                     <label data-lgid="P_CP_PASSWORDSTRENGTH">Password strength</label> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div id="pass_error" class="item_error" style="display: none;"></div> | ||||
|             <div class="item_header" data-lgid="P_CP_CONFIRMNEWPASSWORD">Confirm New Password</div> | ||||
|             <div class="item_text"> | ||||
|                 <input type="password" id="txt_new_pass2" name="newpass2" autocomplete="off" /> | ||||
|             </div> | ||||
|             <div id="pass_error2" class="item_error" style="display: none;"></div> | ||||
|         </div> | ||||
|         <div class="cp_button"> | ||||
|             <input id="button_submit" type="button" value="OK" data-lgid="P_CP_OK" /> | ||||
|         </div> | ||||
|     </div> | ||||
| </asp:Content> | ||||
|  | ||||
							
								
								
									
										29
									
								
								Site/ChangePassword.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								Site/ChangePassword.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | ||||
| 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 ChangePassword : ChangePasswordBasePage | ||||
| { | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     { | ||||
|         string tp = Request.QueryString["tp"]; | ||||
|         if (string.Compare(tp, "ashx", true) == 0) | ||||
|         { | ||||
|             ProcessRequest(); | ||||
|         } | ||||
|         else if (!IsPostBack) | ||||
|         { | ||||
|             Title = PageTitle; | ||||
|             if (CheckLoginSession()) | ||||
|             { | ||||
|                 // nothing | ||||
|                 var s = GetCurrentLoginSession(); | ||||
|                 UserID = s.User.ID; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										417
									
								
								Site/Chart.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										417
									
								
								Site/Chart.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,417 @@ | ||||
| <%@ Page Title="" Language="C#" MasterPageFile="~/IronIntelMasterPage.master" AutoEventWireup="true" CodeFile="Chart.aspx.cs" Inherits="FIC" %> | ||||
|  | ||||
| <asp:Content ID="Content1" ContentPlaceHolderID="holder_head" runat="Server"> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/js/components/css/modal.css")%>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/css/workspace.css") %>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/js/components/css/override.css")%>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/js/components/css/gridview.css")%>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/js/components/css/datagrid.css") %>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/js/components/css/design-grid.min.css") %>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/css/chart.css")%>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/css/pivot.css")%>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/js/components/css/vue-ctrls.css") %>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/css/form.css") %>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/css/wizardctrl.css") %>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/css/Grid.css")%>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("css/datepicker.min.css")%>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/css/JsTreeCss/style.min.css")%>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("fic/css/tabcontrol.css") %>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=Common.GenerateUrl("../css/override.css") %>" rel="stylesheet" /> | ||||
|     <link rel="stylesheet" href="https://js.arcgis.com/3.40/esri/css/esri.css" /> | ||||
|     <style type="text/css"> | ||||
|         body { | ||||
|             /* 禁止选中 */ | ||||
|             -moz-user-select: none; /*火狐*/ | ||||
|             -webkit-user-select: none; /*webkit浏览器*/ | ||||
|             -ms-user-select: none; /*IE10*/ | ||||
|             -khtml-user-select: none; /*早期浏览器*/ | ||||
|             user-select: none; | ||||
|             overflow: hidden; | ||||
|         } | ||||
|  | ||||
|         #wsp_personal { | ||||
|             outline: none; | ||||
|             margin: 0 3px; | ||||
|             height: 33px; | ||||
|             float: left; | ||||
|         } | ||||
|  | ||||
|         #host_header .workspace_menu { | ||||
|             padding-right: 0; | ||||
|             /*overflow-y: auto; | ||||
|                 overflow-x: hidden;*/ | ||||
|             min-width: 255px; | ||||
|         } | ||||
|  | ||||
|             #host_header .workspace_menu .wspMenuTitle { | ||||
|                 height: 30px; | ||||
|                 line-height: 30px; | ||||
|                 font-weight: bold; | ||||
|             } | ||||
|  | ||||
|             #host_header .workspace_menu ul { | ||||
|                 padding: 0; | ||||
|                 margin: 0; | ||||
|                 max-height: 260px; | ||||
|                 overflow-y: auto; | ||||
|                 overflow-x: hidden; | ||||
|             } | ||||
|  | ||||
|             #host_header .workspace_menu li { | ||||
|                 white-space: nowrap; | ||||
|                 height: 24px; | ||||
|                 line-height: 24px; | ||||
|                 cursor: pointer; | ||||
|                 padding: 0 40px 0 2px; | ||||
|                 margin: 0 5px 0 0; | ||||
|                 list-style: none; | ||||
|             } | ||||
|  | ||||
|                 #host_header .workspace_menu li:hover { | ||||
|                     background: #eaeaea; | ||||
|                 } | ||||
|  | ||||
|                 #host_header .workspace_menu li.no-result { | ||||
|                     cursor: default; | ||||
|                     font-style: italic; | ||||
|                 } | ||||
|  | ||||
|                     #host_header .workspace_menu li.no-result:hover { | ||||
|                         background: inherit; | ||||
|                     } | ||||
|  | ||||
|         #wsp_content { | ||||
|             position: fixed; | ||||
|             top: 93px; | ||||
|             width: 100%; | ||||
|             bottom: 0; | ||||
|             overflow: auto; | ||||
|         } | ||||
|  | ||||
|         #workspace_info { | ||||
|             height: 33px; | ||||
|             line-height: 33px; | ||||
|             padding: 0 0 0 4px; | ||||
|             background: rgba(0,0,0,0.2); | ||||
|         } | ||||
|  | ||||
|             #workspace_info .workspace_grade_icon { | ||||
|                 width: 15px; | ||||
|                 height: 11px; | ||||
|                 float: left; | ||||
|                 margin: 11px 0 0 6px; | ||||
|             } | ||||
|  | ||||
|         #chart_comments_container, | ||||
|         #email_subscription_container { | ||||
|             position: fixed; | ||||
|             border: none; | ||||
|             background: white; | ||||
|             top: 0; | ||||
|             right: 0; | ||||
|             height: 100%; | ||||
|             width: 420px; | ||||
|             border-left: 1px solid #aaa; | ||||
|             z-index: 1000; | ||||
|         } | ||||
|  | ||||
|         #email_subscription_container { | ||||
|             width: 900px; | ||||
|         } | ||||
|     </style> | ||||
|     <script type="text/javascript"> | ||||
|         var subpages = []; | ||||
|         var appPath = "<%=this.ResolveUrl("~/") %>"; | ||||
|         var sitePath = "<%=this.ResolveUrl("~/fic/") %>"; | ||||
|         ApplicationPath = sitePath; | ||||
|         var isLocalForm = true; | ||||
|     </script> | ||||
|     <%--<script type="text/javascript" src="<%=Common.GenerateUrl("js/jquery-1.11.3.js") %>"></script>--%> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("js/lib/vue.min.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("js/promise.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/components/modal.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("js/utility.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/dialog.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/additionalFilter.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/editGridCtrl.js") %>"></script> | ||||
|     <%--<script type="text/javascript" src="<%=GenerateUrl("fic/js/controls/changepassword.js") %>"></script>--%> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/workspace.js") %>"></script> | ||||
|      | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("js/echarts.min.js")%>"></script> | ||||
|     <%--<script type="text/javascript" src="//cdn.jsdelivr.net/npm/echarts@4.8.0/dist/echarts.js"></script>--%> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("js/datepicker.min.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("js/lib/vue-color.min.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/components/gridview.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/about.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/menu.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/pivot.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/controls.js") %>"></script> | ||||
|     <%--<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/editGridCtrl.js") %>"></script>--%> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/components/datagrid.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/components/vue-ctrls.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/components/design-grid.min.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/form.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/wizardctrl.js") %>"></script> | ||||
|  | ||||
|     <%-- 覆盖fic定义 --%> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/override.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/g5masterjs.js")%>"></script> | ||||
|  | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/wsp_pivot.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/board.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chart.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/gauge.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/scorecard.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/gridctrl.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/grid.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/graph.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/simplechart.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/favorites.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/fifrs.js")%>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/jstree.min.js")%>"></script> | ||||
|  | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartTypeWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/selectChartType.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/selectChartSubType.js") %>"></script> | ||||
|  | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/DimWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/ListWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/Grid2DWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/Grid3DWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/RssWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/WebWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/MapViewWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/StockWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/VideoWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/FavoriteWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/AlertWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/Management/alertMessageWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/Graph2DWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/Graph3DWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/ColumnLineWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/PieWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/GaugeWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/ScatterPlotWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/FifrsWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/ScorecardWizard.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/commonOp.js") %>"></script> | ||||
|  | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/selectDTOption.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/chartFilter.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/BaseXYPivotCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/D1YPivotCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/D2XYPivotCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/D3XYPivotCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/PointSetXYPivotCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/xCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/zCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/parameterInitValueOption.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/shapeAndColorSetting.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/yCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/pivotCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/subctrls/webPivotCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/aggregatesCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/targetInputDataCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/chartNoteCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/chartInformationCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/setuprssurlCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/stockSymbolsCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/typeCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/setupFavoriteUrlCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/subscribetoAMessageCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/TargetRelation.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/SortByCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/gaugeInformationCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/drilldownselect.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/drilldownurl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/webSetup.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/drilldownchart.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/drilldownCell.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/frptSelectReportCtrl.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/frptSetPivot.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/freeReportSetCells.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/freeReportSetPivots.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/subctrls/targetMappingHeader.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartWizardOptions/subctrls/cellDialog.js") %>"></script> | ||||
|  | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/Management/boardFilters.js") %>"></script> | ||||
|     <script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/Management/workspaceFilters.js") %>"></script> | ||||
|  | ||||
|     <script> | ||||
|         //必须放在地图js之前 | ||||
|         var dojoConfig = { | ||||
|             async: true,//这个参数一定要设置,必须要设置true; | ||||
|             parseOnLoad: true, | ||||
|             paths: { | ||||
|                 extras1: location.pathname.replace(/\/[^/]+$/, "") + "/js/mapview" | ||||
|             }, | ||||
|             cacheBust: true | ||||
|         }; | ||||
|     </script> | ||||
|     <script src="https://js.arcgis.com/3.40"></script> | ||||
|     <script src="<%=Common.GenerateUrl("fic/js/mapview/asset.js")%>"></script> | ||||
|     <script src="<%=Common.GenerateUrl("fic/js/mapview/maphelper.js")%>"></script> | ||||
|     <script src="<%=Common.GenerateUrl("fic/js/mapview/mapview.js")%>"></script> | ||||
|  | ||||
|     <script type="text/javascript"> | ||||
|         var LinkIcons = new Array(); | ||||
|         var frsInstalled = false; | ||||
|  | ||||
|         _utility.rootPath = "<%=this.ResolveUrl("~/") %>"; | ||||
|         _utility.loginedUser = {}; | ||||
|  | ||||
|         // register the plugin | ||||
|         Vue.use(window['g5-vue-ctrls'].directives); | ||||
|         var chartiid ='<%=_chartIID%>'; | ||||
|         var chartname ='<%=_chartName%>'; | ||||
|  | ||||
|         function openMessage(text) { | ||||
|             _utility.showMessage(text, DEFAULT_LANG.FIC); | ||||
|         } | ||||
|  | ||||
|         // 菜单列表接口 | ||||
|         _utility.getChartMenuList = function (chart, pinclass) { | ||||
|             return [ | ||||
|                 { 'cmd': 'customization', 'class': 'custom', 'text': GetLanguageByKey('LHBIS_FIC_CHARTS_CHARTTITLE_A028', 'Customization') }, | ||||
|                 { 'cmd': 'edit_chart', 'class': 'edit', 'text': GetLanguageByKey('LHBIS_FIC_SILVERLIGHT_WSP_RMENUCTRL_A020', 'Edit Chart') }, | ||||
|                 { 'cmd': 'save_chart_as', 'class': 'save-chart-as', 'text': GetLanguageByKey('LHBIS_FIC_SILVERLIGHT_WSP_RMENUCTRL_A021', 'Save Chart As...') }, | ||||
|                 { 'cmd': 'refresh', 'class': 'refresh seperator', 'text': GetLanguageByKey('LHBIS_FIC_CHARTS_CHARTTITLE_A004', 'Refresh Chart') }, | ||||
|                 { 'cmd': 'auto_refresh', 'class': '', 'text': GetLanguageByKey('LHBIS_FIC_CHARTS_CHARTTITLE_A024', 'Auto Refresh') }, | ||||
|                 { 'cmd': 'fixed_columns', 'class': '', 'text': GetLanguageByKey('FI_FRS_RD066', 'Fixed Columns') }, | ||||
|                 { 'cmd': 'disp-reftime', 'class': '', 'text': GetLanguageByKey('LHBIS_FIC_CHARTS_CHARTTITLE_A005', 'Display Refresh Time'), 'checked': chart.displayRefreshTime }, | ||||
|                 { 'cmd': 'reset_fixed_columns', 'class': '', 'text': GetLanguageByKey('LHBIS_FIC_CHARTS_CHARTTITLE_A027', 'Reset Fixed Columns') }, | ||||
|                 { 'cmd': 'chart-note', 'class': '', 'text': GetLanguageByKey('LHBIS_FIC_CHARTS_CHARTTITLE_A006', 'Chart Notes') }, | ||||
|                 { 'cmd': 'addfilter', 'class': '', 'text': GetLanguageByKey('LHBIS_FIC_CHARTS_CHARTCLIENT_A013', 'Additional Filtering') }, | ||||
|                 { 'cmd': 'set_yzero', 'class': 'seperator', 'text': GetLanguageByKey('LHBIS_FIC_CHARTS_CHARTTITLE_A013', 'Set Y axis to zero') }, | ||||
|                 { 'cmd': 'print_chart', 'class': 'seperator', 'text': GetLanguageByKey('LHBIS_FIC_CHARTS_CHARTTITLE_A021', 'Print') }, | ||||
|                 //{ 'cmd': 'fullscreen', 'class': '', 'text': GetLanguageByKey('FULL_SCREEN', 'Full Screen') }, | ||||
|                 { 'cmd': 'pinborder', 'class': 'seperator ' + pinclass, 'text': GetLanguageByKey('PIN_BORDER', 'Pin Border') }, | ||||
|                 { 'cmd': 'adjust_column_width', 'class': '', 'text': GetLanguageByKey('LHBIS_FIC_CHARTS_CHARTTITLE_A012', 'Adjust column width'), 'checked': chart.chart && chart.chart.Adjustcolumnwidth }, | ||||
|                 { 'cmd': 'grid_reset_defaults', 'class': '', 'text': GetLanguageByKey('LHBIS_FIC_CHARTS_CHARTTITLE_A008', 'Reset Defaults') }, | ||||
|                 { 'cmd': 'export_Excel', 'class': '', 'text': GetLanguageByKey('LHBIS_FIC_CHARTS_CHARTTITLE_A009', 'Export to Excel') }, | ||||
|                 { 'cmd': 'export_Xps', 'class': '', 'text': GetLanguageByKey('LHBIS_FIC_CHARTS_CHARTTITLE_A016', 'Export to XPS') }, | ||||
|                 { 'cmd': 'export_Pdf', 'class': 'seperator', 'text': GetLanguageByKey('EXPORT_TO_PDF', 'Export to PDF') }, | ||||
|                 { 'cmd': 'email_subscription', 'class': '', 'text': GetLanguageByKey('LHBIS_FIC_CLIENT_MODULES_RSUBSCRIBE_A008', 'Email Subscription') } | ||||
|             ]; | ||||
|         }; | ||||
|  | ||||
|         $(function () { | ||||
|             $("#host_main").remove(); | ||||
|             $("#divTitleBorder").remove(); | ||||
|             new Promise(getThemes) | ||||
|                 .then(GetUserParamter) | ||||
|                 .then(window.onUserInited || function () { }); | ||||
|  | ||||
|             initLanguage(); | ||||
|  | ||||
|             getChartColorSchemes().catch(catchError); | ||||
|         }); | ||||
|  | ||||
|         function catchError(err) { | ||||
|             _utility.showMessage(err, DEFAULT_LANG.FIC, null, function () { | ||||
|                 window.location = '../Logout.ashx'; | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function init() { | ||||
|             // chart comments | ||||
|             var iframe = $('<iframe id="chart_comments_container" style="display:none;margin-right:-420px"></iframe>'); | ||||
|             var email_iframe = $('<iframe id="email_subscription_container" style="display:none;margin-right:-900px"></iframe>'); | ||||
|             var bg = $('<div id="chart_comments_bg" class="maskbg" style="display:none"></div>').click(function () { | ||||
|                 iframe.stop().animate({ 'margin-right': -420 }, ANIMATE_FAST_SPEED, function () { | ||||
|                     iframe.hide(); | ||||
|                     bg.hide(); | ||||
|                 }); | ||||
|                 email_iframe.stop().animate({ 'margin-right': -900 }, ANIMATE_FAST_SPEED, function () { | ||||
|                     iframe.hide(); | ||||
|                     bg.hide(); | ||||
|                 }); | ||||
|             }); | ||||
|             $(document.body).append(bg, iframe); | ||||
|             $(document.body).append(bg, email_iframe); | ||||
|         } | ||||
|  | ||||
|         var commentOpenCount = 0; | ||||
|         function onCommentsOpened() { | ||||
|             commentOpenCount++; | ||||
|             if (commentOpenCount < 2) { | ||||
|                 return; | ||||
|             } | ||||
|             var container = $('#chart_comments_container')[0]; | ||||
|             //container.contentWindow.user = _utility.loginedUser; | ||||
|             container.contentWindow.showMessage(_utility.loginedUser, _utility.currentLang, sitePath); | ||||
|         } | ||||
|  | ||||
|         var favicon; | ||||
|         var isFavorite = false; | ||||
|         function onUserInited() { | ||||
|             init(); | ||||
|             openChartByIID(); | ||||
|             setFavoriteDisplay(false, chartiid, chartname, 10); | ||||
|  | ||||
|             //GetDefaultWSP().then(init).catch(catchError); | ||||
|         } | ||||
|  | ||||
|         function initChartIcons() { | ||||
|             $(".chart_restore").hide(); | ||||
|             $(".chart_close").show().click(function (e) { | ||||
|                 if (typeof window.parent.hideChartContainer === "function") | ||||
|                     window.parent.hideChartContainer(); | ||||
|             }); | ||||
|             favicon = $('<i class="chart_favorite fa" style="display: none"></i>'); | ||||
|             favicon.click(function () { | ||||
|                 isFavorite = !isFavorite; | ||||
|                 if (typeof window.parent.setChartFavorite === "function") | ||||
|                     window.parent.setChartFavorite(isFavorite, navigate); | ||||
|                 showChartFavorite(isFavorite); | ||||
|                 refreshFavorites(); | ||||
|             }) | ||||
|             $(".chart_comments").after(favicon); | ||||
|         } | ||||
|  | ||||
|         function showChartFavorite(f) { | ||||
|             if (!favicon) | ||||
|                 return; | ||||
|             isFavorite = f; | ||||
|             if (isFavorite) | ||||
|                 favicon.removeClass("chart_unfavorite").addClass("chart_favorite"); | ||||
|             else | ||||
|                 favicon.removeClass("chart_favorite").addClass("chart_unfavorite"); | ||||
|             favicon.show(); | ||||
|         } | ||||
|  | ||||
|         function openChartByIID() { | ||||
|             if (!chartiid || chartiid == "") | ||||
|                 return; | ||||
|             var chart = new $chart(); | ||||
|             chart.wnd = window; | ||||
|             chart.parentDom = window.document; | ||||
|             var obj = { | ||||
|                 ID: chartiid | ||||
|             }; | ||||
|             chart.load(obj); | ||||
|             setTimeout(function () { | ||||
|                 chart.toggleFullscreen(); | ||||
|                 initChartIcons(); | ||||
|                 showChartFavorite(isUserFavorate(chartiid)); | ||||
|             }) | ||||
|         } | ||||
|  | ||||
|         function changeChart(iid, name) { | ||||
|             chartiid = iid; | ||||
|             chartname = name; | ||||
|             openChartByIID(); | ||||
|             setFavoriteDisplay(false, chartiid, chartname, 10); | ||||
|         } | ||||
|  | ||||
|         function ShowLoadingMask() { | ||||
|         } | ||||
|  | ||||
|         function HiddenLoadingMask() { | ||||
|         } | ||||
|     </script> | ||||
| </asp:Content> | ||||
| <asp:Content ID="Content2" ContentPlaceHolderID="holder_content" runat="Server"> | ||||
|     <div id="chart_content"></div> | ||||
| </asp:Content> | ||||
|  | ||||
							
								
								
									
										45
									
								
								Site/Chart.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								Site/Chart.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,45 @@ | ||||
| using FI.FIC; | ||||
| 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 FIC : WorkspaceBasePage | ||||
| { | ||||
|     protected string _sessionID; | ||||
|     protected string _userID; | ||||
|     protected string _userIID; | ||||
|  | ||||
|     protected string _chartIID; | ||||
|     protected string _chartName; | ||||
|  | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     { | ||||
|         if (CheckLoginSession()) | ||||
|         { | ||||
|             // nothing but just check | ||||
|             if (FICHostEnvironment.FICHost == null) | ||||
|             { | ||||
|                 // init ironintel host | ||||
|                 IronIntelHost.Init(); | ||||
|             } | ||||
|  | ||||
|             var session = GetCurrentLoginSession(); | ||||
|             _sessionID = session.SessionID; | ||||
|             if (session.User != null) | ||||
|             { | ||||
|                 _userID = session.User.ID; | ||||
|                 _userIID = session.User.UID; | ||||
|             } | ||||
|  | ||||
|             _chartIID = Request.QueryString["iid"]; | ||||
|             _chartName = Request.QueryString["n"]; | ||||
|  | ||||
|             this.Title = PageTitle; | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										1270
									
								
								Site/Contact/ManageContact.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1270
									
								
								Site/Contact/ManageContact.aspx
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										27
									
								
								Site/Contact/ManageContact.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								Site/Contact/ManageContact.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| using IronIntel.Contractor.Site.Contact; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Web; | ||||
| using System.Web.UI; | ||||
| using System.Web.UI.WebControls; | ||||
|  | ||||
| public partial class ManageContact : ContactBasePage | ||||
| { | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     { | ||||
|         string methodName = Request.Form["MethodName"]; | ||||
|         if (!string.IsNullOrEmpty(methodName)) | ||||
|         { | ||||
|             ProcessRequest(methodName); | ||||
|         } | ||||
|         else if (!IsPostBack) | ||||
|         { | ||||
|             Title = PageTitle; | ||||
|             if (CheckLoginSession()) | ||||
|             { | ||||
|                 //TODO | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										108
									
								
								Site/Credentials/Credentials.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										108
									
								
								Site/Credentials/Credentials.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,108 @@ | ||||
| <%@ Page Title="" Language="C#" MasterPageFile="~/IronIntelMasterPage.master" AutoEventWireup="true" CodeFile="Credentials.aspx.cs" Inherits="Credentials_Credentials" %> | ||||
|  | ||||
| <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">  | ||||
|         var ConnectionsURL = "<%=ConnectionsURL%>"; | ||||
|         var isJDLink = <%=IsJDLink?"true":"false"%>; | ||||
|         var isJDSub = <%=IsJDSub?"true":"false"%>; | ||||
|         var isMyJD = <%=IsMyJD?"true":"false"%>; | ||||
|  | ||||
|         $(function () { | ||||
|             setFavoriteDisplay(true); | ||||
|  | ||||
|             _network.query = function (method, param, callback, error) { | ||||
|                 _network.request("Credentials/Credentials.aspx", -1, method, param, callback, error); | ||||
|             } | ||||
|             _network.query('GetNavs', '', function (data) { | ||||
|                 if (data != null && data.length > 0) { | ||||
|                     var list = []; | ||||
|                     for (var i = 0; i < data.length; i++) { | ||||
|                         var icon = $('<button></button>'); | ||||
|                         var title = getNavInfoByID(data[i].ID, data[i].Title, icon); | ||||
|                         var li = $('<li class="nav_item"></li>').attr({ | ||||
|                             'id': data[i].ID, | ||||
|                             'page': data[i].Url, | ||||
|                             'title': title | ||||
|                         }); | ||||
|                         var a = $('<a></a>').attr('href', '#' + data[i].ID); | ||||
|                         var src = data[i].IconPath; | ||||
|                         if (!src) { | ||||
|                             src = 'img/none.png'; | ||||
|                         } | ||||
|                         var divicon = $('<div></div>').append(icon); | ||||
|                         a.append(divicon); | ||||
|                         a.append($('<span></span>').text(title)); | ||||
|                         li.append(a); | ||||
|                         list.push(li); | ||||
|                     } | ||||
|                     $('.ul_menu').append(list); | ||||
|                 } | ||||
|  | ||||
|                 if (data.length > 0) { | ||||
|                     if (isJDLink || isJDSub || isMyJD) | ||||
|                         default_page = '#' + data[1].ID; | ||||
|                     else | ||||
|                         default_page = '#' + data[0].ID; | ||||
|                     if (!old_hash) { | ||||
|                         old_hash = default_page; | ||||
|                     } | ||||
|  | ||||
|                     window.changePage(old_hash); | ||||
|                 } else { | ||||
|                     // 无权限时跳转至登录页面 | ||||
|                     window.location.href = '<%=LoginPageUrl%>'; | ||||
|                 } | ||||
|             }, function (e) { | ||||
|                 console.log(e); | ||||
|             }); | ||||
|  | ||||
|             window.changePage(old_hash); | ||||
|  | ||||
|             if (ConnectionsURL) | ||||
|                 window.open(ConnectionsURL); | ||||
|         }); | ||||
|  | ||||
|         function getNavInfoByID(id, title1, icon) { | ||||
|             var title = title1; | ||||
|             if (id === "nav_credential") { | ||||
|                 title = GetTextByKey("P_CREDENTIALS", title); | ||||
|                 $(icon).addClass("iconcredentail"); | ||||
|             } | ||||
|             else if (id === "nav_jdlink") { | ||||
|                 title = GetTextByKey("P_JOHNDEERE", title); | ||||
|                 $(icon).addClass("iconjdlink"); | ||||
|             } | ||||
|             else if (id === "nav_jdnotification") { | ||||
|                 title = GetTextByKey("P_JOHNDEERENOTIFICATIONS", title); | ||||
|                 $(icon).addClass("iconjdnotification"); | ||||
|             } | ||||
|             else if (id === "nav_apicredential") { | ||||
|                 title = GetTextByKey("P_APICREDENTIALS", title); | ||||
|                 $(icon).addClass("iconcredentail"); | ||||
|             } | ||||
|             return title; | ||||
|         } | ||||
|  | ||||
|         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> | ||||
|         </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> | ||||
|  | ||||
							
								
								
									
										42
									
								
								Site/Credentials/Credentials.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								Site/Credentials/Credentials.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | ||||
| using IronIntel.Contractor; | ||||
| using IronIntel.Contractor.Site; | ||||
| using IronIntel.Contractor.Site.Credentials; | ||||
| using IronIntel.Contractor.Site.Security; | ||||
| 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 Credentials_Credentials : CredentialsBasePage | ||||
| { | ||||
|     protected string ConnectionsURL = ""; | ||||
|     protected bool IsJDLink = false; | ||||
|     protected bool IsJDSub = false; | ||||
|     protected bool IsMyJD = 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; | ||||
|                 IsJDLink = Helper.IsTrue(Request.Params["isjdlink"] ?? ""); | ||||
|                 IsJDSub = Helper.IsTrue(Request.Params["isjdsub"] ?? ""); | ||||
|                 IsMyJD = Helper.IsTrue(Request.Params["ismyjd"] ?? ""); | ||||
|                 ConnectionsURL = Request.Params["connections"]; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										86
									
								
								Site/Credentials/Credentials.master
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								Site/Credentials/Credentials.master
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,86 @@ | ||||
| <%@ Master Language="C#" AutoEventWireup="true" CodeFile="Credentials.master.cs" Inherits="Credentials" %> | ||||
|  | ||||
| <!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 type="text/css" href="<%=GetUrl("js/components/css/gridview.css") %>" rel="stylesheet" /> | ||||
|     <link type="text/css" href="<%=GetUrl("css/override.css") %>" rel="stylesheet" /> | ||||
|     <link rel="stylesheet" href="<%=GetUrl("css/default.css")%>" type="text/css" /> | ||||
|     <link rel="stylesheet" href="<%=GetUrl("css/split_sub.css")%>" type="text/css" /> | ||||
|     <link rel="stylesheet" href="<%=GetUrl("css/editmultiselect.css")%>" type="text/css" /> | ||||
|     <style type="text/css"> | ||||
|         :root { <%=StyleVariables%> } | ||||
|         .data-grid { | ||||
|             height: 100%; | ||||
|             font-size: 12px !important; | ||||
|             font-family: "Segoe UI","Segoe UI Web (West European)","Segoe UI",-apple-system,BlinkMacSystemFont,"Roboto","Helvetica Neue",sans-serif !important; | ||||
|         } | ||||
|     </style> | ||||
|     <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 src="<%=GetUrl("js/editmultiselect.js")%>" type="text/javascript"></script> | ||||
|     <script src="<%=GetUrl("js/language.js")%>" type="text/javascript"></script> | ||||
|     <script type="text/javascript"> | ||||
|  | ||||
|         var GridView = window.GridView || window['g5-gridview']; | ||||
|  | ||||
|         _network.root = '<%=Page.ResolveUrl("~/")%>'; | ||||
|         var sitePath = "<%=this.ResolveUrl("~/fic/") %>"; | ||||
|  | ||||
|         if (typeof _utility !== 'object') { | ||||
|             _utility = {}; | ||||
|         }        | ||||
|  | ||||
|         function getText(s, flag) { | ||||
|             return (s == null) | ||||
|                 ? (flag ? '<i>null</i>' : '') | ||||
|                 : htmlencode(s).replace(/ /g, ' '); | ||||
|         } | ||||
|  | ||||
|         function GetLanguageByCookie() { | ||||
|             var lang = getCookie('<%=Common.LanguageCookieName%>'); | ||||
|             if (lang == null) { | ||||
|                 return "en-us"; | ||||
|             } else { | ||||
|                 return lang; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $(function () { | ||||
|             _fleet.currentLang = GetLanguageByCookie(); | ||||
|             $("#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); | ||||
|                 $('#mask_bg').height($(document).outerHeight(false)).width($(document).outerWidth(false)); | ||||
|             } | ||||
|  | ||||
|             $(window).resize(function () { | ||||
|                 resizeContent(); | ||||
|             }); | ||||
|             resizeContent(); | ||||
|         }); | ||||
|     </script> | ||||
|     <asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder> | ||||
| </head> | ||||
| <body> | ||||
|     <div id="content1"> | ||||
|         <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> | ||||
|         </asp:ContentPlaceHolder> | ||||
|     </div> | ||||
| </body> | ||||
| </html> | ||||
							
								
								
									
										29
									
								
								Site/Credentials/Credentials.master.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								Site/Credentials/Credentials.master.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | ||||
| 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 Credentials : CommonBase | ||||
| { | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     { | ||||
|         if (!IsPostBack) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 GetUIStyle(); | ||||
|             } | ||||
|             catch | ||||
|             { | ||||
|                 // TODO: errors when get the ui style. | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										466
									
								
								Site/Credentials/ManageAPICredential.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										466
									
								
								Site/Credentials/ManageAPICredential.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,466 @@ | ||||
| <%@ Page Title="" Language="C#" MasterPageFile="~/Credentials/Credentials.master" AutoEventWireup="true" CodeFile="ManageAPICredential.aspx.cs" Inherits="ManageAPICredential" %> | ||||
|  | ||||
| <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"> | ||||
|     <style type="text/css"> | ||||
|         .dialog .dialog-title .dialog-close { | ||||
|             float: right; | ||||
|             margin-right: 6px; | ||||
|             cursor: pointer; | ||||
|         } | ||||
|  | ||||
|             .dialog .dialog-title .dialog-close:before { | ||||
|                 content: '\e600'; | ||||
|             } | ||||
|  | ||||
|         .dialog-content table { | ||||
|             border-collapse: collapse; | ||||
|             width: 100%; | ||||
|         } | ||||
|  | ||||
|             .dialog-content table td { | ||||
|                 padding-top: 30px; | ||||
|             } | ||||
|  | ||||
|                 .dialog-content table td.label { | ||||
|                     width: 130px; | ||||
|                     text-align: right; | ||||
|                     padding-right: 10px; | ||||
|                     line-height: 24px; | ||||
|                     height: 24px; | ||||
|                     vertical-align: top; | ||||
|                 } | ||||
|  | ||||
|                 .dialog-content table td input, | ||||
|                 .dialog-content table td textarea { | ||||
|                     border: 1px solid #a9a9a9; | ||||
|                     width: 200px; | ||||
|                     height: 18px; | ||||
|                     padding: 1px; | ||||
|                 } | ||||
|  | ||||
|                     .dialog-content table td input[type="checkbox"] { | ||||
|                         border: none; | ||||
|                     } | ||||
|  | ||||
|                 .dialog-content table td textarea { | ||||
|                     height: 100px; | ||||
|                     max-width: 200px; | ||||
|                 } | ||||
|  | ||||
|         .icon { | ||||
|             font-family: CalciteWebCoreIcons; | ||||
|             cursor: default; | ||||
|         } | ||||
|     </style> | ||||
|  | ||||
|     <script type="text/javascript"> | ||||
|         var credentialType = "AEMP"; | ||||
|         var credentialList; | ||||
|  | ||||
|         credentialquery = function (method, param, callback, error, nolog) { | ||||
|             _network.request("Credentials/ManageAPICredential.aspx?tp=ashx", -1, method, param, callback, error, nolog); | ||||
|         } | ||||
|  | ||||
|         function OnDelete(cr) { | ||||
|             var cre = cr; | ||||
|             if (!cre) { | ||||
|                 return; | ||||
|             } | ||||
|             showConfirm(GetTextByKey("P_APICRE_DELETETHECREDENTIALTIPS", 'Do you want to delete the credential?'), GetTextByKey("P_APICRE_DELETECREDENTIAL", 'Delete Credential'), function () { | ||||
|                 credentialquery("DeleteApiCredential", cre.ID, function (data) { | ||||
|                     OnRefresh(); | ||||
|                 }, function (err) { | ||||
|                     showAlert(GetTextByKey("P_APICRE_FAILEDDELETECREDENTIAL", 'Failed to delete this credential.'), GetTextByKey("P_APICRE_DELETECREDENTIAL", 'Delete Credential')); | ||||
|                 }); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function OnAdd() { | ||||
|             $('.tr_aicredential').hide(); | ||||
|             $('#tr_enabled').hide(); | ||||
|             creid = undefined; | ||||
|             $('#dialog_apiname').val('').removeAttr("disabled"); | ||||
|             $('#dialog_username').val(''); | ||||
|             $('#dialog_password').val(''); | ||||
|             $('#dialog_apikey').val(''); | ||||
|             $('#dialog_apisecret').val(''); | ||||
|             $('#dialog_apitoken').val(''); | ||||
|             $('#dialog_apitokensecret').val(''); | ||||
|             $('#dialog_enabled').attr('checked', false); | ||||
|             $('#dialog_credential .dialog-title span.title').text(GetTextByKey("P_APICRE_ADDMANUFACTURE", 'Add Credential')); | ||||
|             $('#mask_bg').show(); | ||||
|             $('#dialog_credential') | ||||
|                 .attr('act', 'add') | ||||
|                 .css({ | ||||
|                     'top': (document.documentElement.clientHeight - $('#dialog_credential').height()) / 3, | ||||
|                     'left': (document.documentElement.clientWidth - $('#dialog_credential').width()) / 2 | ||||
|                 }) | ||||
|                 .showDialogfixed(); | ||||
|             $('#dialog_urlkey').focus(); | ||||
|         } | ||||
|  | ||||
|         var creid; | ||||
|         function OnEdit() { | ||||
|             var cre = grid_dt.source[grid_dt.selectedIndex].Values; | ||||
|             if (!cre) { | ||||
|                 creid = undefined; | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
|             $('#tr_enabled').show(); | ||||
|             creid = cre.ID; | ||||
|             $('#dialog_apiname').val(cre.ApiDefinitionId).attr("disabled", "disabled"); | ||||
|             if (cre.HasUserName) { | ||||
|                 $('#tr_username').show(); | ||||
|                 $('#dialog_username').val(cre.UserName); | ||||
|             } | ||||
|             else { | ||||
|                 $('#tr_username').hide(); | ||||
|                 $('#dialog_username').val(''); | ||||
|             } | ||||
|  | ||||
|             if (cre.HasPassword) { | ||||
|                 $('#tr_password').show(); | ||||
|                 $('#dialog_password').val(cre.Password); | ||||
|             } | ||||
|             else { | ||||
|                 $('#tr_password').hide(); | ||||
|                 $('#dialog_password').val(''); | ||||
|             } | ||||
|  | ||||
|             if (cre.HasApiKey) { | ||||
|                 $('#tr_apikey').show(); | ||||
|                 $('#dialog_apikey').val(cre.ApiKey); | ||||
|             } | ||||
|             else { | ||||
|                 $('#tr_apikey').hide(); | ||||
|                 $('#dialog_apikey').val(''); | ||||
|             } | ||||
|  | ||||
|             if (cre.HasApiSecret) { | ||||
|                 $('#tr_apisecret').show(); | ||||
|                 $('#dialog_apisecret').val(cre.ApiSecret); | ||||
|             } | ||||
|             else { | ||||
|                 $('#tr_apisecret').hide(); | ||||
|                 $('#dialog_apisecret').val(''); | ||||
|             } | ||||
|  | ||||
|             if (cre.HasApiToken) { | ||||
|                 $('#tr_apitoken').show(); | ||||
|                 $('#dialog_apitoken').val(cre.ApiToken); | ||||
|             } | ||||
|             else { | ||||
|                 $('#tr_apitoken').hide(); | ||||
|                 $('#dialog_apitoken').val(''); | ||||
|             } | ||||
|  | ||||
|             if (cre.HasApiTokenSecret) { | ||||
|                 $('#tr_apitokensecret').show(); | ||||
|                 $('#dialog_apitokensecret').val(cre.ApiTokenSecret); | ||||
|             } | ||||
|             else { | ||||
|                 $('#tr_apitokensecret').hide(); | ||||
|                 $('#dialog_apitokensecret').val(''); | ||||
|             } | ||||
|  | ||||
|             $('#dialog_enabled').attr("checked", cre.IsEnabled); | ||||
|             $('#dialog_credential .dialog-title span.title').text(GetTextByKey("P_APICRE_EDITMANUFACTURE", 'Edit Credential')); | ||||
|             $('#mask_bg').show(); | ||||
|             $('#dialog_credential') | ||||
|                 .attr('act', 'edit') | ||||
|                 .css({ | ||||
|                     'top': (document.documentElement.clientHeight - $('#dialog_credential').height()) / 3, | ||||
|                     'left': (document.documentElement.clientWidth - $('#dialog_credential').width()) / 2 | ||||
|                 }) | ||||
|                 .showDialog(); | ||||
|             $('#dialog_urlkey').focus(); | ||||
|         } | ||||
|  | ||||
|         function OnDblClick(e) { | ||||
|             OnEdit(); | ||||
|         } | ||||
|  | ||||
|         function OnRefresh() { | ||||
|             showloading(true); | ||||
|             credentialquery("GetAPICredentialDefs", '', function (data) { | ||||
|                 showloading(false); | ||||
|                 credentialList = data; | ||||
|                 showCredentialList(credentialList); | ||||
|             }, function (err) { | ||||
|                 showloading(false); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         function getAPIDictionaries() { | ||||
|             credentialquery("GetAPIDictionaries", '', function (data) { | ||||
|                 var types = []; | ||||
|                 types.push($('<option value="-1"></option>')); | ||||
|                 if (data && data.length > 0) { | ||||
|                     for (var i = 0; i < data.length; i++) { | ||||
|                         var type = data[i]; | ||||
|                         types.push($('<option></option>').prop('selected', i == 0).val(type.Id).text(type.FriendlyName).data('dic', type)); | ||||
|                     } | ||||
|                 } else { | ||||
|                     types[0].prop('selected', true); | ||||
|                 } | ||||
|  | ||||
|                 $('#dialog_apiname').empty().append(types); | ||||
|             }, function (err) { | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         function showCredentialList(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('#credentiallist'); | ||||
|             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: 'ApiName', caption: GetTextByKey("P_APICRE_APINAME", "API Name"), valueIndex: 'ApiName', css: { 'width': 200, 'text-align': 'left' } }, | ||||
|                 { name: 'UserName', caption: GetTextByKey("P_APICRE_USERNAME", "User Name"), valueIndex: 'UserName', css: { 'width': 200, 'text-align': 'left' } }, | ||||
|                 { name: 'IsEnabled', caption: GetTextByKey("P_APICRE_ENABLED", "Enabled"), valueIndex: 'IsEnabled', 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_APICRE_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_APICRE_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) { | ||||
|                     creid = rowdata.Values.ID; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function OnDialogOK() { | ||||
|             var item = { | ||||
|                 'ApiDefinitionId': $('#dialog_apiname').val(), | ||||
|                 'ApiName': $("#dialog_apiname").find("option:selected").text(), | ||||
|                 'UserName': $('#dialog_username').val().replace(/(^\s*)|(\s*$)/g, ''), | ||||
|                 'Password': $('#dialog_password').val(), | ||||
|                 'ApiKey': $('#dialog_apikey').val().replace(/(^\s*)|(\s*$)/g, ''), | ||||
|                 'ApiSecret': $('#dialog_apisecret').val().replace(/(^\s*)|(\s*$)/g, ''), | ||||
|                 'ApiToken': $('#dialog_apitoken').val().replace(/(^\s*)|(\s*$)/g, ''), | ||||
|                 'ApiTokenSecret': $('#dialog_apitokensecret').val().replace(/(^\s*)|(\s*$)/g, ''), | ||||
|                 'IsEnabled': $('#dialog_enabled').attr("checked") == "checked" | ||||
|             }; | ||||
|             var alerttitle; | ||||
|             if (creid) { | ||||
|                 item.ID = creid; | ||||
|                 alerttitle = GetTextByKey("P_APICRE_EDITMANUFACTURE", "Edit Credential"); | ||||
|             } else { | ||||
|                 item.ID = "-1"; | ||||
|                 item.IsEnabled = true; | ||||
|                 alerttitle = GetTextByKey("P_APICRE_ADDMANUFACTURE", "Add Credential"); | ||||
|             } | ||||
|             if (!item.ApiName || item.ApiName.length == 0) { | ||||
|                 showAlert(GetTextByKey("P_APICRE_APINAMENOTBEEMPTY", 'API Name cannot be empty.'), alerttitle); | ||||
|                 $('#dialog_apiname').focus(); | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
|             showloading(true); | ||||
|             var param = JSON.stringify(item); | ||||
|             param = htmlencode(param); | ||||
|             credentialquery("UpdateApiCredentialDefs", param, function (data) { | ||||
|                 showloading(false); | ||||
|                 if (data !== 'OK') { | ||||
|                     showAlert(data, GetTextByKey("P_APICRE_SAVEMANUFACTURE", 'Save Credential')); | ||||
|                 } else { | ||||
|                     $('#dialog_credential').hideDialog(); | ||||
|                     OnRefresh(); | ||||
|                 } | ||||
|             }, function (err) { | ||||
|                 showloading(false); | ||||
|                 showAlert(GetTextByKey("P_APICRE_FAILEDTOSAVECREDENTIAL", 'Failed to save credential.'), GetTextByKey("P_APICRE_SAVEMANUFACTURE", 'Save Credential')); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function setInput(dic) { | ||||
|             $('#tr_username').hide(); | ||||
|             $('#tr_password').hide(); | ||||
|             $('#tr_apikey').hide(); | ||||
|             $('#tr_apitoken').hide(); | ||||
|             $('#tr_apisecret').hide(); | ||||
|             $('#tr_apitokensecret').hide(); | ||||
|             $('#dialog_username').val(''); | ||||
|             $('#dialog_password').val(''); | ||||
|             $('#dialog_apikey').val(''); | ||||
|             $('#dialog_apisecret').val(''); | ||||
|             $('#dialog_apitoken').val(''); | ||||
|             $('#dialog_apitokensecret').val(''); | ||||
|             if (dic) { | ||||
|                 if (dic.ApiUsername) { | ||||
|                     $('#tr_username').show(); | ||||
|                 } | ||||
|                 if (dic.ApiPassword) { | ||||
|                     $('#tr_password').show(); | ||||
|                 } | ||||
|                 if (dic.ApiKey) { | ||||
|                     $('#tr_apikey').show(); | ||||
|                 } | ||||
|                 if (dic.ApiSecret) { | ||||
|                     $('#tr_apisecret').show(); | ||||
|                 } | ||||
|                 if (dic.ApiToken) { | ||||
|                     $('#tr_apitoken').show(); | ||||
|                 } | ||||
|                 if (dic.ApiTokenSecret) { | ||||
|                     $('#tr_apitokensecret').show(); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $(function () { | ||||
|             setPageTitle(GetTextByKey("P_APICREDENTIALS", 'API Credentials'), true); | ||||
|             InitGridData(); | ||||
|             getAPIDictionaries(); | ||||
|  | ||||
|             $("#dialog_apiname").change(function () { | ||||
|                 var dic = $("#dialog_apiname").find("option:selected").data("dic"); | ||||
|                 setInput(dic); | ||||
|             }) | ||||
|             $('#dialog_credential').dialog(function () { | ||||
|                 $('#mask_bg').hide(); | ||||
|             }); | ||||
|             OnRefresh(); | ||||
|             $(window).resize(function () { | ||||
|                 $("#credentiallist").css("height", $(window).height() - $("#credentiallist").offset().top - 4); | ||||
|                 grid_dt && grid_dt.resize(); | ||||
|             }).resize(); | ||||
|         }); | ||||
|  | ||||
|     </script> | ||||
| </asp:Content> | ||||
|  | ||||
| <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> | ||||
|     <div style="min-width: 400px;"> | ||||
|         <div class="page_title" data-lgid="P_APICREDENTIALS">API Credentials</div> | ||||
|         <div class="function_title"> | ||||
|             <span class="sbutton iconadd" onclick="OnAdd();" data-lgid="P_APICRE_ADD">Add</span> | ||||
|             <span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_APICRE_REFRESH">Refresh</span> | ||||
|         </div> | ||||
|         <div class="clear"></div> | ||||
|         <div id="credentiallist"></div> | ||||
|     </div> | ||||
|  | ||||
|     <div id="mask_bg"> | ||||
|         <div class="loading c-spin"></div> | ||||
|     </div> | ||||
|     <div class="dialog" id="dialog_credential" style="display: none; width: 500px;"> | ||||
|         <div class="dialog-title"><span class="title" data-lgid="P_APICRE_ADDMANUFACTURE">Add Credential</span><em class="dialog-close"></em></div> | ||||
|         <div class="dialog-content" style="padding-left: 50px;"> | ||||
|             <table> | ||||
|                 <tr> | ||||
|                     <td class="label" data-lgid="P_APICRE_APINAME_COLON">API Name:</td> | ||||
|                     <td> | ||||
|                         <select id="dialog_apiname" tabindex="1" style="width: 200px;"> | ||||
|                         </select></td> | ||||
|                 </tr> | ||||
|                 <tr id="tr_username" class="tr_aicredential" style="display: none;"> | ||||
|                     <td class="label" data-lgid="P_APICRE_USERNAME_COLON">User Name:</td> | ||||
|                     <td> | ||||
|                         <input type="text" id="dialog_username" maxlength="50" tabindex="1" /></td> | ||||
|                 </tr> | ||||
|                 <tr id="tr_password" class="tr_aicredential" style="display: none;"> | ||||
|                     <td class="label" data-lgid="P_APICRE_PASSWORD_COLON">Password:</td> | ||||
|                     <td> | ||||
|                         <input type="password" id="dialog_password" maxlength="50" tabindex="1" /></td> | ||||
|                 </tr> | ||||
|                 <tr id="tr_apikey" class="tr_aicredential" style="display: none;"> | ||||
|                     <td class="label" data-lgid="P_APICRE_APIKEY_COLON">API Key:</td> | ||||
|                     <td> | ||||
|                         <input type="text" id="dialog_apikey" maxlength="200" tabindex="1" /></td> | ||||
|                 </tr> | ||||
|                 <tr id="tr_apisecret" class="tr_aicredential" style="display: none;"> | ||||
|                     <td class="label" data-lgid="P_APICRE_APISECRET_COLON">API Secret:</td> | ||||
|                     <td> | ||||
|                         <input type="text" id="dialog_apisecret" maxlength="200" tabindex="1" /></td> | ||||
|                 </tr> | ||||
|                 <tr id="tr_apitoken" class="tr_aicredential" style="display: none;"> | ||||
|                     <td class="label" data-lgid="P_APICRE_APITOKEN_COLON">API Token:</td> | ||||
|                     <td> | ||||
|                         <input type="text" id="dialog_apitoken" maxlength="200" tabindex="1" /></td> | ||||
|                 </tr> | ||||
|                 <tr id="tr_apitokensecret" class="tr_aicredential" style="display: none;"> | ||||
|                     <td class="label" data-lgid="P_APICRE_APITOKENSECRET_COLON">API Token Secret:</td> | ||||
|                     <td> | ||||
|                         <input type="text" id="dialog_apitokensecret" maxlength="200" tabindex="1" /></td> | ||||
|                 </tr> | ||||
|                 <tr id="tr_enabled" style="display: none;"> | ||||
|                     <td class="label" data-lgid="P_APICRE_ENABLED_COLON">Enabled:</td> | ||||
|                     <td> | ||||
|                         <input type="checkbox" id="dialog_enabled" style="width: 18px; margin: 0 auto;" tabindex="4" /> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|             </table> | ||||
|         </div> | ||||
|         <div class="dialog-func"> | ||||
|             <input type="button" value="Cancel" data-lgid="P_APICRE_CANCEL" class="dialog-close" tabindex="6" /> | ||||
|             <input type="button" onclick="OnDialogOK();" value="OK" data-lgid="P_APICRE_OK" tabindex="5" /> | ||||
|             <div class="clear"></div> | ||||
|         </div> | ||||
|     </div> | ||||
| </asp:Content> | ||||
|  | ||||
|  | ||||
							
								
								
									
										31
									
								
								Site/Credentials/ManageAPICredential.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								Site/Credentials/ManageAPICredential.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,31 @@ | ||||
| using IronIntel.Contractor.Site; | ||||
| using IronIntel.Contractor.Site.Credentials; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Web; | ||||
| using System.Web.UI; | ||||
| using System.Web.UI.WebControls; | ||||
|  | ||||
| public partial class ManageAPICredential : CredentialEntryBasePage | ||||
| { | ||||
|     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) | ||||
|             { | ||||
|                 Title = PageTitle; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										357
									
								
								Site/Credentials/ManageCredential.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										357
									
								
								Site/Credentials/ManageCredential.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,357 @@ | ||||
| <%@ Page Title="" Language="C#" MasterPageFile="~/Credentials/Credentials.master" AutoEventWireup="true" CodeFile="ManageCredential.aspx.cs" Inherits="ManageCredential" %> | ||||
|  | ||||
| <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"> | ||||
|     <style type="text/css"> | ||||
|         .dialog .dialog-title .dialog-close { | ||||
|             float: right; | ||||
|             margin-right: 6px; | ||||
|             cursor: pointer; | ||||
|         } | ||||
|  | ||||
|             .dialog .dialog-title .dialog-close:before { | ||||
|                 content: '\e600'; | ||||
|             } | ||||
|  | ||||
|         .dialog-content table { | ||||
|             border-collapse: collapse; | ||||
|             width: 100%; | ||||
|         } | ||||
|  | ||||
|             .dialog-content table td.label { | ||||
|                 width: 130px; | ||||
|                 text-align: right; | ||||
|                 padding-right: 10px; | ||||
|                 line-height: 24px; | ||||
|                 height: 24px; | ||||
|                 vertical-align: top; | ||||
|             } | ||||
|  | ||||
|             .dialog-content table td input, | ||||
|             .dialog-content table td input[type="text"], | ||||
|             .dialog-content table td textarea { | ||||
|                 border: 1px solid #a9a9a9; | ||||
|                 width: 320px; | ||||
|                 height: 18px; | ||||
|                 padding: 1px; | ||||
|             } | ||||
|  | ||||
|                 .dialog-content table td input[type="checkbox"] { | ||||
|                     border: none; | ||||
|                     width: unset; | ||||
|                 } | ||||
|  | ||||
|             .dialog-content table td textarea { | ||||
|                 height: 100px; | ||||
|                 max-width: 320px; | ||||
|             } | ||||
|  | ||||
|         .icon { | ||||
|             font-family: CalciteWebCoreIcons; | ||||
|             cursor: default; | ||||
|         } | ||||
|     </style> | ||||
|  | ||||
|     <script type="text/javascript"> | ||||
|         var credentialType = "AEMP"; | ||||
|         var credentialList; | ||||
|  | ||||
|         credentialquery = function (method, param, callback, error, nolog) { | ||||
|             _network.request("Credentials/ManageCredential.aspx?tp=ashx", -1, method, param, callback, error, nolog); | ||||
|         } | ||||
|  | ||||
|         function OnDelete(cr) { | ||||
|             var cre = cr; | ||||
|             if (!cre) { | ||||
|                 return; | ||||
|             } | ||||
|             showConfirm(GetTextByKey("P_CRE_DELETETHECREDENTIALTIPS", 'Do you want to delete the credential?'), GetTextByKey("P_CRE_DELETECREDENTIAL", 'Delete Credential'), function () { | ||||
|                 credentialquery("DeleteAEMPCredential", cre.ID, function (data) { | ||||
|                     OnRefresh(); | ||||
|                 }, function (err) { | ||||
|                     showAlert(GetTextByKey("P_CRE_FAILEDDELETECREDENTIAL", 'Failed to delete this credential.'), GetTextByKey("P_CRE_DELETECREDENTIAL", 'Delete Credential')); | ||||
|                 }); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function OnAdd() { | ||||
|             creid = undefined; | ||||
|             $('#dialog_manufacture').val('JOHNDEERE').removeAttr("disabled"); | ||||
|             $('#dialog_urlkey').val(''); | ||||
|             $('#dialog_username').val(''); | ||||
|             $('#dialog_password').val(''); | ||||
|             $('#dialog_enabled').attr('checked', 'checked'); | ||||
|             $('#dialog_orgid').val(''); | ||||
|             $('#dialog_notes').val(''); | ||||
|             $('#dialog_credential .dialog-title span.title').text(GetTextByKey("P_CRE_ADDMANUFACTURE", 'Add Credential')); | ||||
|             $('#mask_bg').show(); | ||||
|             $('#dialog_credential') | ||||
|                 .attr('act', 'add') | ||||
|                 .css({ | ||||
|                     'top': (document.documentElement.clientHeight - $('#dialog_credential').height()) / 3, | ||||
|                     'left': (document.documentElement.clientWidth - $('#dialog_credential').width()) / 2 | ||||
|                 }) | ||||
|                 .showDialogfixed(); | ||||
|             $('#dialog_urlkey').focus(); | ||||
|         } | ||||
|  | ||||
|         var creid; | ||||
|         function OnEdit() { | ||||
|             var cre = grid_dt.source[grid_dt.selectedIndex].Values; | ||||
|             if (!cre) { | ||||
|                 creid = undefined; | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
|             creid = cre.ID; | ||||
|             $('#dialog_manufacture').val(cre.ManufactureID).attr("disabled", "disabled"); | ||||
|             $('#dialog_urlkey').val(cre.UrlKey); | ||||
|             $('#dialog_username').val(cre.UserName); | ||||
|             $('#dialog_password').val(cre.Password); | ||||
|             $('#dialog_enabled').attr("checked", cre.Enabled); | ||||
|             $('#dialog_orgid').val(cre.OrgnizationID); | ||||
|             $('#dialog_notes').val(cre.Notes); | ||||
|             $('#dialog_credential .dialog-title span.title').text(GetTextByKey("P_CRE_EDITMANUFACTURE", 'Edit Credential')); | ||||
|             $('#mask_bg').show(); | ||||
|             $('#dialog_credential') | ||||
|                 .attr('act', 'edit') | ||||
|                 .css({ | ||||
|                     'top': (document.documentElement.clientHeight - $('#dialog_credential').height()) / 3, | ||||
|                     'left': (document.documentElement.clientWidth - $('#dialog_credential').width()) / 2 | ||||
|                 }) | ||||
|                 .showDialog(); | ||||
|             $('#dialog_urlkey').focus(); | ||||
|         } | ||||
|  | ||||
|         function OnDblClick(e) { | ||||
|             OnEdit(); | ||||
|         } | ||||
|  | ||||
|         function OnRefresh() { | ||||
|             showloading(true); | ||||
|             credentialquery("GetAEMPCredentials", '', function (data) { | ||||
|                 showloading(false); | ||||
|                 credentialList = data; | ||||
|                 showCredentialList(credentialList); | ||||
|             }, function (err) { | ||||
|                 showloading(false); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         function showCredentialList(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('#credentiallist'); | ||||
|             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: 'ManufactureID', caption: GetTextByKey("P_CRE_MANUFACTURE", "Manufacture"), valueIndex: 'ManufactureID', css: { 'width': 200, 'text-align': 'left' } }, | ||||
|                 { name: 'UrlKey', caption: GetTextByKey("P_CRE_URLKEY", "Url Key"), valueIndex: 'UrlKey', css: { 'width': 200, 'text-align': 'left' } }, | ||||
|                 { name: 'UserName', caption: GetTextByKey("P_CRE_USERNAME", "User Name"), valueIndex: 'UserName', css: { 'width': 200, 'text-align': 'left' } }, | ||||
|                 { name: 'Enabled', caption: GetTextByKey("P_CRE_ENABLED", "Enabled"), valueIndex: 'Enabled', css: { 'width': 200, 'text-align': 'left' } }, | ||||
|                 { name: 'Notes', caption: GetTextByKey("P_CRE_NOTES", "Notes"), valueIndex: 'Notes', 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_CRE_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_CRE_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) { | ||||
|                     creid = rowdata.Values.ID; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function OnDialogOK() { | ||||
|             var item = { | ||||
|                 'ManufactureID': $('#dialog_manufacture').val(), | ||||
|                 'UrlKey': $('#dialog_urlkey').val().replace(/(^\s*)|(\s*$)/g, ''), | ||||
|                 'UserName': $('#dialog_username').val().replace(/(^\s*)|(\s*$)/g, ''), | ||||
|                 'Password': $('#dialog_password').val(), | ||||
|                 'Enabled': $('#dialog_enabled').attr("checked") == "checked", | ||||
|                 'OrgnizationID': $('#dialog_orgid').val(), | ||||
|                 'CredentialType': credentialType, | ||||
|                 'Notes': $('#dialog_notes').val() | ||||
|             }; | ||||
|             var alerttitle; | ||||
|             if (creid) { | ||||
|                 item.ID = creid; | ||||
|                 alerttitle = GetTextByKey("P_CRE_EDITMANUFACTURE", "Edit Credential"); | ||||
|             } else { | ||||
|                 item.ID = ""; | ||||
|                 alerttitle = GetTextByKey("P_CRE_ADDMANUFACTURE", "Add Credential"); | ||||
|             } | ||||
|             //if (!item.UrlKey || item.UrlKey.length == 0) { | ||||
|             //    showAlert('Url Key cannot be empty.', alerttitle); | ||||
|             //    $('#dialog_urlkey').focus(); | ||||
|             //    return; | ||||
|             //} | ||||
|             if (!item.UserName || item.UserName.length == 0) { | ||||
|                 showAlert(GetTextByKey("P_CRE_USERNAMENOTBEEMPTY", 'User Name cannot be empty.'), alerttitle); | ||||
|                 $('#dialog_username').focus(); | ||||
|                 return; | ||||
|             } | ||||
|             if (!item.Password || item.Password.length == 0) { | ||||
|                 showAlert(GetTextByKey("P_CRE_PASSWORDNOTBEEMPTY", 'Password cannot be empty.'), alerttitle); | ||||
|                 $('#dialog_username').focus(); | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
|             showloading(true); | ||||
|             var param = JSON.stringify(item); | ||||
|             param = htmlencode(param); | ||||
|             credentialquery("UpdateAEMPCredential", param, function (data) { | ||||
|                 showloading(false); | ||||
|                 if (data !== 'OK') { | ||||
|                     showAlert(data, GetTextByKey("P_CRE_SAVEMANUFACTURE", 'Save Credential')); | ||||
|                 } else { | ||||
|                     $('#dialog_credential').hideDialog(); | ||||
|                     OnRefresh(); | ||||
|                 } | ||||
|             }, function (err) { | ||||
|                 showloading(false); | ||||
|                 showAlert(GetTextByKey("P_CRE_FAILEDTOSAVECREDENTIAL", 'Failed to save credential.'), GetTextByKey("P_CRE_SAVEMANUFACTURE", 'Save Credential')); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         $(function () { | ||||
|             setPageTitle(GetTextByKey("P_CREDENTIALS", 'Credentials'), true); | ||||
|             InitGridData(); | ||||
|  | ||||
|             $('#dialog_credential').dialog(function () { | ||||
|                 $('#mask_bg').hide(); | ||||
|             }); | ||||
|             OnRefresh(); | ||||
|             $(window).resize(function () { | ||||
|                 $("#credentiallist").css("height", $(window).height() - $("#credentiallist").offset().top - 4); | ||||
|                 grid_dt && grid_dt.resize(); | ||||
|             }).resize(); | ||||
|         }); | ||||
|  | ||||
|     </script> | ||||
| </asp:Content> | ||||
|  | ||||
| <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> | ||||
|     <div style="min-width: 400px;"> | ||||
|         <div class="page_title" data-lgid="P_CREDENTIALS">Credentials</div> | ||||
|         <div class="function_title"> | ||||
|             <span class="sbutton iconadd" onclick="OnAdd();" data-lgid="P_CRE_ADD">Add</span> | ||||
|             <span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_CRE_REFRESH">Refresh</span> | ||||
|         </div> | ||||
|         <div class="clear"></div> | ||||
|         <div id="credentiallist"></div> | ||||
|     </div> | ||||
|  | ||||
|     <div id="mask_bg"> | ||||
|         <div class="loading c-spin"></div> | ||||
|     </div> | ||||
|     <div class="dialog" id="dialog_credential" style="display: none; width: 530px;"> | ||||
|         <div class="dialog-title"><span class="title" data-lgid="P_CRE_ADDMANUFACTURE">Add Credential</span><em class="dialog-close"></em></div> | ||||
|         <div class="dialog-content"> | ||||
|             <table style="line-height: 30px;"> | ||||
|                 <tr> | ||||
|                     <td class="label" data-lgid="P_CRE_MANUFACTURE_COLON">Manufacture:</td> | ||||
|                     <td> | ||||
|                         <select id="dialog_manufacture" tabindex="1" style="width: 150px;"> | ||||
|                             <option value="CAT" data-lgid="P_CRE_CAT">CAT</option> | ||||
|                             <option value="JOHNDEERE" data-lgid="P_CRE_JOHNDEERE">JOHN DEERE</option> | ||||
|                             <option value="Link-Belt" data-lgid="P_CRE_LINKBELT">Link-Belt</option> | ||||
|                         </select></td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td class="label" data-lgid="P_CRE_URLKEY_COLON">Url Key:</td> | ||||
|                     <td> | ||||
|                         <input type="text" id="dialog_urlkey" maxlength="200" tabindex="1" /></td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td class="label" data-lgid="P_CRE_USERNAME_COLON">User Name:</td> | ||||
|                     <td> | ||||
|                         <input type="text" id="dialog_username" maxlength="50" tabindex="2" /></td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td class="label" data-lgid="P_CRE_PASSWORD_COLON">Password:</td> | ||||
|                     <td> | ||||
|                         <input type="password" id="dialog_password" maxlength="50" tabindex="3" /></td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td class="label" data-lgid="P_CRE_ENABLED_COLON">Enabled:</td> | ||||
|                     <td> | ||||
|                         <input type="checkbox" id="dialog_enabled" tabindex="4" /> | ||||
|                         <input type="hidden" id="dialog_orgid" /> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td class="label" data-lgid="P_CRE_NOTES_COLON">Notes:</td> | ||||
|                     <td> | ||||
|                         <textarea id="dialog_notes" maxlength="1000" tabindex="4"></textarea> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|             </table> | ||||
|         </div> | ||||
|         <div class="dialog-func"> | ||||
|             <input type="button" value="Cancel" data-lgid="P_CRE_CANCEL" class="dialog-close" tabindex="6" /> | ||||
|             <input type="button" onclick="OnDialogOK();" value="OK" data-lgid="P_CRE_OK" tabindex="5" /> | ||||
|             <div class="clear"></div> | ||||
|         </div> | ||||
|     </div> | ||||
| </asp:Content> | ||||
|  | ||||
|  | ||||
							
								
								
									
										31
									
								
								Site/Credentials/ManageCredential.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								Site/Credentials/ManageCredential.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,31 @@ | ||||
| using IronIntel.Contractor.Site; | ||||
| using IronIntel.Contractor.Site.Credentials; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Web; | ||||
| using System.Web.UI; | ||||
| using System.Web.UI.WebControls; | ||||
|  | ||||
| public partial class ManageCredential : CredentialEntryBasePage | ||||
| { | ||||
|     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) | ||||
|             { | ||||
|                 Title = PageTitle; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										709
									
								
								Site/Credentials/ManageJDLink.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										709
									
								
								Site/Credentials/ManageJDLink.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,709 @@ | ||||
| <%@ Page Title="" Language="C#" MasterPageFile="~/Credentials/Credentials.master" AutoEventWireup="true" CodeFile="ManageJDLink.aspx.cs" Inherits="ManageJDLink" %> | ||||
|  | ||||
| <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"> | ||||
|     <style type="text/css"> | ||||
|         .dialog .dialog-title .dialog-close { | ||||
|             float: right; | ||||
|             margin-right: 6px; | ||||
|             cursor: pointer; | ||||
|         } | ||||
|  | ||||
|             .dialog .dialog-title .dialog-close:before { | ||||
|                 content: '\e600'; | ||||
|             } | ||||
|  | ||||
|         .dialog-content table { | ||||
|             border-collapse: collapse; | ||||
|             width: 100%; | ||||
|         } | ||||
|  | ||||
|             .dialog-content table td { | ||||
|                 padding-top: 30px; | ||||
|             } | ||||
|  | ||||
|                 .dialog-content table td.label { | ||||
|                     width: 130px; | ||||
|                     text-align: right; | ||||
|                     padding-right: 10px; | ||||
|                     line-height: 24px; | ||||
|                     height: 24px; | ||||
|                     vertical-align: top; | ||||
|                 } | ||||
|  | ||||
|                 .dialog-content table td input, | ||||
|                 .dialog-content table td textarea { | ||||
|                     border: 1px solid #a9a9a9; | ||||
|                     width: 200px; | ||||
|                     height: 18px; | ||||
|                     padding: 1px; | ||||
|                 } | ||||
|  | ||||
|                     .dialog-content table td input[type="checkbox"] { | ||||
|                         border: none; | ||||
|                     } | ||||
|  | ||||
|                 .dialog-content table td textarea { | ||||
|                     height: 100px; | ||||
|                     max-width: 200px; | ||||
|                 } | ||||
|  | ||||
|         .icon { | ||||
|             font-family: CalciteWebCoreIcons; | ||||
|             cursor: default; | ||||
|         } | ||||
|     </style> | ||||
|  | ||||
|     <script type="text/javascript"> | ||||
|  | ||||
|         credentialquery = function (method, param, callback, error, nolog) { | ||||
|             _network.request("Credentials/ManageJDLink.aspx?tp=ashx", -1, method, param, callback, error, nolog); | ||||
|         } | ||||
|  | ||||
|         //**************************************Begin JD Link***************************************************// | ||||
|         function OnAdd() { | ||||
|             showloading(true); | ||||
|             credentialquery("CreateJDLinkAuthUrl", "", function (data) { | ||||
|                 showloading(false); | ||||
|                 if (data != "") { | ||||
|                     window.open(data); | ||||
|                 } | ||||
|                 else { | ||||
|                     showAlert(GetTextByKey("P_JDL_FAILEDTOCREATETHISJDLINK", "Failed to create this JD link."), GetTextByKey("P_JDL_CREATEJDLINK", 'Create JD Link')); | ||||
|                 } | ||||
|             }, function (err) { | ||||
|                 showloading(false); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function OnRefresh() { | ||||
|             showloading(true); | ||||
|             credentialquery("GetJDLinkTokenItems", "", function (data) { | ||||
|                 showloading(false); | ||||
|                 if (typeof (data) === "string") { | ||||
|                     showAlert(data, GetTextByKey("P_JDL_ERROR", 'Error')); | ||||
|                     return; | ||||
|                 } | ||||
|                 showCredentialList(data); | ||||
|             }, function (err) { | ||||
|                 showloading(false); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function showCredentialList(data) { | ||||
|             var rows = []; | ||||
|             for (var i = 0; i < data.length; i++) { | ||||
|                 var r = data[i]; | ||||
|                 for (var j in r) { | ||||
|                     if (j === "RequestTime") | ||||
|                         r[j] = { DisplayValue: r["RequestTimeStr"], Value: r[j] }; | ||||
|                 } | ||||
|  | ||||
|                 var fr = { Values: r }; | ||||
|                 rows.push(fr); | ||||
|             } | ||||
|  | ||||
|             grid_dt.setData(rows); | ||||
|         } | ||||
|  | ||||
|         var grid_dt; | ||||
|         function InitGridData() { | ||||
|             grid_dt = new GridView('#jdlinklist'); | ||||
|             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: 'AccountName', caption: GetTextByKey("P_JDL_ACCOUNTNAME", "Account Name"), valueIndex: 'AccountName', css: { 'width': 400, 'text-align': 'left' } }, | ||||
|                 { name: 'RequestTime', caption: GetTextByKey("P_JDL_REQUESTTIME", "Request Time"), valueIndex: 'RequestTime', css: { 'width': 150, 'text-align': 'left' } }, | ||||
|                 { name: 'Organization', caption: "", css: { 'width': 110, 'text-align': 'center' } }, | ||||
|                 { name: 'ManageOrganization', caption: "", css: { 'width': 120, '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 === "Delete") { | ||||
|                     col.isurl = true; | ||||
|                     col.text = "\uf00d"; | ||||
|                     col.events = { | ||||
|                         onclick: function () { | ||||
|                             OnDelete(this); | ||||
|                         } | ||||
|                     }; | ||||
|                     col.classFilter = function (e) { | ||||
|                         return "icon-col"; | ||||
|                     }; | ||||
|                     col.attrs = { 'title': getText("P_JDL_DELETE", 'Delete') }; | ||||
|                 } | ||||
|                 else if (col.name === "Organization") { | ||||
|                     col.isurl = true; | ||||
|                     col.text = GetTextByKey("P_SET_XXX", "My Organizations"); | ||||
|                     col.sortable = false; | ||||
|                     col.events = { | ||||
|                         onclick: function () { | ||||
|                             openMyOrganizationsDialog(this, 0); | ||||
|                         } | ||||
|                     }; | ||||
|                     col.classFilter = function (e) { | ||||
|                         return "icon-col"; | ||||
|                     }; | ||||
|                     col.attrs = { 'title': GetTextByKey("P_SET_XXX", "My Organizations") }; | ||||
|                 } | ||||
|                 else if (col.name === "ManageOrganization") { | ||||
|                     col.isurl = true; | ||||
|                     col.text = GetTextByKey("P_SET_XXX", "Manage Organizations"); | ||||
|                     col.sortable = false; | ||||
|                     col.events = { | ||||
|                         onclick: function () { | ||||
|                             GetJDOrganizationUrl(this); | ||||
|                         } | ||||
|                     }; | ||||
|                     col.classFilter = function (e) { | ||||
|                         return "icon-col"; | ||||
|                     }; | ||||
|                     col.attrs = { 'title': GetTextByKey("P_SET_XXX", "Manage Organizations") }; | ||||
|                 } | ||||
|                 columns.push(col); | ||||
|             } | ||||
|             grid_dt.canMultiSelect = false; | ||||
|             grid_dt.columns = columns; | ||||
|             grid_dt.init(); | ||||
|  | ||||
|             grid_dt.selectedrowchanged = function (rowindex) { | ||||
|                 var rowdata = grid_dt.source[rowindex]; | ||||
|                 if (rowdata) { | ||||
|                     creid = rowdata.Values.ID; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function OnDelete(cr) { | ||||
|             var cre = cr; | ||||
|             if (!cre) { | ||||
|                 return; | ||||
|             } | ||||
|             showConfirm(GetTextByKey("P_JDL_DOYOUWANTTODELETETHEJDLINK", 'Do you want to delete the JD link?'), GetTextByKey("P_JDL_DELETEJDLINK", 'Delete JD Link'), function () { | ||||
|                 credentialquery("DeleteToken", cre.TokenId, function (data) { | ||||
|                     OnRefresh(); | ||||
|                 }, function (err) { | ||||
|  | ||||
|                 }); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         //**************************************End JD Link***************************************************// | ||||
|  | ||||
|  | ||||
|  | ||||
|         //**************************************Begin MyJohnDeere***************************************************// | ||||
|         function OnAddMyJD() { | ||||
|             showloading(true); | ||||
|             credentialquery("CreateMyJDAPIAuthUrl", "", function (data) { | ||||
|                 showloading(false); | ||||
|                 if (data != "") { | ||||
|                     window.open(data); | ||||
|                 } | ||||
|                 else { | ||||
|                     showAlert(GetTextByKey("P_JDL_FAILEDTOCREATETHISMYJOHNDEERE", "Failed to create this MyJohnDeere."), GetTextByKey("P_JDL_CREATEMYJOHNDEERE", 'Create MyJohnDeere')); | ||||
|                 } | ||||
|             }, function (err) { | ||||
|                 showloading(false); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function OnRefreshMyJD() { | ||||
|             showloading(true); | ||||
|             credentialquery("GetMyJDAPITokenItems", "", function (data) { | ||||
|                 showloading(false); | ||||
|                 if (typeof (data) === "string") { | ||||
|                     showAlert(data, GetTextByKey("P_JDL_ERROR", 'Error')); | ||||
|                     return; | ||||
|                 } | ||||
|                 showMyJDList(data); | ||||
|             }, function (err) { | ||||
|                 showloading(false); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function showMyJDList(data) { | ||||
|             var rows = []; | ||||
|             for (var i = 0; i < data.length; i++) { | ||||
|                 var r = data[i]; | ||||
|                 for (var j in r) { | ||||
|                     if (j === "RequestTime") | ||||
|                         r[j] = { DisplayValue: r["RequestTimeStr"], Value: r[j] }; | ||||
|                 } | ||||
|  | ||||
|                 var fr = { Values: r }; | ||||
|                 rows.push(fr); | ||||
|             } | ||||
|  | ||||
|             grid_dtmyjd.setData(rows); | ||||
|         } | ||||
|  | ||||
|         var grid_dtmyjd; | ||||
|         function InitGridMyJDData() { | ||||
|             grid_dtmyjd = new GridView('#myjdlist'); | ||||
|             grid_dtmyjd.lang = { | ||||
|                 all: GetTextByKey("P_GRID_ALL", "(All)"), | ||||
|                 ok: GetTextByKey("P_GRID_OK", "OK"), | ||||
|                 reset: GetTextByKey("P_GRID_RESET", "Reset") | ||||
|             }; | ||||
|             var list_columns = [ | ||||
|                 { name: 'AccountName', caption: GetTextByKey("P_JDL_ACCOUNTNAME", "Account Name"), valueIndex: 'AccountName', css: { 'width': 400, 'text-align': 'left' } }, | ||||
|                 { name: 'RequestTime', caption: GetTextByKey("P_JDL_REQUESTTIME", "Request Time"), valueIndex: 'RequestTime', css: { 'width': 150, 'text-align': 'left' } }, | ||||
|                 { name: 'Organization', caption: "", css: { 'width': 110, 'text-align': 'center' } }, | ||||
|                 { name: 'ManageOrganization', caption: "", css: { 'width': 120, '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 === "Delete") { | ||||
|                     col.isurl = true; | ||||
|                     col.text = "\uf00d"; | ||||
|                     col.events = { | ||||
|                         onclick: function () { | ||||
|                             DeleteMyJDToken(this); | ||||
|                         } | ||||
|                     }; | ||||
|                     col.classFilter = function (e) { | ||||
|                         return "icon-col"; | ||||
|                     }; | ||||
|                     col.attrs = { 'title': getText("P_JDL_DELETE", 'Delete') }; | ||||
|                 } | ||||
|                 else if (col.name === "Organization") { | ||||
|                     col.isurl = true; | ||||
|                     col.text = GetTextByKey("P_SET_XXX", "My Organizations"); | ||||
|                     col.sortable = false; | ||||
|                     col.events = { | ||||
|                         onclick: function () { | ||||
|                             openMyOrganizationsDialog(this, 1); | ||||
|                         } | ||||
|                     }; | ||||
|                     col.classFilter = function (e) { | ||||
|                         return "icon-col"; | ||||
|                     }; | ||||
|                     col.attrs = { 'title': GetTextByKey("P_SET_XXX", "My Organizations") }; | ||||
|                 } | ||||
|                 else if (col.name === "ManageOrganization") { | ||||
|                     col.isurl = true; | ||||
|                     col.text = GetTextByKey("P_SET_XXX", "Manage Organizations"); | ||||
|                     col.sortable = false; | ||||
|                     col.events = { | ||||
|                         onclick: function () { | ||||
|                             GetJDOrganizationUrl(this); | ||||
|                         } | ||||
|                     }; | ||||
|                     col.classFilter = function (e) { | ||||
|                         return "icon-col"; | ||||
|                     }; | ||||
|                     col.attrs = { 'title': GetTextByKey("P_SET_XXX", "Manage Organizations") }; | ||||
|                 } | ||||
|                 columns.push(col); | ||||
|             } | ||||
|             grid_dtmyjd.canMultiSelect = false; | ||||
|             grid_dtmyjd.columns = columns; | ||||
|             grid_dtmyjd.init(); | ||||
|  | ||||
|             grid_dtmyjd.selectedrowchanged = function (rowindex) { | ||||
|                 var rowdata = grid_dtmyjd.source[rowindex]; | ||||
|                 if (rowdata) { | ||||
|                     creid = rowdata.Values.ID; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function DeleteMyJDToken(cr) { | ||||
|             var cre = cr; | ||||
|             if (!cre) { | ||||
|                 return; | ||||
|             } | ||||
|             showConfirm(GetTextByKey("P_JDL_DOYOUWANTTODELETETHEMYJOHNDEERE", 'Do you want to delete the MyJohnDeere?'), GetTextByKey("P_JDL_DELETEMYJOHNDEERE", 'Delete MyJohnDeere'), function () { | ||||
|                 credentialquery("DeleteToken", cre.TokenId, function (data) { | ||||
|                     OnRefreshMyJD(); | ||||
|                 }, function (err) { | ||||
|  | ||||
|                 }); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         //**************************************End MyJohnDeere***************************************************// | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|         //**************************************Begin JD Notifications***************************************************// | ||||
|  | ||||
|         function OnAddNotification() { | ||||
|             $('#dialog_displayname').val(''); | ||||
|             $('#mask_bg').show(); | ||||
|             $('#dialog_credential') | ||||
|                 .attr('act', 'add') | ||||
|                 .css({ | ||||
|                     'top': (document.documentElement.clientHeight - $('#dialog_credential').height()) / 3, | ||||
|                     'left': (document.documentElement.clientWidth - $('#dialog_credential').width()) / 2 | ||||
|                 }) | ||||
|                 .showDialogfixed(); | ||||
|             $('#dialog_displayname').focus(); | ||||
|         } | ||||
|  | ||||
|         function CreateJDSubPubAuthUrl() { | ||||
|             var displayname = $.trim($('#dialog_displayname').val()); | ||||
|             showloading(true); | ||||
|             credentialquery("CreateJDSubPubAuthUrl", displayname, function (data) { | ||||
|                 showloading(false); | ||||
|                 if (data != "") { | ||||
|                     window.open(data); | ||||
|                     $('#dialog_credential').hideDialog(); | ||||
|                     OnRefreshNotification(); | ||||
|                 } | ||||
|                 else { | ||||
|                     showAlert(GetTextByKey("P_JDN_FAILEDTOCREATETHISSUBSCRIPTION", "Failed to create this subscription."), GetTextByKey("P_JDN_CREATEANEWSUBSCRIPTION", 'Create a new subscription')); | ||||
|                 } | ||||
|             }, function (err) { | ||||
|                 $('#dialog_credential').hideDialog(); | ||||
|                 showloading(false); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function OnRefreshNotification() { | ||||
|             showloading(true); | ||||
|             credentialquery("GetNotificationSubscriptions", '', function (data) { | ||||
|                 showloading(false); | ||||
|                 showNotificationList(data); | ||||
|             }, function (err) { | ||||
|                 showloading(false); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function showNotificationList(data) { | ||||
|             var rows = []; | ||||
|             for (var i = 0; i < data.length; i++) { | ||||
|                 var r = data[i]; | ||||
|                 for (var j in r) { | ||||
|                     if (j === "CreateTime") | ||||
|                         r[j] = { DisplayValue: r["CreateTimeStr"], Value: r[j] }; | ||||
|                 } | ||||
|  | ||||
|                 var fr = { Values: r }; | ||||
|                 rows.push(fr); | ||||
|             } | ||||
|  | ||||
|             grid_dtnotification.setData(rows); | ||||
|         } | ||||
|  | ||||
|         var grid_dtnotification; | ||||
|         function InitGridNotificationData() { | ||||
|             grid_dtnotification = new GridView('#jdnotificationlist'); | ||||
|             grid_dtnotification.lang = { | ||||
|                 all: GetTextByKey("P_GRID_ALL", "(All)"), | ||||
|                 ok: GetTextByKey("P_GRID_OK", "OK"), | ||||
|                 reset: GetTextByKey("P_GRID_RESET", "Reset") | ||||
|             }; | ||||
|             var list_columns = [ | ||||
|                 { name: 'DisplayName', caption: GetTextByKey("P_JDN_DISPLAYAME", "Display Name"), valueIndex: 'DisplayName', css: { 'width': 400, 'text-align': 'left' } }, | ||||
|                 { name: 'AccountName', caption: GetTextByKey("P_JDL_USERNAME", "User Name"), valueIndex: 'AccountName', css: { 'width': 400, 'text-align': 'left' } }, | ||||
|                 { name: 'CreateTime', caption: GetTextByKey("P_JDL_SUBSCRIPTIONNDATE", "Subscription Date"), valueIndex: 'CreateTime', css: { 'width': 150, 'text-align': 'left' } }, | ||||
|                 //{ name: 'Organization', caption: "", css: { 'width': 110, '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 === "Delete") { | ||||
|                     col.isurl = true; | ||||
|                     col.text = "\uf00d"; | ||||
|                     col.events = { | ||||
|                         onclick: function () { | ||||
|                             OnDeleteNotification(this); | ||||
|                         } | ||||
|                     }; | ||||
|                     col.classFilter = function (e) { | ||||
|                         return "icon-col"; | ||||
|                     }; | ||||
|                     col.attrs = { 'title': getText("P_JDL_DELETE", 'Delete') }; | ||||
|                 } | ||||
|                 else if (col.name === "Organization") { | ||||
|                     col.isurl = true; | ||||
|                     col.text = GetTextByKey("P_SET_XXX", "My Organizations"); | ||||
|                     col.sortable = false; | ||||
|                     col.events = { | ||||
|                         onclick: function () { | ||||
|                             openMyOrganizationsDialog(this, 2); | ||||
|                         } | ||||
|                     }; | ||||
|                     col.classFilter = function (e) { | ||||
|                         return "icon-col"; | ||||
|                     }; | ||||
|                     col.attrs = { 'title': GetTextByKey("P_SET_XXX", "My Organizations") }; | ||||
|                 } | ||||
|                 columns.push(col); | ||||
|             } | ||||
|             grid_dtnotification.canMultiSelect = false; | ||||
|             grid_dtnotification.columns = columns; | ||||
|             grid_dtnotification.init(); | ||||
|  | ||||
|             grid_dtnotification.selectedrowchanged = function (rowindex) { | ||||
|                 var rowdata = grid_dtnotification.source[rowindex]; | ||||
|                 if (rowdata) { | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function OnDeleteNotification(cr) { | ||||
|             var cre = cr; | ||||
|             if (!cre) { | ||||
|                 return; | ||||
|             } | ||||
|             showConfirm(GetTextByKey("P_JDL_DOYOUWANTTODELETETHESUBSCRIPTION", 'Do you want to delete the subscription?'), GetTextByKey("P_JDL_DELETESUBSCRIPTION", 'Delete Subscription'), function () { | ||||
|                 credentialquery("DeleteNotificationSubscription", cre.Id, function (data) { | ||||
|                     OnRefreshNotification(); | ||||
|                 }, function (err) { }); | ||||
|             }); | ||||
|         } | ||||
|         //**************************************End JD Notifications***************************************************// | ||||
|  | ||||
|  | ||||
|         //**************************************Begin My Organizations***************************************************// | ||||
|  | ||||
|         function openMyOrganizationsDialog(cr, type) {//0:jdlink;1:MyJohnDeere;2:Notification | ||||
|             var cre = cr; | ||||
|             if (!cre) { | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
|             var tokenid = ""; | ||||
|             if (type == 0 || type == 1) | ||||
|                 tokenid = cre.TokenId; | ||||
|             else | ||||
|                 tokenid = cre.Id; | ||||
|  | ||||
|             GetOrganizations(tokenid); | ||||
|  | ||||
|             $('#mask_myorganizationbg').show(); | ||||
|             $('#dialog_myorganization') | ||||
|                 .attr('act', 'add') | ||||
|                 .css({ | ||||
|                     'top': (document.documentElement.clientHeight - $('#dialog_myorganization').height()) / 3, | ||||
|                     'left': (document.documentElement.clientWidth - $('#dialog_myorganization').width()) / 2 | ||||
|                 }) | ||||
|                 .showDialogfixed(); | ||||
|         } | ||||
|  | ||||
|         function GetOrganizations(tokieid) { | ||||
|             showloading(true); | ||||
|             credentialquery("GetOrganizations", tokieid, function (data) { | ||||
|                 showloading(false); | ||||
|                 if (typeof (data) === "string") { | ||||
|                     showAlert(data, GetTextByKey("P_JDL_ERROR", 'Error')); | ||||
|                     return; | ||||
|                 } | ||||
|                 showMyOrgList(data); | ||||
|             }, function (err) { | ||||
|                 showloading(false); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function GetJDOrganizationUrl(cr) { | ||||
|             var cre = cr; | ||||
|             if (!cre) { | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
|             credentialquery("GetJDOrganizationUrl", cre.TokenId, function (data) { | ||||
|                 if (data != "") | ||||
|                     window.open(data); | ||||
|             }, function (err) { | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function showMyOrgList(data) { | ||||
|             var rows = []; | ||||
|             for (var i = 0; i < data.length; i++) { | ||||
|                 var r = data[i]; | ||||
|                 for (var j in r) { | ||||
|                     if (j === "Member") | ||||
|                         r[j] = { DisplayValue: r["Member"] ? "Yes" : "", Value: r[j] }; | ||||
|                 } | ||||
|  | ||||
|                 var fr = { Values: r }; | ||||
|                 rows.push(fr); | ||||
|             } | ||||
|  | ||||
|             grid_dtmyorgs.setData(rows); | ||||
|         } | ||||
|  | ||||
|         var grid_dtmyorgs; | ||||
|         function InitGridMyOrgData() { | ||||
|             grid_dtmyorgs = new GridView('#myorganization_list'); | ||||
|             grid_dtmyorgs.lang = { | ||||
|                 all: GetTextByKey("P_GRID_ALL", "(All)"), | ||||
|                 ok: GetTextByKey("P_GRID_OK", "OK"), | ||||
|                 reset: GetTextByKey("P_GRID_RESET", "Reset") | ||||
|             }; | ||||
|             var list_columns = [ | ||||
|                 { name: 'Id', caption: GetTextByKey("P_JDN_XXX", "Id"), valueIndex: 'Id', css: { 'width': 100, 'text-align': 'left' } }, | ||||
|                 { name: 'Name', caption: GetTextByKey("P_JDL_XXX", "Name"), valueIndex: 'Name', css: { 'width': 300, 'text-align': 'left' } }, | ||||
|                 { name: 'OrgType', caption: GetTextByKey("P_JDL_XXX", "Type"), valueIndex: 'OrgType', css: { 'width': 150, 'text-align': 'left' } }, | ||||
|                 { name: 'Member', caption: GetTextByKey("P_JDL_XXX", "Member"), valueIndex: 'Member', 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; | ||||
|                 columns.push(col); | ||||
|             } | ||||
|             grid_dtmyorgs.canMultiSelect = false; | ||||
|             grid_dtmyorgs.columns = columns; | ||||
|             grid_dtmyorgs.init(); | ||||
|  | ||||
|             grid_dtmyorgs.selectedrowchanged = function (rowindex) { | ||||
|                 var rowdata = grid_dtmyorgs.source[rowindex]; | ||||
|                 if (rowdata) { | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         //**************************************End My Organizations***************************************************// | ||||
|  | ||||
|  | ||||
|         $(function () { | ||||
|             setPageTitle(GetTextByKey("P_JDLINK", 'JD Link'), true); | ||||
|             InitGridData(); | ||||
|             InitGridMyJDData(); | ||||
|             InitGridNotificationData(); | ||||
|             InitGridMyOrgData(); | ||||
|  | ||||
|             OnRefresh(); | ||||
|             OnRefreshMyJD(); | ||||
|             OnRefreshNotification(); | ||||
|  | ||||
|             $('#dialog_credential').dialog(function () { | ||||
|                 $('#mask_bg').hide(); | ||||
|             }); | ||||
|  | ||||
|             $('#dialog_myorganization').dialog(function () { | ||||
|                 $('#mask_myorganizationbg').hide(); | ||||
|             }); | ||||
|  | ||||
|             $(window).resize(function () { | ||||
|                 $("#jdlinklist").css("height", 170); | ||||
|                 grid_dt && grid_dt.resize(); | ||||
|  | ||||
|                 $("#myjdlist").css("height", 170); | ||||
|                 grid_dtmyjd && grid_dtmyjd.resize(); | ||||
|  | ||||
|                 $("#jdnotificationlist").css("height", 170); | ||||
|                 grid_dtnotification && grid_dtnotification.resize(); | ||||
|  | ||||
|                 $("#myorganization_list").css("height", 300); | ||||
|                 grid_dtmyorgs && grid_dtmyorgs.resize(); | ||||
|             }).resize(); | ||||
|         }); | ||||
|  | ||||
|     </script> | ||||
| </asp:Content> | ||||
|  | ||||
| <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> | ||||
|     <div style="min-width: 400px;"> | ||||
|         <div class="page_title" data-lgid="P_JDLINK"> | ||||
|             JD Link  | ||||
|         </div> | ||||
|         <div class="function_title"> | ||||
|             <span class="sbutton iconadd" onclick="OnAdd();" data-lgid="P_JDL_ADD">Add</span> | ||||
|             <span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_JDL_REFRESH">Refresh</span> | ||||
|         </div> | ||||
|         <div class="clear"></div> | ||||
|         <div id="jdlinklist"></div> | ||||
|     </div> | ||||
|  | ||||
|     <div style="min-width: 400px; margin-top: 10px;"> | ||||
|         <div class="page_title" data-lgid="P_JDL_MYJOHNDEERE">MyJohnDeere</div> | ||||
|         <div class="function_title"> | ||||
|             <span class="sbutton iconadd" onclick="OnAddMyJD();" data-lgid="P_JDL_ADD">Add</span> | ||||
|             <span class="sbutton iconrefresh" onclick="OnRefreshMyJD();" data-lgid="P_JDL_REFRESH">Refresh</span> | ||||
|         </div> | ||||
|         <div class="clear"></div> | ||||
|         <div id="myjdlist"></div> | ||||
|     </div> | ||||
|  | ||||
|     <div style="min-width: 400px; margin-top: 10px;"> | ||||
|         <div class="page_title" data-lgid="P_JDL_NOTIFICATIONSUBSCRIPTION">Notification Subscription</div> | ||||
|         <div class="function_title"> | ||||
|             <span class="sbutton iconadd" onclick="OnAddNotification();" data-lgid="P_JDL_ADD">Add</span> | ||||
|             <span class="sbutton iconrefresh" onclick="OnRefreshNotification();" data-lgid="P_JDL_REFRESH">Refresh</span> | ||||
|         </div> | ||||
|         <div class="clear"></div> | ||||
|         <div id="jdnotificationlist"></div> | ||||
|     </div> | ||||
|  | ||||
|     <div id="mask_bg"> | ||||
|         <div class="loading c-spin"></div> | ||||
|     </div> | ||||
|     <div class="dialog" id="dialog_credential" style="display: none; width: 600px;"> | ||||
|         <div class="dialog-title"><span class="title" data-lgid="P_JDN_CREATEANEWSUBSCRIPTION">Create a new subscription</span><em class="dialog-close"></em></div> | ||||
|         <div class="dialog-content"> | ||||
|             <table> | ||||
|                 <tr> | ||||
|                     <td class="label" data-lgid="P_JDN_DISPLAYAME_COLON">Display Name:</td> | ||||
|                     <td> | ||||
|                         <input id="dialog_displayname" maxlength="50" tabindex="2" style="width: 400px;" /></td> | ||||
|                 </tr> | ||||
|             </table> | ||||
|         </div> | ||||
|         <div class="dialog-func" style="margin-top: 16px;"> | ||||
|             <input type="button" value="Cancel" data-lgid="P_JDN_CANCEL" class="dialog-close" tabindex="5" /> | ||||
|             <input type="button" style="width: unset;" onclick="CreateJDSubPubAuthUrl(); return false;" value="Create" data-lgid="P_JDN_CREATE" tabindex="3" /> | ||||
|             <div class="clear"></div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
|     <div id="mask_myorganizationbg" class="maskbg" style="display: none;"> | ||||
|         <div class="loading c-spin"></div> | ||||
|     </div> | ||||
|     <div class="dialog" id="dialog_myorganization" style="display: none; width: 800px;"> | ||||
|         <div class="dialog-title"><span class="title" data-lgid="P_JDN_XXX">My Organizations</span><em class="dialog-close"></em></div> | ||||
|         <div class="dialog-content"> | ||||
|             <div id="myorganization_list"></div> | ||||
|         </div> | ||||
|         <div class="dialog-func" style="margin-top: 16px;"> | ||||
|             <div class="clear"></div> | ||||
|         </div> | ||||
|     </div> | ||||
| </asp:Content> | ||||
|  | ||||
|  | ||||
							
								
								
									
										31
									
								
								Site/Credentials/ManageJDLink.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								Site/Credentials/ManageJDLink.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,31 @@ | ||||
| using IronIntel.Contractor.Site; | ||||
| using IronIntel.Contractor.Site.Credentials; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Web; | ||||
| using System.Web.UI; | ||||
| using System.Web.UI.WebControls; | ||||
|  | ||||
| public partial class ManageJDLink : CredentialEntryBasePage | ||||
| { | ||||
|     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) | ||||
|             { | ||||
|                 Title = PageTitle; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										286
									
								
								Site/Credentials/ManageJDNotifications.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										286
									
								
								Site/Credentials/ManageJDNotifications.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,286 @@ | ||||
| <%@ Page Title="" Language="C#" MasterPageFile="~/Credentials/Credentials.master" AutoEventWireup="true" CodeFile="ManageJDNotifications.aspx.cs" Inherits="ManageJDNotifications" %> | ||||
|  | ||||
| <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"> | ||||
|     <style type="text/css"> | ||||
|         .dialog .dialog-title .dialog-close { | ||||
|             float: right; | ||||
|             margin-right: 6px; | ||||
|             cursor: pointer; | ||||
|         } | ||||
|  | ||||
|             .dialog .dialog-title .dialog-close:before { | ||||
|                 content: '\e600'; | ||||
|             } | ||||
|  | ||||
|         .dialog-content table { | ||||
|             border-collapse: collapse; | ||||
|             width: 100%; | ||||
|         } | ||||
|  | ||||
|             .dialog-content table td { | ||||
|                 padding-top: 30px; | ||||
|             } | ||||
|  | ||||
|                 .dialog-content table td.label { | ||||
|                     width: 130px; | ||||
|                     text-align: right; | ||||
|                     padding-right: 10px; | ||||
|                     line-height: 24px; | ||||
|                     height: 24px; | ||||
|                     vertical-align: top; | ||||
|                 } | ||||
|  | ||||
|                 .dialog-content table td input, | ||||
|                 .dialog-content table td textarea { | ||||
|                     border: 1px solid #a9a9a9; | ||||
|                     width: 200px; | ||||
|                     height: 18px; | ||||
|                     padding: 1px; | ||||
|                 } | ||||
|  | ||||
|                     .dialog-content table td input[type="checkbox"] { | ||||
|                         border: none; | ||||
|                     } | ||||
|  | ||||
|                 .dialog-content table td textarea { | ||||
|                     height: 100px; | ||||
|                     max-width: 200px; | ||||
|                 } | ||||
|  | ||||
|         .icon { | ||||
|             font-family: CalciteWebCoreIcons; | ||||
|             cursor: default; | ||||
|         } | ||||
|     </style> | ||||
|  | ||||
|     <script type="text/javascript"> | ||||
|         var credentialList; | ||||
|         var authdata = undefined; | ||||
|  | ||||
|         credentialquery = function (method, param, callback, error, nolog) { | ||||
|             _network.request("Credentials/ManageJDNotifications.aspx?tp=ashx", -1, method, param, callback, error, nolog); | ||||
|         } | ||||
|  | ||||
|         function OnAdd() { | ||||
|             $('#requestCre').removeAttr("disabled"); | ||||
|             $('#dialog_Verifierd').attr("disabled", "disabled"); | ||||
|             $('#dialog_displayname').attr("disabled", "disabled"); | ||||
|             $('#saveCre').attr("disabled", "disabled"); | ||||
|  | ||||
|             $('#dialog_Verifierd').val(''); | ||||
|             $('#dialog_displayname').val(''); | ||||
|             $('#dialog_password').val(''); | ||||
|             $('#mask_bg').show(); | ||||
|             $('#dialog_credential') | ||||
|                 .attr('act', 'add') | ||||
|                 .css({ | ||||
|                     'top': (document.documentElement.clientHeight - $('#dialog_credential').height()) / 3, | ||||
|                     'left': (document.documentElement.clientWidth - $('#dialog_credential').width()) / 2 | ||||
|                 }) | ||||
|                 .showDialogfixed(); | ||||
|             $('#dialog_displayname').focus(); | ||||
|         } | ||||
|  | ||||
|         function OnRefresh() { | ||||
|             showloading(true); | ||||
|             credentialquery("GetJDNotificationCredentials", [], function (data) { | ||||
|                 showloading(false); | ||||
|                 credentialList = data; | ||||
|                 showCredentialList(credentialList); | ||||
|             }, function (err) { | ||||
|                 showloading(false); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         function showCredentialList(data) { | ||||
|             var rows = []; | ||||
|             for (var i = 0; i < data.length; i++) { | ||||
|                 var r = data[i]; | ||||
|                 for (var j in r) { | ||||
|                     if (j === "ExpireDate") | ||||
|                         r[j] = { DisplayValue: r["ExpireDateStr"], Value: r[j] }; | ||||
|                 } | ||||
|  | ||||
|                 var fr = { Values: r }; | ||||
|                 rows.push(fr); | ||||
|             } | ||||
|  | ||||
|             grid_dt.setData(rows); | ||||
|         } | ||||
|  | ||||
|         var grid_dt; | ||||
|         function InitGridData() { | ||||
|             grid_dt = new GridView('#jdlinklist'); | ||||
|             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: 'UserName', caption: GetTextByKey("P_JDN_USERNAME", "User Name"), valueIndex: 'UserName', css: { 'width': 400, 'text-align': 'left' } }, | ||||
|                 { name: 'DisplayName', caption: GetTextByKey("P_JDN_DISPLAYAME", "Display Name"), valueIndex: 'DisplayName', css: { 'width': 400, 'text-align': 'left' } }, | ||||
|                 { name: 'ExpireDate', caption: GetTextByKey("P_JDN_EXPIRATIONDATE", "Expiration Date"), valueIndex: 'ExpireDate', css: { 'width': 150, 'text-align': 'left' } }, | ||||
|                 { 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 === "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_JDN_DELETE", 'Delete') }; | ||||
|                 } | ||||
|                 columns.push(col); | ||||
|             } | ||||
|             grid_dt.canMultiSelect = false; | ||||
|             grid_dt.columns = columns; | ||||
|             grid_dt.init(); | ||||
|  | ||||
|             grid_dt.selectedrowchanged = function (rowindex) { | ||||
|                 var rowdata = grid_dt.source[rowindex]; | ||||
|                 if (rowdata) { | ||||
|                     creid = rowdata.Values.ID; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function RequestCreClick() { | ||||
|             $('#requestCre').attr("disabled", "disabled"); | ||||
|  | ||||
|             var alerttitle = GetTextByKey("P_JDN_AUTHORIZETHROUGHJOHNDEERE", "Authorize through John Deere"); | ||||
|             credentialquery("JDNotificationAuthorizeRequestToken", [], function (data) { | ||||
|                 if (typeof data === "string") { | ||||
|                     showAlert(data, alerttitle); | ||||
|                     $('#requestCre').removeAttr("disabled"); | ||||
|                     return; | ||||
|                 } | ||||
|                 authdata = data; | ||||
|                 if (authdata.AuthorizeRequestTokenUri != "") { | ||||
|                     window.open(authdata.AuthorizeRequestTokenUri); | ||||
|                     $('#dialog_displayname').removeAttr("disabled").val("").focus(); | ||||
|                     $('#dialog_Verifierd').removeAttr("disabled").val(""); | ||||
|                     $('#saveCre').removeAttr("disabled"); | ||||
|                 } | ||||
|                 else { | ||||
|                     $('#dialog_Verifierd').val("").attr("disabled", "disabled"); | ||||
|                     $('#dialog_displayname').val("").attr("disabled", "disabled"); | ||||
|                     showAlert(GetTextByKey("P_JDN_REQUESTFORVERIFIERFAILED", "Request for Verifier failed."), alerttitle); | ||||
|                 } | ||||
|             }, function (err) { | ||||
|                 showAlert(GetTextByKey("P_JDN_FAILEDTOAUTHORIZETHROUGHJD", "Failed to authorize through John Deere this credential."), alerttitle); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function SaveCre() { | ||||
|             var alerttitle = GetTextByKey("P_JDN_AUTHORIZE", "Authorize"); | ||||
|             var verifier = $.trim($('#dialog_Verifierd').val()); | ||||
|             if (verifier.length == 0) { | ||||
|                 showAlert(GetTextByKey("P_JDN_PLEASEINPUTVERIFIER", 'Please input Verifier.'), alerttitle); | ||||
|                 return false; | ||||
|             } | ||||
|             var displayname = $.trim($('#dialog_displayname').val()); | ||||
|             credentialquery("FinishJDNotificationOAuthRequest", JSON.stringify(authdata) + String.fromCharCode(170) + verifier + String.fromCharCode(170) + displayname, function (data) { | ||||
|                 if (data !== 'OK') { | ||||
|                     showAlert(data, alerttitle); | ||||
|                 } else { | ||||
|                     $('#dialog_credential').hideDialog(); | ||||
|                     OnRefresh(); | ||||
|                 } | ||||
|             }, function (err) { | ||||
|                 showAlert(GetTextByKey("P_JDN_FAILEDTOAUTHORIZETHISCREDENTIAL", "Failed to authorize this credential."), alerttitle); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function OnDelete(cr) { | ||||
|             var cre = cr; | ||||
|             if (!cre) { | ||||
|                 return; | ||||
|             } | ||||
|             var alerttitle = GetTextByKey("P_JDN_DELETECREDENTIAL", "Delete Credential"); | ||||
|             showConfirm(GetTextByKey("P_JDN_DELETETHECREDENTIALTIPS", 'Do you want to delete the credential?'), alerttitle, function () { | ||||
|                 credentialquery("DeleteSubscription", cre.ID, function (data) { | ||||
|                     if (data !== 'OK') { | ||||
|                         showAlert(data, alerttitle); | ||||
|                         return; | ||||
|                     } | ||||
|                     OnRefresh(); | ||||
|                 }, function (err) { | ||||
|                     showAlert(GetTextByKey("GetTextByKey", 'Failed to delete this credential.'), alerttitle); | ||||
|                 }); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         $(function () { | ||||
|             setPageTitle(GetTextByKey("P_JOHNDEERENOTIFICATIONS", 'JohnDeere Notifications'), true); | ||||
|             InitGridData(); | ||||
|  | ||||
|             $('#dialog_credential').dialog(function () { | ||||
|                 $('#mask_bg').hide(); | ||||
|             }); | ||||
|             OnRefresh(); | ||||
|             $(window).resize(function () { | ||||
|                 $("#jdlinklist").css("height", $(window).height() - $("#jdlinklist").offset().top - 4); | ||||
|                 grid_dt && grid_dt.resize(); | ||||
|             }).resize(); | ||||
|         }); | ||||
|  | ||||
|     </script> | ||||
| </asp:Content> | ||||
|  | ||||
| <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> | ||||
|     <div style="min-width: 400px;"> | ||||
|         <div class="page_title" data-lgid="P_JOHNDEERENOTIFICATIONS">JohnDeere Notifications</div> | ||||
|         <div class="function_title"> | ||||
|             <span class="sbutton iconadd" onclick="OnAdd();" data-lgid="P_JDN_ADD">Add</span> | ||||
|             <span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_JDN_REFRESH">Refresh</span> | ||||
|         </div> | ||||
|         <div class="clear"></div> | ||||
|         <div id="jdlinklist"></div> | ||||
|     </div> | ||||
|  | ||||
|     <div id="mask_bg"> | ||||
|         <div class="loading c-spin"></div> | ||||
|     </div> | ||||
|     <div class="dialog" id="dialog_credential" style="display: none; width: 600px;"> | ||||
|         <div class="dialog-title"><span class="title" data-lgid="P_JDN_REQUESTCREDENTIAL">Request Credential</span><em class="dialog-close"></em></div> | ||||
|         <div class="dialog-content"> | ||||
|             <table> | ||||
|                 <tr> | ||||
|                     <td class="label" data-lgid="P_JDN_DISPLAYAME_COLON">Display Name:</td> | ||||
|                     <td> | ||||
|                         <input id="dialog_displayname" maxlength="50" tabindex="2" style="width: 400px;" disabled="disabled" /></td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td class="label" data-lgid="P_JDN_VERIFIER_COLON">Verifier:</td> | ||||
|                     <td> | ||||
|                         <input id="dialog_Verifierd" maxlength="50" tabindex="2" style="width: 400px;" disabled="disabled" /></td> | ||||
|                 </tr> | ||||
|             </table> | ||||
|         </div> | ||||
|         <div class="dialog-func" style="margin-top: 16px;"> | ||||
|             <input type="button" value="Cancel" data-lgid="P_JDN_CANCEL" class="dialog-close" tabindex="5" /> | ||||
|             <input type="button" id="saveCre" style="width: unset;" onclick="SaveCre(); return false;" disabled="disabled" value="Authorize" data-lgid="P_JDN_AUTHORIZE" tabindex="4" /> | ||||
|             <input type="button" id="requestCre" style="width: unset;" onclick="RequestCreClick(); return false;" value="Authorize through John Deere" data-lgid="P_JDN_AUTHORIZETHROUGHJOHNDEERE" tabindex="3" /> | ||||
|             <div class="clear"></div> | ||||
|         </div> | ||||
|     </div> | ||||
| </asp:Content> | ||||
|  | ||||
|  | ||||
							
								
								
									
										33
									
								
								Site/Credentials/ManageJDNotifications.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								Site/Credentials/ManageJDNotifications.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| using Foresight.Fleet.Services.User; | ||||
| using IronIntel.Contractor; | ||||
| using IronIntel.Contractor.Site; | ||||
| using IronIntel.Contractor.Site.Credentials; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Web; | ||||
| using System.Web.UI; | ||||
| using System.Web.UI.WebControls; | ||||
|  | ||||
| public partial class ManageJDNotifications : CredentialEntryBasePage | ||||
| { | ||||
|     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) | ||||
|             { | ||||
|                 Title = PageTitle; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										40
									
								
								Site/Credentials/css/controls.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								Site/Credentials/css/controls.css
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| .tab_holder { | ||||
|  | ||||
| } | ||||
| .tab_header { | ||||
|     height: 30px; | ||||
|     line-height: 30px; | ||||
|     border-bottom: 1px solid #b0b0b0; | ||||
|     /* 禁止选中 */ | ||||
|     -moz-user-select: none; /*火狐*/ | ||||
|     -webkit-user-select: none; /*webkit浏览器*/ | ||||
|     -ms-user-select: none; /*IE10*/ | ||||
|     -khtml-user-select: none; /*早期浏览器*/ | ||||
|     user-select: none; | ||||
| } | ||||
| .tab_header .tab_title { | ||||
|     float: left; | ||||
|     height: 29px; | ||||
|     cursor: pointer; | ||||
|     padding: 0 12px; | ||||
|     border: 1px solid #fff; | ||||
|     border-bottom: none; | ||||
| } | ||||
| .tab_header .tab_title:hover { | ||||
|     /*background: #d7690E;*/ | ||||
|     color: rgb(173,84,12); | ||||
| } | ||||
| .tab_header .selected, | ||||
| .tab_header .selected:hover { | ||||
|     /*background: #F78E1E;*/ | ||||
|     border: 1px solid #b0b0b0; | ||||
|     border-bottom: 1px solid #fff; | ||||
|     /*margin-top: -1px;*/ | ||||
|     color: rgb(173,84,12); | ||||
| } | ||||
| .tab_header .tab_title:first-child { | ||||
|     border-left: none; | ||||
| } | ||||
| .tab_holder .tab_page { | ||||
|  | ||||
| } | ||||
							
								
								
									
										
											BIN
										
									
								
								Site/Credentials/img/apicredential.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Site/Credentials/img/apicredential.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 961 B | 
							
								
								
									
										
											BIN
										
									
								
								Site/Credentials/img/credential.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Site/Credentials/img/credential.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 961 B | 
							
								
								
									
										
											BIN
										
									
								
								Site/Credentials/img/jdlink.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Site/Credentials/img/jdlink.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1001 B | 
							
								
								
									
										
											BIN
										
									
								
								Site/Credentials/img/jdnotifications.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Site/Credentials/img/jdnotifications.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.1 KiB | 
							
								
								
									
										397
									
								
								Site/Credentials/js/controls.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										397
									
								
								Site/Credentials/js/controls.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,397 @@ | ||||
| /// <reference path="../../js/jquery-3.6.0.min.js" /> | ||||
| /// <reference path="../../js/utility.js" /> | ||||
|  | ||||
| $.fn.tab = function (obj) { | ||||
|     return this.each(function () { | ||||
|         var _this = $(this); | ||||
|         _this.data('tabparam', obj); | ||||
|  | ||||
|         function switchPage(page) { | ||||
|             _this.children('.tab_page').hide(); | ||||
|             _this.children('#' + page).show(); | ||||
|         } | ||||
|  | ||||
|         var titles = _this.children('.tab_header').children('.tab_title'); | ||||
|         titles.click(function (e) { | ||||
|             var n_this = $(this); | ||||
|             // invoke function | ||||
|             function next() { | ||||
|                 if (typeof obj.onnext === 'function') { | ||||
|                     obj.onnext(); | ||||
|                 } | ||||
|                 titles.removeClass('selected'); | ||||
|                 var dfor = n_this.addClass('selected').attr('data-for'); | ||||
|                 switchPage(dfor); | ||||
|             } | ||||
|             if (typeof obj.onclick === 'function') { | ||||
|                 obj.onclick(n_this, next); | ||||
|             } else { | ||||
|                 next(); | ||||
|             } | ||||
|         }); | ||||
|         var datafor = titles.removeClass('selected').first().addClass('selected').attr('data-for'); | ||||
|         switchPage(datafor); | ||||
|     }); | ||||
| }; | ||||
|  | ||||
| $.fn.selectable = function (param) { | ||||
|  | ||||
|     param = param || {}; | ||||
|  | ||||
|     function multi_click(e) { | ||||
|         var target = $(e.target); | ||||
|         if (!target.is('tr')) { | ||||
|             target = target.parents('tr').first(); | ||||
|         } | ||||
|         if (param.multiple) { | ||||
|             if (!target.length) | ||||
|                 return; | ||||
|             // ctrl | ||||
|             if (e.ctrlKey) { | ||||
|                 if (target.hasClass('selected')) { | ||||
|                     target.removeClass('selected'); | ||||
|                 } else { | ||||
|                     target.addClass('selected'); | ||||
|                 } | ||||
|             } else if (e.shiftKey) { | ||||
|                 target.addClass('selected'); | ||||
|                 var first = $(this).children('tr.selected:first'); | ||||
|                 var last = $(this).children('tr.selected:last'); | ||||
|                 while (first.attr('uid') != last.attr('uid')) { | ||||
|                     first = first.next(); | ||||
|                     if (!first.length) | ||||
|                         break; | ||||
|                     first.addClass('selected'); | ||||
|                 } | ||||
|             } else { | ||||
|                 $(this).children('tr').removeClass('selected'); | ||||
|                 target.addClass('selected'); | ||||
|             } | ||||
|         } else { | ||||
|             $(this).children('tr').removeClass('selected'); | ||||
|             if (!target.length) | ||||
|                 return; | ||||
|             target.addClass('selected'); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     function dbl_click(e) { | ||||
|         if (typeof param.dblclick !== 'function') | ||||
|             return; | ||||
|  | ||||
|         var target = $(e.target); | ||||
|         if (!target.is('tr')) { | ||||
|             target = target.parents('tr').first(); | ||||
|         } | ||||
|         param.dblclick.apply(this, [target]); | ||||
|     } | ||||
|  | ||||
|     return this.each(function () { | ||||
|         $(this).click(multi_click).dblclick(dbl_click); | ||||
|     }); | ||||
| }; | ||||
|  | ||||
| $.fn.tree = function (data, selectedValues, options) { | ||||
|  | ||||
|     options = options || {}; | ||||
|     selectedValues = selectedValues || []; | ||||
|  | ||||
|     if (!data) { | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     function changeExpand() { | ||||
|         var flag = $(this).hasClass('collapse'); | ||||
|         if (flag) { | ||||
|             $(this).removeClass('collapse').addClass('expand').parent('li').children('ul').show(); | ||||
|         } else { | ||||
|             $(this).removeClass('expand').addClass('collapse').parent('li').children('ul').hide(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     function checkSelected(data) { | ||||
|         for (var i = 0; i < data.length; i++) { | ||||
|             var item = data[i]; | ||||
|             if (selectedValues.indexOf(item.ID) >= 0) { | ||||
|                 return true; | ||||
|             } | ||||
|             if (item.SubData && item.SubData.length > 0) { | ||||
|                 if (checkSelected(item.SubData)) { | ||||
|                     return true; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     function checkChanged() { | ||||
|         var li = $(this).parents('li:first'); | ||||
|         var checked = $(this).prop('checked'); | ||||
|  | ||||
|         // 如果有子节点 | ||||
|         var ul = li.children('ul'); | ||||
|         var indeter = $(this).prop('indeter'); | ||||
|         $(this).removeProp('indeter'); | ||||
|         if (checked) { | ||||
|             // check all | ||||
|             ul.find('input').removeProp('indeter').prop({ 'indeterminate': false, 'checked': true }); | ||||
|         } else { | ||||
|             if (!indeter && ul.length > 0) { | ||||
|                 $(this).prop({ | ||||
|                     'indeterminate': true, | ||||
|                     'indeter': true, | ||||
|                     'checked': true | ||||
|                 }); | ||||
|             } else { | ||||
|                 // uncheck all | ||||
|                 ul.find('input').removeProp('indeter').prop({ 'indeterminate': false, 'checked': false }); | ||||
|             } | ||||
|         } | ||||
|         checkUpper.apply(this); | ||||
|     } | ||||
|  | ||||
|     function checkUpper() { | ||||
|         // 向上寻找父节点 | ||||
|         var ul = $(this).parents('ul:first'); | ||||
|         var inp = ul.prev('em').prev('span').children('input'); | ||||
|         if (inp.length > 0) { | ||||
|             var chks = ul.children('li').children('span').children('input'); | ||||
|             var count = chks.length; | ||||
|             for (var i = 0; i < chks.length; i++) { | ||||
|                 if (chks[i].indeterminate) { | ||||
|                     count = 0.5; | ||||
|                     break; | ||||
|                 } | ||||
|  | ||||
|                 if (!chks[i].checked) { | ||||
|                     count--; | ||||
|                 } | ||||
|             } | ||||
|             if (count == chks.length) { | ||||
|                 // checked all | ||||
|                 inp.removeProp('indeter').prop({ 'indeterminate': false, 'checked': true }); | ||||
|             } else if (count == 0) { | ||||
|                 // unchecked all | ||||
|                 inp.removeProp('indeter').prop({ 'indeterminate': false, 'checked': false }); | ||||
|             } else { | ||||
|                 inp.prop({ | ||||
|                     'indeterminate': true, | ||||
|                     'indeter': true, | ||||
|                     'checked': true | ||||
|                 }); | ||||
|             } | ||||
|             // 遍历 | ||||
|             checkUpper.apply(inp); | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
|     function fillChildren(ul, item, selected) { | ||||
|         var li = $('<li></li>'); | ||||
|         var uid = 'li_' + Math.random().toString().substring(2); | ||||
|         var chk = $('<input type="checkbox"/>').attr('id', uid).val(item.ID).change(checkChanged); | ||||
|         if (selected || selectedValues.indexOf(item.ID) >= 0) { | ||||
|             chk.prop('checked', true); | ||||
|             selected = true; | ||||
|         } | ||||
|         var span = $('<span></span>'); | ||||
|         span.append(chk, $('<label></label>').attr('for', uid).text(item.Description)); | ||||
|         li.append(span); | ||||
|         ul.append(li); | ||||
|         // 判断是否有子节点 | ||||
|         if (item.SubData && item.SubData.length > 0) { | ||||
|             // 判断子节点选中状态 | ||||
|             var ulc; | ||||
|             if (selected || checkSelected(item.SubData)) { | ||||
|                 li.append($('<em class="icn expand"></em>').click(changeExpand)); | ||||
|                 ulc = $('<ul></ul>'); | ||||
|             } else { | ||||
|                 li.append($('<em class="icn collapse"></em>').click(changeExpand)); | ||||
|                 ulc = $('<ul></ul>').css('display', 'none'); | ||||
|             } | ||||
|             var cnt = 0 | ||||
|             for (var i = 0; i < item.SubData.length; i++) { | ||||
|                 if (fillChildren(ulc, item.SubData[i], selected)) { | ||||
|                     cnt++; | ||||
|                 } | ||||
|             } | ||||
|             li.append(ulc); | ||||
|             // 补充父节点的不定状态 | ||||
|             if (!selected && cnt > 0) { | ||||
|                 chk.prop({ | ||||
|                     'indeterminate': true, | ||||
|                     'indeter': true, | ||||
|                     'checked': true | ||||
|                 }); | ||||
|             } | ||||
|         } | ||||
|         return selected; | ||||
|     } | ||||
|  | ||||
|     return this.each(function () { | ||||
|         for (var i = 0 ; i < data.length; i++) { | ||||
|             fillChildren($(this), data[i]); | ||||
|         } | ||||
|     }); | ||||
| }; | ||||
|  | ||||
| var TYPE_USER = 2; | ||||
| var TYPE_GROUP = 1; | ||||
|  | ||||
| $.fn.appendUserCtl = function (param) { | ||||
|     param = param || {}; | ||||
|  | ||||
|     function dtquery(method, p, callback) { | ||||
|         _network.request("Security/DataTablePermission.aspx", -1, method, p, callback, function (e) { | ||||
|             console.log(e); | ||||
|             showmaskbg(false); | ||||
|             showAlert(e.statusText, 'Error'); | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     function groupTitleClick(e) { | ||||
|         if ($(this.lastChild).hasClass('collapse')) { | ||||
|             $(this.lastChild).removeClass('collapse').addClass('expand'); | ||||
|             $(this).nextAll().show(); | ||||
|         } else { | ||||
|             $(this.lastChild).removeClass('expand').addClass('collapse'); | ||||
|             $(this).nextAll().hide(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     var usersul = $('<ul class="ul_menu"></ul>').attr('usertype', TYPE_USER); | ||||
|     var usertitle = $('<li class="ul_header"></li>').append('<span>Users</span><em class="icn expand"></em>').click(groupTitleClick); | ||||
|     usersul.append(usertitle); | ||||
|     dtquery('GetUsers', '', function (data) { | ||||
|         usertitle.nextAll().remove(); | ||||
|         for (var i = 0; i < data.length; i++) { | ||||
|             var li = $('<li class="subitem"></li>') | ||||
|                 .attr({ | ||||
|                     'id': data[i].IID, | ||||
|                     'title': data[i].ID | ||||
|                 }) | ||||
|                 //.text(data[i].DisplayName) | ||||
|                 .append($('<span></span>').text(data[i].DisplayName), $('<i></i>').text('(' + data[i].ID + ')')) | ||||
|                 .data('usertype', data[i].UserType); | ||||
|             li.click(param.selectUser); | ||||
|             usersul.append(li); | ||||
|         } | ||||
|  | ||||
|         // default to load the first | ||||
|         usertitle.next().click(); | ||||
|     }); | ||||
|  | ||||
|     var groupsul = $('<ul class="ul_menu"></ul>').attr('usertype', TYPE_GROUP); | ||||
|     var grouptitle = $('<li class="ul_header"></li>').append('<span>User Groups</span><em class="icn expand"></em>').click(groupTitleClick); | ||||
|     groupsul.append(grouptitle); | ||||
|     dtquery('GetUserGroups', '', function (data) { | ||||
|         grouptitle.nextAll().remove(); | ||||
|         for (var i = 0; i < data.length; i++) { | ||||
|             var li = $('<li class="subitem"></li>').attr('id', data[i].ID).text(data[i].Name); | ||||
|             li.click(param.selectUser); | ||||
|             groupsul.append(li); | ||||
|         } | ||||
|     }); | ||||
|  | ||||
|     return this.append(usersul, groupsul); | ||||
| }; | ||||
| $.fn.getUserIdType = function () { | ||||
|     var li = this.find('li.selected'); | ||||
|     var id = li.attr('id'); | ||||
|     var usertype; | ||||
|     if (li.parent().attr('usertype') == TYPE_GROUP) { | ||||
|         usertype = TYPE_GROUP; | ||||
|     } else { | ||||
|         usertype = TYPE_USER; | ||||
|     } | ||||
|     return { | ||||
|         'id': id, | ||||
|         'type': usertype, | ||||
|         'permission': li.data('usertype') | ||||
|     }; | ||||
| }; | ||||
|  | ||||
| if (typeof Class !== 'function') { | ||||
|  | ||||
|     // 基类实现 (空实现) | ||||
|     Class = function () { }; | ||||
|  | ||||
|     /* Simple JavaScript Inheritance | ||||
|      * By John Resig http://ejohn.org/ | ||||
|      * MIT Licensed. | ||||
|      */ | ||||
|     // Inspired by base2 and Prototype | ||||
|     (function () { | ||||
|         'use strict'; | ||||
|  | ||||
|         var initializing = false, fnTest = /xyz/.test(function () { xyz; }) ? /\b_super\b/ : /.*/; | ||||
|  | ||||
|         // 创建一个继承当前调用类的子类 | ||||
|         Class.extend = function ext(prop) { | ||||
|             var _super = this.prototype; | ||||
|  | ||||
|             // 实例化,此时不执行构造方法 (x.prototype.constructor) | ||||
|             initializing = true; | ||||
|             var prototype = new this(); | ||||
|             initializing = false; | ||||
|  | ||||
|             // 复制属性到新的prototype中 | ||||
|             for (var name in prop) { | ||||
|                 // 判断属性或重载方法 | ||||
|                 prototype[name] = typeof prop[name] == "function" && | ||||
|                     typeof _super[name] == "function" && fnTest.test(prop[name]) ? | ||||
|                     (function (name, fn) { | ||||
|                         return function () { | ||||
|                             var tmp = this._super; | ||||
|  | ||||
|                             this._super = _super[name]; | ||||
|                             var ret = fn.apply(this, arguments); | ||||
|                             this._super = tmp; | ||||
|  | ||||
|                             return ret; | ||||
|                         }; | ||||
|                     })(name, prop[name]) : | ||||
|                     prop[name]; | ||||
|             } | ||||
|  | ||||
|             // 临时构造方法 | ||||
|             function Class() { | ||||
|                 if (!initializing && this.init) | ||||
|                     this.init.apply(this, arguments); | ||||
|             } | ||||
|  | ||||
|             Class.prototype = prototype; | ||||
|             // 修正构造方法的指向 | ||||
|             Class.prototype.constructor = Class; | ||||
|             // 添加扩展 | ||||
|             Class.extend = ext; // arguments.callee; | ||||
|  | ||||
|             return Class; | ||||
|         }; | ||||
|     }()); | ||||
| } | ||||
| if (typeof _chartType === 'undefined') { | ||||
|     _chartType = { | ||||
|         Gauge: 'Gauge', | ||||
|         Grid: 'Grid', | ||||
|         Grid3D: 'Grid3D', | ||||
|         List: 'List', | ||||
|         Line2D: 'Line', | ||||
|         Line3D: 'Line3D', | ||||
|         Column2D: 'Column', | ||||
|         Column3D: 'Column3D', | ||||
|         Bar2D: 'Bar', | ||||
|         Bar3D: 'Bar3D', | ||||
|         ColumnLine: 'ColumnLine', | ||||
|         Scatter: 'ScatterPlot', | ||||
|         Pie: 'Pie', | ||||
|         Doughnut: 'Doughnut', | ||||
|         Scorecard: 'FreeChart', | ||||
|         Rss: 'RSS', | ||||
|         Video: 'Video', | ||||
|         Stock: 'Stock', | ||||
|         Alert: 'Alert', | ||||
|         Favorites: 'Favorites', | ||||
|         FRPT: 'FRPT' | ||||
|     }; | ||||
| } | ||||
							
								
								
									
										119
									
								
								Site/ErrorPage.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										119
									
								
								Site/ErrorPage.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,119 @@ | ||||
| <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ErrorPage.aspx.cs" Inherits="ErrorPage" %> | ||||
|  | ||||
|  | ||||
| <!DOCTYPE html> | ||||
|  | ||||
| <html xmlns="http://www.w3.org/1999/xhtml"> | ||||
| <head> | ||||
|     <title>Error Page</title> | ||||
|     <link rel="stylesheet" href="<%=Page.ResolveUrl("~/")%>css/default.css" type="text/css" /> | ||||
|     <script src="<%=Page.ResolveUrl("~/")%>js/jquery-3.6.0.min.js" type="text/javascript"></script> | ||||
|     <style type="text/css"> | ||||
|         body { | ||||
|             margin: 0; | ||||
|             padding: 0; | ||||
|             border: 0; | ||||
|             font-family: Verdana; | ||||
|             font-size: 12px; | ||||
|         } | ||||
|  | ||||
|         a { | ||||
|             text-decoration: none; | ||||
|             color: #2140fb; | ||||
|         } | ||||
|  | ||||
|             a:hover { | ||||
|                 text-decoration: underline; | ||||
|             } | ||||
|  | ||||
|             a:visited { | ||||
|                 color: #2140fb; | ||||
|             } | ||||
|  | ||||
|         #host_header { | ||||
|             background: #F78E1E; | ||||
|             color: #000; | ||||
|             height: 60px; | ||||
|             /*box-shadow: 0 0 10px rgba(0,0,0,.4);*/ | ||||
|         } | ||||
|  | ||||
|             #host_header .logo { | ||||
|                 float: left; | ||||
|                 height: 55px; | ||||
|             } | ||||
|  | ||||
|         .error_prompt { | ||||
|             font-family: Arial; | ||||
|             font-size: 1.4em; | ||||
|             margin: 48px 30px; | ||||
|         } | ||||
|  | ||||
|             .error_prompt a { | ||||
|                 font-weight: bold; | ||||
|             } | ||||
|  | ||||
|         .error_detail { | ||||
|             margin: 48px 30px; | ||||
|         } | ||||
|  | ||||
|             .error_detail .error_label { | ||||
|                 color: #0094ff; | ||||
|                 cursor: pointer; | ||||
|             } | ||||
|  | ||||
|                 .error_detail .error_label:hover { | ||||
|                     text-decoration: underline; | ||||
|                 } | ||||
|  | ||||
|         .error_detail_div { | ||||
|             background: #ffe880; | ||||
|             font-size: 11px; | ||||
|             font-family: Consolas, 'Lucida Console', 'Courier New', monospace; | ||||
|             padding: 10px; | ||||
|             margin-top: 10px; | ||||
|         } | ||||
|     </style> | ||||
|     <script type="text/javascript"> | ||||
|         var code ="<%=Code %>"; | ||||
|         $(function () { | ||||
|             if (code == "403") | ||||
|                 $("#error_noright").show(); | ||||
|             else | ||||
|                 $("#error_content").show(); | ||||
|  | ||||
|             $('#error_label').click(function () { | ||||
|                 var _div = $('#<%=error_detail.ClientID%>'); | ||||
|                 if (_div.css('display') == 'none') { | ||||
|                     _div.css('display', ''); | ||||
|                 } else { | ||||
|                     _div.css('display', 'none'); | ||||
|                 } | ||||
|             }); | ||||
|         }); | ||||
|     </script> | ||||
| </head> | ||||
| <body> | ||||
|     <div id="host_main"> | ||||
|         <div id="host_header"> | ||||
|             <img src="<%=Page.ResolveUrl("~/")%>titlelogo.ashx" class="logo" style="margin-left: 10px; margin-top: 2px; margin-bottom: 2px;" /> | ||||
|         </div> | ||||
|     </div> | ||||
|     <div id="content"> | ||||
|         <div id="error_content" style="display: none;"> | ||||
|             <div class="error_prompt"> | ||||
|                 Error occurs, please refresh the page later.<br /> | ||||
|                 <br /> | ||||
|                 Or return to the <a href="<%=LoginPageUrl %>">Login page.</a> | ||||
|             </div> | ||||
|             <div class="error_detail" style="display: none"> | ||||
|                 <label class="error_label" id="error_label">Show Detail</label><div id="error_detail" class="error_detail_div" runat="server" style="display: none;">Error occurs.</div> | ||||
|             </div> | ||||
|         </div> | ||||
|         <div id="error_noright" style="display: none; margin-left: 20px; margin-top: 20px;"> | ||||
|             <div>You have no right to access this page.</div> | ||||
|             <br /> | ||||
|             <div>Click <a href="<%=LoginPageUrl %>">here</a> to redirect to the login page.</div> | ||||
|         </div> | ||||
|     </div> | ||||
| </body> | ||||
| </html> | ||||
							
								
								
									
										33
									
								
								Site/ErrorPage.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								Site/ErrorPage.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| using IronIntel.Contractor.Site; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.IO; | ||||
| using System.Linq; | ||||
| using System.Web; | ||||
| using System.Web.UI; | ||||
| using System.Web.UI.WebControls; | ||||
|  | ||||
| public partial class ErrorPage : ContractorBasePage | ||||
| { | ||||
|     protected string Code = ""; | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     { | ||||
|         //string detail; | ||||
|         //using (var reader = new StreamReader(Request.InputStream)) | ||||
|         //{ | ||||
|         //    detail = reader.ReadToEnd(); | ||||
|         //} | ||||
|  | ||||
|         //if (!string.IsNullOrEmpty(detail)) | ||||
|         //{ | ||||
|         //    error_detail.InnerHtml = HttpUtility.HtmlEncode(detail).Replace("\n", "<br/>"); | ||||
|         //} | ||||
|  | ||||
|         Code = Request.Params["code"]; | ||||
|     } | ||||
|  | ||||
|     protected override bool AllowCurrentLoginSessionEnter() | ||||
|     { | ||||
|         return true; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										17
									
								
								Site/ExportToFile.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								Site/ExportToFile.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ExportToFile.aspx.cs" Inherits="ExportToFile" %> | ||||
|  | ||||
| <!DOCTYPE html> | ||||
|  | ||||
| <html xmlns="http://www.w3.org/1999/xhtml"> | ||||
| <head runat="server"> | ||||
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | ||||
|     <title></title> | ||||
| </head> | ||||
| <body> | ||||
|     <form id="form1" runat="server"> | ||||
|     <div> | ||||
|      | ||||
|     </div> | ||||
|     </form> | ||||
| </body> | ||||
| </html> | ||||
							
								
								
									
										681
									
								
								Site/ExportToFile.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										681
									
								
								Site/ExportToFile.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,681 @@ | ||||
| using FI.FIC; | ||||
| using Foresight.Fleet.Services.Asset; | ||||
| using IronIntel.Contractor; | ||||
| using IronIntel.Contractor.Machines; | ||||
| using IronIntel.Contractor.Site; | ||||
| using IronIntel.Contractor.Site.Maintenance; | ||||
| using Newtonsoft.Json; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Data; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| using System.Web; | ||||
| using System.Web.UI; | ||||
| using System.Web.UI.WebControls; | ||||
|  | ||||
| public partial class ExportToFile : ContractorBasePage | ||||
| { | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     { | ||||
|         if (GetCurrentLoginSession() != null) | ||||
|         { | ||||
|             byte[] buffer = null; | ||||
|             string title = ""; | ||||
|             string fileType = "xlsx"; | ||||
|             try | ||||
|             { | ||||
|                 string type = Request.Params["type"]; | ||||
|                 switch (type) | ||||
|                 { | ||||
|                     case "set": | ||||
|                         SetExportParams(); | ||||
|                         break; | ||||
|                     case "exp": | ||||
|                         buffer = ExportByParams(ref title, ref fileType); | ||||
|                         break; | ||||
|                     case "devicesexcel": | ||||
|                         buffer = ExportDeviceErrorList(ref title); | ||||
|                         break; | ||||
|                     case "assetsexcel": | ||||
|                         buffer = ExportAssetErrorList(ref title); | ||||
|                         break; | ||||
|                     default: | ||||
|                         buffer = Export(type, ref title, ref fileType); | ||||
|                         break; | ||||
|                 } | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 SystemParams.WriteLog("error", "ExportToFile", ex.Message, ex.ToString()); | ||||
|             } | ||||
|  | ||||
|             if (string.Equals(fileType, "xlsx", StringComparison.OrdinalIgnoreCase)) | ||||
|             { | ||||
|                 title = title + ".xlsx"; | ||||
|                 Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; | ||||
|             } | ||||
|  | ||||
|             Response.BufferOutput = false; | ||||
|             Response.ContentEncoding = System.Text.Encoding.UTF8; | ||||
|             Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(title, System.Text.Encoding.UTF8)); | ||||
|             if (buffer != null) | ||||
|             { | ||||
|                 Response.AddHeader("Content-Length", buffer.Length.ToString()); | ||||
|                 Response.BinaryWrite(buffer); | ||||
|             } | ||||
|             Response.Flush(); | ||||
|             Response.End(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void SetExportParams() | ||||
|     { | ||||
|         var clientdata = Request.Form["ClientData"]; | ||||
|         string key = ExportExcelManager.SetExprotParams(clientdata); | ||||
|         Response.Write(JsonConvert.SerializeObject(key)); | ||||
|         Response.End(); | ||||
|     } | ||||
|  | ||||
|     private byte[] ExportDeviceErrorList(ref string title) | ||||
|     { | ||||
|         string key = Request.Params["key"]; | ||||
|         title = "Import Devices Error List"; | ||||
|         string p = ExportExcelManager.GetExportParams(key); | ||||
|         if (string.IsNullOrEmpty(p)) | ||||
|             return null; | ||||
|  | ||||
|         DeviceItem[] ds = JsonConvert.DeserializeObject<DeviceItem[]>(p); | ||||
|         IronIntel.Contractor.Users.UserInfo u = GetCurrentUser(); | ||||
|  | ||||
|         string lang = GetLanguageCookie(); | ||||
|         ExportToExcel ete = new ExportToExcel(); | ||||
|         DataTable dt = new DataTable(); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_SOURCE", "Source"), Caption = "SourceName" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_SN", "Air ID or SN"), Caption = "SerialNumber" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_ESN", "ESN"), Caption = "AlternativeSerialNumber" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_DEVICETYPE", "Device Type"), Caption = "DeviceType" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_STATUS", "Status"), Caption = "Status" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_INVOICEDATE", "Invoice Date"), Caption = "InvoiceDate" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_INVOICENUMBER", "Invoice #"), Caption = "InvoiceNumber" }); | ||||
|         if (u.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin) | ||||
|         { | ||||
|             dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_XXXXXX", "Sales Order #"), Caption = "SalesOrderNumber" }); | ||||
|         } | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_SERVICESTATDATE", "Service Start Date"), Caption = "ServiceStartDate" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_ASSETVINSN", "Asset VIN/SN"), Caption = "VIN" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_TAMPERALERTS", "Tamper Alerts"), Caption = "TamperAlerts" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_UTILIZATION", "Utilization"), Caption = "Utilization" }); | ||||
|         if (u.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin) | ||||
|         { | ||||
|             dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_FIINSTALLATION", "FI Install"), Caption = "FIInstalltion" }); | ||||
|             dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_INSTALLER", "Installer"), Caption = "Installer" }); | ||||
|         } | ||||
|  | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MD_NOTES", "Notes"), Caption = "Notes" }); | ||||
|  | ||||
|         if (ds != null && ds.Length > 0) | ||||
|         { | ||||
|             foreach (var r in ds) | ||||
|             { | ||||
|                 int index = 0; | ||||
|                 var dr = dt.NewRow(); | ||||
|                 dr[index] = r.SourceName; | ||||
|                 dr[++index] = r.SerialNumber; | ||||
|                 dr[++index] = r.AlternativeSerialNumber; | ||||
|                 dr[++index] = r.DeviceType; | ||||
|                 dr[++index] = r.Status == 1 ? "Active" : "Inactive"; | ||||
|                 dr[++index] = r.InvoiceDateStr; | ||||
|                 dr[++index] = r.InvoiceNumber; | ||||
|                 if (u.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin) | ||||
|                 { | ||||
|                     dr[++index] = r.SalesOrderNumber; | ||||
|                 } | ||||
|                 dr[++index] = r.ServiceStartDateStr; | ||||
|                 dr[++index] = r.PairedAsset == null ? "" : r.PairedAsset.VIN; | ||||
|                 dr[++index] = r.Tamper ? "Yes" : "No"; | ||||
|                 dr[++index] = r.Utilization ? "Yes" : "No"; | ||||
|                 if (u.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin) | ||||
|                 { | ||||
|                     dr[++index] = r.FIInstalltion ? "Yes" : "No"; | ||||
|                     dr[++index] = r.Installer; | ||||
|                 } | ||||
|  | ||||
|                 dr[++index] = r.Notes; | ||||
|  | ||||
|                 dt.Rows.Add(dr); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         double[] widths; | ||||
|         if (u.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin) | ||||
|         { | ||||
|             widths = new double[] { 120, 120, 120, 120, 120, 120, 120, 120, 150, 120, 120, 120, 120, 120, 120 }; | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             widths = new double[] { 120, 120, 120, 120, 120, 120, 120, 150, 120, 120, 120, 120 }; | ||||
|         } | ||||
|  | ||||
|         byte[] data = ete.CreateExcel(dt, null, widths, null); | ||||
|  | ||||
|         return data; | ||||
|  | ||||
|     } | ||||
|  | ||||
|     private byte[] ExportAssetErrorList(ref string title) | ||||
|     { | ||||
|         string key = Request.Params["key"]; | ||||
|         title = "Import Assets Error List"; | ||||
|         string p = ExportExcelManager.GetExportParams(key); | ||||
|         if (string.IsNullOrEmpty(p)) | ||||
|             return null; | ||||
|  | ||||
|         AssetDetailInfo2[] ds = JsonConvert.DeserializeObject<AssetDetailInfo2[]>(p); | ||||
|         IronIntel.Contractor.Users.UserInfo u = GetCurrentUser(); | ||||
|         string lang = GetLanguageCookie(); | ||||
|         ExportToExcel ete = new ExportToExcel(); | ||||
|         DataTable dt = new DataTable(); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_VINSN", "SN/VIN"), Caption = "VIN" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_ASSETNAME", "Asset Name"), Caption = "Asset Name" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_ASSETNAME2", "Asset Name(Custom)"), Caption = "Asset Name(Custom)" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_YEAR", "Year"), Caption = "Year" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_TYPE", "Asset Type"), Caption = "Asset Type" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_MAKE", "Make"), Caption = "Make" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_MODEL", "Model"), Caption = "Model" }); | ||||
|  | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_EQCLASS", "Eq.Class"), Caption = "Eq.Class" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_DESCRIPTION", "Description"), Caption = "Description" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_URINTERVAL", "Undercarriage Replacement Interval(Hours)"), Caption = "Undercarriage Replacement Interval(Hours)" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_ACQUISITIONTYPE", "Acquisition Type"), Caption = "Acquisition Type" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_COSTCENTER", "Cost Center"), Caption = "Cost Center" }); | ||||
|  | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_HIDE", "Hide/Hidden"), Caption = "Hide/Hidden" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_ONROAD", "On-Road"), Caption = "On-Road" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_TELEMATICSENABLED", "Telematics Enabled"), Caption = "Telematics Enabled" }); | ||||
|         dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_ATTACHMENT", "Attachment"), Caption = "Attachment" }); | ||||
|         if (u.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin) | ||||
|         { | ||||
|             dt.Columns.Add(new DataColumn() { ColumnName = SystemParams.GetTextByKey(lang, "P_MA_PRELOADED", "Preloaded"), Caption = "Preloaded" }); | ||||
|         } | ||||
|  | ||||
|         if (ds != null && ds.Length > 0) | ||||
|         { | ||||
|             foreach (var r in ds) | ||||
|             { | ||||
|                 int index = 0; | ||||
|                 var dr = dt.NewRow(); | ||||
|                 dr[index] = r.VIN; | ||||
|                 dr[++index] = r.Name; | ||||
|                 dr[++index] = r.Name2; | ||||
|                 dr[++index] = r.MakeYear == -1 ? "" : r.MakeYear.ToString(); | ||||
|                 dr[++index] = r.TypeName; | ||||
|                 dr[++index] = r.MakeName; | ||||
|                 dr[++index] = r.ModelName; | ||||
|                 dr[++index] = r.EQClass; | ||||
|                 dr[++index] = r.Description; | ||||
|                 dr[++index] = r.UnderCarriageHours == null ? "" : r.UnderCarriageHours.ToString(); | ||||
|                 dr[++index] = r.AquisitionType; | ||||
|  | ||||
|                 dr[++index] = r.CostCenter; | ||||
|                 dr[++index] = r.Hidden ? "Yes" : "No"; | ||||
|                 dr[++index] = r.OnRoad ? "Yes" : "No"; | ||||
|                 dr[++index] = r.TelematicsEnabled ? "Yes" : "No"; | ||||
|                 dr[++index] = r.Attachment ? "Yes" : "No"; | ||||
|                 if (u.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin) | ||||
|                 { | ||||
|                     dr[++index] = r.Preloaded ? "Yes" : "No"; | ||||
|                 } | ||||
|                 dt.Rows.Add(dr); | ||||
|             } | ||||
|         } | ||||
|         double[] widths; | ||||
|         if (u.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin) | ||||
|         { | ||||
|             widths = new double[] { 120, 120, 150, 120, 120, 120, 120, 120, 120, 200, 120, 120, 120, 120, 160, 120, 120 }; | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             widths = new double[] { 120, 120, 150, 120, 120, 120, 120, 120, 120, 200, 120, 120, 120, 120, 160, 120 }; | ||||
|         } | ||||
|  | ||||
|         byte[] data = ete.CreateExcel(dt, null, widths, null); | ||||
|  | ||||
|         return data; | ||||
|  | ||||
|     } | ||||
|  | ||||
|     private byte[] ExportByParams(ref string title, ref string fileType) | ||||
|     { | ||||
|         string key = Request.Params["key"]; | ||||
|         string p = ExportExcelManager.GetExportParams(key); | ||||
|         if (string.IsNullOrEmpty(p)) | ||||
|             return null; | ||||
|         return ExportByParams(p, ref title, ref fileType); | ||||
|     } | ||||
|  | ||||
|     private byte[] ExportByParams(string p, ref string title, ref string fileType) | ||||
|     { | ||||
|         string[] ps = JsonConvert.DeserializeObject<string[]>(p); | ||||
|         byte[] buffer = null; | ||||
|         switch (ps[0]) | ||||
|         { | ||||
|             case "timeline": | ||||
|                 buffer = ExportAssetsTimeLine(ps, ref title, ref fileType); | ||||
|                 break; | ||||
|             case "workorders": | ||||
|                 buffer = ExportWorkOrders(ps, ref title, ref fileType); | ||||
|                 break; | ||||
|             case "manageassets": | ||||
|                 buffer = ExportManageAssets(ps, ref title, ref fileType); | ||||
|                 break; | ||||
|             case "jobsites": | ||||
|                 buffer = ExportJobSites(ps, ref title, ref fileType); | ||||
|                 break; | ||||
|             case "users": | ||||
|                 buffer = ExportUsers(ps, ref title, ref fileType); | ||||
|                 break; | ||||
|         } | ||||
|         return buffer; | ||||
|     } | ||||
|  | ||||
|     private byte[] Export(string type, ref string title, ref string fileType) | ||||
|     { | ||||
|         byte[] buffer = null; | ||||
|         switch (type) | ||||
|         { | ||||
|             case "rentals": | ||||
|                 buffer = ExportRentals(ref title, ref fileType); | ||||
|                 break; | ||||
|             case "rentalchg": | ||||
|                 buffer = ExportRentalChanges(ref title, ref fileType); | ||||
|                 break; | ||||
|             case "odoadjusthis": | ||||
|                 buffer = ExportOdometerAdjustHistory(ref title, ref fileType); | ||||
|                 break; | ||||
|             case "ehadjusthis": | ||||
|                 buffer = ExportEngineHoursAdjustHistory(ref title, ref fileType); | ||||
|                 break; | ||||
|             case "alerts": | ||||
|                 buffer = ExportAlertsManagement(ref title, ref fileType); | ||||
|                 break; | ||||
|             case "autoackhis": | ||||
|                 buffer = ExportAutoAcknowledChangeHistory(ref title, ref fileType); | ||||
|                 break; | ||||
|             case "requirements": | ||||
|                 buffer = ExportRequirements(ref title, ref fileType); | ||||
|                 break; | ||||
|             case "custrecord": | ||||
|                 buffer = ExportCustomerRecords(ref title, ref fileType); | ||||
|                 break; | ||||
|             case "assetgroups": | ||||
|                 buffer = ExportAssetGroups(ref title, ref fileType); | ||||
|                 break; | ||||
|             case "managedevices": | ||||
|                 buffer = ExportManageDevices(ref title, ref fileType); | ||||
|                 break; | ||||
|             case "maintenancerecords": | ||||
|                 buffer = ExportMaintenanceRecords(ref title, ref fileType); | ||||
|                 break; | ||||
|             case "fuelrecordmanagement": | ||||
|                 buffer = ExportFuelRecordManagement(ref title, ref fileType); | ||||
|                 break; | ||||
|             case "dispatchrequests": | ||||
|                 buffer = ExportDispatchRequests(ref title, ref fileType); | ||||
|                 break; | ||||
|             case "inspecthis": | ||||
|                 buffer = ExportInspectChanges(ref title, ref fileType); | ||||
|                 break; | ||||
|             case "wohis": | ||||
|                 buffer = ExportWorkOrderHistory(ref title, ref fileType); | ||||
|                 break; | ||||
|         } | ||||
|         return buffer; | ||||
|     } | ||||
|  | ||||
|     private byte[] ExportRentals(ref string title, ref string fileType) | ||||
|     { | ||||
|         var lang = GetLanguageCookie(); | ||||
|         title = SystemParams.GetTextByKey(lang, "P_MA_RENTAL", "Rental"); | ||||
|         string companyid = Request.Params["cid"]; | ||||
|         string mid = Request.Params["mid"]; | ||||
|         string from = Request.Params["from"]; | ||||
|         string to = Request.Params["to"]; | ||||
|         string searchtext = Request.Params["t"]; | ||||
|         searchtext = HttpUtility.HtmlDecode(searchtext); | ||||
|         string sortpath = Request.Params["sp"]; | ||||
|         bool desc = Request.Params["desc"].ToLower() == "true"; | ||||
|  | ||||
|         long machineid = 0; | ||||
|         long.TryParse(mid, out machineid); | ||||
|         DateTime fromDate = DateTime.MinValue; | ||||
|         if (!DateTime.TryParse(from, out fromDate)) | ||||
|             fromDate = DateTime.MinValue; | ||||
|         DateTime toDate = DateTime.MaxValue; | ||||
|         if (!DateTime.TryParse(to, out toDate)) | ||||
|             toDate = DateTime.MaxValue; | ||||
|         else | ||||
|             toDate = toDate.AddDays(1).AddSeconds(-1); | ||||
|  | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         var data = ExportExcelManager.ExportRentals(lang, GetCurrentLoginSession().SessionID, companyid, machineid, fromDate, toDate, searchtext, session.User.UID, sortpath, desc); | ||||
|         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "Rentals", "", "", title + ".xlsx", ".xlsx", data); | ||||
|         return data; | ||||
|     } | ||||
|  | ||||
|     private byte[] ExportRentalChanges(ref string title, ref string fileType) | ||||
|     { | ||||
|         var lang = GetLanguageCookie(); | ||||
|         title = SystemParams.GetTextByKey(lang, "P_MA_RENTALCHANGEHISTORY", "Rental Change History"); | ||||
|         string companyid = Request.Params["cid"];//CompanyID | ||||
|         string mid = Request.Params["mid"];//MachineID | ||||
|         string rid = Request.Params["rid"];//RentalID | ||||
|         string from = Request.Params["from"]; | ||||
|         string to = Request.Params["to"]; | ||||
|         string searchtext = Request.Params["t"]; | ||||
|         searchtext = HttpUtility.HtmlDecode(searchtext); | ||||
|         string sortpath = Request.Params["sp"]; | ||||
|         bool desc = Request.Params["desc"].ToLower() == "true"; | ||||
|  | ||||
|         long machineid = 0; | ||||
|         long.TryParse(mid, out machineid); | ||||
|         long rentalid = 0; | ||||
|         long.TryParse(rid, out rentalid); | ||||
|         DateTime fromDate = DateTime.MinValue; | ||||
|         if (!DateTime.TryParse(from, out fromDate)) | ||||
|             fromDate = DateTime.MinValue; | ||||
|         DateTime toDate = DateTime.MaxValue; | ||||
|         if (!DateTime.TryParse(to, out toDate)) | ||||
|             toDate = DateTime.MaxValue; | ||||
|         else | ||||
|             toDate = toDate.AddDays(1).AddSeconds(-1); | ||||
|  | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         var data = ExportExcelManager.ExportRentalChanges(lang, session.SessionID, companyid, machineid, rentalid, fromDate, toDate, searchtext, session.User.UID, sortpath, desc); | ||||
|         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "RentalChangeHistory", "", "", title + ".xlsx", ".xlsx", data); | ||||
|         return data; | ||||
|     } | ||||
|     private byte[] ExportOdometerAdjustHistory(ref string title, ref string fileType) | ||||
|     { | ||||
|         var lang = GetLanguageCookie(); | ||||
|         title = SystemParams.GetTextByKey(lang, "P_MA_ODOMETERADJUSTMENTHISTORY", "Odometer Adjustment History"); | ||||
|         string companyid = Request.Params["cid"];//CompanyID | ||||
|         string mid = Request.Params["mid"];//MachineID | ||||
|         string from = Request.Params["from"]; | ||||
|         string to = Request.Params["to"]; | ||||
|         string sortpath = Request.Params["sp"]; | ||||
|         bool desc = Request.Params["desc"].ToLower() == "true"; | ||||
|  | ||||
|         long machineid = 0; | ||||
|         long.TryParse(mid, out machineid); | ||||
|         DateTime fromDate = Helper.DBMinDateTime; | ||||
|         DateTime toDate = DateTime.MaxValue; | ||||
|         if (!DateTime.TryParse(from, out fromDate)) | ||||
|             fromDate = DateTime.MinValue; | ||||
|         if (!DateTime.TryParse(to, out toDate)) | ||||
|             toDate = DateTime.MaxValue; | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         var data = ExportExcelManager.ExportOdometerAdjustHistory(lang, session.SessionID, companyid, machineid, fromDate, toDate, sortpath, desc); | ||||
|         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "OdometerAdjustmentHistory", "", "", title + ".xlsx", ".xlsx", data); | ||||
|         return data; | ||||
|     } | ||||
|     private byte[] ExportEngineHoursAdjustHistory(ref string title, ref string fileType) | ||||
|     { | ||||
|         var lang = GetLanguageCookie(); | ||||
|         title = SystemParams.GetTextByKey(lang, "P_MA_ENGINEHOURSADJUSTMENTHISTORY", "Engine Hours Adjustment History"); | ||||
|         string companyid = Request.Params["cid"];//CompanyID | ||||
|         string mid = Request.Params["mid"];//MachineID | ||||
|         string from = Request.Params["from"]; | ||||
|         string to = Request.Params["to"]; | ||||
|         string sortpath = Request.Params["sp"]; | ||||
|         bool desc = Request.Params["desc"].ToLower() == "true"; | ||||
|  | ||||
|         long machineid = 0; | ||||
|         long.TryParse(mid, out machineid); | ||||
|         DateTime fromDate = Helper.DBMinDateTime; | ||||
|         DateTime toDate = DateTime.MaxValue; | ||||
|         if (!DateTime.TryParse(from, out fromDate)) | ||||
|             fromDate = DateTime.MinValue; | ||||
|         if (!DateTime.TryParse(to, out toDate)) | ||||
|             toDate = DateTime.MaxValue; | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         var data = ExportExcelManager.ExportEngineHoursAdjustHistory(lang, session.SessionID, companyid, machineid, fromDate, toDate, sortpath, desc); | ||||
|         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "EngineHoursAdjustmentHistory", "", "", title + ".xlsx", ".xlsx", data); | ||||
|         return data; | ||||
|     } | ||||
|  | ||||
|     private byte[] ExportAlertsManagement(ref string title, ref string fileType) | ||||
|     { | ||||
|         string tabstr = Request.Params["tab"]; | ||||
|         int tabindex = 0; | ||||
|         Int32.TryParse(tabstr, out tabindex); | ||||
|         string clientdata = Request.Params["param"]; | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         var useriid = session.User.UID; | ||||
|         var lang = GetLanguageCookie(); | ||||
|         if (tabindex == 1) | ||||
|         { | ||||
|             title = SystemParams.GetTextByKey(lang, "P_AM_ASSETVIEW", "Asset View"); | ||||
|             var data = ExportExcelManager.ExportAssetView(clientdata, session.SessionID, useriid, lang); | ||||
|             FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "AssetView", "", "", title + ".xlsx", ".xlsx", data); | ||||
|             return data; | ||||
|         } | ||||
|         else if (tabindex == 2) | ||||
|         { | ||||
|             title = SystemParams.GetTextByKey(lang, "P_AM_ACKNOWLEDGEDALERTS", "Acknowledged Alerts"); | ||||
|             var data = ExportExcelManager.ExportAcknowledgedAlerts(clientdata, session.SessionID, useriid, lang); | ||||
|             FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "AcknowledgedAlerts", "", "", title + ".xlsx", ".xlsx", data); | ||||
|             return data; | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             title = SystemParams.GetTextByKey(lang, "P_AM_ALERTVIEW", "Alert View"); | ||||
|             var data = ExportExcelManager.ExportAlertsView(clientdata, session.SessionID, useriid, lang); | ||||
|             FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "AlertView", "", "", title + ".xlsx", ".xlsx", data); | ||||
|             return data; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private byte[] ExportAutoAcknowledChangeHistory(ref string title, ref string fileType) | ||||
|     { | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         var lang = GetLanguageCookie(); | ||||
|         title = SystemParams.GetTextByKey(lang, "P_AM_AUTOACKNOWLEDGECHANGEHISTORY", "Auto-Acknowledge Change History"); | ||||
|         var data = ExportExcelManager.ExportAutoAcknowledChangeHistory(session.SessionID, session.User.UID, lang); | ||||
|         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "Auto-AcknowledgeChangeHistory", "", "", title + ".xlsx", ".xlsx", data); | ||||
|         return data; | ||||
|     } | ||||
|  | ||||
|     private byte[] ExportUsers(string[] ps, ref string title, ref string fileType) | ||||
|     { | ||||
|         var lang = GetLanguageCookie(); | ||||
|         title = SystemParams.GetTextByKey(lang, "P_USERMANAGEMENT", "User Management"); | ||||
|         string searchtext = ps[1]; | ||||
|         searchtext = HttpUtility.HtmlDecode(searchtext); | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         var data = ExportExcelManager.ExportUsers(lang, searchtext, ps[2]); | ||||
|         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "Users", "", "", title + ".xlsx", ".xlsx", data); | ||||
|         return data; | ||||
|     } | ||||
|     private byte[] ExportJobSites(string[] ps, ref string title, ref string fileType) | ||||
|     { | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         var lang = GetLanguageCookie(); | ||||
|         title = SystemParams.GetTextByKey(lang, "P_JOBSITES", "Jobsites"); | ||||
|         string searchtext = ps[1]; | ||||
|         string typesdata = ps[2]; | ||||
|         bool active = Helper.IsTrue(ps[3]); | ||||
|  | ||||
|         var data = ExportExcelManager.ExportJobSites(lang, session.SessionID, session.User.UID, searchtext, typesdata, active, ps[4]); | ||||
|         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "JobSites", "", "", title + ".xlsx", ".xlsx", data); | ||||
|         return data; | ||||
|     } | ||||
|  | ||||
|     private byte[] ExportRequirements(ref string title, ref string fileType) | ||||
|     { | ||||
|         var lang = GetLanguageCookie(); | ||||
|         title = SystemParams.GetTextByKey(lang, "P_JS_JOBSITEREQUIREMENTS", "Jobsite Requirements"); | ||||
|         string clientdata = Request.Params["param"]; | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         var data = ExportExcelManager.ExportRequirements(lang, session.SessionID, clientdata); | ||||
|         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "JobsiteRequirements", "", "", title + ".xlsx", ".xlsx", data); | ||||
|         return data; | ||||
|     } | ||||
|  | ||||
|     private byte[] ExportCustomerRecords(ref string title, ref string fileType) | ||||
|     { | ||||
|         var lang = GetLanguageCookie(); | ||||
|         title = SystemParams.GetTextByKey(lang, "P_CUSTOMERRECORD", "Customer Record"); | ||||
|         string clientdata = Request.Params["param"]; | ||||
|         var searchtext = HttpUtility.HtmlDecode(clientdata); | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         var data = ExportExcelManager.ExportCustomerRecords(lang, session.SessionID, searchtext); | ||||
|         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "CustomerRecords", "", "", title + ".xlsx", ".xlsx", data); | ||||
|         return data; | ||||
|     } | ||||
|     private byte[] ExportWorkOrders(string[] ps, ref string title, ref string fileType) | ||||
|     { | ||||
|         var lang = GetLanguageCookie(); | ||||
|         title = SystemParams.GetTextByKey(lang, "P_WORKORDER", "Work Order"); | ||||
|         string clientdata = ps[1]; | ||||
|         string layout = ps[2]; | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         var data = ExportExcelManager.ExportWorkOrders(lang, session.User, session.SessionID, clientdata, layout); | ||||
|         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "WorkOrders", "", "", title + ".xlsx", ".xlsx", data); | ||||
|         return data; | ||||
|     } | ||||
|     private byte[] ExportManageAssets(string[] ps, ref string title, ref string fileType) | ||||
|     { | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         var lang = GetLanguageCookie(); | ||||
|         title = SystemParams.GetTextByKey(lang, "P_MANAGEASSETS", "Manage Assets"); | ||||
|         string clientdata = ps[1]; | ||||
|  | ||||
|         var data = ExportExcelManager.ExportManageAssets(lang, session.SessionID, session.User.UID, clientdata, ps[2], session.User); | ||||
|         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "Assets", "", "", title + ".xlsx", ".xlsx", data); | ||||
|         return data; | ||||
|     } | ||||
|     private byte[] ExportAssetGroups(ref string title, ref string fileType) | ||||
|     { | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         var lang = GetLanguageCookie(); | ||||
|         title = SystemParams.GetTextByKey(lang, "P_ASSETGROUPS", "Asset Groups"); | ||||
|         string clientdata = Request.Params["param"]; | ||||
|         var searchtext = HttpUtility.HtmlDecode(clientdata); | ||||
|  | ||||
|         var data = ExportExcelManager.ExportAssetGroups(lang, session.SessionID, session.User.UID, searchtext); | ||||
|         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "AssetGroups", "", "", title + ".xlsx", ".xlsx", data); | ||||
|         return data; | ||||
|     } | ||||
|     private byte[] ExportManageDevices(ref string title, ref string fileType) | ||||
|     { | ||||
|         var lang = GetLanguageCookie(); | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         title = SystemParams.GetTextByKey(lang, "P_MANAGEDEVICES", "Manage Devices"); | ||||
|         string clientdata = Request.Params["param"]; | ||||
|         clientdata = HttpUtility.HtmlDecode(clientdata); | ||||
|  | ||||
|         var data = ExportExcelManager.ExportManageDevices(lang, session.SessionID, clientdata, session.User); | ||||
|         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "Devices", "", "", title + ".xlsx", ".xlsx", data); | ||||
|         return data; | ||||
|     } | ||||
|     private byte[] ExportMaintenanceRecords(ref string title, ref string fileType) | ||||
|     { | ||||
|         var lang = GetLanguageCookie(); | ||||
|         title = SystemParams.GetTextByKey(lang, "P_MAINTENANCERECORDSMANAGEMENT", "Maintenance Records Management"); | ||||
|         string clientdata = Request.Params["param"]; | ||||
|         clientdata = HttpUtility.HtmlDecode(clientdata); | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         var data = ExportExcelManager.ExportMaintenanceRecords(lang, session.SessionID, session.User.UID, clientdata); | ||||
|         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "MaintenanceRecords", "", "", title + ".xlsx", ".xlsx", data); | ||||
|         return data; | ||||
|     } | ||||
|  | ||||
|     private byte[] ExportFuelRecordManagement(ref string title, ref string fileType) | ||||
|     { | ||||
|         var lang = GetLanguageCookie(); | ||||
|         title = SystemParams.GetTextByKey(lang, "P_FUELRECORDS", "Fuel Records"); | ||||
|         string clientdata = Request.Params["t"]; | ||||
|         var searchtext = HttpUtility.HtmlDecode(clientdata); | ||||
|         string from = Request.Params["from"]; | ||||
|         string to = Request.Params["to"]; | ||||
|         string type = Request.Params["tp"]; | ||||
|         long assetid = Convert.ToInt64(HttpUtility.HtmlDecode(Request.Params["aid"])); | ||||
|  | ||||
|         DateTime beginDate = Helper.DBMinDateTime; | ||||
|         DateTime endDate = DateTime.MaxValue; | ||||
|         if (!DateTime.TryParse(from, out beginDate)) | ||||
|             beginDate = Helper.DBMinDateTime; | ||||
|         if (!DateTime.TryParse(to, out endDate)) | ||||
|             endDate = DateTime.MaxValue; | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         var data = ExportExcelManager.ExportFuelRecordManagement(lang, session.SessionID, searchtext, beginDate, endDate, type, assetid); | ||||
|         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "FuelRecords", "", "", title + ".xlsx", ".xlsx", data); | ||||
|         return data; | ||||
|     } | ||||
|  | ||||
|     private byte[] ExportDispatchRequests(ref string title, ref string fileType) | ||||
|     { | ||||
|         var lang = GetLanguageCookie(); | ||||
|         title = SystemParams.GetTextByKey(lang, "P_JS_DISPATCHREQUESTS", "Dispatch Requests"); | ||||
|         string clientdata = Request.Params["t"]; | ||||
|         var p = HttpUtility.HtmlDecode(clientdata); | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         var data = ExportExcelManager.ExportDispatchRequests(lang, session.SessionID, p); | ||||
|         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "DispatchRequests", "", "", title + ".xlsx", ".xlsx", data); | ||||
|         return data; | ||||
|     } | ||||
|  | ||||
|     private byte[] ExportInspectChanges(ref string title, ref string fileType) | ||||
|     { | ||||
|         var lang = GetLanguageCookie(); | ||||
|         title = SystemParams.GetTextByKey(lang, "P_IPT_INSPECTIONCHANGEHISTORY", "Inspection Change History"); | ||||
|         string clientdata = Request.Params["t"]; | ||||
|         var p = HttpUtility.HtmlDecode(clientdata); | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         var data = ExportExcelManager.ExportInspectChanges(lang, session.SessionID, p); | ||||
|         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "InspectionChangeHistory", "", "", title + ".xlsx", ".xlsx", data); | ||||
|         return data; | ||||
|     } | ||||
|  | ||||
|     private byte[] ExportWorkOrderHistory(ref string title, ref string fileType) | ||||
|     { | ||||
|         var lang = GetLanguageCookie(); | ||||
|         title = SystemParams.GetTextByKey(lang, "P_XXXXXX", "Work Order History"); | ||||
|  | ||||
|         string clientdata = Request.Params["t"]; | ||||
|         var searchtext = HttpUtility.HtmlDecode(clientdata); | ||||
|         string from = Request.Params["from"]; | ||||
|         string to = Request.Params["to"]; | ||||
|         long woid = Convert.ToInt64(HttpUtility.HtmlDecode(Request.Params["woid"])); | ||||
|  | ||||
|         DateTime beginDate = Helper.DBMinDateTime; | ||||
|         DateTime endDate = DateTime.MaxValue; | ||||
|         if (!DateTime.TryParse(from, out beginDate)) | ||||
|             beginDate = Helper.DBMinDateTime; | ||||
|         if (!DateTime.TryParse(to, out endDate)) | ||||
|             endDate = DateTime.MaxValue; | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         var data = ExportExcelManager.ExportWorkOrderHistory(lang, session.SessionID, "", woid, beginDate, endDate, searchtext); | ||||
|         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "WorkOrderHistory", "", "", title + ".xlsx", ".xlsx", data); | ||||
|         return data; | ||||
|     } | ||||
|  | ||||
|     private byte[] ExportAssetsTimeLine(string[] ps, ref string title, ref string fileType) | ||||
|     { | ||||
|         var lang = GetLanguageCookie(); | ||||
|         title = SystemParams.GetTextByKey(lang, "P_XXXXXX", "Time Line"); | ||||
|  | ||||
|         string cid = ps[1]; | ||||
|         long[] asseids = JsonConvert.DeserializeObject<long[]>(ps[2]); | ||||
|         string d = ps[3]; | ||||
|  | ||||
|         DateTime date = Helper.DBMinDateTime; | ||||
|         if (!DateTime.TryParse(d, out date)) | ||||
|             return null; | ||||
|         var session = GetCurrentLoginSession(); | ||||
|         var data = ExportExcelManager.ExportAssetsTimeLine(lang, session.SessionID, cid, asseids, date); | ||||
|         FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "AssetsTimeLine", "", "", title + ".xlsx", ".xlsx", data); | ||||
|         return data; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										905
									
								
								Site/FITracker.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										905
									
								
								Site/FITracker.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,905 @@ | ||||
| <%@ Page Title="" Language="C#" MasterPageFile="~/IronIntelMasterPage.master" AutoEventWireup="true" CodeFile="FITracker.aspx.cs" Inherits="FITracker" %> | ||||
|  | ||||
| <asp:Content ID="Content1" ContentPlaceHolderID="holder_head" runat="Server"> | ||||
|     <link href="css/jquery.datetimepicker.css" rel="stylesheet" /> | ||||
|     <style type="text/css"> | ||||
|         .itemselcted { | ||||
|             background-color: #ccc; | ||||
|         } | ||||
|  | ||||
|         .itemhidden { | ||||
|             display: none; | ||||
|         } | ||||
|  | ||||
|         .itemsuggested { | ||||
|             background-color: #ffff99; | ||||
|         } | ||||
|  | ||||
|         #tbMachineTypes tbody tr:hover { | ||||
|             cursor: default; | ||||
|             background: #ddd; | ||||
|         } | ||||
|  | ||||
|         #tbodyAssigned tr:hover { | ||||
|             cursor: default; | ||||
|             background: #ddd; | ||||
|         } | ||||
|  | ||||
|         #tbodyUnassigned tr:hover { | ||||
|             cursor: default; | ||||
|             background: #ddd; | ||||
|         } | ||||
|  | ||||
|         #tbodySelected tr:hover { | ||||
|             cursor: default; | ||||
|             background: #ddd; | ||||
|         } | ||||
|  | ||||
|         #contentctrl { | ||||
|             position: absolute; | ||||
|             top: 0; | ||||
|             bottom: 0; | ||||
|             left: 0; | ||||
|             right: 0; | ||||
|         } | ||||
|  | ||||
|         .float_left { | ||||
|             float: left; | ||||
|         } | ||||
|  | ||||
|         .function_bar { | ||||
|             float: right; | ||||
|         } | ||||
|  | ||||
|         .user_main { | ||||
|             padding: 0 4px; | ||||
|         } | ||||
|  | ||||
|         .dialog .dialog-title .dialog-close { | ||||
|             float: right; | ||||
|             margin-right: 6px; | ||||
|             cursor: pointer; | ||||
|         } | ||||
|  | ||||
|             .dialog .dialog-title .dialog-close:before { | ||||
|                 content: '\e600'; | ||||
|             } | ||||
|  | ||||
|         .dialog-content table { | ||||
|             border-collapse: collapse; | ||||
|             width: 100%; | ||||
|         } | ||||
|  | ||||
|             .dialog-content table td.label { | ||||
|                 width: 170px; | ||||
|                 text-align: right; | ||||
|                 padding-right: 10px; | ||||
|                 line-height: 28px; | ||||
|                 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; | ||||
|             } | ||||
|  | ||||
|         #dialog_user_randompass { | ||||
|             width: auto; | ||||
|             height: 16px; | ||||
|             margin: 3px 4px 0 4px; | ||||
|         } | ||||
|  | ||||
|         .icon { | ||||
|             font-family: CalciteWebCoreIcons; | ||||
|             cursor: default; | ||||
|         } | ||||
|  | ||||
|         .msgdiv { | ||||
|             padding-bottom: 10px; | ||||
|         } | ||||
|  | ||||
|         .msgtime { | ||||
|             padding-left: 10px; | ||||
|             padding-right: 10px; | ||||
|             margin-bottom: 2px; | ||||
|         } | ||||
|  | ||||
|         .msgself { | ||||
|             white-space: pre-wrap; | ||||
|             max-width: 240px; | ||||
|             border-radius: 5px; | ||||
|             padding-top: 8px; | ||||
|             padding-bottom: 8px; | ||||
|             padding-right: 20px; | ||||
|             padding-left: 20px; | ||||
|             display: inline-block; | ||||
|             margin-right: 10px; | ||||
|             background-color: #9eea6a; | ||||
|             text-align: left; | ||||
|         } | ||||
|  | ||||
|         .msgother { | ||||
|             white-space: pre-wrap; | ||||
|             max-width: 240px; | ||||
|             border-radius: 5px; | ||||
|             padding-top: 8px; | ||||
|             padding-bottom: 8px; | ||||
|             padding-right: 20px; | ||||
|             padding-left: 20px; | ||||
|             display: inline-block; | ||||
|             margin-left: 10px; | ||||
|             background-color: white; | ||||
|         } | ||||
|  | ||||
|         .locicon:before { | ||||
|             padding-right: 2px; | ||||
|             font-family: 'FontAwesome'; | ||||
|             color: rgb(123,28,33); | ||||
|             content: '\f3c5'; | ||||
|         } | ||||
|  | ||||
|         .jsicon:before { | ||||
|             padding-right: 2px; | ||||
|             font-family: 'FontAwesome'; | ||||
|             color: rgb(123,28,33); | ||||
|             content: '\f312'; | ||||
|         } | ||||
|  | ||||
|         .deviceitem { | ||||
|             padding-left: 15px; | ||||
|             padding-right: 10px; | ||||
|             cursor: pointer; | ||||
|             white-space: nowrap; | ||||
|             overflow: hidden; | ||||
|         } | ||||
|  | ||||
|             .deviceitem:hover { | ||||
|                 background-color: #cbcbcb; | ||||
|             } | ||||
|  | ||||
|         .deviceselected { | ||||
|             background-color: #e0e0e0; | ||||
|         } | ||||
|  | ||||
|         .dialogspanbtn { | ||||
|             font-size: 14px; | ||||
|             font-weight: normal; | ||||
|             font-family: 'CalciteWebCoreIcons', 'Fontawesome'; | ||||
|             cursor: pointer; | ||||
|             background: rgb(249, 189, 117); | ||||
|             padding: 2px; | ||||
|         } | ||||
|  | ||||
|         .dialogedit:before { | ||||
|             content: '\e61b'; | ||||
|         } | ||||
|  | ||||
|  | ||||
|         #basemapImg { | ||||
|             width: 100%; | ||||
|             height: 100%; | ||||
|             margin: 0; | ||||
|             padding: 0; | ||||
|             background-repeat: no-repeat; | ||||
|             background-position: center center; | ||||
|             -webkit-border-radius: 5px; | ||||
|             -moz-border-radius: 5px; | ||||
|             -o-border-radius: 5px; | ||||
|             border-radius: 5px; | ||||
|         } | ||||
|  | ||||
|         #basemapTitle { | ||||
|             position: absolute; | ||||
|             z-index: 2; | ||||
|             bottom: 0px; | ||||
|             width: 90%; | ||||
|             color: #4c4c4c; | ||||
|             margin: 0; | ||||
|             font-size: 10px; | ||||
|             line-height: 12px; | ||||
|             display: block; | ||||
|             padding: 2px 5%; | ||||
|             background: #fff; | ||||
|             background: rgba(255, 255, 255, 0.80); | ||||
|             -webkit-border-radius: 0 0 5px 5px; | ||||
|             -moz-border-radius: 0 0 5px 5px; | ||||
|             -o-border-radius: 0 0 5px 5px; | ||||
|             border-radius: 0 0 5px 5px; | ||||
|             text-align: center; | ||||
|         } | ||||
|  | ||||
|         #basemapgalleryDiv { | ||||
|             position: absolute; | ||||
|             right: 15px; | ||||
|             top: 35px; | ||||
|             z-index: 199; | ||||
|             background-color: #EFEFEF; | ||||
|             height: 75px; | ||||
|             width: 75px; | ||||
|             border: solid 1px #57585A; | ||||
|             border-radius: 5px; | ||||
|             padding: 1px; | ||||
|         } | ||||
|  | ||||
|         #basemapGallery { | ||||
|             position: absolute; | ||||
|             right: 15px; | ||||
|             top: 35px; | ||||
|             width: 370px; | ||||
|             height: 120px; | ||||
|             overflow: auto; | ||||
|             display: none; | ||||
|             z-index: 200; | ||||
|             background-color: #EFEFEF; | ||||
|         } | ||||
|     </style> | ||||
|     <link rel="stylesheet" type="text/css" href="css/spectrum.css?v=1" /> | ||||
|     <script src="js/spectrum.js?v=1" type="text/javascript"></script> | ||||
|     <script src="js/jquery.datetimepicker.full.js"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("js/vue.min.js")%>"></script> | ||||
|     <script>Vue.config.productionTip = false; Vue.config.silent = true;</script> | ||||
|     <link rel="stylesheet" href="https://js.arcgis.com/3.40/esri/css/esri.css" /> | ||||
|     <script src="https://js.arcgis.com/3.40"></script> | ||||
|     <script> | ||||
|         _network.trackerquery = function (method, param, callback, error, nolog) { | ||||
|             _network.request("FITracker.aspx?tp=ashx", -1, method, param, callback, error, nolog); | ||||
|         } | ||||
|  | ||||
|         var _allDevices; | ||||
|         var deviceid; | ||||
|         var assetid; | ||||
|         var lastmsgid = -1; | ||||
|         var devicevm; | ||||
|         var deviceinfovm; | ||||
|  | ||||
|         function OnRefresh() { | ||||
|             showloading(true); | ||||
|             _network.trackerquery("GetTrackers", "", function (data) { | ||||
|                 showloading(false); | ||||
|                 _allDevices = data; | ||||
|                 showDeviceList(_allDevices); | ||||
|             }, function (err) { | ||||
|                 showloading(false); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function showDeviceList(data) { | ||||
|             for (var i = 0; i < data.length; i++) { | ||||
|                 var r = data[i]; | ||||
|                 for (var j in r) { | ||||
|                     if (j === "DeviceName" && r["DeviceName"] === "") { | ||||
|                         r["DeviceName"] = r["DeviceID"]; | ||||
|                         break; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             //devicevm.reload([]); | ||||
|             devicevm.reload(data); | ||||
|         } | ||||
|  | ||||
|         function deviceChanged(e, newevice) { | ||||
|             var t = $(e.target); | ||||
|             t.parent().parent().find(".deviceselected").removeClass("deviceselected"); | ||||
|             t.addClass("deviceselected"); | ||||
|             if (newevice) { | ||||
|                 deviceid = newevice.DeviceID; | ||||
|                 assetid = newevice.AssetID; | ||||
|                 lastmsgid = -1; | ||||
|                 $("#msgctrl").empty(); | ||||
|                 loadTracker(); | ||||
|                 deviceinfovm.reload(newevice); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function OnEditAccuracy() { | ||||
|             if (deviceid == undefined || deviceid <= 0) return; | ||||
|             $('#mask_bg').show(); | ||||
|             $('#dialog_accuracy') | ||||
|                 .attr('act', 'add') | ||||
|                 .css({ | ||||
|                     'top': (document.documentElement.clientHeight - $('#dialog_accuracy').height()) / 3, | ||||
|                     'left': (document.documentElement.clientWidth - $('#dialog_accuracy').width()) / 2 | ||||
|                 }) | ||||
|                 .showDialog(); | ||||
|             $('#dialog_accuracyvalue').val($("#txtAccuracy").val()).select(); | ||||
|         } | ||||
|  | ||||
|         function SaveAccuracy() { | ||||
|             if (deviceid == undefined || deviceid <= 0) return; | ||||
|  | ||||
|             var accuracy = $("#dialog_accuracyvalue").val(); | ||||
|             if (accuracy !== "" && isNaN(accuracy)) { | ||||
|                 showAlert(GetTextByKey("P_M3_ACCURACYFORMATERROR", 'Accuracy format error.'), GetTextByKey("P_M3_EDITACCURACY", "Edit Accuracy")); | ||||
|                 return false; | ||||
|             } | ||||
|             if (eval(accuracy) < 0) { | ||||
|                 showAlert(GetTextByKey("P_M3_ACCURACYCANNOTBELESSTHAN0", 'Accuracy cannot be less than 0.'), GetTextByKey("P_M3_EDITACCURACY", "Edit Accuracy")); | ||||
|                 return false; | ||||
|             } | ||||
|             var note = $.trim($('#dialog_accuracynote').val()); | ||||
|  | ||||
|             var param = JSON.stringify([deviceid, accuracy, note]); | ||||
|             param = htmlencode(param); | ||||
|             _network.trackerquery("ChangeAcceptableAccuracy", param, function (data) { | ||||
|                 if (data !== '') { | ||||
|                     showAlert(data, GetTextByKey("P_M3_SENDMESSAGE", 'Send Message')); | ||||
|                 } | ||||
|                 else { | ||||
|                     $("#txtAccuracy").val(accuracy); | ||||
|                     deviceinfovm.device.AcceptableAccuracy = accuracy; | ||||
|                     $('#mask_bg').hide(); | ||||
|                     $('#dialog_accuracy').hideDialog(); | ||||
|                 } | ||||
|             }, function (err) { | ||||
|                 showAlert(GetTextByKey("P_M3_FAILEDTOSENDMESSAGE", 'Failed to send message.'), GetTextByKey("P_M3_SENDMESSAGE", 'Send Message')); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function loadTracker() { | ||||
|             getMessages(); | ||||
|             execIframeFunc("reloaddata", [assetid, ""], "iframemachine"); | ||||
|         } | ||||
|  | ||||
|         var gettingmsgdeviceid = undefined; | ||||
|         function getMessages() { | ||||
|             if (deviceid == undefined || deviceid < 0 || gettingmsgdeviceid == deviceid) | ||||
|                 return; | ||||
|             gettingmsgdeviceid = deviceid; | ||||
|             let tempdeviceid = deviceid; | ||||
|             var param = JSON.stringify([deviceid, lastmsgid]); | ||||
|             _network.trackerquery("GetMessages", param, function (data) { | ||||
|                 if (typeof data === 'string') { | ||||
|                     //showAlert(data, 'Get Messages'); | ||||
|                 } | ||||
|                 else { | ||||
|                     if (data.length > 0) { | ||||
|                         if (tempdeviceid !== deviceid) | ||||
|                             return; | ||||
|                         for (var i = 0; i < data.length; i++) { | ||||
|                             var msg = data[i]; | ||||
|                             if (lastmsgid >= msg.ID) | ||||
|                                 continue; | ||||
|                             showMessage(msg); | ||||
|                             lastmsgid = msg.ID; | ||||
|                         } | ||||
|  | ||||
|                         var scrollHeight = $('#msgctrl').prop("scrollHeight"); | ||||
|                         $('#msgctrl').animate({ scrollTop: scrollHeight }, 400); | ||||
|                     } | ||||
|                 } | ||||
|                 gettingmsgdeviceid = undefined; | ||||
|             }, function (err) { | ||||
|                 gettingmsgdeviceid = undefined; | ||||
|                 //showAlert('Failed to get messages.', 'Get Messages'); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function postMessage(msg, type) { | ||||
|             if (deviceid == undefined || deviceid <= 0) return; | ||||
|             var param = JSON.stringify([deviceid, msg, type]); | ||||
|             param = htmlencode(param); | ||||
|             let tempdeviceid = deviceid; | ||||
|             _network.trackerquery("PostMessage", param, function (data) { | ||||
|                 if (typeof data === 'string') { | ||||
|                     showAlert(data, GetTextByKey("P_M3_SENDMESSAGE", 'Send Message')); | ||||
|                 } | ||||
|                 else { | ||||
|                     var msg = data; | ||||
|                     if (tempdeviceid !== deviceid) | ||||
|                         return; | ||||
|                     if (lastmsgid >= msg.ID) | ||||
|                         return; | ||||
|                     showMessage(msg); | ||||
|                     lastmsgid = msg.ID; | ||||
|  | ||||
|                     var scrollHeight = $('#msgctrl').prop("scrollHeight"); | ||||
|                     $('#msgctrl').animate({ scrollTop: scrollHeight }, 400); | ||||
|                 } | ||||
|             }, function (err) { | ||||
|                 showAlert(GetTextByKey("P_M3_FAILEDTOSENDMESSAGE", 'Failed to send message.'), GetTextByKey("P_M3_SENDMESSAGE", 'Send Message')); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function sendMessage() { | ||||
|             var msg = $("#txtmsg").val(); | ||||
|             if ($.trim(msg) === "") { | ||||
|                 showAlert(GetTextByKey("P_M3_MESSAGECANNOTBEEMPTY", 'Message cannot be empty.'), GetTextByKey("P_M3_SENDMESSAGE", 'Send Message')); | ||||
|                 return; | ||||
|             } | ||||
|             $("#txtmsg").val("").focus(); | ||||
|             //showMessage(msg, true); | ||||
|             postMessage(msg, 0); | ||||
|         } | ||||
|  | ||||
|         function showMessage(msg) { | ||||
|             var msgctrl = $("#msgctrl"); | ||||
|             var div = $("<div class='msgdiv'></div>").appendTo(msgctrl); | ||||
|             $("<div class='msgtime'></div>").text(msg.SenderName + " " + msg.TimeText).appendTo(div); | ||||
|             var contentctrl = $("<div></div>").appendTo(div); | ||||
|             if (msg.MessageType === 1 | msg.MessageType === 2) { | ||||
|                 var lat = 0; | ||||
|                 var lng = 0; | ||||
|                 var text = ""; | ||||
|                 var index = msg.TextMessage.indexOf(","); | ||||
|                 if (index > 0) | ||||
|                     lat = eval(msg.TextMessage.substring(0, index)); | ||||
|                 var index1 = msg.TextMessage.indexOf(",", index + 1); | ||||
|                 if (index1 > 0) { | ||||
|                     lng = eval(msg.TextMessage.substring(index + 1, index1)); | ||||
|                     text = msg.TextMessage.substring(index1 + 1); | ||||
|                 } | ||||
|                 if (msg.MessageType === 1) { | ||||
|                     contentctrl.append($("<span class='jsicon'></span>")); | ||||
|                 } | ||||
|                 else if (msg.MessageType === 2) { | ||||
|                     contentctrl.append($("<span class='locicon'></span>")); | ||||
|                 } | ||||
|                 contentctrl.css("padding-left", 10); | ||||
|                 var js = $("<a href='javascript:void(0);'></a>").text(text); | ||||
|                 contentctrl.append(js); | ||||
|             } | ||||
|             else | ||||
|                 contentctrl.text(msg.TextMessage); | ||||
|             if (msg.IsSelf) { | ||||
|                 contentctrl.addClass("msgself"); | ||||
|                 div.css("text-align", "right"); | ||||
|             } | ||||
|             else | ||||
|                 contentctrl.addClass("msgother"); | ||||
|         } | ||||
|  | ||||
|         function getJobsites() { | ||||
|             _network.trackerquery("GetJobsites", [], function (data) { | ||||
|                 if (typeof data !== 'string') { | ||||
|                     var seljs = $("#selJobsites"); | ||||
|                     for (var i in data) { | ||||
|                         var js = data[i]; | ||||
|                         seljs.append($('<option></option>') | ||||
|                             .attr('value', js.ID) | ||||
|                             .text(js.Name).data("jsobj", js)); | ||||
|                     } | ||||
|                 } | ||||
|             }, function (err) { | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         function sendJobsite() { | ||||
|             $('#jobsitectrl').show(); | ||||
|         } | ||||
|  | ||||
|         function sendJobsiteMessage() { | ||||
|             var seljs = $("#selJobsites"); | ||||
|             var selItem = seljs.find("option:selected"); | ||||
|             var js = selItem ? selItem.data("jsobj") : null; | ||||
|             if (js) { | ||||
|                 var msg = ""; | ||||
|                 msg += js.Latitude + ","; | ||||
|                 msg += js.Longitude + ","; | ||||
|                 msg += js.Name; | ||||
|                 postMessage(msg, 1); | ||||
|             } | ||||
|             $('#jobsitectrl').hide(); | ||||
|         } | ||||
|  | ||||
|         function sendLocation() { | ||||
|             $('#mask_bg').show(); | ||||
|             $('#dialog_map') | ||||
|                 .attr('act', 'add') | ||||
|                 .css({ | ||||
|                     'top': (document.documentElement.clientHeight - $('#dialog_map').height()) / 3, | ||||
|                     'left': (document.documentElement.clientWidth - $('#dialog_map').width()) / 2 | ||||
|                 }) | ||||
|                 .showDialog(); | ||||
|         } | ||||
|  | ||||
|         function sendLocationMessage() { | ||||
|             var latitude = $('#maplatude').text(); | ||||
|             var longitude = $('#maplongitude').text(); | ||||
|             if (latitude !== "" && longitude !== "") { | ||||
|                 var msg = ""; | ||||
|                 msg += latitude + ","; | ||||
|                 msg += longitude + ","; | ||||
|                 msg += "Location"; | ||||
|                 postMessage(msg, 2); | ||||
|                 $('#dialog_map').hideDialog(); | ||||
|                 $('#mask_bg').hide(); | ||||
|             } | ||||
|             else { | ||||
|                 showAlert(GetTextByKey("P_M3_PLEASESELECTALOCATIONTOSENDTO", 'Please select a location to send to.'), GetTextByKey("P_M3_SENDLOCATION", 'Send Location')); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|  | ||||
|         /*地图相关*/ | ||||
|         var polygonitem = []; | ||||
|         var machineGraphics = []; | ||||
|         var isMapLoaded = false; | ||||
|         var isLoadingMap = false; | ||||
|         var mapObj; | ||||
|         var graphicLayer = undefined; | ||||
|         var BasePointLayer = undefined; | ||||
|         var BasePolygonLayer = undefined | ||||
|         var DrawPolygonLayer = undefined | ||||
|         var TransportationLayer = undefined | ||||
|         var GraphicC = undefined; | ||||
|         var PointC = undefined; | ||||
|         var PictureMarkerSymbolC = undefined; | ||||
|         var UnitsC = undefined; | ||||
|         var CircleC = undefined; | ||||
|         var SimpleFillSymbolC = undefined; | ||||
|         var ExtentC = undefined; | ||||
|         var DrawC = undefined; | ||||
|         var toolbar = undefined; | ||||
|         var PolygonC = undefined; | ||||
|         var BasemapGalleryC = undefined; | ||||
|  | ||||
|         function loadMap() { | ||||
|             require(["esri/map", "esri/graphic", "esri/geometry/Point", "esri/symbols/PictureMarkerSymbol", "esri/units", | ||||
|                 "esri/geometry/Circle", "esri/symbols/SimpleFillSymbol", "esri/geometry/Extent", "esri/toolbars/draw", "esri/symbols/SimpleMarkerSymbol", | ||||
|                 "esri/symbols/SimpleLineSymbol", "esri/symbols/SimpleFillSymbol", "esri/geometry/Polygon", "esri/dijit/BasemapGallery", "esri/layers/ArcGISTiledMapServiceLayer"], | ||||
|                 function (Map, Graphic, Point, PictureMarkerSymbol, Units, Circle, SimpleFillSymbol, Extent, Draw, SimpleMarkerSymbol, | ||||
|                     SimpleLineSymbol, SimpleFillSymbol, Polygon, BasemapGallery, ArcGISTiledMapServiceLayer) { | ||||
|                     MapC = Map; | ||||
|                     GraphicC = Graphic; | ||||
|                     PointC = Point; | ||||
|                     PictureMarkerSymbolC = PictureMarkerSymbol; | ||||
|                     UnitsC = Units; | ||||
|                     CircleC = Circle; | ||||
|                     SimpleFillSymbolC = SimpleFillSymbol; | ||||
|                     ExtentC = Extent; | ||||
|                     DrawC = Draw; | ||||
|                     PolygonC = Polygon; | ||||
|                     BasemapGalleryC = BasemapGallery; | ||||
|                     mapObj = new MapC("mapdiv", { | ||||
|                         basemap: "topo", | ||||
|                         center: [-128.694315, 42.202091], // longitude, latitude | ||||
|                         zoom: 4 | ||||
|                     }); | ||||
|  | ||||
|                     dojo.connect(mapObj, "onClick", showCoordinates); | ||||
|                     $('div.esriControlsBR').remove(); | ||||
|                     graphicLayer = new esri.layers.GraphicsLayer(); | ||||
|                     mapObj.addLayer(graphicLayer); | ||||
|                     BasePointLayer = new esri.layers.GraphicsLayer(); | ||||
|                     mapObj.addLayer(BasePointLayer); | ||||
|                     BasePolygonLayer = new esri.layers.GraphicsLayer(); | ||||
|                     mapObj.addLayer(BasePolygonLayer); | ||||
|  | ||||
|                     DrawPolygonLayer = new esri.layers.GraphicsLayer(); | ||||
|                     mapObj.addLayer(DrawPolygonLayer); | ||||
|  | ||||
|                     TransportationLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/arcgis/rest/services/Reference/World_Transportation/MapServer"); | ||||
|  | ||||
|                     // create a toolbar for the map | ||||
|                     //toolbar = new DrawC(mapObj); | ||||
|                     //toolbar.on("draw-complete", completeshape); | ||||
|  | ||||
|                     initBasemapGallery(mapObj); | ||||
|  | ||||
|                     isLoadingMap = false; | ||||
|                     isMapLoaded = true; | ||||
|                 }); | ||||
|         } | ||||
|  | ||||
|         function initBasemapGallery(map) { | ||||
|             $(window).click(function (e) { | ||||
|                 if ($(e.target).attr("id") != "basemapImg") | ||||
|                     $("#basemapGallery").hide(); | ||||
|             }); | ||||
|             var basemap = "topo"; | ||||
|             $("#basemapImg").css("background-image", "url('https://js.arcgis.com/3.40/esri/images/basemap/topo.jpg')"); | ||||
|             $("#basemapTitle").text(GetTextByKey("P_MAP_TOPOGRAPHIC", "Topographic")); | ||||
|  | ||||
|             var basemapGallery = new BasemapGalleryC({ | ||||
|                 showArcGISBasemaps: false, | ||||
|                 map: map | ||||
|             }, "basemapGallery"); | ||||
|  | ||||
|  | ||||
|             var satellitemap = new esri.dijit.Basemap({ | ||||
|                 layers: [new esri.dijit.BasemapLayer({ | ||||
|                     url: "http://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer" | ||||
|                 })], | ||||
|                 title: GetTextByKey("P_MAP_IMAGERY", "Imagery"), | ||||
|                 thumbnailUrl: "https://js.arcgis.com/3.40/esri/images/basemap/satellite.jpg" | ||||
|             }); | ||||
|             basemapGallery.add(satellitemap); | ||||
|  | ||||
|             var topomap = new esri.dijit.Basemap({ | ||||
|                 layers: [new esri.dijit.BasemapLayer({ | ||||
|                     url: "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" | ||||
|                 })], | ||||
|                 title: GetTextByKey("P_MAP_TOPOGRAPHIC", "Topographic"), | ||||
|                 thumbnailUrl: "https://js.arcgis.com/3.40/esri/images/basemap/topo.jpg" | ||||
|             }); | ||||
|             basemapGallery.add(topomap); | ||||
|  | ||||
|             var streetmap = new esri.dijit.Basemap({ | ||||
|                 layers: [new esri.dijit.BasemapLayer({ | ||||
|                     //type: "OpenStreetMap", | ||||
|                     url: "http://server.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer" | ||||
|                 })], | ||||
|                 title: GetTextByKey("P_MAP_STREETS", "Streets"), | ||||
|                 thumbnailUrl: "https://js.arcgis.com/3.40/esri/images/basemap/streets.jpg" | ||||
|  | ||||
|             }); | ||||
|             basemapGallery.add(streetmap); | ||||
|  | ||||
|             basemapGallery.startup(); | ||||
|  | ||||
|             basemapGallery.on("selection-change", function () { | ||||
|                 var basemap = basemapGallery.getSelected(); | ||||
|                 if (basemap) { | ||||
|                     if (basemap.title == "Imagery") | ||||
|                         map.addLayer(TransportationLayer); | ||||
|                     else | ||||
|                         map.removeLayer(TransportationLayer); | ||||
|                     $("#basemapImg").css("background-image", "url('" + basemap.thumbnailUrl + "')"); | ||||
|                     $("#basemapTitle").text(basemap.title); | ||||
|                 } | ||||
|                 $("#basemapGallery").hide(); | ||||
|             }); | ||||
|  | ||||
|             basemapGallery.on("error", function (msg) { | ||||
|                 console.log("basemap gallery error:  ", msg); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function showCoordinates(evt) { | ||||
|             if (evt) { | ||||
|                 var mp = evt.mapPoint; | ||||
|                 $("#mapLocation").css("display", "block"); | ||||
|                 $('#maplatude').text(mp.getLatitude().toFixed(6)); | ||||
|                 $('#maplongitude').text(mp.getLongitude().toFixed(6)); | ||||
|             } | ||||
|  | ||||
|             locateJobSite(); | ||||
|         } | ||||
|  | ||||
|         function locateJobSite(isopen) { | ||||
|             var latitude = parseFloat($('#maplatude').text()); | ||||
|             var longitude = parseFloat($('#maplongitude').text()); | ||||
|             if (latitude == 0 && longitude == 0) return; | ||||
|             var point = new esri.geometry.Point({ | ||||
|                 latitude: latitude, | ||||
|                 longitude: longitude | ||||
|             }); | ||||
|             if (isopen) { | ||||
|                 mapObj.centerAndZoom(point, 3); | ||||
|             } | ||||
|             var symbol = new esri.symbol.TextSymbol({ | ||||
|                 color: [0xf7, 0xc0, 0x03],//#f7c003 | ||||
|                 haloColor: "black", | ||||
|                 haloSize: "1px", | ||||
|                 text: "\ue61d", | ||||
|                 xoffset: 3, | ||||
|                 yoffset: 3, | ||||
|                 font: {  // autocast as esri/symbols/Font | ||||
|                     size: 32, | ||||
|                     family: "CalciteWebCoreIcons", | ||||
|                     weight: "bolder" | ||||
|                 } | ||||
|             }); | ||||
|             graphicLayer.clear(); | ||||
|             var graphic = new esri.Graphic(point, symbol); | ||||
|             graphicLayer.add(graphic); | ||||
|         } | ||||
|  | ||||
|         $(function () { | ||||
|             setPageTitle(GetTextByKey("P_M3", 'M3'), true); | ||||
|             setFavoriteDisplay(true, 500); | ||||
|  | ||||
|             setInterval(getMessages, 5 * 1000);//定时获取消息 | ||||
|             getJobsites(); | ||||
|  | ||||
|             devicevm = new Vue({ | ||||
|                 el: '#devicelist', | ||||
|                 data: { | ||||
|                     devices: [] | ||||
|                 }, | ||||
|                 methods: { | ||||
|                     reload: function (data) { | ||||
|                         this.devices = data; | ||||
|                     }, | ||||
|                     deviceClick: function (e, d) { | ||||
|                         deviceChanged(e, d); | ||||
|                     } | ||||
|                 } | ||||
|             }); | ||||
|  | ||||
|             deviceinfovm = new Vue({ | ||||
|                 el: '#deviceinfo', | ||||
|                 data: { | ||||
|                     device: {} | ||||
|                 }, | ||||
|                 methods: { | ||||
|                     reload: function (data) { | ||||
|                         this.device = data; | ||||
|                     } | ||||
|                 } | ||||
|             }); | ||||
|  | ||||
|             $('#dialog_map').dialog(function () { | ||||
|                 $('#mask_bg').hide(); | ||||
|             }); | ||||
|  | ||||
|             $('#dialog_accuracy').dialog(function () { | ||||
|                 $('#mask_bg').hide(); | ||||
|             }); | ||||
|  | ||||
|             loadMap(); | ||||
|             $("#basemapgalleryDiv").click(null, function (e) { | ||||
|                 $("#basemapGallery").show(); | ||||
|             }); | ||||
|  | ||||
|             $(window).resize(function () { | ||||
|                 //$("#devicelist").css("height", $(window).height() - $("#devicelist").offset().top - 4); | ||||
|                 //grid_dt && grid_dt.resize(); | ||||
|                 //$("#rightctrl").css("height", $(window).height() - $("#rightctrl").offset().top - 4) | ||||
|                 //    .css("width", $(window).width() - 250); | ||||
|             }).resize(); | ||||
|  | ||||
|             $(document).mousedown(function (e) { | ||||
|                 var jsctrl = $('#jobsitectrl'); | ||||
|                 var t = $(e.target); | ||||
|                 if (!t.is(jsctrl) | ||||
|                     && !t.parent().is(jsctrl) | ||||
|                     && !t.parent().parent().is(jsctrl) | ||||
|                     && !t.is($("#btnSendJobsite"))) | ||||
|                     jsctrl.hide(); | ||||
|             }); | ||||
|  | ||||
|             OnRefresh(); | ||||
|         }); | ||||
|  | ||||
|     </script> | ||||
| </asp:Content> | ||||
| <asp:Content ID="Content2" ContentPlaceHolderID="holder_content" runat="Server"> | ||||
|     <div> | ||||
|         <div id="contentctrl"> | ||||
|             <div class="page_title" data-lgid="P_M3">M3</div> | ||||
|             <div class="function_title"> | ||||
|                 <%--<span class="sbutton iconadd" onclick="OnAdd();">Add</span>--%> | ||||
|                 <span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_M3_REFRESH">Refresh</span> | ||||
|             </div> | ||||
|             <div> | ||||
|                 <div id="devicelist" style="position: absolute; width: 240px; left: 5px; top: 75px; bottom: 5px; line-height: 30px; border: 1px solid gray;"> | ||||
|                     <div style="margin-left: 7px; font-size: 14px; font-weight: bold;" data-lgid="P_M3_DEVICES">Devices</div> | ||||
|                     <div v-for="device in devices"> | ||||
|                         <div class='deviceitem' v-on:click="deviceClick($event,device)" v-bind:title="device.DeviceName">{{device.DeviceName}}</div> | ||||
|                     </div> | ||||
|                 </div> | ||||
|                 <div id="rightctrl" style="position: absolute; top: 75px; left: 250px; right: 0px; bottom: 0px;"> | ||||
|                     <div id="deviceinfo" style="border: 1px solid gray; height: 60px; line-height: 24px; min-width: 1100px;"> | ||||
|                         <table> | ||||
|                             <tr> | ||||
|                                 <td style="text-align: right;"><b data-lgid="P_M3_DEVICEID_COLON">Device ID:</b></td> | ||||
|                                 <td style="min-width: 140px;">{{device.DeviceID}}</td> | ||||
|                                 <td style="text-align: right; padding-left: 10px;"><b data-lgid="P_M3_DEVICENAME_COLON">Device Name:</b></td> | ||||
|                                 <td style="min-width: 140px;">{{device.DeviceName}}</td> | ||||
|                                 <td style="text-align: right; padding-left: 10px;"><b data-lgid="P_M3_DEVICETYPE_COLON">Device Type:</b></td> | ||||
|                                 <td style="min-width: 120px;">{{device.DeviceType}}</td> | ||||
|                                 <td style="text-align: right; padding-left: 10px;"><b data-lgid="P_M3_ACCURACY_COLON">Accuracy:</b></td> | ||||
|                                 <td style="min-width: 120px; white-space: nowrap;"> | ||||
|                                     <input type="text" id="txtAccuracy" v-model="device.AcceptableAccuracy" maxlength="8" tabindex="14" style="width: 120px;" disabled="disabled" /> | ||||
|                                     <span id="spanEditAccuracy" class="dialogspanbtn dialogedit" title="Edit Accuracy" data-title-lgid="P_M3_EDITACCURACY" onclick="OnEditAccuracy();"></span></td> | ||||
|                             </tr> | ||||
|                             <tr> | ||||
|                                 <td style="text-align: right;"><b data-lgid="P_M3_ASSETNAME_COLON">Asset Name:</b></td> | ||||
|                                 <td>{{device.Name}}</td> | ||||
|                                 <td style="text-align: right; padding-left: 10px;"><b data-lgid="P_M3_MAKE_COLON">Make:</b></td> | ||||
|                                 <td>{{device.Make}}</td> | ||||
|                                 <td style="text-align: right; padding-left: 10px;"><b data-lgid="P_M3_MODEL_COLON">Model:</b></td> | ||||
|                                 <td>{{device.Model}}</td> | ||||
|                                 <td style="text-align: right; padding-left: 10px;"><b data-lgid="P_M3_TYPE_COLON">Type:</b></td> | ||||
|                                 <td>{{device.Type}}</td> | ||||
|                             </tr> | ||||
|                         </table> | ||||
|                     </div> | ||||
|                     <div style="position: absolute; top: 65px; bottom: 5px; border: 1px solid gray; width: 400px;"> | ||||
|                         <div id="msgctrl" style="position: absolute; top: 0px; bottom: 158px; width: 100%; background-color: #e5e5e5; overflow: auto;"></div> | ||||
|                         <table style="position: absolute; bottom: 5px; width: 100%; border-collapse: collapse; border-spacing: 0;"> | ||||
|                             <tr style="height: 120px;"> | ||||
|                                 <td> | ||||
|                                     <textarea id="txtmsg" style="width: 392px; height: 118px; resize: none;"></textarea> | ||||
|                                 </td> | ||||
|                             </tr> | ||||
|                             <tr style="height: 30px;"> | ||||
|                                 <td style="text-align: right; position: relative;"> | ||||
|                                     <div> | ||||
|                                         <input id="btnSendLocation" type="button" value="Send Location" data-lgid="P_M3_SENDLOCATION" style="margin-right: 10px;" onclick="sendLocation();" /> | ||||
|                                         <input id="btnSendJobsite" type="button" value="Send Jobsite" data-lgid="P_M3_SENDJOBSITE" style="margin-right: 10px;" onclick="sendJobsite();" /> | ||||
|                                         <input type="button" value="Send" data-lgid="P_M3_SEND" style="margin-right: 10px;" onclick="sendMessage();" /> | ||||
|                                         <div id="jobsitectrl" style="position: absolute; background-color: #d2d2d2; top: -40px; right: 62px; padding-top: 10px; padding-bottom: 10px; padding-right: 5px; padding-left: 5px; display: none;"> | ||||
|                                             <select id="selJobsites" style="min-width: 120px; max-height: 280px;"> | ||||
|                                             </select> | ||||
|                                             <input type="button" value="Send" data-lgid="P_M3_SEND" style="margin-left: 5px;" onclick="sendJobsiteMessage();" /> | ||||
|                                         </div> | ||||
|                                     </div> | ||||
|                                 </td> | ||||
|                             </tr> | ||||
|                         </table> | ||||
|                     </div> | ||||
|                     <div style="position: absolute; top: 65px; bottom: 10px; left: 405px; right: 1px; border: 1px solid gray; min-width: 690px;"> | ||||
|                         <iframe id="iframemachine" src="MapViewChart.aspx?ds=FITRACKER" style="width: 100%; height: 100%; display: block; border: none;"></iframe> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|  | ||||
|         <div id="dialogmask" class="maskbg" style="display: none;"> | ||||
|             <div class="loading_icon icon c-spin"></div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
|     <div id="mask_bg"> | ||||
|         <div class="loading c-spin"></div> | ||||
|     </div> | ||||
|     <div class="dialog" id="dialog_map" style="width: 1200px; display: none;"> | ||||
|         <div class="dialog-title"><span class="title" data-lgid="P_M3_SENDLOCATION">Send Location</span><em class="dialog-close"></em></div> | ||||
|  | ||||
|         <div class="dialog-content"> | ||||
|             <div style="float: left; margin-left: 5px; margin-top: -5px;"> | ||||
|                 <div id="mapdiv" style="width: 1180px; height: 540px; background-color: Window;"> | ||||
|                 </div> | ||||
|                 <div id="basemapgalleryDiv"> | ||||
|                     <div id="basemapImg"></div> | ||||
|                     <div id="basemapTitle"></div> | ||||
|                 </div> | ||||
|                 <div id="basemapGallery"></div> | ||||
|  | ||||
|                 <div id="mapLocation" class="dialog-func" style="float: left; display: none;"> | ||||
|                     <span style="margin-left: 5px;" data-lgid="P_M3_LATITUDE_COLON">Latitude: </span> | ||||
|                     <label id="maplatude"></label> | ||||
|                     <span data-lgid="P_M3_LONGITUDE_COLON">  Longitude: </span><label id="maplongitude"></label> | ||||
|                 </div> | ||||
|  | ||||
|                 <div class="dialog-func" style="float: right;"> | ||||
|                     <input type="button" class="dialog-close" style="height: 24px;" value="Cancel" data-lgid="P_M3_CANCEL" tabindex="13" /> | ||||
|                     <input type="button" onclick="sendLocationMessage();" style="height: 24px; width: unset;" value="Send" data-lgid="P_M3_SEND" tabindex="12" /> | ||||
|                     <div class="clear"></div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
|     <div id="dialog_accuracy" class="dialog" style="display: none;"> | ||||
|         <div class="dialog-title"><span class="title" id="popupTitle" data-lgid="P_M3_EDITACCURACY">Edit Accuracy</span><em class="dialog-close"></em></div> | ||||
|         <div class="dialog-content"> | ||||
|             <table style="line-height: 30px;"> | ||||
|                 <tr> | ||||
|                     <td class="label" style="width: 100px;" data-lgid="P_M3_ACCURACY">Accuracy</td> | ||||
|                     <td> | ||||
|                         <input type="text" id="dialog_accuracyvalue" maxlength="100" tabindex="50" style="width: 240px;" /></td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td class="label" style="width: 100px;" data-lgid="P_M3_NOTE_COLON">Note:</td> | ||||
|                     <td> | ||||
|                         <textarea id="dialog_accuracynote" class="inputbox" maxlength="1000" tabindex="51" style="width: 240px; height: 100px; max-width: unset;"></textarea> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|             </table> | ||||
|         </div> | ||||
|  | ||||
|         <div class="dialog-func"> | ||||
|             <input type="button" value="Cancel" data-lgid="P_M3_CANCEL" class="dialog-close" tabindex="53" style="margin-right: 30px;" /> | ||||
|             <input type="button" onclick="SaveAccuracy();" value="OK" data-lgid="P_M3_OK" tabindex="52" /> | ||||
|             <div class="clear"></div> | ||||
|         </div> | ||||
|     </div> | ||||
| </asp:Content> | ||||
|  | ||||
							
								
								
									
										44
									
								
								Site/FITracker.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								Site/FITracker.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,44 @@ | ||||
| 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 FITracker : FITrackerBasePage | ||||
| { | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     { | ||||
|         string tp = Request.Params["tp"]; | ||||
|         if (string.Compare(tp, "ashx", true) == 0) | ||||
|         { | ||||
|             ProcessRequest(); | ||||
|         } | ||||
|         else if (!IsPostBack) | ||||
|         { | ||||
|             Title = PageTitle; | ||||
|             if (CheckLoginSession()) | ||||
|             { | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     protected override int FeatureID | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             return Foresight.Fleet.Services.User.Feature.M3; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     protected override bool AllowCurrentLoginSessionEnter() | ||||
|     { | ||||
|         if (SystemParams.HasLicense("FITracker")) | ||||
|             return base.AllowCurrentLoginSessionEnter(); | ||||
|         else | ||||
|             return false; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										975
									
								
								Site/FilterQ.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										975
									
								
								Site/FilterQ.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,975 @@ | ||||
| <%@ Page Title="" Language="C#" MasterPageFile="~/IronIntelMasterPage.master" AutoEventWireup="true" CodeFile="FilterQ.aspx.cs" Inherits="FilterQ" %> | ||||
|  | ||||
| <asp:Content ID="Content1" ContentPlaceHolderID="holder_head" runat="Server"> | ||||
|     <link rel="stylesheet" href="<%=GetFileUrlWithVersion("css/jquery.datetimepicker.css")%>" /> | ||||
|     <script src="<%=GetFileUrlWithVersion("js/jquery.datetimepicker.full.js")%>"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("js/filterq.js")%>"></script> | ||||
|     <script type="text/javascript"> | ||||
|         var isdealer = <%=IsDealer ? "true" : "false"%>; | ||||
|         var iscontractor = <%=IsContractor ? "true" : "false"%>; | ||||
|         var ship_dates = []; | ||||
|         var column_sort = ''; | ||||
|         var isasc = true; | ||||
|         var task_complete = -1; | ||||
|  | ||||
|         $(function () { | ||||
|             setPageTitle("Filter Q", true); | ||||
|             setFavoriteDisplay(true, 250); | ||||
|  | ||||
|  | ||||
|             function findIt(item, key) { | ||||
|                 if (!item) | ||||
|                     return false; | ||||
|                 if (typeof item.CurrentJob === 'string' && item.CurrentJob.toLowerCase().indexOf(key) >= 0) { return true; } | ||||
|                 if ((typeof item.JobContact === 'string' && item.JobContact.toLowerCase().indexOf(key) >= 0) || | ||||
|                     (typeof item.JobContactNumber === 'string' && item.JobContactNumber.toLowerCase().indexOf(key) >= 0) || | ||||
|                     (typeof item.JobAddress1 === 'string' && item.JobAddress1.toLowerCase().indexOf(key) >= 0) || | ||||
|                     (typeof item.JobAddress2 === 'string' && item.JobAddress2.toLowerCase().indexOf(key) >= 0) || | ||||
|                     (typeof item.JobAddressCity === 'string' && item.JobAddressCity.toLowerCase().indexOf(key) >= 0) || | ||||
|                     (typeof item.JobAddressState === 'string' && item.JobAddressState.toLowerCase().indexOf(key) >= 0) || | ||||
|                     (typeof item.JobAddressZip === 'string' && item.JobAddressZip.toLowerCase().indexOf(key) >= 0)) { return true; } | ||||
|                 if (typeof item.OrgMachineCode === 'string' && item.OrgMachineCode.toLowerCase().indexOf(key) >= 0) { return true; } | ||||
|                 if (typeof item.ManufactuerMake === 'string' && item.ManufactuerMake.toLowerCase().indexOf(key) >= 0) { return true; } | ||||
|                 if (typeof item.Model === 'string' && item.Model.toLowerCase().indexOf(key) >= 0) { return true; } | ||||
|                 if (typeof item.SN === 'string' && item.SN.toLowerCase().indexOf(key) >= 0) { return true; } | ||||
|                 if (typeof item.CumulativeHours === 'number' && item.CumulativeHours.toString().indexOf(key) >= 0) { return true; } | ||||
|                 if (typeof item.MachineTaskHourCheck === 'number' && item.MachineTaskHourCheck.toString().indexOf(key) >= 0) { return true; } | ||||
|                 if (typeof item.DiffToService === 'number' && item.DiffToService.toString().indexOf(key) >= 0) { return true; } | ||||
|                 if (typeof item.EstDueDate === 'string' && item.EstDueDate.indexOf(key) >= 0) { return true; } | ||||
|                 if (typeof item.EstShipDate === 'string' && item.EstShipDate.indexOf(key) >= 0) { return true; } | ||||
|                 return false; | ||||
|             } | ||||
|  | ||||
|             var expandall = false; | ||||
|  | ||||
|             function searchit() { | ||||
|                 if (!expandall) { | ||||
|                     $('#bodyFilters .subheader_tr').each(function (e) { | ||||
|                         var tr = $(this); | ||||
|                         var row = tr.data('row'); | ||||
|                         if (row) { | ||||
|                             var trs = []; | ||||
|                             fillGroup(row, trs, true); | ||||
|                             $(trs).insertAfter(tr); | ||||
|                             tr.removeData('row'); | ||||
|                         } | ||||
|                     }); | ||||
|                     expandall = true; | ||||
|                 } | ||||
|  | ||||
|                 var key = $(this).val().toLowerCase(); | ||||
|  | ||||
|                 var trs = $('#bodyFilters').children('tr'); | ||||
|                 var disp = ''; | ||||
|                 for (var i = 0; i < trs.length; i++) { | ||||
|                     var tr = $(trs[i]); | ||||
|                     if (!key || key.length == 0) { | ||||
|                         if (tr.hasClass('subheader_tr')) { | ||||
|                             tr.css('display', ''); | ||||
|                             disp = tr.find('em').hasClass('expand') ? '' : 'none'; | ||||
|                         } else { | ||||
|                             tr.css('display', disp); | ||||
|                         } | ||||
|                         tr.children('.hide').css('display', ''); | ||||
|                         if (tr.hasClass('top')) { | ||||
|                             tr.children('[rspan]').each(function (e) { | ||||
|                                 $(this).attr('rowspan', $(this).attr('rspan')); | ||||
|                             }); | ||||
|                         } | ||||
|                     } else { | ||||
|                         if (tr.hasClass('subheader_tr')) { | ||||
|                             tr.css('display', 'none'); | ||||
|                             continue; | ||||
|                         } | ||||
|                         var item = tr.data('item'); | ||||
|                         //if (item == undefined) { | ||||
|                         //    item = tr.prev().data('item'); | ||||
|                         //} | ||||
|                         //if (!findIt(item, key)) { | ||||
|                         //    tr.css('display', 'none'); | ||||
|                         //} else { | ||||
|                         //    tr.css('display', ''); | ||||
|                         //    // and search whether its top is visible | ||||
|                         //    // TODO: | ||||
|                         //    //if (!tr.hasClass('top')) { | ||||
|                         //    //    var tps = tr.prevAll('.top'); | ||||
|                         //    //    if (tps.length > 0) { | ||||
|                         //    //        if ($(tps[tps.length - 1]).css('display') == 'none') { | ||||
|                         //    //            tr.children('.hide').css('display', 'table-cell'); | ||||
|                         //    //        } | ||||
|                         //    //    } | ||||
|                         //    //} | ||||
|                         //} | ||||
|                         //if (tr.hasClass('top')) { | ||||
|                         //    tr.children('[rspan]').attr('rowspan', ''); | ||||
|                         //} else { | ||||
|                         //    tr.children('.hide').css('display', 'table-cell'); | ||||
|                         //} | ||||
|                         if (item) { | ||||
|                             if (!findIt(item, key)) { | ||||
|                                 tr.css('display', 'none'); | ||||
|                                 tr.next().css('display', 'none'); | ||||
|                             } else { | ||||
|                                 tr.css('display', ''); | ||||
|                                 tr.next().css('display', ''); | ||||
|                             } | ||||
|                             if (tr.hasClass('top')) { | ||||
|                                 tr.children('[rspan]').attr('rowspan', ''); | ||||
|                             } else { | ||||
|                                 tr.children('.hide').css('display', 'table-cell'); | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             OnRefresh(); | ||||
|  | ||||
|             // prepare search | ||||
|             $('#search_bar').bind('propertychange', searchit).bind('input', searchit); | ||||
|  | ||||
|             $('#popup_editor').detach().appendTo($(document.body)); | ||||
|             $('#mask_editor_bg').detach().appendTo($(document.body)); | ||||
|  | ||||
|             $('#popup_editor').dialog(function () { | ||||
|                 if (editor_saved) { | ||||
|                     OnRefresh(); | ||||
|                 } else { | ||||
|                     showmaskbg(false); | ||||
|                 } | ||||
|             }, false); | ||||
|             $('#popup_editor input.datetime').datetimepicker({ | ||||
|                 timepicker: false, | ||||
|                 format: 'm/d/Y' | ||||
|             }); | ||||
|  | ||||
|             // editor | ||||
|             function changed() { | ||||
|                 editor_changed = true; | ||||
|             } | ||||
|             $('#popup_editor .editor input[type="text"]').bind('propertychange', changed).bind('input', changed).change(changed); | ||||
|             $('#popup_editor .editor input[type="checkbox"]').change(changed); | ||||
|             $('#popup_editor .editor select').change(changed); | ||||
|             $('#popup_editor .editor textarea').change(changed); | ||||
|  | ||||
|             function stopPropagation(e) { | ||||
|                 if (e && e.stopPropagation) { | ||||
|                     e.stopPropagation(); | ||||
|                 } | ||||
|             } | ||||
|             function hideFilters(e) { | ||||
|                 $('.filter_holder').css('display', 'none'); | ||||
|                 $('.ship_holder').css('display', 'none'); | ||||
|             } | ||||
|             $('.filter_holder').click(stopPropagation); | ||||
|             $('.ship_holder').click(stopPropagation); | ||||
|             $('#filter_shipdate').click(function (e) { | ||||
|                 hideFilters(); | ||||
|                 $('.filter_holder').css('display', $('.filter_holder').css('display') == 'none' ? 'block' : 'none'); | ||||
|                 stopPropagation(e); | ||||
|             }); | ||||
|             $('#filter_task').click(function (e) { | ||||
|                 hideFilters(); | ||||
|                 $('.ship_holder').css('display', $('.ship_holder').css('display') == 'none' ? 'block' : 'none'); | ||||
|                 stopPropagation(e); | ||||
|             }); | ||||
|             $('#filter_button').click(function (e) { | ||||
|                 var inps = $('#ul_shipdates input:checked'); | ||||
|                 ship_dates = []; | ||||
|                 for (var i = 0; i < inps.length; i++) { | ||||
|                     ship_dates.push($(inps[i]).val()); | ||||
|                 } | ||||
|                 hideFilters(); | ||||
|                 OnRefresh(); | ||||
|             }); | ||||
|             $('#filter_task_button').click(function (e) { | ||||
|                 task_complete = -1; | ||||
|                 if ($('#radio_task_yes').prop('checked')) { | ||||
|                     task_complete = 1; | ||||
|                 } else if ($('#radio_task_no').prop('checked')) { | ||||
|                     task_complete = 0; | ||||
|                 } | ||||
|                 hideFilters(); | ||||
|                 OnRefresh(); | ||||
|             }); | ||||
|             // sort | ||||
|             $('#filter_header').click(function (e) { | ||||
|                 var target = $(e.target); | ||||
|                 if (target.is('span')) { | ||||
|                     var ths = $('#filter_header').children('th'); | ||||
|                     for (var i = 0; i < ths.length; i++) { | ||||
|                         $(ths[i]).children('em:first').removeClass('asc').removeClass('desc'); | ||||
|                     } | ||||
|                     var c = target.text(); | ||||
|                     if (column_sort == c) { | ||||
|                         isasc = !isasc; | ||||
|                     } else { | ||||
|                         isasc = true; | ||||
|                         column_sort = c; | ||||
|                     } | ||||
|                     target.parents('th:first').children('em:first').addClass(isasc ? 'asc' : 'desc'); | ||||
|                     OnRefresh(); | ||||
|                 } | ||||
|             }); | ||||
|             $(document.body).click(hideFilters); | ||||
|         }); | ||||
|  | ||||
|         function OnSave() { | ||||
|             if (!isdealer && !iscontractor) { | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
|             var trs = $('#bodyFilters').children('tr'); | ||||
|             var items = []; | ||||
|             for (var i = 0; i < trs.length; i++) { | ||||
|                 var tr = $(trs[i]); | ||||
|                 if (tr.hasClass('subheader_tr')) | ||||
|                     continue; | ||||
|  | ||||
|                 var inp; | ||||
|                 var item = tr.data('item'); | ||||
|  | ||||
|                 if (item === undefined) { | ||||
|                     continue; | ||||
|                 } | ||||
|  | ||||
|                 if (isdealer) { | ||||
|                     //inp = tr.find('.job_contact'); | ||||
|                     //if (AlertLimit(inp, 50)) { return; } | ||||
|                     //item.JobContact = inp.val(); | ||||
|                     //inp = tr.find('.job_contact_number'); | ||||
|                     //if (AlertLimit(inp, 12)) { return; } | ||||
|                     //item.JobContactNumber = inp.val(); | ||||
|                     //inp = tr.find('.job_address1'); | ||||
|                     //if (AlertLimit(inp, 50)) { return; } | ||||
|                     //item.JobAddress1 = inp.val(); | ||||
|                     //inp = tr.find('.job_address2'); | ||||
|                     //if (AlertLimit(inp, 50)) { return; } | ||||
|                     //item.JobAddress2 = inp.val(); | ||||
|                     //inp = tr.find('.job_address_city'); | ||||
|                     //if (AlertLimit(inp, 50)) { return; } | ||||
|                     //item.JobAddressCity = inp.val(); | ||||
|                     //inp = tr.find('.job_address_state'); | ||||
|                     //if (AlertLimit(inp, 50)) { return; } | ||||
|                     //item.JobAddressState = inp.val(); | ||||
|                     //inp = tr.find('.job_address_zip'); | ||||
|                     //if (AlertLimit(inp, 50)) { return; } | ||||
|                     //item.JobAddressZip = inp.val(); | ||||
|                     //inp = tr.find('.org_machine_code'); | ||||
|                     //if (AlertLimit(inp, 50)) { return; } | ||||
|                     //item.OrgMachineCode = inp.val(); | ||||
|                     //inp = tr.find('.manufactuer_make'); | ||||
|                     //if (AlertLimit(inp, 20)) { return; } | ||||
|                     //item.ManufactuerMake = inp.val(); | ||||
|                     //inp = tr.find('.model'); | ||||
|                     //if (AlertLimit(inp, 200)) { return; } | ||||
|                     //item.Model = inp.val(); | ||||
|                     //inp = tr.find('.sn'); | ||||
|                     //if (AlertLimit(inp, 100)) { return; } | ||||
|                     //item.SN = inp.val(); | ||||
|                     //inp = tr.find('.cumulative_hours'); | ||||
|                     //if (AlertNumber(inp)) { return; } | ||||
|                     //item.CumulativeHours = parseFloat(inp.val()); | ||||
|                     //inp = tr.find('.machine_task_hour_check'); | ||||
|                     //if (AlertInt(inp)) { return; } | ||||
|                     //item.MachineTaskHourCheck = parseInt(inp.val()); | ||||
|                     //inp = tr.find('.diff_to_service'); | ||||
|                     //if (AlertNumber(inp)) { return; } | ||||
|                     //item.DiffToService = parseFloat(inp.val()); | ||||
|  | ||||
|                     //inp = tr.find('.est_service_needed_by'); | ||||
|                     //if (AlertDate(inp)) { return; } | ||||
|                     //item.ESTServiceNeededBy = inp.val(); | ||||
|                     //inp = tr.find('.est_shop_date'); | ||||
|                     //if (AlertDate(inp)) { return; } | ||||
|                     //item.ESTShopDate = inp.val(); | ||||
|                     item.ESTServiceNeededBy = item.EstDueDate; | ||||
|                     item.ESTShopDate = item.EstShipDate; | ||||
|                 } | ||||
|  | ||||
|                 if (isdealer) { | ||||
|                     //inp = tr.find('.organization_name'); | ||||
|                     //if (AlertLimit(inp, 20)) { return; } | ||||
|                     //item.OrganizationName = inp.val(); | ||||
|                     inp = tr.find('.ups_tracking_number'); | ||||
|                     if (AlertLimit(inp, 100)) { return; } | ||||
|                     item.UPSTrackingNumber = inp.val(); | ||||
|                     item.TaskComplete = tr.find('.task_complete').prop('checked'); | ||||
|                 } | ||||
|                 if (iscontractor || isdealer) { | ||||
|                     //inp = tr.find('.hours_at_service'); | ||||
|                     //if (AlertNumber(inp)) { return; } | ||||
|                     //item.TaskCompletedHours = parseFloat(inp.val()); | ||||
|                     item.RequestJREToService = tr.find('.request_jre_to_service').prop('checked'); | ||||
|                     if (iscontractor) { | ||||
|                         item.Approved = tr.find('.approved_by').prop('checked'); | ||||
|                     } | ||||
|                     //item.Priority = tr.find('.priority').val(); | ||||
|                     if (iscontractor) { | ||||
|                         inp = tr.find('.po'); | ||||
|                         if (AlertLimit(inp, 20)) { return; } | ||||
|                         item.CustomerPO = inp.val(); | ||||
|                     } | ||||
|                     if (isdealer) { | ||||
|                         inp = tr.find('.wonumber'); | ||||
|                         if (AlertLimit(inp, 20)) { return; } | ||||
|                         item.CustomerWO = inp.val(); | ||||
|                     } | ||||
|                     //inp = tr.find('.alt_shipaddress'); | ||||
|                     //if (AlertLimit(inp, 50)) { return; } | ||||
|                     //item.AlternateAddress1 = inp.val(); | ||||
|                     //inp = tr.find('.alt_shipaddress2'); | ||||
|                     //if (AlertLimit(inp, 50)) { return; } | ||||
|                     //item.AlternateAddress2 = inp.val(); | ||||
|                     //inp = tr.find('.alt_shipaddress_city'); | ||||
|                     //if (AlertLimit(inp, 50)) { return; } | ||||
|                     //item.AlternateAddressCity = inp.val(); | ||||
|                     //inp = tr.find('.alt_shipaddress_state'); | ||||
|                     //if (AlertLimit(inp, 50)) { return; } | ||||
|                     //item.AlternateAddressState = inp.val(); | ||||
|                     //inp = tr.find('.alt_shipaddress_zip'); | ||||
|                     //if (AlertLimit(inp, 50)) { return; } | ||||
|                     //item.AlternateAddressZip = inp.val(); | ||||
|                     inp = tr.find('.shipnotes'); | ||||
|                     if (AlertLimit(inp, 250)) { return; } | ||||
|                     item.ShipNotes = inp.val(); | ||||
|                 } | ||||
|                 items.push(item); | ||||
|             } | ||||
|  | ||||
|             showloading(true); | ||||
|  | ||||
|             var json = JSON.stringify(items); | ||||
|             json = htmlencode(json); | ||||
|             filterQuery('SaveFilterQ', json, function (data) { | ||||
|                 showloading(false); | ||||
|                 if (data == true) { | ||||
|                     alert('Save data successful.'); | ||||
|                     window.location = window.location; | ||||
|                 } else { | ||||
|                     alert('Error when save data: ' + data); | ||||
|                 } | ||||
|             }, function (err) { | ||||
|                 console.log(err); | ||||
|                 showloading(false); | ||||
|                 alert('Error occurs when save data.'); | ||||
|             }); | ||||
|         } | ||||
|     </script> | ||||
|     <style type="text/css"> | ||||
|         #host_main { | ||||
|             overflow: hidden; | ||||
|         } | ||||
|  | ||||
|         .hide { | ||||
|             display: none; | ||||
|         } | ||||
|  | ||||
|         .function_bar { | ||||
|             line-height: 30px; | ||||
|             margin: 0; | ||||
|         } | ||||
|  | ||||
|         .search_span { | ||||
|             position: absolute; | ||||
|             left: 18px; | ||||
|             font-family: CalciteWebCoreIcons; | ||||
|             font-size: 1.2em; | ||||
|         } | ||||
|  | ||||
|             .search_span:before { | ||||
|                 content: '\e67b'; | ||||
|             } | ||||
|  | ||||
|         .expand_button { | ||||
|             background: rgb(68,114,196); | ||||
|             width: 18px; | ||||
|             height: 18px; | ||||
|             border: 1px solid rgb(47,82,143); | ||||
|             float: right; | ||||
|             cursor: pointer; | ||||
|             font-family: CalciteWebCoreIcons; | ||||
|             padding: 0; | ||||
|         } | ||||
|  | ||||
|         #search_bar { | ||||
|             border: 1px solid #a9a9a9; | ||||
|             padding: 2px; | ||||
|             width: 360px; | ||||
|             margin-left: 4px; | ||||
|             padding-left: 24px; | ||||
|         } | ||||
|  | ||||
|         .subheader_tr { | ||||
|             background: #eee; | ||||
|             height: 20px; | ||||
|             line-height: 20px; | ||||
|         } | ||||
|  | ||||
|         .icon { | ||||
|             font-family: CalciteWebCoreIcons; | ||||
|             font-style: normal; | ||||
|             cursor: pointer; | ||||
|         } | ||||
|  | ||||
|             .icon.expand:before { | ||||
|                 content: '\e682'; | ||||
|             } | ||||
|  | ||||
|             .icon.collapse:before { | ||||
|                 content: '\e681'; | ||||
|             } | ||||
|  | ||||
|             .icon.filter { | ||||
|                 float: right; | ||||
|                 margin: 2px; | ||||
|             } | ||||
|  | ||||
|                 .icon.filter:before { | ||||
|                     content: '\e653'; | ||||
|                 } | ||||
|  | ||||
|             .icon.asc, | ||||
|             .icon.desc { | ||||
|                 font-size: 9px; | ||||
|                 padding-right: 4px; | ||||
|             } | ||||
|  | ||||
|                 .icon.asc:before { | ||||
|                     content: '\e609'; | ||||
|                 } | ||||
|  | ||||
|                 .icon.desc:before { | ||||
|                     content: '\e608'; | ||||
|                 } | ||||
|  | ||||
|         .subheader { | ||||
|             padding-left: 6px; | ||||
|         } | ||||
|  | ||||
|  | ||||
|         #filter_content { | ||||
|             position: fixed; | ||||
|             width: 100%; | ||||
|             bottom: 0; | ||||
|             top: 145px; | ||||
|             overflow: auto; | ||||
|         } | ||||
|  | ||||
|         #filterTable { | ||||
|             font-family: Arial; | ||||
|             margin: 0 4px; | ||||
|             border-collapse: collapse; | ||||
|             border-spacing: 0; | ||||
|             margin-top: 1px; | ||||
|             table-layout: fixed; | ||||
|         } | ||||
|  | ||||
|             #filterTable td.input textarea { | ||||
|                 font-family: Arial; | ||||
|                 min-height: 12px; | ||||
|                 line-height: 13px; | ||||
|             } | ||||
|  | ||||
|             #filterTable, | ||||
|             #filterTable input, | ||||
|             #filterTable select, | ||||
|             #filterTable textarea { | ||||
|                 font-size: 11px; | ||||
|             } | ||||
|  | ||||
|                 #filterTable th, | ||||
|                 #filterTable td { | ||||
|                     padding: 0; | ||||
|                     border: 1px solid #ddd; | ||||
|                     vertical-align: top; | ||||
|                 } | ||||
|  | ||||
|                 #filterTable td { | ||||
|                     padding: 2px; | ||||
|                     word-break: break-word; | ||||
|                 } | ||||
|  | ||||
|                     #filterTable td.input { | ||||
|                         padding: 2px 1px; | ||||
|                         text-align: center; | ||||
|                         /*background: rgb(255,255,177);*/ | ||||
|                     } | ||||
|  | ||||
|                     #filterTable td.ro { | ||||
|                         background: none; | ||||
|                     } | ||||
|  | ||||
|                     #filterTable td.input input, | ||||
|                     #filterTable td.input textarea { | ||||
|                         border: /*1px inset rgb(238, 238, 238)*/ none; | ||||
|                         padding: 0; | ||||
|                         margin: 0; | ||||
|                         background: rgb(255,255,177); | ||||
|                         width: 100%; | ||||
|                     } | ||||
|  | ||||
|                         #filterTable td.input input:focus, | ||||
|                         #filterTable td.input textarea:focus { | ||||
|                             outline: none; | ||||
|                         } | ||||
|  | ||||
|                 #filterTable thead th { | ||||
|                     background: #ccc; | ||||
|                     word-break: break-word; | ||||
|                     font-weight: bold; | ||||
|                     text-align: left; | ||||
|                 } | ||||
|  | ||||
|                     #filterTable thead th span { | ||||
|                         cursor: pointer; | ||||
|                     } | ||||
|  | ||||
|                         #filterTable thead th span:hover { | ||||
|                             text-decoration: underline; | ||||
|                         } | ||||
|  | ||||
|                 #filterTable thead tr.second_header th { | ||||
|                     background: rgb(235,235,186); | ||||
|                 } | ||||
|  | ||||
|         .priority { | ||||
|             width: 100%; | ||||
|             border: none; | ||||
|             background: rgb(255,255,177); | ||||
|         } | ||||
|  | ||||
|             .priority:focus { | ||||
|                 outline: none; | ||||
|             } | ||||
|  | ||||
|         /*.ups_tracking_number { width: 103px; } | ||||
|         .hours_at_service { width: 74px; } | ||||
|         .po { width: 77px; } | ||||
|         .wonumber { width: 74px; } | ||||
|         .alt_shipaddress { width: 156px; } | ||||
|         .alt_shipaddress2 { width: 156px; } | ||||
|         .alt_shipaddress_city { width: 136px; } | ||||
|         .alt_shipaddress_state { width: 166px; } | ||||
|         .alt_shipaddress_zip { width: 146px; } | ||||
|         .shipnotes { width: 100%; }*/ | ||||
|  | ||||
|         .errorText { | ||||
|             font-weight: bold; | ||||
|             text-align: center; | ||||
|             height: 30px; | ||||
|             line-height: 30px; | ||||
|         } | ||||
|  | ||||
|         .bold { | ||||
|             font-weight: bold; | ||||
|         } | ||||
|  | ||||
|         #filterTable td.input input.red, | ||||
|         #filterTable td.input textarea.red { | ||||
|             /*border: 1px solid red;*/ | ||||
|             background: #ef9999; | ||||
|         } | ||||
|  | ||||
|         #lbl_calc { | ||||
|             font-family: Arial; | ||||
|             min-height: 12px; | ||||
|             line-height: 13px; | ||||
|             font-size: 11px; | ||||
|             padding: 0; | ||||
|             margin: 0; | ||||
|             white-space: nowrap; | ||||
|         } | ||||
|  | ||||
|         .collapse-table { | ||||
|             border: none; | ||||
|             border-collapse: collapse; | ||||
|             width: 100%; | ||||
|             font-size: 13px; | ||||
|         } | ||||
|  | ||||
|             .collapse-table td { | ||||
|                 border: 1px solid #a9a9a9; | ||||
|                 padding: 6px; | ||||
|             } | ||||
|  | ||||
|             .collapse-table .item { | ||||
|                 height: 18px; | ||||
|                 line-height: 18px; | ||||
|             } | ||||
|  | ||||
|                 .collapse-table .item span.caption { | ||||
|                     color: #6b6b6b; | ||||
|                 } | ||||
|  | ||||
|                 .collapse-table .item span.val { | ||||
|                     color: #000; | ||||
|                     font-weight: bold; | ||||
|                 } | ||||
|  | ||||
|             .collapse-table .grid .item span.caption { | ||||
|                 display: table-cell; | ||||
|                 width: 150px; | ||||
|             } | ||||
|  | ||||
|             .collapse-table .grid .item span.val { | ||||
|                 display: table-cell; | ||||
|                 padding-left: 4px; | ||||
|             } | ||||
|  | ||||
|                 .collapse-table .grid .item span.val input { | ||||
|                     width: 300px; | ||||
|                 } | ||||
|  | ||||
|             .collapse-table .item span input { | ||||
|                 border: none; | ||||
|             } | ||||
|  | ||||
|                 .collapse-table .item span input:disabled { | ||||
|                     background: none; | ||||
|                     font-weight: bold; | ||||
|                 } | ||||
|  | ||||
|                 .collapse-table .item span input:focus { | ||||
|                     outline: none; | ||||
|                 } | ||||
|  | ||||
|         .ship_notes { | ||||
|             height: 18px; | ||||
|             padding: 0px; | ||||
|             width: 300px; | ||||
|             vertical-align: bottom; | ||||
|             border: none; | ||||
|             resize: none; | ||||
|             font-family: Arial; | ||||
|             line-height: 18px; | ||||
|         } | ||||
|  | ||||
|             .ship_notes:hover, | ||||
|             .priority_val:hover { | ||||
|                 outline: none; | ||||
|             } | ||||
|  | ||||
|         .date_em { | ||||
|             font-family: CalciteWebCoreIcons; | ||||
|             font-size: 16px; | ||||
|             vertical-align: bottom; | ||||
|         } | ||||
|  | ||||
|         .task_complete { | ||||
|             vertical-align: bottom; | ||||
|         } | ||||
|  | ||||
|         .priority_val { | ||||
|             border: none; | ||||
|         } | ||||
|  | ||||
|         .editor, | ||||
|         .editor input, | ||||
|         .editor textarea, | ||||
|         .editor select { | ||||
|             background: rgb(255,255,177); | ||||
|             font-size: 13px; | ||||
|         } | ||||
|  | ||||
|             .editor .caption { | ||||
|                 background: #fff; | ||||
|                 padding: 3px 0; | ||||
|             } | ||||
|  | ||||
|         .filter_panel { | ||||
|             position: absolute; | ||||
|             background: white; | ||||
|             border: 1px solid #c6c6c6; | ||||
|             display: none; | ||||
|             min-width: 100px; | ||||
|         } | ||||
|  | ||||
|         .filter_holder .scroller { | ||||
|             max-height: 240px; | ||||
|             overflow-y: auto; | ||||
|             overflow-x: hidden; | ||||
|         } | ||||
|  | ||||
|         .filter_holder ul { | ||||
|             padding: 0; | ||||
|             margin: 0; | ||||
|             list-style: none; | ||||
|             /*min-width: 110px;*/ | ||||
|         } | ||||
|  | ||||
|             .filter_holder ul li { | ||||
|                 padding: 0 10px 0 6px; | ||||
|                 height: 22px; | ||||
|                 line-height: 22px; | ||||
|                 cursor: pointer; | ||||
|                 white-space: nowrap; | ||||
|             } | ||||
|  | ||||
|                 .filter_holder ul li input { | ||||
|                     margin: 0; | ||||
|                     padding: 0; | ||||
|                     height: 22px; | ||||
|                     vertical-align: top; | ||||
|                 } | ||||
|  | ||||
|                 .filter_holder ul li label { | ||||
|                     padding-left: 4px; | ||||
|                     cursor: pointer; | ||||
|                 } | ||||
|  | ||||
|                 .filter_holder ul li:hover { | ||||
|                     background: #e6e6e6; | ||||
|                 } | ||||
|  | ||||
|         .ship_holder { | ||||
|             padding-left: 4px; | ||||
|         } | ||||
|  | ||||
|             .ship_holder div { | ||||
|                 height: 22px; | ||||
|                 line-height: 22px; | ||||
|             } | ||||
|  | ||||
|             .ship_holder input { | ||||
|                 margin: 0 4px; | ||||
|                 padding: 0; | ||||
|                 height: 22px; | ||||
|                 vertical-align: top; | ||||
|             } | ||||
|  | ||||
|         .funcs { | ||||
|             padding: 4px; | ||||
|             text-align: right; | ||||
|         } | ||||
|  | ||||
|             .funcs input { | ||||
|                 border: none; | ||||
|                 background: rgb(249, 189, 117); | ||||
|                 cursor: pointer; | ||||
|                 height: 22px; | ||||
|                 padding: 2px 6px; | ||||
|             } | ||||
|  | ||||
|                 .funcs input:hover { | ||||
|                     background: #d7690E; | ||||
|                 } | ||||
|     </style> | ||||
| </asp:Content> | ||||
| <asp:Content ID="Content2" ContentPlaceHolderID="holder_content" runat="Server"> | ||||
|     <div class="search_bar" style="line-height: 30px; padding-top: 10px;"> | ||||
|         <input type="password" style="display: none" autocomplete="new-password" /> | ||||
|         <input type="text" id="search_bar" class="text_bar" /> | ||||
|         <span class="search_span"></span> | ||||
|     </div> | ||||
|     <div class="function_title"> | ||||
|         <span class="sbutton iconsave" onclick="OnSave();">Save</span> | ||||
|         <span class="sbutton icondelete" onclick="OnCancel();">Cancel</span> | ||||
|         <span class="sbutton iconrefresh" onclick="OnRefresh();">Refresh</span> | ||||
|         <span id="span_loading" class="loading c-spin" style="display: none;"></span> | ||||
|     </div> | ||||
|     <div id="filter_content"> | ||||
|         <table id="filterTable"> | ||||
|             <thead> | ||||
|                 <tr style="height: 26px;" id="filter_header"> | ||||
|                     <% if (IsDealer) | ||||
|                         { %> | ||||
|                     <th style="min-width: 159px; width: 159px;" rowspan="2"><em class="icon"></em><span>ORGANIZATION NAME</span></th> | ||||
|                     <% } %> | ||||
|                     <th style="min-width: 91px; width: 91px;"><em class="icon"></em><span>EQUIPMENT CODE</span></th> | ||||
|                     <th style="min-width: 241px; width: 241px;" rowspan="2"><em class="icon"></em><span>CURRENT JOBSITE</span></th> | ||||
|                     <th style="min-width: 220px;" colspan="<%=IsDealer ? 4 : 3%>"><em class="icon"></em><span>JOBSITE CONTACT</span></th> | ||||
|                     <th style="min-width: 100px;"><em class="icon"></em><span>INFO</span></th> | ||||
|                     <th style="min-width: 91px; width: 91px;"> | ||||
|                         <em class="icon"></em> | ||||
|                         <em class="icon filter" id="filter_shipdate"></em> | ||||
|                         <span>ESTIMATED SHIP DATE</span> | ||||
|                         <div class="filter_holder filter_panel"> | ||||
|                             <div class="scroller"> | ||||
|                                 <ul id="ul_shipdates"></ul> | ||||
|                             </div> | ||||
|                             <div class="funcs"> | ||||
|                                 <input type="button" value="Filter" id="filter_button" /> | ||||
|                             </div> | ||||
|                         </div> | ||||
|                     </th> | ||||
|                     <th style="min-width: 91px; width: 91px;"><em class="icon"></em><span>HOURS TO SERVICE</span></th> | ||||
|                     <%--</tr> | ||||
|             <tr class="second_header">--%> | ||||
|                     <% if (IsDealer) | ||||
|                         { %> | ||||
|                     <th style="min-width: 74px; width: 74px;"> | ||||
|                         <em class="icon"></em> | ||||
|                         <em class="icon filter" id="filter_task"></em> | ||||
|                         <span>TASK COMPLETE?</span> | ||||
|                         <div class="ship_holder filter_panel"> | ||||
|                             <div> | ||||
|                                 <input type="radio" name="radio_task" value="-1" id="radio_task_all" checked="checked" /><label for="radio_task_all">All</label> | ||||
|                             </div> | ||||
|                             <div> | ||||
|                                 <input type="radio" name="radio_task" value="1" id="radio_task_yes" /><label for="radio_task_yes">Yes</label> | ||||
|                             </div> | ||||
|                             <div> | ||||
|                                 <input type="radio" name="radio_task" value="0" id="radio_task_no" /><label for="radio_task_no">No</label> | ||||
|                             </div> | ||||
|                             <div class="funcs"> | ||||
|                                 <input type="button" value="Filter" id="filter_task_button" /> | ||||
|                             </div> | ||||
|                         </div> | ||||
|                     </th> | ||||
|                     <th style="min-width: 90px; width: 90px;"><em class="icon"></em><span>UPS TRACKING NUMBER</span></th> | ||||
|                     <% } %> | ||||
|                     <th style="min-width: 84px; width: 84px;"><em class="icon"></em><span>REQUEST JRE TO SERVICE</span></th> | ||||
|                     <th style="min-width: 66px; width: 66px;"><em class="icon"></em><span>APPROVED</span></th> | ||||
|                     <%--<th>PRIORITY</th>--%> | ||||
|                     <% if (IsContractor) | ||||
|                         { %> | ||||
|                     <th style="min-width: 91px; width: 91px;"><em class="icon"></em><span>PO</span></th> | ||||
|                     <% } %> | ||||
|                     <% if (IsDealer) | ||||
|                         { %> | ||||
|                     <th style="min-width: 91px; width: 91px;"><em class="icon"></em><span>WONUMBER</span></th> | ||||
|                     <% } %> | ||||
|                     <th style="min-width: 200px;" colspan="<%=IsDealer ? 1 : 3%>"><em class="icon"></em><span>SHIP NOTES</span></th> | ||||
|                 </tr> | ||||
|             </thead> | ||||
|             <tbody id="bodyFilters"></tbody> | ||||
|         </table> | ||||
|         <div style="visibility: hidden; position: absolute; top: 0;"> | ||||
|             <label id="lbl_calc"></label> | ||||
|         </div> | ||||
|     </div> | ||||
|     <div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div> | ||||
|     <%-- popup editor --%> | ||||
|     <div id="popup_editor" class="dialog" style="display: none; width: 500px;"> | ||||
|         <div class="dialog-title"> | ||||
|             <span class="title">Editor</span> | ||||
|             <em class="dialog-close" style="float: right;"></em> | ||||
|         </div> | ||||
|         <div class="dialog-content" style="padding-bottom: 10px;"> | ||||
|             <table class="collapse-table"> | ||||
|                 <tr> | ||||
|                     <td> | ||||
|                         <div class="item"><span class="caption">Jobsite: </span><span class="val jobsite"></span></div> | ||||
|                         <div class="item"><span class="caption">Organization Name: </span><span class="val org_name"></span></div> | ||||
|                     </td> | ||||
|                     <td style="width: 200px;"> | ||||
|                         <div class="item"><span class="caption">Equipment Code: </span><span class="val eqp_code"></span></div> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td colspan="2" class="grid"> | ||||
|                         <div class="item"><span class="caption">Jobsite Contact: </span><span class="val jobsite_contact"></span></div> | ||||
|                         <div class="item"><span class="caption">Contact Number: </span><span class="val contact_number"></span></div> | ||||
|                         <div class="item"><span class="caption">Address 1: </span><span class="val addrses1"></span></div> | ||||
|                         <div class="item"><span class="caption">Address 2: </span><span class="val address2"></span></div> | ||||
|                         <div class="item"><span class="caption">City: </span><span class="val city"></span></div> | ||||
|                         <div class="item"><span class="caption">State: </span><span class="val state"></span></div> | ||||
|                         <div class="item"><span class="caption">Zip: </span><span class="val zip"></span></div> | ||||
|                         <div class="item"><span class="caption">Make: </span><span class="val make"></span></div> | ||||
|                         <div class="item"><span class="caption">Model: </span><span class="val model"></span></div> | ||||
|                         <div class="item"><span class="caption">SN: </span><span class="val sn"></span></div> | ||||
|                         <div class="item"><span class="caption">Hours: </span><span class="val hours"></span></div> | ||||
|                         <div class="item"><span class="caption">Service Needed: </span><span class="val service_needed"></span></div> | ||||
|                         <div class="item"><span class="caption">Hours to Service: </span><span class="val due"></span></div> | ||||
|                         <%-- editable --%> | ||||
|                         <div class="item editor"> | ||||
|                             <span class="caption">Est. Due Date:<span class="date_em"></span> </span><span class="val"> | ||||
|                                 <input type="text" class="est_due_date datetime" /></span> | ||||
|                         </div> | ||||
|                         <div class="item editor"> | ||||
|                             <span class="caption">Est. Ship Date:<span class="date_em"></span> </span><span class="val"> | ||||
|                                 <input type="text" class="est_ship_date datetime" /></span> | ||||
|                         </div> | ||||
|                         <div class="item editor"> | ||||
|                             <span class="caption">UPS Tracking Number: </span><span class="val"> | ||||
|                                 <input type="text" class="ups_tracking" maxlength="100" /></span> | ||||
|                         </div> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td colspan="2" class="grid"> | ||||
|                         <%--                        <div class="item editor"><span class="caption">Hours at Service: </span><span class="val"><input type="text" class="hours_atservice" /></span></div>--%> | ||||
|                         <div class="item editor"> | ||||
|                             <span class="caption">Priority: </span><span class="val" style="padding-left: 2px;"> | ||||
|                                 <select class="priority_val"> | ||||
|                                     <option value="standard" selected="selected">Standard</option> | ||||
|                                     <option value="next">Next Day Air</option> | ||||
|                                     <option value="2nd">2nd Day Air</option> | ||||
|                                 </select></span> | ||||
|                         </div> | ||||
|                         <div class="item editor"> | ||||
|                             <span class="caption">WO Number: </span><span class="val"> | ||||
|                                 <input type="text" class="wo_number" maxlength="20" /></span> | ||||
|                         </div> | ||||
|                         <div class="item editor"> | ||||
|                             <span class="caption">Alt Ship Address 1: </span><span class="val"> | ||||
|                                 <input type="text" class="alt_ship_address1" maxlength="50" /></span> | ||||
|                         </div> | ||||
|                         <div class="item editor"> | ||||
|                             <span class="caption">Alt Ship Address 2: </span><span class="val"> | ||||
|                                 <input type="text" class="alt_ship_address2" maxlength="50" /></span> | ||||
|                         </div> | ||||
|                         <div class="item editor"> | ||||
|                             <span class="caption">Alt Ship City: </span><span class="val"> | ||||
|                                 <input type="text" class="alt_ship_city" maxlength="50" /></span> | ||||
|                         </div> | ||||
|                         <div class="item editor"> | ||||
|                             <span class="caption">Alt Ship State: </span><span class="val"> | ||||
|                                 <input type="text" class="alt_ship_state" maxlength="50" /></span> | ||||
|                         </div> | ||||
|                         <div class="item editor"> | ||||
|                             <span class="caption">Alt Ship Zip: </span><span class="val"> | ||||
|                                 <input type="text" class="alt_ship_zip" maxlength="50" /></span> | ||||
|                         </div> | ||||
|                         <div class="item editor"> | ||||
|                             <span class="caption">Alt Job: </span><span class="val"> | ||||
|                                 <input type="text" class="alt_job" maxlength="200" /></span> | ||||
|                         </div> | ||||
|                         <div class="item editor"> | ||||
|                             <span class="caption">Alt Jobsite Contact: </span><span class="val"> | ||||
|                                 <input type="text" class="alt_jobsite_contact" maxlength="200" /></span> | ||||
|                         </div> | ||||
|                         <div class="item editor"> | ||||
|                             <span class="caption">Ship Notes: </span><span class="val"> | ||||
|                                 <textarea class="ship_notes" maxlength="250"></textarea></span> | ||||
|                         </div> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td rowspan="2"> | ||||
|                         <div class="item editor"> | ||||
|                             <span class="caption">Request JRE to Service: </span><span class="val"> | ||||
|                                 <input type="checkbox" class="req_jre" style="vertical-align: middle;" /></span> | ||||
|                         </div> | ||||
|                         <div class="item editor"> | ||||
|                             <span class="caption">PO: </span><span class="val"> | ||||
|                                 <input type="text" class="po" maxlength="20" style="width: 90px;" /></span> | ||||
|                             <span class="caption">Approved: </span><span class="val"> | ||||
|                                 <input type="checkbox" class="po_approved" style="vertical-align: middle;" /></span> | ||||
|                         </div> | ||||
|                         <div class="item editor"> | ||||
|                             <span class="caption">Task Complete: </span><span class="val"> | ||||
|                                 <input type="checkbox" class="task_complete" /></span> | ||||
|                         </div> | ||||
|                     </td> | ||||
|                     <td> | ||||
|                         <input type="button" value="Save" style="width: 100%; height: 26px;" onclick="SaveEditor();" /> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td> | ||||
|                         <div style="float: left;"> | ||||
|                             <input type="button" value="Previous" style="height: 26px; width: 90px;" onclick="FillNext(-1);" /> | ||||
|                         </div> | ||||
|                         <div style="float: right;"> | ||||
|                             <input type="button" value="Next" style="height: 26px; width: 90px;" onclick="FillNext(1);" /> | ||||
|                         </div> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|             </table> | ||||
|         </div> | ||||
|         <div class="maskbg" style="display: none;"></div> | ||||
|     </div> | ||||
|     <div class="maskbg" id="mask_editor_bg" style="display: none;"></div> | ||||
| </asp:Content> | ||||
							
								
								
									
										47
									
								
								Site/FilterQ.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								Site/FilterQ.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,47 @@ | ||||
| using Foresight.Fleet.Services.User; | ||||
| using IronIntel.Contractor; | ||||
| using IronIntel.Contractor.Site; | ||||
| using IronIntel.Services; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Web; | ||||
| using System.Web.UI; | ||||
| using System.Web.UI.WebControls; | ||||
|  | ||||
| public partial class FilterQ : FilterQBasePage | ||||
| { | ||||
|     protected bool IsDealer; | ||||
|     protected bool IsContractor; | ||||
|  | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     {         | ||||
|         string tp = Request.QueryString["tp"]; | ||||
|         if (string.Compare(tp, "ashx", true) == 0) | ||||
|         { | ||||
|             ProcessRequest(); | ||||
|         } | ||||
|         else if (!IsPostBack) | ||||
|         { | ||||
|             Title = PageTitle; | ||||
|             if (CheckLoginSession()) | ||||
|             { | ||||
|                 bool license = SystemParams.HasLicense("FilterQ"); | ||||
|                 if (!license) | ||||
|                     RedirectToEntryPage();                 | ||||
|  | ||||
|                 var cmp = SystemParams.GetCompanyInfo(); | ||||
|                 IsDealer = cmp.IsDealer; | ||||
|                 IsContractor = cmp.IsContractor; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     protected override int FeatureID | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             return Foresight.Fleet.Services.User.Feature.FILTERQ; | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										89
									
								
								Site/Global.asax
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								Site/Global.asax
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,89 @@ | ||||
| <%@ Application Language="C#" %> | ||||
|  | ||||
| <script RunAt="server"> | ||||
|  | ||||
|     void Application_Start(object sender, EventArgs e) | ||||
|     { | ||||
|         // Code that runs on application startup | ||||
|         IronIntel.Contractor.SystemParams.CreateDbObjects(); | ||||
|         IronIntel.Contractor.IronIntelHost.Init(); | ||||
|        // FI.FIC.DataProviders.Alert.Alertmanager.Instance.Start(); | ||||
|         //FI.FIC.Models.ScheduleService.Instance.Start(); | ||||
|  | ||||
|       //  FI.FIC.Email.ChartProvider.StartSend(); | ||||
|  | ||||
|         //IronIntel.Contractor.Maintenance.IATCAlertsSyncService.Start(); | ||||
|     } | ||||
|  | ||||
|     void Application_End(object sender, EventArgs e) | ||||
|     { | ||||
|         //FI.FIC.Models.ScheduleService.Instance.Stop(); | ||||
|         //FI.FIC.DataProviders.Alert.Alertmanager.Instance.Stop(); | ||||
|          | ||||
|       //  FI.FIC.Email.ChartProvider.EndSend(); | ||||
|         //IronIntel.Contractor.Maintenance.IATCAlertsSyncService.Stop(); | ||||
|     } | ||||
|  | ||||
|     void Application_Error(object sender, EventArgs e) | ||||
|     { | ||||
|         // Code that runs when an unhandled error occurs | ||||
|         var exception = Server.GetLastError(); | ||||
|         if (exception is HttpUnhandledException) | ||||
|         { | ||||
|             exception = exception.InnerException; | ||||
|             // build error strings | ||||
|             var sb = new StringBuilder(); | ||||
|             while (exception != null) | ||||
|             { | ||||
|                 sb.AppendLine(exception.Message); | ||||
|                 sb.AppendLine(); | ||||
|                 sb.AppendLine(exception.StackTrace); | ||||
|                 sb.AppendLine(new string('-', 20)); | ||||
|                 sb.AppendLine("\n\n"); | ||||
|                 exception = exception.InnerException; | ||||
|             } | ||||
|             var bs = Encoding.UTF8.GetBytes(sb.ToString()); | ||||
|  | ||||
|             // emulate the errorpage | ||||
|             string result = null; | ||||
|             var url = Request.Url; | ||||
|             var addr = string.Format("{0}://{1}:{2}{3}/ErrorPage.aspx", url.Scheme, url.Host, url.Port, Request.ApplicationPath); | ||||
|             var request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(addr); | ||||
|             request.Method = "POST"; | ||||
|             using (var req = request.GetRequestStream()) | ||||
|             { | ||||
|                 req.Write(bs, 0, bs.Length); | ||||
|             } | ||||
|             using (var response = request.GetResponse()) | ||||
|             { | ||||
|                 using (var reader = new System.IO.StreamReader(response.GetResponseStream())) | ||||
|                 { | ||||
|                     result = reader.ReadToEnd(); | ||||
|                 } | ||||
|             } | ||||
|             if (result != null) | ||||
|             { | ||||
|                 Response.Write(result); | ||||
|             } | ||||
|  | ||||
|             Response.StatusCode = 200; | ||||
|             Server.ClearError(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     void Session_Start(object sender, EventArgs e) | ||||
|     { | ||||
|         // Code that runs when a new session is started | ||||
|  | ||||
|     } | ||||
|  | ||||
|     void Session_End(object sender, EventArgs e) | ||||
|     { | ||||
|         // Code that runs when a session ends.  | ||||
|         // Note: The Session_End event is raised only when the sessionstate mode | ||||
|         // is set to InProc in the Web.config file. If session mode is set to StateServer  | ||||
|         // or SQLServer, the event is not raised. | ||||
|  | ||||
|     } | ||||
|  | ||||
| </script> | ||||
							
								
								
									
										719
									
								
								Site/Inspection/FuelReport.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										719
									
								
								Site/Inspection/FuelReport.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,719 @@ | ||||
| <%@ Page Title="" Language="C#" MasterPageFile="~/IronIntelMasterPage.master" AutoEventWireup="true" CodeFile="FuelReport.aspx.cs" Inherits="FuelReport" %> | ||||
|  | ||||
| <asp:Content ID="Content1" ContentPlaceHolderID="holder_head" runat="Server"> | ||||
|     <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("css/sections.css")%>" rel="stylesheet" type="text/css" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("../css/tabcontrol.css")%>" rel="stylesheet" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" type="text/css" /> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script> | ||||
|     <style type="text/css"> | ||||
|         .fa { | ||||
|             display: inline-block; | ||||
|             font: normal normal normal 14px/1 FontAwesome; | ||||
|             font-size: inherit; | ||||
|             text-rendering: auto; | ||||
|             -webkit-font-smoothing: antialiased; | ||||
|             -moz-osx-font-smoothing: grayscale; | ||||
|         } | ||||
|  | ||||
|         .icon-settings { | ||||
|             width: 20px; | ||||
|             height: 20px; | ||||
|         } | ||||
|  | ||||
|             .icon-settings::before { | ||||
|                 content: '\f0ae'; | ||||
|             } | ||||
|     </style> | ||||
|     <style> | ||||
|         .maintable { | ||||
|             border-collapse: collapse; | ||||
|             width: 100%; | ||||
|             page-break-inside: avoid; | ||||
|             line-height: 24px; | ||||
|             table-layout: fixed; | ||||
|         } | ||||
|  | ||||
|             .maintable td { | ||||
|                 /*border: 1px solid #a9a9a9;*/ | ||||
|                 padding-left: 3px; | ||||
|                 padding-right: 3px; | ||||
|             } | ||||
|  | ||||
|             .maintable .mainlabel { | ||||
|                 font-weight: bold; | ||||
|             } | ||||
|  | ||||
|         .catelog { | ||||
|             color: #444; | ||||
|             height: 30px; | ||||
|             line-height: 30px; | ||||
|             margin-top: 8px; | ||||
|             padding-left: 10px; | ||||
|             padding-right: 10px; | ||||
|             font-size: 20px; | ||||
|             font-style: italic; | ||||
|         } | ||||
|  | ||||
|         .page { | ||||
|             /*background-color: #d3d3d3;*/ | ||||
|             /*height: 52px;*/ | ||||
|             line-height: 52px; | ||||
|             margin-top: 8px; | ||||
|             padding-left: 10px; | ||||
|             padding-right: 10px; | ||||
|             font-size: 26px; | ||||
|             font-weight: 700; | ||||
|             color: #333; | ||||
|         } | ||||
|  | ||||
|         .section { | ||||
|             /*background-color: #eaeaea;*/ | ||||
|             /*height: 40px;*/ | ||||
|             line-height: 40px; | ||||
|             padding-left: 30px; | ||||
|             padding-right: 10px; | ||||
|             font-size: 20px; | ||||
|             font-weight: 400; | ||||
|             color: #222; | ||||
|         } | ||||
|  | ||||
|         .question { | ||||
|             min-height: 30px; | ||||
|             line-height: 30px; | ||||
|             padding-left: 70px; | ||||
|             padding-right: 10px; | ||||
|             font-size: 14px; | ||||
|             font-weight: bold; | ||||
|             color: #111; | ||||
|             /*display: flex;*/ | ||||
|         } | ||||
|  | ||||
|         .answer { | ||||
|             min-height: 30px; | ||||
|             line-height: 30px; | ||||
|             padding-left: 90px; | ||||
|             padding-right: 10px; | ||||
|         } | ||||
|  | ||||
|         .media { | ||||
|             width: 120px; | ||||
|             height: 120px; | ||||
|             margin-top: 5px; | ||||
|             margin-bottom: 10px; | ||||
|             margin-right: 10px; | ||||
|             cursor: pointer; | ||||
|             border: 1px solid #b0b0b0; | ||||
|             border-radius: 2px; | ||||
|             box-shadow: rgba(0, 0, 0, 0.4); | ||||
|             text-align: center; | ||||
|             float: left; | ||||
|         } | ||||
|  | ||||
|         .video { | ||||
|             line-height: 120px; | ||||
|             font-size: 30px; | ||||
|             margin: 0 auto; | ||||
|             font-family: 'Fontawesome'; | ||||
|         } | ||||
|  | ||||
|             .video::before { | ||||
|                 content: '\f03d'; | ||||
|             } | ||||
|  | ||||
|         .circle { | ||||
|             width: 12px; | ||||
|             height: 12px; | ||||
|             border-radius: 6px; | ||||
|             display: inline-block; | ||||
|         } | ||||
|  | ||||
|         .label_level { | ||||
|             float: right; | ||||
|             margin-right: 10px; | ||||
|         } | ||||
|  | ||||
|         .tab_header { /*corver*/ | ||||
|             font-size: 18px; | ||||
|             font-weight: 500; | ||||
|         } | ||||
|  | ||||
|             .tab_header [data-href] { | ||||
|                 line-height: 16px; | ||||
|                 height: 16px; | ||||
|             } | ||||
|  | ||||
|                 .tab_header [data-href].selected { | ||||
|                     line-height: 20px; | ||||
|                     height: 20px; | ||||
|                 } | ||||
|  | ||||
|         .assettrmobile { | ||||
|             display: none; | ||||
|         } | ||||
|  | ||||
|         #right_popup { | ||||
|             left: 320px; | ||||
|         } | ||||
|  | ||||
|         .inspect-asset td b { | ||||
|             text-align: right; | ||||
|         } | ||||
|  | ||||
|         @media screen and (orientation: portrait) { | ||||
|             #right_popup { | ||||
|                 left: 0; | ||||
|             } | ||||
|  | ||||
|             .inspect-asset td b { | ||||
|                 text-align: left; | ||||
|             } | ||||
|  | ||||
|             .inspect-asset td span { | ||||
|                 display: block; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         #divreport { | ||||
|             padding-left: 50px; | ||||
|         } | ||||
|  | ||||
|         .img-logo { | ||||
|             width: 100px; | ||||
|         } | ||||
|  | ||||
|         .headertable { | ||||
|             width: 100%; | ||||
|             margin-bottom: 20px; | ||||
|         } | ||||
|  | ||||
|         .footertable { | ||||
|             width: 100%; | ||||
|             margin-top: 30px; | ||||
|             margin-bottom: 20px; | ||||
|         } | ||||
|     </style> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/controls.js")%>" type="text/javascript"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/vue.min.js")%>"></script> | ||||
|     <script>Vue.config.productionTip = false; Vue.config.silent = true;</script> | ||||
|     <script data-main="<%=GetFileUrlWithVersion("js/view-main.js")%>" src="<%=GetFileUrlWithVersion("../js/lib/require-2.3.6.min.js")%>"></script> | ||||
|     <script type="text/javascript"> | ||||
|         var reportid = "<%=ReportID %>"; | ||||
|         var teamintelligence =<%=TeamIntelligence ?"true":"false"%>; | ||||
|         var isAdmin = <%=IsAdminOrSuper ? "true" : "false"%>; | ||||
|         var vm; | ||||
|         var vm1; | ||||
|         var reportdata; | ||||
|  | ||||
|         function inspectionrequest(method, param, callback, error) { | ||||
|             _network.request("Inspection/Inspection.aspx", -1, method, param, callback, error || function (e) { | ||||
|                 showAlert(GetTextByKey('P_IPT_PAGEERROR', 'An unknown error occurred.  Please refresh page.'), GetTextByKey('P_IPT_QUERY', 'Query')); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function showRightPopup(state) { | ||||
|             if (state) { | ||||
|                 $('#content').css('overflow', 'hidden'); | ||||
|                 $("#mask_bg").show(); | ||||
|                 $("#right_popup").css("left", $("#set_left").width()).show(); | ||||
|             } | ||||
|             else { | ||||
|                 $('#content').css('overflow', ''); | ||||
|                 $("#mask_bg").hide(); | ||||
|                 $("#right_popup").hide(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function OnDownLoad() { | ||||
|             window.open("Inspection.aspx?rt=f&t=3&id=" + reportid + "&team=" + (teamintelligence ? 1 : 0), '_blank'); | ||||
|         } | ||||
|  | ||||
|         function OnPrint() { | ||||
|             if (navigator.userAgent.indexOf('Firefox') >= 0 || | ||||
|                 navigator.userAgent.indexOf('Opera') >= 0) { | ||||
|                 window.open("Inspection.aspx?rt=f&t=4&id=" + reportid + "&team=" + (teamintelligence ? 1 : 0), '_blank'); | ||||
|                 return; | ||||
|             } | ||||
|             $("#ifdiv").attr('src', "Inspection.aspx?rt=f&t=4&id=" + reportid + "&team=" + (teamintelligence ? 1 : 0)); | ||||
|             if (!$("#ifdiv").data('inited')) { | ||||
|                 $("#ifdiv").on('load', function () { | ||||
|                     onifload(); | ||||
|                 }).show(); | ||||
|                 $("#ifdiv").data('inited', 1); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function onifload() { | ||||
|             var iframe = document.getElementById('ifdiv'); | ||||
|             iframe.contentWindow.focus(); | ||||
|             iframe.contentWindow.print(); | ||||
|         } | ||||
|  | ||||
|         var grid_fddt; | ||||
|         function showFuelDetailList(data) { | ||||
|             var rows = []; | ||||
|             for (var i = 0; i < data.length; i++) { | ||||
|                 var r = data[i]; | ||||
|                 for (var j in r) { | ||||
|                     if (j === "AssetMeter") { | ||||
|                         r[j] = { DisplayValue: r["AssetMeterStr"], Value: r[j] }; | ||||
|                     } | ||||
|                     if (j === "MasterMeter") { | ||||
|  | ||||
|                         r[j] = { DisplayValue: r["MasterMeterStr"], Value: r[j] }; | ||||
|                     } | ||||
|                     if (j === "QtyPumped") { | ||||
|  | ||||
|                         r[j] = { DisplayValue: r["QtyPumpedStr"], Value: r[j] }; | ||||
|                     } | ||||
|                     if (j === "QtyOnTruck") { | ||||
|  | ||||
|                         r[j] = { DisplayValue: r["QtyOnTruckStr"], Value: r[j] }; | ||||
|                     } | ||||
|                 } | ||||
|                 var fr = { Values: r }; | ||||
|                 rows.push(fr); | ||||
|             } | ||||
|  | ||||
|             var height = 28 * data.length; | ||||
|             if (height < 300) | ||||
|                 height = 300; | ||||
|             $("#fueldetaillist").css("height", height); | ||||
|             grid_fddt.setData(rows); | ||||
|         } | ||||
|  | ||||
|         function InitGridData() { | ||||
|             grid_fddt = new GridView('#fueldetaillist'); | ||||
|             grid_fddt.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_IPT_EQUIPMENT", "Equipment #"), valueIndex: 'AssetName', css: { 'width': 150, 'text-align': 'left' } }, | ||||
|                 { name: 'AssetMeter', caption: GetTextByKey("P_IPT_HOURMETERODOMETER", "Hour Meter/Odometer"), valueIndex: 'AssetMeter', css: { 'width': 136, 'text-align': 'right' } }, | ||||
|                 { name: 'MasterMeter', caption: GetTextByKey("P_IPT_MASTERMETER", "Master Meter"), valueIndex: 'MasterMeter', css: { 'width': 88, 'text-align': 'right' } }, | ||||
|                 { name: 'QtyPumped', caption: GetTextByKey("P_IPT_GALLONSPUMPED", "Gallons Pumped"), valueIndex: 'QtyPumped', css: { 'width': 104, 'text-align': 'right' } }, | ||||
|                 { name: 'QtyOnTruck', caption: GetTextByKey("P_IPT_GALLONSONTRUCK", "Gallons on Truck"), valueIndex: 'QtyOnTruck', css: { 'width': 104, 'text-align': 'right' } }, | ||||
|                 { name: 'JobsiteCode', caption: GetTextByKey("P_IPT_CERTJOB", "CERT JOB #"), valueIndex: 'JobsiteCode', css: { 'width': 150, 'text-align': 'left' } }, | ||||
|                 { name: 'JobsiteName', caption: GetTextByKey("P_IPT_LOCATION", "Location"), valueIndex: 'JobsiteName', css: { 'width': 150, 'text-align': 'left' } }, | ||||
|                 { name: 'EquipmentCondition', caption: GetTextByKey("P_IPT_EQUIPMENTCONDITION", "Equipment Condition"), valueIndex: 'EquipmentCondition', 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; | ||||
|                 col.allowFilter = list_columns[hd].allowFilter; | ||||
|                 columns.push(col); | ||||
|             } | ||||
|             grid_fddt.canMultiSelect = false; | ||||
|             grid_fddt.columns = columns; | ||||
|             grid_fddt.init(); | ||||
|  | ||||
|             grid_fddt.selectedrowchanged = function (rowindex) { | ||||
|                 var rowdata = grid_fddt.source[rowindex]; | ||||
|                 if (rowdata) { | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|  | ||||
|         function showEmailList(data) { | ||||
|             var rows = []; | ||||
|             for (var i = 0; i < data.length; i++) { | ||||
|                 var r = data[i]; | ||||
|                 if (!r.Selected) | ||||
|                     r.Selected = false; | ||||
|                 for (var j in r) { | ||||
|                     if (j === "UID") | ||||
|                         r[j] = { DisplayValue: r["Name"] + "(" + r["ID"] + ")", Value: r[j] }; | ||||
|                 } | ||||
|                 var fr = { Values: r }; | ||||
|                 rows.push(fr); | ||||
|             } | ||||
|  | ||||
|             $("#contactlist").css("height", 270); | ||||
|             grid_dtemail.setData(rows); | ||||
|         } | ||||
|  | ||||
|         var grid_dtemail; | ||||
|         function InitEmailGridData() { | ||||
|             grid_dtemail = new GridView('#contactlist'); | ||||
|             grid_dtemail.lang = { | ||||
|                 all: GetTextByKey("P_GRID_ALL", "(All)"), | ||||
|                 ok: GetTextByKey("P_GRID_OK", "OK"), | ||||
|                 reset: GetTextByKey("P_GRID_RESET", "Reset") | ||||
|             }; | ||||
|             var list_columns = [ | ||||
|                 { name: 'UID', caption: GetTextByKey("P_IPT_CONTACTNAME", "Contact Name"), valueIndex: 'UID', css: { 'width': 320, 'text-align': 'left' } }, | ||||
|                 //{ name: 'ContactType', caption: GetTextByKey("P_IPT_CONTACTTYPE", "Contact Type"), valueIndex: 'ContactType', css: { 'width': 148, 'text-align': 'left' } }, | ||||
|                 //{ name: 'Text', caption: GetTextByKey("P_MV_TEXT", "Text"), valueIndex: 'Text', type: 3, css: { 'width': 45, 'text-align': 'center' } }, | ||||
|                 { name: 'Selected', caption: GetTextByKey("P_IPT_EMAIL", "Email"), valueIndex: 'Selected', type: 3, css: { 'width': 45, '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 (list_columns[hd].type) { | ||||
|                     col.type = list_columns[hd].type; | ||||
|                 } | ||||
|                 columns.push(col); | ||||
|             } | ||||
|             grid_dtemail.canMultiSelect = false; | ||||
|             grid_dtemail.columns = columns; | ||||
|             grid_dtemail.init(); | ||||
|  | ||||
|             grid_dtemail.selectedrowchanged = function (rowindex) { | ||||
|                 var rowdata = grid_dtemail.source[rowindex]; | ||||
|                 if (rowdata) { | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $(function () { | ||||
|             $('#divLeftTitle').remove(); | ||||
|             $('#content').css('margin-left', 0); | ||||
|             $('#fuelrpt_headers_left').html(''); | ||||
|             $('#fuelrpt_headers_middle').html(''); | ||||
|             $('#fuelrpt_headers_right').html(''); | ||||
|             $('#fuelrpt_footers_left').html(''); | ||||
|             $('#fuelrpt_footers_middle').html(''); | ||||
|             $('#fuelrpt_footers_right').html(''); | ||||
|             InitGridData(); | ||||
|             InitEmailGridData(); | ||||
|  | ||||
|             vm = new Vue({ | ||||
|                 el: '#tab_report1', | ||||
|                 data: { | ||||
|                     report: { | ||||
|                         Asset: {}, | ||||
|                         Template: {} | ||||
|                     } | ||||
|                 }, | ||||
|                 methods: { | ||||
|                     reload: function (data) { | ||||
|                         this.report = data; | ||||
|                     } | ||||
|                 } | ||||
|             }); | ||||
|             vm1 = new Vue({ | ||||
|                 el: '#tab_report2', | ||||
|                 data: { | ||||
|                     report: { | ||||
|                         Asset: {}, | ||||
|                         Template: {} | ||||
|                     } | ||||
|                 }, | ||||
|                 methods: { | ||||
|                     reload: function (data) { | ||||
|                         this.report = data; | ||||
|                     } | ||||
|                 } | ||||
|             }); | ||||
|  | ||||
|             GetFuelReport(); | ||||
|  | ||||
|             $('#dialog_sendemail').dialog(function () { | ||||
|                 $('#mask_bg').hide(); | ||||
|             }); | ||||
|  | ||||
|             $('#sendlocation_search').bind('input propertychange', function () { | ||||
|                 searchEmail(false); | ||||
|             }); | ||||
|  | ||||
|             $('#sendlocation_search').keydown(function () { | ||||
|                 searchEmail(false); | ||||
|             }); | ||||
|  | ||||
|             if (!canExport) { | ||||
|                 $('#button-print').hide(); | ||||
|                 $('#button-dl').hide(); | ||||
|             } | ||||
|  | ||||
|         }); | ||||
|         function GetFuelReport() { | ||||
|             showmaskbg(true); | ||||
|             var p = JSON.stringify([teamintelligence, htmlencode(reportid)]); | ||||
|             inspectionrequest("GetFuelReport", p, function (data) { | ||||
|                 if (typeof (data) === "string") { | ||||
|                     showAlert(data, GetTextByKey("P_IPT_ERROR", 'Error')); | ||||
|                 } | ||||
|                 else { | ||||
|                     reportdata = data; | ||||
|                     if (data.FuelDetailItems) | ||||
|                         showFuelDetailList(data.FuelDetailItems); | ||||
|                     vm.reload(data); | ||||
|                     vm1.reload(data); | ||||
|                     $('#fuelrpt_headers_left').html(data.HeaderFooter.HeaderLeft.replace(/\n/g, '<br/>')); | ||||
|                     $('#fuelrpt_headers_middle').html(data.HeaderFooter.HeaderMiddle.replace(/\n/g, '<br/>')); | ||||
|                     $('#fuelrpt_headers_right').html(data.HeaderFooter.HeaderRight.replace(/\n/g, '<br/>')); | ||||
|                     $('#fuelrpt_footers_left').html(data.HeaderFooter.FooterLeft.replace(/\n/g, '<br/>')); | ||||
|                     $('#fuelrpt_footers_middle').html(data.HeaderFooter.FooterMiddle.replace(/\n/g, '<br/>')); | ||||
|                     $('#fuelrpt_footers_right').html(data.HeaderFooter.FooterRight.replace(/\n/g, '<br/>')); | ||||
|                 } | ||||
|  | ||||
|                 showmaskbg(false); | ||||
|             }, function (err) { | ||||
|                 showmaskbg(false); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         function CheckEmail(mail) { | ||||
|             var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; | ||||
|             if (mail.length == 0) | ||||
|                 return true; | ||||
|             return filter.test(mail); | ||||
|         } | ||||
|  | ||||
|         function GetEmailList() { | ||||
|             inspectionrequest("GetFuelLogEmailList", '', function (data) { | ||||
|                 if (typeof (data) !== "string") { | ||||
|                     isloademail = true; | ||||
|                     allemails = data; | ||||
|                     showEmailList(data); | ||||
|                 } | ||||
|             }, function (err) { | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function searchEmail(newopen) {//newopen新打开 | ||||
|             var filter = $('#sendlocation_search').val().trim().toLowerCase(); | ||||
|             if (isloademail && allemails) { | ||||
|                 var emails = []; | ||||
|                 for (var i = 0; i < allemails.length; i++) { | ||||
|                     var m = allemails[i]; | ||||
|                     if (newopen) { | ||||
|                         m.Selected = false; | ||||
|                         emails.push(m); | ||||
|                     } | ||||
|                     else { | ||||
|                         if (!m.Selected) { | ||||
|                             if (m.ID.toLowerCase().indexOf(filter) >= 0 || m.Name.toLowerCase().indexOf(filter) >= 0) | ||||
|                                 emails.push(m); | ||||
|                         } | ||||
|                         else | ||||
|                             emails.push(m); | ||||
|                     } | ||||
|                 } | ||||
|                 showEmailList(emails); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         var isloademail = false; | ||||
|         var allemails = []; | ||||
|         function openSendEmail() { | ||||
|             $('#sendlocation_search').val('').attr('placeholder', GetTextByKey('P_IPT_SEARCH','Search')); | ||||
|              | ||||
|             if (!isloademail) | ||||
|                 GetEmailList(); | ||||
|             else | ||||
|                 searchEmail(true); | ||||
|  | ||||
|             $('#sendlocation_otheremailaddress').val(''); | ||||
|             $('#sendlocation_desc').val(''); | ||||
|             $('#mask_bg').show(); | ||||
|             $('#dialog_sendemail .dialog-title span.title').text(GetTextByKey("P_IPT_SENDEMAIL", 'Send Email')); | ||||
|             //$('#mask_bg').show(); | ||||
|             $('#dialog_sendemail') | ||||
|                 .attr('act', 'edit') | ||||
|                 .css({ | ||||
|                     'width': 510, | ||||
|                     'top': (document.documentElement.clientHeight - $('#dialog_sendemail').height()) / 4, | ||||
|                     'left': (document.documentElement.clientWidth - $('#dialog_sendemail').width()) / 2 | ||||
|                 }) | ||||
|                 .showDialogfixed(); | ||||
|  | ||||
|             setTimeout(function () { | ||||
|                 $("#contactlist").css("height", 270); | ||||
|                 grid_dtemail && grid_dtemail.resize(); | ||||
|             }); | ||||
|         } | ||||
|         function onSendEmail() { | ||||
|             if (grid_dtemail.source.length == 0) { | ||||
|                 $('#dialog_sendemail').hideDialog(); | ||||
|                 $('#mask_bg').hide(); | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
|             var emailaddress = []; | ||||
|  | ||||
|             var otheremailaddressstr = $('#sendlocation_otheremailaddress').val(); | ||||
|             if (otheremailaddressstr !== "") | ||||
|                 emailaddress = otheremailaddressstr.split(';'); | ||||
|             for (var i = 0; i < emailaddress.length; i++) { | ||||
|                 if (!CheckEmail($.trim(emailaddress[i]))) { | ||||
|                     showAlert(GetTextByKey("P_IPT_OTHEREMAILADDRESSISINVALID", 'The other email address {0} is invalid.').replace('{0}', emailaddress[i]), GetTextByKey("P_IPT_SENDEMAIL", 'Send Email')); | ||||
|                     return; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             for (var i = 0; i < grid_dtemail.source.length; i++) { | ||||
|                 var ct = grid_dtemail.source[i].Values; | ||||
|                 if (ct.Selected) | ||||
|                     emailaddress.push(ct.ID); | ||||
|             } | ||||
|  | ||||
|             if (emailaddress.length == 0) { | ||||
|                 $('#dialog_sendemail').hideDialog(); | ||||
|                 $('#mask_bg').hide(); | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
|             var p = [teamintelligence, reportid, htmlencode(JSON.stringify(emailaddress))]; | ||||
|             inspectionrequest("SendFuelTruckFuelReport", JSON.stringify(p), function (data) { | ||||
|                 if (data !== "OK") { | ||||
|                     showAlert(data, GetTextByKey("P_IPT_ERROR", 'Error')); | ||||
|                 } | ||||
|                 else { | ||||
|                     //showAlert(GetTextByKey("P_IPT_MESSAGESENT", 'Message sent.'), GetTextByKey("P_IPT_SENDEMAIL", 'Send Email')); | ||||
|                     $('#dialog_sendemail').hideDialog(); | ||||
|                     $('#mask_bg').hide(); | ||||
|                 } | ||||
|  | ||||
|             }, function (err) { | ||||
|                 showAlert(GetTextByKey("P_IPT_FAILEDTOSENDEMAIL", 'Failed to send email.'), GetTextByKey("P_IPT_SENDEMAIL", 'Send Email')); | ||||
|             }); | ||||
|         } | ||||
|     </script> | ||||
| </asp:Content> | ||||
| <asp:Content ID="Content2" ContentPlaceHolderID="holder_content" runat="Server"> | ||||
|     <div class="function_title" style="text-align: right; margin-top: 2px; margin-bottom: 2px;"> | ||||
|         <span id="button-email" class="sbutton iconmail" onclick="openSendEmail();" data-lgid="P_IPT_SENDEMAIL">Send Email</span> | ||||
|         <span id="button-dl" class="sbutton icondownload" onclick="OnDownLoad();" data-lgid="P_IPT_DOWNLOAD">Download</span> | ||||
|         <span id="button-print" class="sbutton iconprint" onclick="OnPrint();" data-lgid="P_IPT_PRINT">Print</span> | ||||
|     </div> | ||||
|     <div id="divreport" style="width: 1120px; margin: 0px auto;"> | ||||
|         <table class="maintable"> | ||||
|             <tr> | ||||
|                 <td style="width: 100px;"><%=Logo2 %></td> | ||||
|                 <td> | ||||
|                     <h1>Fuel Log * Shipping Paper</h1> | ||||
|                 </td> | ||||
|             </tr> | ||||
|         </table> | ||||
|         <table class="headertable"> | ||||
|             <tr> | ||||
|                 <td id="fuelrpt_headers_left"></td> | ||||
|                 <td id="fuelrpt_headers_middle" style="text-align: center;"></td> | ||||
|                 <td id="fuelrpt_headers_right" style="text-align: right;"></td> | ||||
|             </tr> | ||||
|         </table> | ||||
|         <table id="tab_report1" class="maintable"> | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <label data-lgid="P_IPT_EMPLOYEENUMBER_COLON">Employee #:</label> | ||||
|                     {{report.EmployeeNumber}} </td> | ||||
|                 <td> | ||||
|                     <label style="margin-left: 50px;" data-lgid="P_IPT_DATE_COLON">Date:</label> | ||||
|                     {{report.LocalCalendarDateStr}}</td> | ||||
|                 <td> | ||||
|                     <label style="margin-left: 50px;" data-lgid="P_IPT_EMPLOYEENAME_COLON">Employee Name:</label> | ||||
|                     {{report.EmployeeName}}</td> | ||||
|                 <td> | ||||
|                     <label style="margin-left: 50px;" data-lgid="P_IPT_FUELTRUCKNUMBER_COLON">Fuel Truck#:</label> | ||||
|                     {{report.AssetName}}</td> | ||||
|             </tr> | ||||
|         </table> | ||||
|         <table class="maintable"> | ||||
|             <tr> | ||||
|                 <td id="tdgrid" style="padding: 0;"> | ||||
|                     <div id="fueldetaillist" style="margin-top: 10px; width: 1120px; height: 300px;"></div> | ||||
|                 </td> | ||||
|                 <td></td> | ||||
|             </tr> | ||||
|         </table> | ||||
|         <table id="tab_report2" class="maintable"> | ||||
|             <tr> | ||||
|                 <td style="width: 830px;"> | ||||
|                     <label data-lgid="P_IPT_IWITNESSEDANACCIDENTINJURYTODAY_COLON">I witnessed an accident/injury today:</label> | ||||
|                     {{report.WitnessedAccident}}</td> | ||||
|                 <td> | ||||
|                     <label data-lgid="P_IPT_BULKPUMPMTRBEGINNING_COLON">Bulk Pump Mtr Beginning: </label> | ||||
|                     {{report.StartMasterMeterStr}} </td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <label data-lgid="P_IPT_IWASINVOLVEDINANACCIDENTTODAY_COLON">I was involved in an accident today: </label> | ||||
|                     {{report.InvolvedAccident}} </td> | ||||
|                 <td> | ||||
|                     <label data-lgid="P_IPT_BULKPUMPMTRENDING_COLON">Bulk Pump Mtr Ending: </label> | ||||
|                     {{report.EndMasterMeterStr}}</td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <label data-lgid="P_IPT_IFYESTIPS">If YES, your supervisor must be notified and an accident report filled out.</label></td> | ||||
|                 <td> | ||||
|                     <label data-lgid="P_IPT_GALLONSDISPENSED_COLON">Gallons Dispensed:</label> | ||||
|                     {{report.TotalQtyStr}}</td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|                 <td></td> | ||||
|                 <td> | ||||
|                     <label data-lgid="P_IPT_INCHESLEFTONTRUCK_COLON">Inches Left on Truck:</label> | ||||
|                     {{report.InchesLeftonTruckStr}}</td> | ||||
|             </tr> | ||||
|         </table> | ||||
|         <table class="footertable"> | ||||
|             <tr> | ||||
|                 <td id="fuelrpt_footers_left"></td> | ||||
|                 <td id="fuelrpt_footers_middle" style="text-align: center;"></td> | ||||
|                 <td id="fuelrpt_footers_right" style="text-align: right;"></td> | ||||
|             </tr> | ||||
|         </table> | ||||
|  | ||||
|     </div> | ||||
|     <div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div> | ||||
|     <div id="right_popup" style="display: none; position: absolute; top: 0; right: 0; bottom: 0; background-color: white; overflow: auto;"> | ||||
|     </div> | ||||
|     <iframe id="ifdiv" style="height: 1px; width: 1px; display: none;"></iframe> | ||||
|  | ||||
|     <div class="dialog" id="dialog_sendemail" style="display: none; width: 320px;"> | ||||
|         <div class="dialog-title"><span class="title" data-lgid="P_IPT_SENDEMAIL">Send Email</span><em class="dialog-close"></em></div> | ||||
|         <div class="dialog-content" style="height: 378px;"> | ||||
|             <table style="line-height: 25px;"> | ||||
|                 <tr> | ||||
|                     <td colspan="2" data-lgid="P_IPT_SENDTHISTO">Who do you want to send this to? Select from existing relationships or manual entry.</td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td colspan="2"> | ||||
|                         <input type="text" id="sendlocation_search" style="width: 445px; margin-left: 10px;" placeholder="Search" /></td> | ||||
|                 </tr> | ||||
|                 <tr> | ||||
|                     <td colspan="2"> | ||||
|                         <div id="contactlist" style="height: 270px; width: 450px; margin-left: 10px; margin-right: 10px;"></div> | ||||
|                     </td> | ||||
|                 </tr> | ||||
|                 <tr style="height: 24px;"> | ||||
|                     <td colspan="2" data-lgid="P_IPT_EMAILADDRESSESTIPS">Separate multiple manually entered email or text addresses with a semi-colon (;).</td> | ||||
|                 </tr> | ||||
|                 <tr style="height: 24px;"> | ||||
|                     <td><span data-lgid="P_IPT_OTHEREMAILADDRESS">Other Email Address</span> | ||||
|                     </td> | ||||
|                     <td> | ||||
|                         <input type="text" id="sendlocation_otheremailaddress" style="width: 312px;" autocomplete="off" /></td> | ||||
|                 </tr> | ||||
|             </table> | ||||
|         </div> | ||||
|         <div class="dialog-func"> | ||||
|             <input type="button" value="Cancel" data-lgid="P_IPT_CANCEL" class="dialog-close" tabindex="12" /> | ||||
|             <input type="button" onclick="onSendEmail();" value="Send" data-lgid="P_IPT_SEND" style="width:unset;" tabindex="11" /> | ||||
|             <div class="clear"></div> | ||||
|         </div> | ||||
|     </div> | ||||
| </asp:Content> | ||||
|  | ||||
							
								
								
									
										120
									
								
								Site/Inspection/FuelReport.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										120
									
								
								Site/Inspection/FuelReport.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,120 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Web; | ||||
| using System.Web.UI; | ||||
| using System.Web.UI.WebControls; | ||||
| using Foresight.Fleet.Services.Customer; | ||||
| using Foresight.Fleet.Services.Inspection; | ||||
| using Foresight.Fleet.Services.User; | ||||
| using Foresight.ServiceModel; | ||||
| using IronIntel.Contractor; | ||||
| using IronIntel.Contractor.iisitebase; | ||||
| using IronIntel.Contractor.Site; | ||||
| using IronIntel.Contractor.Users; | ||||
|  | ||||
| public partial class FuelReport : InspectionBasePage | ||||
| { | ||||
|     protected string ReportID; | ||||
|     protected bool TeamIntelligence = false; | ||||
|     public bool ReportReadonly = false; | ||||
|  | ||||
|     private string Logo2html = "<img class=\"img-logo\" src=\"{0}\" style=\" \" />"; | ||||
|     protected string Logo2 = ""; | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     { | ||||
|         CheckUserToken(); | ||||
|         if (!CheckLoginSession()) | ||||
|         { | ||||
|             RedirectToLoginPage(); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             string methodName = Request.Form["MethodName"]; | ||||
|             if (!string.IsNullOrEmpty(methodName)) | ||||
|             { | ||||
|                 ProcessRequest(methodName); | ||||
|             } | ||||
|             else if (!IsPostBack) | ||||
|             { | ||||
|                 var cmp = SystemParams.GetCompanyInfo(); | ||||
|                 this.Title = PageTitle; | ||||
|                 ReportID = Request.Params["rid"]; | ||||
|                 TeamIntelligence = Helper.IsTrue(Request.Params["team"]); | ||||
|                 if (!string.IsNullOrEmpty(ReportID)) | ||||
|                 { | ||||
|                     object ii = GetFuelReportItem(Convert.ToInt64(ReportID)); | ||||
|                     if (ii == null) | ||||
|                     {//没有权限或ID不正确 | ||||
|                         Response.Write("You have no right to access the fuel report."); | ||||
|                         Response.End(); | ||||
|                     } | ||||
|                     //if (ii is TeamInspectItem) | ||||
|                     //    TeamIntelligence = true; | ||||
|                     //ReportReadonly = Helper.IsTrue(Request.Params["ro"]); | ||||
|  | ||||
|                     //if (!ReportReadonly) | ||||
|                     //{ | ||||
|                     //    var user = GetCurrentUser(); | ||||
|                     //    if (user.UserType == IronIntel.Contractor.Users.UserTypes.Common) | ||||
|                     //    { | ||||
|                     //        var client = FleetServiceClientHelper.CreateClient<PermissionProvider>(); | ||||
|                     //        Tuple<Feature, Permissions>[] pmss = client.GetUserPermissions(SystemParams.CompanyID, user.IID); | ||||
|  | ||||
|                     //        if (pmss.Length > 0) | ||||
|                     //        { | ||||
|                     //            Tuple<Feature, Permissions> reportpms = null; | ||||
|                     //            if (TeamIntelligence) | ||||
|                     //                reportpms = pmss.FirstOrDefault(m => m.Item1.Id == Feature.TEAM_REPORTS); | ||||
|                     //            else | ||||
|                     //                reportpms = pmss.FirstOrDefault(m => m.Item1.Id == Feature.INSPECTION_REPORTS); | ||||
|  | ||||
|                     //            if (reportpms == null || reportpms.Item2 == Permissions.ReadOnly) | ||||
|                     //                ReportReadonly = true; | ||||
|                     //        } | ||||
|                     //    } | ||||
|                     //} | ||||
|                 } | ||||
|                 GetLogoHtml(cmp); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|     } | ||||
|     private void GetLogoHtml(CustomerInfo cmp) | ||||
|     { | ||||
|         var root = ResolveUrl("~/"); | ||||
|         var sessionid = GetLoginSessionID(Request); | ||||
|         StringKeyValue kv = UserManagement.GetSiteHederStyleLogo(sessionid); | ||||
|         string styleid = "-1"; | ||||
|         bool hasContractorLogo = false; | ||||
|         if (kv != null) | ||||
|         { | ||||
|             styleid = kv.Key; | ||||
|             hasContractorLogo = Helper.IsTrue(kv.Tag1); | ||||
|         } | ||||
|  | ||||
|         if (cmp.IsContractor) | ||||
|         { | ||||
|             if (hasContractorLogo)//User Contractor | ||||
|             { | ||||
|                 Logo2 = string.Format(Logo2html, root + "titlelogo.ashx?cmpid=" + cmp.ID + "&cmpty=contractor&styid=" + styleid); | ||||
|             } | ||||
|             else if (SystemParams.HasLOGO(cmp.ID))//Contractor | ||||
|             { | ||||
|                 Logo2 = string.Format(Logo2html, root + "titlelogo.ashx?cmpid=" + cmp.ID); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 Logo2 = string.Format("<span class=\"logocenter\">{0}</span>", cmp.Name); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     protected override bool CanDirectAccess | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             return true; | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										306
									
								
								Site/Inspection/Inspection.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										306
									
								
								Site/Inspection/Inspection.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,306 @@ | ||||
| <%@ Page Title="" Language="C#" MasterPageFile="~/IronIntelMasterPage.master" AutoEventWireup="true" CodeFile="Inspection.aspx.cs" Inherits="Inspection" %> | ||||
|  | ||||
| <asp:Content ID="Content1" ContentPlaceHolderID="holder_head" runat="Server"> | ||||
|     <link href="<%=GetFileUrlWithVersion("../css/split.css")%>" rel="stylesheet" type="text/css" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("css/sections.css")%>" rel="stylesheet" type="text/css" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("../css/spectrum.css")%>" rel="stylesheet" type="text/css" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("../css/tabcontrol.css")%>" rel="stylesheet" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" type="text/css" /> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/spectrum.js")%>"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/editableselect.js")%>"></script> | ||||
|     <%--<script src="<%=GetFileUrlWithVersion("../js/split.js")%>"></script>--%> | ||||
|     <style type="text/css"> | ||||
|         .fa { | ||||
|             display: inline-block; | ||||
|             font: normal normal normal 14px/1 FontAwesome; | ||||
|             font-size: inherit; | ||||
|             text-rendering: auto; | ||||
|             -webkit-font-smoothing: antialiased; | ||||
|             -moz-osx-font-smoothing: grayscale; | ||||
|         } | ||||
|  | ||||
|         .icon-menu { | ||||
|             width: 20px; | ||||
|             height: 20px; | ||||
|         } | ||||
|  | ||||
|         .icon-sections::before { | ||||
|             content: '\f03a'; | ||||
|         } | ||||
|  | ||||
|         .icon-templates::before { | ||||
|             content: '\f0ae'; | ||||
|         } | ||||
|  | ||||
|         .icon-packages::before { | ||||
|             content: '\f1b3'; | ||||
|         } | ||||
|  | ||||
|         .icon-report:before { | ||||
|             content: '\f15c'; | ||||
|         } | ||||
|  | ||||
|         .icon-fuellog::before { | ||||
|             content: '\f52f'; | ||||
|         } | ||||
|  | ||||
|         .page_title { | ||||
|             font-size: 24px; | ||||
|         } | ||||
|  | ||||
|         .settings-line { | ||||
|             line-height: 30px; | ||||
|             padding: 0 20px; | ||||
|             box-sizing: border-box; | ||||
|         } | ||||
|  | ||||
|             .settings-line > span { | ||||
|                 display: block; | ||||
|                 padding: 4px 0; | ||||
|             } | ||||
|  | ||||
|             .settings-line > textarea { | ||||
|                 box-sizing: border-box; | ||||
|                 width: 100%; | ||||
|                 height: 70px; | ||||
|                 resize: vertical; | ||||
|             } | ||||
|     </style> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/controls.js")%>" type="text/javascript"></script> | ||||
|     <script data-main="<%=GetFileUrlWithVersion("js/main.js")%>" src="<%=GetFileUrlWithVersion("../js/lib/require-2.3.6.min.js")%>"></script> | ||||
|     <script type="text/javascript"> | ||||
|         var sectiontype = 0;//sectiontype:0 - global,1 - normal | ||||
|         var currenttemplate;//current template in editing | ||||
|         var templatestatus = 0;//templatestatus:0 - draft,1 - published | ||||
|         var templatereadonly = <%=TemplateReadonly ?"true":"false"%>;//published template cannot be edit | ||||
|         var editable = true; | ||||
|         var draggingobj = null; | ||||
|         var IsForesight =<%=IsForesight ?"true":"false"%>; | ||||
|         var IsAdmin =<%=IsAdmin ?"true":"false"%>; | ||||
|         var teamintelligence = false; | ||||
|         var begindate = "<%=BeginDate%>"; | ||||
|         var enddate = "<%=EndDate%>"; | ||||
|  | ||||
|         var ShowTemplate =<%=ShowTemplate ?"true":"false"%>; | ||||
|         var ShowReport =<%=ShowReport ?"true":"false"%>; | ||||
|         var ReportReadonly =<%=ReportReadonly ?"true":"false"%>; | ||||
|         var IsCustomerRecord = <%=IsCustomerRecord ? "true" : "false"%>; | ||||
|         var AllowReassignWorkorders = <%=AllowReassignWorkorders ? "true" : "false"%>; | ||||
|  | ||||
|         function inspectionrequest(method, param, callback, error) { | ||||
|             _network.request("Inspection/Inspection.aspx", -1, method, param, callback, error || function (e) { | ||||
|                 showAlert('An unknown error occurred.  Please refresh page.', 'Query'); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function showRightPopup(state) { | ||||
|             if (state) { | ||||
|                 $("#mask_bg").show(); | ||||
|                 $("#right_popup").css("left", $("#set_left").width()).show(); | ||||
|             } | ||||
|             else { | ||||
|                 $("#mask_bg").hide(); | ||||
|                 $("#right_popup").hide(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function OnPrint(rid) { | ||||
|             $("#ifdiv").attr('src', "Inspection.aspx?rt=f&t=2&id=" + rid); | ||||
|             if (!$("#ifdiv").data('inited')) { | ||||
|                 $("#ifdiv").on('load', function () { | ||||
|                     onifload(); | ||||
|                 }).show(); | ||||
|                 $("#ifdiv").data('inited', 1); | ||||
|             } | ||||
|             //window.open("Inspection.aspx?rt=f&t=2&id=" + reportid, '_blank'); | ||||
|         } | ||||
|  | ||||
|         function onifload() { | ||||
|             var iframe = document.getElementById('ifdiv'); | ||||
|             iframe.contentWindow.focus(); | ||||
|             iframe.contentWindow.print(); | ||||
|         } | ||||
|  | ||||
|         function createSubMenus(items) { | ||||
|             var maintenancesubmenu = $("#inspectsubmenu").empty(); | ||||
|             var ulsubmenus = $('<ul class="lefttitlemenu_ul" style="line-height:32px;"></ul>'); | ||||
|             maintenancesubmenu.append(ulsubmenus); | ||||
|             for (var i = 0; i < items.length; i++) { | ||||
|                 var item = items[i]; | ||||
|                 if (!item) continue; | ||||
|                 var li = $('<li></li>'); | ||||
|                 var a = $('<a></a>').append($("<span></span>").text(item.Title)); | ||||
|                 a.attr('href', '#' + item.ID); | ||||
|                 li.append(a); | ||||
|                 ulsubmenus.append(li); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $(function () { | ||||
|             $("#atemplates").click(function (ev) { | ||||
|                 if ($('#set_left').prop('isexpanded')) | ||||
|                     return; | ||||
|                 if ($('.panel_holder.subitems').is(':visible')) { | ||||
|                     return; | ||||
|                 } | ||||
|                 var items = [{ ID: 'templates/0', Title: GetTextByKey("P_DRAFT", "Draft") }, | ||||
|                     { ID: 'templates/1', Title: GetTextByKey("P_PUBLISHED", "Published") }, | ||||
|                     { ID: 'layouts/0', Title: GetTextByKey("P_LAYOUTS", "Layouts") }]; | ||||
|                 createSubMenus(items); | ||||
|  | ||||
|                 var left = $(this).offset().left; | ||||
|                 var top = $(ev.target).offset().top - 80; | ||||
|                 $('.panel_holder.subitems').css({ | ||||
|                     'opacity': 0, | ||||
|                     'left': 60, | ||||
|                     'right': 'auto', | ||||
|                     'top': top | ||||
|                 }).show().animate({ 'opacity': 1 }, 100); | ||||
|                 $('.panel_holder.subitems .trigle').css({ | ||||
|                     'left': -10,// left - $('.panel_holder.favorites').offset().left, | ||||
|                     'right': 'auto', | ||||
|                     'top': 3 | ||||
|                 }); | ||||
|                 return false; | ||||
|             }); | ||||
|  | ||||
|             $("#apackages").click(function (ev) { | ||||
|                 if ($('#set_left').prop('isexpanded')) | ||||
|                     return; | ||||
|                 if ($('.panel_holder.subitems').is(':visible')) { | ||||
|                     return; | ||||
|                 } | ||||
|                 var items = [{ ID: 'exportpackages', Title: GetTextByKey("P_IPT_EXPORTPACKAGES", "Export Packages") }, | ||||
|                     { ID: 'importpackages', Title: GetTextByKey("P_IPT_IMPORTPACKAGES", "Import Packages") }]; | ||||
|                 createSubMenus(items); | ||||
|  | ||||
|                 var left = $(this).offset().left; | ||||
|                 var top = $(ev.target).offset().top - 80; | ||||
|                 $('.panel_holder.subitems').css({ | ||||
|                     'opacity': 0, | ||||
|                     'left': 60, | ||||
|                     'right': 'auto', | ||||
|                     'top': top | ||||
|                 }).show().animate({ 'opacity': 1 }, 100); | ||||
|                 $('.panel_holder.subitems .trigle').css({ | ||||
|                     'left': -10,// left - $('.panel_holder.favorites').offset().left, | ||||
|                     'right': 'auto', | ||||
|                     'top': 3 | ||||
|                 }); | ||||
|                 return false; | ||||
|             }); | ||||
|         }); | ||||
|     </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 (ShowGlobalSections) | ||||
|                 {%> | ||||
|             <li class="nav_item" data-module="globalsections" data-title-lgid="P_GLOBALSECTIONS"><a href="#globalsections"> | ||||
|                 <div> | ||||
|                     <em class="fa icon-menu icon-sections"></em> | ||||
|                 </div> | ||||
|                 <span data-lgid="P_GLOBALSECTIONS">Global Sections</span></a> | ||||
|             </li> | ||||
|             <%} %> | ||||
|             <%if (ShowTemplate) | ||||
|                 {%> | ||||
|             <li class="nav_item" data-title-lgid="P_TEMPLATES"><a id="atemplates"> | ||||
|                 <div> | ||||
|                     <em class="fa icon-menu icon-templates"></em> | ||||
|                 </div> | ||||
|                 <span data-lgid="P_TEMPLATES">Templates</span></a> | ||||
|             </li> | ||||
|             <li class="nav_item subitem" data-module="templates/0" data-title-lgid="P_DRAFT" style="height: 32px; line-height: 32px; display: none;"><a href="#templates/0"> | ||||
|                 <div style="width: 64px;"> | ||||
|                 </div> | ||||
|                 <span style="color: #666;" data-lgid="P_DRAFT">Draft</span></a> | ||||
|             </li> | ||||
|             <li class="nav_item subitem" data-module="templates/1" data-title-lgid="P_PUBLISHED" style="height: 32px; line-height: 32px; display: none;"><a href="#templates/1"> | ||||
|                 <div style="width: 64px;"> | ||||
|                 </div> | ||||
|                 <span style="color: #666;" data-lgid="P_PUBLISHED">Published</span></a> | ||||
|             </li> | ||||
|             <li class="nav_item subitem" data-module="layouts/0" data-title-lgid="P_LAYOUTS" style="height: 32px; line-height: 32px; display: none;"><a href="#layouts/0"> | ||||
|                 <div style="width: 64px;"> | ||||
|                 </div> | ||||
|                 <span style="color: #666;" data-lgid="P_LAYOUTS">Layouts</span></a> | ||||
|             </li> | ||||
|  | ||||
|             <%if (!TemplateReadonly && ShowExportPackage) | ||||
|                 {%> | ||||
|             <li style="height: 10px;"> | ||||
|                 <hr style="background-color: #d8d8d8; border: none; height: 1px;" /> | ||||
|             </li> | ||||
|  | ||||
|             <li class="nav_item" data-title-lgid="P_IPT_PACKAGES"><a id="apackages"> | ||||
|                 <div> | ||||
|                     <em class="fa icon-menu icon-packages"></em> | ||||
|                 </div> | ||||
|                 <span data-lgid="P_IPT_PACKAGES">Packages</span></a> | ||||
|             </li> | ||||
|             <li class="nav_item subitem" data-module="exportpackages" data-title-lgid="P_IPT_EXPORTPACKAGES" style="height: 32px; line-height: 32px; display: none;"><a href="#exportpackages"> | ||||
|                 <div style="width: 64px;"> | ||||
|                 </div> | ||||
|                 <span style="color: #666;" data-lgid="P_IPT_EXPORTPACKAGES">Export Packages</span></a> | ||||
|             </li> | ||||
|             <li class="nav_item subitem" data-module="importpackages" data-title-lgid="P_IPT_IMPORTPACKAGES" style="height: 32px; line-height: 32px; display: none;"><a href="#importpackages"> | ||||
|                 <div style="width: 64px;"> | ||||
|                 </div> | ||||
|                 <span style="color: #666;" data-lgid="P_IPT_IMPORTPACKAGES">Import Packages</span></a> | ||||
|             </li> | ||||
|             <%} %> | ||||
|             <%} %> | ||||
|  | ||||
|             <%if (ShowReport || ShowFuelLog) | ||||
|                 {%> | ||||
|             <li style="height: 10px;"> | ||||
|                 <hr style="background-color: #d8d8d8; border: none; height: 1px;" /> | ||||
|             </li> | ||||
|             <%} %> | ||||
|  | ||||
|             <%if (ShowReport) | ||||
|                 {%> | ||||
|             <li class="nav_item" data-module="inspections" data-title-lgid="P_INSPECTIONS"><a href="#inspections"> | ||||
|                 <div> | ||||
|                     <em class="fa icon-menu icon-report"></em> | ||||
|                 </div> | ||||
|                 <span data-lgid="P_INSPECTIONS">Inspections</span></a> | ||||
|             </li> | ||||
|             <%} %> | ||||
|             <%if (ShowFuelLog) | ||||
|                 {%> | ||||
|             <li class="nav_item" data-module="fuellog" data-title-lgid="P_IPT_FUELLOG"><a href="#fuellog"> | ||||
|                 <div> | ||||
|                     <em class="fa icon-menu icon-fuellog"></em> | ||||
|                 </div> | ||||
|                 <span data-lgid="P_IPT_FUELLOG">Fuel Log</span></a> | ||||
|             </li> | ||||
|             <%} %> | ||||
|         </ul> | ||||
|         <div class="hostmask maskbg" style="display: none;"></div> | ||||
|     </div> | ||||
|     <div id="set_right" style="height: 100%; overflow: auto;"> | ||||
|         <div class="loading_holder"> | ||||
|             <div class="loading_icon icn icn-spin"></div> | ||||
|         </div> | ||||
|     </div> | ||||
|     <div class="panel_holder subitems"> | ||||
|         <div id="inspectsubmenu" class="menupanel panel"> | ||||
|         </div> | ||||
|         <div class="trigle" style="left: -12px; right: auto;"></div> | ||||
|         <div class="trigle white" style="left: -12px; right: auto;"></div> | ||||
|     </div> | ||||
|  | ||||
|     <div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div> | ||||
|     <div id="right_popup" style="display: none; position: absolute; left: 250px; top: 0; right: 0; bottom: 0; background-color: white; overflow: auto;"> | ||||
|     </div> | ||||
|     <div id="right_popup1" style="display: none; position: absolute; left: 250px; top: 0; right: 0; bottom: 0; background-color: white; overflow: auto;"></div> | ||||
|     <iframe id="ifdiv" style="position: absolute; top: -9999px; height: 1px; width: 1px; border: 0; display: none;"></iframe> | ||||
| </asp:Content> | ||||
|  | ||||
							
								
								
									
										130
									
								
								Site/Inspection/Inspection.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										130
									
								
								Site/Inspection/Inspection.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,130 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Web; | ||||
| using System.Web.UI; | ||||
| using System.Web.UI.WebControls; | ||||
| using Foresight.Fleet.Services.User; | ||||
| using IronIntel.Contractor; | ||||
| using IronIntel.Contractor.Site; | ||||
|  | ||||
| public partial class Inspection : InspectionBasePage | ||||
| { | ||||
|     public bool ShowTemplate = false; | ||||
|     public bool TemplateReadonly = false; | ||||
|     public bool ShowReport = false; | ||||
|     public bool ReportReadonly = false; | ||||
|     public bool ShowGlobalSections = false; | ||||
|     public bool ShowFuelLog = false; | ||||
|     public bool ShowExportPackage = false; | ||||
|     public string BeginDate = ""; | ||||
|     public string EndDate = ""; | ||||
|     public bool IsCustomerRecord = false; | ||||
|     public bool AllowReassignWorkorders = false; | ||||
|  | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     { | ||||
|         if (!CheckLoginSession()) | ||||
|         { | ||||
|             RedirectToLoginPage(); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             string methodName = Request.Form["MethodName"]; | ||||
|             string requesttype = Request.Params["rt"]; | ||||
|             if (!string.IsNullOrEmpty(methodName)) | ||||
|             { | ||||
|                 ProcessRequest(methodName); | ||||
|             } | ||||
|             else if (!string.IsNullOrEmpty(requesttype) && requesttype.ToLower() == "f") | ||||
|             { | ||||
|                 ProcessFileRequest(); | ||||
|             } | ||||
|             else if (!IsPostBack) | ||||
|             { | ||||
|                 this.Title = PageTitle; | ||||
|                 bool inspect = SystemParams.HasLicense("Inspection"); | ||||
|                 bool fuellog = SystemParams.HasLicense("FuelLog"); | ||||
|                 //bool inspectionpkg = SystemParams.HasLicense("ExportInspectionPackage"); | ||||
|                 if (!inspect && !fuellog) | ||||
|                     RedirectToLoginPage(); | ||||
|  | ||||
|                 IsCustomerRecord = SystemParams.HasLicense("CustomerRecord"); | ||||
|                 AllowReassignWorkorders = CheckRight(SystemParams.CompanyID, Feature.REASSIGN_WORKORDERS); | ||||
|                 var user = GetCurrentUser(); | ||||
|  | ||||
|                 ShowExportPackage = inspect && user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin; | ||||
|  | ||||
|                 if (inspect) | ||||
|                 { | ||||
|                     if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin) | ||||
|                     { | ||||
|                         ShowTemplate = true; | ||||
|                         ShowReport = true; | ||||
|                         ShowGlobalSections = true; | ||||
|                     } | ||||
|                     else if (user.UserType == IronIntel.Contractor.Users.UserTypes.Common) | ||||
|                     { | ||||
|                         var client = FleetServiceClientHelper.CreateClient<PermissionProvider>(); | ||||
|                         Tuple<Feature, Permissions>[] pmss = client.GetUserPermissions(SystemParams.CompanyID, user.IID); | ||||
|  | ||||
|                         if (pmss.Length > 0) | ||||
|                         { | ||||
|                             Tuple<Feature, Permissions> temppms = pmss.FirstOrDefault(m => m.Item1.Id == Feature.INSPECTION_TEMPLATES); | ||||
|                             Tuple<Feature, Permissions> reportpms = pmss.FirstOrDefault(m => m.Item1.Id == Feature.INSPECTION_REPORTS); | ||||
|                             if (temppms != null) | ||||
|                             { | ||||
|                                 ShowTemplate = true; | ||||
|                                 if (temppms.Item2 == Permissions.ReadOnly) | ||||
|                                     TemplateReadonly = true; | ||||
|                             } | ||||
|                             if (reportpms != null) | ||||
|                             { | ||||
|                                 ShowReport = true; | ||||
|                                 if (reportpms.Item2 == Permissions.ReadOnly) | ||||
|                                     ReportReadonly = true; | ||||
|                             } | ||||
|                         } | ||||
|  | ||||
|                         if (ShowTemplate == false && ShowReport == false) | ||||
|                             RedirectToEntryPage(); | ||||
|                     } | ||||
|                 } | ||||
|                 if (fuellog) | ||||
|                 { | ||||
|                     if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin) | ||||
|                         ShowFuelLog = true; | ||||
|                     else if (user.UserType == IronIntel.Contractor.Users.UserTypes.Common) | ||||
|                         ShowFuelLog = ShowReport; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow); | ||||
|             BeginDate = userlocaldate.AddDays(-13).ToShortDateString(); | ||||
|             EndDate = userlocaldate.ToShortDateString(); | ||||
|         } | ||||
|     } | ||||
|     public bool IsForesight | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             var user = GetCurrentUser(); | ||||
|             if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin) | ||||
|                 return true; | ||||
|             else | ||||
|                 return false; | ||||
|         } | ||||
|     } | ||||
|     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; | ||||
|         } | ||||
|     } | ||||
|  | ||||
| } | ||||
							
								
								
									
										172
									
								
								Site/Inspection/InspectionChangeHistory.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										172
									
								
								Site/Inspection/InspectionChangeHistory.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,172 @@ | ||||
| <%@ Page Title="" Language="C#" MasterPageFile="~/IronIntelMasterPage.master" AutoEventWireup="true" CodeFile="InspectionChangeHistory.aspx.cs" Inherits="InspectionChangeHistory" %> | ||||
|  | ||||
| <asp:Content ID="Content1" ContentPlaceHolderID="holder_head" runat="Server"> | ||||
|     <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("css/sections.css")%>" rel="stylesheet" type="text/css" /> | ||||
|     <style type="text/css"> | ||||
|         .fa { | ||||
|             display: inline-block; | ||||
|             font: normal normal normal 14px/1 FontAwesome; | ||||
|             font-size: inherit; | ||||
|             text-rendering: auto; | ||||
|             -webkit-font-smoothing: antialiased; | ||||
|             -moz-osx-font-smoothing: grayscale; | ||||
|         } | ||||
|  | ||||
|         .icon-settings { | ||||
|             width: 20px; | ||||
|             height: 20px; | ||||
|         } | ||||
|  | ||||
|             .icon-settings::before { | ||||
|                 content: '\f0ae'; | ||||
|             } | ||||
|     </style> | ||||
|     <style> | ||||
|         .maintable { | ||||
|             border-collapse: collapse; | ||||
|             width: 98%; | ||||
|             page-break-inside: avoid; | ||||
|             margin-left: 1%; | ||||
|             line-height: 24px; | ||||
|             table-layout: fixed; | ||||
|         } | ||||
|  | ||||
|             .maintable td { | ||||
|                 /*border: 1px solid #a9a9a9;*/ | ||||
|                 padding-left: 3px; | ||||
|                 padding-right: 3px; | ||||
|             } | ||||
|  | ||||
|             .maintable .mainlabel { | ||||
|                 font-weight: bold; | ||||
|                 text-align: right; | ||||
|             } | ||||
|     </style> | ||||
|     <script data-main="<%=GetFileUrlWithVersion("js/view-main.js")%>" src="<%=GetFileUrlWithVersion("../js/lib/require-2.3.6.min.js")%>"></script> | ||||
|     <script type="text/javascript"> | ||||
|         var reportid = "<%=ReportID %>"; | ||||
|         var teamintelligence =<%=TeamIntelligence ?"true":"false"%>; | ||||
|         var isAdmin = <%=IsAdminOrSuper ? "true" : "false"%>; | ||||
|  | ||||
|         function inspectionrequest(method, param, callback, error) { | ||||
|             _network.request("Inspection/InspectionChangeHistory.aspx", -1, method, param, callback, error || function (e) { | ||||
|                 showAlert(GetTextByKey('P_IPT_PAGEERROR', 'An unknown error occurred.  Please refresh page.'), GetTextByKey('P_IPT_QUERY', 'Query')); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function OnRefresh() { | ||||
|             showloading(true); | ||||
|             var p = JSON.stringify([teamintelligence, reportid]); | ||||
|             inspectionrequest("GetInspectHistoryItems", p, function (data) { | ||||
|                 showloading(false); | ||||
|                 if (typeof (data) === "string") { | ||||
|                     showAlert(data, GetTextByKey("P_MR_ERROR", 'Error')); | ||||
|                     return; | ||||
|                 } | ||||
|                 showInspections(data); | ||||
|             }, function (err) { | ||||
|                 showloading(false); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function OnExport() { | ||||
|             var p = JSON.stringify([teamintelligence, reportid]); | ||||
|             window.open("../ExportToFile.aspx?type=inspecthis&t=" + htmlencode(p)); | ||||
|         } | ||||
|  | ||||
|         function showInspections(data) { | ||||
|             var rows = []; | ||||
|             for (var i = 0; i < data.length; i++) { | ||||
|                 var r = data[i]; | ||||
|                 var statustext = ""; | ||||
|                 if (r.Status == 0) | ||||
|                     statustext = 'Draft'; | ||||
|                 else if (r.Status == 1) | ||||
|                     statustext = 'Committed'; | ||||
|                 for (var j in r) { | ||||
|                     if (j === "Status") { | ||||
|                         r[j] = { DisplayValue: statustext, Value: r[j] }; | ||||
|                     } else if (j === "CommitTimeLocal") { | ||||
|                         r[j] = { DisplayValue: r["CommitTimeLocalStr"], Value: r[j] }; | ||||
|                     } else if (j === "LastUpdatedTimeLocal") { | ||||
|                         r[j] = { DisplayValue: r["LastUpdatedTimeLocalStr"], Value: r[j] }; | ||||
|                     } else if (j === "VisibleToCustomer") { | ||||
|                         r[j] = { DisplayValue: r["VisibleToCustomer"] ? "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('#inspectlist'); | ||||
|             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: 'LastUpdatedByUserName', caption: GetTextByKey("P_IPT_USERNAME", "User Name"), valueIndex: 'LastUpdatedByUserName', css: { 'width': 300, 'text-align': 'left' } }, | ||||
|                 { name: 'LastUpdatedTimeLocal', caption: GetTextByKey("P_IPT_DATETIME", "Date Time"), valueIndex: 'LastUpdatedTimeLocal', css: { 'width': 150, 'text-align': 'left' } }, | ||||
|                 { name: 'VIN', caption: GetTextByKey("P_IPT_VINSN", "VIN/SN"), valueIndex: 'VIN', css: { 'width': 200, 'text-align': 'left' } }, | ||||
|                 { name: 'AssetName', caption: GetTextByKey("P_IPT_ASSETNAME", "Asset Name"), valueIndex: 'AssetName', css: { 'width': 250, 'text-align': 'left' } }, | ||||
|                 { name: 'WorkOrderNumber', caption: GetTextByKey("P_IPT_WORKORDER", "Work Order #"), valueIndex: 'WorkOrderNumber', 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(); | ||||
|  | ||||
|             OnRefresh(); | ||||
|  | ||||
|             $(window).resize(function () { | ||||
|                 $("#inspectlist").css("height", $(window).height() - $("#inspectlist").offset().top - 4); | ||||
|                 grid_dt && grid_dt.resize(); | ||||
|             }).resize(); | ||||
|  | ||||
|             if (!canExport) { | ||||
|                 $('#spExport').hide(); | ||||
|             } | ||||
|         }); | ||||
|  | ||||
|     </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_IPT_INSPECTIONCHANGEHISTORY">Inspection Change History</div> | ||||
|         <div class="function_title"> | ||||
|             <span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_MR_REFRESH">Refresh</span> | ||||
|             <span id="spExport" class="sbutton iconexport" onclick="OnExport();" data-lgid="P_MR_EXPORTTOEXCEL">Export to Excel</span> | ||||
|         </div> | ||||
|         <div class="clear"></div> | ||||
|         <div id="inspectlist"></div> | ||||
|     </div> | ||||
|     <div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div> | ||||
|  | ||||
| </asp:Content> | ||||
|  | ||||
|  | ||||
							
								
								
									
										56
									
								
								Site/Inspection/InspectionChangeHistory.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								Site/Inspection/InspectionChangeHistory.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,56 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Web; | ||||
| using System.Web.UI; | ||||
| using System.Web.UI.WebControls; | ||||
| using Foresight.Fleet.Services.Inspection; | ||||
| using Foresight.Fleet.Services.User; | ||||
| using IronIntel.Contractor; | ||||
| using IronIntel.Contractor.Site; | ||||
|  | ||||
| public partial class InspectionChangeHistory : InspectionBasePage | ||||
| { | ||||
|     protected string ReportID; | ||||
|     protected bool TeamIntelligence = false; | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     { | ||||
|         CheckUserToken(); | ||||
|         if (!CheckLoginSession()) | ||||
|         { | ||||
|             RedirectToLoginPage(); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             string methodName = Request.Form["MethodName"]; | ||||
|             if (!string.IsNullOrEmpty(methodName)) | ||||
|             { | ||||
|                 ProcessRequest(methodName); | ||||
|             } | ||||
|             else if (!IsPostBack) | ||||
|             { | ||||
|                 this.Title = PageTitle; | ||||
|                 ReportID = Request.Params["rid"]; | ||||
|                 if (!string.IsNullOrEmpty(ReportID)) | ||||
|                 { | ||||
|                     object ii = GetInspectItem(ReportID); | ||||
|                     if (ii == null) | ||||
|                     {//没有权限或ID不正确 | ||||
|                         Response.Write("You have no right to access the report."); | ||||
|                         Response.End(); | ||||
|                     } | ||||
|                     if (ii is TeamInspectItem) | ||||
|                         TeamIntelligence = true; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     protected override bool CanDirectAccess | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             return true; | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										370
									
								
								Site/Inspection/Report.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										370
									
								
								Site/Inspection/Report.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,370 @@ | ||||
| <%@ Page Title="" Language="C#" MasterPageFile="~/IronIntelMasterPage.master" AutoEventWireup="true" CodeFile="Report.aspx.cs" Inherits="InspectionReport" %> | ||||
|  | ||||
| <asp:Content ID="Content1" ContentPlaceHolderID="holder_head" runat="Server"> | ||||
|     <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("css/sections.css")%>" rel="stylesheet" type="text/css" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("../css/tabcontrol.css")%>" rel="stylesheet" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" type="text/css" /> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script> | ||||
|     <style type="text/css"> | ||||
|         .fa { | ||||
|             display: inline-block; | ||||
|             font: normal normal normal 14px/1 FontAwesome; | ||||
|             font-size: inherit; | ||||
|             text-rendering: auto; | ||||
|             -webkit-font-smoothing: antialiased; | ||||
|             -moz-osx-font-smoothing: grayscale; | ||||
|         } | ||||
|  | ||||
|         .icon-settings { | ||||
|             width: 20px; | ||||
|             height: 20px; | ||||
|         } | ||||
|  | ||||
|             .icon-settings::before { | ||||
|                 content: '\f0ae'; | ||||
|             } | ||||
|     </style> | ||||
|     <style> | ||||
|         .maintable { | ||||
|             border-collapse: collapse; | ||||
|             width: 98%; | ||||
|             page-break-inside: avoid; | ||||
|             margin-left: 1%; | ||||
|             line-height: 24px; | ||||
|             table-layout: fixed; | ||||
|         } | ||||
|  | ||||
|             .maintable td { | ||||
|                 /*border: 1px solid #a9a9a9;*/ | ||||
|                 padding-left: 3px; | ||||
|                 padding-right: 3px; | ||||
|             } | ||||
|  | ||||
|             .maintable .mainlabel { | ||||
|                 font-weight: bold; | ||||
|                 text-align: right; | ||||
|             } | ||||
|  | ||||
|         .catelog { | ||||
|             color: #444; | ||||
|             height: 30px; | ||||
|             line-height: 30px; | ||||
|             margin-top: 8px; | ||||
|             padding-left: 10px; | ||||
|             padding-right: 10px; | ||||
|             font-size: 20px; | ||||
|             font-style: italic; | ||||
|         } | ||||
|  | ||||
|         .page { | ||||
|             /*background-color: #d3d3d3;*/ | ||||
|             /*height: 52px;*/ | ||||
|             line-height: 52px; | ||||
|             margin-top: 8px; | ||||
|             padding-left: 10px; | ||||
|             padding-right: 10px; | ||||
|             font-size: 26px; | ||||
|             font-weight: 700; | ||||
|             color: #333; | ||||
|         } | ||||
|  | ||||
|         .section { | ||||
|             /*background-color: #eaeaea;*/ | ||||
|             /*height: 40px;*/ | ||||
|             line-height: 40px; | ||||
|             padding-left: 30px; | ||||
|             padding-right: 10px; | ||||
|             font-size: 20px; | ||||
|             font-weight: 400; | ||||
|             color: #222; | ||||
|         } | ||||
|  | ||||
|         .question { | ||||
|             min-height: 30px; | ||||
|             line-height: 30px; | ||||
|             padding-left: 70px; | ||||
|             padding-right: 10px; | ||||
|             font-size: 14px; | ||||
|             font-weight: bold; | ||||
|             color: #111; | ||||
|             /*display: flex;*/ | ||||
|         } | ||||
|  | ||||
|         .answer { | ||||
|             min-height: 30px; | ||||
|             line-height: 30px; | ||||
|             padding-left: 90px; | ||||
|             padding-right: 10px; | ||||
|         } | ||||
|  | ||||
|         .media { | ||||
|             width: 120px; | ||||
|             height: 120px; | ||||
|             margin-top: 5px; | ||||
|             margin-bottom: 10px; | ||||
|             margin-right: 10px; | ||||
|             cursor: pointer; | ||||
|             border: 1px solid #b0b0b0; | ||||
|             border-radius: 2px; | ||||
|             box-shadow: rgba(0, 0, 0, 0.4); | ||||
|             text-align: center; | ||||
|             float: left; | ||||
|         } | ||||
|  | ||||
|         .video { | ||||
|             line-height: 120px; | ||||
|             font-size: 30px; | ||||
|             margin: 0 auto; | ||||
|             font-family: 'Fontawesome'; | ||||
|         } | ||||
|  | ||||
|             .video::before { | ||||
|                 content: '\f03d'; | ||||
|             } | ||||
|  | ||||
|         .circle { | ||||
|             width: 12px; | ||||
|             height: 12px; | ||||
|             border-radius: 6px; | ||||
|             display: inline-block; | ||||
|         } | ||||
|  | ||||
|         .label_level { | ||||
|             float: right; | ||||
|             margin-right: 10px; | ||||
|         } | ||||
|  | ||||
|         .tab_header { /*corver*/ | ||||
|             font-size: 18px; | ||||
|             font-weight: 500; | ||||
|             height: unset; | ||||
|         } | ||||
|  | ||||
|             .tab_header [data-href] { | ||||
|                 line-height: 16px; | ||||
|                 height: 16px; | ||||
|             } | ||||
|  | ||||
|                 .tab_header [data-href].selected { | ||||
|                     line-height: 20px; | ||||
|                     height: 20px; | ||||
|                 } | ||||
|  | ||||
|         .assettrmobile { | ||||
|             display: none; | ||||
|         } | ||||
|  | ||||
|         #right_popup { | ||||
|             left: 320px; | ||||
|         } | ||||
|  | ||||
|         .inspect-asset td b { | ||||
|             text-align: right; | ||||
|         } | ||||
|  | ||||
|         @media screen and (orientation: portrait) { | ||||
|             #right_popup { | ||||
|                 left: 0; | ||||
|             } | ||||
|  | ||||
|             .inspect-asset td b { | ||||
|                 text-align: left; | ||||
|             } | ||||
|  | ||||
|             .inspect-asset td span { | ||||
|                 display: block; | ||||
|             } | ||||
|         } | ||||
|     </style> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/controls.js")%>" type="text/javascript"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/vue.min.js")%>"></script> | ||||
|     <script>Vue.config.productionTip = false; Vue.config.silent = true;</script> | ||||
|     <script src="<%=GetFileUrlWithVersion("js/report.js")%>" type="text/javascript"></script> | ||||
|     <script data-main="<%=GetFileUrlWithVersion("js/view-main.js")%>" src="<%=GetFileUrlWithVersion("../js/lib/require-2.3.6.min.js")%>"></script> | ||||
|     <script type="text/javascript"> | ||||
|         var reportid = "<%=ReportID %>"; | ||||
|         var teamintelligence =<%=TeamIntelligence ?"true":"false"%>; | ||||
|         var isAdmin = <%=IsAdminOrSuper ? "true" : "false"%>; | ||||
|  | ||||
|         function inspectionrequest(method, param, callback, error) { | ||||
|             _network.request("Inspection/Inspection.aspx", -1, method, param, callback, error || function (e) { | ||||
|                 showAlert(GetTextByKey('P_IPT_PAGEERROR', 'An unknown error occurred.  Please refresh page.'), GetTextByKey('P_IPT_QUERY', 'Query')); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function showRightPopup(state) { | ||||
|             if (state) { | ||||
|                 $('#content').css('overflow', 'hidden'); | ||||
|                 $("#mask_bg").show(); | ||||
|                 $("#right_popup").css("left", $("#set_left").width()).show(); | ||||
|             } | ||||
|             else { | ||||
|                 $('#content').css('overflow', ''); | ||||
|                 $("#mask_bg").hide(); | ||||
|                 $("#right_popup").hide(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function OnDownLoad() { | ||||
|             window.open("Inspection.aspx?rt=f&t=1&id=" + reportid + "&team=" + (teamintelligence ? 1 : 0), '_blank'); | ||||
|         } | ||||
|  | ||||
|         function OnPrint() { | ||||
|             if (navigator.userAgent.indexOf('Firefox') >= 0 || | ||||
|                 navigator.userAgent.indexOf('Opera') >= 0) { | ||||
|                 window.open("Inspection.aspx?rt=f&t=2&id=" + reportid + "&team=" + (teamintelligence ? 1 : 0), '_blank'); | ||||
|                 return; | ||||
|             } | ||||
|             $("#ifdiv").attr('src', "Inspection.aspx?rt=f&t=2&id=" + reportid + "&team=" + (teamintelligence ? 1 : 0)); | ||||
|             if (!$("#ifdiv").data('inited')) { | ||||
|                 $("#ifdiv").on('load', function () { | ||||
|                     onifload(); | ||||
|                 }).show(); | ||||
|                 $("#ifdiv").data('inited', 1); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function onifload() { | ||||
|             var iframe = document.getElementById('ifdiv'); | ||||
|             iframe.contentWindow.focus(); | ||||
|             iframe.contentWindow.print(); | ||||
|         } | ||||
|  | ||||
|         $(function () { | ||||
|             if (!canExport) { | ||||
|                 $('#spPrint').hide(); | ||||
|                 $('#spDownload').hide(); | ||||
|             } | ||||
|         }); | ||||
|     </script> | ||||
| </asp:Content> | ||||
| <asp:Content ID="Content2" ContentPlaceHolderID="holder_content" runat="Server"> | ||||
|     <div class="function_title" style="text-align: right; margin-top: 2px;"> | ||||
|         <% if (!ReportReadonly) | ||||
|             { %> | ||||
|         <span id="button-edit" class="sbutton iconedit" data-lgid="P_IPT_EDIT">Edit</span> | ||||
|         <% } %> | ||||
|         <span id="spDownload" id="button-dl" class="sbutton icondownload" onclick="OnDownLoad();" data-lgid="P_IPT_DOWNLOAD">Download</span> | ||||
|         <span id="spPrint" id="button-print" class="sbutton iconprint" style="margin-right: 20px;" onclick="OnPrint();" data-lgid="P_IPT_PRINT">Print</span> | ||||
|     </div> | ||||
|     <div id="divreport" style="width: 1100px; margin: 0 auto;"> | ||||
|         <img id="reportlayoutlogo" style="width: 100px; margin-top: 5px; display: none;" /> | ||||
|         <h1 style="text-align: center;" v-show="report.Template.DisplayInspectionTitle">{{report.Template.Name}}</h1> | ||||
|         <div style="text-align: center; margin-bottom: 10px;"><span v-show="report.Template.DisplayCommitTime">{{report.CommitTimeLocalStr}}</span><span v-show="report.Template.DisplayCommitBy"> by {{report.CommitedByUserName}}</span></div> | ||||
|         <table class="maintable"> | ||||
|             <tr v-if="report.ReportLayout==null"> | ||||
|                 <td> | ||||
|                     <table class="maintable"> | ||||
|                         <tr class="assettr"> | ||||
|                             <td class="mainlabel" style="width: 80px;" data-lgid="P_IPT_ASSETNAME_COLON">Asset Name:</td> | ||||
|                             <td style="width: 200px;">{{report.Asset.Name}}</td> | ||||
|                             <td class="mainlabel" style="width: 130px;" data-lgid="P_IPT_ASSETNAME2_COLON">Asset Name(Custom):</td> | ||||
|                             <td style="width: 720px;" colspan="5">{{report.Asset.Name2}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettr"> | ||||
|                             <td class="mainlabel" style="width: 80px;" data-lgid="P_IPT_VINSN_COLON">VIN/SN:</td> | ||||
|                             <td style="width: 200px;">{{report.Asset.VIN}}</td> | ||||
|                             <td class="mainlabel" style="width: 130px;" data-lgid="P_IPT_MAKE_COLON">Make:</td> | ||||
|                             <td style="width: 200px;">{{report.Asset.MakeName}}</td> | ||||
|                             <td class="mainlabel" style="width: 50px;" data-lgid="P_IPT_MODEL_COLON">Model:</td> | ||||
|                             <td style="width: 200px;">{{report.Asset.ModelName}}</td> | ||||
|                             <td class="mainlabel" style="width: 70px;" data-lgid="P_IPT_ASSETTYPE_COLON">Asset Type:</td> | ||||
|                             <td style="width: 200px;">{{report.Asset.TypeName}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettr" v-if="report.WorkOrderId>0"> | ||||
|                             <td class="mainlabel" data-lgid="P_IPT_WORKORDER_COLON">Work Order:</td> | ||||
|                             <td>{{report.WorkOrderNumber}}</td> | ||||
|                             <td class="mainlabel" data-lgid="P_IPT_CUSTOMERVISIBLE_COLON">Customer Visible:</td> | ||||
|                             <td colspan="5">{{report.VisibleToCustomer?"Yes":"No"}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile"> | ||||
|                             <td class="mainlabel" style="width: 130px;" data-lgid="P_IPT_ASSETNAME_COLON">Asset Name:</td> | ||||
|                             <td>{{report.Asset.Name}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile"> | ||||
|                             <td class="mainlabel" data-lgid="P_IPT_ASSETNAME2_COLON">Asset Name (Custom):</td> | ||||
|                             <td>{{report.Asset.Name2}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile"> | ||||
|                             <td class="mainlabel" data-lgid="P_IPT_VINSN_COLON">VIN/SN:</td> | ||||
|                             <td>{{report.Asset.VIN}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile"> | ||||
|                             <td class="mainlabel" data-lgid="P_IPT_MAKE_COLON">Make:</td> | ||||
|                             <td>{{report.Asset.MakeName}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile"> | ||||
|                             <td class="mainlabel" data-lgid="P_IPT_MODEL_COLON">Model:</td> | ||||
|                             <td>{{report.Asset.ModelName}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile"> | ||||
|                             <td class="mainlabel" data-lgid="P_IPT_ASSETTYPE_COLON">Asset Type:</td> | ||||
|                             <td>{{report.Asset.TypeName}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile"> | ||||
|                             <td class="mainlabel" data-lgid="P_IPT_WORKORDER_COLON">Work Order:</td> | ||||
|                             <td>{{report.WorkOrderId}}</td> | ||||
|                         </tr> | ||||
|                     </table> | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr v-if="report.ReportLayout!=null"> | ||||
|                 <td> | ||||
|                     <table class="maintable" style="width: 100%;"> | ||||
|                         <tr class="assettr" style="vertical-align: top;"> | ||||
|                             <td class="td_pageheaderleft" style="width: 33%; vertical-align: top;"></td> | ||||
|                             <td class="td_pageheadercenter" style="width: 33%; vertical-align: top;"></td> | ||||
|                             <td class="td_pageheaderright" style="vertical-align: top;"></td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile" style="vertical-align: top;"> | ||||
|                             <td class="td_pageheaderleft" style="text-align: left;"></td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile" style="vertical-align: top;"> | ||||
|                             <td class="td_pageheadercenter" style="text-align: left;"></td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile" style="vertical-align: top;"> | ||||
|                             <td class="td_pageheaderright" style="text-align: left;"></td> | ||||
|                         </tr> | ||||
|                     </table> | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|                 <td id="tdiissues" style="padding: 0;"> | ||||
|                     <div id="divquestions" style="margin-top: 10px;"></div> | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|                 <td id="tdpages" style="padding: 0;"> | ||||
|                     <div id="divpages" style="margin-top: 10px;"></div> | ||||
|                     <div id="divsign"></div> | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr v-if="report.ReportLayout!=null"> | ||||
|                 <td> | ||||
|                     <table class="maintable" style="width: 100%;"> | ||||
|                         <tr class="assettr"> | ||||
|                             <td class="td_pagefooterleft" style="width: 33%; vertical-align: bottom;">{{report.ReportLayout.PageFooterLeft}}</td> | ||||
|                             <td class="td_pagefootercenter" style="width: 33%; vertical-align: bottom;">{{report.ReportLayout.PageFooterCenter}}</td> | ||||
|                             <td class="td_pagefooterright" style="text-align: right; padding-right: 10px; vertical-align: bottom;">{{report.ReportLayout.PageFooterRight}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile" style="vertical-align: bottom;"> | ||||
|                             <td class="td_pagefooterleft" style="text-align: left;">{{report.ReportLayout.PageFooterLeft}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile" style="vertical-align: bottom;"> | ||||
|                             <td class="td_pagefootercenter" style="text-align: left;">{{report.ReportLayout.PageFooterCenter}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile" style="vertical-align: bottom;"> | ||||
|                             <td class="td_pagefooterright" style="text-align: left;">{{report.ReportLayout.PageFooterRight}}</td> | ||||
|                         </tr> | ||||
|                     </table> | ||||
|                 </td> | ||||
|             </tr> | ||||
|         </table> | ||||
|     </div> | ||||
|     <div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div> | ||||
|     <div id="right_popup" style="display: none; position: absolute; top: 0; right: 0; bottom: 0; background-color: white; overflow: auto;"> | ||||
|     </div> | ||||
|     <iframe id="ifdiv" style="height: 1px; width: 1px; display: none;"></iframe> | ||||
| </asp:Content> | ||||
|  | ||||
							
								
								
									
										80
									
								
								Site/Inspection/Report.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								Site/Inspection/Report.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,80 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Web; | ||||
| using System.Web.UI; | ||||
| using System.Web.UI.WebControls; | ||||
| using Foresight.Fleet.Services.Inspection; | ||||
| using Foresight.Fleet.Services.User; | ||||
| using IronIntel.Contractor; | ||||
| using IronIntel.Contractor.Site; | ||||
|  | ||||
| public partial class InspectionReport : InspectionBasePage | ||||
| { | ||||
|     protected string ReportID; | ||||
|     protected bool TeamIntelligence = false; | ||||
|     public bool ReportReadonly = false; | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     { | ||||
|         CheckUserToken(); | ||||
|         if (!CheckLoginSession()) | ||||
|         { | ||||
|             RedirectToLoginPage(); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             string methodName = Request.Form["MethodName"]; | ||||
|             if (!string.IsNullOrEmpty(methodName)) | ||||
|             { | ||||
|                 ProcessRequest(methodName); | ||||
|             } | ||||
|             else if (!IsPostBack) | ||||
|             { | ||||
|                 this.Title = PageTitle; | ||||
|                 ReportID = Request.Params["rid"]; | ||||
|                 if (!string.IsNullOrEmpty(ReportID)) | ||||
|                 { | ||||
|                     object ii = GetInspectItem(ReportID); | ||||
|                     if (ii == null) | ||||
|                     {//没有权限或ID不正确 | ||||
|                         Response.Write("You have no right to access the report."); | ||||
|                         Response.End(); | ||||
|                     } | ||||
|                     if (ii is TeamInspectItem) | ||||
|                         TeamIntelligence = true; | ||||
|                     ReportReadonly = Helper.IsTrue(Request.Params["ro"]); | ||||
|  | ||||
|                     if (!ReportReadonly) | ||||
|                     { | ||||
|                         var user = GetCurrentUser(); | ||||
|                         if (user.UserType == IronIntel.Contractor.Users.UserTypes.Common) | ||||
|                         { | ||||
|                             var client = FleetServiceClientHelper.CreateClient<PermissionProvider>(); | ||||
|                             Tuple<Feature, Permissions>[] pmss = client.GetUserPermissions(SystemParams.CompanyID, user.IID); | ||||
|  | ||||
|                             if (pmss.Length > 0) | ||||
|                             { | ||||
|                                 Tuple<Feature, Permissions> reportpms = null; | ||||
|                                 if (TeamIntelligence) | ||||
|                                     reportpms = pmss.FirstOrDefault(m => m.Item1.Id == Feature.TEAM_REPORTS); | ||||
|                                 else | ||||
|                                     reportpms = pmss.FirstOrDefault(m => m.Item1.Id == Feature.INSPECTION_REPORTS); | ||||
|  | ||||
|                                 if (reportpms == null || reportpms.Item2 == Permissions.ReadOnly) | ||||
|                                     ReportReadonly = true; | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     protected override bool CanDirectAccess | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             return true; | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										369
									
								
								Site/Inspection/ReportForWorkOrder.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										369
									
								
								Site/Inspection/ReportForWorkOrder.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,369 @@ | ||||
| <%@ Page Title="" Language="C#" MasterPageFile="~/IronIntelMasterPage.master" AutoEventWireup="true" CodeFile="ReportForWorkOrder.aspx.cs" Inherits="ReportForWorkOrder" %> | ||||
|  | ||||
| <asp:Content ID="Content1" ContentPlaceHolderID="holder_head" runat="Server"> | ||||
|     <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("css/sections.css")%>" rel="stylesheet" type="text/css" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("../css/tabcontrol.css")%>" rel="stylesheet" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" type="text/css" /> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script> | ||||
|     <style type="text/css"> | ||||
|         .fa { | ||||
|             display: inline-block; | ||||
|             font: normal normal normal 14px/1 FontAwesome; | ||||
|             font-size: inherit; | ||||
|             text-rendering: auto; | ||||
|             -webkit-font-smoothing: antialiased; | ||||
|             -moz-osx-font-smoothing: grayscale; | ||||
|         } | ||||
|  | ||||
|         .icon-settings { | ||||
|             width: 20px; | ||||
|             height: 20px; | ||||
|         } | ||||
|  | ||||
|             .icon-settings::before { | ||||
|                 content: '\f0ae'; | ||||
|             } | ||||
|     </style> | ||||
|     <style> | ||||
|         .maintable { | ||||
|             border-collapse: collapse; | ||||
|             width: 98%; | ||||
|             page-break-inside: avoid; | ||||
|             margin-left: 1%; | ||||
|             line-height: 24px; | ||||
|             table-layout: fixed; | ||||
|         } | ||||
|  | ||||
|             .maintable td { | ||||
|                 /*border: 1px solid #a9a9a9;*/ | ||||
|                 padding-left: 3px; | ||||
|                 padding-right: 3px; | ||||
|             } | ||||
|  | ||||
|             .maintable .mainlabel { | ||||
|                 font-weight: bold; | ||||
|                 text-align: right; | ||||
|             } | ||||
|  | ||||
|         .catelog { | ||||
|             color: #444; | ||||
|             height: 30px; | ||||
|             line-height: 30px; | ||||
|             margin-top: 8px; | ||||
|             padding-left: 10px; | ||||
|             padding-right: 10px; | ||||
|             font-size: 20px; | ||||
|             font-style: italic; | ||||
|         } | ||||
|  | ||||
|         .page { | ||||
|             /*background-color: #d3d3d3;*/ | ||||
|             /*height: 52px;*/ | ||||
|             line-height: 52px; | ||||
|             margin-top: 8px; | ||||
|             padding-left: 10px; | ||||
|             padding-right: 10px; | ||||
|             font-size: 26px; | ||||
|             font-weight: 700; | ||||
|             color: #333; | ||||
|         } | ||||
|  | ||||
|         .section { | ||||
|             /*background-color: #eaeaea;*/ | ||||
|             /*height: 40px;*/ | ||||
|             line-height: 40px; | ||||
|             padding-left: 30px; | ||||
|             padding-right: 10px; | ||||
|             font-size: 20px; | ||||
|             font-weight: 400; | ||||
|             color: #222; | ||||
|         } | ||||
|  | ||||
|         .question { | ||||
|             min-height: 30px; | ||||
|             line-height: 30px; | ||||
|             padding-left: 70px; | ||||
|             padding-right: 10px; | ||||
|             font-size: 14px; | ||||
|             font-weight: bold; | ||||
|             color: #111; | ||||
|             /*display: flex;*/ | ||||
|         } | ||||
|  | ||||
|         .answer { | ||||
|             min-height: 30px; | ||||
|             line-height: 30px; | ||||
|             padding-left: 90px; | ||||
|             padding-right: 10px; | ||||
|         } | ||||
|  | ||||
|         .media { | ||||
|             width: 120px; | ||||
|             height: 120px; | ||||
|             margin-top: 5px; | ||||
|             margin-bottom: 10px; | ||||
|             margin-right: 10px; | ||||
|             cursor: pointer; | ||||
|             border: 1px solid #b0b0b0; | ||||
|             border-radius: 2px; | ||||
|             box-shadow: rgba(0, 0, 0, 0.4); | ||||
|             text-align: center; | ||||
|             float: left; | ||||
|         } | ||||
|  | ||||
|         .video { | ||||
|             line-height: 120px; | ||||
|             font-size: 30px; | ||||
|             margin: 0 auto; | ||||
|             font-family: 'Fontawesome'; | ||||
|         } | ||||
|  | ||||
|             .video::before { | ||||
|                 content: '\f03d'; | ||||
|             } | ||||
|  | ||||
|         .circle { | ||||
|             width: 12px; | ||||
|             height: 12px; | ||||
|             border-radius: 6px; | ||||
|             display: inline-block; | ||||
|         } | ||||
|  | ||||
|         .label_level { | ||||
|             float: right; | ||||
|             margin-right: 10px; | ||||
|         } | ||||
|  | ||||
|         .tab_header { /*corver*/ | ||||
|             font-size: 18px; | ||||
|             font-weight: 500; | ||||
|             height: unset; | ||||
|         } | ||||
|  | ||||
|             .tab_header [data-href] { | ||||
|                 line-height: 16px; | ||||
|                 height: 16px; | ||||
|             } | ||||
|  | ||||
|                 .tab_header [data-href].selected { | ||||
|                     line-height: 20px; | ||||
|                     height: 20px; | ||||
|                 } | ||||
|  | ||||
|         .assettrmobile { | ||||
|             display: none; | ||||
|         } | ||||
|  | ||||
|         #right_popup { | ||||
|             left: 320px; | ||||
|         } | ||||
|  | ||||
|         .inspect-asset td b { | ||||
|             text-align: right; | ||||
|         } | ||||
|  | ||||
|         @media screen and (orientation: portrait) { | ||||
|             #right_popup { | ||||
|                 left: 0; | ||||
|             } | ||||
|  | ||||
|             .inspect-asset td b { | ||||
|                 text-align: left; | ||||
|             } | ||||
|  | ||||
|             .inspect-asset td span { | ||||
|                 display: block; | ||||
|             } | ||||
|         } | ||||
|     </style> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/controls.js")%>" type="text/javascript"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/vue.min.js")%>"></script> | ||||
|     <script>Vue.config.productionTip = false; Vue.config.silent = true;</script> | ||||
|     <script src="<%=GetFileUrlWithVersion("js/report.js")%>" type="text/javascript"></script> | ||||
|     <script data-main="<%=GetFileUrlWithVersion("js/view-main.js")%>" src="<%=GetFileUrlWithVersion("../js/lib/require-2.3.6.min.js")%>"></script> | ||||
|     <script type="text/javascript"> | ||||
|         var reportid = "<%=ReportID %>"; | ||||
|         var teamintelligence =<%=TeamIntelligence ?"true":"false"%>; | ||||
|         var isAdmin = <%=IsAdminOrSuper ? "true" : "false"%>; | ||||
|  | ||||
|         function inspectionrequest(method, param, callback, error) { | ||||
|             _network.request("Inspection/Inspection.aspx", -1, method, param, callback, error || function (e) { | ||||
|                 showAlert(GetTextByKey('P_IPT_PAGEERROR', 'An unknown error occurred.  Please refresh page.'), GetTextByKey('P_IPT_QUERY', 'Query')); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function showRightPopup(state) { | ||||
|             if (state) { | ||||
|                 $('#content').css('overflow', 'hidden'); | ||||
|                 $("#mask_bg").show(); | ||||
|                 $("#right_popup").css("left", $("#set_left").width()).show(); | ||||
|             } | ||||
|             else { | ||||
|                 $('#content').css('overflow', ''); | ||||
|                 $("#mask_bg").hide(); | ||||
|                 $("#right_popup").hide(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function OnDownLoad() { | ||||
|             window.open("Inspection.aspx?rt=f&t=1&id=" + reportid + "&team=" + (teamintelligence ? 1 : 0), '_blank'); | ||||
|         } | ||||
|  | ||||
|         function OnPrint() { | ||||
|             if (navigator.userAgent.indexOf('Firefox') >= 0 || | ||||
|                 navigator.userAgent.indexOf('Opera') >= 0) { | ||||
|                 window.open("Inspection.aspx?rt=f&t=2&id=" + reportid + "&team=" + (teamintelligence ? 1 : 0), '_blank'); | ||||
|                 return; | ||||
|             } | ||||
|             $("#ifdiv").attr('src', "Inspection.aspx?rt=f&t=2&id=" + reportid + "&team=" + (teamintelligence ? 1 : 0)); | ||||
|             if (!$("#ifdiv").data('inited')) { | ||||
|                 $("#ifdiv").on('load', function () { | ||||
|                     onifload(); | ||||
|                 }).show(); | ||||
|                 $("#ifdiv").data('inited', 1); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function onifload() { | ||||
|             var iframe = document.getElementById('ifdiv'); | ||||
|             iframe.contentWindow.focus(); | ||||
|             iframe.contentWindow.print(); | ||||
|         } | ||||
|  | ||||
|         $(function () { | ||||
|             $('#host_main').hide(); | ||||
|             $('#divLeftTitle').hide(); | ||||
|             $('#content').css('top', 0).css('margin-left', 0); | ||||
|  | ||||
|             if (!canExport) { | ||||
|                 $('#button-print').hide(); | ||||
|                 $('#button-dl').hide(); | ||||
|             } | ||||
|         }) | ||||
|     </script> | ||||
| </asp:Content> | ||||
| <asp:Content ID="Content2" ContentPlaceHolderID="holder_content" runat="Server"> | ||||
|     <div class="function_title" style="text-align: right; margin-top: 2px;"> | ||||
|         <span id="button-dl" class="sbutton icondownload" onclick="OnDownLoad();" data-lgid="P_IPT_DOWNLOAD">Download</span> | ||||
|         <span id="button-print" class="sbutton iconprint" style="margin-right: 20px;" onclick="OnPrint();" data-lgid="P_IPT_PRINT">Print</span> | ||||
|     </div> | ||||
|     <div id="divreport" style="width: 1100px; margin: 0 auto;"> | ||||
|         <h1 style="text-align: center;" v-show="report.Template.DisplayInspectionTitle">{{report.Template.Name}}</h1> | ||||
|         <div style="text-align: center; margin-bottom: 10px;"><span v-show="report.Template.DisplayCommitTime">{{report.CommitTimeLocalStr}}</span><span v-show="report.Template.DisplayCommitBy"> by {{report.CommitedByUserName}}</span></div> | ||||
|         <table class="maintable"> | ||||
|             <tr v-if="report.ReportLayout==null"> | ||||
|                 <td> | ||||
|                     <table class="maintable"> | ||||
|                         <tr class="assettr"> | ||||
|                             <td class="mainlabel" style="width: 80px;" data-lgid="P_IPT_ASSETNAME_COLON">Asset Name:</td> | ||||
|                             <td style="width: 200px;">{{report.Asset.Name}}</td> | ||||
|                             <td class="mainlabel" style="width: 130px;" data-lgid="P_IPT_ASSETNAME2_COLON">Asset Name(Custom):</td> | ||||
|                             <td style="width: 720px;" colspan="5">{{report.Asset.Name2}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettr"> | ||||
|                             <td class="mainlabel" style="width: 80px;" data-lgid="P_IPT_VINSN_COLON">VIN/SN:</td> | ||||
|                             <td style="width: 200px;">{{report.Asset.VIN}}</td> | ||||
|                             <td class="mainlabel" style="width: 130px;" data-lgid="P_IPT_MAKE_COLON">Make:</td> | ||||
|                             <td style="width: 200px;">{{report.Asset.MakeName}}</td> | ||||
|                             <td class="mainlabel" style="width: 50px;" data-lgid="P_IPT_MODEL_COLON">Model:</td> | ||||
|                             <td style="width: 200px;">{{report.Asset.ModelName}}</td> | ||||
|                             <td class="mainlabel" style="width: 70px;" data-lgid="P_IPT_ASSETTYPE_COLON">Asset Type:</td> | ||||
|                             <td style="width: 200px;">{{report.Asset.TypeName}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettr" v-if="report.WorkOrderId>0"> | ||||
|                             <td class="mainlabel" data-lgid="P_IPT_WORKORDER_COLON">Work Order:</td> | ||||
|                             <td>{{report.WorkOrderNumber}}</td> | ||||
|                             <td class="mainlabel" data-lgid="P_IPT_CUSTOMERVISIBLE_COLON">Customer Visible:</td> | ||||
|                             <td colspan="5">{{report.VisibleToCustomer?"Yes":"No"}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile"> | ||||
|                             <td class="mainlabel" style="width: 130px;" data-lgid="P_IPT_ASSETNAME_COLON">Asset Name:</td> | ||||
|                             <td>{{report.Asset.Name}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile"> | ||||
|                             <td class="mainlabel" data-lgid="P_IPT_ASSETNAME2_COLON">Asset Name (Custom):</td> | ||||
|                             <td>{{report.Asset.Name2}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile"> | ||||
|                             <td class="mainlabel" data-lgid="P_IPT_VINSN_COLON">VIN/SN:</td> | ||||
|                             <td>{{report.Asset.VIN}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile"> | ||||
|                             <td class="mainlabel" data-lgid="P_IPT_MAKE_COLON">Make:</td> | ||||
|                             <td>{{report.Asset.MakeName}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile"> | ||||
|                             <td class="mainlabel" data-lgid="P_IPT_MODEL_COLON">Model:</td> | ||||
|                             <td>{{report.Asset.ModelName}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile"> | ||||
|                             <td class="mainlabel" data-lgid="P_IPT_ASSETTYPE_COLON">Asset Type:</td> | ||||
|                             <td>{{report.Asset.TypeName}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile"> | ||||
|                             <td class="mainlabel" data-lgid="P_IPT_WORKORDER_COLON">Work Order:</td> | ||||
|                             <td>{{report.WorkOrderId}}</td> | ||||
|                         </tr> | ||||
|                     </table> | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr v-if="report.ReportLayout!=null"> | ||||
|                 <td> | ||||
|                     <table class="maintable" style="width: 100%;"> | ||||
|                         <tr class="assettr" style="vertical-align: top;"> | ||||
|                             <td class="td_pageheaderleft" style="width: 33%; vertical-align: top;"></td> | ||||
|                             <td class="td_pageheadercenter" style="width: 33%; vertical-align: top;"></td> | ||||
|                             <td class="td_pageheaderright" style="vertical-align: top;"></td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile" style="vertical-align: top;"> | ||||
|                             <td class="td_pageheaderleft" style="text-align: left;"></td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile" style="vertical-align: top;"> | ||||
|                             <td class="td_pageheadercenter" style="text-align: left;"></td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile" style="vertical-align: top;"> | ||||
|                             <td class="td_pageheaderright" style="text-align: left;"></td> | ||||
|                         </tr> | ||||
|                     </table> | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|                 <td id="tdiissues" style="padding: 0;"> | ||||
|                     <div id="divquestions" style="margin-top: 10px;"></div> | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|                 <td id="tdpages" style="padding: 0;"> | ||||
|                     <div id="divpages" style="margin-top: 10px;"></div> | ||||
|                     <div id="divsign"></div> | ||||
|                 </td> | ||||
|             </tr> | ||||
|             <tr v-if="report.ReportLayout!=null"> | ||||
|                 <td> | ||||
|                     <table class="maintable" style="width: 100%;"> | ||||
|                         <tr class="assettr"> | ||||
|                             <td class="td_pagefooterleft" style="width: 33%; vertical-align: bottom;">{{report.ReportLayout.PageFooterLeft}}</td> | ||||
|                             <td class="td_pagefootercenter" style="width: 33%; vertical-align: bottom;">{{report.ReportLayout.PageFooterCenter}}</td> | ||||
|                             <td class="td_pagefooterright" style="text-align: right; padding-right: 10px; vertical-align: bottom;">{{report.ReportLayout.PageFooterRight}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile" style="vertical-align: bottom;"> | ||||
|                             <td class="td_pagefooterleft" style="text-align: left;">{{report.ReportLayout.PageFooterLeft}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile" style="vertical-align: bottom;"> | ||||
|                             <td class="td_pagefootercenter" style="text-align: left;">{{report.ReportLayout.PageFooterCenter}}</td> | ||||
|                         </tr> | ||||
|                         <tr class="assettrmobile" style="vertical-align: bottom;"> | ||||
|                             <td class="td_pagefooterright" style="text-align: left;">{{report.ReportLayout.PageFooterRight}}</td> | ||||
|                         </tr> | ||||
|                     </table> | ||||
|                 </td> | ||||
|             </tr> | ||||
|         </table> | ||||
|     </div> | ||||
|     <div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div> | ||||
|     <div id="right_popup" style="display: none; position: absolute; top: 0; right: 0; bottom: 0; background-color: white; overflow: auto;"> | ||||
|     </div> | ||||
|     <iframe id="ifdiv" style="height: 1px; width: 1px; display: none;"></iframe> | ||||
| </asp:Content> | ||||
|  | ||||
							
								
								
									
										56
									
								
								Site/Inspection/ReportForWorkOrder.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								Site/Inspection/ReportForWorkOrder.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,56 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Web; | ||||
| using System.Web.UI; | ||||
| using System.Web.UI.WebControls; | ||||
| using Foresight.Fleet.Services.Inspection; | ||||
| using Foresight.Fleet.Services.User; | ||||
| using IronIntel.Contractor; | ||||
| using IronIntel.Contractor.Site; | ||||
|  | ||||
| public partial class ReportForWorkOrder : InspectionBasePage | ||||
| { | ||||
|     protected string ReportID; | ||||
|     protected bool TeamIntelligence = false; | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     { | ||||
|         CheckUserToken(); | ||||
|         if (!CheckLoginSession()) | ||||
|         { | ||||
|             RedirectToLoginPage(); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             string methodName = Request.Form["MethodName"]; | ||||
|             if (!string.IsNullOrEmpty(methodName)) | ||||
|             { | ||||
|                 ProcessRequest(methodName); | ||||
|             } | ||||
|             else if (!IsPostBack) | ||||
|             { | ||||
|                 this.Title = PageTitle; | ||||
|                 ReportID = Request.Params["rid"]; | ||||
|                 if (!string.IsNullOrEmpty(ReportID)) | ||||
|                 { | ||||
|                     object ii = GetInspectItem(ReportID); | ||||
|                     if (ii == null) | ||||
|                     {//没有权限或ID不正确 | ||||
|                         Response.Write("You have no right to access the report."); | ||||
|                         Response.End(); | ||||
|                     } | ||||
|                     if (ii is TeamInspectItem) | ||||
|                         TeamIntelligence = true; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     protected override bool CanDirectAccess | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             return true; | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										283
									
								
								Site/Inspection/TeamIntelligence.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										283
									
								
								Site/Inspection/TeamIntelligence.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,283 @@ | ||||
| <%@ Page Title="" Language="C#" MasterPageFile="~/IronIntelMasterPage.master" AutoEventWireup="true" CodeFile="TeamIntelligence.aspx.cs" Inherits="TeamIntelligence" %> | ||||
|  | ||||
| <asp:Content ID="Content1" ContentPlaceHolderID="holder_head" runat="Server"> | ||||
|     <link href="<%=GetFileUrlWithVersion("../css/split.css")%>" rel="stylesheet" type="text/css" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("css/sections.css")%>" rel="stylesheet" type="text/css" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("../css/spectrum.css")%>" rel="stylesheet" type="text/css" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("../css/tabcontrol.css")%>" rel="stylesheet" /> | ||||
|     <link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" type="text/css" /> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/spectrum.js")%>"></script> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script> | ||||
|     <%--<script src="<%=GetFileUrlWithVersion("../js/split.js")%>"></script>--%> | ||||
|     <style type="text/css"> | ||||
|         .fa { | ||||
|             display: inline-block; | ||||
|             font: normal normal normal 14px/1 FontAwesome; | ||||
|             font-size: inherit; | ||||
|             text-rendering: auto; | ||||
|             -webkit-font-smoothing: antialiased; | ||||
|             -moz-osx-font-smoothing: grayscale; | ||||
|         } | ||||
|  | ||||
|         .icon-menu { | ||||
|             width: 20px; | ||||
|             height: 20px; | ||||
|         } | ||||
|  | ||||
|         .icon-sections::before { | ||||
|             content: '\f03a'; | ||||
|         } | ||||
|  | ||||
|         .icon-templates::before { | ||||
|             content: '\f0ae'; | ||||
|         } | ||||
|  | ||||
|         .icon-packages::before { | ||||
|             content: '\f1b3'; | ||||
|         } | ||||
|  | ||||
|         .icon-report:before { | ||||
|             content: '\f15c'; | ||||
|         } | ||||
|  | ||||
|         .page_title { | ||||
|             font-size: 24px; | ||||
|         } | ||||
|  | ||||
|         .settings-line { | ||||
|             line-height: 30px; | ||||
|             padding: 0 20px; | ||||
|             box-sizing: border-box; | ||||
|         } | ||||
|  | ||||
|             .settings-line > span { | ||||
|                 display: block; | ||||
|                 padding: 4px 0; | ||||
|             } | ||||
|  | ||||
|             .settings-line > textarea { | ||||
|                 box-sizing: border-box; | ||||
|                 width: 100%; | ||||
|                 height: 70px; | ||||
|                 resize: vertical; | ||||
|             } | ||||
|     </style> | ||||
|     <script src="<%=GetFileUrlWithVersion("../js/controls.js")%>" type="text/javascript"></script> | ||||
|     <script data-main="<%=GetFileUrlWithVersion("js/main.js")%>" src="<%=GetFileUrlWithVersion("../js/lib/require-2.3.6.min.js")%>"></script> | ||||
|     <script type="text/javascript"> | ||||
|         var sectiontype = 0;//sectiontype:0 - global,1 - normal | ||||
|         var templatestatus = 0;//templatestatus:0 - draft,1 - published | ||||
|         var templatereadonly = <%=TemplateReadonly ?"true":"false"%>;;//published template cannot be edit | ||||
|         var editable = true; | ||||
|         var draggingobj = null; | ||||
|         var IsForesight =<%=IsForesight ?"true":"false"%>; | ||||
|         var IsAdmin =<%=IsAdmin ?"true":"false"%>; | ||||
|         var teamintelligence = true; | ||||
|         var begindate = "<%=BeginDate%>"; | ||||
|         var enddate = "<%=EndDate%>"; | ||||
|  | ||||
|         var ShowTemplate =<%=ShowTemplate ?"true":"false"%>; | ||||
|         var ShowReport =<%=ShowReport ?"true":"false"%>; | ||||
|         var ReportReadonly =<%=ReportReadonly ?"true":"false"%>; | ||||
|         var IsCustomerRecord = false;         | ||||
|  | ||||
|         function inspectionrequest(method, param, callback, error) { | ||||
|             _network.request("Inspection/Inspection.aspx", -1, method, param, callback, error || function (e) { | ||||
|                 showAlert('An unknown error occurred.  Please refresh page.', 'Query'); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function showRightPopup(state) { | ||||
|             if (state) { | ||||
|                 $("#mask_bg").show(); | ||||
|                 $("#right_popup").css("left", $("#set_left").width()).show(); | ||||
|             } | ||||
|             else { | ||||
|                 $("#mask_bg").hide(); | ||||
|                 $("#right_popup").hide(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function OnPrint(rid) { | ||||
|             $("#ifdiv").attr('src', "Inspection.aspx?rt=f&t=2&id=" + rid + "&team=" + (teamintelligence ? 1 : 0)); | ||||
|             if (!$("#ifdiv").data('inited')) { | ||||
|                 $("#ifdiv").on('load', function () { | ||||
|                     onifload(); | ||||
|                 }).show(); | ||||
|                 $("#ifdiv").data('inited', 1); | ||||
|             } | ||||
|             //window.open("Inspection.aspx?rt=f&t=2&id=" + reportid, '_blank'); | ||||
|         } | ||||
|  | ||||
|         function onifload() { | ||||
|             var iframe = document.getElementById('ifdiv'); | ||||
|             iframe.contentWindow.focus(); | ||||
|             iframe.contentWindow.print(); | ||||
|         } | ||||
|  | ||||
|         function createSubMenus(items) { | ||||
|             var maintenancesubmenu = $("#inspectsubmenu").empty(); | ||||
|             var ulsubmenus = $('<ul class="lefttitlemenu_ul" style="line-height:32px;"></ul>'); | ||||
|             maintenancesubmenu.append(ulsubmenus); | ||||
|             for (var i = 0; i < items.length; i++) { | ||||
|                 var item = items[i]; | ||||
|                 if (!item) continue; | ||||
|                 var li = $('<li></li>'); | ||||
|                 var a = $('<a></a>').append($("<span></span>").text(item.Title)); | ||||
|                 a.attr('href', '#' + item.ID); | ||||
|                 li.append(a); | ||||
|                 ulsubmenus.append(li); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $(function () { | ||||
|             $("#atemplates").click(function (ev) { | ||||
|                 if ($('#set_left').prop('isexpanded')) | ||||
|                     return; | ||||
|                 if ($('.panel_holder.subitems').is(':visible')) { | ||||
|                     return; | ||||
|                 } | ||||
|                 var items = [{ ID: 'templates/0', Title: GetTextByKey("P_DRAFT", "Draft") }, | ||||
|                 { ID: 'templates/1', Title: GetTextByKey("P_PUBLISHED", "Published") }, | ||||
|                 { ID: 'layouts/0', Title: GetTextByKey("P_LAYOUTS", "Layouts") }]; | ||||
|                 createSubMenus(items); | ||||
|  | ||||
|                 var left = $(this).offset().left; | ||||
|                 var top = $(ev.target).offset().top - 80; | ||||
|                 $('.panel_holder.subitems').css({ | ||||
|                     'opacity': 0, | ||||
|                     'left': 60, | ||||
|                     'right': 'auto', | ||||
|                     'top': top | ||||
|                 }).show().animate({ 'opacity': 1 }, 100); | ||||
|                 $('.panel_holder.subitems .trigle').css({ | ||||
|                     'left': -10,// left - $('.panel_holder.favorites').offset().left, | ||||
|                     'right': 'auto', | ||||
|                     'top': 3 | ||||
|                 }); | ||||
|                 return false; | ||||
|             }); | ||||
|  | ||||
|             $("#apackages").click(function (ev) { | ||||
|                 if ($('#set_left').prop('isexpanded')) | ||||
|                     return; | ||||
|                 if ($('.panel_holder.subitems').is(':visible')) { | ||||
|                     return; | ||||
|                 } | ||||
|                 var items = [{ ID: 'exportpackages', Title: GetTextByKey("P_IPT_EXPORTPACKAGES", "Export Packages") }, | ||||
|                 { ID: 'importpackages', Title: GetTextByKey("P_IPT_IMPORTPACKAGES", "Import Packages") }]; | ||||
|                 createSubMenus(items); | ||||
|  | ||||
|                 var left = $(this).offset().left; | ||||
|                 var top = $(ev.target).offset().top - 80; | ||||
|                 $('.panel_holder.subitems').css({ | ||||
|                     'opacity': 0, | ||||
|                     'left': 60, | ||||
|                     'right': 'auto', | ||||
|                     'top': top | ||||
|                 }).show().animate({ 'opacity': 1 }, 100); | ||||
|                 $('.panel_holder.subitems .trigle').css({ | ||||
|                     'left': -10,// left - $('.panel_holder.favorites').offset().left, | ||||
|                     'right': 'auto', | ||||
|                     'top': 3 | ||||
|                 }); | ||||
|                 return false; | ||||
|             }); | ||||
|         }); | ||||
|     </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 (IsSupperAdmin) | ||||
|                 {%> | ||||
|             <li class="nav_item" data-module="globalsections" data-title-lgid="P_GLOBALSECTIONS"><a href="#globalsections"> | ||||
|                 <div> | ||||
|                     <em class="fa icon-menu icon-sections"></em> | ||||
|                 </div> | ||||
|                 <span data-lgid="P_GLOBALSECTIONS">Global Sections</span></a> | ||||
|             </li> | ||||
|             <%} %> | ||||
|             <%if (ShowTemplate) | ||||
|                 {%> | ||||
|             <li class="nav_item" data-title-lgid="P_TEMPLATES"><a id="atemplates"> | ||||
|                 <div> | ||||
|                     <em class="fa icon-menu icon-templates"></em> | ||||
|                 </div> | ||||
|                 <span data-lgid="P_TEMPLATES">Templates</span></a> | ||||
|             </li> | ||||
|             <li class="nav_item subitem" data-module="templates/0" data-title-lgid="P_DRAFT" style="height: 32px; line-height: 32px; display: none;"><a href="#templates/0"> | ||||
|                 <div style="width: 64px;"> | ||||
|                 </div> | ||||
|                 <span style="color: #666;" data-lgid="P_DRAFT">Draft</span></a> | ||||
|             </li> | ||||
|             <li class="nav_item subitem" data-module="templates/1" data-title-lgid="Published" style="height: 32px; line-height: 32px; display: none;"><a href="#templates/1"> | ||||
|                 <div style="width: 64px;"> | ||||
|                 </div> | ||||
|                 <span style="color: #666;" data-lgid="P_PUBLISHED">Published</span></a> | ||||
|             </li> | ||||
|             <li class="nav_item subitem" data-module="layouts/1" data-title-lgid="P_LAYOUTS" style="height: 32px; line-height: 32px; display: none;"><a href="#layouts/1"> | ||||
|                 <div style="width: 64px;"> | ||||
|                 </div> | ||||
|                 <span style="color: #666;" data-lgid="P_LAYOUTS">Layouts</span></a> | ||||
|             </li> | ||||
|  | ||||
|             <%if (!TemplateReadonly && ShowExportPackage) | ||||
|                 {%> | ||||
|             <li style="height: 10px;"> | ||||
|                 <hr style="background-color: #d8d8d8; border: none; height: 1px;" /> | ||||
|             </li> | ||||
|  | ||||
|             <li class="nav_item" data-title-lgid="P_IPT_PACKAGES"><a id="apackages"> | ||||
|                 <div> | ||||
|                     <em class="fa icon-menu icon-packages"></em> | ||||
|                 </div> | ||||
|                 <span data-lgid="P_IPT_PACKAGES">Packages</span></a> | ||||
|             </li> | ||||
|             <li class="nav_item subitem" data-module="exportpackages" data-title-lgid="P_IPT_EXPORTPACKAGES" style="height: 32px; line-height: 32px; display: none;"><a href="#exportpackages"> | ||||
|                 <div style="width: 64px;"> | ||||
|                 </div> | ||||
|                 <span style="color: #666;" data-lgid="P_IPT_EXPORTPACKAGES">Export Packages</span></a> | ||||
|             </li> | ||||
|             <li class="nav_item subitem" data-module="importpackages" data-title-lgid="P_IPT_IMPORTPACKAGES" style="height: 32px; line-height: 32px; display: none;"><a href="#importpackages"> | ||||
|                 <div style="width: 64px;"> | ||||
|                 </div> | ||||
|                 <span style="color: #666;" data-lgid="P_IPT_IMPORTPACKAGES">Import Packages</span></a> | ||||
|             </li> | ||||
|             <%} %> | ||||
|             <%} %> | ||||
|  | ||||
|             <%if (ShowReport) | ||||
|                 {%> | ||||
|             <li class="nav_item" data-module="inspections" data-title-lgid="P_INSPECTIONS"><a href="#inspections"> | ||||
|                 <div> | ||||
|                     <em class="fa icon-menu icon-report"></em> | ||||
|                 </div> | ||||
|                 <span data-lgid="P_INSPECTIONS">Inspections</span></a> | ||||
|             </li> | ||||
|             <%} %> | ||||
|         </ul> | ||||
|         <div class="hostmask maskbg" style="display: none;"></div> | ||||
|     </div> | ||||
|     <div id="set_right" style="height: 100%; overflow: auto;"> | ||||
|         <div class="loading_holder"> | ||||
|             <div class="loading_icon icn icn-spin"></div> | ||||
|         </div> | ||||
|     </div> | ||||
|     <div class="panel_holder subitems"> | ||||
|         <div id="inspectsubmenu" class="menupanel panel"> | ||||
|         </div> | ||||
|         <div class="trigle" style="left: -12px; right: auto;"></div> | ||||
|         <div class="trigle white" style="left: -12px; right: auto;"></div> | ||||
|     </div> | ||||
|  | ||||
|     <div id="mask_bg" style="display: none;"></div> | ||||
|     <div id="right_popup" style="display: none; position: absolute; left: 250px; top: 0; right: 0; bottom: 0; background-color: white; overflow: auto;"> | ||||
|     </div> | ||||
|     <div id="right_popup1" style="display: none; position: absolute; left: 250px; top: 0; right: 0; bottom: 0; background-color: white; overflow: auto;"></div> | ||||
|     <iframe id="ifdiv" style="position: absolute; top: -9999px; height: 1px; width: 1px; border: 0; display: none;"></iframe> | ||||
| </asp:Content> | ||||
|  | ||||
							
								
								
									
										117
									
								
								Site/Inspection/TeamIntelligence.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										117
									
								
								Site/Inspection/TeamIntelligence.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,117 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Web; | ||||
| using System.Web.UI; | ||||
| using System.Web.UI.WebControls; | ||||
| using Foresight.Fleet.Services.User; | ||||
| using IronIntel.Contractor; | ||||
| using IronIntel.Contractor.Site; | ||||
|  | ||||
| public partial class TeamIntelligence : InspectionBasePage | ||||
| { | ||||
|     public bool ShowTemplate = false; | ||||
|     public bool TemplateReadonly = false; | ||||
|     public bool ShowReport = false; | ||||
|     public bool ShowExportPackage = false; | ||||
|     public bool ReportReadonly = false; | ||||
|     public string BeginDate = ""; | ||||
|     public string EndDate = ""; | ||||
|     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 teamintelligence = SystemParams.HasLicense("TeamIntelligence"); | ||||
|                 if (!teamintelligence) | ||||
|                     RedirectToLoginPage(); | ||||
|                 bool inspectionpkg = SystemParams.HasLicense("ExportInspectionPackage"); | ||||
|  | ||||
|                 var user = GetCurrentUser(); | ||||
|                 ShowExportPackage = inspectionpkg && user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin; | ||||
|                 if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin) | ||||
|                 { | ||||
|                     if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin) | ||||
|                     {//T#12046-Team Intelligence Access | ||||
|                         ShowTemplate = true; | ||||
|                         ShowReport = true; | ||||
|                     } | ||||
|                 } | ||||
|                 else if (user.UserType == IronIntel.Contractor.Users.UserTypes.Common) | ||||
|                 { | ||||
|                     //var client = FleetServiceClientHelper.CreateClient<PermissionProvider>(); | ||||
|                     //Tuple<Feature, Permissions>[] pmss = client.GetUserPermissions(SystemParams.CompanyID, user.IID); | ||||
|  | ||||
|                     //if (pmss.Length > 0) | ||||
|                     //{ | ||||
|                     //    Tuple<Feature, Permissions> temppms = pmss.FirstOrDefault(m => m.Item1.Id == Feature.TEAM_TEMPLATES); | ||||
|                     //    Tuple<Feature, Permissions> reportpms = pmss.FirstOrDefault(m => m.Item1.Id == Feature.TEAM_REPORTS); | ||||
|                     //    if (temppms != null) | ||||
|                     //    { | ||||
|                     //        ShowTemplate = true; | ||||
|                     //        if (temppms.Item2 == Permissions.ReadOnly) | ||||
|                     //            TemplateReadonly = true; | ||||
|                     //    } | ||||
|                     //    if (reportpms != null) | ||||
|                     //    { | ||||
|                     //        ShowReport = true; | ||||
|                     //        if (reportpms.Item2 == Permissions.ReadOnly) | ||||
|                     //            ReportReadonly = true; | ||||
|                     //    } | ||||
|                     //} | ||||
|  | ||||
|                     if (ShowTemplate == false && ShowReport == false) | ||||
|                         RedirectToEntryPage(); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow); | ||||
|             BeginDate = userlocaldate.AddDays(-13).ToShortDateString(); | ||||
|             EndDate = userlocaldate.ToShortDateString(); | ||||
|         } | ||||
|     } | ||||
|     public bool IsForesight | ||||
|     { | ||||
|         get | ||||
|         { | ||||
|             var user = GetCurrentUser(); | ||||
|             if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin) | ||||
|                 return true; | ||||
|             else | ||||
|                 return false; | ||||
|         } | ||||
|     } | ||||
|     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(); | ||||
|             if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin) | ||||
|                 return true; | ||||
|             else | ||||
|                 return false; | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										209
									
								
								Site/Inspection/css/sections.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										209
									
								
								Site/Inspection/css/sections.css
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,209 @@ | ||||
| .question-holder, | ||||
| .section-holder { | ||||
|     white-space: nowrap; | ||||
|     -webkit-font-smoothing: antialiased; | ||||
|     min-height: 40px; | ||||
|     line-height: 40px; | ||||
|     display: -webkit-flex; | ||||
|     display: flex; | ||||
|     box-sizing: border-box; | ||||
|     user-select: none; | ||||
|     margin-left: 20px; | ||||
| } | ||||
|  | ||||
| .section-holder { | ||||
|     background: #e9e9e9; | ||||
|     font-size: 16px; | ||||
|     margin-bottom:2px; | ||||
| } | ||||
| .section-holder:hover { | ||||
|     background-color: #d9d9d9; | ||||
| } | ||||
| .section-input { | ||||
|     padding: 2px 6px; | ||||
|     min-height: 20px; | ||||
|     background-color: #e9e9e9; | ||||
|     background-image: none; | ||||
|     border: 1px solid #e9e9e9; | ||||
|     border-radius: 4px; | ||||
| } | ||||
| .section-input:hover{     | ||||
|     border: 1px solid #666; | ||||
| } | ||||
| .section-input:disabled{     | ||||
|     background: rgba(255,255,255,0); | ||||
|     border-color: rgba(255,255,255,0); | ||||
| } | ||||
|  | ||||
|  | ||||
| .question-holder .question-icon, | ||||
| .section-holder .section-icon { | ||||
|     flex-shrink: 0; | ||||
| } | ||||
| .question-holder .question-icon em { | ||||
|     /*cursor: row-resize;*/ | ||||
|     /*margin-left: 6px;*/ | ||||
|     color: #666; | ||||
| } | ||||
| .holder-even { | ||||
|     background: #f9f9f9; | ||||
| } | ||||
| .question-holder:hover { | ||||
|     background-color: #d9d9d9; | ||||
| } | ||||
| .question-input { | ||||
|     padding: 2px 6px; | ||||
|     min-height: 20px; | ||||
|     background-color: #fff; | ||||
|     border: 1px solid #fff; | ||||
|     border-radius: 4px; | ||||
| } | ||||
| .question-input:hover { | ||||
|     border: 1px solid #666; | ||||
| } | ||||
| .question-input:disabled { | ||||
|     background: rgba(255,255,255,0); | ||||
|     border-color: rgba(255,255,255,0); | ||||
| } | ||||
| .question-holder .question-notes { | ||||
|     flex-grow: 1; | ||||
|     line-height: 24px; | ||||
| } | ||||
| .question-holder .question-name span:hover, | ||||
| .question-holder .template-name span:hover, | ||||
| .question-holder .question-display span:hover, | ||||
| .section-holder .section-display span:hover, | ||||
| .section-holder .section-name span:hover { | ||||
|     text-decoration: underline; | ||||
|     cursor: pointer; | ||||
| } | ||||
| .question-holder .question-cell, | ||||
| .section-holder .section-cell { | ||||
|     display: inline-block; | ||||
|     white-space: nowrap; | ||||
|     text-overflow: ellipsis; | ||||
|     overflow: hidden; | ||||
| } | ||||
| .question-holder .question-cell.fa, | ||||
| .section-holder .section-cell .fa { | ||||
|     line-height: 40px; | ||||
| } | ||||
| .question-holder .question-cell.value-true::before { | ||||
|     content: '\f00c'; | ||||
| } | ||||
| .section-holder .section-cell .add { | ||||
|     cursor: pointer; | ||||
| } | ||||
| .section-holder .section-cell .add::before { | ||||
|     content: '\f0fe'; | ||||
| } | ||||
| .rowdrag { | ||||
|     font-size: 14px; | ||||
|     cursor:move; | ||||
| } | ||||
| .form-control { | ||||
|     /*display: block; | ||||
|     width: 100%;*/ | ||||
|     /*height: 34px;*/ | ||||
|     padding: 2px 6px; | ||||
|     /*font-size: 14px;*/ | ||||
|     /*line-height: 1.42857143;*/ | ||||
|     min-height: 20px; | ||||
|     color: #555; | ||||
|     background-color: #fff; | ||||
|     background-image: none; | ||||
|     border: 1px solid #ccc; | ||||
|     border-radius: 4px; | ||||
|     -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075); | ||||
|     box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075); | ||||
|     -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s; | ||||
|     -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; | ||||
|     transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; | ||||
| } | ||||
|  | ||||
| .prompttext { | ||||
|     color: #adb0b4; | ||||
| } | ||||
|  | ||||
| .editor-toolbar select[data-edit] { | ||||
|     vertical-align: top; | ||||
|     height: 22px; | ||||
|     box-sizing: border-box; | ||||
|     margin-right: 10px; | ||||
| } | ||||
|  | ||||
| .editor-top { | ||||
|     display: flex; | ||||
|     flex-direction: row; | ||||
|     padding: 4px 0; | ||||
| } | ||||
|     .editor-top > span { | ||||
|         flex: 1 1 auto; | ||||
|     } | ||||
|  | ||||
|     .editor-top .editor-select { | ||||
|         min-width: 150px; | ||||
|         margin-left: 4px; | ||||
|     } | ||||
|  | ||||
|     .editor-toolbar a[data-edit], | ||||
|     .svg-button { | ||||
|         display: inline-block; | ||||
|         width: 22px; | ||||
|         height: 22px; | ||||
|         cursor: pointer; | ||||
|         user-select: none; | ||||
|     } | ||||
|  | ||||
|     .editor-toolbar a[data-edit] > svg, | ||||
|     .svg-button > svg { | ||||
|         width: 22px; | ||||
|         height: 14px; | ||||
|         fill: rgba(22,92,220,.7); | ||||
|         transition: fill .2s; | ||||
|         vertical-align: top; | ||||
|         margin-top: 4px; | ||||
|     } | ||||
|  | ||||
|         .editor-toolbar a[data-edit] > svg.black { | ||||
|             fill: rgba(0,0,0,.7) | ||||
|         } | ||||
|  | ||||
|     .editor-toolbar a[data-edit]:hover > svg, | ||||
|     .svg-button:hover > svg { | ||||
|         fill: rgb(22,92,220); | ||||
|     } | ||||
|  | ||||
|         .editor-toolbar a[data-edit]:hover > svg.black { | ||||
|             fill: black | ||||
|         } | ||||
|  | ||||
| .editor-content { | ||||
|     overflow: auto; | ||||
|     width: 100%; | ||||
|     height: 100px; | ||||
|     border: 1px solid lightgray; | ||||
|     outline: none; | ||||
|     padding: 6px; | ||||
|     box-sizing: border-box; | ||||
|     transition: border-color .2s; | ||||
| } | ||||
|  | ||||
|     .editor-content:hover, | ||||
|     .editor-content:focus { | ||||
|         border-color: gray; | ||||
|     } | ||||
|  | ||||
| .svg-button { | ||||
|     line-height: 22px; | ||||
| } | ||||
|  | ||||
| .text-layout-name { | ||||
|     margin-left: 4px; | ||||
|     width: 300px; | ||||
| } | ||||
|  | ||||
| .img-icon-filename { | ||||
|     max-width: 100px; | ||||
|     margin-left: 6px; | ||||
| } | ||||
							
								
								
									
										449
									
								
								Site/Inspection/js/common.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										449
									
								
								Site/Inspection/js/common.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,449 @@ | ||||
| define(function () { | ||||
|     //define([], function () {//ʹ<><CAB9><EFBFBD>ⲿ<EFBFBD><E2B2BF>$<24><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Dialog,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
|     var gs = {}; | ||||
|     gs.title = 'Common'; | ||||
|     gs.description = 'Common'; | ||||
|     gs.version = '1.0'; | ||||
|  | ||||
|     (function () { | ||||
|         'use strict'; | ||||
|  | ||||
|         var iX, iY; | ||||
|  | ||||
|         function dragTitle(ev) { | ||||
|             if (ev.target && ev.target.nodeName === 'EM') | ||||
|                 return false; | ||||
|  | ||||
|             var dialog = ev.data; | ||||
|  | ||||
|             window.draggingDialog = dialog; | ||||
|             var o = getInnerOffset(dialog); | ||||
|             iX = ev.clientX - o.left; | ||||
|             iY = ev.clientY - o.top; | ||||
|             $(document).mousemove(dragmove); | ||||
|             $(document).mouseup(dragup); | ||||
|             var _this = this; | ||||
|             _this.setCapture && _this.setCapture(); | ||||
|  | ||||
|             var window_width = $(window).width(); | ||||
|             var window_height = $(window).height(); | ||||
|             var dragging_width = dialog.width(); | ||||
|             var dragging_height = dialog.height(); | ||||
|             function dragmove(e) { | ||||
|                 var e = e || window.event; | ||||
|                 var left, top; | ||||
|                 left = Math.max(Math.min((e.clientX - iX), window_width - dragging_width - 2), 0); | ||||
|                 top = Math.max(Math.min((e.clientY - iY), window_height - dragging_height - 2), 0); | ||||
|                 window.draggingDialog.css({ | ||||
|                     'left': left, | ||||
|                     'top': top | ||||
|                 }); | ||||
|             }; | ||||
|             function dragup(e) { | ||||
|                 $(document).unbind('mousemove', dragmove); | ||||
|                 $(document).unbind('mouseup', dragup); | ||||
|                 delete window.draggingDialog; | ||||
|                 _this.releaseCapture && _this.releaseCapture(); | ||||
|                 e.cancelBubble = true; | ||||
|             }; | ||||
|  | ||||
|             return false; | ||||
|         } | ||||
|  | ||||
|         $.fn.dialog = function (closefunc, removable) { | ||||
|             this.children('.dialog-title').mousedown(this, dragTitle); | ||||
|             this.find('.dialog-close').click(this, function (e) { | ||||
|                 if (removable) { | ||||
|                     e.data.remove(); | ||||
|                 } else { | ||||
|                     e.data.hideDialog(); | ||||
|                 } | ||||
|                 if (typeof closefunc === 'function') { | ||||
|                     closefunc(e); | ||||
|                 } | ||||
|             }); | ||||
|  | ||||
|             this.find('input.dialog-close').keydown(resettab); | ||||
|             var _this = this; | ||||
|             function resettab(e) { | ||||
|                 if (e.keyCode == 9) { | ||||
|                     var input = _this.find("input:not(:disabled),select:not(:disabled)").eq(0); | ||||
|                     input.focus(); | ||||
|                     return false; | ||||
|                 } | ||||
|             } | ||||
|             this.css({ | ||||
|                 'top': (document.documentElement.clientHeight - this.height()) / 2, | ||||
|                 'left': (document.documentElement.clientWidth - this.width()) / 2 | ||||
|             }); | ||||
|  | ||||
|             return this; | ||||
|         }; | ||||
|  | ||||
|         $.fn.showDialog = function (selfmask) { | ||||
|             //$('#mask_bg').height($(document).outerHeight(false)).width($(document).outerWidth(false)); | ||||
|             if (this.attr("init") !== "1") { | ||||
|                 this.attr("init", "1"); | ||||
|                 var _this = this; | ||||
|  | ||||
|                 if (selfmask !== false) { | ||||
|                     var mask = $('<div class="maskbg"></div>'); | ||||
|                     this.mask = mask; | ||||
|                     this.before(mask); | ||||
|                 } | ||||
|                 $(window).resize(function () { | ||||
|                     //_this.height(_this.parent().outerHeight(false) - 64).width(_this.parent().outerWidth(false) - left - 2); | ||||
|                     if (_this.mask) | ||||
|                         _this.mask.height($(document).outerHeight(false) - 64).width($(document).outerWidth(false)); | ||||
|                 }); | ||||
|             } | ||||
|  | ||||
|             if (this.mask) | ||||
|                 this.mask.show(); | ||||
|             this.show(); | ||||
|  | ||||
|             var top = (document.documentElement.clientHeight - this.height()) / 2; | ||||
|             if (top < 0) top = 0; | ||||
|             var left = (document.documentElement.clientWidth - this.width()) / 2; | ||||
|             if (left < 0) left = 0; | ||||
|             this.css({ | ||||
|                 'top': top, 'left': left | ||||
|             }); | ||||
|  | ||||
|             var input = this.find("input:not(:disabled),select:not(:disabled)").eq(0); | ||||
|             input.focus(); | ||||
|             return this; | ||||
|         }; | ||||
|  | ||||
|         $.fn.showDialogfixed = function (selfmask) { | ||||
|             if (this.attr("init") !== "1") { | ||||
|                 this.attr("init", "1"); | ||||
|                 var _this = this; | ||||
|  | ||||
|                 if (selfmask !== false) { | ||||
|                     var mask = $('<div class="maskbg"></div>'); | ||||
|                     this.mask = mask; | ||||
|                     this.before(mask); | ||||
|                 } | ||||
|             } | ||||
|             var top = (document.documentElement.clientHeight - this.height()) / 3; | ||||
|             if (top < 0) top = 0; | ||||
|             var left = (document.documentElement.clientWidth - this.width()) / 2; | ||||
|             if (left < 0) left = 0; | ||||
|             this.css({ | ||||
|                 'top': top, 'left': left | ||||
|             }); | ||||
|  | ||||
|             if (this.mask) | ||||
|                 this.mask.show(); | ||||
|             this.show(); | ||||
|             var input = this.find("input:not(:disabled),select:not(:disabled)").eq(0); | ||||
|             input.focus(); | ||||
|         }; | ||||
|  | ||||
|         $.fn.hideDialog = function () { | ||||
|             this.hide(); | ||||
|             if (this.mask) | ||||
|                 this.mask.hide(); | ||||
|         }; | ||||
|     })(); | ||||
|  | ||||
|     gs.createDialog = function (title, content, onok, ispicture) { | ||||
|         var d = $('<div class="dialog" style="width: 360px;display:none;"></div>'); | ||||
|         var t = $('<div class="dialog-title"><span class="title"></span><em class="dialog-close"></em></div>'); | ||||
|         t.find('.title').text(title); | ||||
|         d.append(t); | ||||
|  | ||||
|         var c = $('<div class="dialog-content"></div>'); | ||||
|         c.append(content); | ||||
|         d.append(c); | ||||
|  | ||||
|         var funcs = $('<div class="dialog-func"></div>'); | ||||
|         if (!ispicture) | ||||
|             funcs.append($('<input type="button" value="' + GetTextByKey("P_IPT_CANCEL", "Cancel") + '" class="dialog-close" tabindex="9999" />')); | ||||
|         if (!ispicture || (ispicture && !templatereadonly && editable)) | ||||
|             funcs.append($('<input type="button" value="' + GetTextByKey("P_IPT_OK", "OK") + '" tabindex="9998" />').click(onok)); | ||||
|         funcs.append('<div class="clear"></div>'); | ||||
|         d.append(funcs); | ||||
|  | ||||
|         d.dialog(function () { | ||||
|             d.hide(); | ||||
|         }); | ||||
|  | ||||
|         $(document.body).append(d); | ||||
|  | ||||
|         return d; | ||||
|     } | ||||
|  | ||||
|     gs.createMultiTextDialog = function (textbox, pageele) { | ||||
|         if (pageele) { | ||||
|             if (!pageele.IssueId || pageele.IssueId == "") | ||||
|                 editable = true; | ||||
|             else | ||||
|                 editable = false; | ||||
|         } | ||||
|  | ||||
|         var languages = [{ Key: 'fr-fr', Label: GetTextByKey("P_IPT_FRENCH", 'French') }, { Key: 'es-es', Label: GetTextByKey("P_IPT_SPANISH", 'Spanish') }]; | ||||
|         var inputs = []; | ||||
|  | ||||
|         var d = $('<div class="dialog textdialog" style="width: 380px;min-width:380px;box-shadow: rgba(0, 0, 0, 0.4) 0px 0px 5px 0px;"></div>'); | ||||
|         var c = $('<div class="dialog-content" style="margin-top:5px;min-height:unset;"></div>'); | ||||
|         d.append(c); | ||||
|  | ||||
|         var tb = $('<table style="line-height: 30px;"></table>'); | ||||
|         c.append(tb); | ||||
|  | ||||
|         var tr = null; | ||||
|         var input = null; | ||||
|         for (var i = 0; i < languages.length; i++) { | ||||
|             var l = languages[i]; | ||||
|             tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append($('<td class="label" style="width:80px;"></td>').text(l.Label)); | ||||
|             input = $('<input type="text" class="form-control" style="width:220px"  autocomplete="off"/>').attr("tabindex", i + 1); | ||||
|             if (textbox.attr("maxlength")) | ||||
|                 input.attr("maxlength", textbox.attr("maxlength")); | ||||
|             if (templatereadonly || !editable) | ||||
|                 input.prop('disabled', true); | ||||
|             inputs[l.Key] = input; | ||||
|  | ||||
|             var texts = textbox.data("texts") | ||||
|             if (texts) { | ||||
|                 for (var j in texts) { | ||||
|                     var t = texts[j]; | ||||
|                     if (t.Key === l.Key) { | ||||
|                         input.val(t.Value); | ||||
|                         break; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             tr.append($('<td></td>').append(input)); | ||||
|         } | ||||
|  | ||||
|         var funcs = $('<div class="dialog-func"></div>'); | ||||
|         funcs.append($('<input type="button" class="dialog-close" value="' + GetTextByKey("P_IPT_CANCEL", "Cancel") + '" tabindex="9999" />').click(oncancel)); | ||||
|         if (!templatereadonly && editable) | ||||
|             funcs.append($('<input type="button" value="' + GetTextByKey("P_IPT_OK", "OK") + '" tabindex="9998" />').click(onok)); | ||||
|         funcs.append('<div class="clear"></div>'); | ||||
|         d.append(funcs); | ||||
|  | ||||
|         function onok() { | ||||
|             var texts = []; | ||||
|             for (var i in inputs) { | ||||
|                 var input = inputs[i]; | ||||
|                 texts.push({ Key: i, Value: input.val() }); | ||||
|             } | ||||
|             textbox.data("texts", texts); | ||||
|             textbox.change(); | ||||
|             d.remove(); | ||||
|         } | ||||
|         function oncancel() { | ||||
|             d.remove(); | ||||
|         } | ||||
|  | ||||
|         d.css({ | ||||
|             'top': textbox.offset().top + textbox.height() + 5, 'left': textbox.offset().left | ||||
|         }); | ||||
|  | ||||
|         $(document.body).append(d); | ||||
|         $(window).mousedown(function (e) { | ||||
|             if ($(e.target).is(d)) | ||||
|                 return; | ||||
|             else { | ||||
|                 var textdialog = $(e.target).parents(".textdialog"); | ||||
|                 if (textdialog.is(d)) | ||||
|                     return; | ||||
|             } | ||||
|             d.remove(); | ||||
|         }); | ||||
|  | ||||
|         d.find('input.dialog-close').keydown(resettab); | ||||
|         function resettab(e) { | ||||
|             if (e.keyCode == 9) { | ||||
|                 var input = d.find("input:not(:disabled),select:not(:disabled)").eq(0); | ||||
|                 input.focus(); | ||||
|                 return false; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return d; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     gs.createImageDialog = function (obj, pageele) {//pageele should contain StaticPictures attr. | ||||
|         var inputs = []; | ||||
|         var tabindex = 0; | ||||
|  | ||||
|         var d = $('<div class="dialog textdialog" style="width: 380px;min-width:380px;box-shadow: rgba(0, 0, 0, 0.4) 0px 0px 5px 0px;"></div>'); | ||||
|         var c = $('<div class="dialog-content" style="margin-top:5px;min-height:unset;"></div>'); | ||||
|         d.append(c); | ||||
|  | ||||
|         var tb = $('<table style="line-height: 30px;"></table>'); | ||||
|         c.append(tb); | ||||
|  | ||||
|         var tr = null; | ||||
|         var input = null; | ||||
|         if (pageele && pageele.StaticPictures && pageele.StaticPictures.length > 0) { | ||||
|             for (var i = 0; i < pageele.StaticPictures.length; i++) { | ||||
|                 var p = pageele.StaticPictures[i]; | ||||
|                 addpicturerow(p); | ||||
|             } | ||||
|         } | ||||
|         else { | ||||
|             addnopicrow(); | ||||
|         } | ||||
|  | ||||
|         var nopictr = null; | ||||
|         function addnopicrow() { | ||||
|             nopictr = $('<tr style="height:30px;"></tr>'); | ||||
|             var td = $('<td style="padding:5px;padding-left:10px;">No Picture</td>'); | ||||
|             nopictr.append(td); | ||||
|             tb.append(nopictr); | ||||
|         } | ||||
|  | ||||
|         function addpicturerow(p) { | ||||
|             if (nopictr) { | ||||
|                 nopictr.remove(); | ||||
|                 nopictr = null; | ||||
|             } | ||||
|             tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             var td = $('<td></td>'); | ||||
|             var img = $('<img style="width:40px;height:40px;"/>').attr('src', p.Url); | ||||
|             td.append(img); | ||||
|             tr.append(td); | ||||
|             input = $('<input type="text" class="form-control" style="width:220px" maxlength="100" autocomplete="off"/>').attr("tabindex", ++tabindex); | ||||
|             if (templatereadonly || !editable) | ||||
|                 input.prop('disabled', true); | ||||
|             input.val(p.Name); | ||||
|             input.data("pic", p); | ||||
|             inputs.push(input); | ||||
|  | ||||
|             tr.append($('<td></td>').append(input)); | ||||
|  | ||||
|             td = $('<td></td>'); | ||||
|             if (!templatereadonly && editable) { | ||||
|                 var del = $('<span class="spanbtn icondelete"></span>').click(input, function (e) { | ||||
|                     showConfirm(GetTextByKey("P_IPT_DELETEPICTURECONFIRM", 'Are you sure you want to delete this picture?'), GetTextByKey("P_IPT_DELETEPICTURE", 'Delete Picture'), function () { | ||||
|                         var p = e.data.data("pic"); | ||||
|                         e.data.parent().parent().remove(); | ||||
|                         inputs.splice(inputs.indexOf(e.data), 1); | ||||
|  | ||||
|                         //inspectionrequest("DeleteStaticPicture", p.ContentId, function (data) { | ||||
|                         //}, function (err) { | ||||
|                         //}); | ||||
|                     }); | ||||
|                 }); | ||||
|                 td.append(del) | ||||
|             } | ||||
|             tr.append(td); | ||||
|         } | ||||
|  | ||||
|         function browsePicture() { | ||||
|             var file = $('<input type="file" style="display: none;" accept="image/png,image/jpg,image/jpeg" />'); | ||||
|             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 > 1024 * 1024 * 2) { | ||||
|                     alert(GetTextByKey("P_MA_DOCUMENTTIPS1", "Document is too large. Maximum file size is 2MB.")); | ||||
|                     return false; | ||||
|                 } | ||||
|                 SavePicture(file); | ||||
|             }).click(); | ||||
|         } | ||||
|  | ||||
|         function SavePicture(file) { | ||||
|             var formData = new FormData(); | ||||
|             formData.append("pic", file); | ||||
|             formData.append("MethodName", "UploadStaticPicture"); | ||||
|             $.ajax({ | ||||
|                 url: 'Inspection.aspx', | ||||
|                 type: 'POST', | ||||
|                 dataType: 'json', | ||||
|                 processData: false, | ||||
|                 contentType: false, | ||||
|                 data: formData, | ||||
|                 async: true, | ||||
|                 success: function (data) { | ||||
|                     if (data) { | ||||
|                         var p = {}; | ||||
|                         p.ContentId = data.Item1; | ||||
|                         p.Url = data.Item2; | ||||
|                         p.Name = file.name; | ||||
|                         p.DataType = file.name.substring(file.name.lastIndexOf(".")); | ||||
|                         addpicturerow(p); | ||||
|                     } | ||||
|                 }, | ||||
|                 error: function (err) { | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         if (!templatereadonly && editable) { | ||||
|             var addpicdiv = $('<div style="line-height: 30px;"></div>'); | ||||
|             var addpicicon = $('<span class="sbutton iconadd">Add Picture</span>').click(function () { | ||||
|                 browsePicture(); | ||||
|             }); | ||||
|             addpicdiv.append(addpicicon); | ||||
|             var addtemppicicon = $('<span class="sbutton iconadd">Add Template Picture</span>').click(function () { | ||||
|                 //browsePicture(); | ||||
|             }); | ||||
|             addpicdiv.append(addtemppicicon); | ||||
|             c.append(addpicdiv); | ||||
|         } | ||||
|  | ||||
|         var funcs = $('<div class="dialog-func"></div>'); | ||||
|         funcs.append($('<input type="button" value="' + GetTextByKey("P_IPT_OK", "OK") + '" tabindex="9998" />').click(onok)); | ||||
|         funcs.append('<div class="clear"></div>'); | ||||
|         d.append(funcs); | ||||
|  | ||||
|         function onok() { | ||||
|             if (!templatereadonly && editable) { | ||||
|                 var pics = []; | ||||
|                 for (var i in inputs) { | ||||
|                     var input = inputs[i]; | ||||
|                     var p = input.data("pic"); | ||||
|                     p.Name = input.val(); | ||||
|                     pics.push(p); | ||||
|                 } | ||||
|                 pageele.StaticPictures = pics; | ||||
|             } | ||||
|  | ||||
|             d.remove(); | ||||
|         } | ||||
|  | ||||
|         d.css({ | ||||
|             'top': obj.offset().top + obj.height() + 5, 'left': obj.offset().left | ||||
|         }); | ||||
|  | ||||
|         $(document.body).append(d); | ||||
|         $(window).mousedown(function (e) { | ||||
|             if ($(e.target).is(d)) | ||||
|                 return; | ||||
|             else { | ||||
|                 var textdialog = $(e.target).parents(".textdialog"); | ||||
|                 if (textdialog.is(d)) | ||||
|                     return; | ||||
|             } | ||||
|             d.remove(); | ||||
|         }); | ||||
|  | ||||
|         d.find('input.dialog-close').keydown(resettab); | ||||
|         function resettab(e) { | ||||
|             if (e.keyCode == 9) { | ||||
|                 var input = d.find("input:not(:disabled),select:not(:disabled)").eq(0); | ||||
|                 input.focus(); | ||||
|                 return false; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return d; | ||||
|     } | ||||
|  | ||||
|     return gs; | ||||
| }); | ||||
							
								
								
									
										44
									
								
								Site/Inspection/js/main.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								Site/Inspection/js/main.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,44 @@ | ||||
| require.config({ | ||||
|     baseUrl: 'js', | ||||
|     paths: { | ||||
|         //jquery: "../../js/jquery-3.6.0.min", | ||||
|         //spectrum: "../../js/spectrum" | ||||
|     }, | ||||
|     waitSeconds: 0, | ||||
|     urlArgs: "v=437" //+ Math.random() | ||||
| }) | ||||
|  | ||||
| requirejs(['modules/pageloader'], function (loader) { | ||||
|     loader.links = '.ul_menu .nav_item'; | ||||
|     loader.content = '#set_right'; | ||||
|     loader.init(); | ||||
|  | ||||
|     setFavoriteDisplay(true, teamintelligence ? 700 : 650); | ||||
|  | ||||
|     var ANIMATION_DURATION = 120; | ||||
|  | ||||
|     $('#nav_arrow').click(function () { | ||||
|         var flag = !$('#set_left').prop('isexpanded'); | ||||
|         setCookie("LeftPanelExpanded", flag ? "1" : "0"); | ||||
|         $('#set_left').stop() | ||||
|             .prop('isexpanded', flag) | ||||
|             .animate({ 'width': flag ? 250 : 50 }, ANIMATION_DURATION) | ||||
|             //.find('li a').css('display', flag ? 'none' : '') | ||||
|             ; | ||||
|         if (flag) | ||||
|             $('#set_left').find(".subitem").show(); | ||||
|         else | ||||
|             $('#set_left').find(".subitem").hide(); | ||||
|  | ||||
|         $('#set_right').stop() | ||||
|             .animate({ 'margin-left': flag ? 250 : 50 }, ANIMATION_DURATION); | ||||
|  | ||||
|         $('#nav_arrow div').attr('class', 'icn') | ||||
|             .addClass(flag ? 'expand' : 'collapse'); | ||||
|     }); | ||||
|  | ||||
|     $('#set_left').prop('isexpanded', false); | ||||
|     var leftexpanded = getCookie("LeftPanelExpanded") === "1"; | ||||
|     if (leftexpanded) | ||||
|         $('#nav_arrow').click(); | ||||
| }) | ||||
							
								
								
									
										178
									
								
								Site/Inspection/js/modules/editor.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										178
									
								
								Site/Inspection/js/modules/editor.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,178 @@ | ||||
| !function (factory) { | ||||
|     if (typeof define === 'function' && define.amd) { | ||||
|         define([], function () { | ||||
|             return factory(window.jQuery); | ||||
|         }); | ||||
|     } | ||||
| }(function ($) { | ||||
|     'use strict'; | ||||
|  | ||||
|     function Editor(element, options) { | ||||
|         this.selectedRange = null; | ||||
|         this.container = $(element); | ||||
|  | ||||
|         var editor = $('<div class="editor-content"></div>'); | ||||
|         this.container.find('.editor-content').remove(); | ||||
|         this.container.append(editor); | ||||
|         this.editor = editor; | ||||
|  | ||||
|         var defaults = { | ||||
|             toolbarSelector: '.editor-toolbar', | ||||
|             commandRole: 'edit', | ||||
|             activeToolbarClass: 'selected', | ||||
|             selectionColor: 'darkgray' | ||||
|         }; | ||||
|         var opts = $.extend(true, {}, defaults, options); | ||||
|         var toolbarBtnSelector = 'a[data-' + opts.commandRole + '],button[data-' + opts.commandRole + '],input[type=button][data-' + opts.commandRole + ']'; | ||||
|         this.bindHotkeys(editor, opts, toolbarBtnSelector); | ||||
|         this.bindToolbar(editor, this.container.find(opts.toolbarSelector), opts, toolbarBtnSelector); | ||||
|  | ||||
|         editor.attr('contenteditable', true).on('mouseup keyup mouseout', function () { | ||||
|             this.saveSelection(); | ||||
|             this.updateToolbar(toolbarBtnSelector, opts); | ||||
|         }.bind(this)); | ||||
|  | ||||
|         $(window).bind('touchend', function (e) { | ||||
|             if (!this.getCurrentRange) { | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
|             var inside = (editor.is(e.target) || editor.has(e.target).length > 0), | ||||
|                 currentRange = this.getCurrentRange(), | ||||
|                 clear = currentRange && (currentRange.startContainer === currentRange.endContainer && currentRange.startOffset === currentRange.endOffset); | ||||
|  | ||||
|             if (!clear || inside) { | ||||
|                 this.saveSelection(); | ||||
|                 this.updateToolbar(toolbarBtnSelector, opts); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     Editor.prototype.cleanHtml = function () { | ||||
|         var html = this.editor.html(); | ||||
|         return html && html.replace(/(\<br\>|\s|\<div\>\<br\>\<\/div\>| )*$/g, ''); | ||||
|     }; | ||||
|  | ||||
|     Editor.prototype.updateToolbar = function (selector, options) { | ||||
|         if (options.activeToolbarClass) { | ||||
|             this.container.find(options.toolbarSelector).find(selector).each(function () { | ||||
|                 var This = $(this); | ||||
|                 var commandArray = This.data(options.commandRole).split(' '); | ||||
|                 var command = commandArray[0]; | ||||
|                 if (commandArray.length > 1 && document.queryCommandEnabled(command) && document.queryCommandValue(command) === commandArray[1]) { | ||||
|                     This.addClass(options.activeToolbarClass); | ||||
|                 } else if (commandArray.length === [1] && document.queryCommandEnabled(command) && document.queryCommandState(command)) { | ||||
|                     This.addClass(options.activeToolbarClass); | ||||
|                 } else { | ||||
|                     This.removeClass(options.activeToolbarClass); | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     Editor.prototype.execCommand = function (commandWithArgs, valueArg, editor, options, selector) { | ||||
|         var commandArray = commandWithArgs.split(' '), | ||||
|             command = commandArray.shift(), | ||||
|             args = commandArray.join(' ') + (valueArg || ''); | ||||
|         var parts = commandWithArgs.split('-'); | ||||
|         if (parts.length === 1) { | ||||
|             document.execCommand(command, false, args); | ||||
|         } else if (parts.length === 2) { | ||||
|             document.execCommand(parts[0], false, parts[1]); | ||||
|         } | ||||
|         editor.trigger('change'); | ||||
|         this.updateToolbar(selector, options); | ||||
|     }; | ||||
|  | ||||
|     Editor.prototype.bindHotkeys = function (editor, options, selector) { | ||||
|         var This = this; | ||||
|         editor.on('keydown', function (e) { | ||||
|             if (e.key === 'Tab') { | ||||
|                 var command = e.shiftKey ? 'outdent' : 'indent'; | ||||
|                 e.preventDefault(); | ||||
|                 e.stopPropagation(); | ||||
|                 This.execCommand(command, null, editor, options, selector); | ||||
|             } | ||||
|         }).on('keyup', function () { | ||||
|             editor.trigger('change'); | ||||
|         }); | ||||
|     }; | ||||
|  | ||||
|     Editor.prototype.getCurrentRange = function () { | ||||
|         var sel, range; | ||||
|         if (window.getSelection) { | ||||
|             sel = window.getSelection(); | ||||
|             if (sel.getRangeAt && sel.rangeCount) { | ||||
|                 range = sel.getRangeAt(0); | ||||
|             } | ||||
|         } else if (document.selection) { | ||||
|             range = document.selection.createRange(); | ||||
|         } | ||||
|         return range; | ||||
|     }; | ||||
|  | ||||
|     Editor.prototype.saveSelection = function () { | ||||
|         this.selectedRange = this.getCurrentRange(); | ||||
|     } | ||||
|  | ||||
|     Editor.prototype.restoreSelection = function () { | ||||
|         var selection; | ||||
|         if (window.getSelection || document.createRange) { | ||||
|             selection = window.getSelection(); | ||||
|             if (this.selectedRange) { | ||||
|                 try { | ||||
|                     selection.removeAllRanges(); | ||||
|                 } catch { | ||||
|                     document.body.createTextRange().select(); | ||||
|                     document.selection.empty(); | ||||
|                 } | ||||
|                 selection.addRange(this.selectedRange); | ||||
|             } | ||||
|         } else if (document.selection && this.selectedRange) { | ||||
|             this.selectedRange.select(); | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     Editor.prototype.markSelection = function (color) { | ||||
|         this.restoreSelection(); | ||||
|         if (document.queryCommandSupported('hiliteColor')) { | ||||
|             document.execCommand('hiliteColor', false, color || 'transparent'); | ||||
|         } | ||||
|         this.saveSelection(); | ||||
|     }; | ||||
|  | ||||
|     Editor.prototype.bindToolbar = function (editor, toolbar, options, selector) { | ||||
|         var This = this; | ||||
|         toolbar.find(selector).on('click', function () { | ||||
|             var command = $(this).data(options.commandRole); | ||||
|             if (command === 'createlink') { | ||||
|                 var link = prompt('Write the URL here', 'https:\/\/'); | ||||
|                 This.restoreSelection(); | ||||
|                 editor.focus(); | ||||
|                 if (link == null || link === '' || link === 'https:\/\/') { | ||||
|                     This.saveSelection(); | ||||
|                     return; | ||||
|                 } | ||||
|                 This.execCommand(command, link, editor, options, selector); | ||||
|             } else { | ||||
|                 This.restoreSelection(); | ||||
|                 editor.focus(); | ||||
|                 This.execCommand(command, null, editor, options, selector); | ||||
|                 This.saveSelection(); | ||||
|             } | ||||
|         }); | ||||
|         toolbar.find('select').on('change', function () { | ||||
|             var command = $(this).data(options.commandRole); | ||||
|             var value = $(this).val(); | ||||
|             if (value == null || value === '') { | ||||
|                 editor.focus(); | ||||
|                 return; | ||||
|             } | ||||
|             This.execCommand(command + '-' + value, null, editor, options, selector); | ||||
|             editor.focus(); | ||||
|             this.selectedIndex = 0; | ||||
|         }); | ||||
|     }; | ||||
|  | ||||
|     return Editor; | ||||
| }); | ||||
							
								
								
									
										187
									
								
								Site/Inspection/js/modules/exportpackages.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										187
									
								
								Site/Inspection/js/modules/exportpackages.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,187 @@ | ||||
| define(['modules/packages/createpackage'], function (CreatePackageModule) { | ||||
|     var exppkg = {}; | ||||
|     exppkg.title = GetTextByKey("P_IPT_EXPORTPACKAGES", 'Export Packages'); | ||||
|     exppkg.description = GetTextByKey("P_IPT_EXPORTPACKAGES", 'Export Packages'); | ||||
|     exppkg.version = '1.0'; | ||||
|     exppkg.status = 0; | ||||
|  | ||||
|     var datacontent = null; | ||||
|     var grid_dt; | ||||
|     exppkg.createContent = function (args) { | ||||
|         var _this = this; | ||||
|         if (args && args.length > 0) | ||||
|             exppkg.status = eval(args[0]); | ||||
|  | ||||
|         var content = $('<div style="width:100%;" ></div>'); | ||||
|  | ||||
|         function createHeader() { | ||||
|             var header = $('<div></div>'); | ||||
|             header.append($('<div class="page_title"></div>').text(exppkg.title)); | ||||
|             setPageTitle(exppkg.title, true); | ||||
|  | ||||
|             var func = $('<div class="function_title"></div>'); | ||||
|             var iconCreate = $('<span class="sbutton iconadd">' + GetTextByKey("P_IPT_CREATE", "Create") + '</span>').click(function () { | ||||
|                 exppkg.oncreate(); | ||||
|             }); | ||||
|             func.append(iconCreate); | ||||
|             var iconRefresh = $('<span class="sbutton iconrefresh">' + GetTextByKey("P_IPT_REFRESH", "Refresh") + '</span>').click(function () { | ||||
|                 exppkg.refresh(); | ||||
|             }); | ||||
|             func.append(iconRefresh); | ||||
|             header.append(func) | ||||
|  | ||||
|             return header; | ||||
|         } | ||||
|  | ||||
|         function InitGridData() { | ||||
|             var div_grid = $('<div style="padding-right:10px;"></div>'); | ||||
|             div_grid.css("height", $(window).height() - 145); | ||||
|  | ||||
|             grid_dt = new GridView(div_grid); | ||||
|             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: 'PackageName', caption: GetTextByKey("P_IPT_PACKAGENAME", "Package Name"), valueIndex: 'PackageName', css: { 'width': 300, 'text-align': 'left' } }, | ||||
|                 { name: 'Notes', caption: GetTextByKey("P_IPT_NOTES", "Notes"), valueIndex: 'Notes', css: { 'width': 300, 'text-align': 'left' } }, | ||||
|                 { name: 'Creator', caption: GetTextByKey("P_IPT_CREATOR", "Creator"), valueIndex: 'Creator', css: { 'width': 250, 'text-align': 'left' } }, | ||||
|                 { name: 'CreatedOnLocal', caption: GetTextByKey("P_IPT_DATETIMECREATED", "Date/Time Created"), valueIndex: 'CreatedOnLocal', css: { 'width': 180, 'text-align': 'left' } }, | ||||
|                 { name: 'DownLoad', 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; | ||||
|                 if (ReportReadonly && col.name === 'Edit') { | ||||
|                     continue; | ||||
|                 } | ||||
|                 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 === "DownLoad") { | ||||
|                     col.isurl = true; | ||||
|                     col.text = "\uf019"; | ||||
|                     col.sortable = false; | ||||
|                     col.events = { | ||||
|                         onclick: function () { | ||||
|                             _this.onDownLoadPackage(); | ||||
|                         } | ||||
|                     }; | ||||
|                     col.classFilter = function (e) { | ||||
|                         return "icon-col"; | ||||
|                     } | ||||
|                     col.attrs = { 'title': GetTextByKey("P_IPT_DOWNLOADPACKAGE", 'Download Package') }; | ||||
|                 } | ||||
|                 else if (col.name === "Delete") { | ||||
|                     col.isurl = true; | ||||
|                     col.text = "\uf00d"; | ||||
|                     col.sortable = false; | ||||
|                     col.events = { | ||||
|                         onclick: function () { | ||||
|                             _this.onDeletePackage(); | ||||
|                         } | ||||
|                     }; | ||||
|                     col.classFilter = function (e) { | ||||
|                         return "icon-col"; | ||||
|                     } | ||||
|                     col.attrs = { 'title': GetTextByKey("P_IPT_DELETEPACKAGE", 'Delete Package') }; | ||||
|                 } | ||||
|  | ||||
|  | ||||
|                 columns.push(col); | ||||
|             } | ||||
|             grid_dt.canMultiSelect = false; | ||||
|             grid_dt.columns = columns; | ||||
|             grid_dt.init(); | ||||
|             grid_dt.rowdblclick = _this.onDownLoad; | ||||
|  | ||||
|             grid_dt.selectedrowchanged = function (rowindex) { | ||||
|                 var rowdata = grid_dt.source[rowindex]; | ||||
|                 if (rowdata) { | ||||
|                 } | ||||
|             } | ||||
|             return div_grid; | ||||
|         } | ||||
|  | ||||
|         content.append(createHeader()); | ||||
|         content.append(InitGridData()); | ||||
|         datacontent = $('<div></div>'); | ||||
|         content.append(datacontent); | ||||
|  | ||||
|         _this.refresh(); | ||||
|         return content; | ||||
|     } | ||||
|  | ||||
|     exppkg.oncreate = function () { | ||||
|         var _this = this; | ||||
|  | ||||
|         var ei = new CreatePackageModule.CreatePackage(_this); | ||||
|         $('#right_popup').empty().append(ei.createContent()); | ||||
|         showRightPopup(true); | ||||
|     } | ||||
|  | ||||
|     exppkg.onDeletePackage = function () { | ||||
|         var _this = this; | ||||
|         var index = grid_dt.selectedIndex; | ||||
|         var package = grid_dt.source[index].Values; | ||||
|         showConfirm(GetTextByKey("P_IPT_AREYOUSUREYOUWANTTODELETETHISPACKAGE", 'Are you sure you want to delete this package?'), GetTextByKey("P_IPT_DELETEPACKAGE", 'Delete Package'), function () { | ||||
|             var p = JSON.stringify([teamintelligence, htmlencode(package.PackageId)]); | ||||
|             inspectionrequest("DeletePackage", p, function (data) { | ||||
|                 if (data !== 'OK') { | ||||
|                     showAlert(data, GetTextByKey("P_IPT_DELETEPACKAGE", 'Delete Package')); | ||||
|                     return; | ||||
|                 } | ||||
|                 _this.refresh(); | ||||
|             }, function (err) { | ||||
|                 showAlert(GetTextByKey("P_IPT_FAILEDTODELETEPACKAGE", 'Failed to delete package.'), GetTextByKey("P_IPT_DELETEPACKAGE", 'Delete Package')); | ||||
|             }); | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     exppkg.onDownLoadPackage = function () { | ||||
|         var index = grid_dt.selectedIndex; | ||||
|         var package = grid_dt.source[index].Values; | ||||
|         window.open("../filesvc.ashx?sourceType=ipackage&attchid=" + package.PackageId); | ||||
|     } | ||||
|  | ||||
|     function showPackages(data) { | ||||
|         var rows = []; | ||||
|         for (var i = 0; i < data.length; i++) { | ||||
|             var r = data[i]; | ||||
|             for (var j in r) { | ||||
|                 if (j === "CreatedOnLocal") { | ||||
|                     r[j] = { DisplayValue: r["CreatedOnLocalStr"], Value: r[j] }; | ||||
|                 } | ||||
|             } | ||||
|             var fr = { Values: r }; | ||||
|             rows.push(fr); | ||||
|         } | ||||
|  | ||||
|         grid_dt.setData(rows); | ||||
|     } | ||||
|  | ||||
|     exppkg.refresh = function () { | ||||
|         datacontent.empty(); | ||||
|         inspectionrequest("GetCreatedPackages", '', function (data) { | ||||
|             if (typeof (data) === "string") { | ||||
|                 showAlert(data, GetTextByKey("P_IPT_EXPORTPACKAGES", 'Export Packages')); | ||||
|                 return; | ||||
|             } | ||||
|             datacontent.empty(); | ||||
|             if (data) { | ||||
|                 showPackages(data); | ||||
|             } | ||||
|         }, function (err) { | ||||
|         }); | ||||
|     } | ||||
|     return exppkg; | ||||
| }); | ||||
							
								
								
									
										284
									
								
								Site/Inspection/js/modules/fuellog.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										284
									
								
								Site/Inspection/js/modules/fuellog.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,284 @@ | ||||
| define([], function () { | ||||
|     var gs = {}; | ||||
|     gs.title = GetTextByKey("P_IPT_FUELLOG", 'Fuel Log'); | ||||
|     gs.description = GetTextByKey("P_IPT_FUELLOG", 'Fuel Log'); | ||||
|     gs.version = '1.0'; | ||||
|     gs.status = 0; | ||||
|  | ||||
|     var datacontent = null; | ||||
|     var startdateinputcontrol = undefined; | ||||
|     var enddateinputcontrol = undefined; | ||||
|     gs.createContent = function () { | ||||
|         var _this = this; | ||||
|         var content = $('<div style="width:100%;" ></div>'); | ||||
|  | ||||
|         function createHeader() { | ||||
|             var header = $('<div></div>'); | ||||
|             header.append($('<div class="page_title"></div>').text(gs.title)); | ||||
|             setPageTitle(gs.title, true); | ||||
|             var search_bar = $('<div class="search_bar"></div>'); | ||||
|             header.append(search_bar); | ||||
|             search_bar.append('<input type="password" autocomplete="new-password" style="display: none" />'); | ||||
|             search_bar.append('<span style="margin-left:5px;">' + GetTextByKey("P_IPT_BEGINDATE_COLON", "Begin Date:") + '</span>'); | ||||
|             startdateinputcontrol = $('<input type="text" style="margin-left: 5px; width: 80px;" autocomplete="off" />').val(begindate); | ||||
|             search_bar.append($('<span></span>').append(startdateinputcontrol)); | ||||
|             startdateinputcontrol.datetimepicker({ | ||||
|                 timepicker: false, | ||||
|                 format: 'm/d/Y' | ||||
|             }); | ||||
|             search_bar.append('<span style="margin-left:10px;">' + GetTextByKey("P_IPT_ENDDATE_COLON", "End Date:") + '</span>'); | ||||
|             enddateinputcontrol = $('<input type="text" style="margin-left: 5px; width: 80px;" autocomplete="off" />').val(enddate); | ||||
|             search_bar.append($('<span></span>').append(enddateinputcontrol)); | ||||
|             enddateinputcontrol.datetimepicker({ | ||||
|                 timepicker: false, | ||||
|                 format: 'm/d/Y' | ||||
|             }); | ||||
|  | ||||
|             var btnRefresh = $('<input class="search" type="button" value="' + GetTextByKey("P_IPT_SEARCH", "Search") + '" style="margin-left:10px;"/>'); | ||||
|             search_bar.append(btnRefresh); | ||||
|             btnRefresh.click(function () { | ||||
|                 gs.refresh(); | ||||
|             }); | ||||
|  | ||||
|             var func = $('<div class="function_title"></div>'); | ||||
|             var iconRefresh = $('<span class="sbutton iconrefresh">' + GetTextByKey("P_IPT_REFRESH", "Refresh") + '</span>').click(function () { | ||||
|                 gs.refresh(); | ||||
|             }); | ||||
|             func.append(iconRefresh); | ||||
|             var iconSettings = $('<span class="sbutton iconcog" style="float: right; line-height: 20px">' + GetTextByKey("P_MAIN_SETTINGS", "Settings") + '</span>').click(function () { | ||||
|                 gs.createSettings(); | ||||
|             }); | ||||
|             func.append(iconSettings); | ||||
|             header.append(func) | ||||
|  | ||||
|             return header; | ||||
|         } | ||||
|  | ||||
|         content.append(createHeader()); | ||||
|  | ||||
|         var dataheader = $('<div class="question-holder no-hover" style="font-weight: bold;font-size:14px;"></div>'); | ||||
|         dataheader.append('<div style="width:60px; flex-shrink: 0"></div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width: 150px">' + GetTextByKey("P_IPT_DATE", "Date") + '</div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width: 200px">' + GetTextByKey("P_IPT_ASSETNAME", "Asset Name") + '</div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width: 200px">' + GetTextByKey("P_IPT_VIN", "VIN") + '</div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width: 200px;">' + GetTextByKey("P_IPT_EMPLOYEENAME", "Employee Name") + '</div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width: 150px;">' + GetTextByKey("P_IPT_CHECKEDIN", "Checked In") + '</div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width: 150px;">' + GetTextByKey("P_IPT_CHECKEDOUT", "Checked Out") + '</div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width: 90px;padding-right:20px;"></div>'); | ||||
|         content.append(dataheader); | ||||
|  | ||||
|         datacontent = $('<div></div>'); | ||||
|         content.append(datacontent); | ||||
|  | ||||
|         _this.refresh(); | ||||
|         return content; | ||||
|     } | ||||
|  | ||||
|     gs.refresh = function () { | ||||
|         var _this = this; | ||||
|         datacontent.empty(); | ||||
|         var startydate = startdateinputcontrol.val(); | ||||
|         var enddate = enddateinputcontrol.val(); | ||||
|         var p = JSON.stringify([teamintelligence, startydate, enddate]); | ||||
|         inspectionrequest("GetFuelReportItems", htmlencode(p), function (data) { | ||||
|             datacontent.empty(); | ||||
|             if (typeof (data) === "string") { | ||||
|                 showAlert(data, GetTextByKey("P_IPT_ERROR", 'Error')); | ||||
|                 return; | ||||
|             } | ||||
|             if (data) { | ||||
|                 for (var i = 0; i < data.length; i++) { | ||||
|                     _this.createFuelLog(data[i]); | ||||
|                 } | ||||
|                 //showFuelLogs(data); | ||||
|             } | ||||
|         }, function (err) { | ||||
|         }); | ||||
|     } | ||||
|     gs.createFuelLog = function (fuellog) { | ||||
|         var _this = this; | ||||
|         var content = $('<div></div>'); | ||||
|         var holder = $('<div class="section-holder"></div>'); | ||||
|         content.append(holder); | ||||
|  | ||||
|         var btnfuleitem = $('<div class="section-icon" style="width: 30px;"><em class="spanbtn iconangleright" style="font-size:18px;"></em></div>'); | ||||
|         btnfuleitem.click(function () { | ||||
|             var icon = btnfuleitem.find('.spanbtn'); | ||||
|             if (icon.hasClass('iconangleright')) { | ||||
|                 icon.removeClass('iconangleright').addClass('iconangledown'); | ||||
|                 if (fuellog.FuelReportItems) | ||||
|                     _this.createFuelItem(content, fuellog.FuelReportItems); | ||||
|             } | ||||
|             else { | ||||
|                 icon.removeClass('iconangledown').addClass('iconangleright'); | ||||
|                 btnfuleitem.parents().parents().children('.questionitem').remove(); | ||||
|             } | ||||
|         }); | ||||
|         holder.append(btnfuleitem); | ||||
|  | ||||
|         var spantime = $('<lable></lable>').text(GetTextByKey("P_IPT_DATE", "Date:") + fuellog.LocalCalendarDateStr); | ||||
|         var spancount = $('<lable></lable>').text("(" + fuellog.FuelReportCount + ")"); | ||||
|         holder.append($('<div class="section-cell section-name" style="width:200px;flex-grow:0;font-size:12px;"></div>').append(spantime).append(spancount)); | ||||
|         datacontent.append(content); | ||||
|     } | ||||
|  | ||||
|     gs.createFuelItem = function (content, fuelitem) { | ||||
|         var _this = this; | ||||
|         for (var i = 0; i < fuelitem.length; i++) { | ||||
|             var fuel = fuelitem[i]; | ||||
|             var holder = $('<div class="questionitem"></div>'); | ||||
|             var qholder = $('<div class="question-holder"></div>');//question holder | ||||
|             holder.append(qholder); | ||||
|  | ||||
|             if (_this.index % 2 == 1) | ||||
|                 qholder.addClass('holder-even'); | ||||
|  | ||||
|             qholder.append('<div class="question-icon" style="width:30px;"><em class="fa"></em></div>'); | ||||
|  | ||||
|             var span = $('<span></span>').text(fuel.LocalCalendarDateStr); | ||||
|             qholder.append($('<div class="question-cell question-name" style="width: 150px;padding-left:10px;"></div>').append(span)); | ||||
|  | ||||
|             span = $('<span></span>').text(fuel.AssetName); | ||||
|             qholder.append($('<div class="question-cell" style="width: 200px;padding-left:10px;"></div>').append(span)); | ||||
|  | ||||
|             span = $('<span></span>').text(fuel.VIN); | ||||
|             qholder.append($('<div class="question-cell" style="width: 200px;padding-left:10px;"></div>').append(span)); | ||||
|  | ||||
|             span = $('<span></span>').text(fuel.EmployeeName); | ||||
|             qholder.append($('<div class="question-cell" style="width: 200px;padding-left:10px;"></div>').append(span)); | ||||
|  | ||||
|             span = $('<span></span>').text(fuel.CheckInTimeLocalStr); | ||||
|             qholder.append($('<div class="question-cell" style="width: 150px;padding-left:10px;"></div>').append(span)); | ||||
|  | ||||
|             span = $('<span></span>').text(fuel.CheckOutTimeLocalStr); | ||||
|             qholder.append($('<div class="question-cell" style="width: 150px;padding-left:10px;"></div>').append(span)); | ||||
|  | ||||
|             holder.dblclick(fuel, function (e) { | ||||
|                 window.open("fuelreport.aspx?rid=" + e.data.Id + "&team=" + (teamintelligence ? 1 : 0), "_blank"); | ||||
|             }); | ||||
|  | ||||
|             holder.find('.question-name span').click(fuel, function (e) { | ||||
|                 window.open("fuelreport.aspx?rid=" + e.data.Id + "&team=" + (teamintelligence ? 1 : 0), "_blank"); | ||||
|             }); | ||||
|  | ||||
|             content.append(holder); | ||||
|         } | ||||
|     } | ||||
|     gs.createSettings = function () { | ||||
|         var loading = $('<div class="loading_holder" style="top: 0; background-color: rgba(0,0,0,0.2); display: none"></div>'); | ||||
|         loading.append('<div class="loading_icon icn icn-spin"></div>'); | ||||
|  | ||||
|         function onSave(exit) { | ||||
|             var alerttitle = GetTextByKey("P_IPT_FUELRPT_SETTING", 'Fuel Report Page Settings'); | ||||
|             loading.fadeIn(100); | ||||
|             var headerLeft = $('#fuelrpt_headers_left').val(); | ||||
|             var headerMiddle = $('#fuelrpt_headers_middle').val(); | ||||
|             var headerRight = $('#fuelrpt_headers_right').val(); | ||||
|             var footerLeft = $('#fuelrpt_footers_left').val(); | ||||
|             var footerMiddle = $('#fuelrpt_footers_middle').val(); | ||||
|             var footerRight = $('#fuelrpt_footers_right').val(); | ||||
|             var item = { | ||||
|                 '$type': 'Foresight.Fleet.Services.Inspection.FuelReportHeaderFooterItem, FleetServiceClient', | ||||
|                 HeaderLeft: headerLeft, | ||||
|                 HeaderMiddle: headerMiddle, | ||||
|                 HeaderRight: headerRight, | ||||
|                 FooterLeft: footerLeft, | ||||
|                 FooterMiddle: footerMiddle, | ||||
|                 FooterRight: footerRight | ||||
|             }; | ||||
|             var p = [false, htmlencode(JSON.stringify(item))]; | ||||
|             inspectionrequest('UpdateFuelReportHeaderFooter', JSON.stringify(p), function (r) { | ||||
|                 if (r == 'OK') { | ||||
|                     showAlert(GetTextByKey("P_MV_SAVSUCCESSFULLY", 'Saved successfully.'), alerttitle, null, function () { | ||||
|                         loading.fadeOut(100); | ||||
|                         if (exit) { | ||||
|                             showRightPopup(false); | ||||
|                         } | ||||
|                     }); | ||||
|                 } else { | ||||
|                     showAlert(GetTextByKey("P_IPT_FUELRPT_SAVEERROR", 'Failed to save fuel report page settings.'), alerttitle, null, function () { | ||||
|                         loading.fadeOut(100); | ||||
|                     }); | ||||
|                 } | ||||
|             }, 1000); | ||||
|         } | ||||
|  | ||||
|         var content = $('<div></div>'); | ||||
|         var funcs = $('<div class="function_title"></div>'); | ||||
|         var btn = $('<span class="sbutton iconsave">' + GetTextByKey("P_IPT_SAVE", "Save") + '</span>').click(function () { | ||||
|             onSave(); | ||||
|         }); | ||||
|         funcs.append(btn); | ||||
|         btn = $('<span class="sbutton iconsave">' + GetTextByKey("P_IPT_SAVE1", "Save and Exit") + '</span>').click(function () { | ||||
|             onSave(true); | ||||
|         }); | ||||
|         funcs.append(btn); | ||||
|         btn = $('<span class="sbutton iconexit">' + GetTextByKey("P_IPT_SAVE2", "Exit Without Saving") + '</span>').click(function () { | ||||
|             showRightPopup(false); | ||||
|         }); | ||||
|         funcs.append(btn); | ||||
|         content.append(funcs); | ||||
|  | ||||
|         content.append($('<div class="page_title"></div>').text(GetTextByKey('P_IPT_FUELRPT_HEADER', 'Page Headers'))); | ||||
|         var line = $('<div class="settings-line"></div>'); | ||||
|         var label = $('<span></span>').text(GetTextByKey('P_IPT_FUELRPT_LEFT', 'Left')); | ||||
|         line.append(label); | ||||
|         var field = $('<textarea id="fuelrpt_headers_left"></textarea>'); | ||||
|         line.append(field); | ||||
|         content.append(line); | ||||
|  | ||||
|         line = $('<div class="settings-line"></div>'); | ||||
|         label = $('<span></span>').text(GetTextByKey('P_IPT_FUELRPT_MIDDLE', 'Middle')); | ||||
|         line.append(label); | ||||
|         field = $('<textarea id="fuelrpt_headers_middle"></textarea>'); | ||||
|         line.append(field); | ||||
|         content.append(line); | ||||
|  | ||||
|         line = $('<div class="settings-line"></div>'); | ||||
|         label = $('<span></span>').text(GetTextByKey('P_IPT_FUELRPT_RIGHT', 'Right')); | ||||
|         line.append(label); | ||||
|         field = $('<textarea id="fuelrpt_headers_right"></textarea>'); | ||||
|         line.append(field); | ||||
|         content.append(line); | ||||
|         content.append($('<div class="page_title"></div>').text(GetTextByKey('P_IPT_FUELRPT_FOOTER', 'Page Footers'))); | ||||
|  | ||||
|         line = $('<div class="settings-line"></div>'); | ||||
|         label = $('<span></span>').text(GetTextByKey('P_IPT_FUELRPT_LEFT', 'Left')); | ||||
|         line.append(label); | ||||
|         field = $('<textarea id="fuelrpt_footers_left"></textarea>'); | ||||
|         line.append(field); | ||||
|         content.append(line); | ||||
|  | ||||
|         line = $('<div class="settings-line"></div>'); | ||||
|         label = $('<span></span>').text(GetTextByKey('P_IPT_FUELRPT_MIDDLE', 'Middle')); | ||||
|         line.append(label); | ||||
|         field = $('<textarea id="fuelrpt_footers_middle"></textarea>'); | ||||
|         line.append(field); | ||||
|         content.append(line); | ||||
|  | ||||
|         line = $('<div class="settings-line"></div>'); | ||||
|         label = $('<span></span>').text(GetTextByKey('P_IPT_FUELRPT_RIGHT', 'Right')); | ||||
|         line.append(label); | ||||
|         field = $('<textarea id="fuelrpt_footers_right"></textarea>'); | ||||
|         line.append(field); | ||||
|         content.append(line); | ||||
|  | ||||
|         content.append(loading); | ||||
|         $('#right_popup').empty().append(content); | ||||
|         showRightPopup(true); | ||||
|  | ||||
|         loading.fadeIn(100); | ||||
|         inspectionrequest('GetFuelReportHeaderFooter', 'false', function (r) { | ||||
|             //console.log(r); | ||||
|             gs.fuelRptSettings = r; | ||||
|             content.find('#fuelrpt_headers_left').val(r.HeaderLeft); | ||||
|             content.find('#fuelrpt_headers_middle').val(r.HeaderMiddle); | ||||
|             content.find('#fuelrpt_headers_right').val(r.HeaderRight); | ||||
|             content.find('#fuelrpt_footers_left').val(r.FooterLeft); | ||||
|             content.find('#fuelrpt_footers_middle').val(r.FooterMiddle); | ||||
|             content.find('#fuelrpt_footers_right').val(r.FooterRight); | ||||
|             loading.fadeOut(100); | ||||
|         }); | ||||
|     }; | ||||
|     return gs; | ||||
| }); | ||||
							
								
								
									
										105
									
								
								Site/Inspection/js/modules/globalsections.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										105
									
								
								Site/Inspection/js/modules/globalsections.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,105 @@ | ||||
| define(['modules/sections/section', 'modules/sections/addsection'], function (Section, AddSection) { | ||||
|     var gs = {}; | ||||
|     gs.title = GetTextByKey("P_GLOBALSECTIONS", 'Global Sections'); | ||||
|     gs.description = GetTextByKey("P_GLOBALSECTIONS", 'Global Sections'); | ||||
|     gs.version = '1.0'; | ||||
|  | ||||
|     var datacontent = null; | ||||
|     gs.createContent = function (sections) { | ||||
|         templatereadonly = false; | ||||
|         editable = true; | ||||
|         sectiontype = 0;//sectiontype:0 - global,1 - normal | ||||
|         templatestatus = 0;//templatestatus:0 - draft,1 - published | ||||
|  | ||||
|         var content = $('<div style="min-width:1940px;"></div>'); | ||||
|  | ||||
|         function createHeader() { | ||||
|             var header = $('<div></div>'); | ||||
|             header.append($('<div class="page_title"></div>').text(gs.title)); | ||||
|             setPageTitle(gs.title, true); | ||||
|             //var search_bar = $('<div class="search_bar"></div>'); | ||||
|             //header.append(search_bar); | ||||
|             //header.append('<input type="text" id="searchinputtxt" autocomplete="off" />'); | ||||
|             //var btnRefresh = $('<input class="search" type="button" value="Search" />'); | ||||
|             //header.append(btnRefresh); | ||||
|             //btnRefresh.click(function () { | ||||
|             //    gs.refresh(); | ||||
|             //}); | ||||
|  | ||||
|             var func = $('<div class="function_title"></div>'); | ||||
|             var iconAdd = $('<span class="sbutton iconadd">' + GetTextByKey("P_IPT_ADD", "Add") + '</span>').click(function () { | ||||
|                 gs.addSection(); | ||||
|             }); | ||||
|             func.append(iconAdd); | ||||
|             var iconRefresh = $('<span class="sbutton iconrefresh">' + GetTextByKey("P_IPT_REFRESH", "Refresh") + '</span>').click(function () { | ||||
|                 gs.refresh(); | ||||
|             }); | ||||
|             func.append(iconRefresh); | ||||
|             header.append(func) | ||||
|  | ||||
|             return header; | ||||
|         } | ||||
|  | ||||
|         content.append(createHeader()); | ||||
|  | ||||
|         var dataheader = $('<div class="question-holder no-hover" style="font-weight: bold;font-size:14px;"></div>'); | ||||
|         dataheader.append('<div style="width:60px; flex-shrink: 0"></div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width: 200px">' + GetTextByKey("P_IPT_NAME", "Name") + '</div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width: 310px">' + GetTextByKey("P_IPT_DISPLAYTEXT", "Display Text") + '</div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width: 420px">' + GetTextByKey("P_IPT_TYPE", "Type") + '</div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width: 80px; text-align: center">' + GetTextByKey("P_IPT_REQUIRED", "Required") + '</div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width: 100px; text-align: center">' + GetTextByKey("P_IPT_CANCOMMENT", "Can Comment") + '</div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width: 100px; text-align: center">' + GetTextByKey("P_IPT_ISIMPORTANT", "Is Important") + '</div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width: 140px">' + GetTextByKey("P_IPT_CUSTOMERVISIBLE", "Customer Visible") + '</div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width: 140px">' + GetTextByKey("P_IPT_SEVERITYLEVEL", "Severity Level") + '</div>'); | ||||
|         dataheader.append('<div style="flex-grow: 1" style="width: 160px">' + GetTextByKey("P_IPT_NOTES", "Notes") + '</div>'); | ||||
|         if (sectiontype === 0) | ||||
|             dataheader.append('<div class="question-cell" style="width: 120px;">' + GetTextByKey("P_IPT_CREATEDBY", "Created By") + '</div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width: 90px;padding-right:20px;"></div>'); | ||||
|         content.append(dataheader); | ||||
|  | ||||
|         datacontent = $('<div></div>'); | ||||
|         content.append(datacontent); | ||||
|  | ||||
|         //setTimeout(function () { | ||||
|         //    gs.resize(); | ||||
|         //}); | ||||
|         //$(window).resize(function () { | ||||
|         //    gs.resize(); | ||||
|         //}); | ||||
|         if (sections) { | ||||
|             for (var i = 0; i < sections.length; i++) { | ||||
|                 var s = new Section(sections[i], gs); | ||||
|                 datacontent.append(s.createContent()); | ||||
|             } | ||||
|         } | ||||
|         else | ||||
|             this.refresh(); | ||||
|         return content; | ||||
|     } | ||||
|  | ||||
|     gs.resize = function () { | ||||
|         datacontent.css("height", document.documentElement.clientHeight - datacontent.offset().top) | ||||
|     } | ||||
|  | ||||
|     gs.addSection = function () { | ||||
|         var s = new AddSection(gs); | ||||
|         $('#right_popup').empty().append(s.createContent()); | ||||
|         showRightPopup(true); | ||||
|     } | ||||
|  | ||||
|     gs.refresh = function () { | ||||
|         datacontent.empty(); | ||||
|         inspectionrequest("GetGlobalSections", teamintelligence, function (data) { | ||||
|             datacontent.empty(); | ||||
|             if (data) { | ||||
|                 for (var i = 0; i < data.length; i++) { | ||||
|                     var s = new Section(data[i], gs); | ||||
|                     datacontent.append(s.createContent()); | ||||
|                 } | ||||
|             } | ||||
|         }, function (err) { | ||||
|         }); | ||||
|     } | ||||
|     return gs; | ||||
| }); | ||||
							
								
								
									
										376
									
								
								Site/Inspection/js/modules/importpackages.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										376
									
								
								Site/Inspection/js/modules/importpackages.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,376 @@ | ||||
| define([], function () { | ||||
|     var imppkg = {}; | ||||
|  | ||||
|     var txtfilename; | ||||
|     var txtpwd; | ||||
|     var btnbrowse; | ||||
|     var btnunpackpkg; | ||||
|     var txtname; | ||||
|     var txtnotes; | ||||
|     var grid_templatedt; | ||||
|     var grid_sectiondt; | ||||
|     var divpkg; | ||||
|  | ||||
|     var tempgridholder; | ||||
|     var sectiongridholder; | ||||
|  | ||||
|     var filedata; | ||||
|  | ||||
|     function InitTemplateGridData() { | ||||
|         var div_grid = $('<div style="margin-top:5px;"></div>'); | ||||
|         div_grid.css("height", 200); | ||||
|  | ||||
|         grid_templatedt = new GridView(div_grid); | ||||
|         grid_templatedt.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: 'TemplateName', caption: GetTextByKey("P_TEMPLATE", "Template"), valueIndex: 'Name', css: { 'width': 320, 'text-align': 'left' } }, | ||||
|             { name: 'AssetName', caption: GetTextByKey("P_IPT_NOTES", "Notes"), valueIndex: 'Notes', css: { 'width': 400, '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; | ||||
|             if (list_columns[hd].type) { | ||||
|                 col.type = list_columns[hd].type; | ||||
|             } | ||||
|             if (col.name === 'Selected') { | ||||
|                 col.allcheck = true; | ||||
|                 col.sortable = false; | ||||
|             } | ||||
|  | ||||
|             columns.push(col); | ||||
|         } | ||||
|         grid_templatedt.canMultiSelect = false; | ||||
|         grid_templatedt.columns = columns; | ||||
|         grid_templatedt.init(); | ||||
|  | ||||
|         return div_grid; | ||||
|     } | ||||
|  | ||||
|     function showTemplates(data) { | ||||
|         var rows = []; | ||||
|         for (var i = 0; i < data.length; i++) { | ||||
|             var r = data[i]; | ||||
|             r.Selected = true; | ||||
|             var fr = { Values: r }; | ||||
|             rows.push(fr); | ||||
|         } | ||||
|  | ||||
|         grid_templatedt.setData(rows); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     function InitSectionGridData() { | ||||
|         var div_grid = $('<div style="margin-top:5px;"></div>'); | ||||
|         div_grid.css("height", 200); | ||||
|  | ||||
|         grid_sectiondt = new GridView(div_grid); | ||||
|         grid_sectiondt.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: 'SectionName', caption: GetTextByKey("P_IPT_SECTION", "Section"), valueIndex: 'ItemName', css: { 'width': 320, 'text-align': 'left' } }, | ||||
|             { name: 'AssetName', caption: GetTextByKey("P_IPT_NOTES", "Notes"), valueIndex: 'Notes', css: { 'width': 400, '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; | ||||
|             if (list_columns[hd].type) { | ||||
|                 col.type = list_columns[hd].type; | ||||
|             } | ||||
|             if (col.name === 'Selected') { | ||||
|                 col.allcheck = true; | ||||
|                 col.sortable = false; | ||||
|             } | ||||
|  | ||||
|             columns.push(col); | ||||
|         } | ||||
|         grid_sectiondt.canMultiSelect = false; | ||||
|         grid_sectiondt.columns = columns; | ||||
|         grid_sectiondt.init(); | ||||
|  | ||||
|         return div_grid; | ||||
|     } | ||||
|  | ||||
|     function showGlobalSections(data) { | ||||
|         var rows = []; | ||||
|         for (var i = 0; i < data.length; i++) { | ||||
|             var r = data[i]; | ||||
|             r.Selected = true; | ||||
|             var fr = { Values: r }; | ||||
|             rows.push(fr); | ||||
|         } | ||||
|  | ||||
|         grid_sectiondt.setData(rows); | ||||
|     } | ||||
|  | ||||
|     function onImport(_this, overwritten) { | ||||
|         var alerttitle = GetTextByKey("P_IPT_IMPORTPACKAGE", 'Import Package'); | ||||
|         if (!filedata) { | ||||
|             showAlert(GetTextByKey("P_IPT_PLEASESELECTTHEPACKAGEFILE", 'Please select the package file.'), alerttitle); | ||||
|             return; | ||||
|         } | ||||
|         if (txtname.text() == "") { | ||||
|             showAlert(GetTextByKey("P_IPT_PLEASEUNPACKTHEPACKAGE", 'Please unpack the package.'), alerttitle); | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         var templateids = []; | ||||
|         for (var i = 0; i < grid_templatedt.source.length; i++) { | ||||
|             var t = grid_templatedt.source[i].Values; | ||||
|             if (t.Selected) | ||||
|                 templateids.push(t.Id); | ||||
|         } | ||||
|  | ||||
|         var sectionids = []; | ||||
|         for (var i = 0; i < grid_sectiondt.source.length; i++) { | ||||
|             var t = grid_sectiondt.source[i].Values; | ||||
|             if (t.Selected) | ||||
|                 sectionids.push(t.ItemId); | ||||
|         } | ||||
|         if (templateids.length < 1 && sectionids.length < 1) { | ||||
|             showAlert(GetTextByKey("P_IPT_PLEASESELECTATLEASTONETEMPLATEORGLOBALSECTIONTOIMPORT", 'Please select at least one template or global section to import.'), alerttitle); | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         _this.loading && _this.loading.fadeIn(100); | ||||
|  | ||||
|         var p = [overwritten, JSON.stringify(templateids), JSON.stringify(sectionids)]; | ||||
|         p = JSON.stringify(p); | ||||
|         var formData = new FormData(); | ||||
|         formData.append("pkgfile", filedata); | ||||
|         formData.append("MethodName", "ImportPackage"); | ||||
|         formData.append("ClientData", htmldecode(p)); | ||||
|         $.ajax({ | ||||
|             url: 'Inspection.aspx?tp=ashx', | ||||
|             type: 'POST', | ||||
|             dataType: 'json', | ||||
|             processData: false, | ||||
|             contentType: false, | ||||
|             data: formData, | ||||
|             async: true, | ||||
|             success: function (data) { | ||||
|                 if (data === "OK") { | ||||
|                     showAlert(GetTextByKey("P_IPT_PACKAGEHASBEENIMPORTEDSUCCESSFULLY", 'Package has been imported successfully.'), alerttitle); | ||||
|                     filedata = null; | ||||
|                     divpkg.hide(); | ||||
|                     txtfilename.val(""); | ||||
|                     txtpwd.val(""); | ||||
|                     txtname.text(""); | ||||
|                     txtnotes.html(""); | ||||
|                 } else { | ||||
|                     showAlert(data, alerttitle); | ||||
|                 } | ||||
|                 _this.loading && _this.loading.fadeOut(100); | ||||
|             }, | ||||
|             error: function (err) { | ||||
|                 showAlert(err.statusText, alerttitle); | ||||
|                 _this.loading && _this.loading.fadeOut(100); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     function getPackageData(_this) { | ||||
|         var alerttitle = GetTextByKey("P_IPT_IMPORTPACKAGE", 'Import Package'); | ||||
|         var pwd = txtpwd.val(); | ||||
|         if (!pwd || pwd == "") { | ||||
|             showAlert(GetTextByKey("P_IPT_PASSWORDISREQUIRED", 'Password is required.'), alerttitle); | ||||
|             return; | ||||
|         } | ||||
|         _this.loading && _this.loading.fadeIn(100); | ||||
|  | ||||
|         var formData = new FormData(); | ||||
|         formData.append("pkgfile", filedata); | ||||
|         formData.append("MethodName", "GetPackageData"); | ||||
|         formData.append("ClientData", htmldecode(pwd)); | ||||
|         $.ajax({ | ||||
|             url: 'Inspection.aspx?tp=ashx', | ||||
|             type: 'POST', | ||||
|             dataType: 'json', | ||||
|             processData: false, | ||||
|             contentType: false, | ||||
|             data: formData, | ||||
|             async: true, | ||||
|             success: function (data) { | ||||
|                 if (typeof (data) === "string") { | ||||
|                     showAlert(data, alerttitle); | ||||
|                 } else { | ||||
|                     showPackageData(data); | ||||
|                 } | ||||
|                 _this.loading && _this.loading.fadeOut(100); | ||||
|             }, | ||||
|             error: function (err) { | ||||
|                 showAlert(err.statusText, alerttitle); | ||||
|                 _this.loading && _this.loading.fadeOut(100); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     function showPackageData(pkgdata) { | ||||
|         divpkg.show(); | ||||
|         reshowgrid(); | ||||
|         txtname.text(pkgdata.PackageName); | ||||
|         txtnotes.html(replaceHtmlText(pkgdata.Notes)); | ||||
|         showTemplates(pkgdata.Templates); | ||||
|         showGlobalSections(pkgdata.GlobalSections); | ||||
|     } | ||||
|  | ||||
|     imppkg.createContent = function () { | ||||
|         var _this = this; | ||||
|         setPageTitle(GetTextByKey("P_IPT_IMPORTPACKAGE", 'Import Package'), true); | ||||
|         var content = $('<div style="padding-left:10px;padding-right:10px;"></div>'); | ||||
|         this.content = content; | ||||
|         var funcs = $('<div class="function_title"></div>'); | ||||
|         var btn = $('<span class="sbutton iconsave">' + GetTextByKey('P_IPT_IMPORT', 'Import') + '</span>').click(function () { | ||||
|             showConfirm(GetTextByKey("P_IPT_DOYOUWANTTOOVERWRITETHEITEMSWHICHHAVEANEWERVERSION", 'Do you want to overwrite the items which have a higher version?'), GetTextByKey("P_IPT_IMPORTPACKAGE", 'Import Package'), function () { | ||||
|                 onImport(_this, 1); | ||||
|             }, function () { | ||||
|                 onImport(_this, 0); | ||||
|             }); | ||||
|         }); | ||||
|         funcs.append(btn); | ||||
|         content.append(funcs); | ||||
|  | ||||
|         var tb = $('<table style="line-height:24px;"></table>'); | ||||
|         content.append(tb); | ||||
|  | ||||
|         var tr = $('<tr></tr>'); | ||||
|         tb.append(tr); | ||||
|         var td = $('<td class="label" style="width:160px;">' + GetTextByKey('P_IPT_IMPORTPACKAGEFILE_COLON', 'Import Package File:') + '</td>'); | ||||
|         tr.append(td); | ||||
|         td = $('<td></td>'); | ||||
|         tr.append(td); | ||||
|         txtfilename = $('<input type="text" maxlength=100 style="width: 500px; height: 21px;margin-top:5px;margin-bottom:5px;" disabled="disabled"></input>'); | ||||
|         td.append(txtfilename); | ||||
|         btnbrowse = $('<input type="button" value="' + GetTextByKey('P_IPT_BROWSE', 'Browse...') + '" style="margin-left:10px;width:80px;"></input>'); | ||||
|         td.append(btnbrowse); | ||||
|         btnbrowse.click(function UpLoadMachineIcon(type, e) { | ||||
|             var file = $('<input type="file" style="display: none;" />') | ||||
|             file.change(function () { | ||||
|                 filedata = this.files[0]; | ||||
|                 txtname.text(""); | ||||
|                 txtnotes.html("") | ||||
|                 if (filedata) { | ||||
|                     txtfilename.val(filedata.name); | ||||
|                     btnunpackpkg.prop("disabled", false); | ||||
|                 } | ||||
|             }).click(); | ||||
|         }); | ||||
|  | ||||
|         var tr = $('<tr></tr>'); | ||||
|         tb.append(tr); | ||||
|         td = $('<td class="label" style="width:160px;">Password:</td>'); | ||||
|         tr.append(td); | ||||
|         td = $('<td></td>'); | ||||
|         tr.append(td); | ||||
|         txtpwd = $('<input type="password" maxlength=16 style="width: 500px; height: 21px;margin-top:5px;margin-bottom:5px;"></input>'); | ||||
|         td.append(txtpwd); | ||||
|         btnunpackpkg = $('<input type="button" value="' + GetTextByKey('P_IPT_UNPACK', 'Unpack') + '" style="margin-left:10px;width:80px;" disabled="disabled"></input>'); | ||||
|         td.append(btnunpackpkg); | ||||
|         btnunpackpkg.click(function () { | ||||
|             getPackageData(_this); | ||||
|         }); | ||||
|  | ||||
|         divpkg = $('<div style="display:none;"></div>'); | ||||
|         content.append(divpkg); | ||||
|  | ||||
|         var tb = $('<table style="line-height:24px;"></table>'); | ||||
|         divpkg.append(tb); | ||||
|  | ||||
|         var tr = $('<tr></tr>'); | ||||
|         tb.append(tr); | ||||
|         var td = $('<td class="label" style="width:160px;">Name:</td>'); | ||||
|         tr.append(td); | ||||
|         td = $('<td></td>'); | ||||
|         tr.append(td); | ||||
|         txtname = $('<span></span>'); | ||||
|         td.append(txtname); | ||||
|  | ||||
|         var tr = $('<tr></tr>'); | ||||
|         tb.append(tr); | ||||
|         var td = $('<td class="label" style="width:160px;vertical-align:top;">Notes:</td>'); | ||||
|         tr.append(td); | ||||
|         td = $('<td></td>'); | ||||
|         tr.append(td); | ||||
|         txtnotes = $('<div></div>'); | ||||
|         td.append(txtnotes); | ||||
|  | ||||
|         var ul = $('<ul class="tab_header" style="padding-top: 5px;"></ul>'); | ||||
|         divpkg.append(ul); | ||||
|  | ||||
|         var tabName = "tabTemplates"; | ||||
|         var templi = $('<li></li>').attr('data-href', tabName); | ||||
|         ul.append(templi); | ||||
|         templi.append($('<span></span>').text(GetTextByKey("P_TEMPLATES", 'Templates'))); | ||||
|         templi.click(function () { | ||||
|             reshowgrid(); | ||||
|         }); | ||||
|         tempgridholder = InitTemplateGridData(); | ||||
|         tempgridholder.attr('data-page', tabName) | ||||
|         divpkg.append(tempgridholder); | ||||
|  | ||||
|         tabName = "tabSections"; | ||||
|         var li = $('<li></li>').attr('data-href', tabName); | ||||
|         ul.append(li); | ||||
|         li.append($('<span></span>').text(GetTextByKey("P_GLOBALSECTIONS", 'Global Sections'))); | ||||
|         li.click(function () { | ||||
|             reshowgrid(); | ||||
|         }); | ||||
|         sectiongridholder = InitSectionGridData(); | ||||
|         sectiongridholder.attr('data-page', tabName) | ||||
|         divpkg.append(sectiongridholder); | ||||
|  | ||||
|         ul.append($('<li style="clear: both;"></li>')); | ||||
|  | ||||
|         divpkg.tab(); | ||||
|         templi.click(); | ||||
|  | ||||
|         //divpkg.append($('<span style="margin-left:5px;font-size:16px;font-weight:bold;">Templates</span>')); | ||||
|         //divpkg.append(InitTemplateGridData()); | ||||
|  | ||||
|         //divpkg.append($('<span style="margin-left:5px;font-size:16px;font-weight:bold;">Global Sections</span>')); | ||||
|         //divpkg.append(InitSectionGridData()); | ||||
|  | ||||
|         var loading = $('<div id="mask_bg" style="display:none;"></div>'); | ||||
|         _this.loading = loading; | ||||
|         content.append(loading); | ||||
|  | ||||
|         return content; | ||||
|     }; | ||||
|  | ||||
|     function reshowgrid() { | ||||
|         setTimeout(function () { | ||||
|             tempgridholder.css("height", $(window).height() - tempgridholder.offset().top - 15); | ||||
|             grid_templatedt && grid_templatedt.resize(); | ||||
|             sectiongridholder.css("height", $(window).height() - sectiongridholder.offset().top - 15); | ||||
|             grid_sectiondt && grid_sectiondt.resize(); | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     return imppkg; | ||||
| }); | ||||
							
								
								
									
										389
									
								
								Site/Inspection/js/modules/inspections.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										389
									
								
								Site/Inspection/js/modules/inspections.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,389 @@ | ||||
| define(['modules/inspects/inspect', 'modules/inspects/editinspection'], function (Inspect, EditModule) { | ||||
|     var gs = {}; | ||||
|     gs.title = GetTextByKey("P_INSPECTIONS", 'Inspections'); | ||||
|     gs.description = GetTextByKey("P_INSPECTIONS", 'Inspections'); | ||||
|     gs.version = '1.0'; | ||||
|     gs.status = 0; | ||||
|  | ||||
|     var datacontent = null; | ||||
|     var startdateinputcontrol = undefined; | ||||
|     var enddateinputcontrol = undefined; | ||||
|     var searchinputcontrol = undefined; | ||||
|     var makeinputcontrol = undefined; | ||||
|     var modelinputcontrol = undefined; | ||||
|     var typeinputcontrol = undefined; | ||||
|     var grid_dt; | ||||
|     gs.createContent = function (args) { | ||||
|         var _this = this; | ||||
|         if (args && args.length > 0) | ||||
|             gs.status = eval(args[0]); | ||||
|  | ||||
|         var content = $('<div style="width:100%;" ></div>'); | ||||
|  | ||||
|         function createHeader() { | ||||
|             var header = $('<div></div>'); | ||||
|             header.append($('<div class="page_title"></div>').text(gs.title)); | ||||
|             setPageTitle(gs.title, true); | ||||
|             var search_bar = $('<div class="search_bar"></div>'); | ||||
|             header.append(search_bar); | ||||
|             search_bar.append('<input type="password" autocomplete="new-password" style="display: none" />'); | ||||
|             search_bar.append('<span style="margin-left:5px;">' + GetTextByKey("P_IPT_BEGINDATE_COLON", "Begin Date:") + '</span>'); | ||||
|             startdateinputcontrol = $('<input type="text" style="margin-left: 5px; width: 80px;" autocomplete="off" />').val(begindate); | ||||
|             search_bar.append($('<span></span>').append(startdateinputcontrol)); | ||||
|             startdateinputcontrol.datetimepicker({ | ||||
|                 timepicker: false, | ||||
|                 format: 'm/d/Y' | ||||
|             }); | ||||
|             search_bar.append('<span style="margin-left:10px;">' + GetTextByKey("P_IPT_ENDDATE_COLON", "End Date:") + '</span>'); | ||||
|             enddateinputcontrol = $('<input type="text" style="margin-left: 5px; width: 80px;" autocomplete="off" />').val(enddate); | ||||
|             search_bar.append($('<span></span>').append(enddateinputcontrol)); | ||||
|             enddateinputcontrol.datetimepicker({ | ||||
|                 timepicker: false, | ||||
|                 format: 'm/d/Y' | ||||
|             }); | ||||
|  | ||||
|             makeinputcontrol = $('<select type="text" style="margin-left: 5px; width: 80px;" autocomplete="off" />').val(enddate); | ||||
|             search_bar.append($('<span></span>').append(enddateinputcontrol)); | ||||
|             enddateinputcontrol.datetimepicker({ | ||||
|                 timepicker: false, | ||||
|                 format: 'm/d/Y' | ||||
|             }); | ||||
|  | ||||
|  | ||||
|             searchinputcontrol = $('<input type="text" style="margin-left:10px;" autocomplete="off" />'); | ||||
|             search_bar.append(searchinputcontrol); | ||||
|             searchinputcontrol.keydown(function (e) { | ||||
|                 if (e.keyCode == 13 || e.keyCode == 9) | ||||
|                     gs.refresh(); | ||||
|             }); | ||||
|             var btnRefresh = $('<input class="search" type="button" value="' + GetTextByKey("P_IPT_SEARCH", "Search") + '" style="margin-left:10px;"/>'); | ||||
|             search_bar.append(btnRefresh); | ||||
|             btnRefresh.click(function () { | ||||
|                 gs.refresh(); | ||||
|             }); | ||||
|  | ||||
|             var func = $('<div class="function_title"></div>'); | ||||
|             if (!ReportReadonly) { | ||||
|                 var iconEdit = $('<span class="sbutton iconedit">' + GetTextByKey("P_IPT_EDIT", "Edit") + '</span>').click(function () { | ||||
|                     if (grid_dt.selectedIndex >= 0) { | ||||
|                         gs.onedit(); | ||||
|                     } | ||||
|                 }); | ||||
|                 func.append(iconEdit); | ||||
|             } | ||||
|             var iconRefresh = $('<span class="sbutton iconrefresh">' + GetTextByKey("P_IPT_REFRESH", "Refresh") + '</span>').click(function () { | ||||
|                 gs.refresh(); | ||||
|             }); | ||||
|             func.append(iconRefresh); | ||||
|             var iconResetPivots = $('<span class="sbutton iconfilter">' + GetTextByKey("P_IPT_XXXXXX", "Reset Pivots") + '</span>').click(function () { | ||||
|                 if (grid_dt && grid_dt.columns) { | ||||
|                     for (var i = 0; i < grid_dt.columns.length; i++) { | ||||
|                         if (grid_dt.columns[i].filterValues) | ||||
|                             grid_dt.columns[i].filterValues = null; | ||||
|                     } | ||||
|                     grid_dt.refreshGrid(); | ||||
|                 } | ||||
|             }); | ||||
|             func.append(iconResetPivots); | ||||
|             header.append(func) | ||||
|  | ||||
|             return header; | ||||
|         } | ||||
|  | ||||
|         function InitGridData() { | ||||
|             var div_grid = $('<div></div>'); | ||||
|             div_grid.css("height", $(window).height() - 185); | ||||
|  | ||||
|             grid_dt = new GridView(div_grid); | ||||
|             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: 'TemplateName', caption: GetTextByKey("P_TEMPLATE", "Template"), allowFilter: true, valueIndex: 'TemplateName', css: { 'width': 250, 'text-align': 'left' } }, | ||||
|                 { name: 'AssetName', caption: GetTextByKey("P_IPT_ASSETNAME", "Asset Name"), valueIndex: 'AssetName', allowFilter: true, css: { 'width': 200, 'text-align': 'left' } }, | ||||
|                 { name: 'WorkOrderNumber', caption: GetTextByKey("P_IPT_WORKORDER", "Work Order"), valueIndex: 'WorkOrderNumber', allowFilter: true, css: { 'width': 200, 'text-align': 'left' } }, | ||||
|                 { name: 'CustomerName', caption: GetTextByKey("P_IPT_XXX", "Customer Name"), valueIndex: 'CustomerName', allowFilter: true, css: { 'width': 200, 'text-align': 'left' } }, | ||||
|                 { name: 'VisibleToCustomer', caption: GetTextByKey("P_IPT_CUSTOMERVISIBLE", "Customer Visible"), valueIndex: 'VisibleToCustomer', allowFilter: true, css: { 'width': 200, 'text-align': 'left' } }, | ||||
|                 { name: 'VIN', caption: GetTextByKey("P_IPT_VIN", "VIN"), valueIndex: 'VIN', allowFilter: true, css: { 'width': 200, 'text-align': 'left' } }, | ||||
|                 { name: 'MakeName', caption: GetTextByKey("P_IPT_MAKE", "Make"), valueIndex: 'MakeName', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } }, | ||||
|                 { name: 'ModelName', caption: GetTextByKey("P_IPT_MODEL", "Model"), valueIndex: 'ModelName', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } }, | ||||
|                 { name: 'TypeName', caption: GetTextByKey("P_IPT_ASSETTYPE", "Asset Type"), valueIndex: 'TypeName', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } }, | ||||
|                 { name: 'Status', caption: GetTextByKey("P_IPT_STATUS", "Status"), valueIndex: 'Status', allowFilter: true, css: { 'width': 120, 'text-align': 'left' } }, | ||||
|                 { name: 'CommitTimeLocal', caption: GetTextByKey("P_IPT_COMMITTIME", "Commit Time"), valueIndex: 'CommitTimeLocal', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } }, | ||||
|                 { name: 'CommitedByUserName', caption: GetTextByKey("P_IPT_COMMITUSER", "Commit User"), valueIndex: 'CommitedByUserName', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } }, | ||||
|                 { name: 'LastUpdatedTimeLocal', caption: GetTextByKey("P_IPT_LASTUPDATEDTIME", "Last Updated Time"), valueIndex: 'LastUpdatedTimeLocal', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } }, | ||||
|                 { name: 'LastUpdatedByUserName', caption: GetTextByKey("P_IPT_LASTUPDATEDUSER", "Last Updated User"), valueIndex: 'LastUpdatedByUserName', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } }, | ||||
|                 { name: 'Edit', caption: "", css: { 'width': 30, 'text-align': 'center' } }, | ||||
|                 { name: 'Detail', caption: "", css: { 'width': 30, 'text-align': 'center' } }, | ||||
|                 { name: 'DownloadPDF', caption: "", css: { 'width': 30, 'text-align': 'center' } }, | ||||
|                 { name: 'Print', 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; | ||||
|                 if (ReportReadonly && col.name === 'Edit') { | ||||
|                     continue; | ||||
|                 } | ||||
|  | ||||
|                 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 (!IsCustomerRecord && (col.name === "CustomerName")) { | ||||
|                     continue; | ||||
|                 } | ||||
|  | ||||
|                 if (col.name === "TemplateName" || col.name === "AssetName") { | ||||
|                     col.isurl = true; | ||||
|                     col.sortable = false; | ||||
|                     col.events = { | ||||
|                         onclick: function () { | ||||
|                             _this.openReport(); | ||||
|                         } | ||||
|                     }; | ||||
|                     col.styleFilter = function () { | ||||
|                         return { | ||||
|                             'color': 'black', | ||||
|                             'cursor': 'pointer', | ||||
|                             //'text-decoration': 'none' | ||||
|                         }; | ||||
|                     } | ||||
|                 } | ||||
|                 else if (col.name === "Edit") { | ||||
|                     col.isurl = true; | ||||
|                     col.text = "\uf044"; | ||||
|                     col.sortable = false; | ||||
|                     col.events = { | ||||
|                         onclick: function () { | ||||
|                             _this.onedit(); | ||||
|                         } | ||||
|                     }; | ||||
|                     col.classFilter = function (e) { | ||||
|                         return "icon-col"; | ||||
|                     } | ||||
|                     col.attrs = { 'title': GetTextByKey("P_IPT_EDIT", 'Edit') }; | ||||
|                 } | ||||
|                 else if (col.name === "Detail") { | ||||
|                     col.isurl = true; | ||||
|                     col.text = "\uf0c9"; | ||||
|                     col.sortable = false; | ||||
|                     col.events = { | ||||
|                         onclick: function () { | ||||
|                             _this.openReport(); | ||||
|                         } | ||||
|                     }; | ||||
|                     col.classFilter = function (e) { | ||||
|                         return "icon-col"; | ||||
|                     } | ||||
|                     col.attrs = { 'title': GetTextByKey("P_IPT_DETAIL", 'Detail') }; | ||||
|                 } | ||||
|                 else if (col.name === "DownloadPDF") { | ||||
|                     col.isurl = true; | ||||
|                     col.text = "\uf019"; | ||||
|                     col.sortable = false; | ||||
|                     col.visible = canExport; | ||||
|                     col.events = { | ||||
|                         onclick: function () { | ||||
|                             window.open("Inspection.aspx?rt=f&t=1&id=" + this.Id + "&team=" + (teamintelligence ? 1 : 0), '_blank'); | ||||
|                         } | ||||
|                     }; | ||||
|                     col.classFilter = function (e) { | ||||
|                         return "icon-col"; | ||||
|                     } | ||||
|                     col.attrs = { 'title': GetTextByKey("P_IPT_DOWNLOADPDF", 'Download PDF') }; | ||||
|                 } | ||||
|                 else if (col.name === "Print") { | ||||
|                     col.isurl = true; | ||||
|                     col.text = "\uf02f"; | ||||
|                     col.sortable = false; | ||||
|                     col.visible = canExport; | ||||
|                     col.events = { | ||||
|                         onclick: function () { | ||||
|                             if (navigator.userAgent.indexOf('Firefox') >= 0 || | ||||
|                                 navigator.userAgent.indexOf('Opera') >= 0) { | ||||
|                                 window.open("Inspection.aspx?rt=f&t=2&id=" + this.Id + "&team=" + (teamintelligence ? 1 : 0), '_blank'); | ||||
|                             } | ||||
|                             else | ||||
|                                 OnPrint(this.Id); | ||||
|                         } | ||||
|                     }; | ||||
|                     col.classFilter = function (e) { | ||||
|                         return "icon-col"; | ||||
|                     } | ||||
|                     col.attrs = { 'title': GetTextByKey("P_IPT_PRINT", 'Print') }; | ||||
|                 } | ||||
|                 else if (col.name === "ViewChangeHistory") { | ||||
|                     col.isurl = true; | ||||
|                     col.text = "\uf06e"; | ||||
|                     col.sortable = false; | ||||
|                     col.events = { | ||||
|                         onclick: function () { | ||||
|                             _this.onViewChangeHistory(); | ||||
|                         } | ||||
|                     }; | ||||
|                     col.classFilter = function (e) { | ||||
|                         return "icon-col"; | ||||
|                     } | ||||
|                     col.attrs = { 'title': GetTextByKey("P_IPT_VIEWCHANGEHIS", 'View Change History') }; | ||||
|                 } | ||||
|  | ||||
|                 if (col.name === "AssetName" || col.name === "VIN" || col.name === "MakeName" || col.name === "ModelName" || col.name === "TypeName" || col.name === "WorkOrderNumber" || col.name === "VisibleToCustomer" || col.name === "CustomerName") { | ||||
|                     col.visible = !teamintelligence; | ||||
|                 } | ||||
|  | ||||
|                 if (!teamintelligence && AllowReassignWorkorders && col.name === "WorkOrderNumber") { | ||||
|                     col.allowHtml = true; | ||||
|                     col.filterCustom = true; | ||||
|                     col.filter = function (item) { | ||||
|                         if (item.Id === "") | ||||
|                             return htmldecode(item.WorkOrderNumber); | ||||
|  | ||||
|                         var div = $('<div class="dropdown" style="width: 200px;"></div>'); | ||||
|                         div.dropdown(item.WorkOrders || [{ Id: -1, WorkOrderNumber: "Not Assigned" }], { | ||||
|                             search: false, | ||||
|                             textKey: 'WorkOrderNumber', | ||||
|                             valueKey: 'Id', | ||||
|                             selected: item.WorkOrderId > 0 ? item.WorkOrderId : -1, | ||||
|                             parent: '#content' | ||||
|                         }).on('select', function (_e, wo) { | ||||
|                             if (wo) { | ||||
|                                 var msg1 = GetTextByKey('P_WO_AREYOUSURETHATYOUWANTTOPROCEED', 'Are you sure that you want to proceed ?'); | ||||
|                                 var msg = GetTextByKey('P_WO_YOUAREREASSIGNINGTHISWORKORDER', 'You are reassigning this work order. ') + "<br/>" + msg1; | ||||
|                                 if (wo.Completed) | ||||
|                                     msg = GetTextByKey('P_WO_YOUAREREASSIGNINGTHISWORKORDERTOACLOSEDWORKORDER', 'You are reassigning this Work Order to a CLOSED Work Order.') + "<br/>" + msg1; | ||||
|                                 showConfirm(msg, GetTextByKey("P_WO_WORKORDERASSIGNMENT", 'Work Order Assignment'), function () { | ||||
|                                     var oldwoid = item.WorkOrderId; | ||||
|                                     item.WorkOrderId = wo.Id; | ||||
|                                     item.WorkOrderNumber = wo.WorkOrderNumber; | ||||
|                                     updateInspectionWorkOrder(item.Id, item.WorkOrderId, oldwoid, wo.CustomerName); | ||||
|                                 }, function () { | ||||
|                                     var dropdown = div.data('dropdown'); | ||||
|                                     if (dropdown) | ||||
|                                         dropdown.select(item.WorkOrderId > 0 ? item.WorkOrderId : -1); | ||||
|                                 }); | ||||
|                             } | ||||
|                         }); | ||||
|                         return div; | ||||
|                     } | ||||
|                     col.styleFilter = function () { | ||||
|                         return { "width": "100%", 'margin': 0 }; | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
|                 columns.push(col); | ||||
|             } | ||||
|             grid_dt.canMultiSelect = false; | ||||
|             grid_dt.columns = columns; | ||||
|             grid_dt.init(); | ||||
|             grid_dt.rowdblclick = _this.openReport; | ||||
|  | ||||
|             grid_dt.selectedrowchanged = function (rowindex) { | ||||
|                 var rowdata = grid_dt.source[rowindex]; | ||||
|                 if (rowdata) { | ||||
|                 } | ||||
|             } | ||||
|             return div_grid; | ||||
|         } | ||||
|  | ||||
|         content.append(createHeader()); | ||||
|         content.append(InitGridData()); | ||||
|         datacontent = $('<div></div>'); | ||||
|         content.append(datacontent); | ||||
|  | ||||
|         _this.refresh(); | ||||
|         return content; | ||||
|     } | ||||
|  | ||||
|     gs.onedit = function () { | ||||
|         var _this = this; | ||||
|         var index = grid_dt.selectedIndex; | ||||
|         var inspect = grid_dt.source[index].Values; | ||||
|  | ||||
|  | ||||
|         // check permissions | ||||
|         var ei = new EditModule.EditInspection(_this, inspect.Id); | ||||
|         $('#right_popup').empty().append(ei.createContent()); | ||||
|         showRightPopup(true); | ||||
|  | ||||
|  | ||||
|     } | ||||
|  | ||||
|     gs.openReport = function () { | ||||
|         var index = grid_dt.selectedIndex; | ||||
|         var inspect = grid_dt.source[index].Values; | ||||
|         window.open("report.aspx?rid=" + inspect.Id + "&ro=" + (ReportReadonly ? 1 : 0), "_blank"); | ||||
|     } | ||||
|  | ||||
|     gs.onViewChangeHistory = function () { | ||||
|         var index = grid_dt.selectedIndex; | ||||
|         var inspect = grid_dt.source[index].Values; | ||||
|         window.open("InspectionChangeHistory.aspx?rid=" + inspect.Id, "_blank"); | ||||
|     } | ||||
|  | ||||
|     function updateInspectionWorkOrder(id, woid, oldwoid, custname) { | ||||
|         var p = JSON.stringify([id, woid, oldwoid]); | ||||
|         inspectionrequest("UpdateInspectionWorkOrder", htmlencode(p), function (data) { | ||||
|             if (typeof (data) === "string") { | ||||
|                 return; | ||||
|             } | ||||
|             if (grid_dt.selectedIndex >= 0) { | ||||
|                 grid_dt.source[grid_dt.selectedIndex].Values.CustomerName = custname; | ||||
|                 grid_dt && grid_dt.reload(); | ||||
|             } | ||||
|  | ||||
|         }, function (err) { | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     function showInspections(data) { | ||||
|         var rows = []; | ||||
|         for (var i = 0; i < data.length; i++) { | ||||
|             var r = data[i]; | ||||
|             var statustext = ""; | ||||
|             if (r.Status == 0) | ||||
|                 statustext = 'Draft'; | ||||
|             else if (r.Status == 1) | ||||
|                 statustext = 'Committed'; | ||||
|             for (var j in r) { | ||||
|                 if (j === "Status") { | ||||
|                     r[j] = { DisplayValue: statustext, Value: r[j] }; | ||||
|                 } else if (j === "CommitTimeLocal") { | ||||
|                     r[j] = { DisplayValue: r["CommitTimeLocalStr"], Value: r[j] }; | ||||
|                 } else if (j === "LastUpdatedTimeLocal") { | ||||
|                     r[j] = { DisplayValue: r["LastUpdatedTimeLocalStr"], Value: r[j] }; | ||||
|                 } else if (j === "VisibleToCustomer") { | ||||
|                     r[j] = { DisplayValue: r["VisibleToCustomer"] ? "Yes" : "No", Value: r[j] }; | ||||
|                 } | ||||
|             } | ||||
|             var fr = { Values: r }; | ||||
|             rows.push(fr); | ||||
|         } | ||||
|  | ||||
|         grid_dt.setData(rows); | ||||
|     } | ||||
|  | ||||
|     gs.refresh = function () { | ||||
|         datacontent.empty(); | ||||
|         var startydate = startdateinputcontrol.val(); | ||||
|         var enddate = enddateinputcontrol.val(); | ||||
|         var searchtxt = searchinputcontrol.val(); | ||||
|         searchtxt = htmlencode(searchtxt); | ||||
|         var p = JSON.stringify([teamintelligence, startydate, enddate, searchtxt]); | ||||
|         inspectionrequest("GetInspectItems", htmlencode(p), function (data) { | ||||
|             datacontent.empty(); | ||||
|             if (data) { | ||||
|                 showInspections(data); | ||||
|             } | ||||
|         }, function (err) { | ||||
|         }); | ||||
|     } | ||||
|     return gs; | ||||
| }); | ||||
							
								
								
									
										407
									
								
								Site/Inspection/js/modules/inspects/editinspection.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										407
									
								
								Site/Inspection/js/modules/inspects/editinspection.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,407 @@ | ||||
| define(['modules/inspects/editsection', 'modules/inspects/editquestion'], function (Section, Question) { | ||||
|     var edit = function (inspection, id) { | ||||
|         this.reportId = id; | ||||
|         this.instance = inspection; | ||||
|     }; | ||||
|  | ||||
|     var __proto = edit.prototype; | ||||
|  | ||||
|     function onSave(_this, exit) { | ||||
|         var alerttitle = GetTextByKey("P_IPT_EDITINSPECTION", 'Edit Inspection'); | ||||
|         if (!_this || !_this.report) { | ||||
|             showAlert(GetTextByKey("P_IPT_PAGEERROR", 'An unknown error occurred.  Please refresh page.'), alerttitle); | ||||
|             return; | ||||
|         } | ||||
|         _this.loading && _this.loading.fadeIn(100); | ||||
|         var pages = _this.content.children('div[data-page]'); | ||||
|         var answers = []; | ||||
|         for (var i = 0; i < pages.length; i++) { | ||||
|             var qs = $(pages[i]).find('.question-item'); | ||||
|             for (var j = 0; j < qs.length; j++) { | ||||
|                 var question = $(qs[j]).data('question'); | ||||
|                 var q = question.question; | ||||
|                 var a = question.getAnswer(); | ||||
|                 var flag; | ||||
|                 var msg; | ||||
|                 var isChoice = | ||||
|                     q.QuestionType === Question.types.List || | ||||
|                     q.QuestionType === Question.types.DropDown || | ||||
|                     q.QuestionType === Question.types.YesOrNo || | ||||
|                     q.QuestionType === Question.types.EmailList || | ||||
|                     q.QuestionType === Question.types.AssetStatus || | ||||
|                     (q.QuestionType === Question.types.FuelRecords | ||||
|                         && (q.SubType === Question.fueltypes.State || | ||||
|                             q.SubType === Question.fueltypes.FuelType)); | ||||
|                 if (q.IsRequired) { | ||||
|                     if (isChoice) { | ||||
|                         flag = a.SelectedItems == null || a.SelectedItems.length == 0; | ||||
|                     } else if (a.Result == null || a.Result.length == 0) { | ||||
|                         if (q.QuestionType === Question.types.Picture) { | ||||
|                             flag = false; | ||||
|                         } else if (q.QuestionType === Question.types.FuelRecords | ||||
|                             && (q.SubType === Question.fueltypes.TotalCost || | ||||
|                                 q.SubType === Question.fueltypes.Picture)) { | ||||
|                             flag = false; | ||||
|                         } else { | ||||
|                             flag = true; | ||||
|                         } | ||||
|                     } | ||||
|                 } else if (a.Comment == null || a.Comment.length == 0) { | ||||
|                     if (isChoice) { | ||||
|                         if (a.SelectedItems == null || a.SelectedItems.length == 0) { | ||||
|                             continue; | ||||
|                         } | ||||
|                     } else if (a.Result == null || a.Result.length == 0) { | ||||
|                         if (q.QuestionType !== Question.types.Picture) { | ||||
|                             continue; | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|                 // check | ||||
|                 if (!flag && a.Result != null && a.Result.length > 0) { | ||||
|                     switch (q.QuestionType) { | ||||
|                         case Question.types.DateAndTime: | ||||
|                             if (isNaN(new Date(a.Result.replace(' ', 'T')))) { | ||||
|                                 msg = GetTextByKey("P_IPT_SUPPLIEDINPUTISNOTAVALIDTIME", 'Supplied input is not a valid time.'); | ||||
|                             } | ||||
|                             break; | ||||
|                         case Question.types.Email: | ||||
|                             var emails = a.Result.split(';'); | ||||
|                             for (var k = 0; k < emails.length; k++) { | ||||
|                                 if (!/^[0-9a-zA-Z][^@]*@[0-9a-zA-Z.]+$/.test(emails[k].trim())) { | ||||
|                                     msg = GetTextByKey("P_IPT_VALIDEMAILADDRESSFORMATREQUIRED", 'Valid email address format required.'); | ||||
|                                 } | ||||
|                             } | ||||
|                             break; | ||||
|                         case Question.types.EngingHours: | ||||
|                         case Question.types.Number: | ||||
|                         case Question.types.Odometer: | ||||
|                         case Question.types.FuelUsed: | ||||
|                             if (isNaN(Number(a.Result))) { | ||||
|                                 msg = GetTextByKey("P_IPT_SUPPLIEDINPUTISNOTAVALIDNUMBER", 'Supplied input is not a valid number.'); | ||||
|                             } | ||||
|                             break; | ||||
|                         case Question.types.FuelRemaining: | ||||
|                             var d = Number(a.Result); | ||||
|                             if (isNaN(d) || d < 0 || d > 100) { | ||||
|                                 msg = GetTextByKey("P_IPT_SUPPLIEDINPUTISNOTAVALIDPERCENTVALUE", 'Supplied input is not a valid percent value.'); | ||||
|                             } | ||||
|                             break; | ||||
|                         case Question.types.Integer: | ||||
|                             if (isNaN(Number(a.Result)) || a.Result.indexOf('.') >= 0) { | ||||
|                                 msg = 'Supplied input is not a valid integer.'; | ||||
|                             } | ||||
|                             break; | ||||
|                         case Question.types.FuelRecords: | ||||
|                             switch (q.SubType) { | ||||
|                                 case Question.fueltypes.Odometer: | ||||
|                                 case Question.fueltypes.Quantity: | ||||
|                                     if (isNaN(Number(a.Result))) { | ||||
|                                         msg = GetTextByKey("P_IPT_SUPPLIEDINPUTISNOTAVALIDNUMBER", 'Supplied input is not a valid number.'); | ||||
|                                     } | ||||
|                                     break; | ||||
|                             } | ||||
|                             break; | ||||
|                     } | ||||
|                 } | ||||
|                 if (flag || msg) { | ||||
|                     showAlert(flag ? GetTextByKey("P_IPT_THEQUESTIONISREQUIRED", 'The question is required.') : (msg || GetTextByKey("P_IPT_QUESTIONRESULTISINVALID", 'Question result is invalid.')), alerttitle, null, function () { | ||||
|                         if (typeof question.focus === 'function') { | ||||
|                             question.focus(); | ||||
|                         } | ||||
|                     }); | ||||
|                     _this.loading && _this.loading.fadeOut(100); | ||||
|                     return; | ||||
|                 } | ||||
|                 if (q.QuestionType === Question.types.AssetStatus) { | ||||
|                     a.Result = a.Comment; | ||||
|                     a.Comment = ""; | ||||
|                 } | ||||
|  | ||||
|                 answers.push(a); | ||||
|             } | ||||
|         } | ||||
|         _this.report.Answers = answers; | ||||
|         _this.report.Medias = []; | ||||
|         console.log(answers); | ||||
|  | ||||
|         var p = JSON.stringify(_this.report); | ||||
|         inspectionrequest('UpdateInspectionReport', htmlencode(p), function (result) { | ||||
|             if (typeof result === 'string') { | ||||
|                 showAlert(GetTextByKey("P_IPT_PAGEERROR1", 'An unknown error occurred. ') + result, alerttitle); | ||||
|                 _this.loading && _this.loading.fadeOut(100); | ||||
|                 return; | ||||
|             } else if (!result) { | ||||
|                 showAlert(GetTextByKey("P_IPT_FAILEDTOUPDATEINSPECTION", 'Failed to update inspection.'), alerttitle); | ||||
|                 _this.loading && _this.loading.fadeOut(100); | ||||
|                 return; | ||||
|             } else { | ||||
|                 _this.changed = true; | ||||
|                 if (exit) { | ||||
|                     showRightPopup(false); | ||||
|                     if (typeof _this.instance === 'function') { | ||||
|                         showAlert(GetTextByKey("P_IPT_UPDATEINSPECTIONSUCCESSFULLY", 'Update inspection successfully.'), alerttitle, null, function () { | ||||
|                             _this.instance(); | ||||
|                         }); | ||||
|                         return; | ||||
|                     } else { | ||||
|                         _this.instance.refresh(); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             showAlert(GetTextByKey("P_IPT_UPDATEINSPECTIONSUCCESSFULLY", 'Update inspection successfully.'), alerttitle); | ||||
|             _this.loading && _this.loading.fadeOut(100); | ||||
|         }, function () { | ||||
|             showAlert(GetTextByKey("P_IPT_PAGEERROR", 'An unknown error occurred.  Please refresh page.'), alerttitle); | ||||
|             _this.loading && _this.loading.fadeOut(100); | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     __proto.createContent = function () { | ||||
|         var _this = this; | ||||
|         var content = $('<div></div>'); | ||||
|         this.content = content; | ||||
|         var funcs = $('<div class="function_title"></div>'); | ||||
|         var btn = $('<span class="sbutton iconsave">' + GetTextByKey("P_IPT_SAVE", "Save") + '</span>').click(function () { | ||||
|             onSave(_this); | ||||
|         }); | ||||
|         funcs.append(btn); | ||||
|         btn = $('<span class="sbutton iconsave">' + GetTextByKey("P_IPT_SAVE1", "Save and Exit") + '</span>').click(function () { | ||||
|             onSave(_this, true); | ||||
|         }); | ||||
|         funcs.append(btn); | ||||
|         btn = $('<span class="sbutton iconexit">' + GetTextByKey("P_IPT_SAVE2", "Exit Without Saving") + '</span>').click(function () { | ||||
|             showRightPopup(false); | ||||
|             if (_this.changed) { | ||||
|                 if (typeof _this.instance === 'function') { | ||||
|                     _this.instance(); | ||||
|                 } else { | ||||
|                     _this.instance.refresh(); | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|         funcs.append(btn); | ||||
|         content.append(funcs); | ||||
|  | ||||
|         // committed information | ||||
|         var info = $('<div style="margin: 6px 0 0 10px; line-height: 32px"></div>'); | ||||
|         var templatename = $('<span style="font-size: 1.7em"></span>'); | ||||
|         info.append(templatename); | ||||
|         var committedby = $('<span style="margin-left: 10px"></span>'); | ||||
|         info.append(committedby); | ||||
|         content.append(info); | ||||
|         // asset info | ||||
|         var assetpanel = $('<div style="margin: 6px 0 0 10px; line-height: 26px"></div>').hide(); | ||||
|         content.append(assetpanel); | ||||
|  | ||||
|         var ul = $('<ul class="tab_header" style="padding-top: 5px;"></ul>'); | ||||
|         content.append(ul); | ||||
|  | ||||
|         //var tabIndex = 0; | ||||
|         //for (var i = 0; i < this.pages.length; i++) { | ||||
|         //    var p = this.pages[i]; | ||||
|         //    addTab(p, false); | ||||
|         //} | ||||
|         var p = JSON.stringify([teamintelligence, this.reportId]); | ||||
|         inspectionrequest('GetInspectionReportForEdit', htmlencode(p), function (data) { | ||||
|             console.log(data); | ||||
|             if (typeof data === 'string') { | ||||
|                 showAlert(data + GetTextByKey("P_IPT_REFRESHPAGE", ' Please refresh page.'), GetTextByKey("P_IPT_EDITINSPECTION", 'Edit Inspection')); | ||||
|                 return; | ||||
|             } | ||||
|             _this.report = data; | ||||
|             //if (data.AssetList) { | ||||
|             //    window.AssetList = data.AssetList; | ||||
|             //} | ||||
|             if (data.EmailList) { | ||||
|                 window.EmailList = data.EmailList; | ||||
|             } | ||||
|             if (data.JobSiteList) { | ||||
|                 window.JobSiteList = data.JobSiteList; | ||||
|             } | ||||
|             templatename.text(data.Template.Name); | ||||
|             committedby.text(data.CommitTimeLocalStr + ' by ' + data.CommitedByUserName); | ||||
|             if (data.Target === 0 && data.Asset) { | ||||
|                 var asset = data.Asset; | ||||
|                 var tb = $('<table class="inspect-asset" style="width: 100%"></table>'); | ||||
|                 var tr = $('<tr></tr>'); | ||||
|                 var td = $('<td style="width: 25%"><b style="display: inline-block; width: 85px">' + GetTextByKey("P_IPT_ASSETNAME_COLON", "Asset Name:") + '</b></td>'); | ||||
|                 td.append($('<span style="margin-left: 6px"></span>').text(asset.DisplayName)); | ||||
|                 tr.append(td); | ||||
|                 td = $('<td colspan="3" style="width: 75%"><b style="display: inline-block; width: 145px">' + GetTextByKey("P_IPT_ASSETNAME2_COLON", "Asset Name(Custom):") + '</b></td>'); | ||||
|                 td.append($('<span style="margin-left: 6px"></span>').text(asset.Name2 || asset.Name)); | ||||
|                 tr.append(td); | ||||
|                 tb.append(tr); | ||||
|                 tr = $('<tr></tr>'); | ||||
|                 td = $('<td style="width: 25%"><b style="display: inline-block; width: 85px">' + GetTextByKey("P_IPT_VINSN_COLON", "VIN/SN:") + '</b></td>'); | ||||
|                 td.append($('<span style="margin-left: 6px"></span>').text(asset.VIN)); | ||||
|                 tr.append(td); | ||||
|                 td = $('<td style="width: 30%"><b style="display: inline-block; width: 145px">' + GetTextByKey("P_IPT_MAKE_COLON", "Make:") + '</b></td>'); | ||||
|                 td.append($('<span style="margin-left: 6px"></span>').text(asset.MakeName)); | ||||
|                 tr.append(td); | ||||
|                 td = $('<td style="width: 20%"><b>' + GetTextByKey("P_IPT_MODEL_COLON", "Model:") + '</b></td>'); | ||||
|                 td.append($('<span style="margin-left: 6px"></span>').text(asset.ModelName)); | ||||
|                 tr.append(td); | ||||
|                 td = $('<td style="width: 25%"><b>' + GetTextByKey("P_IPT_ASSETTYPE_COLON", "Asset Type:") + '</b></td>'); | ||||
|                 td.append($('<span style="margin-left: 6px"></span>').text(asset.TypeName)); | ||||
|                 tr.append(td); | ||||
|                 tb.append(tr); | ||||
|  | ||||
|                 if (data.ForWorkOrder) { | ||||
|                     tr = $('<tr></tr>'); | ||||
|                     td = $('<td style="width: 25%"><b style="display: inline-block; width: 85px">' + GetTextByKey("P_IPT_WORKORDER_COLON", "Work Order:") + '</b></td>'); | ||||
|                     var selwo = $('<select style="margin-left: 6px;width: 160px"></select>'); | ||||
|                     selwo.change(function () { | ||||
|                         _this.report.WorkOrderId = selwo.find("option:selected").val(); | ||||
|                     }); | ||||
|                     td.append(selwo);//WorkOrderId | ||||
|                     tr.append(td); | ||||
|  | ||||
|  | ||||
|                     td = $('<td style="width: 25%"><label for="chkcv"><b style="display: inline-block; width: 145px;">' + GetTextByKey("P_IPT_CUSTOMERVISIBLE_COLON", "Customer Visible:") + '</b><label></td>'); | ||||
|                     var chkcv = $('<input id="chkcv" type="checkbox" style="margin-left: 6px;" />'); | ||||
|                     chkcv.change(function () { | ||||
|                         _this.report.VisibleToCustomer = chkcv.prop("checked"); | ||||
|                     }); | ||||
|                     chkcv.prop("checked", _this.report.VisibleToCustomer); | ||||
|                     td.append(chkcv);//VisibleToCustomer | ||||
|                     tr.append(td); | ||||
|  | ||||
|                     tb.append(tr); | ||||
|  | ||||
|                     selwo.append($("<option></option>").val(-1).text("")); | ||||
|                     inspectionrequest('GetAssetWorkOrders', data.AssetId, function (list) { | ||||
|                         if (typeof list === 'string') { | ||||
|                         } else if (list && list.length > 0) { | ||||
|                             var txt = ""; | ||||
|                             for (var i = 0; i < list.length; i++) { | ||||
|                                 var wo = list[i]; | ||||
|                                 txt = wo.Id; | ||||
|                                 if (wo.CustomerName && $.trim(wo.CustomerName) != "") | ||||
|                                     txt += " - " + wo.CustomerName; | ||||
|                                 selwo.append($("<option></option>").val(wo.Id).text(txt)); | ||||
|                             } | ||||
|                         } | ||||
|                         selwo.val(data.WorkOrderId); | ||||
|                     }); | ||||
|                 } | ||||
|  | ||||
|                 assetpanel.empty().show().append(tb); | ||||
|             } | ||||
|  | ||||
|             // pages | ||||
|             var hasAssets = false; | ||||
|             for (var i = 0; i < data.Template.Pages.length; i++) { | ||||
|                 var page = data.Template.Pages[i]; | ||||
|                 var name = 'page_' + i; | ||||
|                 var li = $('<li></li>').attr('data-href', name); | ||||
|                 if (i == 0) { | ||||
|                     li.addClass('selected'); | ||||
|                 } | ||||
|                 ul.append(li); | ||||
|                 li.append($('<span class="spanbtn icondetail"></span>')); | ||||
|                 li.append($('<span></span>').text(page.DisplayText)); | ||||
|  | ||||
|                 // content | ||||
|                 var p = $('<div></div>').attr('data-page', name); | ||||
|                 var change = (function (panel) { | ||||
|                     return function (e) { | ||||
|                         var v = e.data.getAnswer(); | ||||
|                         var left = parseFloat(v && v.Result); | ||||
|                         if (isNaN(left)) { | ||||
|                             return; | ||||
|                         } | ||||
|                         var items = panel.find('.question-item'); | ||||
|                         var total; | ||||
|                         var rightObj; | ||||
|                         var right = e.data.question.SubType === Question.fueltypes.Quantity | ||||
|                             ? Question.fueltypes.UnitCost : Question.fueltypes.Quantity; | ||||
|                         for (var n = 0; n < items.length; n++) { | ||||
|                             var q = $(items[n]).data('question'); | ||||
|                             if (q.question.QuestionType === Question.types.FuelRecords) { | ||||
|                                 if (total == null && q.question.SubType === Question.fueltypes.TotalCost) { | ||||
|                                     total = q; | ||||
|                                     if (rightObj != null) { | ||||
|                                         break; | ||||
|                                     } | ||||
|                                 } else if (rightObj == null && q.question.SubType === right) { | ||||
|                                     rightObj = q; | ||||
|                                     if (total != null) { | ||||
|                                         break; | ||||
|                                     } | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|                         if (total != null && rightObj != null) { | ||||
|                             var a = rightObj.getAnswer(); | ||||
|                             var val = parseFloat(a && a.Result); | ||||
|                             if (!isNaN(val)) { | ||||
|                                 total.fillResult((left * val).toFixed(2)); | ||||
|                             } | ||||
|                         } | ||||
|                     }; | ||||
|                 })(p); | ||||
|                 for (var j = 0; j < page.Sections.length; j++) { | ||||
|                     var section = new Section(page.Sections[j], data); | ||||
|                     if (!hasAssets && section.section.Questions.filter(function (q) { | ||||
|                         return q.QuestionType === Question.types.DropDown && ( | ||||
|                             q.LookupSource === Question.sources.Assets || | ||||
|                             q.LookupSource === Question.sources.AssetCustomerName); | ||||
|                     }).length > 0) { | ||||
|                         hasAssets = true; | ||||
|                         inspectionrequest('GetAssetBasicInfoForEdit', '', function (list) { | ||||
|                             if (typeof list === 'string') { | ||||
|                                 console.log(list); | ||||
|                             } else if (list && list.length > 0) { | ||||
|                                 window.AssetList = list; | ||||
|                                 var pages = _this.content.children('div[data-page]'); | ||||
|                                 for (var i = 0; i < pages.length; i++) { | ||||
|                                     var qs = $(pages[i]).find('.question-item'); | ||||
|                                     for (var j = 0; j < qs.length; j++) { | ||||
|                                         var question = $(qs[j]).data('question'); | ||||
|                                         var q = question.question; | ||||
|                                         if (q.QuestionType === Question.types.DropDown && ( | ||||
|                                             q.LookupSource === Question.sources.Assets || | ||||
|                                             q.LookupSource === Question.sources.AssetCustomerName)) { | ||||
|                                             question.setLoaded && question.setLoaded(); | ||||
|                                         } | ||||
|                                     } | ||||
|                                 } | ||||
|                                 console.log(GetTextByKey("P_IPT_LOADEDASSETLIST", 'loaded asset list: ') + list.length); | ||||
|                             } else { | ||||
|                                 console.log(GetTextByKey("P_IPT_FAILEDTODOWNLOADASSETLIST", 'failed to download asset list.')); | ||||
|                             } | ||||
|                         }); | ||||
|                     } | ||||
|                     p.append(section.createContent(change)); | ||||
|                 } | ||||
|                 content.append(p); | ||||
|  | ||||
|                 var items = p.find('.question-item'); | ||||
|                 for (var n = 0; n < items.length; n++) { | ||||
|                     var q = $(items[n]).data('question'); | ||||
|                     if (q.question.QuestionType === Question.types.FuelRecords | ||||
|                         && (q.question.SubType === Question.fueltypes.Quantity || | ||||
|                             q.question.SubType === Question.fueltypes.UnitCost)) { | ||||
|                         change({ data: q }); | ||||
|                         break; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             ul.append($('<li style="clear: both;"></li>')); | ||||
|             content.tab(); | ||||
|  | ||||
|             _this.loading && _this.loading.fadeOut(100); | ||||
|         }); | ||||
|  | ||||
|         var loading = $('<div id="mask_bg"></div>'); | ||||
|         _this.loading = loading; | ||||
|         content.append(loading); | ||||
|  | ||||
|         return content; | ||||
|     }; | ||||
|  | ||||
|     return { | ||||
|         EditInspection: edit | ||||
|     } | ||||
| }); | ||||
							
								
								
									
										948
									
								
								Site/Inspection/js/modules/inspects/editquestion.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										948
									
								
								Site/Inspection/js/modules/inspects/editquestion.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,948 @@ | ||||
| define([], function () { | ||||
|     var QTypes = { | ||||
|         SingleLineText: 0, | ||||
|         MultipleLineText: 1, | ||||
|         Email: 2, | ||||
|         Number: 3, | ||||
|         Integer: 4, | ||||
|         YesOrNo: 5, | ||||
|         Date: 6, | ||||
|         DateAndTime: 7, | ||||
|         DropDown: 8, | ||||
|         List: 9, | ||||
|         Picture: 10, | ||||
|         Odometer: 11, | ||||
|         EngingHours: 12, | ||||
|         FuelRemaining: 13, | ||||
|         EmailList: 14, | ||||
|         FuelRecords: 15, | ||||
|         BarCode: 16, | ||||
|         BarCodeValidate: 17, | ||||
|         FuelUsed: 18, | ||||
|         AssetStatus: 19 | ||||
|     }; | ||||
|     var LookupSources = { | ||||
|         None: 0, | ||||
|         Jobsites: 1, | ||||
|         Assets: 2, | ||||
|         Employee: 3, | ||||
|         AssetCustomerName: 4 | ||||
|     }; | ||||
|     var FuelRecordTypes = { | ||||
|         TransactionDate: 0, | ||||
|         TicketNumber: 1, | ||||
|         DriverName: 2, | ||||
|         RetailerName: 3, | ||||
|         RetailerAddress: 4, | ||||
|         City: 5, | ||||
|         State: 6, | ||||
|         Zip: 7, | ||||
|         Odometer: 8, | ||||
|         FuelType: 9, | ||||
|         Quantity: 10, | ||||
|         UnitCost: 11, | ||||
|         TotalCost: 12, | ||||
|         BrandName: 13, | ||||
|         Notes: 14, | ||||
|         Picture: 15, | ||||
|         DistributedBy: 16 | ||||
|     }; | ||||
|  | ||||
|     // base question type | ||||
|     var question = function (q) { | ||||
|         this.question = q; | ||||
|         // comment | ||||
|         // content | ||||
|         // unit | ||||
|         this.ui = {}; | ||||
|         // items | ||||
|         this.data = {}; | ||||
|     }; | ||||
|     question.prototype.createContent = function (answer, medias, change) { | ||||
|         this.answer = answer; | ||||
|         var content = $('<div class="question-item" style="line-height: 26px; margin: 0 0 22px 22px"></div>'); | ||||
|         var q = this.question; | ||||
|  | ||||
|         var div_title = $('<div style="font-weight: bold; font-size: 1.1em"></div>').text(q.DisplayText); | ||||
|         if (q.IsRequired) { | ||||
|             div_title.append('<span style="color: red; margin-left: 4px">*</span>'); | ||||
|         } | ||||
|         content.append(div_title); | ||||
|         if (q.StaticPictures && q.StaticPictures.length > 0) { | ||||
|             var div_pic = $('<div></div>'); | ||||
|             for (var i = 0; i < q.StaticPictures.length; i++) { | ||||
|                 var pic = q.StaticPictures[i]; | ||||
|                 var img = $('<img style="width:40px;height:40px;margin-left:5px;"/>').attr('src', pic.Url).attr('title', pic.Name); | ||||
|                 img.click(pic.Url, function (e) { | ||||
|                     window.open(e.data, "_blank") | ||||
|                 }); | ||||
|                 div_pic.append(img); | ||||
|             } | ||||
|             content.append(div_pic); | ||||
|         } | ||||
|  | ||||
|         var cnt = $('<div style="margin: 6px 0 0 22px"></div>'); | ||||
|         if (typeof this.createQuestion === 'function') { | ||||
|             this.ui.content = this.createQuestion(answer, medias, change); | ||||
|             cnt.append(this.ui.content); | ||||
|         } else { | ||||
|             cnt.append('<div style="font-style: italic; color: #ccc"><Not implemented yet.></div>'); | ||||
|         } | ||||
|         var divComment = $('<div style="padding: 6px 0"></div>'); | ||||
|         if (q.CanComment) { | ||||
|             var comment = $('<textarea class="form-control" style="width: 100%; box-sizing: border-box; height: 70px" placeholder="Comment"></textarea>'); | ||||
|             comment.attr('maxlength', 500); | ||||
|             if (answer && answer.Comment) { | ||||
|                 comment.val(answer.Comment); | ||||
|             } | ||||
|             this.ui.comment = comment; | ||||
|             divComment.append(comment); | ||||
|         } | ||||
|         cnt.append(divComment); | ||||
|         content.append(cnt); | ||||
|         return content; | ||||
|     }; | ||||
|     question.prototype.getAnswer = function () { | ||||
|         var answer = this.answer; | ||||
|         if (answer == null) { | ||||
|             answer = { | ||||
|                 'QuestionId': this.question.Id, | ||||
|                 'SeverityLevel': this.question.SeverityLevel | ||||
|             }; | ||||
|             this.answer = answer; | ||||
|         } | ||||
|         if (this.ui.comment != null) { | ||||
|             answer.Comment = this.ui.comment.val(); | ||||
|         } | ||||
|         return answer; | ||||
|     }; | ||||
|     question.prototype.focus = function () { | ||||
|         if (this.ui.comment != null) { | ||||
|             this.ui.comment.focus(); | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     // input type question | ||||
|     var inputQuestion = function (q) { | ||||
|         question.call(this, q); | ||||
|     }; | ||||
|     inputQuestion.prototype = Object.create(question.prototype); | ||||
|     inputQuestion.prototype.constructor = inputQuestion; | ||||
|     inputQuestion.prototype.createQuestion = function (answer, _medias, change) { | ||||
|         var content = $('<div></div>'); | ||||
|         var input; | ||||
|         if (this.question.QuestionType === QTypes.MultipleLineText | ||||
|             || (this.question.QuestionType === QTypes.FuelRecords && | ||||
|                 this.question.SubType === FuelRecordTypes.Notes)) { | ||||
|             input = $('<textarea style="width: 100%; height: 70px"></textarea>'); | ||||
|         } else { | ||||
|             input = $('<input type="text" style="width: 100%; height: 21px"></input>'); | ||||
|         } | ||||
|         if (this.question.QuestionType === QTypes.Email) { | ||||
|             input.attr('placeholder', 'name@example.com; ...'); | ||||
|         } else if (this.question.QuestionType === QTypes.FuelRecords) { | ||||
|             if (this.question.SubType === FuelRecordTypes.TotalCost) { | ||||
|                 input.prop('readonly', true).css('background', '#eee'); | ||||
|             } else if (this.question.SubType === FuelRecordTypes.Quantity | ||||
|                 || this.question.SubType === FuelRecordTypes.UnitCost) { | ||||
|                 if (typeof change === 'function') { | ||||
|                     input.on('input propertychange', this, change); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         if (answer && answer.Result) { | ||||
|             input.val(answer.Result); | ||||
|         } | ||||
|         input.attr('maxlength', 500); | ||||
|         input.css('box-sizing', 'border-box'); | ||||
|         input.addClass('form-control'); | ||||
|         this.ui.input = input; | ||||
|         if (typeof this.createUnit === 'function') { | ||||
|             content.append(this.createUnit(answer)); | ||||
|             content.append($('<div style="margin-right: 110px"></div>').append(input)); | ||||
|         } else { | ||||
|             content.append(input); | ||||
|         } | ||||
|  | ||||
|         if (this.question.QuestionType === QTypes.AssetStatus) { | ||||
|             if (_medias && _medias.length > 0) { | ||||
|                 var div_pic = $('<div></div>'); | ||||
|                 for (var i = 0; i < _medias.length; i++) { | ||||
|                     var pic = _medias[i]; | ||||
|                     var img = $('<img style="width:40px;height:40px;margin-left:5px;"/>').attr('src', pic.Url).attr('title', pic.Name); | ||||
|                     img.click(pic.Url, function (e) { | ||||
|                         window.open(e.data, "_blank") | ||||
|                     }); | ||||
|                     div_pic.append(img); | ||||
|                 } | ||||
|                 content.append(div_pic); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return content; | ||||
|     }; | ||||
|     inputQuestion.prototype.getAnswer = function () { | ||||
|         var answer = question.prototype.getAnswer.call(this); | ||||
|         //if (this.question.QuestionType !== QTypes.FuelRecords || | ||||
|         //    this.question.SubType !== FuelRecordTypes.TotalCost) { | ||||
|         answer.Result = this.ui.input.val(); | ||||
|         //} | ||||
|         return answer; | ||||
|     }; | ||||
|     inputQuestion.prototype.fillResult = function (result) { | ||||
|         if (this.ui.input != null) { | ||||
|             this.ui.input.val(result); | ||||
|         } | ||||
|     }; | ||||
|     inputQuestion.prototype.focus = function () { | ||||
|         this.ui.input.focus(); | ||||
|     }; | ||||
|  | ||||
|     // input with dropdown | ||||
|     var inputDropQuestion = function (q) { | ||||
|         inputQuestion.call(this, q); | ||||
|     }; | ||||
|     inputDropQuestion.prototype = Object.create(inputQuestion.prototype); | ||||
|     inputDropQuestion.prototype.constructor = inputDropQuestion; | ||||
|     inputDropQuestion.prototype.createUnit = function (answer) { | ||||
|         var selector = $('<select style="float: right; width: 100px; height: 21px; margin-top: 2px"></select>'); | ||||
|         var opts; | ||||
|         if (this.question.QuestionType === QTypes.FuelRemaining) { | ||||
|             opts = [{ v: 'percent', t: 'Percent' }]; | ||||
|         } else if (this.question.QuestionType === QTypes.Odometer) { | ||||
|             opts = [ | ||||
|                 { v: 'mile', t: 'Mile(s)' }, | ||||
|                 { v: 'kilometre', t: 'kilometre' } | ||||
|             ]; | ||||
|         } else if (this.question.QuestionType === QTypes.FuelUsed) { | ||||
|             opts = [ | ||||
|                 { v: 'Gallon', t: 'Gallon' }, | ||||
|                 { v: 'Litre', t: 'Litre' } | ||||
|             ]; | ||||
|         } else if (this.question.QuestionType === QTypes.FuelRecords) { | ||||
|             if (this.question.SubType === FuelRecordTypes.Odometer) { | ||||
|                 opts = [ | ||||
|                     { v: 'mile', t: 'Mile(s)' }, | ||||
|                     { v: 'kilometre', t: 'Kilometer' } | ||||
|                 ]; | ||||
|             } else if (this.question.SubType === FuelRecordTypes.Quantity) { | ||||
|                 opts = [ | ||||
|                     { v: 'Gallon', t: 'Gallon' }, | ||||
|                     { v: 'Litre', t: 'Litre' } | ||||
|                 ]; | ||||
|             } | ||||
|         } else { | ||||
|             opts = []; | ||||
|         } | ||||
|         for (var i = 0; i < opts.length; i++) { | ||||
|             var o = opts[i]; | ||||
|             selector.append($('<option></option>').val(o.v).text(o.t)); | ||||
|         } | ||||
|         if (answer && answer.Units) { | ||||
|             selector.val(answer.Units); | ||||
|         } else { | ||||
|             selector.val(opts[0].v); | ||||
|         } | ||||
|         this.ui.unit = selector; | ||||
|         return selector; | ||||
|     }; | ||||
|     inputDropQuestion.prototype.getAnswer = function () { | ||||
|         var answer = inputQuestion.prototype.getAnswer.call(this); | ||||
|         answer.Units = this.ui.unit.val(); | ||||
|         return answer; | ||||
|     }; | ||||
|  | ||||
|     // list question | ||||
|     var listQuestion = function (q) { | ||||
|         question.call(this, q); | ||||
|     }; | ||||
|     listQuestion.prototype = Object.create(question.prototype); | ||||
|     listQuestion.prototype.constructor = listQuestion; | ||||
|     listQuestion.prototype.createQuestion = function (answer) { | ||||
|         var content = $('<div></div>'); | ||||
|         var q = this.question; | ||||
|         for (var i = 0; i < q.SelectItems.length; i++) { | ||||
|             var item = q.SelectItems[i]; | ||||
|             var line = $('<div></div>'); | ||||
|             var check; | ||||
|             var name = 'item_' + q.Id; | ||||
|             var id = name + '_' + i; | ||||
|             var left = $('<div style="float: left"></div>'); | ||||
|             var val = item.Value || item.Text; | ||||
|             if (q.MultipleSelect) { | ||||
|                 check = $('<input type="checkbox"></input>').attr('id', id).val(val); | ||||
|             } else { | ||||
|                 check = $('<input type="radio"></input>').attr({ 'id': id, 'name': name }).val(val); | ||||
|             } | ||||
|             check.data('item', item); | ||||
|             if (answer && answer.SelectedItems) { | ||||
|                 var s = answer.SelectedItems.filter(function (a) { return (a.Value || a.Text) === val }); | ||||
|                 if (s.length > 0) { | ||||
|                     check.prop('checked', true); | ||||
|                 } | ||||
|             } | ||||
|             left.append(check); | ||||
|             var circle = $('<div></div>').css({ | ||||
|                 'width': 12, | ||||
|                 'height': 12, | ||||
|                 'border-radius': 6, | ||||
|                 'display': 'inline-block', | ||||
|                 'margin-left': 5, | ||||
|                 'vertical-align': 'middle' | ||||
|             }); | ||||
|             circle.css('background-color', item.BackgroundColor); | ||||
|             left.append(circle); | ||||
|             line.append(left); | ||||
|             line.append($('<label style="margin-left: 45px; display: block"></label>').attr('for', id).text(item.Text)); | ||||
|  | ||||
|             content.append(line); | ||||
|         } | ||||
|         return content; | ||||
|     }; | ||||
|     listQuestion.prototype.getAnswer = function () { | ||||
|         var answer = question.prototype.getAnswer.call(this); | ||||
|         var checks = this.ui.content.find('input:checked'); | ||||
|         var items = []; | ||||
|         for (var i = 0; i < checks.length; i++) { | ||||
|             var item = $(checks[i]).data('item'); | ||||
|             items.push(item); | ||||
|         } | ||||
|         answer.SelectedItems = items; | ||||
|         if (items.length > 0) { | ||||
|             answer.Result = items.map(function (i) { return i.Value || i.Text }).join('\n'); | ||||
|             //answer.SeverityLevel = items[0].SeverityLevel; | ||||
|         } else { | ||||
|             answer.Result = ''; | ||||
|         } | ||||
|         return answer; | ||||
|     }; | ||||
|     listQuestion.prototype.focus = function () { | ||||
|         var ele = this.ui.content.find('input:first'); | ||||
|         if (ele.length > 0) { | ||||
|             ele.focus(); | ||||
|         } else { | ||||
|             question.prototype.focus.call(this); | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     // date&time question | ||||
|     var dateTimeQuestion = function (q) { | ||||
|         question.call(this, q); | ||||
|     }; | ||||
|     dateTimeQuestion.prototype = Object.create(question.prototype); | ||||
|     dateTimeQuestion.prototype.constructor = dateTimeQuestion; | ||||
|     dateTimeQuestion.prototype.createQuestion = function (answer) { | ||||
|         var content = $('<div></div>'); | ||||
|         var q = this.question; | ||||
|         var result; | ||||
|         if (answer && answer.Result) { | ||||
|             result = answer.Result.split(' '); | ||||
|         } | ||||
|         var date = $('<input type="text" style="width: 100px; height: 21px"></input>'); | ||||
|         date.css('box-sizing', 'border-box'); | ||||
|         date.addClass('form-control'); | ||||
|         if (result) { | ||||
|             date.val(result[0]); | ||||
|         } | ||||
|         this.ui.date = date; | ||||
|         content.append(date); | ||||
|         date.datetimepicker({ | ||||
|             timepicker: false, | ||||
|             format: 'Y-m-d', | ||||
|             enterLikeTab: false, | ||||
|             //onSelectDate: function (v, inp) { | ||||
|  | ||||
|             //} | ||||
|         }); | ||||
|         if (q.QuestionType === QTypes.DateAndTime | ||||
|             || (q.QuestionType === QTypes.FuelRecords && | ||||
|                 q.SubType === FuelRecordTypes.TransactionDate)) { | ||||
|             var time = $('<input type="text" style="width: 100px; margin-left: 10px; height: 21px"></input>'); | ||||
|             time.css('box-sizing', 'border-box'); | ||||
|             time.addClass('form-control'); | ||||
|             if (result) { | ||||
|                 time.val(result[1]); | ||||
|             } | ||||
|             this.ui.time = time; | ||||
|             content.append(time); | ||||
|             //time.blur(function () { | ||||
|             //    var dt = new Date('1970-01-01T' + $(this).val()); | ||||
|             //    if (isNaN(dt.getDate())) { | ||||
|             //        $(this).css('border-color', 'red'); | ||||
|             //    } else { | ||||
|             //        $(this).css('border-color', ''); | ||||
|             //    } | ||||
|             //}); | ||||
|             //time.datetimepicker({ | ||||
|             //    datepicker: false, | ||||
|             //    format: 'H:m:s', | ||||
|             //    enterLikeTab: false | ||||
|             //}); | ||||
|         } | ||||
|         return content; | ||||
|     }; | ||||
|     dateTimeQuestion.prototype.getAnswer = function () { | ||||
|         var answer = question.prototype.getAnswer.call(this); | ||||
|         var date = this.ui.date.val(); | ||||
|         if (this.ui.time != null) { | ||||
|             date += ' ' + this.ui.time.val(); | ||||
|         } | ||||
|         if (date != ' ') { | ||||
|             answer.Result = date; | ||||
|         } | ||||
|         return answer; | ||||
|     }; | ||||
|     dateTimeQuestion.prototype.focus = function () { | ||||
|         if (this.ui.time != null) { | ||||
|             this.ui.time.focus(); | ||||
|         } else { | ||||
|             this.ui.date.focus(); | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     // drop question | ||||
|     var dropQuestion = function (q) { | ||||
|         question.call(this, q); | ||||
|     }; | ||||
|     dropQuestion.prototype = Object.create(question.prototype); | ||||
|     dropQuestion.prototype.constructor = dropQuestion; | ||||
|     dropQuestion.prototype.createQuestion = function (answer) { | ||||
|         var _this = this; | ||||
|         var content = $('<div></div>').click(function () { _this.openDrop(content.offset()) }); | ||||
|         var result = $('<div class="drop-result" style="float: left; cursor: pointer"></div>'); | ||||
|         this.fillResult(result, answer && answer.SelectedItems); | ||||
|         content.append(result); | ||||
|         var icon = $('<div class="icon-col iconcaretdown" style="float: left; margin-left: 10px; font-weight: bold"></div>'); | ||||
|         content.append(icon); | ||||
|         if (!this.loaded && ( | ||||
|             this.question.LookupSource === LookupSources.Assets || | ||||
|             this.question.LookupSource === LookupSources.AssetCustomerName)) { | ||||
|             var loading = $('<div class="loading c-spin" style="float: left; margin-left: 10px; color: gray"></div>'); | ||||
|             content.append(loading); | ||||
|         } | ||||
|         content.append('<div style="clear: both"></div>'); | ||||
|         return content; | ||||
|     }; | ||||
|     dropQuestion.prototype.setLoaded = function () { | ||||
|         this.loaded = true; | ||||
|         this.ui.content && this.ui.content.find('.loading').remove(); | ||||
|     }; | ||||
|     dropQuestion.prototype.focus = function () { | ||||
|         var ele = this.ui.content.find('input:first'); | ||||
|         if (ele.length > 0) { | ||||
|             ele.focus(); | ||||
|         } else { | ||||
|             question.prototype.focus.call(this); | ||||
|         } | ||||
|     }; | ||||
|     dropQuestion.prototype.fillResult = function (container, items) { | ||||
|         container.empty(); | ||||
|         if (items && items.length > 0) { | ||||
|             for (var i = 0; i < items.length; i++) { | ||||
|                 var item = items[i]; | ||||
|                 var line = $('<div></div>'); | ||||
|                 line.append($('<input type="hidden"></input>').data('item', item).val(item.Value || item.Text)); | ||||
|                 var circle = $('<div></div>').css({ | ||||
|                     'width': 12, | ||||
|                     'height': 12, | ||||
|                     'border-radius': 6, | ||||
|                     'display': 'inline-block', | ||||
|                     'margin-left': 5, | ||||
|                     'vertical-align': 'middle' | ||||
|                 }); | ||||
|                 circle.css('background-color', item.BackgroundColor || '#ccc'); | ||||
|                 line.append(circle); | ||||
|                 var text; | ||||
|                 if (this.question.QuestionType === QTypes.EmailList) { | ||||
|                     text = item.Text + ' <' + item.Value + '>'; | ||||
|                 } else { | ||||
|                     text = item.Text; | ||||
|                 } | ||||
|                 line.append($('<span style="margin-left: 10px"></span>').text(text)); | ||||
|                 container.append(line); | ||||
|             } | ||||
|         } else { | ||||
|             if (this.question.QuestionType === QTypes.EmailList) { | ||||
|                 container.append($('<span style="color: #ccc">No Emails Selected</span>')); | ||||
|             } else { | ||||
|                 container.append($('<span style="color: #ccc">No Selection</span>')); | ||||
|             } | ||||
|         } | ||||
|     }; | ||||
|     dropQuestion.prototype.openDrop = function (pos) { | ||||
|         var _this = this; | ||||
|         var q = this.question; | ||||
|         var mask = this.ui.mask; | ||||
|         if (mask == null) { | ||||
|             mask = $('<div style="position:fixed; left:0;right:0;top:0;bottom:0"></div>'); | ||||
|             this.ui.mask = mask; | ||||
|         } | ||||
|         mask.on('mousedown touchstart', function () { | ||||
|             if (panel.is(":visible")) { | ||||
|                 panel.find(".iconcheck").click(); | ||||
|             } | ||||
|             //_this.closeDrop() | ||||
|         }); | ||||
|         $(document.body).append(mask); | ||||
|  | ||||
|         // drop panel | ||||
|         var panel = this.ui.droplist; | ||||
|         if (panel != null) { | ||||
|             panel.remove(); | ||||
|         } | ||||
|         panel = $('<div style="position:absolute;background:white;width:400px;height:300px;border:1px solid #ccc;box-shadow:3px 3px 10px #eee"></div>'); | ||||
|         var answer = this.answer; | ||||
|         var isEmailList = q.QuestionType === QTypes.EmailList; | ||||
|         var isEmployee = q.QuestionType === QTypes.DropDown && q.LookupSource === LookupSources.Employee; | ||||
|         var refreshList = function (content, items) { | ||||
|             content.find('.drop-item').remove(); | ||||
|             for (var i = 0; i < items.length; i++) { | ||||
|                 var item = items[i]; | ||||
|                 var line = $('<div class="drop-item"></div>'); | ||||
|                 var check; | ||||
|                 var name = 'item_' + q.Id; | ||||
|                 var id = name + '_' + i; | ||||
|                 var left = $('<div style="float: left"></div>'); | ||||
|                 var val = item.Value || item.Text; | ||||
|                 if (isEmailList || q.MultipleSelect) { | ||||
|                     check = $('<input type="checkbox"></input>').attr('id', id).val(val); | ||||
|                 } else { | ||||
|                     check = $('<input type="radio"></input>').attr({ 'id': id, 'name': name }).val(val); | ||||
|                 } | ||||
|                 check.data('item', item); | ||||
|                 check.change(function () { | ||||
|                     if (!q.MultipleSelect && q.QuestionType !== QTypes.EmailList) { | ||||
|                         for (var i = 0; i < _this.data.items.length; i++) { | ||||
|                             _this.data.items[i].Selected = false; | ||||
|                         } | ||||
|                     } | ||||
|                     $(this).data('item').Selected = $(this).prop('checked'); | ||||
|                 }); | ||||
|                 if (answer && answer.SelectedItems) { | ||||
|                     var s = answer.SelectedItems.filter(function (a) { return (a.Value || a.Text) === val }); | ||||
|                     if (s.length > 0) { | ||||
|                         check.prop('checked', true); | ||||
|                         item.Selected = true; | ||||
|                     } | ||||
|                 } | ||||
|                 left.append(check); | ||||
|                 var circle = $('<div></div>').css({ | ||||
|                     'width': 12, | ||||
|                     'height': 12, | ||||
|                     'border-radius': 6, | ||||
|                     'display': 'inline-block', | ||||
|                     'margin-left': 5, | ||||
|                     'vertical-align': 'middle' | ||||
|                 }); | ||||
|                 circle.css('background-color', item.BackgroundColor); | ||||
|                 left.append(circle); | ||||
|                 line.append(left); | ||||
|                 line.append($('<label style="margin-left: 45px; display: block"></label>').attr('for', id).text( | ||||
|                     isEmailList ? item.Text + ' <' + item.Value + '>' : item.Text)); | ||||
|  | ||||
|                 content.append(line); | ||||
|             } | ||||
|         }; | ||||
|         var search = $('<input type="text" placeholder="Search"></input>').css({ | ||||
|             'height': 29, | ||||
|             'line-height': '29px', | ||||
|             'padding': '0 6px', | ||||
|             'width': '100%', | ||||
|             'border': 'none', | ||||
|             'border-bottom': '1px solid #ccc', | ||||
|             'box-sizing': 'border-box' | ||||
|         }).on('propertychange input', function () { | ||||
|             var items = _this.data.items; | ||||
|             var key = $(this).val().toLowerCase(); | ||||
|             if (items && items.length > 0) { | ||||
|                 items = items.filter(function (e) { return e.Text.toLowerCase().indexOf(key) >= 0 }); | ||||
|                 refreshList(panelContent, items); | ||||
|             } | ||||
|         }); | ||||
|         var funcs = $('<div style="margin-right: 45px"></div>'); | ||||
|         funcs.append(search); | ||||
|         panel.append($('<div class="sbutton iconcheck"></div>').css({ | ||||
|             'float': 'right', | ||||
|             'padding': '0 10px', | ||||
|             'height': 29, | ||||
|             'line-height': '29px' | ||||
|         }).click(function () { | ||||
|             var checks = _this.data.items; // panelContent.find('input:checked'); | ||||
|             var items = []; | ||||
|             for (var i = 0; i < checks.length; i++) { | ||||
|                 var item = checks[i]; // $(checks[i]).data('item'); | ||||
|                 if (item.Selected) { | ||||
|                     items.push(item); | ||||
|                 } | ||||
|             } | ||||
|             if (answer == null) { | ||||
|                 answer = { | ||||
|                     'QuestionId': q.Id, | ||||
|                     'SeverityLevel': q.SeverityLevel | ||||
|                 }; | ||||
|                 _this.answer = answer; | ||||
|             } | ||||
|             answer.SelectedItems = items; | ||||
|             _this.fillResult(_this.ui.content.find('.drop-result'), items); | ||||
|             _this.closeDrop(); | ||||
|         })); | ||||
|         panel.append(funcs); | ||||
|         // scroller | ||||
|         var panelContent = $('<div></div>').css({ | ||||
|             'overflow-y': 'auto', | ||||
|             'line-height': '26px', | ||||
|             'box-sizing': 'border-box', | ||||
|             'height': 270, | ||||
|             'padding': '4px 2px' | ||||
|         }); | ||||
|         panel.append(panelContent); | ||||
|         this.ui.panelContent = panelContent; | ||||
|         var generateItem = function (text, value) { | ||||
|             return { | ||||
|                 'BackgroundColor': '#cccccc', | ||||
|                 'SeverityLevel': q.SeverityLevel, | ||||
|                 'Text': text, | ||||
|                 'Value': value | ||||
|             }; | ||||
|         }; | ||||
|         var items; | ||||
|         if (q.SelectItems && q.SelectItems.length > 0) { | ||||
|             items = q.SelectItems; | ||||
|         } else if (isEmailList || isEmployee) { | ||||
|             if (window.EmailList) { | ||||
|                 items = []; | ||||
|                 for (var i = 0; i < window.EmailList.length; i++) { | ||||
|                     var item = window.EmailList[i]; | ||||
|                     items.push(generateItem( | ||||
|                         isEmployee ? (item.UserName + ' <' + item.Email + '>') : item.UserName, | ||||
|                         isEmailList ? item.Email : item.UserIID)); | ||||
|                 } | ||||
|             } | ||||
|         } else if (q.LookupSource === LookupSources.Jobsites) { | ||||
|             if (window.JobSiteList) { | ||||
|                 items = []; | ||||
|                 for (var i = 0; i < window.JobSiteList.length; i++) { | ||||
|                     var item = window.JobSiteList[i]; | ||||
|                     items.push(generateItem(item.Name, String(item.Id))); | ||||
|                 } | ||||
|             } | ||||
|         } else if (q.LookupSource === LookupSources.Assets) { | ||||
|             if (window.AssetList) { | ||||
|                 items = []; | ||||
|                 for (var i = 0; i < window.AssetList.length; i++) { | ||||
|                     var item = window.AssetList[i]; | ||||
|                     var assetLabel = [item.Name, item.VIN, item.Make, item.Model, item.AssetType].filter(function (a) { return a && a.length > 0 }).join('/'); | ||||
|                     items.push(generateItem(assetLabel, String(item.Id))); | ||||
|                 } | ||||
|             } | ||||
|         } else if (q.LookupSource === LookupSources.AssetCustomerName) { | ||||
|             if (window.AssetList) { | ||||
|                 items = []; | ||||
|                 for (var i = 0; i < window.AssetList.length; i++) { | ||||
|                     var item = window.AssetList[i]; | ||||
|                     var assetLabel = item.Name; | ||||
|                     items.push(generateItem(assetLabel, String(item.Id))); | ||||
|                 } | ||||
|             } | ||||
|         } else if (q.QuestionType === QTypes.FuelRecords) { | ||||
|             if (q.SubType === FuelRecordTypes.State) { | ||||
|                 items = [ | ||||
|                     "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", | ||||
|                     "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", | ||||
|                     "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", | ||||
|                     "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", | ||||
|                     "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY" | ||||
|                 ].map(function (s) { return generateItem(s, s) }); | ||||
|             } else if (q.SubType === FuelRecordTypes.FuelType) { | ||||
|                 items = [ | ||||
|                     { value: "BIOD", text: "B20 Diesel 20% Biodiesel" }, | ||||
|                     { value: "DEF", text: "Diesel Exhaust Fluid" }, | ||||
|                     { value: "DS+", text: "Premium Diesel #2" }, | ||||
|                     { value: "DSL", text: "Diesel #1" }, | ||||
|                     { value: "DSL2", text: "Regular Diesel #2" }, | ||||
|                     { value: "ETH-S", text: "Super Unleaded Ethanol (10% blend)" }, | ||||
|                     { value: "ETH", text: "Unleaded Ethanol (10% blend)" }, | ||||
|                     { value: "FRM", text: "Diesel Off Road (#1 and #2 non" }, | ||||
|                     { value: "FUL", text: "Miscellaneous Fuel" }, | ||||
|                     { value: "FUL-", text: "Other Fuel (Non-Taxable)" }, | ||||
|                     { value: "KERO", text: "Kerosene - Low Sulfur" }, | ||||
|                     { value: "MOT", text: "Motor Oil" }, | ||||
|                     { value: "OTH", text: "General Merchandise" }, | ||||
|                     { value: "SUP4", text: "Unleaded 4" }, | ||||
|                     { value: "SUP", text: "Unleaded Super" }, | ||||
|                     { value: "SVC", text: "Repairs" }, | ||||
|                     { value: "ULSD", text: "Ultra Low Sulfur #2" }, | ||||
|                     { value: "UN+", text: "Unleaded Plus" }, | ||||
|                     { value: "UNL", text: "Unleaded Regular" }, | ||||
|                     { value: "WASH", text: "Car Wash" }, | ||||
|                     { value: "HYD", text: "Hydraulic" }, | ||||
|                     { value: "SHY", text: "Synthetic Hydraulic" }, | ||||
|                     { value: "GRO", text: "Gear Oil" } | ||||
|                 ].map(function (t) { return generateItem(t.text, t.value) }); | ||||
|             } else if (q.SubType === FuelRecordTypes.DistributedBy) { | ||||
|                 items = [ | ||||
|                     { value: "0", text: "Fueling Station" }, | ||||
|                     { value: "1", text: "Fueling Asset" } | ||||
|                 ].map(function (t) { return generateItem(t.text, t.value) }); | ||||
|             } | ||||
|         } | ||||
|         if (items && items.length > 0) { | ||||
|             this.data.items = items; | ||||
|             refreshList(panelContent, items); | ||||
|         } | ||||
|         this.ui.droplist = panel; | ||||
|  | ||||
|         var screenHeight = $(window).height(); | ||||
|         if (pos.top + 300 > screenHeight) { | ||||
|             pos.top = screenHeight - 310; | ||||
|         } | ||||
|         panel.css({ 'left': pos.left, 'top': pos.top }); | ||||
|         $(document.body).append(panel); | ||||
|     }; | ||||
|     dropQuestion.prototype.closeDrop = function () { | ||||
|         this.ui.mask.remove(); | ||||
|         this.ui.mask = null; | ||||
|         this.ui.droplist.remove(); | ||||
|     }; | ||||
|     dropQuestion.prototype.getAnswer = function () { | ||||
|         var answer = question.prototype.getAnswer.call(this); | ||||
|         var checks = this.ui.content.children('.drop-result').find('input'); | ||||
|         var items = []; | ||||
|         for (var i = 0; i < checks.length; i++) { | ||||
|             var item = $(checks[i]).data('item'); | ||||
|             items.push(item); | ||||
|         } | ||||
|         answer.SelectedItems = items; | ||||
|         if (items.length > 0) { | ||||
|             answer.Result = items.map(function (i) { return i.Value || i.Text }).join('\n'); | ||||
|             //answer.SeverityLevel = items[0].SeverityLevel; | ||||
|         } else { | ||||
|             answer.Result = ''; | ||||
|         } | ||||
|         return answer; | ||||
|     }; | ||||
|  | ||||
|     // picture question | ||||
|     var pictureQuestion = function (q) { | ||||
|         question.call(this, q); | ||||
|     }; | ||||
|     pictureQuestion.prototype = Object.create(question.prototype); | ||||
|     pictureQuestion.prototype.constructor = pictureQuestion; | ||||
|     pictureQuestion.prototype.createQuestion = function (_answer, medias) { | ||||
|         var content = $('<div></div>'); | ||||
|         if (medias && medias.length > 0) { | ||||
|             for (var i = 0; i < medias.length; i++) { | ||||
|                 var m = medias[i]; | ||||
|                 var ele; | ||||
|                 if (['.mp4', '.mov'].indexOf(m.FileType.toLowerCase()) >= 0) { | ||||
|                     ele = $('<div></div>').css({ | ||||
|                         'float': 'left', | ||||
|                         'border': '1px solid #ccc', | ||||
|                         'height': 38, | ||||
|                         'width': 38, | ||||
|                         'text-align': 'center' | ||||
|                     }); | ||||
|                     ele.append($('<span></span>').css({ | ||||
|                         'margin': '0 auto', | ||||
|                         'font-family': 'Fontawesome', | ||||
|                         'font-size': '20px', | ||||
|                         'line-height': '38px', | ||||
|                         'color': '#000' | ||||
|                     })); | ||||
|                 } else { | ||||
|                     ele = $('<img></img>').css({ | ||||
|                         'float': 'left', | ||||
|                         'border': '1px solid #ccc', | ||||
|                         'padding': '4px', | ||||
|                         'height': 30, | ||||
|                         'margin-right': 4 | ||||
|                     }).attr('src', m.ThumbnailUrl); | ||||
|                 } | ||||
|                 content.append($('<a target="_blank"></a>').attr('href', m.Url).append(ele)); | ||||
|             } | ||||
|         } else { | ||||
|             content.append('<div style="font-style: italic; color: #ccc"><No media.></div>'); | ||||
|         } | ||||
|         content.append('<div style="clear: both"></div>'); | ||||
|         return content; | ||||
|     }; | ||||
|  | ||||
|  | ||||
|     // assetstatus question | ||||
|     var assetStatusQuestion = function (q) { | ||||
|         question.call(this, q); | ||||
|     }; | ||||
|     assetStatusQuestion.prototype = Object.create(question.prototype); | ||||
|     assetStatusQuestion.prototype.constructor = assetStatusQuestion; | ||||
|     assetStatusQuestion.prototype.createQuestion = function (answer, medias) { | ||||
|         var content = $('<div></div>'); | ||||
|         var q = this.question; | ||||
|         q.SelectItems = [ | ||||
|             { Value: "0", Text: "In Use", BackgroundColor: "#93c47d" }, | ||||
|             { Value: "1", Text: "Available", BackgroundColor: "#9fc5e8" }, | ||||
|             { Value: "2", Text: "Standby", BackgroundColor: "#f3af83" }, | ||||
|             { Value: "10", Text: "Down", BackgroundColor: "#dd7e6b" } | ||||
|         ]; | ||||
|         for (var i = 0; i < q.SelectItems.length; i++) { | ||||
|             var item = q.SelectItems[i]; | ||||
|             var line = $('<div></div>'); | ||||
|             var name = 'item_' + q.Id; | ||||
|             var id = name + '_' + i; | ||||
|             var left = $('<div style="float: left"></div>'); | ||||
|             var val = item.Value || item.Text; | ||||
|             var check = $('<input type="radio"></input>').attr({ 'id': id, 'name': name }).val(val); | ||||
|             check.data('item', item); | ||||
|             if (answer && answer.SelectedItems) { | ||||
|                 var s = answer.SelectedItems.filter(function (a) { return (a.Value || a.Text) === val }); | ||||
|                 if (s.length > 0) { | ||||
|                     check.prop('checked', true); | ||||
|                 } | ||||
|             } | ||||
|             left.append(check); | ||||
|             var circle = $('<div></div>').css({ | ||||
|                 'width': 12, | ||||
|                 'height': 12, | ||||
|                 'border-radius': 6, | ||||
|                 'display': 'inline-block', | ||||
|                 'margin-left': 5, | ||||
|                 'vertical-align': 'middle' | ||||
|             }); | ||||
|             circle.css('background-color', item.BackgroundColor); | ||||
|             left.append(circle); | ||||
|             line.append(left); | ||||
|             line.append($('<label style="margin-left: 45px; display: block"></label>').attr('for', id).text(item.Text)); | ||||
|  | ||||
|             content.append(line); | ||||
|             content.append('<div style="clear: both"></div>'); | ||||
|         } | ||||
|  | ||||
|         if (medias && medias.length > 0) { | ||||
|             var cnt = $('<div style="margin: 6px 0 0 0px"></div>'); | ||||
|             for (var i = 0; i < medias.length; i++) { | ||||
|                 var m = medias[i]; | ||||
|                 var ele; | ||||
|                 if (['.mp4', '.mov'].indexOf(m.FileType.toLowerCase()) >= 0) { | ||||
|                     ele = $('<div></div>').css({ | ||||
|                         'float': 'left', | ||||
|                         'border': '1px solid #ccc', | ||||
|                         'height': 38, | ||||
|                         'width': 38, | ||||
|                         'text-align': 'center' | ||||
|                     }); | ||||
|                     ele.append($('<span></span>').css({ | ||||
|                         'margin': '0 auto', | ||||
|                         'font-family': 'Fontawesome', | ||||
|                         'font-size': '20px', | ||||
|                         'line-height': '38px', | ||||
|                         'color': '#000' | ||||
|                     })); | ||||
|                 } else { | ||||
|                     ele = $('<img></img>').css({ | ||||
|                         'float': 'left', | ||||
|                         'border': '1px solid #ccc', | ||||
|                         'padding': '4px', | ||||
|                         'height': 30, | ||||
|                         'margin-right': 4 | ||||
|                     }).attr('src', m.ThumbnailUrl); | ||||
|                 } | ||||
|                 cnt.append($('<a target="_blank"></a>').attr('href', m.Url).append(ele)); | ||||
|             } | ||||
|             content.append(cnt); | ||||
|         } | ||||
|         content.append('<div style="clear: both"></div>'); | ||||
|  | ||||
|         cnt = $('<div style="margin: 6px 0 0 0px"></div>'); | ||||
|         var divComment = $('<div style="padding: 6px 0"></div>'); | ||||
|         var comment = $('<textarea class="form-control" style="width: 100%; box-sizing: border-box; height: 70px" placeholder="Comment"></textarea>'); | ||||
|         comment.attr('maxlength', 500); | ||||
|         if (answer && answer.Result) { | ||||
|             comment.val(answer.Result); | ||||
|         } | ||||
|         this.ui.comment = comment; | ||||
|         divComment.append(comment); | ||||
|         cnt.append(divComment); | ||||
|         content.append(cnt); | ||||
|  | ||||
|         return content; | ||||
|     }; | ||||
|     assetStatusQuestion.prototype.getAnswer = function () { | ||||
|         var answer = question.prototype.getAnswer.call(this); | ||||
|         var checks = this.ui.content.find('input:checked'); | ||||
|         var items = []; | ||||
|         for (var i = 0; i < checks.length; i++) { | ||||
|             var item = $(checks[i]).data('item'); | ||||
|             items.push(item); | ||||
|         } | ||||
|         answer.SelectedItems = items; | ||||
|         if (items.length > 0) { | ||||
|             answer.Result = items.map(function (i) { return i.Value || i.Text }).join('\n'); | ||||
|             //answer.SeverityLevel = items[0].SeverityLevel; | ||||
|         } else { | ||||
|             answer.Result = ''; | ||||
|         } | ||||
|         return answer; | ||||
|     }; | ||||
|     assetStatusQuestion.prototype.focus = function () { | ||||
|         var ele = this.ui.content.find('input:first'); | ||||
|         if (ele.length > 0) { | ||||
|             ele.focus(); | ||||
|         } else { | ||||
|             question.prototype.focus.call(this); | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|  | ||||
|     return { | ||||
|         types: QTypes, | ||||
|         sources: LookupSources, | ||||
|         fueltypes: FuelRecordTypes, | ||||
|         factory: function (q) { | ||||
|             switch (q.QuestionType) { | ||||
|                 case QTypes.Odometer: | ||||
|                 case QTypes.FuelRemaining: | ||||
|                 case QTypes.FuelUsed: | ||||
|                     return new inputDropQuestion(q); | ||||
|                 case QTypes.YesOrNo: | ||||
|                 case QTypes.List: | ||||
|                     return new listQuestion(q); | ||||
|                 case QTypes.DropDown: | ||||
|                 case QTypes.EmailList: | ||||
|                     return new dropQuestion(q); | ||||
|                 case QTypes.Date: | ||||
|                 case QTypes.DateAndTime: | ||||
|                     return new dateTimeQuestion(q); | ||||
|                 case QTypes.Picture: | ||||
|                     return new pictureQuestion(q); | ||||
|                 case QTypes.FuelRecords: | ||||
|                     switch (q.SubType) { | ||||
|                         case FuelRecordTypes.TransactionDate: | ||||
|                             return new dateTimeQuestion(q); | ||||
|                         case FuelRecordTypes.State: | ||||
|                         case FuelRecordTypes.FuelType: | ||||
|                         case FuelRecordTypes.DistributedBy: | ||||
|                             return new dropQuestion(q); | ||||
|                         case FuelRecordTypes.Odometer: | ||||
|                         case FuelRecordTypes.Quantity: | ||||
|                             return new inputDropQuestion(q); | ||||
|                         case FuelRecordTypes.Picture: | ||||
|                             return new pictureQuestion(q); | ||||
|                         default: | ||||
|                             return new inputQuestion(q); | ||||
|                     } | ||||
|                     break; | ||||
|                 case QTypes.AssetStatus: | ||||
|                     return new assetStatusQuestion(q); | ||||
|                 default: | ||||
|                     return new inputQuestion(q); | ||||
|             } | ||||
|         }, | ||||
|         equals: function (s1, s2) { | ||||
|             if (typeof s1 === 'string' && typeof s2 === 'string') { | ||||
|                 if (s1.toLowerCase() === s2.toLowerCase()) { | ||||
|                     return true; | ||||
|                 } | ||||
|             } | ||||
|             return false; | ||||
|         } | ||||
|     } | ||||
| }); | ||||
							
								
								
									
										66
									
								
								Site/Inspection/js/modules/inspects/editsection.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								Site/Inspection/js/modules/inspects/editsection.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,66 @@ | ||||
| define(['modules/inspects/editquestion'], function (Question) { | ||||
|     var ctor = function (section, report) { | ||||
|         this.section = section; | ||||
|         this.report = report; | ||||
|     }; | ||||
|  | ||||
|     var __proto = ctor.prototype; | ||||
|     __proto.createContent = function (change) { | ||||
|         var content = $('<div style="margin-bottom: 20px"></div>'); | ||||
|  | ||||
|         if (this.section.StaticPictures && this.section.StaticPictures.length > 0) { | ||||
|             var div_pic = $('<div style="background: #eee; padding: 2px 2px;"></div>'); | ||||
|             for (var i = 0; i < this.section.StaticPictures.length; i++) { | ||||
|                 var pic = this.section.StaticPictures[i]; | ||||
|                 var img = $('<img style="width:40px;height:40px;margin-left:5px;"/>').attr('src', pic.Url).attr('title', pic.Name); | ||||
|                 img.click(pic.Url, function (e) { | ||||
|                     window.open(e.data, "_blank") | ||||
|                 }); | ||||
|                 div_pic.append(img); | ||||
|             } | ||||
|             content.append(div_pic); | ||||
|         } | ||||
|  | ||||
|         var div_title = $('<div style="background: #eee; padding: 5px 3px; margin: 5px 0; font-size: 1.4em"></div>').text(this.section.DisplayText); | ||||
|         content.append(div_title); | ||||
|  | ||||
|         for (var i = 0; i < this.section.Questions.length; i++) { | ||||
|             var question = this.section.Questions[i]; | ||||
|  | ||||
|             if (question.QuestionType === Question.types.YesOrNo || | ||||
|                 question.QuestionType === Question.types.DropDown || | ||||
|                 question.QuestionType === Question.types.List) { | ||||
|                 if (!question.SelectItems || question.SelectItems.length <= 0) { | ||||
|                     if (question.QuestionType !== Question.types.DropDown || | ||||
|                         question.LookupSource === 0) { | ||||
|                         continue; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             var q = Question.factory(question); | ||||
|             // get answer and media | ||||
|             var answer = this.report.Answers.filter(function (a) { return Question.equals(a.QuestionId, question.Id) })[0]; | ||||
|             var isPicture = question.QuestionType === Question.types.Picture | ||||
|                 || (question.QuestionType === Question.types.FuelRecords && | ||||
|                     question.SubType === Question.fueltypes.Picture) | ||||
|                 || question.QuestionType === Question.types.AssetStatus; | ||||
|             var medias = isPicture && answer && this.report.Medias.filter(function (m) { return Question.equals(m.AnswerId, answer.Id) }); | ||||
|  | ||||
|             var qContent; | ||||
|             if (question.QuestionType === Question.types.FuelRecords | ||||
|                 && (question.SubType === Question.fueltypes.Quantity || | ||||
|                     question.SubType === Question.fueltypes.UnitCost)) { | ||||
|                 qContent = q.createContent(answer, medias, change); | ||||
|             } else { | ||||
|                 qContent = q.createContent(answer, medias); | ||||
|             } | ||||
|             qContent.data('question', q); | ||||
|             content.append(qContent); | ||||
|         } | ||||
|  | ||||
|         return content; | ||||
|     }; | ||||
|  | ||||
|     return ctor; | ||||
| }); | ||||
							
								
								
									
										55
									
								
								Site/Inspection/js/modules/inspects/inspect.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								Site/Inspection/js/modules/inspects/inspect.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,55 @@ | ||||
| define(['modules/templates/addtemplate'], function (AddTemplate) { | ||||
|     var q = function (ipt, inspect) { | ||||
|         this.inspect = inspect; | ||||
|         this.inspectmodule = ipt; | ||||
|     }; | ||||
|     q.prototype.description = "Inspect"; | ||||
|     q.prototype.version = "1.0.0.0"; | ||||
|  | ||||
|     q.prototype.createContent = function () { | ||||
|         var holder = $('<div class="question-holder"></div>'); | ||||
|         holder.append('<div class="question-cell inspect-templatename" style="width:150px;margin-left:8px;"><span></span></div>'); | ||||
|         holder.append('<div class="question-cell inspect-assetname" style="width:200px;"><span></span></div>'); | ||||
|         holder.append('<div class="question-cell inspect-vin" style="width:200px;"><span></span></div>'); | ||||
|         holder.append('<div class="question-cell inspect-make" style="width:150px;"><span></span></div>'); | ||||
|         holder.append('<div class="question-cell inspect-model" style="width:150px;"><span></span></div>'); | ||||
|         holder.append('<div class="question-cell inspect-type" style="width:150px;"><span></span></div>'); | ||||
|         holder.append('<div class="question-cell inspect-status" style="width:120px;"><span></span></div>'); | ||||
|         holder.append('<div class="question-cell inspect-committime" style="width:150px;"><span></span></div>'); | ||||
|         holder.append('<div class="question-cell inspect-commituser" style="width:150px;"><span></span></div>'); | ||||
|         var funcs = $('<div class="question-cell inspect-func" style="width:92px;text-align:right;padding-right:20px;"></div>'); | ||||
|         holder.append(funcs); | ||||
|         var _this = this; | ||||
|         holder.find('.inspect-assetname span').click(function () { | ||||
|             window.open("report.aspx?rid=" + _this.inspect.Id, "_blank"); | ||||
|         }); | ||||
|         funcs.append($('<em class="spanbtn icondetail"></em>').click(function () { | ||||
|             window.open("report.aspx?rid=" + _this.inspect.Id, "_blank"); | ||||
|         }).attr('title', 'Detail')); | ||||
|         this.holder = holder; | ||||
|         if (this.inspect != null) { | ||||
|             this.updateContent(this.inspect); | ||||
|         } | ||||
|         return holder; | ||||
|     }; | ||||
|     q.prototype.updateContent = function (inspect) { | ||||
|         if (this.inspect != inspect) { | ||||
|             this.inspect = inspect; | ||||
|         } | ||||
|         this.holder.find('.inspect-assetname span').text(inspect.AssetName); | ||||
|         this.holder.find('.inspect-vin span').text(inspect.VIN); | ||||
|         this.holder.find('.inspect-make span').text(inspect.MakeName); | ||||
|         this.holder.find('.inspect-model span').text(inspect.ModelName); | ||||
|         this.holder.find('.inspect-type span').text(inspect.TypeName); | ||||
|         this.holder.find('.inspect-templatename span').text(inspect.TemplateName); | ||||
|         var statustext = ''; | ||||
|         if (inspect.Status == 0) | ||||
|             statustext = 'Draft'; | ||||
|         else if (inspect.Status == 1) | ||||
|             statustext = 'Committed'; | ||||
|         this.holder.find('.inspect-status span').text(statustext); | ||||
|         this.holder.find('.inspect-committime span').text(inspect.CommitTimeLocalStr); | ||||
|         this.holder.find('.inspect-commituser span').text(inspect.CommitedByUserName); | ||||
|     }; | ||||
|     return q; | ||||
| }); | ||||
							
								
								
									
										513
									
								
								Site/Inspection/js/modules/layouts.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										513
									
								
								Site/Inspection/js/modules/layouts.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,513 @@ | ||||
| !function (factory) { | ||||
|     if (typeof define === 'function' && define.amd) { | ||||
|         define(['modules/editor'], function (Editor) { | ||||
|             return factory(window.jQuery, Editor); | ||||
|         }); | ||||
|     } | ||||
| }(function ($, Editor) { | ||||
|     'use strict'; | ||||
|  | ||||
|     var layouts = { | ||||
|         title: GetTextByKey('P_LAYOUTS', 'Layouts'), | ||||
|         description: GetTextByKey('P_LAYOUTS', 'Layouts'), | ||||
|         version: '1.0', | ||||
|         isteam: false, | ||||
|         changed: false, | ||||
|         ui: {} | ||||
|     }; | ||||
|  | ||||
|     function createHeader() { | ||||
|         var header = $('<div></div>'); | ||||
|         header.append($('<div class="page_title"></div>').text(layouts.title)); | ||||
|         setPageTitle(layouts.title, true); | ||||
|         var search_bar = $('<div class="search_bar"></div>'); | ||||
|         header.append(search_bar); | ||||
|         search_bar.append('<input type="password" autocomplete="new-password" style="display: none" />'); | ||||
|         var searchinputcontrol = $('<input type="text" style="margin-left:10px;" autocomplete="off" />'); | ||||
|         layouts.searchInput = searchinputcontrol; | ||||
|         search_bar.append(searchinputcontrol); | ||||
|         searchinputcontrol.keydown(function (e) { | ||||
|             if (e.keyCode == 13 || e.keyCode == 9) | ||||
|                 layouts.refresh(); | ||||
|         }); | ||||
|         var btnRefresh = $('<input class="search" type="button" style="margin-left:10px;"/>').val(GetTextByKey("P_IPT_SEARCH", "Search")); | ||||
|         search_bar.append(btnRefresh); | ||||
|         btnRefresh.click(function () { | ||||
|             layouts.refresh(); | ||||
|         }); | ||||
|  | ||||
|         var func = $('<div class="function_title"></div>'); | ||||
|         var iconAdd = $('<span class="sbutton iconadd"></span>').text(GetTextByKey("P_IPT_ADD", "Add")).on('click', function () { | ||||
|             layouts.onadd(); | ||||
|         }); | ||||
|         func.append(iconAdd); | ||||
|         var iconEdit = $('<span class="sbutton iconedit"></span>').text(GetTextByKey("P_IPT_EDIT", "Edit")).on('click', function () { | ||||
|             if (layouts.grid.selectedIndex >= 0) { | ||||
|                 layouts.onedit(); | ||||
|             } | ||||
|         }).prop('disabled', true); | ||||
|         layouts.ui.edit = iconEdit; | ||||
|         func.append(iconEdit); | ||||
|         var iconRefresh = $('<span class="sbutton iconrefresh"></span>').text(GetTextByKey("P_IPT_REFRESH", "Refresh")).on('click', function () { | ||||
|             layouts.refresh(); | ||||
|         }); | ||||
|         func.append(iconRefresh); | ||||
|         header.append(func) | ||||
|  | ||||
|         return header; | ||||
|     } | ||||
|  | ||||
|     function InitGridData() { | ||||
|         var div_grid = $('<div style="flex: 1 1 auto"></div>'); | ||||
|  | ||||
|         var grid_dt = new GridView(div_grid); | ||||
|         layouts.grid = grid_dt; | ||||
|         grid_dt.lang = { | ||||
|             all: GetTextByKey("P_GRID_ALL", "(All)"), | ||||
|             ok: GetTextByKey("P_GRID_OK", "OK"), | ||||
|             reset: GetTextByKey("P_GRID_RESET", "Reset") | ||||
|         }; | ||||
|         grid_dt.canMultiSelect = false; | ||||
|         grid_dt.columns = [ | ||||
|             { | ||||
|                 caption: GetTextByKey('P_LAYOUT_NAME', 'Layout Name'), | ||||
|                 key: 'Name', | ||||
|                 width: 200, | ||||
|                 isurl: true, | ||||
|                 events: { | ||||
|                     onclick: function () { | ||||
|                         doedit(this.Id); | ||||
|                     } | ||||
|                 }, | ||||
|                 styleFilter: function () { | ||||
|                     return { | ||||
|                         color: 'initial', | ||||
|                         cursor: 'pointer' | ||||
|                     }; | ||||
|                 } | ||||
|             }, | ||||
|             { | ||||
|                 caption: GetTextByKey('P_LAYOUT_NOTES', 'Notes'), | ||||
|                 key: 'Notes', | ||||
|                 width: 300 | ||||
|             }, | ||||
|             { | ||||
|                 isurl: true, | ||||
|                 resizable: false, | ||||
|                 orderable: false, | ||||
|                 sortable: false, | ||||
|                 width: 40, | ||||
|                 align: 'center', | ||||
|                 text: '\uf044', | ||||
|                 events: { | ||||
|                     onclick: function () { | ||||
|                         doedit(this.Id); | ||||
|                     } | ||||
|                 }, | ||||
|                 classFilter: function () { return 'icon-col' }, | ||||
|                 attrs: { | ||||
|                     title: GetTextByKey('P_WOS_EDIT', 'Edit') | ||||
|                 } | ||||
|             }, | ||||
|             { | ||||
|                 isurl: true, | ||||
|                 resizable: false, | ||||
|                 orderable: false, | ||||
|                 sortable: false, | ||||
|                 width: 40, | ||||
|                 align: 'center', | ||||
|                 text: '\uf00d', | ||||
|                 events: { | ||||
|                     onclick: function () { | ||||
|                         var id = this.Id; | ||||
|                         showConfirm( | ||||
|                             GetTextByKey('P_LAYOUT_DELETETIPS', 'Are you sure you want to delete the layout?'), | ||||
|                             GetTextByKey('P_LAYOUTS', 'Layouts'), | ||||
|                             function () { | ||||
|                                 inspectionrequest('DeleteInspectLayout', | ||||
|                                     JSON.stringify([layouts.isteam ? 1 : 0, id]), | ||||
|                                     function (data) { | ||||
|                                         if (data == 'OK') { | ||||
|                                             layouts.refresh(); | ||||
|                                         } else { | ||||
|                                             showAlert(data != 'Failed' ? data : GetTextByKey('P_LAYOUT_FAILEDDELETE', 'Failed to delete this layout.'), GetTextByKey('P_LAYOUTS', 'Layouts')); | ||||
|                                         } | ||||
|                                     }, | ||||
|                                     function () { | ||||
|                                         showAlert(GetTextByKey('P_LAYOUT_FAILEDDELETE', 'Failed to delete this layout.'), GetTextByKey('P_LAYOUTS', 'Layouts')); | ||||
|                                     } | ||||
|                                 ); | ||||
|                             } | ||||
|                         ); | ||||
|                     } | ||||
|                 }, | ||||
|                 classFilter: function () { return 'icon-col' }, | ||||
|                 attrs: { | ||||
|                     title: GetTextByKey('P_WOS_DELETE', 'Delete') | ||||
|                 } | ||||
|             } | ||||
|         ]; | ||||
|         grid_dt.init(); | ||||
|         grid_dt.rowdblclick = layouts.onedit; | ||||
|  | ||||
|         grid_dt.selectedrowchanged = function (rowindex) { | ||||
|             layouts.ui.edit.prop('disabled', rowindex >= 0); | ||||
|         } | ||||
|         return div_grid; | ||||
|     } | ||||
|  | ||||
|     Object.defineProperty(layouts, 'createContent', { | ||||
|         value: function (isteam) { | ||||
|             layouts.isteam = isteam && isteam[0] == '1'; | ||||
|             var content = $('<div style="height:100%; display:flex; flex-direction:column"></div>'); | ||||
|             content.append(createHeader()); | ||||
|             content.append(InitGridData()); | ||||
|             content.append('<div style="height: 2px"></div>'); | ||||
|  | ||||
|             layouts.refresh(); | ||||
|             return content; | ||||
|         } | ||||
|     }); | ||||
|  | ||||
|     Object.defineProperty(layouts, 'refresh', { | ||||
|         value: function () { | ||||
|             layouts.changed = false; | ||||
|             showmaskbg(true); | ||||
|             inspectionrequest('GetInspectLayouts', encodeURIComponent( | ||||
|                 JSON.stringify([layouts.isteam ? 1 : 0, layouts.searchInput.val()]) | ||||
|             ), function (data) { | ||||
|                 if ($.isArray(data)) { | ||||
|                     layouts.grid.setData(data.map(function (i) { return { Values: i } })); | ||||
|                 } else { | ||||
|                     showAlert(data, GetTextByKey('P_LAYOUTS', 'Layouts')); | ||||
|                 } | ||||
|                 showmaskbg(false); | ||||
|             }, function () { | ||||
|                 showmaskbg(false); | ||||
|             }); | ||||
|         } | ||||
|     }); | ||||
|  | ||||
|     function appendToolbar(ele) { | ||||
|         ele.append( | ||||
|             $('<div class="editor-toolbar"></div>').append( | ||||
|                 $('<select data-edit="fontname"></select>').append( | ||||
|                     $('<option selected>- Font -</option>'), | ||||
|                     $('<option>Arial</option>'), | ||||
|                     $('<option>Arial Black</option>'), | ||||
|                     $('<option>Courier New</option>'), | ||||
|                     $('<option>Times New Roman</option>') | ||||
|                 ), | ||||
|                 $('<select data-edit="fontsize"></select>').append( | ||||
|                     $('<option selected>- Size -</option>'), | ||||
|                     $('<option value="1">Very small</option>'), | ||||
|                     $('<option value="2">A bit small</option>'), | ||||
|                     $('<option value="3">Normal</option>'), | ||||
|                     $('<option value="4">Medium-large</option>'), | ||||
|                     $('<option value="5">Big</option>'), | ||||
|                     $('<option value="6">Very big</option>'), | ||||
|                     $('<option value="7">Maximum</option>') | ||||
|                 ), | ||||
|                 $('<a data-edit="undo" title="Undo"><svg><use href="#symbol-undo"></use></svg></a>'), | ||||
|                 $('<a data-edit="redo" title="Redo"><svg><use href="#symbol-redo"></use></svg></a>'), | ||||
|                 $('<a data-edit="bold" title="Bold"><svg class="black"><use href="#symbol-bold"></use></svg></a>'), | ||||
|                 $('<a data-edit="italic" title="Italic"><svg class="black"><use href="#symbol-italic"></use></svg></a>'), | ||||
|                 $('<a data-edit="underline" title="Underline"><svg class="black"><use href="#symbol-underline"></use></svg></a>'), | ||||
|                 $('<a data-edit="createlink" title="Hyperlink"><svg><use href="#symbol-link"></use></svg></a>'), | ||||
|                 $('<select data-edit="forecolor" style="margin-left: 10px">').append( | ||||
|                     $('<option selected>- Color -</option>'), | ||||
|                     $('<option value="red">Red</option>'), | ||||
|                     $('<option value="blue">Blue</option>'), | ||||
|                     $('<option value="green">Green</option>'), | ||||
|                     $('<option value="black">Black</option>') | ||||
|                 ), | ||||
|                 $('<select data-edit>').append( | ||||
|                     $('<option selected>- Fields -</option>'), | ||||
|                     $('<option value="[Advisor]">Advisor</option>'), | ||||
|                     $('<option value="[Asset_Groups]">Asset Group(s)</option>'), | ||||
|                     $('<option value="[Asset_Name]">Asset Name</option>'), | ||||
|                     $('<option value="[Asset_Name_Custom]">Asset Name (Custom)</option>'), | ||||
|                     $('<option value="[Asset_Type]">Asset Type</option>'), | ||||
|                     $('<option value="[Creator]">Creator</option>'), | ||||
|                     $('<option value="[Current_Jobsite]">Current Jobsite</option>'), | ||||
|                     $('<option value="[Current_Location]">Current Location</option>'), | ||||
|                     $('<option value="[Customer_Visible]">Customer Visible</option>'), | ||||
|                     $('<option value="[Date_Performed]">Date Performed</option>'), | ||||
|                     $('<option value="[DateTime_Performed]">Date/Time Performed</option>'), | ||||
|                     $('<option value="[Engine_Hours]">Engine Hours</option>'), | ||||
|                     $('<option value="[Odometer]">Odometer</option>'), | ||||
|                     $('<option value="[Engine_Hours_Or_Odometer]">Engine Hours Or Odometer</option>'), | ||||
|                     $('<option value="[Make]">Make</option>'), | ||||
|                     $('<option value="[Model]">Model</option>'), | ||||
|                     $('<option value="[VIN]">VIN/SN</option>'), | ||||
|                     $('<option value="[Work_Order_Number]">Work Order Number</option>'), | ||||
|                     $('<option value="[Work_Order_Type]">Work Order Type</option>'), | ||||
|                     $('<option value="[Parts_Order_Number]">Parts Order Number</option>'), | ||||
|                     $('<option value="[Year]">Year</option>') | ||||
|                 ) | ||||
|             ) | ||||
|         ); | ||||
|         return ele; | ||||
|     } | ||||
|  | ||||
|     function initEditor(content, id) { | ||||
|         var textarea = $('<textarea class="editor-content"></textarea>'); | ||||
|         if (!layouts.isteam) { | ||||
|             var selector = $('<select class="editor-select"></select>').append( | ||||
|                 $('<option></option>'), | ||||
|                 $('<option value="[Advisor]">Advisor</option>'), | ||||
|                 $('<option value="[Asset_Groups]">Asset Group(s)</option>'), | ||||
|                 $('<option value="[Asset_Name]">Asset Name</option>'), | ||||
|                 $('<option value="[Asset_Name_Custom]">Asset Name (Custom)</option>'), | ||||
|                 $('<option value="[Asset_Type]">Asset Type</option>'), | ||||
|                 $('<option value="[Creator]">Creator</option>'), | ||||
|                 $('<option value="[Current_Jobsite]">Current Jobsite</option>'), | ||||
|                 $('<option value="[Current_Location]">Current Location</option>'), | ||||
|                 $('<option value="[Customer_Visible]">Customer Visible</option>'), | ||||
|                 $('<option value="[Date_Performed]">Date Performed</option>'), | ||||
|                 $('<option value="[DateTime_Performed]">Date/Time Performed</option>'), | ||||
|                 $('<option value="[Engine_Hours]">Engine Hours</option>'), | ||||
|                 $('<option value="[Odometer]">Odometer</option>'), | ||||
|                 $('<option value="[Engine_Hours_Or_Odometer]">Engine Hours Or Odometer</option>'), | ||||
|                 $('<option value="[Make]">Make</option>'), | ||||
|                 $('<option value="[Model]">Model</option>'), | ||||
|                 $('<option value="[VIN]">VIN/SN</option>'), | ||||
|                 $('<option value="[Work_Order_Number]">Work Order Number</option>'), | ||||
|                 $('<option value="[Work_Order_Type]">Work Order Type</option>'),  | ||||
|                 $('<option value="[Parts_Order_Number]">Parts Order Number</option>'), | ||||
|                 $('<option value="[Year]">Year</option>') | ||||
|             ); | ||||
|             if (typeof IsCustomerRecord !== 'undefined' && IsCustomerRecord) { | ||||
|                 selector.append( | ||||
|                     $('<option value="[Company_Name]">Company Name</option>'), | ||||
|                     $('<option value="[Contacts]">Contacts</option>'), | ||||
|                     $('<option value="[Customer_Code]">Customer Code</option>'), | ||||
|                     $('<option value="[Location]">Location</option>') | ||||
|                 ); | ||||
|             } | ||||
|             content.find(id + '-vars').append( | ||||
|                 $('<span></span>').text(GetTextByKey('P_LAYOUT_VARIABLE', 'Variable:')), | ||||
|                 selector.on('change', function () { | ||||
|                     var val = $(this).val(); | ||||
|                     var t = textarea[0]; | ||||
|                     if (document.selection) { | ||||
|                         textarea.focus(); | ||||
|                         var sel = document.selection.createRange(); | ||||
|                         sel.text = val; | ||||
|                         textarea.focus(); | ||||
|                     } else { | ||||
|                         if (t.selectionStart || t.selectionStart == 0) { | ||||
|                             var start = t.selectionStart; | ||||
|                             var end = t.selectionEnd; | ||||
|                             var scrollTop = t.scrollTop; | ||||
|                             t.value = t.value.substr(0, start) + val + t.value.substr(end, t.value.length); | ||||
|                             textarea.focus(); | ||||
|                             t.selectionStart = start + val.length; | ||||
|                             t.selectionEnd = start + val.length; | ||||
|                             t.scrollTop = scrollTop; | ||||
|                         } else { | ||||
|                             t.value += val; | ||||
|                             textarea.focus(); | ||||
|                         } | ||||
|                     } | ||||
|                     $(this).val(''); | ||||
|                 }) | ||||
|             ); | ||||
|         } | ||||
|         content.find(id).append(textarea); | ||||
|     } | ||||
|  | ||||
|     function editLayout(info) { | ||||
|         $('#right_popup').load('js/modules/layouts/addlayout.html?v=2', function () { | ||||
|             var modified = false; | ||||
|             var deleteIcon = false; | ||||
|             var content = $(this).applyFleetLanguageText(true); | ||||
|             content.find('.button-exit').on('click', function () { | ||||
|                 if (modified) { | ||||
|                     showConfirm( | ||||
|                         GetTextByKey('P_LAYOUT_CONFIRMSAVE', 'The inspection layout has been modified, are you sure you want to discard the modifications and exit?'), | ||||
|                         GetTextByKey('P_LAYOUT_EDITINSPECTLAYOUT', 'Edit Inspection Layout'), | ||||
|                         function () { | ||||
|                             showRightPopup(false); | ||||
|                             if (layouts.changed) { | ||||
|                                 layouts.refresh(); | ||||
|                             } | ||||
|                         } | ||||
|                     ); | ||||
|                 } else { | ||||
|                     showRightPopup(false); | ||||
|                     if (layouts.changed) { | ||||
|                         layouts.refresh(); | ||||
|                     } | ||||
|                 } | ||||
|             }); | ||||
|             content.find('.button-icon-upload').on('click', function () { | ||||
|                 content.find('.icon-file file').remove(); | ||||
|                 $('<input type="file" accept="image/png,image/jpeg" />') | ||||
|                     .hide().appendTo(content.find('.icon-file')) | ||||
|                     .on('change', function () { | ||||
|                         if (!/image\/\w+/.test(this.files[0].type)) { | ||||
|                             showAlert(GetTextByKey("P_LAYOUT_UPLOADICONTIPS", 'The file type for the logo is invalid. The file must be JPG or PNG.'), GetTextByKey('P_LAYOUT_SAVEINSPECTLAYOUT', 'Save Inspection Layout')); | ||||
|                             $(this).remove(); | ||||
|                             return; | ||||
|                         } | ||||
|                         var file = this.files[0]; | ||||
|                         var reader = new FileReader(); | ||||
|                         reader.readAsDataURL(file); | ||||
|                         reader.onload = function (e) { | ||||
|                             setTimeout(function () { | ||||
|                                 content.find('.img-icon-filename').remove(); | ||||
|                                 $('<img class="img-icon-filename" />').attr('src', e.target.result).insertAfter(content.find('.icon-file-title')); | ||||
|                             }); | ||||
|                         }; | ||||
|                     }).click(); | ||||
|             }); | ||||
|             content.find('.button-icon-delete').on('click', function () { | ||||
|                 deleteIcon = true; | ||||
|                 content.find('.img-icon-filename').remove(); | ||||
|             }); | ||||
|             var save = function (exit) { | ||||
|                 return function () { | ||||
|                     var title = GetTextByKey('P_LAYOUT_SAVEINSPECTLAYOUT', 'Save Inspection Layout'); | ||||
|                     var name = content.find('.text-layout-name').val(); | ||||
|                     name = name && name.trim(); | ||||
|                     if (name == null || name.length === 0) { | ||||
|                         showAlert( | ||||
|                             GetTextByKey('P_LAYOUT_NAMEISEQUIRED', 'Layout name is required.'), | ||||
|                             title, null, | ||||
|                             function () { content.find('.text-layout-name').focus() } | ||||
|                         ); | ||||
|                         return; | ||||
|                     } | ||||
|  | ||||
|                     var layout = { | ||||
|                         Id: info && info.Id, | ||||
|                         Target: layouts.isteam ? 1 : 0, | ||||
|                         Name: name, | ||||
|                         IncludeLOGO: content.find('#layout-include-logo').prop('checked'), | ||||
|                         Notes: content.find('.text-layout-notes').val(), | ||||
|                         PageHeaderLeft: content.find('.layout-headers-left .editor-content').val(), | ||||
|                         PageHeaderCenter: content.find('.layout-headers-middle .editor-content').val(), | ||||
|                         PageHeaderRight: content.find('.layout-headers-right .editor-content').val(), | ||||
|                         PageFooterLeft: content.find('.layout-footers-left .editor-content').val(), | ||||
|                         PageFooterCenter: content.find('.layout-footers-middle .editor-content').val(), | ||||
|                         PageFooterRight: content.find('.layout-footers-right .editor-content').val() | ||||
|                     }; | ||||
|                     var data = new FormData(); | ||||
|                     var files = content.find('.icon-file input[type="file"]').prop('files'); | ||||
|                     if (files && files[0]) { | ||||
|                         data.append('iconFile', files && files[0]); | ||||
|                     } else if (!deleteIcon) { | ||||
|                         var logo = content.find('.img-icon-filename').prop('src'); | ||||
|                         layout.LOGO = logo.substr(logo.indexOf(';base64,') + 8); | ||||
|                     } | ||||
|                     data.append('MethodName', 'SaveInspectLayout'); | ||||
|                     data.append('ClientData', encodeURIComponent(JSON.stringify(layout))); | ||||
|                     $.ajax({ | ||||
|                         url: window.location.href, | ||||
|                         type: 'POST', | ||||
|                         dataType: 'json', | ||||
|                         processData: false, | ||||
|                         contentType: false, | ||||
|                         data: data, | ||||
|                         success: function (data) { | ||||
|                             if ($.isArray(data)) { | ||||
|                                 if (data[1] !== 'Failed') { | ||||
|                                     if (exit) { | ||||
|                                         showRightPopup(false); | ||||
|                                         layouts.refresh(); | ||||
|                                         return; | ||||
|                                     } | ||||
|                                     if (info == null) { | ||||
|                                         info = layout; | ||||
|                                     } | ||||
|                                     info.Id = data[0]; | ||||
|                                     showAlert(data[1], title, null, function () { | ||||
|                                         layouts.changed = true; | ||||
|                                         modified = false; | ||||
|                                     }); | ||||
|                                 } else { | ||||
|                                     showAlert(GetTextByKey('P_MA_PAGEERROR', 'An unknown error occurred.  Please refresh page.'), title); | ||||
|                                 } | ||||
|                             } else { | ||||
|                                 showAlert(data, title); | ||||
|                             } | ||||
|                         }, | ||||
|                         error: function (err) { | ||||
|                             showAlert(GetTextByKey('P_MA_PAGEERROR', 'An unknown error occurred.  Please refresh page.'), title); | ||||
|                         } | ||||
|                     }); | ||||
|                 } | ||||
|             } | ||||
|             content.find('.button-save').on('click', save()); | ||||
|             content.find('.button-save-exit').on('click', save(true)); | ||||
|             showRightPopup(true); | ||||
|  | ||||
|             //new Editor(appendToolbar($(this).find('.layout-headers-left'))); | ||||
|             //new Editor(appendToolbar($(this).find('.layout-headers-middle'))); | ||||
|             //new Editor(appendToolbar($(this).find('.layout-headers-right'))); | ||||
|             //new Editor(appendToolbar($(this).find('.layout-footers-left'))); | ||||
|             //new Editor(appendToolbar($(this).find('.layout-footers-middle'))); | ||||
|             //new Editor(appendToolbar($(this).find('.layout-footers-right'))); | ||||
|             initEditor(content, '.layout-headers-left'); | ||||
|             initEditor(content, '.layout-headers-middle'); | ||||
|             initEditor(content, '.layout-headers-right'); | ||||
|             initEditor(content, '.layout-footers-left'); | ||||
|             initEditor(content, '.layout-footers-middle'); | ||||
|             initEditor(content, '.layout-footers-right'); | ||||
|  | ||||
|             var onchange = function () { modified = true }; | ||||
|             if (info != null) { | ||||
|                 content.find('.text-layout-name').val(info.Name); | ||||
|                 content.find('#layout-include-logo').prop('checked', info.IncludeLOGO); | ||||
|                 if (info.LOGO != null) { | ||||
|                     content.find('.img-icon-filename').attr('src', 'data:image/png;base64,' + info.LOGO); | ||||
|                 } | ||||
|                 content.find('.text-layout-notes').val(info.Notes); | ||||
|                 content.find('.layout-headers-left .editor-content').val(info.PageHeaderLeft); | ||||
|                 content.find('.layout-headers-middle .editor-content').val(info.PageHeaderCenter); | ||||
|                 content.find('.layout-headers-right .editor-content').val(info.PageHeaderRight); | ||||
|                 content.find('.layout-footers-left .editor-content').val(info.PageFooterLeft); | ||||
|                 content.find('.layout-footers-middle .editor-content').val(info.PageFooterCenter); | ||||
|                 content.find('.layout-footers-right .editor-content').val(info.PageFooterRight); | ||||
|             } | ||||
|             content.find('.text-layout-name').on('change', onchange); | ||||
|             content.find('#layout-include-logo').on('change', onchange); | ||||
|             content.find('.text-layout-notes').on('change', onchange); | ||||
|             content.find('.layout-headers-left .editor-content').on('change', onchange); | ||||
|             content.find('.layout-headers-middle .editor-content').on('change', onchange); | ||||
|             content.find('.layout-headers-right .editor-content').on('change', onchange); | ||||
|             content.find('.layout-footers-left .editor-content').on('change', onchange); | ||||
|             content.find('.layout-footers-middle .editor-content').on('change', onchange); | ||||
|             content.find('.layout-footers-right .editor-content').on('change', onchange); | ||||
|  | ||||
|             content.find('.text-layout-name').focus(); | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     Object.defineProperty(layouts, 'onadd', { | ||||
|         value: function () { | ||||
|             editLayout(); | ||||
|         } | ||||
|     }); | ||||
|  | ||||
|     function doedit(id) { | ||||
|         showmaskbg(true); | ||||
|         var p = [layouts.isteam ? 1 : 0, id]; | ||||
|         inspectionrequest('GetInspectLayout', JSON.stringify(p), function (data) { | ||||
|             editLayout(data); | ||||
|         }, function () { | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     Object.defineProperty(layouts, 'onedit', { | ||||
|         value: function () { | ||||
|             if (layouts.grid && layouts.grid.selectedIndex >= 0) { | ||||
|                 var id = layouts.grid.source[layouts.grid.selectedIndex].Values.Id; | ||||
|                 doedit(id); | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
|  | ||||
|     return layouts; | ||||
| }); | ||||
							
								
								
									
										91
									
								
								Site/Inspection/js/modules/layouts/addlayout.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								Site/Inspection/js/modules/layouts/addlayout.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,91 @@ | ||||
| <!DOCTYPE html> | ||||
| <html> | ||||
| <body> | ||||
|     <div> | ||||
|         <div class="function_title"> | ||||
|             <span class="sbutton iconsave button-save" data-lgid="P_IPT_SAVE">Save</span> | ||||
|             <span class="sbutton iconsave button-save-exit" data-lgid="P_IPT_SAVE1">Save and Exit</span> | ||||
|             <span class="sbutton iconexit button-exit" data-lgid="P_IPT_SAVE2">Exit Without Saving</span> | ||||
|         </div> | ||||
|         <div class="page_title" data-lgid="P_LAYOUT_GENERAL">General</div> | ||||
|         <div style="display: flex"> | ||||
|             <div class="settings-line"> | ||||
|                 <span> | ||||
|                     <span data-lgid="P_LAYOUT_NAMECOLON">Layout Name:</span> | ||||
|                     <b style="color: red">*</b> | ||||
|                     <input type="text" class="text-layout-name" maxlength="200" /> | ||||
|                 </span> | ||||
|                 <span> | ||||
|                     <label for="layout-include-logo" data-lgid="P_LAYOUT_INCLUDELOGO">Include Logo:</label> | ||||
|                     <input type="checkbox" id="layout-include-logo" /> | ||||
|                 </span> | ||||
|                 <span class="icon-file"> | ||||
|                     <span class="icon-file-title" data-lgid="P_LAYOUT_ICONFILENAME">Logo file:</span> | ||||
|                     <img class="img-icon-filename" /> | ||||
|                     <span class="svg-button button-icon-upload"><svg><use href="#symbol-upload"></use></svg></span> | ||||
|                     <span class="svg-button button-icon-delete"><svg><use href="#symbol-close"></use></svg></span> | ||||
|                 </span> | ||||
|             </div> | ||||
|             <div class="settings-line" style="flex: 1 1 auto"> | ||||
|                 <span style="display: flex"> | ||||
|                     <span data-lgid="P_LAYOUT_NOTESCOLON" style="vertical-align:top; white-space:nowrap">Notes:</span> | ||||
|                     <textarea class="text-layout-notes" style="height:100px; width:100%; box-sizing:border-box; margin-left:8px"></textarea> | ||||
|                 </span> | ||||
|             </div> | ||||
|         </div> | ||||
|  | ||||
|         <div class="page_title" data-lgid="P_IPT_FUELRPT_HEADER">Page Headers</div> | ||||
|         <div class="settings-line"> | ||||
|             <div class="editor-top"> | ||||
|                 <span data-lgid="P_IPT_FUELRPT_LEFT">Left</span> | ||||
|                 <div class="layout-headers-left-vars"></div> | ||||
|             </div> | ||||
|             <div class="layout-headers-left"></div> | ||||
|             <div class="editor-top"> | ||||
|                 <span data-lgid="P_IPT_FUELRPT_MIDDLE">Middle</span> | ||||
|                 <div class="layout-headers-middle-vars"></div> | ||||
|             </div> | ||||
|             <div class="layout-headers-middle"></div> | ||||
|             <div class="editor-top"> | ||||
|                 <span data-lgid="P_IPT_FUELRPT_RIGHT">Right</span> | ||||
|                 <div class="layout-headers-right-vars"></div> | ||||
|             </div> | ||||
|             <div class="layout-headers-right"></div> | ||||
|         </div> | ||||
|  | ||||
|         <div class="page_title" data-lgid="P_IPT_FUELRPT_FOOTER">Page Footers</div> | ||||
|         <div class="settings-line" style="padding-bottom: 20px"> | ||||
|             <div class="editor-top"> | ||||
|                 <span data-lgid="P_IPT_FUELRPT_LEFT">Left</span> | ||||
|                 <div class="layout-footers-left-vars"></div> | ||||
|             </div> | ||||
|             <div class="layout-footers-left"></div> | ||||
|             <div class="editor-top"> | ||||
|                 <span data-lgid="P_IPT_FUELRPT_MIDDLE">Middle</span> | ||||
|                 <div class="layout-footers-middle-vars"></div> | ||||
|             </div> | ||||
|             <div class="layout-footers-middle"></div> | ||||
|             <div class="editor-top"> | ||||
|                 <span data-lgid="P_IPT_FUELRPT_RIGHT">Right</span> | ||||
|                 <div class="layout-footers-right-vars"></div> | ||||
|             </div> | ||||
|             <div class="layout-footers-right"></div> | ||||
|         </div> | ||||
|  | ||||
|         <div id="svg-container" style="width: 0; height: 0; overflow: hidden"> | ||||
|             <svg> | ||||
|                 <defs> | ||||
|                     <symbol id="symbol-undo" role="presentation" focusable="false" xmlns:svg="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><g><path d="M212.333 224.333H12c-6.627 0-12-5.373-12-12V12C0 5.373 5.373 0 12 0h48c6.627 0 12 5.373 12 12v78.112C117.773 39.279 184.26 7.47 258.175 8.007c136.906.994 246.448 111.623 246.157 248.532C504.041 393.258 393.12 504 256.333 504c-64.089 0-122.496-24.313-166.51-64.215-5.099-4.622-5.334-12.554-.467-17.42l33.967-33.967c4.474-4.474 11.662-4.717 16.401-.525C170.76 415.336 211.58 432 256.333 432c97.268 0 176-78.716 176-176 0-97.267-78.716-176-176-176-58.496 0-110.28 28.476-142.274 72.333h98.274c6.627 0 12 5.373 12 12v48c0 6.627-5.373 12-12 12z" /></g></symbol> | ||||
|                     <symbol id="symbol-redo" role="presentation" focusable="false" xmlns:svg="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><g><path d="M500.33 0h-47.41a12 12 0 0 0-12 12.57l4 82.76A247.42 247.42 0 0 0 256 8C119.34 8 7.9 119.53 8 256.19 8.1 393.07 119.1 504 256 504a247.1 247.1 0 0 0 166.18-63.91 12 12 0 0 0 .48-17.43l-34-34a12 12 0 0 0-16.38-.55A176 176 0 1 1 402.1 157.8l-101.53-4.87a12 12 0 0 0-12.57 12v47.41a12 12 0 0 0 12 12h200.33a12 12 0 0 0 12-12V12a12 12 0 0 0-12-12z" /></g></symbol> | ||||
|                     <symbol id="symbol-bold" role="presentation" focusable="false" xmlns:svg="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><g><path d="M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z" /></g></symbol> | ||||
|                     <symbol id="symbol-italic" role="presentation" focusable="false" xmlns:svg="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><g><path d="M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z" /></g></symbol> | ||||
|                     <symbol id="symbol-underline" role="presentation" focusable="false" xmlns:svg="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><g><path d="M32 64h32v160c0 88.22 71.78 160 160 160s160-71.78 160-160V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H272a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h32v160a80 80 0 0 1-160 0V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H32a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16zm400 384H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z" /></g></symbol> | ||||
|                     <symbol id="symbol-link" role="presentation" focusable="false" xmlns:svg="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><g><path d="M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z" /></g></symbol> | ||||
|                     <symbol id="symbol-upload" role="presentation" focusable="false" xmlns:svg="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><g><path d="M452 432c0 11-9 20-20 20s-20-9-20-20 9-20 20-20 20 9 20 20zm-84-20c-11 0-20 9-20 20s9 20 20 20 20-9 20-20-9-20-20-20zm144-48v104c0 24.3-19.7 44-44 44H44c-24.3 0-44-19.7-44-44V364c0-24.3 19.7-44 44-44h124v-99.3h-52.7c-35.6 0-53.4-43.1-28.3-68.3L227.7 11.7c15.6-15.6 40.9-15.6 56.6 0L425 152.4c25.2 25.2 7.3 68.3-28.3 68.3H344V320h124c24.3 0 44 19.7 44 44zM200 188.7V376c0 4.4 3.6 8 8 8h96c4.4 0 8-3.6 8-8V188.7h84.7c7.1 0 10.7-8.6 5.7-13.7L261.7 34.3c-3.1-3.1-8.2-3.1-11.3 0L109.7 175c-5 5-1.5 13.7 5.7 13.7H200zM480 364c0-6.6-5.4-12-12-12H344v24c0 22.1-17.9 40-40 40h-96c-22.1 0-40-17.9-40-40v-24H44c-6.6 0-12 5.4-12 12v104c0 6.6 5.4 12 12 12h424c6.6 0 12-5.4 12-12V364z" /></g></symbol> | ||||
|                     <symbol id="symbol-close" role="presentation" focusable="false" xmlns:svg="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><g><path d="M193.94 256L296.5 153.44l21.15-21.15c3.12-3.12 3.12-8.19 0-11.31l-22.63-22.63c-3.12-3.12-8.19-3.12-11.31 0L160 222.06 36.29 98.34c-3.12-3.12-8.19-3.12-11.31 0L2.34 120.97c-3.12 3.12-3.12 8.19 0 11.31L126.06 256 2.34 379.71c-3.12 3.12-3.12 8.19 0 11.31l22.63 22.63c3.12 3.12 8.19 3.12 11.31 0L160 289.94 262.56 392.5l21.15 21.15c3.12 3.12 8.19 3.12 11.31 0l22.63-22.63c3.12-3.12 3.12-8.19 0-11.31L193.94 256z" /></g></symbol> | ||||
|                 </defs> | ||||
|             </svg> | ||||
|         </div> | ||||
|     </div> | ||||
| </body> | ||||
| </html> | ||||
							
								
								
									
										72
									
								
								Site/Inspection/js/modules/pageloader.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								Site/Inspection/js/modules/pageloader.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,72 @@ | ||||
| /* | ||||
|  module - | ||||
|    description: 模块描述 | ||||
|    version: 模块版本 | ||||
|    createContent: 产生模块正文 | ||||
|  */ | ||||
|  | ||||
| define(function () { | ||||
|     var _loader = { | ||||
|         links: '', | ||||
|         content: '', | ||||
|         init: function () { | ||||
|             $(function () { | ||||
|                 $(window).on('hashchange', function (e) { | ||||
|                     var hash = location.hash; | ||||
|                     if (hash == null || hash.length <= 1) { | ||||
|                         $(_loader.links).filter('[data-module]').removeClass('selected'); | ||||
|                         $(_loader.content).empty(); | ||||
|                         return; | ||||
|                     } | ||||
|                     hash = hash.substring(1); | ||||
|                     _loader.jump(hash); | ||||
|                 }); | ||||
|  | ||||
|                 // page loaded | ||||
|                 var hash = location.hash; | ||||
|                 if (hash != null && hash.length > 1) { | ||||
|                     hash = hash.substring(1); | ||||
|                     //$(_loader.links).filter('[data-module="' + hash + '"]').addClass('selected'); | ||||
|                     _loader.jump(hash); | ||||
|                 } | ||||
|                 else { | ||||
|                     //$(_loader.links).first().addClass('selected'); | ||||
|                     hash = $(_loader.links).filter('[data-module]').first().addClass('selected').attr("data-module"); | ||||
|                     _loader.jump(hash); | ||||
|                 } | ||||
|  | ||||
|                 //var links = $(_loader.links).filter('[data-module]'); | ||||
|                 //links.click(function (e) { | ||||
|                 //    // load module | ||||
|                 //    var module = $(e.target).data('module'); | ||||
|                 //    location.hash = module; | ||||
|                 //}); | ||||
|             }); | ||||
|         }, | ||||
|         jump: function (hash) { | ||||
|             var module = null; | ||||
|             var ps = undefined; | ||||
|             if (hash && hash.indexOf('/') > 0) { | ||||
|                 ps = hash.split('/'); | ||||
|                 module = ps[0]; | ||||
|                 ps.splice(0, 1); | ||||
|             } | ||||
|             else | ||||
|                 module = hash; | ||||
|  | ||||
|             if (module) { | ||||
|                 $(_loader.links).filter('[data-module]').removeClass('selected'); | ||||
|                 $(_loader.links).filter('[data-module="' + hash + '"]').addClass('selected'); | ||||
|                 require(['modules/' + module], function (m) { | ||||
|                     $(_loader.content).empty().append(m.createContent(ps)); | ||||
|                 }); | ||||
|             } | ||||
|             //else { | ||||
|             //    require(['modules/' + module], function (m) { | ||||
|             //        $(_loader.content).empty().append(m.createContent()); | ||||
|             //    }); | ||||
|             //} | ||||
|         } | ||||
|     }; | ||||
|     return _loader; | ||||
| }); | ||||
							
								
								
									
										508
									
								
								Site/Inspection/js/modules/sections/addquestion.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										508
									
								
								Site/Inspection/js/modules/sections/addquestion.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,508 @@ | ||||
| define(['common'], function (Common) { | ||||
|  | ||||
|     var aq = function (p, sectionid, question) { | ||||
|         this.sectionid = sectionid; | ||||
|         this.question = question; | ||||
|         this.holder = null; | ||||
|         this.sectionmodule = p; | ||||
|         this.datasaved = false; | ||||
|     }; | ||||
|     aq.prototype.description = "Add or edit question"; | ||||
|     aq.prototype.version = "1.0.0.0"; | ||||
|     aq.prototype.onsave = null; | ||||
|  | ||||
|     var namecontrol = undefined; | ||||
|     var questiontypecontrol = undefined; | ||||
|     var isrequiredcontrol = undefined; | ||||
|     var cancommentcontrol = undefined; | ||||
|     var severitylevelcontrol = undefined; | ||||
|     var isimportantcontrol = undefined; | ||||
|     var displaytextcontrol = undefined; | ||||
|     var notescontrol = undefined; | ||||
|     var optiontr = undefined; | ||||
|     var optiontd = undefined; | ||||
|     var options = []; | ||||
|     var questiontype = undefined; | ||||
|     aq.prototype.createContent = function () { | ||||
|         options = []; | ||||
|         var _this = this; | ||||
|         var content = $('<div></div>'); | ||||
|  | ||||
|         function createHeader() { | ||||
|             var header = $('<div></div>'); | ||||
|  | ||||
|             var funcs = $('<div class="function_title"></div>'); | ||||
|             if (sectiontype == 0) { | ||||
|                 var btn = $('<span class="sbutton iconsave">' + GetTextByKey("P_IPT_SAVE", "Save") + '</span>').click(function () { | ||||
|                     saveData(0); | ||||
|                 }); | ||||
|                 funcs.append(btn); | ||||
|                 btn = $('<span class="sbutton iconsave">' + GetTextByKey("P_IPT_SAVE1", "Save and Exit") + '</span>').click(function () { | ||||
|                     saveData(1); | ||||
|                 }); | ||||
|                 funcs.append(btn); | ||||
|                 btn = $('<span class="sbutton iconexit">' + GetTextByKey("P_IPT_SAVE2", "Exit Without Saving") + '</span>').click(function () { | ||||
|                     showRightPopup(false); | ||||
|                     if (_this.datasaved) | ||||
|                         _this.sectionmodule.refresh(); | ||||
|                 }); | ||||
|                 funcs.append(btn); | ||||
|             } | ||||
|             else { | ||||
|                 header.append($('<div class="function_title" style="background-color:#ddd;font-size:16px;"></div>').text(_this.question ? GetTextByKey("P_IPT_EDITQUESTION", 'Edit Question') : GetTextByKey("P_IPT_ADDQUESTION", 'Add Question'))); | ||||
|                 if (!templatereadonly && (!_this.question || (_this.question && !_this.question.IsLink))) { | ||||
|                     //if (!_this.question || (_this.question && !_this.question.IsLink)) { | ||||
|                     var btn = $('<span class="sbutton iconsave">' + GetTextByKey("P_IPT_OK", "OK") + '</span>').click(function () { | ||||
|                         var item = getData(); | ||||
|                         if (!item) | ||||
|                             return; | ||||
|                         if (_this.onsave) | ||||
|                             _this.onsave(item); | ||||
|                         $('#right_popup1').empty().hide(); | ||||
|                     }); | ||||
|                     funcs.append(btn); | ||||
|                 } | ||||
|                 btn = $('<span class="sbutton iconexit">' + GetTextByKey("P_IPT_CANCEL", "Cancel") + '</span>').click(function () { | ||||
|                     $('#right_popup1').empty().hide(); | ||||
|                 }); | ||||
|                 funcs.append(btn); | ||||
|             } | ||||
|             header.append(funcs) | ||||
|  | ||||
|             return header; | ||||
|         } | ||||
|  | ||||
|         function createQuestionContent() { | ||||
|             var div_main = $('<div class="content_main" style="overflow: auto;"></div>'); | ||||
|             var div_content = $('<div class="edit-content"></div>'); | ||||
|             div_main.append(div_content); | ||||
|             var tb = $('<table style="line-height: 35px;"></table>'); | ||||
|             div_content.append(tb); | ||||
|  | ||||
|             var tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label">' + GetTextByKey("P_IPT_NAME_COLON", "Name:") + '<span class="redasterisk">*</span></td>'); | ||||
|             namecontrol = $('<input type="text" maxlength="100"/>'); | ||||
|             var addiText = $('<span class="spanbtn iconmultitext" style="font-size:14px;" title="' + GetTextByKey("P_IPT_ADDITIONALTEXTS", "Additional Texts") + '"/>'); | ||||
|             addiText.click(function () { | ||||
|                 Common.createMultiTextDialog(namecontrol, _this.question); | ||||
|             }); | ||||
|             tr.append($('<td></td>').append(namecontrol).append(addiText)); | ||||
|  | ||||
|             tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label">' + GetTextByKey("P_IPT_DISPLAYTEXT_COLON", "Display Text:") + '<span  class="redasterisk">*</span></td>'); | ||||
|             displaytextcontrol = $('<input type="text" maxlength="1000" />'); | ||||
|             addiText = $('<span class="spanbtn iconmultitext" style="font-size:14px;" title="' + GetTextByKey("P_IPT_ADDITIONALTEXTS", "Additional Texts") + '"/>'); | ||||
|             addiText.click(function () { | ||||
|                 Common.createMultiTextDialog(displaytextcontrol, _this.question); | ||||
|             }); | ||||
|             tr.append($('<td></td>').append(displaytextcontrol).append(addiText)); | ||||
|  | ||||
|             tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label">Type:</td>'); | ||||
|             questiontypecontrol = createQuestionType(); | ||||
|             questiontypecontrol.change(function () { | ||||
|                 questionTypeChange(); | ||||
|             }); | ||||
|             tr.append($('<td></td>').append(questiontypecontrol)); | ||||
|  | ||||
|             optiontr = $('<tr style="display:none;"></tr>'); | ||||
|             tb.append(optiontr); | ||||
|             optiontr.append('<td class="label"></td>'); | ||||
|             var btn_additem = $('<span class="sbutton iconadd">Add</span>').click(function () { | ||||
|                 addOption(); | ||||
|             }); | ||||
|             optiontd = $('<td></td>').append(btn_additem); | ||||
|             optiontr.append(optiontd); | ||||
|  | ||||
|             tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label" style="vertical-align:inherit;">Is Required:</td>'); | ||||
|             var table = $('<table></table>'); | ||||
|             tr.append($('<td></td>').append(table)); | ||||
|  | ||||
|             tr = $('<tr></tr>'); | ||||
|             table.append(tr); | ||||
|             isrequiredcontrol = $('<input type="checkbox"/>'); | ||||
|             tr.append($('<td style="width:75px;"></td>').append(isrequiredcontrol)); | ||||
|             cancommentcontrol = $('<input type="checkbox" style="margin-left:10px;"  />'); | ||||
|             tr.append($('<td style="width:155px;"><label style="">Can Comment:</label></td>').append(cancommentcontrol)); | ||||
|             isimportantcontrol = $('<input type="checkbox" style="margin-left:10px;" />'); | ||||
|             tr.append($('<td><label>Is Important:</label></td>').append(isimportantcontrol)); | ||||
|  | ||||
|             tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label">Severity Level:</td>') | ||||
|             severitylevelcontrol = createSeverityLevel(); | ||||
|             tr.append($('<td></td>').append(severitylevelcontrol)); | ||||
|  | ||||
|             tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label">Notes:</td>'); | ||||
|             notescontrol = $('<textarea id="dialog_notes" class="inputbox" maxlength="1000" style="width: 400px; margin-top: 6px;"></textarea>'); | ||||
|             tr.append($('<td></td>').append(notescontrol)); | ||||
|  | ||||
|             return div_main; | ||||
|         } | ||||
|  | ||||
|         var option = function (op) { | ||||
|             this.option = op; | ||||
|             this.dialog_text = null; | ||||
|             this.dialog_bgcolor = null; | ||||
|             this.dialog_severitylevel = null; | ||||
|             this.holder = null; | ||||
|             this.removable = true; | ||||
|             if (op) { | ||||
|                 if (op.removable == false) | ||||
|                     this.removable = false; | ||||
|                 else | ||||
|                     this.removable = true; | ||||
|             } | ||||
|         }; | ||||
|  | ||||
|         option.prototype.getContentValue = function () { | ||||
|             var option = this.option || {}; | ||||
|             option.Text = this.dialog_text.val(); | ||||
|             var texts = this.dialog_text.data("texts"); | ||||
|             if (texts) { | ||||
|                 option.LocalTexts = texts; | ||||
|             } | ||||
|             option.BackgroundColor = this.dialog_bgcolor.val(); | ||||
|             option.SeverityLevel = this.dialog_severitylevel.val(); | ||||
|             return option; | ||||
|         } | ||||
|  | ||||
|         option.prototype.removeOption = function () { | ||||
|             this.holder.remove(); | ||||
|             options.splice(options.indexOf(this), 1); | ||||
|         } | ||||
|  | ||||
|         option.prototype.createContent = function () { | ||||
|             var _thisop = this; | ||||
|             var tb = $('<table style="border: 1px solid #a8a8a8; width:700px;margin-top:2px;"></table>'); | ||||
|             this.holder = tb; | ||||
|             var tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             var optext = $('<input type="text" style="width:240px;margin-left:5px;"/>'); | ||||
|             this.dialog_text = optext; | ||||
|             var addiText = $('<span class="spanbtn iconmultitext" style="font-size:14px;" title="' + GetTextByKey("P_IPT_ADDITIONALTEXTS", "Additional Texts") + '"/>'); | ||||
|             addiText.click(function () { | ||||
|                 Common.createMultiTextDialog(optext, _this.question); | ||||
|             }); | ||||
|             tr.append($('<td style="width:295px;"><span class="redasterisk">*</span></td>').append(this.dialog_text).append(addiText)); | ||||
|  | ||||
|             td = $('<td style="width:76px;"></td>'); | ||||
|             tr.append(td); | ||||
|             td.append($('<label>' + GetTextByKey("P_IPT_SEVERITYLEVEL", "Severity Level") + '</label>')); | ||||
|             this.dialog_severitylevel = createSeverityLevel(); | ||||
|             this.dialog_severitylevel.css('width', 100); | ||||
|             tr.append($('<td></td>').append(this.dialog_severitylevel)); | ||||
|             var bg_label = $('<label>' + GetTextByKey("P_IPT_BACKGROUNDCOLOR", "Background Color") + '</label>'); | ||||
|             td = $('<td style="width:100px;"></td>').append(bg_label); | ||||
|             tr.append(td); | ||||
|             this.dialog_bgcolor = $('<input style="width:100px;"/>'); | ||||
|             var bgcolor = $('<div></div>') | ||||
|             bgcolor.append(this.dialog_bgcolor); | ||||
|             td = $('<td></td>').append(bgcolor); | ||||
|             tr.append(td); | ||||
|             initColorCtrl(this.dialog_bgcolor); | ||||
|  | ||||
|             td = $('<td></td>'); | ||||
|             tr.append(td); | ||||
|             if (_thisop.removable) { | ||||
|                 var deleteoptionbtn = $('<em class="spanbtn icondelete"></em>'); | ||||
|                 td.append(deleteoptionbtn.click(function () { | ||||
|                     _thisop.removeOption(); | ||||
|                 })); | ||||
|             } | ||||
|  | ||||
|             if (questiontype === "5") { | ||||
|                 this.dialog_text.attr('disabled', 'disabled'); | ||||
|             } | ||||
|             //else if (questiontype === "8") { | ||||
|             //    bg_label.hide(); | ||||
|             //    bgcolor.hide(); | ||||
|             //    tb.css('width', 324); | ||||
|             //} | ||||
|  | ||||
|  | ||||
|             function updateOptionContent() { | ||||
|                 var op = _thisop.option; | ||||
|                 if (op) { | ||||
|                     _thisop.dialog_text.val(op.Text).data("texts", op.LocalTexts); | ||||
|                     _thisop.dialog_bgcolor.spectrum("set", op.BackgroundColor); | ||||
|                     _thisop.dialog_severitylevel.val(op.SeverityLevel); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             updateOptionContent(); | ||||
|             return tb; | ||||
|         } | ||||
|  | ||||
|         function updateContent() { | ||||
|             var question = _this.question; | ||||
|             if (question) { | ||||
|                 namecontrol.val(question.Name).data("texts", question.LocalNames); | ||||
|                 displaytextcontrol.val(question.DisplayText).data("texts", question.LocalDisplayTexts); | ||||
|                 questiontypecontrol.val(question.QuestionType); | ||||
|                 questionTypeChange(); | ||||
|                 isrequiredcontrol.attr('checked', question.IsRequired); | ||||
|                 cancommentcontrol.attr('checked', question.CanComment); | ||||
|                 isimportantcontrol.attr('checked', question.IsImportant); | ||||
|                 severitylevelcontrol.val(question.SeverityLevel); | ||||
|                 notescontrol.val(question.Notes); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function setDisabled() { | ||||
|             namecontrol.prop('disabled', true); | ||||
|             displaytextcontrol.prop('disabled', true); | ||||
|             questiontypecontrol.prop('disabled', true); | ||||
|             isrequiredcontrol.prop('disabled', true); | ||||
|             cancommentcontrol.prop('disabled', true); | ||||
|             isimportantcontrol.prop('disabled', true); | ||||
|             severitylevelcontrol.prop('disabled', true); | ||||
|             notescontrol.prop('disabled', true); | ||||
|         } | ||||
|  | ||||
|         function questionTypeChange() { | ||||
|             options = []; | ||||
|             optiontd.find('table').remove(); | ||||
|             var type = questiontypecontrol.val(); | ||||
|             questiontype = type; | ||||
|             if (['5', '8', '9'].indexOf(type) >= 0) { | ||||
|                 optiontr.show(); | ||||
|  | ||||
|                 if (type === "5") { | ||||
|                     var ynops = [{ 'Text': GetTextByKey("P_IPT_YES", 'Yes'), 'BackgroundColor': '#0F0', 'Value': 'Yes', 'SeverityLevel': 0 }, { 'Text': GetTextByKey("P_IPT_NO", 'No'), 'BackgroundColor': '#F00', 'Value': 'No', 'SeverityLevel': 0 }]; | ||||
|                     for (var i = 0; i < ynops.length; i++) { | ||||
|                         var op = ynops[i]; if (_this.question) { | ||||
|                             if (i < _this.question.SelectItems.length) { | ||||
|                                 op.BackgroundColor = _this.question.SelectItems[i].BackgroundColor; | ||||
|                                 op.SeverityLevel = _this.question.SelectItems[i].SeverityLevel; | ||||
|                                 op.LocalTexts = _this.question.SelectItems[i].LocalTexts; | ||||
|                             } | ||||
|                         } | ||||
|                         op.removable = false; | ||||
|                         addOption(op); | ||||
|                     } | ||||
|                     optiontr.find('.sbutton').hide(); | ||||
|                 } | ||||
|                 else { | ||||
|                     optiontr.find('.sbutton').show(); | ||||
|                     if (_this.question) { | ||||
|                         for (var i = 0; i < _this.question.SelectItems.length; i++) { | ||||
|                             addOption(_this.question.SelectItems[i]); | ||||
|                         } | ||||
|                     } | ||||
|                     else | ||||
|                         addOption(); | ||||
|                 } | ||||
|             } | ||||
|             else { | ||||
|                 optiontr.hide(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function addOption(item) { | ||||
|             var op = new option(item); | ||||
|             var tb = op.createContent(); | ||||
|             options.push(op); | ||||
|             optiontd.append(tb); | ||||
|         } | ||||
|  | ||||
|         function getData() { | ||||
|             var item = { | ||||
|                 'Name': namecontrol.val(), | ||||
|                 'QuestionType': questiontypecontrol.val(), | ||||
|                 'IsRequired': isrequiredcontrol.prop('checked'), | ||||
|                 'CanComment': cancommentcontrol.prop('checked'), | ||||
|                 'IsImportant': isimportantcontrol.prop('checked'), | ||||
|                 'SeverityLevel': severitylevelcontrol.val(), | ||||
|                 'DisplayText': displaytextcontrol.val(), | ||||
|                 'Notes': notescontrol.val() | ||||
|             }; | ||||
|  | ||||
|             var alerttitle; | ||||
|             if (_this.question) { | ||||
|                 item.Id = _this.question.Id; | ||||
|                 alerttitle = GetTextByKey("P_IPT_EDITQUESTION", "Edit Question"); | ||||
|             } else { | ||||
|                 alerttitle = GetTextByKey("P_IPT_ADDQUESTION", "Add Question"); | ||||
|             } | ||||
|  | ||||
|             var texts = namecontrol.data("texts"); | ||||
|             if (texts) { | ||||
|                 item.LocalNames = texts; | ||||
|             } | ||||
|             texts = displaytextcontrol.data("texts"); | ||||
|             if (texts) { | ||||
|                 item.LocalDisplayTexts = texts; | ||||
|             } | ||||
|  | ||||
|             item.SelectItems = []; | ||||
|             if (options.length > 0) { | ||||
|                 for (var i = 0; i < options.length; i++) { | ||||
|                     var selectitem = options[i].getContentValue(); | ||||
|                     if (!selectitem.Text || selectitem.Text.length == 0) { | ||||
|                         showAlert(GetTextByKey("P_IPT_OPTIONNAMECANNOTBEEMPTY", 'Option name cannot be empty.'), alerttitle); | ||||
|                         return false; | ||||
|                     } | ||||
|                     item.SelectItems.push(selectitem) | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             if (!item.Name || item.Name.length == 0) { | ||||
|                 showAlert(GetTextByKey("P_IPT_NAMENOTBEEMPTY", 'Name cannot be empty.'), alerttitle); | ||||
|                 return false; | ||||
|             } | ||||
|             if (!item.DisplayText || item.DisplayText.length == 0) { | ||||
|                 showAlert(GetTextByKey("P_IPT_DISPLAYTEXTNOTBEEMPTY", 'Display Text cannot be empty.'), alerttitle); | ||||
|                 return false; | ||||
|             } | ||||
|             if ((item.QuestionType === "8" || item.QuestionType === "9") && item.SelectItems.length == 0) { | ||||
|                 showAlert(GetTextByKey("P_IPT_THEREMUSTBEATLEASTONECHOICE", 'There must be at least one choice.'), alerttitle); | ||||
|                 return false; | ||||
|             } | ||||
|  | ||||
|             return item; | ||||
|         } | ||||
|  | ||||
|         saveData = function (exit) { | ||||
|             var item = getData(); | ||||
|             if (!item) return; | ||||
|  | ||||
|             var param = htmlencode(JSON.stringify(item)); | ||||
|             param = JSON.stringify([teamintelligence, _this.sectionid, param]); | ||||
|  | ||||
|             inspectionrequest("SaveGlobalQuestion", param, function (data) { | ||||
|                 if (typeof (data) === "string") { | ||||
|                     showAlert(data, GetTextByKey("P_IPT_SAVEQUESTION", 'Save Question')); | ||||
|                 } else { | ||||
|                     if (!_this.question) { | ||||
|                         _this.question = { 'Id': data[0] }; | ||||
|                     } | ||||
|                     if (exit == 0) { | ||||
|                         _this.datasaved = true; | ||||
|                         showAlert(GetTextByKey("P_IPT_SAVSUCCESSFULLY", 'Saved successfully.'), GetTextByKey("P_IPT_SAVEQUESTION", 'Save Question')); | ||||
|                     } | ||||
|                     if (exit == 1) { | ||||
|                         _this.sectionmodule.refresh(); | ||||
|                         showRightPopup(false); | ||||
|                     } | ||||
|                 } | ||||
|             }, function (err) { | ||||
|                 showAlert(GetTextByKey("P_IPT_FAILEDTOSAVEQUESTION", 'Failed to save question.'), GetTextByKey("P_IPT_SAVEQUESTION", 'Save Question')); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         content.append(createHeader()); | ||||
|         content.append(createQuestionContent()); | ||||
|         updateContent(); | ||||
|         if (templatereadonly) | ||||
|             setDisabled(); | ||||
|         return content; | ||||
|     } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|     function initColorCtrl(ipt_color) { | ||||
|         ipt_color.spectrum({ | ||||
|             allowEmpty: true, | ||||
|             color: "#FFF", | ||||
|             showInput: true, | ||||
|             containerClassName: "full-spectrum", | ||||
|             showInitial: true, | ||||
|             showPalette: true, | ||||
|             showSelectionPalette: true, | ||||
|             showAlpha: true, | ||||
|             maxPaletteSize: 10, | ||||
|             preferredFormat: "hex", | ||||
|             localStorageKey: "spectrum.demo", | ||||
|             chooseText: GetTextByKey("P_IPT_OK", "OK"), | ||||
|             cancelText: GetTextByKey("P_IPT_CANCEL", "Cancel"), | ||||
|             clearText: GetTextByKey("P_SPECTRUM_CLEARCOLORSELECTION", "Clear Color Selection"), | ||||
|             noColorSelectedText: GetTextByKey("P_SPECTRUM_NOCOLORSELECTED", "No Color Selected"), | ||||
|             move: function (color) { | ||||
|                 if (color) | ||||
|                     ipt_color.val(color.toHexString().toUpperCase()); // #ff0000 | ||||
|             }, | ||||
|             show: function () { | ||||
|  | ||||
|             }, | ||||
|             beforeShow: function () { | ||||
|  | ||||
|             }, | ||||
|             hide: function (color) { | ||||
|                 if (color) { | ||||
|                     ipt_color.val(color.toHexString().toUpperCase()); // #ff0000 | ||||
|                 } | ||||
|             }, | ||||
|  | ||||
|             palette: [ | ||||
|                 ["rgb(0, 0, 0)", "rgb(67, 67, 67)", "rgb(102, 102, 102)", /*"rgb(153, 153, 153)","rgb(183, 183, 183)",*/ | ||||
|                     "rgb(204, 204, 204)", "rgb(217, 217, 217)", /*"rgb(239, 239, 239)", "rgb(243, 243, 243)",*/ "rgb(255, 255, 255)"], | ||||
|                 ["rgb(152, 0, 0)", "rgb(255, 0, 0)", "rgb(255, 153, 0)", "rgb(255, 255, 0)", "rgb(0, 255, 0)", | ||||
|                     "rgb(0, 255, 255)", "rgb(74, 134, 232)", "rgb(0, 0, 255)", "rgb(153, 0, 255)", "rgb(255, 0, 255)"], | ||||
|                 ["rgb(230, 184, 175)", "rgb(244, 204, 204)", "rgb(252, 229, 205)", "rgb(255, 242, 204)", "rgb(217, 234, 211)", | ||||
|                     "rgb(208, 224, 227)", "rgb(201, 218, 248)", "rgb(207, 226, 243)", "rgb(217, 210, 233)", "rgb(234, 209, 220)", | ||||
|                     "rgb(221, 126, 107)", "rgb(234, 153, 153)", "rgb(249, 203, 156)", "rgb(255, 229, 153)", "rgb(182, 215, 168)", | ||||
|                     "rgb(162, 196, 201)", "rgb(164, 194, 244)", "rgb(159, 197, 232)", "rgb(180, 167, 214)", "rgb(213, 166, 189)", | ||||
|                     "rgb(204, 65, 37)", "rgb(224, 102, 102)", "rgb(246, 178, 107)", "rgb(255, 217, 102)", "rgb(147, 196, 125)", | ||||
|                     "rgb(118, 165, 175)", "rgb(109, 158, 235)", "rgb(111, 168, 220)", "rgb(142, 124, 195)", "rgb(194, 123, 160)", | ||||
|                     "rgb(166, 28, 0)", "rgb(204, 0, 0)", "rgb(230, 145, 56)", "rgb(241, 194, 50)", "rgb(106, 168, 79)", | ||||
|                     "rgb(69, 129, 142)", "rgb(60, 120, 216)", "rgb(61, 133, 198)", "rgb(103, 78, 167)", "rgb(166, 77, 121)", | ||||
|                     /*"rgb(133, 32, 12)", "rgb(153, 0, 0)", "rgb(180, 95, 6)", "rgb(191, 144, 0)", "rgb(56, 118, 29)", | ||||
|                     "rgb(19, 79, 92)", "rgb(17, 85, 204)", "rgb(11, 83, 148)", "rgb(53, 28, 117)", "rgb(116, 27, 71)",*/ | ||||
|                     "rgb(91, 15, 0)", "rgb(102, 0, 0)", "rgb(120, 63, 4)", "rgb(127, 96, 0)", "rgb(39, 78, 19)", | ||||
|                     "rgb(12, 52, 61)", "rgb(28, 69, 135)", "rgb(7, 55, 99)", "rgb(32, 18, 77)", "rgb(76, 17, 48)"] | ||||
|             ] | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     function createQuestionType() { | ||||
|         var items = []; | ||||
|         items.push({ 'Key': 0, "Value": "Single Line Text" }); | ||||
|         items.push({ 'Key': 1, "Value": "Multiple Line Text" }); | ||||
|         items.push({ 'Key': 2, "Value": "Email (Manual)" }); | ||||
|         items.push({ 'Key': 14, "Value": "Email (Drop Down)" }); | ||||
|         items.push({ 'Key': 3, "Value": "Number" }); | ||||
|         items.push({ 'Key': 4, "Value": "Integer" }); | ||||
|         items.push({ 'Key': 5, "Value": "Yes Or No" }); | ||||
|         items.push({ 'Key': 6, "Value": "Date" }); | ||||
|         items.push({ 'Key': 7, "Value": "Date And Time" }); | ||||
|         items.push({ 'Key': 8, "Value": "Drop Down" }); | ||||
|         items.push({ 'Key': 9, "Value": "List" }); | ||||
|         items.push({ 'Key': 10, "Value": "Picture" }); | ||||
|         if (!teamintelligence) { | ||||
|             items.push({ 'Key': 11, "Value": "Odometer" }); | ||||
|             items.push({ 'Key': 12, "Value": "Engine Hours" }); | ||||
|             items.push({ 'Key': 13, "Value": "Fuel Remaining" }); | ||||
|         } | ||||
|         var sel = $('<select style="width:324px; height:22px;"></select>'); | ||||
|         for (var i = 0; i < items.length; i++) { | ||||
|             var item = items[i]; | ||||
|             sel.append('<option value="' + item.Key + '">' + item.Value + '</option>'); | ||||
|         } | ||||
|         return sel; | ||||
|     } | ||||
|  | ||||
|     function createSeverityLevel() { | ||||
|         var items = []; | ||||
|         items.push({ 'Key': 0, "Value": "None" }); | ||||
|         items.push({ 'Key': 1, "Value": "Low" }); | ||||
|         items.push({ 'Key': 2, "Value": "Medium" }); | ||||
|         items.push({ 'Key': 3, "Value": "High" }); | ||||
|         var sel = $('<select style="width:324px;height:22px;"></select>'); | ||||
|         for (var i = 0; i < items.length; i++) { | ||||
|             var item = items[i]; | ||||
|             sel.append('<option value="' + item.Key + '">' + item.Value + '</option>'); | ||||
|         } | ||||
|         return sel; | ||||
|     } | ||||
|  | ||||
|     return aq; | ||||
| }); | ||||
							
								
								
									
										186
									
								
								Site/Inspection/js/modules/sections/addsection.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										186
									
								
								Site/Inspection/js/modules/sections/addsection.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,186 @@ | ||||
| define(['common'], function (Common) { | ||||
|     var s = function (gs, section) { | ||||
|         this.section = section; | ||||
|         this.dialog = null; | ||||
|         this.gsmodule = gs; | ||||
|         this.datasaved = false; | ||||
|     }; | ||||
|     s.prototype.description = "Add or edit section"; | ||||
|     s.prototype.version = "1.0.0.0"; | ||||
|     s.prototype.onsave = null; | ||||
|  | ||||
|     var namecontrol = undefined; | ||||
|     var displaytextcontrol = undefined; | ||||
|     var notescontrol = undefined; | ||||
|     s.prototype.createContent = function () { | ||||
|         var _this = this; | ||||
|         editable = true; | ||||
|         var content = $('<div></div>'); | ||||
|  | ||||
|         function createHeader() { | ||||
|             var header = $('<div></div>'); | ||||
|  | ||||
|             var func = $('<div class="function_title"></div>'); | ||||
|             if (sectiontype == 0) { | ||||
|                 var btn = $('<span class="sbutton iconsave">' + GetTextByKey("P_IPT_SAVE","Save") + '</span>').click(function () { | ||||
|                     saveData(0); | ||||
|                 }); | ||||
|                 func.append(btn); | ||||
|                 btn = $('<span class="sbutton iconsave">' + GetTextByKey("P_IPT_SAVE1", "Save and Exit") + '</span>').click(function () { | ||||
|                     saveData(1); | ||||
|                 }); | ||||
|                 func.append(btn); | ||||
|                 btn = $('<span class="sbutton iconexit">' + GetTextByKey("P_IPT_SAVE2", "Exit Without Saving") + '</span>').click(function () { | ||||
|                     showRightPopup(false); | ||||
|                     if (_this.datasaved) | ||||
|                         _this.gsmodule.refresh(); | ||||
|                 }); | ||||
|                 func.append(btn); | ||||
|             } | ||||
|             else { | ||||
|                 header.append($('<div class="function_title" style="background-color:#ddd;font-size:16px;"></div>').text(_this.section ? 'Edit Section' : 'Add Section')); | ||||
|                 if (!templatereadonly && (!_this.section || (_this.section && !_this.section.IsLink))) { | ||||
|                     //if (!_this.section || (_this.section && !_this.section.IsLink)) { | ||||
|                     var btn = $('<span class="sbutton iconsave">' + GetTextByKey("P_IPT_OK", "OK") + '</span>').click(function () { | ||||
|                         var item = getData(); | ||||
|                         if (!item) | ||||
|                             return; | ||||
|                         if (_this.onsave) | ||||
|                             _this.onsave(item); | ||||
|                         $('#right_popup1').empty().hide(); | ||||
|                     }); | ||||
|                     func.append(btn); | ||||
|                 } | ||||
|                 btn = $('<span class="sbutton iconexit">' + GetTextByKey("P_IPT_CANCEL", "Cancel") + '</span>').click(function () { | ||||
|                     $('#right_popup1').empty().hide(); | ||||
|                 }); | ||||
|                 func.append(btn); | ||||
|             } | ||||
|             header.append(func) | ||||
|  | ||||
|             return header; | ||||
|         } | ||||
|  | ||||
|         function createSectionContent() { | ||||
|             var div_main = $('<div class="content_main" style="overflow: auto;"></div>'); | ||||
|             var div_content = $('<div class="edit-content"></div>'); | ||||
|             div_main.append(div_content); | ||||
|             var tb = $('<table style="line-height:40px;"></table>'); | ||||
|             div_content.append(tb); | ||||
|  | ||||
|             var tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label" style="vertical-align:middle;">' + GetTextByKey("P_IPT_NAME_COLON", "Name:") + '<span class="redasterisk">*</span></td>'); | ||||
|             namecontrol = $('<input type="text" maxlength="100" autocomplete="off"/>'); | ||||
|             var addiText = $('<span class="spanbtn iconmultitext" style="font-size:14px;" title=""/>'); | ||||
|             addiText.click(function () { | ||||
|                 Common.createMultiTextDialog(namecontrol, _this.section); | ||||
|             }); | ||||
|             tr.append($('<td></td>').append(namecontrol).append(addiText)); | ||||
|  | ||||
|             tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label" style="vertical-align:middle;">' + GetTextByKey("P_IPT_DISPLAYTEXT_COLON", "Display Text:") + '<span class="redasterisk">*</span></td>'); | ||||
|             displaytextcontrol = $('<input type="text" maxlength="200"  autocomplete="off"/>'); | ||||
|             addiText = $('<span class="spanbtn iconmultitext" style="font-size:14px;" title="' + GetTextByKey("P_IPT_ADDITIONALTEXTS", "Additional Texts") + '"/>'); | ||||
|             addiText.click(function () { | ||||
|                 Common.createMultiTextDialog(displaytextcontrol, _this.section); | ||||
|             }); | ||||
|             tr.append($('<td></td>').append(displaytextcontrol).append(addiText)); | ||||
|  | ||||
|             tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label">' + GetTextByKey("P_IPT_NOTES_COLON", "Notes:") + '</td>'); | ||||
|             notescontrol = $('<textarea id="dialog_notes" class="inputbox" maxlength="500" autocomplete="off" style="width: 400px; margin-top: 6px;"></textarea>'); | ||||
|             tr.append($('<td></td>').append(notescontrol)); | ||||
|  | ||||
|             return div_main; | ||||
|         } | ||||
|  | ||||
|         function updateContent() { | ||||
|             var section = _this.section; | ||||
|             if (section) { | ||||
|                 namecontrol.val(section.Name).data("texts", section.LocalNames); | ||||
|                 displaytextcontrol.val(section.DisplayText).data("texts", section.LocalDisplayTexts); | ||||
|                 notescontrol.val(section.Notes); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function setDisabled() { | ||||
|             namecontrol.prop('disabled', true); | ||||
|             displaytextcontrol.prop('disabled', true); | ||||
|             notescontrol.prop('disabled', true); | ||||
|         } | ||||
|  | ||||
|         function getData() { | ||||
|             var item = { | ||||
|                 'Name': namecontrol.val(), | ||||
|                 'DisplayText': displaytextcontrol.val(), | ||||
|                 'Notes': notescontrol.val() | ||||
|             }; | ||||
|             var texts = namecontrol.data("texts"); | ||||
|             if (texts) { | ||||
|                 item.LocalNames = texts; | ||||
|             } | ||||
|             texts = displaytextcontrol.data("texts"); | ||||
|             if (texts) { | ||||
|                 item.LocalDisplayTexts = texts; | ||||
|             } | ||||
|             var alerttitle; | ||||
|             if (_this.section) { | ||||
|                 item.Id = _this.section.Id; | ||||
|                 alerttitle = GetTextByKey("P_IPT_EDITSECTION","Edit Section"); | ||||
|             } else { | ||||
|                 alerttitle = GetTextByKey("P_IPT_ADDSECTION","Add Section"); | ||||
|             } | ||||
|  | ||||
|             if (!item.Name || item.Name.length == 0) { | ||||
|                 showAlert(GetTextByKey("P_IPT_NAMENOTBEEMPTY",'Name cannot be empty.'), alerttitle); | ||||
|                 return false; | ||||
|             } | ||||
|             if (!item.DisplayText || item.DisplayText.length == 0) { | ||||
|                 showAlert(GetTextByKey("P_IPT_DISPLAYTEXTNOTBEEMPTY",'Display Text cannot be empty.'), alerttitle); | ||||
|                 return false; | ||||
|             } | ||||
|  | ||||
|             return item; | ||||
|         } | ||||
|  | ||||
|         function saveData(exit) { | ||||
|             var item = getData(); | ||||
|             if (!item) return; | ||||
|  | ||||
|             var param = JSON.stringify(item); | ||||
|             param = htmlencode(param); | ||||
|             var p = JSON.stringify([teamintelligence, param]); | ||||
|             var alerttitle = GetTextByKey("P_IPT_SAVESECTION", 'Save Section'); | ||||
|             inspectionrequest("SaveGlobalSection", p, function (data) { | ||||
|                 if (typeof (data) === "string") { | ||||
|                     showAlert(data, alerttitle); | ||||
|                 } else { | ||||
|                     if (!_this.section) { | ||||
|                         _this.section = { 'Id': data[0] }; | ||||
|                     } | ||||
|                     if (exit == 0) { | ||||
|                         showAlert(GetTextByKey("P_IPT_SAVSUCCESSFULLY",'Saved successfully.'), alerttitle); | ||||
|                         _this.datasaved = true; | ||||
|                     } | ||||
|                     if (exit == 1) { | ||||
|                         _this.gsmodule.refresh(); | ||||
|                         showRightPopup(false); | ||||
|                     } | ||||
|                 } | ||||
|             }, function (err) { | ||||
|                     showAlert(GetTextByKey("P_IPT_FAILEDTOSAVESECTION",'Failed to save Section.'), alerttitle); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         content.append(createHeader()); | ||||
|         content.append(createSectionContent()); | ||||
|         updateContent(); | ||||
|         if (templatereadonly) | ||||
|             setDisabled(); | ||||
|         return content; | ||||
|     } | ||||
|     return s; | ||||
| }); | ||||
							
								
								
									
										200
									
								
								Site/Inspection/js/modules/sections/option.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										200
									
								
								Site/Inspection/js/modules/sections/option.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,200 @@ | ||||
| define(['common'], function (Common) { | ||||
|     var option = function (q, op) { | ||||
|         this.questionmodule = q; | ||||
|         this.option = op; | ||||
|         this.dialog_text = null; | ||||
|         this.dialog_bgcolor = null; | ||||
|         this.dialog_severitylevel = null; | ||||
|         this.holder = null; | ||||
|         this.texteditable = true; | ||||
|         this.removable = true; | ||||
|         if (op) { | ||||
|             if (op.removable == false) | ||||
|                 this.removable = false; | ||||
|             else | ||||
|                 this.removable = true; | ||||
|         } | ||||
|         this.onremove = null; | ||||
|     }; | ||||
|  | ||||
|     option.prototype.getOptionValue = function () { | ||||
|         var option = this.option || {}; | ||||
|         option.Text = this.dialog_text.val(); | ||||
|         var texts = this.dialog_text.data("texts"); | ||||
|         if (texts) { | ||||
|             option.LocalTexts = texts; | ||||
|         } | ||||
|         option.BackgroundColor = this.dialog_bgcolor.val(); | ||||
|         option.SeverityLevel = this.dialog_severitylevel.val(); | ||||
|         return option; | ||||
|     } | ||||
|  | ||||
|     option.prototype.removeOption = function () { | ||||
|         this.holder.remove(); | ||||
|         if (this.onremove) | ||||
|             this.onremove(this); | ||||
|         this.onsave(); | ||||
|     } | ||||
|  | ||||
|     option.prototype.onsave = function () { | ||||
|         this.questionmodule.onsave(); | ||||
|     } | ||||
|  | ||||
|     option.prototype.createContent = function () { | ||||
|         var _this = this; | ||||
|         var tb = $('<table style="border: 1px solid #a8a8a8; margin-top:2px;line-height:32px;"></table>'); | ||||
|         this.holder = tb; | ||||
|         var tr = $('<tr></tr>'); | ||||
|         tb.append(tr); | ||||
|         var optext = $('<input type="text" class="form-control" style="width:226px;margin-left:5px;"/>'); | ||||
|         this.dialog_text = optext; | ||||
|         var addiText = $('<span class="spanbtn iconmultitext" style="font-size:14px;" title="' + GetTextByKey("P_IPT_ADDITIONALTEXTS", "Additional Texts") + '"/>'); | ||||
|         addiText.click(function () { | ||||
|             Common.createMultiTextDialog(optext); | ||||
|         }); | ||||
|         var td = $('<td colspan="2"><span class="redasterisk">*</span></td>'); | ||||
|         td.append(this.dialog_text).append(addiText) | ||||
|         tr.append(td); | ||||
|  | ||||
|         //tr = $('<tr></tr>'); | ||||
|         //tb.append(tr); | ||||
|         td = $('<td style="width:76px;"></td>'); | ||||
|         tr.append(td); | ||||
|         td.append($('<label>' + GetTextByKey("P_IPT_SEVERITYLEVEL", "Severity Level") + '</label>')); | ||||
|         this.dialog_severitylevel = createSeverityLevel().addClass('form-control'); | ||||
|         this.dialog_severitylevel.css('width', 100); | ||||
|         tr.append($('<td></td>').append(this.dialog_severitylevel)); | ||||
|  | ||||
|         //tr = $('<tr></tr>'); | ||||
|         //tb.append(tr); | ||||
|         var bg_label = $('<label>' + GetTextByKey("P_IPT_BACKGROUNDCOLOR", "Background Color") + '</label>'); | ||||
|         td = $('<td style="width:100px;"></td>').append(bg_label); | ||||
|         tr.append(td); | ||||
|         this.dialog_bgcolor = $('<input style="width:100px;"/>'); | ||||
|         var bgcolor = $('<div></div>') | ||||
|         bgcolor.append(this.dialog_bgcolor); | ||||
|         td = $('<td></td>').append(bgcolor); | ||||
|         tr.append(td); | ||||
|         initColorCtrl(this.dialog_bgcolor); | ||||
|  | ||||
|         if (!this.texteditable) { | ||||
|             this.dialog_text.attr('disabled', 'disabled'); | ||||
|         } | ||||
|         if (this.removable) { | ||||
|             td = $('<td style="width:30px;"></td>'); | ||||
|             tr.append(td); | ||||
|             var deleteoptionbtn = $('<em class="spanbtn icondelete"></em>'); | ||||
|             td.append(deleteoptionbtn.click(function () { | ||||
|                 _this.removeOption(); | ||||
|             })); | ||||
|  | ||||
|             if (templatereadonly || !editable) | ||||
|                 deleteoptionbtn.hide(); | ||||
|         } | ||||
|  | ||||
|         function updateOptionContent() { | ||||
|             var op = _this.option; | ||||
|             if (op) { | ||||
|                 _this.dialog_text.val(op.Text).data("texts", op.LocalTexts); | ||||
|                 if (op.BackgroundColor && op.BackgroundColor != '') | ||||
|                     _this.dialog_bgcolor.spectrum("set", op.BackgroundColor); | ||||
|                 _this.dialog_severitylevel.val(op.SeverityLevel); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function controlSaveEvent() { | ||||
|             _this.dialog_text.change(function () { | ||||
|                 _this.onsave(); | ||||
|             }); | ||||
|             _this.dialog_severitylevel.change(function () { | ||||
|                 _this.onsave(); | ||||
|             }); | ||||
|             _this.dialog_bgcolor.change(function () { | ||||
|                 _this.onsave(); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function setDisabled() { | ||||
|             _this.dialog_text.prop('disabled', true); | ||||
|             _this.dialog_bgcolor.prop('disabled', true); | ||||
|             _this.dialog_severitylevel.prop('disabled', true); | ||||
|         } | ||||
|  | ||||
|         updateOptionContent(); | ||||
|         if (templatereadonly || !editable) | ||||
|             setDisabled(); | ||||
|         controlSaveEvent(); | ||||
|         return tb; | ||||
|     } | ||||
|  | ||||
|     function initColorCtrl(ipt_color) { | ||||
|         ipt_color.spectrum({ | ||||
|             allowEmpty: true, | ||||
|             color: "#FFF", | ||||
|             showInput: true, | ||||
|             containerClassName: "full-spectrum", | ||||
|             showInitial: true, | ||||
|             showPalette: true, | ||||
|             showSelectionPalette: true, | ||||
|             showAlpha: true, | ||||
|             maxPaletteSize: 10, | ||||
|             preferredFormat: "hex", | ||||
|             localStorageKey: "spectrum.demo", | ||||
|             chooseText: GetTextByKey("P_IPT_OK", "OK"), | ||||
|             cancelText: GetTextByKey("P_IPT_CANCEL", "Cancel"), | ||||
|             clearText: GetTextByKey("P_SPECTRUM_CLEARCOLORSELECTION", "Clear Color Selection"), | ||||
|             noColorSelectedText: GetTextByKey("P_SPECTRUM_NOCOLORSELECTED", "No Color Selected"), | ||||
|             disabled: (templatereadonly && !editable), | ||||
|             move: function (color) { | ||||
|                 if (color) | ||||
|                     ipt_color.val(color.toHexString().toUpperCase()); // #ff0000 | ||||
|             }, | ||||
|             show: function () { | ||||
|  | ||||
|             }, | ||||
|             beforeShow: function () { | ||||
|  | ||||
|             }, | ||||
|             hide: function (color) { | ||||
|                 if (color) { | ||||
|                     ipt_color.val(color.toHexString().toUpperCase()); // #ff0000 | ||||
|                 } | ||||
|             }, | ||||
|  | ||||
|             palette: [ | ||||
|                 ["rgb(0, 0, 0)", "rgb(67, 67, 67)", "rgb(102, 102, 102)", /*"rgb(153, 153, 153)","rgb(183, 183, 183)",*/ | ||||
|                     "rgb(204, 204, 204)", "rgb(217, 217, 217)", /*"rgb(239, 239, 239)", "rgb(243, 243, 243)",*/ "rgb(255, 255, 255)"], | ||||
|                 ["rgb(152, 0, 0)", "rgb(255, 0, 0)", "rgb(255, 153, 0)", "rgb(255, 255, 0)", "rgb(0, 255, 0)", | ||||
|                     "rgb(0, 255, 255)", "rgb(74, 134, 232)", "rgb(0, 0, 255)", "rgb(153, 0, 255)", "rgb(255, 0, 255)"], | ||||
|                 ["rgb(230, 184, 175)", "rgb(244, 204, 204)", "rgb(252, 229, 205)", "rgb(255, 242, 204)", "rgb(217, 234, 211)", | ||||
|                     "rgb(208, 224, 227)", "rgb(201, 218, 248)", "rgb(207, 226, 243)", "rgb(217, 210, 233)", "rgb(234, 209, 220)", | ||||
|                     "rgb(221, 126, 107)", "rgb(234, 153, 153)", "rgb(249, 203, 156)", "rgb(255, 229, 153)", "rgb(182, 215, 168)", | ||||
|                     "rgb(162, 196, 201)", "rgb(164, 194, 244)", "rgb(159, 197, 232)", "rgb(180, 167, 214)", "rgb(213, 166, 189)", | ||||
|                     "rgb(204, 65, 37)", "rgb(224, 102, 102)", "rgb(246, 178, 107)", "rgb(255, 217, 102)", "rgb(147, 196, 125)", | ||||
|                     "rgb(118, 165, 175)", "rgb(109, 158, 235)", "rgb(111, 168, 220)", "rgb(142, 124, 195)", "rgb(194, 123, 160)", | ||||
|                     "rgb(166, 28, 0)", "rgb(204, 0, 0)", "rgb(230, 145, 56)", "rgb(241, 194, 50)", "rgb(106, 168, 79)", | ||||
|                     "rgb(69, 129, 142)", "rgb(60, 120, 216)", "rgb(61, 133, 198)", "rgb(103, 78, 167)", "rgb(166, 77, 121)", | ||||
|                     /*"rgb(133, 32, 12)", "rgb(153, 0, 0)", "rgb(180, 95, 6)", "rgb(191, 144, 0)", "rgb(56, 118, 29)", | ||||
|                     "rgb(19, 79, 92)", "rgb(17, 85, 204)", "rgb(11, 83, 148)", "rgb(53, 28, 117)", "rgb(116, 27, 71)",*/ | ||||
|                     "rgb(91, 15, 0)", "rgb(102, 0, 0)", "rgb(120, 63, 4)", "rgb(127, 96, 0)", "rgb(39, 78, 19)", | ||||
|                     "rgb(12, 52, 61)", "rgb(28, 69, 135)", "rgb(7, 55, 99)", "rgb(32, 18, 77)", "rgb(76, 17, 48)"] | ||||
|             ] | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     function createSeverityLevel() { | ||||
|         var items = []; | ||||
|         items.push({ 'Key': 0, "Value": GetTextByKey("P_IPT_SL_NONE", "None") }); | ||||
|         items.push({ 'Key': 1, "Value": GetTextByKey("P_IPT_SL_LOW", "Low") }); | ||||
|         items.push({ 'Key': 2, "Value": GetTextByKey("P_IPT_SL_MEDIUM", "Medium") }); | ||||
|         items.push({ 'Key': 3, "Value": GetTextByKey("P_IPT_SL_HIGH", "High") }); | ||||
|         var sel = $('<select style="width:324px;height:22px;"></select>'); | ||||
|         for (var i = 0; i < items.length; i++) { | ||||
|             var item = items[i]; | ||||
|             sel.append('<option value="' + item.Key + '">' + item.Value + '</option>'); | ||||
|         } | ||||
|         return sel; | ||||
|     } | ||||
|  | ||||
|     return option; | ||||
| }); | ||||
							
								
								
									
										940
									
								
								Site/Inspection/js/modules/sections/question.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										940
									
								
								Site/Inspection/js/modules/sections/question.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,940 @@ | ||||
| define(['modules/sections/addquestion', 'modules/sections/option', 'common', 'modules/templates/picture'], function (AddQuestion, Option, Common, Picture) { | ||||
|     var q = function (sm, question, index) { | ||||
|         this.sectionmodule = sm; | ||||
|         this.section = sm.section; | ||||
|         this.question = question; | ||||
|         this.holder = null; | ||||
|         this.questionholder = null; | ||||
|         this.index = index; | ||||
|  | ||||
|         this.txtName = null; | ||||
|         this.txtDisplayText = null; | ||||
|         this.selQuestionType = null; | ||||
|         this.chkIsRequired = null; | ||||
|         this.chkCanComment = null; | ||||
|         this.chkIsImportant = null; | ||||
|         this.chkCustomerVisible = null; | ||||
|         this.selSeverityLevel = null; | ||||
|         this.txtNotes = null; | ||||
|         this.chkMultipleSelect = null; | ||||
|         this.selLookupSource = null; | ||||
|         this.selSubType = null; | ||||
|         this.txtTransactionDate = null; | ||||
|         this.selState = null; | ||||
|         this.selFuelType = null; | ||||
|         this.selDistributedBy = null; | ||||
|         this.txtBarCodeValidate = null; | ||||
|  | ||||
|         this.optionholder = undefined; | ||||
|         this.optiondiv = undefined; | ||||
|         this.btnoption = undefined; | ||||
|         this.optiontr = undefined; | ||||
|         this.optiontd = undefined; | ||||
|         this.multipleselectdiv = null; | ||||
|         this.lookupsourcespan = null; | ||||
|         this.additemspan = null; | ||||
|         this.optionmodules = []; | ||||
|  | ||||
|         this.saving = false; | ||||
|         this.datachanged = false; | ||||
|  | ||||
|     }; | ||||
|     q.prototype.moduletype = "question"; | ||||
|     q.prototype.description = "Question Module"; | ||||
|     q.prototype.version = "1.0.0.0"; | ||||
|     q.prototype.ondelete = null; | ||||
|  | ||||
|     q.prototype.createContent = function () { | ||||
|         var _this = this; | ||||
|         if (sectiontype === 0) { | ||||
|             if (!_this.question.IssueId || _this.question.IssueId == "") | ||||
|                 editable = true; | ||||
|             else | ||||
|                 editable = false; | ||||
|         } | ||||
|  | ||||
|         var holder = $('<div class="questionitem"></div>'); | ||||
|         _this.holder = holder; | ||||
|         var qholder = $('<div class="question-holder"></div>');//question holder | ||||
|         holder.append(qholder); | ||||
|         _this.questionholder = qholder; | ||||
|         var oholder = $('<div style="display:none;"></div>');//option holder | ||||
|         holder.append(oholder); | ||||
|         _this.optionholder = oholder; | ||||
|  | ||||
|         if (this.index % 2 == 1) | ||||
|             qholder.addClass('holder-even'); | ||||
|         var drag = $('<div class="question-icon" style="width:30px;"><em class="spanbtn iconmove rowdrag"></em></div>'); | ||||
|         qholder.append(drag); | ||||
|         if (!_this.section.IsLink && sectiontype == 1) { | ||||
|             drag.attr('draggable', true); | ||||
|             holder.bind('dragstart', function (e) { | ||||
|                 //var data = e.originalEvent.dataTransfer; | ||||
|                 draggingobj = _this; | ||||
|             }); | ||||
|             holder.bind('dragend', function (e) { | ||||
|                 draggingobj = null; | ||||
|             }); | ||||
|             holder.bind('dragover', function (e) { | ||||
|                 e.originalEvent.preventDefault() | ||||
|             }); | ||||
|             holder.bind('drop', function (e) { | ||||
|                 if (!draggingobj || _this === draggingobj) | ||||
|                     return; | ||||
|                 if (draggingobj.moduletype == "question") { | ||||
|                     var t = $(this); | ||||
|                     var after = e.originalEvent.clientY > t.offset().top + t.height() / 2; | ||||
|                     if (after) | ||||
|                         t.after(draggingobj.holder); | ||||
|                     else | ||||
|                         t.before(draggingobj.holder); | ||||
|  | ||||
|                     draggingobj.sectionmodule.dragOutQuestion(draggingobj); | ||||
|                     _this.sectionmodule.dragInQuestion(_this.question, draggingobj, after); | ||||
|                 } | ||||
|                 else {//section dragging | ||||
|                     if (_this.sectionmodule === draggingobj) | ||||
|                         return; | ||||
|                     else | ||||
|                         _this.sectionmodule.dragInSection(); | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|         else | ||||
|             drag.children().remove(); | ||||
|  | ||||
|         if (templatereadonly || !editable) | ||||
|             drag.hide(); | ||||
|  | ||||
|         qholder.append('<div class="question-icon" style="width:30px;"><em class="fa"></em></div>'); | ||||
|         _this.txtName = $('<input type="text" class="question-input"  maxlength="100" autocomplete="off" style="width:146px;" />'); | ||||
|         var addiText = $('<span class="spanbtn iconmultitext" style="font-size:14px;" title="' + GetTextByKey("P_IPT_ADDITIONALTEXTS", "Additional Texts") + '"/>'); | ||||
|         addiText.click(function () { | ||||
|             Common.createMultiTextDialog(_this.txtName, _this.question); | ||||
|         }); | ||||
|         qholder.append($('<div class="question-cell question-name" style="width: 190px;padding-left:10px;"></div>').append(this.txtName).append(addiText)); | ||||
|  | ||||
|         _this.txtDisplayText = $('<input type="text" class="question-input"  maxlength="200" autocomplete="off" style="width:236px;" />'); | ||||
|         addiText = $('<span class="spanbtn iconmultitext" style="font-size:14px;" title="' + GetTextByKey("P_IPT_ADDITIONALTEXTS", "Additional Texts") + '"/>'); | ||||
|         addiText.click(function () { | ||||
|             Common.createMultiTextDialog(_this.txtDisplayText, _this.question); | ||||
|         }); | ||||
|         var imgicon = $('<span class="spanbtn iconimage" style="font-size:14px;" title="' + GetTextByKey("P_IPT_PICTURES", "Pictures") + '"/>'); | ||||
|         imgicon.click(function (e) { | ||||
|             var picturemodule = new Picture(false, _this.question, function () { _this.onsave() }); | ||||
|             picturemodule.createContent(); | ||||
|             //Common.createImageDialog(_this.txtDisplayText, _this.question); | ||||
|         }); | ||||
|         qholder.append($('<div class="question-cell question-display" style="width: 310px;"></div>').append(this.txtDisplayText).append(addiText).append(imgicon)); | ||||
|  | ||||
|  | ||||
|         //this.selQuestionType<70><65>createQuestionTypeCtrl<72>и<EFBFBD>ֵ | ||||
|         var qt = createQuestionTypeCtrl().css('width', 140); | ||||
|         qholder.append($('<div class="question-cell question-type" style="width: 408px"></div>').append(qt)); | ||||
|         createOptions(); | ||||
|  | ||||
|         _this.chkIsRequired = $('<input type="checkbox" />'); | ||||
|         qholder.append($('<div class="question-cell question-required" style="width: 80px; text-align: center"></div>').append(this.chkIsRequired)); | ||||
|  | ||||
|         _this.chkCanComment = $('<input type="checkbox" />'); | ||||
|         qholder.append($('<div class="question-cell question-comment" style="width: 100px; text-align: center"></div>').append(this.chkCanComment)); | ||||
|  | ||||
|         _this.chkIsImportant = $('<input type="checkbox" />'); | ||||
|         qholder.append($('<div class="question-cell question-important" style="width: 100px; text-align: center"></div>').append(this.chkIsImportant)); | ||||
|  | ||||
|         _this.chkCustomerVisible = $('<input type="checkbox" />'); | ||||
|         qholder.append($('<div class="question-cell question-important" style="width: 140px; text-align: center"></div>').append(this.chkCustomerVisible)); | ||||
|  | ||||
|         _this.selSeverityLevel = createSeverityLevel().addClass('question-input').css('width', 130); | ||||
|         qholder.append($('<div class="question-cell question-security" style="width: 140px"></div>').append(this.selSeverityLevel)); | ||||
|  | ||||
|         _this.txtNotes = $('<textarea class="question-input"  maxlength="500" autocomplete="off" style="width:95%;margin-top:5px;"></textarea>'); | ||||
|         qholder.append($('<div class="question-cell question-notes" style="width: 160px;white-space:normal;"></div>').append(this.txtNotes)); | ||||
|         var funcs = $('<div class="question-cell question-func" style="width: 90px;text-align:right;padding-right:20px;"></div>'); | ||||
|         qholder.append(funcs); | ||||
|         //qholder.find('.question-name span').click(function () { | ||||
|         //    _this.onedit(); | ||||
|         //}); | ||||
|         //qholder.find('.question-display span').click(function () { | ||||
|         //    _this.onedit(); | ||||
|         //}); | ||||
|         if (_this.question.IsLink) { | ||||
|             qholder.find('.question-name input').before('<em class="spanbtn iconlink" style="cursor:default;margin:0;padding-left:0;padding-right:2px;font-size:10px;"></em>'); | ||||
|             qholder.find('input').prop('disabled', true); | ||||
|             qholder.find('select').prop('disabled', true); | ||||
|             qholder.find('textarea').prop('disabled', true); | ||||
|             qholder.find('.iconmultitext').remove(); | ||||
|             qholder.find('.iconimage').remove(); | ||||
|         } | ||||
|         if (!templatereadonly && editable) { | ||||
|             if (!_this.section.IsLink && sectiontype == 1 /*&& !_this.question.IsLink*/) { | ||||
|                 funcs.append($('<em class="spanbtn iconcopy"></em>').click(function () { | ||||
|                     if (_this.oncopy) | ||||
|                         _this.oncopy(_this.getQuestionValue(true, true)); | ||||
|                 }).attr('title', GetTextByKey("P_IPT_COPYQUESTION", 'Copy Question'))); | ||||
|             } | ||||
|             //if (!_this.question.IsLink) { | ||||
|             //    funcs.append($('<em class="spanbtn iconedit"></em>').click(function () { | ||||
|             //        _this.onedit(); | ||||
|             //    }).attr('title', 'Edit Question')); | ||||
|             //} | ||||
|             if (!_this.section.IsLink) { | ||||
|                 funcs.append($('<em class="spanbtn icondelete"></em>').click(function () { | ||||
|                     if (sectiontype == 0) { | ||||
|                         _this.delete(); | ||||
|                     } | ||||
|                     else { | ||||
|                         showConfirm(GetTextByKey("P_IPT_AREYOUSUREYOUWANTTODELETETHISQUESTION", 'Are you sure you want to delete this question?'), GetTextByKey("P_IPT_DELETEQUESTION", 'Delete Question'), function () { | ||||
|                             if (_this.ondelete) { | ||||
|                                 _this.holder.remove(); | ||||
|                                 _this.ondelete(_this); | ||||
|                             } | ||||
|                         }); | ||||
|                     } | ||||
|                 }).attr('title', GetTextByKey("P_IPT_DELETEQUESTION", 'Delete Question'))); | ||||
|             } | ||||
|         } | ||||
|         if (_this.question != null) { | ||||
|             _this.updateContent(_this.question); | ||||
|         } | ||||
|         if (templatereadonly || !editable) | ||||
|             setDisabled(); | ||||
|  | ||||
|         function createQuestionTypeCtrl() { | ||||
|             var tb = $('<table style="line-height:unset;"></table>'); | ||||
|             var tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             var td = $('<td></td>'); | ||||
|             tr.append(td); | ||||
|             _this.selQuestionType = createQuestionType().addClass('question-input'); | ||||
|             td.append(_this.selQuestionType); | ||||
|             _this.selQuestionType.change(function () { | ||||
|                 _this.questionTypeChange(true); | ||||
|             }); | ||||
|  | ||||
|             td = $('<td></td>'); | ||||
|             tr.append(td); | ||||
|             _this.btnoption = $('<span class="spanbtn iconangleleft" style="font-size:18px;"></span>'); | ||||
|             td.append(_this.btnoption); | ||||
|             _this.btnoption.click(function () { | ||||
|                 var icon = $(this); | ||||
|                 var type = _this.selQuestionType.val(); | ||||
|                 if (icon.hasClass('iconangleleft')) { | ||||
|                     icon.removeClass('iconangleleft').addClass('iconangledown'); | ||||
|                     _this.optionholder.show(); | ||||
|                     if (type === "8" || type === "9") | ||||
|                         _this.multipleselectdiv.show(); | ||||
|                     else | ||||
|                         _this.multipleselectdiv.hide(); | ||||
|                 } | ||||
|                 else { | ||||
|                     icon.removeClass('iconangledown').addClass('iconangleleft'); | ||||
|                     _this.optionholder.hide(); | ||||
|                 } | ||||
|             }); | ||||
|  | ||||
|             td = $('<td></td>'); | ||||
|             tr.append(td); | ||||
|             _this.selSubType = createSubType().addClass('question-input').css({ 'width': 128, 'margin-left': '3px' }); | ||||
|             _this.selSubType.change(function () { | ||||
|                 _this.subTypeChange(true); | ||||
|             }); | ||||
|             td.append(_this.selSubType); | ||||
|  | ||||
|  | ||||
|             td = $('<td></td>'); | ||||
|             tr.append(td); | ||||
|  | ||||
|             _this.txtTransactionDate = $('<input type="text" class="question-input"  maxlength="20" autocomplete="off" />').css({ 'width': 100, 'margin-left': '3px' }); | ||||
|             _this.txtTransactionDate.hide(); | ||||
|             _this.txtTransactionDate.datetimepicker({ | ||||
|                 timepicker: false, | ||||
|                 format: 'm/d/Y', | ||||
|                 enterLikeTab: false | ||||
|             }); | ||||
|             _this.txtTransactionDate.change(function () { | ||||
|                 _this.transactionDateChange(true); | ||||
|             }); | ||||
|             td.append(_this.txtTransactionDate); | ||||
|  | ||||
|             _this.selState = createState().addClass('question-input').css({ 'width': 116, 'margin-left': '3px' }); | ||||
|             _this.selState.hide(); | ||||
|             _this.selState.change(function () { | ||||
|                 _this.stateChange(true); | ||||
|             }); | ||||
|             td.append(_this.selState); | ||||
|  | ||||
|             _this.selFuelType = createFuelType().addClass('question-input').css({ 'width': 116, 'margin-left': '3px' }); | ||||
|             _this.selFuelType.hide(); | ||||
|             _this.selFuelType.change(function () { | ||||
|                 _this.fuelTypeChange(true); | ||||
|             }); | ||||
|             td.append(_this.selFuelType); | ||||
|  | ||||
|             _this.selDistributedBy = createDistributedBy().addClass('question-input').css({ 'width': 116, 'margin-left': '3px' }); | ||||
|             _this.selDistributedBy.hide(); | ||||
|             _this.selDistributedBy.change(function () { | ||||
|                 _this.distributedByChange(true); | ||||
|             }); | ||||
|             td.append(_this.selDistributedBy); | ||||
|  | ||||
|  | ||||
|             td = $('<td></td>'); | ||||
|             tr.append(td); | ||||
|             _this.txtBarCodeValidate = $('<input type="text" class="question-input"  maxlength="200" autocomplete="off" isValue="0" promptText="' + GetTextByKey("P_IPT_TEXTTOCOMPARE", "Text to compare") + '" style="width:112px;margin-left:3px;" />'); | ||||
|             _this.txtBarCodeValidate.focus(function () { | ||||
|                 if (_this.txtBarCodeValidate.attr("isValue") === "0") { | ||||
|                     _this.txtBarCodeValidate.val(""); | ||||
|                     _this.txtBarCodeValidate.removeClass("prompttext"); | ||||
|                 } | ||||
|             }); | ||||
|             _this.txtBarCodeValidate.blur(function () { | ||||
|                 if (_this.txtBarCodeValidate.val() == "") { | ||||
|                     _this.txtBarCodeValidate.attr("isValue", "0"); | ||||
|                     _this.txtBarCodeValidate.val(_this.txtBarCodeValidate.attr("promptText")); | ||||
|                     _this.txtBarCodeValidate.addClass("prompttext"); | ||||
|                 } | ||||
|             }); | ||||
|             td.append(_this.txtBarCodeValidate); | ||||
|  | ||||
|             if (_this.question.IsLink) | ||||
|                 _this.btnoption.remove(); | ||||
|  | ||||
|             //tb = $('<table style="line-height:unset;"></table>'); | ||||
|             //_this.multipleselectdiv = $('<span style="margin-left:50px;"><label>Multiple Select:</label></span>'); | ||||
|             //_this.chkMultipleSelect = $('<input type="checkbox" style="margin-left:10px;" />'); | ||||
|             //_this.multipleselectdiv.append(_this.chkMultipleSelect); | ||||
|  | ||||
|             //_this.optiontr = $('<tr style="display:none;"></tr>'); | ||||
|             //tb.append(_this.optiontr); | ||||
|             //var btn_additem = $('<span class="sbutton iconadd">Add Item</span>').click(function () { | ||||
|             //    _this.addOption(); | ||||
|             //}); | ||||
|             //_this.optiontd = $('<td colspan="2"></td>'); | ||||
|             //_this.optiontd.append('<span style="font-weight:bold;margin-right:5px;">Options</span>'); | ||||
|             //_this.optiontd.append(btn_additem); | ||||
|             //_this.optiontd.append(_this.multipleselectdiv); | ||||
|             //_this.optiontr.append(_this.optiontd); | ||||
|             return tb; | ||||
|         } | ||||
|  | ||||
|         function createOptions() { | ||||
|             _this.optiondiv = $('<div style="width:680px;margin-left:540px;padding-left:5px;padding-bottom:5px; border: 1px solid #a8a8a8;line-height:32px;"></div>'); | ||||
|             _this.optionholder.append(_this.optiondiv); | ||||
|             _this.multipleselectdiv = $('<span style="margin-left:50px;"><label>' + GetTextByKey("P_IPT_MULTIPLESELECT_COLON", "Multiple Select:") + '</label></span>'); | ||||
|             _this.chkMultipleSelect = $('<input type="checkbox" style="margin-left:10px;" />'); | ||||
|             _this.multipleselectdiv.append(_this.chkMultipleSelect); | ||||
|             _this.additemspan = $('<span class="sbutton iconadd">' + GetTextByKey("P_IPT_ADDITEM", "Add Item") + '</span>').click(function () { | ||||
|                 _this.addOption(); | ||||
|             }); | ||||
|  | ||||
|             _this.lookupsourcespan = $('<span style="margin-left:50px;"><label>' + GetTextByKey("P_IPT_LOOKUPSOURCE_COLON", "Lookup Source:") + '</label></span>'); | ||||
|             _this.selLookupSource = createLookupSource().addClass('question-input').css({ 'width': 150, 'margin-left': '5px' }); | ||||
|             _this.selLookupSource.change(function () { | ||||
|                 _this.lookupSourcesChange(true); | ||||
|             }); | ||||
|             _this.lookupsourcespan.append(_this.selLookupSource); | ||||
|  | ||||
|             _this.optiondiv.append('<span style="font-weight:bold;margin-right:5px;">' + GetTextByKey("P_IPT_OPTIONS", "Options") + '</span>'); | ||||
|             _this.optiondiv.append(_this.additemspan); | ||||
|             _this.optiondiv.append(_this.multipleselectdiv); | ||||
|             _this.optiondiv.append(_this.lookupsourcespan); | ||||
|         } | ||||
|  | ||||
|         function createQuestionType() { | ||||
|             var items = []; | ||||
|             items.push({ 'Key': 0, "Value": GetTextByKey("P_IPT_QT_SINGLELINETEXT", "Single Line Text") }); | ||||
|             items.push({ 'Key': 1, "Value": GetTextByKey("P_IPT_QT_MULTIPLELINETEXT", "Multiple Line Text") }); | ||||
|             items.push({ 'Key': 2, "Value": GetTextByKey("P_IPT_QT_EMAILMANUAL", "Email (Manual)") }); | ||||
|             items.push({ 'Key': 14, "Value": GetTextByKey("P_IPT_QT_EMAILDROPDOWN", "Email (Drop Down)") }); | ||||
|             items.push({ 'Key': 3, "Value": GetTextByKey("P_IPT_QT_NUMBER", "Number") }); | ||||
|             items.push({ 'Key': 4, "Value": GetTextByKey("P_IPT_QT_INTEGER", "Integer") }); | ||||
|             items.push({ 'Key': 5, "Value": GetTextByKey("P_IPT_QT_YESORNO", "Yes Or No") }); | ||||
|             items.push({ 'Key': 6, "Value": GetTextByKey("P_IPT_QT_DATE", "Date") }); | ||||
|             items.push({ 'Key': 7, "Value": GetTextByKey("P_IPT_QT_DATEANDTIME", "Date And Time") }); | ||||
|             items.push({ 'Key': 8, "Value": GetTextByKey("P_IPT_QT_DROPDOWN", "Drop Down") }); | ||||
|             items.push({ 'Key': 9, "Value": GetTextByKey("P_IPT_QT_LIST", "List") }); | ||||
|             items.push({ 'Key': 10, "Value": GetTextByKey("P_IPT_QT_PICTURE", "Picture") }); | ||||
|             if (!teamintelligence) { | ||||
|                 items.push({ 'Key': 11, "Value": GetTextByKey("P_IPT_QT_ODOMETER", "Odometer") }); | ||||
|                 items.push({ 'Key': 12, "Value": GetTextByKey("P_IPT_QT_ENGINEHOURS", "Engine Hours") }); | ||||
|                 items.push({ 'Key': 13, "Value": GetTextByKey("P_IPT_QT_FUELREMAINING", "Fuel Remaining") }); | ||||
|                 items.push({ 'Key': 15, "Value": GetTextByKey("P_IPT_QT_FUELRECORDS", "Fuel Records") }); | ||||
|             } | ||||
|             items.push({ 'Key': 16, "Value": GetTextByKey("P_IPT_QT_BARCODE", "Bar Code") }); | ||||
|             items.push({ 'Key': 17, "Value": GetTextByKey("P_IPT_QT_BARCODEVALIDATE", "Bar Code Validate") }); | ||||
|             items.push({ 'Key': 18, "Value": GetTextByKey("P_IPT_QT_FUELUSED", "Fuel Used") }); | ||||
|             items.push({ 'Key': 19, "Value": GetTextByKey("P_IPT_QT_XXX", "Asset Status") }); | ||||
|             var sel = $('<select style="width:140px; height:26px;"></select>'); | ||||
|             for (var i = 0; i < items.length; i++) { | ||||
|                 var item = items[i]; | ||||
|                 sel.append('<option value="' + item.Key + '">' + item.Value + '</option>'); | ||||
|             } | ||||
|             return sel; | ||||
|         } | ||||
|  | ||||
|         function createSubType() { | ||||
|             var items = []; | ||||
|             items.push({ 'Key': 0, "Value": GetTextByKey("P_IPT_ST_TRANSACTIONDATE", "Transaction Date") }); | ||||
|             items.push({ 'Key': 1, "Value": GetTextByKey("P_IPT_ST_TICKETRECEIPTNUMBER", "Ticket/Receipt Number") }); | ||||
|             items.push({ 'Key': 2, "Value": GetTextByKey("P_IPT_ST_DRIVERNAME", "Driver Name") }); | ||||
|             items.push({ 'Key': 3, "Value": GetTextByKey("P_IPT_ST_RETAILERNAME", "Retailer Name") }); | ||||
|             items.push({ 'Key': 4, "Value": GetTextByKey("P_IPT_ST_RETAILERADDRESS", "Retailer Address") }); | ||||
|             items.push({ 'Key': 5, "Value": GetTextByKey("P_IPT_ST_CITY", "City") }); | ||||
|             items.push({ 'Key': 6, "Value": GetTextByKey("P_IPT_ST_STATE", "State") }); | ||||
|             items.push({ 'Key': 7, "Value": GetTextByKey("P_IPT_ST_ZIP", "Zip") }); | ||||
|             items.push({ 'Key': 8, "Value": GetTextByKey("P_IPT_ST_ODOMETER", "Odometer") }); | ||||
|             items.push({ 'Key': 9, "Value": GetTextByKey("P_IPT_ST_FUELTYPE", "Fuel Type") }); | ||||
|             items.push({ 'Key': 10, "Value": GetTextByKey("P_IPT_ST_QUANTITY", "Quantity") }); | ||||
|             items.push({ 'Key': 11, "Value": GetTextByKey("P_IPT_ST_UOMCOST", "Unit Cost") }); | ||||
|             items.push({ 'Key': 12, "Value": GetTextByKey("P_IPT_ST_TOTALCOST", "Total Cost") }); | ||||
|             items.push({ 'Key': 13, "Value": GetTextByKey("P_IPT_ST_BRANDNAME", "Brand Name") }); | ||||
|             items.push({ 'Key': 14, "Value": GetTextByKey("P_IPT_ST_NOTES", "Notes") }); | ||||
|             items.push({ 'Key': 15, "Value": GetTextByKey("P_IPT_ST_PICTURE", "Picture") }); | ||||
|             items.push({ 'Key': 16, "Value": GetTextByKey("P_IPT_ST_DISTRIBUTEDBY", "Distributed By") }); | ||||
|             var sel = $('<select style="width:125px; height:26px;"></select>'); | ||||
|             for (var i = 0; i < items.length; i++) { | ||||
|                 var item = items[i]; | ||||
|                 sel.append('<option value="' + item.Key + '">' + item.Value + '</option>'); | ||||
|             } | ||||
|             return sel; | ||||
|         } | ||||
|  | ||||
|         function createDistributedBy() { | ||||
|             var items = []; | ||||
|             items.push({ 'Key': "", "Value": "" }); | ||||
|             items.push({ 'Key': "0", "Value": GetTextByKey("P_FR_FUELINGSTATION", "Fueling Station") }); | ||||
|             items.push({ 'Key': "1", "Value": GetTextByKey("P_FR_FUELINGASSET", "Fueling Asset") }); | ||||
|             var sel = $('<select style="width:125px; height:26px;"></select>'); | ||||
|             for (var i = 0; i < items.length; i++) { | ||||
|                 var item = items[i]; | ||||
|                 sel.append('<option value="' + item.Key + '">' + item.Value + '</option>'); | ||||
|             } | ||||
|             return sel; | ||||
|         } | ||||
|  | ||||
|         function createState() { | ||||
|             var items = []; | ||||
|             items.push("", "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", | ||||
|                 "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"); | ||||
|             var sel = $('<select style="width:125px; height:26px;"></select>'); | ||||
|             for (var i = 0; i < items.length; i++) { | ||||
|                 var item = items[i]; | ||||
|                 sel.append('<option value="' + item + '">' + item + '</option>'); | ||||
|             } | ||||
|             return sel; | ||||
|         } | ||||
|  | ||||
|         function createFuelType() { | ||||
|             var sel = $('<select style="width:125px; height:26px;"></select>'); | ||||
|             sel.append('<option value=""></option>'); | ||||
|             if (typeof fuelTypes !== 'undefined') { | ||||
|                 if (fuelTypes && fuelTypes.length > 0) { | ||||
|                     for (var i = 0; i < fuelTypes.length; i++) { | ||||
|                         var item = fuelTypes[i]; | ||||
|                         sel.append('<option value="' + item.Key + '">' + item.Value + '</option>'); | ||||
|                     } | ||||
|                 } | ||||
|                 if (_this.question && _this.question.QuestionType === 15 && _this.question.SubType === 9) | ||||
|                     sel.val(_this.question.DefaultValue); | ||||
|                 return sel; | ||||
|             } | ||||
|  | ||||
|             inspectionrequest("GetFuelTypes", '', function (data) { | ||||
|                 if (typeof (data) === "string") | ||||
|                     return sel; | ||||
|  | ||||
|                 if (data && data.length > 0) { | ||||
|                     for (var i = 0; i < data.length; i++) { | ||||
|                         var item = data[i]; | ||||
|                         sel.append('<option value="' + item.Key + '">' + item.Value + '</option>'); | ||||
|                     } | ||||
|                 } | ||||
|                 if (_this.question && _this.question.QuestionType === 15 && _this.question.SubType === 9) | ||||
|                     sel.val(_this.question.DefaultValue); | ||||
|  | ||||
|             }, function (err) { | ||||
|             }); | ||||
|  | ||||
|             return sel; | ||||
|         } | ||||
|  | ||||
|         function createSeverityLevel() { | ||||
|             var items = []; | ||||
|             items.push({ 'Key': 0, "Value": GetTextByKey("P_IPT_SL_NONE", "None") }); | ||||
|             items.push({ 'Key': 1, "Value": GetTextByKey("P_IPT_SL_LOW", "Low") }); | ||||
|             items.push({ 'Key': 2, "Value": GetTextByKey("P_IPT_SL_MEDIUM", "Medium") }); | ||||
|             items.push({ 'Key': 3, "Value": GetTextByKey("P_IPT_SL_HIGH", "High") }); | ||||
|             var sel = $('<select style="width:324px;height:26px;"></select>'); | ||||
|             for (var i = 0; i < items.length; i++) { | ||||
|                 var item = items[i]; | ||||
|                 sel.append('<option value="' + item.Key + '">' + item.Value + '</option>'); | ||||
|             } | ||||
|             return sel; | ||||
|         } | ||||
|  | ||||
|         function createLookupSource() { | ||||
|             var items = []; | ||||
|             items.push({ 'Key': 0, "Value": GetTextByKey("P_IPT_LS_MANUALINPUT", "Manual Input") }); | ||||
|             items.push({ 'Key': 1, "Value": GetTextByKey("P_IPT_LS_JOBSITES", "Jobsites") }); | ||||
|             items.push({ 'Key': 2, "Value": GetTextByKey("P_IPT_LS_ASSETS", "Assets") }); | ||||
|             items.push({ 'Key': 4, "Value": GetTextByKey("P_IPT_LS_ASSETNAMECUSTOM", "Asset Name Custom") }); | ||||
|             items.push({ 'Key': 3, "Value": GetTextByKey("P_IPT_LS_EMPLOYEES", "Employees") }); | ||||
|             var sel = $('<select style="width:324px;height:26px;"></select>'); | ||||
|             for (var i = 0; i < items.length; i++) { | ||||
|                 var item = items[i]; | ||||
|                 sel.append('<option value="' + item.Key + '">' + item.Value + '</option>'); | ||||
|             } | ||||
|             return sel; | ||||
|         } | ||||
|  | ||||
|         function controlSaveEvent() { | ||||
|             _this.txtName.change(function () { | ||||
|                 _this.onsave(); | ||||
|             }); | ||||
|             _this.txtDisplayText.change(function () { | ||||
|                 _this.onsave(); | ||||
|             }); | ||||
|             _this.chkIsRequired.click(function () { | ||||
|                 _this.onsave(); | ||||
|             }); | ||||
|             _this.chkCanComment.click(function () { | ||||
|                 _this.onsave(); | ||||
|             }); | ||||
|             _this.chkIsImportant.click(function () { | ||||
|                 _this.onsave(); | ||||
|             }); | ||||
|             _this.chkCustomerVisible.click(function () { | ||||
|                 _this.onsave(); | ||||
|             }); | ||||
|             _this.selSeverityLevel.change(function () { | ||||
|                 _this.onsave(); | ||||
|             }); | ||||
|             _this.txtNotes.blur(function () { | ||||
|                 _this.onsave(); | ||||
|             }); | ||||
|  | ||||
|             _this.chkMultipleSelect.click(function () { | ||||
|                 _this.onsave(); | ||||
|             }); | ||||
|             _this.txtBarCodeValidate.change(function () { | ||||
|                 if (_this.txtBarCodeValidate.val() == "") { | ||||
|                     _this.txtBarCodeValidate.attr("isValue", "0"); | ||||
|                     _this.txtBarCodeValidate.val(_this.txtBarCodeValidate.attr("promptText")); | ||||
|                     _this.txtBarCodeValidate.addClass("prompttext"); | ||||
|                 } | ||||
|                 else { | ||||
|                     _this.txtBarCodeValidate.attr("isValue", "1"); | ||||
|                 } | ||||
|                 _this.onsave(); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function setDisabled() { | ||||
|             _this.txtName.prop('disabled', true); | ||||
|             _this.txtDisplayText.prop('disabled', true); | ||||
|             _this.chkIsRequired.prop('disabled', true); | ||||
|             _this.chkCanComment.prop('disabled', true); | ||||
|             _this.chkIsImportant.prop('disabled', true); | ||||
|             _this.chkCustomerVisible.prop('disabled', true); | ||||
|             _this.selSeverityLevel.prop('disabled', true); | ||||
|             _this.txtNotes.prop('disabled', true); | ||||
|             _this.chkMultipleSelect.prop('disabled', true); | ||||
|             _this.selQuestionType.prop('disabled', true); | ||||
|             _this.selLookupSource.prop('disabled', true); | ||||
|             _this.selSubType.prop('disabled', true); | ||||
|             _this.selDistributedBy.prop('disabled', true); | ||||
|             _this.selFuelType.prop('disabled', true); | ||||
|             _this.txtTransactionDate.prop('disabled', true); | ||||
|             _this.selState.prop('disabled', true); | ||||
|             _this.txtBarCodeValidate.prop('disabled', true); | ||||
|             _this.additemspan.hide(); | ||||
|  | ||||
|             _this.holder.find(".iconmultitext").hide(); | ||||
|             _this.holder.find(".iconimage").hide(); | ||||
|             _this.holder.find(".iconangleleft").hide(); | ||||
|         } | ||||
|         controlSaveEvent(); | ||||
|         return holder; | ||||
|     }; | ||||
|     q.prototype.questionTypeChange = function (needsave) { | ||||
|         var _this = this; | ||||
|         _this.optionmodules = []; | ||||
|         //_this.optiontd.find('table').remove(); | ||||
|         _this.optionholder.find('table').remove(); | ||||
|         var type = _this.selQuestionType.val(); | ||||
|         questiontype = type; | ||||
|         if (['5', '8', '9'].indexOf(type) >= 0) { | ||||
|             _this.btnoption.show(); | ||||
|             if (_this.btnoption.hasClass('iconangledown')) { | ||||
|                 if (type === "8" || type === "9") | ||||
|                     _this.multipleselectdiv.show(); | ||||
|                 else | ||||
|                     _this.multipleselectdiv.hide(); | ||||
|                 //_this.optiontr.show(); | ||||
|                 _this.optionholder.show(); | ||||
|             } | ||||
|  | ||||
|             if (type === "5") { | ||||
|                 var ynops = [{ 'Text': GetTextByKey("P_IPT_YES", 'Yes'), 'BackgroundColor': '#0F0', 'Value': 'Yes', 'SeverityLevel': 0 }, { 'Text': GetTextByKey("P_IPT_NO", 'No'), 'BackgroundColor': '#F00', 'Value': 'No', 'SeverityLevel': 0 }]; | ||||
|                 for (var i = 0; i < ynops.length; i++) { | ||||
|                     var op = ynops[i]; if (_this.question) { | ||||
|                         if (i < _this.question.SelectItems.length) { | ||||
|                             op.BackgroundColor = _this.question.SelectItems[i].BackgroundColor; | ||||
|                             op.SeverityLevel = _this.question.SelectItems[i].SeverityLevel; | ||||
|                             op.LocalTexts = _this.question.SelectItems[i].LocalTexts; | ||||
|                         } | ||||
|                     } | ||||
|                     op.removable = false; | ||||
|                     _this.addOption(op, false); | ||||
|                 } | ||||
|                 //_this.optiontr.find('.sbutton').hide(); | ||||
|                 _this.optionholder.find('.sbutton').hide(); | ||||
|             } | ||||
|             else { | ||||
|                 //_this.optiontr.find('.sbutton').show(); | ||||
|                 _this.optionholder.find('.sbutton').show(); | ||||
|                 if (_this.question) { | ||||
|                     for (var i = 0; i < _this.question.SelectItems.length; i++) { | ||||
|                         _this.addOption(_this.question.SelectItems[i]); | ||||
|                     } | ||||
|                 } | ||||
|                 else | ||||
|                     _this.addOption(); | ||||
|             } | ||||
|  | ||||
|             if (type === "8") { | ||||
|                 _this.lookupsourcespan.show(); | ||||
|             } | ||||
|             else { | ||||
|                 _this.lookupsourcespan.hide(); | ||||
|             } | ||||
|         } | ||||
|         else { | ||||
|             _this.btnoption.hide(); | ||||
|             //_this.optiontr.hide(); | ||||
|             _this.optionholder.hide() | ||||
|             //_this.multipleselectdiv.hide(); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         _this.txtTransactionDate.hide(); | ||||
|         _this.selState.hide(); | ||||
|         _this.selFuelType.hide(); | ||||
|         _this.selDistributedBy.hide(); | ||||
|         if (type === "15" || type === "17") { | ||||
|             if (type === "15") { | ||||
|                 _this.selSubType.show(); | ||||
|                 _this.questionholder.attr('title', GetTextByKey("P_IPT_THESEQUESTIONSCREATEFUELRECORDSINASSETHEALTH", 'These questions create Fuel Records in Asset Health')); | ||||
|                 _this.txtBarCodeValidate.hide(); | ||||
|                 var subtype = _this.selSubType.val(); | ||||
|                 //if (subtype === "0") | ||||
|                 //    _this.txtTransactionDate.show(); | ||||
|                 if (subtype === "6") | ||||
|                     _this.selState.show(); | ||||
|                 else if (subtype === "9") | ||||
|                     _this.selFuelType.show(); | ||||
|                 else if (subtype === "16") | ||||
|                     _this.selDistributedBy.show() | ||||
|             } | ||||
|             else { | ||||
|                 _this.selSubType.hide(); | ||||
|                 _this.questionholder.removeAttr('title'); | ||||
|                 _this.txtBarCodeValidate.show(); | ||||
|             } | ||||
|         } | ||||
|         else { | ||||
|             _this.selSubType.hide(); | ||||
|             _this.txtBarCodeValidate.hide(); | ||||
|             if (!this.question.IsLink) | ||||
|                 _this.chkIsRequired.prop('disabled', false); | ||||
|             _this.questionholder.removeAttr('title'); | ||||
|         } | ||||
|  | ||||
|         if (needsave) | ||||
|             _this.onsave(); | ||||
|     } | ||||
|  | ||||
|     q.prototype.lookupSourcesChange = function (needsave) { | ||||
|         var _this = this; | ||||
|         var type = _this.selQuestionType.val(); | ||||
|         var source = _this.selLookupSource.val(); | ||||
|  | ||||
|         if (type === "8" && source !== "0") { | ||||
|             _this.additemspan.hide(); | ||||
|             _this.optionholder.find('table').remove(); | ||||
|             _this.optionmodules = []; | ||||
|         } | ||||
|         else { | ||||
|             _this.additemspan.show(); | ||||
|         } | ||||
|         if (needsave) | ||||
|             _this.onsave(); | ||||
|     } | ||||
|  | ||||
|     q.prototype.subTypeChange = function (needsave) { | ||||
|         var _this = this; | ||||
|         _this.txtTransactionDate.hide(); | ||||
|         _this.selState.hide(); | ||||
|         _this.selFuelType.hide(); | ||||
|         _this.selDistributedBy.hide(); | ||||
|  | ||||
|         var subtype = _this.selSubType.val(); | ||||
|         //if (subtype === "0") | ||||
|         //    _this.txtTransactionDate.show(); | ||||
|         if (subtype === "6") | ||||
|             _this.selState.show(); | ||||
|         else if (subtype === "9") | ||||
|             _this.selFuelType.show(); | ||||
|         else if (subtype === "16") | ||||
|             _this.selDistributedBy.show() | ||||
|  | ||||
|         if (needsave) | ||||
|             _this.onsave(); | ||||
|     } | ||||
|  | ||||
|     q.prototype.distributedByChange = function (needsave) { | ||||
|         var _this = this; | ||||
|         if (needsave) | ||||
|             _this.onsave(); | ||||
|     } | ||||
|  | ||||
|     q.prototype.stateChange = function (needsave) { | ||||
|         var _this = this; | ||||
|         if (needsave) | ||||
|             _this.onsave(); | ||||
|     } | ||||
|  | ||||
|     q.prototype.transactionDateChange = function (needsave) { | ||||
|         var _this = this; | ||||
|         if (needsave) | ||||
|             _this.onsave(); | ||||
|     } | ||||
|  | ||||
|     q.prototype.fuelTypeChange = function (needsave) { | ||||
|         var _this = this; | ||||
|         if (needsave) | ||||
|             _this.onsave(); | ||||
|     } | ||||
|  | ||||
|     q.prototype.addOption = function (item, texteditable) { | ||||
|         var _this = this; | ||||
|         var op = new Option(_this, item); | ||||
|         op.onremove = function (item) { | ||||
|             _this.optionmodules.splice(_this.optionmodules.indexOf(item), 1); | ||||
|         } | ||||
|         if (texteditable != undefined || texteditable != null) | ||||
|             op.texteditable = texteditable; | ||||
|         _this.optionmodules.push(op); | ||||
|         //_this.optiontd.append(op.createContent()); | ||||
|         _this.optiondiv.append(op.createContent()); | ||||
|     } | ||||
|  | ||||
|     q.prototype.onedit = function () { | ||||
|         var _this = this; | ||||
|         var aq = new AddQuestion(_this.sectionmodule, _this.section.Id, _this.question); | ||||
|         if (sectiontype == 0) { | ||||
|             $('#right_popup').empty().append(aq.createContent()); | ||||
|             showRightPopup(true); | ||||
|         } | ||||
|         else { | ||||
|             aq.onsave = function (question) { | ||||
|                 _this.question.Name = question.Name; | ||||
|                 _this.question.DisplayText = question.DisplayText; | ||||
|                 _this.question.Notes = question.Notes; | ||||
|                 _this.question.LocalNames = question.LocalNames; | ||||
|                 _this.question.LocalDisplayTexts = question.LocalDisplayTexts; | ||||
|  | ||||
|                 _this.question.QuestionType = question.QuestionType; | ||||
|                 _this.question.IsRequired = question.IsRequired; | ||||
|                 _this.question.CanComment = question.CanComment; | ||||
|                 _this.question.IsImportant = question.IsImportant; | ||||
|                 _this.question.SeverityLevel = question.SeverityLevel; | ||||
|                 _this.question.SelectItems = question.SelectItems; | ||||
|  | ||||
|                 _this.updateContent(_this.question); | ||||
|             } | ||||
|             $('#right_popup1').empty().append(aq.createContent()).show(); | ||||
|         } | ||||
|     } | ||||
|     q.prototype.updateContent = function (question) { | ||||
|         if (this.question != question) { | ||||
|             this.question = question; | ||||
|         } | ||||
|  | ||||
|         this.txtName.val(question.Name).data("texts", question.LocalNames); | ||||
|         this.txtDisplayText.val(question.DisplayText).data("texts", question.LocalDisplayTexts); | ||||
|         this.selQuestionType.val(question.QuestionType); | ||||
|         this.questionTypeChange(false); | ||||
|         this.chkIsRequired.attr('checked', question.IsRequired); | ||||
|         this.chkCanComment.attr('checked', question.CanComment); | ||||
|         this.chkIsImportant.attr('checked', question.IsImportant); | ||||
|         this.chkCustomerVisible.attr('checked', question.VisibleToCustomer); | ||||
|         this.selSeverityLevel.val(question.SeverityLevel); | ||||
|         this.txtNotes.val(question.Notes); | ||||
|         this.chkMultipleSelect.attr('checked', question.MultipleSelect); | ||||
|         this.selLookupSource.val(question.LookupSource); | ||||
|         this.lookupSourcesChange(false); | ||||
|         if (question.QuestionType == 15) { | ||||
|             this.selSubType.val(question.SubType); | ||||
|             //if (question.SubType === 0) | ||||
|             //    this.txtTransactionDate.val(question.DefaultValue); | ||||
|             if (question.SubType === 6) | ||||
|                 this.selState.val(question.DefaultValue); | ||||
|             else if (question.SubType === 9) | ||||
|                 this.selFuelType.val(question.DefaultValue); | ||||
|             else if (question.SubType === 16) | ||||
|                 this.selDistributedBy.val(question.DefaultValue); | ||||
|  | ||||
|             this.subTypeChange(false); | ||||
|         } | ||||
|         this.txtBarCodeValidate.val(question.TextToCompare); | ||||
|  | ||||
|         if (this.txtBarCodeValidate.val() == "") { | ||||
|             this.txtBarCodeValidate.attr("isValue", "0"); | ||||
|             this.txtBarCodeValidate.val(this.txtBarCodeValidate.attr("promptText")); | ||||
|             this.txtBarCodeValidate.addClass("prompttext"); | ||||
|         } | ||||
|         else { | ||||
|             this.txtBarCodeValidate.attr("isValue", "1"); | ||||
|             this.txtBarCodeValidate.removeClass("prompttext"); | ||||
|         } | ||||
|     }; | ||||
|     q.prototype.getQuestionValue = function (noalert, nocheck) { | ||||
|         var question = this.question; | ||||
|         question.Name = this.txtName.val(); | ||||
|         question.DisplayText = this.txtDisplayText.val(); | ||||
|         var texts = this.txtName.data("texts"); | ||||
|         if (texts) { | ||||
|             question.LocalNames = texts; | ||||
|         } | ||||
|         texts = this.txtDisplayText.data("texts"); | ||||
|         if (texts) { | ||||
|             question.LocalDisplayTexts = texts; | ||||
|         } | ||||
|  | ||||
|         question.QuestionType = this.selQuestionType.val(); | ||||
|         question.IsRequired = this.chkIsRequired.prop('checked'); | ||||
|         question.CanComment = this.chkCanComment.prop('checked'); | ||||
|         question.IsImportant = this.chkIsImportant.prop('checked'); | ||||
|         question.VisibleToCustomer = this.chkCustomerVisible.prop('checked'); | ||||
|         question.SeverityLevel = this.selSeverityLevel.val(); | ||||
|         question.Notes = this.txtNotes.val(); | ||||
|         if (question.QuestionType === "8" || question.QuestionType === "9") | ||||
|             question.MultipleSelect = this.chkMultipleSelect.prop('checked'); | ||||
|         else | ||||
|             question.MultipleSelect = false; | ||||
|         question.LookupSource = this.selLookupSource.val(); | ||||
|  | ||||
|         question.SubType = this.selSubType.val(); | ||||
|         //if (question.SubType === "0") | ||||
|         //    question.DefaultValue = this.txtTransactionDate.val(); | ||||
|         if (question.SubType === "6") | ||||
|             question.DefaultValue = this.selState.val(); | ||||
|         else if (question.SubType === "9") | ||||
|             question.DefaultValue = this.selFuelType.val(); | ||||
|         else if (question.SubType === "16") | ||||
|             question.DefaultValue = this.selDistributedBy.val(); | ||||
|  | ||||
|         question.TextToCompare = this.txtBarCodeValidate.val(); | ||||
|         if (this.txtBarCodeValidate.attr("isValue") === "0") { | ||||
|             question.TextToCompare = ""; | ||||
|         } | ||||
|         question.SelectItems = []; | ||||
|         var alerttitle = GetTextByKey("P_IPT_QUESTION", "Question"); | ||||
|         if (!nocheck) { | ||||
|             if (!question.Name || question.Name.length == 0) { | ||||
|                 if (!noalert) | ||||
|                     showAlert(GetTextByKey("P_IPT_QUESTIONNAMENOTBEEMPTY", 'Question Name cannot be empty.'), alerttitle); | ||||
|                 return false; | ||||
|             } | ||||
|             if (!question.DisplayText || question.DisplayText.length == 0) { | ||||
|                 if (!noalert) | ||||
|                     showAlert(GetTextByKey("P_IPT_QUESTIONDISPLAYTEXTNOTBEEMPTY", 'Question Display Text cannot be empty.'), alerttitle); | ||||
|                 return false; | ||||
|             } | ||||
|             if (question.QuestionType == "17" && question.IsRequired == true && (!question.TextToCompare || question.TextToCompare.length == 0)) { | ||||
|                 if (!noalert) | ||||
|                     showAlert(GetTextByKey("P_IPT_TEXTTPCOMPARENOTBEEMPTY", 'Text to compare cannot be empty.'), alerttitle); | ||||
|                 return false; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if (this.optionmodules.length > 0) { | ||||
|             for (var i = 0; i < this.optionmodules.length; i++) { | ||||
|                 var selectitem = this.optionmodules[i].getOptionValue(); | ||||
|                 if (!nocheck) { | ||||
|                     if (!selectitem.Text || selectitem.Text.length == 0) { | ||||
|                         if (!noalert) | ||||
|                             showAlert(GetTextByKey("P_IPT_OPTIONNAMECANNOTBEEMPTY", 'Option name cannot be empty.'), alerttitle); | ||||
|                         return false; | ||||
|                     } | ||||
|                 } | ||||
|                 question.SelectItems.push(selectitem) | ||||
|             } | ||||
|         } | ||||
|         //if (!nocheck && !noalert) { | ||||
|         //    if (!noalert) { | ||||
|         //        if ((question.QuestionType === "8" || question.QuestionType === "9") && question.SelectItems.length == 0) { | ||||
|         //            showAlert('There must be at least one choice.', alerttitle); | ||||
|         //            return false; | ||||
|         //        } | ||||
|         //    } | ||||
|         //} | ||||
|         return question; | ||||
|     }; | ||||
|     q.prototype.delete = function () { | ||||
|         var _this = this; | ||||
|         showConfirm(GetTextByKey("P_IPT_AREYOUSUREYOUWANTTODELETETHISQUESTION", 'Are you sure you want to delete this question?'), GetTextByKey("P_IPT_DELETEQUESTION", "Delete Question"), function () { | ||||
|             if (!_this.question.Id) { | ||||
|                 _this.holder.remove(); | ||||
|                 return; | ||||
|             } | ||||
|             var p = JSON.stringify([teamintelligence, htmlencode(_this.question.Id)]); | ||||
|             inspectionrequest("DeleteGlobalQuestion", p, function (data) { | ||||
|                 if (data !== 'OK') | ||||
|                     showAlert(data, GetTextByKey("P_IPT_DELETEQUESTION", "Delete Question")); | ||||
|                 else if (_this.sectionmodule && typeof _this.sectionmodule.refresh === "function") | ||||
|                     _this.sectionmodule.refresh(); | ||||
|             }, function (err) { | ||||
|                 showAlert(GetTextByKey("P_IPT_FAILEDTODELETEQUESTION", 'Failed to delete question.'), GetTextByKey("P_IPT_DELETEQUESTION", "Delete Question")); | ||||
|             }); | ||||
|         }); | ||||
|     }; | ||||
|  | ||||
|     q.prototype.onsave = function () { | ||||
|         var _this = this; | ||||
|         if (sectiontype == 1) return; | ||||
|         var item = _this.getQuestionValue(true); | ||||
|         if (!item) return; | ||||
|  | ||||
|         if (_this.saving) { | ||||
|             _this.datachanged = true; | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         var param = JSON.stringify(item); | ||||
|         param = htmlencode(param); | ||||
|         _this.saving = true; | ||||
|         var p = JSON.stringify([teamintelligence, _this.section.Id, param]); | ||||
|         inspectionrequest("SaveGlobalQuestion", p, function (data) { | ||||
|             if (typeof (data) === "string") { | ||||
|                 showAlert(data, GetTextByKey("P_IPT_SAVEQUESTION", 'Save Question')); | ||||
|             } | ||||
|             else { | ||||
|                 if (!_this.question) | ||||
|                     _this.question = {}; | ||||
|                 _this.question.Id = data[0]; | ||||
|             } | ||||
|             _this.saving = false; | ||||
|             if (_this.datachanged) | ||||
|                 _this.onsave(); | ||||
|         }, function (err) { | ||||
|             showAlert(GetTextByKey("P_IPT_FAILEDTOSAVEQUESTION", 'Failed to save question.'), GetTextByKey("P_IPT_SAVEQUESTION", 'Save Question')); | ||||
|             _this.saving = false; | ||||
|             if (_this.datachanged) | ||||
|                 _this.onsave(); | ||||
|         }); | ||||
|     } | ||||
|     return q; | ||||
| }); | ||||
							
								
								
									
										410
									
								
								Site/Inspection/js/modules/sections/section.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										410
									
								
								Site/Inspection/js/modules/sections/section.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,410 @@ | ||||
| define(['modules/sections/question', 'modules/sections/addsection', 'modules/sections/addquestion', 'common', 'modules/templates/picture'] | ||||
|     , function (Question, AddSection, AddQuestion, Common, Picture) { | ||||
|         var s = function (section, gsm, pm) { | ||||
|             this.section = section; | ||||
|             this.content = null; | ||||
|             this.holder = null; | ||||
|             this.gsmodule = gsm; | ||||
|             this.pagemodule = pm; | ||||
|  | ||||
|             this.txtName = null; | ||||
|             this.txtDisplayText = null; | ||||
|  | ||||
|             if (!this.section.Questions) | ||||
|                 this.section.Questions = []; | ||||
|             this.questionmodules = []; | ||||
|         }; | ||||
|         s.prototype.moduletype = "section"; | ||||
|         s.prototype.description = "Section Module"; | ||||
|         s.prototype.version = "1.0.0.0"; | ||||
|         s.prototype.ondelete = null; | ||||
|  | ||||
|         s.prototype.createContent = function () { | ||||
|             var content = $('<div></div>'); | ||||
|             this.content = content; | ||||
|             var holder = $('<div class="section-holder"></div>'); | ||||
|             content.append(holder); | ||||
|             var _this = this; | ||||
|             if (sectiontype === 0) { | ||||
|                 if (!_this.section.IssueId || _this.section.IssueId == "") | ||||
|                     editable = true; | ||||
|                 else | ||||
|                     editable = false; | ||||
|             } | ||||
|  | ||||
|             if (sectiontype === 0) { | ||||
|                 var package = $('<div class="question-icon section-packages" style="width:30px;padding-left:10px;"><em class="fa icon-menu icon-packages"></em></div>'); | ||||
|                 holder.append(package); | ||||
|             } | ||||
|  | ||||
|             if (sectiontype == 1) { | ||||
|                 var drag = $('<div class="question-icon" style="width:30px;"><em class="spanbtn iconmove rowdrag"></em></div>'); | ||||
|                 holder.append(drag); | ||||
|                 if (sectiontype == 1) { | ||||
|                     drag.attr('draggable', true); | ||||
|                     holder.bind('dragstart', function (e) { | ||||
|                         //var data = e.originalEvent.dataTransfer; | ||||
|                         draggingobj = _this; | ||||
|                     }); | ||||
|                     holder.bind('dragend', function (e) { | ||||
|                         draggingobj = null; | ||||
|                     }); | ||||
|                     holder.bind('dragover', function (e) { | ||||
|                         e.originalEvent.preventDefault() | ||||
|                     }); | ||||
|                     holder.bind('drop', function (e) { | ||||
|                         if (!draggingobj || _this === draggingobj) | ||||
|                             return; | ||||
|                         if (draggingobj.moduletype == "question") { | ||||
|                             if (_this.section.IsLink) | ||||
|                                 return; | ||||
|                             $(this).after(draggingobj.holder); | ||||
|                             draggingobj.sectionmodule.dragOutQuestion(draggingobj); | ||||
|                             _this.dragInQuestion(null, draggingobj, true); | ||||
|                         } | ||||
|                         else { | ||||
|                             var t = $(this); | ||||
|                             var after = e.originalEvent.clientY > t.offset().top + t.height() / 2; | ||||
|                             if (after) | ||||
|                                 t.parent().after(draggingobj.holder.parent()); | ||||
|                             else | ||||
|                                 t.parent().before(draggingobj.holder.parent()); | ||||
|  | ||||
|                             draggingobj.pagemodule.dragOutSection(draggingobj); | ||||
|                             _this.pagemodule.dragInSection(_this.section, draggingobj, after); | ||||
|                         } | ||||
|                     }); | ||||
|                 } | ||||
|                 else | ||||
|                     drag.children().remove(); | ||||
|  | ||||
|                 if ((templatereadonly || !editable)) | ||||
|                     drag.hide(); | ||||
|             } | ||||
|  | ||||
|             var btnsection = $('<div class="section-icon" style="width: 30px;"><em class="spanbtn iconangleright" style="font-size:18px;"></em></div>'); | ||||
|             btnsection.click(function () { | ||||
|                 var icon = btnsection.find('.spanbtn'); | ||||
|                 if (icon.hasClass('iconangleright')) { | ||||
|                     icon.removeClass('iconangleright').addClass('iconangledown'); | ||||
|  | ||||
|                     if (sectiontype == 0) { | ||||
|                         _this.getQuestions(); | ||||
|                     } | ||||
|                     else | ||||
|                         _this.updateQuestions(_this.section.Questions); | ||||
|                 } | ||||
|                 else { | ||||
|                     if (sectiontype == 1) | ||||
|                         _this.getSectionValue(true, true); | ||||
|                     icon.removeClass('iconangledown').addClass('iconangleright'); | ||||
|                     _this.content.children('.questionitem').remove(); | ||||
|                 } | ||||
|             }); | ||||
|             holder.append(btnsection); | ||||
|             this.txtName = $('<input type="text" class="section-input"  maxlength="100" autocomplete="off" style="width:156px;" />'); | ||||
|             this.txtName.change(function () { | ||||
|                 _this.onsave(); | ||||
|             }); | ||||
|             var addiText = $('<span class="spanbtn iconmultitext" style="font-size:14px;" title="' + GetTextByKey("P_IPT_ADDITIONALTEXTS", "Additional Texts") + '"/>'); | ||||
|             addiText.click(function () { | ||||
|                 Common.createMultiTextDialog(_this.txtName, _this.section); | ||||
|             }); | ||||
|             holder.append($('<div class="section-cell section-name" style="width:200px;flex-grow:0;"></div>').append(this.txtName).append(addiText)); | ||||
|  | ||||
|             this.txtDisplayText = $('<input type="text" class="section-input"  maxlength="200" autocomplete="off" style="width:236px;" />'); | ||||
|             this.txtDisplayText.change(function () { | ||||
|                 _this.onsave(); | ||||
|             }); | ||||
|             addiText = $('<span class="spanbtn iconmultitext" style="font-size:14px;" title="' + GetTextByKey("P_IPT_ADDITIONALTEXTS", "Additional Texts") + '"/>'); | ||||
|             addiText.click(function () { | ||||
|                 Common.createMultiTextDialog(_this.txtDisplayText, _this.section); | ||||
|             }); | ||||
|             var imgicon = $('<span class="spanbtn iconimage" style="font-size:14px;" title="' + GetTextByKey("P_IPT_PICTURES", "Pictures") + '"/>'); | ||||
|             imgicon.click(function (e) { | ||||
|                 var picturemodule = new Picture(false, _this.section, function () { _this.onsave() }); | ||||
|                 picturemodule.createContent(); | ||||
|             }); | ||||
|             holder.append($('<div class="section-cell section-display" style="width:230px;flex-grow: 1;"><span></span></div>').append(this.txtDisplayText).append(addiText).append(imgicon)); | ||||
|             if (sectiontype === 0) | ||||
|                 holder.append($('<div class="section-cell section-createdby" style="text-align:center;"><span></span></div>')); | ||||
|  | ||||
|             var funcs = $('<div class="section-cell section-func" style="width: 120px;text-align:right;padding-right:20px;"></div>'); | ||||
|             holder.append(funcs); | ||||
|  | ||||
|             //holder.find('.section-name span').click(function () { | ||||
|             //    _this.onedit(); | ||||
|             //}); | ||||
|             //holder.find('.section-display span').click(function () { | ||||
|             //    _this.onedit(); | ||||
|             //}); | ||||
|             if (_this.section.IsLink) { | ||||
|                 holder.find('.section-name input').before('<em class="spanbtn iconlink" style="cursor:default;margin:0;padding-left:0;padding-right:2px;font-size:10px;"></em>'); | ||||
|                 holder.find('input').prop('disabled', true); | ||||
|                 holder.find('.iconmultitext').remove(); | ||||
|                 holder.find('.iconimage').remove(); | ||||
|             } | ||||
|  | ||||
|             if (!templatereadonly && editable) { | ||||
|                 if (!_this.section.IsLink) { | ||||
|                     funcs.append($('<em class="spanbtn iconadd"></em>').click(function () { | ||||
|                         //var aq = new AddQuestion(_this, _this.section.Id); | ||||
|                         //if (sectiontype == 0) { | ||||
|                         //    $('#right_popup').empty().append(aq.createContent()); | ||||
|                         //    showRightPopup(true); | ||||
|                         //} | ||||
|                         //else { | ||||
|                         //    aq.onsave = function (question) { | ||||
|                         //        if (!_this.section.Questions) | ||||
|                         //            _this.section.Questions = []; | ||||
|                         //        _this.section.Questions.push(question); | ||||
|  | ||||
|                         //        _this.updateQuestions(_this.section.Questions); | ||||
|                         //    } | ||||
|                         //    $('#right_popup1').empty().append(aq.createContent()).show(); | ||||
|                         //} | ||||
|                         var question = { QuestionType: '0', IsRequired: false, CanComment: false, IsImportant: false, SeverityLevel: 0, LookupSource: 0, SelectItems: [] }; | ||||
|                         _this.section.Questions.push(question); | ||||
|                         _this.addQuestionModule(question); | ||||
|                     }).attr('title', GetTextByKey("P_IPT_ADDQUESTION", 'Add Question'))); | ||||
|                 } | ||||
|                 if (sectiontype == 1 && !_this.section.IsLink) { | ||||
|                     funcs.append($('<em class="spanbtn iconcopy"></em>').click(function () { | ||||
|                         if (_this.oncopy) | ||||
|                             _this.oncopy(_this.getSectionValue(true, true)); | ||||
|                     }).attr('title', GetTextByKey("P_IPT_COPYSECTION", 'Copy Section'))); | ||||
|                 } | ||||
|                 //if (!_this.section.IsLink) { | ||||
|                 //    funcs.append($('<em class="spanbtn iconedit"></em>').click(function () { | ||||
|                 //        _this.onedit(); | ||||
|                 //    }).attr('title', 'Edit Section')); | ||||
|                 //} | ||||
|             } | ||||
|             if ((sectiontype === 0 && !templatereadonly) || (sectiontype === 1 && !templatereadonly && editable)) { | ||||
|                 funcs.append($('<em class="spanbtn icondelete"></em>').click(function () { | ||||
|                     if (sectiontype == 0) { | ||||
|                         _this.delete(); | ||||
|                     } | ||||
|                     else { | ||||
|                         showConfirm(GetTextByKey("P_IPT_AREYOUSUREYOUWANTTODELETETHISSECTION", 'Are you sure you want to delete this section?'), GetTextByKey("P_IPT_DELETESECTION", 'Delete Section'), function () { | ||||
|                             if (_this.ondelete) { | ||||
|                                 _this.content.remove(); | ||||
|                                 _this.ondelete(_this); | ||||
|                             } | ||||
|                         }); | ||||
|                     } | ||||
|                 }).attr('title', GetTextByKey("P_IPT_DELETESECTION", 'Delete Section'))); | ||||
|             } | ||||
|  | ||||
|             this.holder = holder; | ||||
|             this.updateContent(this.section); | ||||
|             if (sectiontype == 1) | ||||
|                 btnsection.click(); | ||||
|  | ||||
|             //this.holder.find('input').attr('draggable', true).bind('dragstart', function (e) {//<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD> | ||||
|             //    e.originalEvent.preventDefault(); | ||||
|             //}); | ||||
|             if (templatereadonly || !editable) { | ||||
|                 this.txtName.prop('disabled', true); | ||||
|                 this.txtDisplayText.prop('disabled', true); | ||||
|  | ||||
|                 this.holder.find(".iconmultitext").hide(); | ||||
|                 this.holder.find(".iconimage").hide(); | ||||
|             } | ||||
|             return content; | ||||
|         }; | ||||
|         s.prototype.onedit = function () { | ||||
|             var _this = this; | ||||
|             var s = new AddSection(_this.gsmodule, _this.section); | ||||
|             if (sectiontype == 0) { | ||||
|                 $('#right_popup').empty().append(s.createContent()); | ||||
|                 showRightPopup(true); | ||||
|             } | ||||
|             else { | ||||
|                 s.onsave = function (section) { | ||||
|                     _this.section.Name = section.Name; | ||||
|                     _this.section.DisplayText = section.DisplayText; | ||||
|                     _this.section.Notes = section.Notes; | ||||
|                     _this.section.LocalNames = section.LocalNames; | ||||
|                     _this.section.LocalDisplayTexts = section.LocalDisplayTexts; | ||||
|  | ||||
|                     _this.updateContent(_this.section); | ||||
|                 } | ||||
|                 $('#right_popup1').empty().append(s.createContent()).show(); | ||||
|             } | ||||
|         } | ||||
|         s.prototype.updateContent = function (section) { | ||||
|             if (section) { | ||||
|                 if (sectiontype === 0) { | ||||
|                     if (!section.IssueId || section.IssueId == "") { | ||||
|                         this.holder.find('.section-packages em').hide(); | ||||
|                         this.holder.find('.section-createdby span').text(''); | ||||
|                     } | ||||
|                     else { | ||||
|                         this.holder.find('.section-packages em').show(); | ||||
|                         this.holder.find('.section-createdby span').text(section.IssueName); | ||||
|                     } | ||||
|                 } | ||||
|                 this.txtName.val(section.Name).data("texts", section.LocalNames); | ||||
|                 this.txtDisplayText.val(section.DisplayText).data("texts", section.LocalDisplayTexts);; | ||||
|             } | ||||
|         }; | ||||
|         s.prototype.getSectionValue = function (noalert, nocheck) { | ||||
|             var section = this.section; | ||||
|             section.Name = this.txtName.val(); | ||||
|             section.DisplayText = this.txtDisplayText.val(); | ||||
|             var alerttitle = GetTextByKey("P_IPT_SECTION", "Section"); | ||||
|             if (!nocheck) { | ||||
|                 if (!section.Name || section.Name.length == 0) { | ||||
|                     if (!noalert) | ||||
|                         showAlert(GetTextByKey("P_IPT_SETIONNAMENOTBEEMPTY", 'Section Name cannot be empty.'), alerttitle); | ||||
|                     return false; | ||||
|                 } | ||||
|                 if (!section.DisplayText || section.DisplayText.length == 0) { | ||||
|                     if (!noalert) | ||||
|                         showAlert(GetTextByKey("P_IPT_SECTIONDISPLAYTEXTNOTBEEMPTY", 'Section Display Text cannot be empty.'), alerttitle); | ||||
|                     return false; | ||||
|                 } | ||||
|             } | ||||
|             var texts = this.txtName.data("texts"); | ||||
|             if (texts) { | ||||
|                 section.LocalNames = texts; | ||||
|             } | ||||
|             texts = this.txtDisplayText.data("texts"); | ||||
|             if (texts) { | ||||
|                 section.LocalDisplayTexts = texts; | ||||
|             } | ||||
|             section.Questions = []; | ||||
|             if (this.questionmodules.length > 0) { | ||||
|                 for (var i = 0; i < this.questionmodules.length; i++) { | ||||
|                     var q = this.questionmodules[i].getQuestionValue(noalert, nocheck); | ||||
|                     if (!q) return false; | ||||
|                     section.Questions.push(q); | ||||
|                 } | ||||
|             } | ||||
|             return section; | ||||
|         }; | ||||
|         s.prototype.updateQuestions = function (questions) { | ||||
|             if (questions == null) { | ||||
|                 return; | ||||
|             } | ||||
|             this.questionmodules = []; | ||||
|             this.content.children('.question-holder').remove(); | ||||
|             for (var i = 0; i < questions.length; i++) { | ||||
|                 this.addQuestionModule(questions[i]); | ||||
|             } | ||||
|         }; | ||||
|         s.prototype.addQuestionModule = function (q) { | ||||
|             var _this = this; | ||||
|             if (this.section.IsLink) | ||||
|                 q.IsLink = true; | ||||
|             var qmodule = new Question(this, q, this.section.Questions.indexOf(q)); | ||||
|             qmodule.oncopy = function (question) { | ||||
|                 _this.oncopyquestion(question); | ||||
|             } | ||||
|             qmodule.ondelete = function (qm) {//qm:question module | ||||
|                 _this.section.Questions.splice(_this.section.Questions.indexOf(qm.question), 1); | ||||
|                 _this.questionmodules.splice(_this.questionmodules.indexOf(qm), 1); | ||||
|             } | ||||
|             this.questionmodules.push(qmodule); | ||||
|             this.content.append(qmodule.createContent()); | ||||
|         }; | ||||
|         s.prototype.oncopyquestion = function (question) { | ||||
|             question = JSON.parse(JSON.stringify(question)); | ||||
|             question.Id = ""; | ||||
|             //question.IsLink = false; | ||||
|             //question.ReferenceId = ""; | ||||
|             if (!this.section.Questions) | ||||
|                 this.section.Questions = []; | ||||
|             this.section.Questions.push(question); | ||||
|             this.addQuestionModule(question); | ||||
|         }; | ||||
|         s.prototype.getQuestions = function () { | ||||
|             var _this = this; | ||||
|             var p = JSON.stringify([teamintelligence, htmlencode(this.section.Id)]); | ||||
|             inspectionrequest("GetGlobalQuestions", p, function (data) { | ||||
|                 if (data) { | ||||
|                     _this.section.Questions = data; | ||||
|                     _this.content.children('.questionitem').remove(); | ||||
|                     _this.updateQuestions(data); | ||||
|                 } | ||||
|             }, function (err) { | ||||
|             }); | ||||
|         }; | ||||
|         s.prototype.delete = function () { | ||||
|             var _this = this; | ||||
|             showConfirm(GetTextByKey("P_IPT_AREYOUSUREYOUWANTTODELETETHISSECTION", 'Are you sure you want to delete this section?'), GetTextByKey("P_IPT_DELETESECTION", 'Delete Section'), function () { | ||||
|                 var p = JSON.stringify([teamintelligence, htmlencode(_this.section.Id)]); | ||||
|                 inspectionrequest("DeleteGlobalSection", p, function (data) { | ||||
|                     if (data !== 'OK') | ||||
|                         showAlert(data, GetTextByKey("P_IPT_DELETESECTION", 'Delete Section')); | ||||
|                     else if (_this.gsmodule && typeof _this.gsmodule.refresh === "function") | ||||
|                         _this.gsmodule.refresh(); | ||||
|                 }, function (err) { | ||||
|                     showAlert(GetTextByKey("P_IPT_FAILEDTODELETESECTION", 'Failed to delete section.'), GetTextByKey("P_IPT_DELETESECTION", 'Delete Section')); | ||||
|                 }); | ||||
|             }); | ||||
|         }; | ||||
|         s.prototype.refresh = function () { | ||||
|             var icon = this.content.find('.spanbtn'); | ||||
|             if (icon.hasClass('iconangledown')) { | ||||
|                 this.getQuestions(); | ||||
|             } | ||||
|         }; | ||||
|         s.prototype.dragOutQuestion = function (qm) {//called when question dragged end at question | ||||
|             var index = this.section.Questions.indexOf(qm.question) | ||||
|             if (index >= 0) { | ||||
|                 this.section.Questions.splice(index, 1); | ||||
|                 this.questionmodules.splice(index, 1); | ||||
|             } | ||||
|         }; | ||||
|         s.prototype.dragInQuestion = function (target, qm, after) {//called when question dragged end at question | ||||
|             qm.sectionmodule = this; | ||||
|             qm.section = this.section; | ||||
|             if (!this.section.Questions) | ||||
|                 this.section.Questions = []; | ||||
|             if (this.section.Questions.length == 0) { | ||||
|                 this.section.Questions.push(qm.question); | ||||
|                 this.questionmodules.push(qm); | ||||
|                 return; | ||||
|             } | ||||
|             var tindex = 0; | ||||
|             if (target) { | ||||
|                 tindex = this.section.Questions.indexOf(target); | ||||
|                 if (after) | ||||
|                     tindex = tindex + 1; | ||||
|             } | ||||
|             if (tindex >= 0) { | ||||
|                 this.section.Questions.splice(tindex, 0, qm.question); | ||||
|                 this.questionmodules.splice(tindex, 0, qm); | ||||
|             } | ||||
|         }; | ||||
|         s.prototype.dragInSection = function () {//called when section dragged end at question | ||||
|             this.holder.parent().after(draggingobj.holder.parent()); | ||||
|             draggingobj.pagemodule.dragOutSection(draggingobj); | ||||
|             this.pagemodule.dragInSection(this.section, draggingobj, true); | ||||
|         }; | ||||
|  | ||||
|         s.prototype.onsave = function () { | ||||
|             if (sectiontype == 1) return; | ||||
|             var item = this.getSectionValue(true); | ||||
|             if (!item) return; | ||||
|             var param = JSON.stringify(item); | ||||
|             param = htmlencode(param); | ||||
|             var p = JSON.stringify([teamintelligence, param]); | ||||
|             var _this = this; | ||||
|             inspectionrequest("SaveGlobalSection", p, function (data) { | ||||
|                 if (typeof (data) === "string") { | ||||
|                     showAlert(data, GetTextByKey("P_IPT_SAVESECTION", 'Save Section')); | ||||
|                 } | ||||
|                 else { | ||||
|                     if (!_this.section) | ||||
|                         _this.section = {}; | ||||
|                     _this.section.Id = data[0]; | ||||
|                 } | ||||
|             }, function (err) { | ||||
|                 showAlert(GetTextByKey("P_IPT_FAILEDTOSAVESECTION", 'Failed to save Section.'), GetTextByKey("P_IPT_SAVESECTION", 'Save Section')); | ||||
|             }); | ||||
|         } | ||||
|         return s; | ||||
|     }); | ||||
							
								
								
									
										202
									
								
								Site/Inspection/js/modules/templates.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										202
									
								
								Site/Inspection/js/modules/templates.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,202 @@ | ||||
| define(['modules/templates/template', 'modules/templates/addtemplate'], function (Template, AddTemplate) { | ||||
|  | ||||
|     var tps = {}; | ||||
|     tps.title = GetTextByKey("P_TEMPLATES", 'Templates'); | ||||
|     tps.description = GetTextByKey("P_TEMPLATES", 'Templates'); | ||||
|     tps.version = '1.0'; | ||||
|  | ||||
|     var datacontent = null; | ||||
|     var searchinputcontrol = undefined; | ||||
|     var makeinputcontrol = undefined; | ||||
|     var modelinputcontrol = undefined; | ||||
|     var typeinputcontrol = undefined; | ||||
|     tps.createContent = function (args) { | ||||
|         sectiontype = 1;//sectiontype:0 - global,1 - normal | ||||
|         if (args && args.length > 0) | ||||
|             templatestatus = eval(args[0]);//templatestatus:0 - draft,1 - published | ||||
|  | ||||
|         //templatereadonly = !IsAdmin; | ||||
|  | ||||
|         var content = $('<div></div>'); | ||||
|  | ||||
|         function createHeader() { | ||||
|             var header = $('<div></div>'); | ||||
|             var title = tps.title + " - " + (templatestatus == 0 ? GetTextByKey("P_DRAFT", 'Draft') : GetTextByKey("P_PUBLISHED", 'Published')) | ||||
|             header.append($('<div class="page_title"></div>').text(title)); | ||||
|             setPageTitle(title, true); | ||||
|             var search_bar = $('<div class="search_bar"></div>'); | ||||
|             header.append(search_bar); | ||||
|             search_bar.append('<input type="password" autocomplete="new-password" style="display: none" />'); | ||||
|             if (!teamintelligence) { | ||||
|                 search_bar.append('<span style="margin-left:10px;">' + GetTextByKey("P_IPT_MAKE_COLON", "Make:") + '</span>'); | ||||
|                 makeinputcontrol = $('<select type="text" style="margin-left: 5px; width:160px;height:22px;" autocomplete="off" />'); | ||||
|                 makeinputcontrol.change(function () { | ||||
|                     showAssetModels(); | ||||
|                 }); | ||||
|                 search_bar.append(makeinputcontrol); | ||||
|                 search_bar.append('<span style="margin-left:10px;">' + GetTextByKey("P_IPT_MODEL_COLON", "Model:") + '</span>'); | ||||
|                 modelinputcontrol = $('<select type="text" style="margin-left: 5px; width:160px;height:22px;" autocomplete="off" />'); | ||||
|                 search_bar.append(modelinputcontrol) | ||||
|                 search_bar.append('<span style="margin-left:10px;">' + GetTextByKey("P_IPT_TYPE_COLON", "Type:") + '</span>'); | ||||
|                 typeinputcontrol = $('<select type="text" style="margin-left: 5px; width:160px;height:22px;" autocomplete="off" />'); | ||||
|                 search_bar.append(typeinputcontrol) | ||||
|  | ||||
|                 getAssetMakes(); | ||||
|                 getAssetModels(); | ||||
|                 getAssetTypes(); | ||||
|             } | ||||
|  | ||||
|             searchinputcontrol = $('<input type="text" autocomplete="off" style="margin-left:10px;" />'); | ||||
|             search_bar.append(searchinputcontrol); | ||||
|             searchinputcontrol.keydown(function (e) { | ||||
|                 if (e.keyCode == 13 || e.keyCode == 9) | ||||
|                     tps.refresh(); | ||||
|             }); | ||||
|             var btnRefresh = $('<input class="search" type="button" value="' + GetTextByKey("P_IPT_SEARCH", "Search") + '" style="margin-left:10px;"/>'); | ||||
|             search_bar.append(btnRefresh); | ||||
|             btnRefresh.click(function () { | ||||
|                 tps.refresh(); | ||||
|             }); | ||||
|  | ||||
|             var func = $('<div class="function_title"></div>'); | ||||
|             if (!templatereadonly) { | ||||
|                 var iconAdd = $('<span class="sbutton iconadd">' + GetTextByKey("P_IPT_ADD", "Add") + '</span>').click(function () { | ||||
|                     editable = true; | ||||
|                     tps.addTemplate(); | ||||
|                 }); | ||||
|                 func.append(iconAdd); | ||||
|             } | ||||
|             var iconRefresh = $('<span class="sbutton iconrefresh">' + GetTextByKey("P_IPT_REFRESH", "Refresh") + '</span>').click(function () { | ||||
|                 tps.refresh(); | ||||
|             }); | ||||
|             func.append(iconRefresh); | ||||
|             header.append(func) | ||||
|  | ||||
|             return header; | ||||
|         } | ||||
|  | ||||
|         content.append(createHeader()); | ||||
|  | ||||
|         var dataheader = $('<div class="question-holder no-hover" style="font-weight: bold;font-size:14px;margin-left:8px;"></div>'); | ||||
|         dataheader.append('<div style="width:30px;flex-shrink:0;"></div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width:400px">' + GetTextByKey("P_IPT_NAME", "Name") + '</div>'); | ||||
|         //dataheader.append('<div class="question-cell" style="width: 200px">Display Text</div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width:400px">' + GetTextByKey("P_IPT_NOTES", "Notes") + '</div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width:200px">' + GetTextByKey("P_IPT_CREATEDBY", "Created By") + '</div>'); | ||||
|         dataheader.append('<div class="question-cell" style="width:90px;padding-right:20px;"></div>'); | ||||
|         content.append(dataheader); | ||||
|  | ||||
|         datacontent = $('<div></div>'); | ||||
|         content.append(datacontent); | ||||
|  | ||||
|         this.refresh(); | ||||
|         return content; | ||||
|     } | ||||
|  | ||||
|     tps.addTemplate = function () { | ||||
|         var s = new AddTemplate(tps); | ||||
|         $('#right_popup').empty().append(s.createContent()); | ||||
|         showRightPopup(true); | ||||
|     } | ||||
|  | ||||
|     tps.refresh = function () { | ||||
|         datacontent.empty(); | ||||
|         var searchtxt = searchinputcontrol.val(); | ||||
|         searchtxt = htmlencode(searchtxt); | ||||
|         var makeid = -1; | ||||
|         var modelid = -1; | ||||
|         var typeid = -1; | ||||
|         if (!teamintelligence) { | ||||
|             makeid = makeinputcontrol.val(); | ||||
|             modelid = modelinputcontrol.val(); | ||||
|             typeid = typeinputcontrol.val(); | ||||
|         } | ||||
|         var p = JSON.stringify([teamintelligence, templatestatus, searchtxt, makeid, modelid, typeid]); | ||||
|  | ||||
|         inspectionrequest("GetTemplates", htmlencode(p), function (data) { | ||||
|             datacontent.empty(); | ||||
|             if (data) { | ||||
|                 for (var i = 0; i < data.length; i++) { | ||||
|                     var s = new Template(tps, data[i], i); | ||||
|                     datacontent.append(s.createContent()); | ||||
|                 } | ||||
|             } | ||||
|         }, function (err) { | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     var makesdata = undefined; | ||||
|     var modelsdata = undefined; | ||||
|     var typesdata = undefined; | ||||
|     function getAssetMakes() { | ||||
|         inspectionrequest("GetAssetMakes", "", function (data) { | ||||
|             if (data && data.length > 0) { | ||||
|                 makesdata = data; | ||||
|                 showAssetMakes(); | ||||
|             } | ||||
|         }, function (err) { | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     function getAssetModels() { | ||||
|         var ps = [-1, ""]; | ||||
|         inspectionrequest("GetAssetModels", JSON.stringify(ps), function (data) { | ||||
|             if (data && data.length > 0) { | ||||
|                 modelsdata = data; | ||||
|                 showAssetModels(); | ||||
|             } | ||||
|  | ||||
|         }, function (err) { | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     function getAssetTypes() { | ||||
|         inspectionrequest("GetAssetTypes", "", function (data) { | ||||
|             if (data && data.length > 0) { | ||||
|                 typesdata = data; | ||||
|                 showAssetTypes(); | ||||
|             } | ||||
|         }, function (err) { | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     function showAssetMakes() { | ||||
|         makeinputcontrol.append('<option value="-1">*</option>'); | ||||
|         if (makesdata && makesdata.length > 0) { | ||||
|             for (var i = 0; i < makesdata.length; i++) { | ||||
|                 var item = makesdata[i]; | ||||
|                 makeinputcontrol.append('<option value="' + item.ID + '">' + item.Name + '</option>'); | ||||
|             } | ||||
|             showAssetModels(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     function showAssetModels() { | ||||
|         modelinputcontrol.empty(); | ||||
|         var makeid = makeinputcontrol.val(); | ||||
|         modelinputcontrol.append('<option value="-1">*</option>'); | ||||
|         if (!makeid || makeid == "-1") | ||||
|             modelinputcontrol.prop('disabled', true); | ||||
|         else | ||||
|             modelinputcontrol.prop('disabled', false); | ||||
|         if (modelsdata && modelsdata.length > 0 && makeid != "-1") { | ||||
|             for (var i = 0; i < modelsdata.length; i++) { | ||||
|                 var item = modelsdata[i]; | ||||
|                 if (item.MakeID == parseInt(makeid)) { | ||||
|                     modelinputcontrol.append('<option value="' + item.ID + '">' + item.Name + '</option>'); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     function showAssetTypes() { | ||||
|         typeinputcontrol.append('<option value="-1">*</option>'); | ||||
|         if (typesdata && typesdata.length > 0) { | ||||
|             for (var i = 0; i < typesdata.length; i++) { | ||||
|                 var item = typesdata[i]; | ||||
|                 typeinputcontrol.append('<option value="' + item.Key + '">' + item.Value + '</option>'); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     return tps; | ||||
| }); | ||||
							
								
								
									
										673
									
								
								Site/Inspection/js/modules/templates/addtemplate.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										673
									
								
								Site/Inspection/js/modules/templates/addtemplate.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,673 @@ | ||||
| define(['modules/templates/pages', 'modules/templates/filters', 'modules/templates/picture'], function (Pages, Filters, Picture) { | ||||
|     var s = function (gs, template) { | ||||
|         this.template = template || {}; | ||||
|         currenttemplate = this.template; | ||||
|         this.gsmodule = gs; | ||||
|         this.datasaved = false; | ||||
|         this.content = null; | ||||
|     }; | ||||
|     s.prototype.description = "Add or edit template"; | ||||
|     s.prototype.version = "1.0.0.0"; | ||||
|  | ||||
|     var namecontrol = undefined; | ||||
|     var locationenabledcontrol = undefined; | ||||
|     var needsignaturecontrol = undefined; | ||||
|     var forworkordercontrol = undefined; | ||||
|     var displaycommittimecontrol = undefined; | ||||
|     var displaycommitbycontrol = undefined; | ||||
|     var displayinspectiontitlecontrol = undefined; | ||||
|     var layoutcontrol = undefined; | ||||
|     var lockedcontrol = undefined; | ||||
|     var notescontrol = undefined; | ||||
|     var otheremailcontrol = undefined; | ||||
|     var pages = undefined; | ||||
|     var filtertd = undefined; | ||||
|     var filtersmodule = undefined; | ||||
|     var picturesdiv = undefined; | ||||
|     var picturesadd = undefined; | ||||
|     var grid_contactdt; | ||||
|     var pagesicon = undefined; | ||||
|     var pagescontent = undefined; | ||||
|  | ||||
|  | ||||
|     s.prototype.createContent = function () { | ||||
|         var content = $('<div style="min-width:1350px;"></div>'); | ||||
|         this.content = content; | ||||
|         var _this = this; | ||||
|         function createHeader() { | ||||
|             var header = $('<div></div>'); | ||||
|  | ||||
|             var func = $('<div class="function_title"></div>'); | ||||
|             if (!templatereadonly) { | ||||
|                 var btn = $('<span class="sbutton iconsave">' + GetTextByKey("P_IPT_SAVE", "Save") + '</span>').click(function () { | ||||
|                     onSave(0, 0); | ||||
|                 }); | ||||
|                 func.append(btn); | ||||
|                 btn = $('<span class="sbutton iconsave">' + GetTextByKey("P_IPT_SAVE1", "Save and Exit") + '</span>').click(function () { | ||||
|                     onSave(1, 0); | ||||
|                 }); | ||||
|                 func.append(btn); | ||||
|                 if ((templatestatus == 0 || (!_this.template.Id && templatestatus == 1)) | ||||
|                     && (!_this.template.Id || _this.template.Editable || IsForesight)) { | ||||
|                     btn = $('<span class="sbutton iconshare">' + GetTextByKey("P_IPT_SAVEANDPUBLISH", "Save and Publish") + '</span>').click(function () { | ||||
|                         onSave(1, 1); | ||||
|                     }); | ||||
|                     func.append(btn); | ||||
|                 } | ||||
|             } | ||||
|             btn = $('<span class="sbutton iconexit">' + GetTextByKey("P_IPT_SAVE2", "Exit Without Saving") + '</span>').click(function () { | ||||
|                 showRightPopup(false); | ||||
|                 if (_this.datasaved) | ||||
|                     _this.gsmodule.refresh(); | ||||
|             }); | ||||
|             func.append(btn); | ||||
|             header.append(func) | ||||
|  | ||||
|             return header; | ||||
|         } | ||||
|  | ||||
|         function createTemplateContent() { | ||||
|             var div_main = $('<div class="content_main" style="overflow: auto;margin-top:5px;"></div>'); | ||||
|             var div_content = $('<div class="edit-content"></div>'); | ||||
|             div_main.append(div_content); | ||||
|             var tb = $('<table></table>'); | ||||
|             div_content.append(tb); | ||||
|  | ||||
|             var tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             var td = $('<td class="label" style="width:160px;"></td>'); | ||||
|             tr.append(td); | ||||
|             //tr.append('<td class="label" style="width:100px;">Name:<span class="redasterisk">*</span></td>'); | ||||
|  | ||||
|             var btnsummary = $('<span class="section-icon" style="width:30px;margin-left:8px;margin-right:10px;font-size:18px;color:#666;cursor:pointer;">' + GetTextByKey("P_IPT_SUMMARY", "Summary") + '<em class="spanbtn iconangledown" style="font-size:18px;color:#666;"></em></span>'); | ||||
|             btnsummary.click(function () { | ||||
|                 var icon = btnsummary.find('.spanbtn'); | ||||
|                 if (icon.hasClass('iconangledown')) { | ||||
|                     icon.removeClass('iconangledown').addClass('iconangleright'); | ||||
|                     _this.content.find('.templatetr').hide(); | ||||
|                 } | ||||
|                 else { | ||||
|                     icon.removeClass('iconangleright').addClass('iconangledown'); | ||||
|                     _this.content.find('.templatetr').show(); | ||||
|                 } | ||||
|             }); | ||||
|             td.append(btnsummary).append('<span>' + GetTextByKey("P_IPT_NAME_COLON", "Name:") + '</span><span class="redasterisk">*</span>'); | ||||
|  | ||||
|             namecontrol = $('<input type="text" class="form-control" maxlength="100" autocomplete="off"/>'); | ||||
|             tr.append($('<td></td>').append(namecontrol)); | ||||
|  | ||||
|             tr = $('<tr class="templatetr"></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label" style="width:160px;">' + GetTextByKey("P_IPT_LOCATIONENABLED_COLON", "Location Enabled:") + '</td>'); | ||||
|             locationenabledcontrol = $('<input type="checkbox"/>'); | ||||
|             needsignaturecontrol = $('<input type="checkbox"/>'); | ||||
|             var td = $('<td></td>').append( | ||||
|                 locationenabledcontrol, | ||||
|                 $('<span style="margin-left:40px"></span>').text(GetTextByKey("P_IPT_SIGNATUREREQUIRED_COLON", "Signature Required:")), | ||||
|                 needsignaturecontrol | ||||
|             ); | ||||
|             if (!teamintelligence) { | ||||
|                 td.append($('<span style="margin-left:40px"></span>').text(GetTextByKey("P_IPT_FORWORKORDER_COLON", "For Work Order:"))); | ||||
|                 forworkordercontrol = $('<input type="checkbox"/>'); | ||||
|                 td.append(forworkordercontrol); | ||||
|             } | ||||
|             tr.append(td); | ||||
|  | ||||
|             tr = $('<tr class="templatetr"></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label" style="width:160px;">' + GetTextByKey("P_IPT_XXXXX_COLON", "Display Commit Time:") + '</td>'); | ||||
|             displaycommittimecontrol = $('<input type="checkbox" checked="checked"/>'); | ||||
|             displaycommitbycontrol = $('<input type="checkbox" checked="checked"/>'); | ||||
|             displayinspectiontitlecontrol = $('<input type="checkbox" checked="checked"/>'); | ||||
|             var td = $('<td></td>').append( | ||||
|                 displaycommittimecontrol, | ||||
|                 $('<span style="margin-left:40px"></span>').text(GetTextByKey("P_IPT_XXXXXX_COLON", "Display Commit By:")), | ||||
|                 displaycommitbycontrol, | ||||
|                 $('<span style="margin-left:40px"></span>').text(GetTextByKey("P_IPT_XXXXXX_COLON", "Display Inspection Title:")), | ||||
|                 displayinspectiontitlecontrol | ||||
|             ); | ||||
|             tr.append(td); | ||||
|  | ||||
|             tr = $('<tr class="templatetr"></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append($('<td class="label" style="width:160px;"></td>').text(GetTextByKey("P_LAYOUT_COLON", "Layout:"))); | ||||
|             layoutcontrol = $('<select id="select-layout" class="form-control" style="height: 24px"></select>'); | ||||
|             tr.append($('<td></td>').append(layoutcontrol)); | ||||
|  | ||||
|             if (!teamintelligence) { | ||||
|                 tr = $('<tr class="templatetr" style="height:30px;"></tr>'); | ||||
|                 tb.append(tr); | ||||
|                 tr.append('<td class="label" style="width:160px;vertical-align:top;">' + GetTextByKey("P_IPT_FILTER_COLON", "Filter:") + '</td>') | ||||
|                     .attr("title", GetTextByKey("P_IPT_FILTERTOOLTIPS", "Multiple filters can be applied that act as independent assignments")); | ||||
|                 filtertd = $('<td></td>'); | ||||
|                 tr.append(filtertd); | ||||
|             } | ||||
|  | ||||
|             picturesdiv = $('<div style="width:540px;"><div>'); | ||||
|             tr = $('<tr class="templatetr" style="height:30px;"></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label" style="width:160px;vertical-align:top;">' + GetTextByKey("P_IPT_PICTURE_COLON", "Picture:") + '</td>'); | ||||
|             picturesadd = $('<span class="sbutton iconadd">' + GetTextByKey("P_IPT_ADD", "Add") + '</span>').click(function () { | ||||
|                 var picturemodule = new Picture(true, _this.template, setPictures); | ||||
|                 picturemodule.createContent(); | ||||
|             }); | ||||
|             tr.append($('<td></td>').append(picturesadd)); | ||||
|             tr = $('<tr class="templatetr" style="height:30px;"></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label" style="width:160px;vertical-align:top;"></td>'); | ||||
|             tr.append($('<td></td>').append(picturesdiv)); | ||||
|  | ||||
|             if (IsForesight) { | ||||
|                 tr = $('<tr class="templatetr"></tr>'); | ||||
|                 tb.append(tr); | ||||
|                 tr.append('<td class="label" style="width:160px;">' + GetTextByKey("P_IPT_LOCKED_COLON", "Locked:") + '</td>'); | ||||
|                 lockedcontrol = $('<input type="checkbox"/>'); | ||||
|                 lockedcontrol.prop('checked', false); | ||||
|                 tr.append($('<td></td>').append(lockedcontrol)); | ||||
|                 lockedcontrol.click(function () { | ||||
|                     editable = !$(this).prop("checked"); | ||||
|                     _this.template.Editable = editable; | ||||
|                     updateContent(); | ||||
|                 }); | ||||
|             } | ||||
|  | ||||
|             tr = $('<tr class="templatetr"></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label" style="width:160px;">' + GetTextByKey("P_IPT_NOTES_COLON", "Notes:") + '</td>'); | ||||
|             notescontrol = $('<textarea id="dialog_notes" class="inputbox form-control" maxlength="500" autocomplete="off" style="width: 540px; margin-top: 6px;height:80px;"></textarea>'); | ||||
|             tr.append($('<td></td>').append(notescontrol)); | ||||
|  | ||||
|             //Email  | ||||
|             tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             td = $('<td class="label" style="width:160px;"></td>'); | ||||
|             tr.append(td); | ||||
|             var btnemail = $('<span class="section-icon" style="float:left;width:65px;margin-left:42px;margin-top:10px;margin-right:10px;font-size:18px;color:#666;cursor:pointer;">' + GetTextByKey("P_IPT_EMAIL", "Email") + '<em class="spanbtn iconangledown" style="font-size:18px;color:#666;"></em></span>'); | ||||
|             btnemail.click(function () { | ||||
|                 var icon = btnemail.find('.spanbtn'); | ||||
|                 if (icon.hasClass('iconangledown')) { | ||||
|                     icon.removeClass('iconangledown').addClass('iconangleright'); | ||||
|                     _this.content.find('.emailtd').hide(); | ||||
|                 } | ||||
|                 else { | ||||
|                     icon.removeClass('iconangleright').addClass('iconangledown'); | ||||
|                     _this.content.find('.emailtd').show(); | ||||
|                 } | ||||
|             }); | ||||
|             td.append(btnemail); | ||||
|  | ||||
|             tr.append($('<td class="emailtd"></td>').append(createEmailContent())); | ||||
|  | ||||
|  | ||||
|             return div_main; | ||||
|         } | ||||
|  | ||||
|         function createEmailContent() { | ||||
|             var tb = $('<table style="line-height:25px;margin-top:10px;"></table>'); | ||||
|  | ||||
|             var tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append($('<td>' + GetTextByKey('P_IPT_SENDTHISTO', 'Who do you want to send this to? Select from existing relationships or manual entry.') + '</td>')); | ||||
|  | ||||
|             tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append($('<td></td>').append(InitContactGridData())); | ||||
|  | ||||
|             tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append($('<td>' + GetTextByKey("P_IPT_EMAILADDRESSESTIPS", "Separate multiple manually entered email addresses with a semi-colon (;).") + '</td>')); | ||||
|  | ||||
|             tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             otheremailcontrol = $('<input type="text" class="form-control" maxlength="1000" autocomplete="off" style="margin-left:5px;width: 312px;" autocomplete="off" />'); | ||||
|             tr.append($('<td><span>' + GetTextByKey("P_IPT_OTHEREMAILADDRESS", "Other Email Address") + '</span></td>').append(otheremailcontrol)); | ||||
|  | ||||
|             td = $('<td></td>'); | ||||
|             tr.append(td); | ||||
|  | ||||
|             return tb; | ||||
|         } | ||||
|  | ||||
|         function InitContactGridData() { | ||||
|             var div_grid = $('<div style="width:430px;height:160px;"></div>'); | ||||
|             grid_contactdt = new GridView(div_grid); | ||||
|             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: 'UserName', caption: GetTextByKey("P_IPT_CONTACTNAME", "Contact Name"), valueIndex: 'UserName', css: { 'width': 180, 'text-align': 'left' } }, | ||||
|                 { name: 'ContactType', caption: GetTextByKey("P_IPT_CONTACTTYPE", "Contact Type"), valueIndex: 'ContactType', css: { 'width': 180, 'text-align': 'left' } }, | ||||
|                 //{ name: 'Text', caption: "Text", valueIndex: 'Text', type: 3, css: { 'width': 45, 'text-align': 'center' } }, | ||||
|                 { name: 'Selected', caption: GetTextByKey("P_IPT_EMAIL", "Email"), valueIndex: 'Selected', type: 3, css: { 'width': 45, '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 (list_columns[hd].type) { | ||||
|                     col.type = list_columns[hd].type; | ||||
|                 } | ||||
|                 columns.push(col); | ||||
|                 if (col.name === "Email") { | ||||
|                     col.attrs = function (item) { | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             grid_contactdt.canMultiSelect = false; | ||||
|             grid_contactdt.columns = columns; | ||||
|             grid_contactdt.init(); | ||||
|  | ||||
|             grid_contactdt.selectedrowchanged = function (rowindex) { | ||||
|                 var rowdata = grid_contactdt.source[rowindex]; | ||||
|                 if (rowdata) { | ||||
|                 } | ||||
|             } | ||||
|             return div_grid; | ||||
|         } | ||||
|  | ||||
|         function GetInspectEmailList() { | ||||
|             inspectionrequest("GetInspectEmailList", teamintelligence, function (data) { | ||||
|                 if (typeof (data) !== "string") { | ||||
|                     showInspectEmailList(data); | ||||
|                 } | ||||
|             }, function (err) { | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function getReportLayouts() { | ||||
|             inspectionrequest('GetInspectLayouts', JSON.stringify([teamintelligence ? 1 : 0, '']), function (data) { | ||||
|                 if ($.isArray(data)) { | ||||
|                     var sid = _this.template && _this.template.ReportLayoutId; | ||||
|                     layoutcontrol.empty().append($('<option value=""> </option>').prop('selected', sid == null || sid == '')); | ||||
|                     for (var l of data) { | ||||
|                         layoutcontrol.append($('<option></option>').val(l.Id).text(l.Name).prop('selected', sid == l.Id)); | ||||
|                     } | ||||
|                 } | ||||
|             }, function () { }); | ||||
|         } | ||||
|  | ||||
|         function showInspectEmailList(data) { | ||||
|             var rows = []; | ||||
|             for (var i = 0; i < data.length; i++) { | ||||
|                 var r = data[i]; | ||||
|                 r.Selected = false; | ||||
|                 if (_this.template && _this.template.EmailList) { | ||||
|                     for (var j = 0; j < _this.template.EmailList.length; j++) { | ||||
|                         if (r.UserIID.toLowerCase() == _this.template.EmailList[j].UserIID.toLowerCase()) { | ||||
|                             r.Selected = true; | ||||
|                             break; | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|                 var fr = { Values: r }; | ||||
|                 rows.push(fr); | ||||
|             } | ||||
|  | ||||
|             grid_contactdt.setData(rows); | ||||
|         } | ||||
|  | ||||
|         function getTemplateInfo(id) { | ||||
|             var p = JSON.stringify([teamintelligence, htmlencode(id)]); | ||||
|             inspectionrequest("GetTemplate", p, function (data) { | ||||
|                 if (typeof (data) !== "string") { | ||||
|                     _this.template = data; | ||||
|                     currenttemplate = _this.template; | ||||
|                     getReportLayouts(); | ||||
|                     GetInspectEmailList(); | ||||
|                     updateContent(); | ||||
|                 } | ||||
|             }, function (err) { | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function updateContent() { | ||||
|             if (pagesicon) { | ||||
|                 pagesicon.remove(); | ||||
|                 pagesicon = undefined; | ||||
|             } | ||||
|             if (pagescontent) { | ||||
|                 pagescontent.remove(); | ||||
|                 pagescontent = undefined; | ||||
|             } | ||||
|             if (filtertd) | ||||
|                 filtertd.empty(); | ||||
|  | ||||
|             pagesicon = $('<div class="section-icon" style="width:30px;margin:10px 0 5px 15px;font-size:18px;color:#666;">' + GetTextByKey("P_IPT_PAGES", "Pages") + '</div>'); | ||||
|             content.append(pagesicon); | ||||
|             var template = _this.template; | ||||
|  | ||||
|             if (template.Id) { | ||||
|                 if ((!template.IssueId || template.IssueId == "") && (template.Editable)) | ||||
|                     editable = true; | ||||
|                 else | ||||
|                     editable = false; | ||||
|  | ||||
|                 namecontrol.val(template.Name); | ||||
|                 locationenabledcontrol.prop('checked', template.LocationEnabled); | ||||
|                 needsignaturecontrol.prop('checked', template.NeedSignature); | ||||
|                 if (forworkordercontrol) | ||||
|                     forworkordercontrol.prop('checked', template.ForWorkOrder); | ||||
|  | ||||
|                 displaycommittimecontrol.prop('checked', template.DisplayCommitTime); | ||||
|                 displaycommitbycontrol.prop('checked', template.DisplayCommitBy); | ||||
|                 displayinspectiontitlecontrol.prop('checked', template.DisplayInspectionTitle); | ||||
|  | ||||
|                 layoutcontrol.val(template.ReportLayoutId); | ||||
|                 if (IsForesight) { | ||||
|                     lockedcontrol.prop('checked', !template.Editable); | ||||
|                     if (template.IssueId && template.IssueId != "") | ||||
|                         lockedcontrol.prop('disabled', true); | ||||
|                 } | ||||
|  | ||||
|                 notescontrol.val(template.Notes); | ||||
|                 otheremailcontrol.val(template.Emails); | ||||
|                 setPictures(); | ||||
|                 var next = function () { | ||||
|                     pages = new Pages(template.Pages); | ||||
|                     pagescontent = pages.createContent(); | ||||
|                     content.append(pagescontent); | ||||
|                     if (!teamintelligence) { | ||||
|                         filtersmodule = new Filters(template.Filters) | ||||
|                         filtertd.append(filtersmodule.createContent(template)); | ||||
|                     } | ||||
|                 }; | ||||
|                 inspectionrequest("GetFuelTypes", '', function (data) { | ||||
|                     if ($.isArray(data)) { | ||||
|                         window.fuelTypes = data; | ||||
|                     } | ||||
|                     next(); | ||||
|                 }, function () { | ||||
|                     // TODO: network error | ||||
|                 }); | ||||
|             } | ||||
|             else { | ||||
|                 var next = function () { | ||||
|                     pages = new Pages(); | ||||
|                     pagescontent = pages.createContent(); | ||||
|                     content.append(pagescontent); | ||||
|                     if (!teamintelligence) { | ||||
|                         filtersmodule = new Filters() | ||||
|                         filtertd.append(filtersmodule.createContent()); | ||||
|                     } | ||||
|                 }; | ||||
|                 inspectionrequest("GetFuelTypes", '', function (data) { | ||||
|                     if ($.isArray(data)) { | ||||
|                         window.fuelTypes = data; | ||||
|                     } | ||||
|                     next(); | ||||
|                 }, function () { | ||||
|                     // TODO: network error | ||||
|                 }); | ||||
|             } | ||||
|  | ||||
|             setEditable(); | ||||
|         } | ||||
|  | ||||
|         function setPictures() { | ||||
|             $(picturesdiv).empty(); | ||||
|             if (_this.template.StaticPictures && _this.template.StaticPictures.length > 0) { | ||||
|                 for (var i = 0; i < _this.template.StaticPictures.length; i++) { | ||||
|                     var p = _this.template.StaticPictures[i]; | ||||
|                     var img = $('<img style="width:40px;height:40px;margin-left:5px;"/>').attr('src', p.Url).attr('title', p.Name); | ||||
|                     $(picturesdiv).append(img); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function setEditable() { | ||||
|             if (editable) { | ||||
|                 namecontrol.prop('disabled', false); | ||||
|                 locationenabledcontrol.prop('disabled', false); | ||||
|                 needsignaturecontrol.prop('disabled', false); | ||||
|  | ||||
|                 if (forworkordercontrol) | ||||
|                     forworkordercontrol.prop('disabled', false); | ||||
|  | ||||
|                 displaycommittimecontrol.prop('disabled', false); | ||||
|                 displaycommitbycontrol.prop('disabled', false); | ||||
|                 displayinspectiontitlecontrol.prop('disabled', false); | ||||
|  | ||||
|                 layoutcontrol.prop('disabled', false); | ||||
|                 notescontrol.prop('disabled', false); | ||||
|                 picturesadd.show(); | ||||
|             } | ||||
|             else { | ||||
|                 namecontrol.prop('disabled', true); | ||||
|                 locationenabledcontrol.prop('disabled', true); | ||||
|                 needsignaturecontrol.prop('disabled', true); | ||||
|                 if (forworkordercontrol) | ||||
|                     forworkordercontrol.prop('disabled', true); | ||||
|  | ||||
|                 displaycommittimecontrol.prop('disabled', true); | ||||
|                 displaycommitbycontrol.prop('disabled', true); | ||||
|                 displayinspectiontitlecontrol.prop('disabled', true); | ||||
|  | ||||
|                 layoutcontrol.prop('disabled', true); | ||||
|                 notescontrol.prop('disabled', true); | ||||
|                 picturesadd.hide(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function setDisabled() { | ||||
|             namecontrol.prop('disabled', true); | ||||
|             locationenabledcontrol.prop('disabled', true); | ||||
|             needsignaturecontrol.prop('disabled', true); | ||||
|             if (forworkordercontrol) | ||||
|                 forworkordercontrol.prop('disabled', true); | ||||
|  | ||||
|             displaycommittimecontrol.prop('disabled', true); | ||||
|             displaycommitbycontrol.prop('disabled', true); | ||||
|             displayinspectiontitlecontrol.prop('disabled', true); | ||||
|  | ||||
|             layoutcontrol.prop('disabled', true); | ||||
|             notescontrol.prop('disabled', true); | ||||
|             otheremailcontrol.prop('disabled', true); | ||||
|             if (IsForesight) | ||||
|                 lockedcontrol.prop('disabled', true); | ||||
|         } | ||||
|  | ||||
|         function CheckEmail(mail) { | ||||
|             var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; | ||||
|             if (mail.length == 0) | ||||
|                 return true; | ||||
|             return filter.test(mail); | ||||
|         } | ||||
|  | ||||
|         function getSubTypeName(type) { | ||||
|             var typename = ""; | ||||
|             if (type === "0") | ||||
|                 typename = GetTextByKey("P_IPT_ST_TRANSACTIONDATE", "Transaction Date"); | ||||
|             if (type === "1") | ||||
|                 typename = GetTextByKey("P_IPT_ST_TICKETRECEIPTNUMBER", "Ticket/Receipt Number"); | ||||
|             if (type === "2") | ||||
|                 typename = GetTextByKey("P_IPT_ST_DRIVERNAME", "Driver Name"); | ||||
|             else if (type === "3") | ||||
|                 typename = GetTextByKey("P_IPT_ST_RETAILERNAME", "Retailer Name"); | ||||
|             else if (type === "4") | ||||
|                 typename = GetTextByKey("P_IPT_ST_RETAILERADDRESS", "Retailer Address"); | ||||
|             else if (type === "5") | ||||
|                 typename = GetTextByKey("P_IPT_ST_CITY", "City"); | ||||
|             else if (type === "6") | ||||
|                 typename = GetTextByKey("P_IPT_ST_STATE", "State"); | ||||
|             else if (type === "7") | ||||
|                 typename = GetTextByKey("P_IPT_ST_ZIP", "Zip"); | ||||
|             else if (type === "8") | ||||
|                 typename = GetTextByKey("P_IPT_ST_ODOMETER", "Odometer"); | ||||
|             else if (type === "9") | ||||
|                 typename = GetTextByKey("P_IPT_ST_FUELTYPE", "Fuel Type"); | ||||
|             else if (type === "10") | ||||
|                 typename = GetTextByKey("P_IPT_ST_QUANTITY", "Quantity"); | ||||
|             else if (type === "11") | ||||
|                 typename = GetTextByKey("P_IPT_ST_UOMCOST", "Unit Cost"); | ||||
|             else if (type === "12") | ||||
|                 typename = GetTextByKey("P_IPT_ST_TOTALCOST", "Total Cost"); | ||||
|             else if (type === "13") | ||||
|                 typename = GetTextByKey("P_IPT_ST_BRANDNAME", "Brand Name"); | ||||
|             else if (type === "14") | ||||
|                 typename = GetTextByKey("P_IPT_ST_NOTES", "Notes"); | ||||
|             else if (type === "15") | ||||
|                 typename = GetTextByKey("P_IPT_ST_PICTURE", "Picture"); | ||||
|             else if (type === "16") | ||||
|                 typename = GetTextByKey("P_IPT_ST_DISTRIBUTEDBY", "Distributed By"); | ||||
|             return typename; | ||||
|         } | ||||
|  | ||||
|         function onSave(exit, publish) { | ||||
|             var item = { | ||||
|                 'Name': namecontrol.val(), | ||||
|                 'LocationEnabled': locationenabledcontrol.prop('checked'), | ||||
|                 'NeedSignature': needsignaturecontrol.prop('checked'), | ||||
|                 'ReportLayoutId': layoutcontrol.val(), | ||||
|                 'DisplayCommitTime': displaycommittimecontrol.prop('checked'), | ||||
|                 'DisplayCommitBy': displaycommitbycontrol.prop('checked'), | ||||
|                 'DisplayInspectionTitle': displayinspectiontitlecontrol.prop('checked'), | ||||
|                 'Notes': notescontrol.val() | ||||
|             }; | ||||
|             if (forworkordercontrol) | ||||
|                 item.ForWorkOrder = forworkordercontrol.prop('checked'); | ||||
|  | ||||
|             if (teamintelligence) | ||||
|                 item.Target = 1; | ||||
|  | ||||
|             var alerttitle; | ||||
|             if (_this.template.Id) { | ||||
|                 item.Id = _this.template.Id; | ||||
|                 item.Editable = _this.template.Editable; | ||||
|                 item.IssueId = _this.template.IssueId; | ||||
|                 alerttitle = GetTextByKey("P_IPT_EDITTEMPLATE", "Edit Template"); | ||||
|             } else { | ||||
|                 item.Id = -1; | ||||
|                 item.Editable = true; | ||||
|                 alerttitle = GetTextByKey("P_IPT_ADDTEMPLATE", "Add Template"); | ||||
|             } | ||||
|  | ||||
|             if (IsForesight) | ||||
|                 item.Editable = !lockedcontrol.prop('checked'); | ||||
|  | ||||
|             if (publish === 1) | ||||
|                 item.Status = 1; | ||||
|             else if (_this.template && _this.template.Status == 1) | ||||
|                 item.Status = 1; | ||||
|             else | ||||
|                 item.Status = 0; | ||||
|  | ||||
|             if (!item.Name || item.Name.length == 0) { | ||||
|                 showAlert(GetTextByKey("P_IPT_NAMENOTBEEMPTY", 'Name cannot be empty.'), alerttitle); | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
|             //email | ||||
|             var emailaddress = []; | ||||
|             var otheremailaddressstr = otheremailcontrol.val(); | ||||
|             if (otheremailaddressstr !== "") | ||||
|                 emailaddress = otheremailaddressstr.split(';'); | ||||
|             item.Emails = ""; | ||||
|             for (var i = 0; i < emailaddress.length; i++) { | ||||
|                 var email = $.trim(emailaddress[i]); | ||||
|                 if (!CheckEmail(email)) { | ||||
|                     showAlert(GetTextByKey('P_IPT_OTHEREMAILADDRESSISINVALID', 'The other email address {0} is invalid.').replace('{0}', emailaddress[i]), alerttitle); | ||||
|                     return; | ||||
|                 } | ||||
|                 if (item.Emails === "") | ||||
|                     item.Emails = email; | ||||
|                 else | ||||
|                     item.Emails = item.Emails + ";" + email; | ||||
|             } | ||||
|             item.Emails = otheremailaddressstr; | ||||
|             item.EmailList = []; | ||||
|             for (var i = 0; i < grid_contactdt.source.length; i++) { | ||||
|                 var ct = grid_contactdt.source[i].Values; | ||||
|                 if (ct.Selected) | ||||
|                     item.EmailList.push(ct); | ||||
|             } | ||||
|  | ||||
|             if (pages) { | ||||
|                 item.Pages = pages.getPagesValue(); | ||||
|                 if (!item.Pages) | ||||
|                     return; | ||||
|  | ||||
|                 var subtypes = []; | ||||
|                 for (var i = 0; i < item.Pages.length; i++) { | ||||
|                     var page = item.Pages[i]; | ||||
|                     for (var j = 0; j < page.Sections.length; j++) { | ||||
|                         var section = page.Sections[j]; | ||||
|                         for (var k = 0; k < section.Questions.length; k++) { | ||||
|                             var question = section.Questions[k]; | ||||
|                             if (question.QuestionType == "15" && question.SubType !== "15") { | ||||
|                                 var type = question.SubType; | ||||
|  | ||||
|                                 if (subtypes.indexOf(type) >= 0) { | ||||
|                                     var typename = getSubTypeName(type); | ||||
|                                     showAlert(GetTextByKey("P_IPT_ONLYONEQUESTIONCANBEINCLUDEDINTHETEMPLATE", "Only one {0} question can be included in the template.").replace('{0}', typename), GetTextByKey("P_IPT_SAVETEMPLATE", 'Save Template')); | ||||
|                                     return; | ||||
|                                 } | ||||
|                                 else | ||||
|                                     subtypes.push(type); | ||||
|                             } | ||||
|                             if (question.QuestionType == "17" && question.IsRequired == true && (!question.TextToCompare || question.TextToCompare.length == 0)) { | ||||
|                                 showAlert(GetTextByKey("P_IPT_TEXTTPCOMPARENOTBEEMPTY", "Text to compare cannot be empty."), GetTextByKey("P_IPT_SAVETEMPLATE", 'Save Template')); | ||||
|                                 return; | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             item.Filters = []; | ||||
|             if (!teamintelligence && filtersmodule) { | ||||
|                 item.Filters = filtersmodule.getFiltersValue(); | ||||
|             } | ||||
|  | ||||
|             item.StaticPictures = _this.template.StaticPictures; | ||||
|  | ||||
|             var param = JSON.stringify(item); | ||||
|             var p = JSON.stringify([teamintelligence, htmlencode(param)]); | ||||
|  | ||||
|             inspectionrequest("SaveTemplate", p, function (data) { | ||||
|                 if (typeof (data) === "string") { | ||||
|                     showAlert(data, GetTextByKey("P_IPT_SAVETEMPLATE", 'Save Template')); | ||||
|                 } else { | ||||
|                     if (!_this.template.Id) { | ||||
|                         _this.template.Id = data[0]; | ||||
|                     } | ||||
|                     if (exit == 0) { | ||||
|                         showAlert(GetTextByKey("P_IPT_SAVSUCCESSFULLY", 'Saved successfully.'), GetTextByKey("P_IPT_SAVETEMPLATE", 'Save Template')); | ||||
|                         _this.datasaved = true; | ||||
|                     } | ||||
|                     if (exit == 1) { | ||||
|                         _this.gsmodule.refresh(); | ||||
|                         showRightPopup(false); | ||||
|                     } | ||||
|                 } | ||||
|             }, function (err) { | ||||
|                 showAlert(GetTextByKey("P_IPT_FAILEDTOSAVETEMPLATE", 'Failed to save Template.'), GetTextByKey("P_IPT_SAVETEMPLATE", 'Save Template')); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         content.append(createHeader()); | ||||
|         content.append(createTemplateContent()); | ||||
|  | ||||
|         if (this.template.Id) | ||||
|             getTemplateInfo(this.template.Id); | ||||
|         else { | ||||
|             getReportLayouts(); | ||||
|             GetInspectEmailList(); | ||||
|             updateContent(); | ||||
|         } | ||||
|  | ||||
|         if (templatereadonly) | ||||
|             setDisabled(); | ||||
|         return content; | ||||
|     } | ||||
|     return s; | ||||
| }); | ||||
|  | ||||
							
								
								
									
										317
									
								
								Site/Inspection/js/modules/templates/filters.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										317
									
								
								Site/Inspection/js/modules/templates/filters.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,317 @@ | ||||
| define(['common'], function (Common) { | ||||
|     /************filters module***************/ | ||||
|     var addfilterctrl = null; | ||||
|  | ||||
|     var fsm = function (filters) { | ||||
|         this.filters = filters || []; | ||||
|         this.holder = null; | ||||
|         this.filterModules = []; | ||||
|     }; | ||||
|     fsm.prototype.description = "Template filters module"; | ||||
|     fsm.prototype.version = "1.0.0.0"; | ||||
|  | ||||
|     fsm.prototype.createContent = function () { | ||||
|         var _this = this; | ||||
|         this.holder = $('<div></div>'); | ||||
|  | ||||
|         if (!templatereadonly && editable) { | ||||
|             var btnAddfilter = $('<span class="sbutton iconadd">' + GetTextByKey("P_IPT_ADD", "Add") + '</span>').click(function () { | ||||
|                 if (!addfilterctrl) | ||||
|                     addfilterctrl = new addfilter(); | ||||
|                 addfilterctrl.beginEdit(null, function (f) { | ||||
|                     _this.showFilter(f); | ||||
|                 }); | ||||
|             }); | ||||
|             this.holder.append($('<div style="margin-top:4px;"></div>').append(btnAddfilter)); | ||||
|         } | ||||
|  | ||||
|         if (this.filters) { | ||||
|             for (var i = 0; i < _this.filters.length; i++) { | ||||
|                 this.showFilter(_this.filters[i]); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return this.holder; | ||||
|     } | ||||
|  | ||||
|     fsm.prototype.getFiltersValue = function () { | ||||
|         var fs = []; | ||||
|         for (var i = 0; i < this.filterModules.length; i++) { | ||||
|             fs.push(this.filterModules[i].getFilterValue()); | ||||
|         } | ||||
|         return fs; | ||||
|     } | ||||
|  | ||||
|     fsm.prototype.showFilter = function (filter) { | ||||
|         var _this = this; | ||||
|         var temp = new fm(filter); | ||||
|         temp.ondelete = function (f) { | ||||
|             _this.filters.splice(_this.filters.indexOf(f.filter), 1); | ||||
|             _this.filterModules.splice(_this.filterModules.indexOf(f), 1); | ||||
|         } | ||||
|         _this.filterModules.push(temp); | ||||
|         this.holder.append(temp.createContent()); | ||||
|     } | ||||
|     /************end filters module***************/ | ||||
|  | ||||
|     /************filter module***************/ | ||||
|     var fm = function (filter) { | ||||
|         this.filter = filter; | ||||
|         this.holder = null; | ||||
|         this.txtvin = null; | ||||
|         this.txtmake = null; | ||||
|         this.txtmodel = null; | ||||
|         this.txttype = null; | ||||
|         this.ondelete = null; | ||||
|     }; | ||||
|     fm.prototype.description = "Template filter module"; | ||||
|     fm.prototype.version = "1.0.0.0"; | ||||
|  | ||||
|     fm.prototype.createContent = function () { | ||||
|         var _this = this; | ||||
|  | ||||
|         var tb = $('<table style="border:1px solid #a8a8a8;margin-top:2px; width:810px;line-height:30px;table-layout:fixed;white-space:nowrap;"></table>'); | ||||
|         _this.holder = tb; | ||||
|         var tr = $('<tr></tr>'); | ||||
|         tb.append(tr); | ||||
|  | ||||
|         tr.append($('<td style="width:90px;text-align:right;">' + GetTextByKey("P_IPT_VINSN_COLON", "VIN/SN:") + '</td>')); | ||||
|         this.txtvin = $('<td style="width:160px;padding-left:5px;overflow:hidden;"></td>'); | ||||
|         tr.append(this.txtvin); | ||||
|  | ||||
|         tr.append($('<td style="width:95px;text-align:right;">' + GetTextByKey("P_IPT_MAKE_COLON", "Make:") + '</td>')); | ||||
|         this.txtmake = $('<td style="width:120px;padding-left:5px;overflow:hidden;"></td>'); | ||||
|         tr.append(this.txtmake); | ||||
|  | ||||
|         tr.append($('<td style="width:100px;text-align:right;">' + GetTextByKey("P_IPT_MODEL_COLON", "Model:") + '</td>')); | ||||
|         this.txtmodel = $('<td style="width:120px;padding-left:5px;overflow:hidden;"></td>'); | ||||
|         tr.append(this.txtmodel); | ||||
|  | ||||
|         tr.append($('<td style="width:115px;text-align:right;">' + GetTextByKey("P_IPT_ASSETTYPE_COLON", "Asset Type:") + '</td>')); | ||||
|         this.txttype = $('<td style="width:120px;padding-left:5px;overflow:hidden;"></td>'); | ||||
|         tr.append(this.txttype); | ||||
|  | ||||
|         var btnedit = $('<em class="spanbtn iconedit"></em>').click(function () { | ||||
|             _this.editFilter(); | ||||
|         }).attr('title', GetTextByKey("P_IPT_EDIT", 'Edit')); | ||||
|  | ||||
|         if (!templatereadonly && editable) { | ||||
|             var btndelete = $('<em class="spanbtn icondelete"></em>').click(function () { | ||||
|                 _this.holder.remove(); | ||||
|                 if (_this.ondelete) | ||||
|                     _this.ondelete(_this); | ||||
|             }).attr('title', GetTextByKey("P_IPT_DELETE", 'Delete')); | ||||
|             tr.append($('<td style="width:55px;"></td>').append(btnedit).append(btndelete)); | ||||
|         } | ||||
|  | ||||
|         tr.append($('<td></td>')); | ||||
|  | ||||
|         this.updateFilterContent(); | ||||
|         return tb; | ||||
|     } | ||||
|     fm.prototype.updateFilterContent = function () { | ||||
|         var flt = this.filter; | ||||
|         if (flt) { | ||||
|             this.txtvin.text(flt.VIN); | ||||
|             this.txtmake.text(flt.MakeName); | ||||
|             this.txtmodel.text(flt.ModelName); | ||||
|             this.txttype.text(flt.TypeName); | ||||
|         } | ||||
|     } | ||||
|     fm.prototype.getFilterValue = function () { | ||||
|         return this.filter; | ||||
|     } | ||||
|     fm.prototype.editFilter = function () { | ||||
|         var _this = this; | ||||
|         if (!addfilterctrl) | ||||
|             addfilterctrl = new addfilter(); | ||||
|         addfilterctrl.beginEdit(_this.filter, function (f) { | ||||
|             _this.filter = f; | ||||
|             _this.updateFilterContent(); | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     /************end filter module***************/ | ||||
|  | ||||
|  | ||||
|     /************addfilter module***************/ | ||||
|     var addfilter = function () { | ||||
|         this.filter = null; | ||||
|         this.dialog = null; | ||||
|         this.onok = null; | ||||
|  | ||||
|         var txtVIN = null; | ||||
|         var selMake = null; | ||||
|         var selModel = null; | ||||
|         var selType = null; | ||||
|  | ||||
|         var _this = this; | ||||
|  | ||||
|         this.beginEdit = function (filter, onok) { | ||||
|             this.filter = filter; | ||||
|             this.onok = onok; | ||||
|             if (this.filter) { | ||||
|                 txtVIN.val(this.filter.VIN); | ||||
|                 selMake.val(this.filter.AssetMake); | ||||
|                 selModel.val(this.filter.AssetModel); | ||||
|                 selType.val(this.filter.AssetType); | ||||
|             } | ||||
|             else { | ||||
|                 txtVIN.val(''); | ||||
|                 selMake.val('-1'); | ||||
|                 selModel.val('-1'); | ||||
|                 selType.val('-1'); | ||||
|             } | ||||
|             showAssetModels(); | ||||
|  | ||||
|             if (this.dialog) { | ||||
|                 var title = _this.filter ? GetTextByKey("P_IPT_EDITFILTER", 'Edit Filter') : GetTextByKey("P_IPT_ADDFILTER", 'Add Filter'); | ||||
|                 this.dialog.find('.title').text(title); | ||||
|                 this.dialog.showDialogfixed(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         this.createContent = function () { | ||||
|             var tb = $('<table></table>'); | ||||
|             var tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label">' + GetTextByKey("P_IPT_VINSN_COLON", "VIN/SN:") + '</td>'); | ||||
|             txtVIN = $('<input type="text" class="form-control" maxlength="50" autocomplete="off"/>'); | ||||
|             tr.append($('<td></td>').append(txtVIN)); | ||||
|  | ||||
|             tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label">' + GetTextByKey("P_IPT_MAKE_COLON", "Make:") + '</td>'); | ||||
|             selMake = $('<select class="form-control" style="width:204px;height:22px;"></select>'); | ||||
|             tr.append($('<td></td>').append(selMake)); | ||||
|             selMake.change(function () { | ||||
|                 showAssetModels(); | ||||
|             }); | ||||
|  | ||||
|             tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label">' + GetTextByKey("P_IPT_MODEL_COLON", "Model:") + '</td>'); | ||||
|             selModel = $('<select class="form-control" style="width:204px;height:22px;"></select>'); | ||||
|             tr.append($('<td></td>').append(selModel)); | ||||
|  | ||||
|             tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label">' + GetTextByKey("P_IPT_ASSETTYPE_COLON", "Asset Type:") + '</td>'); | ||||
|             selType = $('<select class="form-control" style="width:204px;height:22px;"></select>'); | ||||
|             tr.append($('<td></td>').append(selType)); | ||||
|  | ||||
|             getAssetMakes(); | ||||
|             getAssetModels(); | ||||
|             getAssetTypes(); | ||||
|  | ||||
|             function OnSave() { | ||||
|                 var item = { | ||||
|                     'VIN': $.trim(txtVIN.val()), | ||||
|                     'AssetMake': selMake.val(), | ||||
|                     'MakeName': selMake.find("option:selected").text(), | ||||
|                     'AssetModel': selModel.val(), | ||||
|                     'ModelName': selModel.find("option:selected").text(), | ||||
|                     'AssetType': selType.val(), | ||||
|                     'TypeName': selType.find("option:selected").text() | ||||
|                 }; | ||||
|                 if (!item.AssetMake || item.AssetMake == '') | ||||
|                     item.AssetMake = '-1'; | ||||
|                 if (!item.AssetModel || item.AssetModel == '') | ||||
|                     item.AssetModel = '-1'; | ||||
|                 if (!item.AssetType || item.AssetType == '') | ||||
|                     item.AssetType = '-1'; | ||||
|                 if (_this.onok) | ||||
|                     _this.onok(item); | ||||
|                 _this.dialog.hideDialog(); | ||||
|             } | ||||
|  | ||||
|             this.dialog = Common.createDialog('', tb, OnSave, false); | ||||
|         } | ||||
|         this.createContent(); | ||||
|  | ||||
|         var makesdata = undefined; | ||||
|         var modelsdata = undefined; | ||||
|         var typesdata = undefined; | ||||
|         function getAssetMakes() { | ||||
|             inspectionrequest("GetAssetMakes", "", function (data) { | ||||
|                 if (data && data.length > 0) { | ||||
|                     makesdata = data; | ||||
|                     showAssetMakes(); | ||||
|                 } | ||||
|             }, function (err) { | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function getAssetModels() { | ||||
|             var ps = [-1, ""]; | ||||
|             inspectionrequest("GetAssetModels", JSON.stringify(ps), function (data) { | ||||
|                 if (data && data.length > 0) { | ||||
|                     modelsdata = data; | ||||
|                     showAssetModels(); | ||||
|                 } | ||||
|  | ||||
|             }, function (err) { | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function getAssetTypes() { | ||||
|             inspectionrequest("GetAssetTypes", "", function (data) { | ||||
|                 if (data && data.length > 0) { | ||||
|                     typesdata = data; | ||||
|                     showAssetTypes(); | ||||
|                 } | ||||
|             }, function (err) { | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function showAssetMakes() { | ||||
|             selMake.append('<option value="-1">*</option>'); | ||||
|             if (makesdata && makesdata.length > 0) { | ||||
|                 for (var i = 0; i < makesdata.length; i++) { | ||||
|                     var item = makesdata[i]; | ||||
|                     selMake.append('<option value="' + item.ID + '">' + item.Name + '</option>'); | ||||
|                 } | ||||
|                 if (_this.filter) { | ||||
|                     selMake.val(_this.filter.AssetMake); | ||||
|                     showAssetModels(); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function showAssetModels() { | ||||
|             selModel.empty(); | ||||
|             var makeid = selMake.val(); | ||||
|             selModel.append('<option value="-1">*</option>'); | ||||
|             if (!makeid || makeid == "-1") | ||||
|                 selModel.prop('disabled', true); | ||||
|             else | ||||
|                 selModel.prop('disabled', false); | ||||
|             if (modelsdata && modelsdata.length > 0 && makeid != "-1") { | ||||
|                 for (var i = 0; i < modelsdata.length; i++) { | ||||
|                     var item = modelsdata[i]; | ||||
|                     if (item.MakeID == parseInt(makeid)) { | ||||
|                         selModel.append('<option value="' + item.ID + '">' + item.Name + '</option>'); | ||||
|                     } | ||||
|                 } | ||||
|                 if (_this.filter) | ||||
|                     selModel.val(_this.filter.AssetModel); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function showAssetTypes() { | ||||
|             selType.append('<option value="-1">*</option>'); | ||||
|             if (typesdata && typesdata.length > 0) { | ||||
|                 for (var i = 0; i < typesdata.length; i++) { | ||||
|                     var item = typesdata[i]; | ||||
|                     selType.append('<option value="' + item.Key + '">' + item.Value + '</option>'); | ||||
|                 } | ||||
|                 if (_this.filter) | ||||
|                     selType.val(_this.filter.AssetType); | ||||
|             } | ||||
|         } | ||||
|     }; | ||||
|     /************end addfilter module***************/ | ||||
|  | ||||
|     return fsm; | ||||
| }); | ||||
							
								
								
									
										165
									
								
								Site/Inspection/js/modules/templates/linksection.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										165
									
								
								Site/Inspection/js/modules/templates/linksection.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,165 @@ | ||||
| define(['common'], function (Common) { | ||||
|  | ||||
|     var dialogSection = null; | ||||
|     var ls = function () { | ||||
|     }; | ||||
|  | ||||
|     ls.prototype.getDialogSection = function () { | ||||
|         if (!dialogSection) | ||||
|             dialogSection = new $sectionselector(); | ||||
|         return dialogSection; | ||||
|     } | ||||
|  | ||||
|     var $sectionselector = function () { | ||||
|         this.title = GetTextByKey("P_IPT_SELECTSECTION", 'Select Section'); | ||||
|         this.companyId = null; | ||||
|         this.exceptSource = null; | ||||
|         this.onOK = null; | ||||
|         this.onDialogClosed = null; | ||||
|     }; | ||||
|  | ||||
|     (function () { | ||||
|         var __proto = $sectionselector.prototype; | ||||
|  | ||||
|         function initGrid(parent) { | ||||
|             var grid = new GridView(parent); | ||||
|             var columns = []; | ||||
|             columns.push({ | ||||
|                 // checkbox | ||||
|                 name: 'check', | ||||
|                 key: 'Selected', | ||||
|                 width: 30, | ||||
|                 align: 'center', | ||||
|                 sortable: false, | ||||
|                 allcheck: true, | ||||
|                 type: 3 | ||||
|             }); | ||||
|             columns.push({ | ||||
|                 key: 'Name', | ||||
|                 caption: GetTextByKey("P_IPT_NAME", 'Name'), | ||||
|                 width: 200 | ||||
|             }, | ||||
|                 { | ||||
|                     key: 'DisplayText', | ||||
|                     caption: GetTextByKey("P_IPT_DISPLAYTEXT", 'DisplayText'), | ||||
|                     width: 320 | ||||
|                 }); | ||||
|             //grid.canMultiSelect = true; | ||||
|             grid.columns = columns; | ||||
|             grid.init(); | ||||
|  | ||||
|             this.gridctrl = grid; | ||||
|         } | ||||
|  | ||||
|         function createDialog() { | ||||
|             var dialog = $('<div class="dialog" style="display: none; width: 602px; height: 380px">'); | ||||
|  | ||||
|             var title = $('<div class="dialog-title"></div>').appendTo(dialog); | ||||
|             title.append($('<span class="title"></span>').text(this.title)); | ||||
|             title.append('<em class="dialog-close"></em>'); | ||||
|  | ||||
|             var content = $('<div class="dialog-content"></div>').appendTo(dialog); | ||||
|  | ||||
|             this.listdiv = $('<div style="width: 580px; height: 290px;margin-bottom:5px;"></div>').appendTo(content); | ||||
|  | ||||
|             var dialogFunction = $('<div class="dialog-func"></div>').appendTo(dialog); | ||||
|             $('<input type="button" value="' + GetTextByKey("P_IPT_CANCEL", "Cancel") + '" class="dialog-close" />').appendTo(dialogFunction); | ||||
|             $('<input type="button" value="' + GetTextByKey("P_IPT_COPY", "Copy") + '" />').click(onCopyClick.bind(this)).appendTo(dialogFunction); | ||||
|             $('<input type="button" value="' + GetTextByKey("P_IPT_ADDASLINK", "Add as Link") + '" />').click(onLinkClick.bind(this)).appendTo(dialogFunction); | ||||
|             $('<div class="clear"></div>').appendTo(dialogFunction); | ||||
|  | ||||
|             $('<div class="maskbg" style="display: none"><div class="loading_icon icon c-spin"></div></div>').appendTo(dialog); | ||||
|  | ||||
|             // init | ||||
|             initGrid.call(this, this.listdiv); | ||||
|             $(document.body).append(dialog); | ||||
|             var mask = $('<div class="maskbg"></div>'); | ||||
|             dialog.data('mask', mask); | ||||
|             dialog.before(mask); | ||||
|  | ||||
|             var _this = this; | ||||
|             dialog.dialog(function () { | ||||
|                 if (_this.onDialogClosed) | ||||
|                     _this.onDialogClosed(); | ||||
|                 if (dialog.data('mask')) | ||||
|                     dialog.data('mask').hide(); | ||||
|             }); | ||||
|             return dialog; | ||||
|         } | ||||
|  | ||||
|         __proto.showSelector = function () { | ||||
|             if (!this.dialog) { | ||||
|                 this.dialog = createDialog.call(this); | ||||
|             } | ||||
|  | ||||
|             if (this.dialog.data('mask')) | ||||
|                 this.dialog.data('mask').show(); | ||||
|             this.dialog.showDialog(false); | ||||
|             this.gridctrl.setData([]); | ||||
|             onSearch.call(this); | ||||
|         }; | ||||
|  | ||||
|         function onKeyPress(e) { | ||||
|             if (e.keyCode === 13) { | ||||
|                 onSearch.call(this); | ||||
|             } | ||||
|         }; | ||||
|  | ||||
|         function excepted(id, source) { | ||||
|             for (var i = 0; i < source.length; i++) { | ||||
|                 if (source[i] === id) { | ||||
|                     return true; | ||||
|                 } | ||||
|             } | ||||
|             return false; | ||||
|         } | ||||
|  | ||||
|         function onSearch() { | ||||
|             var maskbg = this.dialog.find('.maskbg'); | ||||
|             maskbg.show(); | ||||
|  | ||||
|             var excepts = this.exceptSource; | ||||
|             var gridctrl = this.gridctrl; | ||||
|             var title = this.title; | ||||
|             var companyId = this.companyId || ''; | ||||
|  | ||||
|             inspectionrequest("GetGlobalSections", teamintelligence, function (data) { | ||||
|                 if (typeof data === 'string') { | ||||
|                     showAlert(GetTextByKey("P_IPT_FAILEDTOGETTHESECTIONS", 'Failed to get the sections: ') + data, title); | ||||
|                     maskbg.hide(); | ||||
|                     return; | ||||
|                 } | ||||
|                 var items = []; | ||||
|                 for (var i = 0; i < data.length; i++) { | ||||
|                     var it = data[i]; | ||||
|                     if (excepts == null || !excepted(it.Id, excepts)) { | ||||
|                         items.push({ Values: it }); | ||||
|                     } | ||||
|                 } | ||||
|                 gridctrl.setData(items); | ||||
|                 maskbg.hide(); | ||||
|             }, function (err) { | ||||
|                     showAlert(GetTextByKey("P_IPT_FAILEDTOGETTHESECTIONS1",'Failed to get the sections.'), title); | ||||
|                 maskbg.hide(); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function onCopyClick() { | ||||
|             //var index = this.gridctrl.selectedIndex; | ||||
|             this.onOK && this.onOK(this.gridctrl.source, true); | ||||
|             if (this.dialog.data('mask')) | ||||
|                 this.dialog.data('mask').hide(); | ||||
|             this.dialog.hideDialog(); | ||||
|         } | ||||
|  | ||||
|         function onLinkClick() { | ||||
|             //var index = this.gridctrl.selectedIndex; | ||||
|             this.onOK && this.onOK(this.gridctrl.source, false); | ||||
|             if (this.dialog.data('mask')) | ||||
|                 this.dialog.data('mask').hide(); | ||||
|             this.dialog.hideDialog(); | ||||
|         } | ||||
|     })(); | ||||
|  | ||||
|     return ls; | ||||
| }); | ||||
							
								
								
									
										313
									
								
								Site/Inspection/js/modules/templates/page.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										313
									
								
								Site/Inspection/js/modules/templates/page.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,313 @@ | ||||
| define(['modules/sections/section', 'modules/sections/addsection', 'common', 'modules/templates/linksection'], function (Section, AddSection, Common, LinkSection) { | ||||
|     var p = function (page, pagesmodule) { | ||||
|         this.page = page || {}; | ||||
|         this.pagesmodule = pagesmodule; | ||||
|         this.namecontrol = undefined; | ||||
|         this.displaytextcontrol = undefined; | ||||
|         this.notescontrol = undefined; | ||||
|         this.onNameChanged = undefined; | ||||
|         this.datacontent = null; | ||||
|  | ||||
|         this.sectionmodules = []; | ||||
|     }; | ||||
|     p.prototype.description = "Page"; | ||||
|     p.prototype.version = "1.0.0.0"; | ||||
|  | ||||
|     p.prototype.createContent = function () { | ||||
|         var _this = this; | ||||
|         var content = $('<div></div>'); | ||||
|  | ||||
|         function createPageContent() { | ||||
|             var div_main = $('<div class="content_main"></div>'); | ||||
|             var div_content = $('<div class="edit-content"></div>'); | ||||
|             div_main.append(div_content); | ||||
|             var tb = $('<table></table>'); | ||||
|             div_content.append(tb); | ||||
|  | ||||
|             var tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label" style="width:154px;">' + GetTextByKey("P_IPT_NAME_COLON", "Name:") + '<span class="redasterisk">*</span></td>'); | ||||
|             _this.namecontrol = $('<input type="text" class="form-control" maxlength="100" autocomplete="off"/>'); | ||||
|             var addiText = $('<span class="spanbtn iconmultitext" style="font-size:14px;" title="' + GetTextByKey("P_IPT_ADDITIONALTEXTS", "Additional Texts") + '"/>'); | ||||
|             addiText.click(function () { | ||||
|                 Common.createMultiTextDialog(_this.namecontrol); | ||||
|             }); | ||||
|             tr.append($('<td style="white-space:nowrap;"></td>').append(_this.namecontrol).append(addiText)); | ||||
|             _this.namecontrol.change(function () { | ||||
|                 if (_this.onNameChanged) | ||||
|                     _this.onNameChanged($.trim(_this.namecontrol.val())) | ||||
|             }) | ||||
|  | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label" style="width:154px;">' + GetTextByKey("P_IPT_NOTES_COLON", "Notes:") + '</td>'); | ||||
|             _this.notescontrol = $('<textarea id="dialog_notes" class="inputbox form-control" maxlength="500" autocomplete="off" style="width: 540px; margin-top:6px;height:55px;"></textarea>'); | ||||
|             tr.append($('<td rowspan="2"></td>').append(_this.notescontrol)); | ||||
|  | ||||
|             tr = $('<tr></tr>'); | ||||
|             tb.append(tr); | ||||
|             tr.append('<td class="label" style="width:154px;">' + GetTextByKey("P_IPT_DISPLAYTEXT_COLON", "Display Text:") + '<span class="redasterisk">*</span></td>'); | ||||
|             _this.displaytextcontrol = $('<input type="text" class="form-control" maxlength="200" autocomplete="off"/>'); | ||||
|             addiText = $('<span class="spanbtn iconmultitext" style="font-size:14px;" title="' + GetTextByKey("P_IPT_ADDITIONALTEXTS", "Additional Texts") + '"/>'); | ||||
|             addiText.click(function () { | ||||
|                 Common.createMultiTextDialog(_this.displaytextcontrol); | ||||
|             }); | ||||
|             tr.append($('<td style="white-space:nowrap;"></td>').append(_this.displaytextcontrol).append(addiText)); | ||||
|  | ||||
|             var sectioncontent = createSectionContent(); | ||||
|             div_main.append(sectioncontent); | ||||
|             return div_main; | ||||
|         } | ||||
|  | ||||
|         function createSectionContent() { | ||||
|             var content = $('<div style="min-width:1820px;"></div>'); | ||||
|  | ||||
|             function createSectionHeader() { | ||||
|                 var header = $('<div></div>'); | ||||
|                 //header.append($('<div class="page_title"></div>').text(gs.title)); | ||||
|                 var func = $('<div class="function_title"></div>'); | ||||
|                 var iconAdd = $('<span class="sbutton iconadd">' + GetTextByKey("P_IPT_ADD", "Add") + '</span>').click(function () { | ||||
|                     //var s = new AddSection(); | ||||
|                     //s.onsave = function (section) { | ||||
|                     //    _this.page.Sections.push(section); | ||||
|                     //    updateContent(true); | ||||
|                     //} | ||||
|                     //$('#right_popup1').empty().append(s.createContent()).show(); | ||||
|                     var section = {}; | ||||
|                     _this.page.Sections.push(section); | ||||
|                     addSectionModule(section); | ||||
|                 }); | ||||
|                 func.append(iconAdd); | ||||
|                 var iconRefresh = $('<span class="sbutton iconlink">' + GetTextByKey("P_ADDGLOBALSECTION", "Add Global Section") + '</span>').click(function () { | ||||
|                     addGlobalSection(); | ||||
|                 }); | ||||
|                 func.append(iconRefresh); | ||||
|                 header.append(func) | ||||
|  | ||||
|                 return header; | ||||
|             } | ||||
|  | ||||
|             if (!templatereadonly && editable) | ||||
|                 content.append(createSectionHeader()); | ||||
|  | ||||
|             var dataheader = $('<div class="question-holder no-hover" style="font-weight: bold;font-size:14px;"></div>'); | ||||
|             dataheader.append('<div style="width: 60px; flex-shrink: 0"></div>'); | ||||
|             dataheader.append('<div class="question-cell" style="width: 200px">' + GetTextByKey("P_IPT_NAME", "Name") + '</div>'); | ||||
|             dataheader.append('<div class="question-cell" style="width: 310px">' + GetTextByKey("P_IPT_DISPLAYTEXT", "Display Text") + '</div>'); | ||||
|             dataheader.append('<div class="question-cell" style="width: 400px">' + GetTextByKey("P_IPT_TYPE", "Type") + '</div>'); | ||||
|             dataheader.append('<div class="question-cell" style="width: 80px; text-align: center">' + GetTextByKey("P_IPT_REQUIRED", "Required") + '</div>'); | ||||
|             dataheader.append('<div class="question-cell" style="width: 100px; text-align: center">' + GetTextByKey("P_IPT_CANCOMMENT", "Can Comment") + '</div>'); | ||||
|             dataheader.append('<div class="question-cell" style="width: 100px; text-align: center">' + GetTextByKey("P_IPT_ISIMPORTANT", "Is Important") + '</div>'); | ||||
|             dataheader.append('<div class="question-cell" style="width: 140px">' + GetTextByKey("P_IPT_CUSTOMERVISIBLE", "Customer Visible") + '</div>'); | ||||
|             dataheader.append('<div class="question-cell" style="width: 140px">' + GetTextByKey("P_IPT_SEVERITYLEVEL", "Severity Level") + '</div>'); | ||||
|             dataheader.append('<div style="flex-grow: 1" style="width: 160px">' + GetTextByKey("P_IPT_ST_NOTES", "Notes") + '</div>'); | ||||
|             dataheader.append('<div class="question-cell" style="width: 90px;padding-right:20px;"></div>'); | ||||
|             content.append(dataheader); | ||||
|  | ||||
|             _this.datacontent = $('<div></div>'); | ||||
|             content.append(_this.datacontent); | ||||
|  | ||||
|             return content; | ||||
|         } | ||||
|  | ||||
|         function updateContent(sectiononly) { | ||||
|             if (!sectiononly) { | ||||
|                 _this.namecontrol.val(_this.page.Name).data("texts", _this.page.LocalNames); | ||||
|                 _this.displaytextcontrol.val(_this.page.DisplayText).data("texts", _this.page.LocalDisplayTexts); | ||||
|                 _this.notescontrol.val(_this.page.Notes); | ||||
|             } | ||||
|  | ||||
|             if (_this.page.Sections) { | ||||
|                 _this.sectionmodules = []; | ||||
|                 _this.datacontent.empty(); | ||||
|                 for (var i = 0; i < _this.page.Sections.length; i++) { | ||||
|                     //var s = new Section(_this.page.Sections[i], null, _this); | ||||
|                     addSectionModule(_this.page.Sections[i]); | ||||
|                 } | ||||
|             } else | ||||
|                 _this.page.Sections = []; | ||||
|         } | ||||
|  | ||||
|         function addSectionModule(s) { | ||||
|             var sectionmodule = new Section(s, null, _this); | ||||
|             sectionmodule.oncopy = function (section) { | ||||
|                 section = JSON.parse(JSON.stringify(section)); | ||||
|                 section.Id = ""; | ||||
|                 if (!section.IsLink && section.Questions) { | ||||
|                     for (var j = 0; j < section.Questions.length; j++) { | ||||
|                         section.Questions[j].Id = ""; | ||||
|                     } | ||||
|                 } | ||||
|                 _this.page.Sections.push(section); | ||||
|                 addSectionModule(section); | ||||
|             }; | ||||
|             sectionmodule.ondelete = function (sm) { | ||||
|                 _this.page.Sections.splice(_this.page.Sections.indexOf(sm.section), 1); | ||||
|                 _this.sectionmodules.splice(_this.sectionmodules.indexOf(sm), 1); | ||||
|             } | ||||
|             _this.sectionmodules.push(sectionmodule); | ||||
|             _this.datacontent.append(sectionmodule.createContent()); | ||||
|         } | ||||
|  | ||||
|         function setDisabled() { | ||||
|             _this.namecontrol.prop('disabled', true); | ||||
|             _this.displaytextcontrol.prop('disabled', true); | ||||
|             _this.notescontrol.prop('disabled', true); | ||||
|  | ||||
|             content.find(".iconmultitext").hide(); | ||||
|             content.find(".iconimage").hide(); | ||||
|         } | ||||
|  | ||||
|         function addGlobalSection() {//<2F><><EFBFBD><EFBFBD>Global Section | ||||
|             var dialogSection = new LinkSection().getDialogSection(); | ||||
|  | ||||
|             dialogSection.onDialogClosed = function () { | ||||
|             } | ||||
|             dialogSection.onOK = function (sections, iscopy) { | ||||
|                 if (!iscopy) { | ||||
|                     var linkedSectionIds = []; | ||||
|                     if (_this.pagesmodule && _this.pagesmodule.pages) { | ||||
|                         for (var i = 0; i < _this.pagesmodule.pages.length; i++) { | ||||
|                             var page = _this.pagesmodule.pages[i]; | ||||
|                             if (page.Sections) { | ||||
|                                 for (var j = 0; j < page.Sections.length; j++) { | ||||
|                                     var s = page.Sections[j]; | ||||
|                                     if (s.IsLink) | ||||
|                                         linkedSectionIds.push(s.ReferenceId); | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                     if (sections && sections.length > 0) { | ||||
|                         for (var i = 0; i < sections.length; i++) { | ||||
|                             var it = sections[i].Values; | ||||
|                             if (it.Selected && linkedSectionIds.indexOf(it.Id) >= 0) { | ||||
|                                 showAlert(GetTextByKey("P_IPT_ALREADYLINKED", '{0} has already been linked to current template.').replace("{0}", it.Name), GetTextByKey("P_ADDGLOBALSECTION", "Add Global Section")); | ||||
|                                 return; | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
|                 onAddGlobalSection(sections, iscopy); | ||||
|             } | ||||
|  | ||||
|             //var sections = []; | ||||
|             //for (var i = 0; i < _this.page.Sections.length; i++) { | ||||
|             //    if (_this.page.Sections[i].IsLink) | ||||
|             //        sections.push(_this.page.Sections[i].ReferenceId); | ||||
|             //} | ||||
|  | ||||
|             //dialogSection.exceptSource = sections; | ||||
|             dialogSection.showSelector(); | ||||
|         } | ||||
|  | ||||
|         function onAddGlobalSection(sections, iscopy) { | ||||
|             if (sections && sections.length > 0) { | ||||
|                 var sids = []; | ||||
|                 for (var i = 0; i < sections.length; i++) { | ||||
|                     var it = sections[i].Values; | ||||
|                     if (it.Selected) | ||||
|                         sids.push(it.Id); | ||||
|                 } | ||||
|                 var p = JSON.stringify([teamintelligence, JSON.stringify(sids)]); | ||||
|                 inspectionrequest("GetGlobalSectionsByID", p, function (data) { | ||||
|                     if (typeof data === 'string') | ||||
|                         return; | ||||
|                     for (var i = 0; i < data.length; i++) { | ||||
|                         var section = data[i]; | ||||
|                         if (iscopy) {//copy secton<6F><6E>reference its questions | ||||
|                             if (section.Questions) { | ||||
|                                 for (var j = 0; j < section.Questions.length; j++) { | ||||
|                                     var q = section.Questions[j]; | ||||
|                                     q.Id = ''; | ||||
|                                     //q.ReferenceId = q.Id; | ||||
|                                     //q.IsLink = true; | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|                         else {//reference section | ||||
|                             section.ReferenceId = section.Id; | ||||
|                             section.IsLink = true; | ||||
|                         } | ||||
|                         section.Id = ''; | ||||
|                         _this.page.Sections.push(section); | ||||
|                         addSectionModule(section); | ||||
|  | ||||
|                     } | ||||
|                     //updateContent(true); | ||||
|                 }, function (err) { | ||||
|                 }); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         content.append(createPageContent()); | ||||
|         updateContent(); | ||||
|         if (templatereadonly || !editable) | ||||
|             setDisabled(); | ||||
|         return content; | ||||
|     } | ||||
|  | ||||
|     p.prototype.getPageValue = function (noalert, nocheck) { | ||||
|         var page = this.page; | ||||
|         page.Name = this.namecontrol.val(); | ||||
|         page.DisplayText = this.displaytextcontrol.val(); | ||||
|         page.Notes = this.notescontrol.val(); | ||||
|  | ||||
|         var texts = this.namecontrol.data("texts"); | ||||
|         if (texts) { | ||||
|             page.LocalNames = texts; | ||||
|         } | ||||
|         texts = this.displaytextcontrol.data("texts"); | ||||
|         if (texts) { | ||||
|             page.LocalDisplayTexts = texts; | ||||
|         } | ||||
|         if (!nocheck) { | ||||
|             var alerttitle = GetTextByKey("P_IPT_PAGE", 'Page'); | ||||
|             if (!noalert && (!page.Name || page.Name.length == 0)) { | ||||
|                 showAlert(GetTextByKey("P_IPT_PAGENAMENOTBEEMPTY", 'Page Name cannot be empty.'), alerttitle); | ||||
|                 return false; | ||||
|             } | ||||
|             if (!noalert && (!page.DisplayText || page.DisplayText.length == 0)) { | ||||
|                 showAlert(GetTextByKey("P_IPT_DISPLAYTEXTNOTBEEMPTY", 'Display Text cannot be empty.'), alerttitle); | ||||
|                 return false; | ||||
|             } | ||||
|         } | ||||
|         page.Sections = []; | ||||
|         if (this.sectionmodules.length > 0) { | ||||
|             for (var i = 0; i < this.sectionmodules.length; i++) { | ||||
|                 var s = this.sectionmodules[i].getSectionValue(noalert, nocheck); | ||||
|                 if (!s) return false; | ||||
|                 page.Sections.push(s); | ||||
|             } | ||||
|         } | ||||
|         return page; | ||||
|     } | ||||
|     p.prototype.dragOutSection = function (sm) {//called when end drag | ||||
|         var index = this.page.Sections.indexOf(sm.section) | ||||
|         if (index >= 0) { | ||||
|             this.page.Sections.splice(index, 1); | ||||
|             this.sectionmodules.splice(index, 1); | ||||
|         } | ||||
|     }; | ||||
|     p.prototype.dragInSection = function (target, sm, after) {//called when end drag | ||||
|         if (!this.page.Sections) | ||||
|             this.page.Sections = []; | ||||
|         if (this.page.Sections.length == 0) { | ||||
|             this.page.Sections.push(sm.section); | ||||
|             this.sectionmodules.push(sm); | ||||
|             return; | ||||
|         } | ||||
|         var tindex = 0; | ||||
|         if (target) { | ||||
|             tindex = this.page.Sections.indexOf(target); | ||||
|             if (after) | ||||
|                 tindex = tindex + 1; | ||||
|         } | ||||
|         if (tindex >= 0) { | ||||
|             this.page.Sections.splice(tindex, 0, sm.section); | ||||
|             this.sectionmodules.splice(tindex, 0, sm); | ||||
|         } | ||||
|     }; | ||||
|     return p; | ||||
| }); | ||||
|  | ||||
							
								
								
									
										164
									
								
								Site/Inspection/js/modules/templates/pages.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										164
									
								
								Site/Inspection/js/modules/templates/pages.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,164 @@ | ||||
| define(['modules/templates/page'], function (Page) { | ||||
|     var q = function (pages) { | ||||
|         this.pages = pages || []; | ||||
|         this.pageModules = []; | ||||
|     }; | ||||
|     q.prototype.description = "Pages Module"; | ||||
|     q.prototype.version = "1.0.0.0"; | ||||
|  | ||||
|     q.prototype.createContent = function () { | ||||
|         var _this = this; | ||||
|         var pagescontent = $('<div></div>'); | ||||
|         var ul = $('<ul class="tab_header" style="padding-top: 5px;"></ul>'); | ||||
|         pagescontent.append(ul); | ||||
|  | ||||
|         var addli = $('<li data-disabled="1" data-href="add"></li>'); | ||||
|         ul.append(addli); | ||||
|         addli.append($('<span class="spanbtn iconadd"></span>')); | ||||
|         addli.append($('<span>' + GetTextByKey("P_IPT_ADD", "Add") + '</span>')); | ||||
|         addli.click(function () { | ||||
|             addTab(null, true); | ||||
|         }); | ||||
|         if (!templatereadonly && editable) | ||||
|             addli.show(); | ||||
|         else | ||||
|             addli.hide(); | ||||
|         ul.append($('<li style="clear: both;"></li>')); | ||||
|  | ||||
|         var tabIndex = 0; | ||||
|         for (var i = 0; i < this.pages.length; i++) { | ||||
|             var p = this.pages[i]; | ||||
|             addTab(p, false); | ||||
|         } | ||||
|         pagescontent.tab();//tab()<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>addli<6C><69>click<63>¼<EFBFBD> | ||||
|  | ||||
|         function addTab(p, newadd) { | ||||
|             if (!p) { | ||||
|                 p = {}; | ||||
|                 _this.pages.push(p); | ||||
|             } | ||||
|             var tabName = 'tab_' + tabIndex++; | ||||
|  | ||||
|             var pm = new Page(p, _this); | ||||
|             _this.pageModules.push(pm); | ||||
|             var pagecontent = pm.createContent().attr('data-page', tabName); | ||||
|  | ||||
|             var li = $('<li></li>').attr('data-href', tabName); | ||||
|             if (tabIndex == 1) | ||||
|                 li.addClass('selected'); | ||||
|             li.append($('<span></span>').text(p.Name || GetTextByKey("P_IPT_UNNAMED", 'Unnamed'))); | ||||
|             if (!templatereadonly && editable) { | ||||
|                 li.css('padding-right', 6); | ||||
|                 var btncopy = $('<span class="spanbtn iconcopy" style="margin-left:10px;padding-left:3px;padding-right:4px;"></span>'); | ||||
|                 btncopy.click(function () { | ||||
|                     var item = copyPage(pm.getPageValue(true, true)); | ||||
|                     _this.pages.push(item); | ||||
|                     addTab(item, true); | ||||
|                     return false; | ||||
|                 }).attr('title', GetTextByKey("P_IPT_COPYPAGE", 'Copy Page')); | ||||
|                 li.append(btncopy); | ||||
|                 var btndelete = $('<span class="spanbtn icondelete" style="padding-left:3px;"></span>'); | ||||
|                 btndelete.click(function () { | ||||
|                     showConfirm(GetTextByKey("P_IPT_AREYOUSUREYOUWANTTOREMOVETHISPAGE", 'Are you sure you want to remove this page?'), GetTextByKey("P_IPT_REMOVEPAGE", 'Remove Page'), function () { | ||||
|                         var next = li.next(); | ||||
|                         if (next.is(addli)) | ||||
|                             next = li.prev(); | ||||
|                         next.click(); | ||||
|  | ||||
|                         li.remove(); | ||||
|                         pagescontent.children('div[data-page="' + tabName + '"]').remove(); | ||||
|                         _this.pages.splice(_this.pages.indexOf(p), 1); | ||||
|                         _this.pageModules.splice(_this.pageModules.indexOf(pm), 1); | ||||
|                     }); | ||||
|                 }).attr('title', GetTextByKey("P_IPT_DELETEPAGE", 'Delete Page')); | ||||
|                 li.append(btndelete); | ||||
|  | ||||
|                 pm.onNameChanged = function (name) { | ||||
|                     if (name && name != '') | ||||
|                         li.children(":first").text(name); | ||||
|                     else | ||||
|                         li.children(":first").text(GetTextByKey("P_IPT_UNNAMED", 'Unnamed')); | ||||
|                 } | ||||
|             } | ||||
|             else | ||||
|                 addli.hide(); | ||||
|  | ||||
|             binddrag(li, p); | ||||
|             addli.before(li); | ||||
|             if (newadd) { | ||||
|                 pagescontent.tab(); | ||||
|                 li.click(); | ||||
|             } | ||||
|  | ||||
|             pagescontent.append(pagecontent); | ||||
|         } | ||||
|  | ||||
|         var draggingtab = null; | ||||
|         var draggingpage = null; | ||||
|         function binddrag(li, p) { | ||||
|             li.attr('draggable', true); | ||||
|             li.bind('dragstart', function (e) { | ||||
|                 draggingtab = $(this); | ||||
|                 draggingpage = p; | ||||
|             }); | ||||
|             li.bind('dragend', function (e) { | ||||
|                 draggingtab = null; | ||||
|                 draggingpage = null; | ||||
|             }); | ||||
|             li.bind('dragover', function (e) { | ||||
|                 e.originalEvent.preventDefault() | ||||
|             }); | ||||
|             li.bind('drop', function (e) { | ||||
|                 var t = $(this); | ||||
|                 if (t.is(draggingtab)) | ||||
|                     return; | ||||
|                 var t = $(this); | ||||
|                 var after = e.originalEvent.clientX > t.offset().left + t.width() / 2; | ||||
|                 if (after) { | ||||
|                     t.after(draggingtab); | ||||
|                     _this.pages.splice(_this.pages.indexOf(draggingpage), 1); | ||||
|                     _this.pages.splice(_this.pages.indexOf(p) + 1, 0, draggingpage); | ||||
|                 } | ||||
|                 else { | ||||
|                     t.before(draggingtab); | ||||
|                     _this.pages.splice(_this.pages.indexOf(draggingpage), 1); | ||||
|                     _this.pages.splice(_this.pages.indexOf(p), 0, draggingpage); | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         return pagescontent; | ||||
|     }; | ||||
|     q.prototype.getPagesValue = function () { | ||||
|         for (var i = 0; i < this.pageModules.length; i++) { | ||||
|             var p = this.pageModules[i].getPageValue();//getPageValueֱ<65><D6B1><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD> | ||||
|             if (!p) return false; | ||||
|         } | ||||
|         return this.pages; | ||||
|     } | ||||
|  | ||||
|     function copyPage(p) { | ||||
|         var p = JSON.parse(JSON.stringify(p)); | ||||
|         p.Id = ""; | ||||
|         if (p.Sections) { | ||||
|             for (var i = p.Sections.length - 1; i >= 0; i--) { | ||||
|                 var s = p.Sections[i]; | ||||
|                 if (s.IsLink) | ||||
|                     p.Sections.splice(i, 1); | ||||
|             } | ||||
|             for (var i = 0; i < p.Sections.length; i++) { | ||||
|                 var s = p.Sections[i]; | ||||
|                 s.Id = ""; | ||||
|                 if (s.Questions) { | ||||
|                     for (var j = 0; j < s.Questions.length; j++) { | ||||
|                         var q = s.Questions[j]; | ||||
|                         q.Id = ""; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         return p; | ||||
|     } | ||||
|  | ||||
|     return q; | ||||
| }); | ||||
							
								
								
									
										295
									
								
								Site/Inspection/js/modules/templates/picture.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										295
									
								
								Site/Inspection/js/modules/templates/picture.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,295 @@ | ||||
| define(['common', 'modules/templates/templatepicture'], function (Common, TemplatePicture) { | ||||
|     var fsm = function (istemplate, pageele, onok) { | ||||
|         this.pageele = pageele || {}; | ||||
|         this.holder = null; | ||||
|         this.dialog = null; | ||||
|         this.istemplate = istemplate; | ||||
|         this.onok = onok; | ||||
|         this.title = GetTextByKey("P_IPT_PICTURES", "Picture"); | ||||
|     }; | ||||
|     fsm.prototype.description = GetTextByKey("P_IPT_PICTURES", "Picture"); | ||||
|     fsm.prototype.version = "1.0.0.0"; | ||||
|  | ||||
|     fsm.prototype.createContent = function () { | ||||
|         var _this = this; | ||||
|         var input = null; | ||||
|         var nopictr = null; | ||||
|         var tabindex = 0; | ||||
|         if (sectiontype === 0) { | ||||
|             if (!_this.pageele.IssueId || _this.pageele.IssueId == "") | ||||
|                 editable = true; | ||||
|             else | ||||
|                 editable = false; | ||||
|         } | ||||
|  | ||||
|         var content = $('<div style="max-height: 200px;overflow-y: auto;"></div>'); | ||||
|         var tb = $('<table style="max-height:300px;line-height:30px;"></table>'); | ||||
|  | ||||
|         function createPictureContent() { | ||||
|             if (_this.pageele && _this.pageele.StaticPictures && _this.pageele.StaticPictures.length > 0) { | ||||
|                 for (var i = 0; i < _this.pageele.StaticPictures.length; i++) { | ||||
|                     var p = _this.pageele.StaticPictures[i]; | ||||
|                     if (!p.Id) | ||||
|                         p.Id = $.newGuid(); | ||||
|                     addpicturerow(p); | ||||
|                 } | ||||
|             } | ||||
|             //else { | ||||
|             //    addnopicrow(); | ||||
|             //} | ||||
|             return tb; | ||||
|         } | ||||
|  | ||||
|         function createAddButton() { | ||||
|             if (!templatereadonly && editable) { | ||||
|                 var addpicdiv = $('<div style="line-height: 30px;"></div>'); | ||||
|                 var addpicicon = $('<span class="sbutton iconadd">' + GetTextByKey("P_IPT_ADDPICTURE", "Add Picture") + '</span>').click(function () { | ||||
|                     browsePicture(); | ||||
|                 }); | ||||
|                 addpicdiv.append(addpicicon); | ||||
|  | ||||
|                 if (!_this.istemplate && sectiontype == 1) { | ||||
|                     var addtemppicicon = $('<span class="sbutton iconadd">' + GetTextByKey("P_IPT_ADDREFERENCE", "Add Reference") + '</span>').click(function () { | ||||
|  | ||||
|                         var dialogTemplatePicture = new TemplatePicture().getDialogPicture(); | ||||
|  | ||||
|                         dialogTemplatePicture.onDialogClosed = function () { | ||||
|                         } | ||||
|                         dialogTemplatePicture.onOK = function (pics, iscopy) { | ||||
|                             onTemplatePictures(pics, iscopy); | ||||
|                         } | ||||
|  | ||||
|                         dialogTemplatePicture.showSelector(); | ||||
|                     }); | ||||
|                 } | ||||
|                 addpicdiv.append(addtemppicicon); | ||||
|                 content.append(addpicdiv); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function onTemplatePictures(pics, iscopy) { | ||||
|             if (pics && pics.length > 0) { | ||||
|                 var sids = []; | ||||
|                 for (var i = 0; i < pics.length; i++) { | ||||
|                     var it = pics[i].Values; | ||||
|                     if (it.Selected) { | ||||
|                         var p = {}; | ||||
|                         p.Id = $.newGuid(); | ||||
|                         p.ReferenceId = it.Id; | ||||
|                         p.Name = it.Name; | ||||
|                         p.DataType = it.DataType; | ||||
|                         p.ContentId = it.ContentId; | ||||
|                         p.Url = it.Url; | ||||
|                         addpicturerow(p); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function addnopicrow() { | ||||
|             nopictr = $('<tr style="height:30px;"></tr>'); | ||||
|             var td = $('<td style="padding:5px;padding-left:10px;">' + GetTextByKey("P_IPT_NOPICTURE", "No Picture") + '</td>'); | ||||
|             nopictr.append(td); | ||||
|             tb.append(nopictr); | ||||
|         } | ||||
|  | ||||
|         function addpicturerow(p) { | ||||
|             if (nopictr) { | ||||
|                 nopictr.remove(); | ||||
|                 nopictr = null; | ||||
|             } | ||||
|             var tr = $('<tr class="pic"></tr>'); | ||||
|             tb.append(tr); | ||||
|             if (!templatereadonly && editable) | ||||
|                 createdragtd(tr); | ||||
|             createlinktd(tr, p); | ||||
|  | ||||
|             var td = $('<td style="width:50px;"></td>'); | ||||
|             var img = $('<img style="width:30px;height:30px;float:right;margin-right:10px;"/>').attr('src', p.Url); | ||||
|             td.append(img); | ||||
|             tr.append(td); | ||||
|             input = $('<input type="text" class="form-control" style="width:220px" maxlength="100" autocomplete="off"/>').attr("tabindex", ++tabindex); | ||||
|             if (templatereadonly || p.ReferenceId || !editable) | ||||
|                 input.prop('disabled', true); | ||||
|             input.val(p.Name); | ||||
|             tr.data("pic", p); | ||||
|  | ||||
|             tr.append($('<td></td>').append(input)); | ||||
|  | ||||
|             td = $('<td></td>'); | ||||
|             if (!templatereadonly && !IsReferenced(p.Id) && editable) { | ||||
|                 var del = $('<span class="spanbtn icondelete"></span>').click(tr, function (e) { | ||||
|                     showConfirm(GetTextByKey("P_IPT_DELETEFILECONFIRM", 'Are you sure you want to delete this file?'), GetTextByKey("P_IPT_DELETEFILE", 'Delete File'), function () { | ||||
|                         var p = e.data.data("pic"); | ||||
|                         e.data.remove(); | ||||
|                         //var p = JSON.stringify([teamintelligence, p.ContentId]); | ||||
|                         //inspectionrequest("DeleteStaticPicture", htmlencode(p), function (data) { | ||||
|                         //}, function (err) { | ||||
|                         //}); | ||||
|                     }); | ||||
|                 }); | ||||
|                 td.append(del) | ||||
|             } | ||||
|             tr.append(td); | ||||
|             tb.append(tr); | ||||
|         } | ||||
|  | ||||
|         var draggingpicobj | ||||
|         function createdragtd(tr) { | ||||
|             var td = $('<td style="width:32px;"></td>'); | ||||
|             var drag = $('<div class="question-icon" style="width:30px;"><em class="spanbtn iconmove rowdrag" style="font-size:14px;padding:0;"></em></div>'); | ||||
|             td.append(drag); | ||||
|             tr.append(td); | ||||
|  | ||||
|             drag.attr('draggable', true); | ||||
|             tr.bind('dragstart', function (e) { | ||||
|                 //var data = e.originalEvent.dataTransfer; | ||||
|                 draggingpicobj = tr; | ||||
|             }); | ||||
|             tr.bind('dragend', function (e) { | ||||
|                 draggingpicobj = null; | ||||
|             }); | ||||
|             tr.bind('dragover', function (e) { | ||||
|                 e.originalEvent.preventDefault() | ||||
|             }); | ||||
|             tr.bind('drop', function (e) { | ||||
|                 var t = $(this); | ||||
|                 if (!draggingpicobj || t.is(draggingpicobj)) | ||||
|                     return; | ||||
|                 var after = e.originalEvent.clientY > t.offset().top + t.height() / 2; | ||||
|                 if (after) | ||||
|                     t.after(draggingpicobj); | ||||
|                 else | ||||
|                     t.before(draggingpicobj); | ||||
|  | ||||
|                 //draggingobj.pagemodule.dragOutSection(draggingobj); | ||||
|                 //_this.pagemodule.dragInSection(_this.section, draggingobj, after); | ||||
|  | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function createlinktd(tr, pic) { | ||||
|             var td = $('<td style="width:32px;"></td>'); | ||||
|             if (pic.ReferenceId) { | ||||
|                 var link = $('<div class="question-icon" style="width:30px;"><em class="spanbtn iconlink" style="cursor:default;margin:0;padding:0;font-size:10px;"></em></div>'); | ||||
|                 td.append(link); | ||||
|             } | ||||
|             else { | ||||
|                 td.text(" "); | ||||
|             } | ||||
|             tr.append(td); | ||||
|         } | ||||
|  | ||||
|         function IsReferenced(picid) {//check if template picture can be deleted | ||||
|             if (!_this.istemplate) | ||||
|                 return false; | ||||
|             if (currenttemplate && currenttemplate.Pages && currenttemplate.Pages.length > 0) { | ||||
|                 for (var i = 0; i < currenttemplate.Pages.length; i++) { | ||||
|                     var page = currenttemplate.Pages[i]; | ||||
|                     for (var j = 0; j < page.Sections.length; j++) { | ||||
|                         var section = page.Sections[j]; | ||||
|                         if (section.StaticPictures) { | ||||
|                             for (var m = 0; m < section.StaticPictures.length; m++) { | ||||
|                                 var p = section.StaticPictures[m]; | ||||
|                                 if (p.ReferenceId == picid) | ||||
|                                     return true; | ||||
|                             } | ||||
|                         } | ||||
|                         for (var k = 0; k < section.Questions.length; k++) { | ||||
|                             var question = section.Questions[k]; | ||||
|                             if (question.StaticPictures) { | ||||
|                                 for (var n = 0; n < question.StaticPictures.length; n++) { | ||||
|                                     var p = question.StaticPictures[n]; | ||||
|                                     if (p.ReferenceId == picid) | ||||
|                                         return true; | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return false; | ||||
|         } | ||||
|  | ||||
|         function browsePicture() { | ||||
|             var file = $('<input type="file" style="display: none;" accept="image/png,image/jpg,image/jpeg" />'); | ||||
|             file.change(function () { | ||||
|                 var files = this.files; | ||||
|                 var file = files[0]; | ||||
|                 if (file.size == 0) { | ||||
|                     alert(GetTextByKey("P_IPT_FILETIPS", "File size is 0kb, uploading failed.")); | ||||
|                     return false; | ||||
|                 } | ||||
|                 if (file.size > 1024 * 1024 * 2) { | ||||
|                     alert(GetTextByKey("P_IPT_FILETIPS1", "File is too large. Maximum size is 2MB.")); | ||||
|                     return false; | ||||
|                 } | ||||
|                 SavePicture(file); | ||||
|             }).click(); | ||||
|         } | ||||
|  | ||||
|         function SavePicture(file) { | ||||
|             var formData = new FormData(); | ||||
|             formData.append("pic", file); | ||||
|             formData.append("MethodName", "UploadStaticPicture"); | ||||
|             formData.append("ClientData", teamintelligence); | ||||
|             $.ajax({ | ||||
|                 url: 'Inspection.aspx', | ||||
|                 type: 'POST', | ||||
|                 dataType: 'json', | ||||
|                 processData: false, | ||||
|                 contentType: false, | ||||
|                 data: formData, | ||||
|                 async: true, | ||||
|                 success: function (data) { | ||||
|                     if (data) { | ||||
|                         var p = {}; | ||||
|                         p.Id = $.newGuid(); | ||||
|                         p.ContentId = data.Item1; | ||||
|                         p.Url = data.Item2; | ||||
|                         p.Name = file.name; | ||||
|                         p.DataType = file.name.substring(file.name.lastIndexOf(".")); | ||||
|                         addpicturerow(p); | ||||
|                     } | ||||
|                 }, | ||||
|                 error: function (err) { | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function OnSave() { | ||||
|             if (!templatereadonly && editable) { | ||||
|                 var pics = []; | ||||
|  | ||||
|                 tb.find("tr.pic").each(function () { | ||||
|                     var tr = $(this); | ||||
|                     var p = tr.data("pic"); | ||||
|                     p.Name = tr.find("input").val(); | ||||
|                     pics.push(p); | ||||
|                 }) | ||||
|  | ||||
|                 //for (var i in inputs) { | ||||
|                 //    var input = inputs[i]; | ||||
|                 //    var p = input.data("pic"); | ||||
|                 //    p.Name = input.val(); | ||||
|                 //    pics.push(p); | ||||
|                 //} | ||||
|                 _this.pageele.StaticPictures = pics; | ||||
|                 _this.dialog.hideDialog(); | ||||
|                 if (_this.onok) | ||||
|                     _this.onok(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|  | ||||
|         content.append(createAddButton()); | ||||
|         content.append(createPictureContent()); | ||||
|  | ||||
|  | ||||
|         _this.dialog = Common.createDialog(GetTextByKey("P_IPT_PICTURE", "Picture"), content, OnSave, true); | ||||
|         _this.dialog.showDialogfixed(); | ||||
|     } | ||||
|  | ||||
|     return fsm; | ||||
| }); | ||||
							
								
								
									
										140
									
								
								Site/Inspection/js/modules/templates/template.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										140
									
								
								Site/Inspection/js/modules/templates/template.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,140 @@ | ||||
| define(['modules/templates/addtemplate', 'common'], function (AddTemplate, Common) { | ||||
|     var q = function (tp, template, index) { | ||||
|         this.template = template; | ||||
|         this.templatemodule = tp; | ||||
|         this.index = index | ||||
|     }; | ||||
|     q.prototype.description = "Template Module"; | ||||
|     q.prototype.version = "1.0.0.0"; | ||||
|     var newnamecontrol = undefined; | ||||
|     var dialog = null; | ||||
|  | ||||
|     q.prototype.createContent = function () { | ||||
|         var holder = $('<div class="question-holder"></div>'); | ||||
|         if (this.index % 2 == 1) | ||||
|             holder.addClass('holder-even'); | ||||
|         holder.append('<div class="question-icon template-packages" style="width:30px;padding-left:10px; "><em class="fa icon-menu icon-packages"></em></div>'); | ||||
|         holder.append('<div class="question-cell template-name" style="width:390px;padding-left:10px;"><span></span></div>'); | ||||
|         //holder.append('<div class="question-cell template-display" style="width: 280px;"><span></span></div>'); | ||||
|         holder.append('<div class="question-cell template-notes" style="width:400px;"></div>'); | ||||
|         holder.append('<div class="question-cell template-createdby" style="width:200px;"><span></span></div>'); | ||||
|         var funcs = $('<div class="question-cell template-func" style="width:110px;padding-right:20px;"></div>'); | ||||
|         holder.append(funcs); | ||||
|         var _this = this; | ||||
|         holder.find('.template-name span').click(function () { | ||||
|             var aq = new AddTemplate(_this.templatemodule, _this.template); | ||||
|             $('#right_popup').empty().append(aq.createContent()); | ||||
|             showRightPopup(true); | ||||
|         }); | ||||
|  | ||||
|         if (!templatereadonly) { | ||||
|             funcs.append($('<em class="spanbtn iconedit"></em>').click(function () { | ||||
|                 var aq = new AddTemplate(_this.templatemodule, _this.template); | ||||
|                 $('#right_popup').empty().append(aq.createContent()); | ||||
|                 showRightPopup(true); | ||||
|             }).attr('title', GetTextByKey("P_IPT_EDITTEMPLATE", 'Edit Template'))); | ||||
|             if (templatestatus == 0) { | ||||
|                 funcs.append($('<em class="spanbtn iconshare"></em>').click(function () { | ||||
|                     _this.publish(); | ||||
|                 }).attr('title', GetTextByKey("P_IPT_PUBLISHTEMPLATE", 'Publish Template'))); | ||||
|             } | ||||
|             funcs.append($('<em class="spanbtn icondelete"></em>').click(function () { | ||||
|                 _this.delete(); | ||||
|             }).attr('title', GetTextByKey("P_IPT_DELETETEMPLATE", 'Delete Template'))); | ||||
|  | ||||
|             if (!_this.template.IssueId || _this.template.IssueId == "") { | ||||
|                 funcs.append($('<em class="spanbtn iconcopy"></em>').click(function () { | ||||
|                     _this.openSaveAs(); | ||||
|                 }).attr('title', GetTextByKey("P_IPT_SAVEAS", 'Save As'))); | ||||
|             } | ||||
|         } | ||||
|         this.holder = holder; | ||||
|         if (this.template != null) { | ||||
|             this.updateContent(this.template); | ||||
|         } | ||||
|         return holder; | ||||
|     }; | ||||
|     q.prototype.updateContent = function (template) { | ||||
|         if (this.template != template) { | ||||
|             this.template = template; | ||||
|         } | ||||
|         if (!template.IssueId || template.IssueId == "") | ||||
|             this.holder.find('.template-packages em').hide(); | ||||
|         else | ||||
|             this.holder.find('.template-packages em').show(); | ||||
|  | ||||
|         this.holder.find('.template-name span').text(template.Name); | ||||
|         this.holder.find('.template-name span').attr('title', template.Name); | ||||
|         this.holder.find('.template-display span').text(template.DisplayText); | ||||
|         this.holder.find('.template-display span').attr('title', template.DisplayText); | ||||
|         this.holder.children('.template-notes').html(replaceHtmlText(template.Notes)); | ||||
|         this.holder.children('.template-notes').attr('title', replaceHtmlText(template.Notes)); | ||||
|         this.holder.find('.template-createdby span').text(template.IssueName); | ||||
|         this.holder.find('.template-createdby span').attr('title', template.IssueName); | ||||
|     }; | ||||
|     q.prototype.delete = function () { | ||||
|         var _this = this; | ||||
|         showConfirm(GetTextByKey("P_IPT_AREYOUSUREYOUWANTTODELETETHISTEMPLATE", 'Are you sure you want to delete this template?'), GetTextByKey("P_IPT_DELETETEMPLATE", 'Delete Template'), function () { | ||||
|             var p = JSON.stringify([teamintelligence, htmlencode(_this.template.Id)]); | ||||
|             inspectionrequest("DeleteTemplate", p, function (data) { | ||||
|                 if (data !== 'OK') | ||||
|                     showAlert(data, GetTextByKey("P_IPT_DELETETEMPLATE", 'Delete Template')); | ||||
|                 else if (_this.templatemodule && typeof _this.templatemodule.refresh === "function") | ||||
|                     _this.templatemodule.refresh(); | ||||
|             }, function (err) { | ||||
|                 showAlert(GetTextByKey("P_IPT_FAILEDTODELETETEMPLATE", 'Failed to delete template.'), GetTextByKey("P_IPT_DELETETEMPLATE", 'Delete Template')); | ||||
|             }); | ||||
|         }); | ||||
|     }; | ||||
|     q.prototype.publish = function () { | ||||
|         var _this = this; | ||||
|         showConfirm(GetTextByKey("P_IPT_AREYOUSUREYOUWANTTOPUBLISHTHISTEMPLATE", 'Are you sure you want to publish the template?'), GetTextByKey("P_IPT_PUBLISHTEMPLATE", 'Publish Template'), function () { | ||||
|             var p = JSON.stringify([teamintelligence, htmlencode(_this.template.Id)]); | ||||
|             inspectionrequest("PublishTemplate", p, function (data) { | ||||
|                 if (data !== 'OK') | ||||
|                     showAlert(data, GetTextByKey("P_IPT_PUBLISHTEMPLATE", 'Publish Template')); | ||||
|                 else if (_this.templatemodule && typeof _this.templatemodule.refresh === "function") | ||||
|                     _this.templatemodule.refresh(); | ||||
|             }, function (err) { | ||||
|                 showAlert(GetTextByKey("P_IPT_FAILEDTOPUBLISHTEMPLATE", 'Failed to publish template.'), GetTextByKey("P_IPT_PUBLISHTEMPLATE", 'Publish Template')); | ||||
|             }); | ||||
|         }); | ||||
|     }; | ||||
|     q.prototype.openSaveAs = function () { | ||||
|         var _this = this; | ||||
|         var tb = $('<table style="line-height:40px;"></table>'); | ||||
|         var tr = $('<tr></tr>'); | ||||
|         tb.append(tr); | ||||
|         tr.append('<td class="label" style="vertical-align:middle;">' + GetTextByKey("P_IPT_TEMPLATENAME_COLON", "Template Name:") + '<span class="redasterisk">*</span></td>'); | ||||
|         newnamecontrol = $('<input type="text" maxlength="100"/>'); | ||||
|         tr.append($('<td></td>').append(newnamecontrol)); | ||||
|         dialog = Common.createDialog(GetTextByKey("P_IPT_SAVEAS", 'Save As'), tb, function () { | ||||
|             _this.onSaveAs(); | ||||
|         }); | ||||
|         dialog.showDialog(); | ||||
|     }; | ||||
|  | ||||
|     q.prototype.onSaveAs = function () { | ||||
|         var _this = this; | ||||
|         var name = newnamecontrol.val(); | ||||
|         if (!name || name.length == 0) { | ||||
|             showAlert(GetTextByKey("P_IPT_TEMPLATENAMENOTBEEMPTY", 'Template name cannot be empty.'), GetTextByKey("P_IPT_SAVEAS", 'Save As')); | ||||
|             return; | ||||
|         } | ||||
|         name = htmlencode(name); | ||||
|         var p = JSON.stringify([teamintelligence, _this.template.Id, name]); | ||||
|  | ||||
|         inspectionrequest("TemplateSaveAs", htmlencode(p), function (data) { | ||||
|             if (data !== 'OK') | ||||
|                 showAlert(data, GetTextByKey("P_IPT_SAVEAS", 'Save As')); | ||||
|             else if (_this.templatemodule && typeof _this.templatemodule.refresh === "function") | ||||
|                 _this.templatemodule.refresh(); | ||||
|  | ||||
|             dialog.hideDialog(); | ||||
|         }, function (err) { | ||||
|             showAlert(GetTextByKey("P_IPT_FAILEDTOSAVEAS", 'Failed to save as.'), GetTextByKey("P_IPT_SAVEAS", 'Save As')); | ||||
|         }); | ||||
|     }; | ||||
|  | ||||
|     return q; | ||||
| }); | ||||
							
								
								
									
										128
									
								
								Site/Inspection/js/modules/templates/templatepicture.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										128
									
								
								Site/Inspection/js/modules/templates/templatepicture.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,128 @@ | ||||
| define(['common'], function (Common) { | ||||
|  | ||||
|     var dialogPicture = null; | ||||
|     var ls = function () { | ||||
|     }; | ||||
|  | ||||
|     ls.prototype.getDialogPicture = function () { | ||||
|         if (!dialogPicture) | ||||
|             dialogPicture = new $pictureselector(); | ||||
|         return dialogPicture; | ||||
|     } | ||||
|  | ||||
|     var $pictureselector = function () { | ||||
|         this.title = GetTextByKey("P_IPT_SELECTPICTURE", 'Select Picture'); | ||||
|         this.companyId = null; | ||||
|         this.exceptSource = null; | ||||
|         this.onOK = null; | ||||
|         this.onDialogClosed = null; | ||||
|     }; | ||||
|  | ||||
|     (function () { | ||||
|         var __proto = $pictureselector.prototype; | ||||
|  | ||||
|         function initGrid(parent) { | ||||
|             var grid = new GridView(parent); | ||||
|             var columns = []; | ||||
|             columns.push({ | ||||
|                 // checkbox | ||||
|                 name: 'check', | ||||
|                 key: 'Selected', | ||||
|                 width: 30, | ||||
|                 align: 'center', | ||||
|                 sortable: false, | ||||
|                 allcheck: true, | ||||
|                 type: 3 | ||||
|             }); | ||||
|             columns.push({ | ||||
|                 key: 'Name', | ||||
|                 caption: GetTextByKey("P_IPT_NAME", 'Name'), | ||||
|                 width: 200 | ||||
|             }); | ||||
|             //grid.canMultiSelect = true; | ||||
|             grid.columns = columns; | ||||
|             grid.init(); | ||||
|  | ||||
|             this.gridctrl = grid; | ||||
|         } | ||||
|  | ||||
|         function createDialog() { | ||||
|             var dialog = $('<div class="dialog" style="display: none; width: 602px; height: 380px;z-index:1;">'); | ||||
|  | ||||
|             var title = $('<div class="dialog-title"></div>').appendTo(dialog); | ||||
|             title.append($('<span class="title"></span>').text(this.title)); | ||||
|             title.append('<em class="dialog-close"></em>'); | ||||
|  | ||||
|             var content = $('<div class="dialog-content"></div>').appendTo(dialog); | ||||
|  | ||||
|             this.listdiv = $('<div style="width: 580px; height: 290px;margin-bottom:5px;"></div>').appendTo(content); | ||||
|  | ||||
|             var dialogFunction = $('<div class="dialog-func"></div>').appendTo(dialog); | ||||
|             $('<input type="button" value="' + GetTextByKey("P_IPT_CANCEL", "Cancel") + '" class="dialog-close" />').appendTo(dialogFunction); | ||||
|             //$('<input type="button" value="' + GetTextByKey("P_IPT_COPY", "Copy") + '" />').click(onCopyClick.bind(this)).appendTo(dialogFunction); | ||||
|             $('<input type="button" value="' + GetTextByKey("P_IPT_ADDASLINK", "Add as Link") + '" />').click(onLinkClick.bind(this)).appendTo(dialogFunction); | ||||
|             $('<div class="clear"></div>').appendTo(dialogFunction); | ||||
|  | ||||
|             $('<div class="maskbg" style="display: none;z-index:1;"><div class="loading_icon icon c-spin"></div></div>').appendTo(dialog); | ||||
|  | ||||
|             // init | ||||
|             initGrid.call(this, this.listdiv); | ||||
|             $(document.body).append(dialog); | ||||
|             var mask = $('<div class="maskbg"></div>'); | ||||
|             dialog.data('mask', mask); | ||||
|             dialog.before(mask); | ||||
|  | ||||
|             var _this = this; | ||||
|             dialog.dialog(function () { | ||||
|                 if (_this.onDialogClosed) | ||||
|                     _this.onDialogClosed(); | ||||
|                 if (dialog.data('mask')) | ||||
|                     dialog.data('mask').hide(); | ||||
|             }); | ||||
|             return dialog; | ||||
|         } | ||||
|  | ||||
|         __proto.showSelector = function () { | ||||
|             if (!this.dialog) { | ||||
|                 this.dialog = createDialog.call(this); | ||||
|             } | ||||
|  | ||||
|             if (this.dialog.data('mask')) | ||||
|                 this.dialog.data('mask').show(); | ||||
|             this.dialog.showDialog(false); | ||||
|             this.gridctrl.setData([]); | ||||
|             showTemplatePictures.call(this); | ||||
|         }; | ||||
|  | ||||
|         function showTemplatePictures() { | ||||
|             //currenttemplate is defined in Inspection.aspx, it is a global variable | ||||
|             if (currenttemplate && currenttemplate.StaticPictures && currenttemplate.StaticPictures.length > 0) { | ||||
|                 var items = []; | ||||
|                 for (var i = 0; i < currenttemplate.StaticPictures.length; i++) { | ||||
|                     var it = currenttemplate.StaticPictures[i]; | ||||
|                     it.Selected = false; | ||||
|                     items.push({ Values: it }); | ||||
|                 } | ||||
|                 this.gridctrl.setData(items); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         function onCopyClick() { | ||||
|             //var index = this.gridctrl.selectedIndex; | ||||
|             this.onOK && this.onOK(this.gridctrl.source, true); | ||||
|             if (this.dialog.data('mask')) | ||||
|                 this.dialog.data('mask').hide(); | ||||
|             this.dialog.hideDialog(); | ||||
|         } | ||||
|  | ||||
|         function onLinkClick() { | ||||
|             //var index = this.gridctrl.selectedIndex; | ||||
|             this.onOK && this.onOK(this.gridctrl.source, false); | ||||
|             if (this.dialog.data('mask')) | ||||
|                 this.dialog.data('mask').hide(); | ||||
|             this.dialog.hideDialog(); | ||||
|         } | ||||
|     })(); | ||||
|  | ||||
|     return ls; | ||||
| }); | ||||
							
								
								
									
										528
									
								
								Site/Inspection/js/report.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										528
									
								
								Site/Inspection/js/report.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,528 @@ | ||||
|  | ||||
| var vm; | ||||
| var reportdata; | ||||
| $(function () { | ||||
|     $("#host_header").find(".button").remove(); | ||||
|     $("#spanUserName").remove(); | ||||
|  | ||||
|     checkBrowser(); | ||||
|  | ||||
|     if (teamintelligence) { | ||||
|         $('.assettr').remove(); | ||||
|         $(".assettrmobile").remove(); | ||||
|     } | ||||
|     vm = new Vue({ | ||||
|         el: '#divreport', | ||||
|         data: { | ||||
|             report: { | ||||
|                 Asset: {}, | ||||
|                 Template: {}, | ||||
|                 ReportLayout: {} | ||||
|             } | ||||
|         }, | ||||
|         methods: { | ||||
|             reload: function (data) { | ||||
|                 this.report = data; | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
|     GetInspectionReport(); | ||||
| }); | ||||
|  | ||||
| function checkBrowser() { | ||||
|     if (isMobile()) { | ||||
|         $(".logo").remove(); | ||||
|         $(".logoright").remove(); | ||||
|         $(".headernote").remove(); | ||||
|         $("#host_header").css("text-align", "left").css("min-width", "unset"); | ||||
|  | ||||
|         $("#divreport").css("width", "unset"); | ||||
|         //$("#button-edit").remove(); | ||||
|         $("#button-print").remove(); | ||||
|         $("#button-dl").css("margin-right", 10); | ||||
|         $(".assettr").remove(); | ||||
|  | ||||
|         $("#tdiissues").attr("colspan", "2"); | ||||
|         $("#tdpages").attr("colspan", "2"); | ||||
|         //$(".assettrmobile").children().eq(0).css("width", 130); | ||||
|         //$(".assettrmobile").children().eq(1).css("width", "auto"); | ||||
|         $(".assettrmobile").show(); | ||||
|     } | ||||
|     else { | ||||
|         $(".assettrmobile").remove(); | ||||
|     } | ||||
| } | ||||
|  | ||||
| function GetInspectionReport() { | ||||
|     showmaskbg(true); | ||||
|     var p = JSON.stringify([teamintelligence, htmlencode(reportid)]); | ||||
|     inspectionrequest("GetInspectionReport", p, function (data) { | ||||
|         if (typeof (data) === "string") { | ||||
|             showAlert(data, GetTextByKey("P_IPT_ERROR", 'Error')); | ||||
|         } | ||||
|         else { | ||||
|             reportdata = data; | ||||
|             vm.reload(data); | ||||
|             showReportLayout(data.ReportLayout); | ||||
|             showIdentifiedQuestions(data.IdentifiedQuestions); | ||||
|             showPages(data); | ||||
|             showSignature(data); | ||||
|         } | ||||
|  | ||||
|         showmaskbg(false); | ||||
|     }, function (err) { | ||||
|         showmaskbg(false); | ||||
|     }); | ||||
| } | ||||
|  | ||||
| function showReportLayout(layout) { | ||||
|     $('#reportlayoutlogo').hide(); | ||||
|     $('.td_pageheaderleft').html(''); | ||||
|     $('.td_pageheadercenter').html(''); | ||||
|     $('.td_pageheaderright').html(''); | ||||
|     $('.td_pagefooterleft').html(''); | ||||
|     $('.td_pagefootercenter').html(''); | ||||
|     $('.td_pagefooterright').html(''); | ||||
|     if (layout) { | ||||
|         $('.td_pageheaderleft').html(layout.PageHeaderLeft); | ||||
|         $('.td_pageheadercenter').html(layout.PageHeaderCenter); | ||||
|         $('.td_pageheaderright').html(layout.PageHeaderRight); | ||||
|         $('.td_pagefooterleft').html(layout.PageFooterLeft); | ||||
|         $('.td_pagefootercenter').html(layout.PageFooterCenter); | ||||
|         $('.td_pagefooterright').html(layout.PageFooterRight); | ||||
|  | ||||
|         $('#reportlayoutlogo').show(); | ||||
|         if (layout.IncludeLOGO && layout.LOGO && layout.LOGO.length > 0) { | ||||
|             var jpeg = layout.LOGO; | ||||
|             if (typeof (layout.LOGO) !== "string") { | ||||
|                 jpeg = arrayBufferToBase64(layout.LOGO); | ||||
|             } | ||||
|             $('#reportlayoutlogo').attr('src', 'data:image/png;base64,' + jpeg); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| 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 showIdentifiedQuestions(questions) { | ||||
|     if (!questions || questions.length == 0) | ||||
|         return; | ||||
|     var content = $('<div></div>'); | ||||
|     content.append($('<div class="catelog">IDENTIFIED ISSUES</div>')); | ||||
|     if (questions && questions.length > 0) { | ||||
|         for (var i = 0; i < questions.length; i++) { | ||||
|             var q = questions[i]; | ||||
|             var div_question = $('<div class="question"></div>'); | ||||
|             content.append(div_question); | ||||
|             div_question.append($('<div style="width:320px;flex-grow:1;"></div>').text(q.DisplayText)) | ||||
|             if (q.StaticPictures && q.StaticPictures.length > 0) { | ||||
|                 var div_pic = $('<div style=""></div>'); | ||||
|                 div_pic = createPictures(q.StaticPictures, div_pic); | ||||
|                 div_question.append(div_pic) | ||||
|             } | ||||
|  | ||||
|             createAnswerContent(content, q); | ||||
|         } | ||||
|     } | ||||
|     else | ||||
|         content.append($('<div class="question"></div>').text(GetTextByKey("P_IPT_NOQUESTIONS", 'No Questions'))); | ||||
|  | ||||
|     $('#divquestions').append(content); | ||||
| } | ||||
|  | ||||
| function showSeverityLevel(level) { | ||||
|     var levertext = GetTextByKey("P_IPT_SEVERITYLEVEL_COLON", "Severity Level: "); | ||||
|     if (level === 0) | ||||
|         levertext = ""; | ||||
|     if (level === 1) | ||||
|         levertext += GetTextByKey("P_IPT_SL_LOW", "Low"); | ||||
|     else if (level === 2) | ||||
|         levertext += GetTextByKey("P_IPT_SL_MEDIUM", "Medium"); | ||||
|     else if (level === 3) | ||||
|         levertext += GetTextByKey("P_IPT_SL_HIGH", "High"); | ||||
|     return levertext; | ||||
| } | ||||
|  | ||||
| function showPages(report) { | ||||
|     var pages = report.Template.Pages; | ||||
|     var pagescontent = $('<div></div>'); | ||||
|     pagescontent.append($('<div class="catelog" style="margin-top:20px;">' + GetTextByKey("P_IPT_INSPECTIONDETAIL", "INSPECTION DETAIL") + '</div>')); | ||||
|  | ||||
|     for (var i = 0; i < pages.length; i++) { | ||||
|         var p = pages[i]; | ||||
|         var pagecontent = createPage(p); | ||||
|         pagescontent.append(pagecontent); | ||||
|     } | ||||
|     $('#divpages').append(pagescontent); | ||||
| } | ||||
|  | ||||
| function showSignature(report) { | ||||
|     if (report && report.SignatureUrl && report.SignatureUrl != "") { | ||||
|         $('#divsign').append($('<div style="border-bottom:1px solid #dbdbdb;"></div>')); | ||||
|         $('#divsign').append($('<div class="catelog" style="margin-top:20px;">' + GetTextByKey("P_IPT_SIGNATURE", "Signature") + '</div>')); | ||||
|         var pic = $('<img style="height:320px; margin-left:70px;margin-right:10px;margin-bottom:10px;"></img>').attr('src', report.SignatureUrl); | ||||
|         $('#divsign').append(pic); | ||||
|     } | ||||
| } | ||||
|  | ||||
| function createPage(page) { | ||||
|     var content = $('<div style="padding:0px;"></div>'); | ||||
|     var divpage = $('<div class="page"></div>'); | ||||
|     content.append(divpage); | ||||
|  | ||||
|     var btnpage = $('<em class="spanbtn iconangledown" style="font-size:22px;width:24px;"></em>'); | ||||
|     btnpage.click(function () { | ||||
|         var icon = $(this); | ||||
|         if (icon.hasClass('iconangleright')) { | ||||
|             icon.removeClass('iconangleright').addClass('iconangledown'); | ||||
|             icon.parent().next().show(); | ||||
|         } | ||||
|         else { | ||||
|             icon.removeClass('iconangledown').addClass('iconangleright'); | ||||
|             icon.parent().next().hide(); | ||||
|         } | ||||
|     }); | ||||
|     divpage.append(btnpage); | ||||
|     divpage.append($('<span></span>').text(page.DisplayText)); | ||||
|  | ||||
|     var sectioncontent = createSectionContent(page); | ||||
|     content.append(sectioncontent); | ||||
|  | ||||
|     return content; | ||||
| } | ||||
|  | ||||
| function createSectionContent(page) { | ||||
|     var content = $('<div style="margin-bottom:30px;"></div>'); | ||||
|     if (page.Sections && page.Sections.length > 0) { | ||||
|         for (var i = 0; i < page.Sections.length; i++) { | ||||
|             var s = page.Sections[i]; | ||||
|             var divsection = $('<div class="section"></div>'); | ||||
|             content.append(divsection); | ||||
|  | ||||
|             var btnsection = $('<em class="spanbtn iconangledown" style="font-size:18px;display:inline-block;"></em>'); | ||||
|             btnsection.click(function () { | ||||
|                 var icon = $(this); | ||||
|                 if (icon.hasClass('iconangleright')) { | ||||
|                     icon.removeClass('iconangleright').addClass('iconangledown'); | ||||
|                     icon.parent().next().show(); | ||||
|                 } | ||||
|                 else { | ||||
|                     icon.removeClass('iconangledown').addClass('iconangleright'); | ||||
|                     icon.parent().next().hide(); | ||||
|                 } | ||||
|             }); | ||||
|             divsection.append(btnsection); | ||||
|             var ispic = false; | ||||
|             if (s.StaticPictures && s.StaticPictures.length > 0) { | ||||
|                 ispic = true; | ||||
|                 var div_pic = $('<span></span>'); | ||||
|                 createPictures(s.StaticPictures, div_pic); | ||||
|                 divsection.append(div_pic); | ||||
|                 divsection.append('<br/>'); | ||||
|             } | ||||
|             var span_title = $('<span></span>').text(s.DisplayText); | ||||
|             if (ispic) | ||||
|                 span_title.css('margin-left', 24); | ||||
|             divsection.append(span_title); | ||||
|  | ||||
|             var qc = createQuestionContent(s, i); | ||||
|             content.append(qc); | ||||
|         } | ||||
|     } | ||||
|     else | ||||
|         content.append($('<div class="question"></div>').text('No Sections')); | ||||
|     return content; | ||||
| } | ||||
|  | ||||
| function createQuestionContent(section) { | ||||
|     var content = $('<div style="margin-bottom:30px;"></div>'); | ||||
|     if (section.Questions && section.Questions.length > 0) { | ||||
|         for (var i = 0; i < section.Questions.length; i++) { | ||||
|             var q = section.Questions[i]; | ||||
|             var div_question = $('<div class="question"></div>'); | ||||
|             content.append(div_question); | ||||
|  | ||||
|             var div_title = $('<div style="width:320px;flex-grow:1;"></div>').text(q.DisplayText); | ||||
|             div_question.append(div_title); | ||||
|             if (q.StaticPictures && q.StaticPictures.length > 0) { | ||||
|                 var div_pic = $('<div style=""></div>'); | ||||
|                 div_pic = createPictures(q.StaticPictures, div_pic); | ||||
|                 div_question.append(div_pic) | ||||
|             } | ||||
|  | ||||
|             createAnswerContent(content, q); | ||||
|  | ||||
|             if (i != section.Questions.length - 1) | ||||
|                 content.append($('<div style="border-bottom:1px solid #dbdbdb;"></div>')); | ||||
|         } | ||||
|     } | ||||
|     else | ||||
|         content.append($('<div class="question"></div>').text(GetTextByKey("P_IPT_NOQUESTIONS", 'No Questions'))); | ||||
|     return content; | ||||
| } | ||||
|  | ||||
| function createPictures(pictures, p) { | ||||
|     for (var i = 0; i < pictures.length; i++) { | ||||
|         var pic = pictures[i]; | ||||
|         var img = $('<img style="width:40px;height:40px;margin-left:5px;"/>').attr('src', pic.Url).attr('title', pic.Name); | ||||
|         img.click(pic.Url, function (e) { | ||||
|             window.open(e.data, "_blank") | ||||
|         }); | ||||
|         $(p).append(img); | ||||
|     } | ||||
|     return p; | ||||
| } | ||||
|  | ||||
| function createAnswerContent(p, q) { | ||||
|     var leveltext = showSeverityLevel(q.SeverityLevel); | ||||
|     var label_level = $('<label class="label_level"></label>').text(leveltext); | ||||
|     if (reportdata && reportdata.Answers) { | ||||
|         for (var i = 0; i < reportdata.Answers.length; i++) { | ||||
|             var a = reportdata.Answers[i]; | ||||
|             if (a.QuestionId.toLowerCase() == q.Id.toLowerCase()) { | ||||
|                 if ([5, 8, 9, 10, 14, 15, 19].indexOf(q.QuestionType) < 0 | ||||
|                     || (q.QuestionType == 15 && q.SubType != 15)) {//except YesOrNo/DropDown/MultipleChoice/Picture/FuelRecords | ||||
|                     var result = a.Result; | ||||
|                     if (result == null) { | ||||
|                         result = ''; | ||||
|                     } | ||||
|                     if (q.QuestionType == 6 && result.indexOf(' ') >= 0)//Date do not show time | ||||
|                         result = result.split(' ')[0]; | ||||
|                     if (q.QuestionType == 11//Odometer | ||||
|                         || q.QuestionType == 18 //FuelUsed | ||||
|                         || (q.QuestionType == 15 && q.SubType == 8)//FuelRecords Odometer | ||||
|                         || (q.QuestionType == 15 && q.SubType == 10))//FuelRecords Quantity | ||||
|                         result += " " + convertUnits(a.Units); | ||||
|  | ||||
|                     var div_answer = $('<div class="answer"></div>'); | ||||
|                     if (q.QuestionType == 1 | ||||
|                         || (q.QuestionType == 15 && q.SubType == 14)) | ||||
|                         p.append(div_answer.html(replaceHtmlText(result))).append("<div style='clear:both;'></div>"); | ||||
|                     else if (q.QuestionType == 17 && q.TextToCompare != null && result.toLowerCase() != q.TextToCompare.toLowerCase())  // BarCodeValidate | ||||
|                         p.append(div_answer | ||||
|                             .append($('<span style="color:red"></span>').text(result)) | ||||
|                             .append($('<span style="margin-left:6px"></span>').text('(' + q.TextToCompare + ')')) | ||||
|                         ).append("<div style='clear:both;'></div>"); | ||||
|                     else | ||||
|                         p.append(div_answer.text(result)).append("<div style='clear:both;'></div>"); | ||||
|  | ||||
|                     div_answer.append(label_level); | ||||
|                 } | ||||
|                 else if (q.QuestionType == 5) {//YesOrNo | ||||
|                     if (a.SelectedItems && a.SelectedItems.length > 0) { | ||||
|                         var item = $('<div class="answer" ></div>'); | ||||
|                         var div_bg = $('<div class="circle"></div>'); | ||||
|                         var label = $('<label style="margin-left:5px;"></lable>').text(a.SelectedItems[0].Text); | ||||
|                         item.append(div_bg); | ||||
|                         item.append(label); | ||||
|                         leveltext = showSeverityLevel(a.SelectedItems[0].SeverityLevel); | ||||
|                         label_level = $('<label class="label_level"></label>').text(leveltext); | ||||
|                         item.append(label_level); | ||||
|                         if (a.SelectedItems[0].BackgroundColor && a.SelectedItems[0].BackgroundColor != "") { | ||||
|                             div_bg.css('background-color', a.SelectedItems[0].BackgroundColor); | ||||
|                         } | ||||
|                         p.append(item).append("<div style='clear:both;'></div>"); | ||||
|                     } | ||||
|                 } | ||||
|                 else if (q.QuestionType == 8 || q.QuestionType == 9//DropDown、List | ||||
|                     || (q.QuestionType == 15 && q.SubType == 6) | ||||
|                     || (q.QuestionType == 15 && q.SubType == 9)) { | ||||
|                     if (q.MultipleSelect) { | ||||
|                         if (a.SelectedItems && a.SelectedItems.length > 0) { | ||||
|                             for (var j = 0; j < a.SelectedItems.length; j++) { | ||||
|                                 var item = $('<div class="answer"></div>'); | ||||
|                                 var div_bg = $('<div class="circle"></div>'); | ||||
|                                 var label = $('<label style="margin-left:5px;"></lable>').text("" + (j + 1) + ". " + a.SelectedItems[j].Text); | ||||
|                                 item.append(div_bg); | ||||
|                                 item.append(label); | ||||
|                                 leveltext = showSeverityLevel(a.SelectedItems[j].SeverityLevel); | ||||
|                                 label_level = $('<label class="label_level"></label>').text(leveltext); | ||||
|                                 item.append(label_level); | ||||
|                                 if (a.SelectedItems[j].BackgroundColor && a.SelectedItems[j].BackgroundColor != "") { | ||||
|                                     div_bg.css('background-color', a.SelectedItems[j].BackgroundColor); | ||||
|                                 } | ||||
|                                 p.append(item).append("<div style='clear:both;'></div>"); | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                     else { | ||||
|                         if (a.SelectedItems && a.SelectedItems.length > 0) { | ||||
|                             var item = $('<div class="answer" ></div>'); | ||||
|                             var div_bg = $('<div class="circle"></div>'); | ||||
|                             var label = $('<label style="margin-left:5px;"></lable>').text(a.SelectedItems[0].Text); | ||||
|                             item.append(div_bg); | ||||
|                             item.append(label); | ||||
|                             leveltext = showSeverityLevel(a.SelectedItems[0].SeverityLevel); | ||||
|                             label_level = $('<label class="label_level"></label>').text(leveltext); | ||||
|                             item.append(label_level); | ||||
|                             if (a.SelectedItems[0].BackgroundColor && a.SelectedItems[0].BackgroundColor != "") { | ||||
|                                 div_bg.css('background-color', a.SelectedItems[0].BackgroundColor); | ||||
|                             } | ||||
|                             p.append(item).append("<div style='clear:both;'></div>"); | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|                 else if (q.QuestionType == 14) {//Email (Drop Down) | ||||
|                     if (a.SelectedItems && a.SelectedItems.length > 0) { | ||||
|                         for (var j = 0; j < a.SelectedItems.length; j++) { | ||||
|                             var item = $('<div class="answer"></div>'); | ||||
|                             var label = $('<label style="margin-left:5px;"></lable>').text("" + (j + 1) + ". " + a.SelectedItems[j].Text + "<" + a.SelectedItems[j].Value + ">"); | ||||
|                             item.append(label); | ||||
|                             item.append(label_level); | ||||
|                             p.append(item).append("<div style='clear:both;'></div>"); | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|                 else if (q.QuestionType == 10 | ||||
|                     || (q.QuestionType == 15 && q.SubType == 15)) {//Picture | ||||
|                     var pics = $('<div style="min-height:80px;overflow:auto;padding-left:90px;"></div>'); | ||||
|                     p.append(pics); | ||||
|                     //pics.append(label_level); | ||||
|                     if (reportdata.Medias && reportdata.Medias.length > 0) { | ||||
|                         for (var j = 0; j < reportdata.Medias.length; j++) { | ||||
|                             var m = reportdata.Medias[j]; | ||||
|                             if (m.AnswerId.toLowerCase() == a.Id.toLowerCase()) { | ||||
|                                 if (['.mp4', '.mov'].indexOf(m.FileType.toLowerCase()) >= 0) { | ||||
|                                     var v = $('<div class="media"><span class="video"></span></div>'); | ||||
|                                     v.click(m.Url, function (e) { | ||||
|                                         window.open(e.data, "_blank") | ||||
|                                     }); | ||||
|                                     pics.append(v); | ||||
|                                 } | ||||
|                                 else { | ||||
|                                     var pic = $('<img class="media"></img>').attr('src', m.ThumbnailUrl); | ||||
|                                     pic.click(m.Url, function (e) { | ||||
|                                         window.open(e.data, "_blank") | ||||
|                                     }); | ||||
|                                     pics.append(pic); | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|                 else if (q.QuestionType == 19) {//Asset Status | ||||
|                     var divanswer = $('<div class="answer" ></div>'); | ||||
|                     if (a.SelectedItems && a.SelectedItems.length > 0) { | ||||
|                         var div_bg = $('<div class="circle"></div>'); | ||||
|                         var label = $('<label style="margin-left:5px;"></lable>').text(a.SelectedItems[0].Text); | ||||
|                         divanswer.append(div_bg); | ||||
|                         divanswer.append(label); | ||||
|                         if (a.SelectedItems[0].BackgroundColor && a.SelectedItems[0].BackgroundColor != "") { | ||||
|                             div_bg.css('background-color', a.SelectedItems[0].BackgroundColor); | ||||
|                         } | ||||
|                         p.append(divanswer).append("<div style='clear:both;'></div>"); | ||||
|  | ||||
|                     } | ||||
|                     divanswer.append(label_level); | ||||
|  | ||||
|                     var pics = $('<div style="min-height:80px;overflow:auto;padding-left:90px;"></div>'); | ||||
|                     p.append(pics); | ||||
|                     if (reportdata.Medias && reportdata.Medias.length > 0) { | ||||
|                         for (var j = 0; j < reportdata.Medias.length; j++) { | ||||
|                             var m = reportdata.Medias[j]; | ||||
|                             if (m.AnswerId.toLowerCase() == a.Id.toLowerCase()) { | ||||
|                                 if (['.mp4', '.mov'].indexOf(m.FileType.toLowerCase()) >= 0) { | ||||
|                                     var v = $('<div class="media"><span class="video"></span></div>'); | ||||
|                                     v.click(m.Url, function (e) { | ||||
|                                         window.open(e.data, "_blank") | ||||
|                                     }); | ||||
|                                     pics.append(v); | ||||
|                                 } | ||||
|                                 else { | ||||
|                                     var pic = $('<img class="media"></img>').attr('src', m.ThumbnailUrl); | ||||
|                                     pic.click(m.Url, function (e) { | ||||
|                                         window.open(e.data, "_blank") | ||||
|                                     }); | ||||
|                                     pics.append(pic); | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                     if (a.Result && a.Result != "") { | ||||
|                         p.append($('<div class="answer" style="color:#808080"></div>').html(replaceHtmlText(a.Result))); | ||||
|                     } | ||||
|                 } | ||||
|                 if (a.Comment && a.Comment != "") { | ||||
|                     p.append($('<div class="answer" style="color:#808080"></div>').html(replaceHtmlText(a.Comment))); | ||||
|                 } | ||||
|                 return; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     p.append($('<div class="answer"></div>').text("")); | ||||
|  | ||||
|  | ||||
|     //public string Id { get; set; } | ||||
|     //public string QuestionId { get; set; } | ||||
|     //public string Result { get; set; } | ||||
|     //public string Comment { get; set; } | ||||
|     //public string Units { get; set; } | ||||
|     //public SeverityLeveles SeverityLevel { get; set; } | ||||
|     //public List<SelectItem> SelectedItems { get; } | ||||
|  | ||||
|     //SingleLineText = 0, | ||||
|     //MultipleLineText = 1, | ||||
|     //Email = 2, | ||||
|     //Number = 3, | ||||
|     //Integer = 4, | ||||
|     //YesOrNo = 5, | ||||
|     //Date = 6, | ||||
|     //DateAndTime = 7, | ||||
|     //DropDown = 8, | ||||
|     //MultipleChoice = 9, | ||||
|     //Picture = 10, | ||||
|     //Odometer = 11, | ||||
|     //EngingHours = 12 | ||||
|  | ||||
|     //如果是非select类型,则是界面上直接录的值 | ||||
|     //如果question type为odometer时,units表示所用的单位,其它类型忽略units | ||||
|     //如果question是select类型的(多选,单选,yes / no) ,则忽略result, 此时question的答案要从selecteditems当中去取 | ||||
|     //如果是picture类型,result存的是media的id, | ||||
|     //@Tsanie picture类型是这样的吧 | ||||
|     //picture类型的没在ReportInfo结构上存,是MediaInfo里的AnswerId为ReportInfo里的Id | ||||
|     //如果AssetStatus类型,result存的是notes | ||||
|  | ||||
|  | ||||
|     return result; | ||||
| } | ||||
|  | ||||
| function convertUnits(u) { | ||||
|     switch (u.toLowerCase()) { | ||||
|         case "mile": | ||||
|             return "Mile(s)"; | ||||
|         case "kilometre": | ||||
|         case "kilometer": | ||||
|             return "Kilometer"; | ||||
|         case "percent": | ||||
|             return "Percent"; | ||||
|         case "gallon": | ||||
|         case "gal": | ||||
|             return "Gallon"; | ||||
|         case "litre": | ||||
|             return "Litre"; | ||||
|         default: | ||||
|             break; | ||||
|     } | ||||
|     return u; | ||||
| } | ||||
|  | ||||
| function isLight(color) { | ||||
|     color = color.replace('#', ''); | ||||
|     var r, g, b; | ||||
|     if (color.length == 6) { | ||||
|         r = '0x' + color.substr(0, 2); | ||||
|         g = '0x' + color.substr(2, 2); | ||||
|         b = '0x' + color.substr(4, 2); | ||||
|  | ||||
|         return 0.213 * parseInt(r) + 0.715 * parseInt(g) + 0.072 * parseInt(b) > 255 / 2; | ||||
|     } | ||||
|     return true; | ||||
| } | ||||
							
								
								
									
										23
									
								
								Site/Inspection/js/view-main.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								Site/Inspection/js/view-main.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| require.config({ | ||||
|     baseUrl: 'js', | ||||
|     paths: { | ||||
|         //jquery: "../../js/jquery-3.6.0.min", | ||||
|         //spectrum: "../../js/spectrum" | ||||
|     }, | ||||
|     waitSeconds: 0, | ||||
|     urlArgs: "v=38" //+ Math.random() | ||||
| }) | ||||
|  | ||||
| requirejs(['modules/inspects/editinspection'], function (EditModule) { | ||||
|     //if (isAdmin) { | ||||
|         $(function () { | ||||
|             $('#button-edit').click(function () { | ||||
|                 var ei = new EditModule.EditInspection(function () { | ||||
|                     window.location = window.location.href; | ||||
|                 }, reportid); | ||||
|                 $('#right_popup').empty().append(ei.createContent()); | ||||
|                 showRightPopup(true); | ||||
|             }); | ||||
|         }); | ||||
|     //} | ||||
| }) | ||||
							
								
								
									
										105
									
								
								Site/IronIntelMain.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										105
									
								
								Site/IronIntelMain.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,105 @@ | ||||
| <%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/IronIntelMasterPage.master" CodeFile="IronIntelMain.aspx.cs" Inherits="IronIntelMain" %> | ||||
|  | ||||
|  | ||||
| <asp:Content ID="Content1" ContentPlaceHolderID="holder_head" runat="Server"> | ||||
|     <style type="text/css"> | ||||
|         .modules { | ||||
|             margin-left: 240px; | ||||
|             margin-right: 160px; | ||||
|             margin-bottom: 50px; | ||||
|             padding-right: 0px; | ||||
|             /*position: absolute;*/ | ||||
|             /*top: 120px;*/ | ||||
|             /*bottom: 40px;*/ | ||||
|             /*overflow-y: auto;*/ | ||||
|         } | ||||
|  | ||||
|         body { | ||||
|             background-color: #F6F6F6; | ||||
|         } | ||||
|     </style> | ||||
|     <script type="text/javascript"> | ||||
|         SetClientTimeoffset(); | ||||
|  | ||||
|         function showAppModules(data) { | ||||
|             if (data) { | ||||
|                 var sysModules = $("#sysModules").empty(); | ||||
|                 var wspModules = $("#wspModules").empty(); | ||||
|                 for (var i = 0; i < data.length; i++) { | ||||
|                     var m = data[i]; | ||||
|                     if (!m.Visible) continue; | ||||
|                     var mctrl = $("<div class='module'></div>"); | ||||
|                     var icon = createMouduleIcon(m, 0); | ||||
|                     mctrl.append(icon); | ||||
|  | ||||
|                     var namectrl = $("<div class='modulenamectrl'></div>") | ||||
|                         .append($("<div class='modulename'></div>") | ||||
|                             .append($("<span></span>").text(m.ModuleType === 1 ? m.Name : m.CurrentName))); | ||||
|                     mctrl.append(namectrl); | ||||
|                     mctrl.attr("title", m.ModuleType === 1 ? m.Description : m.CurrentDesc); | ||||
|                     var css = []; | ||||
|                     //if (m.BackColor) | ||||
|                     //    css["background-color"] = m.BackColor; | ||||
|                     //if (m.ForeColor) | ||||
|                     //    css["color"] = m.ForeColor; | ||||
|                     mctrl.css(css); | ||||
|                     mctrl.mouseenter(mctrl, function (e) { | ||||
|                         e.data.css("cursor", 'pointer'); | ||||
|                     }); | ||||
|                     mctrl.mousedown(m, function (e) { | ||||
|                         $(e.target).on("mouseup", "", e.data, openAppModule); | ||||
|                     }); | ||||
|                     if (m.ModuleType == 0) { | ||||
|                         sysModules.append(mctrl); | ||||
|                         $("#titleFeatures").show(); | ||||
|                     } | ||||
|                     else if (m.ModuleType == 1) { | ||||
|                         wspModules.append(mctrl); | ||||
|                         $("#titleWSP").show(); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             $("#ploading").hide(); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         function openAppModule(e) { | ||||
|             var url = e.data.Url; | ||||
|             if (e.data.ID == '150') | ||||
|                 url += "#nav_jobsitemanage"; | ||||
|             if (e.data.OpenInNewWindow) | ||||
|                 window.open(url, "_bank"); | ||||
|             else | ||||
|                 window.location = url; | ||||
|             $(e.target).off("mouseup"); | ||||
|         } | ||||
|  | ||||
|         $(document).scroll(null, function (e) { | ||||
|             $("#footer").css("bottom", -$(document).scrollTop()); | ||||
|         }); | ||||
|     </script> | ||||
| </asp:Content> | ||||
|  | ||||
| <asp:Content ID="Content2" ContentPlaceHolderID="holder_content" runat="Server"> | ||||
|     <div id="header" style="height: 60px;"> | ||||
|     </div> | ||||
|     <div id="ploading" class="panel_loading"></div> | ||||
|     <div id="modules" class="modules"> | ||||
|         <div id="titleFeatures" class="modulestitle" style="display: none;" data-lgid="P_MAIN_FEATURES">Features</div> | ||||
|         <div id="sysModules"></div> | ||||
|         <div id="titleWSP" class="modulestitle" style="margin-top: 10px; display: none;" data-lgid="P_MAIN_DASHBOARDS">Dashboards</div> | ||||
|         <div id="wspModules"></div> | ||||
|         <div style="clear: both;"></div> | ||||
|     </div> | ||||
|     <div id="footer" style="width: 100%; background-color: lightgray; position: fixed; bottom: 0px;"> | ||||
|         <table style="margin: 0 auto; margin-right: 10px;"> | ||||
|             <tr id="version_info"> | ||||
|                 <td><span data-lgid="P_MAIN_VERSION_COLON">Version:</span> <%=AppVersion %></td> | ||||
|                 <td data-lgid="P_MAIN_POWEREDBY">Powered By</td> | ||||
|                 <td> | ||||
|                     <img class="logo" src="titlelogo.ashx?cmpid=Foresight&v=0" style="width: 100px; height: 20px;" /> | ||||
|                 </td> | ||||
|             </tr> | ||||
|         </table> | ||||
|     </div> | ||||
| </asp:Content> | ||||
							
								
								
									
										26
									
								
								Site/IronIntelMain.aspx.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								Site/IronIntelMain.aspx.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | ||||
| 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 IronIntelMain : MainBasePage | ||||
| { | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     { | ||||
|         string tp = Request.Params["tp"]; | ||||
|         if (string.Compare(tp, "ashx", true) == 0) | ||||
|         { | ||||
|             ProcessRequest(); | ||||
|         } | ||||
|         else if (!IsPostBack) | ||||
|         { | ||||
|             Title = PageTitle; | ||||
|             if (CheckLoginSession()) | ||||
|             {                 | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										1231
									
								
								Site/IronIntelMasterPage.master
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1231
									
								
								Site/IronIntelMasterPage.master
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										172
									
								
								Site/IronIntelMasterPage.master.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										172
									
								
								Site/IronIntelMasterPage.master.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,172 @@ | ||||
| using FI.FIC; | ||||
| using Foresight.Fleet.Services.Customer; | ||||
| using Foresight.Fleet.Services.Styles; | ||||
| using Foresight.ServiceModel; | ||||
| 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 IronIntelMasterPage : CommonBase | ||||
| { | ||||
|     protected string CompanyTitle; | ||||
|     private string Logo1html = "<img class=\"logo\" src=\"{0}\" style=\" \" />"; | ||||
|     private string Logo2html = "<img class=\"logocenter\" src=\"{0}\" style=\" \" />"; | ||||
|     private string Logo3html = "<img class=\"logoright\" src=\"{0}\" style=\" \" />"; | ||||
|  | ||||
|     protected string Logo1 = ""; | ||||
|     protected string Logo2 = ""; | ||||
|     protected string Logo3 = ""; | ||||
|  | ||||
|     protected string JQueryVersion; | ||||
|  | ||||
|     protected string MenuBackgroundColor = "#D7690E"; | ||||
|  | ||||
|     protected string TitleBarBorderColor = "#FFFFFF"; | ||||
|     protected string CompanyID; | ||||
|     protected string UserID; | ||||
|     protected bool IsReadonlyUser; | ||||
|     protected bool CanSeeUserMessage; | ||||
|  | ||||
|     protected override bool ExportModule | ||||
|     { | ||||
|         get { return true; } | ||||
|     } | ||||
|  | ||||
|     protected void Page_Load(object sender, EventArgs e) | ||||
|     { | ||||
|         if (!IsPostBack) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 var cmp = SystemParams.GetCompanyInfo(); | ||||
|                 CompanyTitle = cmp.Name; | ||||
|                 GetLogoHtml(cmp); | ||||
|                 GetUIStyle(); | ||||
|                 GetMainStyle(); | ||||
|             } | ||||
|             catch | ||||
|             { | ||||
|                 // TODO: errors when get the company name. | ||||
|             } | ||||
|  | ||||
|             if (this.Page is IronIntel.Contractor.Site.ContractorBasePage) | ||||
|             { | ||||
|                 JQueryVersion = ((IronIntel.Contractor.Site.ContractorBasePage)this.Page).JQueryVersion; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void GetLogoHtml(CustomerInfo cmp) | ||||
|     { | ||||
|         var root = ResolveUrl("~/"); | ||||
|         var sessionid = IronIntelBasePage.GetLoginSessionID(Request); | ||||
|         StringKeyValue kv = UserManagement.GetSiteHederStyleLogo(sessionid); | ||||
|         string styleid = "-1"; | ||||
|         bool hasContractorLogo = false; | ||||
|         bool hasDealerLogo = false; | ||||
|         if (kv != null) | ||||
|         { | ||||
|             styleid = kv.Key; | ||||
|             hasContractorLogo = Helper.IsTrue(kv.Tag1); | ||||
|             hasDealerLogo = Helper.IsTrue(kv.Tag2); | ||||
|         } | ||||
|  | ||||
|         if (cmp.IsContractor) | ||||
|         {//Logo1 Dealer;Logo2 Contractor(Self);Logo3 IronIntel | ||||
|             CustomerInfo dealer = SystemParams.GetFirstDealerInfo(); | ||||
|             if (dealer != null) | ||||
|             { | ||||
|                 if (hasDealerLogo)//user Dealer | ||||
|                 { | ||||
|                     Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?cmpid=" + dealer.ID + "&cmpty=dealer&styid=" + styleid); | ||||
|                 } | ||||
|                 else if (SystemParams.HasLOGO(dealer.ID))//Dealer | ||||
|                 { | ||||
|                     Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?cmpid=" + dealer.ID); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     Logo1 = string.Format("<div class=\"logo\">{0}</div>", dealer.Name); | ||||
|                 } | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 Logo1 = string.Empty; | ||||
|             } | ||||
|  | ||||
|             if (hasContractorLogo)//User Contractor | ||||
|             { | ||||
|                 Logo2 = string.Format(Logo2html, root + "titlelogo.ashx?cmpid=" + cmp.ID + "&cmpty=contractor&styid=" + styleid); | ||||
|             } | ||||
|             else if (SystemParams.HasLOGO(cmp.ID))//Contractor | ||||
|             { | ||||
|                 Logo2 = string.Format(Logo2html, root + "titlelogo.ashx?cmpid=" + cmp.ID); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 Logo2 = string.Format("<span class=\"logocenter\">{0}</span>", cmp.Name); | ||||
|             } | ||||
|  | ||||
|             if (SystemParams.ShowForesightLogo()) | ||||
|                 Logo3 = string.Format(Logo3html, root + "titlelogo.ashx?cmpid=foresight"); | ||||
|         } | ||||
|         else | ||||
|         {//Logo1 Dealer(Self);Logo3 IronIntel | ||||
|             if (hasDealerLogo)//user Dealer | ||||
|             { | ||||
|                 Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?cmpid=" + cmp.ID + "&cmpty=dealer&styid=" + styleid); | ||||
|             } | ||||
|             else if (SystemParams.HasLOGO(cmp.ID))//Dealer | ||||
|             { | ||||
|                 Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?cmpid=" + cmp.ID); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 Logo1 = string.Format("<div class=\"logo\">{0}</div>", cmp.Name); | ||||
|             } | ||||
|  | ||||
|             Logo2 = ""; | ||||
|  | ||||
|             if (SystemParams.ShowForesightLogo()) | ||||
|                 Logo3 = string.Format(Logo3html, root + "titlelogo.ashx?cmpid=foresight"); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     protected override StyleInfo GetUIStyle() | ||||
|     { | ||||
|         var info = base.GetUIStyle(); | ||||
|         var user = info.User; | ||||
|         if (user != null) | ||||
|         { | ||||
|             UserID = user.ID; | ||||
|             IsReadonlyUser = user.UserType == UserTypes.Readonly; | ||||
|             CanSeeUserMessage = user.UserType == UserTypes.Common || user.UserType == UserTypes.Admin; | ||||
|             var style = info.Style; | ||||
|             if (style != null) | ||||
|             { | ||||
|                 if (!string.IsNullOrEmpty(style.MenuBackgroundColor)) | ||||
|                 {//目前Menu和Module背景色使用同一个颜色,在有设置的情况下 | ||||
|                     MenuBackgroundColor = style.MenuBackgroundColor; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         CompanyID = SystemParams.CompanyID; | ||||
|         return info; | ||||
|     } | ||||
|  | ||||
|     private void GetMainStyle() | ||||
|     { | ||||
|         var ms = SystemParams.GetMainStyle(); | ||||
|         if (ms != null && !string.IsNullOrEmpty(ms.TitleBarBorderColor)) | ||||
|         { | ||||
|             TitleBarBorderColor = ms.TitleBarBorderColor; | ||||
|         } | ||||
|     } | ||||
| } | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user