package com.jasamedika.medifirst2000.controller;


import java.util.Collection;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.service.LaundryService;
import com.jasamedika.medifirst2000.service.SaranaPrasaranaReportingService;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.vo.RegistrasiPelayananVO;

/**
 * Controller class for Sarana Prasarana Business
 * 
 */
@RestController
@RequestMapping("/sarana-prasarana-reporting")
public class SaranaPrasaranaReportingController extends LocaleController<RegistrasiPelayananVO>
		implements IBaseRestController<RegistrasiPelayananVO> {

	@Autowired
	private SaranaPrasaranaReportingService saranaPrasaranaReportingService;
	
	

	@RequestMapping("/lapDaftarPengeringan")
	public ModelAndView generateDaftarPengeringan(ModelAndView m,
			@RequestParam(value = "startPeriode", required = true) String startPeriode,
			@RequestParam(value = "endPeriode", required = true) String endPeriode,
			@RequestParam(value = "format", required = false) String format) {
		
		Map<String, Object> result = saranaPrasaranaReportingService.getDaftarPengeringan(startPeriode,endPeriode);

		m.addObject("dataSource", result.get("daftarPengeringan"));
		m.addObject("startPeriode", startPeriode);
		m.addObject("endPeriode", endPeriode);
		m.addObject("format", "pdf");
		

		if (format != null && !format.isEmpty()) {
			m.addObject("format", format);
		}

		return m;
	}
	
	@RequestMapping("/daftarPengambilanLinenKotor")
	public ModelAndView generateDaftarPengambilanLinenKotor(ModelAndView m,
			@RequestParam(value = "startPeriode", required = true) String startPeriode,
			@RequestParam(value = "endPeriode", required = true) String endPeriode,
			@RequestParam(value = "format", required = false) String format) {
		Map<String, Object> result = saranaPrasaranaReportingService.getDaftarPengambilanLinenKotor(startPeriode,endPeriode);

		m.addObject("dataSource", result.get("pengambilanLinenKotor"));
		m.addObject("startPeriode", startPeriode);
		m.addObject("endPeriode", endPeriode);
		m.addObject("format", "pdf");
		

		if (format != null && !format.isEmpty()) {
			m.addObject("format", format);
		}

		return m;
	}
	
	@RequestMapping("/daftarPermintaanPerbaikanDariRuangan")
	public ModelAndView generateDaftarPermintaanPerbaikanDariRuangan(ModelAndView m,
			@RequestParam(value = "startPeriode", required = true) String startPeriode,
			@RequestParam(value = "endPeriode", required = true) String endPeriode,
			@RequestParam(value = "format", required = false) String format) {
		Map<String, Object> result = saranaPrasaranaReportingService.getAllPermintaanPerbaikan(startPeriode,endPeriode);

		m.addObject("dataSource", result.get("permintaanPerbaikan"));
		m.addObject("startPeriode", startPeriode);
		m.addObject("endPeriode", endPeriode);		
		m.addObject("format", "pdf");
		

		if (format != null && !format.isEmpty()) {
			m.addObject("format", format);
		}

		return m;
	}
	
	@Override
	public ResponseEntity<Collection<RegistrasiPelayananVO>> getAllVOWithQueryString(HttpServletRequest request,
			Integer page, Integer limit, String sort, String dir) {
		return null;
	}

	@Override
	public ResponseEntity<RegistrasiPelayananVO> getVO(Integer id) {
		return null;
	}

	@Override
	public ResponseEntity<String> addVO(RegistrasiPelayananVO vo) {
		return null;
	}

	@Override
	public ResponseEntity<String> editVO(RegistrasiPelayananVO vo) {
		return null;
	}

	@Override
	public ResponseEntity<String> deleteVO(Integer id) {
		return null;
	}

	@Override
	public ResponseEntity<List<RegistrasiPelayananVO>> getAllVO() {
		return null;
	}

	private String formatBulan(Integer bulan) {
		String bulanString = "";
		switch (bulan) {
		case 1:
			bulanString = "januari";
			break;
		case 2:
			bulanString = "februari";
			break;
		case 3:
			bulanString = "maret";
			break;
		case 4:
			bulanString = "april";
			break;
		case 5:
			bulanString = "mei";
			break;
		case 6:
			bulanString = "juni";
			break;
		case 7:
			bulanString = "juli";
			break;
		case 8:
			bulanString = "agustus";
			break;
		case 9:
			bulanString = "september";
			break;
		case 10:
			bulanString = "oktober";
			break;
		case 11:
			bulanString = "november";
			break;
		case 12:
			bulanString = "desember";
			break;
		}
		return bulanString;
	}
	
}
