fleet-contractor/Site/Maintenance/WorkOrderStatusManagement.aspx
2023-04-28 12:22:26 +08:00

1201 lines
56 KiB
Plaintext

<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="WorkOrderStatusManagement.aspx.cs" Inherits="WorkOrderStatusManagement" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<style type="text/css">
::-ms-clear, ::-ms-reveal {
display: none;
}
.tab-header {
float: left;
padding: 2px 6px;
cursor: pointer;
border: 1px solid #fff;
border-bottom: none;
}
.tab-header:hover {
background: #eee;
}
.tab-header.selected {
border-color: #d8d8d8;
cursor: default;
}
.tab-header.selected:hover {
background: #fff;
}
.label { /*cover tab.css*/
display: table-cell;
}
.login_lable {
height: 24px;
line-height: 24px;
vertical-align: top;
}
.sbutton {
font-weight: 200;
}
.msgdiv {
border: solid 1px lightgray;
margin-top: 5px;
padding-left: 5px;
padding-right: 10px;
padding-top: 3px;
padding-bottom: 3px;
line-height: 24px;
white-space: normal;
word-break: break-word;
overflow: hidden;
}
.msgtime {
text-align: right;
}
.dialog, .data-column-header-filter-panel, .data-column-header-filter-bg {
z-index: 700;
}
.subtitle {
margin: 20px 40px 5px 0px;
font-size: 16px;
color: gray;
}
.subtitle span {
margin-left: 10px;
}
.subtitle hr {
background-color: #d8d8d8;
border: none;
height: 1px;
}
.dialog-content table td.label {
width: 120px;
}
.dialog-content table td input[type="text"], .dialog-content table td textarea {
width: 320px;
}
</style>
<link href="<%=GetFileUrlWithVersion("../css/tabcontrol.css")%>" rel="stylesheet" />
<link href="<%=GetFileUrlWithVersion("../css/spectrum.css")%>" rel="stylesheet" type="text/css" />
<script src="../js/spectrum.js?v=1" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../js/controls.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../js/utility.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../js/language.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../js/modulelang.js")%>" type="text/javascript"></script>
<script type="text/javascript">
var custid = "";
var machines;
var loadingCount = 0;
function worequest(method, param, callback, error) {
_network.request("Maintenance/WorkOrderStatusManagement.aspx", -1, method, param, callback, error || function (e) {
console.log(e);
showmaskbg(false, true);
showAlert(GetTextByKey('P_UM_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_UM_QUERY', 'Query'));
});
}
function showstatusmask(flag) {
if (flag) {
$('#statusmask').fadeIn(100);
} else {
$('#statusmask').fadeOut(100);
}
}
function OnExit(type) {
window.parent.CloseWOStatusDialog(type);
}
var grid_dt;
function InitGridData() {
grid_dt = new GridView('#statuslist');
grid_dt.lang = {
all: GetTextByKey("P_GRID_ALL", "(All)"),
ok: GetTextByKey("P_GRID_OK", "OK"),
reset: GetTextByKey("P_GRID_RESET", "Reset")
};
var list_columns = [
{ name: 'Name', caption: GetTextByKey("P_WO_NAME", "Name"), valueIndex: 'Name', css: { 'width': 300, 'text-align': 'left' } },
{ name: 'StatusCode', caption: GetTextByKey("P_WO_STATUSCODE", "Status Code"), valueIndex: 'StatusCode', css: { 'width': 110, 'text-align': 'left' } },
{ name: 'Color', caption: GetTextByKey("P_WO_COLOR", "Color"), valueIndex: 'Color', css: { 'width': 60, 'text-align': 'center' } },
{ name: 'TechniciansAvailable', caption: GetTextByKey("P_WO_AVAILABLETOTECHNICANS", "Available to Technicians"), valueIndex: 'TechniciansAvailable', type: 3, css: { 'width': 150, 'text-align': 'center' } },
{ name: 'AutoText', caption: GetTextByKey("P_WO_AUTOUPDATECUSTOMER", "Auto Update Customer"), valueIndex: 'AutoText', type: 3, css: { 'width': 140, 'text-align': 'center' } },
{ name: 'Completed', caption: GetTextByKey("P_WO_COMPLETED", "Compeleted"), valueIndex: 'Completed', type: 3, css: { 'width': 100, 'text-align': 'center' } },
{ name: 'DefaultOnOpen', caption: GetTextByKey("P_WO_DEFAULTONOPEN", "Default on Open"), valueIndex: 'DefaultOnOpen', type: 3, css: { 'width': 100, 'text-align': 'center' } },
{ name: 'Message', caption: GetTextByKey("P_WO_MESSAGE", "Message"), valueIndex: 'Message', css: { 'width': 200, 'text-align': 'left' } },
{ name: 'FollowUpMessage', caption: GetTextByKey("P_WO_FOLLOWUPMESSAGE", "Follow Up Message"), valueIndex: 'FollowUpMessage', css: { 'width': 200, 'text-align': 'left' } },
{ name: 'WaitingPeriod', caption: GetTextByKey("P_WO_WAITINGPERIOD", "Waiting Period"), valueIndex: 'WaitingPeriod', css: { 'width': 100, 'text-align': 'left' } },
{ name: 'Repeating', caption: GetTextByKey("P_WO_ISREPEATING", "Repeating?"), valueIndex: 'Repeating', css: { 'width': 90, 'text-align': 'left' } },
{ name: 'Edit', caption: "", css: { 'width': 30, 'text-align': 'center' } },
{ name: 'Delete', caption: "", css: { 'width': 30, '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;
col.allowFilter = list_columns[hd].allowFilter;
col.type = list_columns[hd].type;
if (col.name === "Edit") {
col.isurl = true;
col.text = "\uf044";
col.sortable = false;
col.events = {
onclick: function () {
OnEdit();
}
};
col.classFilter = function (e) {
return "icon-col";
}
col.attrs = { 'title': GetTextByKey("P_UM_EDIT", 'Edit') };
}
else if (col.name === "Delete") {
col.isurl = true;
col.text = "\uf00d";
col.sortable = false;
col.events = {
onclick: function () {
OnDelete(this);
}
};
col.classFilter = function (e) {
return "icon-col";
};
col.styleFilter = function (e) {
if (e.Id == 100)
return { "display": "none" };
};
col.attrs = { 'title': GetTextByKey("P_UM_DELETE", 'Delete') };
} else if (col.name === 'Color') {
col.allowHtml = true;
col.filter = function (item) {
var cb = '<div style="background:' + item.Color + ';width:16px;height:16px;"></div>';
return cb;//+ item.Color;
};
col.styleFilter = function () {
return { display: 'block' };
};
}
else if (col.name === "TechniciansAvailable") {
col.events = {
onchange: function () {
var item = this;
UpdateWOStatusTechniciansAvailable(item.Id, item.TechniciansAvailable);
}
};
}
else if (col.name === "AutoText") {
col.events = {
onchange: function () {
var item = this;
UpdateWOStatusAutoText(item.Id, item.AutoText);
}
};
}
else if (col.name === "Completed") {
col.events = {
onchange: function () {
var item = this;
UpdateWOStatusType(item.Id, item.Completed ? 100 : 0);
}
};
col.enabled = function (e) {
return e.Id !== 100;
};
}
else if (col.name === "DefaultOnOpen") {
col.events = {
onchange: function () {
var item = this;
UpdateWODefaultOnOpen(item.Id, item.DefaultOnOpen ? 1 : 0);
for (var i = 0; i < grid_dt.source.length; i++) {
if (grid_dt.source[i].Values.Id != item.Id)
grid_dt.source[i].Values.DefaultOnOpen = false;
}
grid_dt.reload();
}
};
}
columns.push(col);
}
grid_dt.canMultiSelect = false;
grid_dt.columns = columns;
grid_dt.init();
grid_dt.rowdblclick = OnEdit;
}
function UpdateWOStatusTechniciansAvailable(id, value) {
var item = { 'Key': id, 'Value': value };
var p = htmlencode(JSON.stringify(item));
worequest('UpdateWOStatusTechniciansAvailable', p, function (data) {
if (data !== "OK") {
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
}
//OnRefresh();
});
}
function UpdateWOStatusAutoText(id, value) {
var item = { 'Key': id, 'Value': value };
var p = htmlencode(JSON.stringify(item));
worequest('UpdateWOStatusAutoText', p, function (data) {
if (data !== "OK") {
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
}
//OnRefresh();
});
}
function UpdateWOStatusType(id, value) {
var item = { 'Key': id, 'Value': value };
var p = htmlencode(JSON.stringify(item));
worequest('UpdateWOStatusType', p, function (data) {
if (data !== "OK") {
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
}
//OnRefresh();
});
}
function UpdateWODefaultOnOpen(id, value) {
var item = { 'Key': id, 'Value': value };
var p = htmlencode(JSON.stringify(item));
worequest('UpdateWODefaultOnOpen', p, function (data) {
if (data !== "OK") {
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
}
//OnRefresh();
});
}
function OnRefresh() {
showloading(true);
worequest('GetWorkOrderStatuses', '', function (data) {
showloading(false);
if (typeof (data) === "string") {
showAlert(data, GetTextByKey('P_WO_STATUSSETTING', "Status Setting"));
return;
}
showStatuses(data);
}, function (err) {
showloading(false);
});
}
function insertfield() {
var field = $("#dialog_variables").find("option:selected").text();
$("#dialog_message").focus();
document.execCommand('insertText', false, field);
}
function insertfufield() {
var field = $("#dialog_fuvariables").find("option:selected").text();
$("#dialog_fumessage").focus();
document.execCommand('insertText', false, field);
}
function insertfootnotefield() {
var field = $("#dialog_footnotevariables").find("option:selected").text();
$("#dialog_smsfootnotes").focus();
document.execCommand('insertText', false, field);
}
function insertestimatemsgfield() {
var field = $("#dialog_estimatemsgvariables").find("option:selected").text();
$("#dialog_estimatemsg").focus();
document.execCommand('insertText', false, field);
}
function insertinvoicemsgfield() {
var field = $("#dialog_invoicemsgvariables").find("option:selected").text();
$("#dialog_invoicemsg").focus();
document.execCommand('insertText', false, field);
}
function showStatuses(data) {
var rows = [];
for (var i = 0; i < data.length; i++) {
var r = data[i];
var repeating = "";
if (r.Repeating === 0)
repeating = GetTextByKey('P_WO_ONETIME', 'One Time');
else if (r.Repeating === 1)
repeating = GetTextByKey('P_WO_REPEATING', 'Repeating');
for (var j in r) {
if (j === "Repeating") {
r[j] = { DisplayValue: r["FollowUpMessage"] !== "" ? repeating : "", Value: r[j] };
}
else if (j === "WaitingPeriod") {
r[j] = { DisplayValue: (r["FollowUpMessage"] !== "" && r["WaitingPeriod"] > 0) ? (r["WaitingPeriod"] + " " + r["WaitingPeriodUom"]) : "", Value: r[j] };
}
}
var fr = { Values: r };
rows.push(fr);
}
grid_dt.setData(rows);
}
function OnAdd() {
statusid = undefined;
var alerttitle = GetTextByKey("P_WO_ADDSTATUS", 'Add Status')
$('#dialog_statusname').val("");
$('#dialog_statusname').prop("disabled", "");
$('#dialog_statuscolor').val('#000000');
$("#statuscolor").spectrum("set", "#000000");
$('#dialog_technicansavailable').prop('checked', false);
$('#dialog_autotext').prop('checked', false);
$('#dialog_statustype').prop('checked', false);
$('#dialog_statustype').prop('disabled', false);
$('#dialog_defaultonopen').prop('checked', false);
$('#dialog_message').val('');
$('#dialog_variables').val('');
$('#dialog_statuscode').val('');
$('#dialog_waitingperiod').val('');
$('#dialog_waitingperioduom').val('');
$('#dialog_repeating').val('');
$('#dialog_fumessage').val('');
$('#dialog_fuvariables').val('');
$('#dialog_status .dialog-title span.title').text(alerttitle);
$('#mask_bg').show();
$('#dialog_status')
.css({
'top': (document.documentElement.clientHeight - $('#dialog_status').height()) / 3,
'left': (document.documentElement.clientWidth - $('#dialog_status').width()) / 2
}).showDialogfixed();
}
var statusid;
function OnEdit() {
var index = grid_dt.selectedIndex;
if (index < 0) return;
var status = grid_dt.source[index].Values;
statusid = status.Id;
$('#dialog_statusname').val(status.Name);
if (statusid == 100) {
$('#dialog_statusname').prop("disabled", "disabled");
$('#dialog_statustype').prop('disabled', true);
}
else {
$('#dialog_statusname').prop("disabled", "");
$('#dialog_statustype').prop('disabled', false);
}
$('#dialog_statuscolor').val(status.Color);
$("#statuscolor").spectrum("set", status.Color);
$('#dialog_technicansavailable').prop('checked', status.TechniciansAvailable);
$('#dialog_autotext').prop('checked', status.AutoText);
$('#dialog_statustype').prop('checked', status.Completed);
$('#dialog_defaultonopen').prop('checked', status.DefaultOnOpen);
$('#dialog_message').val(status.Message);
$('#dialog_variables').val('');
$('#dialog_statuscode').val(status.StatusCode);
$('#dialog_waitingperiod').val(status.WaitingPeriod.Value < 0 ? '' : status.WaitingPeriod.Value);
$('#dialog_waitingperioduom').val(status.WaitingPeriodUom);
$('#dialog_repeating').val(status.Repeating.Value < 0 ? '' : status.Repeating.Value);
$('#dialog_fumessage').val(status.FollowUpMessage);
$('#dialog_fuvariables').val('');
$('#dialog_status .dialog-title span.title').text(GetTextByKey("P_WO_EDITSTATUS", 'Edit Status'));
$('#mask_bg').show();
$('#dialog_status')
.css({
'top': (document.documentElement.clientHeight - $('#dialog_status').height()) / 3,
'left': (document.documentElement.clientWidth - $('#dialog_status').width()) / 2
}).showDialogfixed();
}
var IsPositiveInteger1 = /^[1-9]\d*$/;
function onSaveStatus() {
showstatusmask(true);
var item = {
'Name': $.trim($('#dialog_statusname').val()),
'Color': $.trim($('#dialog_statuscolor').val()),
'TechniciansAvailable': $('#dialog_technicansavailable').prop('checked'),
'AutoText': $('#dialog_autotext').prop('checked'),
'StatusType': $('#dialog_statustype').prop('checked') ? 100 : 0,
'DefaultOnOpen': $('#dialog_defaultonopen').prop('checked') ? 1 : 0,
'Message': $.trim($('#dialog_message').val()),
'StatusCode': $.trim($('#dialog_statuscode').val()),
'WaitingPeriod': $.trim($('#dialog_waitingperiod').val()),
'WaitingPeriodUom': $('#dialog_waitingperioduom').val(),
'Repeating': $('#dialog_repeating').val(),
'FollowUpMessage': $.trim($('#dialog_fumessage').val())
};
if (item.Repeating == null)
item.Repeating = 0;
var alerttitle;
if (statusid || statusid == 0) {
item.Id = statusid;
alerttitle = GetTextByKey("P_WO_EDITSTATUS", "Edit Status");
} else {
item.Id = -1;
alerttitle = GetTextByKey("P_WO_ADDSTATUS", "Add Status");
}
if (!item.Name || item.Name.length == 0) {
showAlert(GetTextByKey("P_WO_NAMENOTBEEMPTY", 'Name cannot be empty.'), alerttitle, undefined, function () {
$('#dialog_statusname').focus();
showstatusmask(false);
});
return;
}
if (!item.Color || item.Color.length == 0) {
showAlert(GetTextByKey("P_WO_COLOREMPTY", 'Color cannot be empty.'), alerttitle, undefined, function () {
$('#dialog_statuscolor').focus();
showstatusmask(false);
});
return;
}
if (item.FollowUpMessage === "") {
item.WaitingPeriod = -1;
item.WaitingPeriodUom = "";
item.Repeating = -1;
}
else {
if (item.WaitingPeriod !== "") {
if (!IsPositiveInteger1.test(item.WaitingPeriod)) {
showAlert(GetTextByKey('P_WOS_WAITINGPERIODFORMATERROR', 'Waiting Period format error.'), alerttitle, undefined, function () {
$('#dialog_waitingperiod').focus();
showstatusmask(false);
});
return;
}
} else
item.WaitingPeriod = -1;
}
param = htmlencode(JSON.stringify(item));
worequest("SaveWorkOrderStatus", param, function (data) {
if (typeof (data) === "string") {
showAlert(data, alerttitle, undefined, function () {
showstatusmask(false);
});
} else {
$('#dialog_status').hideDialog();
showstatusmask(false);
OnRefresh();
}
}, function (err) {
showAlert(GetTextByKey("P_WO_FAILEDTOSAVESTATUS", 'Failed to save status.'), alerttitle);
});
}
function OnDelete(c) {
if (!c) {
return;
}
var alerttitle = GetTextByKey("P_WO_DELETESTATUS", 'Delete Status');
showConfirm(GetTextByKey("P_WO_DOYOUWANTTODELETETHISSTATUS", 'Do you want to delete this status?'), alerttitle, function () {
worequest('DeleteWorkOrderStatus', c.Id, function (data) {
if (typeof (data) === "string") {
showAlert(data, alerttitle);
} else {
OnRefresh();
}
}, function (err) {
showAlert(GetTextByKey('P_WO_FAILEDTODELETETHISSTATUS', 'Failed to delete this status.'), alerttitle);
});
});
}
function initColorCtrl() {
$("#statuscolor").spectrum({
allowEmpty: true,
color: "#FFF",
showInput: true,
containerClassName: "full-spectrum",
showInitial: true,
showPalette: true,
showSelectionPalette: true,
showAlpha: true,
maxPaletteSize: 10,
preferredFormat: "hex",
localStorageKey: "spectrum.demo",
chooseText: GetTextByKey("P_JS_OK", "OK"),
cancelText: GetTextByKey("P_JS_CANCEL", "Cancel"),
clearText: GetTextByKey("P_SPECTRUM_CLEARCOLORSELECTION", "Clear Color Selection"),
noColorSelectedText: GetTextByKey("P_SPECTRUM_NOCOLORSELECTED", "No Color Selected"),
move: function (color) {
if (color)
$("#dialog_statuscolor").val(color.toHexString().toUpperCase()); // #ff0000
},
show: function () {
},
beforeShow: function () {
},
hide: function (color) {
if (color) {
$("#dialog_statuscolor").val(color.toHexString().toUpperCase()); // #ff0000
}
},
palette: [
["rgb(0, 0, 0)", "rgb(67, 67, 67)", "rgb(102, 102, 102)", /*"rgb(153, 153, 153)","rgb(183, 183, 183)",*/
"rgb(204, 204, 204)", "rgb(217, 217, 217)", /*"rgb(239, 239, 239)", "rgb(243, 243, 243)",*/ "rgb(255, 255, 255)"],
["rgb(152, 0, 0)", "rgb(255, 0, 0)", "rgb(255, 153, 0)", "rgb(255, 255, 0)", "rgb(0, 255, 0)",
"rgb(0, 255, 255)", "rgb(74, 134, 232)", "rgb(0, 0, 255)", "rgb(153, 0, 255)", "rgb(255, 0, 255)"],
["rgb(230, 184, 175)", "rgb(244, 204, 204)", "rgb(252, 229, 205)", "rgb(255, 242, 204)", "rgb(217, 234, 211)",
"rgb(208, 224, 227)", "rgb(201, 218, 248)", "rgb(207, 226, 243)", "rgb(217, 210, 233)", "rgb(234, 209, 220)",
"rgb(221, 126, 107)", "rgb(234, 153, 153)", "rgb(249, 203, 156)", "rgb(255, 229, 153)", "rgb(182, 215, 168)",
"rgb(162, 196, 201)", "rgb(164, 194, 244)", "rgb(159, 197, 232)", "rgb(180, 167, 214)", "rgb(213, 166, 189)",
"rgb(204, 65, 37)", "rgb(224, 102, 102)", "rgb(246, 178, 107)", "rgb(255, 217, 102)", "rgb(147, 196, 125)",
"rgb(118, 165, 175)", "rgb(109, 158, 235)", "rgb(111, 168, 220)", "rgb(142, 124, 195)", "rgb(194, 123, 160)",
"rgb(166, 28, 0)", "rgb(204, 0, 0)", "rgb(230, 145, 56)", "rgb(241, 194, 50)", "rgb(106, 168, 79)",
"rgb(69, 129, 142)", "rgb(60, 120, 216)", "rgb(61, 133, 198)", "rgb(103, 78, 167)", "rgb(166, 77, 121)",
/*"rgb(133, 32, 12)", "rgb(153, 0, 0)", "rgb(180, 95, 6)", "rgb(191, 144, 0)", "rgb(56, 118, 29)",
"rgb(19, 79, 92)", "rgb(17, 85, 204)", "rgb(11, 83, 148)", "rgb(53, 28, 117)", "rgb(116, 27, 71)",*/
"rgb(91, 15, 0)", "rgb(102, 0, 0)", "rgb(120, 63, 4)", "rgb(127, 96, 0)", "rgb(39, 78, 19)",
"rgb(12, 52, 61)", "rgb(28, 69, 135)", "rgb(7, 55, 99)", "rgb(32, 18, 77)", "rgb(76, 17, 48)"]
]
});
}
/********************** SMS Auto-Send Schedule **********************/
function initTimeControl() {
var c = $('#smswt_starttimehour');
for (var i = 1; i <= 12; i++) {
c.append($("<option></option>").val(i).text(i))
}
c.val("08");
c = $('#smswt_starttimeminute');
for (var i = 0; i < 60; i++) {
if (i < 10)
c.append($("<option></option>").val("0" + i).text("0" + i))
else
c.append($("<option></option>").val(i).text(i))
}
c = $('#smswt_endtimehour');
for (var i = 1; i <= 12; i++) {
c.append($("<option></option>").val(i).text(i))
}
c.val("18");
c = $('#smswt_endtimeminute');
for (var i = 0; i < 60; i++) {
if (i < 10)
c.append($("<option></option>").val("0" + i).text("0" + i))
else
c.append($("<option></option>").val(i).text(i))
}
}
var daysArray = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
function getDays() {
var days = "";
if ($("#chkSu").prop("checked"))
days += daysArray[0] + ",";
if ($("#chkMo").prop("checked"))
days += daysArray[1] + ",";
if ($("#chkTu").prop("checked"))
days += daysArray[2] + ",";
if ($("#chkWe").prop("checked"))
days += daysArray[3] + ",";
if ($("#chkTh").prop("checked"))
days += daysArray[4] + ",";
if ($("#chkFr").prop("checked"))
days += daysArray[5] + ",";
if ($("#chkSa").prop("checked"))
days += daysArray[6] + ",";
if (days.length > 0)
days = days.substr(0, days.length - 1);
return days;
}
function setDays(days) {
$(".tdDays input").prop("checked", false);
if (days.indexOf(daysArray[0]) >= 0)
$("#chkSu").prop("checked", true);
if (days.indexOf(daysArray[1]) >= 0)
$("#chkMo").prop("checked", true);
if (days.indexOf(daysArray[2]) >= 0)
$("#chkTu").prop("checked", true);
if (days.indexOf(daysArray[3]) >= 0)
$("#chkWe").prop("checked", true);
if (days.indexOf(daysArray[4]) >= 0)
$("#chkTh").prop("checked", true);
if (days.indexOf(daysArray[5]) >= 0)
$("#chkFr").prop("checked", true);
if (days.indexOf(daysArray[6]) >= 0)
$("#chkSa").prop("checked", true);
}
function saveWOServiceTimeSetting() {
var days = getDays();
var startHour = $("#smswt_starttimehour").val();
var startHour_t = $("#smswt_starttimehour_t").val();
if (startHour_t == "AM") {
if (startHour == "12")
startHour = 0;
}
else {
if (startHour != "12")
startHour = eval(startHour) + 12;
}
var startMin = $("#smswt_starttimeminute").val();
var endHour = $("#smswt_endtimehour").val();
var endHour_t = $("#smswt_endtimehour_t").val();
if (endHour_t == "AM") {
if (endHour == "12")
endHour = 0;
}
else {
if (endHour != "12")
endHour = eval(endHour) + 12;
}
var endMin = $("#smswt_endtimeminute").val();
var alerttitle = GetTextByKey("P_WO_SETSCHEDULEFORAUTOMATICSMS", "Set Schedule for Automatic SMS Communications");
if (eval(startHour + startMin) > eval(endHour + endMin)) {
showAlert(GetTextByKey("P_CM_ENDTIMEMUSTBELATERTHANSTARTTIME", 'End Time must be later than Start Time.'), alerttitle);
return;
}
var param = days + ";" + startHour + ":" + startMin + ";" + endHour + ":" + endMin;
worequest("SetWOServiceTimeSetting", param, function (data) {
if (typeof (data) === "string") {
showAlert(data, alerttitle);
} else {
showmaskbg(false)
showAlert(GetTextByKey("P_WO_SAVSUCCESSFULLY", "Saved successfully."), alerttitle);
}
}, function (err) {
showAlert(GetTextByKey("P_WO_SAVESMSAUTOSENDSCHEDULEFAILED", 'Failed to save SMS Auto-Send schedule.'), alerttitle);
});
}
function getWOServiceTimeSetting() {
showloading(true);
worequest("GetWOServiceTimeSetting", "", function (data) {
showloading(false);
if (typeof (data) === "string") {
showAlert(data, alerttitle);
}
if (data && data.Setting && data.Setting !== "") {
var temps = data.Setting.split(';');
setDays(temps[0]);
var stime = temps[1].split(":");
var etime = temps[2].split(":");
var shour = eval(stime[0]);
if (shour == 0)
$("#smswt_starttimehour").val("12");
else
$("#smswt_starttimehour").val("" + (shour <= 12 ? shour : (shour - 12)));
$("#smswt_starttimehour_t").val(shour < 12 ? "AM" : "PM");
$("#smswt_starttimeminute").val(stime[1]);
var ehour = eval(etime[0]);
if (ehour == 0)
$("#smswt_endtimehour").val("12");
else
$("#smswt_endtimehour").val("" + (ehour <= 12 ? ehour : (ehour - 12)));
$("#smswt_endtimehour_t").val(ehour < 12 ? "AM" : "PM");
$("#smswt_endtimeminute").val(etime[1]);
}
else {
$(".tdDays input").prop("checked", true);
$("#smswt_starttimehour").val("8");
$("#smswt_starttimehour_t").val("AM");
$("#smswt_starttimeminute").val("00");
$("#smswt_endtimehour").val("6");
$("#smswt_endtimehour_t").val("PM");
$("#smswt_endtimeminute").val("00");
}
}, function (err) {
showloading(false);
});
}
/**********************End SMS Auto-Send Schedule **********************/
/**********************SMS Footnotes **********************/
function saveSMSFootnotes() {
var smsfootnotes = $("#dialog_smsfootnotes").val();
var alerttitle = GetTextByKey("P_WO_SMSFOOTNOTES", "SMS Footnotes");
worequest("SetSMSFootnotes", htmlencode(smsfootnotes), function (data) {
if (data !== "") {
showAlert(data, alerttitle);
} else {
showAlert(GetTextByKey("P_WO_SAVSUCCESSFULLY", "Saved successfully."), alerttitle);
}
}, function (err) {
});
}
function getSMSFootnotes() {
showloading(true);
worequest("GetSMSFootnotes", "", function (data) {
showloading(false);
//if (data !== "") {
// showAlert(data, GetTextByKey("P_WO_SMSFOOTNOTES", "SMS Footnotes"));
// return;
//}
$("#dialog_smsfootnotes").val(data);
}, function (err) {
showloading(false);
});
}
/**********************End SMS Footnotes **********************/
/**********************Estimate Setting**********************/
function saveEstimateSettings() {
var msg = $("#dialog_estimatemsg").val();
var poreq = $("#dialog_estimateporequired").prop("checked") ? "1" : "0";
var alerttitle = GetTextByKey("P_WO_ESTIMATES", "Estimates");
worequest("SetEstimateSettings", htmlencode(JSON.stringify([msg, poreq])), function (data) {
if (data !== "") {
showAlert(data, alerttitle);
} else {
showAlert(GetTextByKey("P_WO_SAVSUCCESSFULLY", "Saved successfully."), alerttitle);
}
}, function (err) {
});
}
function getEstimateSettings() {
showloading(true);
worequest("GetEstimateSettings", "", function (data) {
showloading(false);
if (data && typeof data != 'string') {
$("#dialog_estimatemsg").val(data[0]);
$("#dialog_estimateporequired").prop("checked", data[1] == "1");
}
}, function (err) {
showloading(false);
});
}
/**********************End Estimate Setting **********************/
/**********************SMS Invice Setting **********************/
function saveInvoiceSettings() {
var msg = $("#dialog_invoicemsg").val();
var alerttitle = GetTextByKey("P_WO_INVOICES", "Invoices");
worequest("SetInvoiceSettings", htmlencode(msg), function (data) {
if (data !== "") {
showAlert(data, alerttitle);
} else {
showAlert(GetTextByKey("P_WO_SAVSUCCESSFULLY", "Saved successfully."), alerttitle);
}
}, function (err) {
});
}
function getInvoiceSettings() {
showloading(true);
worequest("GetInvoiceSettings", "", function (data) {
showloading(false);
$("#dialog_invoicemsg").val(data);
}, function (err) {
showloading(false);
});
}
/**********************End Invoice Setting **********************/
function reshowgrid() {
setTimeout(function () {
grid_dt && grid_dt.resize();
});
}
$(function () {
InitGridData();
OnRefresh();
initColorCtrl();
initTimeControl();
$("#li_smsautosendschedule").click(function () {
if (!$("#li_smsautosendschedule").data("loaded")) {
$("#li_smsautosendschedule").data("loaded", true);
getWOServiceTimeSetting();
}
});
$("#li_smsfootnotes").click(function () {
if (!$("#li_smsfootnotes").data("loaded")) {
$("#li_smsfootnotes").data("loaded", true);
getSMSFootnotes();
}
});
$("#li_invoicemsg").click(function () {
if (!$("#li_invoicemsg").data("loaded")) {
$("#li_invoicemsg").data("loaded", true);
getInvoiceSettings();
}
});
$("#li_estimatemsg").click(function () {
if (!$("#li_estimatemsg").data("loaded")) {
$("#li_estimatemsg").data("loaded", true);
getEstimateSettings();
}
});
$("#div_container").tab();
$('#dialog_status').dialog(function () {
showmaskbg(false);
});
$('#dialog_statuscolor').keyup(null, function () {
$("#statuscolor").spectrum("set", $('#dialog_statuscolor').val());
});
$(window).resize(function () {
$("#statuslist").css("height", $(window).height() - $("#statuslist").offset().top - 4);
grid_dt && grid_dt.resize();
}).resize();
});
</script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div id="mask_bg" style="display: none; z-index: 500">
<div class="loading c-spin"></div>
</div>
<div id="div_container">
<ul id="ul_container" class="tab_header">
<li data-href="tab_statussetting" onclick="reshowgrid();" class="selected" data-lgid="P_WO_STATUSSETTING">Status Setting</li>
<%if (IsAdmin)
{%>
<li id="li_smsautosendschedule" data-href="tab_smsautosendschedule" data-lgid="P_WO_SMSAUTOSENDSCHEDULE">SMS Auto-Send Schedule</li>
<%}%>
<li id="li_smsfootnotes" data-href="tab_smsfootnotes" data-lgid="P_WO_SMSFOOTNOTES">SMS Footnotes</li>
<li id="li_estimatemsg" data-href="tab_estimatemsg" data-lgid="P_WO_ESTIMATES">Estimates</li>
<li id="li_invoicemsg" data-href="tab_invoicemsg" data-lgid="P_WO_INVOICES">Invoices</li>
</ul>
<div id="tab_statussetting" data-page="tab_statussetting">
<div class="function_title">
<span class="sbutton iconadd" onclick="OnAdd();" data-lgid="P_WO_ADD">Add</span>
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_WO_REFRESH">Refresh</span>
<span class="sbutton iconexit" onclick="OnExit(0);" data-lgid="P_WO_EXIT">Exit</span>
</div>
<div class="clear"></div>
<div id="statuslist"></div>
</div>
<div data-page="tab_smsautosendschedule" style="display: none;">
<div class="function_title">
<span class="sbutton iconsave" onclick="saveWOServiceTimeSetting();" data-lgid="P_WO_SAVE">Save</span>
<span class="sbutton iconexit" onclick="OnExit(0);" data-lgid="P_WO_EXIT">Exit</span>
</div>
<div class="clear"></div>
<table style="line-height: 32px; margin-left: 20px; margin-right: 10px; width: 450px;">
<tr class="tdDays">
<td class="label" data-lgid="P_CM_DAYS_COLON">Day(s):</td>
<td>
<input type="checkbox" id="chkSu" checked="checked" tabindex="3" style="width: auto; margin-left: 0px; margin-right: 2px;" class="middlechk" /><label for="chkSu" data-lgid="P_CM_SUNDAY">Sunday</label>
</td>
<td>
<input type="checkbox" id="chkMo" checked="checked" tabindex="4" style="width: auto; margin-left: 20px; margin-right: 2px;" class="middlechk" /><label for="chkMo" data-lgid="P_CM_MONDAY">Monday</label>
</td>
<td>
<input type="checkbox" id="chkTu" checked="checked" tabindex="5" style="width: auto; margin-left: 20px; margin-right: 2px;" class="middlechk" /><label for="chkTu" data-lgid="P_CM_TUESDAY">Tuesday</label>
</td>
<td>
<input type="checkbox" id="chkWe" checked="checked" tabindex="6" style="width: auto; margin-left: 20px; margin-right: 2px;" class="middlechk" /><label for="chkWe" data-lgid="P_CM_WEDNESDAY">Wednesday</label>
</td>
</tr>
<tr class="tdDays">
<td class="label"></td>
<td>
<input type="checkbox" id="chkTh" checked="checked" tabindex="7" style="width: auto; margin-left: 0px; margin-right: 2px;" class="middlechk" /><label for="chkTh" data-lgid="P_CM_THURSDAY">Thursday</label>
</td>
<td>
<input type="checkbox" id="chkFr" checked="checked" tabindex="8" style="width: auto; margin-left: 20px; margin-right: 2px;" class="middlechk" /><label for="chkFr" data-lgid="P_CM_FRIDAY">Friday</label>
</td>
<td>
<input type="checkbox" id="chkSa" checked="checked" tabindex="9" style="width: auto; margin-left: 20px; margin-right: 2px;" class="middlechk" /><label for="chkSa" data-lgid="P_CM_SATURDAY">Saturday</label>
</td>
<td></td>
</tr>
<tr>
<td class="label">Start Time:</td>
<td colspan="5">
<select id="smswt_starttimehour" style="width: 48px;">
</select>
<span style="font-weight: bold;">&nbsp;&nbsp;:&nbsp;&nbsp;</span>
<select id="smswt_starttimeminute" style="width: 48px;">
</select>
<select id="smswt_starttimehour_t" style="width: 48px;">
<option value="AM">AM</option>
<option value="PM">PM</option>
</select>
</td>
</tr>
<tr>
<td class="label">End Time:</td>
<td colspan="5">
<select id="smswt_endtimehour" style="width: 48px;">
</select>
<span style="font-weight: bold;">&nbsp;&nbsp;:&nbsp;&nbsp;</span>
<select id="smswt_endtimeminute" style="width: 48px;">
</select>
<select id="smswt_endtimehour_t" style="width: 48px;">
<option value="AM">AM</option>
<option value="PM">PM</option>
</select>
</td>
</tr>
</table>
</div>
<div data-page="tab_smsfootnotes" style="display: none;">
<div class="function_title">
<span class="sbutton iconsave" onclick="saveSMSFootnotes();" data-lgid="P_WO_SAVE">Save</span>
<span class="sbutton iconexit" onclick="OnExit(0);" data-lgid="P_WO_EXIT">Exit</span>
</div>
<div class="clear"></div>
<div class="subtitle" style="margin-top: 10px;">
<span data-lgid="P_WO_XXXXXX">Text Message Footnote</span>
<select id="dialog_footnotevariables" style="width: 156px; margin-left: 20px;">
<option value="0">[Site_Name]</option>
<option value="1">[Location]</option>
<option value="13">[Asset]</option>
<option value="4">[VIN]</option>
<option value="2">[Make]</option>
<option value="3">[Model]</option>
<option value="5">[Id_Phone]</option>
<option value="6">[Advisor]</option>
<option value="7">[Company_Name]</option>
<option value="8">[Contact_Name]</option>
<option value="9">[Contact_First_Name]</option>
<option value="10">[Status_Link]</option>
<option value="11">[Technician_Name]</option>
<option value="12">[Work_Order_Number]</option>
<option value="13">[Parts_Order_Number]</option>
</select>
<input type="button" onclick="insertfootnotefield();" data-lgid="P_WO_ADD" style="width: auto; margin-left: 5px;" tabindex="1" />
</div>
<div>
<textarea id="dialog_smsfootnotes" style="width: 640px; height: 160px;" maxlength="200"></textarea>
</div>
</div>
<div data-page="tab_estimatemsg" style="display: none;">
<div class="function_title">
<span class="sbutton iconsave" onclick="saveEstimateSettings();" data-lgid="P_WO_SAVE">Save</span>
<span class="sbutton iconexit" onclick="OnExit(0);" data-lgid="P_WO_EXIT">Exit</span>
</div>
<div class="clear"></div>
<div class="subtitle" style="margin-top: 10px;">
<span data-lgid="P_WO_XXXXXX">Message</span>
<select id="dialog_estimatemsgvariables" style="width: 156px; margin-left: 20px;">
<option value="0">[Site_Name]</option>
<option value="1">[Location]</option>
<option value="13">[Asset]</option>
<option value="4">[VIN]</option>
<option value="2">[Make]</option>
<option value="3">[Model]</option>
<option value="5">[Id_Phone]</option>
<option value="6">[Advisor]</option>
<option value="7">[Company_Name]</option>
<option value="8">[Contact_Name]</option>
<option value="9">[Contact_First_Name]</option>
<option value="10">[Status_Link]</option>
<option value="11">[Technician_Name]</option>
<option value="12">[Work_Order_Number]</option>
<option value="13">[Parts_Order_Number]</option>
</select>
<input type="button" onclick="insertestimatemsgfield();" data-lgid="P_WO_ADD" style="width: auto; margin-left: 5px;" tabindex="1" />
</div>
<div>
<textarea id="dialog_estimatemsg" style="width: 640px; height: 160px;" maxlength="200"></textarea>
</div>
<div>
<label data-lgid="P_WO_XXXXXX" for="dialog_estimateporequired">Default to PO Required: </label>
<input type="checkbox" id="dialog_estimateporequired" />
</div>
</div>
<div data-page="tab_invoicemsg" style="display: none;">
<div class="function_title">
<span class="sbutton iconsave" onclick="saveInvoiceSettings();" data-lgid="P_WO_SAVE">Save</span>
<span class="sbutton iconexit" onclick="OnExit(0);" data-lgid="P_WO_EXIT">Exit</span>
</div>
<div class="clear"></div>
<div class="subtitle" style="margin-top: 10px;">
<span data-lgid="P_WO_XXXXXX">Message</span>
<select id="dialog_invoicemsgvariables" style="width: 156px; margin-left: 20px;">
<option value="0">[Site_Name]</option>
<option value="1">[Location]</option>
<option value="13">[Asset]</option>
<option value="4">[VIN]</option>
<option value="2">[Make]</option>
<option value="3">[Model]</option>
<option value="5">[Id_Phone]</option>
<option value="6">[Advisor]</option>
<option value="7">[Company_Name]</option>
<option value="8">[Contact_Name]</option>
<option value="9">[Contact_First_Name]</option>
<option value="10">[Status_Link]</option>
<option value="11">[Technician_Name]</option>
<option value="12">[Work_Order_Number]</option>
<option value="13">[Parts_Order_Number]</option>
</select>
<input type="button" onclick="insertinvoicemsgfield();" data-lgid="P_WO_ADD" style="width: auto; margin-left: 5px;" tabindex="1" />
</div>
<div>
<textarea id="dialog_invoicemsg" style="width: 640px; height: 160px;" maxlength="200"></textarea>
</div>
</div>
</div>
<div class="dialog" id="dialog_status" style="display: none;">
<div class="dialog-title"><span class="title" data-lgid="P_WO_ADDSTATUS">Add Status</span><em class="dialog-close"></em></div>
<div class="dialog-content">
<table style="line-height: 30px; table-layout: fixed; width: 620px;">
<tr>
<td class="label" style="width: 155px;"><span data-lgid="P_WO_NAME_COLON">Name:</span><span class="redasterisk">*</span></td>
<td>
<input type="text" id="dialog_statusname" tabindex="1" maxlength="200" autocomplete="off" /></td>
</tr>
<tr>
<td class="label" style="width: 155px;"><span data-lgid="P_WO_STATUSCODE_COLON">Status Code:</span></td>
<td>
<input type="text" id="dialog_statuscode" tabindex="1" maxlength="15" autocomplete="off" style="width: 140px;" /></td>
</tr>
<tr>
<td class="label"><span data-lgid="P_WO_COLOR_COLON">Color:</span><span class="redasterisk">*</span></td>
<td>
<input type="text" id="dialog_statuscolor" autocomplete="off" maxlength="20" tabindex="1" style="width: 140px;" />
<input id="statuscolor" /></td>
</tr>
<tr>
<td class="label"><span data-lgid="P_WO_AVAILABLETOTECHNICANS_COLON">Available to Technicians:</span></td>
<td>
<input type="checkbox" id="dialog_technicansavailable" style="width: auto;" tabindex="1" />
</td>
</tr>
<tr>
<td class="label"><span data-lgid="P_WO_AUTOUPDATECUSTOMER_COLON" style="margin-left: 30px;">P_WO_AUTOUPDATECUSTOMER_COLON:</span></td>
<td>
<input type="checkbox" id="dialog_autotext" style="width: auto; margin-left: 5px;" tabindex="1" />
</td>
</tr>
<tr>
<td class="label"><span data-lgid="P_WO_COMPLETED_COLON" style="margin-left: 30px;">Completed:</span></td>
<td>
<input type="checkbox" id="dialog_statustype" style="width: auto; margin-left: 5px;" tabindex="1" />
</td>
</tr>
<tr>
<td class="label"><span data-lgid="P_WO_DEFAULTONOPEN_COLON" style="margin-left: 30px;">Default on Open:</span></td>
<td>
<input type="checkbox" id="dialog_defaultonopen" style="width: auto; margin-left: 5px;" tabindex="1" />
</td>
</tr>
<tr>
<td class="label" style="width: 130px;"><span data-lgid="P_WO_MESSAGE_COLON">Message:</span></td>
<td>
<select id="dialog_variables" style="width: 156px;">
<option value="0">[Site_Name]</option>
<option value="1">[Location]</option>
<option value="13">[Asset]</option>
<option value="4">[VIN]</option>
<option value="2">[Make]</option>
<option value="3">[Model]</option>
<option value="5">[Id_Phone]</option>
<option value="6">[Advisor]</option>
<option value="7">[Company_Name]</option>
<option value="8">[Contact_Name]</option>
<option value="9">[Contact_First_Name]</option>
<option value="10">[Status_Link]</option>
<option value="11">[Technician_Name]</option>
<option value="12">[Work_Order_Number]</option>
<option value="13">[Parts_Order_Number]</option>
</select>
<input type="button" onclick="insertfield();" data-lgid="P_WO_ADD" style="width: auto; margin-left: 5px;" tabindex="1" />
<textarea id="dialog_message" tabindex="1" style="width: 442px; height: 80px;" maxlength="1000"></textarea></td>
</tr>
<tr>
<td class="label" style="width: 130px;"><span data-lgid="P_WO_FOLLOWUPMESSAGE_COLON">Follow Up Message:</span></td>
<td>
<select id="dialog_fuvariables" style="width: 156px;">
<option value="0">[Site_Name]</option>
<option value="1">[Location]</option>
<option value="13">[Asset]</option>
<option value="4">[VIN]</option>
<option value="2">[Make]</option>
<option value="3">[Model]</option>
<option value="5">[Id_Phone]</option>
<option value="6">[Advisor]</option>
<option value="7">[Company_Name]</option>
<option value="8">[Contact_Name]</option>
<option value="9">[Contact_First_Name]</option>
<option value="10">[Status_Link]</option>
<option value="11">[Technician_Name]</option>
<option value="12">[Work_Order_Number]</option>
<option value="13">[Parts_Order_Number]</option>
</select>
<input type="button" onclick="insertfufield();" data-lgid="P_WO_ADD" style="width: auto; margin-left: 5px;" tabindex="1" />
<input type="text" id="dialog_waitingperiod" tabindex="1" maxlength="8" autocomplete="off" style="width: 60px; margin-left: 10px;" />
<select id="dialog_waitingperioduom" style="width: 80px;">
<option value="Hours">Hours</option>
<option value="Days">Days</option>
<option value="Weeks">Weeks</option>
<option value="Months">Months</option>
</select>
<select id="dialog_repeating" style="width: 80px;">
<option value="0" data-lgid="P_WO_ONETIME">One Time</option>
<option value="1" data-lgid="P_WO_REPEATING">Repeating</option>
</select>
<textarea id="dialog_fumessage" tabindex="1" style="width: 442px; height: 80px;" maxlength="1000"></textarea></td>
</tr>
</table>
</div>
<div class="dialog-func">
<input type="button" value="Cancel" data-lgid="P_UM_CANCEL" class="dialog-close" tabindex="18" style="height: 26px;" />
<input type="button" onclick="onSaveStatus();" value="OK" data-lgid="P_UM_OK" tabindex="17" />
<div style="clear: both;"></div>
</div>
<div class="maskbg" id="statusmask" style="display: none;"></div>
</div>
</asp:Content>