function ShowEngineHours(n){var u=[],r,t,i;for(isCalampEH=!1,isPedigreeEH=!1,isOEMDD2EH=!1,primarydatadourcenameEH=undefined,primarydatadourceEH=undefined,r=0;r0&&(t.AsofTime=n[0].AsofTime,t.AsofTimeLocal=n[0].AsofTimeLocal,t.EventTimeLocalText=n[0].EventTimeLocalText,t.EventTimeText=n[0].EventTimeText);t.VBUS_Calc=t.VBUS-r;t.VBUS_Calc={DisplayValue:t.VBUS_Calc.toFixed(2),Value:t.VBUS_Calc};t.Gps_Calc=t.Gps-u;t.Gps_Calc={DisplayValue:t.Gps_Calc.toFixed(2),Value:t.Gps_Calc};f.push(t);grid_enginehoursmostrecentdt.sortIndex=-1;grid_enginehoursmostrecentdt.sortDirection=-1;grid_enginehoursmostrecentdt.setData(f)}}function ShowEngineHoursHis(n){for(var t,i,u=[],r=0;r0){i==1?showAlert(GetTextByKey("P_MA_CHECKENGINEHOURSMINNIMUMTIME","The adjustment cannot be completed as provided. The engine hours reading date provided cannot be prior to initial telematic data available for the asset."),GetTextByKey("P_MA_ADJUSTENGINEHOURS","Adjust Engine Hours")):showAlert(GetTextByKey("P_MA_CHECKENGINEHOURSMINNIMUMTIME1","The adjustment cannot be completed as provided. The engine hours reading date provided must be prior to or equal to the latest telematic data available for the asset."),GetTextByKey("P_MA_ADJUSTENGINEHOURS","Adjust Engine Hours"));return}t==="submit"?SaveAdjustEngineHours(n):t==="preview"&&GetCalampEngineHoursHistoryPreview(n)},function(){showsubmask("adjustenginehoursmask",!1)})}function SaveAdjustEngineHours(n){var i,t;showsubloading("adjustenginehoursmask",!0);i=JSON.stringify(n);i=htmlencode(i);showsubloading("adjustenginehoursmask",!0);t=GetTextByKey("P_MA_ADJUSTENGINEHOURS",GetTextByKey("P_MA_ADJUSTENGINEHOURS","Adjust Engine Hours"));devicerequest("SaveAdjustEngineHours",i,function(n){showsubloading("adjustenginehoursmask",!1);n!=="OK"?showAlert(n,t):(getEnineHours(),getMachineInfo(),showAlert(GetTextByKey("P_MA_SUCCESSFULLY","{0} Successfully.").replace("{0}",t),t));$("#dialog_adjustenginehours").hideDialog();showmaskbg(!1)},function(n){console.log(n);showAlert(GetTextByKey("P_MA_FAILEDTO","Failed to {0}.").replace("{0}",t),t);showsubloading("adjustenginehoursmask",!1)})}function OnPreviewEngineHours(){getEngineHoursHisPreview()}function openAddEnginHours(){var t=customerdatetime.split(" "),i=t[0],n=t[1].split(":"),r=n[0].length==1?"0"+n[0]:n[0],u=n[1];$("#dialogaddgenginehours_enginehours").val("");$("#dialogadd_enginehourstimezone").val(customertimezone?customertimezone:"UTC");$("#dialogaddenginehours_date").val(i);$("#dialogaddenginehours_timehour").val(r);$("#dialogaddenginehours_timeminute").val(u);$("#dialogaddenginehours_Notes").val("");$("#dialog_addenginehours .dialog-title span.title").text(GetTextByKey("P_MA_ADDENGINEHOURS","Add Engine Hours"));showmaskbg(!0);$("#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(){showsubmask("addenginehoursmask",!0);var n=GetTextByKey("P_MA_ADDENGINEHOURS","Add Engine Hours"),t=GetTextByKey("P_MA_ENGINEHOURS","Engine Hours");showConfirm1(GetTextByKey("P_MA_DOYOUWANTTOADDTHEENGINEHOURS","Do you want to add the engine hours?"),n,function(){var i={CustomerID:contractorid,AssetID:machineid,EngineHours:$("#dialogaddgenginehours_enginehours").val(),EngineHoursDate:$("#dialogaddenginehours_date").val(),Notes:$("#dialogaddenginehours_Notes").val()},u,f,e,r;if(i.EngineHours!==""){if(isNaN(i.EngineHours)){showAlert(GetTextByKey("P_MA_FORMATERROR","{0} format error.").replace("{0}",t),n);showsubmask("addenginehoursmask",!1);return}if(i.EngineHours<=0){showAlert(GetTextByKey("P_MA_MUSTBEGREATERTHAN0","{0} must be greater than 0.").replace("{0}",t),n);showsubmask("addenginehoursmask",!1);return}}else{showAlert(GetTextByKey("P_MA_NOTBEEMPTY","{0} cannot be empty.").replace("{0}",t),n);showsubmask("addenginehoursmask",!1);return}if(i.EngineHoursDate===""){showAlert(GetTextByKey("P_MA_NOTBEEMPTY","{0} cannot be empty.").replace("{0}",t),n);showsubmask("addenginehoursmask",!1);return}u=$("#dialogadd_enginehourstimezone").find("option:selected").attr("offset");i.OffsetMinute=u;i.TimeZone=$("#dialogadd_enginehourstimezone").find("option:selected").val();f=$("#dialogaddenginehours_timehour").val();e=$("#dialogaddenginehours_timeminute").val();i.EngineHoursDate=i.EngineHoursDate.replace("-","/")+" "+f+":"+e+":00";r=JSON.stringify(i);r=htmlencode(r);showsubloading("addenginehoursmask",!0);devicerequest("AddManuallyInputEngineHours",r,function(t){showsubloading("addenginehoursmask",!1);t!=="OK"?(t==="Failed"&&(t=GetTextByKey("P_MA_FAILED","Failed")),showAlert(t,n)):(getEnineHours(),getMachineInfo(),showAlert(GetTextByKey("P_MA_SUCCESSFULLY","{0} Successfully.").replace("{0}",GetTextByKey("P_MA_ADDENGINEHOURS","Add Engine Hours")),n));$("#dialog_addenginehours").hideDialog();showmaskbg(!1)},function(t){console.log(t);showsubloading("addenginehoursmask",!1);showAlert(GetTextByKey("P_MA_FAILEDTO","Failed to {0}.").replace("{0}",GetTextByKey("P_MA_ADDENGINEHOURS","Add Engine Hours")),n)})},function(){showsubmask("addenginehoursmask",!1)})}function openEngineHoursAdjustHistory(){window.open("EngineHoursAdjustHistory.aspx?cid="+contractorid+"&mid="+machineid)}function ShowFuelRemainings(n){for(var t,i,u=[],r=0;r0&&(t.AsofTime=n[0].AsofTime,t.AsofTimeLocal=n[0].AsofTimeLocal,t.EventTimeLocalText=n[0].EventTimeLocalText,t.EventTimeText=n[0].EventTimeText);t.VBUS_Calc=t.VBUS-r;t.VBUS_Calc={DisplayValue:t.VBUS_Calc.toFixed(2),Value:t.VBUS_Calc};t.Gps_Calc=t.Gps-u;t.Gps_Calc={DisplayValue:t.Gps_Calc.toFixed(2),Value:t.Gps_Calc};f.push(t);grid_odometermostrecentdt.sortIndex=-1;grid_odometermostrecentdt.sortDirection=-1;grid_odometermostrecentdt.setData(f)}}function ShowOdometerHis(n){for(var t,i,u=[],r=0;r0){i==1?showAlert(GetTextByKey("P_MA_CHECKODOMETERMINNIMUMTIME1","The adjustment cannot be completed as provided. The odometer reading date provided cannot be prior to initial telematic data available for the asset."),GetTextByKey("P_MA_ADJUSTODOMETER","Adjust Odometer")):showAlert(GetTextByKey("P_MA_CHECKODOMETERMINNIMUMTIME","The adjustment cannot be completed as provided. The odometer reading date provided must be prior to or equal to the latest telematic data available for the asset."),GetTextByKey("P_MA_ADJUSTODOMETER","Adjust Odometer"));return}t==="submit"?SaveAdjustOdometer(n):t==="preview"&&GetOdometerHistoryPreview(n)},function(){showsubmask("adjustodomask",!1)})}function SaveAdjustOdometer(n){showsubloading("adjustodomask",!0);var t=JSON.stringify(n);t=htmlencode(t);devicerequest("SaveAdjustOdometer",t,function(n){showsubloading("adjustodomask",!1);n!=="OK"?showAlert(n,GetTextByKey("P_MA_ADJUSTODOMETER","Adjust Odometer")):(getOdometers(),getMachineInfo(),showAlert(GetTextByKey("P_MA_ADJUSTODOMETERSUCCESSFULLY","Adjust Odometer Successfully."),GetTextByKey("P_MA_ADJUSTODOMETER","Adjust Odometer")));$("#dialog_adjustodometer").hideDialog();showmaskbg(!1)},function(){showAlert(GetTextByKey("P_MA_FAILEDTOADJUSTDOMETER","Failed to adjust Odometer."),GetTextByKey("P_MA_ADJUSTODOMETER","Adjust Odometer"));showsubloading("adjustodomask",!1)})}function OnPreviewOdometer(){getOdometerHisPreview()}function openAddOdometer(){var t=customerdatetime.split(" "),i=t[0],n=t[1].split(":"),r=n[0].length==1?"0"+n[0]:n[0],u=n[1];$("#dialogadd_odometer").val("");$("#dialogadd_sel_odometeruom").val(systemunitofodometer);$("#dialogadd_odometertimezone").val(customertimezone?customertimezone:"UTC");$("#dialogadd_odometerdate").val(i);$("#dialogadd_timehour").val(r);$("#dialogadd_timeminute").val(u);$("#dialogadd_notes").val("");$("#dialog_addodometer .dialog-title span.title").text(GetTextByKey("P_MA_ADDODOMETER","Add Odometer"));showmaskbg(!0);$("#dialog_addodometer").css({top:(document.documentElement.clientHeight-$("#dialog_addodometer").height())/3,left:(document.documentElement.clientWidth-$("#dialog_addodometer").width())/2}).showDialogfixed();$("#dialogadd_odometer").focus()}function OnAddOdometer(){showsubmask("addodomask",!0);var n=GetTextByKey("P_MA_ADDODOMETER","Add Odometer");showConfirm1(GetTextByKey("P_MA_DOYOUWANTTOADDTHEODOMETER","Do you want to add the odometer?"),n,function(){var t={CustomerID:contractorid,AssetID:machineid,Odometer:$("#dialogadd_odometer").val(),UOM:$("#dialogadd_sel_odometeruom").val(),OdometerDate:$("#dialogadd_odometerdate").val(),Notes:$("#dialogadd_notes").val()},r,u,f,i;if(t.Odometer!==""){if(isNaN(t.Odometer)){showAlert(GetTextByKey("P_MA_ODOMETERFORMATERROR","Odometer format error."),n);showsubmask("addodomask",!1);return}if(t.Odometer<=0){showAlert(GetTextByKey("P_MA_ODOMETERMUSTBEGREATERTHAN0","ODOMeter must be greater than 0."),n);showsubmask("addodomask",!1);return}}else{showAlert(GetTextByKey("P_MA_ODOMETRCANNOTBEEMPTY","Odometer cannot be empty."),n);showsubmask("addodomask",!1);return}if(t.OdometerDate===""){showAlert(GetTextByKey("P_MA_ODOMETRDATACANNOTBEEMPTY","Odometer date cannot be empty."),n);showsubmask("addodomask",!1);return}r=$("#dialogadd_odometertimezone").find("option:selected").attr("offset");t.OffsetMinute=r;t.TimeZone=$("#dialogadd_odometertimezone").find("option:selected").val();u=$("#dialogadd_timehour").val();f=$("#dialogadd_timeminute").val();t.OdometerDate=t.OdometerDate.replace("-","/")+" "+u+":"+f+":00";i=JSON.stringify(t);i=htmlencode(i);showsubloading("addodomask",!0);devicerequest("AddManuallyInputOdometer",i,function(t){showsubloading("addodomask",!1);t!=="OK"?showAlert(t,n):(getOdometers(),getMachineInfo(),showAlert("Add Odometer Successfully.",n));$("#dialog_addodometer").hideDialog();showmaskbg(!1)},function(){showAlert("Failed to add Odometer.",n);showsubloading("addodomask",!1)})},function(){showsubloading("addodomask",!1)})}function openOdometerAdjustHistory(){window.open("OdometerAdjustHistory.aspx?cid="+contractorid+"&mid="+machineid)}function auditHide(n){var t=$(n.target),i;t.data("hide")==1?(t.data("hide",0),i=t.parent(),i.next().show(),i.next().next().show(),t.removeClass("plus").addClass("minus")):(t.data("hide",1),i=t.parent(),i.next().hide(),i.next().next().hide(),t.removeClass("minus").addClass("plus"))}function initTime(){for(var t=$("#dialogadjust_timehour"),n=0;n<24;n++)n<10?t.append($("