<%-- $HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/apps/igeoportal-standard/branches/2.5_testing/modules/csw/csw_shopping_cart.jsp $ --%>
<%--
 This file is part of deegree, http://deegree.org/
 Copyright (C) 2001-2009 by:
 - Department of Geography, University of Bonn -
 and
 - lat/lon GmbH -

 This library is free software; you can redistribute it and/or modify it under
 the terms of the GNU Lesser General Public License as published by the Free
 Software Foundation; either version 2.1 of the License, or (at your option)
 any later version.
 This library is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 details.
 You should have received a copy of the GNU Lesser General Public License
 along with this library; if not, write to the Free Software Foundation, Inc.,
 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

 Contact information:

 lat/lon GmbH
 Aennchenstr. 19, 53177 Bonn
 Germany
 http://lat-lon.de/

 Department of Geography, University of Bonn
 Prof. Dr. Klaus Greve
 Postfach 1147, 53001 Bonn
 Germany
 http://www.geographie.uni-bonn.de/deegree/

 e-mail: info@deegree.org
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page import="org.deegree.model.spatialschema.Envelope" %>
<%@ page import="org.deegree.portal.standard.csw.control.Constants" %>
<%@ page import="org.deegree.portal.standard.csw.model.*" %>
<%@ page import="org.deegree.i18n.Messages" %>
<%@ page import="java.util.Locale" %>
<%
    Locale loc = request.getLocale();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="audience" content="">
        <meta name="author" content="lat/lon GmbH, Judit Mays">
        <meta name="keywords" content="OGC OpenGIS">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="imagetoolbar" content="no">
        <title>selected_items</title>
    
        <link href="../../css/deegree.css" rel="stylesheet" type="text/css">
        <script language="JavaScript1.2" TYPE="text/javascript" src="./modules/csw/csw_functions_search_result.js"></script>
        <script language="JavaScript1.2" TYPE="text/javascript" src="./modules/csw/csw_functions_shop.js"></script>
    </head>
    <body class="main">
        <p align="center" class="title">Selected Items</p>
        <table>
            <tr>
                <td>
                    <form name="auswahlform" enctype="application/x-www-form-urlencoded">
                        <table class="md">
                        <%
                        ShoppingCart cart = 
                            (ShoppingCart)request.getAttribute( Constants.SESSION_SHOPPINGCART );
                        List contents = (ArrayList)cart.getContents();
                        
                        if ( contents != null && contents.size() > 0 ) {
                        %>
                            <tr>
                                <td colspan="3" class="highlight">
                                    <p class="spacebottom">Your selection contains the following items:</p>
                                </td>
                            </tr>
                        <%
                            for( int i = 0; i < contents.size(); i++ ) {
                                DataSessionRecord dsr = (DataSessionRecord)contents.get( i );
                                ServiceSessionRecord[] ssrArray = (ServiceSessionRecord[])dsr.getServices();
                                
                                String dId = null;
                                String dCatalog = null;
                                String dTitle = null;
                                String serviceCatalogs = "";
                                Envelope bbox = null;
                                
                                if ( ssrArray != null ) {
                                    dCatalog = dsr.getCatalogName();
                                    dId = dsr.getIdentifier();
                                    dTitle = dsr.getTitle();
                                    bbox = dsr.getBoundingBox();
                        %>
                            <tr>
                                <td>
                        <%
                                    out.print( dTitle );
                        %>
                                </td>
                                <td>
                                    <input type="checkbox" name="<% out.print( dId + ":" + dCatalog + ":"  + dTitle ); %>" />
                        <%
                                    if ( bbox != null ) {
                        %>
                                        <input type="hidden" 
                                           name="BBOX:<% out.print( dId + ":" + dCatalog + ":"  + dTitle ); %>"
                                           value="<% out.print( bbox.getMin().getX() + "," );
                                                     out.print( bbox.getMin().getY() + "," );
                                                     out.print( bbox.getMax().getX() + "," );
                                                     out.print( bbox.getMax().getY() ); %>" />
                        <%
                                    //} else {
                                        //out.print( "&nbsp;-- no bbox --&nbsp;" );
                                    }
                        %>
                                </td>
                                <td>
                        <%
                                    for( int j = 0; j < ssrArray.length; j++ ) {
                                        String sType = ssrArray[j].getServiceType();
                                        if ( "OGC:WMS".equals( sType ) || "WMS".equals(sType) ) {
                                            out.print( "<img src='./images/csw_viewable.gif' border='0' alt='viewable' />" );
                                        } else if ( "OGC:WFS".equals(sType) || "WFS".equals(sType) ) {
                                            out.print( "<img src='./images/csw_downloadable.gif' border='0' alt='downlaodable' />" );
                                        } else {
                                            out.print( "unknown service type: " + sType );
                                        }
                                        //out.print( ssrArray[j].getServiceAddress() );
                                        //out.print( ssrArray[j].getServiceTypeVersion() );
                                    }
                        %>
                                </td>
                            </tr>
                        <%
                                } // end if( ssrArray != null )
                            } // end for(contents.size())
                        %>
                            <!--tr>
                                <td colspan="3" class="highlight">
                                    <p class="spacetop">Please choose the data you would like to view or to delete.</p>
                                    <hr />
                                </td>
                            </tr-->
                            <tr><td width="20">&nbsp;</td></tr>
                            <tr>
                                <td colspan="3">
                                    <table width ="100%">
                                        <tr>
                                            <td>
                                                <p class="spacetop">
                                                    <a href="javascript:displayMap();" class="buttonArea"><%=Messages.get( loc, "IGEO_STD_BTN_DISPLAYMAP" ) %></a>
                                                </p>
                                            </td>
                                            <!-- 
                                            <td>
                                                <p class="spacetop">
                                                    <a href="javascript:performDownload();" class="buttonArea"><%=Messages.get( loc, "IGEO_STD_BTN_DWNLD" ) %></a>
                                                </p>
                                            </td>
                                             -->
                                             <td>
                                                <p class="spacetop">
                                                    <a href="javascript:performDelete();" class="buttonArea"><%=Messages.get( loc, "IGEO_STD_BTN_DELETESEL" ) %></a>
                                                </p>
                                            </td>
                                            <td>
                                                <p class="spacetop">
                                                    <a href="javascript:performDeleteAll();" class="buttonArea"><%=Messages.get( loc, "IGEO_STD_BTN_DELETEALL" ) %></a>
                                                </p>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        <%
                        // end if ( contents != null && contents.size() > 0 )
                        } else {
                        %>
                            <tr>
                                <td>Your selection contains no items!</td>
                            </tr>
                        <%
                        }
                        %>
                        </table>
                    </form>
                </td>
            </tr>
        </table>
    </body>
</html>
