Search in sources :

Example 1 with ClientPersonalInfoDto

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

the class PictureFormFile method updatePersonalInfo.

@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updatePersonalInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    ClientBO clientInSession = getClientFromSession(request);
    Integer oldClientVersionNumber = clientInSession.getVersionNo();
    Integer customerId = clientInSession.getCustomerId();
    String clientStatus = clientInSession.getCustomerStatus().getName();
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    short loanOfficerId = clientInSession.getCreatedBy();
    final String clientSystemId = clientInSession.getGlobalCustNum();
    ClientPersonalInfoDto clientPersonalInfo = this.clientServiceFacade.retrieveClientPersonalInfoForUpdate(clientSystemId, clientStatus, loanOfficerId);
    AddressDto address = null;
    if (actionForm.getAddress() != null) {
        address = Address.toDto(actionForm.getAddress());
    }
    if (clientPersonalInfo.getCustomerDetail() != null) {
        if (clientPersonalInfo.getCustomerDetail().getAddress() != null) {
            if (clientPersonalInfo.getCustomerDetail().getAddress().getPhoneNumber() != null && (!clientPersonalInfo.getCustomerDetail().getAddress().getPhoneNumber().equals(address.getPhoneNumber()))) {
                UserContext userContext = getUserContext(request);
                if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
                    throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
                }
            } else if (clientPersonalInfo.getCustomerDetail().getAddress().getPhoneNumber() == null && address.getPhoneNumber() != null && !address.getPhoneNumber().equals("")) {
                UserContext userContext = getUserContext(request);
                if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
                    throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
                }
            }
        } else if (address.getPhoneNumber() != null && !address.getPhoneNumber().equals("")) {
            UserContext userContext = getUserContext(request);
            if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
                throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
            }
        }
    } else if (address.getPhoneNumber() != null && !address.getPhoneNumber().equals("")) {
        UserContext userContext = getUserContext(request);
        if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
            throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
        }
    }
    ClientNameDetailDto spouseFather = null;
    if (!ClientRules.isFamilyDetailsRequired()) {
        spouseFather = actionForm.getSpouseName();
    }
    InputStream picture = null;
    if (actionForm.getPicture() != null && StringUtils.isNotBlank(actionForm.getPicture().getFileName())) {
        picture = actionForm.getCustomerPicture();
    }
    ClientNameDetailDto clientNameDetails = actionForm.getClientName();
    ClientPersonalDetailDto clientDetail = actionForm.getClientDetailView();
    String governmentId = actionForm.getGovernmentId();
    String clientDisplayName = actionForm.getClientName().getDisplayName();
    String dateOfBirth = actionForm.getDateOfBirth();
    ClientPersonalInfoUpdate personalInfo = new ClientPersonalInfoUpdate(customerId, oldClientVersionNumber, customFields, address, clientDetail, clientNameDetails, spouseFather, picture, governmentId, clientDisplayName, dateOfBirth);
    this.clientServiceFacade.updateClientPersonalInfo(personalInfo, clientStatus, loanOfficerId);
    return mapping.findForward(ActionForwards.updatePersonalInfo_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) CustomerException(org.mifos.customers.exceptions.CustomerException) UserContext(org.mifos.security.util.UserContext) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ClientBO(org.mifos.customers.client.business.ClientBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) ArrayList(java.util.ArrayList) AddressDto(org.mifos.dto.domain.AddressDto) ClientPersonalInfoUpdate(org.mifos.dto.domain.ClientPersonalInfoUpdate) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalInfoDto(org.mifos.dto.screen.ClientPersonalInfoDto) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with ClientPersonalInfoDto

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

the class PictureFormFile method editPersonalInfo.

@TransactionDemarcate(joinToken = true)
public ActionForward editPersonalInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    actionForm.clearMostButNotAllFieldsOnActionForm();
    ClientBO clientFromSession = getClientFromSession(request);
    final String clientSystemId = clientFromSession.getGlobalCustNum();
    ClientBO client = this.customerDao.findClientBySystemId(clientSystemId);
    short loanOfficerId = client.getCreatedBy();
    String clientStatus = client.getCustomerStatus().getName();
    ClientPersonalInfoDto personalInfo = this.clientServiceFacade.retrieveClientPersonalInfoForUpdate(clientSystemId, clientStatus, loanOfficerId);
    SessionUtils.setCollectionAttribute(ClientConstants.SALUTATION_ENTITY, personalInfo.getClientDropdowns().getSalutations(), request);
    SessionUtils.setCollectionAttribute(ClientConstants.GENDER_ENTITY, personalInfo.getClientDropdowns().getGenders(), request);
    SessionUtils.setCollectionAttribute(ClientConstants.MARITAL_STATUS_ENTITY, personalInfo.getClientDropdowns().getMaritalStatuses(), request);
    SessionUtils.setCollectionAttribute(ClientConstants.CITIZENSHIP_ENTITY, personalInfo.getClientDropdowns().getCitizenship(), request);
    SessionUtils.setCollectionAttribute(ClientConstants.ETHNICITY_ENTITY, personalInfo.getClientDropdowns().getEthnicity(), request);
    SessionUtils.setCollectionAttribute(ClientConstants.EDUCATION_LEVEL_ENTITY, personalInfo.getClientDropdowns().getEducationLevels(), request);
    SessionUtils.setCollectionAttribute(ClientConstants.BUSINESS_ACTIVITIES_ENTITY, personalInfo.getClientDropdowns().getBusinessActivity(), request);
    SessionUtils.setCollectionAttribute(ClientConstants.POVERTY_STATUS, personalInfo.getClientDropdowns().getPoverty(), request);
    SessionUtils.setCollectionAttribute(ClientConstants.HANDICAPPED_ENTITY, personalInfo.getClientDropdowns().getHandicapped(), request);
    UserContext userContext = getUserContext(request);
    List<SpouseFatherLookupEntity> spouseFather = legacyMasterDao.findMasterDataEntitiesWithLocale(SpouseFatherLookupEntity.class);
    SessionUtils.setCollectionAttribute(ClientConstants.SPOUSE_FATHER_ENTITY, spouseFather, request);
    SessionUtils.setAttribute("CanEditPhoneNumber", ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId()), request);
    InformationOrderServiceFacade informationOrderServiceFacade = ApplicationContextProvider.getBean(InformationOrderServiceFacade.class);
    SessionUtils.setCollectionAttribute("personalInformationOrder", informationOrderServiceFacade.getInformationOrder("CreateClient"), request);
    boolean isFamilyDetailsRequired = personalInfo.getClientRules().isFamilyDetailsRequired();
    SessionUtils.setAttribute(ClientConstants.ARE_FAMILY_DETAILS_REQUIRED, isFamilyDetailsRequired, request);
    if (isFamilyDetailsRequired) {
        SessionUtils.setAttribute(ClientConstants.ARE_FAMILY_DETAILS_MANDATORY, isFamilyDetailsMandatory(), request);
        SessionUtils.setAttribute(ClientConstants.ARE_FAMILY_DETAILS_HIDDEN, false, request);
    } else {
        SessionUtils.setAttribute(ClientConstants.ARE_FAMILY_DETAILS_MANDATORY, isSpouseFatherInformationMandatory(), request);
        SessionUtils.setAttribute(ClientConstants.ARE_FAMILY_DETAILS_HIDDEN, isSpouseFatherInformationHidden(), request);
    }
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, new ArrayList<CustomFieldDto>(), request);
    // customer specific
    actionForm.setCustomerId(personalInfo.getCustomerDetail().getCustomerId().toString());
    actionForm.setLoanOfficerId(personalInfo.getCustomerDetail().getLoanOfficerIdAsString());
    actionForm.setGlobalCustNum(personalInfo.getCustomerDetail().getGlobalCustNum());
    actionForm.setExternalId(personalInfo.getCustomerDetail().getExternalId());
    actionForm.setAddress(Address.toAddress(client.getAddress()));
    // client specific
    actionForm.setGovernmentId(personalInfo.getClientDetail().getGovernmentId());
    actionForm.setDateOfBirth(personalInfo.getClientDetail().getDateOfBirth());
    actionForm.setClientDetailView(personalInfo.getClientDetail().getCustomerDetail());
    ClientNameDetailDto clientName = personalInfo.getClientDetail().getClientName();
    clientName.setNames(ClientRules.getNameSequence());
    actionForm.setClientName(clientName);
    String photoDelete = request.getParameter("photoDelete");
    if (photoDelete != null && photoDelete.equals("true")) {
        ApplicationContextProvider.getBean(ClientPhotoService.class).delete(client.getCustomerId().longValue());
    }
    boolean isPhotoFieldHidden = FieldConfig.getInstance().isFieldHidden("Client.Photo");
    SessionUtils.setAttribute(ClientConstants.IS_PHOTO_FIELD_HIDDEN, isPhotoFieldHidden, request);
    if (!isPhotoFieldHidden) {
        ClientPhotoDto clientPhotoDto = this.clientServiceFacade.getClientPhoto(client.getCustomerId().longValue());
        if (clientPhotoDto != null) {
            FormFile formFile = new PictureFormFile(clientPhotoDto.getContentType(), clientPhotoDto.getOut(), client.getCustomerId().toString(), clientPhotoDto.getContentLength().intValue());
            actionForm.setPicture(formFile);
        } else {
            actionForm.setPicture(null);
        }
    } else {
        actionForm.setPicture(null);
    }
    ClientNameDetailDto spouseName = personalInfo.getClientDetail().getSpouseName();
    if (spouseName != null) {
        spouseName.setNames(ClientRules.getNameSequence());
        actionForm.setSpouseName(spouseName);
    }
    actionForm.setSpouseName(spouseName);
    actionForm.setCustomFields(new ArrayList<CustomFieldDto>());
    SessionUtils.removeThenSetAttribute(Constants.BUSINESS_KEY, client, request);
    return mapping.findForward(ActionForwards.editPersonalInfo_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) ClientPhotoService(org.mifos.framework.image.service.ClientPhotoService) UserContext(org.mifos.security.util.UserContext) ClientBO(org.mifos.customers.client.business.ClientBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) FormFile(org.apache.struts.upload.FormFile) InformationOrderServiceFacade(org.mifos.platform.questionnaire.service.InformationOrderServiceFacade) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) SpouseFatherLookupEntity(org.mifos.application.master.business.SpouseFatherLookupEntity) ClientPersonalInfoDto(org.mifos.dto.screen.ClientPersonalInfoDto) ClientPhotoDto(org.mifos.dto.screen.ClientPhotoDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with ClientPersonalInfoDto

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

the class ClientServiceFacadeWebTier method retrieveClientPersonalInfoForUpdate.

@Override
public ClientPersonalInfoDto retrieveClientPersonalInfoForUpdate(String clientSystemId, String clientStatus, short loanOfficerId) {
    ClientDropdownsDto clientDropdowns = retrieveClientDropdownData();
    ClientRulesDto clientRules = retrieveClientRules();
    ClientBO client = this.customerDao.findClientBySystemId(clientSystemId);
    CustomerDetailDto customerDetailDto = client.toCustomerDetailDto();
    ClientDetailDto clientDetailDto = client.toClientDetailDto(clientRules.isFamilyDetailsRequired());
    return new ClientPersonalInfoDto(clientDropdowns, clientRules, customerDetailDto, clientDetailDto);
}
Also used : ClientRulesDto(org.mifos.dto.domain.ClientRulesDto) ClientBO(org.mifos.customers.client.business.ClientBO) ClientDetailDto(org.mifos.dto.screen.ClientDetailDto) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) ClientPersonalInfoDto(org.mifos.dto.screen.ClientPersonalInfoDto) ClientDropdownsDto(org.mifos.dto.screen.ClientDropdownsDto)

Aggregations

ClientBO (org.mifos.customers.client.business.ClientBO)3 ClientPersonalInfoDto (org.mifos.dto.screen.ClientPersonalInfoDto)3 ClientCustActionForm (org.mifos.customers.client.struts.actionforms.ClientCustActionForm)2 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)2 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)2 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)2 UserContext (org.mifos.security.util.UserContext)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 FormFile (org.apache.struts.upload.FormFile)1 SpouseFatherLookupEntity (org.mifos.application.master.business.SpouseFatherLookupEntity)1 CustomerException (org.mifos.customers.exceptions.CustomerException)1 AddressDto (org.mifos.dto.domain.AddressDto)1 ClientPersonalInfoUpdate (org.mifos.dto.domain.ClientPersonalInfoUpdate)1 ClientRulesDto (org.mifos.dto.domain.ClientRulesDto)1 CustomerDetailDto (org.mifos.dto.domain.CustomerDetailDto)1 ClientDetailDto (org.mifos.dto.screen.ClientDetailDto)1 ClientDropdownsDto (org.mifos.dto.screen.ClientDropdownsDto)1 ClientPersonalDetailDto (org.mifos.dto.screen.ClientPersonalDetailDto)1