From 8a129ab3eaf61678d028d3486354234a9bae7f70 Mon Sep 17 00:00:00 2001 From: Deepak Pansheriya Date: Tue, 10 Feb 2015 19:15:04 +0530 Subject: [PATCH] IDEMPIERE-2389 Print format and View Report selection on process dialog. --- .../oracle/201502041515_IDEMPIERE-2389.sql | 30 ++++ .../201502041515_IDEMPIERE-2389.sql | 32 ++++ .../org/compiere/model/I_AD_PInstance.java | 24 +++ .../org/compiere/model/X_AD_PInstance.java | 53 ++++++- .../src/org/compiere/print/ReportEngine.java | 13 ++ .../src/org/compiere/process/ProcessInfo.java | 10 ++ .../webui/apps/AbstractProcessDialog.java | 2 +- .../adempiere/webui/apps/ProcessDialog.java | 144 +++++++++++++++++- .../org/adempiere/webui/apps/WProcessCtl.java | 54 +++---- .../webui/window/ZkReportViewer.java | 41 +++-- .../src/org/compiere/print/ReportCtl.java | 18 ++- 11 files changed, 370 insertions(+), 51 deletions(-) create mode 100644 migration/i2.1z/oracle/201502041515_IDEMPIERE-2389.sql create mode 100644 migration/i2.1z/postgresql/201502041515_IDEMPIERE-2389.sql diff --git a/migration/i2.1z/oracle/201502041515_IDEMPIERE-2389.sql b/migration/i2.1z/oracle/201502041515_IDEMPIERE-2389.sql new file mode 100644 index 0000000000..257e71eb7e --- /dev/null +++ b/migration/i2.1z/oracle/201502041515_IDEMPIERE-2389.sql @@ -0,0 +1,30 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Feb 4, 2015 3:20:47 PM IST +-- IDEMPIERE-2389 Add ReportType and AD_PrintFormat_ID in AD_PInstance Table +INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Reference_Value_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure) VALUES (211830,0,'Report Type',282,'ReportType',NULL,5,'N','N','N','N','N',0,'N',10,NULL,0,0,'Y',TO_DATE('2015-02-04 15:20:46','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2015-02-04 15:20:46','YYYY-MM-DD HH24:MI:SS'),100,202814,'Y','N','D','N','N','N','Y','613c626e-e9a4-4efb-a39c-88529c27aea4','Y',0,'N','N') +; + +-- Feb 4, 2015 3:20:54 PM IST +ALTER TABLE AD_PInstance ADD ReportType VARCHAR2(5) DEFAULT NULL +; + +-- Feb 4, 2015 4:10:38 PM IST +INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure) VALUES (211834,0,'Print Format','Data Print Format','The print format determines how data is rendered for print.',282,'AD_PrintFormat_ID',NULL,22,'N','N','N','N','N',0,'N',19,0,0,'Y',TO_DATE('2015-02-04 16:10:36','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2015-02-04 16:10:36','YYYY-MM-DD HH24:MI:SS'),100,1790,'Y','N','D','N','N','N','Y','d2dbfea7-01e4-4fd5-8d75-cfe123ccf422','Y',0,'N','N') +; + +-- Feb 4, 2015 4:10:41 PM IST +UPDATE AD_Column SET IsToolbarButton='N', FKConstraintName='ADPrintFormat_ADPInstance', FKConstraintType='N',Updated=TO_DATE('2015-02-04 16:10:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=211834 +; + +-- Feb 4, 2015 4:10:41 PM IST +ALTER TABLE AD_PInstance ADD AD_PrintFormat_ID NUMBER(10) DEFAULT NULL +; + +-- Feb 4, 2015 4:10:42 PM IST +ALTER TABLE AD_PInstance ADD CONSTRAINT ADPrintFormat_ADPInstance FOREIGN KEY (AD_PrintFormat_ID) REFERENCES ad_printformat(ad_printformat_id) DEFERRABLE INITIALLY DEFERRED +; + +SELECT register_migration_script('201502041515_IDEMPIERE-2389.sql') FROM dual +; diff --git a/migration/i2.1z/postgresql/201502041515_IDEMPIERE-2389.sql b/migration/i2.1z/postgresql/201502041515_IDEMPIERE-2389.sql new file mode 100644 index 0000000000..0fdeb45967 --- /dev/null +++ b/migration/i2.1z/postgresql/201502041515_IDEMPIERE-2389.sql @@ -0,0 +1,32 @@ +-- Feb 4, 2015 3:19:23 PM IST +-- IDEMPIERE-2389 Add ReportType and AD_PrintFormat_ID in AD_PInstance Table +INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,PrintName,EntityType,AD_Element_UU) VALUES (202814,0,0,'Y',TO_TIMESTAMP('2015-02-04 15:19:22','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2015-02-04 15:19:22','YYYY-MM-DD HH24:MI:SS'),100,'ReportType','Report Type','Report Type','D','84422b03-ffa2-435b-a485-9ac5de986f0c') +; + +-- Feb 4, 2015 3:20:47 PM IST +INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Reference_Value_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure) VALUES (211830,0,'Report Type',282,'ReportType',NULL,5,'N','N','N','N','N',0,'N',10,NULL,0,0,'Y',TO_TIMESTAMP('2015-02-04 15:20:46','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2015-02-04 15:20:46','YYYY-MM-DD HH24:MI:SS'),100,202814,'Y','N','D','N','N','N','Y','613c626e-e9a4-4efb-a39c-88529c27aea4','Y',0,'N','N') +; + +-- Feb 4, 2015 3:20:54 PM IST +ALTER TABLE AD_PInstance ADD COLUMN ReportType VARCHAR(5) DEFAULT NULL +; + +-- Feb 4, 2015 4:10:38 PM IST +INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure) VALUES (211834,0,'Print Format','Data Print Format','The print format determines how data is rendered for print.',282,'AD_PrintFormat_ID',NULL,22,'N','N','N','N','N',0,'N',19,0,0,'Y',TO_TIMESTAMP('2015-02-04 16:10:36','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2015-02-04 16:10:36','YYYY-MM-DD HH24:MI:SS'),100,1790,'Y','N','D','N','N','N','Y','d2dbfea7-01e4-4fd5-8d75-cfe123ccf422','Y',0,'N','N') +; + +-- Feb 4, 2015 4:10:41 PM IST +UPDATE AD_Column SET IsToolbarButton='N', FKConstraintName='ADPrintFormat_ADPInstance', FKConstraintType='N',Updated=TO_TIMESTAMP('2015-02-04 16:10:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=211834 +; + +-- Feb 4, 2015 4:10:41 PM IST +ALTER TABLE AD_PInstance ADD COLUMN AD_PrintFormat_ID NUMERIC(10) DEFAULT NULL +; + +-- Feb 4, 2015 4:10:42 PM IST +ALTER TABLE AD_PInstance ADD CONSTRAINT ADPrintFormat_ADPInstance FOREIGN KEY (AD_PrintFormat_ID) REFERENCES ad_printformat(ad_printformat_id) DEFERRABLE INITIALLY DEFERRED +; + +SELECT register_migration_script('201502041515_IDEMPIERE-2389.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/compiere/model/I_AD_PInstance.java b/org.adempiere.base/src/org/compiere/model/I_AD_PInstance.java index cd87a40724..3c6186cae4 100644 --- a/org.adempiere.base/src/org/compiere/model/I_AD_PInstance.java +++ b/org.adempiere.base/src/org/compiere/model/I_AD_PInstance.java @@ -84,6 +84,21 @@ public interface I_AD_PInstance /** Get AD_PInstance_UU */ public String getAD_PInstance_UU(); + /** Column name AD_PrintFormat_ID */ + public static final String COLUMNNAME_AD_PrintFormat_ID = "AD_PrintFormat_ID"; + + /** Set Print Format. + * Data Print Format + */ + public void setAD_PrintFormat_ID (int AD_PrintFormat_ID); + + /** Get Print Format. + * Data Print Format + */ + public int getAD_PrintFormat_ID(); + + public org.compiere.model.I_AD_PrintFormat getAD_PrintFormat() throws RuntimeException; + /** Column name AD_Process_ID */ public static final String COLUMNNAME_AD_Process_ID = "AD_Process_ID"; @@ -209,6 +224,15 @@ public interface I_AD_PInstance */ public int getRecord_ID(); + /** Column name ReportType */ + public static final String COLUMNNAME_ReportType = "ReportType"; + + /** Set Report Type */ + public void setReportType (String ReportType); + + /** Get Report Type */ + public String getReportType(); + /** Column name Result */ public static final String COLUMNNAME_Result = "Result"; diff --git a/org.adempiere.base/src/org/compiere/model/X_AD_PInstance.java b/org.adempiere.base/src/org/compiere/model/X_AD_PInstance.java index 26d68db70f..38db3309ab 100644 --- a/org.adempiere.base/src/org/compiere/model/X_AD_PInstance.java +++ b/org.adempiere.base/src/org/compiere/model/X_AD_PInstance.java @@ -30,7 +30,7 @@ public class X_AD_PInstance extends PO implements I_AD_PInstance, I_Persistent /** * */ - private static final long serialVersionUID = 20141030L; + private static final long serialVersionUID = 20150204L; /** Standard Constructor */ public X_AD_PInstance (Properties ctx, int AD_PInstance_ID, String trxName) @@ -44,6 +44,8 @@ public class X_AD_PInstance extends PO implements I_AD_PInstance, I_Persistent setIsRunAsJob (false); // N setRecord_ID (0); + setReportType (null); +// P } */ } @@ -120,6 +122,34 @@ public class X_AD_PInstance extends PO implements I_AD_PInstance, I_Persistent return (String)get_Value(COLUMNNAME_AD_PInstance_UU); } + public org.compiere.model.I_AD_PrintFormat getAD_PrintFormat() throws RuntimeException + { + return (org.compiere.model.I_AD_PrintFormat)MTable.get(getCtx(), org.compiere.model.I_AD_PrintFormat.Table_Name) + .getPO(getAD_PrintFormat_ID(), get_TrxName()); } + + /** Set Print Format. + @param AD_PrintFormat_ID + Data Print Format + */ + public void setAD_PrintFormat_ID (int AD_PrintFormat_ID) + { + if (AD_PrintFormat_ID < 1) + set_Value (COLUMNNAME_AD_PrintFormat_ID, null); + else + set_Value (COLUMNNAME_AD_PrintFormat_ID, Integer.valueOf(AD_PrintFormat_ID)); + } + + /** Get Print Format. + @return Data Print Format + */ + public int getAD_PrintFormat_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_AD_PrintFormat_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + public org.compiere.model.I_AD_Process getAD_Process() throws RuntimeException { return (org.compiere.model.I_AD_Process)MTable.get(getCtx(), org.compiere.model.I_AD_Process.Table_Name) @@ -300,6 +330,27 @@ public class X_AD_PInstance extends PO implements I_AD_PInstance, I_Persistent return ii.intValue(); } + /** PDF = P */ + public static final String REPORTTYPE_PDF = "P"; + /** HTML = H */ + public static final String REPORTTYPE_HTML = "H"; + /** XLS = X */ + public static final String REPORTTYPE_XLS = "X"; + /** Set Report Type. + @param ReportType Report Type */ + public void setReportType (String ReportType) + { + + set_Value (COLUMNNAME_ReportType, ReportType); + } + + /** Get Report Type. + @return Report Type */ + public String getReportType () + { + return (String)get_Value(COLUMNNAME_ReportType); + } + /** Set Result. @param Result Result of the action taken diff --git a/org.adempiere.base/src/org/compiere/print/ReportEngine.java b/org.adempiere.base/src/org/compiere/print/ReportEngine.java index 6a232aaa45..6a28842cad 100644 --- a/org.adempiere.base/src/org/compiere/print/ReportEngine.java +++ b/org.adempiere.base/src/org/compiere/print/ReportEngine.java @@ -1762,4 +1762,17 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) { m_summary = summary; } + + private String reportType; + + public void setReportType(String type) + { + reportType = type; + } + + public String getReportType() + { + return reportType; + } + } // ReportEngine diff --git a/org.adempiere.base/src/org/compiere/process/ProcessInfo.java b/org.adempiere.base/src/org/compiere/process/ProcessInfo.java index 98195ce49a..80d79f8cf3 100644 --- a/org.adempiere.base/src/org/compiere/process/ProcessInfo.java +++ b/org.adempiere.base/src/org/compiere/process/ProcessInfo.java @@ -144,6 +144,16 @@ public class ProcessInfo implements Serializable private transient PO m_po = null; + private String reportType = null; + + public String getReportType() { + return reportType; + } + + public void setReportType(String reportType) { + this.reportType = reportType; + } + /** * String representation * @return String representation diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AbstractProcessDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AbstractProcessDialog.java index 9b855a1fc6..1199636b93 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AbstractProcessDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AbstractProcessDialog.java @@ -90,7 +90,7 @@ public abstract class AbstractProcessDialog extends Window implements IProcessUI private static CLogger log = CLogger.getCLogger(AbstractProcessDialog.class); - private int m_WindowNo; + protected int m_WindowNo; private Properties m_ctx; private int m_AD_Process_ID; private ProcessInfo m_pi = null; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java index 93489ca59e..10cd6b6408 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java @@ -23,6 +23,7 @@ import java.io.FileOutputStream; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; +import java.util.Properties; import java.util.logging.Level; import org.adempiere.util.Callback; @@ -33,12 +34,14 @@ import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.DocumentLink; import org.adempiere.webui.component.Grid; import org.adempiere.webui.component.GridFactory; +import org.adempiere.webui.component.Listbox; import org.adempiere.webui.component.Mask; import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Window; import org.adempiere.webui.desktop.IDesktop; +import org.adempiere.webui.editor.WTableDirEditor; import org.adempiere.webui.factory.ButtonFactory; import org.adempiere.webui.panel.IHelpContext; import org.adempiere.webui.part.WindowContainer; @@ -47,10 +50,16 @@ import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.window.FDialog; import org.adempiere.webui.window.SimplePDFViewer; +import org.compiere.model.Lookup; +import org.compiere.model.MLookupFactory; import org.compiere.model.MPInstance; import org.compiere.model.MPInstancePara; import org.compiere.model.MProcess; +import org.compiere.model.MRole; +import org.compiere.model.MTable; import org.compiere.model.X_AD_CtxHelp; +import org.compiere.model.X_AD_ReportView; +import org.compiere.print.MPrintFormat; import org.compiere.print.ReportEngine; import org.compiere.process.ProcessInfo; import org.compiere.process.ProcessInfoLog; @@ -146,6 +155,8 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene int WindowNo = SessionManager.getAppDesktop().registerWindow(this); this.setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, WindowNo); Env.setContext(Env.getCtx(), WindowNo, "IsSOTrx", isSOTrx ? "Y" : "N"); + m_ctx = Env.getCtx(); + m_AD_Process_ID = AD_Process_ID; try { MProcess process = MProcess.get(Env.getCtx(), AD_Process_ID); @@ -165,6 +176,62 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene } } // ProcessDialog + private void listPrintFormat() + { + int AD_Column_ID = 0; + boolean m_isCanExport = false; + + MProcess pr = new MProcess(m_ctx, m_AD_Process_ID, null); + int table_ID = 0; + try + { + if (pr.getAD_ReportView_ID() > 0) + { + X_AD_ReportView m_Reportview = new X_AD_ReportView(m_ctx, pr.getAD_ReportView_ID(), null); + table_ID = m_Reportview.getAD_Table_ID(); + } + else if (pr.getAD_PrintFormat_ID() > 0) + { + MPrintFormat format = new MPrintFormat(m_ctx, pr.getAD_PrintFormat_ID(), null); + table_ID = format.getAD_Table_ID(); + } + String valCode = null; + if (table_ID > 0) + { + valCode = "AD_PrintFormat.AD_Table_ID=" + table_ID; + m_isCanExport = MRole.getDefault().isCanExport(table_ID); + } + Lookup lookup = MLookupFactory.get (Env.getCtx(), m_WindowNo, + AD_Column_ID, DisplayType.TableDir, + Env.getLanguage(Env.getCtx()), "AD_PrintFormat_ID", 0, false, + valCode); + + fPrintFormat = new WTableDirEditor("AD_PrintFormat_ID", false, false, true, lookup); + } + catch (Exception e) + { + log.log(Level.SEVERE, e.getLocalizedMessage()); + } + + freportType.removeAllItems(); + freportType.setMold("select"); + freportType.appendItem("HTML", "HTML"); + + if (m_isCanExport) + { + freportType.appendItem("PDF", "PDF"); + freportType.appendItem("Excel", "XLS"); + } + freportType.setSelectedIndex(0); + + String where = "AD_Process_ID = ? AND AD_User_ID = ? AND Name IS NULL "; + + MPInstance lastrun = MTable.get(Env.getCtx(), MPInstance.Table_Name).createQuery(where, null).setOnlyActiveRecords(true).setClient_ID() + .setParameters(m_AD_Process_ID, Env.getContextAsInt(Env.getCtx(), "#AD_User_ID")).setOrderBy("Created DESC").first(); + + setReportTypeAndPrintFormat(lastrun); + } + private void querySaved() { //user query @@ -203,12 +270,15 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene center.setStyle("border: none"); Rows rows = southRowPanel.newRows(); + rows.getParent().getId(); + Row row1 = rows.newRow(); Row row = rows.newRow(); Hbox hBox = new Hbox(); + Hbox hBox1 = new Hbox(); lSaved = new Label(Msg.getMsg(Env.getCtx(), "SavedParameter")); - hBox.appendChild(lSaved); + hBox1.appendChild(lSaved); fSavedName.addEventListener(Events.ON_CHANGE, this); hBox.appendChild(fSavedName); @@ -220,21 +290,50 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene bDelete.addActionListener(this); hBox.appendChild(bDelete); + hBox.setStyle("margin-right:30px;"); + hBox1.setStyle("margin-right:30px;"); + row1.appendChild(hBox1); row.appendChild(hBox); + + // Print format on report para + MProcess pr = new MProcess(m_ctx, m_AD_Process_ID, null); + if (pr.isReport() && pr.getJasperReport() == null) + { + listPrintFormat(); - if(!showLastRun) + hBox = new Hbox(); + hBox1 = new Hbox(); + hBox1.appendChild(lPrintFormat); + hBox.appendChild(fPrintFormat.getComponent()); + row1.appendChild(hBox1); + row.appendChild(hBox); + + hBox = new Hbox(); + hBox1 = new Hbox(); + hBox1.appendChild(lreportType); + hBox.appendChild(freportType); + row1.appendChild(hBox1); + row.appendChild(hBox); + } + + if(!showLastRun) + { hBox.setVisible(false); + hBox1.setVisible(false); + } Panel confParaPanel =new Panel(); - confParaPanel.setAlign("right"); + confParaPanel.setStyle("float:right"); // Invert - Unify OK/Cancel IDEMPIERE-77 bOK = ButtonFactory.createNamedButton(ConfirmPanel.A_OK, true, true); bOK.setId("Ok"); + bOK.setWidth("50%"); bOK.addEventListener(Events.ON_CLICK, this); confParaPanel.appendChild(bOK); bCancel = ButtonFactory.createNamedButton(ConfirmPanel.A_CANCEL, true, true); bCancel.setId("Cancel"); + bCancel.setWidth("50%"); bCancel.addEventListener(Events.ON_CLICK, this); confParaPanel.appendChild(bCancel); row.appendChild(confParaPanel); @@ -255,6 +354,15 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene private List savedParams; private Label lSaved; + private Properties m_ctx; + private int m_AD_Process_ID; + + // Print Format and View Report + private WTableDirEditor fPrintFormat = null; + private Listbox freportType = new Listbox(); + private Label lPrintFormat = new Label(Msg.translate(Env.getCtx(), "AD_PrintFormat_ID")); + private Label lreportType = new Label(Msg.translate(Env.getCtx(), "view.report")); + /** * Set Visible * (set focus to OK if visible) @@ -289,6 +397,16 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene } else if (component instanceof Button) { Button element = (Button)component; if ("Ok".equalsIgnoreCase(element.getId())) { + if(freportType.getSelectedItem() != null) { + getProcessInfo().setReportType(freportType.getSelectedItem().getValue().toString()); + } + if(fPrintFormat != null && fPrintFormat.getValue() != null) { + MPrintFormat format = new MPrintFormat(m_ctx, (Integer) fPrintFormat.getValue(), null); + if (format != null) { + getProcessInfo().setSerializableObject(format); + } + } + if (isParameterPage) startProcess(); else @@ -310,6 +428,9 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene para.deleteEx(true); } getParameterPanel().saveParameters(); + savedParams.get(i).setAD_PrintFormat_ID((Integer)fPrintFormat.getValue()); + savedParams.get(i).setReportType(freportType.getSelectedItem().getValue().toString()); + savedParams.get(i).saveEx(); } } } @@ -320,6 +441,8 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene instance = new MPInstance(Env.getCtx(), getProcessInfo().getAD_Process_ID(), getProcessInfo().getRecord_ID()); instance.setName(saveName); + instance.setAD_PrintFormat_ID((Integer) fPrintFormat.getValue()); + instance.setReportType(freportType.getSelectedItem().getValue().toString()); instance.saveEx(); getProcessInfo().setAD_PInstance_ID(instance.getAD_PInstance_ID()); // Get Parameters @@ -390,8 +513,23 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene return item; } + private void setReportTypeAndPrintFormat(MPInstance instance) + { + if (fPrintFormat != null && instance != null) { + fPrintFormat.setValue((Integer) instance.getAD_PrintFormat_ID()); + } + + if (freportType != null && instance != null) { + if (instance.getReportType() == null) + freportType.setValue("HTML"); + else + freportType.setValue(instance.getReportType()); + } + } + private void loadSavedParams(MPInstance instance) { getParameterPanel().loadParameters(instance); + setReportTypeAndPrintFormat(instance); } private void doOnClick(A btn) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/WProcessCtl.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/WProcessCtl.java index 450d0d62f3..421ae229ab 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/WProcessCtl.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/WProcessCtl.java @@ -126,34 +126,34 @@ public class WProcessCtl extends AbstractProcessCtl { { if (log.isLoggable(Level.FINE)) log.fine("WindowNo=" + WindowNo + " - " + pi); - if (pi.getAD_PInstance_ID() < 1) { //red1 bypass if PInstance exists - MPInstance instance = null; - try - { - instance = new MPInstance(Env.getCtx(), pi.getAD_Process_ID(), pi.getRecord_ID()); - } - catch (Exception e) - { - pi.setSummary (e.getLocalizedMessage()); - pi.setError (true); - log.warning(pi.toString()); - return; - } - catch (Error e) - { - pi.setSummary (e.getLocalizedMessage()); - pi.setError (true); - log.warning(pi.toString()); - return; - } - if (!instance.save()) - { - pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessNoInstance")); - pi.setError (true); - return; - } - pi.setAD_PInstance_ID (instance.getAD_PInstance_ID()); +// if (pi.getAD_PInstance_ID() < 1) { //red1 bypass if PInstance exists + MPInstance instance = null; + try + { + instance = new MPInstance(Env.getCtx(), pi.getAD_Process_ID(), pi.getRecord_ID()); } + catch (Exception e) + { + pi.setSummary (e.getLocalizedMessage()); + pi.setError (true); + log.warning(pi.toString()); + return; + } + catch (Error e) + { + pi.setSummary (e.getLocalizedMessage()); + pi.setError (true); + log.warning(pi.toString()); + return; + } + if (!instance.save()) + { + pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessNoInstance")); + pi.setError (true); + return; + } + pi.setAD_PInstance_ID (instance.getAD_PInstance_ID()); +// } // Get Parameters if (parameter != null) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java index 2633ea6a40..028789de16 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java @@ -261,22 +261,33 @@ public class ZkReportViewer extends Window implements EventListener, ITab previewType.addEventListener(Events.ON_SELECT, this); toolBar.appendChild(new Separator("vertical")); - //set default type - String type = m_reportEngine.getPrintFormat().isForm() - // a42niem - provide explicit default and check on client/org specifics - ? MSysConfig.getValue(MSysConfig.ZK_REPORT_FORM_OUTPUT_TYPE,"PDF",Env.getAD_Client_ID(m_ctx),Env.getAD_Org_ID(m_ctx)) - : MSysConfig.getValue(MSysConfig.ZK_REPORT_TABLE_OUTPUT_TYPE,"PDF",Env.getAD_Client_ID(m_ctx),Env.getAD_Org_ID(m_ctx)); - - if ("HTML".equals(type)) { - previewType.setSelectedIndex(0); - } else if ("PDF".equals(type) && m_isCanExport) { - previewType.setSelectedIndex(1); - } else if ("XLS".equals(type) && m_isCanExport) { - previewType.setSelectedIndex(2); - } else { - // XXX - provide hint if unexpected value - previewType.setSelectedIndex(0); //fall back to HTML + int pTypeIndex = 0; + + if (m_reportEngine.getReportType() != null) + { + if (m_reportEngine.getReportType().equals("PDF") && m_isCanExport) + pTypeIndex = 1; + else if (m_reportEngine.getReportType().equals("XLS") && m_isCanExport) + pTypeIndex = 2; } + else + { + //set default type + String type = m_reportEngine.getPrintFormat().isForm() + // a42niem - provide explicit default and check on client/org specifics + ? MSysConfig.getValue(MSysConfig.ZK_REPORT_FORM_OUTPUT_TYPE,"PDF",Env.getAD_Client_ID(m_ctx),Env.getAD_Org_ID(m_ctx)) + : MSysConfig.getValue(MSysConfig.ZK_REPORT_TABLE_OUTPUT_TYPE,"PDF",Env.getAD_Client_ID(m_ctx),Env.getAD_Org_ID(m_ctx)); + + if ("HTML".equals(type)) { + pTypeIndex = 0; + } else if ("PDF".equals(type) && m_isCanExport) { + pTypeIndex = 1; + } else if ("XLS".equals(type) && m_isCanExport) { + pTypeIndex = 2; + } + } + + previewType.setSelectedIndex(pTypeIndex); labelDrill.setValue(Msg.getMsg(Env.getCtx(), "Drill") + ": "); toolBar.appendChild(labelDrill); diff --git a/org.adempiere.ui/src/org/compiere/print/ReportCtl.java b/org.adempiere.ui/src/org/compiere/print/ReportCtl.java index dbac1f4ef1..13ccb24ce2 100644 --- a/org.adempiere.ui/src/org/compiere/print/ReportCtl.java +++ b/org.adempiere.ui/src/org/compiere/print/ReportCtl.java @@ -32,6 +32,7 @@ import java.util.logging.Level; import org.adempiere.base.Service; import org.adempiere.exceptions.AdempiereException; import org.adempiere.util.IProcessUI; +import org.compiere.model.MPInstance; import org.compiere.model.MPaySelectionCheck; import org.compiere.model.MProcess; import org.compiere.model.MQuery; @@ -124,6 +125,15 @@ public class ReportCtl if (s_log.isLoggable(Level.INFO)) s_log.info("start - " + pi); m_pi = pi; + + MPInstance instance = new MPInstance(Env.getCtx(), pi.getAD_PInstance_ID(), null); + + if (pi.getReportType() != null) + instance.setReportType(pi.getReportType()); + if (pi.getSerializableObject() != null) + instance.setAD_PrintFormat_ID(((MPrintFormat)pi.getSerializableObject()).getAD_PrintFormat_ID()); + instance.saveEx(); + /** * Order Print */ @@ -233,9 +243,6 @@ public class ReportCtl MQuery query = MQuery.get (ctx, pi.getAD_PInstance_ID(), TableName); PrintInfo info = new PrintInfo(pi); re = new ReportEngine(ctx, format, query, info); - re.setWindowNo(WindowNo); - createOutput(re, pi.isPrintPreview(), null); - return true; } // // Create Report Engine normally @@ -246,9 +253,12 @@ public class ReportCtl pi.setSummary("No ReportEngine"); return false; } - re.setWindowNo(WindowNo); } + if (pi.getReportType() != null) { + re.setReportType(pi.getReportType()); + } + re.setWindowNo(WindowNo); createOutput(re, pi.isPrintPreview(), null); return true; } // startStandardReport