Search in sources :

Example 16 with Lead

use of com.axelor.apps.crm.db.Lead in project axelor-open-suite by axelor.

the class TargetListController method openFilteredLeads.

public void openFilteredLeads(ActionRequest request, ActionResponse response) {
    TargetList targetList = request.getContext().asType(TargetList.class);
    String leadFilters = null;
    try {
        leadFilters = Beans.get(TargetListService.class).getLeadQuery(targetList);
        if (leadFilters != null) {
            response.setView(ActionView.define(I18n.get("Leads")).model(Lead.class.getName()).add("grid", "lead-grid").add("form", "lead-form").param("search-filters", "lead-filters").domain(leadFilters).map());
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : TargetList(com.axelor.apps.marketing.db.TargetList) Lead(com.axelor.apps.crm.db.Lead)

Example 17 with Lead

use of com.axelor.apps.crm.db.Lead in project axelor-open-suite by axelor.

the class LeadController method loseLead.

public void loseLead(ActionRequest request, ActionResponse response) {
    try {
        Lead lead = request.getContext().asType(Lead.class);
        Beans.get(LeadService.class).loseLead(Beans.get(LeadRepository.class).find(lead.getId()), lead.getLostReason());
        response.setCanClose(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : LeadService(com.axelor.apps.crm.service.LeadService) Lead(com.axelor.apps.crm.db.Lead) BirtException(org.eclipse.birt.core.exception.BirtException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException)

Example 18 with Lead

use of com.axelor.apps.crm.db.Lead in project axelor-open-suite by axelor.

the class LeadServiceImpl method importLead.

@SuppressWarnings("rawtypes")
public Object importLead(Object bean, Map values) {
    assert bean instanceof Lead;
    Lead lead = (Lead) bean;
    User user = AuthUtils.getUser();
    lead.setUser(user);
    lead.setTeam(user.getActiveTeam());
    return lead;
}
Also used : User(com.axelor.auth.db.User) Lead(com.axelor.apps.crm.db.Lead)

Example 19 with Lead

use of com.axelor.apps.crm.db.Lead in project axelor-open-suite by axelor.

the class OpportunityServiceImpl method createClientFromLead.

@Override
@Transactional(rollbackOn = { Exception.class })
public Partner createClientFromLead(Opportunity opportunity) throws AxelorException {
    Lead lead = opportunity.getLead();
    if (lead == null) {
        throw new AxelorException(opportunity, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.LEAD_PARTNER));
    }
    String name = lead.getFullName();
    Address address = null;
    if (lead.getPrimaryAddress() != null) {
        // avoids printing 'null'
        String addressL6 = lead.getPrimaryPostalCode() == null ? "" : lead.getPrimaryPostalCode() + " ";
        addressL6 += lead.getPrimaryCity() == null ? "" : lead.getPrimaryCity().getName();
        address = addressService.createAddress(null, null, lead.getPrimaryAddress(), null, addressL6, lead.getPrimaryCountry());
        address.setFullName(addressService.computeFullName(address));
    }
    EmailAddress email = null;
    if (lead.getEmailAddress() != null) {
        email = new EmailAddress(lead.getEmailAddress().getAddress());
    }
    Partner partner = Beans.get(PartnerService.class).createPartner(name, null, lead.getFixedPhone(), lead.getMobilePhone(), email, opportunity.getCurrency(), address, address, true);
    opportunity.setPartner(partner);
    opportunityRepo.save(opportunity);
    return partner;
}
Also used : AxelorException(com.axelor.exception.AxelorException) EmailAddress(com.axelor.apps.message.db.EmailAddress) Address(com.axelor.apps.base.db.Address) Lead(com.axelor.apps.crm.db.Lead) PartnerService(com.axelor.apps.base.service.PartnerService) Partner(com.axelor.apps.base.db.Partner) EmailAddress(com.axelor.apps.message.db.EmailAddress) Transactional(com.google.inject.persist.Transactional)

Example 20 with Lead

use of com.axelor.apps.crm.db.Lead in project axelor-open-suite by axelor.

the class ConvertLeadWizardController method setIndividualPartner.

public void setIndividualPartner(ActionRequest request, ActionResponse response) throws AxelorException {
    Lead lead = findLead(request);
    if (request.getContext().get("partnerTypeSelect").toString().equals("2")) {
        response.setAttr("firstName", "value", lead.getFirstName());
        response.setAttr("name", "value", lead.getName());
    } else {
        response.setAttr("name", "value", lead.getEnterpriseName());
    }
}
Also used : Lead(com.axelor.apps.crm.db.Lead)

Aggregations

Lead (com.axelor.apps.crm.db.Lead)24 Partner (com.axelor.apps.base.db.Partner)7 Transactional (com.google.inject.persist.Transactional)6 LeadService (com.axelor.apps.crm.service.LeadService)4 CampaignRepository (com.axelor.apps.marketing.db.repo.CampaignRepository)4 AxelorException (com.axelor.exception.AxelorException)4 LeadRepository (com.axelor.apps.crm.db.repo.LeadRepository)3 Map (java.util.Map)3 Address (com.axelor.apps.base.db.Address)2 AppBase (com.axelor.apps.base.db.AppBase)2 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)2 EmailAddress (com.axelor.apps.message.db.EmailAddress)2 Context (com.axelor.rpc.Context)2 Company (com.axelor.apps.base.db.Company)1 Country (com.axelor.apps.base.db.Country)1 CompanyRepository (com.axelor.apps.base.db.repo.CompanyRepository)1 MapService (com.axelor.apps.base.service.MapService)1 PartnerService (com.axelor.apps.base.service.PartnerService)1 Event (com.axelor.apps.crm.db.Event)1 Campaign (com.axelor.apps.marketing.db.Campaign)1