Search in sources :

Example 1 with ExtraHours

use of com.axelor.apps.hr.db.ExtraHours in project axelor-open-suite by axelor.

the class ExtraHoursController method cancel.

// canceling request and sending mail to applicant
public void cancel(ActionRequest request, ActionResponse response) throws AxelorException {
    try {
        ExtraHours extraHours = request.getContext().asType(ExtraHours.class);
        extraHours = Beans.get(ExtraHoursRepository.class).find(extraHours.getId());
        Beans.get(ExtraHoursService.class).cancel(extraHours);
        Message message = Beans.get(ExtraHoursService.class).sendCancellationEmail(extraHours);
        if (message != null && message.getStatusSelect() == MessageRepository.STATUS_SENT) {
            response.setFlash(String.format(I18n.get("Email sent to %s"), Beans.get(MessageServiceBaseImpl.class).getToRecipients(message)));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    } finally {
        response.setReload(true);
    }
}
Also used : ExtraHours(com.axelor.apps.hr.db.ExtraHours) Message(com.axelor.apps.message.db.Message) MessageServiceBaseImpl(com.axelor.apps.base.service.message.MessageServiceBaseImpl) ExtraHoursService(com.axelor.apps.hr.service.extra.hours.ExtraHoursService) AxelorException(com.axelor.exception.AxelorException)

Example 2 with ExtraHours

use of com.axelor.apps.hr.db.ExtraHours in project axelor-open-suite by axelor.

the class ExtraHoursController method refuse.

// refusing request and sending mail to applicant
public void refuse(ActionRequest request, ActionResponse response) throws AxelorException {
    try {
        ExtraHours extraHours = request.getContext().asType(ExtraHours.class);
        extraHours = Beans.get(ExtraHoursRepository.class).find(extraHours.getId());
        Beans.get(ExtraHoursService.class).refuse(extraHours);
        Message message = Beans.get(ExtraHoursService.class).sendRefusalEmail(extraHours);
        if (message != null && message.getStatusSelect() == MessageRepository.STATUS_SENT) {
            response.setFlash(String.format(I18n.get("Email sent to %s"), Beans.get(MessageServiceBaseImpl.class).getToRecipients(message)));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    } finally {
        response.setReload(true);
    }
}
Also used : ExtraHours(com.axelor.apps.hr.db.ExtraHours) Message(com.axelor.apps.message.db.Message) MessageServiceBaseImpl(com.axelor.apps.base.service.message.MessageServiceBaseImpl) ExtraHoursService(com.axelor.apps.hr.service.extra.hours.ExtraHoursService) AxelorException(com.axelor.exception.AxelorException)

Example 3 with ExtraHours

use of com.axelor.apps.hr.db.ExtraHours in project axelor-open-suite by axelor.

the class ExtraHoursController method editExtraHoursSelected.

public void editExtraHoursSelected(ActionRequest request, ActionResponse response) {
    Map extraHoursMap = (Map) request.getContext().get("extraHoursSelect");
    ExtraHours extraHours = Beans.get(ExtraHoursRepository.class).find(new Long((Integer) extraHoursMap.get("id")));
    response.setView(ActionView.define("Extra hours").model(ExtraHours.class.getName()).add("form", "extra-hours-form").param("forceEdit", "true").domain("self.id = " + extraHoursMap.get("id")).context("_showRecord", String.valueOf(extraHours.getId())).map());
}
Also used : ExtraHours(com.axelor.apps.hr.db.ExtraHours) ExtraHoursRepository(com.axelor.apps.hr.db.repo.ExtraHoursRepository) Map(java.util.Map)

Example 4 with ExtraHours

use of com.axelor.apps.hr.db.ExtraHours in project axelor-open-suite by axelor.

the class ExtraHoursController method compute.

// counting total hours while computing extra hours lines
public void compute(ActionRequest request, ActionResponse response) {
    try {
        ExtraHours extraHours = request.getContext().asType(ExtraHours.class);
        Beans.get(ExtraHoursService.class).compute(extraHours);
        response.setValue("totalQty", extraHours.getTotalQty());
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ExtraHours(com.axelor.apps.hr.db.ExtraHours) ExtraHoursService(com.axelor.apps.hr.service.extra.hours.ExtraHoursService) AxelorException(com.axelor.exception.AxelorException)

Example 5 with ExtraHours

use of com.axelor.apps.hr.db.ExtraHours in project axelor-open-suite by axelor.

the class ExtraHoursController method confirm.

// confirming request and sending mail to manager
public void confirm(ActionRequest request, ActionResponse response) throws AxelorException {
    try {
        ExtraHours extraHours = request.getContext().asType(ExtraHours.class);
        extraHours = Beans.get(ExtraHoursRepository.class).find(extraHours.getId());
        Beans.get(ExtraHoursService.class).confirm(extraHours);
        Message message = Beans.get(ExtraHoursService.class).sendConfirmationEmail(extraHours);
        if (message != null && message.getStatusSelect() == MessageRepository.STATUS_SENT) {
            response.setFlash(String.format(I18n.get("Email sent to %s"), Beans.get(MessageServiceBaseImpl.class).getToRecipients(message)));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    } finally {
        response.setReload(true);
    }
}
Also used : ExtraHours(com.axelor.apps.hr.db.ExtraHours) Message(com.axelor.apps.message.db.Message) MessageServiceBaseImpl(com.axelor.apps.base.service.message.MessageServiceBaseImpl) ExtraHoursService(com.axelor.apps.hr.service.extra.hours.ExtraHoursService) AxelorException(com.axelor.exception.AxelorException)

Aggregations

ExtraHours (com.axelor.apps.hr.db.ExtraHours)6 ExtraHoursService (com.axelor.apps.hr.service.extra.hours.ExtraHoursService)5 AxelorException (com.axelor.exception.AxelorException)5 MessageServiceBaseImpl (com.axelor.apps.base.service.message.MessageServiceBaseImpl)4 Message (com.axelor.apps.message.db.Message)4 PeriodService (com.axelor.apps.base.service.PeriodService)1 ExtraHoursRepository (com.axelor.apps.hr.db.repo.ExtraHoursRepository)1 Map (java.util.Map)1