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 = $('
'); function createHeader() { var header = $(''); header.append($('').text(gs.title)); setPageTitle(gs.title, true); var search_bar = $(''); header.append(search_bar); search_bar.append(''); search_bar.append('' + GetTextByKey("P_IPT_BEGINDATE_COLON", "Begin Date:") + ''); startdateinputcontrol = $('').val(begindate); search_bar.append($('').append(startdateinputcontrol)); search_bar.append('' + GetTextByKey("P_IPT_ENDDATE_COLON", "End Date:") + ''); enddateinputcontrol = $('').val(enddate); search_bar.append($('').append(enddateinputcontrol)); makeinputcontrol = $('').val(enddate); searchinputcontrol = $(''); search_bar.append(searchinputcontrol); searchinputcontrol.keydown(function (e) { if (e.keyCode == 13 || e.keyCode == 9) gs.refresh(); }); var btnRefresh = $(''); search_bar.append(btnRefresh); btnRefresh.click(function () { gs.refresh(); }); var func = $(''); if (!ReportReadonly) { var iconEdit = $(' ').click(function () { if (grid_dt.selectedIndex >= 0) { gs.onedit(); } }); func.append(iconEdit); } var iconRefresh = $(' ').click(function () { gs.refresh(); }); func.append(iconRefresh); var iconResetPivots = $(' ').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.reload(); } }); func.append(iconResetPivots); var iconprints = $(' ').click(function () { var tempsource = grid_dt.source; for (var i = 0; i < tempsource.length; i++) { var inspect = tempsource[i]; if (inspect.Selected) { if (navigator.userAgent.indexOf('Firefox') >= 0 || navigator.userAgent.indexOf('Opera') >= 0) { window.open("Inspection.aspx?rt=f&t=2&id=" + inspect.Id + "&team=" + (teamintelligence ? 1 : 0), '_blank'); } else openPrintFrame(inspect.Id); } } }); func.append(iconprints); var icondownloads = $(' ').click(function () { var tempsource = grid_dt.source; for (var i = 0; i < tempsource.length; i++) { var inspect = tempsource[i]; if (inspect.Selected) { openDownloadFrame(inspect.Id); } } }); func.append(icondownloads); header.append(func) return header; } function InitGridData() { var div_grid = $(''); div_grid.css({ "height": $(window).height() - 185, "position": "relative" }); grid_dt = createGridView(div_grid); 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: 'WorkOrderId', allowFilter: true, css: { 'width': 200, 'text-align': 'left' } }, { name: 'CustomerName', caption: GetTextByKey("P_IPT_CUSTOMERNAME", "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 = [ { // checkbox name: 'check', key: 'Selected', width: 45, align: 'center', sortable: false, allcheck: true, type: 3 } ]; // 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.events = { onclick: function () { _this.openReport(); } }; col.styleFilter = function () { return { 'color': 'black', 'cursor': 'pointer', //'text-decoration': 'none' }; } } else if (col.name === "Edit") { col.sortable = false; col.resizable = false; col.type = GridView.ColumnTypes.Icon; col.text = 'edit'; col.events = { onclick: function () { _this.onedit(); } }; col.attrs = { 'title': GetTextByKey("P_IPT_EDIT", 'Edit') }; } else if (col.name === "Detail") { col.sortable = false; col.resizable = false; col.type = GridView.ColumnTypes.Icon; col.text = "info-circle"; col.events = { onclick: function () { _this.openReport(); } }; col.attrs = { 'title': GetTextByKey("P_IPT_DETAIL", 'Detail') }; } else if (col.name === "DownloadPDF") { col.sortable = false; col.resizable = false; col.type = GridView.ColumnTypes.Icon; col.text = "download"; 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.sortable = false; col.resizable = false; col.type = GridView.ColumnTypes.Icon; col.text = "print"; 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.sortable = false; col.resizable = false; col.type = GridView.ColumnTypes.Icon; col.text = "history"; 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.type = GridView.ColumnTypes.Dropdown; col.filter = function (item, editing) { return editing ? String(item.WorkOrderId) : item.WorkOrderNumber; }; col.dropOptions = { search: true, textKey: 'WorkOrderNumber', valueKey: 'Id' }; col.sourceCache = false; col.source = function (item) { return item.WorkOrders ??= [{ Id: -1, WorkOrderNumber: "Not Assigned" }]; }; col.onDropExpanded = function (item, drop) { if (!item.WorkOrdersLoaded) { item.WorkOrdersLoaded = true; inspectionrequest('GetAssetWorkOrders', item.AssetId, function (data) { if (typeof data === 'string') { } else if (data && data.length > 0) { var source = [ { Id: -1, WorkOrderNumber: "Not Assigned" } ]; var sel = null; var exists = false; var selected; if (item.WorkOrders && item.WorkOrders.length == 1) sel = item.WorkOrders[0]; else exists = true; for (var i = 0; i < data.length; i++) { var u = data[i]; source.push(u); if (item.WorkOrderId == u.Id) item.WorkOrderId = selected = u.Id; if (sel && (sel.Id < 0 || sel.Id == u.Id)) exists = true; } if (!exists) { source.push(sel); } item.WorkOrders = source; drop.source = source; drop.select(selected, true); } }, function () { }); } }; col.onChanged = function (item, value, old, wo) { if (value != old) { 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. ') + "