158 lines
5.9 KiB
Plaintext
158 lines
5.9 KiB
Plaintext
@using EnVisage.Code.Extensions
|
|
@using EnVisage.Models.Dashboard
|
|
@using Kendo.Mvc.UI
|
|
|
|
@model string
|
|
|
|
@{
|
|
var teamUrl = Url.Action("Board", "Team");
|
|
var gridName = Model;
|
|
}
|
|
|
|
|
|
@(Html.Kendo().Grid<ForecastResourceAvailabilityGridItem>()
|
|
.Name(Model).AutoBind(false)
|
|
.HtmlAttributes(new { style = "margin-top: 50px; display: none;" })
|
|
.DataSource(ds => ds
|
|
.Custom()
|
|
.Type("aspnetmvc-ajax")
|
|
.ServerPaging(true).ServerAggregates(true).ServerSorting(true).ServerGrouping(true)
|
|
.Transport(transport =>
|
|
{
|
|
transport.Read(read => read.Action("GetResourceAvailability", "ForecastGrid").Type(HttpVerbs.Post).Data("getFilterParams"));
|
|
})
|
|
.Group(groups =>
|
|
{
|
|
groups.Add(product => product.ExpenditureCategory);
|
|
//groups.Add(product => product.TeamName);
|
|
})
|
|
.Aggregates(aggr =>
|
|
{
|
|
aggr.Add(x => x.AvailableHours).Sum();
|
|
aggr.Add(x => x.AllocatedHours).Sum();
|
|
aggr.Add(x => x.NonProjectTimeHours).Sum();
|
|
aggr.Add(x => x.ResourceAvailability).Sum();
|
|
})
|
|
.PageSize(25)
|
|
.Schema(schema =>
|
|
{
|
|
schema.Total("Total");
|
|
schema.Aggregates("Aggregates");
|
|
schema.Data("Data");
|
|
schema.Groups("Groups");
|
|
})
|
|
)
|
|
.Events(events =>
|
|
{
|
|
events.DataBound("onGridDataBound");
|
|
events.ColumnReorder("function(e) { columnReorder(e, '" + gridName + "'); }");
|
|
events.ColumnResize("columnResize");
|
|
events.ColumnShow("function(e) { columnShowHide(e, '" + gridName + "'); }");
|
|
events.ColumnHide("function(e) { columnShowHide(e, '" + gridName + "'); }");
|
|
events.ExcelExport("onExcelExport");
|
|
})
|
|
.Pageable(paging =>
|
|
{
|
|
paging.Enabled(true);
|
|
paging.PageSizes(new[] { 25, 50, 100 });
|
|
})
|
|
.Pageable(paging => { paging.Enabled(true).PageSizes(new[] { 25, 50, 100 }); })
|
|
.Resizable(resize => resize.Columns(true))
|
|
.Sortable(sorting => sorting.Enabled(true))
|
|
.Scrollable(scroll => scroll.Enabled(true).Height(800))
|
|
.Reorderable(reorder => reorder.Columns(true))
|
|
.Columns(columns =>
|
|
{
|
|
columns.Bound(x => x.ExpenditureCategory).Width(200)
|
|
.Title("Expenditure Category")
|
|
.ClientGroupFooterTemplate("#=getRaReportGroupSummaryText(data, '" + gridName + "', 'ExpenditureCategory')#")
|
|
.ClientFooterTemplate("#=getGroupSummaryText('Summary', '" + gridName + "', 'ExpenditureCategory')#");
|
|
|
|
columns.Bound(x => x.TeamName).Width(200)
|
|
.Title("Team Name")
|
|
.ClientTemplate("<a href='" + teamUrl + "?teamId=#=TeamId#'>#=TeamName#</a")
|
|
.ClientGroupFooterTemplate("#=getRaReportGroupSummaryText(data, '" + gridName + "', 'TeamName')#")
|
|
.ClientFooterTemplate("#=getGroupSummaryText('Summary', '" + gridName + "', 'TeamName')#");
|
|
|
|
columns.Bound(x => x.FirstName).Width(200).Title("First Name")
|
|
.ClientGroupFooterTemplate("#=getRaReportGroupSummaryText(data, '" + gridName + "', 'FirstName')#")
|
|
.ClientFooterTemplate("#=getGroupSummaryText('Summary', '" + gridName + "', 'FirstName')#");
|
|
|
|
columns.Bound(x => x.LastName).Width(200).Title("Last Name")
|
|
.ClientGroupFooterTemplate("#=getRaReportGroupSummaryText(data, '" + gridName + "', 'LastName')#")
|
|
.ClientFooterTemplate("#=getGroupSummaryText('Summary', '" + gridName + "', 'LastName')#");
|
|
|
|
columns.Bound(x => x.AvailableHours)
|
|
.Width(200)
|
|
.Title("Available Hours")
|
|
.Groupable(false)
|
|
.Format("{0:n2}")
|
|
.ClientGroupFooterTemplate("#=getHoursSummaryValue(sum)#")
|
|
.ClientFooterTemplate("#=getHoursSummaryValue(sum)#");
|
|
columns.Bound(x => x.AllocatedHours)
|
|
.Width(200)
|
|
.Title("Allocated Hours")
|
|
.Groupable(false)
|
|
.Format("{0:n2}")
|
|
.ClientGroupFooterTemplate("#=getHoursSummaryValue(sum)#")
|
|
.ClientFooterTemplate("#=getHoursSummaryValue(sum)#");
|
|
columns.Bound(x => x.NonProjectTimeHours)
|
|
.Width(200)
|
|
.Title("Non Project Time Hours")
|
|
.Groupable(false)
|
|
.Format("{0:n2}")
|
|
.ClientGroupFooterTemplate("#=getHoursSummaryValue(sum)#")
|
|
.ClientFooterTemplate("#=getHoursSummaryValue(sum)#");
|
|
columns.Bound(x => x.ResourceAvailability)
|
|
.Width(200)
|
|
.Title("Resource Availability")
|
|
.Groupable(false)
|
|
.Format("{0:n2}")
|
|
.ClientGroupFooterTemplate("#=getHoursSummaryValue(sum)#")
|
|
.ClientFooterTemplate("#=getHoursSummaryValue(sum)#");
|
|
})
|
|
.NoRecords("No matching records found for the given search criteria")
|
|
.Pdf(pdf => pdf
|
|
.AllPages()
|
|
.ForceProxy(true)
|
|
.RepeatHeaders()
|
|
.FileName(Model + "Report.pdf")
|
|
.ProxyURL(Url.Action("ExportResourceAvailability", "ForecastGrid"))
|
|
)
|
|
.Excel(excel => excel
|
|
.AllPages(true)
|
|
.ForceProxy(true)
|
|
.FileName(Model + "Report.xlsx")
|
|
.ProxyURL(Url.Action("ExportResourceAvailability", "ForecastGrid"))
|
|
)
|
|
)
|
|
|
|
<script>
|
|
function getRaReportGroupSummaryText(data, gridName, columnName) {
|
|
// SA. Method returns text to display in Group summary field cell.
|
|
// Returns "text", if field "columnName" is the first column in the grid, otherwise returns empty string
|
|
var result = "";
|
|
var grid = $("#" + gridName).data("kendoGrid");
|
|
|
|
if (columnName && grid && grid.columns) {
|
|
var visibleIndex = -1;
|
|
|
|
for (var index = 0; index < grid.columns.length; index++) {
|
|
if (!grid.columns[index].hidden)
|
|
visibleIndex++;
|
|
|
|
if ((grid.columns[index].field == columnName) && (visibleIndex == 0)) {
|
|
var text = 'Summary ' + data.parent().value;
|
|
result = '<span title="' + htmlEncode(text) + '">' + text + '</span>';
|
|
}
|
|
|
|
if (visibleIndex >= 0)
|
|
break;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
</script>
|
|
|