48 Dao dao =
new CrmPU();
49 Vendor vendor = (Vendor) dao.getSingleResultOrNull(
50 "select v from Vendor v where v.idContact = ?",
53 Date newFrom =
new CheckDate(
getFrom()).addDays(-7).getDate(),
54 newTo =
new CheckDate(
getTo()).addDays(7).getDate();
55 List<SaleAction> list = dao.getResultList(
56 "select sa from SaleAction sa " +
57 "where sa.vendorProspect.vendor = ? " +
59 "(sa.actionDate >= ? and sa.actionDate <= ?) " +
60 "or (sa.finalDate >= ? and sa.finalDate <= ?) " +
61 "or (sa.actionDate < ? and sa.finalDate > ?) " +
63 new Object[] { vendor,
68 for(SaleAction sa : list) {
69 DefaultCalendarEvent calendarEvent =
new DefaultCalendarEvent();
70 calendarEvent.setLocked(
false);
71 calendarEvent.setDone(sa.getStatus() > 0);
72 if(sa.getStatus() > SaleAction.SA_PENDING) {
73 calendarEvent.setHeaderColor(CalendarColor.SILVER.getHeader());
74 calendarEvent.setContentColor(CalendarColor.SILVER.getContent());
76 calendarEvent.setHeaderColor(CalendarColor.GREEN.getHeader());
77 calendarEvent.setContentColor(CalendarColor.GREEN.getContent());
79 calendarEvent.setBeginDate(sa.getActionDate());
80 calendarEvent.setEndDate(sa.getFinalDate());
81 calendarEvent.setPath(CrmPU.getObjectPath(sa));
82 calendarEvent.setOrganizer(sa.getVendorProspect().getVendor().getIContact());
83 PhraseBuilder pb =
new PhraseBuilder();
84 VendorProspect vp = sa.getVendorProspect();
85 pb.addWord(vp.getSaleProspect().getCustomer().getName());
86 pb.addPendingSeparator(Chars.forward().toString());
87 pb.addWord(vp.getSaleProspect().getDescription());
88 calendarEvent.setTitle(pb.toString());
89 pb.addPendingSeparator(Chars.nl().repeat(2).toString());
90 pb.addWord(sa.getComment());
91 pb.addPendingSeparator(Chars.nl().repeat(2).toString());
92 for(IContact contact : sa.getIAttendees()) {
93 pb.addWord(contact.getName());
94 pb.addPendingSeparator(
", ");
95 calendarEvent.addAttendee(contact);
97 calendarEvent.setContent(pb.toString());
98 calendarEvent.setEventId(Strings.identifier(
"sa" + sa.getId() +
99 ObjectString.formatObject(calendarEvent.getBeginDate(), ObjectString.COMPRESSED_DATE_PATTERN,
true)));
100 addResult(calendarEvent.getEventId(), calendarEvent);
Object addResult(String key, Object value)