<%@page import="com.capgemini.reports.ReportEnum"%>
<%@page import="com.capgemini.reports.common.scheduling.controller.SchedulingReaderServlet.SchedulingReportEntry"%>
<%@page import="com.capgemini.reports.formatting.AllSchedulingReports" %>
<%@page import="java.util.List" %>
<%@page import="java.util.Set" %>
<%! final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("com.capgemini.reports.all_scheduling_reports.jsp"); %>

<%
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1
response.setHeader("Pragma", "no-cache"); // HTTP 1.0
response.setDateHeader("Expires", 0); // Proxies
%>

<!--
	This page displays all information on report scheduling.
It is only called by the SchedulingReaderServlet.java servlet, which adds mandatory attributes to the request.

Top left is a filter on report codes for this page.
	Top right is a combobox that tells if the report selected in the filter can be launched online by the users.
    
	Below is a table listing all currently scheduled reports:
	- Report Code (R01 / R20...)
	- Scheduling name
	- Periodicity (weekly, monthly, etc.)
	- Last modification date
	- Owning administrator (a User)
	- Next scheduled launch
	- a button opening a popup showing the report's Functional parameters
	- a button opening a page to edit the line's scheduling parameters
	- a button to delete the line's schedule altogether
	
	URL parameters to this page are:
     - 'schedulings' (MANDATORY)
        A List of SchedulingReportEntry, containing all schedulings to be dispayed in the page.
	 - 'reportCode'(optional)
	 	possible values: TOUS, R01, R21, etc.
	 	The selected report code in the filter.
	 - 'page' (optional)
	 	possible values: 1, 2, 3...
	 	The page in scheduling list.
-->
<% 
    String reportCode = request.getParameter("reportCode");
    List<String> allReports = ReportEnum.getListReportCode();
    ReportEnum reportEnum = allReports.contains(reportCode) ? ReportEnum.fromCode(reportCode) : null;
    String pageNum = request.getParameter("page");
    String userLogin = request.getRemoteUser();
    Set<SchedulingReportEntry> entries = (Set<SchedulingReportEntry>) request.getAttribute("schedulings");
    
    log.trace("reportCode = " + reportCode);
    log.trace("reportEnum = " + (reportEnum==null ? "(null)" : reportEnum.toString()));
    log.trace("page       = " + pageNum);
    log.trace("userLogin  = " + userLogin);
    log.trace("entries    = " + entries.toString());
%>
<%= new AllSchedulingReports(reportEnum, pageNum, userLogin, entries).makeJsContent() %>

