IDEMPIERE-1055 Print Dunning Letters on remote machine throwing errors
This commit is contained in:
parent
b3c1e844df
commit
f8b6a4f726
|
@ -14,11 +14,18 @@
|
|||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.process;
|
||||
package org.adempiere.webui.process;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.window.SimplePDFViewer;
|
||||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.model.MClient;
|
||||
import org.compiere.model.MDunningLevel;
|
||||
|
@ -31,6 +38,8 @@ import org.compiere.model.MUserMail;
|
|||
import org.compiere.model.PrintInfo;
|
||||
import org.compiere.print.MPrintFormat;
|
||||
import org.compiere.print.ReportEngine;
|
||||
import org.compiere.process.ProcessInfoParameter;
|
||||
import org.compiere.process.SvrProcess;
|
||||
import org.compiere.util.AdempiereUserError;
|
||||
import org.compiere.util.EMail;
|
||||
|
||||
|
@ -114,6 +123,7 @@ public class DunningPrint extends SvrProcess
|
|||
int count = 0;
|
||||
int errors = 0;
|
||||
MDunningRunEntry[] entries = run.getEntries(false);
|
||||
List<File> pdfList = new ArrayList<File>();
|
||||
for (int i = 0; i < entries.length; i++)
|
||||
{
|
||||
MDunningRunEntry entry = entries[i];
|
||||
|
@ -156,6 +166,7 @@ public class DunningPrint extends SvrProcess
|
|||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// query
|
||||
MQuery query = new MQuery("C_Dunning_Header_v");
|
||||
query.addRestriction("C_DunningRunEntry_ID", MQuery.EQUAL,
|
||||
|
@ -227,7 +238,10 @@ public class DunningPrint extends SvrProcess
|
|||
re.print ();
|
||||
count++;
|
||||
printed = true;
|
||||
pdfList.add(re.getPDF());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (printed)
|
||||
{
|
||||
|
@ -244,6 +258,27 @@ public class DunningPrint extends SvrProcess
|
|||
StringBuilder msgreturn = new StringBuilder("@Sent@=").append(count).append(" - @Errors@=").append(errors);
|
||||
return msgreturn.toString();
|
||||
}
|
||||
|
||||
if (pdfList.size() > 1) {
|
||||
try {
|
||||
File outFile = File.createTempFile("DunningPrint", ".pdf");
|
||||
AEnv.mergePdf(pdfList, outFile);
|
||||
Window win = new SimplePDFViewer(this.getName(), new FileInputStream(outFile));
|
||||
win.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
|
||||
SessionManager.getAppDesktop().showWindow(win, "center");
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
||||
}
|
||||
} else if (pdfList.size() > 0) {
|
||||
try {
|
||||
Window win = new SimplePDFViewer(this.getName(), new FileInputStream(pdfList.get(0)));
|
||||
win.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
|
||||
SessionManager.getAppDesktop().showWindow(win, "center");
|
||||
} catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
StringBuilder msgreturn = new StringBuilder("@Printed@=").append(count);
|
||||
return msgreturn.toString();
|
||||
} // doIt
|
||||
|
|
Loading…
Reference in New Issue