/*******************************************************************************
 * Copyright 2019 2Fi Business Solutions Ltd.
 *
 *
 *
 * This code is copyrighted. Under no circumstances should any party, people,
 * or organization should redistribute any portions of this code in any form,
 * either verbatim or through electronic media, to any third parties, unless
 * under explicit written permission by 2Fi Business Solutions Ltd.
 ******************************************************************************/
package com.ffii.tbms.reports.web;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.ffii.core.utils.Params;
import com.ffii.core.web.AbstractController;
import com.ffii.tbms.reports.service.CustomerFirstOrderReportService;


@Controller
@RequestMapping(value = "/report/customer-first-order")
public class CustomerFirstOrderReportController extends AbstractController {

	@Autowired
	private CustomerFirstOrderReportService service;

	@RequestMapping(value = "/excel", method = { RequestMethod.GET, RequestMethod.POST })
	public String excel(Model model, HttpServletRequest request, HttpServletResponse response)
	 throws ServletRequestBindingException {

		List<Map<String, Object>> records = service.search();
		List<Map<String, Object>> noOrderList = service.searchNoOrderCustomer();

		model.addAttribute(Params.RECORDS, records);
		model.addAttribute("noOrderList", noOrderList);

		return "customerFirstOrderReportExcelView";
	}
}
