add site
This commit is contained in:
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;
|
||||
});
|
Reference in New Issue
Block a user