private void viewReport() throws Exception {
    Date fromDate = fromDatePicker.getDate();
    Date toDate = toDatePicker.getDate();

    if (fromDate.after(toDate)) {
      POSMessageDialog.showError(
          BackOfficeWindow.getInstance(),
          com.floreantpos.POSConstants.FROM_DATE_CANNOT_BE_GREATER_THAN_TO_DATE_);
      return;
    }

    fromDate = DateUtil.startOfDay(fromDate);
    toDate = DateUtil.endOfDay(toDate);

    ReportService reportService = new ReportService();
    MenuUsageReport report = reportService.getMenuUsageReport(fromDate, toDate);

    HashMap<String, Object> map = new HashMap<String, Object>();
    map.put("reportTitle", "========= LAPORAN PENJUALAN PER MENU ==========");
    map.put("fromDate", ReportService.formatShortDate(fromDate));
    map.put("toDate", ReportService.formatShortDate(toDate));
    map.put("reportTime", ReportService.formatFullDate(new Date()));

    JasperReport jasperReport =
        (JasperReport)
            JRLoader.loadObject(
                getClass().getResource("/com/floreantpos/ui/report/menu_usage_report.jasper"));
    JasperPrint jasperPrint =
        JasperFillManager.fillReport(
            jasperReport, map, new JRTableModelDataSource(report.getTableModel()));
    JRViewer viewer = new JRViewer(jasperPrint);
    reportContainer.removeAll();
    reportContainer.add(viewer);
    reportContainer.revalidate();
  }
  private void viewReport() throws Exception {
    Date fromDate = fromDatePicker.getDate();
    Date toDate = toDatePicker.getDate();

    if (fromDate.after(toDate)) {
      POSMessageDialog.showError(
          com.floreantpos.util.POSUtil.getFocusedWindow(),
          com.floreantpos.POSConstants.FROM_DATE_CANNOT_BE_GREATER_THAN_TO_DATE_);
      return;
    }

    fromDate = DateUtil.startOfDay(fromDate);
    toDate = DateUtil.endOfDay(toDate);

    ReportService reportService = new ReportService();
    JournalReportModel report = reportService.getJournalReport(fromDate, toDate);

    HashMap<String, Object> map = new HashMap<String, Object>();
    map.put("reportTitle", "========= JOURNAL REPORT ==========");
    map.put("fromDate", ReportService.formatShortDate(fromDate));
    map.put("toDate", ReportService.formatShortDate(toDate));
    map.put("reportTime", ReportService.formatFullDate(new Date()));

    JasperReport jasperReport = ReportUtil.getReport("journal_report");
    JasperPrint jasperPrint =
        JasperFillManager.fillReport(
            jasperReport, map, new JRTableModelDataSource(report.getTableModel()));
    JRViewer viewer = new JRViewer(jasperPrint);
    reportContainer.removeAll();
    reportContainer.add(viewer);
    reportContainer.revalidate();
  }
  private void viewReport() throws Exception {
    Date fromDate = fromDatePicker.getDate();
    Date toDate = toDatePicker.getDate();

    if (fromDate.after(toDate)) {
      POSMessageDialog.showError(
          BackOfficeWindow.getInstance(),
          com.floreantpos.POSConstants.FROM_DATE_CANNOT_BE_GREATER_THAN_TO_DATE_);
      return;
    }

    fromDate = DateUtil.startOfDay(fromDate);
    toDate = DateUtil.endOfDay(toDate);

    ReportService reportService = new ReportService();
    CreditCardReport report = reportService.getCreditCardReport(fromDate, toDate);

    HashMap<String, Object> map = new HashMap<String, Object>();
    ReportUtil.populateRestaurantProperties(map);
    map.put(
        "reportTitle",
        "========= " + Messages.getString("PosMessage.142").toUpperCase() + " ==========");
    map.put("fromDate", ReportService.formatShortDate(fromDate));
    map.put("toDate", ReportService.formatShortDate(toDate));
    map.put("reportTime", ReportService.formatFullDate(new Date()));

    map.put("salesCount", String.valueOf(report.getTotalSalesCount()));
    map.put("totalSales", NumberUtil.formatNumber(report.getTotalSales()));
    map.put("netTips", NumberUtil.formatNumber(report.getNetTips()));
    map.put("netTipsPaid", NumberUtil.formatNumber(report.getTipsPaid()));
    map.put("netCharge", NumberUtil.formatNumber(report.getNetCharge()));

    JasperReport jasperReport =
        (JasperReport)
            JRLoader.loadObject(
                getClass().getResource("/com/floreantpos/ui/report/credit_card_report.jasper"));
    JasperPrint jasperPrint =
        JasperFillManager.fillReport(
            jasperReport, map, new JRTableModelDataSource(report.getTableModel()));
    JRViewer viewer = new JRViewer(jasperPrint);
    reportContainer.removeAll();
    reportContainer.add(viewer);
    reportContainer.revalidate();
  }
  @Override
  public void refresh() throws Exception {
    // Date date1 = DateUtils.startOfDay(getStartDate());
    // Date date2 = DateUtils.endOfDay(getEndDate());

    List<Ticket> tickets = TicketDAO.getInstance().findOpenTickets();
    TicketReportModel reportModel = new TicketReportModel();
    reportModel.setItems(tickets);

    HashMap map = new HashMap();
    ReportUtil.populateRestaurantProperties(map);
    map.put(
        "reportTitle",
        Messages.getString("OpenTicketSummaryReport.0")); // $NON-NLS-1$ //$NON-NLS-2$
    map.put("reportTime", ReportService.formatFullDate(new Date())); // $NON-NLS-1$
    // map.put("dateRange", Application.formatDate(date1) + " to " + Application.formatDate(date2));
    map.put("terminalName", com.floreantpos.POSConstants.ALL); // $NON-NLS-1$

    JasperReport masterReport = ReportUtil.getReport("open_ticket_summary_report"); // $NON-NLS-1$
    JasperPrint print =
        JasperFillManager.fillReport(masterReport, map, new JRTableModelDataSource(reportModel));
    viewer = new JRViewer(print);
  }