/*
 * OpcionesAction.java
 *
 * Created on 21 de noviembre de 2007, 10:14
 */

package servlets;

import javax.servlet.http.*;

import org.apache.struts.action.*;
import org.apache.struts.actions.*;

import javabeans.*;
import modelo.*;
import java.util.*;

public class OpcionesAction extends MappingDispatchAction {
    public ActionForward factura(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {  
         HttpSession sesion=request.getSession();
         ValidacionForm vf=(ValidacionForm)sesion.getAttribute("ValidacionForm");
         GestionLlamadas gl=getGestionLlamadas(request);
         
         request.setAttribute("precio",gl.getFactura(vf.getPassword()));
         return mapping.findForward("vistafactura");
    }   
    public ActionForward numeros(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception { 
         //el FormBean ValidacionForm contiene los teléfonos 
         //asociados al usuario
         return mapping.findForward("vistanumeros");        
    }
    public ActionForward detalles(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {      
         HttpSession sesion=request.getSession();
         ValidacionForm vf=(ValidacionForm)sesion.getAttribute("ValidacionForm");
         GestionLlamadas gl=getGestionLlamadas(request);             
         request.setAttribute("llamadas",gl.getLlamadas(vf.getPassword()));
         return mapping.findForward("vistadetalles");
    } 
    private GestionLlamadas getGestionLlamadas(HttpServletRequest request){
        String driver=this.getServlet().getServletContext().getInitParameter("driver");
        String cadenaCon=this.getServlet().getServletContext().getInitParameter("cadenaCon");
        return new GestionLlamadas(driver,cadenaCon);     
    }    
}
