Search in sources :

Example 1 with Ticket

use of com.axelor.apps.helpdesk.db.Ticket in project axelor-open-suite by axelor.

the class TicketServiceImpl method assignToMeTicket.

/**
 * Ticket assign to the current user.
 */
@Override
@Transactional
public void assignToMeTicket(Long id, List<?> ids) {
    if (id != null) {
        Ticket ticket = ticketRepo.find(id);
        ticket.setAssignedToUser(AuthUtils.getUser());
        ticketRepo.save(ticket);
    } else if (!ids.isEmpty()) {
        for (Ticket ticket : ticketRepo.all().filter("id in ?1", ids).fetch()) {
            ticket.setAssignedToUser(AuthUtils.getUser());
            ticketRepo.save(ticket);
        }
    }
}
Also used : Ticket(com.axelor.apps.helpdesk.db.Ticket) Transactional(com.google.inject.persist.Transactional)

Example 2 with Ticket

use of com.axelor.apps.helpdesk.db.Ticket in project axelor-open-suite by axelor.

the class TimerTicketServiceImpl method start.

@Override
@Transactional(rollbackOn = { Exception.class })
public TimerHistory start(Model model, Timer timer, LocalDateTime dateTime) throws AxelorException {
    Ticket ticket = (Ticket) model;
    boolean isNewTimer = timer == null;
    timer = tryStartOrCreate(timer);
    if (isNewTimer) {
        ticket.addTimerListItem(timer);
    }
    TimerHistory history = new TimerHistory();
    history.setStartDateT(dateTime);
    history.setTimer(timer);
    timer.addTimerHistoryListItem(history);
    return timerHistoryRepository.save(history);
}
Also used : Ticket(com.axelor.apps.helpdesk.db.Ticket) TimerHistory(com.axelor.apps.base.db.TimerHistory) Transactional(com.google.inject.persist.Transactional)

Example 3 with Ticket

use of com.axelor.apps.helpdesk.db.Ticket in project axelor-open-suite by axelor.

the class TimerTicketServiceImpl method find.

@Override
public Timer find(Model model) throws AxelorException {
    User user = userService.getUser();
    Ticket ticket = (Ticket) model;
    List<Timer> timerList = ticket.getTimerList();
    if (timerList != null && !timerList.isEmpty()) {
        return timerList.stream().filter(t -> t.getAssignedToUser() == user).findFirst().orElse(null);
    }
    return null;
}
Also used : Ticket(com.axelor.apps.helpdesk.db.Ticket) User(com.axelor.auth.db.User) Timer(com.axelor.apps.base.db.Timer)

Example 4 with Ticket

use of com.axelor.apps.helpdesk.db.Ticket in project axelor-open-suite by axelor.

the class TicketController method startTimer.

public void startTimer(ActionRequest request, ActionResponse response) {
    try {
        Ticket ticket = request.getContext().asType(Ticket.class);
        Beans.get(TimerTicketService.class).start(ticket, Beans.get(AppBaseService.class).getTodayDateTime().toLocalDateTime());
    } catch (Exception e) {
        TraceBackService.trace(response, e, ResponseMessageType.ERROR);
    }
}
Also used : Ticket(com.axelor.apps.helpdesk.db.Ticket) AppBaseService(com.axelor.apps.base.service.app.AppBaseService) TimerTicketService(com.axelor.apps.helpdesk.service.TimerTicketService)

Example 5 with Ticket

use of com.axelor.apps.helpdesk.db.Ticket in project axelor-open-suite by axelor.

the class TicketController method computeFromEndDateTime.

/**
 * Compute duration or startDateTime from endDateTime
 *
 * @param request
 * @param response
 */
public void computeFromEndDateTime(ActionRequest request, ActionResponse response) {
    try {
        Ticket ticket = request.getContext().asType(Ticket.class);
        if (ticket.getEndDateT() != null) {
            if (ticket.getStartDateT() != null && ticket.getStartDateT().isBefore(ticket.getEndDateT())) {
                Duration duration = DurationTool.computeDuration(ticket.getStartDateT(), ticket.getEndDateT());
                response.setValue("duration", DurationTool.getSecondsDuration(duration));
            } else if (ticket.getDuration() != null) {
                response.setValue("startDateT", DateTool.minusSeconds(ticket.getEndDateT(), ticket.getDuration()));
            }
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Ticket(com.axelor.apps.helpdesk.db.Ticket) Duration(java.time.Duration)

Aggregations

Ticket (com.axelor.apps.helpdesk.db.Ticket)15 TimerTicketService (com.axelor.apps.helpdesk.service.TimerTicketService)5 User (com.axelor.auth.db.User)5 ClientViewService (com.axelor.apps.portal.service.ClientViewService)4 Filter (com.axelor.rpc.filter.Filter)4 Transactional (com.google.inject.persist.Transactional)4 Timer (com.axelor.apps.base.db.Timer)2 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)2 TicketRepository (com.axelor.apps.helpdesk.db.repo.TicketRepository)2 Duration (java.time.Duration)2 TimerHistory (com.axelor.apps.base.db.TimerHistory)1