');
dataheader.append('');
content.append(dataheader);
datacontent = $('');
content.append(datacontent);
_this.refresh();
return content;
}
gs.refresh = function () {
var begindate = startdateinputcontrol.val();
var enddate = enddateinputcontrol.val();
if (begindate && !startdateinputcontrol.is(':valid')) {
showAlert(GetTextByKey('P_COMMON_BEGINDATEISINVALID', "The begin date is invalid."), GetTextByKey("P_FR_ERROR", 'Error'));
return;
}
if (enddate && !enddateinputcontrol.is(':valid')) {
showAlert(GetTextByKey('P_COMMON_ENDDATEISINVALID', "The end date is invalid."), GetTextByKey("P_FR_ERROR", 'Error'));
return;
}
if (begindate && enddate && begindate > enddate) {
showAlert(GetTextByKey("P_JS_ENDDATEMUSTBELATERTHANBEGINDATE", "End Date must be later than Begin Date."), GetTextByKey("P_FR_ERROR", 'Error'));
return;
}
var _this = this;
datacontent.empty();
var p = JSON.stringify([teamintelligence, begindate, enddate]);
showloading(true);
inspectionrequest("GetFuelReportItems", htmlencode(p), function (data) {
showloading(false);
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) {
showloading(false);
});
}
gs.createFuelLog = function (fuellog) {
var _this = this;
var content = $('');
var holder = $('');
content.append(holder);
var btnfuleitem = $('
');
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 = $('').text(GetTextByKey("P_IPT_DATE", "Date:") + fuellog.LocalCalendarDateStr);
var spancount = $('').text("(" + fuellog.FuelReportCount + ")");
holder.append($('').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 = $('');
var qholder = $('');//question holder
holder.append(qholder);
if (_this.index % 2 == 1)
qholder.addClass('holder-even');
qholder.append('
');
var span = $('').text(fuel.LocalCalendarDateStr);
qholder.append($('').append(span));
span = $('').text(fuel.AssetName);
qholder.append($('').append(span));
span = $('').text(fuel.VIN);
qholder.append($('').append(span));
span = $('').text(fuel.EmployeeName);
qholder.append($('').append(span));
span = $('').text(fuel.CheckInTimeLocalStr);
qholder.append($('').append(span));
span = $('').text(fuel.CheckOutTimeLocalStr);
qholder.append($('').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 = $('');
loading.append('');
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) {
loading.hide();
if (r == 'OK') {
showAlert(GetTextByKey("P_MV_SAVSUCCESSFULLY", 'Saved successfully.'), alerttitle, null, function () {
if (exit) {
showRightPopup(false);
}
});
} else {
showAlert(GetTextByKey("P_IPT_FUELRPT_SAVEERROR", 'Failed to save fuel report page settings.'), alerttitle, null, function () {
});
}
}, 1000);
}
var content = $('');
var funcs = $('');
var btn = $('' + GetTextByKey("P_IPT_SAVE", "Save") + '').click(function () {
onSave();
});
funcs.append(btn);
btn = $('' + GetTextByKey("P_IPT_SAVE1", "Save and Exit") + '').click(function () {
onSave(true);
});
funcs.append(btn);
btn = $('' + GetTextByKey("P_IPT_SAVE2", "Exit Without Saving") + '').click(function () {
showRightPopup(false);
});
funcs.append(btn);
content.append(funcs);
content.append($('').text(GetTextByKey('P_IPT_FUELRPT_HEADER', 'Page Headers')));
var line = $('');
var label = $('').text(GetTextByKey('P_IPT_FUELRPT_LEFT', 'Left'));
line.append(label);
var field = $('');
line.append(field);
content.append(line);
line = $('');
label = $('').text(GetTextByKey('P_IPT_FUELRPT_MIDDLE', 'Middle'));
line.append(label);
field = $('');
line.append(field);
content.append(line);
line = $('');
label = $('').text(GetTextByKey('P_IPT_FUELRPT_RIGHT', 'Right'));
line.append(label);
field = $('');
line.append(field);
content.append(line);
content.append($('').text(GetTextByKey('P_IPT_FUELRPT_FOOTER', 'Page Footers')));
line = $('');
label = $('').text(GetTextByKey('P_IPT_FUELRPT_LEFT', 'Left'));
line.append(label);
field = $('');
line.append(field);
content.append(line);
line = $('');
label = $('').text(GetTextByKey('P_IPT_FUELRPT_MIDDLE', 'Middle'));
line.append(label);
field = $('');
line.append(field);
content.append(line);
line = $('');
label = $('').text(GetTextByKey('P_IPT_FUELRPT_RIGHT', 'Right'));
line.append(label);
field = $('');
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;
});