2025-05-22 13:35:27 -07:00

687 lines
28 KiB
Plaintext

@using Microsoft.AspNet.Identity
@model Fab2ApprovalSystem.Models.LotDisposition
@{
ViewBag.Title = "Home Page";
}
<link rel="stylesheet" href="/Content/kendo/kendo.blueopal.min.css" />
<link rel="stylesheet" href="~/Content/kendogridcustom.css" />
<style>
.red {
color: red;
}
.hide {
visibility: hidden;
}
.hideControl {
display: none;
}
</style>
<nav class="navbar navbar-default" role="navigation" style="font-size: 11px">
<div class="container-fluid">
<!-- Collect the nav links, forms, and other content for toggling -->
<ul class="nav navbar-nav" id="myTab">
<li><a href=@Url.Action("Index", "Home", new {tabName = "MyTasks"})>My Tasks</a></li>
<li><a href=@Url.Action("Index", "Home", new { tabName = "AllTasks" })>All Documents</a></li>
@*<li><a href=@Url.Action("ViewMyTrainingAssignments", "Training", new { userID = GlobalVars.GetUserId(Session) })>My Training</a></li>*@
@*<li><a href=@Url.Action("SpecialWorkRequestList", "Home", new { tabName = "AllTasks" })>Special Work Requests</a></li>*@
@*<li><a href="file:////temirwfp001.irworld.irf.com/UserData/QA/CommonRO/Projects/AVI Tool/">AVI Tool</a></li>*@
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Create New<b class="caret"></b></a>
<ul class="dropdown-menu" style="font-size: 11px">
<li><a href=@Url.Action("Create", "LotDisposition")>Lot Dispostion</a></li>
<li><a href=@Url.Action("Create", "MRB")>MRB</a></li>
<li><a href=@Url.Action("Create", "ECN")>ECN</a></li>
@*<li><a href=@Url.Action("CreateWorkRequest", "LotTraveler")>Create Special Work Request</a></li>*@
@*<li><a href="#">Another Doc</a></li>*@
</ul>
</li>
</ul>
<form class="navbar-form navbar-right" role="search">
@*<div class="form-group">
<input type="text" class="form-control" placeholder="Search" style="font-size: 11px">
</div>*@
@if (!GlobalVars.IsOOO(Session))
{
<button class="btn btn-default btn-primary" data-toggle="modal" id="OOO">Out Of Office</button>
}
else
{
<button class="btn btn-default btn-warning" id="OOOExpire">Expire OOO Status</button>
}
@*<button type="submit" class="btn btn-primary" style="font-size: 11px">Submit</button>*@
</form>
<!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
@if (ViewBag.ActiveTabName == "MyTasks")
{
<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">
My Tasks
</td>
</tr>
</table>
</div>
<div id="mytasklistdiv" class="k-content" style="font-size: 11px">
@(Html.Kendo().Grid<Fab2ApprovalSystem.ViewModels.IssuesViewModel>()
.Name("mytasklist")
.Columns(columns =>
{
//columns.Bound(l => l.IssueID);
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;" });
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}");
columns.Bound(l => l.ItemStatus);
columns.Command(command => command.Custom("Re-Assign").Click("showReAssignRole")).Width("100px");
})
.Selectable(selectable => selectable.Mode(GridSelectionMode.Single).Type(GridSelectionType.Row))
.HtmlAttributes(new { style = "height: 700px;" })
.Scrollable()
.Groupable()
.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()
.PageSize(50)
.Read(read => read.Action("GetTaskList", "Home")))
.ClientRowTemplate(" <tr class=#:ItemStatus == 2? 'red':'white'# data-uid='#= uid #'>" +
"<td> <a href='/#=DocumentType#/Edit?IssueID=#=DocID#'>#=IssueID#</a></td>" +
"<td>#: DocumentType #</td>" +
"<td>#: SubDoc #</td>" +
"<td>#:Originator #</td>" +
"<td>#: IssueDate #</td>" +
"<td>#:Title #</td>" +
"<td>#: LotNos #</td>" +
"<td>#:PendingApprovers #</td>" +
"<td>#:SubmitedDate #</td>" +
"<td>#: CloseDate #</td> " +
"<td>#: Item Status </td> " +
"<td><button class='btn btn-warning btn-xs' id='Delegate' name='Refresh' onclick='showReAssignRole(&quot;#=PendingApprovers#&quot;,&quot;#=CloseDate#&quot;,&quot;#=DocID#&quot;, &quot;#=DocumentType#&quot;,&quot;#=SubmitedDate#&quot;);'>Delegate</buton></td>" +
"</tr>"
)
)
</div>
</div>
}
<input type="hidden" id="currentTab" value="@ViewBag.ActiveTabName" />
@if (ViewBag.ActiveTabName == "AllTasks")
{
<div class="panel panel-default">
<div class="panel-heading">
<table style="width: 100%">
@*<tr>
<td style="font-size: 12px; font-weight: bold; color: royalblue">
<div class="checkbox">
<label>
<input type="checkbox" id="IncludeAllDocuments"> Include Closed Documents
</label>
</div>
</td>
</tr>*@
<tr>
<td align="center" style="font-size: 15px; font-weight: bold; color: crimson">
All Documents
</td>
</tr>
</table>
</div>
<div id="alltasklistdiv" class="k-content" style="font-size: 11px;">
@if (GlobalVars.IsAdmin(Session))
{
@(Html.Kendo().Grid<Fab2ApprovalSystem.ViewModels.IssuesViewModel>()
.Name("alltasklist")
.Columns(columns =>
{
//columns.Bound(l => l.IssueID);
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;" });
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}");
columns.Template(t => { }).HeaderTemplate("").ClientTemplate(@"
<a href='javascript: void(0)' class='abutton delete' onclick='deleteRow(this)' title='button delete'>button delete</a>");
//columns.Command(command => command.Destroy());
})
.Selectable(selectable => selectable.Mode(GridSelectionMode.Single).Type(GridSelectionType.Row))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.HtmlAttributes(new { style = "height: 700px;" })
.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("GetDocuments", "Home"))
.Destroy(destroy => destroy.Action("DeleteItem", "Home"))
)
)
}
else
{
@(Html.Kendo().Grid<Fab2ApprovalSystem.ViewModels.IssuesViewModel>()
.Name("alltasklist")
.Columns(columns =>
{
//columns.Bound(l => l.IssueID);
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;" });
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}");
})
.Selectable(selectable => selectable.Mode(GridSelectionMode.Single).Type(GridSelectionType.Row))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.HtmlAttributes(new { style = "height: 700px;" })
.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("GetDocuments", "Home"))
.Destroy(destroy => destroy.Action("DeleteItem", "Home"))
)
)
}
</div>
</div>
}
<div class="modal fade" id="OOODialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">Out Of Office for user: @User.Identity.GetUserName()</h4>
</div>
<div class="modal-body">
<div class="row hideControl" id="DelegateLabel">
<div class="col-sm-12">
<div class="control-group">
<div class="controls">
<div class="controls">
<label for="CurrentUser">Delegate To:</label>
</div>
</div>
</div>
</div>
</div>
<div class="row hideControl" id="DelegateControl">
<div class="col-sm-12">
<div class="control-group">
<div class="controls">
<div class="controls">
@(Html.Kendo().DropDownList()
.Name("DelegateTo")
.HtmlAttributes(new { style = "width: 250px" })
.DataTextField("FullName")
.DataValueField("UserID")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetAllUserList", "Admin");
});
})
)
</div>
</div>
</div>
</div>
</div>
<br />
<div class="row">
<div class="col-sm-6">
<div class="control-group">
<div class="controls">
<label for="CurrentUser">Start Date:</label>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="control-group">
<div class="controls">
<div class="controls">
<label for="CurrentUser">End Date:</label>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="control-group">
<div class="controls">
@(Html.Kendo().DatePicker()
.Name("txtStartDate")
//.Value()
)
</div>
</div>
</div>
@*<div class="col-sm-6">
<div class="control-group">
<div class="controls">
<input type="text" id="test"/>
</div>
</div>
</div>*@
<div class="col-sm-6">
<div class="control-group">
<div class="controls">
@(Html.Kendo().DatePicker()
.Name("txtEndDate")
//.Value()
)
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="SaveOOOInfo">Save</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="ReAssignApproval" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">Re-Assign for Approval From: <label class="bg-danger" id="ReAssignApproverFromLabel">Me</label></h4>
</div>
<div class="modal-body">
<div class="control-group">
<div class="controls">
<h4 class="modal-title" id="myModalLabel">Re-Assign for Approval to:</h4>
<div id='lstReAssignApproval'>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="ConfirmReAssignment">Confirm Re-assignment</button>
</div>
</div>
</div>
</div>
<script>
var issueID="";
var docType = "";
var submitdate = "";
var userName = '@GlobalVars.GetUserName(Session)';
$(document).ready(function () {
})
@*$("#mytasklist").on("dblclick", "tr.k-state-selected", function (e) {
var grid = $("#mytasklist").data("kendoGrid");
var row = e.currentTarget;
var issueID = row.cells[0].innerText; //
var url = '@Url.Action("Edit", "LotDisposition", new { issueID = "__id__" })';
window.location.href = url.replace('__id__', issueID);
})
$("#alltasklist").on("dblclick", "tr.k-state-selected", function (e) {
var grid = $("#mytalltasklistasklist").data("kendoGrid");
var row = e.currentTarget;
var issueID = row.cells[0].innerText; //
var url = '@Url.Action("Edit", "LotDisposition", new { issueID = "__id__" })';
window.location.href = url.replace('__id__', issueID);
})*@
var userid = @GlobalVars.GetUserId(Session);
$("#IncludeAllDocuments").on("click", function () {
alert("clicked");
})
$('#OOO').on('click', function () {
$("#OOODialog").modal('show');
return false;
})
$('#OOOExpire').on('click', function () {
//alert('in');
var tab = $('#currentTab').val();
var urlString = '@Url.Action("ExpireOOOStatus", "Home")'; // '/Home/ExpireOOOStatus';
if (confirm('Are you sure you want to expire the OOO status')) {
$.ajax({
type: "Post",
url: urlString,
data: {
tab: tab
},
success: function (result) {
var url = '@Url.Action("Index", "Home", new { tabName = "rep" })';
window.location.href(url.replace("rep", tab));
},
error: function (result) {
alert("Failed " + result.responseText);
}
});
}
return false;
})
$('#SaveOOOInfo').on('click', function () {
var tab = $('#currentTab').val();
var bfound = false;
if (userid == $("#DelegateTo").data("kendoDropDownList").value()) {
alert('The OOO person cannot be same as the delegate to person');
return false;
}
var fullDate = new Date()
//convert month to 2 digits
var twoDigitMonth = ((fullDate.getMonth().length + 1) === 1) ? (fullDate.getMonth() + 1) : '0' + (fullDate.getMonth() + 1);
var tempCurrentDate = twoDigitMonth + "/" + fullDate.getDate() + "/" + fullDate.getFullYear();
var arrCurrDate = tempCurrentDate.split('/');
var currentDate = new Date(arrCurrDate[2], arrCurrDate[0] - 1, arrCurrDate[1]);
if (!$("#txtStartDate").val() || !$("#txtEndDate").val()) {
alert('Start or the End Date cannot be blank');
return false;
}
var stDateEntered = $("#txtStartDate").val();
var arrStDate = stDateEntered.split('/');
var stDate = new Date(arrStDate[2], arrStDate[0] - 1, arrStDate[1]);
var endDateEntered = $("#txtEndDate").val();
var arrEndDate = endDateEntered.split('/');
var endDate = new Date(arrEndDate[2], arrEndDate[0] - 1, arrEndDate[1]);
if (stDate < currentDate) {
alert("Start Date should be greater than or equal the Current Date ");
return false;
}
if (endDate <= stDate) {
alert("The End Date should be greater than the Start Date ");
return false;
}
$("#OOODialog").modal('hide');
//var urlString = '/Home/SetOOOStatus';
var urlString = '@Url.Action("SetOOOStatus", "Home")';
$.ajax({
type: "Post",
url: urlString,
data: {
//oooUserID: userids,
delegatedTo: delegate,
startDate: $("#txtStartDate").val(),
endDate: $("#txtEndDate").val(),
tab: tab
},
success: function (result) {
if (result == "9") {
alert('The user which you selected for Delegation has already been assigned to another user for Delegation\n Please select a different user for Delgation')
}
else {
var url = '@Url.Action("Index", "Home", new { tabName = "rep" })';
window.location.href(url.replace("rep", tab));
}
},
error: function (result) {
alert("Failed " + result.responseText);
}
});
return false;
});
function deleteRow(element) {
grid = $("#alltasklist").data("kendoGrid");
grid.removeRow($(element).closest("tr"));
//grid.removeRow($(element));
}
function showReAssignRole(_pendingApprovers, _closeDate, _issueID, _docType, _submitDate) {
//alert(_closeDate);;
//alert(_pendingApprovers);
if (_pendingApprovers.indexOf(userName) == -1)
{
alert("You are not one of the approvers for this document");
return;
}
if (_submitDate == 'null')
{
alert("Cannot delegate the document as it has not been submitted yet");
return;
}
if (_closeDate != 'null') {
alert("Cannot delegate as the approval loop has already been closed");
return;
}
issueID = _issueID;
docType = _docType;
submitdate = _submitDate;
$('#ReAssignApproverFromLabel').text(userName);
// var searchText = ($("#txtSearch").val());
var url = "/Home/GetAllUsersList";
var source =
{
datatype: "json",
datafields: [
{ name: 'UserID' },
{ name: 'FullName' }
],
id: 'id',
url: url,
};
var dataAdapter = new $.jqx.dataAdapter(source);
// Create a jqxListBox
$("#lstReAssignApproval").jqxListBox({
multipleextended: false, theme: "arctic", source: dataAdapter, displayMember: "FullName", valueMember: "UserID", width: 200, height: 250
});
$("#ReAssignApproval").modal('show');
//alert(dataItem.FullName);
}
$('#ConfirmReAssignment').on('click', function () {
// get selected items.
var bfound = false;
var userids;
var itemsToAdd = $('#lstReAssignApproval').jqxListBox('getSelectedItems');
if (itemsToAdd.length > 0) {
for (var i = 0; i < itemsToAdd.length; i++) {
if (itemsToAdd[i].label != undefined) {
var tempvalue = itemsToAdd[i].value;
var templabel = itemsToAdd[i].label;
if (userids == null)
userids = tempvalue;
else
userids += "~" + tempvalue;
}
};
//
ReAssignApproval(userids);
}
$("#ReAssignApproval").modal('hide');
return false;
});
var ReAssignApproval = function (userids) {
var urlString = '/Home/DelegateDocumentApproval';
$.ajax({
type: "Post",
url: urlString,
data: {
issueID: issueID,
delegateTo: userids,
ecnTypeString: docType
},
success: function (result) {
var grid = $("#mytasklist").data("kendoGrid");
grid.dataSource.read();
}
});
};
</script>