<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
    <HEAD>
        <TITLE> Schedule Meeting </TITLE>
        <META NAME="Generator" CONTENT="EditPlus">
        <META NAME="Author" CONTENT="">
        <META NAME="Keywords" CONTENT="">
        <META NAME="Description" CONTENT="">
        <%@ page import = "java.util.*" %>
        <%@ page import = "com.test.DataBase;" %>
        <script type='text/javascript' src='zapatec.js'></script>
        
        <!-- Custom includes -->	
        <!-- import the calendar script -->
        <script type="text/javascript" src="calendar.js"></script>
        
        <!-- import the language module -->
        <script type="text/javascript" src="calendar-en.js"></script>
        
        <!-- Theme css -->
        <link href="forest.css" rel="stylesheet" type="text/css">
        
        
        <script>
            function notify(){
                var selobj=document.getElementById('finaldateList');
                datetimelist=new Array(selobj.options.length);
                for(var i=0;i<selobj.options.length;++i){
                    datetimelist[i]=selobj.options[i].text;
                }
                location.href="confirmnegotiate?datetimelist="+datetimelist;
            }

            function cancel(){
                window.close()
            }
            
            
            function addtoScheduleList()
            {
                var selobj=document.getElementById('dateList');
                var value=selobj.options[selobj.selectedIndex].text;
                var opt = document.createElement("option");
                opt.text=value;
                opt.value=value;
                if(document.getElementById("finaldateList").options.length < 3 && selobj.selectedIndex!=-1)
                {     
                    document.getElementById("finaldateList").options.add(opt);
                    document.getElementById("dateList").options.remove(selobj.selectedIndex);
                }
                else
                {
                    alert("You have already selected Three dates");
                }
            }
            
            function removefinaldate()
            {
                var selobj=document.getElementById('finaldateList');
                var value=selobj.options[selobj.selectedIndex].text;
                if (document.getElementById('finaldateList').length!=0){
                    document.getElementById('finaldateList').options.remove(selobj.selectedIndex);
                    var opt = document.createElement("option");
                    opt.text=value;
                    opt.value=value;
                    document.getElementById("dateList").options.add(opt);
                }
            
            }
            
            function finaldatelistss()
            {         
                var selobj=document.getElementById('finaldateList');
                for(var i=0;i<selobj.options.length;++i){
                    selobj.options[i].selected=true;
             
                }       

            }
            
        </script>
        
    </HEAD>
    
    <body background="_themes/aftrnoon/background_aftrnoon.gif" bgcolor="#FFFFFF" text="#000000" link="#983738" vlink="#703637" alink="#C76565"><!--mstheme--><font face="Verdana,Arial,Helvetica,sans-serif" size="1">
            
            <form name="renegotiate" action ="getnewdates.jsp" method="post" onsubmit="finaldatelistss()">
                <table  width="100%">
                    <tr>
                        <td align="center" colspan="2" width="100%">
                            <jsp:include page="banner.html"></jsp:include>
                        </td>
                    </tr>
                    
                </table>
                <%
            String id = (String) request.getSession().getAttribute("id");
            session.setAttribute("id", id);
                %>
                <table  width="100%" align="center" border='0'>
                    <tr>
                        <td width="100%" align = "center">
                            <h3><u> Suggested Date and Time List for Re-Negotiation</u></h3>
                        </td>
                    </tr>
                    <tr>
                        <td width="100%" align = "center">
                            <select name="dateList" size="3"  multiple>
                                <%
            try {
                String agenda = (String) session.getAttribute("meetingAgenda");

                ArrayList<String[]> renegotiateList = new ArrayList<String[]>();
                renegotiateList = DataBase.getRenegotiationDetails(agenda);
                System.out.println("Size is :" + renegotiateList.size());

                if (!renegotiateList.isEmpty()) {
                    for (int i = 0; i < renegotiateList.size(); i++) {
                        String[] array2 = renegotiateList.get(i);

                        System.out.println("count :" + i);
                        String roomid = array2[0];
                        String roomname = array2[1];
                        String startdate = array2[2];
                        String enddate = array2[3];
                        String listitems = (array2[0] + "/ " + roomname + " : " + startdate + "-" + enddate);
                        session.setAttribute("agendaaa", array2[4]);
                        System.out.println("array2[4]" + array2[4]);
                                %>
                                
                                <option value = "<%=listitems%>" > <%=listitems%> </option> 
                                
                                
                                <%}
                }
            } catch (Exception e) {
                e.printStackTrace();
            }%>
                                
                             
                            </select>
                            
                            
                            <input type="button" value="Add" onclick="addtoScheduleList()"/>
                            
                            
                        </td>
                        
                    </tr>
                    <%
            String agenda = (String) session.getAttribute("meetingAgenda");
            ArrayList<ArrayList<String[]>> totallist = new ArrayList<ArrayList<String[]>>();
            totallist = DataBase.updateRenogiationDetails(agenda, id);
            System.out.println("totallist Size is :" + totallist.size());

            if (!totallist.isEmpty()) {
                session.setAttribute("totallist", totallist);
                System.out.println("totallist is set in session");
                session.setAttribute("agenda", agenda);
            }
                    %>
                    <TR>
                        <td>&nbsp;</td>
                    </tr>
                    
                    <tr>
                        <td width="100%" align = "center">
                            <select name="finaldateList" size="3" id="finaldateList"  multiple></select>
                            <input type="button" value="Delete" onclick="removefinaldate()"/>
                        </td>
                    </tr>
                    <TR>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        
                        <td width="100%" align = "center">
                            <input type="Submit" value="Propose New Date" >
                            <input type="button" value="Cancel" onclick="cancel()">
                            <input type="button" value="Submit" onclick="notify()">
                            
                        </td>
                    </tr>
                </table>
            </form>
    <!--mstheme--></font></body>
</HTML>
