use of org.compiere.model.PrintInfo in project adempiere by adempiere.
the class WPrintDocument method print.
public void print(PO document, String printFormantName, int windowNo) {
boolean retValue = true;
if (FDialog.ask(windowNo, SessionManager.getAppDesktop().getComponent(), "PrintShipments")) {
do {
try {
String keyColumnName = document.get_KeyColumns()[0];
MPrintFormat format = MPrintFormat.get(Env.getCtx(), MPrintFormat.getPrintFormat_ID(printFormantName, document.get_Table_ID(), 0), false);
MQuery query = new MQuery(document.get_TableName());
query.addRestriction(keyColumnName, MQuery.EQUAL, document.get_ValueAsInt(keyColumnName));
// Engine
PrintInfo info = new PrintInfo(document.get_TableName(), document.get_Table_ID(), document.get_ValueAsInt(keyColumnName));
ReportEngine re = new ReportEngine(Env.getCtx(), format, query, info);
if (re != null) {
SimplePDFViewer win = new SimplePDFViewer(printFormantName, new FileInputStream(re.getPDF()));
SessionManager.getAppDesktop().showWindow(win, "center");
}
} catch (Exception e) {
} finally {
retValue = FDialog.ask(windowNo, SessionManager.getAppDesktop().getComponent(), Msg.getMsg(Env.getCtx(), "PrintoutOK?"));
}
} while (!retValue);
}
}
use of org.compiere.model.PrintInfo in project adempiere by adempiere.
the class ReleaseInOutBound method getReportEngine.
/*
* get the a Report Engine Instance using the view table
* @param tableName
*/
private ReportEngine getReportEngine(String formatName, String tableName, int recordId) {
// Get Format & Data
int formatId = MPrintFormat.getPrintFormat_ID(formatName, MTable.getTable_ID(tableName), getAD_Client_ID());
MPrintFormat format = MPrintFormat.get(getCtx(), formatId, true);
if (format == null) {
addLog("@NotFound@ @AD_PrintFormat_ID@");
return null;
}
// query
MQuery query = new MQuery(tableName);
query.addRestriction(MDDOrder.COLUMNNAME_DD_Order_ID, MQuery.EQUAL, recordId);
// Engine
PrintInfo info = new PrintInfo(tableName, MTable.getTable_ID(tableName), recordId);
ReportEngine reportEngine = new ReportEngine(getCtx(), format, query, info);
return reportEngine;
}
use of org.compiere.model.PrintInfo in project adempiere by adempiere.
the class ZkJRViewer method cmd_archive.
// cmd_sendMail
/**
*
* Create a Archive for specified report
* Create an entry at AD_Archive table
*
*/
private void cmd_archive() {
boolean success = false;
byte[] data = getPDFAsArray(file);
MArchive arc = null;
if (data != null) {
PrintInfo printInfo = null;
if (null != processInfo) {
printInfo = new PrintInfo(processInfo);
}
if (null != printInfo) {
arc = new MArchive(Env.getCtx(), printInfo, null);
}
if (null != arc) {
arc.setBinaryData(data);
arc.setAD_Process_ID(processInfo.getAD_Process_ID());
arc.setRecord_ID(processInfo.getRecord_ID());
arc.setName(processInfo.getTitle());
success = arc.save();
}
}
if (success) {
FDialog.info(0, this, Msg.getMsg(ctx, "ArchiveSuccess", new Object[] { arc.getName() }));
log.log(Level.FINE, arc.getName() + " Archived Into " + arc.getAD_Archive_ID());
archive.setDisabled(Boolean.TRUE);
} else {
throw new AdempiereException("ArchiveError");
}
}
use of org.compiere.model.PrintInfo in project adempiere by adempiere.
the class ReportCtl method startStandardReport.
/**************************************************************************
* Start Standard Report.
* - Get Table Info & submit.<br>
* A report can be created from:
* <ol>
* <li>attached MPrintFormat, if any (see {@link ProcessInfo#setTransientObject(Object)}, {@link ProcessInfo#setSerializableObject(java.io.Serializable)}
* <li>process information (AD_Process.AD_PrintFormat_ID, AD_Process.AD_ReportView_ID)
* </ol>
* @param processInfo Process Info
* @param IsDirectPrint if true, prints directly - otherwise View
* @return true if OK
*/
public static boolean startStandardReport(ProcessInfo processInfo) {
ReportEngine reportEngine = null;
//
// Create Report Engine by using attached MPrintFormat (if any)
Object transientObject = processInfo.getTransientObject();
if (transientObject == null)
transientObject = processInfo.getSerializableObject();
if (transientObject != null && transientObject instanceof MPrintFormat) {
Properties ctx = Env.getCtx();
MPrintFormat format = (MPrintFormat) transientObject;
String tableName = MTable.getTableName(ctx, format.getAD_Table_ID());
MQuery query = MQuery.get(ctx, processInfo.getAD_PInstance_ID(), tableName);
PrintInfo info = new PrintInfo(processInfo);
reportEngine = new ReportEngine(ctx, format, query, info);
createOutput(reportEngine, processInfo.isPrintPreview(), null);
return true;
} else //
// Create Report Engine normally
{
reportEngine = ReportEngine.get(Env.getCtx(), processInfo);
if (reportEngine == null) {
processInfo.setSummary("No ReportEngine");
return false;
}
}
createOutput(reportEngine, processInfo.isPrintPreview(), null);
return true;
}
use of org.compiere.model.PrintInfo in project adempiere by adempiere.
the class Viewer method main.
// cmd_translate
/*************************************************************************/
/**
* Test
* @param args args
*/
public static void main(String[] args) {
Login.initTest(true);
MQuery q = new MQuery("C_Invoice");
q.addRestriction("C_Invoice_ID", MQuery.EQUAL, new Integer(103));
// 102 = Invoice - 100 = Order
PrintInfo i = new PrintInfo("test", X_C_Invoice.Table_ID, 102, 0);
MPrintFormat f = MPrintFormat.get(Env.getCtx(), 102, false);
ReportEngine re = new ReportEngine(Env.getCtx(), f, q, i);
// MPrintFormat f = new MPrintFormat(Env.getCtx(), 101);
// ReportEngine re = new ReportEngine(f, null);
new Viewer(re);
}
Aggregations