Search in sources :

Example 6 with Message

use of com.axelor.apps.message.db.Message in project axelor-open-suite by axelor.

the class TimesheetController method refuse.

// action called when refusing a timesheet. Changing status + Sending mail to Applicant
public void refuse(ActionRequest request, ActionResponse response) throws AxelorException {
    try {
        Timesheet timesheet = request.getContext().asType(Timesheet.class);
        timesheet = Beans.get(TimesheetRepository.class).find(timesheet.getId());
        Message message = Beans.get(TimesheetService.class).refuseAndSendRefusalEmail(timesheet);
        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 : Message(com.axelor.apps.message.db.Message) Timesheet(com.axelor.apps.hr.db.Timesheet) MessageServiceBaseImpl(com.axelor.apps.base.service.message.MessageServiceBaseImpl) TimesheetService(com.axelor.apps.hr.service.timesheet.TimesheetService) AxelorException(com.axelor.exception.AxelorException)

Example 7 with Message

use of com.axelor.apps.message.db.Message in project axelor-open-suite by axelor.

the class TimesheetController method cancel.

public void cancel(ActionRequest request, ActionResponse response) {
    try {
        Timesheet timesheet = request.getContext().asType(Timesheet.class);
        timesheet = Beans.get(TimesheetRepository.class).find(timesheet.getId());
        Message message = Beans.get(TimesheetService.class).cancelAndSendCancellationEmail(timesheet);
        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 : Message(com.axelor.apps.message.db.Message) Timesheet(com.axelor.apps.hr.db.Timesheet) MessageServiceBaseImpl(com.axelor.apps.base.service.message.MessageServiceBaseImpl) TimesheetService(com.axelor.apps.hr.service.timesheet.TimesheetService) AxelorException(com.axelor.exception.AxelorException)

Example 8 with Message

use of com.axelor.apps.message.db.Message in project axelor-open-suite by axelor.

the class TimesheetController method confirm.

/**
 * Action called when confirming a timesheet. Changing status + Sending mail to Manager
 *
 * @param request
 * @param response
 */
public void confirm(ActionRequest request, ActionResponse response) {
    try {
        Timesheet timesheet = request.getContext().asType(Timesheet.class);
        timesheet = Beans.get(TimesheetRepository.class).find(timesheet.getId());
        Message message = Beans.get(TimesheetService.class).confirmAndSendConfirmationEmail(timesheet);
        if (message != null && message.getStatusSelect() == MessageRepository.STATUS_SENT) {
            response.setFlash(String.format(I18n.get("Email sent to %s"), Beans.get(MessageServiceBaseImpl.class).getToRecipients(message)));
        }
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(e);
        response.setError(e.getMessage());
    }
}
Also used : Message(com.axelor.apps.message.db.Message) Timesheet(com.axelor.apps.hr.db.Timesheet) MessageServiceBaseImpl(com.axelor.apps.base.service.message.MessageServiceBaseImpl) TimesheetService(com.axelor.apps.hr.service.timesheet.TimesheetService) AxelorException(com.axelor.exception.AxelorException)

Example 9 with Message

use of com.axelor.apps.message.db.Message in project axelor-open-suite by axelor.

the class ExpenseController method refuse.

// refusing expense and sending mail to applicant
public void refuse(ActionRequest request, ActionResponse response) throws AxelorException {
    try {
        Expense expense = request.getContext().asType(Expense.class);
        expense = Beans.get(ExpenseRepository.class).find(expense.getId());
        ExpenseService expenseService = Beans.get(ExpenseService.class);
        expenseService.refuse(expense);
        Message message = expenseService.sendRefusalEmail(expense);
        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 : IExceptionMessage(com.axelor.apps.hr.exception.IExceptionMessage) Message(com.axelor.apps.message.db.Message) Expense(com.axelor.apps.hr.db.Expense) MessageServiceBaseImpl(com.axelor.apps.base.service.message.MessageServiceBaseImpl) ExpenseService(com.axelor.apps.hr.service.expense.ExpenseService) AxelorException(com.axelor.exception.AxelorException)

Example 10 with Message

use of com.axelor.apps.message.db.Message in project axelor-open-suite by axelor.

the class ExpenseController method send.

// sending expense and sending mail to manager
public void send(ActionRequest request, ActionResponse response) throws AxelorException {
    try {
        Expense expense = request.getContext().asType(Expense.class);
        expense = Beans.get(ExpenseRepository.class).find(expense.getId());
        ExpenseService expenseService = Beans.get(ExpenseService.class);
        expenseService.confirm(expense);
        Message message = expenseService.sendConfirmationEmail(expense);
        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 : IExceptionMessage(com.axelor.apps.hr.exception.IExceptionMessage) Message(com.axelor.apps.message.db.Message) Expense(com.axelor.apps.hr.db.Expense) MessageServiceBaseImpl(com.axelor.apps.base.service.message.MessageServiceBaseImpl) ExpenseService(com.axelor.apps.hr.service.expense.ExpenseService) AxelorException(com.axelor.exception.AxelorException)

Aggregations

Message (com.axelor.apps.message.db.Message)54 AxelorException (com.axelor.exception.AxelorException)25 MessageServiceBaseImpl (com.axelor.apps.base.service.message.MessageServiceBaseImpl)16 IExceptionMessage (com.axelor.apps.message.exception.IExceptionMessage)14 Transactional (com.google.inject.persist.Transactional)13 IExceptionMessage (com.axelor.apps.hr.exception.IExceptionMessage)11 Template (com.axelor.apps.message.db.Template)7 Timesheet (com.axelor.apps.hr.db.Timesheet)6 ArrayList (java.util.ArrayList)6 Employee (com.axelor.apps.hr.db.Employee)5 EmailAddress (com.axelor.apps.message.db.EmailAddress)5 IExceptionMessage (com.axelor.apps.base.exceptions.IExceptionMessage)4 Expense (com.axelor.apps.hr.db.Expense)4 ExtraHours (com.axelor.apps.hr.db.ExtraHours)4 LeaveRequest (com.axelor.apps.hr.db.LeaveRequest)4 ExpenseService (com.axelor.apps.hr.service.expense.ExpenseService)4 ExtraHoursService (com.axelor.apps.hr.service.extra.hours.ExtraHoursService)4 LeaveService (com.axelor.apps.hr.service.leave.LeaveService)4 TimesheetService (com.axelor.apps.hr.service.timesheet.TimesheetService)4 User (com.axelor.auth.db.User)4