<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="AddMaintenanceRecord.aspx.cs" Inherits="AddMaintenanceRecord" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"> <style type="text/css"> ::-ms-clear, ::-ms-reveal { display: none; } .edit-content table { border-collapse: collapse; width: 100%; } .edit-content table td.label { width: 200px; text-align: right; padding-right: 10px; line-height: 24px; height: 24px; vertical-align: top; } .edit-content table td input, .edit-content table td textarea { border: 1px solid #a9a9a9; width: 320px; height: 18px; padding: 1px; } .edit-content table td input[type="checkbox"] { border: none; } .edit-content table td textarea { height: 100px; resize: none; /*max-width: 200px;*/ } .a { text-decoration: none; color: #2140fb; } .subtitle { margin: 20px 40px 5px 0px; font-size: 16px; color: gray; } .subtitle span { margin-left: 10px; } .subtitle hr { background-color: #d8d8d8; border: none; height: 1px; } .machinetd { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; } #host_main { overflow: hidden; } </style> <link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" /> <script src="<%=GetFileUrlWithVersion("../Maintenance/js/inputdatactr.js")%>" type="text/javascript"></script> <script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script> <script src="<%=GetFileUrlWithVersion("../js/editableselect.js")%>"></script> <script src="<%=GetFileUrlWithVersion("js/maintenancelogattachment.js")%>" type="text/javascript"></script> <script type="text/javascript"> var maintenanceid = ""; <%--"<%=MaintenanceID %>";--%> var machineid = "";<%--"<%=MachineID %>";--%> var _attachments = []; var isshowdelete = true; var currentdate = "<%=CurrentDate %>"; function maintenancerequest(method, param, callback, error) { _network.request("Maintenance/AddMaintenanceRecord.aspx", -1, method, param, callback, error || function (e) { console.log(e); showmaskbg(false, true); showAlert(GetTextByKey('P_MRM_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_MRM_QUERY', 'Query')); }); } function getUnCompletedPMAlerts(next) { $('#pmAlerts_tbody').empty(); showloading(true); maintenancerequest("GetUnCompletedPMAlerts", machineid + String.fromCharCode(170) + maintenanceid, function (data) { showloading(false); if (typeof (data) === "string") { showAlert(data, GetTextByKey("P_MRM_ERROR", 'Error')); return; } var alerts = data; for (var i = 0; i < alerts.length; i++) { var alert = alerts[i] var tr = $('<tr></tr>').attr('alertid', alert.AlertID); var tdalertid = $('<td style="word-wrap:break-word;word-break:break-all;"></td>').text(alert.AlertID); var tdtitle = $('<td style="word-wrap:break-word;word-break:break-all;"></td>').text(alert.AlertTitle); var tdtime = $('<td style="word-wrap:break-word;word-break:break-all;"></td>').text(alert.AlertTime); tr.click(tr, function (e) { var alertid = $(this).attr("alertid"); if (e.data.hasClass("selected")) $('#dialog_pmalerts').val(""); else $('#dialog_pmalerts').val(alertid); $('#dialog_pmalerts').focus(); }); tr.append(tdalertid, tdtitle, tdtime); $('#pmAlerts_tbody').append(tr); var rid = $('#dialog_pmalerts').val();//maintenanceid if (rid == alert.AlertID + '') tr.addClass("selected"); } if (next) next(); }, function (err) { console.log(err); showloading(false); }); } function OnAdd() { $("#dialog_pmalerts").attr("disabled", false); $('#dig_mtype').attr("disabled", false); $('#dialog_pmalerts').val(''); $('#dialog_mdate').val(''); $('#dialog_hours').val(''); $('#dialog_notes').val(''); $('#dialog_cost').val(''); $('#dialog_invoicenumber').val(''); $('#dig_completedby').val(''); $('#dig_mtype').val('Hours'); $('#dialog_distance').val(''); $('#dig_uom').val(systemunitofodometer); $('#tr_distance').hide(); $('#tr_hours').show(); $('#tabAttachments').hide(); $("#tbAttas").empty(); $('#dateformatspan').css('display', ''); } var recorddata; function OnEdit() { $('#dig_mtype').attr("disabled", true); showloading(true); maintenancerequest("GetMaintenanceInfo", maintenanceid, function (data) { showloading(false); if (typeof (data) === "string") { showAlert(data, GetTextByKey("P_MRM_ERROR", 'Error')); return; } var record = data; recorddata = record; if (record.LogType === "Hours" || record.LogType === "Undercarriage" || record.LogType === "TimeOffRoad") { $('#tr_distance').hide(); $('#tr_hours').show(); } else { $('#tr_hours').hide(); $('#tr_distance').show(); } if (record.LogType === "Undercarriage" || record.LogType === "TimeOffRoad" || record.LogType === "TimeOverRoad") { $("#dialog_pmalerts").val("").attr("disabled", true); } else { $("#dialog_pmalerts").attr("disabled", false); } if (record.AlertID > 0) { $('#dialog_pmalerts').val(record.AlertID); } else { $('#dialog_pmalerts').val(''); } $('#dialog_mdate').val(record.StrForMaintenanceDate); $('#dialog_hours').val(record.MaintenanceHours); $('#dialog_notes').val(record.Notes); $('#dig_mtype').val(record.LogType); $('#dialog_distance').val(record.ODOMeter); $('#dig_uom').val(record.ODOMemterUOM); $('#dialog_cost').val(record.Cost); $('#dialog_invoicenumber').val(record.InvoiceNumber); $('#dig_completedby').val(record.CompletedByName); if ($.trim($('#dialog_mdate').val()) == "") { $('#dateformatspan').css('display', ''); } else { $('#dateformatspan').css('display', 'none'); } getMaintenanceLogAttachments(); }, function (err) { console.log(err); showloading(false); }); } function OnSave(exit, callback) { var mdate = $.trim($('#dialog_mdate').val()); var hoursvalue = $.trim($('#dialog_hours').val()); var mnote = $.trim($('#dialog_notes').val()); var logtype = $.trim($('#dig_mtype').val()); var odomer = $.trim($('#dialog_distance').val()); var odomeruom = $.trim($('#dig_uom').val()); var cost = $.trim($('#dialog_cost').val()); var invoicenumber = $.trim($('#dialog_invoicenumber').val()); var completedbyname = $.trim($('#dig_completedby').val()); var alerttitle = GetTextByKey("P_MRM_SYSTEMINFORMATION", "System Information"); if (mdate.length == 0 || ((logtype == "Hours" || logtype == "Undercarriage" || logtype == "TimeOffRoad") && hoursvalue.length == 0) || ((logtype == "Distance" || logtype == "TimeOverRoad") && odomer.length == 0) || mnote.length == 0) { showAlert(GetTextByKey("P_MRM_ITEMSMUSTREQUIRED", "The items with * are required."), alerttitle); return false; } if (!checkDate(mdate)) { $('#dialog_user').css('z-index', 0); showAlert(GetTextByKey("P_MRM_DATEFORMATERROR", "Date format error."), alerttitle); return false; } else { var dat1 = new Date(mdate); var curdate = new Date(currentdate); if (dat1 > curdate) { showAlert(GetTextByKey("P_MRM_MAINTENANCEDATENOTBEINTHEFUTURE", "Maintenance Date cannot be in the future."), alerttitle); return false; } } if (logtype === "Hours" || logtype === "Undercarriage" || logtype === "TimeOffRoad") { odomer = 0; odomeruom = ""; if (parseFloat(hoursvalue) <= 0 || hoursvalue == "" || isNaN(hoursvalue)) { $('#dialog_user').css('z-index', 0); showAlert(GetTextByKey("P_MRM_MAINTENANCEHOURSVALUEMUSTBEGREATERTHAN0", "Maintenance Hours value must be greater than 0."), alerttitle); return false; } } else { hoursvalue = 0; if (parseFloat(odomer) <= 0 || odomer == "" || isNaN(odomer)) { $('#dialog_user').css('z-index', 0); showAlert(GetTextByKey("P_MRM_MAINTENANCEDISTANCEVALUEMUSTBEGREATERTHAN0", "Maintenance Distance value must be greater than 0."), alerttitle); return false; } } if (cost !== "") { if (parseFloat(cost) < 0 || isNaN(cost)) { $('#dialog_cost').css('z-index', 0); showAlert(GetTextByKey("P_MRM_COSTVALUEMUSTBEGREATERTHAN0", "Cost Value must be greater than 0."), alerttitle); return false; } } if (cost === "") cost = 0; var alertid = ($('#dialog_pmalerts').val() == "" ? "-1" : $('#dialog_pmalerts').val()); if (logtype === "Undercarriage" || logtype === "TimeOffRoad" || logtype === "TimeOverRoad") alertid = "-1"; var item = { MaintenanceID: maintenanceid, AlertID: alertid, MachineID: machineid, MaintenanceDate: mdate, MaintenanceHours: hoursvalue, ODOMeter: odomer, ODOMemterUOM: odomeruom, Notes: mnote, Cost: cost, InvoiceNumber: invoicenumber, CompletedByName: completedbyname, LogType: logtype, AttachmentIDs: _attachments } var param = JSON.stringify(item); param = htmlencode(param); showloading(true); maintenancerequest("Addmaintenance", param, function (data) { showloading(false); var title = GetTextByKey("P_MRM_SAVEMAINTENANCERECORD", 'Save Maintenance Record'); if (typeof (data) === "string") { if (data === "Failed to save,The user is not logged.") data = GetTextByKey("P_MRM_FAILEDTOSAVETHEUSERISNOTLOGGED", "Failed to save,The user is not logged."); showAlert(data, title); } else { maintenanceid = data[0]; if (callback) { callback(item); } else { if (exit == 0) showAlert(GetTextByKey("P_MRM_SAVSUCCESSFULLY", data[1]), title); if (exit == 1) OnExit(exit); } } }, function (err) { console.log(err); showloading(false); showAlert(GetTextByKey("P_MRM_FAILEDTOSAVEMAINTENANCERECORD", 'Failed to save Maintenance Record.'), title); }); } function OnExit(type) { window.parent.CloseDialog(type); } function init(mid, mcid) { machineid = mid; maintenanceid = mcid; OnAdd(); if (maintenanceid !== undefined && maintenanceid !== '') { getUnCompletedPMAlerts(OnEdit); } else { getUnCompletedPMAlerts(); } } $(function () { init(); $('#dialog_mdate').click(function () { $('#dateformatspan').css('display', 'none'); }).blur(function () { if ($.trim($(this).val()) == "") { $('#dateformatspan').css('display', ''); } else { $('#dateformatspan').css('display', 'none'); } }) $('#dialog_mdate').datetimepicker({ timepicker: false, format: 'm/d/Y', enterLikeTab: false, onSelectDate: function (v, inp) { var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00'); inp.parent().data('val', [date]); } }) InputControl($('#dialog_hours')); $('#dialog_hours').change(function () { if (!inputValueFormat(this)) { $(this).val(''); } }) $(document).mouseup(function (e) { var targetE = e.target; if (!targetE.id || (targetE.id != "dialog_pmalerts" && targetE.id != "pmAlertDropDIV")) $("#pmAlertDropDIV").hide(); }); $("#dialog_pmalerts_span").click(function () { var mtype = $('#dig_mtype').val(); if (mtype === "Undercarriage" || mtype === "TimeOffRoad" || mtype === "TimeOverRoad") return; $("#pmAlertDropDIV").show(); $('#pmAlerts_tbody tr').each(function (item) { var tr = $(this); var alertid = tr.attr('alertid') tr.removeClass("selected"); var rid = $('#dialog_pmalerts').val();//maintenanceid if (rid == alertid + '') tr.addClass("selected"); }) }); $("#dialog_pmalerts_span").keydown(function (e) { if (event.which == 9) { $("#pmAlertDropDIV").hide(); } if (event.which == 8) return false; }); $('#dig_mtype').change(function () { var logType = $(this).val(); if (logType === "Hours" || logType === "Undercarriage" || logType === "TimeOffRoad") { $('#tr_distance').hide(); $('#tr_hours').show(); } else { $('#tr_hours').hide(); $('#tr_distance').show(); } if (logType === "Undercarriage" || logType === "TimeOffRoad" || logType === "TimeOverRoad") { $("#dialog_pmalerts").val("").attr("disabled", true); } else { $("#dialog_pmalerts").attr("disabled", false); } }); function resizeContent() { $('#divcontent').css('height', $(window).height() - $('#divcontent').offset().top - 4); $('.content_main').css('min-height', 0); } window.onresize = resizeContent; resizeContent(); }); </script> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div> <div> <div class="function_title"> <span class="sbutton iconsave" onclick="OnSave(0);" data-lgid="P_MRM_SAVE">Save</span> <span class="sbutton iconsave" onclick="OnSave(1);" data-lgid="P_MRM_SAVE1">Save and Exit</span> <span class="sbutton iconexit" onclick="OnExit(0);" data-lgid="P_MRM_SAVE2">Exit Without Saving</span> </div> <div class="clear"></div> <div id="divcontent" style="overflow: auto;"> <div class="edit-content"> <div class="subtitle"> <span data-lgid="P_MRM_MAINTENANCEINFORMATION">Maintenance Information</span> <hr /> </div> <table id="dialogdatatb" style="line-height: 30px;"> <tr> <td class="label" data-lgid="P_MRM_PMALERT_COLON">PM Alert:</td> <td> <span id="dialog_pmalerts_span"> <input type="text" id="dialog_pmalerts" tabindex="1" maxlength="15" readonly="readonly" /> <img style="margin-left: -18px; width: 7px; height: 7px;" src="../img/desc.jpg" /></span> <div id="pmAlertDropDIV" style="border: 1px solid #b0b0b0; width: 675px; height: 400px; overflow: auto; position: absolute; left: 212px; background-color: Window; display: none; z-index: 10; margin-top: -3px;"> <table id="pmAlertDropTable" class="main_table" style="border: none; width: 675px;"> <thead> <tr id="pmAlertDropTitle" style="border-width: 0px; background-color: #d3d1d1;"> <th data-lgid="P_MRM_ALERTID">Alert ID</th> <th data-lgid="P_MRM_ALERTTITLE"> Alert Title</th> <th style="width: 145px;" data-lgid="P_MRM_ALERTTIME"> Alert Time</th> </tr> </thead> <tbody id="pmAlerts_tbody"> </tbody> </table> </div> </td> </tr> <tr> <td class="label"><span data-lgid="P_MRM_MAINTENANCEDATE_COLON">Maintenance Date:</span><span style="color: red; margin-left: 3px;">*</span></td> <td> <input type="text" id="dialog_mdate" tabindex="2" /><span id="dateformatspan" style="color: #b0b0b0; position: absolute; left: 220px;" onclick="$(this).css('display','none');$('#dialog_mdate').focus();">Format:(MM/DD/YYYY)</span></td> </tr> <tr> <td class="label"><span data-lgid="P_MRM_MAINTENANCETYPE_COLON">Maintenance Type:</span><span style="color: red; margin-left: 3px;">*</span></td> <td> <select id="dig_mtype" disabled="disabled" style="width: 324px; height: 22px;" tabindex="3"> <option value="Hours" data-lgid="P_MRM_HOURS">Hours</option> <option value="Distance" data-lgid="P_MRM_DISTANCE">Distance</option> <option value="Undercarriage" data-lgid="P_MRM_UNDERCARRIAGE">Undercarriage</option> <option value="TimeOffRoad" data-lgid="P_MRM_TIMEOFFROAD">Time/Off-Road</option> <option value="TimeOverRoad" data-lgid="P_MRM_TIMEOVERROAD">Time/Over Road</option> </select></td> </tr> <tr id="tr_hours"> <td class="label"><span data-lgid="P_MRM_MAINTENANCEHOURS_COLON">Maintenance Hours:</span><span style="color: red; margin-left: 3px;">*</span></td> <td> <input type="text" id="dialog_hours" tabindex="4" maxlength="15" /></td> </tr> <tr id="tr_distance"> <td class="label" style="width: 151px;"><span data-lgid="P_MRM_MAINTENANCEDISTANCE_COLON">Maintenance Distance:</span> <span style="color: red; margin-left: 3px; width: 151px;">*</span></td> <td> <input type="text" id="dialog_distance" tabindex="4" maxlength="15" style="width: 227px;" /> <select id="dig_uom" style="width: 90px; height: 22px;" tabindex="5"> <option value="Mile" data-lgid="P_MRM_MILE">Mile</option> <option value="Kilometre" data-lgid="P_MRM_KILOMETER">Kilometer</option> </select> </td> </tr> <tr> <td class="label" data-lgid="P_MRM_COST_COLON">Cost:</td> <td> <input type="text" id="dialog_cost" tabindex="6" maxlength="15" /></td> </tr> <tr> <td class="label" data-lgid="P_MRM_INVOICENUMBER_COLON">Invoice Number:</td> <td> <input type="text" id="dialog_invoicenumber" tabindex="7" maxlength="50" /></td> </tr> <tr> <td class="label" data-lgid="P_MRM_COMPLETEDBY_COLON">Completed By:</td> <td> <input type="text" id="dig_completedby" tabindex="8" maxlength="200" /> </td> </tr> <tr> <td class="label"><span data-lgid="P_MRM_DESCRIPTION_COLON">Description:</span><span style="color: red; margin-left: 3px;">*</span></td> <td> <textarea id="dialog_notes" maxlength="1900" tabindex="9" style="width: 560px; height: 150px; margin-top: 4px;"></textarea></td> </tr> <tr> <td class="label" data-lgid="P_MRM_ATTACHMENTS_COLON">Attachments:</td> <td> <input id="uploadattfile" type="button" value="Add File..." data-lgid="P_MRM_ADDFILE" onclick="UpLoadMaintenanceLogAttachment()" tabindex="16" style="background-color: #0099FF; color: #FFFFFF; height: 20px; width: 200px;" /> <%-- <input id="Addfiles" type="button" value="Add File..." tabindex="10" style="background-color: #0099FF; color: #FFFFFF; height: 20px; width: 200px;" onclick="openFileDialog()" /> <input type="file" id="fileinput" style="display: none;" multiple="multiple" onchange="fillticketattchList()" />--%> </td> </tr> <tr> <td class="label"></td> <td> <table id="tabAttachments" style="border: 1px solid #a8a8a8; line-height: 25px; margin-top: -5px; width: 564px;"> <tr> <td> <div class="content_main"> <table id="tbAttas" style="table-layout: fixed;"></table> </div> </td> </tr> </table> </td> </tr> </table> </div> </div> </div> </asp:Content>