<%@page import="com.capgemini.reports.ReportEnum"%>
<%@page import="java.util.Arrays"%>
<%@page import="java.util.Collections"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page import="com.capgemini.framework.common.StringHelper"%>
<%@page import="com.capgemini.framework.common.SettingsHelper"%>
<%@page import="com.capgemini.reports.database.manager.MngSchedulingReport"%>
<%@page import="com.capgemini.reports.database.javabean.enumeration.SchedulingEnum"%>
<%@page import="com.capgemini.reports.database.javabean.enumeration.ReportCriteriaEnum"%>
<%@page import="com.capgemini.reports.database.manager.MngSchedulingCriteriaVal"%>
<%@page import="com.capgemini.reports.common.scheduling.view.NewSchedulingFormatter"%>
<%@page import="com.capgemini.reports.common.scheduling.view.UpdateSchedulingFormatter"%>

<%
    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
    
    
    boolean isDevMode      = SettingsHelper.isDevMode();
    
    String selectedFilter  = request.getParameter("activeSchedulingList");
    String curReportNumber = selectedFilter.equals("TOUS") ? selectedFilter : "R" + selectedFilter;
    
    ReportEnum reportEntryEnum = ReportEnum.fromCode(curReportNumber);
    String reportTitleCanonicalName = curReportNumber.concat(" - ").concat( reportEntryEnum.getReportTitle() );
    
    String jspURL          = "template_r" + selectedFilter + ".jsp";
    String reportCode      = "R" + selectedFilter ;
%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Planification -</title>
    
    
    <link rel="stylesheet" href="/kurt-web/css/pikaday.css">
    <link rel="stylesheet" href="/kurt-web/css/kurt-style.css">
    <link rel="stylesheet" href="/kurt-web/css/kurt-style-frame.css">
    <link rel="stylesheet" href="/kurt-web/css/scheduling.css">
    
    <script src="/kurt-web/js/kurt-common-submit.js"></script>
    <script src="/kurt-web/js/moment.js"></script>
    <script src="/kurt-web/js/pikaday.js"></script>
    <script src="/kurt-web/js/post_form.js"></script>
    <script src="/kurt-web/js/schedulingReport.js"></script>
    <script src="/kurt-web/js/obtain_data.js"></script>
    
    
    <!--[if IE 8]> <style> input { padding-bottom:0; } </style> <![endif]-->
    
    <!-- Load specific script in IE8 for JSON support -->
    <!--[if lt IE 9]> <script src="/kurt-web/js/json2.js" type="text/javascript"></script> <![endif]-->

</head>

<body id="body_frame">
    <!-- TITLE -->
    <img src="/kurt-web/ihm/calendar_planification.png" align="left" width="64" height="64" hspace="12" />
    <br />
    <h1>Planification <%=reportTitleCanonicalName%> (Cr&eacute;ation)</h1>

    <div align="left" style="margin-left: 220px;">
        <form class="form" id="reportSchedulingForm" method="post" onsubmit="return false;">
            <!--  Functional content -->
            <div>
                <div id="functionnal">
                    <div id="div_title_scheduling">
                        <p class="title_planification">D&eacute;finition du Rapport</p>
                    </div>
                    <div id="content_functionnal">
                        <!-- Put the report code the functional data to be able to find which report we want to launch -->
                        <%-- <input type="text" id="report_code" name="report_code" value="<%=reportCode%>" hidden="true"/> --%>
                        <!-- Now import the real functional data -->
                        <jsp:include page="<%=jspURL%>">
                            <jsp:param name="isActiveButtonSubmit" value="false" />
                            <jsp:param name="isUpdateReport" value="false" />
                            <jsp:param name="isCheckAuthorized" value="false" />
                            <jsp:param name="idReport" value="" />
                            <jsp:param name="reportCode" value="<%=reportCode%>" />
                        </jsp:include>
                    </div>
                </div>
                <div id="temporal">
                    <script src="/kurt-web/js/schedulingReportsCreaUpd.js"></script>
                </div>
            </div>

            <!--  Scheduling content -->
            <div id="div_title_scheduling">
                <p class="title_planification">Crit&egrave;res de Planification du Rapport</p>
            </div>

            <br />
            <!--  START_SCHEDULING -->
            <%=new NewSchedulingFormatter().showNewReportSchedulingPage()%>
            <!--  END_SCHEDULING -->

            <br/>
            <br/>
            <div id="loading" style="display: none; text-align: center;">
                <i>Traitement en cours...</i>
                <br />
                <img src="/kurt-web/ihm/progress.gif" vspace="6" width="129" height="20">
            </div>
            <!-- boutons -->
            <div id="div_buttons" align="center">
                <button class="formButton" onclick="sendSchedulingReport('/kurt-web/scheduling/submit', '&report_code=<%=reportCode%>')">Enregistrement</button>
                <button class="formButton" onclick="getReport('<%=curReportNumber%>')">Retour</button>
            </div>

            <script>
			    /* Initialize date picker only for report in list */
                initPicker('datepicker_planification', 'container_planification');
			</script>
        </form>
    </div>
</body>
</html>
