/**
   * getEmployeesReportBetweenDates(-,-) method takes fromDate, toDate as a inputs and displays all
   * employees working details during given period of time.
   */
  @RequestMapping(value = "/getEmployeesReportBetweenDates", method = RequestMethod.POST)
  public @ResponseBody String getEmployeesReportBetweenDates(
      @RequestParam("fromDate") String fromDate, @RequestParam("toDate") String toDate) {
    logger.info("inside ReportGenerationController getEmployeesReportBetweenDates()");

    return reportGenerationService.getEmployeesReportBetweenDates(
        new Date(Long.valueOf(fromDate)), new Date(Long.valueOf(toDate)));
  }
 /**
  * getWeeklyReportOfAllEmployeeByWeek(-) method display the working details of an employee for a
  * week using line chart.
  *
  * @throws ParseException If text format is not supported
  */
 @RequestMapping(value = "/getWeeklyProductivityOfAllEmployeeByWeek", method = RequestMethod.POST)
 public @ResponseBody String getWeeklyProductivityOfAllEmployeeByWeek(
     HttpServletRequest request, @RequestParam("week") String week) throws ParseException {
   logger.info("inside ReportGenerationController getWeeklyProductivityOfAllEmployeeByWeek()");
   if (HttpSessionUtility.verifySession(request, "adminId"))
     return reportGenerationService.getWeeklyProductivityOfAllEmployeeByWeek(week);
   else return JsonUtility.convertToJson("-1");
 }
  /**
   * getAllEmployeesReportByDate(-) method take attendanceDate as a input and display all employees
   * working details on a specified date.
   */
  @RequestMapping(value = "/getAllEmployeesReportByDate", method = RequestMethod.POST)
  public @ResponseBody String getAllEmployeesReportByDate(
      @RequestParam("attendanceDate") String attendanceDate) {
    logger.info("inside ReportGenerationController getAllEmployeesReportByDate()");

    return reportGenerationService.getAllEmployeesReportByDate(
        new Date(Long.valueOf(attendanceDate)));
  }
  /**
   * getEmployeeReportForYearByIdAndYear(-,-) method takes employeeId,year as a inputs and displays
   * employee working details during given particular year.
   */
  @RequestMapping(value = "/getEmployeeReportForYearByIdAndYear", method = RequestMethod.POST)
  public @ResponseBody String getEmployeeReportForYearByIdAndYear(
      @RequestParam("employeeId") int employeeId, @RequestParam("year") String year)
      throws Exception {
    logger.info("inside ReportGenerationController getEmployeeReportForYearByIdAndYear()");

    return reportGenerationService.getEmployeeReportForYearByIdAndYear(employeeId, year);
  }
  /** This method returns today attendance details as Json object array to front-end. */
  @RequestMapping(value = "/getTodayReport", method = RequestMethod.GET)
  public @ResponseBody String getDayWiseReport() {
    logger.info("in ReportGenerationController getDayWiseReport()");

    String reportDetails = reportGenerationService.getTodayAttendanceDetails();

    return reportDetails;
  }
 /** This method is to find all employee productivity for given year. */
 @RequestMapping(value = "/getAllEmployeeAnnualProductivity", method = RequestMethod.POST)
 public @ResponseBody String getAllEmployeeAnnualProductivity(
     HttpServletRequest request, @RequestParam("year") int year) {
   logger.info("inside ReportGenerationController getAllEmployeeAnnualProductivity()");
   logger.info("data received:  year: " + year);
   if (HttpSessionUtility.verifySession(request, "adminId"))
     return reportGenerationService.getAllEmployeeAnnualProductivity(year);
   else return JsonUtility.convertToJson("-1");
 }
  /**
   * getDailyReportGraphOfIndividual(-) method display the working details of an employee using line
   * chart.
   */
  @RequestMapping(value = "/getDailyReportGraphOfIndividual", method = RequestMethod.POST)
  public @ResponseBody String getDailyReportOfIndividual(
      @RequestParam("employeeId") int employeeId,
      @RequestParam("attendanceDate") String attendanceDate) {
    logger.info("inside ReportGenerationController getDailyReportOfIndividual()");

    return reportGenerationService.getDailyReportOfIndividual(
        employeeId, new Date(Long.valueOf(attendanceDate)));
  }
  /**
   * getAllEmployeeReportForMonthByMonth(-) method takes month as a inputs and displays all
   * employees working details during given period of time.
   *
   * @throws Exception
   */
  @RequestMapping(value = "/getAllEmployeeReportForYearByYearDate", method = RequestMethod.POST)
  public @ResponseBody String getAllEmployeeReportForYearByYearDate(
      @RequestParam("yearDate") String yearDate) throws Exception {
    logger.info("inside ReportGenerationController getAllEmployeeReportForYearByYearDate()");

    logger.info("Year in getAllEmployeeReportForYearByYearDate : " + yearDate);

    return reportGenerationService.getAllEmployeeReportForYearByYearDate(yearDate);
  }
  /**
   * getAllEmployeeReportForMonthByMonth(-) method takes month as a inputs and displays all
   * employees working details during given period of time.
   *
   * @throws Exception
   */
  @RequestMapping(value = "/getAllEmployeeReportForMonthByMonth", method = RequestMethod.POST)
  public @ResponseBody String getAllEmployeeReportForMonthByMonth(
      @RequestParam("month") String month) throws Exception {
    logger.info("inside ReportGenerationController getAllEmployeeReportForMonthByMonth()");

    logger.info("Month in getAllEmployeeReportForMonthByMonth : " + month);

    return reportGenerationService.getAllEmployeeReportForMonthByMonth(month);
  }
  /**
   * getReportByIdAndDate(-,-)method takes employeeId , attendanceDate as a inputs and display
   * particular employee working details on given date if it is worked on this date.
   */
  @RequestMapping(value = "/getReportByIdAndDate", method = RequestMethod.POST)
  public @ResponseBody String getReportByIdAndDate(
      @RequestParam("employeeId") int employeeId,
      @RequestParam("attendanceDate") String attendanceDate,
      HttpServletRequest request) {
    logger.info("inside ReportGenerationController getReportByIdAndDate()");

    return reportGenerationService.getEmployeeWorkingDetailsByIdAndDate(
        employeeId, new Date(Long.valueOf(attendanceDate)));
  }
  /**
   * getReportByIdFromDateToDate(-,-,-) method takes employeeId , fromDate, toDate as a inputs and
   * display the working details of an employee during given period of time.
   */
  @RequestMapping(value = "/getReportByIdFromDateToDate", method = RequestMethod.GET)
  public @ResponseBody String getReportByIdFromDateToDate(
      @RequestParam("employeeId") int employeeId,
      @RequestParam("fromDate") String fromDate,
      @RequestParam("toDate") String toDate) {
    logger.info("inside ReportGenerationController getReportByIdFromDateToDate()");

    return reportGenerationService.getEmployeeWorkingDetailsByDates(
        employeeId, new Date(Long.valueOf(fromDate)), new Date(Long.valueOf(toDate)));
  }
 /**
  * getAllEmployeeReportForMonthByMonth(-) method takes month as a inputs and displays all
  * employees working details during given period of time.
  *
  * @throws Exception
  */
 @RequestMapping(
     value = "/getMonthlyProductivityOfAllEmployeeByMonth",
     method = RequestMethod.POST)
 public @ResponseBody String getMonthlyProductivityOfAllEmployeeByMonth(
     HttpServletRequest request, @RequestParam("month") String month) {
   logger.info("inside ReportGenerationController getMonthlyProductivityOfAllEmployeeByMonth()");
   logger.info("Month in getMonthlyProductivityOfAllEmployeeByMonth : " + month);
   if (HttpSessionUtility.verifySession(request, "adminId"))
     return reportGenerationService.getMonthlyProductivityOfAllEmployeeByMonth(month);
   else return JsonUtility.convertToJson("-1");
 }
  /**
   * getEmployeeReportForWeekByIdAndWeekDate(-,-) method takes employeeId,weekDate as a inputs and
   * displays employee working details during given period of time.
   *
   * @throws Exception
   */
  @RequestMapping(value = "/getEmployeeReportForWeekByIdAndWeekDate", method = RequestMethod.POST)
  public @ResponseBody String getEmployeeReportForWeekByIdAndWeekDate(
      @RequestParam("employeeId") int employeeId, @RequestParam("weekDate") String weekDate)
      throws Exception {
    logger.info("inside ReportGenerationController getEmployeeReportForWeekByIdAndWeekDate()");

    logger.info("Employee ID:" + employeeId);

    logger.info("Date: " + weekDate);

    return reportGenerationService.getEmployeeReportForWeekByIdAndWeekDate(employeeId, weekDate);
  }
  /**
   * getAutoCompleteInfo(-) method take employeeId as a input and display all employeeId's or
   * employeeName's in the search box based on the user supplied values.
   */
  @RequestMapping(value = "/getAutoCompleteInfo", method = RequestMethod.POST)
  public @ResponseBody String getAutoCompleteInfo(@RequestParam("employeeId") String employeeId) {
    String pattern = "^[0-9]$";

    List<Integer> infolist = null;
    Pattern p = Pattern.compile(pattern);
    Matcher m = p.matcher(employeeId);
    if (m.find()) {
      logger.info("Integer:" + employeeId);
      logger.info("inside ReportGenerationController getAutoCompleteInfo()");
      logger.info("received employee id: " + employeeId);
      int empid = Integer.parseInt(employeeId);
      infolist = reportGenerationService.getAutoCompleteInfo(empid);
      logger.info("info list in controller:" + infolist);

      return JsonUtility.convertToJson(infolist);
    } else {
      logger.info("String:" + employeeId);
      List<String> data = reportGenerationService.getAutoCompleteInfo(employeeId);
      return JsonUtility.convertToJson(data);
    }
  }
  /**
   * getReportById(-) method take employeeId (Integer) as a input and display all the working
   * details of an employee.
   */
  @RequestMapping(value = "/getReportById", method = RequestMethod.POST)
  public @ResponseBody String getReportById(@RequestParam("employeeId") int employeeId) {
    logger.info("inside ReportGenerationController getReportById()");

    return reportGenerationService.getEmployeeWorkingDetailsById(employeeId);
  }
  /**
   * getReportByName(-) take input as employeeId (String) and display the total working details of
   * an employee.
   */
  @RequestMapping(value = "/getReportByName", method = RequestMethod.POST)
  public @ResponseBody String getReportByName(@RequestParam("employeeId") String employeeId) {
    logger.info("inside ReportGenerationController getReportByName()");

    return reportGenerationService.getReportByName(employeeId);
  }
  /** getAllEmployeesWorkingDetails() method will display working details of all employees. */
  @RequestMapping(value = "/getAllEmployeesWorkingDetails", method = RequestMethod.POST)
  public @ResponseBody String getAllEmployeesWorkingDetails() {
    logger.info("inside ReportGenerationController getAllEmployeesWorkingDetails()");

    return reportGenerationService.getAllEmployeesWorkingDetails();
  }