This commit is contained in:
2023-04-28 12:22:26 +08:00
parent 88e0a25ecd
commit c9723008af
1047 changed files with 443540 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,57 @@
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site;
using IronIntel.Contractor.Site.Customer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class AddCustomerRecord : CustomerRecordBasePage
{
protected string IID;
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
protected bool CRReadOnly = false;
protected bool AllowCanOpenWO = false;
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest();
}
else if (!IsPostBack)
{
this.Title = PageTitle;
bool license = SystemParams.HasLicense("CustomerRecord");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.CUSTOMER_RECORD);
if (!permission)
RedirectToLoginPage();
CRReadOnly = CheckReadonly(SystemParams.CompanyID, Feature.CUSTOMER_RECORD);
AllowCanOpenWO = SystemParams.HasLicense("AllowWOCreationFromFleetManagementPage");
}
}
}
public bool IsSupperAdmin
{
get
{
var user = GetCurrentUser();
return user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,75 @@
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site;
using IronIntel.Contractor.Site.Maintenance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class AddFuelRecord : FuelRecordBasePage
{
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
this.Title = PageTitle;
bool license = SystemParams.HasLicense("FuelRecords");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.FUEL_RECORDS);
if (!permission)
RedirectToLoginPage();
}
}
}
protected override bool ThrowIfNotAllowed
{
get
{
return true;
}
}
protected override bool AllowCurrentLoginSessionEnter()
{
var f = base.AllowCurrentLoginSessionEnter();
if (!f)
{
return false;
}
var user = GetCurrentUser();
return user != null && user.UserType >= IronIntel.Contractor.Users.UserTypes.Common;
}
public bool IsAdmin
{
get
{
var user = GetCurrentUser();
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
return true;
else
return false;
}
}
}

View File

@ -0,0 +1,556 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="AddMaintenanceRecord.aspx.cs" Inherits="AddMaintenanceRecord" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<style type="text/css">
::-ms-clear, ::-ms-reveal {
display: none;
}
.edit-content table {
border-collapse: collapse;
width: 100%;
}
.edit-content table td.label {
width: 200px;
text-align: right;
padding-right: 10px;
line-height: 24px;
height: 24px;
vertical-align: top;
}
.edit-content table td input,
.edit-content table td textarea {
border: 1px solid #a9a9a9;
width: 320px;
height: 18px;
padding: 1px;
}
.edit-content table td input[type="checkbox"] {
border: none;
}
.edit-content table td textarea {
height: 100px;
resize: none;
/*max-width: 200px;*/
}
.a {
text-decoration: none;
color: #2140fb;
}
.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;
}
.machinetd {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
#host_main {
overflow: hidden;
}
</style>
<link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" />
<script src="<%=GetFileUrlWithVersion("../Maintenance/js/inputdatactr.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script>
<script src="<%=GetFileUrlWithVersion("../js/editableselect.js")%>"></script>
<script src="<%=GetFileUrlWithVersion("js/maintenancelogattachment.js")%>" type="text/javascript"></script>
<script type="text/javascript">
var maintenanceid = ""; <%--"<%=MaintenanceID %>";--%>
var machineid = "";<%--"<%=MachineID %>";--%>
var _attachments = [];
var isshowdelete = true;
var currentdate = "<%=CurrentDate %>";
function maintenancerequest(method, param, callback, error) {
_network.request("Maintenance/AddMaintenanceRecord.aspx", -1, method, param, callback, error || function (e) {
console.log(e);
showmaskbg(false, true);
showAlert(GetTextByKey('P_MRM_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_MRM_QUERY', 'Query'));
});
}
function getUnCompletedPMAlerts(next) {
$('#pmAlerts_tbody').empty();
showloading(true);
maintenancerequest("GetUnCompletedPMAlerts", machineid + String.fromCharCode(170) + maintenanceid, function (data) {
showloading(false);
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_MRM_ERROR", 'Error'));
return;
}
var alerts = data;
for (var i = 0; i < alerts.length; i++) {
var alert = alerts[i]
var tr = $('<tr></tr>').attr('alertid', alert.AlertID);
var tdalertid = $('<td style="word-wrap:break-word;word-break:break-all;"></td>').text(alert.AlertID);
var tdtitle = $('<td style="word-wrap:break-word;word-break:break-all;"></td>').text(alert.AlertTitle);
var tdtime = $('<td style="word-wrap:break-word;word-break:break-all;"></td>').text(alert.AlertTime);
tr.click(tr, function (e) {
var alertid = $(this).attr("alertid");
if (e.data.hasClass("selected"))
$('#dialog_pmalerts').val("");
else
$('#dialog_pmalerts').val(alertid);
$('#dialog_pmalerts').focus();
});
tr.append(tdalertid, tdtitle, tdtime);
$('#pmAlerts_tbody').append(tr);
var rid = $('#dialog_pmalerts').val();//maintenanceid
if (rid == alert.AlertID + '')
tr.addClass("selected");
}
if (next)
next();
}, function (err) {
console.log(err);
showloading(false);
});
}
function OnAdd() {
$("#dialog_pmalerts").attr("disabled", false);
$('#dig_mtype').attr("disabled", false);
$('#dialog_pmalerts').val('');
$('#dialog_mdate').val('');
$('#dialog_hours').val('');
$('#dialog_notes').val('');
$('#dialog_cost').val('');
$('#dialog_invoicenumber').val('');
$('#dig_completedby').val('');
$('#dig_mtype').val('Hours');
$('#dialog_distance').val('');
$('#dig_uom').val(systemunitofodometer);
$('#tr_distance').hide();
$('#tr_hours').show();
$('#tabAttachments').hide();
$("#tbAttas").empty();
$('#dateformatspan').css('display', '');
}
var recorddata;
function OnEdit() {
$('#dig_mtype').attr("disabled", true);
showloading(true);
maintenancerequest("GetMaintenanceInfo", maintenanceid, function (data) {
showloading(false);
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_MRM_ERROR", 'Error'));
return;
}
var record = data;
recorddata = record;
if (record.LogType === "Hours"
|| record.LogType === "Undercarriage"
|| record.LogType === "TimeOffRoad") {
$('#tr_distance').hide();
$('#tr_hours').show();
}
else {
$('#tr_hours').hide();
$('#tr_distance').show();
}
if (record.LogType === "Undercarriage"
|| record.LogType === "TimeOffRoad"
|| record.LogType === "TimeOverRoad") {
$("#dialog_pmalerts").val("").attr("disabled", true);
}
else {
$("#dialog_pmalerts").attr("disabled", false);
}
if (record.AlertID > 0) {
$('#dialog_pmalerts').val(record.AlertID);
}
else {
$('#dialog_pmalerts').val('');
}
$('#dialog_mdate').val(record.StrForMaintenanceDate);
$('#dialog_hours').val(record.MaintenanceHours);
$('#dialog_notes').val(record.Notes);
$('#dig_mtype').val(record.LogType);
$('#dialog_distance').val(record.ODOMeter);
$('#dig_uom').val(record.ODOMemterUOM);
$('#dialog_cost').val(record.Cost);
$('#dialog_invoicenumber').val(record.InvoiceNumber);
$('#dig_completedby').val(record.CompletedByName);
if ($.trim($('#dialog_mdate').val()) == "") {
$('#dateformatspan').css('display', '');
}
else {
$('#dateformatspan').css('display', 'none');
}
getMaintenanceLogAttachments();
}, function (err) {
console.log(err);
showloading(false);
});
}
function OnSave(exit, callback) {
var mdate = $.trim($('#dialog_mdate').val());
var hoursvalue = $.trim($('#dialog_hours').val());
var mnote = $.trim($('#dialog_notes').val());
var logtype = $.trim($('#dig_mtype').val());
var odomer = $.trim($('#dialog_distance').val());
var odomeruom = $.trim($('#dig_uom').val());
var cost = $.trim($('#dialog_cost').val());
var invoicenumber = $.trim($('#dialog_invoicenumber').val());
var completedbyname = $.trim($('#dig_completedby').val());
var alerttitle = GetTextByKey("P_MRM_SYSTEMINFORMATION", "System Information");
if (mdate.length == 0
|| ((logtype == "Hours" || logtype == "Undercarriage" || logtype == "TimeOffRoad") && hoursvalue.length == 0)
|| ((logtype == "Distance" || logtype == "TimeOverRoad") && odomer.length == 0)
|| mnote.length == 0) {
showAlert(GetTextByKey("P_MRM_ITEMSMUSTREQUIRED", "The items with * are required."), alerttitle);
return false;
}
if (!checkDate(mdate)) {
$('#dialog_user').css('z-index', 0);
showAlert(GetTextByKey("P_MRM_DATEFORMATERROR", "Date format error."), alerttitle);
return false;
}
else {
var dat1 = new Date(mdate);
var curdate = new Date(currentdate);
if (dat1 > curdate) {
showAlert(GetTextByKey("P_MRM_MAINTENANCEDATENOTBEINTHEFUTURE", "Maintenance Date cannot be in the future."), alerttitle);
return false;
}
}
if (logtype === "Hours"
|| logtype === "Undercarriage"
|| logtype === "TimeOffRoad") {
odomer = 0;
odomeruom = "";
if (parseFloat(hoursvalue) <= 0 || hoursvalue == "" || isNaN(hoursvalue)) {
$('#dialog_user').css('z-index', 0);
showAlert(GetTextByKey("P_MRM_MAINTENANCEHOURSVALUEMUSTBEGREATERTHAN0", "Maintenance Hours value must be greater than 0."), alerttitle);
return false;
}
}
else {
hoursvalue = 0;
if (parseFloat(odomer) <= 0 || odomer == "" || isNaN(odomer)) {
$('#dialog_user').css('z-index', 0);
showAlert(GetTextByKey("P_MRM_MAINTENANCEDISTANCEVALUEMUSTBEGREATERTHAN0", "Maintenance Distance value must be greater than 0."), alerttitle);
return false;
}
}
if (cost !== "") {
if (parseFloat(cost) < 0 || isNaN(cost)) {
$('#dialog_cost').css('z-index', 0);
showAlert(GetTextByKey("P_MRM_COSTVALUEMUSTBEGREATERTHAN0", "Cost Value must be greater than 0."), alerttitle);
return false;
}
}
if (cost === "")
cost = 0;
var alertid = ($('#dialog_pmalerts').val() == "" ? "-1" : $('#dialog_pmalerts').val());
if (logtype === "Undercarriage"
|| logtype === "TimeOffRoad"
|| logtype === "TimeOverRoad")
alertid = "-1";
var item = {
MaintenanceID: maintenanceid,
AlertID: alertid,
MachineID: machineid,
MaintenanceDate: mdate,
MaintenanceHours: hoursvalue,
ODOMeter: odomer,
ODOMemterUOM: odomeruom,
Notes: mnote,
Cost: cost,
InvoiceNumber: invoicenumber,
CompletedByName: completedbyname,
LogType: logtype,
AttachmentIDs: _attachments
}
var param = JSON.stringify(item);
param = htmlencode(param);
showloading(true);
maintenancerequest("Addmaintenance", param, function (data) {
showloading(false);
var title = GetTextByKey("P_MRM_SAVEMAINTENANCERECORD", 'Save Maintenance Record');
if (typeof (data) === "string") {
if (data === "Failed to save,The user is not logged.")
data = GetTextByKey("P_MRM_FAILEDTOSAVETHEUSERISNOTLOGGED", "Failed to save,The user is not logged.");
showAlert(data, title);
} else {
maintenanceid = data[0];
if (callback) {
callback(item);
}
else {
if (exit == 0)
showAlert(GetTextByKey("P_MRM_SAVSUCCESSFULLY", data[1]), title);
if (exit == 1)
OnExit(exit);
}
}
}, function (err) {
console.log(err);
showloading(false);
showAlert(GetTextByKey("P_MRM_FAILEDTOSAVEMAINTENANCERECORD", 'Failed to save Maintenance Record.'), title);
});
}
function OnExit(type) {
window.parent.CloseDialog(type);
}
function init(mid, mcid) {
machineid = mid;
maintenanceid = mcid;
OnAdd();
if (maintenanceid !== undefined && maintenanceid !== '') {
getUnCompletedPMAlerts(OnEdit);
}
else {
getUnCompletedPMAlerts();
}
}
$(function () {
init();
$('#dialog_mdate').click(function () { $('#dateformatspan').css('display', 'none'); }).blur(function () {
if ($.trim($(this).val()) == "") {
$('#dateformatspan').css('display', '');
}
else {
$('#dateformatspan').css('display', 'none');
}
})
$('#dialog_mdate').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]);
}
})
InputControl($('#dialog_hours'));
$('#dialog_hours').change(function () { if (!inputValueFormat(this)) { $(this).val(''); } })
$(document).mouseup(function (e) {
var targetE = e.target;
if (!targetE.id || (targetE.id != "dialog_pmalerts" && targetE.id != "pmAlertDropDIV"))
$("#pmAlertDropDIV").hide();
});
$("#dialog_pmalerts_span").click(function () {
var mtype = $('#dig_mtype').val();
if (mtype === "Undercarriage"
|| mtype === "TimeOffRoad"
|| mtype === "TimeOverRoad")
return;
$("#pmAlertDropDIV").show();
$('#pmAlerts_tbody tr').each(function (item) {
var tr = $(this);
var alertid = tr.attr('alertid')
tr.removeClass("selected");
var rid = $('#dialog_pmalerts').val();//maintenanceid
if (rid == alertid + '')
tr.addClass("selected");
})
});
$("#dialog_pmalerts_span").keydown(function (e) {
if (event.which == 9) {
$("#pmAlertDropDIV").hide();
}
if (event.which == 8)
return false;
});
$('#dig_mtype').change(function () {
var logType = $(this).val();
if (logType === "Hours"
|| logType === "Undercarriage"
|| logType === "TimeOffRoad") {
$('#tr_distance').hide();
$('#tr_hours').show();
}
else {
$('#tr_hours').hide();
$('#tr_distance').show();
}
if (logType === "Undercarriage"
|| logType === "TimeOffRoad"
|| logType === "TimeOverRoad") {
$("#dialog_pmalerts").val("").attr("disabled", true);
}
else {
$("#dialog_pmalerts").attr("disabled", false);
}
});
function resizeContent() {
$('#divcontent').css('height', $(window).height() - $('#divcontent').offset().top - 4);
$('.content_main').css('min-height', 0);
}
window.onresize = resizeContent;
resizeContent();
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div>
<div>
<div class="function_title">
<span class="sbutton iconsave" onclick="OnSave(0);" data-lgid="P_MRM_SAVE">Save</span>
<span class="sbutton iconsave" onclick="OnSave(1);" data-lgid="P_MRM_SAVE1">Save and Exit</span>
<span class="sbutton iconexit" onclick="OnExit(0);" data-lgid="P_MRM_SAVE2">Exit Without Saving</span>
</div>
<div class="clear"></div>
<div id="divcontent" style="overflow: auto;">
<div class="edit-content">
<div class="subtitle">
<span data-lgid="P_MRM_MAINTENANCEINFORMATION">Maintenance Information</span>
<hr />
</div>
<table id="dialogdatatb" style="line-height: 30px;">
<tr>
<td class="label" data-lgid="P_MRM_PMALERT_COLON">PM Alert:</td>
<td>
<span id="dialog_pmalerts_span">
<input type="text" id="dialog_pmalerts" tabindex="1" maxlength="15" readonly="readonly" />
<img style="margin-left: -18px; width: 7px; height: 7px;" src="../img/desc.jpg" /></span>
<div id="pmAlertDropDIV" style="border: 1px solid #b0b0b0; width: 675px; height: 400px; overflow: auto; position: absolute; left: 212px; background-color: Window; display: none; z-index: 10; margin-top: -3px;">
<table id="pmAlertDropTable" class="main_table" style="border: none; width: 675px;">
<thead>
<tr id="pmAlertDropTitle" style="border-width: 0px; background-color: #d3d1d1;">
<th data-lgid="P_MRM_ALERTID">Alert ID</th>
<th data-lgid="P_MRM_ALERTTITLE">&nbsp;Alert Title</th>
<th style="width: 145px;" data-lgid="P_MRM_ALERTTIME">&nbsp;Alert Time</th>
</tr>
</thead>
<tbody id="pmAlerts_tbody">
</tbody>
</table>
</div>
</td>
</tr>
<tr>
<td class="label"><span data-lgid="P_MRM_MAINTENANCEDATE_COLON">Maintenance Date:</span><span style="color: red; margin-left: 3px;">*</span></td>
<td>
<input type="text" id="dialog_mdate" tabindex="2" /><span id="dateformatspan" style="color: #b0b0b0; position: absolute; left: 220px;" onclick="$(this).css('display','none');$('#dialog_mdate').focus();">Format:(MM/DD/YYYY)</span></td>
</tr>
<tr>
<td class="label"><span data-lgid="P_MRM_MAINTENANCETYPE_COLON">Maintenance Type:</span><span style="color: red; margin-left: 3px;">*</span></td>
<td>
<select id="dig_mtype" disabled="disabled" style="width: 324px; height: 22px;" tabindex="3">
<option value="Hours" data-lgid="P_MRM_HOURS">Hours</option>
<option value="Distance" data-lgid="P_MRM_DISTANCE">Distance</option>
<option value="Undercarriage" data-lgid="P_MRM_UNDERCARRIAGE">Undercarriage</option>
<option value="TimeOffRoad" data-lgid="P_MRM_TIMEOFFROAD">Time/Off-Road</option>
<option value="TimeOverRoad" data-lgid="P_MRM_TIMEOVERROAD">Time/Over Road</option>
</select></td>
</tr>
<tr id="tr_hours">
<td class="label"><span data-lgid="P_MRM_MAINTENANCEHOURS_COLON">Maintenance Hours:</span><span style="color: red; margin-left: 3px;">*</span></td>
<td>
<input type="text" id="dialog_hours" tabindex="4" maxlength="15" /></td>
</tr>
<tr id="tr_distance">
<td class="label" style="width: 151px;"><span data-lgid="P_MRM_MAINTENANCEDISTANCE_COLON">Maintenance Distance:</span> <span style="color: red; margin-left: 3px; width: 151px;">*</span></td>
<td>
<input type="text" id="dialog_distance" tabindex="4" maxlength="15" style="width: 227px;" />
<select id="dig_uom" style="width: 90px; height: 22px;" tabindex="5">
<option value="Mile" data-lgid="P_MRM_MILE">Mile</option>
<option value="Kilometre" data-lgid="P_MRM_KILOMETER">Kilometer</option>
</select>
</td>
</tr>
<tr>
<td class="label" data-lgid="P_MRM_COST_COLON">Cost:</td>
<td>
<input type="text" id="dialog_cost" tabindex="6" maxlength="15" /></td>
</tr>
<tr>
<td class="label" data-lgid="P_MRM_INVOICENUMBER_COLON">Invoice Number:</td>
<td>
<input type="text" id="dialog_invoicenumber" tabindex="7" maxlength="50" /></td>
</tr>
<tr>
<td class="label" data-lgid="P_MRM_COMPLETEDBY_COLON">Completed By:</td>
<td>
<input type="text" id="dig_completedby" tabindex="8" maxlength="200" />
</td>
</tr>
<tr>
<td class="label"><span data-lgid="P_MRM_DESCRIPTION_COLON">Description:</span><span style="color: red; margin-left: 3px;">*</span></td>
<td>
<textarea id="dialog_notes" maxlength="1900" tabindex="9" style="width: 560px; height: 150px; margin-top: 4px;"></textarea></td>
</tr>
<tr>
<td class="label" data-lgid="P_MRM_ATTACHMENTS_COLON">Attachments:</td>
<td>
<input id="uploadattfile" type="button" value="Add File..." data-lgid="P_MRM_ADDFILE" onclick="UpLoadMaintenanceLogAttachment()" tabindex="16" style="background-color: #0099FF; color: #FFFFFF; height: 20px; width: 200px;" />
<%-- <input id="Addfiles" type="button" value="Add File..." tabindex="10" style="background-color: #0099FF; color: #FFFFFF; height: 20px; width: 200px;" onclick="openFileDialog()" />
<input type="file" id="fileinput" style="display: none;" multiple="multiple" onchange="fillticketattchList()" />--%>
</td>
</tr>
<tr>
<td class="label"></td>
<td>
<table id="tabAttachments" style="border: 1px solid #a8a8a8; line-height: 25px; margin-top: -5px; width: 564px;">
<tr>
<td>
<div class="content_main">
<table id="tbAttas" style="table-layout: fixed;"></table>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
</div>
</asp:Content>

View File

@ -0,0 +1,73 @@
using IronIntel.Contractor;
using IronIntel.Contractor.Site;
using IronIntel.Contractor.Site.Maintenance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class AddMaintenanceRecord : MaintanceRecordsBasePage
{
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
public string MaintenanceID = "";
public string MachineID = "";
public string CurrentDate = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
this.Title = PageTitle;
MaintenanceID = Request.Params["mcid"];
MachineID = Request.Params["mid"];
}
}
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
CurrentDate = userlocaldate.ToShortDateString();
}
protected override bool ThrowIfNotAllowed
{
get
{
return true;
}
}
protected override bool AllowCurrentLoginSessionEnter()
{
var f = base.AllowCurrentLoginSessionEnter();
if (!f)
{
return false;
}
var user = GetCurrentUser();
return user != null && user.UserType >= IronIntel.Contractor.Users.UserTypes.Common;
}
public bool IsAdmin
{
get
{
var user = GetCurrentUser();
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
return true;
else
return false;
}
}
}

View File

@ -0,0 +1,329 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="AddSurveyTemplate.aspx.cs" Inherits="AddSurveyTemplate" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link href="<%=Common.GenerateUrl("../css/tabcontrol.css") %>" rel="stylesheet" />
<link href="<%=Common.GenerateUrl("../Inspection/css/sections.css") %>" rel="stylesheet" />
<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;
}
</style>
<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 src="<%=GetFileUrlWithVersion("js/addsurveytemplate.js")%>" type="text/javascript"></script>
<script type="text/javascript">
var surveyid = "";
var assetid = 0;
var surveydata;
var wosurveyCtrl;
var surveytempreadonly = true;
function worequest(method, param, callback, error) {
_network.request("Maintenance/AddSurveyTemplate.aspx", -1, method, param, callback, error || function (e) {
console.log(e);
showmaskbg(false, true);
showAlert(GetTextByKey('P_WOS_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_WOS_QUERY', 'Query'));
});
}
function showcontatcmask(flag) {
if (flag) {
$('#contatcmask').fadeIn(100);
} else {
$('#contatcmask').fadeOut(100);
}
}
function OnAdd() {
surveytempreadonly = false;
setDisabled();
$('#dialog_name').val("");
$('#dialog_active').prop('checked', true);
if (surveyid) {
getSurveyTemplateInfo(true);
} else {
$('#dialog_notes').val("");
$('#questionlist').empty();
wosurveyCtrl = undefined;
}
}
function getSurveyTemplateInfo(copy) {
showLoading();
$('#questionlist').empty();
wosurveyCtrl = undefined;
worequest("GetSurveyTemplateInfo", surveyid, function (data) {
hideLoading();
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_WOS_ERROR", 'Error'));
return;
}
if (copy) {
surveyid = void 0;
if (data.Questions && data.Questions.length > 0) {
for (var q of data.Questions) {
delete q.Id;
}
}
} else {
$('#dialog_name').val(data.Name);
$('#dialog_active').prop('checked', data.Active);
}
surveydata = data;
$('#dialog_notes').val(surveydata.Notes);
if (surveydata.Questions && surveydata.Questions.length > 0) {
wosurveyCtrl = new $wosurvey($('#questionlist'));
wosurveyCtrl.updateQuestions(surveydata.Questions);
}
}, function (err) {
hideLoading();
});
}
function OnEdit() {
setDisabled();
getSurveyTemplateInfo();
}
function OnSave(exit) {
if (surveytempreadonly) {
surveydata.Active = $('#dialog_active').prop('checked');
param = htmlencode(JSON.stringify(surveydata));
} else {
var item = {
'Name': $.trim($('#dialog_name').val()),
'Active': $('#dialog_active').prop('checked'),
'Notes': $.trim($('#dialog_notes').val())
};
var alerttitle;
if (surveyid) {
item.Id = surveyid;
alerttitle = GetTextByKey("P_WOS_EDITSURVEYTEMPLATE", "Edit Survey Template");
} else {
item.Id = -1;
alerttitle = GetTextByKey("P_WOS_ADDSURVEYTEMPLATE", "Add Survey Template");
}
if (!item.Name || item.Name.length == 0) {
showAlert(GetTextByKey("P_WOS_TEMPLATENAMECANNOTBEEMPTY", 'Template Name cannot be empty.'), alerttitle, undefined, function () { $('#dialog_name').focus(); });
return;
}
if (wosurveyCtrl) {
item.Questions = wosurveyCtrl.getQuestionInputs();
if (!item.Questions)
return;
}
param = htmlencode(JSON.stringify(item));
}
showmaskbg(true);
worequest("SaveSurveyTemplate", param, function (data) {
showmaskbg(false);
if (typeof (data) === "string") {
showAlert(data, alerttitle);
} else {
surveyid = data;
if (exit == 0) {
if (surveyid > 0)
showAlert(GetTextByKey("P_WOS_SAVSUCCESSFULLY", "Saved successfully."), alerttitle);
}
else if (exit == 1)
OnExit(exit);
}
}, function (err) {
showAlert(GetTextByKey("P_WOS_FAILEDTOSAVESURVEYTEMPLATE", 'Failed to save survey template.'), alerttitle);
});
}
function OnExit(type) {
if (window.parent && typeof window.parent.CloseCustomerDialog == 'function')
window.parent.CloseCustomerDialog(type);
else
window.parent.CloseDialog(type);
}
function init(sid, readonly, copy) {
surveyid = sid;
$('#tab_header_info').click();
$('.comments').hide();
if (surveyid && !copy) {
surveytempreadonly = readonly;
OnEdit();
}
else {
OnAdd();
}
}
function setDisabled() {
if (surveytempreadonly) {
//$('.iconsave').hide();
//$('.iconadd').hide();
$('#dialog_name').attr('disabled', true);
//$('#dialog_active').attr('disabled', true);
$('#dialog_notes').attr('disabled', true);
}
else {
//$('.iconsave').show();
//$('.iconadd').show();
$('#dialog_name').attr('disabled', false);
//$('#dialog_active').attr('disabled', false);
$('#dialog_notes').attr('disabled', false);
}
}
function showLoading() {
$("#dialogmask").show();
}
function hideLoading() {
$("#dialogmask").hide();
}
$(function () {
init();
function resizeContent() {
$('#divcontent').css('height', $(window).height() - $('#divcontent').offset().top - 4);
}
window.onresize = resizeContent;
resizeContent();
});
</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>
<div id="dialogmask" class="maskbg" style="display: none; z-index: 500;">
<div class="loading_icon icon c-spin"></div>
</div>
<div class="function_title">
<span class="sbutton iconsave" onclick="OnSave(0);" data-lgid="P_UM_SAVE">Save</span>
<span class="sbutton iconsave" onclick="OnSave(1);" data-lgid="P_UM_SAVE1">Save and Exit</span>
<span class="sbutton iconexit" onclick="OnExit(0);" data-lgid="P_UM_SAVE2">Exit Without Saving</span>
</div>
<div class="clear"></div>
<div class="content_main" id="divcontent" style="overflow: auto;">
<div class="edit-content" style="min-width: 1500px;">
<table style="line-height: 30px; table-layout: fixed; width: 600px;">
<tr>
<td class="label"><span data-lgid="P_WOS_NAME_COLON">Name:</span><span class="redasterisk">*</span></td>
<td>
<input type="text" id="dialog_name" tabindex="1" maxlength="50" autocomplete="off" /></td>
</tr>
<tr>
<td class="label" data-lgid="P_UM_ACTIVE_COLON">Active:</td>
<td>
<input type="checkbox" id="dialog_active" tabindex="2"/></td>
</tr>
<tr>
<td class="label" data-lgid="P_WOS_NOTES_COLON">Notes:</td>
<td>
<textarea id="dialog_notes" tabindex="13" style="width: 840px; height: 100px; margin-top: 6px;" maxlength="500"></textarea></td>
</tr>
</table>
<div class="subtitle">
<span data-lgid="P_WOS_QUESTIONINFORMATION">Question Information</span>
<span class="sbutton iconadd" style="display: inline;" onclick="onAddQuestion()">Add</span>
<hr />
</div>
<div class="question-holder no-hover" style="font-weight: bold; font-size: 14px; background-color: #f0f0f0;">
<div style="width: 30px; flex-shrink: 0"></div>
<div class="question-cell" style="width: 160px"><span data-lgid="P_WOS_NAME" style="padding-left: 15px;">Name</span></div>
<div class="question-cell" style="width: 300px"><span data-lgid="P_WOS_TITLE" style="padding-left: 15px;">Title</span></div>
<div class="question-cell" style="width: 300px"><span data-lgid="P_WOS_TITLETIPS">Title Tips</span></div>
<div class="question-cell" style="width: 240px"><span data-lgid="P_WOS_TYPES">Types</span></div>
<div class="question-cell" style="width: 100px"><span data-lgid="P_WOS_REQUIRED">Required</span></div>
<div style="flex-grow: 1">Notes</div>
<div class="question-cell" style="width: 40px; padding-right: 20px;"></div>
</div>
<div id="questionlist"></div>
</div>
</div>
</div>
</asp:Content>

View File

@ -0,0 +1,53 @@
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site;
using IronIntel.Contractor.Site.Maintenance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class AddSurveyTemplate : WorkOrderBasePage
{
protected string IID;
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
public bool EmailSubscribe = false;
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
this.Title = PageTitle;
bool license = SystemParams.HasLicense("CustomerRecord");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.CUSTOMER_RECORD);
if (!permission)
RedirectToLoginPage();
}
}
}
public bool IsSupperAdmin
{
get
{
var user = GetCurrentUser();
return user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,126 @@
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Maintenance;
using IronIntel.Contractor.Site;
using IronIntel.Contractor.Site.Maintenance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class AddWorkOrder : WorkOrderBasePage
{
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
public string WorkOrderID = "";
public string MachineID = "";
public string AlertIDs = "";
public string MeterType = "";
public bool AllowCommunicate = false;
public bool AllowCustomer = false;
public bool AllowInspection = false;
public string NowDate = "";
public bool AllowReopenWorkorders = false;
public bool AllowReassignWorkorders = false;
public bool AllowDeleteAtta = false;
public bool WOReadOnly = false;
public bool CRReadOnly = false;
public bool COMMReadOnly = false;
protected void Page_Load(object sender, EventArgs e)
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
var session = GetCurrentLoginSession();
if (session == null || !AllowCurrentLoginSessionEnter())
{
Response.Write("<script languge='javascript'>alert('You do not have permission to access this information. If you believe this is an error, please contact your administrator.');</script>");
Response.End();
}
this.Title = PageTitle;
bool license = SystemParams.HasLicense("WorkOrder");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.WORK_ORDER);
if (!permission)
RedirectToLoginPage();
WOReadOnly = CheckReadonly(SystemParams.CompanyID, Feature.WORK_ORDER);
AllowCommunicate = CheckRight(SystemParams.CompanyID, Feature.COMMUNICATEWITHCUSTOMER);
bool crls = SystemParams.HasLicense("CustomerRecord");
bool crpermission = CheckRight(SystemParams.CompanyID, Feature.CUSTOMER_RECORD);
AllowCustomer = crls && crpermission;
AllowCommunicate = crls && AllowCommunicate;
CRReadOnly = WOReadOnly || CheckReadonly(SystemParams.CompanyID, Feature.CUSTOMER_RECORD);
COMMReadOnly = WOReadOnly || CheckReadonly(SystemParams.CompanyID, Feature.COMMUNICATEWITHCUSTOMER);
license = SystemParams.HasLicense("Inspection");
AllowInspection = license && CheckRight(SystemParams.CompanyID, Feature.INSPECTION_REPORTS);
AllowReopenWorkorders = !WOReadOnly && CheckRight(SystemParams.CompanyID, Feature.REOPENWORKORDERS);
AllowReassignWorkorders = !WOReadOnly && CheckRight(SystemParams.CompanyID, Feature.REASSIGN_WORKORDERS);
AllowDeleteAtta = !WOReadOnly && CheckRight(SystemParams.CompanyID, Feature.WORKORDERDELETEATTACHMENT);
WorkOrderID = Request.Params["woid"];
MachineID = Request.Params["mid"];
AlertIDs = Request.Params["aids"];
MeterType = Request.Params["metertype"];
if (!string.IsNullOrEmpty(WorkOrderID))
{
var user = GetCurrentUser();
bool result = new WorkOrderManager(SystemParams.DataDbConnectionString).CanAccessWorkOrder(GetCurrentLoginSession().SessionID, WorkOrderID, MachineID, user.IID);
if (!result)
{
Response.Write("<script languge='javascript'>alert('You do not have permission to access this information. If you believe this is an error, please contact your administrator.');</script>");
Response.End();
}
}
}
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
NowDate = userlocaldate.ToShortDateString();
}
protected override bool AllowCurrentLoginSessionEnter()
{
var f = base.AllowCurrentLoginSessionEnter();
if (!f)
{
return false;
}
var user = GetCurrentUser();
return user != null && user.UserType >= IronIntel.Contractor.Users.UserTypes.Common;
}
public bool IsAdmin
{
get
{
var user = GetCurrentUser();
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
return true;
else
return false;
}
}
public bool IsAdvisor
{
get
{
var user = GetCurrentUser();
if (user.ContactType == IronIntel.Contractor.Users.ContactTypes.Advisor)
return true;
else
return false;
}
}
}

View File

@ -0,0 +1,786 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="AlertAutomationManagement.aspx.cs" Inherits="AlertAutomationManagement" %>
<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;
}
.div_filter .dropdown {
width: 322px;
margin: 2px 0 0 0px;
}
.div_panel {
min-width: 322px;
}
</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 alerttypeparam;
var assetgroupparam;
var jobsitesparam;
var assigntosparam;
var alerttype_editmultiselect;
var assetgroup_editmultiselect;
var jobsite_editmultiselect;
var assignto_editmultiselect;
function alertrequest(method, param, callback, error) {
_network.request("Maintenance/AlertAutomationManagement.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 worequest(method, param, callback, error) {
_network.request("Maintenance/WorkOrderMaintenance.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() {
window.parent.CloseAlertAutomationDialog();
}
//******************************Begin Auto Acknowledge**********************************//
function showAutoAcknowledge(data) {
var rows = [];
for (var i = 0; i < data.length; i++) {
var r = data[i];
var fr = { Values: r };
rows.push(fr);
}
autoacknowledge_dt.setData(rows);
}
var autoacknowledge_dt;
function InitAutoAcknowledgeGridData() {
autoacknowledge_dt = new GridView('#div_autoacknowledgelist');
autoacknowledge_dt.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: 'Value', caption: GetTextByKey("P_AM_ALERTTYPE", "Alert Type"), valueIndex: 'Value', 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.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;
if (list_columns[hd].type) {
col.type = list_columns[hd].type;
}
columns.push(col);
}
autoacknowledge_dt.canMultiSelect = false;
autoacknowledge_dt.columns = columns;
autoacknowledge_dt.init();
}
var alerttypesdata;
function GetAlertTypes() {
alertrequest('GetAlertTypes', '', function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_AM_ERROR", 'Error'));
return;
}
data.splice(0, 0, { Key: "", Value: GetTextByKey("P_XXXXX", '(Blank)') });
alerttypesdata = data;
alerttypeparam = {
items: data,
selectedvalue: []
};
alerttypesdata = data;
alerttype_editmultiselect = editmultiselect(alerttypeparam);
$('#div_alerttype').append(alerttype_editmultiselect);
GetAutoAcknowledgeAlertTypes();
});
}
function GetAssetGroups() {
alertrequest('GetAssetGroups', '', function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_AM_ERROR", 'Error'));
return;
}
assetgroupparam = {
items: data,
selectedvalue: []
};
assetgroup_editmultiselect = editmultiselect(assetgroupparam);
$('#div_assetgroup').append(assetgroup_editmultiselect);
});
}
function GetJobsites() {
alertrequest('GetJobsites', '', function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_AM_ERROR", 'Error'));
return;
}
jobsitesparam = {
items: data,
selectedvalue: []
};
jobsite_editmultiselect = editmultiselect(jobsitesparam);
$('#div_jobsites').append(jobsite_editmultiselect);
});
}
function GetAssigntos() {
alertrequest('GetAssignTos', '', function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_AM_ERROR", 'Error'));
return;
}
assigntosparam = {
items: data,
selectedvalue: []
};
assignto_editmultiselect = editmultiselect(assigntosparam);
$('#div_assigntos').append(assignto_editmultiselect);
});
}
function GetWorkOrderStatuses() {
worequest('GetWorkOrderStatuses', '', function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_AM_ERROR", 'Error'));
return;
}
if (data && data.length > 0) {
$("#dialog_wostatus").empty();
for (var i = 0; i < data.length; i++) {
var kv = data[i];
var op = $("<option></option>").val(kv.Id).text(kv.Name);
$("#dialog_wostatus").append(op);
}
}
});
}
function GetAutoAcknowledgeAlertTypes() {
alertrequest('GetAutoAcknowledgeAlertTypes', '', function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_AM_ERROR", 'Error'));
return;
}
var types = [];
for (var i = 0; i < alerttypesdata.length; i++) {
var t = alerttypesdata[i];
if (t.Key === "Preventative Maintenance" || t.Key === "Yellow-Inspect" || t.Key === "Red-Inspect")
continue;
t.Selected = false;
if (data.indexOf(alerttypesdata[i].Key) >= 0)
t.Selected = true;
types.push(t);
}
showAutoAcknowledge(types);
});
}
function OnViewAutoAcknowledChangeHistory() {
window.open("AutoAcknowledChangeHistory.aspx");
}
function onSaveAutoAcknowledgeAlertTypes() {
var alerttypes = [];
for (var i = 0; i < autoacknowledge_dt.source.length; i++) {
var ct = autoacknowledge_dt.source[i].Values;
if (ct.Selected)
alerttypes.push(ct.Key);
}
alertrequest('SaveAutoAcknowledgeAlertTypes', htmlencode(JSON.stringify(alerttypes)), function (data) {
if (data !== "OK") {
showAlert(data, GetTextByKey("P_MV_ERROR", 'Error'));
}
else {
showAlert(GetTextByKey('P_WO_SAVSUCCESSFULLY', 'Saved successfully.'), GetTextByKey("P_AM_AUTOACKNOWLEDGE", 'Auto-Acknowledge'));
}
});
}
//******************************End Auto Acknowledge**********************************//
//******************************Begin Work Order Generator**********************************//
var wogeneratorgrid_dt;
function InitWOGeneratorGridData() {
wogeneratorgrid_dt = new GridView('#wogeneratorlist');
wogeneratorgrid_dt.lang = {
all: GetTextByKey("P_GRID_ALL", "(All)"),
ok: GetTextByKey("P_GRID_OK", "OK"),
reset: GetTextByKey("P_GRID_RESET", "Reset")
};
var list_columns = [
{ name: 'AlertTypesStr', caption: GetTextByKey("P_AM_ALERTTYPE", "Alert Type"), valueIndex: 'AlertTypesStr', css: { 'width': 200, 'text-align': 'left' } },
{ name: 'AssetGroupsStr', caption: GetTextByKey("P_AM_ASSETGROUP", "Asset Group"), valueIndex: 'AssetGroupsStr', css: { 'width': 200, 'text-align': 'left' } },
{ name: 'JobSitesStr', caption: GetTextByKey("P_UM_JOBSITES", "Jobsite(s)"), valueIndex: 'JobSitesStr', css: { 'width': 200, 'text-align': 'left' } },
{ name: 'AssignTosStr', caption: GetTextByKey("P_JS_ASSIGNEDTO", "Assigned To"), valueIndex: 'AssignTosStr', css: { 'width': 200, 'text-align': 'left' } },
{ name: 'StatusAssignmentName', caption: GetTextByKey("P_AM_STATUSASSIGNMENT", "Status Assignment"), valueIndex: 'StatusAssignmentName', css: { 'width': 150, 'text-align': 'left' } },
{ name: 'IncludeAllAlerts', caption: GetTextByKey("P_AM_INCLUDEALLALERTS", "Include All Alerts"), valueIndex: 'IncludeAllAlerts', css: { 'width': 150, 'text-align': 'left' } },
{ name: 'EmailWorkorder', caption: GetTextByKey("P_AM_EMAILWORKORDER", "Email Work Order"), valueIndex: 'EmailWorkorder', css: { 'width': 150, 'text-align': 'left' } },
{ name: 'EmailFrom', caption: GetTextByKey("P_AM_XXX", "Email From"), valueIndex: 'EmailFrom', css: { 'width': 150, 'text-align': 'left' } },
{ name: 'Description', caption: GetTextByKey("P_AM_XXX", "Description"), valueIndex: 'Description', css: { 'width': 150, '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 () {
OnEditWOGenerator();
}
};
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 () {
OnDeleteWOGenerator(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') };
}
columns.push(col);
}
wogeneratorgrid_dt.canMultiSelect = false;
wogeneratorgrid_dt.columns = columns;
wogeneratorgrid_dt.init();
wogeneratorgrid_dt.rowdblclick = OnEditWOGenerator;
}
function GetWorkOrderGenerators() {
alertrequest('GetWorkOrderGenerators', '', function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey('P_AM_ALERTAUTOMATION', "Alert Automation"));
showstatusmask(false);
return;
}
showWorkOrderGenerators(data);
}, function (err) {
});
}
function showWorkOrderGenerators(data) {
var rows = [];
for (var i = 0; i < data.length; i++) {
var r = data[i];
var desctype = parseInt(r.DescType);
var desc = "";
if (desctype === 0)
desc = 'Trigger Alerts';
else if (desctype === 1)
desc = 'All Alerts';
else if (desctype === 10)
desc = r.Description;
for (var j in r) {
if (j === "IncludeAllAlerts") {
r[j] = { DisplayValue: r.IncludeAllAlerts ? "Yes" : "No", Value: r[j] };
}
if (j === "EmailWorkorder") {
r[j] = { DisplayValue: r.EmailWorkorder ? "Yes" : "No", Value: r[j] };
}
if (j === "AlertTypesStr") {
r[j] = { DisplayValue: r.AlertTypesStr === "" ? "All" : r.AlertTypesStr, Value: r[j] };
}
if (j === "AssetGroupsStr") {
r[j] = { DisplayValue: r.AssetGroupsStr === "" ? "All" : r.AssetGroupsStr, Value: r[j] };
}
if (j === "JobSitesStr") {
r[j] = { DisplayValue: r.JobSitesStr === "" ? "All" : r.JobSitesStr, Value: r[j] };
}
if (j === "AssignTosStr") {
r[j] = { DisplayValue: r.AssignTosStr === "" ? "All" : r.AssignTosStr, Value: r[j] };
}
if (j === "Description") {
r[j] = { DisplayValue: desc, Value: r[j] };
}
}
var fr = { Values: r };
rows.push(fr);
}
wogeneratorgrid_dt.setData(rows);
}
function OnAddWOGenerator() {
$('#tr_desc').hide();
generatorid = undefined;
var alerttitle = GetTextByKey("P_AM_ADDWORKORDERGENERATOR", 'Add Work Order Generator')
alerttype_editmultiselect.setValues([]);
assetgroup_editmultiselect.setValues([]);
jobsite_editmultiselect.setValues([]);
assignto_editmultiselect.setValues([]);
$('#dialog_wostatus').val("");
$('#dialog_includeallalerts').prop('checked', false);
$('#dialog_emailworkorder').prop('checked', false);
$('#dialog_emailfrom').val("");
$('#dialog_desctype').val("");
$('#dialog_desc').val("");
$('#dialog_wogenerator .dialog-title span.title').text(alerttitle);
$('#mask_bg').show();
$('#dialog_wogenerator')
.css({
'top': (document.documentElement.clientHeight - $('#dialog_wogenerator').height()) / 3,
'left': (document.documentElement.clientWidth - $('#dialog_wogenerator').width()) / 3
}).showDialogfixed();
}
var generatorid;
function OnEditWOGenerator() {
var index = wogeneratorgrid_dt.selectedIndex;
if (index < 0) return;
var generator = wogeneratorgrid_dt.source[index].Values;
generatorid = generator.Id;
alerttype_editmultiselect.setValues(generator.AlertTypes || []);
assetgroup_editmultiselect.setValues(generator.AssetGroups || []);
jobsite_editmultiselect.setValues(generator.JobSites || []);
assignto_editmultiselect.setValues(generator.AssignTos || []);
$('#dialog_wostatus').val(generator.StatusAssignment);
$('#dialog_includeallalerts').prop('checked', generator.IncludeAllAlerts.Value);
$('#dialog_emailworkorder').prop('checked', generator.EmailWorkorder.Value);
$('#dialog_emailfrom').val(generator.EmailFrom);
$('#dialog_desctype').val(generator.DescType);
if (parseInt(generator.DescType) === 10) {
$('#tr_desc').show();
$('#dialog_desc').val(generator.Description.Value);
}
else {
$('#tr_desc').hide();
$('#dialog_desc').val("");
}
$('#dialog_wogenerator .dialog-title span.title').text(GetTextByKey("P_AM_EDITWORKORDERGENERATOR", 'Edit Work Order Generator'));
$('#mask_bg').show();
$('#dialog_wogenerator')
.css({
'top': (document.documentElement.clientHeight - $('#dialog_wogenerator').height()) / 3,
'left': (document.documentElement.clientWidth - $('#dialog_wogenerator').width()) / 3
}).showDialogfixed();
}
function onSaveWorkOrderGenerator() {
showstatusmask(true);
var alerttypes = [];
if (alerttypeparam) {
alerttypes = alerttypeparam.selectedvalue;
}
var assetgroups = [];
if (assetgroupparam) {
assetgroups = assetgroupparam.selectedvalue;
}
var jobsites = [];
if (jobsitesparam) {
jobsites = jobsitesparam.selectedvalue;
}
var assigntos = [];
if (assigntosparam) {
assigntos = assigntosparam.selectedvalue;
}
var item = {
'StatusAssignment': $('#dialog_wostatus').val(),
'AlertTypes': alerttypes,
'AssetGroups': assetgroups,
'JobSites': jobsites,
'AssignTos': assigntos,
'IncludeAllAlerts': $('#dialog_includeallalerts').prop('checked'),
'EmailWorkorder': $('#dialog_emailworkorder').prop('checked'),
'EmailFrom': $('#dialog_emailfrom').val(),
'DescType': $('#dialog_desctype').val(),
'Description': $('#dialog_desc').val()
};
var alerttitle;
if (generatorid || generatorid == 0) {
item.Id = generatorid;
alerttitle = GetTextByKey("P_AM_EDITWORKORDERGENERATOR", "Edit Work Order Generator");
} else {
item.Id = -1;
alerttitle = GetTextByKey("P_AM_ADDWORKORDERGENERATOR", "Add Work Order Generator");
}
if (item.AssignTos.length == 0) {
showAlert(GetTextByKey("P_WO_XXX", 'Assigned to cannot be empty.'), alerttitle, undefined, function () {
showstatusmask(false);
});
return;
}
if (!item.StatusAssignment) {
showAlert(GetTextByKey("P_WO_XXX", 'Status assignment cannot be empty.'), alerttitle, undefined, function () {
showstatusmask(false);
});
return;
}
if (item.EmailFrom !== "" && !isEmail(item.EmailFrom)) {
showAlert(GetTextByKey("P_WO_XXX", 'Email from is not a valid.'), alerttitle, undefined, function () {
showstatusmask(false);
});
return;
}
if (!item.DescType)
item.DescType = -1;
param = htmlencode(JSON.stringify(item));
alertrequest("SaveWorkOrderGenerator", param, function (data) {
if (typeof (data) === "string") {
showAlert(data, alerttitle, undefined, function () {
showstatusmask(false);
});
} else {
$('#dialog_wogenerator').hideDialog();
showstatusmask(false);
showmaskbg(false);
GetWorkOrderGenerators();
}
}, function (err) {
showAlert(GetTextByKey("P_AM_FAILEDTOSAVEWORKORDERGENERATOR", 'Failed to save work order generator.'), alerttitle);
});
}
function OnDeleteWOGenerator(c) {
if (!c) {
return;
}
var alerttitle = GetTextByKey("P_AM_DELETEWORKORDERGENERATOR", 'Delete Work Order Generator');
showConfirm(GetTextByKey("P_AM_DOYOUWANTTODELETETHISWORKORDERGENERATOR", 'Do you want to delete this work order generator?'), alerttitle, function () {
alertrequest('DeleteWorkOrderGenerator', c.Id, function (data) {
if (typeof (data) === "string") {
showAlert(data, alerttitle);
} else {
GetWorkOrderGenerators();
}
}, function (err) {
showAlert(GetTextByKey('P_AM_FAILEDTODELETEWORKORDERGENERATOR', 'Failed to delete this work order generator.'), alerttitle);
});
});
}
//******************************End Work Order Generator**********************************//
$(function () {
InitAutoAcknowledgeGridData();
InitWOGeneratorGridData();
GetAlertTypes();
GetWorkOrderGenerators();
GetAssetGroups();
GetJobsites();
GetAssigntos();
GetWorkOrderStatuses();
$('#dialog_wogenerator').dialog(function () {
showmaskbg(false);
});
$('#div_container').tab();
$("#dialog_desctype").change(function () {
var desctype = $('#dialog_desctype').val();
if (parseInt(desctype) === 10) {
$('#tr_desc').show();
}
else {
$('#tr_desc').hide();
}
});
$(window).resize(function () {
$("#div_autoacknowledgelist").css("height", $(window).height() - $("#div_autoacknowledgelist").offset().top - 4);
autoacknowledge_dt && autoacknowledge_dt.resize();
$("#wogeneratorlist").css("height", $(window).height() - $("#wogeneratorlist").offset().top - 4);
wogeneratorgrid_dt && wogeneratorgrid_dt.resize();
}).resize();
});
function reshowgrid() {
setTimeout(function () {
$("#div_autoacknowledgelist").css("height", $(window).height() - $("#div_autoacknowledgelist").offset().top - 4);
autoacknowledge_dt && autoacknowledge_dt.resize();
$("#wogeneratorlist").css("height", $(window).height() - $("#wogeneratorlist").offset().top - 4);
wogeneratorgrid_dt && wogeneratorgrid_dt.resize();
});
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div id="div_container">
<ul id="ul_container" class="tab_header">
<li id="li_autoacknowledge" data-href="tab_autoacknowledge" onclick="reshowgrid();" class="selected" data-lgid="P_AM_AUTOACKNOWLEDGE">Auto-Acknowledge</li>
<%if (AllowWorkOrderGenerator)
{ %>
<li data-href="tab_workordergenerator" onclick="reshowgrid();" data-lgid="P_AM_WORKORDERGENERATOR">Work Order Generator</li>
<%} %>
</ul>
<div id="tab_autoacknowledge" data-page="tab_autoacknowledge">
<div class="function_title">
<span class="sbutton iconsave" onclick="onSaveAutoAcknowledgeAlertTypes();" data-lgid="P_WO_SAVE">Save</span>
<span class="sbutton iconview" onclick="OnViewAutoAcknowledChangeHistory();" data-lgid="P_AM_VIEWCHANGEHIS">View Change History</span>
<span class="sbutton iconexit" onclick="OnExit(0);" data-lgid="P_WO_SAVE2">Exit Without Saving</span>
</div>
<div class="clear"></div>
<div id="div_autoacknowledgelist"></div>
</div>
<div id="tab_workordergenerator" data-page="tab_workordergenerator">
<div class="function_title">
<span class="sbutton iconadd" onclick="OnAddWOGenerator();" data-lgid="P_AM_ADDWORKORDERGENERATOR">Add Work Order Generator</span>
<span class="sbutton iconexit" onclick="OnExit(0);" data-lgid="P_WO_SAVE2">Exit Without Saving</span>
</div>
<div class="clear"></div>
<div id="wogeneratorlist">
</div>
</div>
</div>
<div id="mask_bg" style="display: none;">
<div class="loading_holder">
</div>
</div>
<div class="dialog" id="dialog_wogenerator" style="display: none;">
<div class="dialog-title"><span class="title" data-lgid="P_AM_ADDWORKORDERGENERATOR">Add Work Order Generator</span><em class="dialog-close"></em></div>
<div class="dialog-content">
<table style="line-height: 30px; table-layout: fixed; width: 500px;">
<tr>
<td class="label"><span data-lgid="P_AM_ALERTTYPE_COLON">Alert Type:</span></td>
<td>
<div id="div_alerttype"></div>
</td>
</tr>
<tr>
<td class="label"><span data-lgid="P_AM_ASSETGROUP_COLON">Asset Group:</span></td>
<td>
<div id="div_assetgroup"></div>
</td>
</tr>
<tr>
<td class="label"><span data-lgid="P_AM_JOBSITES_COLON">Jobsites:</span></td>
<td>
<div id="div_jobsites"></div>
</td>
</tr>
<tr>
<td class="label"><span data-lgid="P_WO_ASSIGNEDTO_COLON">Assign To:</span></td>
<td>
<div id="div_assigntos"></div>
</td>
</tr>
<tr>
<td class="label"><span data-lgid="P_AM_STATUSASSIGNMENT_COLON">Status Assignment:</span></td>
<td>
<select id="dialog_wostatus" tabindex="1" style="width: 322px;"></select>
</td>
</tr>
<tr>
<td class="label"><span data-lgid="P_AM_INCLUDEALLALERTS_COLON">Include All Alerts:</span></td>
<td>
<input type="checkbox" id="dialog_includeallalerts" style="width: auto;" tabindex="1" />
</td>
</tr>
<tr>
<td class="label"><span data-lgid="P_AM_EMAILWORKORDER_COLON">Email Work Order:</span></td>
<td>
<input type="checkbox" id="dialog_emailworkorder" style="width: auto;" tabindex="1" />
</td>
</tr>
<tr>
<td class="label"><span data-lgid="P_AM_XXX">Email From:</span></td>
<td>
<input type="text" id="dialog_emailfrom" maxlength="200" tabindex="1" />
</td>
</tr>
<tr>
<td class="label"><span data-lgid="P_AM_XXX">Description:</span></td>
<td>
<select id="dialog_desctype" tabindex="1" style="width: 324px;">
<option value="-1"></option>
<option value="0">Trigger Alerts</option>
<option value="1">All Alerts</option>
<option value="10">Other</option>
</select>
</td>
</tr>
<tr id="tr_desc" style="display: none;">
<td class="label"></td>
<td>
<textarea id="dialog_desc" maxlength="2000" tabindex="1" style="height: 80px;"></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="onSaveWorkOrderGenerator();" 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>

View File

@ -0,0 +1,54 @@
using Foresight.Fleet.Services.User;
using Foresight.ServiceModel;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Maintenance;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class AlertAutomationManagement : AlertsBasePage
{
public bool AllowWorkOrderGenerator = false;
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
this.Title = PageTitle;
bool license = SystemParams.HasLicense("AlertsManagement");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.ALERTS_MANAGEMENT);
if (!permission)
RedirectToLoginPage();
AllowWorkOrderGenerator = CheckRight(SystemParams.CompanyID, Feature.WORKORDERGENERATOR);
}
}
}
public bool IsSupperAdmin
{
get
{
var user = GetCurrentUser();
return user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Maintenance;
public partial class Maintenance_AlertsManagement : AlertsBasePage
{
public string BeginDate = "";
public string EndDate = "";
public string AssetID = "";
public bool InDialog = false;
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
this.Title = PageTitle;
bool license = SystemParams.HasLicense("AlertsManagement");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.ALERTS_MANAGEMENT);
if (!permission)
RedirectToLoginPage();
AssetID = Request.Params["mid"] ?? "";
InDialog = Request.Params["InDialog"] == "1";
}
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
if (InDialog)
BeginDate = userlocaldate.AddDays(-13).ToShortDateString();
else
BeginDate = userlocaldate.AddDays(-6).ToShortDateString();
EndDate = userlocaldate.ToShortDateString();
}
}
public bool CanEditWorkOrder
{
get
{
bool license = SystemParams.HasLicense("WorkOrder");
bool permission = CheckRight(SystemParams.CompanyID, Feature.WORK_ORDER);
return license && permission;
}
}
}

View File

@ -0,0 +1,175 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/IronIntelMasterPage.master" AutoEventWireup="true" CodeFile="AutoAcknowledChangeHistory.aspx.cs" Inherits="AutoAcknowledChangeHistory" %>
<asp:Content ID="Content1" ContentPlaceHolderID="holder_head" runat="Server">
<style type="text/css">
.selectinput {
width: 150px;
margin-right: 10px;
}
.dialog-content table {
border-collapse: collapse;
width: 100%;
}
.dialog-content table td.label {
width: 150px;
text-align: right;
padding-right: 10px;
line-height: 24px;
height: 24px;
vertical-align: top;
}
.dialog-content table td input,
.dialog-content table td textarea {
border: 1px solid #a9a9a9;
width: 200px;
height: 18px;
padding: 1px;
}
.dialog-content table td input[type="checkbox"] {
border: none;
}
.dialog-content table td textarea {
height: 100px;
max-width: 200px;
}
#dialogdatatb td {
padding-top: 5px;
}
.a {
text-decoration: none;
color: #2140fb;
}
</style>
<script type="text/javascript">
var historydata;
function alertrequest(method, param, callback, error) {
_network.request("Maintenance/AutoAcknowledChangeHistory.aspx", -1, method, param, callback, error || function (e) {
showAlert(GetTextByKey('P_AM_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_AM_QUERY', 'Query'));
});
}
function enterKeydown(e) {
if (e.keyCode == 13) {
OnRefresh();
}
}
function OnRefresh() {
showloading(true);
alertrequest("GetAutoAcknowledgeAlertTypesHistory", "", function (data) {
showloading(false);
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_AM_ERROR", 'Error'));
return;
}
if (data && data.length > 0)
historydata = data;
else
historydata = [];
showAutoAcknowledgeList(historydata);
}, function (err) {
showloading(false);
});
}
function showAutoAcknowledgeList(data) {
var rows = [];
for (var i = 0; i < data.length; i++) {
var r = data[i];
for (var j in r) {
if (j === "AutoAcknowledge") {
r[j] = { DisplayValue: r["AutoAcknowledge"] > 0 ? "Yes" : "No", Value: r[j] };
}
else if (j === "LocalUpdatedOn") {
r[j] = { DisplayValue: r["LocalUpdatedOnStr"], Value: r[j] };
}
}
var fr = { Values: r };
rows.push(fr);
}
grid_dt.setData(rows);
}
var grid_dt;
function InitGridData() {
grid_dt = new GridView('#autoacknowledgelist');
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: 'AlertType', caption: GetTextByKey("P_AM_ALERTTYPE", "Alert Type"), valueIndex: 'AlertType', allowFilter: true, css: { 'width': 300, 'text-align': 'left' } },
{ name: 'AutoAcknowledge', caption: GetTextByKey("P_AM_AUTOACKNOWLEDGE1", "Auto Acknowledge"), valueIndex: 'AutoAcknowledge', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
{ name: 'UpdatedByName', caption: GetTextByKey("P_AM_USERNAME", "User Name"), valueIndex: 'UpdatedByName', allowFilter: true, css: { 'width': 250, 'text-align': 'left' } },
{ name: 'LocalUpdatedOn', caption: GetTextByKey("P_AM_UPDATEDATE", "Update Date"), valueIndex: 'LocalUpdatedOn', css: { 'width': 180, '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_dt.canMultiSelect = false;
grid_dt.columns = columns;
grid_dt.init();
grid_dt.selectedrowchanged = function (rowindex) {
var rowdata = grid_dt.source[rowindex];
if (rowdata) {
}
}
}
function OnExport() {
window.open("../ExportToFile.aspx?type=autoackhis");
}
$(function () {
InitGridData();
OnRefresh();
$(window).resize(function () {
$("#autoacknowledgelist").css("height", $(window).height() - $("#autoacknowledgelist").offset().top - 4);
grid_dt && grid_dt.resize();
}).resize();
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="holder_content" runat="Server">
<div id="recordcontent" style="padding: 0px; margin: 0px;">
<div class="page_title" data-lgid="P_AM_AUTOACKNOWLEDGECHANGEHISTORY">Auto-Acknowledge Change History</div>
<div class="search_bar">
</div>
<div class="function_title">
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_AM_REFRESH">Refresh</span>
<span class="sbutton iconexport" onclick="OnExport();" data-lgid="P_AM_EXPORT">Export to Excel</span>
</div>
<div class="clear"></div>
<div id="autoacknowledgelist"></div>
</div>
<div id="mask_bg" style="display: none;">
<div class="loading c-spin"></div>
</div>
</asp:Content>

View File

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Maintenance;
public partial class AutoAcknowledChangeHistory : AlertsBasePage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
this.Title = PageTitle;
bool license = SystemParams.HasLicense("AlertsManagement");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.ALERTS_MANAGEMENT);
if (!permission)
RedirectToLoginPage();
}
}
}
}

View File

@ -0,0 +1,440 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="CustomerRecordManagement.aspx.cs" Inherits="Maintenance_CustomerRecordManagement" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<style type="text/css">
.no_wrap th {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.max160 {
max-width: 160px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.dialog-content table {
border-collapse: collapse;
width: 100%;
line-height: 32px;
}
.dialog-content table td.label {
width: 130px;
text-align: right;
padding-right: 10px;
line-height: 24px;
height: 24px;
vertical-align: top;
}
.dialog-content table td input,
.dialog-content table td textarea {
border: 1px solid #a9a9a9;
width: 250px;
height: 18px;
padding: 1px;
}
#dialog_machines .dialog-content table td input {
width: auto;
}
.dialog-content table td textarea {
margin-top: 6px;
}
.dialog-content table td select {
width: 254px;
height: 24px;
}
.dialog-content table td input[type="checkbox"] {
border: none;
}
.dialog-content table td textarea {
height: 150px;
width: 420px;
max-width: 500px;
}
.ctl_button {
font-family: 'CalciteWebCoreIcons';
display: block;
margin: 6px auto;
width: 60px;
height: 22px;
line-height: 21px;
padding: 0;
}
#dialog_machinegroup {
z-index: 500;
width: 870px;
top: 60px;
left: 150px;
}
.inputbox {
width: 500px;
padding: 1px;
}
.group_table .main_table {
table-layout: fixed;
}
.group_table .main_table thead tr {
display: block;
}
.group_table .main_table tbody {
height: 280px;
display: block;
overflow-y: auto;
}
.group_table .main_table th {
width: 165px;
}
.group_table .main_table td {
width: 165px;
white-space: nowrap;
word-break: keep-all;
}
.group_table .main_table td div {
width: 165px;
overflow: hidden;
white-space: nowrap;
word-break: keep-all;
text-overflow: ellipsis;
}
.td_controller {
vertical-align: middle;
padding: 40px 8px;
/*border-left: 1px solid #b0b0b0;
border-right: 1px solid #b0b0b0;*/
}
.ctl_button {
font-family: 'CalciteWebCoreIcons';
display: block;
margin: 6px auto;
width: 60px;
height: 22px;
line-height: 21px;
padding: 0;
}
.machine_maskbg {
top: 0;
left: 0;
width: 100%;
height: 100%;
position: absolute;
background: #000;
opacity: 0.2;
}
</style>
<script src="<%=GetFileUrlWithVersion("js/controls.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../js/assetselector.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../fic/js/utility.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("js/customerrecord.js")%>" type="text/javascript"></script>
<script type="text/javascript">
var IsDealer = <%=IsDealer ?"true":"false"%>;
var CRReadOnly = <%=CRReadOnly ?"true":"false"%>;
customerquery = function (method, param, callback, error) {
_network.request("Maintenance/CustomerRecordManagement.aspx", -1, method, param, callback, error);
}
function OnDelete(u) {
if (!u) {
return;
}
showConfirm(GetTextByKey("P_CR_DOYOUWANTTODELETETHISCUSTOMERRECORD", 'Do you want to delete this customer record?'), GetTextByKey("P_CR_DELETECUSTOMERRECORD", 'Delete Customer Record'), function () {
customerquery('DeletePartner', u.Id, function (data) {
OnRefresh();
}, function (err) {
showAlert(GetTextByKey('P_CR_FAILEDTODELETETHISCUSTOMERRECORD', 'Failed to delete this customer record.'), GetTextByKey("P_CR_DELETECUSTOMERRECORD", 'Delete Customer Record'));
});
});
}
function CloseDialog(type) {
$('#dialog_user').hideDialog();
OnRefresh();
showmaskbg(false);
}
function OnAdd() {
execIframeFunc("init", [], "iframeuser");
showmaskbg(true);
$('#dialog_user')
.attr('act', 'add')
.showDialogRight();
}
var custrecordid;
function OnEdit() {
var index = grid_dt.selectedIndex;
if (index < 0) {
showAlert(GetTextByKey("P_CR_PLEASESELECTCUSTOMERRECORD", "Please select customer record."), GetTextByKey("P_CUSTOMERRECORD", "Customer Record")); return;
}
var cust = grid_dt.source[index].Values;
if (!cust) {
custrecordid = undefined;
return;
}
custrecordid = cust.Id;
execIframeFunc("init", [custrecordid], "iframeuser");
showmaskbg(true);
$('#dialog_user')
.attr('act', 'edit')
.showDialogRight();
}
function OnDblClick(e) {
OnEdit();
}
function OnRefresh() {
showloading(true);
var searchtxt = "";
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
customerquery('GetPartners', searchtxt, function (data) {
showloading(false);
if (typeof (data) === "string") {
showAlert(data, GetTextByKey('P_CUSTOMERRECORD', "Customer Record"));
return;
}
showCustomerList(data);
}, function (err) {
showloading(false);
});
}
function showCustomerList(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_dt.setData(rows);
}
var grid_dt;
function InitGridData() {
grid_dt = new GridView('#customerlist');
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: 'Code', caption: GetTextByKey("P_CR_CODE", "Code"), valueIndex: 'Code', allowFilter: true, css: { 'width': 120, 'text-align': 'left' } },
{ name: 'Name', caption: GetTextByKey("P_CR_COMPANYNAME", "Company Name"), valueIndex: 'Name', allowFilter: true, css: { 'width': 240, 'text-align': 'left' } },
//{ name: 'ContactName', caption: GetTextByKey("P_CR_CONTACTNAME", "Contact Name"), valueIndex: 'ContactName', css: { 'width': 150, 'text-align': 'left' } },
//{ name: 'ContactEmail', caption: GetTextByKey("P_CR_CONTACTEMAIL", "Contact Email"), valueIndex: 'ContactEmail', css: { 'width': 130, 'text-align': 'left' } },
//{ name: 'ContactMobilePhone', caption: GetTextByKey("P_CR_CONTACTMOBILE", "Contact Mobile"), valueIndex: 'ContactMobilePhone', css: { 'width': 140, 'text-align': 'left' } },
//{ name: 'ContactPreferenceStr', caption: GetTextByKey("P_CR_CONTACTPREFERENCES", "Contact Preferences"), valueIndex: 'ContactPreferenceStr', css: { 'width': 130, 'text-align': 'left' } },
{ name: 'SalespersonCode', caption: GetTextByKey("P_CR_SALESPERSONCODE", "Salesperson Code"), valueIndex: 'SalespersonCode', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
{ name: 'SalespersonName', caption: GetTextByKey("P_CR_SALESPERSONNAME", "Salesperson Name"), valueIndex: 'SalespersonName', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
{ name: 'Address', caption: GetTextByKey("P_CR_ADDRESS", "Address"), valueIndex: 'Address', css: { 'width': 200, 'text-align': 'left' } },
{ name: 'Notes', caption: GetTextByKey("P_CR_NOTES", "Notes"), valueIndex: 'Notes', css: { 'width': 300, 'text-align': 'left' } },
{ name: 'Edit', caption: "", css: { 'width': 30, 'text-align': 'center' } },
{ name: 'AssetAssignment', 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;
if (CRReadOnly && (col.name === "Edit" || col.name === "AssetAssignment" || col.name === "Delete")) {
continue;
}
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.attrs = { 'title': GetTextByKey("P_UM_DELETE", 'Delete') };
}
else if (col.name === "AssetAssignment") {
col.visible = !IsDealer;
col.isurl = true;
col.text = "\uf63c";
col.sortable = false;
col.events = {
onclick: function () {
OnManageMachine(this);
}
};
col.classFilter = function (e) {
return "icon-col";
};
col.attrs = { 'title': GetTextByKey("P_UM_ASSETSASSIGNMENT", 'Assets Assignment') };
}
columns.push(col);
}
grid_dt.canMultiSelect = false;
grid_dt.columns = columns;
grid_dt.init();
grid_dt.rowdblclick = OnEdit;
grid_dt.selectedrowchanged = function (rowindex) {
var rowdata = grid_dt.source[rowindex];
if (rowdata) {
uiid = rowdata.Values.IID;
}
}
}
$(function () {
setPageTitle(GetTextByKey("P_CUSTOMERRECORD", "Customer Record"), true);
InitGridData();
$('#dialog_managemahchine').dialog(function () {
$('.machine_maskbg').hide();
});
OnRefresh();
$('#dialog_managemahchine').dialog(function () {
$('.machine_maskbg').hide();
});
$('#searchinputtxt').keydown(searchEnter);
$(window).resize(function () {
$("#customerlist").css("height", $(window).height() - $("#customerlist").offset().top - 4);
grid_dt && grid_dt.resize();
}).resize();
if (!canExport) {
$('#spExport').hide();
}
});
function searchEnter(e) {
if (e.keyCode == 13 || e.keyCode == 9) {
OnRefresh();
}
}
function OnExport() {
var searchtxt = "";
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
window.open("../ExportToFile.aspx?type=custrecord&param=" + searchtxt);
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div style="min-width: 400px;">
<div class="page_title" data-lgid="P_CUSTOMERRECORD">Customer Record</div>
<div class="search_bar">
<input type="password" autocomplete="new-password" style="display: none" />
<input type="text" id="searchinputtxt" autocomplete="off" />
<input class="search" type="button" onclick="OnRefresh();" value="Search" data-lgid="P_CM_SEARCH" />
</div>
<div class="function_title">
<%if (!CRReadOnly)
{%>
<span class="sbutton iconadd" onclick="OnAdd();" data-lgid="P_UM_ADD">Add</span>
<span class="sbutton iconedit" onclick="OnEdit();" data-lgid="P_UM_EDIT">Edit</span>
<%}%>
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_UM_REFRESH">Refresh</span>
<span id="spExport" class="sbutton iconexport" onclick="OnExport();" data-lgid="P_MR_EXPORTTOEXCEL">Export to Excel</span>
</div>
<div class="clear"></div>
<div id="customerlist"></div>
<div class="machine_maskbg" style="display: none;"></div>
<div class="dialog" id="dialog_managemahchine" style="display: none;">
<div id="dialogmask" class="maskbg" style="display: none; z-index: 1;">
<div class="loading_icon icon c-spin"></div>
</div>
<div class="dialog-title"><span class="title" data-lgid="P_UM_ASSETASSIGNMENT">Asset Assignment</span><em class="dialog-close"></em></div>
<div class="machine_filter" style="display: none">
<span data-lgid="P_UM_TYPE_COLON">Type: </span>
<select id="sel_machine_type" tabindex="20"></select>
<input type="text" id="txt_machine_key" tabindex="21" />
<input type="button" class="ybutton" id="button_machine_filter" value="Filter" data-lgid="P_UM_FILTER" tabindex="22" />
<span id="span_text_holder" style="display: none;"></span>
</div>
<div class="machine_filter" style="margin: 9px 6px 5px">
<span class="sbutton iconadd" onclick="OnMachineAdd()" data-lgid="P_UM_ADD">Add</span>
<span class="sbutton icondelete" onclick="OnMachineDelete()" data-lgid="P_UM_DELETE">Delete</span>
</div>
<div class="div_machines">
<table class="table_holder">
<tbody>
<tr>
<td style="padding: 2px 4px 4px">
<div id="selectedmachinelist" style="height: 500px; width: 780px;"></div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="dialog-func">
<input type="button" value="Close" data-lgid="P_UM_CLOSE" class="dialog-close" tabindex="28" />
<div class="clear"></div>
</div>
</div>
<div id="mask_bg" style="display: none;">
<div class="loading c-spin"></div>
</div>
<div class="dialog" id="dialog_user" style="display: none; height: 100%; border-bottom: 0; border-top: 0;">
<iframe id="iframeuser" src="AddCustomerRecord.aspx" style="width: 100%; height: 100%; display: block; border: none;"></iframe>
<div class="maskbg" style="display: none;"></div>
</div>
</div>
</asp:Content>

View File

@ -0,0 +1,47 @@
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Customer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Maintenance_CustomerRecordManagement : CustomerRecordBasePage
{
protected string IID;
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
protected bool CRReadOnly = false;
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
// TODO: sub page
//RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest();
}
else if (!IsPostBack)
{
// todo nothing
IID = GetCurrentLoginSession().User.UID;
this.Title = PageTitle;
bool license = SystemParams.HasLicense("CustomerRecord");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.CUSTOMER_RECORD);
if (!permission)
RedirectToLoginPage();
CRReadOnly = CheckReadonly(SystemParams.CompanyID, Feature.CUSTOMER_RECORD);
}
}
}
}

View File

@ -0,0 +1,192 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/IronIntelMasterPage.master" AutoEventWireup="true" CodeFile="FuelRecordChangeHistory.aspx.cs" Inherits="FuelRecordChangeHistory" %>
<asp:Content ID="Content1" ContentPlaceHolderID="holder_head" runat="Server">
<style type="text/css">
.selectinput {
width: 150px;
margin-right: 10px;
}
.dialog-content table {
border-collapse: collapse;
width: 100%;
}
.dialog-content table td.label {
width: 150px;
text-align: right;
padding-right: 10px;
line-height: 24px;
height: 24px;
vertical-align: top;
}
.dialog-content table td input,
.dialog-content table td textarea {
border: 1px solid #a9a9a9;
width: 200px;
height: 18px;
padding: 1px;
}
.dialog-content table td input[type="checkbox"] {
border: none;
}
.dialog-content table td textarea {
height: 100px;
max-width: 200px;
}
#dialogdatatb td {
padding-top: 5px;
}
.a {
text-decoration: none;
color: #2140fb;
}
</style>
<script type="text/javascript">
var FuelID = "<%=FuelID %>";
var fuelrecorddata;
function fuelrequest(method, param, callback, error) {
_network.request("Maintenance/FuelRecordChangeHistory.aspx", -1, method, param, callback, error || function (e) {
showAlert(GetTextByKey('P_FR_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_FR_QUERY', 'Query'));
});
}
function enterKeydown(e) {
if (e.keyCode == 13) {
OnRefresh();
}
}
function OnRefresh() {
showloading(true);
fuelrequest("GetFuelRecordChangeHistory", FuelID, function (data) {
showloading(false);
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_FR_ERROR", 'Error'));
return;
}
if (data && data.length > 0)
fuelrecorddata = data;
else
fuelrecorddata = [];
showFuelRecordList(fuelrecorddata);
}, function (err) {
showloading(false);
});
}
function showFuelRecordList(data) {
var rows = [];
for (var i = 0; i < data.length; i++) {
var r = data[i];
for (var j in r) {
if (j === "TransactionLocalDate") {
r[j] = { DisplayValue: r["TransactionLocalDateStr"], Value: r[j] };
}
else if (j === "AddedOn_Local") {
r[j] = { DisplayValue: r["AddedOn_LocalStr"], Value: r[j] };
}
else if (j === "LastUpdatedOn_Local") {
r[j] = { DisplayValue: r["LastUpdatedOn_LocalStr"], Value: r[j] };
}
}
var fr = { Values: r };
rows.push(fr);
}
grid_dt.setData(rows);
}
var grid_dt;
function InitGridData() {
grid_dt = new GridView('#recordlist');
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: 'AssetName', caption: GetTextByKey("P_FR_ASSETNAME", GetTextByKey("P_FR_ASSETNAME", "Asset Name")), valueIndex: 'AssetName', css: { 'width': 180, 'text-align': 'left' } },
{ name: 'AssetMake', caption: GetTextByKey("P_FR_MAKE", "Make"), valueIndex: 'AssetMake', allowFilter: true, css: { 'width': 120, 'text-align': 'left' } },
{ name: 'AssetModel', caption: GetTextByKey("P_FR_MODEL", "Model"), valueIndex: 'AssetModel', allowFilter: true, css: { 'width': 120, 'text-align': 'left' } },
{ name: 'VIN', caption: GetTextByKey("P_FR_SNVIN", "SN/VIN"), valueIndex: 'VIN', css: { 'width': 180, 'text-align': 'left' } },
{ name: 'TicketNumber', caption: GetTextByKey("P_FR_TICKETNUMBER", "Ticket Number"), valueIndex: 'TicketNumber', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'DriverName', caption: GetTextByKey("P_FR_DRIVERNAME", "Driver Name"), valueIndex: 'DriverName', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'FuelType', caption: GetTextByKey("P_FR_FUELTYPE", "Fuel Type"), valueIndex: 'FuelType', allowFilter: true, css: { 'width': 90, 'text-align': 'left' } },
{ name: 'TransactionLocalDate', caption: GetTextByKey("P_FR_TRANSACTIONDATE", "Transaction Date"), valueIndex: 'TransactionLocalDate', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'RetailerName', caption: GetTextByKey("P_FR_RETAILERNAME", "Retailer Name"), valueIndex: 'RetailerName', css: { 'width': 180, 'text-align': 'left' } },
{ name: 'RetailerAddress', caption: GetTextByKey("P_FR_ADDRESS", "Address"), valueIndex: 'RetailerAddress', css: { 'width': 180, 'text-align': 'left' } },
{ name: 'RetailerCity', caption: GetTextByKey("P_FR_CITY", "City"), valueIndex: 'RetailerCity', css: { 'width': 150, 'text-align': 'left' } },
{ name: 'RetailerState', caption: GetTextByKey("P_FR_STATE", "State"), valueIndex: 'RetailerState', css: { 'width': 80, 'text-align': 'left' } },
{ name: 'RetailerZip', caption: GetTextByKey("P_FR_ZIP", "Zip"), valueIndex: 'RetailerZip', css: { 'width': 80, 'text-align': 'left' } },
{ name: 'Quantity', caption: GetTextByKey("P_FR_QUANTITY", "Quantity"), valueIndex: 'Quantity', css: { 'width': 80, 'text-align': 'right' } },
{ name: 'Uom', caption: GetTextByKey("P_FR_UOM", "Uom"), valueIndex: 'Uom', css: { 'width': 80, 'text-align': 'left' } },
{ name: 'TotalCost', caption: GetTextByKey("P_FR_TOTALCOST", "Total Cost"), valueIndex: 'TotalCost', css: { 'width': 80, 'text-align': 'right' } },
{ name: 'AddedByName', caption: GetTextByKey("P_FR_ADDEDNAME", "Added Name"), valueIndex: 'AddedByName', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'AddedOn_Local', caption: GetTextByKey("P_FR_ADDEDON", "Added On"), valueIndex: 'AddedOn_Local', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'LasetUpdatedByName', caption: GetTextByKey("P_FR_LASTUPDATEDNAME", "Last Updated Name"), valueIndex: 'LasetUpdatedByName', css: { 'width': 122, 'text-align': 'left' } },
{ name: 'LastUpdatedOn_Local', caption: GetTextByKey("P_FR_LASTUPDATEDON", "Last Updated On"), valueIndex: 'LastUpdatedOn_Local', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'Notes', caption: GetTextByKey("P_FR_NOTES", "Notes"), valueIndex: 'Notes', 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_dt.canMultiSelect = false;
grid_dt.columns = columns;
grid_dt.init();
grid_dt.selectedrowchanged = function (rowindex) {
var rowdata = grid_dt.source[rowindex];
if (rowdata) {
}
}
}
$(function () {
InitGridData();
OnRefresh();
$(window).resize(function () {
$("#recordlist").css("height", $(window).height() - $("#recordlist").offset().top - 4);
grid_dt && grid_dt.resize();
}).resize();
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="holder_content" runat="Server">
<div id="recordcontent" style="padding: 0px; margin: 0px;">
<div class="page_title" data-lgid="P_FR_FUELRECORDCHANGEHISTORY">Fuel Record Change History</div>
<div class="search_bar">
</div>
<div class="function_title">
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_FR_REFRESH">Refresh</span>
</div>
<div class="clear"></div>
<div id="recordlist"></div>
</div>
<div id="mask_bg" style="display: none;">
<div class="loading c-spin"></div>
</div>
</asp:Content>

View File

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Maintenance;
public partial class FuelRecordChangeHistory : FuelRecordBasePage
{
public string FuelID = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
this.Title = PageTitle;
bool license = SystemParams.HasLicense("FuelRecords");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.FUEL_RECORDS);
if (!permission)
RedirectToLoginPage();
FuelID = Request.Params["fuleid"];
}
}
}
}

View File

@ -0,0 +1,395 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="FuelRecordManagement.aspx.cs" Inherits="Maintenance_FuelRecordManagement" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link href="../css/jquery.datetimepicker.css" rel="stylesheet" />
<style type="text/css">
.selectinput {
width: 150px;
margin-right: 10px;
}
.dialog-content table {
border-collapse: collapse;
width: 100%;
}
.dialog-content table td.label {
width: 150px;
text-align: right;
padding-right: 10px;
line-height: 24px;
height: 24px;
vertical-align: top;
}
.dialog-content table td input,
.dialog-content table td textarea {
border: 1px solid #a9a9a9;
width: 200px;
height: 18px;
padding: 1px;
}
.dialog-content table td input[type="checkbox"] {
border: none;
}
.dialog-content table td textarea {
height: 100px;
max-width: 200px;
}
#dialogdatatb td {
padding-top: 5px;
}
.a {
text-decoration: none;
color: #2140fb;
}
</style>
<script src="../js/jquery.datetimepicker.full.js"></script>
<script src="<%=GetFileUrlWithVersion("js/inputdatactr.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../js/editableselect.js")%>" type="text/javascript"></script>
<script type="text/javascript">
var fuelrecorddata;
var assetid = "<%=AssetID %>";
function fuelrequest(method, param, callback, error) {
_network.request("Maintenance/FuelRecordManagement.aspx", -1, method, param, callback, error || function (e) {
showmaskbg(false, true);
showAlert(GetTextByKey('P_FR_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_FR_QUERY', 'Query'));
});
}
function recordrequest(method, param, callback, error) {
_network.request("Maintenance/MaintanceRecordsManagement.aspx", -1, method, param, callback, error || function (e) {
showmaskbg(false, true);
showAlert(GetTextByKey('P_FR_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_FR_QUERY', 'Query'));
});
}
function enterKeydown(e) {
if (e.keyCode == 13) {
OnRefresh();
}
}
function GetTypesData() {
recordrequest("GetTypesData", '', function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_FR_ERROR", 'Error'));
return;
}
$('#typeselectinput').empty();
$("<option></option>").val("-1").text(GetTextByKey("P_SELECT_ALL", "All")).appendTo($("#typeselectinput"));
for (var i = 0; i < data.length; i++) {
$("<option></option>").val(data[i].Key).text(data[i].Value).appendTo($("#typeselectinput"));
}
OnRefresh();
}, function (err) {
})
}
function OnRefresh() {
showloading(true);
var type = $('#typeselectinput').find("option:selected").val();
var searchtxt = "";
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
var startdate = htmlencode($('#startdatetxt').val());
var enddate = htmlencode($('#enddatetxt').val());
var aid = (!assetid || assetid == "") ? -1 : eval(assetid);
fuelrequest("GetFuelRecords", type + String.fromCharCode(170) + startdate + String.fromCharCode(170) + enddate + String.fromCharCode(170) + searchtxt + String.fromCharCode(170) + aid, function (data) {
showloading(false);
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_FR_ERROR", 'Error'));
return;
}
if (data && data.length > 0)
fuelrecorddata = data;
else
fuelrecorddata = [];
showFuelRecordList(fuelrecorddata);
}, function (err) {
showloading(false);
});
}
function getLangUom(text) {
var langtext = text;
if (text === "Litre")
langtext = GetTextByKey("P_FR_LITRE", "Litre");
else if (text === "Gallon")
langtext = GetTextByKey("P_FR_GALLON", "Gallon");
return langtext;
}
function showFuelRecordList(data) {
var rows = [];
for (var i = 0; i < data.length; i++) {
var r = data[i];
for (var j in r) {
if (j === "TransactionLocalDate") {
r[j] = { DisplayValue: r["TransactionLocalDateStr"], Value: r[j] };
}
else if (j === "DistributedBy") {
r["DistributedBy"] = { DisplayValue: r.DistributedBy == 0 ? "Fueling Station" : "Fueling Asset", Value: r[j] };
}
//else if (j === "Uom") {
// r[j] = { DisplayValue: getLangUom(r["Uom"]), Value: r[j] };
//}
}
var fr = { Values: r };
rows.push(fr);
}
grid_dt.setData(rows);
}
var grid_dt;
function InitGridData() {
grid_dt = new GridView('#recordlist');
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: 'AssetName', caption: GetTextByKey("P_FR_ASSETNAME", "Asset Name"), valueIndex: 'AssetName', css: { 'width': 180, 'text-align': 'left' } },
{ name: 'AssetMake', caption: GetTextByKey("P_FR_MAKE", "Make"), valueIndex: 'AssetMake', allowFilter: true, css: { 'width': 120, 'text-align': 'left' } },
{ name: 'AssetModel', caption: GetTextByKey("P_FR_MODEL", "Model"), valueIndex: 'AssetModel', allowFilter: true, css: { 'width': 120, 'text-align': 'left' } },
{ name: 'VIN', caption: GetTextByKey("P_FR_SNVIN", "SN/VIN"), valueIndex: 'VIN', css: { 'width': 180, 'text-align': 'left' } },
{ name: 'TransactionLocalDate', caption: GetTextByKey("P_FR_TRANSACTIONDATE", "Transaction Date"), valueIndex: 'TransactionLocalDate', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'DistributedBy', caption: GetTextByKey("P_FR_DISTRIBUTEDBY", "Distributed By"), valueIndex: 'DistributedBy', allowFilter: true, css: { 'width': 120, 'text-align': 'left' } },
{ name: 'RetailerName', caption: GetTextByKey("P_FR_RETAILERNAME", "Retailer Name"), valueIndex: 'RetailerName', css: { 'width': 180, 'text-align': 'left' } },
{ name: 'FuelingAssetName', caption: GetTextByKey("P_FR_ASSET", "Asset"), valueIndex: 'FuelingAssetName', css: { 'width': 180, 'text-align': 'left' } },
{ name: 'Quantity', caption: GetTextByKey("P_FR_QUANTITY", "Quantity"), valueIndex: 'Quantity', css: { 'width': 80, 'text-align': 'right' } },
{ name: 'Uom', caption: GetTextByKey("P_FR_UOM", "UOM"), valueIndex: 'Uom', css: { 'width': 80, 'text-align': 'left' } },
{ name: 'UnitCost', caption: GetTextByKey("P_FR_UOMCOST", "Unit Cost"), valueIndex: 'UnitCost', css: { 'width': 80, 'text-align': 'right' } },
{ name: 'TotalCost', caption: GetTextByKey("P_FR_TOTALCOST", "Total Cost"), valueIndex: 'TotalCost', css: { 'width': 80, 'text-align': 'right' } },
{ 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;
if (col.name === "Edit") {
col.isurl = true;
col.text = "\uf044";
col.events = {
onclick: function () {
OnEdit();
}
};
col.classFilter = function (e) {
return "icon-col";
}
col.attrs = { 'title': GetTextByKey("P_FR_EDIT", 'Edit') };
}
else if (col.name === "Delete") {
col.isurl = true;
col.text = "\uf00d";
col.events = {
onclick: function () {
OnDelete(this);
}
};
col.classFilter = function (e) {
return "icon-col";
};
col.styleFilter = function (e) {
return {
display: e.IsComesFromAPI ? 'none' : ''
};
};
col.attrs = { 'title': GetTextByKey("P_FR_DELETE", 'Delete') };
}
columns.push(col);
}
grid_dt.canMultiSelect = false;
grid_dt.columns = columns;
grid_dt.init();
grid_dt.rowdblclick = OnEdit;
grid_dt.selectedrowchanged = function (rowindex) {
var rowdata = grid_dt.source[rowindex];
if (rowdata) {
}
}
}
//执行iframe中函数
var doIFrameFunc = function (v_mymethod, v_params, v_frmName) {
if (document.getElementById(v_frmName)) {
var fn = document.getElementById(v_frmName).contentWindow[v_mymethod];
if (fn) {
if (v_params == null)
return fn();
else {
return fn.apply(this, v_params);
}
}
return null;
}
}
function ShowDialog(type) {
showmaskbg(true);
$('#dialog_fuelrecord')
.attr('act', type)
.showDialogRight();
}
function CloseDialog(type) {
$('#dialog_fuelrecord').hideDialog();
OnRefresh();
}
function OnAdd() {
doIFrameFunc("init", [], "iframfuelrecord");
ShowDialog("add");
}
function OnEdit() {
var index = grid_dt.selectedIndex;
if (index < 0) {
showAlert(GetTextByKey("P_FR_PLEASESELECTAFUELRECORD", "Please select a fuel record."), GetTextByKey("P_FR_EDITFUELRECORD", "Edit Fuel Record"));
return;
}
var record = grid_dt.source[index].Values;
if (!record)
return;
doIFrameFunc("init", [record], "iframfuelrecord");
showmaskbg(true);
ShowDialog("edit");
}
function OnDelete(record) {
if (!record) {
return;
}
var alerttitle = GetTextByKey("P_FR_DELETEFUELRECORD", 'Delete Fuel Record');
showConfirm(GetTextByKey("P_FR_DOYOUDELETETHEFULERECORD", 'Do you want to delete the fuel record?'), alerttitle, function () {
fuelrequest("DeleteFuelRecord", record.FuelID, function (data) {
if (data !== "OK")
showAlert(data, alerttitle);
else
OnRefresh();
}, function (err) {
showAlert(GetTextByKey("P_FR_FAILEDTODELETETHISFUELRECORD", 'Failed to delete this fuel record.'), alerttitle);
});
});
}
$(function () {
setPageTitle(GetTextByKey("P_FUELRECORDS", "Fuel Records"), true);
InitGridData();
GetTypesData();
$('#startdatetxt').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]);
}
});
$('#enddatetxt').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]);
}
});
$('#searchinputtxt').keydown(enterKeydown);
$('#typeselectinput').change(function () { OnRefresh(); });
$(window).resize(function () {
$("#recordlist").css("height", $(window).height() - $("#recordlist").offset().top - 4);
grid_dt && grid_dt.resize();
}).resize();
if (!canExport) {
$('#spExport').hide();
}
});
function changeasset(aid) {
assetid = aid;
OnRefresh();
}
function OnExit() {
window.parent.CloseFuelRecordsDialog();
}
function OnExport() {
var searchtxt = "";
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
var type = $('#typeselectinput').find("option:selected").val();
var from = htmlencode($('#startdatetxt').val());
var to = htmlencode($('#enddatetxt').val());
var aid = (!assetid || assetid == "") ? -1 : eval(assetid);
window.open("../ExportToFile.aspx?type=fuelrecordmanagement&t=" + searchtxt + "&from=" + from + "&to=" + to + "&tp=" + type + "&aid=" + aid);
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div id="recordcontent" style="padding: 0px; margin: 0px;">
<div class="page_title" data-lgid="P_FUELRECORDS">Fuel Records</div>
<div class="search_bar">
<input type="password" autocomplete="new-password" style="display: none" />
<span data-lgid="P_FR_BEGINDATE_COLON">Begin Date:&nbsp;</span>
<span>
<input id="startdatetxt" type="text" style="width: 100px;" value="<%=BeginDate %>" autocomplete="off" /></span>
<span data-lgid="P_FR_ENDDATE_COLON">End Date:&nbsp;</span>
<span>
<input id="enddatetxt" type="text" style="width: 100px;" value="<%=EndDate %>" autocomplete="off" /></span>
<span data-lgid="P_FR_ASSETTYPE_COLON" style="padding-left: 5px;">Type:</span>&nbsp;&nbsp;<select class="selectinput" id="typeselectinput"></select>
<input id="searchinputtxt" type="text" autocomplete="off" />
<input class="search" type="button" onclick="OnRefresh();" value="Search" data-lgid="P_FR_SEARCH" style="margin-left: 5px;" />
</div>
<div class="function_title">
<span class="sbutton iconadd" onclick="OnAdd();" style="<%=InDialog?"display:none;": ""%>;" data-lgid="P_FR_ADD">Add</span>
<span class="sbutton iconedit" onclick="OnEdit();" style="<%=InDialog?"display:none;": ""%>;" data-lgid="P_FR_EDIT">Edit</span>
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_FR_REFRESH">Refresh</span>
<span id="spExport" class="sbutton iconexport" onclick="OnExport();" data-lgid="P_MR_EXPORTTOEXCEL">Export to Excel</span>
<span class="sbutton iconexit" onclick="OnExit();" style="<%=InDialog?"": "display:none;"%>;" data-lgid="P_WO_EXIT">Exit</span>
</div>
<div class="clear"></div>
<div id="recordlist"></div>
</div>
<div id="mask_bg" style="display: none;">
<div class="loading c-spin"></div>
</div>
<div class="dialog" id="dialog_fuelrecord" style="display: none; height: 100%; border-bottom: 0; border-top: 0;">
<iframe id="iframfuelrecord" src="AddFuelRecord.aspx" style="width: 100%; height: 100%; display: block; border: none;"></iframe>
<div class="maskbg" style="display: none;"></div>
</div>
</asp:Content>

View File

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Maintenance;
public partial class Maintenance_FuelRecordManagement : FuelRecordBasePage
{
public string BeginDate = "";
public string EndDate = "";
public string AssetID = "";
public bool InDialog = false;
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
this.Title = PageTitle;
bool license = SystemParams.HasLicense("FuelRecords");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.FUEL_RECORDS);
if (!permission)
RedirectToLoginPage();
AssetID = Request.Params["mid"] ?? "";
InDialog = Request.Params["InDialog"] == "1";
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
BeginDate = userlocaldate.AddDays(-6).ToShortDateString();
EndDate = userlocaldate.ToShortDateString();
}
}
}
}

View File

@ -0,0 +1,634 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="MachineMaintenanceInfo.aspx.cs" Inherits="Maintenance_MachineMaintenanceInfo" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link href="../css/jquery.datetimepicker.css" rel="stylesheet" />
<style type="text/css">
.return {
float: left;
width: 50px;
line-height: 56px;
font-style: normal;
text-align: left;
cursor: pointer;
}
.return:before {
content: '\e631';
}
.cupbutton {
background-color: rgb(249, 189, 117);
border: none;
padding-top: 5px;
padding-bottom: 5px;
margin-left: 10px;
cursor: pointer;
width: 60px;
}
.cupbutton:hover {
background: #d7690E;
}
.labeltdstyle {
text-align: right;
padding-top: 10px;
padding-left: 10px;
}
.inputtdstyle {
text-align: left;
padding-top: 10px;
}
.a {
text-decoration: none;
color: #2140fb;
}
.dialog .dialog-title .dialog-close {
float: right;
margin-right: 6px;
cursor: pointer;
}
.dialog .dialog-title .dialog-close:before {
content: '\e600';
}
.dialog-content table {
border-collapse: collapse;
width: 100%;
}
.dialog-content table td.label {
width: 150px;
text-align: right;
padding-right: 10px;
line-height: 24px;
height: 24px;
vertical-align: middle;
}
.dialog-content table td input,
.dialog-content table td textarea {
border: 1px solid #a9a9a9;
width: 200px;
height: 18px;
padding: 1px;
}
.dialog-content table td input[type="checkbox"] {
border: none;
}
.dialog-content table td textarea {
height: 100px;
max-width: 200px;
}
#dialogdatatb td {
padding-top: 5px;
}
#droptable td, th {
word-break: keep-all;
white-space: nowrap;
}
.sbutton {
font-size: 16px;
font-weight: bold;
}
.sbutton:before {
color: black;
}
</style>
<script src="../js/jquery.datetimepicker.full.js"></script>
<script src="<%=GetFileUrlWithVersion("js/inputdatactr.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../js/editableselect.js")%>" type="text/javascript"></script>
<%--<script src="<%=GetFileUrlWithVersion("js/attachments.js")%>" type="text/javascript"></script>--%>
<script type="text/javascript">
var assetid = "<%=AssetID %>";
$(function () {
InitGridData();
if (document.all) {
$('#dropDIV').css('left', 262);
}
GetTypesData();
$('#dialog_maintenance').prop('iframe', true).dialog(function () {
showmaskbg(false);
});
$('#dialog_mdate').click(function () { $('#dateformatspan').css('display', 'none'); }).blur(function () {
if ($.trim($(this).val()) == "") {
$('#dateformatspan').css('display', '');
}
else {
$('#dateformatspan').css('display', 'none');
}
}).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]);
}
})
InputControl($('#dialog_hours'));
$('#dialog_hours').change(function () { if (!inputValueFormat(this)) { $(this).val(''); } })
if (!assetid || assetid == "")
$('#searchinputtxt').bind('input propertychange', function () { SearchmachineList(false); }).click(function () { SearchmachineList(true); });
else {
$('#searchinputtxt').val(assetid).attr("disabled", "disabled");
$('#typeselectinput').attr("disabled", "disabled");
OnSearch();
}
$('#typeselectinput').change(function () { SearchmachineList(false); });
$('#dropDIV').mouseup(function (e) { e.stopPropagation(); });
$('#droptitle').mouseup(function (e) { e.stopPropagation(); });
$(document).mouseup(function (e) {
var targetE = e.target;
if (!targetE.id || (targetE.id != "searchinputtxt" && targetE.id != "dropDIV"))
$('#dropDIV').css('display', 'none');
});
$('#content').scroll(function () {
$('#dropDIV').css('display', 'none');
});
$('#dig_mtype').change(function () {
var logType = $(this).val();
if (logType === "Hours"
|| logType === "Undercarriage"
|| logType === "TimeOffRoad") {
$('#tr_distance').hide();
$('#tr_hours').show();
}
else {
$('#tr_hours').hide();
$('#tr_distance').show();
}
if (logType === "Undercarriage"
|| logType === "TimeOffRoad"
|| logType === "TimeOverRoad") {
$("#dialog_pmalerts").val("").attr("disabled", true);
}
else {
$("#dialog_pmalerts").attr("disabled", false);
}
});
$(window).resize(function () {
$("#recordlist").css("height", $(window).height() - $("#recordlist").offset().top - 15);
grid_dt && grid_dt.resize();
}).resize();
})
function leavedrpdiv(e) {
$(this).css('display', 'none');
}
function SearchmachineList(fromclick) {
if (!fromclick)
ClearMachinInfo();
var val = $('#searchinputtxt').val();
if (val.length > 100) {
val = val.substr(0, 100);
$('#searchinputtxt').val(val);
}
$.ajax(
{
type: "POST",
async: false,
datatype: "json",
url: "MachineMaintenanceInfo.aspx",
data: {
type: $('#typeselectinput').find("option:selected").val(),
searchtxt: htmlencode($.trim($('#searchinputtxt').val())),
MethodName: "SearchmachineList"
},
success: function (datastr) {
$('#machines_tbody').empty();
if (datastr != "") {
var machinesdata = eval("(" + datastr + ")");
$('#dropDIV').css('display', '');
var maxtcount = 50;
if (machinesdata.length <= 50)
maxtcount = machinesdata.length;
for (var i = 0; i < maxtcount; i++) {
var tr = $('<tr></tr>').attr({ 'rowindex': i, 'id': machinesdata[i].MachineID }).click(function () {
$('#searchinputtxt').val($(this)[0].attributes['id'].value);
$('#machines_tbody tr').each(function () {
$(this).removeClass("selected");
})
$(this).addClass("selected");
OnSearch();
$('#dropDIV').hide();
});
var tdid = $('<td></td>').text(machinesdata[i].MachineID);
var tdvin = $('<td></td>').text(machinesdata[i].VIN);
var tdname = $('<td></td>').text(machinesdata[i].DisplayName);
var tdmake = $('<td></td>').text(machinesdata[i].Make);
var tdmodel = $('<td></td>').text(machinesdata[i].Model);
var tdtype = $('<td></td>').text(machinesdata[i].MachineType);
tr.append(tdid, tdvin, tdname, tdmake, tdmodel, tdtype);
$('#machines_tbody').append(tr);
}
}
else {
$('#dropDIV').css('display', '');
}
},
error: function (msg) {
showAlert(msg.statusText, GetTextByKey("P_MRM_ERROR", 'Error'));
}
}
)
}
function GetTypesData() {
$.ajax(
{
type: "POST",
async: false,
datatype: "json",
url: "MachineMaintenanceInfo.aspx",
data: {
MethodName: "GetTypesData"
},
success: function (data) {
$('#typeselectinput').empty();
$("<option></option>").val("").text(GetTextByKey("P_SELECT_ALL", "All")).appendTo($("#typeselectinput"));
if (data != "" && data != "[]") {
var datattype = JSON.parse(data);
for (var i = 0; i < datattype.length; i++) {
$("<option></option>").val(datattype[i].Key).text(datattype[i].Value).appendTo($("#typeselectinput"));
}
}
},
error: function (msg) {
showAlert(msg.statusText, GetTextByKey("P_MRM_ERROR", 'Error'));
}
}
)
}
function GetRecordesbymachineID() {
showloading(true);
if ($('#mid').val() == "") {
showAlert(GetTextByKey("P_MRM_SAVEWORKORDERFIRST", "Please select an Asset."), GetTextByKey("P_MRM_SYSTEMINFORMATION", "System Information"));
return false;
}
$.ajax(
{
type: "POST",
async: false,
datatype: "json",
url: "MachineMaintenanceInfo.aspx",
data: {
machineID: $('#mid').val(),
MethodName: "GetRecordsbymachineID"
},
success: function (datastr) {
showloading(false);
if (datastr != "") {
var recordsdata = eval("(" + datastr + ")");
showRecordList(recordsdata);
}
},
error: function (msg) {
showloading(false);
showAlert(msg.statusText, GetTextByKey("P_MRM_ERROR", 'Error'));
}
}
)
}
function showRecordList(data) {
var rows = [];
for (var i = 0; i < data.length; i++) {
var r = data[i];
var distype = r.LogType;
if (r.LogType == "TimeOffRoad")
distype = 'Time/Off-Road';
else if (r.LogType == "TimeOverRoad")
distype = 'Time/Over Road';
for (var j in r) {
if (j === "LogType") {
r[j] = { DisplayValue: distype, Value: r[j] };
}
else if (j === "MaintenanceDate") {
r[j] = { DisplayValue: r["StrForMaintenanceDate"], Value: r[j] };
}
}
var fr = { Values: r };
rows.push(fr);
}
grid_dt.setData(rows);
}
var grid_dt;
function InitGridData() {
grid_dt = new GridView('#recordlist');
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: 'MaintenanceDate', caption: GetTextByKey("P_MRM_DATE", "Date"), valueIndex: 'MaintenanceDate', css: { 'width': 90, 'text-align': 'left' } },
{ name: 'LogType', caption: GetTextByKey("P_MRM_MAINTENANCETYPE", "Maintenance Type"), valueIndex: 'LogType', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'MaintenanceHours', caption: GetTextByKey("P_MRM_MAINTENANCEHOURS", "Maintenance Hours"), valueIndex: 'MaintenanceHours', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'ODOMeter', caption: GetTextByKey("P_MRM_MAINTENANCEDISTANCE", "Maintenance Distance"), valueIndex: 'ODOMeter', css: { 'width': 135, 'text-align': 'left' } },
{ name: 'ODOMemterUOM', caption: GetTextByKey("P_MRM_DISTANCEUOM", "Distance UOM"), valueIndex: 'ODOMemterUOM', css: { 'width': 100, 'text-align': 'left' } },
{ name: 'Cost', caption: GetTextByKey("P_MRM_COST", "Cost"), valueIndex: 'Cost', css: { 'width': 100, 'text-align': 'left' } },
{ name: 'InvoiceNumber', caption: GetTextByKey("P_MRM_INVOICENUMBER", "Invoice Number"), valueIndex: 'InvoiceNumber', css: { 'width': 110, 'text-align': 'left' } },
{ name: 'CompletedByName', caption: GetTextByKey("P_MRM_COMPLETEDBY", "Completed By"), valueIndex: 'CompletedByName', css: { 'width': 110, 'text-align': 'left' } },
{ name: 'Notes', caption: GetTextByKey("P_MRM_DESCRIPTION", "Description"), valueIndex: 'Notes', css: { 'width': 190, '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;
if (col.name === "Edit") {
col.isurl = true;
col.text = "\uf044";
col.events = {
onclick: function () {
OnEdit();
}
};
col.classFilter = function (e) {
return "icon-col";
}
col.attrs = { 'title': GetTextByKey("P_MRM_EDIT", 'Edit') };
}
else if (col.name === "Delete") {
col.isurl = true;
col.text = "\uf00d";
col.events = {
onclick: function () {
OnDelete(this);
}
};
col.classFilter = function (e) {
return "icon-col";
};
col.attrs = { 'title': GetTextByKey("P_MRM_DELETE", 'Delete') };
}
columns.push(col);
}
grid_dt.canMultiSelect = false;
grid_dt.columns = columns;
grid_dt.init();
grid_dt.rowdblclick = OnEdit;
grid_dt.selectedrowchanged = function (rowindex) {
var rowdata = grid_dt.source[rowindex];
if (rowdata) {
}
}
}
function OnSearch() {
var machineID = $.trim($('#searchinputtxt').val());
if (machineID.length == 0) {
SearchmachineList(true);
return;
}
ClearMachinInfo();
$.ajax(
{
type: "POST",
async: false,
datatype: "json",
url: "MachineMaintenanceInfo.aspx",
data: {
machineID: htmldecode($.trim($('#searchinputtxt').val())),
MethodName: "GetmachineInfo"
},
success: function (datastr) {
if (datastr != "") {
var machinesdata = eval("(" + datastr + ")");
if (machinesdata.MachineID == -1) {
SearchmachineList(true);
return;
}
else {
refreshDom(machinesdata);
GetRecordesbymachineID();
}
}
$('#mask_bg').css('height', $(document).height())
},
error: function (msg) {
showAlert(msg.statusText, GetTextByKey("P_MRM_ERROR", 'Error'));
}
}
)
}
function ClearMachinInfo() {
$('#mid').val('');
$('#mpin').val('');
$('#mname').val('');
$('#mmake').val('');
$('#mmodel').val('');
$('#mtype').val('');
$('#mengine').val('');
//$('#records_tbody').empty();//TODO
}
function refreshDom(data) {
$('#mid').val(data.MachineID);
$('#mpin').val(data.VIN);
$('#mname').val(data.DisplayName);
$('#mmake').val(data.Make);
$('#mmodel').val(data.Model);
$('#mtype').val(data.MachineType);
$('#mengine').val(data.EngineHours);
}
//执行iframe中函数
var doIFrameFunc = function (v_mymethod, v_params, v_frmName) {
if (document.getElementById(v_frmName)) {
var fn = document.getElementById(v_frmName).contentWindow[v_mymethod];
if (fn) {
if (v_params == null)
return fn();
else {
return fn.apply(this, v_params);
}
}
return null;
}
}
function CloseDialog(type) {
$('#dialog_maintenancerecord').hideDialog();
if (type == 1) {
GetRecordesbymachineID();
}
else {
showmaskbg(false);
}
}
function DoubleClick(e) {
OnEdit();
}
function OnAdd() {
var machineid = $('#mid').val()
if (machineid == "") {
showAlert(GetTextByKey("P_MRM_SAVEWORKORDERFIRST", "Please select an Asset."), GetTextByKey("P_MRM_SYSTEMINFORMATION", "System Information"));
return false;
}
doIFrameFunc("init", [machineid], "iframemaintenancerecord");
showmaskbg(true);
$('#dialog_maintenancerecord')
.attr('act', 'add')
.showDialogRight();
}
function OnEdit() {
var record = grid_dt.source[grid_dt.selectedIndex].Values;
doIFrameFunc("init", [record.MachineID, record.MaintenanceID], "iframemaintenancerecord");
showmaskbg(true);
$('#dialog_maintenancerecord')
.attr('act', 'edit')
.showDialogRight();
}
function OnDelete(record) {
showConfirm(GetTextByKey("P_MRM_DELETETHERECORD", "Would you like to delete the record?"), GetTextByKey("P_MRM_SYSTEMINFORMATION", "System Information"), function () {
$.ajax({
type: "POST",
async: false,
datatype: "json",
url: "MachineMaintenanceInfo.aspx",
data: {
maintenanceid: record.MaintenanceID,
MethodName: "Deletemaintenance"
},
success: function (msg) {
GetRecordesbymachineID();
showAlert(GetTextByKey('P_MRM_DELETEDSUCCESSFULLY', 'Deleted Successfully.'), GetTextByKey("P_MRM_SYSTEMINFORMATION", GetTextByKey("P_MRM_SYSTEMINFORMATION", "System Information")));
},
error: function (msg) {
showAlert(GetTextByKey('P_MRM_FAILEDTODELETERECORD', 'Failed to delete record.'), GetTextByKey("P_MRM_ERROR", 'Error'));
}
})
}, function () { return false; });
}
function back() {
if (assetid && assetid !== "")
window.location.href = "MaintanceRecordsManagement.aspx?InDialog=" +<%=InDialog?"1": "0"%>+"&mid=" + assetid;
else
window.location.href = "MaintanceRecordsManagement.aspx";
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div class="content_main" style="min-width: 1000px; padding-left: 15px;">
<div class="page_title">
<span class="sbutton iconback" onclick="back();"></span>
<span data-lgid="P_MRM_ADDMAINTENANCERECORD">Add Maintenance Record</span>
</div>
<div class="clear"></div>
<div style="border: 1px solid #b0b0b0; padding: 0px; padding-top: 20px; padding-bottom: 20px; margin: 0px; margin-top: 10px; margin-bottom: 20px; position: relative; height: 30px;">
<span style="margin-left: 10px;" data-lgid="P_MRM_TYPE_COLON">Type: </span>&nbsp;
<select class="selectinput" id="typeselectinput" style="width: 150px;"></select>
<input id="searchinputtxt" autocomplete="off" style="width: 500px; padding: 0px; height: 18px; margin: 0px; border: 1px solid #b0b0b0;" />
<input class="search cupbutton" type="button" onclick="OnSearch();" value="Search" data-lgid="P_MRM_SEARCH" />
<span id="currentmachineID"></span>
<div style="position: absolute; top: -10px; left: 10px; background-color: Window;" data-lgid="P_MRM_SEARCHASSET">Search Asset</div>
<div id="dropDIV" style="border: 1px solid #b0b0b0; width: 500px; height: 400px; overflow: auto; position: absolute; top: 43px; left: 200px; background-color: Window; display: none; z-index: 10;">
<table id="droptable" class="main_table" style="border: none;">
<thead>
<tr id="droptitle" style="border-width: 0px; background-color: #d3d1d1;">
<th style="width: 100px;" data-lgid="P_MRM_ASSETID">&nbsp;AssetID</th>
<th style="width: 200px;" data-lgid="P_MRM_SN">&nbsp;SN</th>
<th data-lgid="P_MRM_ASSETNAME">&nbsp;Asset Name</th>
<th data-lgid="P_MRM_MAKE">&nbsp;Make</th>
<th data-lgid="P_MRM_MODEL">&nbsp;Model</th>
<th data-lgid="P_MRM_ASSETTYPE">&nbsp;Type</th>
</tr>
</thead>
<tbody id="machines_tbody">
</tbody>
</table>
</div>
</div>
<div style="border: 1px solid #b0b0b0; position: relative; margin-bottom: 20px; padding-bottom: 10px;">
<table>
<tr>
<td class="labeltdstyle" data-lgid="P_MRM_ASSETID1_COLON">AssetID:</td>
<td class="inputtdstyle">
<input class="selectinput" id="mid" disabled="disabled" /></td>
<td class="labeltdstyle" data-lgid="P_MRM_SN_COLON">SN:</td>
<td class="inputtdstyle">
<input class="selectinput" id="mpin" disabled="disabled" /></td>
<td class="labeltdstyle" data-lgid="P_MRM_ASSETNAME_COLON">Asset Name:</td>
<td class="inputtdstyle">
<input class="selectinput" id="mname" disabled="disabled" /></td>
<td class="labeltdstyle" data-lgid="P_MRM_ENGINEHOURS_COLON">Engine Hours:</td>
<td class="inputtdstyle">
<input class="selectinput" id="mengine" disabled="disabled" /></td>
</tr>
<tr>
<td class="labeltdstyle" data-lgid="P_MRM_MAKE_COLON">Make:</td>
<td class="inputtdstyle">
<input class="selectinput" id="mmake" disabled="disabled" /></td>
<td class="labeltdstyle" data-lgid="P_MRM_MODEL_COLON">Model:</td>
<td class="inputtdstyle">
<input class="selectinput" id="mmodel" disabled="disabled" /></td>
<td class="labeltdstyle" data-lgid="P_MRM_ASSETTYPE_COLON">Type:</td>
<td class="inputtdstyle" colspan="3">
<input class="selectinput" id="mtype" style="width: 99.5%;" disabled="disabled" /></td>
<%-- <td class="labeltdstyle"></td>
<td class="inputtdstyle"></td>--%>
</tr>
</table>
<div style="position: absolute; top: -10px; left: 10px; background-color: Window;" data-lgid="P_MRM_ASSETINFORMATION">Asset Information</div>
</div>
<div style="border: 1px solid #b0b0b0; position: relative; padding-top: 0px; padding-bottom: 10px;">
<div style="float: right; margin-top: 10px; margin-bottom: 10px; padding-right: 20px;">
<input type="button" class="cupbutton" onclick="OnAdd();" value="Add" data-lgid="P_MRM_ADD" />
<input type="button" class="cupbutton" onclick="GetRecordesbymachineID();" value="Refresh" data-lgid="P_MRM_REFRESH" />
</div>
<div id="recordlist" style="margin-top: 50px;"></div>
<div style="position: absolute; top: -10px; left: 10px; background-color: Window;" data-lgid="P_MAINTENANCERECORDS">Maintenance Records</div>
</div>
</div>
<div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div>
<div class="dialog" id="dialog_maintenancerecord" style="display: none; height: 100%; border-bottom: 0; border-top: 0;">
<iframe id="iframemaintenancerecord" src="AddMaintenanceRecord.aspx" style="width: 100%; height: 100%; display: block; border: none;"></iframe>
<div class="maskbg" style="display: none;"></div>
</div>
</asp:Content>

View File

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Maintenance;
public partial class Maintenance_MachineMaintenanceInfo : MaintanceRecordsBasePage
{
public string AssetID = "";
public bool InDialog = false;
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
bool license = SystemParams.HasLicense("PreventativeMaintenance");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.PREVENTATIVE_MAINTENANCE);
if (!permission)
RedirectToLoginPage();
AssetID = Request.Params["mid"] ?? "";
InDialog = Request.Params["InDialog"] == "1";
}
}
}
}

View File

@ -0,0 +1,437 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="MaintanceRecordsManagement.aspx.cs" Inherits="Maintenance_MaintanceRecordsManagement" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link href="../css/jquery.datetimepicker.css" rel="stylesheet" />
<style type="text/css">
.selectinput {
width: 150px;
margin-right: 10px;
}
.dialog-content table {
border-collapse: collapse;
width: 100%;
}
.dialog-content table td.label {
width: 150px;
text-align: right;
padding-right: 10px;
line-height: 24px;
height: 24px;
vertical-align: top;
}
.dialog-content table td input,
.dialog-content table td textarea {
border: 1px solid #a9a9a9;
width: 200px;
height: 18px;
padding: 1px;
}
.dialog-content table td input[type="checkbox"] {
border: none;
}
.dialog-content table td textarea {
height: 100px;
max-width: 200px;
}
#dialogdatatb td {
padding-top: 5px;
}
.a {
text-decoration: none;
color: #2140fb;
}
</style>
<script src="../js/jquery.datetimepicker.full.js"></script>
<script src="<%=GetFileUrlWithVersion("js/inputdatactr.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../js/editableselect.js")%>" type="text/javascript"></script>
<script type="text/javascript">
var recorddata;
var assetid = "<%=AssetID %>";
$(function () {
setPageTitle(GetTextByKey("P_MAINTENANCERECORDSMANAGEMENT", "Maintenance Records Management"), true);
InitGridData();
GetTypesData();
GetRecordes();
$('#dialog_mdate').click(function () { $('#dateformatspan').css('display', 'none'); }).blur(function () {
if ($.trim($(this).val()) == "") {
$('#dateformatspan').css('display', '');
}
else {
$('#dateformatspan').css('display', 'none');
}
})
$('#startdatetxt').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]);
}
});
$('#enddatetxt').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_mdate').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]);
}
})
InputControl($('#dialog_hours'));
$('#dialog_hours').change(function () { if (!inputValueFormat(this)) { $(this).val(''); } })
$('#searchinputtxt').keydown(enterKeydown);
$('#typeselectinput').change(function () { GetRecordes(); });
if (!canExport) {
$('#spExport').hide();
}
$(window).resize(function () {
$("#recordlist").css("height", $(window).height() - $("#recordlist").offset().top - 4);
grid_dt && grid_dt.resize();
}).resize();
});
function enterKeydown(e) {
if (e.keyCode == 13) {
GetRecordes();
}
}
function GetTypesData() {
$.ajax(
{
type: "POST",
async: false,
datatype: "json",
url: "MaintanceRecordsManagement.aspx",
data: {
MethodName: "GetTypesData"
},
success: function (data) {
$('#typeselectinput').empty();
$("<option></option>").val("").text(GetTextByKey("P_SELECT_ALL", "All")).appendTo($("#typeselectinput"));
if (data != "" && data != "[]") {
var datattype = JSON.parse(data);
for (var i = 0; i < datattype.length; i++) {
$("<option></option>").val(datattype[i].Key).text(datattype[i].Value).appendTo($("#typeselectinput"));
}
}
},
error: function (msg) {
showAlert(msg.statusText, GetTextByKey("P_MRM_ERROR", 'Error'));
}
}
)
}
function GetRecordes() {
showloading(true);
$.ajax(
{
type: "POST",
async: false,
datatype: "json",
url: "MaintanceRecordsManagement.aspx",
data: {
assetid: assetid,
maintenanceType: "Hours",
type: $('#typeselectinput').find("option:selected").val(),
searchtxt: encodeURIComponent($.trim($('#searchinputtxt').val())),
sortype: encodeURIComponent($.trim($('#maintance_type').val())),
sortdata: encodeURIComponent($.trim($('#maintance_sort').val())),
startdate: encodeURIComponent($.trim($('#startdatetxt').val())),
enddate: encodeURIComponent($.trim($('#enddatetxt').val())),
MethodName: "GetRecords"
},
success: function (datastr) {
if (datastr != "") {
recorddata = eval("(" + datastr + ")");
showRecordList(recorddata);
}
showloading(false);
},
error: function (msg) {
showAlert(msg.statusText, GetTextByKey("P_MRM_ERROR", 'Error'));
showloading(false);
}
}
)
}
function showRecordList(data) {
var rows = [];
for (var i = 0; i < data.length; i++) {
var r = data[i];
var distype = r.LogType;
if (r.LogType == "TimeOffRoad")
distype = 'Time/Off-Road';
else if (r.LogType == "TimeOverRoad")
distype = 'Time/Over Road';
for (var j in r) {
if (j === "LogType") {
r[j] = { DisplayValue: distype, Value: r[j] };
}
else if (j === "MaintenanceDate") {
r[j] = { DisplayValue: r["StrForMaintenanceDate"], Value: r[j] };
}
else if (j === "AlertTime") {
r[j] = { DisplayValue: r["StrForAlertTime"], Value: r[j] };
}
else if (j === "AlertID") {
r[j] = r[j] <= 0 ? "" : r[j];
}
}
var fr = { Values: r };
rows.push(fr);
}
grid_dt.setData(rows);
}
var grid_dt;
function InitGridData() {
grid_dt = new GridView('#recordlist');
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: 'MachineID', caption: GetTextByKey("P_MRM_ASSETID", "Asset ID"), valueIndex: 'MachineID', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'MachinePin', caption: GetTextByKey("P_MRM_SN", "SN"), valueIndex: 'MachinePin', css: { 'width': 200, 'text-align': 'left' } },
{ name: 'DisplayName', caption: GetTextByKey("P_MRM_NAME", "Name"), valueIndex: 'DisplayName', css: { 'width': 200, 'text-align': 'left' } },
{ name: 'MaintenanceDate', caption: GetTextByKey("P_MRM_MAINTENANCEDATE", "Maintenance Date"), valueIndex: 'MaintenanceDate', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'LogType', caption: GetTextByKey("P_MRM_MAINTENANCETYPE", "Maintenance Type"), valueIndex: 'LogType', allowFilter: true, css: { 'width': 130, 'text-align': 'left' } },
{ name: 'MaintenanceHours', caption: GetTextByKey("P_MRM_MAINTENANCEHOURS", "Maintenance Hours"), valueIndex: 'MaintenanceHours', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'ODOMeter', caption: GetTextByKey("P_MRM_MAINTENANCEDISTANCE", "Maintenance Distance"), valueIndex: 'ODOMeter', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'ODOMemterUOM', caption: GetTextByKey("P_MRM_DISTANCEUOM", "Distance UOM"), valueIndex: 'ODOMemterUOM', allowFilter: true, css: { 'width': 120, 'text-align': 'left' } },
{ name: 'Cost', caption: GetTextByKey("P_MRM_COST", "Cost"), valueIndex: 'Cost', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'InvoiceNumber', caption: GetTextByKey("P_MRM_INVOICENUMBER", "Invoice Number"), valueIndex: 'InvoiceNumber', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'CompletedByName', caption: GetTextByKey("P_MRM_COMPLETEDBY", "Completed By"), valueIndex: 'CompletedByName', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
{ name: 'Notes', caption: GetTextByKey("P_MRM_DESCRIPTION", "Description"), valueIndex: 'Notes', css: { 'width': 200, 'text-align': 'left' } },
{ name: 'MachineMake', caption: GetTextByKey("P_MRM_MAKE", "Make"), valueIndex: 'MachineMake', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
{ name: 'MachineModel', caption: GetTextByKey("P_MRM_MODEL", "Model"), valueIndex: 'MachineModel', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
{ name: 'MachineType', caption: GetTextByKey("P_MRM_ASSETTYPE", "Type"), valueIndex: 'MachineType', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
{ name: 'AlertID', caption: GetTextByKey("P_MRM_ALERTID", "Alert ID"), valueIndex: 'AlertID', css: { 'width': 80, 'text-align': 'left' } },
{ name: 'AlertTitle', caption: GetTextByKey("P_MRM_ALERTTITLE", "Alert Title"), valueIndex: 'AlertTitle', css: { 'width': 200, 'text-align': 'left' } },
{ name: 'AlertType', caption: GetTextByKey("P_MRM_ALERTTYPE", "Alert Type"), valueIndex: 'AlertType', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
{ name: 'AlertTime', caption: GetTextByKey("P_MRM_ALERTTIME", "Alert Time"), valueIndex: 'AlertTime', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'Attachment', caption: "", css: { 'width': 30, 'text-align': 'center' } },
{ 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;
if (col.name === "Attachment") {
//col.isurl = true;
col.text = "\uf0c6";
col.classFilter = function (e) {
return "icon-col";
}
col.styleFilter = function (item) {
return {
display: item.HasAttachment ? '' : 'none',
cursor: "default"
};
}
col.attrs = { 'title': GetTextByKey("P_MRM_ATTACHMENT", 'Attachment') };
}
else if (col.name === "Edit") {
col.isurl = true;
col.text = "\uf044";
col.events = {
onclick: function () {
OnEdit();
}
};
col.classFilter = function (e) {
return "icon-col";
}
col.attrs = { 'title': GetTextByKey("P_MRM_EDIT", 'Edit') };
}
else if (col.name === "Delete") {
col.isurl = true;
col.text = "\uf00d";
col.events = {
onclick: function () {
OnDelete(this);
}
};
col.classFilter = function (e) {
return "icon-col";
};
col.attrs = { 'title': GetTextByKey("P_MRM_DELETE", 'Delete') };
}
columns.push(col);
}
grid_dt.canMultiSelect = false;
grid_dt.columns = columns;
grid_dt.init();
grid_dt.rowdblclick = OnEdit;
grid_dt.selectedrowchanged = function (rowindex) {
var rowdata = grid_dt.source[rowindex];
if (rowdata) {
}
}
}
//执行iframe中函数
var doIFrameFunc = function (v_mymethod, v_params, v_frmName) {
if (document.getElementById(v_frmName)) {
var fn = document.getElementById(v_frmName).contentWindow[v_mymethod];
if (fn) {
if (v_params == null)
return fn();
else {
return fn.apply(this, v_params);
}
}
return null;
}
}
function CloseDialog(type) {
$('#dialog_maintenancerecord').hideDialog();
if (type == 1) {
GetRecordes();
}
else {
showmaskbg(false);
}
}
function OnAdd() {
if (assetid && assetid !== "")
window.location.href = "MachineMaintenanceInfo.aspx?InDialog=" +<%=InDialog?"1": "0"%>+"&mid=" + assetid;
else
window.location.href = "MachineMaintenanceInfo.aspx";
}
function DoubleClick(e) {
OnEdit();
}
function OnEdit() {
var record = grid_dt.source[grid_dt.selectedIndex].Values;
doIFrameFunc("init", [record.MachineID, record.MaintenanceID], "iframemaintenancerecord");
showmaskbg(true);
$('#dialog_maintenancerecord')
.attr('act', 'edit')
.showDialogRight();
}
function OnDelete(record) {
if (!record) {
return;
}
showConfirm(GetTextByKey("P_MRM_DELETETHERECORD", "Would you like to delete the record?"), GetTextByKey("P_MRM_SYSTEMINFORMATION", "System Information"), function () {
$.ajax({
type: "POST",
async: false,
dataType: "json",
url: "MaintanceRecordsManagement.aspx",
data: {
maintenanceid: record.MaintenanceID,
MethodName: "Deletemaintenance"
},
success: function (msg) {
GetRecordes();
showAlert(msg, GetTextByKey("P_MRM_SYSTEMINFORMATION", "System Information"));
},
error: function (msg) {
showAlert(msg.statusText, GetTextByKey("P_MRM_ERROR", 'Error'));
}
})
}, function () { return false; });
}
function changeasset(aid) {//mapview调用
assetid = aid;
GetRecordes();
}
function OnExit() {
window.parent.CloseWorkOrderDialog();
}
function OnExport() {
var maintenancetype = "Hours";
var type = $('#typeselectinput').find("option:selected").val();
var searchtxt = encodeURIComponent($.trim($('#searchinputtxt').val()));
var sortype = encodeURIComponent($.trim($('#maintance_type').val()));
var sortdata = encodeURIComponent($.trim($('#maintance_sort').val()));
var startdate = encodeURIComponent($.trim($('#startdatetxt').val()));
var enddate = encodeURIComponent($.trim($('#enddatetxt').val()));
var p = [assetid, maintenancetype, type, searchtxt, sortype, sortdata, startdate, enddate];
var param = htmlencode(JSON.stringify(p));
window.open("../ExportToFile.aspx?type=maintenancerecords&param=" + param);
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div id="recordcontent" style="padding: 0px; margin: 0px;">
<div class="page_title" data-lgid="P_MAINTENANCERECORDSMANAGEMENT">Maintenance Records Management</div>
<div class="search_bar" style="<%=InDialog?"display:none;": ""%>">
<input type="password" autocomplete="new-password" style="display: none" />
<span style="padding-left: 5px;" data-lgid="P_FR_BEGINDATE_COLON">Begin Date:&nbsp;</span>
<span>
<input id="startdatetxt" style="width: 100px;" value="<%=BeginDate %>" autocomplete="off" /></span>
<span style="padding-left: 5px;" data-lgid="P_FR_ENDDATE_COLON">End Date:&nbsp;</span>
<span>
<input id="enddatetxt" style="width: 100px;" value="<%=EndDate %>" autocomplete="off" /></span>
<span style="padding-left: 5px;" data-lgid="P_MRM_TYPE_COLON">Type:</span>&nbsp;&nbsp;<select class="selectinput" id="typeselectinput"></select>
<input id="searchinputtxt" autocomplete="off" />
<input class="search" type="button" onclick="GetRecordes();" value="Search" data-lgid="P_MRM_SEARCH" />
</div>
<div class="function_title">
<span class="sbutton iconadd" onclick="OnAdd();" data-lgid="P_MRM_ADD">Add</span>
<span class="sbutton iconrefresh" onclick="GetRecordes();" data-lgid="P_MRM_REFRESH">Refresh</span>
<span id="spExport" class="sbutton iconexport" onclick="OnExport();" data-lgid="P_UTILITY_EXPORTTOEXCEL">Export to Excel</span>
<span class="sbutton iconexit" onclick="OnExit();" style="<%=InDialog?"": "display:none;"%>" data-lgid="P_MRM_EXIT">Exit</span>
</div>
<div class="clear"></div>
<div id="recordlist"></div>
</div>
<div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div>
<div class="dialog" id="dialog_maintenancerecord" style="display: none; height: 100%; border-bottom: 0; border-top: 0;">
<iframe id="iframemaintenancerecord" src="AddMaintenanceRecord.aspx" style="width: 100%; height: 100%; display: block; border: none;"></iframe>
<div class="maskbg" style="display: none;"></div>
</div>
</asp:Content>

View File

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Maintenance;
public partial class Maintenance_MaintanceRecordsManagement : MaintanceRecordsBasePage
{
public string BeginDate = "";
public string EndDate = "";
public string AssetID = "";
public bool InDialog = false;
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
bool license = SystemParams.HasLicense("PreventativeMaintenance");
bool mrlicense = SystemParams.HasLicense("MaintenanceRecord");
if (!license || !mrlicense)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.PREVENTATIVE_MAINTENANCE);
if (!permission)
RedirectToLoginPage();
AssetID = Request.Params["mid"] ?? "";
InDialog = Request.Params["InDialog"] == "1";
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
BeginDate = userlocaldate.AddDays(-6).ToShortDateString();
EndDate = userlocaldate.ToShortDateString();
}
}
}
}

View File

@ -0,0 +1,189 @@
<%@ Page Title="" Language="C#" MasterPageFile="../IronIntelMasterPage.master" AutoEventWireup="true" CodeFile="Maintenance.aspx.cs" Inherits="Maintenance_Maintenance" %>
<asp:Content ID="Content1" ContentPlaceHolderID="holder_head" runat="Server">
<link href="<%=GetFileUrlWithVersion("../css/split.css")%>" rel="stylesheet" type="text/css" />
<script src="<%=GetFileUrlWithVersion("../js/split.js")%>"></script>
<script type="text/javascript">
$(function () {
setFavoriteDisplay(true);
_network.query = function (method, param, callback, error) {
_network.request("Maintenance/Maintenance.aspx", -1, method, param, callback, error);
}
var surveysubitems = [];
_network.query('GetNavs', '', function (data) {
if (data != null && data.length > 0) {
var list = [];
for (var i = 0; i < data.length; i++) {
var icon = null;
if (data[i].ID == "nav_customerrecord" || data[i].ID == "nav_workorder") {
var src = data[i].IconPath;
if (!src) {
src = 'img/none.png';
}
icon = $('<img style="width: 20px; height: 20px;"/>').attr("src", src);
}
else
icon = $('<button></button>');
var title = getNavInfoByID(data[i].ID, data[i].Title, icon);
var li = $('<li class="nav_item"></li>').attr({
'id': data[i].ID,
'page': data[i].Url,
'title': title
});
var a = $('<a></a>')
if (data[i].ID !== 'nav_customersatisfactionsurveys')
a.attr('href', '#' + data[i].ID);
else {
a.click(function (ev) {
if ($('#set_left').prop('isexpanded'))
return;
if ($('.panel_holder.subitems').is(':visible')) {
return;
}
createSubMenus(surveysubitems);
var left = $(this).offset().left;
var top = $(ev.target).offset().top - 80;
$('.panel_holder.subitems').css({
'opacity': 0,
'left': 60,
'right': 'auto',
'top': top
}).show().animate({ 'opacity': 1 }, 100);
$('.panel_holder.subitems .trigle').css({
'left': -10,// left - $('.panel_holder.favorites').offset().left,
'right': 'auto',
'top': 3
});
return false;
});
}
var divicon = $('<div></div>').append(icon);
a.append(divicon);
var span_title = $('<span></span>').text(title);
if (data[i].ID === 'nav_surveymanagementresult' || data[i].ID === 'nav_wosurveytemplate' || data[i].ID === 'nav_wosurveytemplatereport') {
span_title.css('padding-left', 12);
li.addClass('subitem');
surveysubitems.push(data[i]);
}
a.append(span_title);
li.append(a);
list.push(li);
}
$('.ul_menu').append(list);
}
if (data.length > 0) {
default_page = '#' + data[0].ID;
if (!old_hash) {
old_hash = default_page;
}
window.changePage(old_hash);
} else {
// 无权限时跳转至登录页面
window.location.href = '<%=LoginPageUrl%>';
}
if ($('#set_left').prop('isexpanded'))
$('#set_left').find(".subitem").show();
else
$('#set_left').find(".subitem").hide();
}, function (e) {
console.log(e);
});
function createSubMenus(items) {
var maintenancesubmenu = $("#maintenancesubmenu").empty();
var ulsubmenus = $('<ul class="lefttitlemenu_ul" style="line-height:32px;"></ul>');
maintenancesubmenu.append(ulsubmenus);
for (var i = 0; i < items.length; i++) {
var item = items[i];
if (!item) continue;
var li = $('<li></li>');
var a = $('<a></a>').append($("<span></span>").text(item.Title));
a.attr('href', '#' + item.ID);
li.append(a);
ulsubmenus.append(li);
}
}
window.changePage(old_hash);
});
function getNavInfoByID(id, title1, icon) {
var title = title1;
if (id === "nav_alertsmanagement") {
title = GetTextByKey("P_ALERTSMANAGEMENTNEW", title);
$(icon).addClass("iconmanagealerts");
}
else if (id === "nav_workorder") {
title = GetTextByKey("P_WORKORDERNEW", title);
$(icon).addClass("iconworkorder");
}
else if (id === "nav_workorderhis") {
title = GetTextByKey("P_WORKORDERHISTORY", title);
$(icon).addClass("iconhistory");
}
else if (id === "nav_record") {
title = GetTextByKey("P_MAINTENANCERECORDLEGACY", title);
$(icon).addClass("iconrecord");
}
else if (id === "nav_fuelrecord") {
title = GetTextByKey("P_FUELRECORDS", title);
$(icon).addClass("iconfuelrecord");
}
else if (id === "nav_maintenanceschedule") {
title = GetTextByKey("P_PM_MAINTENANCESCHEDULES", title);
$(icon).addClass("iconmaintenanceschedule");
}
else if (id === "nav_customerrecord") {
title = GetTextByKey("P_CUSTOMERRECORD", title);
//$(icon).addClass("iconmaintenanceschedule");
}
else if (id === "nav_customersatisfactionsurveys") {
title = GetTextByKey("P_CUSTOMERSATISFACTIONSURVEYS", title);
$(icon).addClass("icontemplate");
}
else if (id === "nav_surveymanagementresult") {
title = GetTextByKey("P_WOS_SURVEYMANAGEMENTRESULT", title);
}
else if (id === "nav_wosurveytemplate") {
title = GetTextByKey("P_WOS_TEMPLATES", title);
}
else if (id === "nav_wosurveytemplatereport") {
title = GetTextByKey("P_WOS_TEMPLATES_REPORT", title);
}
return title;
}
function afterpagechanged(hash, name) {
setFavorateStyle(hash, name);
};
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="holder_content" runat="Server">
<div id="set_left">
<ul class="ul_menu">
<li id="nav_arrow">
<div class="icn collapse"></div>
</li>
</ul>
<div class="hostmask maskbg" style="display: none;"></div>
</div>
<div id="set_right">
<div class="loading_holder">
<div class="loading_icon icn icn-spin"></div>
</div>
</div>
<div class="panel_holder subitems">
<div id="maintenancesubmenu" class="menupanel panel">
</div>
<div class="trigle" style="left: -12px; right: auto;"></div>
<div class="trigle white" style="left: -12px; right: auto;"></div>
</div>
</asp:Content>

View File

@ -0,0 +1,33 @@
using Foresight.Fleet.Services.User;
using Foresight.Security.License;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Maintenance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Maintenance_Maintenance : MaintenanceBasePage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
this.Title = PageTitle;
}
}
}
}

View File

@ -0,0 +1,121 @@
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MaintenanceBase.master.cs" Inherits="Maintenance_MaintenanceBase" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title></title>
<link type="text/css" href="<%=GetUrl("js/components/css/gridview.css") %>" rel="stylesheet" />
<link type="text/css" href="<%=GetUrl("js/lib/ui.min.css") %>" rel="stylesheet" />
<link type="text/css" href="<%=GetUrl("css/override.css") %>" rel="stylesheet" />
<link rel="stylesheet" href="<%=GetUrl("css/default.css")%>" type="text/css" />
<link rel="stylesheet" href="<%=GetUrl("css/split_sub.css")%>" type="text/css" />
<link rel="stylesheet" href="<%=GetUrl("css/editmultiselect.css")%>" type="text/css" />
<link rel="stylesheet" href="<%=GetUrl("js/lib/app.min.css") %>" type="text/css" />
<style type="text/css">
:root { <%=StyleVariables%> }
#search {
background-color: rgb(235, 235, 235);
border: none;
padding-top: 5px;
padding-bottom: 5px;
cursor: pointer;
}
#search:hover {
background: rgb(225, 225, 225);
}
</style>
<script src="<%=GetUrl("js/lib/utility.min.js")%>" type="text/javascript"></script>
<script src="<%=GetUrl("js/lib/ui.min.js")%>" type="text/javascript"></script>
<script src="<%=GetUrl("js/lib/app.min.js")%>" type="text/javascript"></script>
<script src="<%=GetUrl("js/jquery-3.6.0.min.js")%>" type="text/javascript"></script>
<script src="<%=GetUrl("js/cookie.js")%>" type="text/javascript"></script>
<script src="<%=GetUrl("js/utility.js")%>" type="text/javascript"></script>
<script src="<%=GetUrl("js/editmultiselect.js")%>" type="text/javascript"></script>
<script type="text/javascript" src="<%=GetUrl("js/components/gridview.js") %>"></script>
<script type="text/javascript" src="<%=GetUrl("js/language.js") %>"></script>
<script type="text/javascript">
var canExport = <%= CanExportFile %>;
var GridView = window.GridView || window['g5-gridview'];
_network.root = '<%=Page.ResolveUrl("~/")%>';
consts = {
path: _network.root
};
function getText(s, flag) {
return (s == null)
? (flag ? '<i>null</i>' : '')
: htmlencode(s, $('#div_text_holder')).replace(/ /g, '&nbsp;');
}
function GetLanguageByCookie() {
var lang = getCookie('<%=Common.LanguageCookieName%>');
if (lang == null) {
return "en-us";
} else {
return lang;
}
}
function systemrequest(method, param, callback, error) {
_network.request("SystemSettings/SystemOptions.aspx", -1, method, param, callback, error || function (e) {
console.log(e);
showmaskbg(false, true);
showAlert(GetTextByKey('P_WO_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_WO_QUERY', 'Query'));
});
}
var systemunitofodometer;
function GetSystemUnitOfOdometer() {
systemrequest("GetSystemUnitOfOdometer", "", function (data) {
systemunitofodometer = data;
}, function (err) {
});
}
$(function () {
_fleet.currentLang = GetLanguageByCookie();
GetSystemUnitOfOdometer();
$("#content1").applyFleetLanguageText(true);
// 加载完毕后通知上级页面
if (typeof window.parent.onsubpageloaded == 'function') {
window.parent.onsubpageloaded();
}
if (typeof window.parent.ondocumentclick == 'function') {
$(document.body).click(window.parent.ondocumentclick);
}
function resizeContent() {
if ($('.content_main').length > 0)
$('.content_main').css('min-height', $(window).height() - $('.content_main').offset().top - 4);
if ($('#listDiv').length > 0)
$('#listDiv').css('min-height', $(window).height() - $('#listDiv').offset().top - 4);
$('#mask_bg').height($(document).outerHeight(false)).width($(document).outerWidth(false));
}
$(window).resize(function () {
resizeContent();
});
//window.onresize = resizeContent;
resizeContent();
$(document.body).click(function (e) {
if (typeof hidePanels === 'function')
hidePanels();
});
});
</script>
<asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder>
</head>
<body>
<div id="content1">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<div id="div_text_holder"></div>
</body>
</html>

View File

@ -0,0 +1,36 @@
using FI.FIC;
using Foresight.Fleet.Services.Styles;
using IronIntel.Contractor;
using IronIntel.Contractor.iisitebase;
using IronIntel.Contractor.Site;
using IronIntel.Contractor.Users;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Maintenance_MaintenanceBase : CommonBase
{
protected override bool ExportModule
{
get { return true; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
GetUIStyle();
}
catch
{
// TODO: errors when get the ui style.
}
}
}
}

View File

@ -0,0 +1,407 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="MaintenanceSchedulesManagement.aspx.cs" Inherits="MaintenanceSchedulesManagement" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link href="<%=GetFileUrlWithVersion("css/maintenance.css")%>" rel="stylesheet" type="text/css" />
<style type="text/css">
/*body { overflow-x: hidden; }*/
.maintenance {
table-layout: fixed;
border-bottom: none;
width: auto;
min-width: 100%;
}
#pm_tbody {
}
#pm_tbody .tr_noresults {
font-style: italic;
}
#pm_tbody .tr_noresults:hover {
background: none;
}
.maintenance tr {
border-bottom: 1px solid #e6e6e6;
}
.main_table .td_intervals {
padding: 0 0 0 60px;
}
.main_table .tr_intervals {
border-bottom: none;
}
.main_table .tr_intervals:hover {
background: none;
}
.icon {
float: left;
font-style: normal;
width: 20px;
font-size: 11px;
height: 16px;
line-height: 16px;
}
.expand:before {
content: '\e608';
}
.collapse:before {
content: '\e607';
}
.dialog_table {
width: 100%;
}
.dialog_table tr {
height: 40px;
}
</style>
<script src="<%=GetFileUrlWithVersion("js/controls.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("js/schedule.js")%>" type="text/javascript"></script>
<script type="text/javascript">
var interval_label = 'Hours';
var currentdate = "<%=CurrentDate %>";
function pmquery(method, param, callback, error) {
_network.request("Maintenance/MaintenanceSchedulesManagement.aspx", -1, method, param, callback, error || function (e) {
console.log(e);
showmaskbg(false, true);
showAlert('An unknown error occurred. Please refresh page.', 'Query');
showAlert(GetTextByKey('P_PM_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_PM_QUERY', 'Query'));
});
}
function getIntervalLabel(type, unit) {
switch (type) {
case "TBM": return "Days"; break;
case "ADM":
case "RDM":
if (unit === "Kilometre")
return "Kilometres"
else
return "Miles";
break;
default: return "Hours"; break;
}
}
function OnAdd() {
window.location.href = 'ScheduleDetail.aspx?TP=ADM';
}
function OnDialogOK() {
var title = GetTextByKey('P_PM_ADDABSOLUTEHOURSINTERVAL', 'Add Absolute Hours Interval');
var pmsid = $('#dialog_interval').attr('data-id')
var name = $('#dig_name').val();
var interval = parseInt($('#dig_interval').val());
var period = parseInt($('#dig_period').val());
var recurring = $('#dig_recurring').prop('checked');
var priority = $('#dig_priority').val();
var description = $('#dig_servicedec').val();
var expectedcost = $('#dig_expectedcost').val();
var item = {
'PmScheduleID': pmsid,
'Intervals': [{
'ServiceName': name,
'Interval': interval,
'NotificationPeriod': period,
'Recurring': recurring,
'Priority': priority,
'ServiceDescription': description,
'ExpectedCost': expectedcost
}]
};
if (!_sc.checkIntervalItem(item.Intervals[0])) {
return;
}
pmquery('AddPmInterval', htmlencode(JSON.stringify(item)), function (data) {
if (!data || data.length == 0) {
$('#dialog_interval').hideDialog();
$('#refresh_button').click();
} else {
showAlert(data, title);
}
});
}
var firstload = true;
function refreshData() {
var p = [
$('#sel_plantype').val(),
$('#sel_plan').val(),
htmlencode($.trim($('#searchinputtxt').val()))
];
var param = JSON.stringify(p);
showloading(true);
pmquery('GetMaintenanceSchedules', param, function (data) {
showloading(false);
if (firstload == true) {
setPlans(data)
firstload = false;
}
if (data && data.length > 0) {
var trs = [];
for (var i = 0; i < data.length; i++) {
createItem(trs, data[i]);
}
$('#pm_tbody').empty().append(trs);
} else {
$('#pm_tbody').empty().append('<tr class="tr_noresults"><td colspan="5">' + GetTextByKey("P_PM_NORESULTS", "No results.") + '</td></tr>');
}
}, function () {
showloading(false);
});
}
function createItem(trs, item) {
var tr = $('<tr></tr>').attr('data-id', item.PmScheduleID);
var td = $('<td></td>').css('width', 340);
td.append($('<em class="icon collapse"></em>').click(collapse));
td.append($('<div class="item_name"></div>').html(getText(item.PmScheduleName)).attr('title', item.PmScheduleName));
tr.append(td);
td = $('<td></td>');
td.append($('<div class="item_desc"></div>').html(getText(item.Notes)).attr('title', item.Notes));
tr.append(td);
td = $('<td></td>');
td.append($('<div class="item_type"></div>').html(getText(item.PmScheduleTypeStr)).attr('title', item.PmScheduleTypeStr));
tr.append(td);
td = $('<td class="td_funcs"></td>').css({ 'width': 70, 'min-width': 70 });
td.append($('<a onclick="return false;">' + GetTextByKey("P_PM_DELETE", "Delete") + '</a>').click(deleteItem));
tr.append(td);
td = $('<td class="td_funcs"></td>').css({ 'width': 120, 'min-width': 120 });
td.append($('<a onclick="return false;">' + GetTextByKey("P_PM_MANAGESCHEDULE", "Manage schedule") + '</a>').click(editItem));
tr.append(td);
td = $('<td class="td_funcs"></td>').css({ 'width': 120, 'min-width': 120 });
var a = $('<a onclick="return false;">' + GetTextByKey("P_PM_MANAGEASSETS", "Manage assets") + '</a>');
if (item.Intervals && item.Intervals.length > 0) {
a.click(editItemMachine);
} else {
a.addClass('disabled');
}
td.append(a);
tr.append(td);
trs.push(tr);
tr = $('<tr class="tr_intervals" style="display:none;"></tr>');
td = $('<td colspan="6" class="td_intervals"></td>');
tr.append(td);
var table = $('<table class="table_intervals"></table>');
td.append(table);
trs.push(tr);
tr = $('<tr></tr>');
tr.append('<th style="width: 150px;">' + GetTextByKey("P_PM_SERVICENAME", "Service Name") + '</th>');
tr.append('<th style="width: 150px;">' + GetTextByKey("P_PM_INTERVAL", "Interval") + '</th>');
tr.append('<th style="width: 180px;">' + GetTextByKey("P_PM_NOTIFICATIONPERIOD", "Notification Period") + '</th>');
tr.append('<th style="width: 80px;">' + GetTextByKey("P_PM_RECURRING", "Recurring") + '</th>');
//tr.append('<th style="width: 80px;">Predictive</th>');
//tr.append('<th style="width: 100px;">Service Type</th>');
tr.append('<th style="width: 200px;">' + GetTextByKey("P_PM_SERVICEDESCRIPTION", "Service Description") + '</th>');
tr.append('<th style="width: 100px;">' + GetTextByKey("P_PM_EXPECTEDCOST", "Expected Cost") + '</th>');
tr.append('<th style="width: 80px;">' + GetTextByKey("P_PM_PRIORITY", "Priority") + '</th>');
tr.append($('<th style="width: 166px; min-width: 166px;" class="td_funcs"></th>')
.append($('<a onclick="return false;">' + GetTextByKey("P_PM_ADD", "Add") + '</a>').click(function () {
var rst = "";
if (item.PmScheduleType == "PM")
rst = GetTextByKey('P_PM_ADDABSOLUTEHOURSINTERVAL', 'Add Absolute Hours Interval');
else if (item.PmScheduleType == "TBM")
rst = GetTextByKey('P_PM_ADDTIMEBASEDNTERVAL', 'Add TimeBased Interval');
else if (item.PmScheduleType == "HM")
rst = GetTextByKey('P_PM_ADDHOURSTERVAL', 'Add Hours Interval');
else if (item.PmScheduleType == "ADM")
rst = GetTextByKey('P_PM_ADDABSOLUTEDISTANCEINTERVAL', 'Add Absolute Distance Interval');
else if (item.PmScheduleType == "RDM")
rst = GetTextByKey('P_PM_ADDDISTANCEINTERVAL', 'Add Distance Interval');
$('#dialog_interval .dialog-title span.title').text(rst);
_sc.addIntervalItem(item.PmScheduleID);
})));
table.append($('<thead></thead>').append(tr));
if (item.Intervals && item.Intervals.length > 0) {
interval_label = getIntervalLabel(item.PmScheduleType, item.PmScheduleUom);
for (var i = 0; i < item.Intervals.length; i++) {
tr = _sc.createIntervalTr(item.Intervals[i]);
table.append(tr);
}
}
}
function deleteItem(e) {
var tr = $(this).parents('tr:first');
var iid = tr.attr('data-id');
showConfirm(GetTextByKey("P_PM_DELETETHISSCHEDULE", 'Do you want to delete this schedule?'), GetTextByKey("P_PM_DELETE", 'Delete'), function (e) {
pmquery('DeletePmSchedule', iid, function (data) {
if (!data || data.length == 0) {
refreshData();
} else {
showAlert(data, GetTextByKey("P_PM_DELETE", 'Delete'));
}
});
});
}
function editItem(e) {
var tr = $(this).parents('tr:first');
var iid = tr.attr('data-id');
window.location.href = 'ScheduleDetail.aspx?IID=' + iid;
}
function editItemMachine(e) {
var tr = $(this).parents('tr:first');
var iid = tr.attr('data-id');
window.location.href = 'ScheduleMachines.aspx?IID=' + iid;
}
function collapse(e) {
if ($(this).hasClass('expand')) {
// 收折
$(this).parents('tr:first').next('tr.tr_intervals').css('display', 'none');
$(this).removeClass('expand').addClass('collapse');
} else {
$(this).parents('tr:first').next('tr.tr_intervals').css('display', '');
$(this).removeClass('collapse').addClass('expand');
}
}
function setPlans(data) {
$('#sel_plan').empty();
var opt = $('<option></option>').val("").text(" ");
$('#sel_plan').append(opt);
if (data && data.length > 0) {
for (var i = 0; i < data.length; i++) {
opt = $('<option></option>').val(data[i].PmScheduleID).text(data[i].PmScheduleName);
$('#sel_plan').append(opt);
}
}
}
$(function () {
setPageTitle(GetTextByKey("P_PM_MAINTENANCESCHEDULES", "Maintenance Schedules"), true);
$('#sel_plantype').change(refreshData);
$('#sel_plan').change(refreshData);
$("#expandintervals").click(function (e) {
var btn = $(this);
if (btn.text() == "Expand Intervals") {
btn.removeClass("iconadd");
btn.addClass("iconreduce");
btn.text("Collapse Intervals");
$('#pm_tbody').find(".icon").each(function () {
if ($(this).hasClass("collapse"))
$(this).click();
});
}
else {
btn.removeClass("iconreduce");
btn.addClass("iconadd");
btn.text("Expand Intervals");
$('#pm_tbody').find(".icon").each(function () {
if ($(this).hasClass("expand"))
$(this).click();
});
}
});
$('#refresh_button').click(refreshData);
refreshData();
// dialog
$('#dig_interval').number();
$('#dig_period').number();
$('#dig_priority').number();
$('#dialog_interval').dialog(function () {
showmaskbg(false);
});
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div style="min-width: 850px;">
<div class="page_title" data-lgid="P_PM_MAINTENANCESCHEDULES">Maintenance Schedules</div>
<div class="search_bar">
<input type="password" autocomplete="new-password" style="display: none" />
<span style="padding-left: 5px;" data-lgid="P_PM_PLAN_COLON">Plan:</span>&nbsp;&nbsp;<select class="selectinput" id="sel_plan"></select>
<span style="padding-left: 5px;" data-lgid="P_PM_PLANTYPE_COLON">Plan Type:</span>&nbsp;&nbsp;
<select class="selectinput" id="sel_plantype">
<option value=""></option>
<option value="ADM">Absolute Distance</option>
<option value="PM">Absolute Hours</option>
<option value="RDM">Relative Distance</option>
<option value="HM">Relative Hours</option>
<option value="TBM">Relative Time</option>
</select>
<span style="padding-left: 5px;" data-lgid="P_PM_ASSET_COLON">Asset:</span>&nbsp;&nbsp;
<input id="searchinputtxt" type="text" autocomplete="off" />
<input class="search" type="button" onclick="refreshData();" value="Search" data-lgid="P_MRM_SEARCH" style="margin-left: 5px;" />
</div>
<div class="function_title">
<span class="sbutton iconadd" onclick="OnAdd();" data-lgid="P_PM_ADD">Add</span>
<span class="sbutton iconrefresh" id="refresh_button" data-lgid="P_PM_REFRESH">Refresh</span>
<span class="sbutton iconadd" id="expandintervals" data-lgid="P_PM_EXPANDINTERVALS">Expand Intervals</span>
</div>
<div class="clear"></div>
<div class="content_main content_div">
<table class="main_table maintenance">
<tbody id="pm_tbody"></tbody>
</table>
</div>
<div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div>
</div>
<div class="dialog" id="dialog_interval" style="display: none; z-index: 500;">
<div class="dialog-title"><span class="title" data-lgid="P_PM_ADDABSOLUTEHOURSINTERVAL">Add Absolute Hours Interval</span><em class="dialog-close"></em></div>
<div class="dialog-content">
<table class="dialog_table">
<tr>
<td class="label" data-lgid="P_PM_SERVICENAME_COLON">Service Name:</td>
<td>
<input type="text" class="inputbox intervalinput" id="dig_name" tabindex="1" maxlength="50" /></td>
</tr>
<tr>
<td class="label" data-lgid="P_PM_INTERVAL_COLON">Interval:<b class="red">*</b></td>
<td>
<input type="text" class="inputbox intervalinput" id="dig_interval" tabindex="2" maxlength="10" /></td>
</tr>
<tr>
<td class="label" data-lgid="P_PM_NOTIFICATIONPERIOD_COLON">Notification Period:<b class="red">*</b></td>
<td>
<input type="text" class="inputbox intervalinput" id="dig_period" tabindex="3" maxlength="10" /></td>
</tr>
<tr>
<td class="label" data-lgid="P_PM_RECURRING_COLON">Recurring:</td>
<td>
<input type="checkbox" id="dig_recurring" tabindex="4" /></td>
</tr>
<tr>
<td class="label" data-lgid="P_PM_SERVICEDESCRIPTION_COLON">Service Description:<b class="red">*</b></td>
<td>
<textarea id="dig_servicedec" class="servicedescription" maxlength="3000" tabindex="5"></textarea></td>
</tr>
<tr>
<td class="label" data-lgid="P_PM_EXPECTEDCOST_COLON">Expected Cost:<b class="red">*</b></td>
<td>
<input type="text" class="inputbox intervalinput inp_expectedcost" id="dig_expectedcost" tabindex="5" maxlength="12" /></td>
</tr>
<tr>
<td class="label" data-lgid="P_PM_PRIORITY_COLON">Priority:<b class="red">*</b></td>
<td>
<input type="text" class="inputbox intervalinput inp_priority" id="dig_priority" tabindex="6" maxlength="5" /></td>
</tr>
</table>
</div>
<div class="dialog-func">
<input type="button" value="Cancel" data-lgid="P_PM_CANCEL" class="dialog-close" tabindex="7" />
<input type="button" onclick="OnDialogOK();" value="OK" data-lgid="P_PM_OK" tabindex="6" />
<div class="clear"></div>
</div>
<div class="maskbg" style="display: none;"></div>
</div>
</asp:Content>

View File

@ -0,0 +1,42 @@
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Maintenance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class MaintenanceSchedulesManagement : PreventativeMaintenanceBasePage
{
public string CurrentDate = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
// TODO: sub page
//RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
bool license = SystemParams.HasLicense("PreventativeMaintenance");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.PREVENTATIVE_MAINTENANCE);
if (!permission)
RedirectToLoginPage();
}
}
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
CurrentDate = userlocaldate.ToShortDateString();
}
}

View File

@ -0,0 +1,460 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="ScheduleDetail.aspx.cs" Inherits="Maintenance_ScheduleDetail" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link href="<%=GetFileUrlWithVersion("css/maintenance.css")%>" rel="stylesheet" type="text/css" />
<style type="text/css">
body {
min-width: 730px;
}
.return {
float: left;
width: 50px;
font-style: normal;
text-align: center;
cursor: pointer;
}
.return:before {
content: '\e631';
}
#sc_name {
width: 400px;
}
#sc_notes {
width: 400px;
height: 100px;
}
#th_intervals {
padding: 0;
}
.table_intervals tbody tr {
background: #fff;
}
.table_intervals tr:last-child {
border-bottom: none;
}
.table_intervals td {
font-weight: normal;
}
.dialog_table {
width: 100%;
}
.dialog_table tr {
height: 40px;
}
.maintenance th {
vertical-align: top;
}
.maintenance tr {
background: #fff;
}
.maintenance .td_funcs {
vertical-align: middle;
}
.table_intervals th input {
padding: 1px;
}
</style>
<script src="<%=GetFileUrlWithVersion("js/controls.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("js/schedule.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../js/editableselect.js")%>"></script>
<script type="text/javascript">
var iid = '<%=IID%>';
var scheduleUom = '<%=PmScheduleUom%>';
var scheduletype = '<%=ScheduleType%>';
var interval_label = getIntervalLabel();
var currentdate = "<%=CurrentDate %>";
function getIntervalLabel() {
switch (scheduletype) {
case "TBM": return "Days"; break;
case "ADM":
case "RDM":
if (scheduleUom === "Kilometre")
return "Kilometres"
else
return "Miles";
break;
default: return "Hours"; break;
}
}
function pmquery(method, param, callback, error) {
_network.request("Maintenance/ScheduleDetail.aspx", -1, method, param, callback, error || function (e) {
console.log(e);
showAlert(GetTextByKey("P_PM_FAILEDTOLOADDATA", 'Failed to load data: ') + e.statusText, GetTextByKey("P_PM_SCHEDULEDETAIL", 'Schedule Detail'));
});
}
function OnSave(exit) {
var name = $('#sc_name').val();
var scheduleUom = null;
if (scheduletype == "ADM" || scheduletype == "RDM") {
scheduleUom = $('#sc_intervaluom').val();
}
var notes = $('#sc_notes').val();
if (name.trim().length == 0) {
showAlert(GetTextByKey("P_PM_SCHEDULENAMECANNOTBEEMPTY", 'Schedule Name cannot be empty.'), GetTextByKey("P_PM_SAVE", 'Save'), undefined, function () {
$('#sc_name').focus();
});
return;
}
var schedule = {
'IID': iid,
'Name': name,
'Type': $('#sc_plantype').val(),
'Notes': notes,
'ScheduleUom': scheduleUom,
'Intervals': []
};
// 组织intervals
var trs = $('#tbody_intervals').children('tr');
for (var i = 0; i < trs.length; i++) {
var tr = $(trs[i]);
var item = {
'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);
schedule.Intervals.push(item);
}
pmquery('SavePmSchedule', htmlencode(JSON.stringify(schedule)), function (data) {
if (/[a-zA-Z\d]{8}-[a-zA-Z\d]{4}-[a-zA-Z\d]{4}-[a-zA-Z\d]{4}-[a-zA-Z\d]{12}/.test(data)) {
if (exit == 0) {
showAlert(GetTextByKey("P_PM_SAVSUCCESSFULLY", 'Saved successfully.'), GetTextByKey("P_PM_SAVE", 'Save'));
window.location.href = 'ScheduleDetail.aspx?IID=' + data;
}
if (exit == 1)
OnExit();
} else {
showAlert(GetTextByKey("P_PM_FAILEDTOSAVESCHEDULE", 'Failed to save schedule: ') + data, GetTextByKey("P_PM_SAVE", 'Save'));
}
});
}
function OnExit() {
window.location.href = 'MaintenanceSchedulesManagement.aspx';
}
function OnRefresh() {
window.location.href = window.location.href;
}
function OnDialogOK() {
var pmsid = $('#dialog_interval').attr('data-id')
var name = $('#dig_name').val();
var interval = parseInt($('#dig_interval').val());
var period = parseInt($('#dig_period').val());
var recurring = $('#dig_recurring').prop('checked');
var priority = $('#dig_priority').val();
var expectedcost = $('#dig_expectedcost').val();
var description = $('#dig_servicedec').val();
var unit = $('#sc_intervaluom').val();
var item = {
'PmScheduleID': pmsid,
'Intervals': [{
'ServiceName': name,
'Interval': interval,
'NotificationPeriod': period,
'Recurring': recurring,
'Priority': priority,
'ExpectedCost': expectedcost,
'ServiceDescription': description
}]
};
if (!_sc.checkIntervalItem(item.Intervals[0])) {
return;
}
function next() {
$('#th_intervals .table_intervals tbody').append(_sc.createIntervalTr(item.Intervals[0], true));
showmaskbg(false);
$('#dialog_interval').hideDialog();
}
next();
}
var editableSelectSchedule;
$(function () {
if (iid) {
$('#sc_plantype').val(scheduletype);
$('#sc_plantype').attr('disabled', true);
}
else {
$('#sc_plantype').val('');
$('#sc_plantype').attr('disabled', false);
}
if (scheduletype == "ADM" || scheduletype == "RDM") {
$('#trScheduleUom').show();
$('#sc_intervaluom').val(scheduleUom);
}
else {
$('#trScheduleUom').hide();
$('#sc_intervaluom').val('');
}
$("#sc_intervaluom").change(function (e) {
scheduleUom = $('#sc_intervaluom').val();
interval_label = getIntervalLabel();
$('.span_uom').text(interval_label);
});
$("#sc_plantype").change(function (e) {
scheduletype = $('#sc_plantype').val();
interval_label = getIntervalLabel();
$('.span_uom').text(interval_label);
if (scheduletype == "ADM" || scheduletype == "RDM")
$('#trScheduleUom').show();
else
$('#trScheduleUom').hide();
getSchedules();
});
showmaskbg(true, true);
// load intervals
pmquery('GETPMINTERVALBYSCHEDULEID', iid, function (data) {
$('#th_intervals').append(loadIntervals(data));
editableSelectSchedule = new $editableselect($("#dialog_schedule"));
getSchedules();
});
$('#dig_interval').number();
$('#dig_period').number();
$('#dig_priority').number();
$('#dialog_interval').dialog(function () {
showmaskbg(false);
});
showmaskbg(false);
function resizeContent() {
$('.content_main').css('min-height', $(window).height() - $('.content_main').offset().top - 24);
}
window.onresize = resizeContent;
resizeContent();
});
function loadIntervals(data) {
var table = $('<table class="table_intervals"></table>');
tr = $('<tr></tr>');
tr.append('<th style="width: 150px;">' + GetTextByKey("P_PM_SERVICENAME", "Service Name") + '</th>');
tr.append('<th style="width: 150px;">' + GetTextByKey("P_PM_INTERVAL", "Interval") + '</th>');
tr.append('<th style="width: 180px;">' + GetTextByKey("P_PM_NOTIFICATIONPERIOD", "Notification Period") + '</th>');
tr.append('<th style="width: 80px;">' + GetTextByKey("P_PM_RECURRING", "Recurring") + '</th>');
//tr.append('<th style="width: 80px;">Predictive</th>');
//tr.append('<th style="width: 100px;">Service Type</th>');
tr.append('<th style="width: 200px;">' + GetTextByKey("P_PM_SERVICEDESCRIPTION", "Service Description") + '</th>');
tr.append('<th style="width: 100px;">' + GetTextByKey("P_PM_EXPECTEDCOST", "Expected Cost") + '</th>');
tr.append('<th style="width: 80px;">' + GetTextByKey("P_PM_PRIORITY", "Priority") + '</th>');
tr.append($('<th style="width: 350px;" class="td_funcs"></th>')
.append($('<a onclick="return false;">' + GetTextByKey("P_PM_ADD", "Add") + '</a>').click(iid, _sc.addIntervalItem))
.append($('<div id="dialog_schedule" style="width: 150px; height: 22px;margin-left: 20px;float:left;"></div>'))
.append($('<a onclick="return false;" style="margin-left: 5px;">' + GetTextByKey("P_PM_COPYSCHEDULE", "Copy Schedule") + '</a>').click(function () {
onCopySchedule();
})
)
);
table.append($('<thead></thead>').append(tr));
var body = $('<tbody id="tbody_intervals"></tbody>');
if (data && data.length > 0) {
for (var i = 0; i < data.length; i++) {
data[i].ServiceName = htmldecode(data[i].ServiceName);
body.append(_sc.createIntervalTr(data[i], true));
}
}
table.append(body);
return table;
}
function getSchedules() {
var p = ['', '', ''];
var param = JSON.stringify(p);
pmquery("GetMaintenanceSchedules", param, function (data) {
if (data && data.length > 0) {
var schedules = [];
var type = $('#sc_plantype').val();
for (var i = 0; i < data.length; i++) {
var s = data[i];
if ((type === "PM" || type === "HM") && (s.PmScheduleType === "PM" || s.PmScheduleType === "HM")) {
schedules.push(s);
}
if (type === "TBM" && s.PmScheduleType === "TBM") {
schedules.push(s);
}
if ((type === "ADM" || type === "RDM") && (s.PmScheduleType === "ADM" || s.PmScheduleType === "RDM")) {
schedules.push(s);
}
}
editableSelectSchedule.datasource = schedules;
editableSelectSchedule.valuepath = "PmScheduleID"
editableSelectSchedule.displaypath = "PmScheduleName";
}
}, function (err) {
});
}
function onCopySchedule() {
var schedule = editableSelectSchedule.selecteditem();
if (schedule && schedule.Intervals && schedule.Intervals.length > 0) {
var tboby = $('#tbody_intervals');
for (var i = 0; i < schedule.Intervals.length; i++) {
var sch = schedule.Intervals[i];
sch.PmIntervalID = "";
var tr = _sc.createIntervalTr(sch, true)
tboby.append(tr);
}
}
}
function back() {
window.location.href = 'MaintenanceSchedulesManagement.aspx';
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div style="min-width: 400px;">
<div class="page_title">
<span class="sbutton iconback" onclick="back();"></span>
<span id="span_title" data-lgid="P_PM_MANAGEMAINTENANCESCHEDULE">Manage Maintenance Schedule</span>
</div>
<div class="function_title">
<span class="sbutton iconsave" onclick="OnSave(0);" data-lgid="P_PM_SAVE">Save</span>
<span class="sbutton iconsave" onclick="OnSave(1);" data-lgid="P_PM_SAVE1">Save and Exit</span>
<span class="sbutton iconexit" onclick="OnExit();" data-lgid="P_PM_SAVE2">Exit Without Saving</span>
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_PM_REFRESH">Refresh</span>
</div>
<div class="clear"></div>
<div class="content_main content_div">
<table class="main_table maintenance">
<thead>
<tr>
<th style="width: 140px;" data-lgid="P_PM_NAME_COLON">Name:</th>
<td>
<input type="text" id="sc_name" value="<%=Schedule == null ? null : Schedule.PmScheduleName %>" maxlength="200" autocomplete="off" /></td>
</tr>
<tr>
<th data-lgid="P_PM_PLANTYPE_COLON">Plan Type:</th>
<td>
<select id="sc_plantype" style="width: 150px;" disabled="disabled">
<option value="ADM">Absolute Distance</option>
<option value="PM">Absolute Hours</option>
<option value="RDM">Relative Distance</option>
<option value="HM">Relative Hours</option>
<option value="TBM">Relative Time</option>
</select></td>
</tr>
<tr id="trScheduleUom" style="display: none;">
<th data-lgid="P_PM_ODOMETERUOM_COLON">Odometer UOM:</th>
<td>
<select id="sc_intervaluom">
<option value="Mile" data-lgid="P_PM_MILE">Mile</option>
<option value="Kilometre" data-lgid="P_PM_KILOMETER">Kilometer</option>
</select></td>
</tr>
<tr>
<th data-lgid="P_PM_DESCRIPTION_COLON">Description:</th>
<td>
<textarea id="sc_notes" maxlength="1000"><%=Schedule == null ? null : Schedule.Notes %></textarea></td>
</tr>
<tr>
<th data-lgid="P_PM_INTERVALS_COLON">Intervals:</th>
<td id="th_intervals"></td>
</tr>
</thead>
</table>
</div>
<div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div>
</div>
<div class="dialog" id="dialog_interval" style="display: none; z-index: 500;">
<div class="dialog-title"><span class="title" data-lgid="P_PM_ADDINTERVAL">Add Interval</span><em class="dialog-close"></em></div>
<div class="dialog-content">
<table class="dialog_table">
<tr>
<td class="label" data-lgid="P_PM_SERVICENAME_COLON">Service Name:</td>
<td>
<input type="text" class="inputbox intervalinput" id="dig_name" tabindex="1" maxlength="50" autocomplete="off" /></td>
</tr>
<tr>
<td class="label" data-lgid="P_PM_INTERVAL_COLON">Interval:<b class="red">*</b></td>
<td>
<input type="text" class="inputbox intervalinput" id="dig_interval" tabindex="2" maxlength="10" autocomplete="off" /></td>
</tr>
<tr>
<td class="label" data-lgid="P_PM_NOTIFICATIONPERIOD_COLON">Notification Period:<b class="red">*</b></td>
<td>
<input type="text" class="inputbox intervalinput" id="dig_period" tabindex="3" maxlength="10" autocomplete="off" /></td>
</tr>
<tr>
<td class="label" data-lgid="P_PM_RECURRING_COLON">Recurring:</td>
<td>
<input type="checkbox" id="dig_recurring" tabindex="5" /></td>
</tr>
<tr>
<td class="label" data-lgid="P_PM_SERVICEDESCRIPTION_COLON">Service Description:<b class="red">*</b></td>
<td>
<textarea id="dig_servicedec" class="servicedescription" maxlength="3000" tabindex="5"></textarea></td>
</tr>
<tr>
<td class="label" data-lgid="P_PM_EXPECTEDCOST_COLON">Expected Cost:<b class="red">*</b></td>
<td>
<input type="text" class="inputbox intervalinput inp_expectedcost" id="dig_expectedcost" tabindex="5" maxlength="12" autocomplete="off" /></td>
</tr>
<tr>
<td class="label" data-lgid="P_PM_PRIORITY_COLON">Priority:<b class="red">*</b></td>
<td>
<input type="text" class="inputbox intervalinput inp_priority" id="dig_priority" tabindex="7" maxlength="5" autocomplete="off" /></td>
</tr>
</table>
</div>
<div class="dialog-func">
<input type="button" value="Cancel" data-lgid="P_PM_CANCEL" class="dialog-close" tabindex="9" />
<input type="button" onclick="OnDialogOK();" value="OK" data-lgid="P_PM_OK" tabindex="8" />
<div class="clear"></div>
</div>
<div class="maskbg" style="display: none;"></div>
</div>
</asp:Content>

View File

@ -0,0 +1,70 @@
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Maintenance;
using IronIntel.Contractor.Site.Maintenance;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Maintenance_ScheduleDetail : PreventativeMaintenanceBasePage
{
protected string IID;
protected string ScheduleType;
protected PmScheduleInfo Schedule;
protected string PmScheduleUom;
public string CurrentDate = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
// TODO: sub page
//RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
bool license = SystemParams.HasLicense("PreventativeMaintenance");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.PREVENTATIVE_MAINTENANCE);
if (!permission)
RedirectToLoginPage();
IID = Request.QueryString["IID"];
ScheduleType = Request.QueryString["TP"];
if (!string.IsNullOrWhiteSpace(IID))
{
Schedule = MaintenanceManagement.GetPMScheduleByID(GetCurrentLoginSession().SessionID, IID);
ScheduleType = Schedule.PmScheduleType;
PmScheduleUom = Schedule.PmScheduleUom;
}
else
{
PmScheduleUom = SystemParams.GetStringParam("UnitOfOdometer");
}
if (string.IsNullOrWhiteSpace(ScheduleType))
{
ScheduleType = "PM";
}
else
{
ScheduleType = ScheduleType.ToUpper();
}
}
}
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
CurrentDate = userlocaldate.ToShortDateString();
}
}

View File

@ -0,0 +1,484 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="ScheduleMachines.aspx.cs" Inherits="Maintenance_ScheduleMachines" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link href="../css/jquery.datetimepicker.css" rel="stylesheet" />
<link href="../css/datepicker.min.css" rel="stylesheet" />
<style type="text/css">
body {
min-width: 995px;
}
.return {
float: left;
width: 50px;
font-style: normal;
text-align: center;
cursor: pointer;
}
.return:before {
content: '\e631';
}
.expand:before {
content: '\e608';
}
.collapse:before {
content: '\e607';
}
.page_title {
margin-left: 10px;
}
.maintenance {
table-layout: fixed;
}
.maintenance em {
font-style: normal;
font-size: 11px;
cursor: pointer;
line-height: 16px;
float: left;
}
.maintenance th {
vertical-align: top;
}
.maintenance tr {
background: #fff;
}
.maintenance .td_funcs {
padding: 0;
font-weight: normal;
vertical-align: middle;
}
.maintenance .td_funcs a {
float: left;
cursor: pointer;
margin-left: 20px;
}
.maintenance .td_funcs a:first-child {
margin-left: 0;
}
#th_intervals {
padding: 0;
}
.table_intervals {
width: 100%;
color: #666;
border-collapse: collapse;
}
.table_intervals thead tr {
background: #f9f9f9;
/*font-weight: bold;*/
}
.table_intervals thead tr:hover {
background: #f9f9f9;
}
.table_intervals tbody tr,
.table_intervals tbody tr:hover {
background: #fff;
}
.table_intervals tr:last-child {
border-bottom: none;
}
.table_intervals td {
font-weight: normal;
overflow: hidden;
text-overflow: ellipsis;
}
.table_intervals td input {
width: 60px;
border: 1px solid #fff;
}
.table_intervals td input.focused,
.table_intervals td input:hover {
border-color: #666;
}
.table_intervals .editing {
display: none;
}
.table_intervals .editing input {
width: auto;
cursor: pointer;
background: rgb(249, 189, 117);
margin-left: 6px;
border: none;
padding: 5px 14px;
}
.table_intervals .editing input:hover {
background: #d7690E;
}
.maintenance .th_machines {
padding: 0;
}
.machine_filter {
height: 32px;
line-height: 32px;
}
.machine_filter select {
height: 23px;
min-width: 100px;
max-width: 300px;
}
.machine_filter span {
margin-left: 8px;
}
#txt_machine_key {
height: 21px;
padding: 0;
margin: 0;
border: 1px solid #aaa;
}
.ybutton {
width: auto;
line-height: normal;
margin-left: 6px;
border: none;
background: rgb(249, 189, 117);
padding: 5px 14px;
cursor: pointer;
}
.ybutton:hover {
background: #d7690E;
}
.machines {
/*table-layout: fixed;*/
word-break: keep-all;
}
.machines td {
padding-right: 5px;
white-space: nowrap;
}
.machines td input {
width: auto;
}
.table_holder {
border-collapse: collapse;
height: 100%;
}
.table_holder thead th {
text-align: left;
}
.table_holder tbody tr {
line-height: 28px;
height: 28px;
}
.table_holder td {
vertical-align: top;
}
.table_holder .td_controller {
vertical-align: middle;
padding: 40px 8px;
border-left: 1px solid #b0b0b0;
border-right: 1px solid #b0b0b0;
}
.table_holder .scroller {
height: 100%;
overflow-y: auto;
}
.ctl_button {
font-family: 'CalciteWebCoreIcons';
display: block;
margin: 6px auto;
width: 60px;
height: 22px;
line-height: 21px;
padding: 0;
}
.right_main {
min-width: 400px;
}
.page_title .sbutton {
font-size: 16px;
font-weight: bold;
}
.page_title .sbutton:before {
color: black;
}
.data-grid .autoHeightBody {
position: static;
max-height: 400px;
}
.data-grid .hidden-x {
overflow-x: hidden;
}
.data-grid .noMax {
/*max-height: none;*/
}
</style>
<script src="<%=GetFileUrlWithVersion("../js/vue.min.js")%>" type="text/javascript"></script>
<script>Vue.config.productionTip = false; Vue.config.silent = true;</script>
<script src="<%=GetFileUrlWithVersion("../js/components/datagrid.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("js/schedule.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("js/scheduleassets.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../js/assetselector.js")%>" type="text/javascript"></script>
<%--<script src="../js/jquery.datetimepicker.full.js"></script>--%>
<script src="../js/datepicker.min.js"></script>
<script type="text/javascript">
var iid = '<%=IID%>';
var scheduleUom = '<%=PmScheduleUom%>';
var scheduletype = '<%=ScheduleType%>';
var interval_label = getIntervalLabel();
var currentdate = "<%=CurrentDate %>";
var _ScheduleAssets = [];
var _showSelectedMachines = [];
var _SelectedUnSavedMachines = [];
var assignedassetCtrl;
var allintervals = [];
function getIntervalLabel() {
switch (scheduletype) {
case "TBM": return "Days"; break;
case "ADM":
case "RDM":
if (scheduleUom === "Kilometre")
return "Kilometres"
else
return "Miles";
break;
default: return "Hours"; break;
}
}
function pmquery(method, param, callback, error) {
_network.request("Maintenance/ScheduleMachines.aspx", -1, method, param, callback, error || function (e) {
console.log(e);
showAlert(GetTextByKey("P_PM_FAILEDTOLOADDATA", 'Failed to load data: ') + e.statusText, GetTextByKey("P_PM_SCHEDULEASSETS", 'Schedule Assets'));
});
}
function OnExpandCollapse() {
var flag = $(this).hasClass('expand');
$('.collapsable').css('display', flag ? 'none' : '');
if (flag) {
$(this).removeClass('expand').addClass('collapse');
resizeMachines();
} else {
$(this).removeClass('collapse').addClass('expand');
resizeMachines();
}
}
function resizeMachines() {
$('.scroller').css('height', $('.right_main').height() - $('.maintenance').height() - 5);
$('.scroller').css('width', ($('.right_main').width() - $('.td_controller').width()) / 2 - 15);
}
function OnRefresh() {
window.location.href = window.location.href;
}
function setHeaderTitle() {
var title = '<%=Header%>';
if (title === "Manage Time Based Maintenance Assets")
title = GetTextByKey("P_PM_MANAGETIMEBASEDMAINTENANCEASSETS", "Manage Time Based Maintenance Assets");
else if (title === "Manage Hours Maintenance Assets")
title = GetTextByKey("P_PM_MANAGEHOURSMAINTENANCEASSETS", "Manage Hours Maintenance Assets");
else if (title === "Manage Absolute Distance Maintenance Assets")
title = GetTextByKey("P_PM_MANAGEABSOLUTEDISTANCEMAINTENANCEASSETS", "Manage Absolute Distance Maintenance Assets");
else if (title === "Manage Relative Distance Maintenance Assets")
title = GetTextByKey("P_PM_MANAGERELATIVEDISTANCEMAINTENANCEASSETS", "Manage Relative Distance Maintenance Assets");
else if (title === "Manage Absolute Hours Maintenance Assets")
title = GetTextByKey("P_PM_MANAGEABSOLUTEHOURSMAINTENANCEASSETS", "Manage Absolute Hours Maintenance Assets");
$('#span_title').text(title);
}
$(function () {
assignedassetCtrl = new $manageassetsCtrl();
assignedassetCtrl.Init($("#divScheduleAssets"));
selectedassetsctrl = new $manageassetsCtrl();
selectedassetsctrl.Init($("#selectedassets"), true);
if (scheduletype == "ADM" || scheduletype == "RDM") {
$('#trScheduleUom').css('display', '');
}
$('#em_collapse_schedule').click(OnExpandCollapse);
setHeaderTitle();
// load intervals
pmquery('GetPMScheduleByID', iid, function (data) {
if (typeof (data) !== "string") {
allintervals.length = 0;
if (data.AllIntervals) {
for (var i = 0; i < data.AllIntervals.length; i++) {
allintervals.push(data.AllIntervals[i]);
}
}
$('#th_intervals').append(loadIntervals(data.Intervals));
getMachineTypes();
}
});
$('#sel_machine_type').change(getMatchSelectedMachines);
$('#button_machine_filter').click(getMatchSelectedMachines);
$('#chk_showallassignedassets').click(getMatchSelectedMachines);
$('#txt_machine_key').keypress(function (e) {
if (e.keyCode == 13 && !$('#button_machine_filter').prop('disabled')) {
$('#button_machine_filter').click();
}
});
$('#dialog_selectedassets').dialog(function () {
showmaskbg(false);
});
$(window).resize(resizeMachines);
resizeMachines();
function resizeContent() {
$('.content_main').css('min-height', $(window).height() - $('.content_main').offset().top - 1);
$("#divScheduleAssets").css("height", $(window).height() - $("#divScheduleAssets").offset().top - 10);
}
window.onresize = resizeContent;
resizeContent();
});
function loadIntervals(data) {
var table = $('<table class="table_intervals"></table>');
tr = $('<tr></tr>');
tr.append('<th style="width: 150px;">' + GetTextByKey("P_PM_SERVICENAME", "Service Name") + '</th>');
tr.append('<th style="width: 180px;">' + GetTextByKey("P_PM_INTERVAL", "Interval") + '</th>');
tr.append('<th style="width: 180px;">' + GetTextByKey("P_PM_NOTIFICATIONPERIOD", "Notification Period") + '</th>');
tr.append('<th style="width: 80px;">' + GetTextByKey("P_PM_RECURRING", "Recurring") + '</th>');
//tr.append('<th style="width: 80px;">Predictive</th>');
//tr.append('<th style="width: 100px;">Service Type</th>');
tr.append('<th style="width: 200px;">' + GetTextByKey("P_PM_SERVICEDESCRIPTION", "Service Description") + '</th>');
tr.append('<th style="width: 100px;">' + GetTextByKey("P_PM_EXPECTEDCOST", "Expected Cost") + '</th>');
tr.append('<th style="width: 80px;">' + GetTextByKey("P_PM_PRIORITY", "Priority") + '</th>');
table.append($('<thead></thead>').append(tr));
var body = $('<tbody></tbody>');
if (data && data.length > 0) {
for (var i = 0; i < data.length; i++) {
data[i].ServiceName = htmldecode(data[i].ServiceName);
body.append(_sc.createIntervalReadonlyTr(data[i]));
}
}
table.append(body);
return table;
}
function back() {
window.location.href = 'MaintenanceSchedulesManagement.aspx';
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div class="right_main">
<div class="page_title">
<span class="sbutton iconback" onclick="back();"></span>
<span id="span_title"></span>
</div>
<div class="function_title">
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_PM_REFRESH">Refresh</span>
</div>
<div class="clear"></div>
<div class="content_main content_div">
<table class="main_table maintenance">
<thead>
<tr>
<th style="width: 10px;"><em class="icon expand" id="em_collapse_schedule"></em></th>
<th style="width: 140px;" data-lgid="P_PM_NAME_COLON">Name:</th>
<td><%=Schedule == null ? null : HttpUtility.HtmlEncode(Schedule.PmScheduleName) %></td>
</tr>
<tr id="trScheduleUom" style="display: none;">
<th style="width: 10px;"></th>
<th style="width: 140px;" data-lgid="P_PM_ODOMETERUOM_COLON">Odometer UOM:</th>
<td><%=Schedule == null ? null : HttpUtility.HtmlEncode(Schedule.PmScheduleUom) %></td>
</tr>
<tr class="collapsable">
<th></th>
<th data-lgid="P_PM_DESCRIPTION_COLON">Description:</th>
<td><%=Schedule == null ? null : HttpUtility.HtmlEncode(Schedule.Notes).Replace("\n", "<br/>") %></td>
</tr>
<tr class="collapsable">
<th></th>
<th data-lgid="P_PM_INTERVALS_COLON">Intervals:</th>
<td id="th_intervals"></td>
</tr>
<tr>
<td class="th_machines" colspan="3">
<div class="machine_filter">
<span data-lgid="P_PM_ASSETSTYPE_COLON">Assets Type: </span>
<select id="sel_machine_type" style="width: 230px;"></select>
<input type="text" id="txt_machine_key" />
<input type="button" class="ybutton" id="button_machine_filter" value="Filter" data-lgid="P_PM_FILTER" />
<input type="button" class="ybutton" onclick="OnSaveMachines();" value="Save" data-lgid="P_PM_SAVE" />
<input type="button" class="ybutton" onclick="OnAddAssets();" value="Add" data-lgid="P_PM_ADD" />
<input type="button" class="ybutton" onclick="OnRemoveAssets();" value="Remove" data-lgid="P_PM_REMOVE" />
</div>
</td>
</tr>
</thead>
</table>
<div>
<div id="divScheduleAssets" style="min-height: 400px;"></div>
</div>
</div>
</div>
<div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div>
<div class="dialog" id="dialog_selectedassets" style="display: none;">
<div class="dialog-title"><span class="title" data-lgid="P_PM_SETASSETS">Set Assets</span><em class="dialog-close"></em></div>
<div class="dialog-content">
<div id="selectedassets" style="height: 400px; width: 700px;"></div>
</div>
<div class="dialog-func">
<input type="button" value="Cancel" data-lgid="P_PM_CANCEL" class="dialog-close" tabindex="18" />
<input type="button" onclick="OnSetAssetsDialogOK();" value="OK" data-lgid="P_PM_OK" tabindex="17" />
<div class="clear"></div>
</div>
</div>
</asp:Content>

View File

@ -0,0 +1,92 @@
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Maintenance;
using IronIntel.Contractor.Site.Maintenance;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Maintenance_ScheduleMachines : PreventativeMaintenanceBasePage
{
protected string IID;
protected string ScheduleType;
protected string Header;
protected PmScheduleInfo Schedule;
protected string StartingColumn;
protected string PmScheduleUom;
public string CurrentDate = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
// TODO: sub page
//RedirectToLoginPage();
}
else
{
bool license = SystemParams.HasLicense("PreventativeMaintenance");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.PREVENTATIVE_MAINTENANCE);
if (!permission)
RedirectToLoginPage();
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
// todo nothing
IID = Request.QueryString["IID"];
if (string.IsNullOrWhiteSpace(IID))
{
Response.Redirect("MaintenanceSchedulesManagement.aspx", true);
return;
}
Schedule = MaintenanceManagement.GetPMScheduleByID(GetCurrentLoginSession().SessionID, IID);
ScheduleType = Schedule.PmScheduleType;
PmScheduleUom = Schedule.PmScheduleUom;
if (string.IsNullOrWhiteSpace(ScheduleType))
{
ScheduleType = "PM";
}
else
{
ScheduleType = ScheduleType.ToUpper();
}
switch (ScheduleType)
{
case "TBM":
Header = "Manage Time Based Maintenance Assets";
StartingColumn = "<th>Plan Start Date</th>";
break;
case "HM":
Header = "Manage Hours Maintenance Assets";
StartingColumn = "<th>Starting Hours</th>";
break;
case "ADM":
Header = "Manage Absolute Distance Maintenance Assets";
break;
case "RDM":
Header = "Manage Relative Distance Maintenance Assets";
StartingColumn = "<th style='min-width:60px;'>Starting Distance</th>";
break;
default:
Header = "Manage Absolute Hours Maintenance Assets";
break;
}
}
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
CurrentDate = userlocaldate.ToShortDateString();
}
}
}

View File

@ -0,0 +1,502 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="SurveyAutomationManagement.aspx.cs" Inherits="SurveyAutomationManagement" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<style type="text/css">
.label {
min-width: 100px;
font-weight: bold;
padding-right: 10px;
text-align: right;
}
.middlechk {
width: auto;
height: 13px;
margin-top: 0px;
margin-bottom: 1px;
vertical-align: middle;
}
.subtitle {
margin: 20px 40px 5px 0px;
font-size: 16px;
color: gray;
}
.subtitle span {
margin-left: 30px;
}
.subtitle hr {
background-color: #d8d8d8;
border: none;
height: 1px;
}
</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/SurveyAutomationManagement.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.CloseSurveyAutomationDialog(type);
}
function GetTemplateData() {
worequest("GetSurveyTemplateItems", '', function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_FR_ERROR", 'Error'));
return;
}
$('#dialog_template').empty();
for (var i = 0; i < data.length; i++) {
if (data[i].Active)
$("<option></option>").val(data[i].Id).text(data[i].Name).appendTo($("#dialog_template"));
}
GetWorkOrderTypes();
}, function (err) {
})
}
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);
}
var IsPositiveInteger = /^[0-9]\d*$/;
function saveSurveyAutomationSetting() {
var item = {
'TemplateId': $('#dialog_template').val(),
'DaysFromCompletedDate': $('#dialog_completeddatedays').val(),
'DaysSinceLastReceivedSurvey': $('#dialog_receivedsurveydays').val(),
'Resend': $('#dialog_resend').val(),
'ResendAfterDays': $('#dialog_resendafterdays').val(),
'Randomization': $('#dialog_randomization').val(),
'ExcludeWorkOrderTypes': $('#dialog_wotype').dropdownVals()
};
if (!item.TemplateId)
item.TemplateId = -1;
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_XXXX", "Survey Automation");
if (item.DaysFromCompletedDate !== "") {
if (!IsPositiveInteger.test(item.DaysFromCompletedDate)) {
showAlert(GetTextByKey("P_SET_XXX", 'Number of Days from Completed Date format error.'), alerttitle);
return;
}
}
else
item.DaysFromCompletedDate = 0;
if (item.DaysSinceLastReceivedSurvey !== "") {
if (!IsPositiveInteger.test(item.DaysSinceLastReceivedSurvey)) {
showAlert(GetTextByKey("P_SET_XXX", 'Days Since Contact Last Received a Survey format error.'), alerttitle);
return;
}
}
else
item.DaysSinceLastReceivedSurvey = 0;
if (item.ResendAfterDays !== "") {
if (!IsPositiveInteger.test(item.ResendAfterDays)) {
showAlert(GetTextByKey("P_SET_XXX", 'Resend After Number of Days format error.'), alerttitle);
return;
}
}
else
item.ResendAfterDays = 0;
if (item.Randomization !== "") {
if (!IsPositiveInteger.test(item.Randomization)) {
showAlert(GetTextByKey("P_SET_XXX", 'Randomization format error.'), alerttitle);
return;
}
}
else
item.Randomization = 0;
if (eval(startHour + startMin) > eval(endHour + endMin)) {
showAlert(GetTextByKey("P_CM_ENDTIMEMUSTBELATERTHANSTARTTIME", 'End Time must be later than Start Time.'), alerttitle);
return;
}
item.SurveySendTimes = days + ";" + startHour + ":" + startMin + ";" + endHour + ":" + endMin;
var param = JSON.stringify(item);
param = htmlencode(param);
showloading(true);
worequest("SetSurveyAutomationSetting", param, function (data) {
showloading(false);
if (typeof (data) === "string") {
showAlert(data, alerttitle);
} else {
showAlert(GetTextByKey("P_WO_SAVSUCCESSFULLY", "Saved successfully."), alerttitle);
}
}, function (err) {
showloading(false);
showAlert(GetTextByKey("P_XXXX", 'Failed to save Survey Automation.'), alerttitle);
});
}
var surveyautomationdata;
function OnRefresh() {
var alerttitle = GetTextByKey("P_XXXX", "Survey Automation");
showloading(true);
worequest("GetSurveyAutomationSetting", "", function (data) {
showloading(false);
if (typeof (data) === "string") {
showAlert(data, alerttitle);
}
if (data) {
surveyautomationdata = data;
$('#dialog_template').val(data.TemplateId);
$('#dialog_completeddatedays').val(data.DaysFromCompletedDate);
$('#dialog_receivedsurveydays').val(data.DaysSinceLastReceivedSurvey);
$('#dialog_resend').val(data.Resend);
$('#dialog_resendafterdays').val(data.ResendAfterDays);
$('#dialog_randomization').val(data.Randomization);
$('#dialog_wotype').dropdownVals(data.ExcludeWorkOrderTypes);
if (data.SurveySendTimes && data.SurveySendTimes !== "") {
var temps = data.SurveySendTimes.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 {
$('#dialog_template').val('');
$('#dialog_completeddatedays').val('');
$('#dialog_receivedsurveydays').val('');
$('#dialog_resend').val('0');
$('#dialog_resendafterdays').val('');
$('#dialog_randomization').val('');
$('#dialog_randomization').val('');
$('#dialog_wotype').dropdownVal([]);
$(".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);
});
}
function GetWorkOrderTypes() {
worequest('GetAllWorkOrderTypes', '', function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_AM_ERROR", 'Error'));
return;
}
$('#dialog_wotype').dropdownSource(data);
OnRefresh();
});
}
$(function () {
$('#dialog_wotype').dropdown([], {
search: true,
multiselect: true,
valueKey: 'Key',
textKey: 'Value'
});
initTimeControl();
GetTemplateData();
$(document).mousedown(function () {
$('#divtooltip').hide();
});
$('.iconquestion').click(function (e) {
var offset = $(this).offset();
var left = offset.left;
var top = offset.top;
$("#divtooltip").text($(this).next().text()).css('left', left + 35).css('top', top + 6).show();
});
$(window).resize(function () {
}).resize();
});
</script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div style="padding: 0px; margin: 0px;">
<div class="page_title"></div>
<div class="function_title">
<span class="sbutton iconsave" onclick="saveSurveyAutomationSetting();" data-lgid="P_SET_SAVE">Save</span>
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_SET_REFRESH">Refresh</span>
<span class="sbutton iconexit" onclick="OnExit(0);" data-lgid="P_WO_EXIT">Exit</span>
</div>
<div class="clear"></div>
<div class="content_main content_div" style="padding-top: 20px;">
<table style="line-height: 30px;">
<tr>
<td class="label" style="width: 300px;" data-lgid="P_XXXX">Default Template:</td>
<td colspan="4">
<select style="width: 300px; margin-left: 5px;" id="dialog_template"></select>
<span class="sbutton iconquestion" style="padding-right: 0px;"></span>
<span class="span_title" style="color: gray; display: none;" data-lgid="XXXX">Select the survey you would like sent by default</span>
</td>
</tr>
<tr>
<td class="label" data-lgid="P_XXXX">Number of Days from Completed Date:</td>
<td colspan="4">
<input id="dialog_completeddatedays" type="text" style="width: 100px;" maxlength="10" />
<span class="sbutton iconquestion" style="padding-right: 0px;"></span>
<span class="span_title" style="color: gray; display: none;" data-lgid="XXXX">How many days after a work order is closed would you like the survey sent? To send immediately upon close enter 0.</span>
</td>
</tr>
<tr>
<td class="label" data-lgid="P_XXXX">Days Since Contact Last Received a Survey:</td>
<td colspan="4">
<input id="dialog_receivedsurveydays" type="text" style="width: 100px;" maxlength="10" />
<span class="sbutton iconquestion" style="padding-right: 0px;"></span>
<span class="span_title" style="color: gray; display: none;" data-lgid="XXXX">For customers with multiple work orders, limit how many surveys they can receive. Ex:
0: Customer is eligible to receive a survey for every work order closed.
30: Customer would not receive a second survey for at least 30 days regardless of how many work orders have been completed for them.
</span>
</td>
</tr>
<tr>
<td class="label" data-lgid="P_XXXX">Resend?</td>
<td colspan="4">
<select id="dialog_resend" style="width: 104px;">
<option value="0" data-lgid="P_SET_NO">No</option>
<option value="1" data-lgid="P_SET_YES">Yes</option>
</select>
<span class="sbutton iconquestion" style="padding-right: 0px;"></span>
<span class="span_title" style="color: gray; display: none;" data-lgid="XXXX">If a customer has not replied, would you like to automatically resend the survey? Y/N</span>
</td>
</tr>
<tr>
<td class="label" data-lgid="P_XXXX">Resend After Number of Days:</td>
<td colspan="4">
<input id="dialog_resendafterdays" type="text" style="width: 100px;" maxlength="10" />
<span class="sbutton iconquestion" style="padding-right: 0px;"></span>
<span class="span_title" style="color: gray; display: none;" data-lgid="XXXX">If resend is selected, resend after how many days of non-response? Note that this will only be resent 1 time.</span>
</td>
</tr>
<tr>
<td class="label" data-lgid="P_XXXX">Randomization: </td>
<td colspan="4">
<input id="dialog_randomization" type="text" style="width: 100px;" maxlength="10" />
<span class="sbutton iconquestion" style="padding-right: 0px;"></span>
<span class="span_title" style="color: gray; display: none;" data-lgid="XXXX">Send 1 survey for every how many completed work orders? Note that if a work order is selected that has no valid contacts or all contacts are opted out, that work order will not be counted in the randomization. </span>
</td>
</tr>
<tr>
<td class="label" data-lgid="P_XXXX">Exclude Specific Work Order Types:</td>
<td colspan="4">
<div id="dialog_wotype" style="width: 320px; float: left;" class="dropdown"></div>
<div style="float: left; padding-left: 5px;">
<span class="sbutton iconquestion" style="padding-right: 0px;"></span>
<span class="span_title" style="color: gray; display: none;" data-lgid="XXXX">To exclude specific work order types (ie, Internal) select from the dropdown here. Multi-Select is allowed.</span>
</div>
</td>
</tr>
<tr>
<td class="label" data-lgid="P_XXXX">Survey Send Times:</td>
<td colspan="4"></td>
</tr>
<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 id="divtooltip" style="position: absolute; width: 480px; background-color: white;"></div>
</div>
</div>
<div id="mask_bg" style="display: none; z-index: 500">
<div class="loading c-spin"></div>
</div>
</asp:Content>

View File

@ -0,0 +1,68 @@
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Maintenance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class SurveyAutomationManagement : WorkOrderBasePage
{
protected string IID;
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
public bool EmailSubscribe = false;
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
this.Title = PageTitle;
bool license = SystemParams.HasLicense("CustomerRecord");
if (!license)
RedirectToLoginPage();
if (!IsAdmin)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.CUSTOMER_RECORD);
bool permission1 = CheckRight(SystemParams.CompanyID, Feature.WORKORDERSURVEYS);
if (!permission || !permission1)
RedirectToLoginPage();
}
}
}
public bool IsSupperAdmin
{
get
{
var user = GetCurrentUser();
return user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin;
}
}
public bool IsAdmin
{
get
{
var user = GetCurrentUser();
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
return true;
else
return false;
}
}
}

View File

@ -0,0 +1,259 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="SurveyDetail.aspx.cs" Inherits="SurveyDetail" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link href="<%=Common.GenerateUrl("../css/tabcontrol.css") %>" rel="stylesheet" />
<link href="<%=Common.GenerateUrl("../Inspection/css/sections.css") %>" rel="stylesheet" />
<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;
}
.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;
}
.catelog {
color: #444;
height: 30px;
line-height: 30px;
margin-top: 8px;
padding-left: 10px;
padding-right: 10px;
font-size: 20px;
font-style: italic;
}
.page {
line-height: 52px;
margin-top: 8px;
padding-left: 10px;
padding-right: 10px;
font-size: 26px;
font-weight: 700;
color: #333;
}
.question {
min-height: 30px;
line-height: 30px;
padding-left: 30px;
padding-right: 10px;
font-size: 14px;
font-weight: bold;
color: #111;
/*display: flex;*/
}
.answer {
min-height: 30px;
padding-left: 50px;
padding-right: 10px;
}
.maintable {
border-collapse: collapse;
width: 98%;
page-break-inside: avoid;
margin-left: 1%;
line-height: 24px;
table-layout: fixed;
}
.maintable td {
/*border: 1px solid #a9a9a9;*/
padding-left: 3px;
padding-right: 3px;
}
.maintable .mainlabel {
font-weight: bold;
text-align: right;
}
.question-tips {
font-weight: normal;
font-size: .8rem;
margin-left: 8px;
color: gray;
display: inline-block;
}
.noneanswer {
min-height: 30px;
padding-left: 50px;
padding-right: 10px;
font-weight: normal;
font-size: .8rem;
margin-left: 8px;
color: gray;
display: inline-block;
font-style: italic;
}
</style>
<script src="<%=GetFileUrlWithVersion("../js/controls.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../js/vue.min.js")%>" type="text/javascript"></script>
<script>Vue.config.productionTip = false; Vue.config.silent = true;</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 src="<%=GetFileUrlWithVersion("js/surveydetail.js")%>" type="text/javascript"></script>
<script type="text/javascript">
var surveyid = "";
var vm;
var surveydata;
function worequest(method, param, callback, error) {
_network.request("Maintenance/SurveyDetail.aspx", -1, method, param, callback, error || function (e) {
console.log(e);
showmaskbg(false, true);
showAlert(GetTextByKey('P_WOS_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_WOS_QUERY', 'Query'));
});
}
function showcontatcmask(flag) {
if (flag) {
$('#contatcmask').fadeIn(100);
} else {
$('#contatcmask').fadeOut(100);
}
}
function OnExit(type) {
if (window.parent && typeof window.parent.CloseCustomerDialog == 'function')
window.parent.CloseCustomerDialog(type);
else
window.parent.CloseDialog(type);
}
function init(sid) {
surveyid = sid;
if (!surveyid || surveyid === '')
return;
GetWorkOrderSurveyResult();
}
function showLoading() {
$("#dialogmask").show();
}
function hideLoading() {
$("#dialogmask").hide();
}
$(function () {
vm = new Vue({
el: '#divresult',
data: {
result: {
SurveyData: {
Question: {
Questions: {}
}
}
}
},
methods: {
reload: function (data) {
this.result = data;
}
}
});
function resizeContent() {
$('#divcontent').css('height', $(window).height() - $('#divcontent').offset().top - 4);
}
window.onresize = resizeContent;
resizeContent();
});
</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>
<div id="dialogmask" class="maskbg" style="display: none; z-index: 500;">
<div class="loading_icon icon c-spin"></div>
</div>
<div class="function_title">
<span class="sbutton icondelete" onclick="OnExit(0);" style="margin-left: 756px; font-size: 16px;"></span>
</div>
<div class="clear"></div>
<div class="content_main" id="divcontent" style="overflow: auto;">
<div id="divresult" style="margin: 0 auto;">
<h1 style="text-align: center;">{{result.SurveyData.Question.Questions.Name}}</h1>
<div style="text-align: center; margin-bottom: 10px;"><span style="font-weight: bold;" data-lgid="P_WOS_REPLYTIME_COLON">Reply Time: </span> {{result.SubmitTimeStr}}</div>
<table class="maintable">
<tr style="text-align: center;">
<td><span class="mainlabel" data-lgid="P_WOS_WORKORDERNUMBER_COLON">Work Order Number:</span> {{result.SurveyData.Question.WorkOrderNumber}}</td>
</tr>
<tr style="text-align: center;">
<td><span class="mainlabel" data-lgid="P_WOS_ASSET_COLON">Asset:</span> {{result.SurveyData.Question.AssetVIN}}/{{result.SurveyData.Question.AssetMake}}/{{result.SurveyData.Question.AssetModel}}</td>
</tr>
<tr style="text-align: center;">
<td><span class="mainlabel" data-lgid="P_WOS_CONTACT_COLON">Contact:</span> {{result.SurveyData.Question.CustomerName}}/{{result.SurveyData.Question.CustomerPhone}}</td>
</tr>
<tr>
<td style="padding: 0;">
<div id="divtemplate" style="margin-top: 10px;"></div>
</td>
</tr>
</table>
</div>
</div>
</div>
</asp:Content>

View File

@ -0,0 +1,53 @@
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site;
using IronIntel.Contractor.Site.Maintenance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class SurveyDetail : WorkOrderBasePage
{
protected string IID;
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
public bool EmailSubscribe = false;
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
this.Title = PageTitle;
bool license = SystemParams.HasLicense("CustomerRecord");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.CUSTOMER_RECORD);
if (!permission)
RedirectToLoginPage();
}
}
}
public bool IsSupperAdmin
{
get
{
var user = GetCurrentUser();
return user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin;
}
}
}

View File

@ -0,0 +1,937 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="SurveyManagement.aspx.cs" Inherits="SurveyManagement" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<style type="text/css">
.no_wrap th {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.max160 {
max-width: 160px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.dialog-content table {
border-collapse: collapse;
width: 100%;
line-height: 32px;
}
.dialog-content table td.label {
width: 130px;
text-align: right;
padding-right: 10px;
line-height: 24px;
height: 24px;
vertical-align: top;
}
.dialog-content table td input,
.dialog-content table td textarea {
border: 1px solid #a9a9a9;
width: 250px;
height: 18px;
padding: 1px;
}
#dialog_machines .dialog-content table td input {
width: auto;
}
.dialog-content table td textarea {
margin-top: 6px;
}
.dialog-content table td select {
width: 254px;
height: 24px;
}
.dialog-content table td input[type="checkbox"] {
border: none;
}
.dialog-content table td textarea {
height: 150px;
width: 420px;
max-width: 500px;
}
.ctl_button {
font-family: 'CalciteWebCoreIcons';
display: block;
margin: 6px auto;
width: 60px;
height: 22px;
line-height: 21px;
padding: 0;
}
#dialog_machinegroup {
z-index: 500;
width: 870px;
top: 60px;
left: 150px;
}
.inputbox {
width: 500px;
padding: 1px;
}
.group_table .main_table {
table-layout: fixed;
}
.group_table .main_table thead tr {
display: block;
}
.group_table .main_table tbody {
height: 280px;
display: block;
overflow-y: auto;
}
.group_table .main_table th {
width: 165px;
}
.group_table .main_table td {
width: 165px;
white-space: nowrap;
word-break: keep-all;
}
.group_table .main_table td div {
width: 165px;
overflow: hidden;
white-space: nowrap;
word-break: keep-all;
text-overflow: ellipsis;
}
.td_controller {
vertical-align: middle;
padding: 40px 8px;
/*border-left: 1px solid #b0b0b0;
border-right: 1px solid #b0b0b0;*/
}
.ctl_button {
font-family: 'CalciteWebCoreIcons';
display: block;
margin: 6px auto;
width: 60px;
height: 22px;
line-height: 21px;
padding: 0;
}
.machine_maskbg {
top: 0;
left: 0;
width: 100%;
height: 100%;
position: absolute;
background: #000;
opacity: 0.2;
}
.div_filter .dropdown {
width: 100px;
}
</style>
<link href="../css/jquery.datetimepicker.css" rel="stylesheet" />
<script src="../js/jquery.datetimepicker.full.js"></script>
<script src="<%=GetFileUrlWithVersion("js/controls.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../fic/js/utility.js")%>" type="text/javascript"></script>
<script type="text/javascript">
var IsDealer = <%=IsDealer ?"true":"false"%>;
woquery = function (method, param, callback, error) {
_network.request("Maintenance/SurveyManagement.aspx", -1, method, param, callback, error);
}
function OnRefresh() {
showloading(true);
var type = $('#typeselectinput').find("option:selected").val();
var startdate = htmlencode($('#startdatetxt').val());
var enddate = htmlencode($('#enddatetxt').val());
var wostartdate = htmlencode($('#wostartdatetxt').val());
var woenddate = htmlencode($('#woenddatetxt').val());
var searchtxt = "";
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
var locations = [];
if (locationparam)
locations = locationparam.selectedvalue;
var advisors = [];
if (advisorparam)
advisors = advisorparam.selectedvalue;
var template = $('#templateselectinput').find("option:selected").val();
var param = JSON.stringify([type, startdate, enddate, searchtxt, JSON.stringify(locations), JSON.stringify(advisors), template, wostartdate, woenddate]);
param = htmlencode(param);
if (drilldownparams == null) {
woquery('GetWorkOrderSurveys', param, function (data) {
showloading(false);
if (typeof (data) === "string") {
showAlert(data, GetTextByKey('P_WOS_SURVEYMANAGEMENTRESULT', "Survey Management/Result"));
return;
}
showSurveyList(data);
}, function (err) {
showloading(false);
});
}
else {
woquery('GetWorkOrderSurveysByIDs', htmlencode(drilldownparams), function (data) {
drilldownparams = null;
if (typeof (data) === "string") {
showAlert(data, GetTextByKey('P_WOS_SURVEYMANAGEMENTRESULT', "Survey Management/Result"));
showmaskbg(false);
return;
}
showSurveyList(data);
showmaskbg(false);
}, function (err) {
drilldownparams = null;
showmaskbg(false);
});
}
}
function showSurveyList(data) {
var rows = [];
for (var i = 0; i < data.length; i++) {
var r = data[i];
var statusstr = "";
if (r.Status === 0)
statusstr = GetTextByKey('P_WOS_WAITINGCUSTOMERREPLY', 'Waiting Customer Reply');
else if (r.Status === 1)
statusstr = GetTextByKey('P_WOS_REPLIED', 'Replied');
else if (r.Status === 2)
statusstr = GetTextByKey('P_WOS_XXX', 'No Sent');
else if (r.Status === 3)
statusstr = GetTextByKey('P_WOS_XXX', 'Do Not Send');
for (var j in r) {
if (j === "SentTime") {
r[j] = { DisplayValue: r["SentTimeStr"], Value: r[j] };
}
else if (j === "SubmitTime") {
r[j] = { DisplayValue: r["SubmitTimeStr"], Value: r[j] };
}
else if (j === "Status") {
r[j] = { DisplayValue: statusstr, Value: r[j] };
}
}
var fr = { Values: r };
rows.push(fr);
}
grid_dt.setData(rows);
}
var grid_dt;
function InitGridData() {
grid_dt = new GridView('#surveylist');
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: 'Selected', caption: "", valueIndex: 'Selected', type: 3, css: { 'width': 30, 'text-align': 'center' } },
{ name: 'WorkOrderNumber', caption: GetTextByKey("P_WO_WORKORDERNUMBER", "Work Order Number"), valueIndex: 'WorkOrderNumber', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
{ name: 'SurveyName', caption: GetTextByKey("P_WOS_SURVEYNAME", "Survey Name"), valueIndex: 'SurveyName', css: { 'width': 150, 'text-align': 'left' } },
{ name: 'Status', caption: GetTextByKey("P_WO_STATUS", "Status"), valueIndex: 'Status', allowFilter: true, css: { 'width': 160, 'text-align': 'left' } },
{ name: 'SentTime', caption: GetTextByKey("P_WOS_SENTDATE", "Sent Date"), valueIndex: 'SentTime', css: { 'width': 130, 'text-align': 'left' } },
{ name: 'SubmitTime', caption: GetTextByKey("P_WOS_REPLYDATE", "Reply Date"), valueIndex: 'SubmitTime', css: { 'width': 130, 'text-align': 'left' } },
{ name: 'CustomerName', caption: GetTextByKey("P_WOS_CUSTOMERNAME", "Customer Name"), valueIndex: 'CustomerName', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
{ name: 'ContactName', caption: GetTextByKey("P_WOS_CONTACTNAME", "Contact Name"), valueIndex: 'ContactName', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
{ name: 'ContactNumber', caption: GetTextByKey("P_WOS_CONTACTNUMBER", "Contact Number"), valueIndex: 'ContactNumber', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
//{ name: 'AssetVIN', caption: GetTextByKey("P_WO_VIN", "VIN"), valueIndex: 'AssetVIN', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
{ name: 'LocationName', caption: GetTextByKey("P_WO_LOCATION", "Location"), valueIndex: 'LocationName', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
{ name: 'AdvisorName', caption: GetTextByKey("P_WO_ADVISOR", "Advisor"), valueIndex: 'AdvisorName', allowFilter: true, css: { 'width': 150, 'text-align': 'left' } },
{ name: 'AssetMake', caption: GetTextByKey("P_WO_MAKE", "Make"), valueIndex: 'AssetMake', allowFilter: true, css: { 'width': 120, 'text-align': 'left' } },
{ name: 'AssetModel', caption: GetTextByKey("P_WO_MODEL", "Model"), valueIndex: 'AssetModel', allowFilter: true, css: { 'width': 120, 'text-align': 'left' } },
{ name: 'DoNotSend', caption: GetTextByKey("P_JS_XXX", "Do Not Send"), valueIndex: 'DoNotSend', type: 3, css: { 'width': 90, 'text-align': 'center' } },
//{ name: 'AssetType', caption: GetTextByKey("P_WO_ASSETTYPE", "Asset Type"), valueIndex: 'AssetType', allowFilter: true, css: { 'width': 120, 'text-align': 'left' } },
{ name: 'Detail', caption: "", css: { 'width': 30, 'text-align': 'center' } },
{ name: 'DownloadPDF', caption: "", css: { 'width': 30, 'text-align': 'center' } },
{ name: 'Print', caption: "", css: { 'width': 30, 'text-align': 'center' } },
{ name: 'Surveys', caption: "", alwaysshow: true, 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 === "Selected") {
col.allcheck = true;
col.events = {
onchange: function (item) {
item.Selected = this.Selected;
}
};
col.styleFilter = function (item) {
return {
display: (item.Status.Value == 2 && item.Contacts.length > 0) ? '' : 'none'
};
}
}
if (col.name === "DoNotSend") {
col.events = {
onchange: function () {
var item = this;
SetDoNotSendSurvey(item.WorkOrderId, item.DoNotSend);
}
};
col.styleFilter = function (item) {
return {
display: (item.Status.Value == 2 || item.DoNotSend) ? '' : 'none'
};
}
}
if (col.name === "Surveys") {
col.sortable = false;
col.isurl = true;
col.text = "\uf15c";
col.events = {
onclick: function () {
onSendWOSurveys(this);
}
};
col.classFilter = function (e) {
return "icon-col";
};
col.styleFilter = function (item) {
return {
display: (item.Status.Value == 2 && item.Contacts.length > 0) ? '' : 'none'
};
};
col.attrs = { 'title': GetTextByKey("P_XXXXX", 'Send Survey') };
}
if (col.name === "WorkOrderNumber" || col.name === "SurveyName") {
col.isurl = true;
//col.sortable = false;
col.events = {
onclick: function () {
openSurveyDetail();
}
};
col.styleFilter = function () {
return {
'color': 'black',
'cursor': 'pointer',
//'text-decoration': 'none'
};
}
}
else if (col.name === "Detail") {
col.isurl = true;
col.text = "\uf0c9";
col.sortable = false;
col.events = {
onclick: function () {
openSurveyDetail();
}
};
col.classFilter = function (e) {
return "icon-col";
}
col.styleFilter = function (e) {
if (e.Status.Value != 1)
return { "display": "none" };
};
col.attrs = { 'title': GetTextByKey("P_IPT_DETAIL", 'Detail') };
}
else if (col.name === "DownloadPDF") {
col.isurl = true;
col.text = "\uf019";
col.sortable = false;
col.events = {
onclick: function () {
window.open("SurveyManagement.aspx?rt=f&t=1&id=" + this.Id, '_blank');
}
};
col.classFilter = function (e) {
return "icon-col";
}
col.styleFilter = function (e) {
if (!canExport) {
return { "display": "none" };
}
if (e.Status.Value != 1)
return { "display": "none" };
};
col.attrs = { 'title': GetTextByKey("P_IPT_DOWNLOADPDF", 'Download PDF') };
}
else if (col.name === "Print") {
col.isurl = true;
col.text = "\uf02f";
col.sortable = false;
col.events = {
onclick: function () {
if (navigator.userAgent.indexOf('Firefox') >= 0 ||
navigator.userAgent.indexOf('Opera') >= 0) {
window.open("SurveyManagement.aspx?rt=f&t=2&id=" + this.Id, '_blank');
}
else
OnPrint(this.Id);
}
};
col.classFilter = function (e) {
return "icon-col";
}
col.styleFilter = function (e) {
if (!canExport) {
return { "display": "none" };
}
if (e.Status.Value != 1)
return { "display": "none" };
};
col.attrs = { 'title': GetTextByKey("P_IPT_PRINT", 'Print') };
}
if (col.name === "NotSend") {
col.events = {
onchange: function () {
var item = this;
var msg = "";
if (item.Completed)
msg = GetTextByKey("P_JS_DOYOUWANTTOMARKCOMPLETE", "Do you want to mark complete?");
else
msg = GetTextByKey("P_JS_DOYOUWANTTOUNMARKCOMPLETION", "Do you want to unmark completion?");
showConfirm(msg, GetTextByKey("P_JS_MARKCOMPLATE", 'Mark Complete'), function () {
}, function () {
item.NotSend = !item.NotSend;
grid_dt.reload();
showmaskbg(false);
});
}
};
}
columns.push(col);
}
grid_dt.canMultiSelect = false;
grid_dt.columns = columns;
grid_dt.init();
grid_dt.rowdblclick = openSurveyDetail;
grid_dt.selectedrowchanged = function (rowindex) {
var rowdata = grid_dt.source[rowindex];
if (rowdata) {
}
}
}
function CloseDialog(type) {
$('#dialog_survey').hideDialog();
showmaskbg(false);
}
var surveyid;
function openSurveyDetail() {
var index = grid_dt.selectedIndex;
if (index < 0) {
showAlert(GetTextByKey("P_WOS_PLEASESELECTSURVEY", "Please select survey."), GetTextByKey("P_WORKORDERSURVEYTEMPLATES", "Work Order Survey Templates")); return;
}
var survey = grid_dt.source[index].Values;
if (!survey) {
surveyid = undefined;
return;
}
if (survey.Status.Value !== 1)
return;
surveyid = survey.Id;
execIframeFunc("init", [surveyid], "iframesurveydetail");
showmaskbg(true);
$('#dialog_survey')
.attr('act', 'edit')
.showDialogRight2();
}
var locationparam;
var advisorparam;
var location_editmultiselect;
var advisor_editmultiselect;
function GetFilterDataSource() {
$('#div_locations').empty();
$('#div_departments').empty();
$('#div_advisors').empty();
woquery('GetFilterDataSource', '', function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_AM_ERROR", 'Error'));
return;
}
for (var i = 0; i < data.Locations.length; i++) {
var loc = data.Locations[i];
loc.sublevel = loc.PId > 0 ? 1 : 0;
}
locationparam = {
items: data.Locations,
selectedvalue: locationparam ? locationparam.selectedvalue : [],
width: 120,
valuepath: "ID",
textpath: "Name"
};
location_editmultiselect = editmultiselect(locationparam);
$('#div_locations').append(location_editmultiselect);
advisorparam = {
items: JSON.parse(JSON.stringify(data.Advisors)),
selectedvalue: advisorparam ? advisorparam.selectedvalue : [],
width: 120
};
advisor_editmultiselect = editmultiselect(advisorparam);
$('#div_advisors').append(advisor_editmultiselect);
}, function () {
});
}
function GetTemplateData() {
woquery("GetSurveyTemplateItems", '', function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_FR_ERROR", 'Error'));
return;
}
$('#templateselectinput').empty();
$("<option></option>").val("-1").text(GetTextByKey("P_SELECT_ALL", "All")).appendTo($("#templateselectinput"));
for (var i = 0; i < data.length; i++) {
$("<option></option>").val(data[i].Id).text(data[i].Name).appendTo($("#templateselectinput"));
}
if (selecttemplate)
$('#templateselectinput').val(selecttemplate);
OnRefresh();
}, function (err) {
})
}
var drilldownparams = null;
function getParams() {
var p = getCookie("WOSurveyReportParams");
if (!p) return;
setCookie("WOSurveyReportParams", "", -1);
p = JSON.parse(htmldecode(decodeURIComponent(p)));
//$('#templateselectinput').val(p[0]);
selecttemplate = p[0];
$('#startdatetxt').val(p[1]);
$('#enddatetxt').val(p[2]);
$('#wostartdatetxt').val('');
$('#woenddatetxt').val('');
if (!locationparam) locationparam = {};
locationparam.selectedvalue = JSON.parse(p[3]);
if (!advisorparam) advisorparam = {};
advisorparam.selectedvalue = JSON.parse(p[4]);
if (p[5] != null) {
drilldownparams = p[5];
}
}
var selecttemplate = null;
$(function () {
setPageTitle(GetTextByKey("P_WOS_SURVEYMANAGEMENTRESULT", "Survey Management/Result"), true);
InitGridData();
getParams();
GetFilterDataSource();
GetTemplateData();
$('#startdatetxt').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]);
}
});
$('#enddatetxt').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]);
}
});
$('#wostartdatetxt').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]);
}
});
$('#woenddatetxt').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_sendwosurveys').dialog(function () {
showmaskbg(false);
});
$('#templateselectinput').change(function () { OnRefresh(); });
$('#searchinputtxt').keydown(searchEnter);
$(window).resize(function () {
$("#surveylist").css("height", $(window).height() - $("#surveylist").offset().top - 4);
grid_dt && grid_dt.resize();
}).resize();
});
function searchEnter(e) {
if (e.keyCode == 13 || e.keyCode == 9) {
OnRefresh();
}
}
function OnExport() {
var searchtxt = "";
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
window.open("../ExportToFile.aspx?type=custrecord&t=" + searchtxt);
}
function OnPrint(rid) {
$("#ifdiv").attr('src', "SurveyManagement.aspx?rt=f&t=2&id=" + rid);
if (!$("#ifdiv").data('inited')) {
$("#ifdiv").on('load', function () {
onifload();
}).show();
$("#ifdiv").data('inited', 1);
}
//window.open("Inspection.aspx?rt=f&t=2&id=" + reportid, '_blank');
}
function onifload() {
var iframe = document.getElementById('ifdiv');
iframe.contentWindow.focus();
iframe.contentWindow.print();
}
var surveytemplatedata;
function GetSurveyTemplateItems() {
$('#dialog_wosurveytemplates').empty();
woquery('GetSurveyTemplateItems', '', function (data) {
$('#dialog_wosurveytemplates').empty();
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
return;
}
surveytemplatedata = data;
if (data && data.length > 0) {
for (var i = 0; i < data.length; i++) {
if (data[i].Active) {
var op = $("<option></option>").val(data[i].Id).text(data[i].Name);
$('#dialog_wosurveytemplates').append(op);
}
}
}
});
}
var _selectedwoids = [];
function onSendWOSurveys(wo) {
_selectedwoids = [];
$('#tr_wocontact').hide();
if (!wo) {
var woids = [];
var wos = [];
for (var i = 0; i < grid_dt.source.length; i++) {
var gwo = grid_dt.source[i].Values;
if (gwo.Selected && gwo.Status.Value == 2 && gwo.Contacts.length > 0) {
woids.push(gwo.WorkOrderId);
wos.push(gwo);
}
}
if (woids.length == 0)
return;
_selectedwoids = woids;
if (wos.length == 1)
wo = wos[0];
}
if (wo) {
$('#tr_wocontact').show();
if (wo.Contacts && wo.Contacts.length > 0) {
var tb = $('<table style="width:98%;"></table>');
for (var i = 0; i < wo.Contacts.length; i++) {
var contact = wo.Contacts[i];
var mp = $.trim(contact.MobilePhone);
var email = $.trim(contact.Email);
if ((contact.ContactPreference == "0" && !checkPhoneNumber(mp))
|| (contact.ContactPreference == "1" && !isEmail(email))
|| contact.ContactPreference == "2")
continue;
var ptext = contact.Name;
if (contact.ContactPreference === 0)
ptext += " " + contact.MobilePhoneDisplayText;
else if (contact.ContactPreference === 1)
ptext += " - " + contact.Email;
var tr = $('<tr></tr>');
var td = $('<td></td>');
var span = $('<span></span>').text(ptext);
if (contact.SurveyOptOut_BC) {
span.css('color', 'lightgray').css('padding-left', 20);
}
else {
var chk = $('<input name="wocontactsurvey" type="checkbox" style="width: unset;" />').data('contact', contact);
td.append(chk)
}
td.append(span);
tr.append(td).appendTo(tb);
}
$("#dialog_wosurveyscontacts").empty().append(tb);
}
}
$('#dialog_wosurveytemplates').val('');
showmaskbg(true);
$('#dialog_sendwosurveys .dialog-title span.title').text(GetTextByKey("P_WO_SENDWORKORDERSURVEYS", 'Send Work Order Surveys'));
if (!surveytemplatedata) {
GetSurveyTemplateItems();
}
$('#dialog_sendwosurveys').data('wo', wo)
.css({
'top': (document.documentElement.clientHeight - $('#dialog_sendwosurveys').height()) / 3,
'left': (document.documentElement.clientWidth - $('#dialog_sendwosurveys').width()) / 2
}).showDialogfixed();
}
function SendWOSurveys() {
var tempid = $('#dialog_wosurveytemplates').val();
if (!tempid || tempid == "") {
showAlert(GetTextByKey("P_WO_XXXXXX", 'Please select a template.'), GetTextByKey("P_WO_SENDWORKORDERSURVEYS", 'Send Work Order Surveys'));
return;
}
var wo = $('#dialog_sendwosurveys').data('wo');
if (wo) {
var contacts = [];
$('#dialog_sendwosurveys input:checkbox[name=wocontactsurvey]:checked').each(function (i, chk) {
var contact = $(chk).data('contact');
contacts.push(contact);
});
var param = JSON.stringify([wo.WorkOrderId, tempid, JSON.stringify(contacts)]);
param = htmlencode(param);
woquery("CreateWorkOrderSurveysByContacts", param, function (data) {
if (data !== "") {
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
return;
}
OnRefresh();
}, function (err) {
showAlert(err, GetTextByKey("P_WO_ERROR", 'Error'));
showmaskbg(false);
});
}
else {
if (!_selectedwoids || _selectedwoids.length == 0)
return;
var param = JSON.stringify([JSON.stringify(_selectedwoids), tempid]);
param = htmlencode(param);
woquery("SendWorkOrderSurveys", param, function (data) {
if (data !== "") {
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
return;
}
OnRefresh();
}, function (err) {
showAlert(err, GetTextByKey("P_WO_ERROR", 'Error'));
showmaskbg(false);
});
}
$('#dialog_sendwosurveys').hideDialog();
showmaskbg(false);
}
function CloseSurveyAutomationDialog(type) {
$('#dialog_surveyautomation').hideDialog();
OnRefresh();
execIframeFunc("refreshstatus", [], "iframeworkorder");
}
function ShowSurveyAutomationDialog(type) {
showmaskbg(true);
$('#dialog_surveyautomation')
.attr('act', type)
.showDialogRight();
}
function openSurveyAutomation() {
$('#iframesurveyautomation').attr('src', 'SurveyAutomationManagement.aspx');
ShowSurveyAutomationDialog();
}
function SetDoNotSendSurvey(woid, donotsend) {
var item = [woid, donotsend];
var p = htmlencode(JSON.stringify(item));
woquery('SetDoNotSendSurvey', p, function (data) {
if (data !== "OK") {
showAlert(data, GetTextByKey("P_AM_ERROR", 'Error'));
}
OnRefresh();
});
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div style="min-width: 1850px;">
<div class="page_title">
<span data-lgid="P_WOS_SURVEYMANAGEMENTRESULT">Survey Management/Result</span>
<%if (IsAdmin)
{%>
<span class="sbutton iconcog" style="float: right; font-size: 14px; margin-right: 15px; cursor: pointer;" onclick="openSurveyAutomation();">
<label data-lgid="P_XXXXX">Survey Automation</label></span>
<%}%>
<div style="clear: both;"></div>
</div>
<div style="margin-top: -15px; font-size: 12px;">
<span style="margin-left: 310px;" data-lgid="P_FR_XXX">Survey Sent Date</span>
<span style="margin-left: 730px;" data-lgid="P_FR_XXX">Work Order Completed</span>
</div>
<div class="search_bar">
<input type="password" autocomplete="new-password" style="display: none" />
<span data-lgid="P_WO_TEMPLATES_COLON">Template:</span>
<div>
<select class="selectinput" style="width: 120px; margin-left: 5px;" id="templateselectinput"></select>
</div>
<span style="margin-left: 5px;" data-lgid="P_FR_XXX">Begin Date:&nbsp;</span>
<div>
<input id="startdatetxt" type="text" style="width: 70px; margin-left: 5px;" value="<%=BeginDate %>" autocomplete="off" />
</div>
<span style="margin-left: 5px;" data-lgid="P_FR_XXX">End Date:&nbsp;</span>
<div>
<input id="enddatetxt" type="text" style="width: 70px; margin-left: 5px;" value="<%=EndDate %>" autocomplete="off" />
</div>
<span data-lgid="P_WOS_SURVEYSTATUS" style="margin-left: 5px;">Survey Status:</span>&nbsp;&nbsp;
<div>
<select class="selectinput" id="typeselectinput" style="width: 150px; margin-left: 5px;">
<option value="-1" data-lgid="P_WOS_ALL">All</option>
<option value="0" data-lgid="P_WOS_WAITINGCUSTOMERREPLY">Waiting Customer Reply</option>
<option value="1" data-lgid="P_WOS_REPLIED">Replied</option>
<option value="2" data-lgid="P_WOS_XXX">No Sent</option>
<option value="3" data-lgid="P_WOS_XXX">Do Not Send</option>
</select>
</div>
<span data-lgid="P_WO_LOCATION_COLON">Location:</span>
<div id="div_locations"></div>
<span data-lgid="P_WO_ADVISOR_COLON">Advisor:</span>
<div id="div_advisors"></div>
<span style="margin-left: 5px;" data-lgid="P_FR_XXX">Begin Date:&nbsp;</span>
<div>
<input id="wostartdatetxt" type="text" style="width: 70px; margin-left: 5px;" value="<%=BeginDate %>" autocomplete="off" />
</div>
<span style="margin-left: 5px;" data-lgid="P_FR_XXX">End Date:&nbsp;</span>
<div>
<input id="woenddatetxt" type="text" style="width: 70px; margin-left: 5px;" value="<%=EndDate %>" autocomplete="off" />
</div>
<input id="searchinputtxt" type="text" autocomplete="off" style="width: 100px; margin-left: 5px;" />
<input class="search" type="button" onclick="OnRefresh();" value="Search" data-lgid="P_FR_SEARCH" style="margin-left: 5px;" />
</div>
<div class="function_title">
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_UM_REFRESH">Refresh</span>
<span class="sbutton iconsendsurvey" onclick="onSendWOSurveys(null);" data-lgid="P_UM_XXX">Send Survey</span>
<%--<span class="sbutton iconexport" onclick="OnExport();" data-lgid="P_MR_EXPORTTOEXCEL">Export to Excel</span>--%>
</div>
<div class="clear"></div>
<div id="surveylist"></div>
<div id="mask_bg" style="display: none;">
<div class="loading c-spin"></div>
</div>
<div class="dialog" id="dialog_survey" style="display: none; height: 100%; border-bottom: 0; border-top: 0; left: unset;">
<iframe id="iframesurveydetail" src="SurveyDetail.aspx" style="width: 100%; height: 100%; display: block; border: none;"></iframe>
<div class="maskbg" style="display: none;"></div>
</div>
</div>
<div class="dialog" id="dialog_sendwosurveys" style="display: none;">
<div class="dialog-title"><span class="title" data-lgid="P_WO_SENDWORKORDERSURVEYS">Send Work Order Surveys</span><em class="dialog-close"></em></div>
<div class="dialog-content">
<table style="line-height: 30px; margin-left: 10px; margin-right: 10px;">
<tr>
<td class="label" data-lgid="P_WO_TEMPLATES_COLON">Templates:</td>
<td class="cont">
<select id="dialog_wosurveytemplates" tabindex="1" style="height: 22px; width: 324px;">
</select></td>
</tr>
<tr id="tr_wocontact" style="display: none;">
<td class="label" style="vertical-align: top;">
<span data-lgid="P_WO_CONTACTS_COLON">Contacts:</span></td>
<td>
<div id="dialog_wosurveyscontacts" style="max-height: 150px; overflow: auto;"></div>
</td>
</tr>
</table>
</div>
<div class="dialog-func">
<input type="button" value="Cancel" data-lgid="P_WO_CANCEL" class="dialog-close" tabindex="18" />
<input type="button" onclick="SendWOSurveys();" value="Send" data-lgid="P_WO_SEND" tabindex="17" />
<div class="clear"></div>
</div>
</div>
<iframe id="ifdiv" style="position: absolute; top: -9999px; height: 1px; width: 1px; border: 0; display: none;"></iframe>
<div class="dialog" id="dialog_surveyautomation" style="display: none; height: 100%; border-bottom: 0; border-top: 0;">
<%--<div class="dialog-title"><span class="title">Add Work Order</span></div>--%>
<iframe id="iframesurveyautomation" style="width: 100%; height: 100%; display: block; border: none;"></iframe>
<div class="maskbg" style="display: none;"></div>
</div>
</asp:Content>

View File

@ -0,0 +1,69 @@
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Maintenance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class SurveyManagement : WorkOrderBasePage
{
protected string IID;
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
public string BeginDate = "";
public string EndDate = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
// TODO: sub page
//RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
string requesttype = Request.Params["rt"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!string.IsNullOrEmpty(requesttype) && requesttype.ToLower() == "f")
{
ProcessFileRequest();
}
else if (!IsPostBack)
{
// todo nothing
IID = GetCurrentLoginSession().User.UID;
this.Title = PageTitle;
bool license = SystemParams.HasLicense("CustomerRecord");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.CUSTOMER_RECORD);
bool permission1 = CheckRight(SystemParams.CompanyID, Feature.WORKORDERSURVEYS);
if (!permission || !permission1)
RedirectToLoginPage();
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
BeginDate = userlocaldate.AddMonths(-1).ToShortDateString();
EndDate = userlocaldate.ToShortDateString();
}
}
}
public bool IsAdmin
{
get
{
var user = GetCurrentUser();
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
return true;
else
return false;
}
}
}

View File

@ -0,0 +1,418 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="SurveyTemplateManagement.aspx.cs" Inherits="SurveyTemplateManagement" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<style type="text/css">
.no_wrap th {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.max160 {
max-width: 160px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.dialog-content table {
border-collapse: collapse;
width: 100%;
line-height: 32px;
}
.dialog-content table td.label {
width: 130px;
text-align: right;
padding-right: 10px;
line-height: 24px;
height: 24px;
vertical-align: top;
}
.dialog-content table td input,
.dialog-content table td textarea {
border: 1px solid #a9a9a9;
width: 250px;
height: 18px;
padding: 1px;
}
#dialog_machines .dialog-content table td input {
width: auto;
}
.dialog-content table td textarea {
margin-top: 6px;
}
.dialog-content table td select {
width: 254px;
height: 24px;
}
.dialog-content table td input[type="checkbox"] {
border: none;
}
.dialog-content table td textarea {
height: 150px;
width: 420px;
max-width: 500px;
}
.ctl_button {
font-family: 'CalciteWebCoreIcons';
display: block;
margin: 6px auto;
width: 60px;
height: 22px;
line-height: 21px;
padding: 0;
}
#dialog_machinegroup {
z-index: 500;
width: 870px;
top: 60px;
left: 150px;
}
.inputbox {
width: 500px;
padding: 1px;
}
.group_table .main_table {
table-layout: fixed;
}
.group_table .main_table thead tr {
display: block;
}
.group_table .main_table tbody {
height: 280px;
display: block;
overflow-y: auto;
}
.group_table .main_table th {
width: 165px;
}
.group_table .main_table td {
width: 165px;
white-space: nowrap;
word-break: keep-all;
}
.group_table .main_table td div {
width: 165px;
overflow: hidden;
white-space: nowrap;
word-break: keep-all;
text-overflow: ellipsis;
}
.td_controller {
vertical-align: middle;
padding: 40px 8px;
/*border-left: 1px solid #b0b0b0;
border-right: 1px solid #b0b0b0;*/
}
.ctl_button {
font-family: 'CalciteWebCoreIcons';
display: block;
margin: 6px auto;
width: 60px;
height: 22px;
line-height: 21px;
padding: 0;
}
.machine_maskbg {
top: 0;
left: 0;
width: 100%;
height: 100%;
position: absolute;
background: #000;
opacity: 0.2;
}
</style>
<script src="<%=GetFileUrlWithVersion("js/controls.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../fic/js/utility.js")%>" type="text/javascript"></script>
<script type="text/javascript">
var IsDealer = <%=IsDealer ?"true":"false"%>;
woquery = function (method, param, callback, error) {
_network.request("Maintenance/SurveyTemplateManagement.aspx", -1, method, param, callback, error);
}
function OnDelete(u) {
if (!u) {
return;
}
var alerttitle = GetTextByKey("P_WOS_DELETESURVEYTEMPLATE", 'Delete Survey Template');
showConfirm(GetTextByKey("P_WOS_DOYOUWANTTODELETETHISSURVEYTEMPLATE", 'Do you want to delete this survey template?'), alerttitle, function () {
woquery('DeleteSurveyTemplate', u.Id, function (data) {
OnRefresh();
}, function (err) {
showAlert(GetTextByKey('P_WOS_FAILEDTODELETETHISSURVEYTEMPLATE', 'Failed to delete this survey template.'), alerttitle);
});
});
}
function CloseDialog(type) {
$('#dialog_survey').hideDialog();
OnRefresh();
showmaskbg(false);
}
function OnAdd() {
execIframeFunc("init", [], "iframesurveytemplate");
showmaskbg(true);
$('#dialog_survey')
.attr('act', 'add')
.showDialogRight();
}
var surveyid;
function OnEdit() {
var index = grid_dt.selectedIndex;
if (index < 0) {
showAlert(GetTextByKey("P_WOS_PLEASESELECTSURVEYTEMPLATE", "Please select survey template."), GetTextByKey("P_WORKORDERSURVEYTEMPLATES", "Work Order Survey Templates")); return;
}
var survey = grid_dt.source[index].Values;
if (!survey) {
surveyid = undefined;
return;
}
surveyid = survey.Id;
execIframeFunc("init", [surveyid, survey.InUse], "iframesurveytemplate");
showmaskbg(true);
$('#dialog_survey')
.attr('act', 'edit')
.showDialogRight();
}
function OnCopy(id) {
if (id == null) {
showAlert(GetTextByKey("P_WOS_PLEASESELECTSURVEYTEMPLATE", "Please select survey template."), GetTextByKey("P_WORKORDERSURVEYTEMPLATES", "Work Order Survey Templates"));
return;
}
execIframeFunc("init", [id, false, true], "iframesurveytemplate");
showmaskbg(true);
$('#dialog_survey')
.attr('act', 'add')
.showDialogRight();
}
function OnDblClick(e) {
OnEdit();
}
function OnRefresh() {
showloading(true);
var searchtxt = "";
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
woquery('GetSurveyTemplateItems', searchtxt, function (data) {
showloading(false);
if (typeof (data) === "string") {
showAlert(data, GetTextByKey('P_WORKORDERSURVEYS', "Survey Template"));
return;
}
showSurveyList(data);
}, function (err) {
showloading(false);
});
}
function showSurveyList(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_dt.setData(rows);
}
var grid_dt;
function InitGridData() {
grid_dt = new GridView('#surveylist');
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_WOS_NAME", "Name"), valueIndex: 'Name', css: { 'width': 300, 'text-align': 'left' } },
{ name: 'Notes', caption: GetTextByKey("P_WOS_NOTES", "Notes"), valueIndex: 'Notes', css: { 'width': 320, 'text-align': 'left' } },
{ name: 'Active', caption: GetTextByKey("P_UM_ACTIVE", "Active"), valueIndex: 'Active', css: { 'width': 100, 'text-align': 'center' } },
{ name: 'Edit', caption: "", css: { 'width': 30, 'text-align': 'center' } },
{ name: 'Copy', caption: "", css: { 'width': 30, 'text-align': 'center' } },
{ name: 'Preview', 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;
if (col.name === 'Active') {
col.type = 3;
col.enabled = false;
}
else 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_WOS_EDIT", 'Edit') };
}
else if (col.name === 'Copy') {
col.isurl = true;
col.text = '\uf0c5';
col.sortable = false;
col.classFilter = function () { return 'icon-col' };
col.attrs = { 'title': GetTextByKey('P_IPT_COPY', 'Copy') };
col.events = {
onclick: function () {
OnCopy(this.Id);
}
};
}
else if (col.name === 'Preview') {
col.isurl = true;
col.text = '\uf06e';
col.sortable = false;
col.classFilter = function () { return 'icon-col' };
col.attrs = { 'title': GetTextByKey('P_MA_PREVIEW', 'Preview') };
col.events = {
onclick: function () {
showmaskbg(true);
woquery('GetSurveyPreviewUrl', encodeURIComponent(this.Id), function (data) {
if (typeof data === "string") {
showAlert(data, GetTextByKey('P_WORKORDERSURVEYS', "Survey Template"));
showmaskbg(false);
return;
}
window.open(data[0]);
showmaskbg(false);
}, function (err) {
showmaskbg(false);
});
}
};
}
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) {
return {
display: (e.InUse) ? 'none' : ''
};
};
col.attrs = { 'title': GetTextByKey("P_WOS_DELETE", 'Delete') };
}
columns.push(col);
}
grid_dt.canMultiSelect = false;
grid_dt.columns = columns;
grid_dt.init();
grid_dt.rowdblclick = OnEdit;
grid_dt.selectedrowchanged = function (rowindex) {
var rowdata = grid_dt.source[rowindex];
if (rowdata) {
}
}
}
$(function () {
setPageTitle(GetTextByKey("P_WORKORDERSURVEYTEMPLATES", "Work Order Survey Templates"), true);
InitGridData();
OnRefresh();
$('#searchinputtxt').keydown(searchEnter);
$(window).resize(function () {
$("#surveylist").css("height", $(window).height() - $("#surveylist").offset().top - 4);
grid_dt && grid_dt.resize();
}).resize();
});
function searchEnter(e) {
if (e.keyCode == 13 || e.keyCode == 9) {
OnRefresh();
}
}
function OnExport() {
var searchtxt = "";
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
window.open("../ExportToFile.aspx?type=custrecord&t=" + searchtxt);
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div style="min-width: 400px;">
<div class="page_title" data-lgid="P_WORKORDERSURVEYTEMPLATES">Work Order Survey Templates</div>
<div class="search_bar">
<input type="password" autocomplete="new-password" style="display: none" />
<input type="text" id="searchinputtxt" autocomplete="off" />
<input class="search" type="button" onclick="OnRefresh();" value="Search" data-lgid="P_CM_SEARCH" style="margin-left: 5px;" />
</div>
<div class="function_title">
<span class="sbutton iconadd" onclick="OnAdd();" data-lgid="P_UM_ADD">Add</span>
<span class="sbutton iconedit" onclick="OnEdit();" data-lgid="P_UM_EDIT">Edit</span>
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_UM_REFRESH">Refresh</span>
<%--<span class="sbutton iconexport" onclick="OnExport();" data-lgid="P_MR_EXPORTTOEXCEL">Export to Excel</span>--%>
</div>
<div class="clear"></div>
<div id="surveylist"></div>
<div id="mask_bg" style="display: none;">
<div class="loading c-spin"></div>
</div>
<div class="dialog" id="dialog_survey" style="display: none; height: 100%; border-bottom: 0; border-top: 0;">
<iframe id="iframesurveytemplate" src="AddSurveyTemplate.aspx" style="width: 100%; height: 100%; display: block; border: none;"></iframe>
<div class="maskbg" style="display: none;"></div>
</div>
</div>
</asp:Content>

View File

@ -0,0 +1,46 @@
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Maintenance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class SurveyTemplateManagement : WorkOrderBasePage
{
protected string IID;
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
// TODO: sub page
//RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
// todo nothing
IID = GetCurrentLoginSession().User.UID;
this.Title = PageTitle;
bool license = SystemParams.HasLicense("CustomerRecord");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.CUSTOMER_RECORD);
bool permission1 = CheckRight(SystemParams.CompanyID, Feature.WORKORDERSURVEYS);
if (!permission || !permission1)
RedirectToLoginPage();
}
}
}
}

View File

@ -0,0 +1,533 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="SurveyTemplatePrint.aspx.cs" Inherits="Maintenance_SurveyTemplatePrint" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<style type="text/css">
.no_wrap th {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.max160 {
max-width: 160px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.dialog-content table {
border-collapse: collapse;
width: 100%;
line-height: 32px;
}
.dialog-content table td.label {
width: 130px;
text-align: right;
padding-right: 10px;
line-height: 24px;
height: 24px;
vertical-align: top;
}
.dialog-content table td input,
.dialog-content table td textarea {
border: 1px solid #a9a9a9;
width: 250px;
height: 18px;
padding: 1px;
}
#dialog_machines .dialog-content table td input {
width: auto;
}
.dialog-content table td textarea {
margin-top: 6px;
}
.dialog-content table td select {
width: 254px;
height: 24px;
}
.dialog-content table td input[type="checkbox"] {
border: none;
}
.dialog-content table td textarea {
height: 150px;
width: 420px;
max-width: 500px;
}
.ctl_button {
font-family: 'CalciteWebCoreIcons';
display: block;
margin: 6px auto;
width: 60px;
height: 22px;
line-height: 21px;
padding: 0;
}
#dialog_machinegroup {
z-index: 500;
width: 870px;
top: 60px;
left: 150px;
}
.inputbox {
width: 500px;
padding: 1px;
}
.group_table .main_table {
table-layout: fixed;
}
.group_table .main_table thead tr {
display: block;
}
.group_table .main_table tbody {
height: 280px;
display: block;
overflow-y: auto;
}
.group_table .main_table th {
width: 165px;
}
.group_table .main_table td {
width: 165px;
white-space: nowrap;
word-break: keep-all;
}
.group_table .main_table td div {
width: 165px;
overflow: hidden;
white-space: nowrap;
word-break: keep-all;
text-overflow: ellipsis;
}
.td_controller {
vertical-align: middle;
padding: 40px 8px;
/*border-left: 1px solid #b0b0b0;
border-right: 1px solid #b0b0b0;*/
}
.ctl_button {
font-family: 'CalciteWebCoreIcons';
display: block;
margin: 6px auto;
width: 60px;
height: 22px;
line-height: 21px;
padding: 0;
}
.machine_maskbg {
top: 0;
left: 0;
width: 100%;
height: 100%;
position: absolute;
background: #000;
opacity: 0.2;
}
.div_filter .dropdown {
width: 100px;
}
.page-chart {
page-break-inside: avoid;
}
</style>
<script src="../js/echarts.min.js"></script>
<script src="<%=GetFileUrlWithVersion("js/controls.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../fic/js/utility.js")%>" type="text/javascript"></script>
<script type="text/javascript">
var colors = [
"#4386d8", "#ff9a2e", "#db443f", "#a8d44f", "#8560b3",
"#3cbfe3", "#afd8f8", "#008e8e", "#8BBa00", "#fabd0f",
"#fa6e46", "#9d080d", "#a186be", "#cc6600", "#fdc689"
];
function reportrequest(method, param, callback, error) {
_network.request("Maintenance/SurveyTemplateReport.aspx", -1, method, param, callback, error || function () {
showmaskbg(false, true);
showAlert(GetTextByKey('P_FR_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_FR_QUERY', 'Query'));
});
}
function InitYesNoBar(q, content, id, s1, s2, d1, d2, index) {
var myChart = echarts.init(content.find('#' + id)[0]);
var option = {
//title: {
// text: q.Title
//},
color: ['#a8d44f', '#db443f'],
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'none'
}
},
legend: {
top: '10%',
left: 'right'
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'value',
boundaryGap: [0, 0.01]
},
yAxis: {
type: 'category',
data: [' ', ' ', ' ']
},
series: [
{
name: s1,
type: 'bar',
data: [null, d1, null]
},
{
name: s2,
type: 'bar',
data: [null, d2, null]
}
]
};
myChart.setOption(option);
}
function InitChooseBar(q, content, id, data, text) {
var myChart = echarts.init(content.find('#' + id)[0]);
var option = {
//title: {
// text: q.Title
//},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'none'
}
},
color: colors,
xAxis: {
type: 'category',
data: data,
axisTick: {
alignWithLabel: true
},
axisLabel: {
interval: 0,
rotate: 45
},
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
yAxis: [{
type: 'value',
name: '',
position: 'left',
alignTicks: true,
axisLine: {
show: true,
lineStyle: {
color: '#5470C6'
}
},
axisLabel: {
formatter: function (value, index) {
if ((value + '').indexOf('.') >= 0) {
return '';
}
return value;
}
}
}],
series: [
{
data: text,
type: 'bar',
barWidth: 50
}
]
};
myChart.setOption(option);
}
function InitScoreBar(q, content, id, data, text, avgData) {
var myChart = echarts.init(content.find('#' + id)[0]);
var option = {
//title: {
// text: q.Title
//},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'none'
}
},
color: colors,
xAxis: {
type: 'category',
data: data,
axisTick: {
alignWithLabel: true
},
axisLabel: {
interval: 0,
rotate: 45
},
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
legend: {},
yAxis: [{
type: 'value',
name: '',
position: 'left',
alignTicks: true,
axisLine: {
show: true,
lineStyle: {
color: '#5470C6'
}
},
axisLabel: {
formatter: function (value, index) {
if ((value + '').indexOf('.') >= 0) {
return '';
}
return value;
}
}
},
//{
// type: 'value',
// name: '',
// position: 'right',
// alignTicks: true,
// offset: 0,
// axisLine: {
// show: true,
// lineStyle: {
// color: '#91CC75'
// }
// },
// axisLabel: {
// formatter: '{value}'
// }
//}
],
series: [
{
data: text,
type: 'bar',
barWidth: 50
},
//{
// name: '',
// type: 'line',
// yAxisIndex: 1,
// data: avgData
//}
]
};
myChart.setOption(option);
}
function InitScorePie(q, content, id, pieData) {
var myChart1 = echarts.init(content.find('#' + id)[0]);
var option1 = {
//title: {
// text: q.Title,
// left: 'center'
//},
color: colors,
tooltip: {
trigger: 'item',
formatter: '{b} : {c} ({d}%)'
},
legend: {
type: 'scroll',
orient: 'vertical',
right: 10,
top: 20,
bottom: 20,
},
series: [
{
name: '',
type: 'pie',
radius: '55%',
center: ['40%', '50%'],
data: pieData,
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};
myChart1.setOption(option1);
}
function InitReport(report) {
var content = $('#surveyreport');
content.html('');
$('<div></div>').css('font-size', 24).css('text-align', 'center').css('font-weight', 'bold').text(report.TemplateName).appendTo(content);
var text = GetTextByKey('P_WOS_TEMPLATES_REPORT_COUNT', 'There are {0} surveys in total.').replace('{0}', report.SurveyCount);
$('<div></div>').css('font-size', 16).css('text-align', 'center').css('font-weight', 'bold').html(text).appendTo(content);
$('<br/>').appendTo(content);
$('<br/>').appendTo(content);
for (var i in report.Questions) {
var q = report.Questions[i];
if (q.QuestionType === 2) {
//Choose
$('<div></div>').css('font-size', 24).css('font-weight', 'bold').css('padding-left', '10px').text(q.Title).appendTo(content);
var data = [];
var vs = [];
var pieData = [];
for (var j in q.Values) {
var vv = q.Values[j];
data.push(vv.DisplayText);
vs.push(vv.Count);
pieData.push({ value: vv.Count, name: vv.DisplayText });
}
var div = $('<div></div>').attr('id', 'choosediv' + i);
div.appendTo(content);
var id = 'choosebardiv' + i;
$('<div class="page-chart" style="height: 300px"></div>').attr('id', id).appendTo(div);
InitChooseBar(q, content, id, data, vs);
id = 'choosepiediv' + i;
$('<div class="page-chart" style="height: 300px"></div>').attr('id', id).appendTo(div);
InitScorePie(q, content, id, pieData);
$('<br/>').appendTo(content);
$('<br/>').appendTo(content);
}
else if (q.QuestionType === 3) {
//YesOrNo
$('<div></div>').css('font-size', 24).css('font-weight', 'bold').css('padding-left', '10px').text(q.Title).appendTo(content);
var id = 'yesnobardiv' + i;
$('<div class="page-chart" style="width: 70%; height: 220px"></div>').attr('id', id).appendTo(content);
InitYesNoBar(q, content, id, q.Values[0].DisplayText, q.Values[1].DisplayText, q.Values[0].Count, q.Values[1].Count, i);
$('<br/>').appendTo(content);
$('<br/>').appendTo(content);
} else if (q.QuestionType === 4) {
//Score
$('<div></div>').css('font-size', 24).css('font-weight', 'bold').css('padding-left', '10px').text(q.Title).appendTo(content);
var data = [];
var vs = [];
var pieData = [];
var avgData = [];
for (var j in q.Values) {
var vv = q.Values[j];
data.push(vv.DisplayText);
vs.push(vv.Count);
pieData.push({ value: vv.Count, name: vv.DisplayText });
avgData.push(q.AverageScore);
}
var div = $('<div></div>').attr('id', 'scorediv' + i);
div.appendTo(content);
var id = 'scorebardiv' + i;
$('<div class="page-chart" style="height: 300px"></div>').attr('id', id).appendTo(div);
InitScoreBar(q, content, id, data, vs, avgData);
id = 'scorepiediv' + i;
$('<div class="page-chart" style="height: 300px"></div>').attr('id', id).appendTo(div);
InitScorePie(q, content, id, pieData);
$('<br/>').appendTo(content);
$('<br/>').appendTo(content);
}
}
}
// JSON.stringify([template, startdate, enddate, JSON.stringify(locations), JSON.stringify(advisors)]);
$(function () {
setPageTitle(GetTextByKey("P_WOS_TEMPLATES_REPORT", "Report"), true);
showmaskbg(true);
var param = $('#<%=@params.ClientID%>').val();
reportrequest('GetSurveyTemplateReport', htmlencode(param), function (data) {
//console.log(data);
if (typeof (data) === "string") {
showAlert(data, GetTextByKey('P_WOS_TEMPLATES_REPORT', "Report"));
showmaskbg(false);
return;
}
if (data != null) {
InitReport(data);
setTimeout(function () { window.print() }, 1000);
}
showmaskbg(false);
}, function () {
showmaskbg(false);
});
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div style="min-width: 400px; width: 1000px">
<div class="page_title" data-lgid="P_WOS_TEMPLATES_REPORT">Report</div>
<div class="search_bar">
<input type="hidden" id="params" runat="server" />
<span data-lgid="P_WO_TEMPLATES_COLON">Template:</span>
<div>
<span id="templatename" style="margin-left: 5px" runat="server"></span>
</div>
<span id="startdate_span" style="margin-left: 5px" data-lgid="P_FR_BEGINDATE_COLON" runat="server">Begin Date:&nbsp;</span>
<div>
<span id="startdate" style="margin-left: 5px" runat="server"></span>
</div>
<span id="enddate_span" style="margin-left: 5px" data-lgid="P_FR_ENDDATE_COLON" runat="server">End Date:&nbsp;</span>
<div>
<span id="enddate" style="margin-left: 5px" runat="server"></span>
</div>
<span id="locations_span" data-lgid="P_WO_LOCATION_COLON" runat="server">Location:</span>
<div id="locations" runat="server"></div>
<span id="advisors_span" data-lgid="P_WO_ADVISOR_COLON" runat="server">Advisor:</span>
<div id="advisors" runat="server"></div>
</div>
<div class="clear"></div>
<br />
<div id="surveyreport"></div>
<div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div>
</div>
</asp:Content>

View File

@ -0,0 +1,91 @@
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Maintenance;
using Newtonsoft.Json;
using System;
using System.Linq;
using System.Net;
public partial class Maintenance_SurveyTemplatePrint : WorkOrderBasePage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
// TODO: sub page
//RedirectToLoginPage();
}
else if (!IsPostBack)
{
Title = PageTitle;
bool license = SystemParams.HasLicense("CustomerRecord");
if (!license)
{
RedirectToLoginPage();
}
bool permission = CheckRight(SystemParams.CompanyID, Feature.CUSTOMER_RECORD);
bool permission1 = CheckRight(SystemParams.CompanyID, Feature.WORKORDERSURVEYS);
if (!permission || !permission1)
{
RedirectToLoginPage();
}
var template = Request.QueryString["tid"];
templatename.InnerText = WebUtility.UrlDecode(Request.QueryString["tname"]);
var start = WebUtility.UrlDecode(Request.QueryString["start"]);
var end = WebUtility.UrlDecode(Request.QueryString["end"]);
if (string.IsNullOrEmpty(start))
{
startdate_span.Visible = false;
}
else
{
startdate.InnerText = start;
}
if (string.IsNullOrEmpty(end))
{
enddate_span.Visible = false;
}
else
{
enddate.InnerText = end;
}
string[] locids;
string[] advids;
var locs = WebUtility.UrlDecode(Request.QueryString["locs"]);
if (string.IsNullOrEmpty(locs))
{
locids = new string[0];
locations_span.Visible = false;
}
else
{
var array = locs.Split(',');
locids = array.Select(loc => loc.Split(';').FirstOrDefault()).ToArray();
locations.InnerText = string.Join(", ", array.Select(loc => loc.Split(';').LastOrDefault()));
}
var advs = WebUtility.UrlDecode(Request.QueryString["advs"]);
if (string.IsNullOrEmpty(advs))
{
advids = new string[0];
advisors_span.Visible = false;
}
else
{
var array = advs.Split(',');
advids = array.Select(a => a.Split(';').FirstOrDefault()).ToArray();
advisors.InnerText = string.Join(", ", array.Select(a => a.Split(';').LastOrDefault()));
}
@params.Value = JsonConvert.SerializeObject(new[]
{
template,
start,
end,
JsonConvert.SerializeObject(locids),
JsonConvert.SerializeObject(advids)
});
}
}
}

View File

@ -0,0 +1,906 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="SurveyTemplateReport.aspx.cs" Inherits="Maintenance_SurveyTemplateReport" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<style type="text/css">
.no_wrap th {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.max160 {
max-width: 160px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.dialog-content table {
border-collapse: collapse;
width: 100%;
line-height: 32px;
}
.dialog-content table td.label {
width: 130px;
text-align: right;
padding-right: 10px;
line-height: 24px;
height: 24px;
vertical-align: top;
}
.dialog-content table td input,
.dialog-content table td textarea {
border: 1px solid #a9a9a9;
width: 250px;
height: 18px;
padding: 1px;
}
#dialog_machines .dialog-content table td input {
width: auto;
}
.dialog-content table td textarea {
margin-top: 6px;
}
.dialog-content table td select {
width: 254px;
height: 24px;
}
.dialog-content table td input[type="checkbox"] {
border: none;
}
.dialog-content table td textarea {
height: 150px;
width: 420px;
max-width: 500px;
}
.ctl_button {
font-family: 'CalciteWebCoreIcons';
display: block;
margin: 6px auto;
width: 60px;
height: 22px;
line-height: 21px;
padding: 0;
}
#dialog_machinegroup {
z-index: 500;
width: 870px;
top: 60px;
left: 150px;
}
.inputbox {
width: 500px;
padding: 1px;
}
.group_table .main_table {
table-layout: fixed;
}
.group_table .main_table thead tr {
display: block;
}
.group_table .main_table tbody {
height: 280px;
display: block;
overflow-y: auto;
}
.group_table .main_table th {
width: 165px;
}
.group_table .main_table td {
width: 165px;
white-space: nowrap;
word-break: keep-all;
}
.group_table .main_table td div {
width: 165px;
overflow: hidden;
white-space: nowrap;
word-break: keep-all;
text-overflow: ellipsis;
}
.td_controller {
vertical-align: middle;
padding: 40px 8px;
/*border-left: 1px solid #b0b0b0;
border-right: 1px solid #b0b0b0;*/
}
.ctl_button {
font-family: 'CalciteWebCoreIcons';
display: block;
margin: 6px auto;
width: 60px;
height: 22px;
line-height: 21px;
padding: 0;
}
.machine_maskbg {
top: 0;
left: 0;
width: 100%;
height: 100%;
position: absolute;
background: #000;
opacity: 0.2;
}
.div_filter .dropdown {
width: 100px;
}
.emailpopus-close {
float: right;
margin-right: 6px;
cursor: pointer;
}
.emailpopus-close:before {
content: '\e600';
}
.dialog-content .data-grid .data-grid-body .data-grid-body-content td input {
width: unset;
height: unset;
}
</style>
<link href="../css/jquery.datetimepicker.css" rel="stylesheet" />
<script src="../js/jquery.datetimepicker.full.js"></script>
<script src="../js/echarts.min.js"></script>
<script src="<%=GetFileUrlWithVersion("js/controls.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../fic/js/utility.js")%>" type="text/javascript"></script>
<script type="text/javascript">
var colors = [
"#4386d8", "#ff9a2e", "#db443f", "#a8d44f", "#8560b3",
"#3cbfe3", "#afd8f8", "#008e8e", "#8BBa00", "#fabd0f",
"#fa6e46", "#9d080d", "#a186be", "#cc6600", "#fdc689"
];
function reportrequest(method, param, callback, error) {
_network.request("Maintenance/SurveyTemplateReport.aspx", -1, method, param, callback, error || function (e) {
showmaskbg(false, true);
showAlert(GetTextByKey('P_FR_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_FR_QUERY', 'Query'));
});
}
function InitYesNoBar(q, content, id, s1, s2, d1, d2, index) {
var myChart = echarts.init(content.find('#' + id)[0]);
var option = {
//title: {
// text: q.Title
//},
color: ['#a8d44f', '#db443f'],
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'none'
}
},
legend: {
top: '10%',
left: 'right'
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'value',
boundaryGap: [0, 0.01]
},
yAxis: {
type: 'category',
data: [' ', ' ', ' ']
},
series: [
{
name: s1,
type: 'bar',
data: [null, d1, null]
},
{
name: s2,
type: 'bar',
data: [null, d2, null]
}
]
};
option && myChart.setOption(option);
myChart.on('dblclick', function (params) {
var i = params.seriesIndex;
var s = q.Values[i].Surveys.join(',');
console.log(s);
if (s.length > 0) {
drilldowndetail(s);
}
});
}
function InitChooseBar(q, content, id, data, text) {
var myChart = echarts.init(content.find('#' + id)[0]);
var option = {
//title: {
// text: q.Title
//},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'none'
}
},
color: colors,
xAxis: {
type: 'category',
data: data,
axisTick: {
alignWithLabel: true
},
axisLabel: {
interval: 0,
rotate: 45
},
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
yAxis: [{
type: 'value',
name: '',
position: 'left',
alignTicks: true,
axisLine: {
show: true,
lineStyle: {
color: '#5470C6'
}
},
axisLabel: {
formatter: function (value, index) {
if ((value + '').indexOf('.') >= 0) {
return '';
}
return value;
}
}
}],
series: [
{
data: text,
type: 'bar',
barWidth: 50
}
]
};
option && myChart.setOption(option);
myChart.on('dblclick', function (params) {
var i = params.dataIndex;
var s = q.Values[i].Surveys.join(',');
console.log(s);
if (s.length > 0) {
drilldowndetail(s);
}
});
}
function InitScoreBar(q, content, id, data, text, avgData) {
var myChart = echarts.init(content.find('#' + id)[0]);
var option = {
//title: {
// text: q.Title
//},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'none'
}
},
color: colors,
xAxis: {
type: 'category',
data: data,
axisTick: {
alignWithLabel: true
},
axisLabel: {
interval: 0,
rotate: 45
},
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
legend: {},
yAxis: [{
type: 'value',
name: '',
position: 'left',
alignTicks: true,
axisLine: {
show: true,
lineStyle: {
color: '#5470C6'
}
},
axisLabel: {
formatter: function (value, index) {
if ((value + '').indexOf('.') >= 0) {
return '';
}
return value;
}
}
},
//{
// type: 'value',
// name: '',
// position: 'right',
// alignTicks: true,
// offset: 0,
// axisLine: {
// show: true,
// lineStyle: {
// color: '#91CC75'
// }
// },
// axisLabel: {
// formatter: '{value}'
// }
//}
],
series: [
{
data: text,
type: 'bar',
barWidth: 50
},
//{
// name: '',
// type: 'line',
// yAxisIndex: 1,
// data: avgData
//}
]
};
option && myChart.setOption(option);
myChart.on('dblclick', function (params) {
var i = params.dataIndex;
var s = q.Values[i].Surveys.join(',');
console.log(s);
if (s.length > 0) {
drilldowndetail(s);
}
});
}
function InitScorePie(q, content, id, pieData) {
var myChart1 = echarts.init(content.find('#' + id)[0]);
var option1 = {
//title: {
// text: q.Title,
// left: 'center'
//},
color: colors,
tooltip: {
trigger: 'item',
formatter: '{b} : {c} ({d}%)'
},
legend: {
type: 'scroll',
orient: 'vertical',
right: 10,
top: 20,
bottom: 20,
},
series: [
{
name: '',
type: 'pie',
radius: '55%',
center: ['40%', '50%'],
data: pieData,
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};
option1 && myChart1.setOption(option1);
myChart1.on('dblclick', function (params) {
var i = params.dataIndex;
var s = q.Values[i].Surveys.join(',');
console.log(s);
if (s.length > 0) {
drilldowndetail(s);
}
});
}
function drilldowndetail(ids) {
var template = $('#templateselectinput').find("option:selected").val();
var startdate = htmlencode($('#startdatetxt').val());
var enddate = htmlencode($('#enddatetxt').val());
var locations = [];
if (locationparam)
locations = locationparam.selectedvalue;
var advisors = [];
if (advisorparam)
advisors = advisorparam.selectedvalue;
var param = JSON.stringify([template, startdate, enddate, JSON.stringify(locations), JSON.stringify(advisors), ids]);
param = htmlencode(param);
setCookieSeconds("WOSurveyReportParams", param, 60);
window.open("maintenance.aspx?#nav_surveymanagementresult")
//alert('testing');
}
function InitReport(report) {
var content = $('#surveyreport');
content.html('');
$('<div></div>').css('font-size', 24).css('text-align', 'center').css('font-weight', 'bold').text(report.TemplateName).appendTo(content);
var text = GetTextByKey('P_WOS_TEMPLATES_REPORT_COUNT', 'There are {0} surveys in total.').replace('{0}', report.SurveyCount);
if (report.SurveyCount > 0) {
text = text + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a style='font-weight: normal' href='javascript:void(0);' onclick='drilldowndetail();'>" + GetTextByKey('P_MA_DETAIL', 'Detail') + "</a>";
}
$('<div></div>').css('font-size', 16).css('text-align', 'center').css('font-weight', 'bold').html(text).appendTo(content);
$('<br/>').appendTo(content);
$('<br/>').appendTo(content);
for (var i in report.Questions) {
var q = report.Questions[i];
if (q.QuestionType === 2) {
//Choose
$('<div></div>').css('font-size', 24).css('font-weight', 'bold').css('padding-left', '10px').text(q.Title).appendTo(content);
var data = [];
var vs = [];
var pieData = [];
for (var j in q.Values) {
var vv = q.Values[j];
data.push(vv.DisplayText);
vs.push(vv.Count);
pieData.push({ value: vv.Count, name: vv.DisplayText });
}
var id = 'choosediv' + i;
var div = $('<div id=\'' + id + '\' style=\'display: flex; height: 320px\'></div>');
div.appendTo(content);
var id = 'choosebardiv' + i;
$('<div id=\'' + id + '\'></div>').css('width', '50%').appendTo(div);
InitChooseBar(q, content, id, data, vs);
id = 'choosepiediv' + i;
$('<div id=\'' + id + '\'></div>').css('width', '50%').appendTo(div);
InitScorePie(q, content, id, pieData);
$('<br/>').appendTo(content);
$('<br/>').appendTo(content);
}
else if (q.QuestionType === 3) {
//YesOrNo
$('<div></div>').css('font-size', 24).css('font-weight', 'bold').css('padding-left', '10px').text(q.Title).appendTo(content);
var id = 'yesnobardiv' + i;
$('<div id=\'' + id + '\'></div>').css('width', '70%').css('height', '220px').appendTo(content);
InitYesNoBar(q, content, id, q.Values[0].DisplayText, q.Values[1].DisplayText, q.Values[0].Count, q.Values[1].Count, i);
$('<br/>').appendTo(content);
$('<br/>').appendTo(content);
} else if (q.QuestionType === 4) {
//Score
$('<div></div>').css('font-size', 24).css('font-weight', 'bold').css('padding-left', '10px').text(q.Title).appendTo(content);
var data = [];
var vs = [];
var pieData = [];
var avgData = [];
for (var j in q.Values) {
var vv = q.Values[j];
data.push(vv.DisplayText);
vs.push(vv.Count);
pieData.push({ value: vv.Count, name: vv.DisplayText });
avgData.push(q.AverageScore);
}
var id = 'scorediv' + i;
var div = $('<div id=\'' + id + '\' style=\'display: flex; height: 320px\'></div>');
div.appendTo(content);
id = 'scorebardiv' + i;
$('<div id=\'' + id + '\'></div>').css('width', '50%').appendTo(div);
InitScoreBar(q, content, id, data, vs, avgData);
id = 'scorepiediv' + i;
$('<div id=\'' + id + '\'></div>').css('width', '50%').appendTo(div);
InitScorePie(q, content, id, pieData);
$('<br/>').appendTo(content);
$('<br/>').appendTo(content);
}
}
}
var locationparam;
var advisorparam;
var location_editmultiselect;
var advisor_editmultiselect;
function GetFilterDataSource() {
$('#div_locations').empty();
$('#div_advisors').empty();
reportrequest('GetFilterDataSource', '', function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_AM_ERROR", 'Error'));
return;
}
for (var i = 0; i < data.Locations.length; i++) {
var loc = data.Locations[i];
loc.sublevel = loc.PId > 0 ? 1 : 0;
}
locationparam = {
items: data.Locations,
selectedvalue: [],
width: 120,
valuepath: "ID",
textpath: "Name"
};
location_editmultiselect = editmultiselect(locationparam);
$('#div_locations').append(location_editmultiselect);
advisorparam = {
items: JSON.parse(JSON.stringify(data.Advisors)),
selectedvalue: [],
width: 120
};
advisor_editmultiselect = editmultiselect(advisorparam);
$('#div_advisors').append(advisor_editmultiselect);
}, function () {
});
}
function getParams(tid) {
var startdate = htmlencode($('#startdatetxt').val());
var enddate = htmlencode($('#enddatetxt').val());
var locations = [];
if (locationparam)
locations = locationparam.selectedvalue;
var advisors = [];
if (advisorparam)
advisors = advisorparam.selectedvalue;
return JSON.stringify([tid, startdate, enddate, JSON.stringify(locations), JSON.stringify(advisors)]);
}
var reportData;
function OnRefresh() {
showloading(true);
var template = $('#templateselectinput').find("option:selected").val();
var param = getParams(template);
param = htmlencode(param);
reportrequest('GetSurveyTemplateReport', param, function (data) {
showloading(false);
//console.log(data);
if (typeof (data) === "string") {
showAlert(data, GetTextByKey('P_WOS_TEMPLATES_REPORT', "Report"));
return;
}
if (data != null) {
InitReport(data);
}
else {
reportData = null;
$('#surveyreport').html('');
}
}, function (err) {
showloading(false);
});
}
function OnPrint() {
var selectedTemplate = $('#templateselectinput').find("option:selected");
var tid = Number(selectedTemplate.val());
if (tid < 0) {
showAlert(GetTextByKey("P_WO_XXXX", "Please select a template."), GetTextByKey("P_MR_PRINT", "Print"));
return;
}
var tname = encodeURIComponent(selectedTemplate.text());
var start = encodeURIComponent($('#startdatetxt').val());
var end = encodeURIComponent($('#enddatetxt').val());
var locs = locationparam == null ? '' : encodeURIComponent(locationparam.selectedvalue.map(function (v) {
var item = locationparam.items.filter(function (i) { return i.ID == v })[0];
if (item != null) {
return v + ';' + item.Name;
}
return v;
}).join(','));
var advs = advisorparam == null ? '' : encodeURIComponent(advisorparam.selectedvalue.map(function (v) {
var item = advisorparam.items.filter(function (i) { return i.Key == v })[0];
if (item != null) {
return v + ';' + item.Value;
}
return v;
}).join(','));
window.open('SurveyTemplatePrint.aspx?tid=' + tid + '&tname=' + tname + '&start=' + start + '&end=' + end + '&locs=' + locs + '&advs=' + advs);
}
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: 'ID', caption: GetTextByKey("P_WO_EMAIL", "Email"), valueIndex: 'ID', css: { 'width': 148, 'text-align': 'left' } },
{ name: 'Email', caption: '', 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);
}
grid_contactdt.canMultiSelect = false;
grid_contactdt.columns = columns;
grid_contactdt.init();
}
function getContacts() {
reportrequest("GetAllFollowers", '', function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
return;
}
var rows = [];
for (var i = 0; i < data.length; i++) {
var r = data[i];
var fr = {
Values: {
ID: r.ID,
DisplayName: r.DisplayName,
ContactTypeName: r.ContactTypeName,
Email: false
}
};
rows.push(fr);
}
grid_contactdt.setData(rows);
}, function () {
});
}
function openSendEmail() {
$('#email_otheremailaddress').val('');
var template = $('#templateselectinput').find("option:selected").val();
var tid = Number(template);
if (isNaN(tid) || tid < 0) {
showAlert(GetTextByKey("P_WO_XXXX", "Please select a template."), GetTextByKey("P_WO_SENDEMAIL", "Send Email"));
return;
}
$(document.body).css('overflow', 'hidden');
getContacts();
$('#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();
$(document.body).css('overflow', '');
}
function CheckEmail(mail) {
if (mail == null || mail.length == 0)
return false;
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return filter.test(mail);
}
function onSendSurveyReport() {
var alerttitle = GetTextByKey("P_WO_SENDEMAIL", "Send Email");
var emailaddress = [];
var otheremailaddressstr = $('#email_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': address[i], '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.DisplayName, 'Value': ct.ID });
}
}
if (emailaddress.length == 0) {
hideSendEmailPopup();
return;
}
var template = $('#templateselectinput').find("option:selected").val();
var param = getParams(template);
reportrequest('GetSurveyTemplateEmail', encodeURIComponent(param + String.fromCharCode(170) + JSON.stringify(emailaddress)), function (data) {
if (typeof data === 'string') {
_dialog.showAlert(data, alerttitle);
return;
}
hideSendEmailPopup();
_dialog.showAlert(GetTextByKey("P_WO_MESSAGESENT", 'Message sent'), alerttitle);
});
}
$(function () {
setPageTitle(GetTextByKey("P_WOS_TEMPLATES_REPORT", "Report"), true);
InitContactGridData();
GetTemplateData();
GetFilterDataSource();
$('.emailpopus-close').on('click', function () {
hideSendEmailPopup();
});
$('#startdatetxt').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]);
}
});
$('#enddatetxt').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]);
}
});
$('#templateselectinput').change(function () { OnRefresh(); });
});
function GetTemplateData() {
reportrequest("GetSurveyTemplateItems", '', function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_FR_ERROR", 'Error'));
return;
}
$('#templateselectinput').empty();
$("<option></option>").val("-1").text('').appendTo($("#templateselectinput"));
for (var i = 0; i < data.length; i++) {
$("<option></option>").val(data[i].Id).text(data[i].Name).appendTo($("#templateselectinput"));
}
//OnRefresh();
}, function () {
})
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div style="min-width: 400px;">
<div class="page_title" data-lgid="P_WOS_TEMPLATES_REPORT">Report</div>
<div class="search_bar">
<input type="password" autocomplete="new-password" style="display: none" />
<span data-lgid="P_WO_TEMPLATES_COLON">Template:</span>
<div>
<select class="selectinput" style="width: 120px; margin-left: 5px;" id="templateselectinput"></select>
</div>
<span style="margin-left: 5px;" data-lgid="P_FR_BEGINDATE_COLON">Begin Date:&nbsp;</span>
<div>
<input id="startdatetxt" type="text" style="width: 80px; margin-left: 5px;" autocomplete="off" />
</div>
<span style="margin-left: 5px;" data-lgid="P_FR_ENDDATE_COLON">End Date:&nbsp;</span>
<div>
<input id="enddatetxt" type="text" style="width: 80px; margin-left: 5px;" autocomplete="off" />
</div>
<span data-lgid="P_WO_LOCATION_COLON">Location:</span>
<div id="div_locations"></div>
<span data-lgid="P_WO_ADVISOR_COLON">Advisor:</span>
<div id="div_advisors"></div>
<input class="search" style="margin-left: 5px;" type="button" onclick="OnRefresh();" value="View" data-lgid="P_MA_VIEW" />
<input class="search" style="margin-left: 5px" type="button" onclick="OnPrint();" value="Print" data-lgid="P_MR_PRINT" />
<input class="search" style="width: unset; min-width: 80px; margin-left: 5px" type="button" onclick="openSendEmail();" value="Send Email" data-lgid="P_WO_SENDEMAIL" />
</div>
<div class="clear"></div>
<br />
<div id="surveyreport"></div>
<div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div>
</div>
<div id="sendemailpopupmask" class="maskbg" style="display: none;"></div>
<div class="dialog" id="sendemailpopupdialog" style="display: none; width: 480px">
<div class="dialog-title"><span class="title" data-lgid="P_WO_XXXX">Send Survey Report</span><em class="emailpopus-close"></em></div>
<div class="dialog-content" style="height: 350px">
<table>
<tr>
<td data-lgid="P_WO_SENDTHISTO">Who do you want to send this to? Select from existing relationships or manual entry.</td>
</tr>
<tr>
<td>
<div id="contactlist" style="height: 240px; width: 420px; margin-left: 10px; margin-right: 10px;"></div>
</td>
</tr>
<tr>
<td data-lgid="P_WO_EMAILADDRESSESTIPS">Separate multiple manually entered email addresses with a semi-colon (;).</td>
</tr>
<tr>
<td><span data-lgid="P_WO_OTHEREMAILADDRESS">Other Email Address</span>
<input type="text" id="email_otheremailaddress" style="width: 312px;" autocomplete="off" /></td>
</tr>
</table>
</div>
<div class="dialog-func">
<input type="button" value="Cancel" data-lgid="P_WO_CANCEL" class="emailpopus-close" tabindex="153" />
<input type="button" onclick="onSendSurveyReport();" value="OK" data-lgid="P_WO_OK" tabindex="152" />
<div class="clear"></div>
</div>
</div>
</asp:Content>

View File

@ -0,0 +1,43 @@
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Maintenance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Maintenance_SurveyTemplateReport : WorkOrderBasePage
{
protected string IID;
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
// TODO: sub page
//RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
IID = GetCurrentLoginSession().User.UID;
this.Title = PageTitle;
bool license = SystemParams.HasLicense("CustomerRecord");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.CUSTOMER_RECORD);
bool permission1 = CheckRight(SystemParams.CompanyID, Feature.WORKORDERSURVEYS);
if (!permission || !permission1)
RedirectToLoginPage();
}
}
}
}

View File

@ -0,0 +1,562 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="WorkOrderHistory.aspx.cs" Inherits="WorkOrderHistory" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link href="../css/jquery.datetimepicker.css" rel="stylesheet" />
<style type="text/css">
.no_wrap th {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.max160 {
max-width: 160px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.dialog-content table {
border-collapse: collapse;
width: 100%;
line-height: 32px;
}
.dialog-content table td.label {
width: 130px;
text-align: right;
padding-right: 10px;
line-height: 24px;
height: 24px;
vertical-align: top;
}
.dialog-content table td input,
.dialog-content table td textarea {
border: 1px solid #a9a9a9;
width: 250px;
height: 18px;
padding: 1px;
}
#dialog_machines .dialog-content table td input {
width: auto;
}
.dialog-content table td textarea {
margin-top: 6px;
}
.dialog-content table td select {
width: 254px;
height: 24px;
}
.dialog-content table td input[type="checkbox"] {
border: none;
}
.dialog-content table td textarea {
height: 150px;
width: 420px;
max-width: 500px;
}
.ctl_button {
font-family: 'CalciteWebCoreIcons';
display: block;
margin: 6px auto;
width: 60px;
height: 22px;
line-height: 21px;
padding: 0;
}
#dialog_machinegroup {
z-index: 500;
width: 870px;
top: 60px;
left: 150px;
}
.inputbox {
width: 500px;
padding: 1px;
}
.group_table .main_table {
table-layout: fixed;
}
.group_table .main_table thead tr {
display: block;
}
.group_table .main_table tbody {
height: 280px;
display: block;
overflow-y: auto;
}
.group_table .main_table th {
width: 165px;
}
.group_table .main_table td {
width: 165px;
white-space: nowrap;
word-break: keep-all;
}
.group_table .main_table td div {
width: 165px;
overflow: hidden;
white-space: nowrap;
word-break: keep-all;
text-overflow: ellipsis;
}
.td_controller {
vertical-align: middle;
padding: 40px 8px;
/*border-left: 1px solid #b0b0b0;
border-right: 1px solid #b0b0b0;*/
}
.ctl_button {
font-family: 'CalciteWebCoreIcons';
display: block;
margin: 6px auto;
width: 60px;
height: 22px;
line-height: 21px;
padding: 0;
}
#tbwoh {
width: 100%;
line-height: 30px;
border-collapse: collapse;
border-spacing: 0;
}
#tbwoh th {
border: 1px solid #bababa;
background-color: #d8dce1;
text-align: left;
border-right: 1px solid #bababa;
font-weight: bold;
position: relative;
padding-left: 5px;
}
#tbwoh tr {
border-bottom: 1px solid #cacaca;
}
#tbwoh td {
border-right: 1px solid #cacaca;
padding-left: 5px;
}
</style>
<script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../js/editableselect.js")%>"></script>
<script src="<%=GetFileUrlWithVersion("js/controls.js")%>" type="text/javascript"></script>
<script type="text/javascript">
woquery = function (method, param, callback, error) {
_network.request("Maintenance/WorkOrderHistory.aspx", -1, method, param, callback, error);
}
function CloseDialog(type) {
$('#dialog_user').hideDialog();
OnRefresh();
}
function OnRefresh() {
var woid = $('#div_wonumber').dropdownVal();
if (!woid) {
return;
}
showloading(true);
var beginDate = $('#startdatetxt').val();
var endDate = $('#enddatetxt').val();
var searchtxt = "";
searchtxt = htmlencode($.trim($('#searchinputtxt').val()));
woquery('GetWorkOrderHistorys', JSON.stringify([woid, beginDate, endDate, searchtxt]), function (data) {
showloading(false);
if (typeof (data) === "string") {
showAlert(data, GetTextByKey('P_WORKORDER', "Work Order"));
return;
}
showWorkOrderList(data);
}, function (err) {
showloading(false);
});
}
function showWorkOrderList(data) {
var wohlist = $("#wohlist").empty();
//var logid = -1;
var datetime = "";
var ftr = null;
var count = 0;
for (var i = 0; i < data.length; i++) {
var r = data[i];
var type = "";
var status = "";
var category = "";
if (r.UpdateType == 0)
type = GetTextByKey('P_WO_XXX', 'Manually');
else if (r.UpdateType == 1)
type = GetTextByKey('P_WO_XXX', 'Automatically');
else if (r.UpdateType == 2)
type = GetTextByKey('P_WO_XXX', 'System');
if (r.UpdateStatus == 0)
status = GetTextByKey('P_WO_XXX', 'Created');
else if (r.UpdateStatus == 1 || r.UpdateStatus == 4 || r.UpdateStatus == 9999)
status = GetTextByKey('P_WO_XXX', 'Modified');
else if (r.UpdateStatus == 2)
status = GetTextByKey('P_WO_XXX', 'Closed');
else if (r.UpdateStatus == 3)
status = GetTextByKey('P_WO_XXX', 'Re_Opened');
//else if (r.UpdateStatus == 4)
// status = GetTextByKey('P_WO_XXX', 'Restored');
//else if (r.UpdateStatus == 9999)
// status = GetTextByKey('P_WO_XXX', 'Deleted');
switch (r.Category) {
case 0:
category = GetTextByKey('P_WO_XXX', 'Work Order Status');
break;
case 1:
category = GetTextByKey('P_WO_XXX', 'Assigned To');
break;
case 2:
category = GetTextByKey('P_WO_XXX', 'Advisor');
break;
case 3:
category = GetTextByKey('P_WO_XXX', 'Work Order Type');
break;
case 4:
category = GetTextByKey('P_WO_XXX', 'Location');
break;
case 5:
category = GetTextByKey('P_WO_XXX', 'Department');
break;
case 6:
category = GetTextByKey('P_WO_XXX', 'Alternate Status');
break;
case 7:
category = GetTextByKey('P_WO_XXX', 'Description');
break;
case 8:
category = GetTextByKey('P_WO_XXX', 'Invoice Number');
break;
case 9:
category = GetTextByKey('P_WO_XXX', 'Internal ID');
break;
case 10:
category = GetTextByKey('P_WO_XXX', 'Complete Date');
break;
case 11:
category = GetTextByKey('P_WO_XXX', 'Next Follow Up Date');
break;
case 12:
category = GetTextByKey('P_WO_XXX', 'Due Date');
break;
case 13:
category = GetTextByKey('P_WO_XXX', 'Parts Expected Date');
break;
case 14:
category = GetTextByKey('P_WO_XXX', 'Last Labor Date');
break;
case 15:
category = GetTextByKey('P_WO_XXX', 'Total Cost');
break;
case 16:
category = GetTextByKey('P_WO_XXX', 'Expected Cost');
break;
case 17:
category = GetTextByKey('P_WO_XXX', 'Parts Cost');
break;
case 18:
category = GetTextByKey('P_WO_XXX', 'Travel Time Cost');
break;
case 19:
category = GetTextByKey('P_WO_XXX', 'Labor Cost');
break;
case 20:
category = GetTextByKey('P_WO_XXX', 'Other Cost');
break;
case 21:
category = GetTextByKey('P_WO_XXX', 'Estimate');
break;
case 22:
category = GetTextByKey('P_WO_XXX', 'Inspection');
break;
case 23:
category = GetTextByKey('P_WO_XXX', 'Invoice');
break;
case 24:
category = GetTextByKey('P_WO_XXX', 'Segment User');
break;
case 25:
category = GetTextByKey('P_WO_XXX', 'Segment Hours');
break;
case 26:
category = GetTextByKey('P_WO_XXX', 'Segment Jobsite');
break;
case 27:
category = GetTextByKey('P_WO_XXX', 'Segment Cost');
break;
case 28:
category = GetTextByKey('P_WO_XXX', 'Segment Component');
break;
case 29:
category = GetTextByKey('P_WO_XXX', 'Segment Completed');
break;
case 30:
category = GetTextByKey('P_WO_XXX', 'Segment Completed Date');
break;
case 31:
category = GetTextByKey('P_WO_XXX', 'Segment Description');
break;
case 32:
category = GetTextByKey('P_WO_XXX', 'Segment Notes');
break;
case 33:
category = GetTextByKey('P_WO_XXX', 'Segment');
break;
case 34:
category = GetTextByKey('P_WO_XXX', 'Alerts');
break;
case 35:
category = GetTextByKey('P_WO_XXX', 'Segment Type');
break;
case 36:
category = GetTextByKey('P_WO_XXX', 'Segment Billable');
break;
case 37:
category = GetTextByKey('P_WO_XXX', 'Component');
break;
case 38:
category = GetTextByKey('P_WO_XXX', 'Billable');
break;
case 39:
category = GetTextByKey('P_WO_XXX', 'Bill to job');
break;
case 40:
category = GetTextByKey('P_WO_XXX', 'Work Order Attachment');
break;
case 41:
category = GetTextByKey('P_WO_XXX', 'Estimate Attachment');
break;
case 42:
category = GetTextByKey('P_WO_XXX', 'Invoice Attachment');
break;
case 43:
category = GetTextByKey('P_WO_XXX', 'Company Name');
break;
case 44:
category = GetTextByKey('P_WO_XXX', 'Asset');
break;
case 45:
category = GetTextByKey('P_WO_XXX', 'Parts Order Number');
break;
case 46:
category = GetTextByKey('P_WO_XXX', 'Parts Status');
break;
case 47:
category = GetTextByKey('P_WO_XXX', 'Salesperson');
break;
case 48:
category = GetTextByKey('P_WO_XXX', 'Inspection Template');
break;
case 97:
category = GetTextByKey('P_WO_XXX', 'Deleted');
break;
case 98:
category = GetTextByKey('P_WO_XXX', 'Restored');
break;
case 99:
category = GetTextByKey('P_WO_XXX', 'WO Life Cycle');
break;
default:
category = GetTextByKey('P_WO_XXX', 'Other');
break;
}
var tr = $("<tr></tr>");
//if (logid != r.Id) {
if (datetime !== r.DateTimeStr) {
if (ftr && count > 1)
ftr.children().eq(0).attr("rowspan", count);
count = 0;
ftr = tr;
tr.append($("<td></td>").text(r.DateTimeStr));
}
tr.append($("<td></td>").text(status));
tr.append($("<td></td>").text(type));
tr.append($("<td></td>").text(r.UpdateBy));
tr.append($("<td></td>").text(category));
tr.append($("<td></td>").text(r.Detail));
var td_del = $("<td></td>");
tr.append(td_del);
if (r.UpdateStatus == 9999 && r.CanDeleteAndRestore) {
var span_del = $('<a href="#" data-lgid="P_UM_XXXX">Restore</a>').data('wo', r).click(ManageDeleteAndRestore);
td_del.append(span_del);
}
if (i % 2 == 1)
tr.css("background-color", "#f1f4f8");
wohlist.append(tr);
//logid = r.Id;
datetime = r.DateTimeStr;
count++;
}
if (ftr && count > 1)
ftr.children().eq(0).attr("rowspan", count);
}
function ManageDeleteAndRestore() {
var wo = $(this).data('wo');
if (!wo)
return;
var alerttitle = GetTextByKey('P_WORKORDER', "Work Order");
showConfirm(GetTextByKey("P_WO_XXX", 'Are you sure you want to restore this work order?'), alerttitle, function () {
woquery("RestoreDeleteWorkOrder", wo.WorkOrderId, function (data) {
if (data == "OK")
OnRefresh();
}, function (err) {
showAlert(GetTextByKey("P_WO_XXX", 'Failed to restore this work order.'), alerttitle);
});
});
}
function GetWorkOrderNumbers() {
woquery('GetWorkOrderNumbers', '', function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_AM_ERROR", 'Error'));
return;
}
$('#div_wonumber').dropdownSource(data);
});
}
$(function () {
setPageTitle(GetTextByKey("P_WORKORDERHISTORY", "Work Order History"), true);
$('#div_wonumber').dropdown([], {
search: true,
valueKey: 'Key',
textKey: 'Value'
});
GetWorkOrderNumbers();
OnRefresh();
$('#startdatetxt').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]);
}
});
$('#enddatetxt').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]);
}
});
$('#searchinputtxt').keydown(searchEnter);
$(window).resize(function () {
$("#divwoh").css("height", $(window).height() - $("#divwoh").offset().top - 4);
//grid_dt && grid_dt.resize();
}).resize();
if (!canExport) {
$('#spExport').hide();
}
});
function searchEnter(e) {
if (e.keyCode == 13 || e.keyCode == 9) {
OnRefresh();
}
}
function OnExport() {
var woid = $('#div_wonumber').dropdownVal();
if (!woid) {
return;
}
var from = $('#startdatetxt').val();
var to = $('#enddatetxt').val();
var searchtxt = "";
window.open("../ExportToFile.aspx?type=wohis&t=" + searchtxt + "&from=" + from + "&to=" + to + "&woid=" + woid);
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div style="min-width: 400px;">
<div class="page_title" data-lgid="P_XXX">Work Order History</div>
<div class="search_bar">
<input type="password" autocomplete="new-password" style="display: none" />
<span data-lgid="P_XXX">Work Order Number:</span>
<div class="dropdown" id="div_wonumber" style="width: 200px"></div>
<span style="margin-left: 5px;" data-lgid="P_FR_BEGINDATE_COLON">Begin Date:&nbsp;</span>
<div>
<input id="startdatetxt" type="text" style="width: 80px; margin-left: 5px;" value="<%=BeginDate %>" autocomplete="off" />
</div>
<span style="margin-left: 5px;" data-lgid="P_FR_ENDDATE_COLON">End Date:&nbsp;</span>
<div>
<input id="enddatetxt" type="text" style="width: 80px; margin-left: 5px;" value="<%=EndDate %>" autocomplete="off" />
</div>
<div style="display: none;">
<input id="searchinputtxt" autocomplete="off" style="width: 100px; margin-left: 5px;" />
</div>
<input class="search" type="button" onclick="OnRefresh();" style="margin-left: 10px;" value="Search" data-lgid="P_FR_SEARCH" />
</div>
<div class="function_title">
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_UM_REFRESH">Refresh</span>
<span id="spExport" class="sbutton iconexport" onclick="OnExport();" data-lgid="P_MR_EXPORTTOEXCEL">Export to Excel</span>
</div>
<div class="clear"></div>
<div id="divwoh" style="overflow: auto;">
<table id="tbwoh" style="min-width: 1250px; table-layout: fixed;">
<thead>
<tr>
<th style="width: 150px;" data-lgid="P_XXX">Date/Time Stamp</th>
<th style="width: 80px;" data-lgid="P_XXX">Update</th>
<th style="width: 120px;" data-lgid="P_XXX">Update Type</th>
<th style="width: 200px;" data-lgid="P_XXX">By</th>
<th style="width: 200px;" data-lgid="P_XXX">Category</th>
<th style="width: 400px;" data-lgid="P_XXX">Detail</th>
<th></th>
</tr>
</thead>
<tbody id="wohlist" style="border: 1px solid #cacaca; overflow: hidden; text-overflow: ellipsis;">
</tbody>
</table>
</div>
<div id="mask_bg" style="display: none;">
<div class="loading c-spin"></div>
</div>
</div>
</asp:Content>

View File

@ -0,0 +1,47 @@
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Maintenance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class WorkOrderHistory : WorkOrderBasePage
{
protected string IID;
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
public string BeginDate = "";
public string EndDate = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
// TODO: sub page
//RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
bool license = SystemParams.HasLicense("WorkOrder");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.WORKORDERHISTORY);
if (!permission)
RedirectToLoginPage();
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
BeginDate = userlocaldate.AddMonths(-1).ToShortDateString();
EndDate = userlocaldate.ToShortDateString();
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,115 @@
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Maintenance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Maintenance_WorkOrderMaintenance : WorkOrderBasePage
{
public string AssetID = "";
public bool InDialog = false;
public bool AllowWorkOrderConfiguration = false;
public bool IsCustomerRecordAllow = false;
public bool HasCustomerRecord = false;
public bool AllowReopenWorkorders = false;
public bool AllowWorkOrderSurveys = false;
protected string MSGWebSocketURL = "";
public string NowDate = "";
public bool WOReadOnly = false;
public bool COMMReadOnly = false;
public bool AllowCommunicate = false;
protected string CID = "";
protected void Page_Load(object sender, EventArgs e)
{
string methodName = Request.Form["MethodName"];
string requesttype = Request.Params["rt"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!string.IsNullOrEmpty(requesttype) && requesttype.ToLower() == "f")
{
ProcessFileRequest();
}
else if (!IsPostBack)
{
CheckLoginSession();
bool license = SystemParams.HasLicense("WorkOrder");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.WORK_ORDER);
if (!permission)
RedirectToLoginPage();
WOReadOnly = CheckReadonly(SystemParams.CompanyID, Feature.WORK_ORDER);
AllowWorkOrderConfiguration = CheckRight(SystemParams.CompanyID, Feature.WORKORDERCONFIGURATION);
IsCustomerRecordAllow = SystemParams.HasLicense("CustomerRecord");
bool crpermission = CheckRight(SystemParams.CompanyID, Feature.CUSTOMER_RECORD);
HasCustomerRecord = IsCustomerRecordAllow && crpermission;
AllowReopenWorkorders = !WOReadOnly && CheckRight(SystemParams.CompanyID, Feature.REOPENWORKORDERS);
AllowWorkOrderSurveys = !WOReadOnly && CheckRight(SystemParams.CompanyID, Feature.WORKORDERSURVEYS);
COMMReadOnly = WOReadOnly || CheckReadonly(SystemParams.CompanyID, Feature.COMMUNICATEWITHCUSTOMER);
AllowCommunicate = CheckRight(SystemParams.CompanyID, Feature.COMMUNICATEWITHCUSTOMER);
AllowCommunicate = IsCustomerRecordAllow && AllowCommunicate;
AssetID = Request.Params["mid"] ?? "";
InDialog = Request.Params["InDialog"] == "1";
MSGWebSocketURL = SystemParams.WebSocketURL + "&msgcodes=500,501,502,503,504,505,506,507";
CID = SystemParams.CompanyID;
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
NowDate = userlocaldate.ToShortDateString();
}
}
public bool CanViewMR
{
get
{
bool license = SystemParams.HasLicense("PreventativeMaintenance");
bool mrlicense = SystemParams.HasLicense("MaintenanceRecord");
bool permission = CheckRight(SystemParams.CompanyID, Feature.PREVENTATIVE_MAINTENANCE);
return !SystemParams.IsDealer && license && mrlicense && permission;
}
}
public bool IsSupperAdmin
{
get
{
var user = GetCurrentUser();
return user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin;
}
}
public bool IsAdmin
{
get
{
var user = GetCurrentUser();
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
return true;
else
return false;
}
}
public bool IsAdvisor
{
get
{
var user = GetCurrentUser();
if (user.ContactType == IronIntel.Contractor.Users.ContactTypes.Advisor)
return true;
else
return false;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,64 @@
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Maintenance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class WorkOrderStatusManagement : WorkOrderBasePage
{
protected string IID;
public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
public bool EmailSubscribe = false;
protected void Page_Load(object sender, EventArgs e)
{
if (!CheckLoginSession())
{
RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
this.Title = PageTitle;
bool license = SystemParams.HasLicense("WorkOrder");
if (!license)
RedirectToLoginPage();
bool permission = CheckRight(SystemParams.CompanyID, Feature.WORK_ORDER);
if (!permission)
RedirectToLoginPage();
}
}
}
public bool IsSupperAdmin
{
get
{
var user = GetCurrentUser();
return user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin;
}
}
public bool IsAdmin
{
get
{
var user = GetCurrentUser();
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
return true;
else
return false;
}
}
}

View File

@ -0,0 +1,113 @@
a.disabled {
cursor: default !important;
color: #ccc;
}
a.disabled:hover {
text-decoration: none;
}
.table_intervals {
width: 100%;
color: #666;
border-collapse: collapse;
table-layout:fixed;
}
.table_intervals thead tr {
background: #f9f9f9;
/*font-weight: bold;*/
}
.table_intervals thead tr:hover { background: #f9f9f9; }
.table_intervals td input {
width: 60px;
border: 1px solid #fff;
}
.table_intervals td input.focused,
.table_intervals td input:hover {
border-color: #666;
}
.table_intervals td input:disabled,
.table_intervals td input:disabled:hover,
.table_intervals tr:hover td input:disabled {
background: #ddd;
color: #ddd;
border-color: #ddd;
}
.table_intervals .editing { display: none; }
.table_intervals .editing input {
width: auto;
cursor: pointer;
background: rgb(249, 189, 117);
margin-left: 6px;
border: none;
padding: 5px 14px;
}
.table_intervals .editing input:hover { background: #d7690E; }
.table_intervals td textarea {
border: 1px solid #fff;
}
.table_intervals td textarea.focused,
.table_intervals td textarea:hover {
border-color: #666;
}
.table_intervals td textarea:disabled,
.table_intervals td textarea:disabled:hover,
.table_intervals tr:textarea td input:disabled {
background: #ddd;
color: #ddd;
border-color: #ddd;
}
.table_intervals .editing textarea {
width: auto;
cursor: pointer;
background: rgb(249, 189, 117);
margin-left: 6px;
border: none;
padding: 5px 14px;
}
.table_intervals .editing textarea:hover { background: #d7690E; }
.maintenance .td_funcs {
padding: 0;
font-weight: normal;
}
.maintenance .td_funcs:last-child {
padding-right: 8px;
}
.maintenance .td_funcs a {
white-space: nowrap;
float: left;
cursor: pointer;
margin-left: 20px;
}
.maintenance .td_funcs a:first-child {
margin-left: 2px;
}
.maintenance .item_name {
margin-left: 24px;
width: 340px;
}
.maintenance .item_type {
width: 100px;
}
.maintenance .item_desc {
max-width: 320px;
}
.maintenance .item_desc,
.maintenance .item_type,
.maintenance .item_name {
overflow: hidden;
text-overflow: ellipsis;
}
.servicedescription {
height:120px;
width:250px;
}
.intervalinput {
width:250px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View 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********************************************//

View 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);
}

File diff suppressed because it is too large Load Diff

47
Site/Maintenance/js/controls.js vendored Normal file
View 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);
});
};

View 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");// + "&nbsp;&nbsp;&nbsp;&nbsp;" + jobsite.Name + "&nbsp;&nbsp;&nbsp;&nbsp;" + "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********************************/
/*****************************************************************************/

View 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'));
}
}
});
}
}

View 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;
}
}

View 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'));
}
}
});
}
}

File diff suppressed because it is too large Load Diff

View 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 ? '&#xe605;' : ''));
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;
};
})();

View 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);
}
});
});
}

View 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)')));
}

View 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('');
}
}

View 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) {
});
}

View 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);
}

View 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: '&nbsp;' }];
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();
}

View 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***********************************//