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