add site
This commit is contained in:
307
Site/Maintenance/js/addcustomerrecord.js
Normal file
307
Site/Maintenance/js/addcustomerrecord.js
Normal file
@ -0,0 +1,307 @@
|
||||
|
||||
var dialogAUAssets;
|
||||
$(function () {
|
||||
InitGridSelectedMachines();
|
||||
dialogAUAssets = new $assetselector('dialog_machines');
|
||||
dialogAUAssets.onDialogClosed = function () {
|
||||
showmaskbg(false);
|
||||
};
|
||||
dialogAUAssets.onOK = function (source) {
|
||||
var items = [];
|
||||
var ids = [];
|
||||
for (var i = 0; i < source.length; i++) {
|
||||
var it = source[i].Values;
|
||||
if (it.Selected) {
|
||||
items.push({
|
||||
Values: {
|
||||
ID: it.Id,
|
||||
VIN: it.VIN,
|
||||
Name: it.Name,
|
||||
MakeName: it.MakeName,
|
||||
ModelName: it.ModelName,
|
||||
TypeName: it.TypeName
|
||||
}
|
||||
});
|
||||
ids.push(it.Id);
|
||||
}
|
||||
}
|
||||
grid_dtassets.setData(grid_dtassets.innerSource.concat(items));
|
||||
if (ids.length > 0)
|
||||
assignAssets(ids);
|
||||
$('#mask_bg').hide();
|
||||
};
|
||||
});
|
||||
|
||||
function getAssignData() {
|
||||
_selectedMachines = [];
|
||||
|
||||
grid_dtassets.setData([]);
|
||||
if (custid && custid != "") {
|
||||
GetSelectedAssets();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//**************************************Asset(s)****************************************************//
|
||||
var grid_dtassets;
|
||||
function InitGridSelectedMachines() {
|
||||
grid_dtassets = new GridView('#selectedmachinelist');
|
||||
grid_dtassets.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'VIN', caption: GetTextByKey("P_UM_SN", "SN"), valueIndex: 'VIN', css: { 'width': 200, 'text-align': 'left' } },
|
||||
{ name: 'Name', caption: GetTextByKey("P_UM_NAME", "Name"), valueIndex: 'Name', css: { 'width': 200, 'text-align': 'left' } },
|
||||
{ name: 'MakeName', caption: GetTextByKey("P_UM_MAKE", "Make"), valueIndex: 'MakeName', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'ModelName', caption: GetTextByKey("P_UM_MODEL", "Model"), valueIndex: 'ModelName', css: { 'width': 150, 'text-align': 'left' } },
|
||||
{ name: 'TypeName', caption: GetTextByKey("P_UM_ASSETSTYPE", "Type"), valueIndex: 'TypeName', css: { 'width': 170, 'text-align': 'left' } }
|
||||
];
|
||||
var columns = [
|
||||
{
|
||||
// checkbox
|
||||
name: 'check',
|
||||
key: 'selected',
|
||||
width: 30,
|
||||
align: 'center',
|
||||
sortable: false,
|
||||
allcheck: true,
|
||||
type: 3
|
||||
}
|
||||
];
|
||||
// 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.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
col.allowFilter = col.name === 'TypeName';
|
||||
col.styleFilter = function (item) {
|
||||
if (item.Highlight)
|
||||
return { 'background-color': 'yellow' };
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
|
||||
grid_dtassets.canMultiSelect = true;
|
||||
grid_dtassets.columns = columns;
|
||||
grid_dtassets.init();
|
||||
|
||||
grid_dtassets.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_dtassets.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showSelectedMachine(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
|
||||
grid_dtassets.setData(rows);
|
||||
}
|
||||
|
||||
// 获取已选中的Assets
|
||||
function GetSelectedAssets() {
|
||||
_selectedMachines = [];
|
||||
$("#dialogmask").show();
|
||||
crrequest('GetAssignedMachines', custid, function (data) {
|
||||
if (typeof data === "string") {
|
||||
showAlert(data, GetTextByKey("P_UM_ASSETASSIGNMENT", "Asset Assignment"));
|
||||
return;
|
||||
}
|
||||
_selectedMachines = data;
|
||||
showSelectedMachine(_selectedMachines);
|
||||
$("#dialogmask").hide();
|
||||
}, function (e) {
|
||||
$("#dialogmask").hide();
|
||||
});
|
||||
}
|
||||
|
||||
function assignAssets(ids, next) {
|
||||
var p = [
|
||||
custid,
|
||||
JSON.stringify(ids)
|
||||
];
|
||||
|
||||
$("#dialogmask").show();
|
||||
crrequest('AssignMachines', htmlencode(JSON.stringify(p)), function (r) {
|
||||
$("#dialogmask").hide();
|
||||
if (r !== 'OK') {
|
||||
showAlert(r, GetTextByKey("P_UM_ASSETASSIGNMENT", 'Asset Assignment'));
|
||||
}
|
||||
if (next)
|
||||
next();
|
||||
}, function () {
|
||||
$("#dialogmask").hide();
|
||||
});
|
||||
}
|
||||
|
||||
function OnAssetAdd() {
|
||||
showmaskbg(true);
|
||||
dialogAUAssets.exceptSource = grid_dtassets.innerSource.map(function (s) {
|
||||
return s.Values.ID;
|
||||
});
|
||||
dialogAUAssets.showSelector();
|
||||
$('#mask_bg').css('height', '100%');
|
||||
}
|
||||
|
||||
function OnMachineDelete() {
|
||||
showConfirm(GetTextByKey("P_UM_DELETESELECTEDASSET", 'Are you sure you want to delete these selected assets?'), GetTextByKey("P_UM_ASSETASSIGNMENT", "Asset Assignment"), function () {
|
||||
var ids = [];
|
||||
for (var i = grid_dtassets.innerSource.length - 1; i >= 0; i--) {
|
||||
var s = grid_dtassets.innerSource[i].Values;
|
||||
if (s.selected) {
|
||||
grid_dtassets.innerSource.splice(i, 1);
|
||||
ids.push(s.ID);
|
||||
}
|
||||
}
|
||||
if (grid_dtassets.source != null) {
|
||||
for (var j = grid_dtassets.source.length - 1; j >= 0; j--) {
|
||||
var l = grid_dtassets.source[j].Values;
|
||||
if (l.selected) {
|
||||
grid_dtassets.source.splice(j, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
grid_dtassets.reset();
|
||||
|
||||
var params = [
|
||||
custid,
|
||||
JSON.stringify(ids)
|
||||
];
|
||||
$("#dialogmask").show();
|
||||
crrequest('RemoveAssignedMachines', htmlencode(JSON.stringify(params)), function (r) {
|
||||
$("#dialogmask").hide();
|
||||
if (r !== 'OK') {
|
||||
showAlert(r, GetTextByKey("P_UM_ASSETASSIGNMENT", "Asset Assignment"));
|
||||
}
|
||||
}, function () {
|
||||
$("#dialogmask").show();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//***********************************Begin Salesperson********************************************//
|
||||
function showsalespersonmask(flag) {
|
||||
if (flag) {
|
||||
$('#salespersonmask').fadeIn(100);
|
||||
} else {
|
||||
$('#salespersonmask').fadeOut(100);
|
||||
}
|
||||
}
|
||||
|
||||
var grid_dtsp;
|
||||
function InitSPGridData() {
|
||||
grid_dtsp = new GridView('#salespersonlist');
|
||||
grid_dtsp.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'ID', caption: GetTextByKey("P_UM_USERIDOREMAIL", "User ID/Email"), valueIndex: 'ID', css: { 'width': 180, 'text-align': 'left' } },
|
||||
{ name: 'DisplayName', caption: GetTextByKey("P_UM_USERNAME", "User Name"), valueIndex: 'DisplayName', css: { 'width': 200, 'text-align': 'left' } },
|
||||
{ name: 'FOB', caption: GetTextByKey("P_UM_EMPLOYEEIDORFOB", "Employee ID or FOB"), valueIndex: 'FOB', css: { 'width': 200, '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.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
col.allowFilter = list_columns[hd].allowFilter;
|
||||
columns.push(col);
|
||||
}
|
||||
grid_dtsp.canMultiSelect = false;
|
||||
grid_dtsp.columns = columns;
|
||||
grid_dtsp.init();
|
||||
}
|
||||
|
||||
function showSalespersons(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_dtsp.setData(rows);
|
||||
}
|
||||
|
||||
function GetSalespersons() {
|
||||
var searchtxt = $.trim($('#sp_searchinputtxt').val());
|
||||
crrequest('GetSalespersons', searchtxt, function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey('P_CUSTOMERRECORD', "Customer Record"));
|
||||
showcontatcmask(false);
|
||||
return;
|
||||
}
|
||||
showSalespersons(data);
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
function onOpenSalesperson() {
|
||||
var alerttitle = GetTextByKey("P_CR_SELECTSALESPERSON", 'Select Salesperson');
|
||||
$('#sp_searchinputtxt').val('');
|
||||
GetSalespersons();
|
||||
$('#dialog_salesperson .dialog-title span.title').text(alerttitle);
|
||||
$('#mask_bg').show();
|
||||
$('#dialog_salesperson')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_salesperson').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_salesperson').width()) / 2
|
||||
}).showDialogfixed();
|
||||
|
||||
setTimeout(function () {
|
||||
grid_dtsp && grid_dtsp.resize();
|
||||
});
|
||||
}
|
||||
|
||||
function searchSalespersonEnter(e) {
|
||||
if (e.keyCode == 13 || e.keyCode == 9) {
|
||||
GetSalespersons();
|
||||
}
|
||||
}
|
||||
|
||||
function onSetSalesperson() {
|
||||
var index = grid_dtsp.selectedIndex;
|
||||
if (index < 0) {
|
||||
$('#dialog_salesperson').hideDialog();
|
||||
showmaskbg(false);
|
||||
return;
|
||||
}
|
||||
var salesperson = grid_dtsp.source[index].Values;
|
||||
$('#dialog_salespersoncode').data('spiid', salesperson.IID);
|
||||
$('#dialog_salespersoncode').val(salesperson.FOB);
|
||||
$('#dialog_salespersonname').val(salesperson.DisplayName);
|
||||
|
||||
$('#dialog_salesperson').hideDialog();
|
||||
showmaskbg(false);
|
||||
}
|
||||
|
||||
function onDeleteSalesperson() {
|
||||
$('#dialog_salespersoncode').data('spiid', '');
|
||||
$('#dialog_salespersoncode').val('');
|
||||
$('#dialog_salespersonname').val('');
|
||||
}
|
||||
|
||||
//***********************************End Salesperson********************************************//
|
403
Site/Maintenance/js/addsurveytemplate.js
Normal file
403
Site/Maintenance/js/addsurveytemplate.js
Normal file
@ -0,0 +1,403 @@
|
||||
if (typeof ($wosurvey) !== "function") {
|
||||
$wosurvey = function (c) {
|
||||
var _this = this;
|
||||
this.content = c;
|
||||
this.questions = [];
|
||||
this.questionmodules = [];
|
||||
|
||||
this.updateQuestions = function (qs) {
|
||||
this.questions = qs;
|
||||
if (!this.questions) {
|
||||
return;
|
||||
}
|
||||
this.questionmodules = [];
|
||||
this.content.children('.question-holder').remove();
|
||||
for (var i = 0; i < this.questions.length; i++) {
|
||||
this.addQuestionModule(this.questions[i]);
|
||||
}
|
||||
};
|
||||
|
||||
this.addQuestionModule = function (q) {
|
||||
var qmodule = new $wosurveyquestion(_this, q, _this.questions.indexOf(q));
|
||||
qmodule.ondelete = function (qm) {//qm:question module
|
||||
_this.questions.splice(_this.questions.indexOf(qm.question), 1);
|
||||
_this.questionmodules.splice(_this.questionmodules.indexOf(qm), 1);
|
||||
}
|
||||
if (_this.questions.indexOf(q) < 0)
|
||||
_this.questions.push(q);
|
||||
_this.questionmodules.push(qmodule);
|
||||
_this.content.append(qmodule.createContent());
|
||||
};
|
||||
|
||||
this.getQuestionInputs = function () {
|
||||
this.questions = [];
|
||||
if (this.questionmodules.length > 0) {
|
||||
for (var i = 0; i < this.questionmodules.length; i++) {
|
||||
var q = this.questionmodules[i].getQuestionValue();
|
||||
if (!q) return false;
|
||||
this.questions.push(q);
|
||||
}
|
||||
}
|
||||
return this.questions;
|
||||
};
|
||||
}
|
||||
|
||||
$wosurveyquestion = function (survey, q, index) {
|
||||
var wosurvey = survey;
|
||||
var _this = this;
|
||||
this.question = q;
|
||||
this.index = index;
|
||||
this.ondelete = null;
|
||||
this.txtName = null;
|
||||
this.txttitle = null;
|
||||
this.txttitletips = null;
|
||||
this.txtNotes = null;
|
||||
this.selQuestionType = null;
|
||||
this.chkMultipleSelect = null;
|
||||
this.chkisrequired = null;
|
||||
this.additemspan = null;
|
||||
this.multipleselectdiv = null;
|
||||
this.optionmodules = [];
|
||||
|
||||
this.holder = null;
|
||||
|
||||
this.createContent = function () {
|
||||
var holder = $('<div class="questionitem"></div>');
|
||||
_this.holder = holder;
|
||||
var qholder = $('<div class="question-holder"></div>');//question holder
|
||||
holder.append(qholder);
|
||||
_this.questionholder = qholder;
|
||||
var oholder = $('<div style="display:none;"></div>');//option holder
|
||||
holder.append(oholder);
|
||||
_this.optionholder = oholder;
|
||||
|
||||
if (this.index % 2 == 1)
|
||||
qholder.addClass('holder-even');
|
||||
var drag = $('<div class="question-icon" style="width:30px;"><em class="spanbtn iconmove rowdrag"></em></div>');
|
||||
qholder.append(drag);
|
||||
|
||||
drag.attr('draggable', true);
|
||||
holder.bind('dragstart', function (e) {
|
||||
draggingobj = _this;
|
||||
});
|
||||
holder.bind('dragend', function (e) {
|
||||
draggingobj = null;
|
||||
});
|
||||
holder.bind('dragover', function (e) {
|
||||
e.originalEvent.preventDefault()
|
||||
});
|
||||
holder.bind('drop', function (e) {
|
||||
if (!draggingobj || _this === draggingobj)
|
||||
return;
|
||||
var t = $(this);
|
||||
var after = e.originalEvent.clientY > t.offset().top + t.height() / 2;
|
||||
if (after)
|
||||
t.after(draggingobj.holder);
|
||||
else
|
||||
t.before(draggingobj.holder);
|
||||
|
||||
var index = wosurvey.questions.indexOf(draggingobj.question)
|
||||
if (index >= 0) {
|
||||
wosurvey.questions.splice(index, 1);
|
||||
wosurvey.questionmodules.splice(index, 1);
|
||||
}
|
||||
|
||||
var tindex = 0;
|
||||
if (_this.question) {
|
||||
tindex = wosurvey.questions.indexOf(_this.question);
|
||||
if (after)
|
||||
tindex = tindex + 1;
|
||||
}
|
||||
if (tindex >= 0) {
|
||||
wosurvey.questions.splice(tindex, 0, draggingobj.question);
|
||||
wosurvey.questionmodules.splice(tindex, 0, draggingobj);
|
||||
}
|
||||
});
|
||||
|
||||
_this.txtName = $('<input type="text" class="question-input" maxlength="20" autocomplete="off" style="width:126px;margin-left:5px;" />');
|
||||
qholder.append($('<div class="question-cell question-name" style="width: 160px;"></div>').append('<span class="redasterisk">*</span>').append(this.txtName));
|
||||
|
||||
_this.txttitle = $('<input type="text" class="question-input" maxlength="200" autocomplete="off" style="width:246px;margin-left:5px;" />');
|
||||
qholder.append($('<div class="question-cell question-display" style="width: 300px;"></div>').append('<span class="redasterisk">*</span>').append(this.txttitle));
|
||||
|
||||
_this.txttitletips = $('<input type="text" class="question-input" maxlength="500" autocomplete="off" style="width:246px;margin-left:5px;" />');
|
||||
qholder.append($('<div class="question-cell question-display" style="width: 300px;"></div>').append(this.txttitletips));
|
||||
|
||||
|
||||
//this.selQuestionType在createQuestionTypeCtrl中赋值
|
||||
var qt = createQuestionTypeCtrl().css('width', 140);
|
||||
qholder.append($('<div class="question-cell question-type" style="width: 240px"></div>').append(qt));
|
||||
createOptions();
|
||||
|
||||
_this.chkisrequired = $('<input type="checkbox"/>');
|
||||
qholder.append($('<div class="question-cell question-display" style="width: 100px;"></div>').append(this.chkisrequired));
|
||||
|
||||
_this.txtNotes = $('<textarea class="question-input" maxlength="500" autocomplete="off" style="width:94%;margin-top:5px;"></textarea>');
|
||||
qholder.append($('<div class="question-cell question-notes" style="flex-grow: 1;white-space:normal;"></div>').append(this.txtNotes));
|
||||
var funcs = $('<div class="question-cell question-func" style="width: 90px;text-align:right;padding-right:20px;"></div>');
|
||||
qholder.append(funcs);
|
||||
|
||||
if (!surveytempreadonly) {
|
||||
funcs.append($('<em class="spanbtn icondelete"></em>').click(function () {
|
||||
showConfirm(GetTextByKey("P_IPT_AREYOUSUREYOUWANTTODELETETHISQUESTION", 'Are you sure you want to delete this question?'), GetTextByKey("P_IPT_DELETEQUESTION", 'Delete Question'), function () {
|
||||
if (_this.ondelete) {
|
||||
_this.holder.remove();
|
||||
_this.ondelete(_this);
|
||||
}
|
||||
});
|
||||
}).attr('title', GetTextByKey("P_IPT_DELETEQUESTION", 'Delete Question')));
|
||||
}
|
||||
|
||||
|
||||
function createQuestionTypeCtrl() {
|
||||
var tb = $('<table style="line-height:unset;"></table>');
|
||||
var tr = $('<tr></tr>');
|
||||
tb.append(tr);
|
||||
var td = $('<td></td>');
|
||||
tr.append(td);
|
||||
_this.selQuestionType = createQuestionType().addClass('question-input');
|
||||
td.append(_this.selQuestionType);
|
||||
_this.selQuestionType.change(function () {
|
||||
_this.questionTypeChange();
|
||||
});
|
||||
|
||||
td = $('<td></td>');
|
||||
tr.append(td);
|
||||
_this.btnoption = $('<span class="spanbtn iconangleleft" style="font-size:18px;"></span>');
|
||||
td.append(_this.btnoption);
|
||||
_this.btnoption.click(function () {
|
||||
var icon = $(this);
|
||||
var type = _this.selQuestionType.val();
|
||||
if (icon.hasClass('iconangleleft')) {
|
||||
icon.removeClass('iconangleleft').addClass('iconangledown');
|
||||
_this.optionholder.show();
|
||||
if (type === "2")
|
||||
_this.multipleselectdiv.show();
|
||||
else
|
||||
_this.multipleselectdiv.hide();
|
||||
}
|
||||
else {
|
||||
icon.removeClass('iconangledown').addClass('iconangleleft');
|
||||
_this.optionholder.hide();
|
||||
}
|
||||
});
|
||||
|
||||
if (_this.question && (_this.question.QuestionType === "2" || _this.question.QuestionType === "4"))
|
||||
_this.btnoption.show();
|
||||
else
|
||||
_this.btnoption.hide();
|
||||
return tb;
|
||||
}
|
||||
|
||||
function createOptions() {
|
||||
_this.optiondiv = $('<div style="width:500px;margin-left:540px;padding-left:5px;padding-bottom:5px; border: 1px solid #a8a8a8;line-height:32px;"></div>');
|
||||
_this.optionholder.append(_this.optiondiv);
|
||||
_this.multipleselectdiv = $('<span style="margin-left:50px;"><label>' + GetTextByKey("P_IPT_MULTIPLESELECT_COLON", "Multiple Select:") + '</label></span>');
|
||||
_this.chkMultipleSelect = $('<input type="checkbox" style="margin-left:10px;" />');
|
||||
_this.multipleselectdiv.append(_this.chkMultipleSelect);
|
||||
_this.optiondiv.append('<span style="font-weight:bold;margin-right:5px;">' + GetTextByKey("P_IPT_OPTIONS", "Options") + '</span>');
|
||||
if (!surveytempreadonly) {
|
||||
_this.additemspan = $('<span class="sbutton iconadd">' + GetTextByKey("P_IPT_ADDITEM", "Add Item") + '</span>').click(function () {
|
||||
_this.addOption();
|
||||
});
|
||||
_this.optiondiv.append(_this.additemspan);
|
||||
}
|
||||
_this.optiondiv.append(_this.multipleselectdiv);
|
||||
}
|
||||
|
||||
function createQuestionType() {
|
||||
var items = [];
|
||||
items.push({ 'Key': 0, "Value": GetTextByKey("P_WOS_SINGLELINETEXT", "Single Line Text") });
|
||||
items.push({ 'Key': 1, "Value": GetTextByKey("P_WOS_MULTIPLELINETEXT", "Multiple Line Text") });
|
||||
items.push({ 'Key': 2, "Value": GetTextByKey("P_WOS_CHOOSE", "Choose") });
|
||||
items.push({ 'Key': 3, "Value": GetTextByKey("P_WOS_YESORNO", "Yes Or No") });
|
||||
items.push({ 'Key': 4, "Value": GetTextByKey("P_WOS_SCORE", "Score") });
|
||||
var sel = $('<select style="width:140px; height:26px;"></select>');
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var item = items[i];
|
||||
sel.append('<option value="' + item.Key + '">' + item.Value + '</option>');
|
||||
}
|
||||
return sel;
|
||||
}
|
||||
|
||||
this.questionTypeChange = function () {
|
||||
var _this = this;
|
||||
_this.optionmodules = [];
|
||||
_this.optionholder.find('table').remove();
|
||||
var type = _this.selQuestionType.val();
|
||||
//questiontype = type;
|
||||
if (type === "2" || type === "4") {
|
||||
_this.btnoption.show();
|
||||
_this.optionholder.find('.sbutton').show();
|
||||
if (_this.btnoption.hasClass('iconangledown')) {
|
||||
if (type === "2")
|
||||
_this.multipleselectdiv.show();
|
||||
else
|
||||
_this.multipleselectdiv.hide();
|
||||
|
||||
_this.optionholder.show();
|
||||
}
|
||||
|
||||
if (_this.question) {
|
||||
for (var i = 0; i < _this.question.AvailableItems.length; i++) {
|
||||
_this.addOption(_this.question.AvailableItems[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
_this.btnoption.hide();
|
||||
_this.optionholder.hide()
|
||||
}
|
||||
}
|
||||
|
||||
this.addOption = function (item) {
|
||||
var _this = this;
|
||||
var opcontent = _this.createOptionContent(item);
|
||||
_this.optionmodules.push(opcontent);
|
||||
_this.optiondiv.append(opcontent);
|
||||
}
|
||||
|
||||
this.createOptionContent = function (item) {
|
||||
var tb = $('<table style="border: 1px solid #a8a8a8; margin-top:2px;line-height:32px;"></table>');
|
||||
var tr = $('<tr></tr>');
|
||||
tb.append(tr);
|
||||
var opkey = $('<input type="text" class="form-control" maxlength="20" style="width:100px;margin-left:5px;"/>');
|
||||
var td = $('<td style="padding-left:10px;">' + GetTextByKey('P_WOS_VALUE', 'Value: ') + '</td>');
|
||||
if (_this.selQuestionType.val() === "4") {
|
||||
td.text(GetTextByKey('P_WOS_SCORE_COLON', 'Score: '));
|
||||
}
|
||||
td.append('<span class="redasterisk">*</span>');
|
||||
td.append(opkey);
|
||||
tr.append(td);
|
||||
|
||||
var optext = $('<input type="text" class="form-control" maxlength="100" style="width:180px;margin-left:5px;"/>');
|
||||
td = $('<td>' + GetTextByKey('P_WOS_DISPLAYTEXT_COLON', 'Display Text: ') + '<span class="redasterisk">*</span></td>');
|
||||
td.append(optext);
|
||||
tr.append(td);
|
||||
|
||||
td = $('<td style="width:30px;"></td>');
|
||||
tr.append(td);
|
||||
if (!surveytempreadonly) {
|
||||
var deleteoptionbtn = $('<em class="spanbtn icondelete"></em>').data('tb', tb);
|
||||
td.append(deleteoptionbtn.click(function () {
|
||||
this.parentElement.parentElement.parentElement.remove();
|
||||
var d_tb = $(this).data('tb');
|
||||
_this.optionmodules.splice(_this.optionmodules.indexOf(d_tb), 1);
|
||||
}));
|
||||
}
|
||||
|
||||
tb.getOptionValue = function () {
|
||||
return {
|
||||
Key: opkey.val(),
|
||||
Value: optext.val()
|
||||
}
|
||||
}
|
||||
tb.setOptionValue = function (key, text) {
|
||||
opkey.val(key);
|
||||
optext.val(text);
|
||||
}
|
||||
tb.setDisabled = function () {
|
||||
opkey.prop('disabled', true);
|
||||
optext.prop('disabled', true);
|
||||
}
|
||||
if (item)
|
||||
tb.setOptionValue(item.Key, item.Value);
|
||||
|
||||
if (surveytempreadonly)
|
||||
tb.setDisabled();
|
||||
|
||||
return tb;
|
||||
}
|
||||
|
||||
this.updateContent = function (question) {
|
||||
if (this.question != question) {
|
||||
this.question = question;
|
||||
}
|
||||
|
||||
this.txtName.val(question.Name);
|
||||
this.txttitle.val(question.Title);
|
||||
this.txttitletips.val(question.TitleTips);
|
||||
this.selQuestionType.val(question.QuestionType);
|
||||
this.questionTypeChange();
|
||||
this.txtNotes.val(question.Notes);
|
||||
this.chkMultipleSelect.attr('checked', question.MultipleSelect);
|
||||
this.chkisrequired.attr('checked', question.IsRequired);
|
||||
};
|
||||
|
||||
this.getQuestionValue = function () {
|
||||
var question = this.question;
|
||||
question.Name = this.txtName.val();
|
||||
question.Title = this.txttitle.val();
|
||||
question.TitleTips = this.txttitletips.val();
|
||||
question.QuestionType = this.selQuestionType.val();
|
||||
question.Notes = this.txtNotes.val();
|
||||
question.IsRequired = this.chkisrequired.prop('checked');
|
||||
if (question.QuestionType === "2")
|
||||
question.MultipleSelect = this.chkMultipleSelect.prop('checked');
|
||||
else
|
||||
question.MultipleSelect = false;
|
||||
|
||||
question.AvailableItems = [];
|
||||
var alerttitle = GetTextByKey("P_WOS_QUESTION", "Question");
|
||||
if (!question.Name || question.Name.length == 0) {
|
||||
showAlert(GetTextByKey("P_WOS_QUESTIONNAMENOTBEEMPTY", 'Question Name cannot be empty.'), alerttitle);
|
||||
return false;
|
||||
}
|
||||
if (!question.Title || question.Title.length == 0) {
|
||||
showAlert(GetTextByKey("P_WOS_QUESTIONTITLENOTBEEMPTY", 'Question Title cannot be empty.'), alerttitle);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.optionmodules.length > 0) {
|
||||
for (var i = 0; i < this.optionmodules.length; i++) {
|
||||
var selectitem = this.optionmodules[i].getOptionValue();
|
||||
|
||||
if (!selectitem.Key || selectitem.Key.length == 0) {
|
||||
showAlert(GetTextByKey("P_WOS_VALUENOTBEEMPTY", 'Value cannot be empty.'), alerttitle);
|
||||
return false;
|
||||
}
|
||||
if (question.QuestionType === "4") {
|
||||
if (!IsPositiveInteger1.test(selectitem.Key)) {
|
||||
showAlert(GetTextByKey("P_WOS_SCOREISNOTAVALIDINTEGER", 'Score is not a valid integer.'), alerttitle);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!selectitem.Value || selectitem.Value.length == 0) {
|
||||
showAlert(GetTextByKey("P_WOS_DISPLAYNAMENOTBEEMPTY", 'Display Name cannot be empty.'), alerttitle);
|
||||
return false;
|
||||
}
|
||||
question.AvailableItems.push(selectitem)
|
||||
}
|
||||
}
|
||||
return question;
|
||||
};
|
||||
|
||||
|
||||
_this.updateContent(_this.question);
|
||||
if (surveytempreadonly)
|
||||
setDisabled();
|
||||
|
||||
function setDisabled() {
|
||||
_this.txtName.prop('disabled', true);
|
||||
_this.txttitle.prop('disabled', true);
|
||||
_this.txttitletips.prop('disabled', true);
|
||||
_this.selQuestionType.prop('disabled', true);
|
||||
_this.txtNotes.prop('disabled', true);
|
||||
_this.chkMultipleSelect.prop('disabled', true);
|
||||
_this.chkisrequired.prop('disabled', true);
|
||||
}
|
||||
return holder;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var IsPositiveInteger1 = /^[1-9]\d*$/;
|
||||
|
||||
function onAddQuestion() {
|
||||
if (!wosurveyCtrl) {
|
||||
wosurveyCtrl = new $wosurvey($('#questionlist'));
|
||||
}
|
||||
var question = { QuestionType: '0', SeverityLevel: 0, AvailableItems: [] };
|
||||
wosurveyCtrl.addQuestionModule(question);
|
||||
}
|
3557
Site/Maintenance/js/addworkorder.js
Normal file
3557
Site/Maintenance/js/addworkorder.js
Normal file
File diff suppressed because it is too large
Load Diff
47
Site/Maintenance/js/controls.js
vendored
Normal file
47
Site/Maintenance/js/controls.js
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/// <reference path="../../js/jquery-3.6.0.min.js" />
|
||||
/// <reference path="../../js/utility.js" />
|
||||
|
||||
// controls
|
||||
$.fn.number = function () {
|
||||
return this.each(function () {
|
||||
function changed(e)
|
||||
{
|
||||
//if (this.className.indexOf('inp_priority') >= 0 && this.value == 0) {
|
||||
// this.value = '';
|
||||
//}
|
||||
//else {
|
||||
var m = this.value.match(/[0-9]+/g);
|
||||
if (!m) {
|
||||
this.value = '1';
|
||||
} else {
|
||||
this.value = m.join('');
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
function keydown(e) {
|
||||
if (e.altKey || e.ctrlKey) {
|
||||
return true;
|
||||
}
|
||||
switch (e.keyCode) {
|
||||
case 8: // backspace
|
||||
case 9: // tab
|
||||
case 46: // del
|
||||
return true;
|
||||
}
|
||||
if ($(this).hasClass('inp_priority') && (e.keyCode == 96 || e.keyCode == 48) && $(this).val() == '')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//if ('0123456789'.indexOf(e.key) >= 0) {
|
||||
// return true;
|
||||
//}
|
||||
if ((e.keyCode >= 96 && e.keyCode <= 105) || (e.keyCode >= 48 && e.keyCode <= 57)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
$(this).unbind('change.num').unbind('keydown.num').bind('change.num', changed).bind('keydown.num', keydown);
|
||||
});
|
||||
};
|
255
Site/Maintenance/js/customerrecord.js
Normal file
255
Site/Maintenance/js/customerrecord.js
Normal file
@ -0,0 +1,255 @@
|
||||
var dialogAssets;
|
||||
|
||||
$(function () {
|
||||
InitGridSelectedMachines();
|
||||
|
||||
dialogAssets = new $assetselector('dialog_machines');
|
||||
dialogAssets.onDialogClosed = function () {
|
||||
showmaskbg(false);
|
||||
};
|
||||
dialogAssets.onOK = function (source) {
|
||||
var items = [];
|
||||
for (var i = 0; i < source.length; i++) {
|
||||
var it = source[i].Values;
|
||||
if (it.Selected) {
|
||||
items.push({
|
||||
Values: {
|
||||
ID: it.Id,
|
||||
VIN: it.VIN,
|
||||
Name: it.Name,
|
||||
MakeName: it.MakeName,
|
||||
ModelName: it.ModelName,
|
||||
TypeName: it.TypeName
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
var p = [
|
||||
custrecordid,
|
||||
JSON.stringify(items.map(function (f) { return f.Values.ID; }))
|
||||
];
|
||||
|
||||
$("#dialogmask").show();
|
||||
customerquery('AssignMachines', htmlencode(JSON.stringify(p)), function (r) {
|
||||
showmaskbg(false);
|
||||
$("#dialogmask").hide();
|
||||
if (r === 'OK') {
|
||||
grid_dtsm.setData(grid_dtsm.innerSource.concat(items));
|
||||
} else {
|
||||
showAlert(r, GetTextByKey("P_UM_ASSETASSIGNMENT", 'Asset Assignment'));
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
/************************** Machine********************************/
|
||||
/*************************************************************************/
|
||||
|
||||
function OnMachineAdd() {
|
||||
showmaskbg(true);
|
||||
dialogAssets.exceptSource = grid_dtsm.innerSource.map(function (s) {
|
||||
return s.Values.ID;
|
||||
});
|
||||
dialogAssets.showSelector();
|
||||
$('#mask_bg').css('height', '100%');
|
||||
}
|
||||
|
||||
var _selectedMachines = [];
|
||||
|
||||
function OnManageMachine(u) {
|
||||
$('#chk_showallassignedassets').prop('checked', false);
|
||||
$('#txt_machine_key').val('');
|
||||
|
||||
if (!u) {
|
||||
custrecordid = undefined;
|
||||
return;
|
||||
}
|
||||
|
||||
custrecordid = u.Id;
|
||||
|
||||
var title = GetTextByKey("P_UM_ASSETASSIGNMENT", "Asset Assignment");// + " " + jobsite.Name + " " + "Radius_UOM: " + jobsite.Radius_UOM
|
||||
$('#dialog_managemahchine .dialog-title span.title').html(title);
|
||||
$('.machine_maskbg').show();
|
||||
$('#dialog_managemahchine')
|
||||
.attr('init', 1)
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_managemahchine').height()) / 5,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_managemahchine').width()) / 2
|
||||
}).showDialog();
|
||||
|
||||
grid_dtsm.setData([]);
|
||||
$('#selectedmachinelist input[type="checkbox"]').prop('checked', false);
|
||||
|
||||
GetAssignedMachines();
|
||||
}
|
||||
|
||||
|
||||
// 获取已选中的machines
|
||||
function GetAssignedMachines() {
|
||||
$("#dialogmask").show();
|
||||
customerquery('GetAssignedMachines', custrecordid, function (data) {
|
||||
if (typeof data === "string") {
|
||||
showAlert(data, GetTextByKey("P_UM_ASSETASSIGNMENT", "Asset Assignment"));
|
||||
return;
|
||||
}
|
||||
showSelectedMachine(data);
|
||||
$("#dialogmask").hide();
|
||||
}, function (e) {
|
||||
$("#dialogmask").hide();
|
||||
});
|
||||
}
|
||||
|
||||
function showSelectedMachine(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
|
||||
grid_dtsm.setData(rows);
|
||||
}
|
||||
|
||||
function OnMachineDeleteSingle(item) {
|
||||
showConfirm(GetTextByKey("P_UM_DELETEASSIGNEDASSET", 'Are you sure you want to delete the assigned asset: {0}?').replace('{0}', item.Name), GetTextByKey("P_UM_ASSETASSIGNMENT", "Asset Assignment"), function () {
|
||||
var params = [
|
||||
custrecordid,
|
||||
JSON.stringify([item.ID])
|
||||
];
|
||||
$("#dialogmask").show();
|
||||
customerquery('RemoveAssignedMachines', htmlencode(JSON.stringify(params)), function (r) {
|
||||
$("#dialogmask").hide();
|
||||
if (r !== 'OK') {
|
||||
showAlert(r, GetTextByKey("P_UM_ASSETASSIGNMENT", "Asset Assignment"));
|
||||
} else {
|
||||
for (var i = 0; i < grid_dtsm.innerSource.length; i++) {
|
||||
var s = grid_dtsm.innerSource[i].Values;
|
||||
if (s.ID === item.ID) {
|
||||
grid_dtsm.innerSource.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (grid_dtsm.source != null) {
|
||||
for (var j = 0; j < grid_dtsm.source.length; j++) {
|
||||
if (item.ID === grid_dtsm.source[j].Values.ID) {
|
||||
grid_dtsm.source.splice(j, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
grid_dtsm.reset();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function OnMachineDelete() {
|
||||
showConfirm(GetTextByKey("P_UM_DELETESELECTEDASSET", 'Are you sure you want to delete these selected assets?'), GetTextByKey("P_UM_ASSETASSIGNMENT", "Asset Assignment"), function () {
|
||||
var ids = grid_dtsm.innerSource.filter(function (s) { return s.Values.selected; }).map(function (s) { return s.Values.ID; });
|
||||
var params = [
|
||||
custrecordid,
|
||||
JSON.stringify(ids)
|
||||
];
|
||||
$("#dialogmask").show();
|
||||
customerquery('RemoveAssignedMachines', htmlencode(JSON.stringify(params)), function (r) {
|
||||
$("#dialogmask").hide();
|
||||
if (r !== 'OK') {
|
||||
showAlert(r, GetTextByKey("P_UM_ASSETASSIGNMENT", "Asset Assignment"));
|
||||
} else {
|
||||
for (var i = grid_dtsm.innerSource.length - 1; i >= 0; i--) {
|
||||
var s = grid_dtsm.innerSource[i].Values;
|
||||
if (s.selected) {
|
||||
grid_dtsm.innerSource.splice(i, 1);
|
||||
}
|
||||
}
|
||||
if (grid_dtsm.source != null) {
|
||||
for (var j = grid_dtsm.source.length - 1; j >= 0; j--) {
|
||||
var l = grid_dtsm.source[j].Values;
|
||||
if (l.selected) {
|
||||
grid_dtsm.source.splice(j, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
grid_dtsm.reset();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var grid_dtsm;
|
||||
function InitGridSelectedMachines() {
|
||||
grid_dtsm = new GridView('#selectedmachinelist');
|
||||
grid_dtsm.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'VIN', caption: GetTextByKey("P_UM_SN", "SN"), valueIndex: 'VIN', css: { 'width': 160, 'text-align': 'left' } },
|
||||
{ name: 'Name', caption: GetTextByKey("P_UM_NAME", "Name"), valueIndex: 'Name', css: { 'width': 160, 'text-align': 'left' } },
|
||||
{ name: 'MakeName', caption: GetTextByKey("P_UM_MAKE", "Make"), valueIndex: 'MakeName', css: { 'width': 90, 'text-align': 'left' } },
|
||||
{ name: 'ModelName', caption: GetTextByKey("P_UM_MODEL", "Model"), valueIndex: 'ModelName', css: { 'width': 90, 'text-align': 'left' } },
|
||||
{ name: 'TypeName', caption: GetTextByKey("P_UM_ASSETSTYPE", "Type"), valueIndex: 'TypeName', css: { 'width': 170, 'text-align': 'left' } }
|
||||
];
|
||||
var columns = [
|
||||
{
|
||||
// checkbox
|
||||
name: 'check',
|
||||
key: 'selected',
|
||||
width: 30,
|
||||
align: 'center',
|
||||
sortable: false,
|
||||
allcheck: true,
|
||||
type: 3
|
||||
}
|
||||
];
|
||||
// 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.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
col.allowFilter = col.name === 'TypeName';
|
||||
col.styleFilter = function (item) {
|
||||
if (item.Highlight)
|
||||
return { 'background-color': 'yellow' };
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
columns.push({
|
||||
name: 'delete',
|
||||
width: 30,
|
||||
align: 'center',
|
||||
sortable: false,
|
||||
isurl: true,
|
||||
text: '\uf00d',
|
||||
events: {
|
||||
onclick: function () {
|
||||
OnMachineDeleteSingle(this);
|
||||
}
|
||||
},
|
||||
classFilter: function (e) {
|
||||
return "icon-col";
|
||||
},
|
||||
attrs: { 'title': GetTextByKey("P_UM_DELETE", 'Delete') }
|
||||
});
|
||||
grid_dtsm.canMultiSelect = true;
|
||||
grid_dtsm.columns = columns;
|
||||
grid_dtsm.init();
|
||||
|
||||
grid_dtsm.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_dtsm.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************End Machine********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
|
165
Site/Maintenance/js/fuelrecordattachments.js
Normal file
165
Site/Maintenance/js/fuelrecordattachments.js
Normal file
@ -0,0 +1,165 @@
|
||||
|
||||
function UpLoadAttachment() {
|
||||
var file = $('<input type="file" style="display: none;" multiple="multiple" />');
|
||||
file.change(function () {
|
||||
var files = this.files;
|
||||
if (files.length > 0) {
|
||||
onSaveAttachment(files);
|
||||
}
|
||||
}).click();
|
||||
}
|
||||
|
||||
var filesinuploading = [];
|
||||
var uploadingindex = -1;
|
||||
var fileupload_errors = "";
|
||||
function onSaveAttachment(files) {
|
||||
fileupload_errors = "";
|
||||
if (!fuelid) {
|
||||
OnSave(0, this, function () {
|
||||
$('#att_mask_bg').show();
|
||||
if (filesinuploading.length > 0) {
|
||||
for (var i = 0; i < files.length; i++)
|
||||
filesinuploading.push(fuelid, files[i]);
|
||||
}
|
||||
else {
|
||||
filesinuploading = files;
|
||||
DoUploadAttachments(fuelid);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$('#att_mask_bg').show();
|
||||
if (filesinuploading.length > 0) {
|
||||
for (var i = 0; i < files.length; i++)
|
||||
filesinuploading.push(files[i]);
|
||||
}
|
||||
else {
|
||||
filesinuploading = files;
|
||||
DoUploadAttachments(fuelid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function DoUploadAttachments(fid) {
|
||||
if (fid != fuelid) {
|
||||
filesinuploading = [];
|
||||
uploadingindex = -1;
|
||||
return;
|
||||
}
|
||||
uploadingindex++;
|
||||
if (uploadingindex >= filesinuploading.length) {
|
||||
uploadingindex--;
|
||||
filesinuploading = [];
|
||||
uploadingindex = -1;
|
||||
getAttachments();
|
||||
if (fileupload_errors !== "")
|
||||
showAlert(fileupload_errors, GetTextByKey("P_WO_XXXXX", 'Upload failed'));
|
||||
$('#att_mask_bg').hide();
|
||||
return;
|
||||
}
|
||||
var file = filesinuploading[uploadingindex];
|
||||
if (file.name.length > 200) {
|
||||
showUplpadingStatus(GetTextByKey("P_WO_XXX", "Attachment name length cannot be greater than 200."));
|
||||
DoUploadAttachments(fid);
|
||||
return;
|
||||
}
|
||||
if (file.size == 0) {
|
||||
showUplpadingStatus(GetTextByKey("P_WO_ATTACHMENTSTIPS", "Attachment size is 0kb, uploading failed."));
|
||||
DoUploadAttachments(fid);
|
||||
return;
|
||||
}
|
||||
if (file.size > 50 * 1024 * 1024) {
|
||||
showUplpadingStatus(GetTextByKey("P_WO_ATTACHMENTSTIPS1", "Attachment is too large. Maximum file size is 50 MB."));
|
||||
DoUploadAttachments(fid);
|
||||
return;
|
||||
}
|
||||
|
||||
var formData = new FormData();
|
||||
formData.append("iconFile", file);
|
||||
formData.append("MethodName", "AddAttachment");
|
||||
formData.append("ClientData", fid);
|
||||
$.ajax({
|
||||
url: 'AddFuelRecord.aspx',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
data: formData,
|
||||
async: true,
|
||||
success: function (data) {
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, GetTextByKey("P_FR_ATTACHMENTS", 'Attachment File'));
|
||||
} else {
|
||||
DoUploadAttachments(fid);
|
||||
}
|
||||
},
|
||||
error: function (err) {
|
||||
showUplpadingStatus(GetTextByKey("P_WO_XXXXX", 'Upload failed'));
|
||||
DoUploadAttachments(fid);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function showUplpadingStatus(msg) {
|
||||
if (filesinuploading.length == 0) return;
|
||||
var filename = filesinuploading[uploadingindex].name;
|
||||
if (filename.length > 50)
|
||||
filename = filename.substring(0, 49) + "...";
|
||||
|
||||
var statustxt = filename + " - " + msg;
|
||||
if (fileupload_errors === "")
|
||||
fileupload_errors = statustxt;
|
||||
else
|
||||
fileupload_errors = fileupload_errors + " \n " + statustxt;
|
||||
}
|
||||
|
||||
function deleteAttachment(attID) {
|
||||
if (confirm(GetTextByKey("P_FR_DELETEATTACHMENTTIPS", "Are you sure you want to delete the attachment?"))) {
|
||||
fuelrequest("DeleteAttachment", attID, function (data) {
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, GetTextByKey("P_FR_DELETEATTACHMENT", 'Delete Attachment'));
|
||||
}
|
||||
else
|
||||
getAttachments();
|
||||
}, function (err) {
|
||||
showAlert(GetTextByKey("P_FR_FAILEDDELETEATTACHMENT", 'Failed to delete this attachment.'), GetTextByKey("P_FR_DELETEATTACHMENT", 'Delete Attachment'));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getAttachments() {
|
||||
if (fuelid) {
|
||||
$('#tbAttas').empty();
|
||||
$('#lable_attachment').hide();
|
||||
fuelrequest('GetAttachments', fuelid, function (data) {
|
||||
if (data && data.length > 0) {
|
||||
if (fuel && fuel.IsComesFromAPI)
|
||||
$('#lable_attachment').show();
|
||||
$('#tabAttachments').show();
|
||||
var flist = data;
|
||||
for (var i = 0; i < flist.length; i++) {
|
||||
var trrecoard = $('<tr></tr>').attr('id', flist[i].ID);
|
||||
var tdfile = $('<td style=""></td>');
|
||||
var filename = $("<label style='border-bottom: 1px solid RGB(30, 144, 255);color: RGB(30,144,255);cursor:pointer;'></label>").text(flist[i].FileName).click(function () {
|
||||
window.open("../filesvc.ashx?attchid=" + this.parentElement.parentElement.id + "&sourceType=workorderattachment");
|
||||
});
|
||||
var span = $('<span></span>').text(flist[i].AddedByUserName).css("margin-right", 5).css("margin-left", 5).css("color", "black");
|
||||
var spanby = $('<span></span>').text(flist[i].AddedOnStr).css("color", "black");
|
||||
tdfile.append(filename, span, spanby);
|
||||
|
||||
if (isshowdelete) {
|
||||
var tdimg = $('<td style="width:18px;border:none;text-align:center;"></td>');
|
||||
var imgDom = $('<span class="sbutton icondelete" style="padding:0;" ></span>').click(function () {
|
||||
deleteAttachment(this.parentElement.parentElement.id);
|
||||
});
|
||||
tdimg.append(imgDom);
|
||||
trrecoard.append(tdimg);
|
||||
}
|
||||
trrecoard.append(tdfile).appendTo($('#tbAttas'));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
177
Site/Maintenance/js/inputdatactr.js
Normal file
177
Site/Maintenance/js/inputdatactr.js
Normal file
@ -0,0 +1,177 @@
|
||||
//监听键盘输入是否为数字
|
||||
function MouseDownCheckNumber(evt, object) {
|
||||
var length = object.value.length;
|
||||
var textvalue = object.value;
|
||||
var c = evt.keyCode;
|
||||
|
||||
var nlenselect;
|
||||
var nstart;
|
||||
var nend;
|
||||
|
||||
var ch;
|
||||
var part;
|
||||
|
||||
nlenselect = object.selectionEnd - object.selectionStart;
|
||||
nstart = object.selectionStart;
|
||||
nend = object.selectionEnd;
|
||||
|
||||
if (nstart === undefined) {
|
||||
try {
|
||||
var rng;
|
||||
if (object.tagName.toLowerCase() == "textarea") { //TEXTAREA
|
||||
rng = evt.srcElement.createTextRange();
|
||||
rng.moveToPoint(evt.x, evt.y);
|
||||
} else { //Text
|
||||
rng = document.selection.createRange();
|
||||
}
|
||||
nlenselect = rng.text.length;
|
||||
rng.moveStart("character", -evt.srcElement.value.length);
|
||||
nend = rng.text.length;
|
||||
nstart = Math.max(0, nend - nlenselect);
|
||||
} catch (e) {
|
||||
throw new Error(10, "failed to get cursor position.")
|
||||
}
|
||||
}
|
||||
|
||||
if (nlenselect > 0) {
|
||||
part = object.value.substring(nstart, object.selectionEnd);
|
||||
}
|
||||
else {
|
||||
part = "";
|
||||
}
|
||||
|
||||
/*-- Control the "-" key----*/
|
||||
if (((c == 173 || c == 189 || c == 109) && !evt.shiftKey) || c == 229) {
|
||||
return false;
|
||||
}
|
||||
/*--- Control the dot key--*/
|
||||
else if ((c == 190 || c == 110) && !evt.shiftKey) {
|
||||
if (textvalue.indexOf('.') == -1) {
|
||||
if (length == 0) {
|
||||
}
|
||||
else if (nstart == 0) {
|
||||
if (part.length == 0 && textvalue.charCodeAt(0) != 45) {
|
||||
}
|
||||
else if (part.length != 0) {
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (part.indexOf('.') != -1) {
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((c >= 35 && c <= 40) || c == 46 || c == 9) {
|
||||
}
|
||||
/* Control the Number Key*/
|
||||
else if (((evt.keyCode >= 48 && evt.keyCode <= 59) && !evt.shiftKey) || (c >= 96 && c <= 105)) {
|
||||
if (length == 0) {
|
||||
}
|
||||
else if (length != 0) {
|
||||
/* check the number length behind the dot*/
|
||||
var op = length - textvalue.indexOf('.');
|
||||
if (textvalue.indexOf('.') != -1) {
|
||||
if (part.length != 0) {
|
||||
}
|
||||
else if (nstart > textvalue.indexOf('.')) {
|
||||
if (object.lengthbehinddot != null) {
|
||||
if ((length - textvalue.indexOf('.')) > object.lengthbehinddot) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* check ... */
|
||||
ch = textvalue.charCodeAt(0);
|
||||
|
||||
if (nstart == 0 && part.length != 0) {
|
||||
}
|
||||
else if (nstart == 0 && ch == 45) { // -
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Open the Ctrl + C Copy Key*/
|
||||
else if ((evt.keyCode == 67 || evt.keyCode == 99) && evt.ctrlKey) {
|
||||
}
|
||||
/* Open the Ctrl + V Paste Key*/
|
||||
else if ((evt.keyCode == 86 || evt.keyCode == 118) && evt.ctrlKey) {
|
||||
}
|
||||
/* Open the Ctrl + Z Back Key*/
|
||||
else if ((evt.keyCode == 90 || evt.keyCode == 122) && evt.ctrlKey) {
|
||||
}
|
||||
/* Open the Esc Key*/
|
||||
else if (evt.keyCode == 27) {
|
||||
}
|
||||
else if ((evt.keyCode < 48 || evt.keyCode > 59) && evt.keyCode != 8 || evt.shiftKey) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//对输入框的输入类型控制
|
||||
function InputControl(object) {
|
||||
object.mouseup(function () { return false; });
|
||||
object.keydown(function (evt) {
|
||||
var c = evt.which;
|
||||
if (c == 13) {
|
||||
tmp = $(this).attr("id");
|
||||
setTimeout(EnterFocus, 200);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if (c != 9) {
|
||||
var b = MouseDownCheckNumber(evt, $(this)[0]);
|
||||
if (!b)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function inputValueFormat(obj) {
|
||||
var curval =$.trim($.trim($(obj).val()));
|
||||
var floatvalue = parseFloat(curval);
|
||||
if (floatvalue <= 0 || isNaN(floatvalue) || curval == "")
|
||||
return false;
|
||||
else {
|
||||
$(obj).val(floatvalue);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function checkDate(obj) {
|
||||
var splarray = obj.split('/');
|
||||
if (splarray.length != 3) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* 不易判断多种语言环境下的不同顺序格式,例如 2021/9/13 与 9/13/2021
|
||||
*
|
||||
var mm=parseInt(splarray[0]);
|
||||
var dd=parseInt(splarray[1]);
|
||||
var yyyy=parseInt(splarray[2]);
|
||||
if (mm > 0 && mm <= 12 && dd > 0 && dd <= 31 && yyyy >= 1900) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
var date = new Date(obj);
|
||||
if (isNaN(date.getTime())) {
|
||||
return;
|
||||
}
|
||||
if (date.getFullYear() < 1900) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
109
Site/Maintenance/js/maintenancelogattachment.js
Normal file
109
Site/Maintenance/js/maintenancelogattachment.js
Normal file
@ -0,0 +1,109 @@
|
||||
|
||||
function UpLoadMaintenanceLogAttachment() {
|
||||
var file = $('<input type="file" style="display: none;" multiple="multiple" />');
|
||||
file.change(function () {
|
||||
var files = this.files;
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
if (files[i].size == 0) {
|
||||
alert(GetTextByKey("P_MRM_ATTACHMENTSTIPS", "Attachment size is 0kb, uploading failed."));
|
||||
return false;
|
||||
}
|
||||
if (files[i].size > 50 * 1024 * 1024) {
|
||||
alert(GetTextByKey("P_MRM_ATTACHMENTSTIPS1", "Attachment is too large. Maximum file size is 50 MB."));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!maintenanceid) {
|
||||
OnSave(0, function () {
|
||||
SaveMaintenanceLogAttachmentFiles(files);
|
||||
});
|
||||
return;
|
||||
}
|
||||
else {
|
||||
SaveMaintenanceLogAttachmentFiles(files);
|
||||
}
|
||||
}).click();
|
||||
}
|
||||
|
||||
|
||||
function SaveMaintenanceLogAttachmentFiles(files) {
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var iconfile = files[i];
|
||||
ChangeMaintenanceLogAttachmentFile(iconfile);
|
||||
}
|
||||
}
|
||||
|
||||
function ChangeMaintenanceLogAttachmentFile(file) {
|
||||
var formData = new FormData();
|
||||
formData.append("iconFile", file);
|
||||
formData.append("MethodName", "AddAttachment");
|
||||
formData.append("ClientData", maintenanceid);
|
||||
$.ajax({
|
||||
url: 'AddMaintenanceRecord.aspx',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
data: formData,
|
||||
async: true,
|
||||
success: function (data) {
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, GetTextByKey("P_MRM_ATTACHMENTS", 'Attachment File'));
|
||||
} else {
|
||||
getMaintenanceLogAttachments();
|
||||
}
|
||||
},
|
||||
error: function (err) {
|
||||
showAlert(err.statusText, GetTextByKey("P_MRM_ATTACHMENTS", 'Attachment File'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deleteAttachment(attID) {
|
||||
if (confirm(GetTextByKey("P_MRM_DELETEATTACHMENTTIPS", "Are you sure you want to delete the attachment?"))) {
|
||||
maintenancerequest("DeleteAttachment", attID, function (data) {
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, GetTextByKey("P_MRM_DELETEATTACHMENT", 'Delete Attachment'));
|
||||
}
|
||||
else
|
||||
getMaintenanceLogAttachments();
|
||||
}, function (err) {
|
||||
showAlert(GetTextByKey("P_MRM_FAILEDDELETEATTACHMENT",'Failed to delete this attachment.'), GetTextByKey("P_MRM_DELETEATTACHMENT", 'Delete Attachment'));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getMaintenanceLogAttachments() {
|
||||
if (maintenanceid) {
|
||||
$('#tbAttas').empty();
|
||||
maintenancerequest('GetAttachments', maintenanceid, function (data) {
|
||||
if (data && data.length > 0) {
|
||||
$('#tabAttachments').show();
|
||||
var flist = data;
|
||||
for (var i = 0; i < flist.length; i++) {
|
||||
var trrecoard = $('<tr></tr>').attr('id', flist[i].ID);
|
||||
var tdfile = $('<td style=""></td>');
|
||||
var filename = $("<label style='border-bottom: 1px solid RGB(30, 144, 255);color: RGB(30,144,255);cursor:pointer;'></label>").text(flist[i].FileName).click(function () {
|
||||
window.open("../filesvc.ashx?attchid=" + this.parentElement.parentElement.id + "&sourceType=workorderattachment");
|
||||
});
|
||||
var span = $('<span></span>').text(flist[i].AddedByUserName).css("margin-right", 5);
|
||||
var spanby = $('<span></span>').text(flist[i].AddedOnStr);
|
||||
tdfile.append(filename, span, spanby);
|
||||
|
||||
if (isshowdelete) {
|
||||
var tdimg = $('<td style="width:18px;border:none;text-align:center;"></td>');
|
||||
var imgDom = $('<span class="sbutton icondelete" style="padding:0;" ></span>').click(function () {
|
||||
deleteAttachment(this.parentElement.parentElement.id);
|
||||
});
|
||||
tdimg.append(imgDom);
|
||||
trrecoard.append(tdimg);
|
||||
}
|
||||
|
||||
trrecoard.append(tdfile).appendTo($('#tbAttas'));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
1902
Site/Maintenance/js/manageworkorder.js
Normal file
1902
Site/Maintenance/js/manageworkorder.js
Normal file
File diff suppressed because it is too large
Load Diff
339
Site/Maintenance/js/schedule.js
Normal file
339
Site/Maintenance/js/schedule.js
Normal file
@ -0,0 +1,339 @@
|
||||
/// <reference path="../../js/jquery-3.6.0.min.js" />
|
||||
/// <reference path="../../js/utility.js" />
|
||||
|
||||
_sc = {};
|
||||
|
||||
(function () {
|
||||
_sc.focusIntervalItem = function (e) {
|
||||
if (e.data) {
|
||||
return;
|
||||
}
|
||||
var tr = $(this).parents('tr:first');
|
||||
tr.find('input[type="text"]').addClass('focused');
|
||||
tr.find('textarea').addClass('focused');
|
||||
tr.find('select').addClass('focused');
|
||||
|
||||
tr.find('.general').css('display', 'none');
|
||||
tr.find('.editing').css('display', 'block');
|
||||
};
|
||||
|
||||
_sc.changeIntervalUom = function (e) {
|
||||
var td = $(e.target).parent().next();
|
||||
td.find('span').text($(e.target).val());
|
||||
};
|
||||
|
||||
|
||||
_sc.addIntervalItem = function (schid) {
|
||||
$('#dig_name').val('');
|
||||
$('#dig_interval').val('');
|
||||
$('#dig_period').val('');
|
||||
$('#dig_expectedcost').val('');
|
||||
$('#dig_recurring').prop('checked', false).unbind('change').change(function () {
|
||||
$('#dig_priority').prop('disabled', !$(this).prop('checked'));
|
||||
});
|
||||
$('#dig_priority').prop('disabled', true).val('');
|
||||
$('#dig_servicedec').val('');
|
||||
|
||||
showmaskbg(true);
|
||||
$('#dialog_interval')
|
||||
.attr('data-id', schid)
|
||||
.css({
|
||||
'top': ($(window).height() - $('#dialog_interval').height()) / 3,
|
||||
'left': ($(window).width() - $('#dialog_interval').width()) / 3
|
||||
})
|
||||
.showDialog();
|
||||
$('#dig_name').focus();
|
||||
};
|
||||
_sc.deleteIntervalItem = function (e) {
|
||||
var tr = $(this).parents('tr:first');
|
||||
var iid = tr.attr('data-id');
|
||||
var alerttitle = GetTextByKey("P_PM_DELETE", 'Delete');
|
||||
var comfirmmsg = GetTextByKey("P_PM_DELETETHISINTERVAL", 'Do you want to delete this interval?');
|
||||
if (e.data || !iid) {
|
||||
showConfirm(comfirmmsg, alerttitle, function (e) {
|
||||
tr.remove();
|
||||
});
|
||||
} else {
|
||||
showConfirm(comfirmmsg, alerttitle, function (e) {
|
||||
pmquery('DeletePmInterval', iid, function (data) {
|
||||
if (!data || data.length == 0) {
|
||||
//tr.remove();
|
||||
$('#refresh_button').click();
|
||||
} else {
|
||||
showAlert(data, alerttitle);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_sc.checkIntervalItem = function (item) {
|
||||
var alerttitle = GetTextByKey("P_PM_UPDATEINTERVAL", 'Update Interval');
|
||||
if (!item.ServiceName || item.ServiceName.trim().length == 0) {
|
||||
showAlert(GetTextByKey("P_PM_SERVICENAMENOTBEEMPTY", 'Service Name cannot be empty.'), alerttitle);
|
||||
return false;
|
||||
}
|
||||
item.ServiceName = item.ServiceName.trim();
|
||||
if (isNaN(item.Interval)) {
|
||||
showAlert(GetTextByKey("P_PM_INTERVALMUSTBEANUMBER", 'Interval must be a number.'), alerttitle);
|
||||
return false;
|
||||
}
|
||||
if (isNaN(item.NotificationPeriod)) {
|
||||
showAlert(GetTextByKey("P_PM_NOTIFICATIONPERIODMUSTBEANUMBER", 'Notification Period must be a number.'), alerttitle);
|
||||
return false;
|
||||
}
|
||||
if (item.NotificationPeriod >= item.Interval) {
|
||||
showAlert(GetTextByKey("P_PM_NOTIFICATIONPERIODMUSTLESSOREQUALINTERVAL", 'Notification period must be less than or equal to the Interval.'), alerttitle);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.ExpectedCost && item.ExpectedCost.length > 0) {
|
||||
if (isNaN(item.ExpectedCost) || item.ExpectedCost < 0) {
|
||||
showAlert(GetTextByKey("P_PM_EXPECTEDCOSTFORMATERROR", 'Expected Cost format error.'), alerttitle);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
item.ExpectedCost = 0;
|
||||
|
||||
if (item.Recurring) {
|
||||
item.Priority = parseInt(item.Priority);
|
||||
if (isNaN(item.Priority)) {
|
||||
showAlert(GetTextByKey("P_PM_PRIORITYUSTBEANUMBER", 'Priority must be a number.'), alerttitle);
|
||||
return false;
|
||||
} else if (item.Priority < 0) {
|
||||
showAlert(GetTextByKey("P_PM_PRIORITYNOTLESS0", 'Priority cannot be less than 0.'), alerttitle);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
item.Priority = 0;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
_sc.saveIntervalItem = function (e) {
|
||||
var tr = $(this).parents('tr:first');
|
||||
|
||||
function next() {
|
||||
tr.find('input[type="text"]').removeClass('focused');
|
||||
tr.find('textarea').removeClass('focused');
|
||||
tr.find('select').removeClass('focused');
|
||||
tr.find('.general').css('display', 'block');
|
||||
tr.find('.editing').css('display', 'none');
|
||||
var inps = tr.find('input[type="text"]');
|
||||
for (var i = 0; i < inps.length; i++) {
|
||||
var inp = $(inps[i]);
|
||||
inp.attr('data-ori', inp.val());
|
||||
}
|
||||
}
|
||||
|
||||
var item = {
|
||||
'ScheduleId': tr.attr('data-scheduleid'),
|
||||
'PmIntervalID': tr.attr('data-id'),
|
||||
'Interval': parseInt(tr.find('.inp_interval').val()),
|
||||
'NotificationPeriod': parseInt(tr.find('.inp_period').val()),
|
||||
'ServiceName': tr.find('.inp_name').val(),
|
||||
'Recurring': tr.find('.inp_recurring').prop('checked'),
|
||||
'Priority': tr.find('.inp_priority').val(),
|
||||
'ServiceDescription': tr.find('.textarea_desc').val(),
|
||||
'ExpectedCost': tr.find('.ipt_expectedcost').val()
|
||||
};
|
||||
if (!_sc.checkIntervalItem(item)) {
|
||||
return;
|
||||
}
|
||||
tr.find('.inp_name').val(item.ServiceName);
|
||||
tr.find('.inp_interval').val(item.Interval);
|
||||
tr.find('.inp_period').val(item.NotificationPeriod);
|
||||
tr.find('.textarea_desc').val(item.ServiceDescription);
|
||||
tr.find('.ipt_expectedcost').val(item.ExpectedCost);
|
||||
|
||||
pmquery('UpdatePmInterval', htmlencode(JSON.stringify(item)), function (data) {
|
||||
if (!data || data.length == 0) {
|
||||
next();
|
||||
} else {
|
||||
showAlert(data, GetTextByKey("P_PM_UPDATEINTERVAL", 'Update Interval'));
|
||||
}
|
||||
});
|
||||
};
|
||||
_sc.cancelIntervalSave = function (e) {
|
||||
var tr = $(this).parents('tr:first');
|
||||
tr.find('input[type="text"]').removeClass('focused');
|
||||
tr.find('textarea').removeClass('focused');
|
||||
tr.find('select').removeClass('focused');
|
||||
tr.find('.general').css('display', 'block');
|
||||
tr.find('.editing').css('display', 'none');
|
||||
var inps = tr.find('input');
|
||||
for (var i = 0; i < inps.length; i++) {
|
||||
var inp = $(inps[i]);
|
||||
var data = inp.attr('data-ori');
|
||||
if (inp.attr('type') == 'text') {
|
||||
inp.val(data || '');
|
||||
} else if (inp.attr('type') == 'checkbox') {
|
||||
inp.prop('checked', eval(data));
|
||||
}
|
||||
}
|
||||
var recurring = tr.find('.inp_recurring').prop('checked');
|
||||
var inp = tr.find('.inp_priority');
|
||||
inp.prop('disabled', !recurring);
|
||||
if (recurring) {
|
||||
inp.parent('td').removeClass('gray_field');
|
||||
} else {
|
||||
inp.parent('td').addClass('gray_field');
|
||||
}
|
||||
|
||||
var textarea = tr.find('.textarea_desc');
|
||||
var desc = $(textarea).attr('data-ori');
|
||||
$(textarea).val(desc);
|
||||
};
|
||||
|
||||
var interval_uom = "";
|
||||
_sc.createIntervalTr = function (item, flag) {
|
||||
function changeEnable(e) {
|
||||
var flag = $(this).prop('checked');
|
||||
var inp = $(this).parents('tr:first').find('.inp_priority');
|
||||
inp.prop('disabled', !flag);
|
||||
if (flag) {
|
||||
inp.parent('td').removeClass('gray_field');
|
||||
} else {
|
||||
inp.parent('td').addClass('gray_field');
|
||||
}
|
||||
}
|
||||
|
||||
var tr = $('<tr></tr>').attr('data-id', item.PmIntervalID).attr('data-scheduleid', item.ScheduleId);
|
||||
var td;
|
||||
td = $('<td></td>');
|
||||
td.append($('<input type="text" class="inp_name" maxlength="50"/>')
|
||||
.css('width', '100%')
|
||||
.attr('data-ori', item.ServiceName)
|
||||
.val(item.ServiceName)
|
||||
.focus(flag, _sc.focusIntervalItem));
|
||||
tr.append(td);
|
||||
|
||||
td = $('<td></td>');
|
||||
td.append($('<input type="text" class="inp_interval" maxlength="9"/>')
|
||||
.attr('data-ori', item.Interval)
|
||||
.val(item.Interval)
|
||||
.focus(flag, _sc.focusIntervalItem)
|
||||
.number());
|
||||
|
||||
|
||||
/*interval uom */
|
||||
interval_uom = interval_label;
|
||||
td.append("<span class='span_uom' style='margin-left:8px;'> " + interval_uom + "</span>");
|
||||
tr.append(td);
|
||||
|
||||
td = $('<td></td>');
|
||||
td.append($('<input type="text" class="inp_period" maxlength="9"/>')
|
||||
.attr('data-ori', item.NotificationPeriod)
|
||||
.val(item.NotificationPeriod)
|
||||
.focus(flag, _sc.focusIntervalItem)
|
||||
.number());
|
||||
|
||||
td.append("<span class='span_uom' style='margin-left:8px;'> " + interval_uom + "</span>");
|
||||
tr.append(td);
|
||||
|
||||
td = $('<td></td>');
|
||||
td.append($('<input type="checkbox" class="inp_recurring"/>')
|
||||
.attr('data-ori', item.Recurring)
|
||||
.prop('checked', item.Recurring)
|
||||
.change(changeEnable)
|
||||
.focus(flag, _sc.focusIntervalItem));
|
||||
tr.append(td);
|
||||
|
||||
//td = $('<td class="gray_field"></td>');
|
||||
//tr.append(td);
|
||||
|
||||
//td = $('<td class="gray_field"></td>');
|
||||
//tr.append(td);
|
||||
|
||||
//desc
|
||||
td = $('<td></td>');
|
||||
td.append($('<textarea class="textarea_desc" maxlength="3000"></textarea>')
|
||||
.css('width', '98%').css('height', '28px').css('resize', 'none')
|
||||
.attr('data-ori', item.ServiceDescription)
|
||||
.val(item.ServiceDescription)
|
||||
.focus(flag, _sc.focusIntervalItem));
|
||||
tr.append(td);
|
||||
|
||||
//Expected Cost
|
||||
td = $('<td></td>');
|
||||
td.append($('<input type="text" class="ipt_expectedcost" maxlength="12"/>')
|
||||
.css('width', '100%')
|
||||
.attr('data-ori', item.ExpectedCost)
|
||||
.val(item.ExpectedCost)
|
||||
.focus(flag, _sc.focusIntervalItem));
|
||||
tr.append(td);
|
||||
|
||||
|
||||
td = $('<td></td>');
|
||||
if (!item.Recurring) {
|
||||
td.addClass('gray_field');
|
||||
}
|
||||
td.append($('<input type="text" class="inp_priority" maxlength="5"/>')
|
||||
.attr('data-ori', item.Recurring ? item.Priority : '')
|
||||
.val(item.Recurring ? item.Priority : '')
|
||||
.prop('disabled', !item.Recurring)
|
||||
.focus(flag, _sc.focusIntervalItem)
|
||||
.number());
|
||||
tr.append(td);
|
||||
|
||||
td = $('<td class="td_funcs"></td>');
|
||||
// 常规操作
|
||||
var div = $('<div class="general"></div>');
|
||||
div.append($('<a onclick="return false;">' + GetTextByKey("P_PM_DELETE", "Delete") + '</a>').click(flag, _sc.deleteIntervalItem));
|
||||
td.append(div);
|
||||
div = $('<div class="editing"></div>');
|
||||
div.append($('<input type="button" value="' + GetTextByKey("P_PM_SAVE", "Save") + '"/>').click(_sc.saveIntervalItem));
|
||||
div.append($('<input type="button" value="' + GetTextByKey("P_PM_CANCEL", "Cancel") + '"/>').click(_sc.cancelIntervalSave));
|
||||
td.append(div);
|
||||
tr.append(td);
|
||||
|
||||
return tr;
|
||||
};
|
||||
|
||||
_sc.createIntervalReadonlyTr = function (item) {
|
||||
var tr = $('<tr></tr>').attr('data-id', item.PmIntervalID);
|
||||
var td;
|
||||
td = $('<td style="width: 150px;"></td>');
|
||||
td.append($('<span class="inp_name"></span>').text(item.ServiceName));
|
||||
tr.append(td);
|
||||
|
||||
/*interval uom */
|
||||
interval_uom = interval_label;
|
||||
td = $('<td></td>');
|
||||
td.append($('<span class="inp_interval"></span>').text(item.Interval));
|
||||
td.append('<span> ' + interval_uom + '</span>');
|
||||
tr.append(td);
|
||||
|
||||
td = $('<td></td>');
|
||||
td.append($('<span class="inp_period"></span>').text(item.NotificationPeriod));
|
||||
td.append('<span> ' + interval_uom + '</span>');
|
||||
tr.append(td);
|
||||
|
||||
td = $('<td></td>');
|
||||
td.append($('<span class="inp_recurring icon"></span>').html(item.Recurring ? '' : ''));
|
||||
tr.append(td);
|
||||
|
||||
//td = $('<td></td>');
|
||||
//tr.append(td);
|
||||
|
||||
//td = $('<td></td>');
|
||||
//tr.append(td);
|
||||
|
||||
//desc
|
||||
td = $('<td></td>');
|
||||
td.append($('<div class="inp_desc"></div>').css('max-width', '200px').css('max-height', '24px')
|
||||
.html(getText(item.ServiceDescription)).attr('title', item.ServiceDescription));
|
||||
tr.append(td);
|
||||
|
||||
td = $('<td></td>');
|
||||
td.append($('<span class="ipt_expectedcost"></span>').text(item.ExpectedCost));
|
||||
tr.append(td);
|
||||
|
||||
td = $('<td></td>');
|
||||
td.append($('<span class="inp_priority"></span>').text(item.Recurring ? item.Priority : ''));
|
||||
tr.append(td);
|
||||
|
||||
return tr;
|
||||
};
|
||||
})();
|
514
Site/Maintenance/js/scheduleassets.js
Normal file
514
Site/Maintenance/js/scheduleassets.js
Normal file
@ -0,0 +1,514 @@
|
||||
|
||||
if (typeof manageassetsCtrl !== 'function') {
|
||||
$manageassetsCtrl = function manageassetsCtrl() {
|
||||
this.tmpobj = {
|
||||
};
|
||||
this.wizardCtrl = null;
|
||||
this.vue = null;
|
||||
};
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var dataGrid = window.DataGrid || window['g5-datagrid'];
|
||||
|
||||
$manageassetsCtrl.prototype.getData = function (/*dataObj, tmpdata*/) {
|
||||
return this.vue.source;
|
||||
};
|
||||
|
||||
$manageassetsCtrl.prototype.setData = function (assetData) {
|
||||
if (assetData) {
|
||||
for (var i = 0; i < assetData.length; i++) {
|
||||
var a = assetData[i];
|
||||
a.Selected = false;
|
||||
if (a.Highlight == undefined)
|
||||
a.Highlight = false;
|
||||
}
|
||||
}
|
||||
this.vue.source = assetData ? assetData : [];
|
||||
this.vue.$refs.grid.resize();
|
||||
};
|
||||
|
||||
$manageassetsCtrl.prototype.reload = function () {
|
||||
this.vue.$refs.grid.reload()
|
||||
};
|
||||
|
||||
$manageassetsCtrl.prototype.Init = function (parent, newselected) {
|
||||
var ethis = this;
|
||||
//加载子页面模版
|
||||
parent.load('../template/ManageAssetsCtrl.html?v=8', function () {
|
||||
ethis.vue = new Vue({
|
||||
el: parent.find('.ManageAssetsCtrl')[0],
|
||||
components: {
|
||||
'data-grid': dataGrid
|
||||
},
|
||||
data: {
|
||||
wnd: window.parent,
|
||||
editable: true,
|
||||
columns: [],
|
||||
source: []
|
||||
},
|
||||
computed: {
|
||||
},
|
||||
watch: {
|
||||
source: function (val) {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
cellvaluechanged: function (item, key) {
|
||||
},
|
||||
rowdblclick: function (e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
ethis.vue.columns = createGridColumn(newselected);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
function createGridColumn(newselected) {
|
||||
var editable = false;
|
||||
var columns = [
|
||||
{
|
||||
key: 'Selected',
|
||||
caption: '',
|
||||
type: dataGrid.COLUMN_TYPE.checkbox,
|
||||
width: 30,
|
||||
align: 'center',
|
||||
sortable: false,
|
||||
orderable: false,
|
||||
enabled: true,
|
||||
resizable: false,
|
||||
allcheck: false,
|
||||
visible: !newselected
|
||||
},
|
||||
{
|
||||
key: 'VIN',
|
||||
caption: GetTextByKey("P_PM_SN", 'SN'),
|
||||
type: dataGrid.COLUMN_TYPE.lable,
|
||||
width: 140,
|
||||
orderable: false,
|
||||
resizable: true,
|
||||
enabled: editable,
|
||||
styleFilter: function (item) {
|
||||
if (item.Highlight)
|
||||
return { 'background-color': 'yellow' };
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'Name',
|
||||
caption: GetTextByKey("P_PM_NAME", 'Name'),
|
||||
type: dataGrid.COLUMN_TYPE.lable,
|
||||
width: 140,
|
||||
orderable: false,
|
||||
resizable: true,
|
||||
enabled: editable,
|
||||
styleFilter: function (item) {
|
||||
if (item.Highlight)
|
||||
return { 'background-color': 'yellow' };
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'MakeName',
|
||||
caption: GetTextByKey("P_PM_MAKE", 'Make'),
|
||||
type: dataGrid.COLUMN_TYPE.lable,
|
||||
width: 100,
|
||||
orderable: false,
|
||||
enabled: editable,
|
||||
resizable: true,
|
||||
visible: !newselected,
|
||||
styleFilter: function (item) {
|
||||
if (item.Highlight)
|
||||
return { 'background-color': 'yellow' };
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'ModelName',
|
||||
caption: GetTextByKey("P_PM_MODEL", 'Model'),
|
||||
type: dataGrid.COLUMN_TYPE.lable,
|
||||
width: 100,
|
||||
orderable: false,
|
||||
resizable: true,
|
||||
enabled: editable,
|
||||
visible: !newselected,
|
||||
styleFilter: function (item) {
|
||||
if (item.Highlight)
|
||||
return { 'background-color': 'yellow' };
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'EngineHours',
|
||||
caption: GetTextByKey("P_PM_CURRENTHOURS", 'Current Hours'),
|
||||
type: dataGrid.COLUMN_TYPE.lable,
|
||||
width: 100,
|
||||
orderable: false,
|
||||
resizable: true,
|
||||
visible: (scheduletype === "HM" || scheduletype === "PM")
|
||||
},
|
||||
{
|
||||
key: 'StartHours',
|
||||
caption: GetTextByKey("P_PM_STARTINGHOURS", 'Starting Hours'),
|
||||
type: dataGrid.COLUMN_TYPE.input,
|
||||
width: 100,
|
||||
orderable: false,
|
||||
resizable: false,
|
||||
enabled: 'Enabled',
|
||||
visible: (scheduletype === "HM" || scheduletype === "PM")
|
||||
},
|
||||
{
|
||||
key: 'Odometer',
|
||||
caption: GetTextByKey("P_PM_CURRENTODOMETER", 'Current Odometer'),
|
||||
type: dataGrid.COLUMN_TYPE.lable,
|
||||
width: 120,
|
||||
orderable: false,
|
||||
resizable: true,
|
||||
visible: (scheduletype === "RDM" || scheduletype === "ADM")
|
||||
},
|
||||
{
|
||||
key: 'StartOdometer',
|
||||
caption: GetTextByKey("P_PM_STARTODOMETER", 'Start Odometer'),
|
||||
type: dataGrid.COLUMN_TYPE.input,
|
||||
width: 100,
|
||||
orderable: false,
|
||||
resizable: false,
|
||||
enabled: 'Enabled',
|
||||
visible: (scheduletype === "RDM" || scheduletype === "ADM")
|
||||
},
|
||||
{
|
||||
key: 'StartDateString',
|
||||
caption: GetTextByKey("P_PM_PLANSTARTDATE", 'Plan Start Date'),
|
||||
type: dataGrid.COLUMN_TYPE.datepicker,
|
||||
width: 100,
|
||||
orderable: false,
|
||||
resizable: false,
|
||||
enabled: 'Enabled',
|
||||
visible: scheduletype === "TBM"
|
||||
},
|
||||
{
|
||||
key: 'StartIntervalValue',
|
||||
caption: GetTextByKey("P_PM_STARTINTERVAL", 'Start Interval'),
|
||||
type: dataGrid.COLUMN_TYPE.dropdown,
|
||||
source: 'TempIntervals',
|
||||
width: 100,
|
||||
orderable: false,
|
||||
resizable: false,
|
||||
enabled: 'Enabled',
|
||||
visible: (scheduletype === "HM" || scheduletype === "RDM" || scheduletype === "TBM")
|
||||
}
|
||||
];
|
||||
|
||||
return columns;
|
||||
}
|
||||
}());
|
||||
}
|
||||
|
||||
function getIntervalValues(currentValue) {
|
||||
var result = [];//取当前值的前两个和后10个Interval
|
||||
if (allintervals && allintervals.length > 0) {
|
||||
var maxInterval = allintervals[allintervals.length - 1];
|
||||
var pervoid = parseInt(currentValue / maxInterval);
|
||||
var remain = currentValue % maxInterval;
|
||||
if (remain > 0)
|
||||
pervoid++;
|
||||
var maxpervoid = pervoid + 1;
|
||||
var minpervoid = pervoid - parseInt(10 / allintervals.length) - 1;//10表示向后取10
|
||||
if (minpervoid < 0)
|
||||
minpervoid = 0;
|
||||
|
||||
for (var pi = maxpervoid; pi >= minpervoid; pi--) {
|
||||
for (var i = allintervals.length - 1; i >= 0; i--) {
|
||||
var interval = allintervals[i];
|
||||
var tempinterval = pi * maxInterval + interval;
|
||||
result.push(tempinterval);
|
||||
if (tempinterval >= currentValue) {
|
||||
if (result.length > 2)
|
||||
result.splice(0, 1);
|
||||
}
|
||||
else if (result.length == 12)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/******************************Assets********************************/
|
||||
function getMachineTypes() {
|
||||
pmquery('GetMachineTypes', '', function (data) {
|
||||
var types = [];
|
||||
types.push($('<option value="-1">' + GetTextByKey("P_SELECT_ALL","All") + '</option>'));
|
||||
if (data && data.length > 0) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
types.push($('<option></option>').val(data[i].ID).text(data[i].Name));
|
||||
}
|
||||
}
|
||||
types[0].prop('selected', true);
|
||||
$('#sel_machine_type').empty().append(types);
|
||||
GetSelectedMachines();
|
||||
});
|
||||
}
|
||||
|
||||
function GetSelectedMachines() {
|
||||
_ScheduleAssets = [];
|
||||
|
||||
pmquery('GetSelectedMachines', iid, function (data) {
|
||||
if (typeof data === "string") {
|
||||
showAlert(data, GetTextByKey("P_PM_ASSETASSIGNMENT", 'Asset Assignment'));
|
||||
return;
|
||||
}
|
||||
_ScheduleAssets = data;
|
||||
for (var i = 0; i < _SelectedUnSavedMachines.length; i++) {
|
||||
_ScheduleAssets.push(_SelectedUnSavedMachines[i]);
|
||||
}
|
||||
|
||||
getMatchSelectedMachines();
|
||||
});
|
||||
}
|
||||
|
||||
function getMatchSelectedMachines() {
|
||||
var typeid = $('#sel_machine_type').val();
|
||||
var machinefilter = $('#txt_machine_key').val().toLowerCase();
|
||||
var showallassigned = $('#chk_showallassignedassets').prop('checked');
|
||||
|
||||
_showSelectedMachines = [];
|
||||
var unMatched = [];
|
||||
for (var i = 0; i < _ScheduleAssets.length; i++) {
|
||||
var m = _ScheduleAssets[i];
|
||||
m.Enabled = !m.AlertsCount || m.AlertsCount == 0;
|
||||
m.Highlight = false;
|
||||
if (((typeid == -1 || typeid == m.TypeID)
|
||||
&& (machinefilter == "" || m.VIN.toLowerCase().indexOf(machinefilter) >= 0
|
||||
|| m.Name.toLowerCase().indexOf(machinefilter) >= 0))) {
|
||||
m.Highlight = showallassigned && (machinefilter !== "" || typeid != -1);
|
||||
|
||||
if (scheduletype == "HM" || scheduletype == "RDM") {
|
||||
var value = 0;
|
||||
if (scheduletype == "HM")
|
||||
value = m.StartHours;
|
||||
else
|
||||
value = m.StartOdometer;
|
||||
m.TempIntervals = getIntervalValues(value);
|
||||
m.TempIntervals.splice(0, 0, "");
|
||||
}
|
||||
else {
|
||||
m.TempIntervals = [];
|
||||
m.TempIntervals.push("");
|
||||
if (allintervals) {
|
||||
for (var j = 0; j < allintervals.length; j++)
|
||||
m.TempIntervals.push(allintervals[j]);
|
||||
}
|
||||
}
|
||||
|
||||
_showSelectedMachines.push(m);//Show All时,满足是啥条件的放在前面并高亮显示
|
||||
}
|
||||
else if (showallassigned)
|
||||
unMatched.push(m);
|
||||
}
|
||||
|
||||
if (showallassigned) {
|
||||
for (var i in unMatched)
|
||||
_showSelectedMachines.push(unMatched[i]);
|
||||
}
|
||||
|
||||
if (assignedassetCtrl) {
|
||||
assignedassetCtrl.setData(_showSelectedMachines);
|
||||
//assignedassetCtrl.reload();
|
||||
}
|
||||
}
|
||||
|
||||
function OnSaveMachines() {
|
||||
var assets = [];
|
||||
for (var i = 0; i < _ScheduleAssets.length; i++) {
|
||||
var machine = _ScheduleAssets[i];
|
||||
var asset = {};
|
||||
asset.AssetId = machine.AssetId;
|
||||
asset.StartIntervalValue = machine.StartIntervalValue;
|
||||
switch (scheduletype) {
|
||||
case "TBM":
|
||||
asset.StartDate = machine.StartDateString;
|
||||
if (asset.StartDate == "")
|
||||
asset.StartDate = "1900-01-01";
|
||||
break;
|
||||
case "PM":
|
||||
case "HM":
|
||||
asset.StartHours = machine.StartHours;
|
||||
if (asset.StartHours == "")
|
||||
asset.StartHours = "0";
|
||||
break;
|
||||
case "ADM":
|
||||
case "RDM":
|
||||
asset.StartOdometer = machine.StartOdometer;
|
||||
if (asset.StartOdometer == "")
|
||||
asset.StartOdometer = "0";
|
||||
break;
|
||||
}
|
||||
|
||||
assets.push(asset);
|
||||
}
|
||||
var item = {
|
||||
'IID': iid,
|
||||
'Assets': assets
|
||||
};
|
||||
|
||||
pmquery('SaveMachines', JSON.stringify(item), function (data) {
|
||||
if (!data || data.length == 0) {
|
||||
// success
|
||||
for (var i = 0; i < _ScheduleAssets.length; i++) {
|
||||
_ScheduleAssets[i].unSaved = false;
|
||||
}
|
||||
showAlert(GetTextByKey("P_PM_SAVEASSETLISTSUCCESSFUL", 'Save asset list successful.'));
|
||||
} else {
|
||||
showAlert(GetTextByKey("P_PM_FAILEDTOSAVEASSETLIST", 'Failed to save asset list.') + "\n" + data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var dialogAssets = undefined;
|
||||
function OnAddAssets() {
|
||||
if (!dialogAssets) {
|
||||
dialogAssets = new $assetselector("dialog_assets");
|
||||
dialogAssets.allowhidden = false;
|
||||
dialogAssets.onDialogClosed = function () {
|
||||
showmaskbg(false);
|
||||
}
|
||||
dialogAssets.onOK = function (assets) {
|
||||
if (assets && assets.length > 0) {
|
||||
setNewSelectedAseets(assets);
|
||||
}
|
||||
}
|
||||
}
|
||||
showmaskbg(true);
|
||||
var assets = [];
|
||||
for (var i = 0; i < _ScheduleAssets.length; i++) {
|
||||
assets.push(_ScheduleAssets[i].AssetId);
|
||||
}
|
||||
dialogAssets.exceptSource = assets;
|
||||
dialogAssets.showSelector(assets);
|
||||
}
|
||||
|
||||
function convertOdometer(odometer, odounit) {
|
||||
var unit = scheduleUom;
|
||||
var value = odometer;
|
||||
if (odometer > 0 && unit && odounit
|
||||
&& unit.toLowerCase().charAt(0) != odounit.toLowerCase().charAt(0)) {
|
||||
if (unit.toLowerCase().startsWith("m"))
|
||||
value = odometer * 0.6213712;
|
||||
else
|
||||
value = odometer / 0.6213712;
|
||||
}
|
||||
return Math.round(value);
|
||||
}
|
||||
|
||||
var selectedassetsctrl = undefined;
|
||||
function setNewSelectedAseets(assets) {
|
||||
var newassets = [];
|
||||
for (var i = 0; i < assets.length; i++) {
|
||||
var a = assets[i].Values;
|
||||
if (!a.Selected) continue;
|
||||
|
||||
var item = {};
|
||||
item.AssetId = a.Id;
|
||||
item.Selected = false;
|
||||
item.VIN = a.VIN;
|
||||
item.Name = a.Name;
|
||||
item.MakeName = a.MakeName;
|
||||
item.ModelName = a.ModelName;
|
||||
item.EngineHours = a.EngineHours;
|
||||
item.StartHours = a.EngineHours;
|
||||
item.Odometer = convertOdometer(a.Odometer, a.OdometerUnits);
|
||||
item.StartOdometer = item.Odometer;
|
||||
item.OdometerUnits = a.OdometerUnits;
|
||||
item.StartDateString = currentdate;
|
||||
item.StartIntervalValue = "";
|
||||
item.Enabled = true;
|
||||
if (scheduletype == "HM" || scheduletype == "RDM") {
|
||||
var value = 0;
|
||||
if (scheduletype == "HM")
|
||||
value = item.StartHours;
|
||||
else
|
||||
value = item.StartOdometer;
|
||||
item.TempIntervals = getIntervalValues(value);
|
||||
item.TempIntervals.splice(0, 0, "");
|
||||
}
|
||||
else {
|
||||
item.TempIntervals = [];
|
||||
item.TempIntervals.push("");
|
||||
if (allintervals) {
|
||||
for (var j = 0; j < allintervals.length; j++)
|
||||
item.TempIntervals.push(allintervals[j]);
|
||||
}
|
||||
}
|
||||
|
||||
newassets.push(item);
|
||||
}
|
||||
if (newassets.length == 0) {
|
||||
showmaskbg(false);
|
||||
return;
|
||||
}
|
||||
|
||||
$('#dialog_selectedassets')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_machinegroup').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_machinegroup').width()) / 2
|
||||
}).showDialog();
|
||||
|
||||
selectedassetsctrl.setData(newassets);
|
||||
}
|
||||
|
||||
function OnSetAssetsDialogOK() {
|
||||
for (var i = 0; i < selectedassetsctrl.vue.source.length; i++) {
|
||||
var asset = selectedassetsctrl.vue.source[i];
|
||||
asset.unSaved = true;
|
||||
_ScheduleAssets.push(asset);
|
||||
}
|
||||
|
||||
getMatchSelectedMachines();
|
||||
showmaskbg(false);
|
||||
$('#dialog_selectedassets').hideDialog();
|
||||
}
|
||||
|
||||
function OnRemoveAssets() {
|
||||
_SelectedUnSavedMachines = [];
|
||||
var assets = [];
|
||||
var assetwillalerts = "";
|
||||
for (var i = 0; i < _ScheduleAssets.length; i++) {
|
||||
var asset = _ScheduleAssets[i];
|
||||
if (asset.unSaved && !asset.Selected)
|
||||
_SelectedUnSavedMachines.push(asset);
|
||||
if (asset.Selected) {
|
||||
assets.push(asset.AssetId);
|
||||
if (asset.UnMaintainedAlert && asset.UnMaintainedAlert > 0) {
|
||||
if (assetwillalerts == "")
|
||||
assetwillalerts = asset.Name;
|
||||
else
|
||||
assetwillalerts += ", " + asset.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (assets.length == 0)
|
||||
return;
|
||||
|
||||
var item = {
|
||||
'ScheduleID': iid,
|
||||
'Assets': assets
|
||||
};
|
||||
|
||||
var msg = GetTextByKey("P_PM_DOYOUWANTTOREMOVEHESELECTEDASSETSFROMTHISSCHEDULE", "Do you want to remove the selected assets from this schedule?");
|
||||
if (assetwillalerts != "") {
|
||||
var msg = GetTextByKey("P_PM_DELETEUNASSIGNEDPMALERTSFORTHEFOLLOWINGASSETSTIPS", "Select OK below will result in the deletion of existing unassigned PM alerts for the following assets: ");
|
||||
msg += assetwillalerts + ".<br/>";
|
||||
msg += GetTextByKey("P_PM_DELTEALERTSYESORNOTIPS", "If you do not want those alerts deleted, select CANCEL and assign appropriate alerts to a maintenance record or work order in asset health prior to deletion/removal.");
|
||||
}
|
||||
|
||||
showConfirm(msg, GetTextByKey("P_PM_REMOVEASSETS", 'Remove Assets'), function (e) {
|
||||
pmquery('RemovePMAssets', JSON.stringify(item), function (data) {
|
||||
if (!data || data.length == 0) {
|
||||
showAlert(GetTextByKey("P_PM_ASSETSREMOVEDSUCCESSFULLY", 'Assets removed successfully.'));
|
||||
GetSelectedMachines();
|
||||
} else {
|
||||
showAlert(GetTextByKey("P_PM_FAILEDTOREMOVEASSETS", 'Failed to remove assets.') + "\n" + data);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
97
Site/Maintenance/js/surveydetail.js
Normal file
97
Site/Maintenance/js/surveydetail.js
Normal file
@ -0,0 +1,97 @@
|
||||
function GetWorkOrderSurveyResult() {
|
||||
$('#divtemplate').empty();
|
||||
showmaskbg(true);
|
||||
worequest("GetWorkOrderSurveyResult", surveyid, function (data) {
|
||||
$('#divtemplate').empty();
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_WOS_ERROR", 'Error'));
|
||||
}
|
||||
else {
|
||||
surveydata = data.SurveyData;
|
||||
vm.reload(data);
|
||||
createTemplate(data.SurveyData);
|
||||
}
|
||||
|
||||
showmaskbg(false);
|
||||
}, function (err) {
|
||||
showmaskbg(false);
|
||||
});
|
||||
}
|
||||
|
||||
function createTemplate(survey) {
|
||||
var template = survey.Question.Questions;
|
||||
var tempcontent = $('<div></div>');
|
||||
|
||||
var content = $('<div style="padding:0px;"></div>');
|
||||
var divpage = $('<div class="page"></div>');
|
||||
content.append(divpage);
|
||||
tempcontent.append(content);
|
||||
|
||||
var questioncontent = createQuestionContent(template);
|
||||
content.append(questioncontent);
|
||||
|
||||
$('#divtemplate').append(tempcontent);
|
||||
}
|
||||
|
||||
function createQuestionContent(template) {
|
||||
var content = $('<div style="margin-bottom:30px;"></div>');
|
||||
if (template.Questions && template.Questions.length > 0) {
|
||||
for (var i = 0; i < template.Questions.length; i++) {
|
||||
var q = template.Questions[i];
|
||||
var div_question = $('<div class="question"></div>');
|
||||
content.append(div_question);
|
||||
|
||||
var div_title = $('<div style="flex-grow:1;"></div>');
|
||||
if (i != 0) {
|
||||
div_title.css('margin-top', 20);
|
||||
}
|
||||
var span_name = $('<span></span>').text(q.Title);
|
||||
var span_title = $('<span class="question-tips"></span>').text(q.TitleTips);
|
||||
div_title.append(span_name).append(span_title)
|
||||
div_question.append(div_title);
|
||||
createAnswerContent(content, q);
|
||||
}
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
|
||||
function createAnswerContent(p, q) {
|
||||
if (surveydata && surveydata.Result) {
|
||||
for (var i = 0; i < surveydata.Result.length; i++) {
|
||||
var a = surveydata.Result[i];
|
||||
if (a.QuestionId.toLowerCase() == q.Id.toLowerCase()) {
|
||||
if (q.QuestionType == 2) {
|
||||
if (q.MultipleSelect) {
|
||||
if (a.Values && a.Values.length > 0) {
|
||||
for (var j = 0; j < a.Values.length; j++) {
|
||||
var item = $('<div class="answer"></div>');
|
||||
var label = $('<label style="margin-left:5px;"></lable>').text("" + (j + 1) + ". " + a.Values[j].Value);
|
||||
item.append(label);
|
||||
p.append(item).append("<div style='clear:both;'></div>");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (a.Values && a.Values.length > 0) {
|
||||
var item = $('<div class="answer" ></div>');
|
||||
var label = $('<label style="margin-left:5px;"></lable>').text(a.Values[0].Value);
|
||||
item.append(label);
|
||||
p.append(item).append("<div style='clear:both;'></div>");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (a.Values && a.Values.length > 0) {
|
||||
var item = $('<div class="answer" ></div>');
|
||||
var div = $('<div style="margin-left:5px;"></div>').html(replaceHtmlText(a.Values[0].Value));
|
||||
item.append(div);
|
||||
p.append(item).append("<div style='clear:both;'></div>");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
p.append($('<div class="noneanswer"></div>').text(GetTextByKey('P_WOS_NONE', '(None)')));
|
||||
}
|
359
Site/Maintenance/js/wocommunication.js
Normal file
359
Site/Maintenance/js/wocommunication.js
Normal file
@ -0,0 +1,359 @@
|
||||
|
||||
function getComments(reset) {
|
||||
if (reset) {
|
||||
resetComments();
|
||||
}
|
||||
if (!workorderid || workorderid == "") return;
|
||||
$('#mask_over_bg').show();
|
||||
worequest("GetComments", workorderid, function (data) {
|
||||
$('#mask_over_bg').hide();
|
||||
if (typeof (data) === "string") {
|
||||
return;
|
||||
}
|
||||
$("#li_comments").data("loaded", true);
|
||||
internal?.load(data);
|
||||
}, function (err) {
|
||||
$('#mask_over_bg').hide();
|
||||
});
|
||||
}
|
||||
|
||||
function showComment(comment, isfirst) {
|
||||
var commoentctrl = $("#divcomments");
|
||||
var div = $("<div class='msgdiv'></div>").appendTo(commoentctrl);
|
||||
if (isfirst)
|
||||
div.css("margin-top", 0);
|
||||
|
||||
var divuser = $("<div class='msgtime'></div>").appendTo(div);
|
||||
divuser.append($("<div style='float:left;font-weight: bold;'></div>").text(comment.UserName));
|
||||
divuser.append($("<div style='float:right;color: #aaa;'></div>").text(comment.SubmitDateStr));
|
||||
|
||||
var divcontent = $("<div></div>").appendTo(div);
|
||||
var contentctrl = $("<div style='clear:both;'></div>");
|
||||
divcontent.append(contentctrl);
|
||||
contentctrl.html(replaceHtmlText(comment.Comment));
|
||||
if (comment.FollowUp && comment.FollowUp !== "") {
|
||||
var sendto = "";
|
||||
var emails = comment.FollowUp.split(';');
|
||||
if (emails && emails.length > 0) {
|
||||
for (var i = 0; i < emails.length; i++) {
|
||||
sendto += emails[i] + "\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (sendto !== "")
|
||||
sendto = GetTextByKey("P_WO_SENTTO_COLON", "Sent To :") + "\r\n" + sendto;
|
||||
var div_status = $("<div style='float:right;font-weight: bold;color: #aaa;'></div>").text(GetTextByKey('P_WO_SENT', 'Sent')).attr('title', sendto);
|
||||
divcontent.append(div_status);
|
||||
}
|
||||
}
|
||||
|
||||
function addWorkOrderComment(comment) {
|
||||
if ($.trim(comment) == "") {
|
||||
//showAlert(GetTextByKey("P_FR_PLEASEINPUTTHECOMMENT", "Please input the comment."), GetTextByKey("P_WO_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
|
||||
var param = JSON.stringify([workorderid, comment]);
|
||||
param = htmlencode(param);
|
||||
$('#mask_over_bg').show();
|
||||
worequest("AddWorkOrderComment", param, function (data) {
|
||||
$('#mask_over_bg').hide();
|
||||
if (data !== "") {
|
||||
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
if (typeof internal !== 'undefined') {
|
||||
internal.text = '';
|
||||
}
|
||||
$('#commentsinputcount').text("0/" + $('#dialog_comments').attr("maxlength"));
|
||||
getComments();
|
||||
}, function (err) {
|
||||
$('#mask_over_bg').hide();
|
||||
});
|
||||
}
|
||||
|
||||
function resetComments() {
|
||||
if (typeof internal !== 'undefined') {
|
||||
internal.text = '';
|
||||
internal.load();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
var communicationsLoading = false;
|
||||
var communicationsLoadingWaitCount = 0;
|
||||
/**Communication */
|
||||
function getCommunications(reset) {
|
||||
if (reset) {
|
||||
resetCommunications();
|
||||
}
|
||||
if (communicationsLoading) {
|
||||
communicationsLoadingWaitCount++;
|
||||
return;
|
||||
}
|
||||
communicationsLoading = true;
|
||||
|
||||
if (!workorderid || workorderid == "") return;
|
||||
$('#mask_over_bg').show();
|
||||
worequest("GetCommunications", workorderid, function (data) {
|
||||
communicationsLoading = false;
|
||||
$('#mask_over_bg').hide();
|
||||
if (typeof (data) === "string") {
|
||||
return;
|
||||
}
|
||||
$("#li_communications").data("loaded", true);
|
||||
customer?.load(data, customercontacts, followers);
|
||||
|
||||
if (communicationsLoadingWaitCount > 0) {
|
||||
communicationsLoadingWaitCount = 0;
|
||||
getCommunications(reset);
|
||||
}
|
||||
}, function (err) {
|
||||
communicationsLoading = false;
|
||||
if (communicationsLoadingWaitCount > 0) {
|
||||
communicationsLoadingWaitCount = 0;
|
||||
getCommunications(reset);
|
||||
}
|
||||
$('#mask_over_bg').hide();
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
showAlert(GetTextByKey("P_WO_PLEASEINPUTTHEPHONENUMBEROREMAL", "Please input the phone number or email."), GetTextByKey("P_WO_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
|
||||
var comm = customer?.text;
|
||||
if ($.trim(comm) == "") {
|
||||
showAlert(GetTextByKey("P_WO_PLEASEINPUTTHEMESSAGE", "Please input the message."), GetTextByKey("P_WO_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
|
||||
var includeStatusLink = customer?.statusLink;
|
||||
|
||||
var param = JSON.stringify([workorderid, JSON.stringify(pmemails), comm, (includeStatusLink ? "1" : "0")]);
|
||||
param = htmlencode(param);
|
||||
$('#mask_over_bg').show();
|
||||
worequest("AddWorkOrderCommunication", param, function (data) {
|
||||
$('#mask_over_bg').hide();
|
||||
if (data !== "") {
|
||||
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
if (typeof customer !== 'undefined') {
|
||||
customer.text = '';
|
||||
}
|
||||
$('#msginputcount').text("0/" + $('#dialog_communications').attr("maxlength"));
|
||||
getCommunications();
|
||||
}, function (err) {
|
||||
$('#mask_over_bg').hide();
|
||||
});
|
||||
}
|
||||
|
||||
function OnAddCommunication() {
|
||||
addWorkOrderCommunication();
|
||||
}
|
||||
|
||||
function resetCommunications() {
|
||||
if (typeof customer !== 'undefined') {
|
||||
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('');
|
||||
}
|
||||
}
|
720
Site/Maintenance/js/workorderalert.js
Normal file
720
Site/Maintenance/js/workorderalert.js
Normal file
@ -0,0 +1,720 @@
|
||||
|
||||
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) {
|
||||
});
|
||||
}
|
||||
|
801
Site/Maintenance/js/workorderattachments.js
Normal file
801
Site/Maintenance/js/workorderattachments.js
Normal file
@ -0,0 +1,801 @@
|
||||
|
||||
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);
|
||||
}
|
444
Site/Maintenance/js/workordersegment.js
Normal file
444
Site/Maintenance/js/workordersegment.js
Normal file
@ -0,0 +1,444 @@
|
||||
$(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();
|
||||
}
|
405
Site/Maintenance/js/workordersendemail.js
Normal file
405
Site/Maintenance/js/workordersendemail.js
Normal file
@ -0,0 +1,405 @@
|
||||
$(function () {
|
||||
InitContactGridData();
|
||||
InitICContactGridData();
|
||||
|
||||
$('#sendworkorder_search').bind('input propertychange', function () {
|
||||
showContactList(false);
|
||||
});
|
||||
|
||||
$('#sendworkorder_search').keydown(function () {
|
||||
showContactList(false);
|
||||
});
|
||||
|
||||
$('#sendinternalcomments_search').bind('input propertychange', function () {
|
||||
showICContactList(false);
|
||||
});
|
||||
|
||||
$('#sendinternalcomments_search').keydown(function () {
|
||||
showICContactList(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
var machineContacts = [];
|
||||
function getMachineContacts(assetid) {
|
||||
grid_contactdt && grid_contactdt.setData([]);
|
||||
grid_iccontactdt && grid_iccontactdt.setData([]);
|
||||
worequest("GetMachineContacts", assetid, function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
machineContacts = data;
|
||||
showContactList(true);
|
||||
showICContactList(true);
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function showContactList(newopen) {
|
||||
var rows = [];
|
||||
if (machineContacts && machineContacts.length > 0) {
|
||||
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];
|
||||
|
||||
var fr = { Values: r };
|
||||
if (newopen) {
|
||||
if (assignedto.toLowerCase() === r.IID.toLowerCase())
|
||||
r.Email = true;
|
||||
else
|
||||
r.Email = false;
|
||||
if (assignedto.toLowerCase() === r.IID.toLowerCase())
|
||||
rows.splice(0, 0, fr);
|
||||
else
|
||||
rows.push(fr);
|
||||
}
|
||||
else {
|
||||
if (!r.Text && !r.Email) {
|
||||
if (r.DisplayName.toLowerCase().indexOf(filter) >= 0) {
|
||||
if (assignedto.toLowerCase() === r.IID.toLowerCase())
|
||||
rows.splice(0, 0, fr);
|
||||
else
|
||||
rows.push(fr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (assignedto.toLowerCase() === r.IID.toLowerCase())
|
||||
rows.splice(0, 0, fr);
|
||||
else
|
||||
rows.push(fr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
grid_contactdt.setData(rows);
|
||||
}
|
||||
|
||||
var grid_contactdt;
|
||||
function InitContactGridData() {
|
||||
grid_contactdt = new GridView('#contactlist');
|
||||
grid_contactdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'DisplayName', caption: GetTextByKey("P_WO_CONTACTNAME", "Contact Name"), valueIndex: 'DisplayName', css: { 'width': 148, 'text-align': 'left' } },
|
||||
{ name: 'ContactTypeName', caption: GetTextByKey("P_WO_CONTACTTYPE", "Contact Type"), valueIndex: 'ContactTypeName', css: { 'width': 148, 'text-align': 'left' } },
|
||||
//{ name: 'Text', caption: "Text", valueIndex: 'Text', type: 3, css: { 'width': 45, 'text-align': 'center' } },
|
||||
{ name: 'Email', caption: GetTextByKey("P_WO_EMAIL", "Email"), valueIndex: 'Email', type: 3, css: { 'width': 60, 'text-align': 'center' } }
|
||||
];
|
||||
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.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
columns.push(col);
|
||||
//if (col.name === "Text") {
|
||||
// col.enabled = function (item) {
|
||||
// return item.TextAddress !== '';
|
||||
// };
|
||||
//}
|
||||
if (col.name === "Email") {
|
||||
col.enabled = function (item) {
|
||||
return item.ID !== '';
|
||||
};
|
||||
}
|
||||
}
|
||||
grid_contactdt.canMultiSelect = false;
|
||||
grid_contactdt.columns = columns;
|
||||
grid_contactdt.init();
|
||||
|
||||
grid_contactdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_contactdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function openSendEmail() {
|
||||
$('#sendworkorder_desc').val('');
|
||||
$('#sendworkorder_otheremailaddress').val('');
|
||||
$('#sendworkorder_search').val('');
|
||||
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;
|
||||
}
|
||||
getMachineContacts(mid);
|
||||
|
||||
$('#sendemailpopupmask').css('height', $('#dialog_workorder').height());
|
||||
$('#sendemailpopupmask').css('min-width', $('#divcontent').width());
|
||||
$('#sendemailpopupmask').show();
|
||||
$('#sendemailpopupdialog').show();
|
||||
$('#sendemailpopupdialog').css({
|
||||
"top": ($("#sendemailpopupmask").height() - $('#sendemailpopupdialog').height()) / 2,
|
||||
"left": ($("#sendemailpopupmask").width() - $('#sendemailpopupdialog').width()) / 2
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function hideSendEmailPopup() {
|
||||
$('#sendemailpopupmask').hide();
|
||||
$('#sendemailpopupdialog').hide();
|
||||
}
|
||||
|
||||
function CheckEmail(mail) {
|
||||
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
|
||||
if (mail.length == 0)
|
||||
return true;
|
||||
return filter.test(mail);
|
||||
}
|
||||
|
||||
function onSendWorkOrder() {
|
||||
var alerttitle = GetTextByKey("P_WO_SENDWORKORDER", "Send Work Order");
|
||||
if (!workorderid || workorderid === "") {
|
||||
showAlert(GetTextByKey("P_WO_SAVEWORKORDERFIRST", "Please save work order first."), alerttitle);
|
||||
return;
|
||||
}
|
||||
|
||||
var emailaddress = [];
|
||||
var otheremailaddressstr = $('#sendworkorder_otheremailaddress').val();
|
||||
if (otheremailaddressstr !== "") {
|
||||
var address = otheremailaddressstr.split(';');
|
||||
for (var i = 0; i < address.length; i++) {
|
||||
if (!CheckEmail($.trim(address[i]))) {
|
||||
_dialog.showAlert(GetTextByKey("P_WO_OTHERADDRESSINVALID", 'The other email address {0} is invalid.').replace('{0}', emailaddress[i]), alerttitle);
|
||||
return;
|
||||
}
|
||||
emailaddress.push({ 'Key': '', 'Value': address[i] });
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < grid_contactdt.source.length; i++) {
|
||||
var ct = grid_contactdt.source[i].Values;
|
||||
if (ct.Email) {
|
||||
emailaddress.push({ 'Key': ct.IID, 'Value': ct.ID });
|
||||
}
|
||||
}
|
||||
|
||||
if (emailaddress.length == 0) {
|
||||
hideSendEmailPopup();
|
||||
return;
|
||||
}
|
||||
var desc = $('#sendworkorder_desc').val();
|
||||
worequest("SendWorkOrder", workorderid + String.fromCharCode(170) + JSON.stringify(emailaddress) + String.fromCharCode(170) + desc, function (data) {
|
||||
if (data !== 'OK') {
|
||||
showAlert(data, alerttitle);
|
||||
}
|
||||
else
|
||||
showAlert(GetTextByKey("P_WO_MESSAGESENT", 'Message sent'), alerttitle);
|
||||
|
||||
hideSendEmailPopup();
|
||||
}, function (err) {
|
||||
_dialog.showAlert(GetTextByKey("P_WO_FAILEDSENDWORKORDER", 'Failed to send work order.'), alerttitle);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//***********************Send Internal Comments Email Begin***********************************//
|
||||
|
||||
|
||||
var grid_iccontactdt;
|
||||
function InitICContactGridData() {
|
||||
grid_iccontactdt = new GridView('#iccontactlist');
|
||||
grid_iccontactdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'DisplayName', caption: GetTextByKey("P_WO_CONTACTNAME", "Contact Name"), valueIndex: 'DisplayName', css: { 'width': 148, 'text-align': 'left' } },
|
||||
{ name: 'ContactTypeName', caption: GetTextByKey("P_WO_CONTACTTYPE", "Contact Type"), valueIndex: 'ContactTypeName', css: { 'width': 148, 'text-align': 'left' } },
|
||||
{ name: 'Text', caption: "Text", valueIndex: 'Text', type: 3, css: { 'width': 45, 'text-align': 'center' } },
|
||||
{ name: 'Email', caption: GetTextByKey("P_WO_EMAIL", "Email"), valueIndex: 'Email', type: 3, css: { 'width': 60, 'text-align': 'center' } }
|
||||
];
|
||||
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.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
columns.push(col);
|
||||
if (col.name === "Text") {
|
||||
col.enabled = function (item) {
|
||||
return item.Mobile != null && $.trim(item.Mobile).length > 0;
|
||||
};
|
||||
}
|
||||
if (col.name === "Email") {
|
||||
col.enabled = function (item) {
|
||||
return item.ID !== '';
|
||||
};
|
||||
}
|
||||
}
|
||||
grid_iccontactdt.canMultiSelect = false;
|
||||
grid_iccontactdt.columns = columns;
|
||||
grid_iccontactdt.init();
|
||||
|
||||
grid_iccontactdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_iccontactdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showICContactList(newopen) {
|
||||
var filter = $('#sendinternalcomments_search').val().trim().toLowerCase();
|
||||
var rows = [];
|
||||
if (machineContacts && machineContacts.length > 0) {
|
||||
for (var i = 0; i < machineContacts.length; i++) {
|
||||
var r = machineContacts[i];
|
||||
if (newopen) {
|
||||
r.Text = false;
|
||||
r.Email = false;
|
||||
rows.push({ Values: r });
|
||||
}
|
||||
else {
|
||||
if (!r.Text && !r.Email) {
|
||||
if (r.DisplayName.toLowerCase().indexOf(filter) >= 0)
|
||||
rows.push({ Values: r });
|
||||
}
|
||||
else
|
||||
rows.push({ Values: r });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
grid_iccontactdt.setData(rows);
|
||||
}
|
||||
|
||||
function openSendICEmail() {
|
||||
var comment = internal?.text;
|
||||
if ($.trim(comment) == "") {
|
||||
return;
|
||||
}
|
||||
$('#sendic_otheremailaddress').val('');
|
||||
$('#sendic_phonenumber').val('');
|
||||
$('#sendinternalcomments_search').val('');
|
||||
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;
|
||||
}
|
||||
getMachineContacts(mid);
|
||||
|
||||
$('#sendicemailpopupmask').css('height', $('#dialog_workorder').height());
|
||||
$('#sendicemailpopupmask').css('min-width', $('#divcontent').width());
|
||||
$('#sendicemailpopupmask').show();
|
||||
$('#sendicemailpopupdialog').show();
|
||||
$('#sendicemailpopupdialog').css({
|
||||
"top": ($("#sendicemailpopupmask").height() - $('#sendicemailpopupdialog').height()) / 2,
|
||||
"left": ($("#sendicemailpopupmask").width() - $('#sendicemailpopupdialog').width()) / 2
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function hideSendICEmailPopup() {
|
||||
$('#sendicemailpopupmask').hide();
|
||||
$('#sendicemailpopupdialog').hide();
|
||||
}
|
||||
|
||||
function onSendInternalComments() {
|
||||
var comment = internal?.text;
|
||||
if ($.trim(comment) == "") {
|
||||
hideSendICEmailPopup();
|
||||
return;
|
||||
}
|
||||
var alerttitle = GetTextByKey("P_WO_SENDINTERNALCOMMENTS", "Send Internal Comments");
|
||||
var emailaddress = [];
|
||||
var otheremailaddressstr = $('#sendic_otheremailaddress').val();
|
||||
if (otheremailaddressstr !== "") {
|
||||
var address = otheremailaddressstr.split(';');
|
||||
for (var i = 0; i < address.length; i++) {
|
||||
if (!CheckEmail($.trim(address[i]))) {
|
||||
_dialog.showAlert(GetTextByKey("P_WO_OTHERADDRESSINVALID", 'The other email address {0} is invalid.').replace('{0}', emailaddress[i]), alerttitle);
|
||||
return;
|
||||
}
|
||||
emailaddress.push({ 'Key': '', 'Value': address[i] });
|
||||
}
|
||||
}
|
||||
|
||||
var phonenumbers = [];
|
||||
var pm = $('#sendic_phonenumber').val();
|
||||
if (pm !== "") {
|
||||
var pms = pm.split(';');
|
||||
for (var i = 0; i < pms.length; i++) {
|
||||
if (pms[i] === "")
|
||||
continue;
|
||||
if (!checkPhoneNumber(pms[i]) && !CheckEmail(pms[i])) {
|
||||
showAlert(GetTextByKey("P_WO_THEMOBILENUMBERISINVALID", "The mobile number {0} is invalid.").replace('{0}', pms[i]), alerttitle);
|
||||
return;
|
||||
}
|
||||
phonenumbers.push({ 'Key': '', 'Value': pms[i] });
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < grid_iccontactdt.source.length; i++) {
|
||||
var ct = grid_iccontactdt.source[i].Values;
|
||||
if (ct.Email) {
|
||||
emailaddress.push({ 'Key': ct.IID, 'Value': ct.ID });
|
||||
}
|
||||
if (ct.Text && (checkPhoneNumber(ct.Mobile) || CheckEmail(ct.Mobile))) {
|
||||
phonenumbers.push({ 'Key': ct.IID, 'Value': ct.Mobile });
|
||||
}
|
||||
}
|
||||
|
||||
var param = JSON.stringify([workorderid, comment, JSON.stringify(emailaddress), JSON.stringify(phonenumbers)]);
|
||||
param = htmlencode(param);
|
||||
worequest("SendInternalComments", param, function (data) {
|
||||
if (data !== "") {
|
||||
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
if (typeof internal !== 'undefined') {
|
||||
internal.text = '';
|
||||
}
|
||||
hideSendICEmailPopup();
|
||||
getComments();
|
||||
|
||||
}, function (err) {
|
||||
hideSendICEmailPopup();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
//***********************Send Internal Comments Email End***********************************//
|
Reference in New Issue
Block a user