/** Prepares the list */ public void prepare() throws Exception { ActionContext context = ActionContext.getContext(); Map<String, Object> session = context.getSession(); String local = (String) session.get("locale"); this.statuses = callStatusService.getOptions(CallStatus.class.getSimpleName(), local); this.directions = callDirectionService.getOptions(CallDirection.class.getSimpleName(), local); this.reminderOptions = reminderOptionService.getOptions(ReminderOption.class.getSimpleName(), local); // Gets reminder email template list String hql = "select new EmailTemplate(id,name) from EmailTemplate where type = 'callRemind' order by created_on"; reminderTemplates = emailTemplateService.findByHQL(hql); }
/** * Gets the list data. * * @return null */ public String listFull() throws Exception { UserUtil.permissionCheck("view_document"); User loginUser = UserUtil.getLoginUser(); int scope = loginUser.getScope_document(); StringBuilder hqlBuilder = new StringBuilder("select new Document(id,name) from Document"); if (scope == Role.OWNER_OR_DISABLED) { hqlBuilder.append(" where owner = ").append(loginUser.getId()); } hqlBuilder.append(" order by created_on desc"); List<Document> result = baseService.findByHQL(hqlBuilder.toString()); documents = result.iterator(); return SUCCESS; }
public String selectTemplate() throws Exception { UserUtil.permissionCheck("update_call"); call = baseService.getEntityById(Call.class, this.getId()); Date start_date = call.getStart_date(); SimpleDateFormat dateFormat = new SimpleDateFormat(Constant.DATE_TIME_FORMAT); startDate = ""; if (start_date != null) { startDate = dateFormat.format(start_date); } EmailTemplate emailTemplte = emailTemplateService.getEntityById(EmailTemplate.class, emailTemplateID); this.setText_only(emailTemplte.isText_only()); this.setSubject(CommonUtil.fromNullToEmpty(emailTemplte.getSubject())); String content = ""; if (this.isText_only()) { content = emailTemplte.getText_body(); } else { content = emailTemplte.getHtml_body(); } // Replaces the variable in the body if (content != null) { content = content.replaceAll("\\$call.subject", CommonUtil.fromNullToEmpty(call.getSubject())); content = content.replaceAll("\\$call.start_date", startDate); } if (this.isText_only()) { this.setText_body(content); } else { this.setHtml_body(content); } // Gets email template list String hql = "select new EmailTemplate(id,name) from EmailTemplate where type = 'callInvite' order by created_on"; emailTemplates = emailTemplateService.findByHQL(hql); return SUCCESS; }
/** * Sends invitation mail to all participants. * * @return the SUCCESS result */ public String sendInvites() throws Exception { UserUtil.permissionCheck("update_call"); call = baseService.getEntityById(Call.class, call.getId()); Date start_date = call.getStart_date(); SimpleDateFormat dateFormat = new SimpleDateFormat(Constant.DATE_TIME_FORMAT); startDate = ""; if (start_date != null) { startDate = dateFormat.format(start_date); } this.setId(call.getId()); ActionContext context = ActionContext.getContext(); Map<String, Object> session = context.getSession(); User loginUser = (User) session.get(AuthenticationSuccessListener.LOGIN_USER); StringBuilder targetEmails = new StringBuilder(""); Set<Contact> contacts = call.getContacts(); if (contacts != null) { for (Contact contact : contacts) { String email = contact.getEmail(); if (CommonUtil.isNullOrEmpty(email)) { continue; } if (targetEmails.length() > 0) { targetEmails.append(","); } targetEmails.append(email); } } Set<Lead> leads = call.getLeads(); if (leads != null) { for (Lead lead : leads) { String email = lead.getEmail(); if (CommonUtil.isNullOrEmpty(email)) { continue; } if (targetEmails.length() > 0) { targetEmails.append(","); } targetEmails.append(email); } } from = loginUser.getEmail(); if (from == null) { from = ""; } Set<User> users = call.getUsers(); if (users != null) { for (User user : users) { String email = user.getEmail(); if (CommonUtil.isNullOrEmpty(email) || (from != null && email.endsWith(from))) { continue; } if (targetEmails.length() > 0) { targetEmails.append(","); } targetEmails.append(email); } } if (targetEmails.length() > 0) { to = targetEmails.toString(); } // Gets email template list String hql = "select new EmailTemplate(id,name) from EmailTemplate where type = 'callInvite' order by created_on"; emailTemplates = emailTemplateService.findByHQL(hql); return SUCCESS; }