Search in sources :

Example 6 with Event

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

the class LeadServiceImpl method convertLead.

/**
 * Convert lead into a partner
 *
 * @param lead
 * @return
 * @throws AxelorException
 */
@Transactional(rollbackOn = { Exception.class })
public Lead convertLead(Lead lead, Partner partner, Partner contactPartner) throws AxelorException {
    if (partner != null && contactPartner != null) {
        contactPartner = partnerRepo.save(contactPartner);
        if (partner.getContactPartnerSet() == null) {
            partner.setContactPartnerSet(new HashSet<>());
        }
        partner.getContactPartnerSet().add(contactPartner);
        contactPartner.setMainPartner(partner);
    }
    if (partner != null) {
        partner = partnerRepo.save(partner);
        lead.setPartner(partner);
    }
    for (Event event : lead.getEventList()) {
        event.setPartner(partner);
        event.setContactPartner(contactPartner);
        eventRepo.save(event);
    }
    for (Opportunity opportunity : lead.getOpportunitiesList()) {
        opportunity.setPartner(partner);
        opportunityRepo.save(opportunity);
    }
    lead.setStatusSelect(LeadRepository.LEAD_STATUS_CONVERTED);
    return leadRepo.save(lead);
}
Also used : Opportunity(com.axelor.apps.crm.db.Opportunity) Event(com.axelor.apps.crm.db.Event) Transactional(com.google.inject.persist.Transactional)

Example 7 with Event

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

the class CampaignServiceImpl method generateEvents.

@Transactional
public void generateEvents(Campaign campaign) {
    LocalDateTime eventStartDateTime = campaign.getEventStartDateTime();
    LocalDateTime eventEndDateTime = campaign.getEventEndDateTime();
    Long duration = campaign.getDuration();
    for (Partner partner : campaign.getPartnerSet()) {
        Event event = new Event();
        if (partner.getIsContact()) {
            event.setContactPartner(partner);
        } else {
            event.setPartner(partner);
        }
        event.setUser(campaign.getGenerateEventPerPartnerOrLead() ? partner.getUser() : campaign.getEventUser());
        event.setSubject(campaign.getSubject());
        event.setTypeSelect(campaign.getEventTypeSelect());
        event.setStartDateTime(eventStartDateTime);
        event.setEndDateTime(eventEndDateTime);
        event.setDuration(duration);
        event.setTeam(campaign.getGenerateEventPerPartnerOrLead() ? partner.getTeam() : campaign.getTeam());
        event.setCampaign(campaign);
        event.setStatusSelect(1);
        eventRepo.save(event);
    }
    for (Lead lead : campaign.getLeadSet()) {
        Event event = new Event();
        event.setLead(lead);
        event.setUser(campaign.getGenerateEventPerPartnerOrLead() ? lead.getUser() : campaign.getEventUser());
        event.setSubject(campaign.getSubject());
        event.setTypeSelect(campaign.getEventTypeSelect());
        event.setStartDateTime(eventStartDateTime);
        event.setEndDateTime(eventEndDateTime);
        event.setDuration(duration);
        event.setTeam(campaign.getGenerateEventPerPartnerOrLead() ? lead.getTeam() : campaign.getTeam());
        event.setCampaign(campaign);
        event.setStatusSelect(1);
        eventRepo.save(event);
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) Lead(com.axelor.apps.crm.db.Lead) Event(com.axelor.apps.crm.db.Event) Partner(com.axelor.apps.base.db.Partner) Transactional(com.google.inject.persist.Transactional)

Example 8 with Event

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

the class TrainingRegisterController method EventUserUpdate.

@Transactional
public void EventUserUpdate(ActionRequest request, ActionResponse response) {
    TrainingRegister trainingRegister = request.getContext().asType(TrainingRegister.class);
    if (trainingRegister.getEventList() != null) {
        for (Event event : trainingRegister.getEventList()) {
            event.setUser(trainingRegister.getEmployee().getUser());
            eventRepository.save(event);
        }
    }
}
Also used : TrainingRegister(com.axelor.apps.talent.db.TrainingRegister) Event(com.axelor.apps.crm.db.Event) Transactional(com.google.inject.persist.Transactional)

Example 9 with Event

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

the class TrainingRegisterController method EventCalenderUpdate.

@Transactional
public void EventCalenderUpdate(ActionRequest request, ActionResponse response) {
    TrainingRegister trainingRegister = request.getContext().asType(TrainingRegister.class);
    if (trainingRegister.getEventList() != null) {
        for (Event event : trainingRegister.getEventList()) {
            event.setCalendar(trainingRegister.getCalendar());
            eventRepository.save(event);
        }
    }
}
Also used : TrainingRegister(com.axelor.apps.talent.db.TrainingRegister) Event(com.axelor.apps.crm.db.Event) Transactional(com.google.inject.persist.Transactional)

Example 10 with Event

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

the class TrainingRegisterTalentRepository method remove.

@Override
public void remove(TrainingRegister trainingRegister) {
    Training training = trainingRegister.getTraining();
    TrainingSession session = trainingRegister.getTrainingSession();
    List<Event> eventList = trainingRegister.getEventList();
    for (Event event : eventList) {
        eventRepo.remove(event);
    }
    super.remove(trainingRegister);
    trainingRegisterService.updateTrainingRating(training, null);
    if (session != null) {
        trainingRegisterService.updateSessionRating(session, null);
    }
}
Also used : Training(com.axelor.apps.talent.db.Training) Event(com.axelor.apps.crm.db.Event) TrainingSession(com.axelor.apps.talent.db.TrainingSession)

Aggregations

Event (com.axelor.apps.crm.db.Event)36 Transactional (com.google.inject.persist.Transactional)21 EventRepository (com.axelor.apps.crm.db.repo.EventRepository)11 EventService (com.axelor.apps.crm.service.EventService)7 ICalendarEventService (com.axelor.base.service.ical.ICalendarEventService)7 TrainingRegister (com.axelor.apps.talent.db.TrainingRegister)6 Duration (java.time.Duration)6 AxelorException (com.axelor.exception.AxelorException)5 LocalDateTime (java.time.LocalDateTime)4 RecurrenceConfiguration (com.axelor.apps.crm.db.RecurrenceConfiguration)3 RecurrenceConfigurationRepository (com.axelor.apps.crm.db.repo.RecurrenceConfigurationRepository)3 HashMap (java.util.HashMap)3 TooManyIterationsException (org.apache.commons.math3.exception.TooManyIterationsException)3 Partner (com.axelor.apps.base.db.Partner)2 Lead (com.axelor.apps.crm.db.Lead)2 Training (com.axelor.apps.talent.db.Training)2 TrainingSession (com.axelor.apps.talent.db.TrainingSession)2 TrainingSessionRepository (com.axelor.apps.talent.db.repo.TrainingSessionRepository)2 User (com.axelor.auth.db.User)2 DayOfWeek (java.time.DayOfWeek)2