add site
This commit is contained in:
284
Site/Inspection/js/modules/fuellog.js
Normal file
284
Site/Inspection/js/modules/fuellog.js
Normal file
@ -0,0 +1,284 @@
|
||||
define([], function () {
|
||||
var gs = {};
|
||||
gs.title = GetTextByKey("P_IPT_FUELLOG", 'Fuel Log');
|
||||
gs.description = GetTextByKey("P_IPT_FUELLOG", 'Fuel Log');
|
||||
gs.version = '1.0';
|
||||
gs.status = 0;
|
||||
|
||||
var datacontent = null;
|
||||
var startdateinputcontrol = undefined;
|
||||
var enddateinputcontrol = undefined;
|
||||
gs.createContent = function () {
|
||||
var _this = this;
|
||||
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'
|
||||
});
|
||||
|
||||
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>');
|
||||
var iconRefresh = $('<span class="sbutton iconrefresh">' + GetTextByKey("P_IPT_REFRESH", "Refresh") + '</span>').click(function () {
|
||||
gs.refresh();
|
||||
});
|
||||
func.append(iconRefresh);
|
||||
var iconSettings = $('<span class="sbutton iconcog" style="float: right; line-height: 20px">' + GetTextByKey("P_MAIN_SETTINGS", "Settings") + '</span>').click(function () {
|
||||
gs.createSettings();
|
||||
});
|
||||
func.append(iconSettings);
|
||||
header.append(func)
|
||||
|
||||
return header;
|
||||
}
|
||||
|
||||
content.append(createHeader());
|
||||
|
||||
var dataheader = $('<div class="question-holder no-hover" style="font-weight: bold;font-size:14px;"></div>');
|
||||
dataheader.append('<div style="width:60px; flex-shrink: 0"></div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 150px">' + GetTextByKey("P_IPT_DATE", "Date") + '</div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 200px">' + GetTextByKey("P_IPT_ASSETNAME", "Asset Name") + '</div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 200px">' + GetTextByKey("P_IPT_VIN", "VIN") + '</div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 200px;">' + GetTextByKey("P_IPT_EMPLOYEENAME", "Employee Name") + '</div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 150px;">' + GetTextByKey("P_IPT_CHECKEDIN", "Checked In") + '</div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 150px;">' + GetTextByKey("P_IPT_CHECKEDOUT", "Checked Out") + '</div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 90px;padding-right:20px;"></div>');
|
||||
content.append(dataheader);
|
||||
|
||||
datacontent = $('<div></div>');
|
||||
content.append(datacontent);
|
||||
|
||||
_this.refresh();
|
||||
return content;
|
||||
}
|
||||
|
||||
gs.refresh = function () {
|
||||
var _this = this;
|
||||
datacontent.empty();
|
||||
var startydate = startdateinputcontrol.val();
|
||||
var enddate = enddateinputcontrol.val();
|
||||
var p = JSON.stringify([teamintelligence, startydate, enddate]);
|
||||
inspectionrequest("GetFuelReportItems", htmlencode(p), function (data) {
|
||||
datacontent.empty();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_IPT_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
if (data) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
_this.createFuelLog(data[i]);
|
||||
}
|
||||
//showFuelLogs(data);
|
||||
}
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
gs.createFuelLog = function (fuellog) {
|
||||
var _this = this;
|
||||
var content = $('<div></div>');
|
||||
var holder = $('<div class="section-holder"></div>');
|
||||
content.append(holder);
|
||||
|
||||
var btnfuleitem = $('<div class="section-icon" style="width: 30px;"><em class="spanbtn iconangleright" style="font-size:18px;"></em></div>');
|
||||
btnfuleitem.click(function () {
|
||||
var icon = btnfuleitem.find('.spanbtn');
|
||||
if (icon.hasClass('iconangleright')) {
|
||||
icon.removeClass('iconangleright').addClass('iconangledown');
|
||||
if (fuellog.FuelReportItems)
|
||||
_this.createFuelItem(content, fuellog.FuelReportItems);
|
||||
}
|
||||
else {
|
||||
icon.removeClass('iconangledown').addClass('iconangleright');
|
||||
btnfuleitem.parents().parents().children('.questionitem').remove();
|
||||
}
|
||||
});
|
||||
holder.append(btnfuleitem);
|
||||
|
||||
var spantime = $('<lable></lable>').text(GetTextByKey("P_IPT_DATE", "Date:") + fuellog.LocalCalendarDateStr);
|
||||
var spancount = $('<lable></lable>').text("(" + fuellog.FuelReportCount + ")");
|
||||
holder.append($('<div class="section-cell section-name" style="width:200px;flex-grow:0;font-size:12px;"></div>').append(spantime).append(spancount));
|
||||
datacontent.append(content);
|
||||
}
|
||||
|
||||
gs.createFuelItem = function (content, fuelitem) {
|
||||
var _this = this;
|
||||
for (var i = 0; i < fuelitem.length; i++) {
|
||||
var fuel = fuelitem[i];
|
||||
var holder = $('<div class="questionitem"></div>');
|
||||
var qholder = $('<div class="question-holder"></div>');//question holder
|
||||
holder.append(qholder);
|
||||
|
||||
if (_this.index % 2 == 1)
|
||||
qholder.addClass('holder-even');
|
||||
|
||||
qholder.append('<div class="question-icon" style="width:30px;"><em class="fa"></em></div>');
|
||||
|
||||
var span = $('<span></span>').text(fuel.LocalCalendarDateStr);
|
||||
qholder.append($('<div class="question-cell question-name" style="width: 150px;padding-left:10px;"></div>').append(span));
|
||||
|
||||
span = $('<span></span>').text(fuel.AssetName);
|
||||
qholder.append($('<div class="question-cell" style="width: 200px;padding-left:10px;"></div>').append(span));
|
||||
|
||||
span = $('<span></span>').text(fuel.VIN);
|
||||
qholder.append($('<div class="question-cell" style="width: 200px;padding-left:10px;"></div>').append(span));
|
||||
|
||||
span = $('<span></span>').text(fuel.EmployeeName);
|
||||
qholder.append($('<div class="question-cell" style="width: 200px;padding-left:10px;"></div>').append(span));
|
||||
|
||||
span = $('<span></span>').text(fuel.CheckInTimeLocalStr);
|
||||
qholder.append($('<div class="question-cell" style="width: 150px;padding-left:10px;"></div>').append(span));
|
||||
|
||||
span = $('<span></span>').text(fuel.CheckOutTimeLocalStr);
|
||||
qholder.append($('<div class="question-cell" style="width: 150px;padding-left:10px;"></div>').append(span));
|
||||
|
||||
holder.dblclick(fuel, function (e) {
|
||||
window.open("fuelreport.aspx?rid=" + e.data.Id + "&team=" + (teamintelligence ? 1 : 0), "_blank");
|
||||
});
|
||||
|
||||
holder.find('.question-name span').click(fuel, function (e) {
|
||||
window.open("fuelreport.aspx?rid=" + e.data.Id + "&team=" + (teamintelligence ? 1 : 0), "_blank");
|
||||
});
|
||||
|
||||
content.append(holder);
|
||||
}
|
||||
}
|
||||
gs.createSettings = function () {
|
||||
var loading = $('<div class="loading_holder" style="top: 0; background-color: rgba(0,0,0,0.2); display: none"></div>');
|
||||
loading.append('<div class="loading_icon icn icn-spin"></div>');
|
||||
|
||||
function onSave(exit) {
|
||||
var alerttitle = GetTextByKey("P_IPT_FUELRPT_SETTING", 'Fuel Report Page Settings');
|
||||
loading.fadeIn(100);
|
||||
var headerLeft = $('#fuelrpt_headers_left').val();
|
||||
var headerMiddle = $('#fuelrpt_headers_middle').val();
|
||||
var headerRight = $('#fuelrpt_headers_right').val();
|
||||
var footerLeft = $('#fuelrpt_footers_left').val();
|
||||
var footerMiddle = $('#fuelrpt_footers_middle').val();
|
||||
var footerRight = $('#fuelrpt_footers_right').val();
|
||||
var item = {
|
||||
'$type': 'Foresight.Fleet.Services.Inspection.FuelReportHeaderFooterItem, FleetServiceClient',
|
||||
HeaderLeft: headerLeft,
|
||||
HeaderMiddle: headerMiddle,
|
||||
HeaderRight: headerRight,
|
||||
FooterLeft: footerLeft,
|
||||
FooterMiddle: footerMiddle,
|
||||
FooterRight: footerRight
|
||||
};
|
||||
var p = [false, htmlencode(JSON.stringify(item))];
|
||||
inspectionrequest('UpdateFuelReportHeaderFooter', JSON.stringify(p), function (r) {
|
||||
if (r == 'OK') {
|
||||
showAlert(GetTextByKey("P_MV_SAVSUCCESSFULLY", 'Saved successfully.'), alerttitle, null, function () {
|
||||
loading.fadeOut(100);
|
||||
if (exit) {
|
||||
showRightPopup(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
showAlert(GetTextByKey("P_IPT_FUELRPT_SAVEERROR", 'Failed to save fuel report page settings.'), alerttitle, null, function () {
|
||||
loading.fadeOut(100);
|
||||
});
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
var content = $('<div></div>');
|
||||
var funcs = $('<div class="function_title"></div>');
|
||||
var btn = $('<span class="sbutton iconsave">' + GetTextByKey("P_IPT_SAVE", "Save") + '</span>').click(function () {
|
||||
onSave();
|
||||
});
|
||||
funcs.append(btn);
|
||||
btn = $('<span class="sbutton iconsave">' + GetTextByKey("P_IPT_SAVE1", "Save and Exit") + '</span>').click(function () {
|
||||
onSave(true);
|
||||
});
|
||||
funcs.append(btn);
|
||||
btn = $('<span class="sbutton iconexit">' + GetTextByKey("P_IPT_SAVE2", "Exit Without Saving") + '</span>').click(function () {
|
||||
showRightPopup(false);
|
||||
});
|
||||
funcs.append(btn);
|
||||
content.append(funcs);
|
||||
|
||||
content.append($('<div class="page_title"></div>').text(GetTextByKey('P_IPT_FUELRPT_HEADER', 'Page Headers')));
|
||||
var line = $('<div class="settings-line"></div>');
|
||||
var label = $('<span></span>').text(GetTextByKey('P_IPT_FUELRPT_LEFT', 'Left'));
|
||||
line.append(label);
|
||||
var field = $('<textarea id="fuelrpt_headers_left"></textarea>');
|
||||
line.append(field);
|
||||
content.append(line);
|
||||
|
||||
line = $('<div class="settings-line"></div>');
|
||||
label = $('<span></span>').text(GetTextByKey('P_IPT_FUELRPT_MIDDLE', 'Middle'));
|
||||
line.append(label);
|
||||
field = $('<textarea id="fuelrpt_headers_middle"></textarea>');
|
||||
line.append(field);
|
||||
content.append(line);
|
||||
|
||||
line = $('<div class="settings-line"></div>');
|
||||
label = $('<span></span>').text(GetTextByKey('P_IPT_FUELRPT_RIGHT', 'Right'));
|
||||
line.append(label);
|
||||
field = $('<textarea id="fuelrpt_headers_right"></textarea>');
|
||||
line.append(field);
|
||||
content.append(line);
|
||||
content.append($('<div class="page_title"></div>').text(GetTextByKey('P_IPT_FUELRPT_FOOTER', 'Page Footers')));
|
||||
|
||||
line = $('<div class="settings-line"></div>');
|
||||
label = $('<span></span>').text(GetTextByKey('P_IPT_FUELRPT_LEFT', 'Left'));
|
||||
line.append(label);
|
||||
field = $('<textarea id="fuelrpt_footers_left"></textarea>');
|
||||
line.append(field);
|
||||
content.append(line);
|
||||
|
||||
line = $('<div class="settings-line"></div>');
|
||||
label = $('<span></span>').text(GetTextByKey('P_IPT_FUELRPT_MIDDLE', 'Middle'));
|
||||
line.append(label);
|
||||
field = $('<textarea id="fuelrpt_footers_middle"></textarea>');
|
||||
line.append(field);
|
||||
content.append(line);
|
||||
|
||||
line = $('<div class="settings-line"></div>');
|
||||
label = $('<span></span>').text(GetTextByKey('P_IPT_FUELRPT_RIGHT', 'Right'));
|
||||
line.append(label);
|
||||
field = $('<textarea id="fuelrpt_footers_right"></textarea>');
|
||||
line.append(field);
|
||||
content.append(line);
|
||||
|
||||
content.append(loading);
|
||||
$('#right_popup').empty().append(content);
|
||||
showRightPopup(true);
|
||||
|
||||
loading.fadeIn(100);
|
||||
inspectionrequest('GetFuelReportHeaderFooter', 'false', function (r) {
|
||||
//console.log(r);
|
||||
gs.fuelRptSettings = r;
|
||||
content.find('#fuelrpt_headers_left').val(r.HeaderLeft);
|
||||
content.find('#fuelrpt_headers_middle').val(r.HeaderMiddle);
|
||||
content.find('#fuelrpt_headers_right').val(r.HeaderRight);
|
||||
content.find('#fuelrpt_footers_left').val(r.FooterLeft);
|
||||
content.find('#fuelrpt_footers_middle').val(r.FooterMiddle);
|
||||
content.find('#fuelrpt_footers_right').val(r.FooterRight);
|
||||
loading.fadeOut(100);
|
||||
});
|
||||
};
|
||||
return gs;
|
||||
});
|
Reference in New Issue
Block a user