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);
}
}
}
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);
}
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;
}
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);
}
}
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);
}
}
Aggregations