package com.rms.tfc.web;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.rms.tfc.service.DetallePedidoBean;
import com.rms.tfc.service.PedidoService;

@Controller
public class DetallePedidoController {

	@Resource
	private PedidoService pedidoService;
	
	@RequestMapping("/DetallePedido.html")
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String idPedido = request.getParameter("idPedido");
		Boolean esHistorico = Boolean.valueOf(request.getParameter("esHistorico"));
		DetallePedidoBean detallePedidoBean = pedidoService.getDetallePedido(new Long(idPedido));
		if (esHistorico.booleanValue()){
			return new ModelAndView("detallePedidoHistorico", "objetoJSP", detallePedidoBean);
		} else {
			return new ModelAndView("detallePedido", "objetoJSP", detallePedidoBean);
		}
    }

	public void setPedidoService(PedidoService pedidoService) {
		this.pedidoService = pedidoService;
	}
}