From b4aaabb8b4190135ea14036e16c3dcb6e6817ee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Tak=C3=A1cs?= <93127072+PeterTakacs300@users.noreply.github.com> Date: Wed, 30 Nov 2022 04:46:34 +0100 Subject: [PATCH] IDEMPIERE-5490 - Dashboard Content->Report -> Allow specify Print Format (#1589) * IDEMPIERE-5490 - Dashboard Content->Report -> Allow specify Print Format * IDEMPIERE-5490 - add AD_PrintFormat_ID to Dashboard Content table --- .../oracle/202211290811_IDEMPIERE-5490.sql | 62 +++++++++++++++++++ .../202211290811_IDEMPIERE-5490.sql | 59 ++++++++++++++++++ .../compiere/model/I_PA_DashboardContent.java | 15 +++++ .../compiere/model/X_PA_DashboardContent.java | 38 ++++++++++-- .../src/org/compiere/print/ReportEngine.java | 5 +- .../webui/desktop/DashboardController.java | 22 ++++--- 6 files changed, 186 insertions(+), 15 deletions(-) create mode 100644 migration/iD10/oracle/202211290811_IDEMPIERE-5490.sql create mode 100644 migration/iD10/postgresql/202211290811_IDEMPIERE-5490.sql diff --git a/migration/iD10/oracle/202211290811_IDEMPIERE-5490.sql b/migration/iD10/oracle/202211290811_IDEMPIERE-5490.sql new file mode 100644 index 0000000000..185961c275 --- /dev/null +++ b/migration/iD10/oracle/202211290811_IDEMPIERE-5490.sql @@ -0,0 +1,62 @@ +-- IDEMPIERE-5490 +SELECT register_migration_script('202211290811_IDEMPIERE-5490.sql') FROM dual; + +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Nov 29, 2022, 8:11:25 AM CET +INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,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,FKConstraintType,IsHtml) VALUES (215651,0,'Print Format','Data Print Format','The print format determines how data is rendered for print.',50010,'AD_PrintFormat_ID',22,'N','N','N','N','N',0,'N',19,0,0,'Y',TO_TIMESTAMP('2022-11-29 08:11:24','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-11-29 08:11:24','YYYY-MM-DD HH24:MI:SS'),100,1790,'Y','N','D','N','N','N','Y','220f22c5-c44c-4be3-9585-34865be85329','Y',0,'N','N','N','N') +; + +-- Nov 29, 2022, 8:11:26 AM CET +UPDATE AD_Column SET FKConstraintName='ADPrintFormat_PADashboardConte', FKConstraintType='N',Updated=TO_TIMESTAMP('2022-11-29 08:11:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=215651 +; + +-- Nov 29, 2022, 8:11:26 AM CET +ALTER TABLE PA_DashboardContent ADD AD_PrintFormat_ID NUMBER(10) DEFAULT NULL +; + +-- Nov 29, 2022, 8:11:26 AM CET +ALTER TABLE PA_DashboardContent ADD CONSTRAINT ADPrintFormat_PADashboardConte FOREIGN KEY (AD_PrintFormat_ID) REFERENCES ad_printformat(ad_printformat_id) DEFERRABLE INITIALLY DEFERRED +; + +-- Nov 29, 2022, 8:12:18 AM CET +INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLogic,DisplayLength,SeqNo,SortNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField,IsQuickForm) VALUES (207428,'Print Format','Data Print Format','The print format determines how data is rendered for print.',50010,215651,'Y','@AD_Process_ID@>0',0,250,0,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2022-11-29 08:12:18','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-11-29 08:12:18','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','a79096d1-5cbd-416c-bf98-6180d39dc6af','Y',240,1,1,1,'N','N','N','N') +; + +-- Nov 29, 2022, 8:13:36 AM CET +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=180, XPosition=4, ColumnSpan=2,Updated=TO_TIMESTAMP('2022-11-29 08:13:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207428 +; + +-- Nov 29, 2022, 8:13:36 AM CET +UPDATE AD_Field SET SeqNo=190,Updated=TO_TIMESTAMP('2022-11-29 08:13:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207135 +; + +-- Nov 29, 2022, 8:13:36 AM CET +UPDATE AD_Field SET SeqNo=200,Updated=TO_TIMESTAMP('2022-11-29 08:13:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207187 +; + +-- Nov 29, 2022, 8:13:36 AM CET +UPDATE AD_Field SET SeqNo=210,Updated=TO_TIMESTAMP('2022-11-29 08:13:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207125 +; + +-- Nov 29, 2022, 8:13:36 AM CET +UPDATE AD_Field SET SeqNo=220,Updated=TO_TIMESTAMP('2022-11-29 08:13:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=56504 +; + +-- Nov 29, 2022, 8:13:36 AM CET +UPDATE AD_Field SET SeqNo=230,Updated=TO_TIMESTAMP('2022-11-29 08:13:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200268 +; + +-- Nov 29, 2022, 8:13:36 AM CET +UPDATE AD_Field SET SeqNo=240,Updated=TO_TIMESTAMP('2022-11-29 08:13:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200260 +; + +-- Nov 29, 2022, 8:13:36 AM CET +UPDATE AD_Field SET SeqNo=250,Updated=TO_TIMESTAMP('2022-11-29 08:13:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202286 +; + +-- Nov 29, 2022, 8:35:24 AM CET +UPDATE AD_Column SET AD_Val_Rule_ID=200135,Updated=TO_TIMESTAMP('2022-11-29 08:35:24','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=215651 +; + diff --git a/migration/iD10/postgresql/202211290811_IDEMPIERE-5490.sql b/migration/iD10/postgresql/202211290811_IDEMPIERE-5490.sql new file mode 100644 index 0000000000..dd702b06a9 --- /dev/null +++ b/migration/iD10/postgresql/202211290811_IDEMPIERE-5490.sql @@ -0,0 +1,59 @@ +-- IDEMPIERE-5490 +SELECT register_migration_script('202211290811_IDEMPIERE-5490.sql') FROM dual; + +-- Nov 29, 2022, 8:11:25 AM CET +INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,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,FKConstraintType,IsHtml) VALUES (215651,0,'Print Format','Data Print Format','The print format determines how data is rendered for print.',50010,'AD_PrintFormat_ID',22,'N','N','N','N','N',0,'N',19,0,0,'Y',TO_TIMESTAMP('2022-11-29 08:11:24','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-11-29 08:11:24','YYYY-MM-DD HH24:MI:SS'),100,1790,'Y','N','D','N','N','N','Y','220f22c5-c44c-4be3-9585-34865be85329','Y',0,'N','N','N','N') +; + +-- Nov 29, 2022, 8:11:26 AM CET +UPDATE AD_Column SET FKConstraintName='ADPrintFormat_PADashboardConte', FKConstraintType='N',Updated=TO_TIMESTAMP('2022-11-29 08:11:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=215651 +; + +-- Nov 29, 2022, 8:11:26 AM CET +ALTER TABLE PA_DashboardContent ADD COLUMN AD_PrintFormat_ID NUMERIC(10) DEFAULT NULL +; + +-- Nov 29, 2022, 8:11:26 AM CET +ALTER TABLE PA_DashboardContent ADD CONSTRAINT ADPrintFormat_PADashboardConte FOREIGN KEY (AD_PrintFormat_ID) REFERENCES ad_printformat(ad_printformat_id) DEFERRABLE INITIALLY DEFERRED +; + +-- Nov 29, 2022, 8:12:18 AM CET +INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLogic,DisplayLength,SeqNo,SortNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField,IsQuickForm) VALUES (207428,'Print Format','Data Print Format','The print format determines how data is rendered for print.',50010,215651,'Y','@AD_Process_ID@>0',0,250,0,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2022-11-29 08:12:18','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-11-29 08:12:18','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','a79096d1-5cbd-416c-bf98-6180d39dc6af','Y',240,1,1,1,'N','N','N','N') +; + +-- Nov 29, 2022, 8:13:36 AM CET +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=180, XPosition=4, ColumnSpan=2,Updated=TO_TIMESTAMP('2022-11-29 08:13:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207428 +; + +-- Nov 29, 2022, 8:13:36 AM CET +UPDATE AD_Field SET SeqNo=190,Updated=TO_TIMESTAMP('2022-11-29 08:13:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207135 +; + +-- Nov 29, 2022, 8:13:36 AM CET +UPDATE AD_Field SET SeqNo=200,Updated=TO_TIMESTAMP('2022-11-29 08:13:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207187 +; + +-- Nov 29, 2022, 8:13:36 AM CET +UPDATE AD_Field SET SeqNo=210,Updated=TO_TIMESTAMP('2022-11-29 08:13:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207125 +; + +-- Nov 29, 2022, 8:13:36 AM CET +UPDATE AD_Field SET SeqNo=220,Updated=TO_TIMESTAMP('2022-11-29 08:13:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=56504 +; + +-- Nov 29, 2022, 8:13:36 AM CET +UPDATE AD_Field SET SeqNo=230,Updated=TO_TIMESTAMP('2022-11-29 08:13:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200268 +; + +-- Nov 29, 2022, 8:13:36 AM CET +UPDATE AD_Field SET SeqNo=240,Updated=TO_TIMESTAMP('2022-11-29 08:13:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200260 +; + +-- Nov 29, 2022, 8:13:36 AM CET +UPDATE AD_Field SET SeqNo=250,Updated=TO_TIMESTAMP('2022-11-29 08:13:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202286 +; + +-- Nov 29, 2022, 8:35:24 AM CET +UPDATE AD_Column SET AD_Val_Rule_ID=200135,Updated=TO_TIMESTAMP('2022-11-29 08:35:24','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=215651 +; + diff --git a/org.adempiere.base/src/org/compiere/model/I_PA_DashboardContent.java b/org.adempiere.base/src/org/compiere/model/I_PA_DashboardContent.java index c854e7a5c2..9113043350 100644 --- a/org.adempiere.base/src/org/compiere/model/I_PA_DashboardContent.java +++ b/org.adempiere.base/src/org/compiere/model/I_PA_DashboardContent.java @@ -73,6 +73,21 @@ public interface I_PA_DashboardContent */ public int getAD_Org_ID(); + /** 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"; diff --git a/org.adempiere.base/src/org/compiere/model/X_PA_DashboardContent.java b/org.adempiere.base/src/org/compiere/model/X_PA_DashboardContent.java index 577b3f3332..27372acae4 100644 --- a/org.adempiere.base/src/org/compiere/model/X_PA_DashboardContent.java +++ b/org.adempiere.base/src/org/compiere/model/X_PA_DashboardContent.java @@ -33,7 +33,7 @@ public class X_PA_DashboardContent extends PO implements I_PA_DashboardContent, /** * */ - private static final long serialVersionUID = 20220907L; + private static final long serialVersionUID = 20221129L; /** Standard Constructor */ public X_PA_DashboardContent (Properties ctx, int PA_DashboardContent_ID, String trxName) @@ -47,8 +47,8 @@ public class X_PA_DashboardContent extends PO implements I_PA_DashboardContent, // Y setIsEmbedReportContent (false); // N - setIsMaximizable (false); -// N + setIsMaximizable (true); +// Y setIsShowInDashboard (true); // 'Y' setIsShowTitle (true); @@ -70,8 +70,8 @@ public class X_PA_DashboardContent extends PO implements I_PA_DashboardContent, // Y setIsEmbedReportContent (false); // N - setIsMaximizable (false); -// N + setIsMaximizable (true); +// Y setIsShowInDashboard (true); // 'Y' setIsShowTitle (true); @@ -136,6 +136,34 @@ public class X_PA_DashboardContent extends PO implements I_PA_DashboardContent, return ii.intValue(); } + 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_ID) + .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_ID) diff --git a/org.adempiere.base/src/org/compiere/print/ReportEngine.java b/org.adempiere.base/src/org/compiere/print/ReportEngine.java index 01580c7037..5b60e20183 100644 --- a/org.adempiere.base/src/org/compiere/print/ReportEngine.java +++ b/org.adempiere.base/src/org/compiere/print/ReportEngine.java @@ -1871,7 +1871,10 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) IsForm = "Y".equals(rs.getString(6)); // required Client_ID = rs.getInt(7); instance = new MPInstance(ctx, pi.getAD_PInstance_ID(), null); - instance.setAD_PrintFormat_ID(AD_PrintFormat_ID); + if(instance.getAD_PrintFormat_ID() <= 0) + instance.setAD_PrintFormat_ID(AD_PrintFormat_ID); + else + AD_PrintFormat_ID = instance.getAD_PrintFormat_ID(); setDefaultReportTypeToPInstance(ctx, instance, AD_PrintFormat_ID); instance.saveEx(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java index 7874707c8e..81f5611871 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java @@ -668,7 +668,7 @@ public class DashboardController implements EventListener { Iframe iframe = new Iframe(); iframe.setSclass("dashboard-report-iframe"); content.appendChild(iframe); - iframe.setContent(generateReport(AD_Process_ID, processParameters)); + iframe.setContent(generateReport(AD_Process_ID, dc.getAD_PrintFormat_ID(), processParameters)); Toolbar toolbar = new Toolbar(); content.appendChild(toolbar); @@ -678,6 +678,7 @@ public class DashboardController implements EventListener { btn = new ToolBarButton(); btn.setAttribute("AD_Process_ID", AD_Process_ID); btn.setAttribute("ProcessParameters", processParameters); + btn.setAttribute("AD_PrintFormat_ID", dc.getAD_PrintFormat_ID()); btn.addEventListener(Events.ON_CLICK, this); btn.setLabel(Msg.getMsg(Env.getCtx(), "ViewReportInNewTab")); toolbar.appendChild(new Separator("vertical")); @@ -691,7 +692,7 @@ public class DashboardController implements EventListener { else btn.setImage(ThemeManager.getThemeResource("images/Refresh16.png")); - btn.addEventListener(Events.ON_CLICK, e -> iframe.setContent(generateReport(AD_Process_ID, processParameters))); + btn.addEventListener(Events.ON_CLICK, e -> iframe.setContent(generateReport(AD_Process_ID, dc.getAD_PrintFormat_ID(), processParameters))); toolbar.appendChild(btn); } else @@ -884,8 +885,9 @@ public class DashboardController implements EventListener { { int processId = (Integer)btn.getAttribute("AD_Process_ID"); String parameters = (String)btn.getAttribute("ProcessParameters"); + int printFormatId = (Integer)btn.getAttribute("AD_PrintFormat_ID"); if (processId > 0) - openReportInViewer(processId, parameters); + openReportInViewer(processId, printFormatId, parameters); } } } @@ -1274,7 +1276,7 @@ public class DashboardController implements EventListener { return htmlString; } - private ReportEngine runReport(int AD_Process_ID, String parameters) { + private ReportEngine runReport(int AD_Process_ID, int AD_PrintFormat_ID, String parameters) { MProcess process = MProcess.get(Env.getCtx(), AD_Process_ID); if (!process.isReport() || process.getAD_ReportView_ID() == 0) throw new IllegalArgumentException("Not a Report AD_Process_ID=" + process.getAD_Process_ID() @@ -1283,7 +1285,9 @@ public class DashboardController implements EventListener { int AD_Table_ID = 0; int Record_ID = 0; // - MPInstance pInstance = new MPInstance(process, Record_ID); + MPInstance pInstance = new MPInstance(Env.getCtx(), AD_Process_ID, Record_ID); + if(AD_PrintFormat_ID > 0) + pInstance.setAD_PrintFormat_ID(AD_PrintFormat_ID); pInstance.setIsProcessing(true); pInstance.saveEx(); try { @@ -1311,8 +1315,8 @@ public class DashboardController implements EventListener { } - private AMedia generateReport(int AD_Process_ID, String parameters) throws Exception { - ReportEngine re = runReport(AD_Process_ID, parameters); + private AMedia generateReport(int AD_Process_ID, int AD_PrintFormat_ID, String parameters) throws Exception { + ReportEngine re = runReport(AD_Process_ID, AD_PrintFormat_ID, parameters); File file = FileUtil.createTempFile(re.getName(), ".html"); re.createHTML(file, false, AEnv.getLanguage(Env.getCtx()), new HTMLExtension(Executions.getCurrent().getContextPath(), "rp", @@ -1320,8 +1324,8 @@ public class DashboardController implements EventListener { return new AMedia(re.getName(), "html", "text/html", file, false); } - protected void openReportInViewer(int AD_Process_ID, String parameters) { - ReportEngine re = runReport(AD_Process_ID, parameters); + protected void openReportInViewer(int AD_Process_ID, int AD_PrintFormat_ID, String parameters) { + ReportEngine re = runReport(AD_Process_ID, AD_PrintFormat_ID, parameters); new ZkReportViewerProvider().openViewer(re); }