Search in sources :

Example 1 with CustomerNoteFormDto

use of org.mifos.dto.screen.CustomerNoteFormDto in project head by mifos.

the class CenterServiceFacadeWebTier method retrieveCustomerNote.

@Override
public CustomerNoteFormDto retrieveCustomerNote(String globalCustNum) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    CustomerBO customer = this.customerDao.findCustomerBySystemId(globalCustNum);
    PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
    Integer customerLevel = customer.getCustomerLevel().getId().intValue();
    String globalNum = customer.getGlobalCustNum();
    String displayName = customer.getDisplayName();
    LocalDate commentDate = new LocalDate();
    String commentUser = loggedInUser.getDisplayName();
    return new CustomerNoteFormDto(globalNum, displayName, customerLevel, commentDate, commentUser, "");
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) CustomerBO(org.mifos.customers.business.CustomerBO) MifosUser(org.mifos.security.MifosUser) CustomerNoteFormDto(org.mifos.dto.screen.CustomerNoteFormDto) LocalDate(org.joda.time.LocalDate)

Example 2 with CustomerNoteFormDto

use of org.mifos.dto.screen.CustomerNoteFormDto in project head by mifos.

the class CustomerNotesAction method load.

@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In CustomerNotesAction::load()");
    CustomerNotesActionForm notesActionForm = (CustomerNotesActionForm) form;
    notesActionForm.setComment("");
    notesActionForm.setCommentDate("");
    UserContext userContext = getUserContext(request);
    Integer customerId = Integer.valueOf(((CustomerNotesActionForm) form).getCustomerId());
    CustomerBO customerBO = this.customerDao.findCustomerById(customerId);
    customerBO.setUserContext(userContext);
    CustomerNoteFormDto noteDto = this.centerServiceFacade.retrieveCustomerNote(customerBO.getGlobalCustNum());
    notesActionForm.setLevelId(noteDto.getCustomerLevel().toString());
    notesActionForm.setGlobalCustNum(noteDto.getGlobalNum());
    notesActionForm.setCustomerName(noteDto.getDisplayName());
    notesActionForm.setCommentDate(DateUtils.getCurrentDate(userContext.getPreferredLocale()));
    if (customerBO.isCenter()) {
        notesActionForm.setInput("center");
    } else if (customerBO.isGroup()) {
        notesActionForm.setInput("group");
    } else if (customerBO.isClient()) {
        notesActionForm.setInput("client");
    }
    SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, customerBO, request);
    SessionUtils.setAttribute(CustomerConstants.PERSONNEL_NAME, noteDto.getCommentUser(), request);
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : CustomerNotesActionForm(org.mifos.customers.struts.actionforms.CustomerNotesActionForm) UserContext(org.mifos.security.util.UserContext) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerNoteFormDto(org.mifos.dto.screen.CustomerNoteFormDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with CustomerNoteFormDto

use of org.mifos.dto.screen.CustomerNoteFormDto in project head by mifos.

the class CustomerNotesAction method create.

@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In CustomerNotesAction::create()");
    ActionForward forward = null;
    CustomerNotesActionForm notesActionForm = (CustomerNotesActionForm) form;
    Integer customerId = Integer.valueOf(((CustomerNotesActionForm) form).getCustomerId());
    CustomerBO customerBO = this.customerDao.findCustomerById(customerId);
    UserContext uc = getUserContext(request);
    if (customerBO.getPersonnel() != null) {
        checkPermissionForAddingNotes(AccountTypes.CUSTOMER_ACCOUNT, customerBO.getLevel(), uc, customerBO.getOffice().getOfficeId(), customerBO.getPersonnel().getPersonnelId());
    } else {
        checkPermissionForAddingNotes(AccountTypes.CUSTOMER_ACCOUNT, customerBO.getLevel(), uc, customerBO.getOffice().getOfficeId(), uc.getId());
    }
    CustomerNoteFormDto customerNoteForm = new CustomerNoteFormDto(customerBO.getGlobalCustNum(), customerBO.getDisplayName(), customerBO.getCustomerLevel().getId().intValue(), new LocalDate(), "", notesActionForm.getComment());
    this.centerServiceFacade.createCustomerNote(customerNoteForm);
    forward = mapping.findForward(getDetailCustomerPage(notesActionForm));
    return forward;
}
Also used : CustomerNotesActionForm(org.mifos.customers.struts.actionforms.CustomerNotesActionForm) UserContext(org.mifos.security.util.UserContext) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerNoteFormDto(org.mifos.dto.screen.CustomerNoteFormDto) LocalDate(org.joda.time.LocalDate) ActionForward(org.apache.struts.action.ActionForward) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

CustomerBO (org.mifos.customers.business.CustomerBO)3 CustomerNoteFormDto (org.mifos.dto.screen.CustomerNoteFormDto)3 UserContext (org.mifos.security.util.UserContext)3 LocalDate (org.joda.time.LocalDate)2 CustomerNotesActionForm (org.mifos.customers.struts.actionforms.CustomerNotesActionForm)2 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)2 ActionForward (org.apache.struts.action.ActionForward)1 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)1 CloseSession (org.mifos.framework.util.helpers.CloseSession)1 MifosUser (org.mifos.security.MifosUser)1