87 final Collection<DocumentLine> lines = getLines();
88 final Document doc = getDocument();
89 if(lines !=
null && lines.size() > 0) {
90 DocumentLine sample = lines.iterator().next();
91 int fractionDigits = doc.getCurrency().getDefaultFractionDigits();
92 final Map parameters =
new HashMap();
93 Company company = CompanyWrapper.getCompanyFrom(sample);
94 Contact companyContact = (Contact) company.getIContact().getContact();
95 parameters.put(
"company", company);
96 parameters.put(
"companyContact", companyContact);
97 parameters.put(
"dateFormat", DateFormats.getDefaultFormat());
98 parameters.put(
"currencyFormat", DecimalFormats.getStringFormat(fractionDigits));
99 parameters.put(
"showDescendants", Boolean.TRUE);
100 Contact contractor = (Contact) doc.getContract().getIContractor().getContact();
101 parameters.put(
"contractor", contractor);
102 parameters.put(
"exportFormat", type);
103 parameters.put(
"REPORT_RESOURCE_BUNDLE", Application.getBundle(
105 ((Contact) doc.getContract().getIContractor().getContact()).getLocale(),
106 ElephantContext.getSiteLocales()));
110 parameters.put(
"SUBREPORT_DIR",
"../_reports/financials/document/");
111 parameters.put(
"LOGO_IMAGE", ElephantContext.getRealPath(
"/WEB-INF/_reports/images/doc_logo.png"));
112 final String file =
"/WEB-INF/_reports/financials/document/" + doc.getDocumentDefinition().getName() +
116 if(sendToParticipants) {
117 MailRecipients.selectRecipients(doc.getContract().getIParticipantsEmail(),
new Command() {
119 public Object execute(Context context) {
120 MailRecipients mr = (MailRecipients) context.get(
"component");
121 Collection<IContact> emails = mr.getRecipients();
122 doPrint(emails, doc, lines, parameters, file, type);
128 MailRecipients.selectRecipients(List.of(Authentication.getIContact()),
new Command() {
130 public Object execute(Context context) {
131 MailRecipients mr = (MailRecipients) context.get(
"component");
132 Collection<IContact> emails = mr.getRecipients();
133 doPrint(emails, doc, lines, parameters, file, type);
139 if(sendToParticipants) {
140 Collection<IContact> emails = doc.getContract().getIParticipantsEmail();
141 doPrint(emails, doc, lines, parameters, file, type);
143 if(sendToCurrent && Authentication.isAdministrator()) {
144 Collection<IContact> emails = List.of(Authentication.getIContact());
145 doPrint(emails, doc, lines, parameters, file, type);
148 if(!(sendToParticipants || sendToCurrent)) {
149 ReportPrint.print(doc.getDocDescription(),
150 lines, parameters, file,
"/WEB-INF/_reports/financials/document/Document" +
154 }
catch (JRException ex) {
155 Logger.getLogger(DocumentReport.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(
null), ex);