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)); startdateinputcontrol.datetimepicker({ timepicker: false, format: 'm/d/Y' }); search_bar.append('' + GetTextByKey("P_IPT_ENDDATE_COLON", "End Date:") + ''); enddateinputcontrol = $('').val(enddate); search_bar.append($('').append(enddateinputcontrol)); enddateinputcontrol.datetimepicker({ timepicker: false, format: 'm/d/Y' }); makeinputcontrol = $('').val(enddate); search_bar.append($('').append(enddateinputcontrol)); enddateinputcontrol.datetimepicker({ timepicker: false, format: 'm/d/Y' }); 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.refreshGrid(); } }); func.append(iconResetPivots); var iconprints = $(' ').click(function () { for (var i = 0; i < grid_dt.source.length; i++) { var inspect = grid_dt.source[i].Values; 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 () { for (var i = 0; i < grid_dt.source.length; i++) { var inspect = grid_dt.source[i].Values; 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); 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 = [ { // 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.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.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. ') + "