@Override
  public List<MaintenanceSpendBySupplier> getMaintenanceSpendBetweenTwoDates(Date from, Date to) {
    Date fromDate = dateTimeFormatHelper.resetTimeAndMonthStart(from);
    Date toDate = dateTimeFormatHelper.resetTimeAndMonthEnd(to);
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(toDate);
    // Set time fields to last hour:minute:second:millisecond
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    calendar.set(Calendar.MILLISECOND, 999);

    Query maintenanceSpendListQuery = new Query();
    maintenanceSpendListQuery.addCriteria(
        Criteria.where("transactionDate")
            .exists(true)
            .andOperator(
                Criteria.where("transactionDate").gte(fromDate),
                Criteria.where("transactionDate").lte(calendar.getTime())));

    /*
    List<MaintenanceSpendBySupplier> maintenanceSpendList = mongoOperation.find(maintenanceSpendListQuery, MaintenanceSpendBySupplier.class);

    System.out.println(" MaintenanceSpendBySupplierRepository - GENERAL QUERY - Start= " + to + " | To= " + to);
    if (maintenanceSpendList.isEmpty()) {
    System.out.println("MaintenanceSpendBySupplierRepository  - GENERAL QUERY - NO MATCHING RECORDS FOUND");
    }

    for (MaintenanceSpendBySupplier maintenanceSpend : maintenanceSpendList) {
    System.out.println(" MaintenanceSpendBySupplierRepository - GENERAL QUERY - Date= " + maintenanceSpend.getTransactionDate() + " | Cost= " + maintenanceSpend.getMaintenanceCost() + " | Truck= " + maintenanceSpend.getTruckId() + " | Supplier" + maintenanceSpend.getSupplierId());
    }
    System.out.println("--==--");
    */
    return mongoOperation.find(maintenanceSpendListQuery, MaintenanceSpendBySupplier.class);
  }
 @Override
 public List<MaintenanceSpendBySupplier> getMaintenanceSpendBySupplierBetweenTwoDates(
     ServiceProvider serviceProvider, Date from, Date to) {
   Date fromDate = dateTimeFormatHelper.resetTimeAndMonthStart(from);
   Date toDate = dateTimeFormatHelper.resetTimeAndMonthEnd(to);
   Calendar calendar = Calendar.getInstance();
   calendar.setTime(toDate);
   // Set time fields to last hour:minute:second:millisecond
   calendar.set(Calendar.HOUR_OF_DAY, 23);
   calendar.set(Calendar.MINUTE, 59);
   calendar.set(Calendar.SECOND, 59);
   calendar.set(Calendar.MILLISECOND, 999);
   return getSupplierMaintenanceSpend(serviceProvider, fromDate, calendar.getTime());
 }
  @Override
  public List<MaintenanceSpendBySupplier> getMaintenanceSpendByTruckForMonth(
      Truck truck, Date month) {
    Date from = dateTimeFormatHelper.resetTimeAndMonthStart(month);
    Date to = dateTimeFormatHelper.resetTimeAndMonthEnd(month);
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(to);
    // Set time fields to last hour:minute:second:millisecond
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    calendar.set(Calendar.MILLISECOND, 999);

    return getTruckMaintenanceSpend(truck, from, calendar.getTime());
  }
  public AssignedDriversTable(MshenguMain main) {
    this.main = main;
    setSizeFull();

    addContainerProperty("Vehicle Number", String.class, null);
    addContainerProperty("Brand", String.class, null);
    addContainerProperty("Model", String.class, null);
    addContainerProperty("Number Plate", String.class, null);
    addContainerProperty("Expire Date", String.class, null);
    addContainerProperty("Driver", String.class, null);
    addContainerProperty("In Service?", Boolean.class, null);
    // addContainerProperty("Contact Number", String.class, null);

    // Add Data Columns
    List<Truck> truckList = TruckFacade.getTruckService().findAll();
    for (Truck truck : truckList) {
      addItem(
          new Object[] {
            truck.getVehicleNumber(),
            truck.getBrand(),
            truck.getModel(),
            truck.getNumberPlate(),
            formatHelper.getYearMonthDay(truck.getDateOfExpire()),
            truck.getDriverName(),
            truck.isIsActive(),
          },
          truck.getId());
    }
    // Allow selecting items from the table.
    setNullSelectionAllowed(false);

    setSelectable(true);
    // Send changes in selection immediately to server.
    setImmediate(true);
  }
  public InnactiveServiceRequestTable(
      final MshenguMain main, final InnactiveServiceRequestTab tab) {
    this.main = main;
    setSizeFull();

    addContainerProperty("Ref Number", String.class, null);
    addContainerProperty("Request Date", String.class, null);
    addContainerProperty("Customer", String.class, null);
    addContainerProperty("Site", String.class, null);
    addContainerProperty("Contact Person", String.class, null);
    addContainerProperty("Contact Number", String.class, null);
    //        addContainerProperty("Cell Number", String.class, null);
    //        addContainerProperty("Email", String.class, null);
    addContainerProperty("Request Type", String.class, null);
    addContainerProperty("Status ", String.class, null);
    addContainerProperty("Follow Up", Button.class, null);

    // Add Data Columns
    List<ServiceRequest> serviceRequestList =
        ServiceRequestFacade.getServiceRequestService().findAllClosed();
    for (ServiceRequest serviceRequest : serviceRequestList) {

      Button followUpButton = new Button("Follow up");
      followUpButton.setStyleName(Reindeer.BUTTON_LINK);
      followUpButton.setData(serviceRequest.getId());
      followUpButton.addClickListener(
          new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
              String incidentId = (String) event.getButton().getData();
              InnactiveServiceRequestFollowUpTab form =
                  new InnactiveServiceRequestFollowUpTab(main, incidentId);
              tab.removeAllComponents();
              tab.addComponent(form);
            }
          });
      String customerName = getCustomerName(serviceRequest.getCustomerId());
      String siteName = getSiteName(serviceRequest.getSiteId());
      addItem(
          new Object[] {
            serviceRequest.getRefNumber(),
            formatHelper.getDayMonthYear(serviceRequest.getRequestDate()),
            customerName,
            siteName,
            serviceRequest.getContactPersonName(),
            serviceRequest.getContactPersonMainNumber(),
            //                    serviceRequest.getContactPersonAlternativeNumber(),
            //                    serviceRequest.getContactPersonEmail(),
            //                    formatHelper.getDayMonthYear(serviceRequest.getDeliveryDate()),
            serviceRequest.getServiceRequestTypeName(),
            serviceRequest.getLastUserActionStatusName(), //
            // iconHelper.getCheckOrBlank(serviceRequest.isClosed()),
            followUpButton,
          },
          serviceRequest.getId());
    }
    // Allow selecting items from the table.
    setNullSelectionAllowed(false);

    setSelectable(true);
    // Send changes in selection immediately to server.
    setImmediate(true);
  }