Search in sources :

Example 21 with ClientCustActionForm

use of org.mifos.customers.client.struts.actionforms.ClientCustActionForm in project head by mifos.

the class PictureFormFile method updateMfiInfo.

@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updateMfiInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    ClientBO clientInSession = getClientFromSession(request);
    Integer clientId = clientInSession.getCustomerId();
    Integer oldVersionNumber = clientInSession.getVersionNo();
    boolean trained = false;
    if (trainedValue(actionForm) != null && trainedValue(actionForm).equals(YesNoFlag.YES.getValue())) {
        trained = true;
    }
    DateTime trainedDate = null;
    try {
        java.sql.Date inputDate = trainedDate(actionForm);
        if (inputDate != null) {
            trainedDate = new DateTime(trainedDate(actionForm));
        }
    } catch (InvalidDateException e) {
        throw new CustomerException(ClientConstants.TRAINED_DATE_MANDATORY);
    }
    Short personnelId = Short.valueOf("-1");
    if (groupFlagValue(actionForm).equals(YesNoFlag.NO.getValue())) {
        if (actionForm.getLoanOfficerIdValue() != null) {
            personnelId = actionForm.getLoanOfficerIdValue();
        }
    } else if (groupFlagValue(actionForm).equals(YesNoFlag.YES.getValue())) {
        // TODO for an urgent fix this reads client to get personnelId.
        // Client is read again in updateClientMfiInfo. Refactor to only read in
        // updateClientMfiInfo.
        ClientBO client = (ClientBO) this.customerDao.findCustomerById(clientId);
        personnelId = client.getPersonnel().getPersonnelId();
    }
    ClientMfiInfoUpdate clientMfiInfoUpdate = new ClientMfiInfoUpdate(clientId, oldVersionNumber, personnelId, externalId(actionForm), trained, trainedDate);
    this.clientServiceFacade.updateClientMfiInfo(clientMfiInfoUpdate);
    return mapping.findForward(ActionForwards.updateMfiInfo_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) CustomerException(org.mifos.customers.exceptions.CustomerException) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ClientMfiInfoUpdate(org.mifos.dto.domain.ClientMfiInfoUpdate) ClientBO(org.mifos.customers.client.business.ClientBO) DateTime(org.joda.time.DateTime) Date(java.sql.Date) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 22 with ClientCustActionForm

use of org.mifos.customers.client.struts.actionforms.ClientCustActionForm in project head by mifos.

the class PictureFormFile method retrievePictureOnPreview.

@TransactionDemarcate(joinToken = true)
public ActionForward retrievePictureOnPreview(ActionMapping mapping, ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    InputStream in = actionForm.getPicture().getInputStream();
    in.mark(0);
    response.setContentType("image/jpeg");
    BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
    // 4K buffer buf, 0, buf.length
    byte[] by = new byte[1024 * 4];
    int index = in.read(by, 0, 1024 * 4);
    while (index != -1) {
        out.write(by, 0, index);
        index = in.read(by, 0, 1024 * 4);
    }
    out.flush();
    out.close();
    in.reset();
    String forward = ClientConstants.CUSTOMER_PICTURE_PAGE;
    return mapping.findForward(forward);
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) BufferedOutputStream(java.io.BufferedOutputStream) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 23 with ClientCustActionForm

use of org.mifos.customers.client.struts.actionforms.ClientCustActionForm in project head by mifos.

the class PictureFormFile method previewEditFamilyInfo.

@TransactionDemarcate(joinToken = true)
public ActionForward previewEditFamilyInfo(ActionMapping mapping, ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse httpservletresponse) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    actionForm.setFamilyDateOfBirth();
    actionForm.constructFamilyDetails();
    return mapping.findForward(ActionForwards.previewEditFamilyInfo_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 24 with ClientCustActionForm

use of org.mifos.customers.client.struts.actionforms.ClientCustActionForm in project head by mifos.

the class PictureFormFile method create.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    MeetingBO meeting = (MeetingBO) SessionUtils.getAttribute(CustomerConstants.CUSTOMER_MEETING, request);
    List<SavingsDetailDto> allowedSavingProducts = getSavingsOfferingsFromSession(request);
    if (ClientRules.isFamilyDetailsRequired()) {
        actionForm.setFamilyDateOfBirth();
        actionForm.constructFamilyDetails();
    }
    List<Short> selectedSavingProducts = actionForm.getSelectedOfferings();
    String clientName = actionForm.getClientName().getDisplayName();
    Short clientStatus = actionForm.getStatusValue().getValue();
    java.sql.Date mfiJoiningDate = DateUtils.getDateAsSentFromBrowser(actionForm.getMfiJoiningDate());
    String externalId = actionForm.getExternalId();
    AddressDto address = null;
    if (actionForm.getAddress() != null) {
        address = Address.toDto(actionForm.getAddress());
    }
    Short formedBy = actionForm.getFormedByPersonnelValue();
    java.sql.Date dateOfBirth = DateUtils.getDateAsSentFromBrowser(actionForm.getDateOfBirth());
    String governmentId = actionForm.getGovernmentId();
    boolean trained = isTrained(actionForm.getTrainedValue());
    java.sql.Date trainedDate = DateUtils.getDateAsSentFromBrowser(actionForm.getTrainedDate());
    Short groupFlagValue = actionForm.getGroupFlagValue();
    ClientNameDetailDto clientNameDetailDto = actionForm.getClientName();
    ClientPersonalDetailDto clientPersonalDetailDto = actionForm.getClientDetailView();
    ClientNameDetailDto spouseFatherName = actionForm.getSpouseName();
    InputStream picture = actionForm.getCustomerPicture();
    String parentGroupId = actionForm.getParentGroupId();
    List<ClientNameDetailDto> familyNames = actionForm.getFamilyNames();
    List<ClientFamilyDetailDto> familyDetails = actionForm.getFamilyDetails();
    Short loanOfficerId = actionForm.getLoanOfficerIdValue();
    Short officeId = actionForm.getOfficeIdValue();
    // only applies when status is active
    LocalDate activationDateAsToday = new LocalDate();
    ClientCreationDetail clientCreationDetail = new ClientCreationDetail(selectedSavingProducts, clientName, clientStatus, mfiJoiningDate, externalId, address, formedBy, dateOfBirth, governmentId, trained, trainedDate, groupFlagValue, clientNameDetailDto, clientPersonalDetailDto, spouseFatherName, picture, actionForm.getFeesToApply(), parentGroupId, familyNames, familyDetails, loanOfficerId, officeId, activationDateAsToday);
    MeetingDto meetingDto = null;
    if (meeting != null) {
        meetingDto = meeting.toDto();
    }
    CustomerDetailsDto clientDetails = this.clientServiceFacade.createNewClient(clientCreationDetail, meetingDto, allowedSavingProducts);
    List<FormFile> formFiles = actionForm.getFiles();
    List<UploadedFileDto> filesMetadata = actionForm.getFilesMetadata();
    for (int i = 0; i < formFiles.size(); i++) {
        if (formFiles.get(i).getFileSize() != 0) {
            InputStream inputStream = formFiles.get(i).getInputStream();
            UploadedFileDto fileMetadata = filesMetadata.get(i);
            clientServiceFacade.uploadFile(clientDetails.getId(), inputStream, fileMetadata);
        }
    }
    actionForm.setCustomerId(clientDetails.getId().toString());
    actionForm.setGlobalCustNum(clientDetails.getGlobalCustNum());
    actionForm.setEditFamily("notEdit");
    createClientQuestionnaire.saveResponses(request, actionForm, clientDetails.getId());
    return mapping.findForward(ActionForwards.create_success.toString());
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) LocalDate(org.joda.time.LocalDate) FormFile(org.apache.struts.upload.FormFile) ClientCreationDetail(org.mifos.dto.domain.ClientCreationDetail) ClientFamilyDetailDto(org.mifos.dto.screen.ClientFamilyDetailDto) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) UploadedFileDto(org.mifos.dto.screen.UploadedFileDto) ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) AddressDto(org.mifos.dto.domain.AddressDto) Date(java.sql.Date) MeetingDto(org.mifos.dto.domain.MeetingDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 25 with ClientCustActionForm

use of org.mifos.customers.client.struts.actionforms.ClientCustActionForm in project head by mifos.

the class PictureFormFile method chooseOffice.

@TransactionDemarcate(saveToken = true)
public ActionForward chooseOffice(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    actionForm.setGroupFlag(ClientConstants.NO);
    OnlyBranchOfficeHierarchyDto officeHierarchy = customerServiceFacade.retrieveBranchOnlyOfficeHierarchy();
    SessionUtils.setAttribute(OnlyBranchOfficeHierarchyDto.IDENTIFIER, officeHierarchy, request);
    return mapping.findForward(ActionForwards.chooseOffice_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) OnlyBranchOfficeHierarchyDto(org.mifos.dto.screen.OnlyBranchOfficeHierarchyDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

ClientCustActionForm (org.mifos.customers.client.struts.actionforms.ClientCustActionForm)29 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)21 ArrayList (java.util.ArrayList)10 List (java.util.List)8 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)8 Test (org.junit.Test)7 ClientBO (org.mifos.customers.client.business.ClientBO)7 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)7 BusinessActivityEntity (org.mifos.application.master.business.BusinessActivityEntity)5 MeetingBO (org.mifos.application.meeting.business.MeetingBO)5 UserContext (org.mifos.security.util.UserContext)5 FormFile (org.apache.struts.upload.FormFile)4 ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)4 InformationOrderServiceFacade (org.mifos.platform.questionnaire.service.InformationOrderServiceFacade)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputStream (java.io.InputStream)3 DateTime (org.joda.time.DateTime)3 FeeDto (org.mifos.accounts.fees.business.FeeDto)3 SpouseFatherLookupEntity (org.mifos.application.master.business.SpouseFatherLookupEntity)3 SavingsDetailDto (org.mifos.dto.domain.SavingsDetailDto)3