<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Project.Master" Inherits="System.Web.Mvc.ViewPage<AdministratorConsole.Models.ProjectController.MainViewModel>" %>

<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="server">
    <% Html.DevExpress().RenderScripts(Page,new Script { ExtensionSuite = ExtensionSuite.Editors }); %>
    <% Html.DevExpress().RenderStyleSheets(Page,new StyleSheet { ExtensionSuite = ExtensionSuite.Editors, Theme = "Youthful" }); %>
    <script language="javascript" type="text/javascript">
        function loadProjectDetail() {
            <% if (ProjectTypeHelper.GetIsRevitServerProject(Model.CurrentProject.RevitServerVersion)) { %>
                var getURL = '<%= Url.Action("ProjectMainDetail", "RevitServer") %>';
            <% } else { %>
                var getURL = '<%= Url.Action("ProjectMainDetail", Model.CurrentProject.RevitServerVersion) %>';
            <% } %>

            $.ajax({
                type: 'GET',
                url: getURL,
                data: {
                    projectId: '<%= Model.CurrentProject.ExternalId %>'
                },
                cache: false,
                success: function (response) {
                    $('#project-detail-container').html(response);
                }
            });
        }

        function reportModelEvent(id) {
            $.ajax({
                type: 'GET',
                url: '<%=Url.Action("ModelEvents")%>',
                data: {
                    id: id
                },
                cache: false,
                success: function (response) {
                    $("#modal-overlay").html(response);
                },
                complete: function () {
                    showModelDialog();

                    $("#model").focus();
                }
            });
        }

        window.onload = function () {
            loadProjectDetail();
        };
    </script>
    <div id="banner-space">
        <div id="banner-detail-container">
            <div class="left-floating-panel">
	            <div id="project-title"><span><%= Html.Encode(Model.CurrentProject.Name) %></span><span id="project-number"><%= Html.Encode(Model.CurrentProject.Number) %></span></div>
                <div id="project-database-export"><b>Last Database Export:</b> <% if (Model.CurrentProject.LastDatabaseExport.HasValue)
                                                                                  { %><%= DateTimeHelper.ToString(Model.CurrentProject.LastDatabaseExport.Value) %><% } else { %>No Exports<% } %></div>
	        </div>
            <% if (Model.ProjectHome.CheckEngine) { %><div class="left-floating-panel"><a href="<%= Url.Action("Index/" + Model.CurrentProject.ExternalId, "ModelMetrics") %>"><img id="check-engine-icon" src="<%= Request.ApplicationPath.TrimEnd(new char[] { '/' }) %>/Images/Icons/checkEngine.png" border="0" /></a></div><% } %>
            <% if (Model.LicenseType != LicenseType.ODP)
               { %>
                <div class="right-floating-panel total-time-container-outer">
                    <div id="total-time-container">
				        <div class="header">Total Time Saved</div>
			            <div class="value"><%= (Math.Ceiling(Model.CurrentProject.CompletedTasksTime.TotalHours)).ToString("000") %> hrs</div>
                    </div>
                </div>
            <% } %>
            <% Html.RenderPartial("Partials/LaunchableTasks", new LaunchableTasksModel(Model.CurrentProject, Model.AvailableTasks, Model.CurrentUser)); %>
            <div class="clear"></div>
        </div>
    </div>
    <div id="content-wrap">
        <% Html.RenderPartial("Navigation/_SideNavigation", Model.MenuNavigationModel); %>
        <div id="content">
            <% if (Model.CurrentProject.HasAdministratorAccess(Model.CurrentUser))
                { %>
                <div class="project-actions">
                    <nav class="action-dropdown page-admin">
                    <a href="#">Edit</a>
                        <ul>
                            <li><%= Html.ActionLink(TextHelper.GetText("Edit Project"), "Edit/" + Model.CurrentProject.ExternalId, "Project")%></li>
                            <li><%= Html.ActionLink("Request Rescan", "RequestModelRescanMain/" + Model.CurrentProject.ExternalId, "Project")%></li>
                            <li><a href="<%= Url.Action("Index/" + Model.CurrentProject.ExternalId, "ProjectUsers")%>">Manage Users</a></li>
                            <li><%= Html.ActionLink("File Filters", "FileFilters/" + Model.CurrentProject.ExternalId, "Project")%></li>
                            <li><a href="<%= Url.Action("Index/" + Model.CurrentProject.ExternalId, "CopyFrom")%>"><%= TextHelper.GetText("Copy From Project") %></a></li>
                            <li><a href="<%= Url.Action("Archive/" + Model.CurrentProject.ExternalId, "Project")%>"><%= TextHelper.GetText("Archive Project") %></a></li>
                            <li><a href="<%= Url.Action("Index/" + Model.CurrentProject.ExternalId, "ProjectLogs")%>">View Logs</a></li>
                            <li><a onclick="reportModelEvent('<%= Model.CurrentProject.ExternalId %>')">Report Model Event</a></li>
                            <li><a href="<%= Url.Action("Edit/" + Model.CurrentProject.ExternalId, "Glue")%>">Manage Glue</a></li>
                            <li><a href="<%= Url.Action("Edit/" + Model.CurrentProject.ExternalId, "Viewer")%>">Manage Viewer</a></li>
                            <% if (Model.CurrentProject.Active) { %>
                                <li><a href="<%= Url.Action("Deactivate/" + Model.CurrentProject.ExternalId, "Project")%>"><%= TextHelper.GetText("Deactivate Project") %></a></li>
                            <% } else { %>
                                <li><a href="<%= Url.Action("Activate/" + Model.CurrentProject.ExternalId, "Project")%>"><%= TextHelper.GetText("Activate Project") %></a></li>
                            <% } %>
                            <li><a href="<%= Url.Action("Delete/" + Model.CurrentProject.ExternalId, "Project")%>"><%= TextHelper.GetText("Delete Project") %></a></li>
                        </ul>
                    </nav>
                </div>
                <div class="clear"></div>
            <% } else if (Model.CurrentProject.HasTaskCoordinatorAccess(Model.CurrentUser)) { %>
                <div class="project-actions">
                    <nav class="action-dropdown page-admin">
                    <a href="#">Edit</a>
                        <ul>
                            <li><%= Html.ActionLink("File Filters", "FileFilters/" + Model.CurrentProject.ExternalId, "Project")%></li>
                            <li><a onclick="reportModelEvent('<%= Model.CurrentProject.ExternalId %>')">Report Model Event</a></li>
                        </ul>
                    </nav>
                </div>
                <div class="clear"></div>
            <% } %>
            <div id="project-detail-container"></div>
            <%= Model.ProjectHomeHTMLBuilder.RetrieveProjectHomeHTML() %>
            <div class="clear"></div>
        </div>
    </div>
</asp:Content>
