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());
}
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);
}
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());
}
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());
}
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());
}
Aggregations