137 lines
4.1 KiB
Plaintext
137 lines
4.1 KiB
Plaintext
|
|
@model Fab2ApprovalSystem.Models.D7PreventiveAction
|
|
|
|
@Html.HiddenFor(model => model.ID, new { id = "d7ID" })
|
|
@Html.HiddenFor(model => model.CANo, new { id = "d7CANo" })
|
|
<div>
|
|
|
|
@(Html.Kendo().Upload()
|
|
.Name("D7PA_Attachemnt")
|
|
.Async(a => a
|
|
.Save("SaveD7PA_Attachemnt", "CorrectiveAction")
|
|
.AutoUpload(true)
|
|
)
|
|
.ShowFileList(false)
|
|
.Events(events => events.Upload("D7UploadData").Success("D7RefreshGrids").Error("D7FileUplaodError")
|
|
)
|
|
|
|
)
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-sm-12">
|
|
|
|
|
|
@(Html.Kendo().Grid<Fab2ApprovalSystem.Models.CA_Attachment>()
|
|
.Name("D7PA_Attachments")
|
|
.Columns(columns =>
|
|
{
|
|
columns.Bound(a => a.ID).Visible(false);
|
|
columns.Bound(a => a.FileGUID).Visible(false);
|
|
columns.Bound(a => a.D5D6CAID).Visible(false);
|
|
columns.Bound(a => a.FileName);
|
|
columns.Bound(a => a.UploadedByName);
|
|
columns.Bound(a => a.UploadDateTime).Format("{0:MM/dd/yy hh:mm:ss}");
|
|
columns.Command(command => command.Custom("View").Click("DownloadCAAttachment"));
|
|
columns.Command(command => command.Custom("Delete").Click("DeleteD7PAAttachment"));
|
|
|
|
})
|
|
|
|
.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("GetD7ItemAttachments", "CorrectiveAction", new { d7PAID = Model.ID }))
|
|
)
|
|
)
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
var fileData;
|
|
|
|
|
|
function D7RefreshGrids(e) {
|
|
var grid = $("#D7PA_Attachments").data("kendoGrid");
|
|
grid.dataSource.read($("#d7ID").val());
|
|
RefreshD7PAGrid();
|
|
}
|
|
|
|
function D7UploadData(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|.slddrw|.sldprt)$/)) {
|
|
alert("Only Word/PowerPoint/Excel/PDF/Image/Text files can be uploaded!")
|
|
e.preventDefault();
|
|
}
|
|
|
|
});
|
|
|
|
|
|
e.data = {
|
|
d7PAID: $("#d7ID").val(),
|
|
caNo: $("#d7CANo").val()
|
|
};
|
|
}
|
|
|
|
|
|
function RefreshD7PAGrid() {
|
|
var grid = $("#D7PreventiveActions").data("kendoGrid");
|
|
grid.dataSource.read($('@Model.CANo').val());
|
|
}
|
|
|
|
|
|
function DeleteD7PAAttachment(e) {
|
|
e.preventDefault();
|
|
if (confirm("Are you sure you want to delete this Attachment?")) {
|
|
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
|
|
var fileName = dataItem.FileGUID;
|
|
var attachmentID = dataItem.ID;
|
|
|
|
$.ajax({
|
|
url: "/CorrectiveAction/DeleteCAAttachment",
|
|
type: "POST",
|
|
datatype: "json",
|
|
data: {
|
|
attachmentID: attachmentID
|
|
},
|
|
success: function (data) {
|
|
|
|
RefreshGrids();
|
|
},
|
|
error: function (result) {
|
|
alert("Failed " + result);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
function D7FileUplaodError(e) {
|
|
if (e.errors) {
|
|
var message = "Errors:\n";
|
|
$.each(e.errors, function (key, value) {
|
|
if ('errors' in value) {
|
|
$.each(value.errors, function () {
|
|
message += this + "\n";
|
|
});
|
|
}
|
|
});
|
|
alert(message);
|
|
}
|
|
|
|
alert("Error");
|
|
}
|
|
|
|
</script>
|