mesa-fab-approval/Fab2ApprovalSystem/Views/Home/SpecialWorkRequestList.cshtml
Jonathan Ouellette 580e90f6a2 initial add
2022-09-27 14:10:30 -07:00

441 lines
16 KiB
Plaintext

@{
Layout = "_HomeLayout.cshtml";
}
@{
ViewBag.Title = "Special Work Request";
}
@*<h2>Work Request / LotTravelers</h2>*@
<body onload="LoadSWRFilter();" onunload="SaveSWRFilter()">
<div class="panel panel-default">
<div class="panel-heading">
<table style="width: 100%">
<tr>
<td align="center" style="font-size: 15px; font-weight: bold; color: crimson">
Work Requests/Lot Travelers
</td>
</tr>
<tr>
<td align="center">
<label id="headerID" style="font-size: small; font-weight: bold; color: blue; font-family: 'Times New Roman'">
</label>
</td>
</tr>
</table>
</div>
<div id="specialRequestdiv" class="k-content" style="font-size: 11px">
@(Html.Kendo().Grid<Fab2ApprovalSystem.ViewModels.IssuesViewModel>()
.Name("WorkRequests")
.Columns(columns =>
{
columns.Bound(l => l.IssueID).Template(@<text> @Html.ActionLink(@item.IssueID.ToString(), null)</text>)
.ClientTemplate("<a href='/#=DocumentType#/Edit?IssueID=#=DocID#'>#=IssueID#</a>");
columns.Bound(l => l.DocumentType);
columns.Bound(l => l.SubDoc);
columns.Bound(l => l.Originator);
columns.Bound(l => l.IssueDate).Format("{0:MM/dd/yy hh:mm:ss}");
columns.Bound(l => l.Title);
columns.Bound(l => l.LotNos);
columns.Bound(l => l.PendingApprovers).HtmlAttributes(new { style = "font-weight: bold; color: red;" }).Width("350px");
columns.Bound(l => l.SubmitedDate).Format("{0:MM/dd/yy hh:mm:ss}");
columns.Bound(l => l.CloseDate).Format("{0:MM/dd/yy hh:mm:ss}");
})
.Events(e => e.DataBound("onWorkRequestsDB"))
.ClientDetailTemplateId("template")
.Selectable(selectable => selectable.Mode(GridSelectionMode.Single).Type(GridSelectionType.Row))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.HtmlAttributes(new { style = "height:700px; width:100%; font-size: 11px" })
.Scrollable()
.Sortable()
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators => operators
.ForString(str => str
.Clear()
.Contains("Contains")
.DoesNotContain("Does not contain")
.StartsWith("Starts with")
.EndsWith("Ends with")
.IsEqualTo("Is equal to")
.IsNotEqualTo("Is not equal to ")
)
)
)
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model =>
{
model.Id(p => p.IssueID);
//model.Field(p => p.TotalCost).Editable(false);
})
.PageSize(50)
.Read(read => read.Action("GetWorkRequests", "Home"))
.Destroy(destroy => destroy.Action("DeleteItem", "Home"))
)
)
</div>
</div>
</body>
<script id="template" type="text/kendo-tmpl">
@(Html.Kendo().Grid<Fab2ApprovalSystem.Models.LTLot>()
.Name("Lots_#=IssueID#")
.Columns(columns =>
{
columns.Bound(a => a.ID).Visible(false);
columns.Bound(a => a.WorkRequestID).Visible(false);
columns.Bound(a => a.LotNumber).Width("50px"); ;
columns.Bound(a => a.WIPPartNumber).Width("50px"); ;
columns.Bound(a => a.WaferQty).Width("50px"); ;
columns.Bound(a => a.PartDescription).Width("150px"); ;
columns.Bound(a => a.Process).Width("50px"); ;
columns.Bound(a => a.Location).Width("50px"); ;
columns.Bound(a => a.Operation).Width("50px"); ;
columns.Bound(a => a.LotStatus).Width("25px"); ;
columns.Bound(a => a.LotTravelerCurrentRevision).Width("50px");
columns.Bound(a => a.TravelerStatus).Width("50px");
columns.Bound(a => a.UploadedByName).Width("50px");
@*columns.Bound(a => a.ID).Template(@<text> @Html.ActionLink(@item.LotNumber.ToString(), null)</text>)
.ClientTemplate("<a href='http://10.72.100.74/user/wsr2/wsr_lot.php?lot=\\#=LotNumber\\#' target='_blank'>View</a>").Title("History").Width("50px");
columns.Bound(p => p.ButtonAttrib).ClientTemplate("\\#=buildUpdateCreateButtons(ButtonAttrib)\\#").Width("50px").Title("");
columns.Bound(p => p.ButtonAttrib).ClientTemplate("\\#=buildUpdateDeleteExecuteButtons(ButtonAttrib)\\#").Width("50px").Title("");*@
})
.Sortable()
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators => operators
.ForString(str => str
.Clear()
.Contains("Contains")
.DoesNotContain("Does not contain")
.StartsWith("Starts with")
.EndsWith("Ends with")
.IsEqualTo("Is equal to")
.IsNotEqualTo("Is not equal to ")
)
)
)
.Scrollable()
.HtmlAttributes(new { style = "height:200px; width:100%; font-size: 10px" })
.DataSource(dataSource => dataSource
.Ajax()
//.Batch(false)
.ServerOperation(false)
.Model(model =>
{
model.Id(p => p.ID);
})
.PageSize(20)
.Read(read => read.Action("GetLotList", "Home", new { workRequestID = "#=IssueID#" }))
)
.Resizable(resize => resize.Columns(true))
.ToClientTemplate()
)
</script>
<script type="text/javascript">
function buildUpdateCreateButtons(data) {
//alert(approvalid + ' ');
var ltLotID;
var workRequestID;
var travelerGenerated;
var temp = data.split('~');
travelerGenerated = temp[0];
ltLotID = temp[1];
workRequestID = temp[2];
//alert(data);
var template = "";
if (travelerGenerated == 'True') {
template += '<input type="button" value="Update Traveler" class="btn btn-warning btn-xs" id="UpdateTravlerID" onclick="DisplayLotTravlerForUpdate(\'' + ltLotID + '\')" style="font-size: 10px;"/>';
}
else {
template += '<input type="button" value="Create Traveler" class="btn btn-warning btn-xs" id="CreateTravelerID" onclick="CreateTraveler(\'' + ltLotID + '\', \'' + workRequestID + '\')" style="font-size: 10px"/>';
}
//alert(template);
return template;
}
function buildUpdateDeleteExecuteButtons(data) {
//alert(approvalid + ' ');
var ltLotID;
var workRequestID;
var travelerGenerated;
var temp = data.split('~');
travelerGenerated = temp[0];
ltLotID = temp[1];
workRequestID = temp[2];
var template = "";
if (travelerGenerated == 'True') {
template += '<input type="button" value="Execute Traveler" class="btn btn-warning btn-xs" id="ExecTravelerID" onclick="DisplayLotTravlerForExecute(\'' + ltLotID + '\')" style="font-size: 10px"/>';
}
else {
template += '<input type="button" value="Delete Lot" class="btn btn-warning btn-xs" id="DeleteLotID" onclick="DeleteLot(\'' + ltLotID + '\')" style="font-size: 10px"/>';
}
return template;
}
function DisplayLotTravlerForUpdate(ltLotID) {
$.ajax({
url: "/LotTraveler/DisplayLotTraveler",
type: "GET",
datatype: "json",
contentType: "application/json; charset=utf-8",
data: {
ltLotID: ltLotID
},
success: function (data) {
if (data == 'Update') {
var url = '@Url.Action("LotTravelerUpdate", "LotTraveler", new { ltLotID = "__id__" })';
url = url.replace('amp;', '');
window.location.href = url.replace('__id__', ltLotID);
}
else {
var url = '@Url.Action("LotTravelerReadonly", "LotTraveler", new { ltLotID = "__id__", revisionNumber = "__revID__" })';
var temp = data.split('~');
url = url.replace('__revID__', temp[1])
url = url.replace('amp;', '');
window.location.href = url.replace('__id__', ltLotID);
}
},
error: function (result) {
alert("Failed " + result);
}
});
}
function DisplayLotTravlerForExecute(ltLotID) {
@*var url = '@Url.Action("LotTravelerExecute", "LotTraveler", new { ltLotID = "__id__" })';
window.location.href = url.replace('__id__', ltLotID);*@
$.ajax({
url: "/LotTraveler/DisplayLotTravelerForExecute",
type: "GET",
datatype: "json",
contentType: "application/json; charset=utf-8",
data: {
ltLotID: ltLotID
},
success: function (data) {
if (data == 'Execute') {
var url = '@Url.Action("LotTravelerExecute", "LotTraveler", new { ltLotID = "__id__" })';
url = url.replace('amp;', '');
window.location.href = url.replace('__id__', ltLotID);
}
else {
var url = '@Url.Action("LotTravelerReadonly", "LotTraveler", new { ltLotID = "__id__", revisionNumber = "__revID__" })';
var temp = data.split('~');
url = url.replace('__revID__', temp[1])
url = url.replace('amp;', '');
window.location.href = url.replace('__id__', ltLotID);
}
},
error: function (result) {
alert("Failed " + result);
}
});
}
function CreateTraveler(ltLotID, workRequestID) {
$.ajax({
url: "/LotTraveler/CreateTaveler",
type: "GET",
datatype: "json",
contentType: "application/json; charset=utf-8",
data: {
ltLotID: ltLotID,
workRequestID: workRequestID
},
success: function (data) {
var grid = $("#Lots").data("kendoGrid");
grid.dataSource.read(workRequestID);
alert("Lot Traveler Created!")
},
error: function (result) {
alert("Failed " + result);
}
});
}
function DeleteLot(ltLotID) {
if (confirm("Are you sure you want to proceed with the DELETE operation")) {
$.ajax({
url: "/LotTraveler/DeleteLot",
type: "GET",
datatype: "json",
contentType: "application/json; charset=utf-8",
data: {
ltLotID: ltLotID
},
success: function () {
var grid = $("#Lots").data("kendoGrid");
grid.dataSource.read(workRequestID);
alert("Lot Deleted")
},
error: function (result) {
alert("Failed " + result);
}
});
}
}
function LoadSWRFilter() {
//alert("load");
var grid = $("#WorkRequests").data("kendoGrid");
var dataSource = grid.dataSource;
$.ajax({
url: "/Home/LoadSWRFilter",
success: function (state) {
//alert(state);
state = JSON.parse(state);
var options = grid.options;
//options.dataSource.page = state.page;
//options.dataSource.pageSize = state.pageSize;
//options.dataSource.sort = state.sort;
options.dataSource.filter = state.filter;
//options.dataSource.group = state.group;
displaySWRfilter(state.filter);
grid.destroy();
$("#WorkRequests")
.empty()
.kendoGrid(options);
},
erro: function (result) {
alert("Failed")
}
});
}
function SaveSWRFilter() {
// alert("save");
var grid = $("#WorkRequests").data("kendoGrid");
var dataSource = grid.dataSource;
var state = {
//page: dataSource.page(),
//pageSize: dataSource.pageSize(),
//sort: dataSource.sort(),
filter: dataSource.filter()
//group: dataSource.group()
};
var str = JSON.stringify(state);
$.ajax({
url: "/Home/SaveSWRFilter",
data: {
data: JSON.stringify(state)
}
});
}
function displaySWRfilter(filter) {
var currentFilter = filter; // get current filter
// create HTML representation of the filter (this implementation works only for simple cases)
var filterHtml = "";
if (currentFilter != null) {
currentFilter.filters.forEach(function (filter, index) {
filterHtml += "[" + filter.field + " " +
filter.operator + " " +
"'" + filter.value + "'] ";
if (currentFilter.filters.length > 1 && index !== currentFilter.filters.length - 1) {
filterHtml += " " + currentFilter.logic + " ";
}
});
// display it somewhere
$("#filter").html(filterHtml);
if (filterHtml != '') {
$("#headerID").text(" Filter = " + filterHtml)
$("#headerID").css("color", "blue");
}
else {
$("#headerID").text("");
}
}
}
function onWorkRequestsDB(e) {
var grid = $("#WorkRequests").data("kendoGrid");
var dataSource = grid.dataSource;
var state = {
//page: dataSource.page(),
//pageSize: dataSource.pageSize(),
//sort: dataSource.sort(),
filter: dataSource.filter()
}
displaySWRfilter(dataSource.filter());
}
</script>