Search in sources :

Example 1 with CustomerHierarchyDto

use of org.mifos.dto.domain.CustomerHierarchyDto in project head by mifos.

the class HomePageController method loadLoanOfficerCustomersHierarchyForSelectedDay.

private void loadLoanOfficerCustomersHierarchyForSelectedDay(Short userId, ModelAndView modelAndView, CustomerSearchFormBean customerSearchFormBean) throws MifosException {
    CustomerHierarchyDto hierarchy;
    List<String> nearestDates = new ArrayList<String>();
    DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", personnelServiceFacade.getUserPreferredLocale());
    Date selectedDate = new LocalDate().toDateMidnight().toDate();
    DateTime nextDate = new DateTime();
    for (int i = 0; i < 7; i++) {
        nearestDates.add(formatter.format(nextDate.toDate()));
        nextDate = nextDate.plusDays(1);
    }
    if (customerSearchFormBean.getSelectedDateOption() != null) {
        try {
            selectedDate = formatter.parse(customerSearchFormBean.getSelectedDateOption());
        } catch (ParseException e) {
            throw new MifosException(e);
        }
    }
    hierarchy = personnelServiceFacade.getLoanOfficerCustomersHierarchyForDay(userId, new DateTime(selectedDate));
    modelAndView.addObject("nearestDates", nearestDates);
    modelAndView.addObject("hierarchy", hierarchy);
}
Also used : MifosException(org.mifos.core.MifosException) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) CustomerHierarchyDto(org.mifos.dto.domain.CustomerHierarchyDto) ArrayList(java.util.ArrayList) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) LocalDate(org.joda.time.LocalDate) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime)

Example 2 with CustomerHierarchyDto

use of org.mifos.dto.domain.CustomerHierarchyDto in project head by mifos.

the class CustSearchAction method loadLoanOfficerCustomersHierarchyForSelectedDay.

/**
     * Retrieve meetings for loan officer for selected day.
     * @param personnel
     * @param request
     * @return
     * @throws Exception
     */
private String loadLoanOfficerCustomersHierarchyForSelectedDay(Short userId, HttpServletRequest request, CustSearchActionForm form) throws Exception {
    CustomerHierarchyDto hierarchy;
    List<String> nearestDates = new ArrayList<String>();
    DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
    Date selectedDate;
    DateTime nextDate = new DateTime();
    for (int i = 0; i < 7; i++) {
        nearestDates.add(formatter.format(nextDate.toDate()));
        nextDate = nextDate.plusDays(1);
    }
    if (form.getSelectedDateOption() != null) {
        selectedDate = formatter.parse(form.getSelectedDateOption());
    } else {
        selectedDate = new LocalDate().toDateMidnight().toDate();
    }
    hierarchy = personnelServiceFacade.getLoanOfficerCustomersHierarchyForDay(userId, new DateTime(selectedDate));
    SessionUtils.setCollectionAttribute("nearestDates", nearestDates, request);
    SessionUtils.setAttribute("hierarchy", hierarchy, request);
    return CustomerSearchConstants.LOADFORWARDLOANOFFICER_SUCCESS;
}
Also used : DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) CustomerHierarchyDto(org.mifos.dto.domain.CustomerHierarchyDto) ArrayList(java.util.ArrayList) SimpleDateFormat(java.text.SimpleDateFormat) LocalDate(org.joda.time.LocalDate) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime)

Example 3 with CustomerHierarchyDto

use of org.mifos.dto.domain.CustomerHierarchyDto in project head by mifos.

the class PersonnelServiceFacadeWebTier method getLoanOfficerCustomersHierarchyForDay.

@Override
public CustomerHierarchyDto getLoanOfficerCustomersHierarchyForDay(Short loanOfficerId, DateTime day) {
    PersonnelBO personnel = personnelDao.findPersonnelById(loanOfficerId);
    CustomerHierarchyDto hierarchy = new CustomerHierarchyDto();
    // Yesterday as current date because upcoming meetings should include current day
    DateTime currentDate = new DateTime().minusDays(1);
    if (ClientRules.getCenterHierarchyExists()) {
        for (CustomerDetailDto center : this.customerDao.findActiveCentersUnderUser(personnel)) {
            CustomerBO centerBO = this.customerDao.findCustomerById(center.getCustomerId());
            if (isCustomerHavingMeetingOnDay(centerBO, day, currentDate)) {
                CenterDescriptionDto centerDescription = new CenterDescriptionDto();
                centerDescription.setId(center.getCustomerId());
                centerDescription.setDisplayName(center.getDisplayName());
                centerDescription.setGlobalCustNum(center.getGlobalCustNum());
                centerDescription.setSearchId(center.getSearchId());
                hierarchy.getCenters().add(centerDescription);
            }
        }
    }
    allGroups: for (CustomerDetailDto group : this.customerDao.findGroupsUnderUser(personnel)) {
        CustomerBO groupBO = this.customerDao.findCustomerById(group.getCustomerId());
        if (isCustomerHavingMeetingOnDay(groupBO, day, currentDate)) {
            GroupDescriptionDto groupDescription = new GroupDescriptionDto();
            groupDescription.setId(group.getCustomerId());
            groupDescription.setDisplayName(group.getDisplayName());
            groupDescription.setGlobalCustNum(group.getGlobalCustNum());
            groupDescription.setSearchId(group.getSearchId());
            for (ClientBO client : this.customerDao.findActiveClientsUnderParent(group.getSearchId(), personnel.getOffice().getOfficeId())) {
                ClientDescriptionDto clientDescription = new ClientDescriptionDto();
                clientDescription.setId(client.getCustomerId());
                clientDescription.setDisplayName(client.getDisplayName());
                clientDescription.setGlobalCustNum(client.getGlobalCustNum());
                clientDescription.setSearchId(client.getSearchId());
                groupDescription.getClients().add(clientDescription);
            }
            for (CenterDescriptionDto center : hierarchy.getCenters()) {
                if (group.getSearchId().startsWith(center.getSearchId())) {
                    center.getGroups().add(groupDescription);
                    continue allGroups;
                }
            }
            hierarchy.getGroups().add(groupDescription);
        }
    }
    return hierarchy;
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CenterDescriptionDto(org.mifos.dto.domain.CenterDescriptionDto) ClientBO(org.mifos.customers.client.business.ClientBO) CustomerHierarchyDto(org.mifos.dto.domain.CustomerHierarchyDto) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) CustomerBO(org.mifos.customers.business.CustomerBO) GroupDescriptionDto(org.mifos.dto.domain.GroupDescriptionDto) ClientDescriptionDto(org.mifos.dto.domain.ClientDescriptionDto) DateTime(org.joda.time.DateTime)

Example 4 with CustomerHierarchyDto

use of org.mifos.dto.domain.CustomerHierarchyDto in project head by mifos.

the class PersonnelRESTController method getCustomersUnderPersonnel.

@RequestMapping(value = "personnel/id-current/clients", method = RequestMethod.GET)
@ResponseBody
public CustomerHierarchyDto getCustomersUnderPersonnel() {
    PersonnelBO loanOfficer = this.personnelDao.findPersonnelById(getCurrentPersonnel().getPersonnelId());
    CustomerHierarchyDto hierarchy = new CustomerHierarchyDto();
    if (ClientRules.getCenterHierarchyExists()) {
        for (CustomerDetailDto center : this.customerDao.findActiveCentersUnderUser(loanOfficer)) {
            CenterDescriptionDto centerDescription = new CenterDescriptionDto();
            centerDescription.setId(center.getCustomerId());
            centerDescription.setDisplayName(center.getDisplayName());
            centerDescription.setGlobalCustNum(center.getGlobalCustNum());
            centerDescription.setSearchId(center.getSearchId());
            hierarchy.getCenters().add(centerDescription);
        }
    }
    allGroups: for (CustomerDetailDto group : this.customerDao.findGroupsUnderUser(loanOfficer)) {
        GroupDescriptionDto groupDescription = new GroupDescriptionDto();
        groupDescription.setId(group.getCustomerId());
        groupDescription.setDisplayName(group.getDisplayName());
        groupDescription.setGlobalCustNum(group.getGlobalCustNum());
        groupDescription.setSearchId(group.getSearchId());
        for (ClientBO client : this.customerDao.findAllExceptClosedAndCancelledClientsUnderParent(group.getSearchId(), loanOfficer.getOffice().getOfficeId())) {
            ClientDescriptionDto clientDescription = new ClientDescriptionDto();
            clientDescription.setId(client.getCustomerId());
            clientDescription.setDisplayName(client.getDisplayName());
            clientDescription.setGlobalCustNum(client.getGlobalCustNum());
            clientDescription.setSearchId(client.getSearchId());
            groupDescription.getClients().add(clientDescription);
        }
        for (CenterDescriptionDto center : hierarchy.getCenters()) {
            if (group.getSearchId().startsWith(center.getSearchId())) {
                center.getGroups().add(groupDescription);
                continue allGroups;
            }
        }
        hierarchy.getGroups().add(groupDescription);
    }
    for (ClientBO client : this.customerDao.findAllExceptClosedAndCancelledClientsWithoutGroupForLoanOfficer(loanOfficer.getPersonnelId(), loanOfficer.getOffice().getOfficeId())) {
        ClientDescriptionDto clientDescription = new ClientDescriptionDto();
        clientDescription.setId(client.getCustomerId());
        clientDescription.setDisplayName(client.getDisplayName());
        clientDescription.setGlobalCustNum(client.getGlobalCustNum());
        clientDescription.setSearchId(client.getSearchId());
        hierarchy.getClients().add(clientDescription);
    }
    return hierarchy;
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CenterDescriptionDto(org.mifos.dto.domain.CenterDescriptionDto) ClientBO(org.mifos.customers.client.business.ClientBO) CustomerHierarchyDto(org.mifos.dto.domain.CustomerHierarchyDto) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) GroupDescriptionDto(org.mifos.dto.domain.GroupDescriptionDto) ClientDescriptionDto(org.mifos.dto.domain.ClientDescriptionDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

CustomerHierarchyDto (org.mifos.dto.domain.CustomerHierarchyDto)4 DateTime (org.joda.time.DateTime)3 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 LocalDate (org.joda.time.LocalDate)2 ClientBO (org.mifos.customers.client.business.ClientBO)2 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 CenterDescriptionDto (org.mifos.dto.domain.CenterDescriptionDto)2 ClientDescriptionDto (org.mifos.dto.domain.ClientDescriptionDto)2 CustomerDetailDto (org.mifos.dto.domain.CustomerDetailDto)2 GroupDescriptionDto (org.mifos.dto.domain.GroupDescriptionDto)2 ParseException (java.text.ParseException)1 MifosException (org.mifos.core.MifosException)1 CustomerBO (org.mifos.customers.business.CustomerBO)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1