Search in sources :

Example 11 with CustomerStatusDetailDto

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

the class SearchResultController method showSearchResults.

@RequestMapping(value = "/searchResult", method = { RequestMethod.POST, RequestMethod.GET })
public ModelAndView showSearchResults(HttpServletRequest request, @ModelAttribute("customerSearch") @Valid CustomerSearchFormBean customerSearchFormBean, BindingResult result) throws PersistenceException {
    ModelAndView modelAndView = new ModelAndView();
    sitePreferenceHelper.resolveSiteType(modelAndView, "searchResult", request);
    // mobile search result view doesn't use ajax search
    if (sitePreferenceHelper.isMobile(request)) {
        return legacyShowSearchResults(request, customerSearchFormBean, result);
    }
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    List<OfficeDto> officeDtoList = officeServiceFacade.retrieveActiveBranchesUnderUser((short) user.getUserId());
    Map<String, String> officesMap = new HashMap<String, String>();
    for (OfficeDto officeDto : officeDtoList) {
        officesMap.put(officeDto.getId().toString(), officeDto.getName());
    }
    customerSearchFormBean.setOffices(officesMap);
    modelAndView.addObject("customerSearch", customerSearchFormBean);
    boolean isCenterHierarchyExists = configurationServiceFacade.getBooleanConfig("ClientRules.CenterHierarchyExists");
    modelAndView.addObject("isCenterHierarchyExists", isCenterHierarchyExists);
    HashMap<String, ArrayList<CustomerStatusDetailDto>> customerStates = new HashMap<String, ArrayList<CustomerStatusDetailDto>>();
    customerStates.putAll(customerSearchServiceFacade.getAvailibleCustomerStates());
    modelAndView.addObject("availibleCustomerStates", customerStates);
    List<ValueListElement> availibleClientGenders = clientServiceFacade.getClientGenders();
    modelAndView.addObject("availibleClientGenders", availibleClientGenders);
    if (result.hasErrors()) {
        return modelAndView;
    }
    CustomerHierarchyDto customerHierarchyDto = new CustomerHierarchyDto();
    if (customerSearchFormBean.getFilters() == null) {
        customerSearchFormBean.setFilters(new SearchFiltersDto());
    }
    if (customerSearchFormBean.getSearchString() != null && !customerSearchFormBean.getSearchString().isEmpty()) {
        customerHierarchyDto = customerSearchServiceFacade.search(customerSearchFormBean.getSearchString(), customerSearchFormBean.getOfficeId(), 0, 10, customerSearchFormBean.getFilters());
    }
    modelAndView.addObject("customerHierarchy", customerHierarchyDto);
    modelAndView.addObject("startIndex", 0);
    return modelAndView;
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) CustomerStatusDetailDto(org.mifos.dto.screen.CustomerStatusDetailDto) HashMap(java.util.HashMap) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser) SearchFiltersDto(org.mifos.dto.screen.SearchFiltersDto) CustomerHierarchyDto(org.mifos.dto.screen.CustomerHierarchyDto) ValueListElement(org.mifos.dto.domain.ValueListElement) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

CustomerStatusDetailDto (org.mifos.dto.screen.CustomerStatusDetailDto)11 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)9 ValueListElement (org.mifos.dto.domain.ValueListElement)8 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)5 CustSearchActionForm (org.mifos.customers.struts.actionforms.CustSearchActionForm)4 UserContext (org.mifos.security.util.UserContext)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ModelAndView (org.springframework.web.servlet.ModelAndView)4 CustomerHierarchyDto (org.mifos.dto.screen.CustomerHierarchyDto)3 MifosUser (org.mifos.security.MifosUser)3 CustomerLevel (org.mifos.customers.api.CustomerLevel)2 CustomerPersistence (org.mifos.customers.persistence.CustomerPersistence)2 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 OfficeDto (org.mifos.dto.domain.OfficeDto)2 UserDetailDto (org.mifos.dto.domain.UserDetailDto)2 SearchFiltersDto (org.mifos.dto.screen.SearchFiltersDto)2 IncludePage (freemarker.ext.servlet.IncludePage)1 CustomerBO (org.mifos.customers.business.CustomerBO)1 CustomerStatusEntity (org.mifos.customers.business.CustomerStatusEntity)1