<!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 renegotiate()
            {
            document.results.action = "renegotiate.jsp"
            document.results.submit();
            }
            
            //function popUp(url) {
            //    newwindow=window.open(url,'','height=250,width=400');
             //   if (window.focus) {newwindow.focus()}
              //  return false;
            //}
           // function confirmpopUp(url) {
           //     newwindow=window.open(url,'','height=350,width=450');
              //  if (window.focus) {newwindow.focus()}
             //   return false;
            //}
            function cancelMeeting() {
                var answer = confirm("Do you really want to Cancel?");
                if(answer)
                {
                 
                    location.href="CancelMeetings";
                }
                else
                {
                    return false;
                }
            }
            function reinit(){
                var answer = confirm("Do you really want to Reinitiate the process?");
                if(answer)
                {
                    alert("Old Meeting Details are purged!");
                    location.href="new_request.jsp";
                }
                else
                {
                    return false;
                }
                
            }
            function logoff()
            {
                var answer = confirm("Do you really want to Log off?");
                if(answer)
                {
                    location.href = "LogOut.jsp";
                }
                else
                {
                    return false;
                }

            }
            function confirms()
           {
              
                    location.href = "ConfirmCount.jsp";
              
            } 
            
         </script>
        
    </HEAD>
    
    <body background="_themes/aftrnoon/background_aftrnoon.gif" bgcolor="#FFFFFF" text="#000000" link="#983738" vlink="#703637" alink="#C76565"><!--mstheme-->
            
        <form name="results" action="confirmMeetingPage.jsp" method="get">
            <font size="2">
                <table  width="100%">
                    <tr>
                        <td align="center" colspan="2" width="100%">
                            <jsp:include page="banner.html"></jsp:include>
                        </td>
                    </tr>
                    
                </table>
                
                <table align="center" width="100%">
                    <tr>
                        <td align="center">
                            <u><h3>Meeting Results</h3></u>
                        </td>
                        <td align="right" nowrap width=5%">
                            <a href="welcome.jsp"><font size="3">Home</font></a>
                            &nbsp;&nbsp;&nbsp;
                            <a href="#" onclick="logoff();"><font size="3">Sign out</font></a>
                        </td>
                        
                        
                    </tr>
                </table>
                <%
String id=(String)request.getSession().getAttribute("id");
session.setAttribute("id", id);
%>
                <table cellpadding = "5" align="center" width="80%">
                    <%  
                    try{
                        String agenda = request.getParameter("meetingAgenda");
                    
                    String username = (String)request.getSession().getAttribute("id");
                    session.setAttribute("id", username);
                    
                    ArrayList<ArrayList<String[]>> meetingList = new ArrayList<ArrayList<String[]>>();
                    meetingList = DataBase.getMeetingStatus(agenda,username);  
                    System.out.println("Size is :"+meetingList.size());
                    ArrayList<String[]> meetingcountList1 = new ArrayList<String[]>();
                    ArrayList<String[]> meetingcountList2 = new ArrayList<String[]>();
                    ArrayList<String[]> meetingcountList3 = new ArrayList<String[]>();
                    if(!meetingList.isEmpty())
                    {
                         
                           meetingcountList1 = meetingList.get(0);
                           meetingcountList2 = meetingList.get(1);
                           meetingcountList3 = meetingList.get(2);
                            
                        if(!meetingList.isEmpty())
                        {   
                        for (int i=0;i<meetingcountList1.size();i++)
                        {
                           
                            String[] array2 = meetingcountList1.get(i);
                                                      
                            System.out.println("no of meetings :"+meetingcountList1.size());
                              String  meetingid = array2[0];
                              String  Agenda  = array2[1];
                              String  status  = array2[2];
                              String  startdate  = array2[3];
                              String  enddate  = array2[4];
                              //String  empid  = array2[5];
                              
                    %>
                        <tr>
                            <td width="20%">
                                Meeting id :
                            </td>
                            <td width="20%" nowrap>
                                <%= meetingid%>	
                                </td>   
                                <td width="15%">
                                    StartDate/Time :
                                </td>                                
                                <td width="15%">
                                    <%=startdate%>
                                </td>
                                <td width="15%">
                                    EndDate/Time :
                                </td>                                
                                <td width="15%">
                                    <%=enddate%>
                                </td>
                                
                        </tr>
                        <tr>
                            <td width="20%">
                                Agenda :
                            </td>
                            <td colspan ='5 'width = "80%"nowrap>
                                <%= Agenda%>	
                            </td>
                        </tr>
                        <tr>
                            <td>
                                No of Accepts : 
                            </td>
                            <td>
                                <%= status%>
                            </td>
                    </tr>
                    <tr>
                        <td width ="100%" colspan='6'>
                            <hr></hr>
                        </td>
                    </tr>
                    <%}}if(!meetingcountList2.isEmpty()){
                         for (int i=0;i<meetingcountList2.size();i++)
                        {
                        String[] array3 = meetingcountList2.get(i);
                                                          
                     String rejects = array3[0];
                     %>
                    <tr>
                        <td>
                            No of Rejects : 
                        </td>
                        <td>
                           <%=rejects%>
                        </td>
                    </tr>
                    <%}}
                     %>
                    <tr>
                        <td colspan='2'>
                            Participants Pending with their <i><b>Votes</b></i> :
                        </td>
                        <td>
                            <select name="PendingList" size="1" readonly>
                            <% if(!meetingcountList3.isEmpty()){
                         for (int i=0;i<meetingcountList3.size();i++)
                        {
                        String[] array4 = meetingcountList3.get(i);
                                                          
                     String waiting = array4[0];
                                %>
                             <option value = "<%=waiting%>"><%=waiting%></option>
                           
                                  
                           <%}}}}catch(Exception e){
                               e.printStackTrace();
                            }
                            %>

                            </select>
                        </td>
                        
                    </tr>
                    <tr>
                        <td>
                            &nbsp; 
                            
                        </td>
                    </tr>
                    
                </table>
                <table align="center">
                    <tr>
                        <td align="center">
                            <p align="center"><b><u>View of Participants and their availability for Meeting</u></b></p>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                </table>
                <table align="center" cellpadding="5" border="1">
                    
                    <tr>
                        <td>
                            <b>Participant Name</b>
                        </td>
                        <td>
                            <b>Meeting Status</b>
                        </td>
                        <td>
                            <b>Accepted Date and Time - Room</b>
                        </td>
                        <td>
                            <b>Suggested Date and Time - Room</b>
                        </td>
                        <td>
                            <b>Equipments List</b>
                        </td>
                    </tr>
                    <%
                    String meetingAgenda = request.getParameter("meetingAgenda");
                    try{
                    String agenda = meetingAgenda;
                    
                    String username = (String)request.getSession().getAttribute("id");
                    ArrayList<ArrayList<String[]>> meetingtableList = new ArrayList<ArrayList<String[]>>();
                    meetingtableList = DataBase.getMeetingDetails(agenda,username);  
                    System.out.println("Size is :"+meetingtableList.size());
                    ArrayList<String[]> meetingtableList1 = new ArrayList<String[]>();
                    ArrayList<String[]> meetingtableList2 = new ArrayList<String[]>();
                    if(!meetingtableList.isEmpty())
                    {
                        meetingtableList1 = meetingtableList.get(0);
                        meetingtableList2 = meetingtableList.get(1); 
                        for (int j=0;j<meetingtableList1.size();j++)
                        {
                            String[] tablearray = meetingtableList1.get(j);
                            
                            System.out.println("count :"+j);
                              String  firstname = tablearray[0];
                              String  tempstatus = tablearray[1];
                              System.out.println("status"+tempstatus);
                              String  meetingstatus  = "";
                              if(tempstatus.equals("1"))
                                  {
                                 meetingstatus  = "Accepted";
                                  }
                              if(tempstatus.equals("2"))
                                  {
                                  meetingstatus  = "Rejected";
                                  }
                              if(tempstatus.equals("3"))
                                  {
                                  meetingstatus  = "Renegotiated";
                                  }
                              if(tempstatus.equals("4"))
                                  {
                                 meetingstatus  = "Proposed";
                                  }
                             if(tempstatus.equals("5"))
                                  {
                                        meetingstatus  = "Initiated";
                                  }
                              
                              String  startdate2  = tablearray[2];
                              String  enddate2  = tablearray[3];
                              String  isactive  = tablearray[4];
                              String  empid = tablearray[5];
                              /*
         *   0 - invited
         *   1 - accepted
         *   2 - rejected
         *   3 - proposed
         *   4 - tentative
         */
                    %>
                    
                    <%if(isactive.equals("1")){%>
                    <tr bgcolor="orange">
                    <%}else{%>
                    <tr >
                        <%}%>      
                        <td>
                            <%=firstname%>
                        </td>
                        <td>
                            <%=meetingstatus%>
                        </td>
                        <% if(meetingstatus.equals("Rejected")){%>
                         <td>
                            <center>____ </center> 
                        </td>                        
                        <%}else{%>                        
                        <td >
                            <%=startdate2%>
                        </td>
                         <%} if(meetingstatus.equals("Rejected")){%>
                         <td>
                            <center>____ </center> 
                        </td>                        
                        <%}else{%>                        
                        <td >
                            <%=enddate2%>
                        </td>
                        
                       
                        <td >
                           <%}for (int k=0;k<meetingtableList2.size();k++)
                            {
                            String[] tablearray2 = meetingtableList2.get(k);
                            
                            System.out.println("count :"+k);
                              String  list2empid = tablearray2[0];
                              String  equipName = tablearray2[1];
                              %>  
                          <%  if(isactive.equals("1"))
                              {
                                if (list2empid.equals(empid))
                              {%>
                                  
                              <%=equipName%>&nbsp;
                              
                              <%}}}%>
                        </td>
                        
                    </tr>
                    <%}}}catch(Exception e){
                               System.out.println("the error"+e);
                               e.printStackTrace();
                            }
                            %>
                </table>
                <table align="center" cellpadding="5">
                    <tr>
                        <td>
                            &nbsp;
                        </td>
                           <%
            session.setAttribute("id",id);
            session.setAttribute("meetingAgenda", meetingAgenda);
            session.setAttribute("agenda", meetingAgenda);

                        %>
                     
                    </tr>
                    <tr>
                        <td align="center" > <input type ="button" value="Confirm" onclick="confirms()">
                            <input type ="button" value="Renegotiate" onclick="renegotiate();">
                        <input type ="button" value="Cancel Meeting" onclick="cancelMeeting()">
                        
                    </tr>
                    
                </table>
            </font>
        </form>
    <!--mstheme--></body>
</HTML>
