IDEMPIERE-2389 Print format and View Report selection on process dialog.

This commit is contained in:
Deepak Pansheriya 2015-02-10 19:15:04 +05:30
parent 133250f6d6
commit 8a129ab3ea
11 changed files with 370 additions and 51 deletions

View File

@ -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
;

View File

@ -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
;

View File

@ -84,6 +84,21 @@ public interface I_AD_PInstance
/** Get AD_PInstance_UU */ /** Get AD_PInstance_UU */
public String getAD_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 */ /** Column name AD_Process_ID */
public static final String COLUMNNAME_AD_Process_ID = "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(); 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 */ /** Column name Result */
public static final String COLUMNNAME_Result = "Result"; public static final String COLUMNNAME_Result = "Result";

View File

@ -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 */ /** Standard Constructor */
public X_AD_PInstance (Properties ctx, int AD_PInstance_ID, String trxName) 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); setIsRunAsJob (false);
// N // N
setRecord_ID (0); 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); 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 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) 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(); 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. /** Set Result.
@param Result @param Result
Result of the action taken Result of the action taken

View File

@ -1762,4 +1762,17 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
{ {
m_summary = summary; m_summary = summary;
} }
private String reportType;
public void setReportType(String type)
{
reportType = type;
}
public String getReportType()
{
return reportType;
}
} // ReportEngine } // ReportEngine

View File

@ -144,6 +144,16 @@ public class ProcessInfo implements Serializable
private transient PO m_po = null; 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 * String representation
* @return String representation * @return String representation

View File

@ -90,7 +90,7 @@ public abstract class AbstractProcessDialog extends Window implements IProcessUI
private static CLogger log = CLogger.getCLogger(AbstractProcessDialog.class); private static CLogger log = CLogger.getCLogger(AbstractProcessDialog.class);
private int m_WindowNo; protected int m_WindowNo;
private Properties m_ctx; private Properties m_ctx;
private int m_AD_Process_ID; private int m_AD_Process_ID;
private ProcessInfo m_pi = null; private ProcessInfo m_pi = null;

View File

@ -23,6 +23,7 @@ import java.io.FileOutputStream;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.util.Callback; 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.DocumentLink;
import org.adempiere.webui.component.Grid; import org.adempiere.webui.component.Grid;
import org.adempiere.webui.component.GridFactory; import org.adempiere.webui.component.GridFactory;
import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.Mask; import org.adempiere.webui.component.Mask;
import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.Panel;
import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Row;
import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Rows;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.desktop.IDesktop; import org.adempiere.webui.desktop.IDesktop;
import org.adempiere.webui.editor.WTableDirEditor;
import org.adempiere.webui.factory.ButtonFactory; import org.adempiere.webui.factory.ButtonFactory;
import org.adempiere.webui.panel.IHelpContext; import org.adempiere.webui.panel.IHelpContext;
import org.adempiere.webui.part.WindowContainer; 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.theme.ThemeManager;
import org.adempiere.webui.window.FDialog; import org.adempiere.webui.window.FDialog;
import org.adempiere.webui.window.SimplePDFViewer; 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.MPInstance;
import org.compiere.model.MPInstancePara; import org.compiere.model.MPInstancePara;
import org.compiere.model.MProcess; 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_CtxHelp;
import org.compiere.model.X_AD_ReportView;
import org.compiere.print.MPrintFormat;
import org.compiere.print.ReportEngine; import org.compiere.print.ReportEngine;
import org.compiere.process.ProcessInfo; import org.compiere.process.ProcessInfo;
import org.compiere.process.ProcessInfoLog; import org.compiere.process.ProcessInfoLog;
@ -146,6 +155,8 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene
int WindowNo = SessionManager.getAppDesktop().registerWindow(this); int WindowNo = SessionManager.getAppDesktop().registerWindow(this);
this.setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, WindowNo); this.setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, WindowNo);
Env.setContext(Env.getCtx(), WindowNo, "IsSOTrx", isSOTrx ? "Y" : "N"); Env.setContext(Env.getCtx(), WindowNo, "IsSOTrx", isSOTrx ? "Y" : "N");
m_ctx = Env.getCtx();
m_AD_Process_ID = AD_Process_ID;
try try
{ {
MProcess process = MProcess.get(Env.getCtx(), AD_Process_ID); MProcess process = MProcess.get(Env.getCtx(), AD_Process_ID);
@ -165,6 +176,62 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene
} }
} // ProcessDialog } // 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() private void querySaved()
{ {
//user query //user query
@ -203,12 +270,15 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene
center.setStyle("border: none"); center.setStyle("border: none");
Rows rows = southRowPanel.newRows(); Rows rows = southRowPanel.newRows();
rows.getParent().getId();
Row row1 = rows.newRow();
Row row = rows.newRow(); Row row = rows.newRow();
Hbox hBox = new Hbox(); Hbox hBox = new Hbox();
Hbox hBox1 = new Hbox();
lSaved = new Label(Msg.getMsg(Env.getCtx(), "SavedParameter")); lSaved = new Label(Msg.getMsg(Env.getCtx(), "SavedParameter"));
hBox.appendChild(lSaved); hBox1.appendChild(lSaved);
fSavedName.addEventListener(Events.ON_CHANGE, this); fSavedName.addEventListener(Events.ON_CHANGE, this);
hBox.appendChild(fSavedName); hBox.appendChild(fSavedName);
@ -220,21 +290,50 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene
bDelete.addActionListener(this); bDelete.addActionListener(this);
hBox.appendChild(bDelete); hBox.appendChild(bDelete);
hBox.setStyle("margin-right:30px;");
hBox1.setStyle("margin-right:30px;");
row1.appendChild(hBox1);
row.appendChild(hBox); 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); hBox.setVisible(false);
hBox1.setVisible(false);
}
Panel confParaPanel =new Panel(); Panel confParaPanel =new Panel();
confParaPanel.setAlign("right"); confParaPanel.setStyle("float:right");
// Invert - Unify OK/Cancel IDEMPIERE-77 // Invert - Unify OK/Cancel IDEMPIERE-77
bOK = ButtonFactory.createNamedButton(ConfirmPanel.A_OK, true, true); bOK = ButtonFactory.createNamedButton(ConfirmPanel.A_OK, true, true);
bOK.setId("Ok"); bOK.setId("Ok");
bOK.setWidth("50%");
bOK.addEventListener(Events.ON_CLICK, this); bOK.addEventListener(Events.ON_CLICK, this);
confParaPanel.appendChild(bOK); confParaPanel.appendChild(bOK);
bCancel = ButtonFactory.createNamedButton(ConfirmPanel.A_CANCEL, true, true); bCancel = ButtonFactory.createNamedButton(ConfirmPanel.A_CANCEL, true, true);
bCancel.setId("Cancel"); bCancel.setId("Cancel");
bCancel.setWidth("50%");
bCancel.addEventListener(Events.ON_CLICK, this); bCancel.addEventListener(Events.ON_CLICK, this);
confParaPanel.appendChild(bCancel); confParaPanel.appendChild(bCancel);
row.appendChild(confParaPanel); row.appendChild(confParaPanel);
@ -255,6 +354,15 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene
private List<MPInstance> savedParams; private List<MPInstance> savedParams;
private Label lSaved; 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 Visible
* (set focus to OK if visible) * (set focus to OK if visible)
@ -289,6 +397,16 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene
} else if (component instanceof Button) { } else if (component instanceof Button) {
Button element = (Button)component; Button element = (Button)component;
if ("Ok".equalsIgnoreCase(element.getId())) { 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) if (isParameterPage)
startProcess(); startProcess();
else else
@ -310,6 +428,9 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene
para.deleteEx(true); para.deleteEx(true);
} }
getParameterPanel().saveParameters(); 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(), instance = new MPInstance(Env.getCtx(),
getProcessInfo().getAD_Process_ID(), getProcessInfo().getRecord_ID()); getProcessInfo().getAD_Process_ID(), getProcessInfo().getRecord_ID());
instance.setName(saveName); instance.setName(saveName);
instance.setAD_PrintFormat_ID((Integer) fPrintFormat.getValue());
instance.setReportType(freportType.getSelectedItem().getValue().toString());
instance.saveEx(); instance.saveEx();
getProcessInfo().setAD_PInstance_ID(instance.getAD_PInstance_ID()); getProcessInfo().setAD_PInstance_ID(instance.getAD_PInstance_ID());
// Get Parameters // Get Parameters
@ -390,8 +513,23 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene
return item; 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) { private void loadSavedParams(MPInstance instance) {
getParameterPanel().loadParameters(instance); getParameterPanel().loadParameters(instance);
setReportTypeAndPrintFormat(instance);
} }
private void doOnClick(A btn) { private void doOnClick(A btn) {

View File

@ -126,34 +126,34 @@ public class WProcessCtl extends AbstractProcessCtl {
{ {
if (log.isLoggable(Level.FINE)) log.fine("WindowNo=" + WindowNo + " - " + pi); if (log.isLoggable(Level.FINE)) log.fine("WindowNo=" + WindowNo + " - " + pi);
if (pi.getAD_PInstance_ID() < 1) { //red1 bypass if PInstance exists // if (pi.getAD_PInstance_ID() < 1) { //red1 bypass if PInstance exists
MPInstance instance = null; MPInstance instance = null;
try try
{ {
instance = new MPInstance(Env.getCtx(), pi.getAD_Process_ID(), pi.getRecord_ID()); 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());
} }
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 // Get Parameters
if (parameter != null) { if (parameter != null) {

View File

@ -261,22 +261,33 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
previewType.addEventListener(Events.ON_SELECT, this); previewType.addEventListener(Events.ON_SELECT, this);
toolBar.appendChild(new Separator("vertical")); toolBar.appendChild(new Separator("vertical"));
//set default type int pTypeIndex = 0;
String type = m_reportEngine.getPrintFormat().isForm()
// a42niem - provide explicit default and check on client/org specifics if (m_reportEngine.getReportType() != null)
? 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 (m_reportEngine.getReportType().equals("PDF") && m_isCanExport)
pTypeIndex = 1;
if ("HTML".equals(type)) { else if (m_reportEngine.getReportType().equals("XLS") && m_isCanExport)
previewType.setSelectedIndex(0); pTypeIndex = 2;
} 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
} }
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") + ": "); labelDrill.setValue(Msg.getMsg(Env.getCtx(), "Drill") + ": ");
toolBar.appendChild(labelDrill); toolBar.appendChild(labelDrill);

View File

@ -32,6 +32,7 @@ import java.util.logging.Level;
import org.adempiere.base.Service; import org.adempiere.base.Service;
import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.AdempiereException;
import org.adempiere.util.IProcessUI; import org.adempiere.util.IProcessUI;
import org.compiere.model.MPInstance;
import org.compiere.model.MPaySelectionCheck; import org.compiere.model.MPaySelectionCheck;
import org.compiere.model.MProcess; import org.compiere.model.MProcess;
import org.compiere.model.MQuery; import org.compiere.model.MQuery;
@ -124,6 +125,15 @@ public class ReportCtl
if (s_log.isLoggable(Level.INFO)) s_log.info("start - " + pi); if (s_log.isLoggable(Level.INFO)) s_log.info("start - " + pi);
m_pi = 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 * Order Print
*/ */
@ -233,9 +243,6 @@ public class ReportCtl
MQuery query = MQuery.get (ctx, pi.getAD_PInstance_ID(), TableName); MQuery query = MQuery.get (ctx, pi.getAD_PInstance_ID(), TableName);
PrintInfo info = new PrintInfo(pi); PrintInfo info = new PrintInfo(pi);
re = new ReportEngine(ctx, format, query, info); re = new ReportEngine(ctx, format, query, info);
re.setWindowNo(WindowNo);
createOutput(re, pi.isPrintPreview(), null);
return true;
} }
// //
// Create Report Engine normally // Create Report Engine normally
@ -246,9 +253,12 @@ public class ReportCtl
pi.setSummary("No ReportEngine"); pi.setSummary("No ReportEngine");
return false; return false;
} }
re.setWindowNo(WindowNo);
} }
if (pi.getReportType() != null) {
re.setReportType(pi.getReportType());
}
re.setWindowNo(WindowNo);
createOutput(re, pi.isPrintPreview(), null); createOutput(re, pi.isPrintPreview(), null);
return true; return true;
} // startStandardReport } // startStandardReport