@RequestMapping(
     value = "staff/{id}/{type}",
     method = RequestMethod.GET,
     produces = "application/pdf")
 public void getReport(
     @PathVariable("id") Integer id,
     @RequestParam("start") String s,
     @RequestParam("end") String e,
     @PathVariable("type") String type,
     HttpServletResponse response)
     throws IOException {
   DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
   if (type.equals("pdf")) gen = new PDFGenerator();
   else gen = new SheetGenerator();
   try {
     Date start = formatter.parse(s);
     Date end = formatter.parse(e);
     String dateHeader = start + " - " + end;
     Collection<Activity> acts =
         activityRepository.findByDateBetweenAndEmplIdAndSubmittedTrue(start, end, id);
     InputStream is = new FileInputStream(gen.getDocumentByStaff(acts, dateHeader));
     if (type.equals("pdf")) response.setContentType("application/pdf");
     else
       response.setContentType(
           "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
     OutputStream os = response.getOutputStream();
     int n = 0;
     byte[] byteBuffer = new byte[16384];
     while ((n = is.read(byteBuffer)) > -1) {
       os.write(byteBuffer, 0, n); // Don't allow any extra bytes to creep in, final write
     }
     response.flushBuffer();
   } catch (Exception ex) {
   }
 }
 @RequestMapping(
     value = "staff/{id}/{m}/{type}",
     method = RequestMethod.GET,
     produces = "application/xls")
 public void getStaffReportByMonth(
     @PathVariable("id") Integer id,
     @PathVariable("m") Integer month,
     @PathVariable("type") String type,
     HttpServletResponse response)
     throws IOException {
   String dateHeader = new DateFormatSymbols().getMonths()[month];
   if (type.equals("pdf")) gen = new PDFGenerator();
   else gen = new SheetGenerator();
   Calendar cal = Calendar.getInstance();
   cal.set(Calendar.MONTH, month);
   cal.set(Calendar.DAY_OF_MONTH, 1);
   Date beginDate = new Date(cal.getTime().getTime());
   cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
   Date endDate = new Date(cal.getTime().getTime());
   Collection<Activity> list =
       activityRepository.findByDateBetweenAndEmplIdAndSubmittedTrue(beginDate, endDate, id);
   try {
     InputStream is = new FileInputStream(gen.getDocumentByStaff(list, dateHeader));
     if (type.equals("pdf")) response.setContentType("application/pdf");
     else
       response.setContentType(
           "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
     OutputStream os = response.getOutputStream();
     int n = 0;
     byte[] byteBuffer = new byte[16384];
     while ((n = is.read(byteBuffer)) > -1) {
       os.write(byteBuffer, 0, n); // Don't allow any extra bytes to creep in, final write
     }
     response.flushBuffer();
   } catch (Exception ex) {
   }
 }