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
This commit is contained in:
Peter Takács 2022-11-30 04:46:34 +01:00 committed by GitHub
parent 2870bd56c7
commit b4aaabb8b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 186 additions and 15 deletions

View File

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

View File

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

View File

@ -73,6 +73,21 @@ public interface I_PA_DashboardContent
*/ */
public int getAD_Org_ID(); 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 */ /** 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";

View File

@ -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 */ /** Standard Constructor */
public X_PA_DashboardContent (Properties ctx, int PA_DashboardContent_ID, String trxName) 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 // Y
setIsEmbedReportContent (false); setIsEmbedReportContent (false);
// N // N
setIsMaximizable (false); setIsMaximizable (true);
// N // Y
setIsShowInDashboard (true); setIsShowInDashboard (true);
// 'Y' // 'Y'
setIsShowTitle (true); setIsShowTitle (true);
@ -70,8 +70,8 @@ public class X_PA_DashboardContent extends PO implements I_PA_DashboardContent,
// Y // Y
setIsEmbedReportContent (false); setIsEmbedReportContent (false);
// N // N
setIsMaximizable (false); setIsMaximizable (true);
// N // Y
setIsShowInDashboard (true); setIsShowInDashboard (true);
// 'Y' // 'Y'
setIsShowTitle (true); setIsShowTitle (true);
@ -136,6 +136,34 @@ public class X_PA_DashboardContent extends PO implements I_PA_DashboardContent,
return ii.intValue(); 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 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) return (org.compiere.model.I_AD_Process)MTable.get(getCtx(), org.compiere.model.I_AD_Process.Table_ID)

View File

@ -1871,7 +1871,10 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
IsForm = "Y".equals(rs.getString(6)); // required IsForm = "Y".equals(rs.getString(6)); // required
Client_ID = rs.getInt(7); Client_ID = rs.getInt(7);
instance = new MPInstance(ctx, pi.getAD_PInstance_ID(), null); 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); setDefaultReportTypeToPInstance(ctx, instance, AD_PrintFormat_ID);
instance.saveEx(); instance.saveEx();
} }

View File

@ -668,7 +668,7 @@ public class DashboardController implements EventListener<Event> {
Iframe iframe = new Iframe(); Iframe iframe = new Iframe();
iframe.setSclass("dashboard-report-iframe"); iframe.setSclass("dashboard-report-iframe");
content.appendChild(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(); Toolbar toolbar = new Toolbar();
content.appendChild(toolbar); content.appendChild(toolbar);
@ -678,6 +678,7 @@ public class DashboardController implements EventListener<Event> {
btn = new ToolBarButton(); btn = new ToolBarButton();
btn.setAttribute("AD_Process_ID", AD_Process_ID); btn.setAttribute("AD_Process_ID", AD_Process_ID);
btn.setAttribute("ProcessParameters", processParameters); btn.setAttribute("ProcessParameters", processParameters);
btn.setAttribute("AD_PrintFormat_ID", dc.getAD_PrintFormat_ID());
btn.addEventListener(Events.ON_CLICK, this); btn.addEventListener(Events.ON_CLICK, this);
btn.setLabel(Msg.getMsg(Env.getCtx(), "ViewReportInNewTab")); btn.setLabel(Msg.getMsg(Env.getCtx(), "ViewReportInNewTab"));
toolbar.appendChild(new Separator("vertical")); toolbar.appendChild(new Separator("vertical"));
@ -691,7 +692,7 @@ public class DashboardController implements EventListener<Event> {
else else
btn.setImage(ThemeManager.getThemeResource("images/Refresh16.png")); 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); toolbar.appendChild(btn);
} }
else else
@ -884,8 +885,9 @@ public class DashboardController implements EventListener<Event> {
{ {
int processId = (Integer)btn.getAttribute("AD_Process_ID"); int processId = (Integer)btn.getAttribute("AD_Process_ID");
String parameters = (String)btn.getAttribute("ProcessParameters"); String parameters = (String)btn.getAttribute("ProcessParameters");
int printFormatId = (Integer)btn.getAttribute("AD_PrintFormat_ID");
if (processId > 0) if (processId > 0)
openReportInViewer(processId, parameters); openReportInViewer(processId, printFormatId, parameters);
} }
} }
} }
@ -1274,7 +1276,7 @@ public class DashboardController implements EventListener<Event> {
return htmlString; 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); MProcess process = MProcess.get(Env.getCtx(), AD_Process_ID);
if (!process.isReport() || process.getAD_ReportView_ID() == 0) if (!process.isReport() || process.getAD_ReportView_ID() == 0)
throw new IllegalArgumentException("Not a Report AD_Process_ID=" + process.getAD_Process_ID() throw new IllegalArgumentException("Not a Report AD_Process_ID=" + process.getAD_Process_ID()
@ -1283,7 +1285,9 @@ public class DashboardController implements EventListener<Event> {
int AD_Table_ID = 0; int AD_Table_ID = 0;
int Record_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.setIsProcessing(true);
pInstance.saveEx(); pInstance.saveEx();
try { try {
@ -1311,8 +1315,8 @@ public class DashboardController implements EventListener<Event> {
} }
private AMedia generateReport(int AD_Process_ID, String parameters) throws Exception { private AMedia generateReport(int AD_Process_ID, int AD_PrintFormat_ID, String parameters) throws Exception {
ReportEngine re = runReport(AD_Process_ID, parameters); ReportEngine re = runReport(AD_Process_ID, AD_PrintFormat_ID, parameters);
File file = FileUtil.createTempFile(re.getName(), ".html"); File file = FileUtil.createTempFile(re.getName(), ".html");
re.createHTML(file, false, AEnv.getLanguage(Env.getCtx()), new HTMLExtension(Executions.getCurrent().getContextPath(), "rp", re.createHTML(file, false, AEnv.getLanguage(Env.getCtx()), new HTMLExtension(Executions.getCurrent().getContextPath(), "rp",
@ -1320,8 +1324,8 @@ public class DashboardController implements EventListener<Event> {
return new AMedia(re.getName(), "html", "text/html", file, false); return new AMedia(re.getName(), "html", "text/html", file, false);
} }
protected void openReportInViewer(int AD_Process_ID, String parameters) { protected void openReportInViewer(int AD_Process_ID, int AD_PrintFormat_ID, String parameters) {
ReportEngine re = runReport(AD_Process_ID, parameters); ReportEngine re = runReport(AD_Process_ID, AD_PrintFormat_ID, parameters);
new ZkReportViewerProvider().openViewer(re); new ZkReportViewerProvider().openViewer(re);
} }