示例#1
0
  private void doLogin() throws RuntimeException {

    Application application = Application.getInstance();

    UserDAO dao = new UserDAO();
    User user = dao.findUser(Integer.valueOf(userId));
    if (!user.getPassword().equals(PasswordHasher.hashPassword(userPassword))) {
      throw new RuntimeException(POSConstants.WRONG_PASSWORD);
    }

    Shift currentShift = ShiftUtil.getCurrentShift();
    if (currentShift == null) {
      throw new RuntimeException(POSConstants.NO_SHIFT_CONFIGURED);
    }

    adjustUserShift(user, currentShift);

    application.setCurrentUser(user);
    application.setCurrentShift(currentShift);

    application.getRootView().showView(SwitchboardView.VIEW_NAME);
  }
  public void updateTicketList() {
    User user = Application.getCurrentUser();

    TicketDAO dao = TicketDAO.getInstance();
    List<Ticket> openTickets;

    boolean showAllOpenTicket = false;
    if (user.getNewUserType() != null) {
      Set<UserPermission> permissions = user.getNewUserType().getPermissions();
      if (permissions != null) {
        for (UserPermission permission : permissions) {
          if (permission.equals(UserPermission.VIEW_ALL_OPEN_TICKET)) {
            showAllOpenTicket = true;
            break;
          }
        }
      }
    }

    if (showAllOpenTicket) {
      openTickets = dao.findOpenTickets();
    } else {
      openTickets = dao.findOpenTicketsForUser(user);
    }
    openTicketList.setTickets(openTickets);

    lblUserName.setText(
        POSConstants.WELCOME
            + " "
            + user.toString()
            + ". "
            + POSConstants.YOU
            + " "
            + POSConstants.HAVE
            + " "
            + openTickets.size()
            + " "
            + POSConstants.TICKETS);
  }
示例#3
0
  private void reClockInUser(Calendar currentTime, User user, Shift currentShift) {
    POSMessageDialog.showMessage("You will be clocked out from previous Shift");

    Application application = Application.getInstance();
    AttendenceHistoryDAO attendenceHistoryDAO = new AttendenceHistoryDAO();

    AttendenceHistory attendenceHistory = attendenceHistoryDAO.findHistoryByClockedInTime(user);
    if (attendenceHistory == null) {
      attendenceHistory = new AttendenceHistory();
      Date lastClockInTime = user.getLastClockInTime();
      Calendar c = Calendar.getInstance();
      c.setTime(lastClockInTime);
      attendenceHistory.setClockInTime(lastClockInTime);
      attendenceHistory.setClockInHour(Short.valueOf((short) c.get(Calendar.HOUR)));
      attendenceHistory.setUser(user);
      attendenceHistory.setTerminal(application.getTerminal());
      attendenceHistory.setShift(user.getCurrentShift());
    }

    user.doClockOut(attendenceHistory, currentShift, currentTime);

    user.doClockIn(application.getTerminal(), currentShift, currentTime);
  }
  private void doClockOut() {
    int option =
        JOptionPane.showOptionDialog(
            this,
            POSConstants.CONFIRM_CLOCK_OUT,
            POSConstants.CONFIRM,
            JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            null,
            null);
    if (option != JOptionPane.YES_OPTION) {
      return;
    }

    User user = Application.getCurrentUser();
    AttendenceHistoryDAO attendenceHistoryDAO = new AttendenceHistoryDAO();
    AttendenceHistory attendenceHistory = attendenceHistoryDAO.findHistoryByClockedInTime(user);
    if (attendenceHistory == null) {
      attendenceHistory = new AttendenceHistory();
      Date lastClockInTime = user.getLastClockInTime();
      Calendar c = Calendar.getInstance();
      c.setTime(lastClockInTime);
      attendenceHistory.setClockInTime(lastClockInTime);
      attendenceHistory.setClockInHour((short) c.get(Calendar.HOUR));
      attendenceHistory.setUser(user);
      attendenceHistory.setTerminal(Application.getInstance().getTerminal());
      attendenceHistory.setShift(user.getCurrentShift());
    }

    Shift shift = user.getCurrentShift();
    Calendar calendar = Calendar.getInstance();

    user.doClockOut(attendenceHistory, shift, calendar);

    Application.getInstance().logout();
  }
示例#5
0
  public EmployeeInOutHistory findDriverHistoryByClockedInTime(User user) {
    Session session = null;

    try {
      session = getSession();
      Criteria criteria = session.createCriteria(EmployeeInOutHistory.class);
      criteria.add(Restrictions.eq(EmployeeInOutHistory.PROP_OUT_TIME, user.getLastClockOutTime()));
      criteria.add(Restrictions.eq(EmployeeInOutHistory.PROP_USER, user));

      return (EmployeeInOutHistory) criteria.uniqueResult();
    } finally {
      if (session != null) {
        closeSession(session);
      }
    }
  }
示例#6
0
  private void adjustUserShift(User user, Shift currentShift) {
    Application application = Application.getInstance();
    Calendar currentTime = Calendar.getInstance();

    if (user.isClockedIn() != null && user.isClockedIn().booleanValue()) {
      Shift userShift = user.getCurrentShift();
      Date userLastClockInTime = user.getLastClockInTime();
      long elaspedTimeSinceLastLogin =
          Math.abs(currentTime.getTimeInMillis() - userLastClockInTime.getTime());

      if (userShift != null) {
        if (!userShift.equals(currentShift)) {
          reClockInUser(currentTime, user, currentShift);
        } else if (userShift.getShiftLength() != null
            && (elaspedTimeSinceLastLogin >= userShift.getShiftLength())) {
          reClockInUser(currentTime, user, currentShift);
        }
      } else {
        user.doClockIn(application.getTerminal(), currentShift, currentTime);
      }
    } else {
      user.doClockIn(application.getTerminal(), currentShift, currentTime);
    }
  }
  public void updateView() {
    User user = Application.getCurrentUser();
    UserType userType = user.getNewUserType();
    if (userType != null) {
      Set<UserPermission> permissions = userType.getPermissions();
      if (permissions != null) {
        btnNewTicket.setEnabled(false);
        btnBackOffice.setEnabled(false);
        btnEditTicket.setEnabled(false);

        if (!"false".equalsIgnoreCase(AppConfig.getFeatureGroupTicketFlag())) {
          btnGroupSettle.setEnabled(false);
        }

        if (!"false".equalsIgnoreCase(AppConfig.getManagerMenuFlag())) {
          btnManager.setEnabled(false);
        }

        if (!"false".equalsIgnoreCase(AppConfig.getFeaturePenarikanFlag())) {
          btnPayout.setEnabled(false);
        }

        btnReopenTicket.setEnabled(false);
        btnSettleTicket.setEnabled(false);

        if (!"false".equalsIgnoreCase(AppConfig.getFeatureSplitTicketFlag())) {
          btnSplitTicket.setEnabled(false);
        }

        btnTakeout.setEnabled(false);
        btnVoidTicket.setEnabled(false);

        for (UserPermission permission : permissions) {
          if (permission.equals(UserPermission.VOID_TICKET)) {
            btnVoidTicket.setEnabled(true);
          } else if (permission.equals(UserPermission.PAY_OUT)) {
            if (!"false".equalsIgnoreCase(AppConfig.getFeaturePenarikanFlag())) {
              btnPayout.setEnabled(true);
            }
          } else if (permission.equals(UserPermission.SETTLE_TICKET)) {
            btnSettleTicket.setEnabled(true);
            if (!"false".equalsIgnoreCase(AppConfig.getFeatureGroupTicketFlag())) {
              btnGroupSettle.setEnabled(true);
            }
          } else if (permission.equals(UserPermission.REOPEN_TICKET)) {
            btnReopenTicket.setEnabled(true);
          } else if (permission.equals(UserPermission.PERFORM_MANAGER_TASK)) {
            if (!"false".equalsIgnoreCase(AppConfig.getManagerMenuFlag())) {
              btnManager.setEnabled(true);
            }
          } else if (permission.equals(UserPermission.SPLIT_TICKET)) {
            if (!"false".equalsIgnoreCase(AppConfig.getFeatureSplitTicketFlag())) {
              btnSplitTicket.setEnabled(true);
            }
          } else if (permission.equals(UserPermission.TAKE_OUT)) {
            btnTakeout.setEnabled(true);
          } else if (permission.equals(UserPermission.VIEW_BACK_OFFICE)) {
            btnBackOffice.setEnabled(true);
          }
          //                    else if (permission.equals(UserPermission.PAY_OUT)) {
          //                        btnPayout.setEnabled(true);
          //                    }
          else if (permission.equals(UserPermission.EDIT_TICKET)) {
            btnEditTicket.setEnabled(true);
          } else if (permission.equals(UserPermission.CREATE_NEW_TICKET)) {
            btnNewTicket.setEnabled(true);
          }
        }
      }
    }

    updateTicketList();
  }