19 package org.turro.erp.task;
21 import java.util.Collection;
22 import java.util.HashMap;
24 import java.util.logging.Level;
25 import java.util.logging.Logger;
26 import net.sf.jasperreports.engine.JRException;
27 import org.turro.string.Strings;
28 import org.turro.command.Command;
29 import org.turro.command.Context;
30 import org.turro.contacts.Contact;
31 import org.turro.elephant.util.DateFormats;
32 import org.turro.elephant.util.DecimalFormats;
33 import org.turro.erp.entity.HumanResource;
34 import org.turro.financials.document.DocumentReport;
35 import org.turro.financials.entity.Company;
36 import org.turro.financials.model.business.CompanyWrapper;
37 import org.turro.contacts.util.MailRecipients;
38 import org.turro.elephant.context.Application;
39 import org.turro.elephant.context.ElephantContext;
40 import org.turro.elephant.security.IUser;
41 import org.turro.plugin.contacts.IContact;
42 import org.turro.plugin.contacts.MailContact;
43 import org.turro.util.PhraseBuilder;
44 import org.turro.zkoss.print.ReportPrint;
45 import org.turro.zkoss.print.ReportTypeEnum;
56 private boolean sendToParticipants =
false;
59 this.workloads = workloads;
63 this.sendToParticipants = sendToParticipants;
67 this.
operator =
operator;
68 if(
operator !=
null) {
69 subOperator =
operator.getOperator() ==
null ? null :
operator.getOperator().getContract().getIContractor();
74 if(workloads !=
null && !workloads.isEmpty()) {
76 final Map parameters =
new HashMap();
79 parameters.put(
"company", company);
80 parameters.put(
"companyContact", companyContact);
83 parameters.put(
"operator",
operator);
84 parameters.put(
"subOperator", subOperator);
88 ((
Contact)
operator.getContract().getIContractor().getContact()).getLocale(),
91 parameters.put(
"SUBREPORT_DIR",
"../_reports/erp/worksheet/");
93 final String file =
"/WEB-INF/_reports/erp/worksheet/Worksheet_" + Strings.toFile(
operator.getName()) +
".jasper";
95 if(sendToParticipants) {
96 Collection<IContact> cemails =
operator.getContract().getIParticipantsEmail();
97 if(subOperator !=
null && subOperator.
isWebUser()) {
98 cemails.add(subOperator);
100 String mailString = getMailString(
operator.getContract().getIParticipantsEmail());
103 public Object execute(Context context) {
109 wss, parameters, file,
"/WEB-INF/_reports/erp/worksheet/Worksheet.jasper",
112 }
catch (JRException ex) {
113 Logger.getLogger(
WorksheetReport.class.getName()).log(Level.SEVERE,
null, ex);
121 wss, parameters, file,
"/WEB-INF/_reports/erp/worksheet/Worksheet.jasper",
124 }
catch (JRException ex) {
125 Logger.getLogger(
DocumentReport.class.getName()).log(Level.SEVERE,
null, ex);
130 private String getMailString(Collection<IContact> iParticipantsEmail) {
131 PhraseBuilder pb =
new PhraseBuilder();
132 for(
IContact c : iParticipantsEmail) {
135 pb.addPendingSeparator(
",");
138 return pb.toString();
static ResourceBundle getBundle(String bundle, Locale locale, String configured)
static Application getApplication()
static String getString(String key)
static String getRealPath(String path)
static String getSiteLocales()
void setOperator(HumanResource operator)
void setWorkloads(WorkloadSet workloads)
void setSendToParticipants(boolean sendToParticipants)
static Company getDefaultCompany()
static void print(String title, Collection collection, Map parameters, String jasperFile, String defaultFile, String type, String certificateStore)
static void send(String title, Collection collection, Map parameters, String jasperFile, String defaultFile, String type, String certificateStore, Collection< IContact > contacts, String comment, Collection< MailAttachment > attachments, Consumer onFinish)
static final String CONNECTOR_EMAIL