97 final RegisterView formalView = ViewWrapper.getFormalView();
98 Integer startPage = 1;
99 year =
new CheckDate().getYear();
101 InputDialog.getInput(
102 Framework.getCurrent().getPage(),
105 new InputField(
"From", new CheckDate().setMonth(1).setDay(1).getDate(), null, 0),
106 new InputField(
"To", new CheckDate().setMonth(12).setDay(31).getDate(), null, 0),
107 new InputField(
"Start page", startPage, null, 0),
108 new InputField(
"Book", null, null, 0) {
110 protected HtmlBasedComponent createEditor() {
111 BookListbox bl = new BookListbox();
112 bl.setMold(
"select");
116 new InputField(
"Export", Boolean.valueOf(
false),
null, 0)
119 public Object execute(Context context) {
120 BookDefinition bookDefinition =
null;
121 Integer startPage = 1;
122 Date from =
null, to =
null;
123 Boolean export =
false;
124 InputField[] fields = (InputField[]) context.get(
"fields");
125 if(fields.length > 0) {
126 for(InputField f : fields) {
127 if(
"From".equals(f.getLabel())) {
128 from = (Date) f.getValue();
129 }
else if(
"To".equals(f.getLabel())) {
130 to = (Date) f.getValue();
131 }
else if(
"Start page".equals(f.getLabel())) {
132 startPage = (Integer) f.getValue() - 1;
133 }
else if(
"Book".equals(f.getLabel())) {
134 bookDefinition = (BookDefinition) f.getValue();
135 }
else if(
"Export".equals(f.getLabel())) {
136 export = (Boolean) f.getValue();
139 if(from !=
null && to !=
null) {
140 if(bookDefinition.getId() == 4) {
141 Collection<Long> lines = getDocuments(formalView, from, to);
142 if(lines !=
null && lines.size() > 0) {
143 Map parameters =
new HashMap();
144 int fractionDigits = CompanyWrapper.getCompanyCurrency().getDefaultFractionDigits();
145 Company company = CompanyWrapper.getDefaultCompany();
146 Contact companyContact = (Contact) company.getIContact().getContact();
147 parameters.put(
"labels", Application.getStringMap());
148 parameters.put(
"i_", I_.api());
149 parameters.put(
"i", I_.map());
150 parameters.put(
"k", I_.byKeyMap());
151 parameters.put(
"bookDef", bookDefinition);
152 parameters.put(
"majors", getMajorBook(bookDefinition));
153 parameters.put(
"title", I_.get(
"Book") +
": " + bookDefinition.getDescription());
154 parameters.put(
"company", company);
155 parameters.put(
"companyContact", companyContact);
156 parameters.put(
"dateFormat", DateFormats.getDefaultFormat());
157 parameters.put(
"currencyFormat", DecimalFormats.getStringFormat(fractionDigits));
158 parameters.put(
"exportFormat", type);
159 parameters.put(
"from", from);
160 parameters.put(
"to", to);
162 String name = ElephantContext.getSiteName() +
"_Book" + bookDefinition.getDescription() +
".xls";
163 Filedownload.save(
getExcelForDocuments(name, lines, parameters),
new MimetypesFileTypeMap().getContentType(name), name);
186 Collection<Long> lines = getBookRegisters(formalView, from, to, bookDefinition);
187 if(lines !=
null && lines.size() > 0) {
188 Map parameters =
new HashMap();
189 int fractionDigits = CompanyWrapper.getCompanyCurrency().getDefaultFractionDigits();
190 Company company = CompanyWrapper.getDefaultCompany();
191 Contact companyContact = (Contact) company.getIContact().getContact();
192 parameters.put(
"labels", Application.getStringMap());
193 parameters.put(
"i_", I_.api());
194 parameters.put(
"i", I_.map());
195 parameters.put(
"k", I_.byKeyMap());
196 parameters.put(
"bookDef", bookDefinition);
197 parameters.put(
"majors", getMajorBook(bookDefinition));
198 parameters.put(
"title", I_.get(
"Book") +
": " + bookDefinition.getDescription());
199 parameters.put(
"company", company);
200 parameters.put(
"companyContact", companyContact);
201 parameters.put(
"dateFormat", DateFormats.getDefaultFormat());
202 parameters.put(
"currencyFormat", DecimalFormats.getStringFormat(fractionDigits));
203 parameters.put(
"exportFormat", type);
204 parameters.put(
"from", from);
205 parameters.put(
"to", to);
207 String name = ElephantContext.getSiteName() +
"_Book" + bookDefinition.getDescription() +
".xls";
208 Filedownload.save(
getExcel(name, lines, parameters),
new MimetypesFileTypeMap().getContentType(name), name);
210 parameters.put(
"startPage", startPage);
211 parameters.put(
"SUBREPORT_DIR",
"../_reports/financials/accounting/");
212 String file =
"/WEB-INF/_reports/financials/accounting/PrintBookDocuments.jasper";
213 OnDemandBeanCollection collection =
new OnDemandBeanCollection(lines) {
215 protected Object getRealBean(Object bean) {
216 return new FinancialsPU().find(BookRegister.class, (Long) bean);
220 ReportPrint.print(I_.get(
"Books"),
221 collection, parameters, file,
null,
223 }
catch (JRException ex) {
224 Logger.getLogger(
PrintBook.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(
null), ex);
static InputStream getExcel(String sheetName, Collection< Long > bookRegisters, Map parameters)
static InputStream getExcelForDocuments(String sheetName, Collection< Long > documentIds, Map parameters)