/*
 * 
 * Created on Jun 28, 2005
 * 
 * György Süveges
 * Etixpert Kft.
 * Copyright(c) 2005
 * 
 */
package com.etixpert.evolution.gui.servlets.pageactions;

import java.util.*;

import javax.servlet.http.HttpServletRequest;

import com.etixpert.evolution.app.order.Bill;

/**
 * @author Suveges Gyorgy
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class linkedbill extends PDFLinker {

    /**
     * 
     */
    public linkedbill() {
        super();
        // TODO Auto-generated constructor stub
    }

    /* (non-Javadoc)
     * @see com.etixpert.evolution.gui.servlets.pageactions.PDFLinker#getPDFs(javax.servlet.http.HttpServletRequest)
     */
    protected byte[][] getPDFs(HttpServletRequest req) throws Exception {
        // TODO Auto-generated method stub
        Set orders = (Set) req.getSession().getAttribute("orderids");
        req.getSession().removeAttribute("orderids");
        if (orders.size()==0) return null;
        byte[][] bills = new byte[orders.size()][];
        logger.info("Generating linked bill");
        
		String realPath = req.getSession().getServletContext().getRealPath("/WEB-INF/");
        logger.info("Realpath of web-inf is: "+realPath);
		int i=0;
        for (Iterator it = orders.iterator(); it.hasNext();) {
           
            byte[] data = Bill.generate(it.next(), realPath);
            bills[i++]= data;
        }
        
        
        return bills;
    }

}
