mesa-fab-approval/Fab2ApprovalSystem/Views/Training/ViewMyTrainingAssignment.cshtml
2023-10-30 17:19:20 +01:00

283 lines
7.8 KiB
Plaintext

@model IEnumerable<Fab2ApprovalSystem.Models.TrainingDocAck>
@{
ViewBag.Title = "ViewMyTrainingAssignment";
Layout = "~/Views/Home/_HomeLayout.cshtml";
}
<h2>Training Assignment</h2>
@{if (ViewBag.IsCompleted == true)
{
<h5 style="color:red;">This assignment is completed.</h5>
} }
<a href="/Training/ViewMyTrainingAssignments" class="btn btn-primary">Back To My Training</a>
@{if (Model.Count() <= 0 && ViewBag.IsCompleted == false)
{
<button onclick="AssignmentReviewButton(@ViewBag.AssignmentID)" class="btn btn-primary">Confirm Training Review</button>
}
}
<style>
tr:nth-child(even) {
background: #CCC
}
tr:nth-child(odd) {
background: #FFF
}
#cover-spin {
position: fixed;
width: 100%;
left: 0;
right: 0;
top: 0;
bottom: 0;
background-color: rgba(255,255,255,0.7);
z-index: 9998;
display: none;
}
#reviewMessage {
position: fixed;
width: 100%;
left: 0;
right: 0;
top: 0;
bottom: 0;
/*background-color: rgba(255,255,255,0.7);*/
z-index: 9999;
display: none;
}
@@-webkit-keyframes spin {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
@@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
#cover-spin::after {
content: '';
display: block;
position: absolute;
left: 48%;
top: 40%;
width: 40px;
height: 40px;
border-style: solid;
border-color: black;
border-top-color: transparent;
border-width: 4px;
border-radius: 50%;
-webkit-animation: spin .8s linear infinite;
animation: spin .8s linear infinite;
}
#reviewMessage p {
display: block;
position: absolute;
left: 28%;
top: 50%;
font-size: 40px;
}
</style>
<div id="cover-spin">
</div>
<div id="reviewMessage">
<p>Please review the downloaded document</p>
</div>
@{ if (Model.Count() > 0){
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.ECNNumber)
</th>
<th>
@Html.DisplayNameFor(model => model.DateReviewed)
</th>
<th>
@Html.DisplayNameFor(model => model.Reviewed)
</th>
<th>
@Html.DisplayNameFor(model => model.FileName)
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@{ViewBag.ECNNumber = item.ECNNumber;
}
@Html.ActionLink(item.ECNNumber.ToString(), "ReadOnly", "ECN", new { issueID = item.ECNNumber }, new { target = "_blank" })
</td>
<td>
@Html.DisplayFor(modelItem => item.DateReviewed)
</td>
@if (item.Reviewed == true)
{
<td>Reviewed</td>
}
else
{
<td>
Not Reviewed
</td>
}
@*<td>
@Html.DisplayFor(modelItem => item.Reviewed)
</td>*@
<td>
@*onclick="documentClick(@item.AttachmentID, @item.ECNNumber, @item.ID, @item.TrainingAssignmentID)">
@Html.DisplayFor(modelItem => item.FileName)*@
@if (ViewBag.IsCompleted == false)
{
<button onclick="documentClick(@item.AttachmentID, @item.ECNNumber, @item.ID, @item.TrainingAssignmentID)" class="btn btn-primary">@item.FileName</button>
}
</td>
<td></td>
</tr>
}
</table>
}}
<div>
@{Html.RenderAction("ECNTrainingView", "ECN", new { IssueID = Convert.ToInt32(ViewBag.ECNNumber) });}
</div>
<div class="modal fade" id="ConfirmReview" tabindex="0" role="dialog" aria-hidden="true" data-backdrop="static">
<div class="modal-dialog modal-lg" style="width:500px;">
<div class="modal-content">
<div class="modal-header" style="background-color: #fce0a3;">
<h3 class="modal-title">Mark As Reviewed</h3>
</div>
<div class="modal-body">
<p>Do you want to mark the document as reviewed?</p>
<input type="button" class="btn" value="Yes" onclick="MarkAsReviewed()" />
</div>
<div class="modal-footer" style="background-color: #fce0a3; ">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var CurrAssignmentID = '';
var CurrId = '';
function documentClick(attachmentID, ecnNumber, trainingDockAckID, assignmentID) {
//window.open('http://messa016ec.infineon.com/ECN/DownloadFile?attachmentID=' + attachmentID + '&ecnNumber=' + ecnNumber, '_blank');
window.open('/ECN/DownloadFile?attachmentID=' + attachmentID + '&ecnNumber=' + ecnNumber, '_blank');
CurrAssignmentID = assignmentID;
CurrId = trainingDockAckID;
$('#cover-spin').show(0);
$('#reviewMessage').show(0);
setTimeout(AcknowledgeScreen, 60000);
//setTimeout(
// () => {
// $('#cover-spin').hide(0);
// $('#reviewMessage').hide(0);
// $("#ConfirmReview").modal('show');
// },
// 60 * 1000
//);
//MarkAsReviewed(assignmentID, trainingDockAckID)
}
function AcknowledgeScreen() {
$('#cover-spin').hide(0);
$('#reviewMessage').hide(0);
$("#ConfirmReview").modal('show');
}
function AssignmentReviewButton(AssignmentID) {
var sendInfo = {
trainingAssignmentID: AssignmentID,
};
$('#cover-spin').show(0);
$.ajax({
type: "POST",
url: "/Training/AcknowledgeReviewNoDocuments",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(sendInfo),
dataType: "json",
success: function (r) {
window.location.reload();
//window.location.reload();
//var json = $.parseJSON(r);
//alert('Success');
//RefreshDocs();
//RefreshDocs();
//RefreshData();
},
error: function (req, status, error) {
alert(error);
$('#cover-spin').hide(0);
}
});
//$("#ConfirmReview").modal('close');
//window.location.reload();
}
function MarkAsReviewed() {
console.log("Starting Review Timer");
//sleep(10000);
//alert(AttachmentId)
var sendInfo = {
trainingAssignmentID: CurrAssignmentID,
trainingDocAckID: CurrId
};
$('#cover-spin').show(0);
$.ajax({
type: "POST",
url: "/Training/AcknowledgeDocument",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(sendInfo),
dataType: "html",
success: function (r) {
window.location.reload();
//window.location.reload();
//var json = $.parseJSON(r);
//alert('Success');
//RefreshDocs();
//RefreshDocs();
//RefreshData();
},
error: function (req, status, error) {
alert(error);
$('#cover-spin').hide(0);
}
});
//$("#ConfirmReview").modal('close');
//console.log("Review Timer Finished");
}
</script>