fleet-contractor/Site/js/jobsitesummary.js
2023-04-28 12:22:26 +08:00

204 lines
7.7 KiB
JavaScript

if (typeof ($jobsitesummary) != "function") {
var ctrlindex = 0;
var assetIconCollapsed = false;
var alertsCollapsed = false;
$jobsitesummary = function (p, js, type, jobsites) {//type 0.left;1.bottom
if (typeof p === "string")
p = $("#" + p);
if (!p)
p = document;
this.type = type;
this.jobsite = js;
this.jobsites = jobsites;
this.status = 0;
this.ctrlindex = ctrlindex++;
this.jobsitechanged = null;
var _this = this;
this.basectrl = $('<div></div>');
//if (this.jobsites && this.jobsites.length > 1) {
// this.basectrl.css('margin-top', 10);
// var div_jobsite = $('<div style="width: 360px;margin-left:40px;"></div>');
// div_jobsite.dropdown(this.jobsites, {
// search: true,
// valueKey: 'ID',
// textKey: 'Name'
// });
// div_jobsite.find(".dropdown-wrapper").css("border", "1px solid #b9b9b9");
// if (this.jobsite)
// div_jobsite.dropdownVal(this.jobsite.ID);
// div_jobsite.on('select', function (_e, item) {
// if (item.ID != _this.jobsite.ID) {
// var temps = _this.jobsites.filter(function (a) { return a.ID == item.ID })
// if (_this.jobsitechanged && temps && temps.length > 0)
// _this.jobsitechanged(_this.jobsites.indexOf(temps[0]));
// }
// });
// p.append(div_jobsite);
//}
p.append(this.basectrl);
//this.maskbgctrl = $('<div class="maskbg"><div class="loading_icon icon c-spin"></div></div>');
//p.append(this.maskbgctrl);
this.contractid = $("#selContractor").val();
if (!this.contractid) this.contractid = "";
this.refresh = function (js) {
_this.basectrl.empty();
_this.jobsite = js;
showJobsiteInfo();
}
if (this.jobsite) {
showJobsiteInfo();
}
function setIconBr(div_icon) {
var br = '<br />';
//if (_this.type == 0)
div_icon.append(br);
}
function showJobsiteIcon() {
var js = _this.jobsite;
var div_icon = $('<div></div>');
var iconheight = p.height();
if (iconheight == 0)
iconheight = p.parent().height();
if (_this.type == 0) {
div_icon.css({ 'height': iconheight - 4, 'margin-top': -20 });
}
else {
div_icon.css({ 'height': iconheight + 5 });
//if (_this.jobsites && _this.jobsites.length > 1) {
// div_icon.css({ 'height': p.parent().height() + 5, 'margin-top': -42 });
//}
div_icon.removeClass("divicon_left");
div_icon.addClass("divicon_bottom");
}
div_icon.removeClass("divicon_bottom");
div_icon.addClass("divicon_left");
var span;
if (canEditJobsite) {
span = $('<span class="iconjobsite" style="cursor: pointer;" title="' + GetTextByKey("P_JS_EDITJOBSITE", "Edit Jobsite") + '"></span>');
span.click(js, function (e) {
OnEditJobsite(js);
});
div_icon.append(span);
setIconBr(div_icon);
}
span = $("<span class='iconmail' style='cursor:pointer;' onclick='openSendEmails(\"" + js.CompanyID + "\"," + js.ID + ",1)' title='" + GetTextByKey("P_MV_SENDJOBSITE", "Send Jobsite") + "'></span>");
div_icon.append(span);
setIconBr(div_icon);
if (type == 0) {
div_icon.find("span").click(function (e) {
p.hide();
$('#assetsummarytrigle').hide();
});
}
return div_icon;
}
function showJobsiteInfo() {
if (!_this.jobsite) return;
var js = _this.jobsite;
var br = '<br />';
if (_this.type == 0) {
var div_close = $('<div style="height:20px;"></div>');
_this.basectrl.append(div_close);
var span_close = $('<span class="clearbtn" style="float: right; padding: 5px;cursor:pointer;"></span>').click(function () {
p.hide();
$('#assetsummarytrigle').hide();
});
div_close.append(span_close);
}
if (showTooltipIcons) {
var div_icon = showJobsiteIcon();
_this.basectrl.append(div_icon);
}
var div_summary = $('<div class="assetsummaryinfo_div"></div>').css("text-align", "left");
if (!showTooltipIcons)
div_summary.css("margin-left", 10);
_this.basectrl.append(div_summary);
var b = $('<b>' + GetTextByKey("P_MV_NAME_COLON", "Name:") + ' </b>');
div_summary.append(b);
var label = $('<label></label>').text(js.Name);
div_summary.append(label).append(br);
b = $('<b>' + GetTextByKey("P_JS_CODE_COLON", "Code:") + ' </b>');
div_summary.append(b);
var label = $('<label></label>').text(js.Code);
div_summary.append(label).append(br);
b = $('<b>' + GetTextByKey("P_JS_NUMBER_COLON", "Number:") + ' </b>');
div_summary.append(b);
var label = $('<label></label>').text(js.Number);
div_summary.append(label).append(br);
b = $('<b>' + GetTextByKey("P_MV_LATLONG_COLON", "Lat/Long:") + ' </b>');
div_summary.append(b);
var label = $('<label></label>').text(js.Latitude + ", " + js.Longitude);
div_summary.append(label).append(br);
b = $('<b>' + GetTextByKey("P_MV_DELIVERYADDRESS_COLON", "Delivery Address:") + ' </b>');
div_summary.append(b);
label = $('<label></label>').text(js.Address1);
div_summary.append(label).append(br);
div_summary.append(br);
b = $('<b>' + GetTextByKey("P_JS_FOREMAN_COLON", "Foreman:") + ' </b>');
div_summary.append(b);
var ftxt = js.Foreman;
if (ftxt === "") {
if (js.Phone !== "")
ftxt = js.Phone;
}
else {
if (js.Phone !== "")
ftxt = ftxt + "," + js.Phone;
}
var label = $('<label></label>').text(ftxt);
div_summary.append(label).append(br);
div_summary.append(br);
b = $('<b>' + GetTextByKey("P_JS_STATDATE_COLON", "Start Date:") + ' </b>');
div_summary.append(b);
var label = $('<label></label>').text(js.StartDateStr);
div_summary.append(label).append(br);
b = $('<b>' + GetTextByKey("P_JS_PROJECTEDENDDATE_COLON", "Projected End Date:") + ' </b>');
div_summary.append(b);
var label = $('<label></label>').text(js.ProjectedEndDateStr);
div_summary.append(label).append(br);
b = $('<b>' + GetTextByKey("P_JS_ENDDATE_COLON", "End Date:") + ' </b>');
div_summary.append(b);
var label = $('<label></label>').text(js.EndDateStr);
div_summary.append(label).append(br);
div_summary.append(br);
b = $('<b>' + GetTextByKey("P_MV_NOTES_COLON", "Notes:") + ' </b>');
div_summary.append(b);
var notes = (js.Notes && js.Notes !== "") ? replaceHtmlText(js.Notes) : "";
var label = $('<label></label>').html(notes);
div_summary.append(label).append(br);
}
}
}