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

231 lines
8.4 KiB
Plaintext

@model Fab2ApprovalSystem.Models.LTLotTravelerHoldSteps
@Html.HiddenFor(model => model.LTLotID, new { id = "LotID" })
@Html.HiddenFor(model => model.ID, new { id = "ltHoldStepID" })
@Html.HiddenFor(model => model.SWRNumber, new { id = "swrNumber" })
@Html.HiddenFor(model => model.CurrentRevision, new { id = "currentRevision" })
@Html.HiddenFor(model => model.WorkRequestID, new { id = "workRequestID" })
@*@Html.HiddenFor(model => model.currentStep, new { id = "currentStep" })*@
<div class="row">
<div class="col-sm-2">
<div class="control-group">
<label for="BaseFlow">Document Type:</label>
<div class="controls" style="width:200px; font-size: 10px">
<div id="ex" class="k-content">
@(Html.Kendo().DropDownList()
.Name("docType")
.DataTextField("Text")
.DataValueField("Value")
.BindTo(new List<SelectListItem>() {
new SelectListItem() {
Text = "Instructions",
Value = "Instructions"
},
new SelectListItem() {
Text = "Traveler",
Value = "Traveler"
},
new SelectListItem() {
Text = "Other",
Value = "Other"
}
})
.Value("1")
.HtmlAttributes(new { style = "width:100px;" })
)
</div>
</div>
</div>
</div>
<div class="col-sm-10">
<div class="control-group">
@(Html.Kendo().Upload()
.Name("LotTravHoldStepAttachment")
.Async(a => a
.Save("LotTravHoldStepAttachSaveRev", "LotTraveler")
.AutoUpload(true)
)
.ShowFileList(false)
.Events(events => events.Success("SetDocType").Upload("UploadData")
)
)
</div>
</div>
</div>
<!--.Save("AttachSave", "LotTraveler", new { ltHoldStepID = Model.ID, currentRevision = Model.Revision, swrNo = Model.SWRNumber })-->
<div class="row">
@(Html.Kendo().Grid<Fab2ApprovalSystem.Models.LTLotTravAttachment>()
.Name("LTHoldStepAttachments")
.Columns(columns =>
{
columns.Bound(a => a.ID).Visible(false);
columns.Bound(a => a.FileGUID).Visible(false);
columns.Bound(a => a.LTLotTravHoldStepID).Visible(false);
columns.Bound(a => a.FileName).Template(@<text> @Html.ActionLink(@item.FileName.ToString(), null)</text>).Width("100px");
//.ClientTemplate("<a href='" + GlobalVars.AttachmentUrl + "LotTraveler/#=SWRNumber#/Rev#=Revision#/#=FileGUID#.#=FileExtension#' target='_blank'>#=FileName#</a>");
columns.Bound(a => a.DocType);
columns.Bound(a => a.UploadedByName);
columns.Bound(a => a.UploadTime).Format("{0:MM/dd/yy hh:mm:ss}");
columns.Command(c => c.Custom("View").Click("DownloadAttachment")).Width("100px");
})
.Sortable()
.Scrollable()
.HtmlAttributes(new { style = "height:125; width:100%; font-size: 10px" })
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Model(model =>
{
model.Id(p => p.ID);
})
.PageSize(50)
.Read(read => read.Action("GetLTHoldStepAttachments", "LotTraveler", new { ltHoldStepID = Model.ID }))
)
)
</div>
<script type="text/javascript">
var fileData;
function SetDocType(e) {
//alert(newSession);
if (newSession) {
newSession = false;
grid = $("#HoldSteps").data("kendoGrid");
grid.dataSource.read($("#LotID").val());
$("#AddLTHoldStepAttachmentFormRevision").modal('hide');
// update the header and the Revision
var urlString = '/LotTraveler/GetLotTravelerHeader'
$.ajax({
type: "Post",
url: urlString,
type: "GET",
contentType: "application/json; charset=utf-8",
data: { ltLotID: $("#LotID").val() },
success: function (data) {
// update the header and the Revision
//alert(data.LastUpdate);
$("#txtUpdatedBy").val(data.LastUpdatedBy);
$("#txtLastUpdate").val((formatJSONDate(data.LastUpdate)))
$("#RevNumber").text("Fab2 Electronic Lot Traveler - Lot#" + data.LotNumber + " Rev " + data.LotTravCurrentRevision)
$("#RevNumber").css("color", "blue");
var url = "/LotTraveler/GetLotTravRevisions";
$.ajax({
url: url,
type: "GET",
datatype: "json",
data: {
ltLotID: $("#LotID").val()
},
success: function (data) {
$("#Revisions").data("kendoDropDownList").dataSource.data(data);
},
error: function (result) {
alert("Failed " + result);
}
});
},
error: function (result) {
alert("Failed " + result);
}
});
}
else {
var grid = $("#LTHoldStepAttachments").data("kendoGrid");
grid.dataSource.read($("#ltHoldStepID").val());
grid = $("#HoldSteps").data("kendoGrid");
grid.dataSource.read($("#workRequestID").val());
}
}
function UploadData(e) {
fileData = e;
var files = e.files;
$.each(files, function () {
if (!this.extension.toLowerCase().match(/^(.doc|.docx|.ppt|.pptx|.xls|.xlsx|.xlsm|.pdf|.gif|.jpeg|.jpg|.bmp|.png|.txt)$/)) {
alert("Only Word/PowerPoint/Excel/PDF/Image/Text files can be uploaded!")
e.preventDefault();
}
});
e.data = {
// workRequestID: $("#workRequestID").val(),
ltHoldStepID: $("#ltHoldStepID").val(),
currentWRRevision: $("#currentRevision").val(),
swrNo: $("#swrNumber").val(),
docType: $("#docType").data("kendoDropDownList").value(),
revComments: $("#revisionHoldStepAttComments").val()
};
}
function RefreshHoldStepGrid() {
var grid = $("#HoldSteps").data("kendoGrid");
grid.dataSource.read($("#ltHoldStepID").val());
}
@*function RefreshWorkReqAttachmentsGrid() {
var grid = $("#WorkRequestAttachments").data("kendoGrid");
grid.dataSource.read($("@Model.ID").val());
}*@
function DownloadAttachment(e) {
e.preventDefault();
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
var fileGUID = dataItem.FileGUID;
var attachmentID = dataItem.AttachmentID;
window.location = '/LotTraveler/DownloadFile?fileGuid=' + fileGUID + '&swrNumber=' + "@Model.SWRNumber" + "&typeOfDoc=1";
}
//$("#submitHoldStepAttRevComments").on('click', function () {
// $.ajax({
// url: '/LotTraveler/HoldStepAttachSave',
// type: "POST",
// contentType: "application/json; charset=utf-8",
// data: { HoldStepAttachment: fileData, ltHoldStepID: $("#ltHoldStepID").val(), currentRevision: $("#currentRevision").val(), swrNo: $("#swrNumber").val(), docType: $("#docType").data("kendoDropDownList").value() },
// //data: JSON.stringify(fileData),
// success: function (data) {
// $("#WinHoldStepAttRevComments").modal('hide');
// }
// })
//})
</script>