.
This commit is contained in:
@ -28,7 +28,7 @@ $(function () {
|
||||
grid_dtassets.setData(grid_dtassets.innerSource.concat(items));
|
||||
if (ids.length > 0)
|
||||
assignAssets(ids);
|
||||
$('#mask_bg').hide();
|
||||
showmaskbg(false);
|
||||
};
|
||||
});
|
||||
|
||||
@ -63,7 +63,7 @@ function InitGridSelectedMachines() {
|
||||
// checkbox
|
||||
name: 'check',
|
||||
key: 'selected',
|
||||
width: 30,
|
||||
width: 45,
|
||||
align: 'center',
|
||||
sortable: false,
|
||||
allcheck: true,
|
||||
@ -152,7 +152,6 @@ function OnAssetAdd() {
|
||||
return s.Values.ID;
|
||||
});
|
||||
dialogAUAssets.showSelector();
|
||||
$('#mask_bg').css('height', '100%');
|
||||
}
|
||||
|
||||
function OnMachineDelete() {
|
||||
@ -264,7 +263,7 @@ function onOpenSalesperson() {
|
||||
$('#sp_searchinputtxt').val('');
|
||||
GetSalespersons();
|
||||
$('#dialog_salesperson .dialog-title span.title').text(alerttitle);
|
||||
$('#mask_bg').show();
|
||||
showmaskbg(true);
|
||||
$('#dialog_salesperson')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_salesperson').height()) / 3,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -51,7 +51,6 @@ function OnMachineAdd() {
|
||||
return s.Values.ID;
|
||||
});
|
||||
dialogAssets.showSelector();
|
||||
$('#mask_bg').css('height', '100%');
|
||||
}
|
||||
|
||||
var _selectedMachines = [];
|
||||
@ -196,7 +195,7 @@ function InitGridSelectedMachines() {
|
||||
// checkbox
|
||||
name: 'check',
|
||||
key: 'selected',
|
||||
width: 30,
|
||||
width: 45,
|
||||
align: 'center',
|
||||
sortable: false,
|
||||
allcheck: true,
|
||||
|
@ -16,20 +16,20 @@ function onSaveAttachment(files) {
|
||||
fileupload_errors = "";
|
||||
if (!fuelid) {
|
||||
OnSave(0, this, function () {
|
||||
$('#att_mask_bg').show();
|
||||
showloading(true);
|
||||
if (filesinuploading.length > 0) {
|
||||
for (var i = 0; i < files.length; i++)
|
||||
filesinuploading.push(fuelid, files[i]);
|
||||
}
|
||||
else {
|
||||
filesinuploading = files;
|
||||
filesinuploading = files;
|
||||
DoUploadAttachments(fuelid);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$('#att_mask_bg').show();
|
||||
showloading(true);
|
||||
if (filesinuploading.length > 0) {
|
||||
for (var i = 0; i < files.length; i++)
|
||||
filesinuploading.push(files[i]);
|
||||
@ -55,7 +55,7 @@ function DoUploadAttachments(fid) {
|
||||
getAttachments();
|
||||
if (fileupload_errors !== "")
|
||||
showAlert(fileupload_errors, GetTextByKey("P_WO_XXXXX", 'Upload failed'));
|
||||
$('#att_mask_bg').hide();
|
||||
showloading(false);
|
||||
return;
|
||||
}
|
||||
var file = filesinuploading[uploadingindex];
|
||||
|
@ -193,7 +193,7 @@ function InitGridData() {
|
||||
|| item.TextMessageStatus == 412)//Landline
|
||||
return '#FFC107';
|
||||
if (!item.CommunicationAcknowledged)
|
||||
return '#1E88E5';
|
||||
return '#79B6FF';
|
||||
if (!item.EstimateAcknowledged) {
|
||||
if (item.ApprovedEstimates > 0)
|
||||
return '#07FF93';
|
||||
@ -202,13 +202,28 @@ function InitGridData() {
|
||||
}
|
||||
}
|
||||
};
|
||||
var styleFilter = function (item) {
|
||||
if (item.Id.Value > 0 && IsAdvisor) {
|
||||
if (item.TextMessageStatus == 0//Undelivered
|
||||
|| item.TextMessageStatus == 9//Failed
|
||||
|| item.TextMessageStatus == 10//Opt-Out
|
||||
|| item.TextMessageStatus == 412//Landline
|
||||
|| !item.CommunicationAcknowledged
|
||||
|| (!item.EstimateAcknowledged && (item.ApprovedEstimates > 0 || item.RejectedEstimates > 0))
|
||||
)
|
||||
return { "font-weight": "bold" };
|
||||
}
|
||||
return {};
|
||||
}
|
||||
if (col.name !== 'Edit' && col.name !== "Print" && col.name !== "Delete" && col.name !== "AssetAlert")
|
||||
col.styleFilter = styleFilter;
|
||||
if (!IsCustomerRecordAllow && (col.name === "Customer")) {
|
||||
continue;
|
||||
}
|
||||
if (!AllowWorkOrderSurveys && (col.name === "Surveys")) {
|
||||
continue;
|
||||
}
|
||||
if (!HasCustomerRecord && (col.name === "Advisor" || col.name === "CustomerCode" || col.name === "Contacts"
|
||||
if (!AllowCustomer && (col.name === "Advisor" || col.name === "CustomerCode" || col.name === "Contacts"
|
||||
|| col.name === "LastCommunication" || col.name === "LastCommunicationDate" || col.name === "LastCommunicationBy"
|
||||
|| col.name === "AlternateStatus" || col.name === "EstimateStatus" || col.name === "Surveys"
|
||||
|| col.name === "PublishedEstimates" || col.name === "ApprovedEstimates" || col.name === "RejectedEstimates" || col.name === "PendingEstimates"
|
||||
@ -292,8 +307,8 @@ function InitGridData() {
|
||||
|
||||
return selector;
|
||||
}
|
||||
col.styleFilter = function () {
|
||||
return { "width": "100%", 'padding': 0 };
|
||||
col.styleFilter = function (item) {
|
||||
return Object.assign({}, styleFilter(item), { "width": "100%", 'padding': 0 });
|
||||
}
|
||||
}
|
||||
else if (col.name === "WorkOrderType") {
|
||||
@ -333,8 +348,8 @@ function InitGridData() {
|
||||
updateWorkOrder(item);
|
||||
});
|
||||
}
|
||||
col.styleFilter = function () {
|
||||
return { "width": "100%", 'padding': 0 };
|
||||
col.styleFilter = function (item) {
|
||||
return Object.assign({}, styleFilter(item), { "width": "100%", 'padding': 0 });
|
||||
}
|
||||
}
|
||||
else if (col.name === "Advisor") {
|
||||
@ -376,8 +391,8 @@ function InitGridData() {
|
||||
}
|
||||
});
|
||||
}
|
||||
col.styleFilter = function () {
|
||||
return { "width": "100%", 'padding': 0 };
|
||||
col.styleFilter = function (item) {
|
||||
return Object.assign({}, styleFilter(item), { "width": "100%", 'padding': 0 });
|
||||
}
|
||||
}
|
||||
else if (col.name === "AssignedToName") {
|
||||
@ -463,8 +478,8 @@ function InitGridData() {
|
||||
});
|
||||
return selector;
|
||||
}
|
||||
col.styleFilter = function () {
|
||||
return { "width": "100%", 'padding': 0 };
|
||||
col.styleFilter = function (item) {
|
||||
return Object.assign({}, styleFilter(item), { "width": "100%", 'padding': 0 });
|
||||
}
|
||||
}
|
||||
else if (col.name === "DueDate") {
|
||||
@ -502,8 +517,8 @@ function InitGridData() {
|
||||
}
|
||||
return ipt;
|
||||
}
|
||||
col.styleFilter = function () {
|
||||
return { "width": "100%", 'padding': 0 };
|
||||
col.styleFilter = function (item) {
|
||||
return Object.assign({}, styleFilter(item), { "width": "100%", 'padding': 0 });
|
||||
}
|
||||
}
|
||||
else if (col.name === "CompleteDate") {
|
||||
@ -537,8 +552,8 @@ function InitGridData() {
|
||||
}
|
||||
return ipt;
|
||||
}
|
||||
col.styleFilter = function () {
|
||||
return { "width": "100%", 'padding': 0 };
|
||||
col.styleFilter = function (item) {
|
||||
return Object.assign({}, styleFilter(item), { "width": "100%", 'padding': 0 });
|
||||
}
|
||||
}
|
||||
else if (col.name === "NextFollowUpDate") {
|
||||
@ -552,7 +567,7 @@ function InitGridData() {
|
||||
var color = !item.Completed && item.NextFollowUpDate.Value && new Date(item.NextFollowUpDate.Value) < new Date(currentdate) ? 'red' : null;
|
||||
return $('<span class="margin-input-span status-cell"></span>').css({
|
||||
'background-color': color,
|
||||
'color': 'white'
|
||||
//'color': 'white'
|
||||
}).text(item.NextFollowUpDateStr);
|
||||
};
|
||||
col.editFilter = function (item) {
|
||||
@ -560,7 +575,7 @@ function InitGridData() {
|
||||
var color = !item.Completed && item.NextFollowUpDate.Value && new Date(item.NextFollowUpDate.Value) < new Date(currentdate) ? 'red' : null;
|
||||
return $('<span class="margin-input-span status-cell"></span>').css({
|
||||
'background-color': color,
|
||||
'color': 'white'
|
||||
//'color': 'white'
|
||||
}).text(item.NextFollowUpDateStr);
|
||||
}
|
||||
|
||||
@ -596,8 +611,8 @@ function InitGridData() {
|
||||
}
|
||||
return ipt;
|
||||
}
|
||||
col.styleFilter = function () {
|
||||
return { "width": "100%", 'padding': 0 };
|
||||
col.styleFilter = function (item) {
|
||||
return Object.assign({}, styleFilter(item), { "width": "100%", 'padding': 0 });
|
||||
}
|
||||
}
|
||||
else if (col.name === "Description") {
|
||||
@ -647,9 +662,9 @@ function InitGridData() {
|
||||
}
|
||||
}
|
||||
else if (col.name === 'AssetName') {
|
||||
col.styleFilter = function () {
|
||||
return { 'white-space': 'pre-line', 'line-height': '20px' };
|
||||
};
|
||||
col.styleFilter = function (item) {
|
||||
return Object.assign({}, styleFilter(item), { 'white-space': 'pre-line', 'line-height': '20px' });
|
||||
}
|
||||
}
|
||||
else if (col.name === 'InspectionCount') {
|
||||
col.styleFilter = function (item) {
|
||||
@ -826,12 +841,12 @@ function InitGridData() {
|
||||
return tb;
|
||||
}
|
||||
};
|
||||
col.styleFilter = function () {
|
||||
return {
|
||||
col.styleFilter = function (item) {
|
||||
return Object.assign({}, styleFilter(item), {
|
||||
'margin-top': '3px',
|
||||
'margin-bottom': '0px',
|
||||
};
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
else if (col.name === "PartsExpectedDate") {
|
||||
col.allowHtml = true;
|
||||
@ -868,8 +883,8 @@ function InitGridData() {
|
||||
}
|
||||
return ipt;
|
||||
}
|
||||
col.styleFilter = function () {
|
||||
return { "width": "100%", 'padding': 0 };
|
||||
col.styleFilter = function (item) {
|
||||
return Object.assign({}, styleFilter(item), { "width": "100%", 'padding': 0 });
|
||||
}
|
||||
}
|
||||
else if (col.name === "LastLaborDate") {
|
||||
@ -907,8 +922,8 @@ function InitGridData() {
|
||||
}
|
||||
return ipt;
|
||||
}
|
||||
col.styleFilter = function () {
|
||||
return { "width": "100%", 'padding': 0 };
|
||||
col.styleFilter = function (item) {
|
||||
return Object.assign({}, styleFilter(item), { "width": "100%", 'padding': 0 });
|
||||
}
|
||||
}
|
||||
else if (col.name === "InspectionRequired") {
|
||||
@ -933,8 +948,8 @@ function InitGridData() {
|
||||
}
|
||||
return ipt;
|
||||
}
|
||||
col.styleFilter = function () {
|
||||
return { "width": "100%" };
|
||||
col.styleFilter = function (item) {
|
||||
return Object.assign({}, styleFilter(item), { "width": "100%" });
|
||||
}
|
||||
}
|
||||
else if (col.name === "AutoText") {
|
||||
@ -959,8 +974,8 @@ function InitGridData() {
|
||||
}
|
||||
return ipt;
|
||||
}
|
||||
col.styleFilter = function () {
|
||||
return { "width": "100%" };
|
||||
col.styleFilter = function (item) {
|
||||
return Object.assign({}, styleFilter(item), { "width": "100%" });
|
||||
}
|
||||
}
|
||||
else if (col.name === "Department") {
|
||||
@ -1049,8 +1064,8 @@ function InitGridData() {
|
||||
});
|
||||
return selector;
|
||||
}
|
||||
col.styleFilter = function () {
|
||||
return { "width": "100%", 'padding': 0 };
|
||||
col.styleFilter = function (item) {
|
||||
return Object.assign({}, styleFilter(item), { "width": "100%", 'padding': 0 });
|
||||
}
|
||||
}
|
||||
else if (col.name === "Location") {
|
||||
@ -1139,8 +1154,8 @@ function InitGridData() {
|
||||
});
|
||||
return selector;
|
||||
}
|
||||
col.styleFilter = function () {
|
||||
return { "width": "100%", 'padding': 0 };
|
||||
col.styleFilter = function (item) {
|
||||
return Object.assign({}, styleFilter(item), { "width": "100%", 'padding': 0 });
|
||||
}
|
||||
}
|
||||
else if (col.name === "SalespersonName") {
|
||||
@ -1210,8 +1225,8 @@ function InitGridData() {
|
||||
});
|
||||
return selector;
|
||||
}
|
||||
col.styleFilter = function () {
|
||||
return { "width": "100%", 'padding': 0 };
|
||||
col.styleFilter = function (item) {
|
||||
return Object.assign({}, styleFilter(item), { "width": "100%", 'padding': 0 });
|
||||
}
|
||||
}
|
||||
else if (col.name === "LastCommunication") {
|
||||
@ -1276,7 +1291,10 @@ function InitGridData() {
|
||||
|
||||
grid_dt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_dt.source[rowindex];
|
||||
if (rowdata) {
|
||||
if (rowdata && rowdata.Values.Id.Value > 0) {
|
||||
if (!wowidgetobj)
|
||||
wowidgetobj = new WorkOrderWidget();
|
||||
wowidgetobj.changeWorkOrder(rowdata.Values);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,6 @@ function resetComments() {
|
||||
internal.text = '';
|
||||
internal.load();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -119,168 +118,6 @@ function getCommunications(reset) {
|
||||
});
|
||||
}
|
||||
|
||||
function showCommunication(txt, isfirst) {
|
||||
var commoentctrl = $("#divcommunications");
|
||||
var div = $("<div class='txtdiv'></div>").appendTo(commoentctrl);
|
||||
if (isfirst)
|
||||
div.css("margin-top", 0);
|
||||
var name = "";
|
||||
if (txt.IsReply) {
|
||||
for (var i = 0; i < customercontacts.length; i++) {
|
||||
var contact = customercontacts[i];
|
||||
if (isEmail(txt.Sender)) {
|
||||
if (contact.Email === txt.Sender) {
|
||||
name = contact.Name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (contact.MobilePhone === txt.Sender) {
|
||||
name = contact.Name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (name !== "") {
|
||||
$("<div style='font-weight:bold;'></div>").text(name).appendTo(div);
|
||||
}
|
||||
|
||||
var sendto = "";
|
||||
if (!txt.IsReply && txt.OriPhoneNumbers && txt.OriPhoneNumbers.length > 0) {
|
||||
for (var i = 0; i < txt.OriPhoneNumbers.length; i++) {
|
||||
var oriph = txt.OriPhoneNumbers[i];
|
||||
if (customercontacts && customercontacts.length > 0) {
|
||||
var cname = "";
|
||||
for (var j = 0; j < customercontacts.length; j++) {
|
||||
var contact = customercontacts[j];
|
||||
if (isEmail(oriph)) {
|
||||
if (contact.Email === oriph) {
|
||||
cname = contact.Email + " - " + contact.Name + "\r\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (contact.MobilePhone === oriph) {
|
||||
cname = contact.MobilePhone + " - " + contact.Name + "\r\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cname === "") {
|
||||
for (var j = 0; j < followers.length; j++) {
|
||||
var follower = followers[j];
|
||||
if (isEmail(oriph)) {
|
||||
if (follower.Email === oriph) {
|
||||
cname = follower.Email + " - " + follower.Name + "\r\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (follower.MobilePhone === oriph) {
|
||||
cname = follower.MobilePhone + " - " + follower.Name + "\r\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cname === "")
|
||||
sendto += oriph + "\r\n";
|
||||
else
|
||||
sendto += cname;
|
||||
}
|
||||
else {
|
||||
sendto += oriph + "\r\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sendto !== "")
|
||||
sendto = GetTextByKey("P_WO_SENTTO_COLON", "Send To :") + "\r\n" + sendto;
|
||||
|
||||
$("<div class='txttime'></div>").text(((txt.IsReply && $.trim(txt.FormatSender) !== "") ? txt.FormatSender : txt.Sender) + " - " + txt.TimeStr).attr('title', txt.IsReply ? "" : sendto).appendTo(div);
|
||||
var contentctrl = $("<div></div>").appendTo(div);
|
||||
if (txt.Message.toLowerCase().indexOf("http://") >= 0 || txt.Message.toLowerCase().indexOf("https://") >= 0) {
|
||||
contentctrl.html(formatUrl(txt.Message));
|
||||
}
|
||||
else {
|
||||
contentctrl.text(txt.Message);
|
||||
}
|
||||
if (txt.IsReply)
|
||||
contentctrl.addClass("txtother");
|
||||
else {
|
||||
contentctrl.addClass("txtself");
|
||||
var status = getMsgStatus(txt);
|
||||
if (status.Status != -100) {
|
||||
var statustext = "";
|
||||
if (status.Status == 0) {
|
||||
statustext = GetTextByKey("P_WO_XXXXXX", "Pending");
|
||||
contentctrl.css("background-color", "#FFC107");
|
||||
}
|
||||
else if (status.Status == 1) {
|
||||
statustext = GetTextByKey("P_WO_XXXXXX", "Sent");
|
||||
}
|
||||
else if (status.Status == 9) {
|
||||
statustext = GetTextByKey("P_WO_XXXXXX", "Failed");
|
||||
contentctrl.css("background-color", "#FFC107");
|
||||
}
|
||||
else if (status.Status == 10) {
|
||||
statustext = GetTextByKey("P_WO_XXXXXX", "Opt-Out");
|
||||
contentctrl.css("background-color", "#FFC107");
|
||||
}
|
||||
else if (status.Status == 412) {
|
||||
statustext = GetTextByKey("P_WO_XXXXXX", "Landline");
|
||||
contentctrl.css("background-color", "#FFC107");
|
||||
}
|
||||
else {
|
||||
statustext = GetTextByKey("P_WO_XXXXXX", "Undelivered");
|
||||
contentctrl.css("background-color", "#FFC107");
|
||||
}
|
||||
|
||||
var divstatus = $("<div style='text-align:right;margin-top:3px;font-weight:bold;margin-right:-12px;font-size:10px;'>Failed</div>").text(statustext);
|
||||
if (status.Status == -10)
|
||||
divstatus.attr('title', status.StatusMsg)
|
||||
}
|
||||
contentctrl.append(divstatus);
|
||||
div.css("text-align", "right");
|
||||
}
|
||||
}
|
||||
|
||||
function getMsgStatus(txt) {
|
||||
var status = -100;//没有状态,页面上不显示
|
||||
var ls = [];
|
||||
var statusmsg = "";
|
||||
if (!txt.StatusIncorrect && txt.Participator != null && txt.Participator.length > 0) {
|
||||
for (var i = 0; i < txt.Participator.length; i++) {
|
||||
var p = txt.Participator[i];
|
||||
if (!isEmail(p.CustomerNumber)) {
|
||||
if (ls.indexOf(p.Status) < 0)
|
||||
ls.push(p.Status);
|
||||
|
||||
if (statusmsg == "")
|
||||
statusmsg = p.CustomerNumber + ": ";
|
||||
else
|
||||
statusmsg += "\r\n" + p.CustomerNumber + ": ";
|
||||
|
||||
if (p.Status == 0) {
|
||||
statusmsg += GetTextByKey("P_WO_XXXXXX", "Undelivered");
|
||||
}
|
||||
else if (p.Status == 1) {
|
||||
statusmsg += GetTextByKey("P_WO_XXXXXX", "Sent");
|
||||
}
|
||||
else if (p.Status == 9) {
|
||||
statusmsg += GetTextByKey("P_WO_XXXXXX", "Failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ls.length == 1)
|
||||
status = ls[0];
|
||||
else if (ls.length > 1)
|
||||
status = -10;//多种状态
|
||||
return { Status: status, StatusMsg: statusmsg };
|
||||
}
|
||||
|
||||
function addWorkOrderCommunication() {
|
||||
var pmemails = customer?.contacts;
|
||||
if (pmemails == null || pmemails.length === 0) {
|
||||
@ -324,36 +161,4 @@ function resetCommunications() {
|
||||
customer.text = '';
|
||||
customer.load();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function setPhoneNumber() {
|
||||
if (customercontacts) {
|
||||
var names = "";
|
||||
for (var i = 0; i < customercontacts.length; i++) {
|
||||
var c = customercontacts[i];
|
||||
if (c.OptOut || c.OptOut_BC) continue;
|
||||
var mp = $.trim(c.MobilePhone);
|
||||
var email = $.trim(c.Email);
|
||||
if ((c.ContactPreference == "0" && (checkPhoneNumber(mp))
|
||||
|| (c.ContactPreference == "1" && isEmail(email)))) {
|
||||
if (names == "")
|
||||
names = c.Name;
|
||||
else
|
||||
names += ";" + c.Name;
|
||||
}
|
||||
}
|
||||
if (typeof customer !== 'undefined') {
|
||||
customer.contacts = customercontacts;
|
||||
}
|
||||
$('#dialog_est_phonenum').val(names);
|
||||
$('#dialog_invoice_phonenum').val(names);
|
||||
}
|
||||
else {
|
||||
if (typeof customer !== 'undefined') {
|
||||
customer.contacts = null;
|
||||
}
|
||||
$('#dialog_est_phonenum').val("");
|
||||
$('#dialog_invoice_phonenum').val('');
|
||||
}
|
||||
}
|
@ -1,720 +0,0 @@
|
||||
|
||||
function showAllAlerts(alerts) {
|
||||
if (alerts.DTCAlerts && alerts.DTCAlerts.length > 0) {
|
||||
_DTCAlerts = alerts.DTCAlerts;
|
||||
$("#divdtcalerts").show();
|
||||
showAlerts(_DTCAlerts, grid_dtcalertdt);
|
||||
}
|
||||
else {
|
||||
_DTCAlerts = [];
|
||||
showAlerts(_DTCAlerts, grid_dtcalertdt);
|
||||
}
|
||||
|
||||
if (alerts.PMAlerts && alerts.PMAlerts.length > 0) {
|
||||
_PMAAlerts = alerts.PMAlerts;
|
||||
//$("#divpmaalerts").show();
|
||||
showAlerts(_PMAAlerts, grid_pmaalertdt);
|
||||
|
||||
$('#dialog_expectedcost').val(alerts.AllExpectedCost === 0 ? '' : alerts.AllExpectedCost);
|
||||
}
|
||||
else {
|
||||
_PMAAlerts = [];
|
||||
showAlerts(_PMAAlerts, grid_pmaalertdt);
|
||||
}
|
||||
|
||||
if (alerts.InspectAlerts && alerts.InspectAlerts.length > 0) {
|
||||
_InspectAlerts = alerts.InspectAlerts;
|
||||
$("#divinspectalerts").show();
|
||||
showAlerts(_InspectAlerts, grid_inspectalertdt);
|
||||
}
|
||||
else {
|
||||
_InspectAlerts = [];
|
||||
showAlerts(_InspectAlerts, grid_inspectalertdt);
|
||||
}
|
||||
|
||||
if (alerts.OilAlerts && alerts.OilAlerts.length > 0) {
|
||||
_OilAlerts = alerts.OilAlerts;
|
||||
$("#divoilalerts").show();
|
||||
showAlerts(_OilAlerts, grid_oilalertdt);
|
||||
}
|
||||
else {
|
||||
_OilAlerts = [];
|
||||
showAlerts(_OilAlerts, grid_oilalertdt);
|
||||
}
|
||||
}
|
||||
|
||||
function showAlerts(data, grid_dt) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
alertids.push(r.AlertID);
|
||||
if (r.RepeatedAlerts) {
|
||||
for (var j = 0; j < r.RepeatedAlerts.length; j++) {
|
||||
alertids.push(r.RepeatedAlerts[j]);
|
||||
}
|
||||
}
|
||||
for (var j in r) {
|
||||
r["EngineHoursObj"] = { DisplayValue: r["EngineHours"] == 0 ? "" : r["EngineHours"], Value: r["EngineHours"] };
|
||||
r["AlertLocalTime"] = { DisplayValue: r["AlertLocalTimeStr"], Value: r["AlertLocalTime"] };
|
||||
}
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
|
||||
grid_dt.setData(rows);
|
||||
}
|
||||
|
||||
var grid_dtcalertdt;
|
||||
function InitDTCAlertGridData() {
|
||||
grid_dtcalertdt = new GridView('#dtcalertslist');
|
||||
grid_dtcalertdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'Selected', caption: "", valueIndex: 'Selected', type: 3, css: { 'width': 30, 'text-align': 'center' } },
|
||||
{ name: 'EngineHours', caption: GetTextByKey("P_WO_HOURS", "Hours"), valueIndex: 'EngineHoursObj', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'AlertType', caption: GetTextByKey("P_WO_ALERTTYPE", "Alert Type"), valueIndex: 'AlertType', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'Description', caption: GetTextByKey("P_WO_DESCRIPTION", "Description"), valueIndex: 'Description', css: { 'width': 480, 'text-align': 'left' } },
|
||||
//{ name: 'ServiceDescription', caption: GetTextByKey("P_WO_SERVICEDESCRIPTION", "Service Description"), valueIndex: 'ServiceDescription', css: { 'width': 240, 'text-align': 'left' } },
|
||||
{ name: 'AlertCount', caption: GetTextByKey("P_WO_COUNT", "Count"), valueIndex: 'AlertCount', css: { 'width': 100, 'text-align': 'left' } },
|
||||
{ name: 'AlertLocalTime', caption: GetTextByKey("P_WO_LATESTDATETIME", "Latest DateTime"), valueIndex: 'AlertLocalTime', css: { 'width': 150, 'text-align': 'left' } }
|
||||
];
|
||||
var columns = [];
|
||||
// head
|
||||
for (var hd in list_columns) {
|
||||
var col = {};
|
||||
col.name = list_columns[hd].name;
|
||||
col.caption = list_columns[hd].caption;
|
||||
col.visible = true;
|
||||
col.sortable = true;
|
||||
col.type = list_columns[hd].type;
|
||||
col.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
columns.push(col);
|
||||
if (col.name === "Selected") {
|
||||
col.allcheck = true;
|
||||
}
|
||||
}
|
||||
grid_dtcalertdt.canMultiSelect = false;
|
||||
grid_dtcalertdt.columns = columns;
|
||||
grid_dtcalertdt.init();
|
||||
|
||||
grid_dtcalertdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_dtcalertdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var grid_pmaalertdt;
|
||||
function InitPMAAlertGridData() {
|
||||
grid_pmaalertdt = new GridView('#pmaalertslist');
|
||||
grid_pmaalertdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'Selected', caption: "", valueIndex: 'Selected', type: 3, css: { 'width': 30, 'text-align': 'center' } },
|
||||
{ name: 'EngineHours', caption: GetTextByKey("P_WO_HOURS", "Hours"), valueIndex: 'EngineHoursObj', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'AlertType', caption: GetTextByKey("P_WO_ALERTTYPE", "Alert Type"), valueIndex: 'AlertType', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'Description', caption: GetTextByKey("P_WO_DESCRIPTION", "Description"), valueIndex: 'Description', css: { 'width': 240, 'text-align': 'left' } },
|
||||
{ name: 'ServiceDescription', caption: GetTextByKey("P_WO_SERVICEDESCRIPTION", "Service Description"), valueIndex: 'ServiceDescription', css: { 'width': 240, 'text-align': 'left' } },
|
||||
{ name: 'ExpectedCost', caption: GetTextByKey("P_PM_EXPECTEDCOST", "Expected Cost"), valueIndex: 'ExpectedCost', css: { 'width': 100, 'text-align': 'left' } },
|
||||
{ name: 'AlertCount', caption: GetTextByKey("P_WO_COUNT", "Count"), valueIndex: 'AlertCount', css: { 'width': 100, 'text-align': 'left' } },
|
||||
{ name: 'AlertLocalTime', caption: GetTextByKey("P_WO_LATESTDATETIME", "Latest DateTime"), valueIndex: 'AlertLocalTime', css: { 'width': 150, 'text-align': 'left' } }
|
||||
];
|
||||
var columns = [];
|
||||
// head
|
||||
for (var hd in list_columns) {
|
||||
var col = {};
|
||||
col.name = list_columns[hd].name;
|
||||
col.caption = list_columns[hd].caption;
|
||||
col.visible = true;
|
||||
col.sortable = true;
|
||||
col.type = list_columns[hd].type;
|
||||
col.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
columns.push(col);
|
||||
if (col.name === "Selected") {
|
||||
col.allcheck = true;
|
||||
}
|
||||
}
|
||||
grid_pmaalertdt.canMultiSelect = false;
|
||||
grid_pmaalertdt.columns = columns;
|
||||
grid_pmaalertdt.init();
|
||||
|
||||
grid_pmaalertdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_pmaalertdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var grid_inspectalertdt;
|
||||
function InitInspectAlertGridData() {
|
||||
grid_inspectalertdt = new GridView('#inspectalertslist');
|
||||
grid_inspectalertdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'Selected', caption: "", valueIndex: 'Selected', type: 3, css: { 'width': 30, 'text-align': 'center' } },
|
||||
{ name: 'EngineHours', caption: GetTextByKey("P_WO_HOURS", "Hours"), valueIndex: 'EngineHoursObj', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'AlertType', caption: GetTextByKey("P_WO_ALERTTYPE", "Alert Type"), valueIndex: 'AlertType', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'Description', caption: GetTextByKey("P_WO_DESCRIPTION", "Description"), valueIndex: 'Description', css: { 'width': 480, 'text-align': 'left' } },
|
||||
//{ name: 'ServiceDescription', caption: GetTextByKey("P_WO_SERVICEDESCRIPTION", "Service Description"), valueIndex: 'ServiceDescription', css: { 'width': 240, 'text-align': 'left' } },
|
||||
{ name: 'AlertCount', caption: GetTextByKey("P_WO_COUNT", "Count"), valueIndex: 'AlertCount', css: { 'width': 100, 'text-align': 'left' } },
|
||||
{ name: 'AlertLocalTime', caption: GetTextByKey("P_WO_LATESTDATETIME", "Latest DateTime"), valueIndex: 'AlertLocalTime', css: { 'width': 150, 'text-align': 'left' } }
|
||||
];
|
||||
var columns = [];
|
||||
// head
|
||||
for (var hd in list_columns) {
|
||||
var col = {};
|
||||
col.name = list_columns[hd].name;
|
||||
col.caption = list_columns[hd].caption;
|
||||
col.visible = true;
|
||||
col.sortable = true;
|
||||
col.type = list_columns[hd].type;
|
||||
col.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
columns.push(col);
|
||||
if (col.name === "Selected") {
|
||||
col.allcheck = true;
|
||||
}
|
||||
}
|
||||
grid_inspectalertdt.canMultiSelect = false;
|
||||
grid_inspectalertdt.columns = columns;
|
||||
grid_inspectalertdt.init();
|
||||
|
||||
grid_inspectalertdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_inspectalertdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var grid_oilalertdt;
|
||||
function InitOilAlertGridData() {
|
||||
grid_oilalertdt = new GridView('#oilalertslist');
|
||||
grid_oilalertdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'Selected', caption: "", valueIndex: 'Selected', type: 3, css: { 'width': 30, 'text-align': 'center' } },
|
||||
{ name: 'EngineHours', caption: GetTextByKey("P_WO_HOURS", "Hours"), valueIndex: 'EngineHoursObj', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'AlertType', caption: GetTextByKey("P_WO_ALERTTYPE", "Alert Type"), valueIndex: 'AlertType', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'Description', caption: GetTextByKey("P_WO_DESCRIPTION", "Description"), valueIndex: 'Description', css: { 'width': 480, 'text-align': 'left' } },
|
||||
//{ name: 'ServiceDescription', caption: GetTextByKey("P_WO_SERVICEDESCRIPTION", "Service Description"), valueIndex: 'ServiceDescription', css: { 'width': 240, 'text-align': 'left' } },
|
||||
{ name: 'AlertCount', caption: GetTextByKey("P_WO_COUNT", "Count"), valueIndex: 'AlertCount', css: { 'width': 100, 'text-align': 'left' } },
|
||||
{ name: 'AlertLocalTime', caption: GetTextByKey("P_WO_LATESTDATETIME", "Latest DateTime"), valueIndex: 'AlertLocalTime', css: { 'width': 150, 'text-align': 'left' } }
|
||||
];
|
||||
var columns = [];
|
||||
// head
|
||||
for (var hd in list_columns) {
|
||||
var col = {};
|
||||
col.name = list_columns[hd].name;
|
||||
col.caption = list_columns[hd].caption;
|
||||
col.visible = true;
|
||||
col.sortable = true;
|
||||
col.type = list_columns[hd].type;
|
||||
col.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
columns.push(col);
|
||||
if (col.name === "Selected") {
|
||||
col.allcheck = true;
|
||||
}
|
||||
}
|
||||
grid_oilalertdt.canMultiSelect = false;
|
||||
grid_oilalertdt.columns = columns;
|
||||
grid_oilalertdt.init();
|
||||
|
||||
grid_oilalertdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_oilalertdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showNoneAssienedAlerts(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
for (var j in r) {
|
||||
if (j === "EngineHours")
|
||||
r[j] = { DisplayValue: r[j] == 0 ? "" : r[j], Value: r[j] };
|
||||
else if (j === "AlertLocalTime")
|
||||
r[j] = { DisplayValue: r["AlertLocalTimeStr"], Value: r[j] };
|
||||
}
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
|
||||
grid_noneassignedalertdt.setData(rows);
|
||||
}
|
||||
var grid_noneassignedalertdt;
|
||||
function InitNoneAssignedAlertGridData() {
|
||||
grid_noneassignedalertdt = new GridView('#noneassignedalertlist');
|
||||
grid_noneassignedalertdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'Selected', caption: "", valueIndex: 'Selected', type: 3, css: { 'width': 30, 'text-align': 'center' } },
|
||||
{ name: 'EngineHours', caption: GetTextByKey("P_WO_HOURS", "Hours"), valueIndex: 'EngineHours', css: { 'width': 80, 'text-align': 'left' } },
|
||||
{ name: 'AlertType', caption: GetTextByKey("P_WO_ALERTTYPE", "Alert Type"), valueIndex: 'AlertType', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'Description', caption: GetTextByKey("P_WO_DESCRIPTION", "Description"), valueIndex: 'Description', css: { 'width': 200, 'text-align': 'left' } },
|
||||
{ name: 'ServiceDescription', caption: GetTextByKey("P_WO_SERVICEDESCRIPTION", "Service Description"), valueIndex: 'ServiceDescription', css: { 'width': 200, 'text-align': 'left' } },
|
||||
{ name: 'AlertTime', caption: GetTextByKey("P_WO_LATESTDATETIME", "Latest DateTime"), valueIndex: 'AlertTime', css: { 'width': 125, 'text-align': 'left' } }
|
||||
];
|
||||
var columns = [];
|
||||
// head
|
||||
for (var hd in list_columns) {
|
||||
var col = {};
|
||||
col.name = list_columns[hd].name;
|
||||
col.caption = list_columns[hd].caption;
|
||||
col.visible = true;
|
||||
col.sortable = true;
|
||||
col.type = list_columns[hd].type;
|
||||
col.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
columns.push(col);
|
||||
if (col.name === "Selected") {
|
||||
col.allcheck = true;
|
||||
}
|
||||
}
|
||||
grid_noneassignedalertdt.canMultiSelect = false;
|
||||
grid_noneassignedalertdt.columns = columns;
|
||||
grid_noneassignedalertdt.init();
|
||||
|
||||
grid_noneassignedalertdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_noneassignedalertdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function clearAlertData() {
|
||||
_DTCAlerts = [];
|
||||
_PMAAlerts = [];
|
||||
_InspectAlerts = [];
|
||||
_OilAlerts = [];
|
||||
grid_dtcalertdt.setData([]);
|
||||
grid_pmaalertdt.setData([]);
|
||||
grid_inspectalertdt.setData([]);
|
||||
grid_oilalertdt.setData([]);
|
||||
}
|
||||
|
||||
var _DTCAlerts = [];
|
||||
var _PMAAlerts = [];
|
||||
var _InspectAlerts = [];
|
||||
var _OilAlerts = [];
|
||||
function getAlerts() {
|
||||
$("#divdtcalerts").hide();
|
||||
//$("#divpmaalerts").hide();
|
||||
$("#divinspectalerts").hide();
|
||||
$("#divoilalerts").hide();
|
||||
|
||||
clearAlertData();
|
||||
|
||||
alertrequest("GETWORKORDERALERTS", workorderid, function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
showAllAlerts(data);
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
function getAssetAlerts(mid) {
|
||||
$("#divdtcalerts").hide();
|
||||
//$("#divpmaalerts").hide();
|
||||
$("#divinspectalerts").hide();
|
||||
$("#divoilalerts").hide();
|
||||
|
||||
clearAlertData();
|
||||
|
||||
if (!mid)
|
||||
mid = machineid;
|
||||
|
||||
showloading(true);
|
||||
alertrequest("GETASSETALERTS", mid + String.fromCharCode(170) + JSON.stringify(alertids), function (data) {
|
||||
showloading(false);
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
showAllAlerts(data);
|
||||
}, function (err) {
|
||||
showloading(false);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function reshowgrid() {
|
||||
setTimeout(function () {
|
||||
$("#dtcalertslist").css("height", 240);
|
||||
grid_dtcalertdt && grid_dtcalertdt.resize();
|
||||
$("#pmaalertslist").css("height", 240);
|
||||
grid_pmaalertdt && grid_pmaalertdt.resize();
|
||||
$("#inspectalertslist").css("height", 240);
|
||||
grid_inspectalertdt && grid_inspectalertdt.resize();
|
||||
$("#oilalertslist").css("height", 240);
|
||||
grid_oilalertdt && grid_oilalertdt.resize();
|
||||
});
|
||||
}
|
||||
|
||||
function showAlertPopup() {
|
||||
$('#alertpopupmask').show();
|
||||
$('#alertpopupdialog').show();
|
||||
$('#alertpopupdialog').css({
|
||||
"top": ($("#alertpopupmask").height() - $('#alertpopupdialog').height()) / 2,
|
||||
"left": ($("#alertpopupmask").width() - $('#alertpopupdialog').width()) / 2
|
||||
});
|
||||
|
||||
//$("#noneassignedalertlist").css("height", $('#alertpopupdialog').height() - $("#alertpopupdialog").offset().top - 4);
|
||||
grid_noneassignedalertdt && grid_noneassignedalertdt.resize();
|
||||
}
|
||||
|
||||
function hideAlertPopup() {
|
||||
$('#alertpopupdialog').hide();
|
||||
$('#alertpopupmask').hide();
|
||||
}
|
||||
|
||||
function OnAddAlerts() {
|
||||
if (!workorderid || workorderid === "") {
|
||||
showAlert(GetTextByKey("P_WO_SAVEWORKORDERFIRST", "Please save work order first."), GetTextByKey("P_WO_ADDALERTS", 'Add Alerts'));
|
||||
return;
|
||||
}
|
||||
getNoneAssignedAlerts();
|
||||
}
|
||||
|
||||
var noneassignedalerts = [];
|
||||
function getNoneAssignedAlerts() {
|
||||
var mid;
|
||||
if (typeof editableSelectMachine != "undefined") {
|
||||
var machine = editableSelectMachine.selecteditem();
|
||||
if (machine)
|
||||
mid = machine.Id;
|
||||
}
|
||||
else
|
||||
mid = machineid;
|
||||
|
||||
if (!mid) {
|
||||
showAlert(GetTextByKey("P_WO_PLEASESELECTANASSET", "Please select an Asset."), GetTextByKey("P_WO_SENDEMAIL", "Send Email"));
|
||||
$('#dialog_machine').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
worequest("GetNoneAssignedAlerts", mid, function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
showAlertPopup();
|
||||
noneassignedalerts = data;
|
||||
showNoneAssienedAlerts(noneassignedalerts);
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function AddOrRemoveAlertsFromWorkOrder(isadd, alertids) {
|
||||
worequest("AddOrRemoveAlertsFromWorkOrder", workorderid + String.fromCharCode(170) + JSON.stringify(alertids) + String.fromCharCode(170) + isadd, function (data) {
|
||||
if (isadd)
|
||||
hideAlertPopup();
|
||||
getAlerts();
|
||||
}, function (err) {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function OnRemoveAlerts() {
|
||||
var alerts = [];
|
||||
alertids = [];
|
||||
if (_DTCAlerts.length > 0) {
|
||||
for (var i = _DTCAlerts.length - 1; i >= 0; i--) {
|
||||
var alert = _DTCAlerts[i];
|
||||
if (alert.Selected) {
|
||||
alerts.push(alert.AlertID);
|
||||
_DTCAlerts.splice(i, 1);
|
||||
//if (alertids.indexOf(alert.AlertID) >= 0)
|
||||
// alertids.splice(alertids.indexOf(alert.AlertID), 1);
|
||||
if (alert.RepeatedAlerts) {
|
||||
for (var j = 0; j < alert.RepeatedAlerts.length; j++) {
|
||||
alerts.push(alert.RepeatedAlerts[j]);
|
||||
//alertids.splice(alertids.indexOf(alert.RepeatedAlerts[j]), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
showAlerts(_DTCAlerts, grid_dtcalertdt);
|
||||
}
|
||||
if (_PMAAlerts.length > 0) {
|
||||
for (var i = _PMAAlerts.length - 1; i >= 0; i--) {
|
||||
var alert = _PMAAlerts[i];
|
||||
if (alert.Selected) {
|
||||
alerts.push(alert.AlertID);
|
||||
_PMAAlerts.splice(i, 1);
|
||||
//if (alertids.indexOf(alert.AlertID) >= 0)
|
||||
// alertids.splice(alertids.indexOf(alert.AlertID), 1);
|
||||
if (alert.RepeatedAlerts) {
|
||||
for (var j = 0; j < alert.RepeatedAlerts.length; j++) {
|
||||
alerts.push(alert.RepeatedAlerts[j]);
|
||||
//alertids.splice(alertids.indexOf(alert.RepeatedAlerts[j]), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
showAlerts(_PMAAlerts, grid_pmaalertdt);
|
||||
//grid_pmaalertdt.setData(_PMAAlerts);
|
||||
}
|
||||
if (_InspectAlerts.length > 0) {
|
||||
for (var i = _InspectAlerts.length - 1; i >= 0; i--) {
|
||||
var alert = _InspectAlerts[i];
|
||||
if (alert.Selected) {
|
||||
alerts.push(alert.AlertID);
|
||||
_InspectAlerts.splice(i, 1);
|
||||
//if (alertids.indexOf(alert.AlertID) >= 0)
|
||||
// alertids.splice(alertids.indexOf(alert.AlertID), 1);
|
||||
if (alert.RepeatedAlerts) {
|
||||
for (var j = 0; j < alert.RepeatedAlerts.length; j++) {
|
||||
alerts.push(alert.RepeatedAlerts[j]);
|
||||
//alertids.splice(alertids.indexOf(alert.RepeatedAlerts[j]), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
showAlerts(_InspectAlerts, grid_inspectalertdt);
|
||||
}
|
||||
if (_OilAlerts.length > 0) {
|
||||
for (var i = _OilAlerts.length - 1; i >= 0; i--) {
|
||||
var alert = _OilAlerts[i];
|
||||
if (alert.Selected) {
|
||||
alerts.push(alert.AlertID);
|
||||
_OilAlerts.splice(i, 1);
|
||||
//if (alertids.indexOf(alert.AlertID) >= 0)
|
||||
// alertids.splice(alertids.indexOf(alert.AlertID), 1);
|
||||
if (alert.RepeatedAlerts) {
|
||||
for (var j = 0; j < alert.RepeatedAlerts.length; j++) {
|
||||
alerts.push(alert.RepeatedAlerts[j]);
|
||||
//alertids.splice(alertids.indexOf(alert.RepeatedAlerts[j]), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
showAlerts(_OilAlerts, grid_oilalertdt);
|
||||
}
|
||||
if (alerts.length == 0) {
|
||||
showAlert(GetTextByKey("P_WO_PLEASESELECTANALERT", "Please select an Alert."), GetTextByKey("P_WO_REMOVEALERTS", "Remove Alerts"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (workorderid && workorderid !== "") {
|
||||
AddOrRemoveAlertsFromWorkOrder(false, alerts);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function OnSaveAlerts() {
|
||||
var alerts = [];
|
||||
if (noneassignedalerts.length > 0) {
|
||||
for (var i in noneassignedalerts) {
|
||||
var alert = noneassignedalerts[i];
|
||||
if (alert.Selected) {
|
||||
alerts.push(alert.ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (alerts.length == 0) {
|
||||
showAlert(GetTextByKey("P_WO_PLEASESELECTANALERT", "Please select an Alert."), GetTextByKey("P_WO_ADDALERTS", "Add Alerts"));
|
||||
return;
|
||||
}
|
||||
AddOrRemoveAlertsFromWorkOrder(true, alerts);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//**********************************Add PM Alerts (Alerts not yet triggered)***********************************************/
|
||||
|
||||
|
||||
function showAllPMSchedules(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
for (var j in r) {
|
||||
}
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
|
||||
grid_pmschedulesdt.setData(rows);
|
||||
}
|
||||
|
||||
var grid_pmschedulesdt;
|
||||
function InitAllPMSchedulesGridData() {
|
||||
grid_pmschedulesdt = new GridView('#allpmpmalertslist');
|
||||
grid_pmschedulesdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'Selected', caption: "", valueIndex: 'Selected', type: 3, css: { 'width': 30, 'text-align': 'center' } },
|
||||
{ name: 'Name', caption: GetTextByKey("P_MV_SCHEDULENAME", "Schedule Name"), valueIndex: 'Name', css: { 'width': 300, 'text-align': 'left' } }
|
||||
];
|
||||
var columns = [];
|
||||
// head
|
||||
for (var hd in list_columns) {
|
||||
var col = {};
|
||||
col.name = list_columns[hd].name;
|
||||
col.caption = list_columns[hd].caption;
|
||||
col.visible = true;
|
||||
col.sortable = true;
|
||||
col.type = list_columns[hd].type;
|
||||
col.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
columns.push(col);
|
||||
if (col.name === "Selected") {
|
||||
col.allcheck = true;
|
||||
}
|
||||
}
|
||||
grid_pmschedulesdt.canMultiSelect = false;
|
||||
grid_pmschedulesdt.columns = columns;
|
||||
grid_pmschedulesdt.init();
|
||||
|
||||
grid_pmschedulesdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_pmschedulesdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showAllPMSchedulePopup() {
|
||||
$('#allpmschedulepopupmask').show();
|
||||
$('#allpmschedulepopupdialog').show();
|
||||
$('#allpmschedulepopupdialog').css({
|
||||
"top": ($("#allpmschedulepopupmask").height() - $('#allpmschedulepopupdialog').height()) / 2,
|
||||
"left": ($("#allpmschedulepopupmask").width() - $('#allpmschedulepopupdialog').width()) / 2
|
||||
});
|
||||
|
||||
grid_pmschedulesdt && grid_pmschedulesdt.resize();
|
||||
}
|
||||
|
||||
function hideAllPMSchedulePopup() {
|
||||
$('#allpmschedulepopupdialog').hide();
|
||||
$('#allpmschedulepopupmask').hide();
|
||||
}
|
||||
|
||||
function OnAddAllPMSchedules() {
|
||||
if (!workorderid || workorderid === "") {
|
||||
showAlert(GetTextByKey("P_WO_SAVEWORKORDERFIRST", "Please save work order first."), GetTextByKey("P_WO_ADDALERTS", 'Add Alerts'));
|
||||
return;
|
||||
}
|
||||
GetPMSchedulesByAsset();
|
||||
}
|
||||
|
||||
var allpmschedules = [];
|
||||
function GetPMSchedulesByAsset() {
|
||||
var mid;
|
||||
if (typeof editableSelectMachine != "undefined") {
|
||||
var machine = editableSelectMachine.selecteditem();
|
||||
if (machine)
|
||||
mid = machine.Id;
|
||||
}
|
||||
else
|
||||
mid = machineid;
|
||||
|
||||
if (!mid) {
|
||||
showAlert(GetTextByKey("P_WO_PLEASESELECTANASSET", "Please select an Asset."), GetTextByKey("P_WO_SENDEMAIL", "Send Email"));
|
||||
$('#dialog_machine').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
showAllPMSchedulePopup();
|
||||
worequest("GetPMSchedulesByAsset", mid, function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
allpmschedules = data;
|
||||
showAllPMSchedules(allpmschedules);
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
function GenerateManualPMAlerts() {
|
||||
var schids = [];
|
||||
if (allpmschedules.length > 0) {
|
||||
for (var i in allpmschedules) {
|
||||
var pmsch = allpmschedules[i];
|
||||
if (pmsch.Selected) {
|
||||
schids.push(pmsch.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (schids.length == 0) {
|
||||
showAlert(GetTextByKey("P_WO_PLEASESELECTAPLAN", "Please select a plan."), GetTextByKey("P_WO_ADDALERTS", "Add Alerts"));
|
||||
return;
|
||||
}
|
||||
|
||||
var mid;
|
||||
if (typeof editableSelectMachine != "undefined") {
|
||||
var machine = editableSelectMachine.selecteditem();
|
||||
if (machine)
|
||||
mid = machine.Id;
|
||||
}
|
||||
else
|
||||
mid = machineid;
|
||||
|
||||
if (!mid) {
|
||||
showAlert(GetTextByKey("P_WO_PLEASESELECTANASSET", "Please select an Asset."), GetTextByKey("P_WO_SENDEMAIL", "Send Email"));
|
||||
$('#dialog_machine').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
worequest("GenerateManualPMAlerts", JSON.stringify([mid, workorderid, JSON.stringify(schids)])
|
||||
, function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
else {
|
||||
var msg = "";
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
if (r.Status == -1)
|
||||
msg += GetTextByKey("P_WO_FAILEDTOGENERATEALERT", "Failed to generate alert.") + " (" + r.ScheduleName + ")\r\n";
|
||||
else if (r.Status == 1)
|
||||
msg += GetTextByKey("P_WO_FAILEDTOGENERATEALERT1", "Unable to generate alert because there already exists an unmaintained alert.") + " (" + r.ScheduleName + ")\r\n";
|
||||
else if (r.Status == 2) {
|
||||
if (r.UOM == "hour(s)")
|
||||
msg += GetTextByKey("P_WO_FAILEDTOGENERATEALERT2", "Unable to generate alert until Hour Meter is higher than ") + r.NextTargetValue.toLocaleString() + " " + r.UOM + " (" + r.ScheduleName + ")\r\n";
|
||||
else if (r.UOM == "day(s)")
|
||||
msg += GetTextByKey("P_WO_FAILEDTOGENERATEALERT3", "Unable to generate alert until {0} later {1}").replace('{0}', r.NextTargetValue.toLocaleString() + " " + r.UOM).replace('{1}', " (" + r.ScheduleName + ")\r\n");
|
||||
else
|
||||
msg += GetTextByKey("P_WO_FAILEDTOGENERATEALERT4", "Unable to generate alert until odometer is higher than ") + r.NextTargetValue.toLocaleString() + " " + r.UOM + " (" + r.ScheduleName + ")\r\n";
|
||||
}
|
||||
}
|
||||
if (msg !== "")
|
||||
showAlert(msg, GetTextByKey("P_WO_ERROR", 'Error'));
|
||||
}
|
||||
hideAllPMSchedulePopup();
|
||||
getAlerts();
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
@ -1,801 +0,0 @@
|
||||
|
||||
function UpLoadWorkOrderAttachment() {
|
||||
var file = $('<input type="file" style="display: none;" multiple="multiple" />');
|
||||
file.change(function () {
|
||||
var files = this.files;
|
||||
if (files.length > 0) {
|
||||
onSaveWOAttachment(files);
|
||||
}
|
||||
}).click();
|
||||
}
|
||||
|
||||
var filesinuploading = [];
|
||||
var uploadingindex = -1;
|
||||
var fileupload_errors = "";
|
||||
function onSaveWOAttachment(files) {
|
||||
fileupload_errors = "";
|
||||
if (!workorderid) {
|
||||
OnSave(0, function () {
|
||||
showLoading();
|
||||
$('.span_attupload').show();
|
||||
$('.span_vieuploadmsg').css('margin-left', 0);
|
||||
$('.span_vieuploadmsg').show();
|
||||
if (filesinuploading.length > 0) {
|
||||
for (var i = 0; i < files.length; i++)
|
||||
filesinuploading.push(workorderid, files[i]);
|
||||
showUplpadingStatus(0);
|
||||
}
|
||||
else {
|
||||
filesinuploading = files;
|
||||
DoUploadWorkOrderAttachments(workorderid);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
showLoading();
|
||||
$('.span_attupload').show();
|
||||
$('.span_vieuploadmsg').css('margin-left', 0);
|
||||
$('.span_vieuploadmsg').show();
|
||||
if (filesinuploading.length > 0) {
|
||||
for (var i = 0; i < files.length; i++)
|
||||
filesinuploading.push(files[i]);
|
||||
showUplpadingStatus(0);
|
||||
}
|
||||
else {
|
||||
filesinuploading = files;
|
||||
DoUploadWorkOrderAttachments(workorderid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function DoUploadWorkOrderAttachments(woid) {
|
||||
if (woid != workorderid) {
|
||||
filesinuploading = [];
|
||||
uploadingindex = -1;
|
||||
return;
|
||||
}
|
||||
uploadingindex++;
|
||||
if (uploadingindex >= filesinuploading.length) {
|
||||
uploadingindex--;
|
||||
showUplpadingStatus(3);
|
||||
filesinuploading = [];
|
||||
uploadingindex = -1;
|
||||
$('.span_attupload').hide();
|
||||
$('.span_vieuploadmsg').css('margin-left', 200);
|
||||
getWorkOrderAttachments();
|
||||
|
||||
hideLoading();
|
||||
if (fileupload_errors !== "")
|
||||
showAlert(fileupload_errors, GetTextByKey("P_WO_XXXXX", 'Upload failed'));
|
||||
return;
|
||||
}
|
||||
var file = filesinuploading[uploadingindex];
|
||||
if (file.name.length > 200) {
|
||||
showUplpadingStatus(2, GetTextByKey("P_WO_XXX", "Attachment name length cannot be greater than 200."));
|
||||
DoUploadWorkOrderAttachments(woid);
|
||||
return;
|
||||
}
|
||||
if (file.size == 0) {
|
||||
showUplpadingStatus(2, GetTextByKey("P_WO_ATTACHMENTSTIPS", "Attachment size is 0kb, uploading failed."));
|
||||
DoUploadWorkOrderAttachments(woid);
|
||||
return;
|
||||
}
|
||||
if (file.size > 50 * 1024 * 1024) {
|
||||
showUplpadingStatus(2, GetTextByKey("P_WO_ATTACHMENTSTIPS1", "Attachment is too large. Maximum file size is 50 MB."));
|
||||
DoUploadWorkOrderAttachments(woid);
|
||||
return;
|
||||
}
|
||||
|
||||
showUplpadingStatus(0);
|
||||
|
||||
var top = $(window).height() / 2 - 100;
|
||||
var left = $(window).width() / 2 - 100;
|
||||
var width = $('#dialogattmask .lable_attuploadname').width();
|
||||
$('#dialogattmask .loading_icon').css({ top: top, left: left });
|
||||
$('#dialogattmask .lable_attuploadname').css({ top: top + 70, left: ($(window).width() - width - 100) / 2 });
|
||||
|
||||
var p = JSON.stringify([workorderid, ""]);
|
||||
var formData = new FormData();
|
||||
formData.append("iconFile", file);
|
||||
formData.append("MethodName", "AddAttachment");
|
||||
formData.append("ClientData", p);
|
||||
var url = 'AddWorkOrder.aspx';
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
data: formData,
|
||||
async: true,
|
||||
success: function (data) {
|
||||
if (data !== 'OK') {
|
||||
showAlert(GetTextByKey("P_WO_XXXXX", 'Upload failed'), GetTextByKey("P_WO_ATTACHMENTFILE", 'Attachment File'));
|
||||
}
|
||||
showUplpadingStatus(1);
|
||||
DoUploadWorkOrderAttachments(woid);
|
||||
},
|
||||
error: function (err) {
|
||||
showUplpadingStatus(2, GetTextByKey("P_WO_XXXXX", 'Upload failed'));
|
||||
DoUploadWorkOrderAttachments(woid);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function showUplpadingStatus(status, msg) {
|
||||
if (filesinuploading.length == 0) return;
|
||||
var filename = filesinuploading[uploadingindex].name;
|
||||
if (filename.length > 50)
|
||||
filename = filename.substring(0, 49) + "...";
|
||||
|
||||
var statustxt = "";
|
||||
if (status == 0) {
|
||||
statustxt = "Uploading " + filename + " (" + (uploadingindex + 1) + "/" + filesinuploading.length + ")";
|
||||
$('.lable_attuploadname').text(statustxt);
|
||||
}
|
||||
else if (status == 1) {
|
||||
statustxt = filename;
|
||||
$('#attupload_ul').append('<li style="padding-left: 0;height:unset;line-height:24px;"><span class="sbutton iconattsuc">' + statustxt + '</span></li>');
|
||||
}
|
||||
else if (status == 2) {
|
||||
statustxt = filename + " - " + msg;
|
||||
$('#attupload_ul').append('<li style="padding-left: 0;height:unset;line-height:24px;"><span class="sbutton iconatterror">' + statustxt + '</span></li>');
|
||||
if (fileupload_errors === "")
|
||||
fileupload_errors = statustxt;
|
||||
else
|
||||
fileupload_errors = fileupload_errors + " \n " + statustxt;
|
||||
}
|
||||
else if (status == 3) {
|
||||
statustxt = "Upload Completed";
|
||||
statustxt = "";
|
||||
$('.lable_attuploadname').text(statustxt);
|
||||
}
|
||||
}
|
||||
|
||||
function deleteAttachment(attID) {
|
||||
if (confirm(GetTextByKey("P_WO_DELETEATTACHMENTTIPS", "Are you sure you want to delete the attachment?"))) {
|
||||
worequest("DeleteAttachment", attID, function (data) {
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, GetTextByKey("P_WO_DELETEATTACHMENT", 'Delete Attachment'));
|
||||
}
|
||||
else {
|
||||
getWorkOrderAttachments();
|
||||
}
|
||||
}, function (err) {
|
||||
showAlert(GetTextByKey("P_WO_FAILEDDELETEATTACHMENT", 'Failed to delete this attachment.'), GetTextByKey("P_WO_DELETEATTACHMENT", 'Delete Attachment'));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var allAttachments;
|
||||
var viewtype = 0;
|
||||
function onViewAttachment(type) {
|
||||
viewtype = type;
|
||||
if (typeof setCookie === "function")
|
||||
setCookie("woattachmentviewtype", viewtype);
|
||||
|
||||
$(".woattafoldicon").removeClass("iconchevronright").addClass("iconchevrondown");
|
||||
$(".woattafoldtr").show();
|
||||
showWOAttachments();
|
||||
}
|
||||
|
||||
function showWOAttachments() {
|
||||
$('#div_woatts').empty();
|
||||
$('#div_atts').empty();
|
||||
$('#div_iatts').empty();
|
||||
$('#woattslist_tbody').empty();
|
||||
$('#woassetattslist_tbody').empty();
|
||||
$('#woiptattslist_tbody').empty();
|
||||
|
||||
if (!viewtype)
|
||||
viewtype = 0;
|
||||
|
||||
if (parseInt(viewtype) === 1) {
|
||||
$('#div_attlarge').hide();
|
||||
$('#div_attlist').show();
|
||||
showAttachmentList(allAttachments);
|
||||
}
|
||||
else {
|
||||
$('#div_attlarge').show();
|
||||
$('#div_attlist').hide();
|
||||
showWorkOrderAttachments(allAttachments);
|
||||
}
|
||||
$('#dialogattmask').height($(document).outerHeight(false)).width($(document).outerWidth(false));
|
||||
}
|
||||
|
||||
function getWorkOrderAttachments(next) {
|
||||
if (workorderid) {
|
||||
worequest('GetAttachments', JSON.stringify([workorderid, machineid]), function (data) {
|
||||
if (data && typeof data != "string") {
|
||||
allAttachments = data;
|
||||
if (next)
|
||||
next();
|
||||
else {
|
||||
showWOAttachments(allAttachments);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var imgTypes = [".jfif", ".jpg", ".jpeg", ".bmp", ".png", ".tiff", ".gif"];
|
||||
var printTypes = ['.pdf', ".jfif", ".jpg", ".jpeg", ".bmp", ".png", ".tiff", ".gif"];//types to be loaded to print
|
||||
function showWorkOrderAttachments(attas) {
|
||||
var div_aatts = $('#div_aatts');
|
||||
div_aatts.empty();
|
||||
var div_woatts = $('#div_woatts');
|
||||
div_woatts.empty();
|
||||
var div_iatts = $('#div_iatts');
|
||||
div_iatts.empty();
|
||||
if (attas.AssetAttachments && attas.AssetAttachments.length > 0) {
|
||||
for (var i = 0; i < attas.AssetAttachments.length; i++) {
|
||||
var att = attas.AssetAttachments[i];
|
||||
if (imgTypes.indexOf(att.FileType.toLowerCase()) >= 0)
|
||||
att.ThumbnailUrl = att.Url + "&thumb=1";
|
||||
var div = createAttaDiv(att);
|
||||
|
||||
if ($.inArray(att.FileType.toLowerCase(), printTypes) >= 0) {
|
||||
var sprint = $('<span class="attaprint"></span>').attr('title', GetTextByKey("P_WO_PRINT", 'Print')).click(att, function (e) {
|
||||
openPrintFrame(e.data.AttachmentType, e.data.AttachmentIdStr);
|
||||
});
|
||||
div.append(sprint);
|
||||
}
|
||||
|
||||
if (att.FileType.toLowerCase() != "url") {
|
||||
var sdownload = $('<span class="attadownload"></span>').attr('title', GetTextByKey("P_WO_DOWNLOAD", 'Download')).click(att, function (e) {
|
||||
openDownloadFrame(e.data.Url + "&d=1");
|
||||
});
|
||||
div.append(sdownload);
|
||||
}
|
||||
|
||||
div_aatts.append(div);
|
||||
}
|
||||
}
|
||||
if (attas.WorkOrderAttachments && attas.WorkOrderAttachments.length > 0) {
|
||||
for (var i = 0; i < attas.WorkOrderAttachments.length; i++) {
|
||||
var att = attas.WorkOrderAttachments[i];
|
||||
|
||||
var pdiv = $('<div class="divattp"></div>');
|
||||
var div = createAttaDiv(att, true);
|
||||
|
||||
var div1 = $('<div style=" margin-top: 15px;"></div>');
|
||||
var ext_span = $('<span style="font-weight:500;"></span>').text(GetTextByKey("P_WO_AVAILABLETOCUSTOMER", 'Available to Customer'));
|
||||
var ext_chk = $('<input type="checkbox" />').prop('checked', att.AvailableToCustomer).click(att, function (e) {
|
||||
updateWOAttachmentExtension(e.data.AttachmentId, $(this).prop('checked'));
|
||||
});
|
||||
div1.append(ext_chk).append(ext_span);
|
||||
pdiv.append(div1);
|
||||
|
||||
if (AllowDeleteAtta) {
|
||||
var sdel = $('<span class="delete"></span>').attr('title', GetTextByKey("P_WO_DELETE", 'Delete')).click(att, function (e) {
|
||||
deleteAttachment(e.data.AttachmentId);
|
||||
});
|
||||
div.append(sdel);
|
||||
}
|
||||
|
||||
if ($.inArray(att.FileType.toLowerCase(), printTypes) >= 0) {
|
||||
var sprint = $('<span class="attaprint"></span>').attr('title', GetTextByKey("P_WO_PRINT", 'Print')).click(att, function (e) {
|
||||
openPrintFrame(e.data.AttachmentType, e.data.AttachmentIdStr);
|
||||
});
|
||||
div.append(sprint);
|
||||
}
|
||||
|
||||
var sdownload = $('<span class="attadownload"></span>').attr('title', GetTextByKey("P_WO_DOWNLOAD", 'Download')).click(att, function (e) {
|
||||
openDownloadFrame(e.data.Url + "&d=1");
|
||||
});
|
||||
div.append(sdownload);
|
||||
pdiv.append(div);
|
||||
|
||||
var caption = att.Notes === "" ? att.FileName : att.Notes;
|
||||
var div3 = $('<div style="text-align:center;clear:both;height:25px;"></div>');
|
||||
var iptcaption = $('<input type="text" style="width: 296px;" class="inp_name" style="height:24px;" maxlength="200"/>').attr('data-ori', caption).val(caption);
|
||||
iptcaption.data('attdata', att);
|
||||
div3.append(iptcaption);
|
||||
iptcaption.focus({ AttachmentId: att.AttachmentId, iptcaption: iptcaption }, function (e) {
|
||||
e.data.iptcaption.addClass('focused');
|
||||
});
|
||||
iptcaption.blur({ div: div, AttachmentId: att.AttachmentId, iptcaption: iptcaption, caption: caption }, function (e) {
|
||||
e.data.iptcaption.removeClass('focused');
|
||||
updateWOAttachmentCaption(e.data);
|
||||
});
|
||||
iptcaption.keydown({ div: div, AttachmentId: att.AttachmentId, iptcaption: iptcaption, caption: caption }, function (e) {
|
||||
if (e.keyCode == 13 || e.keyCode == 9) {
|
||||
e.data.iptcaption.blur();
|
||||
}
|
||||
});
|
||||
pdiv.append(div3);
|
||||
div_woatts.append(pdiv);
|
||||
}
|
||||
}
|
||||
if (attas.InspectionAttachments && attas.InspectionAttachments.length > 0) {
|
||||
for (var i = 0; i < attas.InspectionAttachments.length; i++) {
|
||||
var att = attas.InspectionAttachments[i];
|
||||
var div = createAttaDiv(att);
|
||||
|
||||
if ($.inArray(att.FileType.toLowerCase(), printTypes) >= 0) {
|
||||
var sprint = $('<span class="attaprint"></span>').attr('title', GetTextByKey("P_WO_PRINT", 'Print')).click(att, function (e) {
|
||||
openPrintFrame(e.data.AttachmentType, e.data.AttachmentIdStr);
|
||||
});
|
||||
div.append(sprint);
|
||||
}
|
||||
|
||||
var sdownload = $('<span class="attadownload"></span>').attr('title', GetTextByKey("P_WO_DOWNLOAD", 'Download')).click(att, function (e) {
|
||||
openDownloadFrame(e.data.Url + "&d=1");
|
||||
});
|
||||
div.append(sdownload);
|
||||
|
||||
div_iatts.append(div);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createAttaDiv(att, iswoatta) {
|
||||
var div = $('<div class="divatt"></div>').attr('title', att.FileName);
|
||||
if (iswoatta)
|
||||
div.attr('title', att.Notes === "" ? att.FileName : att.Notes)
|
||||
|
||||
if (!att.FileType || att.FileType == "") att.FileType = ".jpg";
|
||||
if (imgTypes.indexOf(att.FileType.toLowerCase()) >= 0) {
|
||||
var pic = $('<img class="picture"></img>').attr('src', att.ThumbnailUrl);
|
||||
pic.click(att, function (e) {
|
||||
window.open(e.data.Url, "_blank")
|
||||
});
|
||||
div.append(pic);
|
||||
}
|
||||
else {
|
||||
var sdown = $('<img class="picture" />').click(att, function (e) {
|
||||
window.open(e.data.Url);
|
||||
});
|
||||
setAttachemntIcon(att.FileType, sdown);
|
||||
div.append(sdown);
|
||||
}
|
||||
return div
|
||||
}
|
||||
|
||||
function updateWOAttachmentExtension(attID, chk) {
|
||||
var item = {
|
||||
'Key': "1",
|
||||
'Value': chk
|
||||
};
|
||||
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
|
||||
worequest('UpdateWOAttachmentExtension', JSON.stringify([attID, param]), function (data) {
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, GetTextByKey("P_WO_AVAILABLETOCUSTOMER", 'Available to Customer'));
|
||||
}
|
||||
if (allAttachments && allAttachments.WorkOrderAttachments) {
|
||||
for (var i = 0; i < allAttachments.WorkOrderAttachments.length; i++) {
|
||||
if (allAttachments.WorkOrderAttachments[i].AttachmentId == attID) {
|
||||
allAttachments.WorkOrderAttachments[i].AvailableToCustomer = chk;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
var grid_panddattachments
|
||||
function InitPAndDGrid() {
|
||||
grid_panddattachments = new GridView('#dialog_wopanddattachmentlist');
|
||||
var list_columns = [
|
||||
{ name: 'Selected', caption: "", valueIndex: 'Selected', type: 3, css: { 'width': 30, 'text-align': 'center' } },
|
||||
{ name: 'ThumbnailUrl', caption: "", valueIndex: 'ThumbnailUrl', css: { 'width': 42, 'text-align': 'center' } },
|
||||
{ name: 'FileName', caption: GetTextByKey("P_WO_NAME", "Name"), valueIndex: 'FileName', css: { 'width': 280, 'text-align': 'left' } }
|
||||
];
|
||||
|
||||
var columns = [];
|
||||
for (var hd in list_columns) {
|
||||
var col = {};
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
col.name = list_columns[hd].name;
|
||||
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;
|
||||
columns.push(col);
|
||||
|
||||
if (col.name == "Selected") {
|
||||
col.allcheck = true;
|
||||
col.sortable = false;
|
||||
}
|
||||
else if (col.name == "ThumbnailUrl") {
|
||||
col.allowHtml = true;
|
||||
col.filterCustom = true;
|
||||
col.filter = function (item) {
|
||||
if (imgTypes.indexOf(item.FileType.toLowerCase()) >= 0)
|
||||
return $('<img style="height:30px;width:30px;"></img>').attr('src', item.ThumbnailUrl);
|
||||
else {
|
||||
var sdown = $('<img style="height:30px;width:30px;line-height:40px;" />')
|
||||
setAttachemntIcon(item.FileType, sdown);
|
||||
return sdown;
|
||||
}
|
||||
}
|
||||
col.styleFilter = function () {
|
||||
return { "width": "100%", 'margin': 0 };
|
||||
}
|
||||
}
|
||||
}
|
||||
grid_panddattachments.canMultiSelect = true;
|
||||
grid_panddattachments.columns = columns;
|
||||
grid_panddattachments.init();
|
||||
}
|
||||
|
||||
function openPAndDGDialog(type) {
|
||||
if (!allAttachments) return;
|
||||
|
||||
var d = $("#dialog_panddattachments");
|
||||
if (!d.data("loaded")) {
|
||||
d.data("loaded", true);
|
||||
InitPAndDGrid();
|
||||
}
|
||||
if (type == 0) {
|
||||
$("#btnPrintWOAttachments").show();
|
||||
$("#btnDownloadWOAttachments").hide();
|
||||
}
|
||||
else {
|
||||
$("#btnPrintWOAttachments").hide();
|
||||
$("#btnDownloadWOAttachments").show();
|
||||
}
|
||||
var data = [];
|
||||
if (allAttachments.AssetAttachments && allAttachments.AssetAttachments.length > 0)
|
||||
data = data.concat(allAttachments.AssetAttachments);
|
||||
if (allAttachments.WorkOrderAttachments && allAttachments.WorkOrderAttachments.length > 0)
|
||||
data = data.concat(allAttachments.WorkOrderAttachments);
|
||||
if (allAttachments.InspectionAttachments && allAttachments.InspectionAttachments.length > 0)
|
||||
data = data.concat(allAttachments.InspectionAttachments);
|
||||
|
||||
var count = 0;
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var att = data[i];
|
||||
if (att.FileType.toLowerCase() == "url") continue;
|
||||
if (type == 1 || $.inArray(att.FileType.toLowerCase(), printTypes) >= 0) {
|
||||
var fr = {
|
||||
Values: {
|
||||
FileName: att.Notes === "" ? att.FileName : att.Notes,
|
||||
FileType: att.FileType,
|
||||
Url: att.Url,
|
||||
ThumbnailUrl: att.ThumbnailUrl,
|
||||
AttachmentType: att.AttachmentType,
|
||||
AttachmentIdStr: att.AttachmentIdStr,
|
||||
Selected: false,
|
||||
}
|
||||
};
|
||||
rows.push(fr);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
$('#dialog_panddattachments .dialog-title span.title').text(GetTextByKey("P_WO_ATTACHMENTS", 'Attachments') + " (" + count + ")");
|
||||
showmaskbg(true);
|
||||
d.css({
|
||||
'top': (document.documentElement.clientHeight - d.height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - d.width()) / 2
|
||||
}).showDialogfixed();
|
||||
|
||||
setTimeout(function () {
|
||||
grid_panddattachments.setData(rows);
|
||||
});
|
||||
}
|
||||
|
||||
function getSelectedPAndDAttas() {
|
||||
var sels = [];
|
||||
if (grid_panddattachments && grid_panddattachments.source) {
|
||||
for (var i = 0; i < grid_panddattachments.source.length; i++) {
|
||||
var a = grid_panddattachments.source[i].Values;
|
||||
if (a.Selected)
|
||||
sels.push(a);
|
||||
}
|
||||
}
|
||||
return sels;
|
||||
}
|
||||
|
||||
function printWOAttachments() {
|
||||
var sels = getSelectedPAndDAttas();
|
||||
if (!sels || sels.length == 0) return;
|
||||
if (sels && sels.length > 0) {
|
||||
for (var i = 0; i < sels.length; i++) {
|
||||
var att = sels[i];
|
||||
if ($.inArray(att.FileType.toLowerCase(), printTypes) >= 0) {
|
||||
openPrintFrame(att.AttachmentType, att.AttachmentIdStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
showmaskbg(false);
|
||||
$('#dialog_panddattachments').hideDialog();
|
||||
}
|
||||
|
||||
function openPrintFrame(attatype, id) {
|
||||
var frame = $("<iframe style='display:none;'></iframe>");
|
||||
$(document.body).after(frame);
|
||||
//frame.attr("src", url);
|
||||
frame.attr("src", _network.root + "Print.aspx?pt=3&at=" + attatype + "&id=" + id);
|
||||
|
||||
frame.on('load', function () {
|
||||
setTimeout(function () {
|
||||
frame.contents().find("body").css("text-align", "center");
|
||||
//frame.contents().find("img").css("max-height", window.screen.availHeight).css("max-width", window.screen.availWidth);
|
||||
frame.contents().find("img").css("max-height", "98%").css("max-width", "98%");
|
||||
frame[0].contentWindow.print();
|
||||
});
|
||||
setTimeout(function () {
|
||||
frame.remove();
|
||||
}, 60000);
|
||||
});
|
||||
}
|
||||
|
||||
function downloadWOAttachments() {
|
||||
var sels = getSelectedPAndDAttas();
|
||||
if (!sels || sels.length == 0) return;
|
||||
if (sels && sels.length > 0) {
|
||||
for (var i = 0; i < sels.length; i++) {
|
||||
var att = sels[i];
|
||||
openDownloadFrame(att.Url + "&d=1");
|
||||
}
|
||||
}
|
||||
|
||||
showmaskbg(false);
|
||||
$('#dialog_panddattachments').hideDialog();
|
||||
}
|
||||
|
||||
function openDownloadFrame(url) {
|
||||
var frame = $("<iframe style='display:none;'></iframe>");
|
||||
$(document.body).after(frame);
|
||||
frame.attr("src", url);
|
||||
|
||||
var timer = setInterval(function () {
|
||||
if (frame[0].contentDocument && (frame[0].contentDocument.readyState == "complete" || frame[0].contentDocument.readyState == 4)) {
|
||||
frame.remove();
|
||||
clearInterval(timer);
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
function updateWOAttachmentCaption(edata) {
|
||||
var attid = edata.AttachmentId;
|
||||
var caption = edata.iptcaption.val();
|
||||
|
||||
if (caption === "") {
|
||||
var pcap = edata.caption;
|
||||
if (edata.iptcaption.data('caption'))
|
||||
pcap = edata.iptcaption.data('caption');
|
||||
edata.iptcaption.val(pcap);
|
||||
return;
|
||||
}
|
||||
|
||||
var att = edata.iptcaption.data('attdata');
|
||||
att.Notes = caption;
|
||||
|
||||
if (allAttachments && allAttachments.WorkOrderAttachments) {
|
||||
for (var i = 0; i < allAttachments.WorkOrderAttachments.length; i++) {
|
||||
if (allAttachments.WorkOrderAttachments[i].AttachmentId == att.AttachmentId) {
|
||||
allAttachments.WorkOrderAttachments[i] = att;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
worequest('UpdateWorkOrderAttachmentCaption', JSON.stringify([attid, htmlencode(caption)]), function (data) {
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, GetTextByKey("P_WO_XXX", 'Update Caption'));
|
||||
}
|
||||
else {
|
||||
if (edata.div)
|
||||
edata.div.attr('title', caption);
|
||||
edata.iptcaption.data('caption', caption);
|
||||
}
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
//***********************************Begin Attachment List************************************//
|
||||
|
||||
function showAttachmentList(data) {
|
||||
$('#woattslist_tbody').empty();
|
||||
$('#woassetattslist_tbody').empty();
|
||||
$('#woiptattslist_tbody').empty();
|
||||
if (data.WorkOrderAttachments && data.WorkOrderAttachments.length > 0) {
|
||||
for (var i = 0; i < data.WorkOrderAttachments.length; i++) {
|
||||
var att = data.WorkOrderAttachments[i];
|
||||
var tr = createWOAttachmentTr(att);
|
||||
$('#woattslist_tbody').append(tr);
|
||||
}
|
||||
}
|
||||
if (data.AssetAttachments && data.AssetAttachments.length > 0) {
|
||||
for (var i = 0; i < data.AssetAttachments.length; i++) {
|
||||
var att = data.AssetAttachments[i];
|
||||
if (imgTypes.indexOf(att.FileType.toLowerCase()) >= 0)
|
||||
att.ThumbnailUrl = att.Url + "&thumb=1";
|
||||
var tr = createWOOtherAttachmentTr(att);
|
||||
$('#woassetattslist_tbody').append(tr);
|
||||
}
|
||||
}
|
||||
if (data.InspectionAttachments && data.InspectionAttachments.length > 0) {
|
||||
for (var i = 0; i < data.InspectionAttachments.length; i++) {
|
||||
var att = data.InspectionAttachments[i];
|
||||
var tr = createWOOtherAttachmentTr(att);
|
||||
$('#woiptattslist_tbody').append(tr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createWOAttachmentTr(att) {
|
||||
var caption = att.Notes === "" ? att.FileName : att.Notes;
|
||||
var tr = $('<tr></tr>').attr('data-id', att.AttachmentId);
|
||||
var td;
|
||||
tr.append('<td></td>');
|
||||
|
||||
td = $('<td></td>');
|
||||
if (!att.FileType || att.FileType == "")
|
||||
att.FileType = ".jpg";
|
||||
|
||||
var divpic = $('<div style="width:60px;height:60px;text-align:center;"></div>');
|
||||
td.append(divpic);
|
||||
if (imgTypes.indexOf(att.FileType.toLowerCase()) >= 0) {
|
||||
var pic = $('<img class="wolist_picture"></img>').attr('src', att.ThumbnailUrl);
|
||||
pic.click(att, function (e) {
|
||||
window.open(e.data.Url, "_blank")
|
||||
});
|
||||
divpic.append(pic);
|
||||
}
|
||||
else {
|
||||
var sdown = $('<img class="wolist_picture" />').click(att, function (e) {
|
||||
window.open(e.data.Url);
|
||||
});
|
||||
setAttachemntIcon(att.FileType, sdown);
|
||||
divpic.append(sdown);
|
||||
}
|
||||
tr.append(td);
|
||||
|
||||
td = $('<td style="padding-left:20px;"></td>');
|
||||
var iptcaption = $('<input type="text" class="inp_name" maxlength="200" style="height:24px;"/>').css('width', '100%').attr('data-ori', caption).val(caption);
|
||||
iptcaption.data('attdata', att);
|
||||
td.append(iptcaption);
|
||||
iptcaption.focus({ AttachmentId: att.AttachmentId, iptcaption: iptcaption }, function (e) {
|
||||
e.data.iptcaption.addClass('focused');
|
||||
});
|
||||
iptcaption.blur({ AttachmentId: att.AttachmentId, iptcaption: iptcaption, caption: caption }, function (e) {
|
||||
e.data.iptcaption.removeClass('focused');
|
||||
updateWOAttachmentCaption(e.data);
|
||||
});
|
||||
|
||||
iptcaption.keydown({ AttachmentId: att.AttachmentId, iptcaption: iptcaption, caption: caption }, function (e) {
|
||||
if (e.keyCode == 13 || e.keyCode == 9) {
|
||||
e.data.iptcaption.blur();
|
||||
}
|
||||
});
|
||||
tr.append(td);
|
||||
|
||||
|
||||
td = $('<td></td>');
|
||||
var chk_tocust = $('<input type="checkbox" class="inp_recurring"/>').attr('data-ori', att.AvailableToCustomer).prop('checked', att.AvailableToCustomer);
|
||||
td.append(chk_tocust);
|
||||
chk_tocust.click(att, function (e) {
|
||||
updateWOAttachmentExtension(e.data.AttachmentId, $(this).prop('checked'));
|
||||
});
|
||||
tr.append(td);
|
||||
|
||||
td = $('<td class="td_funcs"></td>');
|
||||
var sdel = $('<span class="wolist_icon wolist_delete"></span>').attr('title', GetTextByKey("P_WO_DELETE", 'Delete')).click(att, function (e) {
|
||||
deleteAttachment(e.data.AttachmentId);
|
||||
});
|
||||
td.append(sdel);
|
||||
|
||||
var sdownload = $('<span class="wolist_icon wolist_attadownload"></span>').attr('title', GetTextByKey("P_WO_DOWNLOAD", 'Download')).click(att, function (e) {
|
||||
openDownloadFrame(e.data.Url + "&d=1");
|
||||
});
|
||||
td.append(sdownload);
|
||||
|
||||
if ($.inArray(att.FileType.toLowerCase(), printTypes) >= 0) {
|
||||
var sprint = $('<span class="wolist_icon wolist_attaprint"></span>').attr('title', GetTextByKey("P_WO_PRINT", 'Print')).click(att, function (e) {
|
||||
openPrintFrame(e.data.AttachmentType, e.data.AttachmentIdStr);
|
||||
});
|
||||
td.append(sprint);
|
||||
}
|
||||
|
||||
tr.append(td);
|
||||
return tr;
|
||||
}
|
||||
|
||||
function createWOOtherAttachmentTr(att) {
|
||||
var tr = $('<tr></tr>').attr('data-id', att.AttachmentId);
|
||||
var td;
|
||||
tr.append('<td></td>');
|
||||
|
||||
td = $('<td></td>');
|
||||
if (!att.FileType || att.FileType == "")
|
||||
att.FileType = ".jpg";
|
||||
|
||||
var divpic = $('<div style="width:60px;height:60px;text-align:center;"></div>');
|
||||
td.append(divpic);
|
||||
if (imgTypes.indexOf(att.FileType.toLowerCase()) >= 0) {
|
||||
var pic = $('<img class="wolist_picture"></img>').attr('src', att.ThumbnailUrl);
|
||||
pic.click(att, function (e) {
|
||||
window.open(e.data.Url, "_blank")
|
||||
});
|
||||
divpic.append(pic);
|
||||
}
|
||||
else {
|
||||
var sdown = $('<img class="wolist_picture" />').click(att, function (e) {
|
||||
window.open(e.data.Url);
|
||||
});
|
||||
setAttachemntIcon(att.FileType, sdown);
|
||||
divpic.append(sdown);
|
||||
}
|
||||
tr.append(td);
|
||||
|
||||
td = $('<td style="padding-left:20px;"></td>').text(att.FileName);
|
||||
tr.append(td);
|
||||
|
||||
tr.append('<td></td>');
|
||||
|
||||
td = $('<td class="td_funcs"></td>');
|
||||
if (att.FileType.toLowerCase() != "url") {
|
||||
var sdownload = $('<span class="wolist_icon wolist_attadownload"></span>').attr('title', GetTextByKey("P_WO_DOWNLOAD", 'Download')).click(att, function (e) {
|
||||
openDownloadFrame(e.data.Url + "&d=1");
|
||||
});
|
||||
td.append(sdownload);
|
||||
}
|
||||
|
||||
if ($.inArray(att.FileType.toLowerCase(), printTypes) >= 0) {
|
||||
var sprint = $('<span class="wolist_icon wolist_attaprint"></span>').attr('title', GetTextByKey("P_WO_PRINT", 'Print')).click(att, function (e) {
|
||||
openPrintFrame(e.data.AttachmentType, e.data.AttachmentIdStr);
|
||||
});
|
||||
td.append(sprint);
|
||||
}
|
||||
|
||||
tr.append(td);
|
||||
return tr;
|
||||
}
|
||||
|
||||
//***********************************End Attachment List************************************//
|
||||
|
||||
|
||||
function dragOverWOAttachment(ev) {
|
||||
ev.preventDefault();
|
||||
ev.dataTransfer.dropEffect = 'link';
|
||||
//$('#dialogattdragmask').css({ height: $('#tb_woattlarge').height(), top: $('#tb_woattlarge').offset().top });
|
||||
//$('#dialogattdragmask').show();
|
||||
|
||||
}
|
||||
function dropWOAttachment(ev) {
|
||||
//$('#dialogattdragmask').hide();
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
var df = ev.dataTransfer;
|
||||
var files = [];
|
||||
if (df.items !== undefined) {
|
||||
for (var i = 0; i < df.items.length; i++) {
|
||||
var item = df.items[i];
|
||||
if (item.kind === "file" && (item.webkitGetAsEntry() == null || item.webkitGetAsEntry().isFile)) {
|
||||
var file = item.getAsFile();
|
||||
files.push(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (files.length > 0)
|
||||
onSaveWOAttachment(files);
|
||||
}
|
||||
|
||||
function cutWOAttachment(ev) {
|
||||
ev.stopPropagation();
|
||||
var df = ev.clipboardData;
|
||||
var files = [];
|
||||
if (df.items !== undefined) {
|
||||
for (var i = 0; i < df.items.length; i++) {
|
||||
var item = df.items[i];
|
||||
if (item.kind === "file" && (item.webkitGetAsEntry() == null || item.webkitGetAsEntry().isFile)) {
|
||||
var file = item.getAsFile();
|
||||
files.push(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (files.length > 0)
|
||||
onSaveWOAttachment(files);
|
||||
}
|
@ -1,444 +0,0 @@
|
||||
$(function () {
|
||||
$("#dialog_segmenthour").keydown(numberinput);
|
||||
$("#dialog_segmentcost").keydown(numberinput);
|
||||
});
|
||||
|
||||
function numberinput(e) {
|
||||
var keyCode = e.which;
|
||||
if (keyCode === 9//tab
|
||||
|| keyCode === 8 || keyCode === 46 //delete
|
||||
|| keyCode === 110 || keyCode === 190//.
|
||||
|| keyCode === 37 || keyCode === 39//left right
|
||||
|| keyCode === 55 || keyCode === 56//home end
|
||||
|| (keyCode >= 48 && keyCode <= 57)
|
||||
|| (keyCode >= 96 && keyCode <= 105))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function GetSegmentDataSource(next) {
|
||||
worequest("GetSegmentDataSource", '', function (data) {
|
||||
if (data.Users && data.Users.length > 0) {
|
||||
userdata = data.Users;
|
||||
$('#dialog_segmentuser').dropdownSource(userdata);
|
||||
}
|
||||
if (data.JobSites && data.JobSites.length > 0) {
|
||||
var jss = [{ ID: '-1', Name: ' ', html: ' ' }];
|
||||
for (var js of data.JobSites) {
|
||||
jss.push(js);
|
||||
}
|
||||
jobsitedata = jss;
|
||||
$("#dialog_segmentjobsite").dropdownSource(jobsitedata);
|
||||
}
|
||||
if (data.Components && data.Components.length > 0) {
|
||||
var source = [];
|
||||
for (var type of data.Components) {
|
||||
source.push({ value: type });
|
||||
}
|
||||
components = source;
|
||||
$("#dialog_segmentcomponent").dropdownSource(components);
|
||||
}
|
||||
if (data.SegmentTypes && data.SegmentTypes.length > 0) {
|
||||
var source = [];
|
||||
for (var type of data.SegmentTypes) {
|
||||
source.push({ value: type });
|
||||
}
|
||||
segmenttypes = source;
|
||||
$("#dialog_segmenttype").dropdownSource(segmenttypes);
|
||||
}
|
||||
|
||||
if (next)
|
||||
next();
|
||||
|
||||
}, function (err) {
|
||||
console.log(err);;
|
||||
});
|
||||
}
|
||||
|
||||
function GetSegmentDataSource1(next) {
|
||||
worequest("GetSegmentDataSource1", '', function (data) {
|
||||
if (data.Components && data.Components.length > 0) {
|
||||
var source = [];
|
||||
for (var type of data.Components) {
|
||||
source.push({ value: type });
|
||||
}
|
||||
components = source;
|
||||
$("#dialog_segmentcomponent").dropdownSource(components);
|
||||
}
|
||||
if (data.SegmentTypes && data.SegmentTypes.length > 0) {
|
||||
var source = [];
|
||||
for (var type of data.SegmentTypes) {
|
||||
source.push({ value: type });
|
||||
}
|
||||
segmenttypes = source;
|
||||
$("#dialog_segmenttype").dropdownSource(segmenttypes);
|
||||
}
|
||||
|
||||
if (next)
|
||||
next();
|
||||
|
||||
}, function (err) {
|
||||
console.log(err);;
|
||||
});
|
||||
}
|
||||
|
||||
function SetCompleted(index) {
|
||||
var date = $('#dialog_segmentcompleteddate' + index).val();
|
||||
if (date.length > 0 && checkDate(date)) {
|
||||
$('#dialog_segmentcompleted' + index).prop('checked', true);
|
||||
}
|
||||
}
|
||||
|
||||
var segmentdata = [];
|
||||
function initControl(index) {
|
||||
$('#dialog_segmentcompleteddate' + index).datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
|
||||
$('#dialog_segmentuser' + index).dropdown(userdata || [], {
|
||||
search: true,
|
||||
valueKey: 'IID',
|
||||
textKey: 'DisplayName'
|
||||
});
|
||||
|
||||
|
||||
$("#dialog_segmentjobsite" + index).dropdown(jobsitedata || [], {
|
||||
search: true,
|
||||
valueKey: 'ID',
|
||||
textKey: 'Name'
|
||||
});
|
||||
|
||||
|
||||
$("#dialog_segmenttype" + index).dropdown(segmenttypes || [], {
|
||||
input: true,
|
||||
maxlength: 50,
|
||||
textKey: 'value'
|
||||
});
|
||||
|
||||
|
||||
$("#dialog_segmentcomponent" + index).dropdown(components || [], {
|
||||
input: true,
|
||||
maxlength: 40,
|
||||
textKey: 'value'
|
||||
});
|
||||
}
|
||||
|
||||
function getSegments(callbake) {
|
||||
segmentindex = 0;
|
||||
$('#tab_segments .segments_table').remove();
|
||||
if (!workorderid || workorderid == "") return;
|
||||
worequest("GetSegments", workorderid, function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
if (data && data.length > 0) {
|
||||
//$('#dialog_workordercosts').attr('disabled', true);
|
||||
segmentdata = data;
|
||||
var wocost = 0;
|
||||
for (var i = 0; i < segmentdata.length; i++) {
|
||||
wocost += segmentdata[i].Cost;
|
||||
showSegment(segmentdata[i]);
|
||||
}
|
||||
$('#dialog_workordercosts').val(wocost);
|
||||
}
|
||||
else {
|
||||
//$('#dialog_workordercosts').attr('disabled', false);
|
||||
if (workorderdata)
|
||||
$('#dialog_workordercosts').val(workorderdata.WorkOrderTotalCost == 0 ? "" : workorderdata.WorkOrderTotalCost);
|
||||
segmentdata = [];
|
||||
if (callbake)
|
||||
callbake();
|
||||
}
|
||||
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
var segmentindex = 0;
|
||||
function showSegment(segment) {
|
||||
segmentindex++;
|
||||
var div_segments = $('#tab_segments');
|
||||
var table = $('<table id="tabsegment_' + segmentindex + '" class="segments_table"></table>');
|
||||
table.data('index', segmentindex);
|
||||
var tr1 = $('<tr></tr>');
|
||||
var tr1_td1 = $('<td class="label" style="font-size:14px;font-weight:500;text-align:left;">' + GetTextByKey("P_WO_SEGMENT", "Segment") + " " + segmentindex + '</td>"');
|
||||
if (!WOReadOnly) {
|
||||
var s_del = $('<span class="sbutton icondelete" onclick="DeleteSegment(' + segmentindex + ');"></span>');
|
||||
tr1_td1.append(s_del);
|
||||
}
|
||||
var tr1_td2 = $('<td></td>"');
|
||||
tr1.append(tr1_td1).append(tr1_td2);
|
||||
table.append(tr1);
|
||||
|
||||
var tr = $('<tr></tr>');
|
||||
var td1 = $('<td class="label">' + GetTextByKey("P_WO_USER_COLON", " User:") + '</td>"');
|
||||
var td2 = $('<td></td>"');
|
||||
var sel_user = $('<div id="dialog_segmentuser' + segmentindex + '" class="dropdown"></div>').css("width", 320);
|
||||
td2.append(sel_user);
|
||||
var td3 = $('<td class="label">' + GetTextByKey("P_WO_COMPLETED_COLON", "Completed:") + '</td>"');
|
||||
var td4 = $('<td></td>"');
|
||||
var chk_completed = $('<input type="checkbox" id="dialog_segmentcompleted' + segmentindex + '" class="inputbox" />');
|
||||
td4.append(chk_completed);
|
||||
tr.append(td1).append(td2).append(td3).append(td4);
|
||||
table.append(tr);
|
||||
|
||||
tr = $('<tr></tr>');
|
||||
td1 = $('<td class="label">' + GetTextByKey("P_WO_HOURS_COLON", "Hours:") + '</td>"');
|
||||
td2 = $('<td></td>"');
|
||||
var input_hour = $('<input type="text" id="dialog_segmenthour' + segmentindex + '" class="inputbox" maxlength="12" />')
|
||||
.keydown(numberinput);
|
||||
td2.append(input_hour);
|
||||
td3 = $('<td class="label">' + GetTextByKey("P_WO_COMPLETEDDATE_COLON", "Completed Date:") + '</td>"');
|
||||
td4 = $('<td></td>"');
|
||||
var input_completeddate = $('<input type="text" id="dialog_segmentcompleteddate' + segmentindex + '" class="inputbox" onchange="SetCompleted(' + segmentindex + ')" />');
|
||||
td4.append(input_completeddate);
|
||||
tr.append(td1).append(td2).append(td3).append(td4);
|
||||
table.append(tr);
|
||||
|
||||
|
||||
tr = $('<tr></tr>');
|
||||
td1 = $('<td class="label">' + GetTextByKey("P_WO_JOBSITE_COLON", "Jobsite:") + '</td>"');
|
||||
td2 = $('<td></td>"');
|
||||
var sel_jobsite = $('<div id="dialog_segmentjobsite' + segmentindex + '" class="dropdown"></div>').css("width", 320);
|
||||
td2.append(sel_jobsite);
|
||||
td3 = $('<td class="label"><span>' + GetTextByKey("P_WO_DESCRIPTION_COLON", "Description:") + '</span><span class="redasterisk">*</span></td>"');
|
||||
td4 = $('<td></td>"');
|
||||
var input_desc = $('<input type="text" id="dialog_segmentdesc' + segmentindex + '" class="inputbox" maxlength="200" />');
|
||||
td4.append(input_desc);
|
||||
tr.append(td1).append(td2).append(td3).append(td4);
|
||||
table.append(tr);
|
||||
|
||||
tr = $('<tr></tr>');
|
||||
td1 = $('<td class="label">' + GetTextByKey("P_WO_COST_COLON", "Cost:") + '</td>"');
|
||||
td2 = $('<td></td>"');
|
||||
var input_cost = $('<input type="text" id="dialog_segmentcost' + segmentindex + '" class="inputbox" />')
|
||||
.keydown(numberinput);
|
||||
td2.append(input_cost);
|
||||
td3 = $('<td class="label">' + GetTextByKey("P_WO_NOTES_COLON", "Notes:") + '</td>"');
|
||||
td4 = $('<td rowspan="4"></td>"').css("vertical-align", "top");
|
||||
var textarea_notes = $('<textarea id="dialog_segmentnotes' + segmentindex + '" class="inputbox" maxlength="500" style="width: 450px; height: 120px;"></textarea>')
|
||||
td4.append(textarea_notes);
|
||||
tr.append(td1).append(td2).append(td3).append(td4);
|
||||
table.append(tr);
|
||||
|
||||
tr = $('<tr></tr>');
|
||||
td1 = $('<td class="label">' + GetTextByKey("P_WO_XXXXXX_COLON", "Segment Type:") + '</td>"');
|
||||
td2 = $('<td></td>"');
|
||||
var sel_segmenttype = $('<div id="dialog_segmenttype' + segmentindex + '" class="dropdown"></div>').css("width", 320);
|
||||
td2.append(sel_segmenttype);
|
||||
tr.append(td1).append(td2);
|
||||
table.append(tr);
|
||||
|
||||
tr = $('<tr></tr>');
|
||||
td1 = $('<td class="label">' + GetTextByKey("P_WO_COMPONENT_COLON", "Component:") + '</td>"');
|
||||
td2 = $('<td></td>"');
|
||||
var sel_component = $('<div id="dialog_segmentcomponent' + segmentindex + '" class="dropdown"></div>').css("width", 320);
|
||||
td2.append(sel_component);
|
||||
tr.append(td1).append(td2);
|
||||
table.append(tr);
|
||||
|
||||
tr = $('<tr></tr>');
|
||||
td1 = $('<td class="label">' + GetTextByKey("P_WO_XXXXXX_COLON", "Billable:") + '</td>"');
|
||||
td2 = $('<td></td>"');
|
||||
var chk_billable = $('<input type="checkbox" id="dialog_segmentbillable' + segmentindex + '" class="inputbox" />');
|
||||
td2.append(chk_billable);
|
||||
tr.append(td1).append(td2);
|
||||
table.append(tr);
|
||||
|
||||
if (!WOReadOnly) {
|
||||
tr = $('<tr></tr>');
|
||||
td1 = $('<td colspan="4" style="text-align: right;"></td>"');
|
||||
var input_save = $('<input type="button" value="Save" style="width:80px;height:25px;" id="btn_savesegment' + segmentindex + '" onclick="SaveSegment(' + segmentindex + ')" />').val(GetTextByKey("P_WO_SAVE", "Save"));
|
||||
var input_cancel = $('<input type="button" value="Cancel" style="width:80px;height:25px;margin-left:10px;" onclick="CancelSegment(' + segmentindex + ')"/>').val(GetTextByKey("P_WO_CANCEL", "Cancel"));
|
||||
td1.append(input_save).append(input_cancel);
|
||||
tr.append(td1);
|
||||
table.append(tr);
|
||||
}
|
||||
|
||||
div_segments.append(table);
|
||||
|
||||
initControl(segmentindex);
|
||||
$('#tabsegment_' + segmentindex).data('segment', segment);
|
||||
$('#dialog_segmentuser' + segmentindex).dropdownVal(segment.UserIID);
|
||||
$('#dialog_segmentdesc' + segmentindex).val(segment.Description);
|
||||
$('#dialog_segmenthour' + segmentindex).val(segment.Hours === 0 ? "" : segment.Hours);
|
||||
$('#dialog_segmentnotes' + segmentindex).val(segment.Notes);
|
||||
$('#dialog_segmentjobsite' + segmentindex).dropdownVal(segment.JobsiteID);
|
||||
$('#dialog_segmentcost' + segmentindex).val(segment.Cost === 0 ? "" : segment.Cost);
|
||||
$('#dialog_segmenttype' + segmentindex).dropdownVal(segment.SegmentType);
|
||||
$('#dialog_segmentcompleted' + segmentindex).prop('checked', segment.Completed);
|
||||
$('#dialog_segmentcompleteddate' + segmentindex).val(segment.CompletedDateStr);
|
||||
$('#dialog_segmentcomponent' + segmentindex).dropdownVal(segment.Component);
|
||||
$('#dialog_segmentbillable' + segmentindex).prop('checked', segment.Billable);
|
||||
}
|
||||
|
||||
function OnAddSegment() {
|
||||
if (!workorderid || workorderid === "") {
|
||||
showAlert(GetTextByKey("P_WO_SAVEWORKORDERFIRST", "Please save work order first."), GetTextByKey("P_WO_ADDSEGMENT", "Add Segment"));
|
||||
return;
|
||||
}
|
||||
|
||||
$('#dialog_segmentuser').dropdownVal('');
|
||||
$('#dialog_segmentdesc').val('');
|
||||
$('#dialog_segmenthour').val('');
|
||||
$('#dialog_segmentnotes').val('');
|
||||
$('#dialog_segmentjobsite').dropdownVal('');
|
||||
$('#dialog_segmentcost').val('');
|
||||
$('#dialog_segmentcompleted').prop('checked', false);
|
||||
$('#dialog_segmentcompleteddate').val('');
|
||||
$('#dialog_segmenttype').dropdownVal('');
|
||||
$('#dialog_segmentcomponent').dropdownVal('');
|
||||
$('#dialog_segmentbillable').prop('checked', false);
|
||||
|
||||
showPopup();
|
||||
}
|
||||
|
||||
function DeleteSegment(index) {
|
||||
var segment = $('#tabsegment_' + index).data('segment');
|
||||
if (!segment)
|
||||
return;
|
||||
showConfirm(GetTextByKey("P_WO_DOYOUWANTTODELETETHESEGMENT", 'Do you want to delete the segment?'), GetTextByKey("P_WO_DELETESEGMENT", 'Delete Segment'), function () {
|
||||
worequest("DeleteSegment", segment.SegmentID, function (data) {
|
||||
GetSegmentDataSource1(function () {
|
||||
getSegments(getTotalCost);
|
||||
});
|
||||
}, function (err) {
|
||||
showAlert(GetTextByKey("P_WO_FAILEDDELETESEGMENT", 'Failed to delete this segment.'), GetTextByKey("P_WO_DELETESEGMENT", 'Delete Segment'));
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function CancelSegment(index) {
|
||||
var segment = $('#tabsegment_' + index).data('segment');
|
||||
if (!segment)
|
||||
return;
|
||||
$('#dialog_segmentuser' + index).dropdownVal(segment.UserIID);
|
||||
$('#dialog_segmentdesc' + index).val(segment.Description);
|
||||
$('#dialog_segmenthour' + index).val(segment.Hours);
|
||||
$('#dialog_segmentnotes' + index).val(segment.Notes);
|
||||
$('#dialog_segmentjobsite' + index).dropdownVal(segment.JobsiteID);
|
||||
$('#dialog_segmentcost' + index).val(segment.Cost);
|
||||
$('#dialog_segmentcompleted' + index).prop('checked', segment.Completed);
|
||||
$('#dialog_segmentcompleteddate' + index).val(segment.CompletedDateStr);
|
||||
$('#dialog_segmenttype' + index).dropdownVal(segment.SegmentType);
|
||||
$('#dialog_segmentcomponent' + index).dropdownVal(segment.Component);
|
||||
$('#dialog_segmentbillable' + index).prop('checked', segment.Billable);
|
||||
}
|
||||
|
||||
function SaveSegment(index) {
|
||||
$('#btn_savesegment' + index).attr('disabled', true);
|
||||
var segmentid = -1;
|
||||
var alerttitle = GetTextByKey("P_WO_ADDSEGMENT", "Add Segment");
|
||||
if (index !== "") {
|
||||
var alerttitle = GetTextByKey("P_WO_EDITSEGMENT", "Edit Segment");
|
||||
var segment = $('#tabsegment_' + index).data('segment');
|
||||
if (!segment)
|
||||
return;
|
||||
segmentid = segment.SegmentID;
|
||||
}
|
||||
var item = {
|
||||
'SegmentID': segmentid,
|
||||
'WorkOrderID': workorderid,
|
||||
'UserIID': $('#dialog_segmentuser' + index).dropdownVal(),
|
||||
'Description': $('#dialog_segmentdesc' + index).val(),
|
||||
'Hours': $('#dialog_segmenthour' + index).val(),
|
||||
'Notes': $('#dialog_segmentnotes' + index).val(),
|
||||
'JobsiteID': $('#dialog_segmentjobsite' + index).dropdownVal(),
|
||||
'Cost': $('#dialog_segmentcost' + index).val(),
|
||||
'Completed': $('#dialog_segmentcompleted' + index).prop('checked'),
|
||||
'CompletedDate': $('#dialog_segmentcompleteddate' + index).val(),
|
||||
'SegmentType': $('#dialog_segmenttype' + index).dropdownVal(),
|
||||
'Component': $('#dialog_segmentcomponent' + index).dropdownVal(),
|
||||
'Billable': $('#dialog_segmentbillable' + index).prop('checked')
|
||||
};
|
||||
|
||||
if (item.Description === "" || item.Description.length == 0) {
|
||||
showAlert(GetTextByKey("P_WO_DESCRIPTIONREQUIRED", 'Description is required.'), alerttitle);
|
||||
$('#btn_savesegment' + index).attr('disabled', false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.Hours !== "") {
|
||||
if (isNaN(item.Hours)) {
|
||||
showAlert(GetTextByKey("P_WO_HOURSFORMATERROR", 'Hours format error.'), alerttitle);
|
||||
$('#btn_savesegment' + index).attr('disabled', false);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (item.Hours <= 0) {
|
||||
showAlert(GetTextByKey("P_WO_HOURSMUSTBEGREATERTHAN0", 'Hours must be greater than 0.'), alerttitle);
|
||||
$('#btn_savesegment' + index).attr('disabled', false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (item.Cost !== "") {
|
||||
if (isNaN(item.Cost)) {
|
||||
showAlert(GetTextByKey("P_WO_COSTFORMATERROR", 'Cost format error.'), alerttitle);
|
||||
$('#btn_savesegment' + index).attr('disabled', false);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (item.Cost <= 0) {
|
||||
showAlert(GetTextByKey("P_WO_COSTMUSTBEGREATERTHAN0", 'Cost must be greater than 0.'), alerttitle);
|
||||
$('#btn_savesegment' + index).attr('disabled', false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (item.Cost === "")
|
||||
item.Cost = -1;
|
||||
if (item.Hours === "")
|
||||
item.Hours = -1;
|
||||
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
worequest("SaveSegment", param, function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
$('#btn_savesegment' + index).attr('disabled', false);
|
||||
showAlert(data, alerttitle);
|
||||
} else {
|
||||
$('#btn_savesegment' + index).attr('disabled', false);
|
||||
if (index !== "") {
|
||||
showAlert(GetTextByKey("P_WO_SAVSUCCESSFULLY", "Saved successfully."), alerttitle);
|
||||
}
|
||||
GetSegmentDataSource1(function () {
|
||||
getSegments(getTotalCost);
|
||||
});
|
||||
hidePopup();
|
||||
}
|
||||
}, function (err) {
|
||||
$('#btn_savesegment' + index).attr('disabled', false);
|
||||
console.log(err);
|
||||
showAlert(GetTextByKey("P_WO_FAILEDTOSAVESEGMENT", 'Failed to save segment.'), alerttitle);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function showPopup() {
|
||||
$('#popupmask').css('height', $('#dialog_workorder').height());
|
||||
$('#popupmask').show();
|
||||
$('#popupdialog').show();
|
||||
$('#popupdialog').css({
|
||||
"top": ($("#popupmask").height() - $('#popupdialog').height()) / 2,
|
||||
"left": ($("#popupmask").width() - $('#popupdialog').width()) / 2
|
||||
});
|
||||
|
||||
$('#dialog_segmentuser').focus();
|
||||
}
|
||||
|
||||
function hidePopup() {
|
||||
$('#popupmask').hide();
|
||||
$('#popupdialog').hide();
|
||||
}
|
@ -18,6 +18,13 @@
|
||||
showICContactList(false);
|
||||
});
|
||||
|
||||
$('#sendemailpopupdialog').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
|
||||
$('#sendicemailpopupdialog').dialog(function () {
|
||||
showmaskbg(false);
|
||||
});
|
||||
});
|
||||
|
||||
var machineContacts = [];
|
||||
@ -40,7 +47,7 @@ function getMachineContacts(assetid) {
|
||||
function showContactList(newopen) {
|
||||
var rows = [];
|
||||
if (machineContacts && machineContacts.length > 0) {
|
||||
var filter = $('#sendworkorder_search').val().trim().toLowerCase();
|
||||
var filter = $('#sendworkorder_search').val()?.trim()?.toLowerCase();
|
||||
var assignedto = $.trim($('#dialog_assignto').val());
|
||||
for (var i = 0; i < machineContacts.length; i++) {
|
||||
var r = machineContacts[i];
|
||||
@ -74,6 +81,7 @@ function showContactList(newopen) {
|
||||
}
|
||||
}
|
||||
}
|
||||
rows = rows.sort(function (a, b) { return ((b.Text || b.Email) ? 1 : 0) - ((a.Text || a.Email) ? 1 : 0) });
|
||||
|
||||
grid_contactdt.setData(rows);
|
||||
}
|
||||
@ -149,19 +157,16 @@ function openSendEmail() {
|
||||
}
|
||||
getMachineContacts(mid);
|
||||
|
||||
$('#sendemailpopupmask').css('height', $('#dialog_workorder').height());
|
||||
$('#sendemailpopupmask').css('min-width', $('#divcontent').width());
|
||||
$('#sendemailpopupmask').show();
|
||||
$('#sendemailpopupdialog').show();
|
||||
showmaskbg(true);
|
||||
$('#sendemailpopupdialog').css({
|
||||
"top": ($("#sendemailpopupmask").height() - $('#sendemailpopupdialog').height()) / 2,
|
||||
"left": ($("#sendemailpopupmask").width() - $('#sendemailpopupdialog').width()) / 2
|
||||
});
|
||||
'top': (document.documentElement.clientHeight - $('#sendemailpopupdialog').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#sendemailpopupdialog').width()) / 2
|
||||
}).showDialogfixed();
|
||||
}
|
||||
|
||||
|
||||
function hideSendEmailPopup() {
|
||||
$('#sendemailpopupmask').hide();
|
||||
showmaskbg(false);
|
||||
$('#sendemailpopupdialog').hide();
|
||||
}
|
||||
|
||||
@ -293,6 +298,7 @@ function showICContactList(newopen) {
|
||||
}
|
||||
}
|
||||
}
|
||||
rows = rows.sort(function (a, b) { return ((b.Text || b.Email) ? 1 : 0) - ((a.Text || a.Email) ? 1 : 0) });
|
||||
|
||||
grid_iccontactdt.setData(rows);
|
||||
}
|
||||
@ -321,19 +327,16 @@ function openSendICEmail() {
|
||||
}
|
||||
getMachineContacts(mid);
|
||||
|
||||
$('#sendicemailpopupmask').css('height', $('#dialog_workorder').height());
|
||||
$('#sendicemailpopupmask').css('min-width', $('#divcontent').width());
|
||||
$('#sendicemailpopupmask').show();
|
||||
$('#sendicemailpopupdialog').show();
|
||||
showmaskbg(true);
|
||||
$('#sendicemailpopupdialog').css({
|
||||
"top": ($("#sendicemailpopupmask").height() - $('#sendicemailpopupdialog').height()) / 2,
|
||||
"left": ($("#sendicemailpopupmask").width() - $('#sendicemailpopupdialog').width()) / 2
|
||||
});
|
||||
'top': (document.documentElement.clientHeight - $('#sendicemailpopupdialog').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#sendicemailpopupdialog').width()) / 2
|
||||
}).showDialogfixed();
|
||||
}
|
||||
|
||||
|
||||
function hideSendICEmailPopup() {
|
||||
$('#sendicemailpopupmask').hide();
|
||||
showmaskbg(false);
|
||||
$('#sendicemailpopupdialog').hide();
|
||||
}
|
||||
|
||||
@ -393,7 +396,10 @@ function onSendInternalComments() {
|
||||
internal.text = '';
|
||||
}
|
||||
hideSendICEmailPopup();
|
||||
getComments();
|
||||
if (typeof wowidgetobj != 'undefined')
|
||||
wowidgetobj.reloaddata("InternalComments");
|
||||
else
|
||||
getComments();
|
||||
|
||||
}, function (err) {
|
||||
hideSendICEmailPopup();
|
||||
|
6279
Site/Maintenance/js/workordertabitems.js
Normal file
6279
Site/Maintenance/js/workordertabitems.js
Normal file
File diff suppressed because it is too large
Load Diff
407
Site/Maintenance/js/workorderwidgets.js
Normal file
407
Site/Maintenance/js/workorderwidgets.js
Normal file
@ -0,0 +1,407 @@
|
||||
var $wowidgetselector = function (id) {
|
||||
this.containerId = id;
|
||||
this.title = GetTextByKey("P_XXX", 'Widgets');
|
||||
this.companyId = null;;
|
||||
this.forceSingle = false;
|
||||
this.exceptShareAsset = false;
|
||||
this.onOK = null;
|
||||
this.onDialogClosed = null;
|
||||
this.includechild = true;
|
||||
this.allowhidden = true;
|
||||
this.uid = null;
|
||||
};
|
||||
|
||||
(function () {
|
||||
var __proto = $wowidgetselector.prototype;
|
||||
|
||||
function initWidgetsGrid(parent) {
|
||||
var grid = new GridView(parent);
|
||||
grid.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var styleFilter = function (item) {
|
||||
if (item.Suggested) {
|
||||
return {
|
||||
//'background-color': 'yellow',
|
||||
'display': 'block',
|
||||
'margin': 0,
|
||||
'box-sizing': 'border-box',
|
||||
'padding': '0 4px',
|
||||
'height': '27px',
|
||||
'line-height': '27px',
|
||||
'overflow': 'hidden',
|
||||
'text-overflow': 'ellipsis'
|
||||
};
|
||||
}
|
||||
};
|
||||
var bgFilter = function (item) {
|
||||
if (item.Suggested)
|
||||
return 'yellow';
|
||||
};
|
||||
var columns = [];
|
||||
columns.push({
|
||||
// checkbox
|
||||
name: 'check',
|
||||
key: 'Visible',
|
||||
width: 45,
|
||||
align: 'center',
|
||||
sortable: false,
|
||||
allcheck: true,
|
||||
type: 3
|
||||
},
|
||||
{
|
||||
key: 'WidgetName',
|
||||
caption: 'Name',
|
||||
width: 300,
|
||||
styleFilter: styleFilter,
|
||||
bgFilter: bgFilter
|
||||
});
|
||||
//grid.canMultiSelect = true;
|
||||
grid.columns = columns;
|
||||
grid.init();
|
||||
|
||||
this.gridWidgets = grid;
|
||||
}
|
||||
|
||||
function createDialog() {
|
||||
var dialog = $('<div class="dialog" style="display: none; width: 550px; height: 440px">').attr('id', this.containerId);
|
||||
|
||||
var title = $('<div class="dialog-title"></div>').appendTo(dialog);
|
||||
title.append($('<span class="title"></span>').text(this.title));
|
||||
title.append('<em class="dialog-close"></em>');
|
||||
|
||||
var content = $('<div class="dialog-content"></div>').appendTo(dialog);
|
||||
|
||||
var labeldiv = $('<div style="margin: 4px 0 0 10px; line-height: 25px"></div>').appendTo(content);
|
||||
$('<span></span>').text(GetTextByKey("P_XXX", 'Which Widgets Should be Displayed?')).appendTo(labeldiv);
|
||||
|
||||
this.widgetList = $('<div style="width: 520px; height: 320px; margin: 10px 0 4px"></div>').appendTo(content);
|
||||
|
||||
var dialogFunction = $('<div class="dialog-func"></div>').appendTo(dialog);
|
||||
$('<input type="button" value="' + GetTextByKey("P_SELECTASSETS_CANCEL", "Cancel") + '" class="dialog-close" />').appendTo(dialogFunction).css("height", 'unset');
|
||||
$('<input type="button" value="' + GetTextByKey("P_SELECTASSETS_OK", "OK") + '" />').click(onOKClick.bind(this)).appendTo(dialogFunction);
|
||||
$('<div class="clear"></div>').appendTo(dialogFunction);
|
||||
|
||||
$('<div class="maskbg" style="display: none"><div class="loading_icon icon c-spin"></div></div>').appendTo(dialog);
|
||||
|
||||
// init
|
||||
initWidgetsGrid.call(this, this.widgetList);
|
||||
$(document.body).append(dialog);
|
||||
|
||||
dialog.dialog(this.onDialogClosed);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
__proto.showSelector = function (topRatio, force) {
|
||||
var dialog;
|
||||
if (force) {
|
||||
$('#' + this.containerId).remove();
|
||||
dialog = createDialog.call(this);
|
||||
} else {
|
||||
dialog = $('#' + this.containerId);
|
||||
if (!dialog.length) {
|
||||
dialog = createDialog.call(this);
|
||||
}
|
||||
}
|
||||
this.dialog = dialog;
|
||||
dialog.attr('init', '1').css({
|
||||
'top': (document.documentElement.clientHeight - dialog.height()) / (topRatio || 3),
|
||||
'left': (document.documentElement.clientWidth - dialog.width()) / 2
|
||||
}).showDialogfixed();
|
||||
this.gridWidgets.setData(widgetdata);
|
||||
onSearch.call(this);
|
||||
};
|
||||
|
||||
function worequest(method, param, callback, error) {
|
||||
var path = "";
|
||||
if (_network.root != null && _network.root.length > 0) {
|
||||
path = "Maintenance/";
|
||||
}
|
||||
_network.request(path + "WorkOrderMaintenance.aspx", -1, method, param, callback, error || function (e) {
|
||||
console.log(e);
|
||||
});
|
||||
}
|
||||
|
||||
function onSearch() {
|
||||
var maskbg = this.dialog.find('.maskbg');
|
||||
maskbg.show();
|
||||
var gridWidgets = this.gridWidgets;
|
||||
var title = this.title;
|
||||
|
||||
worequest("GetWorkOrderWidgets", "", function (data) {
|
||||
if (typeof data === 'string') {
|
||||
showAlert(GetTextByKey("P_XXX", 'Error'), title);
|
||||
maskbg.hide();
|
||||
return;
|
||||
}
|
||||
var items = [];
|
||||
for (var i = 0; i < widgetdata.length; i++) {
|
||||
var item = widgetdata[i].Values;
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
if (item.WidgetId == data[j].WidgetId) {
|
||||
item.Visible = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
items.push({ Values: item });
|
||||
}
|
||||
|
||||
gridWidgets.setData(items);
|
||||
maskbg.hide();
|
||||
}, function () {
|
||||
showAlert(GetTextByKey("P_XXXX", 'Failed to get the work order widget list.'), title);
|
||||
maskbg.hide();
|
||||
});
|
||||
}
|
||||
|
||||
function onOKClick() {
|
||||
var widgets = [];
|
||||
for (var i = 0; i < this.gridWidgets.source.length; i++) {
|
||||
widgets.push(this.gridWidgets.source[i].Values);
|
||||
}
|
||||
|
||||
var _this = this;
|
||||
var alerttitle = GetTextByKey("P_WO_XXX", "Save Widgets");
|
||||
var param = JSON.stringify(widgets);
|
||||
param = htmlencode(param);
|
||||
worequest("SaveWorkOrderWidgets", param, function (data) {
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, alerttitle);
|
||||
return;
|
||||
}
|
||||
_this.onOK && _this.onOK();
|
||||
_this.dialog.hideDialog();
|
||||
showmaskbg(false);
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
var WorkOrderWidget = function () {
|
||||
this.workorderid = null;
|
||||
this.assetid = null;
|
||||
this.workorderwidgets = null;
|
||||
this.widgets = {};
|
||||
this.popups = {};
|
||||
var _this = this;
|
||||
this.getWorkOrderWidgets = function () {
|
||||
this.workorderwidgets = null;
|
||||
var title = GetTextByKey("P_XXX", 'Widget');
|
||||
worequest("GetWorkOrderWidgets", "", function (data) {
|
||||
if (typeof data === 'string') {
|
||||
showAlert(GetTextByKey("P_XXX", 'Error'), title);
|
||||
return;
|
||||
}
|
||||
_this.workorderwidgets = data;
|
||||
_this.showWorkOrderWidgets();
|
||||
_this.getWorkOrderContacts(_this.workorderid);
|
||||
|
||||
}, function () {
|
||||
showAlert(GetTextByKey("P_XXXX", 'Failed to get the work order widget list.'), title);
|
||||
});
|
||||
}
|
||||
|
||||
this.changeWorkOrder = function (wo) {
|
||||
window.workorderid = this.workorderid = wo.Id.Value;
|
||||
window.machineid = this.assetid = wo.AssetId;
|
||||
this.wo = wo;
|
||||
if (!this.workorderwidgets) {
|
||||
this.getWorkOrderWidgets();
|
||||
} else {
|
||||
for (let w of this.workorderwidgets) {
|
||||
if (Object.prototype.hasOwnProperty.call(this.widgets, w.WidgetId)) {
|
||||
this.widgets[w.WidgetId].changewo(this.workorderid, this.assetid, wo);
|
||||
}
|
||||
}
|
||||
this.getWorkOrderContacts(this.workorderid);
|
||||
}
|
||||
}
|
||||
|
||||
this.reloadWidgets = function () {
|
||||
if (this.workorderwidgets != null) {
|
||||
for (let w of this.workorderwidgets) {
|
||||
this.popups[w.WidgetId]?.close(false);
|
||||
if (this.widgets[w.WidgetId] && typeof this.widgets[w.WidgetId].close == 'function')
|
||||
this.widgets[w.WidgetId].close();
|
||||
}
|
||||
}
|
||||
this.getWorkOrderWidgets();
|
||||
};
|
||||
|
||||
this.onmsgreceived = function (data) {
|
||||
if (this.workorderwidgets != null) {
|
||||
if (data && this.workorderid == data.Message) {
|
||||
if (data.Code == "501") {
|
||||
for (let w of this.workorderwidgets) {
|
||||
this.widgets[w.WidgetId].changewo(this.workorderid);
|
||||
}
|
||||
this.getWorkOrderContacts(this.workorderid);
|
||||
}
|
||||
else if (data.Code == "503" || data.Code == "504" || data.Code == "507") {
|
||||
this.widgets['CustomerCommunication']?.changewo(this.workorderid);
|
||||
this.getWorkOrderContacts(this.workorderid);
|
||||
}
|
||||
else if (data.Code == "505") {
|
||||
this.widgets['InternalComments']?.changewo(this.workorderid);
|
||||
}
|
||||
else if (data.Code == "506") {
|
||||
this.getWorkOrderContacts(this.workorderid);
|
||||
}
|
||||
else if (data.Code == "502")//delete
|
||||
{
|
||||
for (let w of this.workorderwidgets) {
|
||||
this.popups[w.WidgetId]?.close(false);
|
||||
if (this.widgets[w.WidgetId] && typeof this.widgets[w.WidgetId].close == 'function')
|
||||
this.widgets[w.WidgetId].close();
|
||||
}
|
||||
this.workorderwidgets = null;
|
||||
this.popups = [];
|
||||
this.widgets = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.reloaddata = function (widgetid) {
|
||||
if (this.workorderwidgets != null) {
|
||||
this.widgets[widgetid]?.changewo(this.workorderid);
|
||||
}
|
||||
this.getWorkOrderContacts(this.workorderid);
|
||||
};
|
||||
|
||||
this.showWorkOrderWidgets = function () {
|
||||
this.defX = 0;
|
||||
this.defY = 0;
|
||||
this.currentZIndex = 200 + this.workorderwidgets.length;
|
||||
for (let w of this.workorderwidgets) {
|
||||
this.createWidgetDialog(w);
|
||||
}
|
||||
}
|
||||
|
||||
this.saveWorkOrderWidgets = function (widget, layout) {
|
||||
widget.Layout = JSON.stringify(layout);
|
||||
|
||||
var title = GetTextByKey("P_XXX", 'Widget');
|
||||
worequest('SaveWorkOrderWidgetLayout', JSON.stringify(widget), function (data) {
|
||||
if (data === 'OK') {
|
||||
return;
|
||||
}
|
||||
showAlert(data, title);
|
||||
}, function () {
|
||||
showAlert(GetTextByKey("P_XXXX", 'Failed to save the work order widget layout.'), title);
|
||||
});
|
||||
};
|
||||
|
||||
this.getWorkOrderContacts = function (woid) {
|
||||
worequest('GetWorkOrderContacts', woid, function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey('P_CUSTOMERRECORD', "Customer Record"));
|
||||
return;
|
||||
}
|
||||
if (_this.workorderwidgets != null) {
|
||||
for (let w of _this.workorderwidgets) {
|
||||
if (_this.widgets[w.WidgetId] && typeof _this.widgets[w.WidgetId].updatecontact == 'function')
|
||||
_this.widgets[w.WidgetId].updatecontact(data);
|
||||
}
|
||||
}
|
||||
}, function () {
|
||||
});
|
||||
};
|
||||
|
||||
this.createWidgetDialog = function (widget) {
|
||||
const ui = window['lib-ui'];
|
||||
|
||||
let layout = widget.Layout;
|
||||
if (!layout || layout === '') {
|
||||
let x = this.defX;
|
||||
let y = this.defY;
|
||||
let width = $(document.body).width();
|
||||
let height = $(document.body).height();
|
||||
let left = 20 + 320 * x;
|
||||
if (left + 300 > width) {
|
||||
x = 0;
|
||||
left = 20;
|
||||
y++;
|
||||
this.defY = y;
|
||||
}
|
||||
let top = height - (y == 0 ? 420 : 320 * (y + 1));
|
||||
x++;
|
||||
this.defX = x;
|
||||
layout = { left, top, width: 300, height: 400 };
|
||||
} else {
|
||||
layout = JSON.parse(widget.Layout);
|
||||
}
|
||||
let zIndex = this.currentZIndex--;
|
||||
|
||||
var container = ui.createElement('div', 'class-content');
|
||||
var _this = this;
|
||||
const popup = new ui.Popup({
|
||||
title: widgetdata.find(function (v) { return v.Values.WidgetId == widget.WidgetId })?.Values?.WidgetName,
|
||||
content: container,
|
||||
mask: false,
|
||||
// movable: false,
|
||||
resizable: true,
|
||||
collapsable: true,
|
||||
zIndex,
|
||||
changeZIndex: true,
|
||||
minWidth: 210,
|
||||
minHeight: 200,
|
||||
buttons: [
|
||||
//{
|
||||
// text: 'Loading', trigger: p => {
|
||||
// p.loading = true;
|
||||
// setTimeout(() => p.loading = false, 1000);
|
||||
// return false;
|
||||
// }
|
||||
//},
|
||||
//{ text: 'OK' }
|
||||
],
|
||||
onMoveEnded: function () { _this.saveWorkOrderWidgets(widget, popup.rect) },
|
||||
onResizeEnded: function () { _this.saveWorkOrderWidgets(widget, popup.rect) }
|
||||
});
|
||||
popup.show();
|
||||
popup.rect = layout;
|
||||
this.popups[widget.WidgetId] = popup;
|
||||
|
||||
let options = {
|
||||
parent: $(container),
|
||||
canExport: canExport,
|
||||
showloading: function (flag) {
|
||||
popup.loading = flag;
|
||||
}
|
||||
};
|
||||
let content;
|
||||
switch (widget.WidgetId) {
|
||||
case 'CustomerCommunication':
|
||||
content = new $wocommunication(options);
|
||||
let checkLink = ui.createCheckbox({
|
||||
className: 'check-status-link',
|
||||
enabled: !content.customer.readonly,
|
||||
checkedNode: ui.createIcon('fa-regular', 'link'),
|
||||
uncheckedNode: ui.createIcon('fa-regular', 'unlink'),
|
||||
onchange: function () {
|
||||
content.customer.statusLink = this.checked;
|
||||
ui.setTooltip(checkLink, this.checked ?
|
||||
GetTextByKey('P_WO_XXXXXX', 'Status Link Included') :
|
||||
GetTextByKey('P_WO_XXXXXX', 'Status Link Excluded'));
|
||||
}
|
||||
});
|
||||
ui.setTooltip(checkLink, GetTextByKey('P_WO_XXXXXX', 'Status Link Excluded'));
|
||||
$(checkLink).insertAfter(options.parent.parents('.ui-popup-container').find('.ui-popup-header>.ui-popup-header-title'));
|
||||
break;
|
||||
case 'InternalComments': content = new $wointernal(options); break;
|
||||
case 'Alerts': content = new $woalert(options); break;
|
||||
case 'Segments': content = new $wosegment(options); break;
|
||||
case 'Attachments': content = new $woattachment(options); break;
|
||||
case 'Inspections': content = new $woinspection(options); break;
|
||||
case 'Estimates': content = new $woestimate(options); break;
|
||||
case 'Invoices': content = new $woinvoice(options); break;
|
||||
}
|
||||
if (content != null) {
|
||||
this.widgets[widget.WidgetId] = content;
|
||||
content.changewo(this.workorderid, this.assetid, this.wo);
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user