IDEMPIERE-4899 Report: print product instance attribute name and valu… (#814)

* IDEMPIERE-4899 Report: print product instance attribute name and value as column

* IDEMPIERE-4899 Report: print product instance attribute name and value as column

- use parenthesis for display logic
- fixed display logic evaluation exception
- fixed index out of bound exception for xls and xlsx

* IDEMPIERE-4899 Report: print product instance attribute name and value as column

- Fix css for columns that have been shifted to the right
This commit is contained in:
hengsin 2021-08-06 17:12:05 +08:00 committed by GitHub
parent 63c327dde4
commit d3d1a735b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 1074 additions and 101 deletions

View File

@ -0,0 +1,85 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
INSERT INTO AD_Val_Rule (Code,AD_Val_Rule_ID,Name,Updated,Type,AD_Val_Rule_UU,CreatedBy,UpdatedBy,AD_Org_ID,IsActive,AD_Client_ID,Created,EntityType) VALUES ('M_AttributeValue.M_Attribute_ID=@M_Attribute_ID@',200100,'M_AttributeValue of M_Attribute (Dictionary)',TO_DATE('2021-08-04 15:51:27','YYYY-MM-DD HH24:MI:SS'),'S','3f465604-2f70-4bf8-a874-87ad6d4cd7e5',100,100,0,'Y',0,TO_DATE('2021-08-04 15:51:27','YYYY-MM-DD HH24:MI:SS'),'D')
;
-- Aug 2, 2017 1:39:02 PM GMT+08:00
-- IDEMPIERE-4899 Report: print product instance attribute name and value as column
INSERT INTO AD_Element (AD_Element_ID,ColumnName,Help,Updated,Name,Description,PrintName,AD_Element_UU,IsActive,Created,AD_Org_ID,CreatedBy,UpdatedBy,AD_Client_ID,EntityType) VALUES (203123,'IsPrintInstanceAttributes','This control the printing of product attribute set instance. When checked, the report will have one column for each instance attribute instead of printing the description of attribute set instance.',TO_DATE('2021-08-04 13:39:00','YYYY-MM-DD HH24:MI:SS'),'Print Instance Attributes','Print each instance attributes as report column instead of printing the description of attribute set instance','Print Instance Attributes','6c12c1aa-3760-4261-b37d-cf8c9050ea86','Y',TO_DATE('2021-08-04 13:39:00','YYYY-MM-DD HH24:MI:SS'),0,100,100,0,'D')
;
-- Aug 2, 2017 1:40:07 PM GMT+08:00
INSERT INTO AD_Column (AD_Column_ID,SeqNoSelection,IsSyncDatabase,Version,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,Updated,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,IsActive,CreatedBy,UpdatedBy,IsAlwaysUpdateable,AD_Client_ID,AD_Org_ID,Created,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID,IsToolbarButton) VALUES (213184,0,'N',0,'Y','N','N',0,'N',1,'N','N','N','Y','21121b4e-772a-4a09-bde9-bdc1e26a67e6',TO_DATE('2021-08-04 13:40:06','YYYY-MM-DD HH24:MI:SS'),'Y','IsPrintInstanceAttributes','Print each instance attributes as report column instead of printing the description of attribute set instance','N','This control the printing of product attribute set instance. When checked, the report will have one column for each instance attribute instead of printing the description of attribute set instance.','Print Instance Attributes','Y','Y',100,100,'N',0,0,TO_DATE('2021-08-04 13:40:06','YYYY-MM-DD HH24:MI:SS'),'D','N','N','N',203123,20,489,'N')
;
-- Aug 2, 2017 1:40:20 PM GMT+08:00
ALTER TABLE AD_PrintFormatItem ADD IsPrintInstanceAttributes CHAR(1) DEFAULT 'N' CHECK (IsPrintInstanceAttributes IN ('Y','N')) NOT NULL
;
-- Aug 2, 2017 1:44:13 PM GMT+08:00
INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,Help,DisplayLogic,AD_Org_ID,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID) VALUES (0,205192,'N',0,'N','N',155,'Y','N','This control the printing of product attribute set instance. When checked, the report will have one column for each instance attribute instead of printing the description of attribute set instance.','@PrintFormatType@=F & @AD_Column_ID.AD_Reference_ID@=35',0,TO_DATE('2021-08-04 13:44:13','YYYY-MM-DD HH24:MI:SS'),'Print each instance attributes as report column instead of printing the description of attribute set instance','Print Instance Attributes','984bc17c-ad84-4f7c-bad3-009a259d6a1f','Y','N',100,100,'Y','Y',155,5,'N',0,TO_DATE('2021-08-04 13:44:13','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',213184,'D',426)
;
-- Aug 3, 2017 10:42:42 PM GMT+08:00
-- IDEMPIERE-4899 Report: print product instance attribute name and value as column
INSERT INTO AD_Val_Rule (Code,AD_Val_Rule_ID,Name,Updated,Type,AD_Val_Rule_UU,CreatedBy,UpdatedBy,AD_Org_ID,IsActive,AD_Client_ID,Created,EntityType) VALUES ('M_Attribute.M_Attribute_ID IN ( SELECT M_Attribute_ID FROM M_AttributeUse WHERE IsActive=''Y'' AND M_AttributeSet_ID=@M_Product_M_AttributeSet_ID@ )',200099,'M_Attribute of M_Product_M_AttributeSet',TO_DATE('2021-08-04 22:42:40','YYYY-MM-DD HH24:MI:SS'),'S','16287e64-946d-4256-abfe-6dcc694eebb7',100,100,0,'Y',0,TO_DATE('2021-08-04 22:42:40','YYYY-MM-DD HH24:MI:SS'),'D')
;
-- Aug 3, 2017 10:44:52 PM GMT+08:00
UPDATE AD_Element SET Name='Product Attribute Set', PrintName='Product Attribute Set',Updated=TO_DATE('2021-08-04 22:44:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=201353
;
-- Aug 3, 2017 10:44:52 PM GMT+08:00
UPDATE AD_Column SET ColumnName='M_Product_M_AttributeSet_ID', Name='Product Attribute Set', Description=NULL, Help=NULL WHERE AD_Element_ID=201353
;
-- Aug 3, 2017 10:44:52 PM GMT+08:00
UPDATE AD_InfoColumn SET ColumnName='M_Product_M_AttributeSet_ID', Name='Product Attribute Set', Description=NULL, Help=NULL WHERE AD_Element_ID=201353 AND IsCentrallyMaintained='Y'
;
-- Aug 3, 2017 10:44:52 PM GMT+08:00
UPDATE AD_Field SET Name='Product Attribute Set', Description=NULL, Help=NULL WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=201353) AND IsCentrallyMaintained='Y'
;
-- Aug 3, 2017 10:44:52 PM GMT+08:00
UPDATE AD_PrintFormatItem SET PrintName='Product Attribute Set', Name='Product Attribute Set' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=AD_PrintFormatItem.AD_Column_ID AND c.AD_Element_ID=201353)
;
-- Aug 4, 2017 4:58:53 PM GMT+08:00
-- IDEMPIERE-4899 Report: print product instance attribute name and value as column
UPDATE AD_Val_Rule SET Code='M_Attribute.M_Attribute_ID IN ( SELECT M_Attribute_ID FROM M_AttributeUse WHERE IsActive=''Y'' AND M_AttributeSet_ID=@M_Product_M_AttributeSet_ID@ ) AND M_Attribute.IsInstanceAttribute=''N''',Updated=TO_DATE('2021-08-04 16:58:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=200099
;
-- Aug 7, 2017 10:05:56 AM GMT+08:00
-- IDEMPIERE-4899 Report: print product instance attribute name and value as column
UPDATE AD_Element SET Help='This control the printing of product attribute set instance. When checked, the report will have one column for each attribute instead of printing the description of attribute set instance.', Name='Print Attributes', Description='Print each attributes as report column instead of printing the description of attribute set instance', PrintName='Print Attributes',Updated=TO_DATE('2021-08-04 10:05:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=203123
;
-- Aug 7, 2017 10:05:56 AM GMT+08:00
UPDATE AD_Column SET ColumnName='IsPrintInstanceAttributes', Name='Print Attributes', Description='Print each attributes as report column instead of printing the description of attribute set instance', Help='This control the printing of product attribute set instance. When checked, the report will have one column for each attribute instead of printing the description of attribute set instance.' WHERE AD_Element_ID=203123
;
-- Aug 7, 2017 10:05:57 AM GMT+08:00
UPDATE AD_InfoColumn SET ColumnName='IsPrintInstanceAttributes', Name='Print Attributes', Description='Print each attributes as report column instead of printing the description of attribute set instance', Help='This control the printing of product attribute set instance. When checked, the report will have one column for each attribute instead of printing the description of attribute set instance.' WHERE AD_Element_ID=203123 AND IsCentrallyMaintained='Y'
;
-- Aug 7, 2017 10:05:57 AM GMT+08:00
UPDATE AD_Field SET Name='Print Attributes', Description='Print each attributes as report column instead of printing the description of attribute set instance', Help='This control the printing of product attribute set instance. When checked, the report will have one column for each attribute instead of printing the description of attribute set instance.' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=203123) AND IsCentrallyMaintained='Y'
;
-- Aug 7, 2017 10:05:57 AM GMT+08:00
UPDATE AD_PrintFormatItem SET PrintName='Print Attributes', Name='Print Attributes' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=AD_PrintFormatItem.AD_Column_ID AND c.AD_Element_ID=203123)
;
-- Aug 9, 2017 10:58:35 AM GMT+08:00
-- IDEMPIERE-4899 Report: print product instance attribute name and value as column
UPDATE AD_Val_Rule SET Code='M_Attribute.M_Attribute_ID IN ( SELECT M_Attribute_ID FROM M_AttributeUse WHERE IsActive=''Y'' AND M_AttributeSet_ID=@M_Product_M_AttributeSet_ID@ )',Updated=TO_DATE('2021-08-04 10:58:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=200099
;
-- Aug 10, 2017 7:35:34 AM GMT+08:00
UPDATE AD_Field SET DisplayLogic='(@AD_Column_ID.AD_Reference_ID@=35 | @AD_Column_ID.ColumnName@=''M_AttributeSetInstance_ID'') & @PrintFormatType@=F & @IsForm@=N', AD_Val_Rule_ID=NULL, AD_Reference_Value_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-08-04 08:20:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205192
;
SELECT register_migration_script('202108021350_IDEMPIERE-4899.sql') FROM dual
;

View File

@ -0,0 +1,82 @@
INSERT INTO AD_Val_Rule (Code,AD_Val_Rule_ID,Name,Updated,Type,AD_Val_Rule_UU,CreatedBy,UpdatedBy,AD_Org_ID,IsActive,AD_Client_ID,Created,EntityType) VALUES ('M_AttributeValue.M_Attribute_ID=@M_Attribute_ID@',200100,'M_AttributeValue of M_Attribute (Dictionary)',TO_TIMESTAMP('2021-08-04 15:51:27','YYYY-MM-DD HH24:MI:SS'),'S','3f465604-2f70-4bf8-a874-87ad6d4cd7e5',100,100,0,'Y',0,TO_TIMESTAMP('2021-08-04 15:51:27','YYYY-MM-DD HH24:MI:SS'),'D')
;
-- Aug 2, 2017 1:39:02 PM GMT+08:00
-- IDEMPIERE-4899 Report: print product instance attribute name and value as column
INSERT INTO AD_Element (AD_Element_ID,ColumnName,Help,Updated,Name,Description,PrintName,AD_Element_UU,IsActive,Created,AD_Org_ID,CreatedBy,UpdatedBy,AD_Client_ID,EntityType) VALUES (203123,'IsPrintInstanceAttributes','This control the printing of product attribute set instance. When checked, the report will have one column for each instance attribute instead of printing the description of attribute set instance.',TO_TIMESTAMP('2021-08-04 13:39:00','YYYY-MM-DD HH24:MI:SS'),'Print Instance Attributes','Print each instance attributes as report column instead of printing the description of attribute set instance','Print Instance Attributes','6c12c1aa-3760-4261-b37d-cf8c9050ea86','Y',TO_TIMESTAMP('2021-08-04 13:39:00','YYYY-MM-DD HH24:MI:SS'),0,100,100,0,'D')
;
-- Aug 2, 2017 1:40:07 PM GMT+08:00
INSERT INTO AD_Column (AD_Column_ID,SeqNoSelection,IsSyncDatabase,Version,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,Updated,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,IsActive,CreatedBy,UpdatedBy,IsAlwaysUpdateable,AD_Client_ID,AD_Org_ID,Created,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID,IsToolbarButton) VALUES (213184,0,'N',0,'Y','N','N',0,'N',1,'N','N','N','Y','21121b4e-772a-4a09-bde9-bdc1e26a67e6',TO_TIMESTAMP('2021-08-04 13:40:06','YYYY-MM-DD HH24:MI:SS'),'Y','IsPrintInstanceAttributes','Print each instance attributes as report column instead of printing the description of attribute set instance','N','This control the printing of product attribute set instance. When checked, the report will have one column for each instance attribute instead of printing the description of attribute set instance.','Print Instance Attributes','Y','Y',100,100,'N',0,0,TO_TIMESTAMP('2021-08-04 13:40:06','YYYY-MM-DD HH24:MI:SS'),'D','N','N','N',203123,20,489,'N')
;
-- Aug 2, 2017 1:40:20 PM GMT+08:00
ALTER TABLE AD_PrintFormatItem ADD COLUMN IsPrintInstanceAttributes CHAR(1) DEFAULT 'N' CHECK (IsPrintInstanceAttributes IN ('Y','N')) NOT NULL
;
-- Aug 2, 2017 1:44:13 PM GMT+08:00
INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,Help,DisplayLogic,AD_Org_ID,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID) VALUES (0,205192,'N',0,'N','N',155,'Y','N','This control the printing of product attribute set instance. When checked, the report will have one column for each instance attribute instead of printing the description of attribute set instance.','@PrintFormatType@=F & @AD_Column_ID.AD_Reference_ID@=35',0,TO_TIMESTAMP('2021-08-04 13:44:13','YYYY-MM-DD HH24:MI:SS'),'Print each instance attributes as report column instead of printing the description of attribute set instance','Print Instance Attributes','984bc17c-ad84-4f7c-bad3-009a259d6a1f','Y','N',100,100,'Y','Y',155,5,'N',0,TO_TIMESTAMP('2021-08-04 13:44:13','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',213184,'D',426)
;
-- Aug 3, 2017 10:42:42 PM GMT+08:00
-- IDEMPIERE-4899 Report: print product instance attribute name and value as column
INSERT INTO AD_Val_Rule (Code,AD_Val_Rule_ID,Name,Updated,Type,AD_Val_Rule_UU,CreatedBy,UpdatedBy,AD_Org_ID,IsActive,AD_Client_ID,Created,EntityType) VALUES ('M_Attribute.M_Attribute_ID IN ( SELECT M_Attribute_ID FROM M_AttributeUse WHERE IsActive=''Y'' AND M_AttributeSet_ID=@M_Product_M_AttributeSet_ID@ )',200099,'M_Attribute of M_Product_M_AttributeSet',TO_TIMESTAMP('2021-08-04 22:42:40','YYYY-MM-DD HH24:MI:SS'),'S','16287e64-946d-4256-abfe-6dcc694eebb7',100,100,0,'Y',0,TO_TIMESTAMP('2021-08-04 22:42:40','YYYY-MM-DD HH24:MI:SS'),'D')
;
-- Aug 3, 2017 10:44:52 PM GMT+08:00
UPDATE AD_Element SET Name='Product Attribute Set', PrintName='Product Attribute Set',Updated=TO_TIMESTAMP('2021-08-04 22:44:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=201353
;
-- Aug 3, 2017 10:44:52 PM GMT+08:00
UPDATE AD_Column SET ColumnName='M_Product_M_AttributeSet_ID', Name='Product Attribute Set', Description=NULL, Help=NULL WHERE AD_Element_ID=201353
;
-- Aug 3, 2017 10:44:52 PM GMT+08:00
UPDATE AD_InfoColumn SET ColumnName='M_Product_M_AttributeSet_ID', Name='Product Attribute Set', Description=NULL, Help=NULL WHERE AD_Element_ID=201353 AND IsCentrallyMaintained='Y'
;
-- Aug 3, 2017 10:44:52 PM GMT+08:00
UPDATE AD_Field SET Name='Product Attribute Set', Description=NULL, Help=NULL WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=201353) AND IsCentrallyMaintained='Y'
;
-- Aug 3, 2017 10:44:52 PM GMT+08:00
UPDATE AD_PrintFormatItem SET PrintName='Product Attribute Set', Name='Product Attribute Set' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=AD_PrintFormatItem.AD_Column_ID AND c.AD_Element_ID=201353)
;
-- Aug 4, 2017 4:58:53 PM GMT+08:00
-- IDEMPIERE-4899 Report: print product instance attribute name and value as column
UPDATE AD_Val_Rule SET Code='M_Attribute.M_Attribute_ID IN ( SELECT M_Attribute_ID FROM M_AttributeUse WHERE IsActive=''Y'' AND M_AttributeSet_ID=@M_Product_M_AttributeSet_ID@ ) AND M_Attribute.IsInstanceAttribute=''N''',Updated=TO_TIMESTAMP('2021-08-04 16:58:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=200099
;
-- Aug 7, 2017 10:05:56 AM GMT+08:00
-- IDEMPIERE-4899 Report: print product instance attribute name and value as column
UPDATE AD_Element SET Help='This control the printing of product attribute set instance. When checked, the report will have one column for each attribute instead of printing the description of attribute set instance.', Name='Print Attributes', Description='Print each attributes as report column instead of printing the description of attribute set instance', PrintName='Print Attributes',Updated=TO_TIMESTAMP('2021-08-04 10:05:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=203123
;
-- Aug 7, 2017 10:05:56 AM GMT+08:00
UPDATE AD_Column SET ColumnName='IsPrintInstanceAttributes', Name='Print Attributes', Description='Print each attributes as report column instead of printing the description of attribute set instance', Help='This control the printing of product attribute set instance. When checked, the report will have one column for each attribute instead of printing the description of attribute set instance.' WHERE AD_Element_ID=203123
;
-- Aug 7, 2017 10:05:57 AM GMT+08:00
UPDATE AD_InfoColumn SET ColumnName='IsPrintInstanceAttributes', Name='Print Attributes', Description='Print each attributes as report column instead of printing the description of attribute set instance', Help='This control the printing of product attribute set instance. When checked, the report will have one column for each attribute instead of printing the description of attribute set instance.' WHERE AD_Element_ID=203123 AND IsCentrallyMaintained='Y'
;
-- Aug 7, 2017 10:05:57 AM GMT+08:00
UPDATE AD_Field SET Name='Print Attributes', Description='Print each attributes as report column instead of printing the description of attribute set instance', Help='This control the printing of product attribute set instance. When checked, the report will have one column for each attribute instead of printing the description of attribute set instance.' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=203123) AND IsCentrallyMaintained='Y'
;
-- Aug 7, 2017 10:05:57 AM GMT+08:00
UPDATE AD_PrintFormatItem SET PrintName='Print Attributes', Name='Print Attributes' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=AD_PrintFormatItem.AD_Column_ID AND c.AD_Element_ID=203123)
;
-- Aug 9, 2017 10:58:35 AM GMT+08:00
-- IDEMPIERE-4899 Report: print product instance attribute name and value as column
UPDATE AD_Val_Rule SET Code='M_Attribute.M_Attribute_ID IN ( SELECT M_Attribute_ID FROM M_AttributeUse WHERE IsActive=''Y'' AND M_AttributeSet_ID=@M_Product_M_AttributeSet_ID@ )',Updated=TO_TIMESTAMP('2021-08-04 10:58:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=200099
;
-- Aug 10, 2017 7:35:34 AM GMT+08:00
UPDATE AD_Field SET DisplayLogic='(@AD_Column_ID.AD_Reference_ID@=35 | @AD_Column_ID.ColumnName@=''M_AttributeSetInstance_ID'') & @PrintFormatType@=F & @IsForm@=N', AD_Val_Rule_ID=NULL, AD_Reference_Value_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-08-04 08:20:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205192
;
SELECT register_migration_script('202108021350_IDEMPIERE-4899.sql') FROM dual
;

View File

@ -18,6 +18,7 @@ import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
@ -37,6 +38,8 @@ import org.compiere.print.MPrintFormatItem;
import org.compiere.print.MPrintPaper; import org.compiere.print.MPrintPaper;
import org.compiere.print.PrintData; import org.compiere.print.PrintData;
import org.compiere.print.PrintDataElement; import org.compiere.print.PrintDataElement;
import org.compiere.print.layout.InstanceAttributeColumn;
import org.compiere.print.layout.InstanceAttributeData;
import org.compiere.print.layout.PrintDataEvaluatee; import org.compiere.print.layout.PrintDataEvaluatee;
import org.compiere.util.DisplayType; import org.compiere.util.DisplayType;
import org.compiere.util.Evaluator; import org.compiere.util.Evaluator;
@ -96,7 +99,12 @@ extends AbstractExcelExporter
if (m_printData.getRowIndex() != row) if (m_printData.getRowIndex() != row)
m_printData.setRowIndex(row); m_printData.setRowIndex(row);
// //
MPrintFormatItem item = (MPrintFormatItem) columns.get(col); Object colObj = columns.get(col);
if (colObj instanceof InstanceAttributeColumn) {
InstanceAttributeColumn ia = (InstanceAttributeColumn) colObj;
return ia.getPrintDataElement(row);
} else if (colObj instanceof MPrintFormatItem) {
MPrintFormatItem item = (MPrintFormatItem) colObj;
Object obj = null; Object obj = null;
if (item.isTypeField() || item.isTypePrintFormat() && item.isImageField()) { if (item.isTypeField() || item.isTypePrintFormat() && item.isImageField()) {
@ -112,6 +120,7 @@ extends AbstractExcelExporter
if (obj != null && obj instanceof PrintDataElement) { if (obj != null && obj instanceof PrintDataElement) {
return (PrintDataElement)obj; return (PrintDataElement)obj;
} }
}
return null; return null;
} }
@Override @Override
@ -195,6 +204,9 @@ extends AbstractExcelExporter
if (colObj instanceof MPrintFormatItem) { if (colObj instanceof MPrintFormatItem) {
MPrintFormatItem item = (MPrintFormatItem) colObj; MPrintFormatItem item = (MPrintFormatItem) colObj;
return item.getPrintName(getLanguage()); return item.getPrintName(getLanguage());
} else if (colObj instanceof InstanceAttributeColumn) {
InstanceAttributeColumn ia = (InstanceAttributeColumn) colObj;
return ia.getName();
} else { } else {
return ""; return "";
} }
@ -306,12 +318,40 @@ extends AbstractExcelExporter
@Override @Override
protected void export(OutputStream out) throws Exception { protected void export(OutputStream out) throws Exception {
columns = new ArrayList<>(); columns = new ArrayList<>();
List<InstanceAttributeData> asiElements = new ArrayList<>();
int columnCount = 0;
for (int col = 0; col < m_printFormat.getItemCount(); col++) for (int col = 0; col < m_printFormat.getItemCount(); col++)
{ {
MPrintFormatItem item = m_printFormat.getItem(col); MPrintFormatItem item = m_printFormat.getItem(col);
if (item.isPrinted()) if (item.isPrinted())
{
if (item.isTypeField() && item.isPrintInstanceAttributes())
{
InstanceAttributeData asiElement = new InstanceAttributeData(item, columnCount);
asiElement.readAttributesData(m_printData);
asiElements.add(asiElement);
continue;
}
else
{ {
columns.add(item); columns.add(item);
columnCount++;
}
}
}
if (asiElements.size() > 0)
{
int columnCreated = 0;
for(InstanceAttributeData data : asiElements)
{
List<InstanceAttributeColumn> instanceColumns = data.getColumns();
int index = data.getColumnIndex() + columnCreated;
for(InstanceAttributeColumn c : instanceColumns)
{
columns.add(index, c);
index++;
columnCreated++;
}
} }
} }
@ -544,7 +584,9 @@ extends AbstractExcelExporter
if (m_printData.getRowIndex() != row) if (m_printData.getRowIndex() != row)
m_printData.setRowIndex(row); m_printData.setRowIndex(row);
MPrintFormatItem item = m_printFormat.getItem(col); Object colobj = columns.get(col);
MPrintFormatItem item = colobj instanceof InstanceAttributeColumn ? ((InstanceAttributeColumn)colobj).getPrintFormatItem()
: (MPrintFormatItem)colobj;
if (Util.isEmpty(item.getDisplayLogic())) if (Util.isEmpty(item.getDisplayLogic()))
return true; return true;

View File

@ -17,6 +17,7 @@ import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
@ -36,6 +37,8 @@ import org.compiere.print.MPrintFormatItem;
import org.compiere.print.MPrintPaper; import org.compiere.print.MPrintPaper;
import org.compiere.print.PrintData; import org.compiere.print.PrintData;
import org.compiere.print.PrintDataElement; import org.compiere.print.PrintDataElement;
import org.compiere.print.layout.InstanceAttributeColumn;
import org.compiere.print.layout.InstanceAttributeData;
import org.compiere.print.layout.PrintDataEvaluatee; import org.compiere.print.layout.PrintDataEvaluatee;
import org.compiere.util.DisplayType; import org.compiere.util.DisplayType;
import org.compiere.util.Evaluator; import org.compiere.util.Evaluator;
@ -98,7 +101,12 @@ public class PrintDataXLSXExporter extends AbstractXLSXExporter
if (m_printData.getRowIndex() != row) if (m_printData.getRowIndex() != row)
m_printData.setRowIndex(row); m_printData.setRowIndex(row);
// //
MPrintFormatItem item = (MPrintFormatItem) columns.get(col); Object colObj = columns.get(col);
if (colObj instanceof InstanceAttributeColumn) {
InstanceAttributeColumn ia = (InstanceAttributeColumn) colObj;
return ia.getPrintDataElement(row);
} else if (colObj instanceof MPrintFormatItem) {
MPrintFormatItem item = (MPrintFormatItem) colObj;
Object obj = null; Object obj = null;
if (item.isTypeField() || item.isTypePrintFormat() && item.isImageField()) if (item.isTypeField() || item.isTypePrintFormat() && item.isImageField())
@ -116,6 +124,7 @@ public class PrintDataXLSXExporter extends AbstractXLSXExporter
{ {
return (PrintDataElement) obj; return (PrintDataElement) obj;
} }
}
return null; return null;
} }
@ -210,6 +219,9 @@ public class PrintDataXLSXExporter extends AbstractXLSXExporter
if (colObj instanceof MPrintFormatItem) { if (colObj instanceof MPrintFormatItem) {
MPrintFormatItem item = (MPrintFormatItem) colObj; MPrintFormatItem item = (MPrintFormatItem) colObj;
return item.getPrintName(getLanguage()); return item.getPrintName(getLanguage());
} else if (colObj instanceof InstanceAttributeColumn) {
InstanceAttributeColumn ia = (InstanceAttributeColumn) colObj;
return ia.getName();
} else { } else {
return ""; return "";
} }
@ -313,7 +325,9 @@ public class PrintDataXLSXExporter extends AbstractXLSXExporter
if (m_printData.getRowIndex() != row) if (m_printData.getRowIndex() != row)
m_printData.setRowIndex(row); m_printData.setRowIndex(row);
MPrintFormatItem item = m_printFormat.getItem(col); Object colobj = columns.get(col);
MPrintFormatItem item = colobj instanceof InstanceAttributeColumn ? ((InstanceAttributeColumn)colobj).getPrintFormatItem()
: (MPrintFormatItem)colobj;
if ( Util.isEmpty(item.getDisplayLogic())) if ( Util.isEmpty(item.getDisplayLogic()))
return true; return true;
@ -343,12 +357,40 @@ public class PrintDataXLSXExporter extends AbstractXLSXExporter
@Override @Override
protected void export(OutputStream out) throws Exception { protected void export(OutputStream out) throws Exception {
columns = new ArrayList<>(); columns = new ArrayList<>();
List<InstanceAttributeData> asiElements = new ArrayList<>();
int columnCount = 0;
for (int col = 0; col < m_printFormat.getItemCount(); col++) for (int col = 0; col < m_printFormat.getItemCount(); col++)
{ {
MPrintFormatItem item = m_printFormat.getItem(col); MPrintFormatItem item = m_printFormat.getItem(col);
if (item.isPrinted()) if (item.isPrinted())
{
if (item.isTypeField() && item.isPrintInstanceAttributes())
{
InstanceAttributeData asiElement = new InstanceAttributeData(item, columnCount);
asiElement.readAttributesData(m_printData);
asiElements.add(asiElement);
continue;
}
else
{ {
columns.add(item); columns.add(item);
columnCount++;
}
}
}
if (asiElements.size() > 0)
{
int columnCreated = 0;
for(InstanceAttributeData data : asiElements)
{
List<InstanceAttributeColumn> instanceColumns = data.getColumns();
int index = data.getColumnIndex() + columnCreated;
for(InstanceAttributeColumn c : instanceColumns)
{
columns.add(index, c);
index++;
columnCreated++;
}
} }
} }

View File

@ -541,6 +541,19 @@ public interface I_AD_PrintFormatItem
*/ */
public boolean isPrinted(); public boolean isPrinted();
/** Column name IsPrintInstanceAttributes */
public static final String COLUMNNAME_IsPrintInstanceAttributes = "IsPrintInstanceAttributes";
/** Set Print Attributes.
* Print each attributes as report column instead of printing the description of attribute set instance
*/
public void setIsPrintInstanceAttributes (boolean IsPrintInstanceAttributes);
/** Get Print Attributes.
* Print each attributes as report column instead of printing the description of attribute set instance
*/
public boolean isPrintInstanceAttributes();
/** Column name IsRelativePosition */ /** Column name IsRelativePosition */
public static final String COLUMNNAME_IsRelativePosition = "IsRelativePosition"; public static final String COLUMNNAME_IsRelativePosition = "IsRelativePosition";

View File

@ -30,7 +30,7 @@ public class X_AD_PrintFormatItem extends PO implements I_AD_PrintFormatItem, I_
/** /**
* *
*/ */
private static final long serialVersionUID = 20210220L; private static final long serialVersionUID = 20210803L;
/** Standard Constructor */ /** Standard Constructor */
public X_AD_PrintFormatItem (Properties ctx, int AD_PrintFormatItem_ID, String trxName) public X_AD_PrintFormatItem (Properties ctx, int AD_PrintFormatItem_ID, String trxName)
@ -68,6 +68,8 @@ public class X_AD_PrintFormatItem extends PO implements I_AD_PrintFormatItem, I_
// Y // Y
setIsPrinted (true); setIsPrinted (true);
// Y // Y
setIsPrintInstanceAttributes (false);
// N
setIsRelativePosition (true); setIsRelativePosition (true);
// Y // Y
setIsRunningTotal (false); setIsRunningTotal (false);
@ -351,22 +353,38 @@ public class X_AD_PrintFormatItem extends PO implements I_AD_PrintFormatItem, I_
/** BarcodeType AD_Reference_ID=377 */ /** BarcodeType AD_Reference_ID=377 */
public static final int BARCODETYPE_AD_Reference_ID=377; public static final int BARCODETYPE_AD_Reference_ID=377;
/** Codabar 2 of 7 linear = 2o9 */
public static final String BARCODETYPE_Codabar2Of7Linear = "2o9";
/** Code 39 3 of 9 linear w/o Checksum = 3o9 */
public static final String BARCODETYPE_Code393Of9LinearWOChecksum = "3o9";
/** Codeabar linear = COD */
public static final String BARCODETYPE_CodeabarLinear = "COD";
/** Code 128 dynamically switching = C28 */
public static final String BARCODETYPE_Code128DynamicallySwitching = "C28";
/** Code 128 A character set = 28A */ /** Code 128 A character set = 28A */
public static final String BARCODETYPE_Code128ACharacterSet = "28A"; public static final String BARCODETYPE_Code128ACharacterSet = "28A";
/** Code 128 B character set = 28B */ /** Code 128 B character set = 28B */
public static final String BARCODETYPE_Code128BCharacterSet = "28B"; public static final String BARCODETYPE_Code128BCharacterSet = "28B";
/** Code 128 C character set = 28C */ /** Code 128 C character set = 28C */
public static final String BARCODETYPE_Code128CCharacterSet = "28C"; public static final String BARCODETYPE_Code128CCharacterSet = "28C";
/** Codabar 2 of 7 linear = 2o9 */
public static final String BARCODETYPE_Codabar2Of7Linear = "2o9";
/** Code 39 w/o Checksum = 39c */
public static final String BARCODETYPE_Code39WOChecksum = "39c";
/** Code 39 with Checksum = 39C */
public static final String BARCODETYPE_Code39WithChecksum = "39C";
/** Code 39 3 of 9 linear w/o Checksum = 3o9 */
public static final String BARCODETYPE_Code393Of9LinearWOChecksum = "3o9";
/** Code 39 3 of 9 linear with Checksum = 3O9 */
public static final String BARCODETYPE_Code393Of9LinearWithChecksum = "3O9";
/** PDF417 two dimensional = 417 */
public static final String BARCODETYPE_PDF417TwoDimensional = "417";
/** SCC-14 shipping code UCC/EAN 128 = C14 */
public static final String BARCODETYPE_SCC_14ShippingCodeUCCEAN128 = "C14";
/** SSCC-18 number UCC/EAN 128 = C18 */
public static final String BARCODETYPE_SSCC_18NumberUCCEAN128 = "C18";
/** Code 128 dynamically switching = C28 */
public static final String BARCODETYPE_Code128DynamicallySwitching = "C28";
/** Code 39 linear w/o Checksum = c39 */
public static final String BARCODETYPE_Code39LinearWOChecksum = "c39";
/** Code 39 linear with Checksum = C39 */ /** Code 39 linear with Checksum = C39 */
public static final String BARCODETYPE_Code39LinearWithChecksum = "C39"; public static final String BARCODETYPE_Code39LinearWithChecksum = "C39";
/** Codeabar linear = COD */
public static final String BARCODETYPE_CodeabarLinear = "COD";
/** EAN 13 = E13 */
public static final String BARCODETYPE_EAN13 = "E13";
/** EAN 128 = E28 */ /** EAN 128 = E28 */
public static final String BARCODETYPE_EAN128 = "E28"; public static final String BARCODETYPE_EAN128 = "E28";
/** Global Trade Item No GTIN UCC/EAN 128 = GTN */ /** Global Trade Item No GTIN UCC/EAN 128 = GTN */
@ -375,38 +393,22 @@ public class X_AD_PrintFormatItem extends PO implements I_AD_PrintFormatItem, I_
public static final String BARCODETYPE_CodabarMonarchLinear = "MON"; public static final String BARCODETYPE_CodabarMonarchLinear = "MON";
/** Codabar NW-7 linear = NW7 */ /** Codabar NW-7 linear = NW7 */
public static final String BARCODETYPE_CodabarNW_7Linear = "NW7"; public static final String BARCODETYPE_CodabarNW_7Linear = "NW7";
/** PDF417 two dimensional = 417 */ /** QR Code = QRC */
public static final String BARCODETYPE_PDF417TwoDimensional = "417"; public static final String BARCODETYPE_QRCode = "QRC";
/** SCC-14 shipping code UCC/EAN 128 = C14 */
public static final String BARCODETYPE_SCC_14ShippingCodeUCCEAN128 = "C14";
/** Shipment ID number UCC/EAN 128 = SID */ /** Shipment ID number UCC/EAN 128 = SID */
public static final String BARCODETYPE_ShipmentIDNumberUCCEAN128 = "SID"; public static final String BARCODETYPE_ShipmentIDNumberUCCEAN128 = "SID";
/** UCC 128 = U28 */ /** UCC 128 = U28 */
public static final String BARCODETYPE_UCC128 = "U28"; public static final String BARCODETYPE_UCC128 = "U28";
/** UPC-A = UPA */
public static final String BARCODETYPE_UPC_A = "UPA";
/** Code 39 USD3 w/o Checksum = us3 */
public static final String BARCODETYPE_Code39USD3WOChecksum = "us3";
/** Code 39 USD3 with Checksum = US3 */ /** Code 39 USD3 with Checksum = US3 */
public static final String BARCODETYPE_Code39USD3WithChecksum = "US3"; public static final String BARCODETYPE_Code39USD3WithChecksum = "US3";
/** Codabar USD-4 linear = US4 */ /** Codabar USD-4 linear = US4 */
public static final String BARCODETYPE_CodabarUSD_4Linear = "US4"; public static final String BARCODETYPE_CodabarUSD_4Linear = "US4";
/** US Postal Service UCC/EAN 128 = USP */ /** US Postal Service UCC/EAN 128 = USP */
public static final String BARCODETYPE_USPostalServiceUCCEAN128 = "USP"; public static final String BARCODETYPE_USPostalServiceUCCEAN128 = "USP";
/** SSCC-18 number UCC/EAN 128 = C18 */
public static final String BARCODETYPE_SSCC_18NumberUCCEAN128 = "C18";
/** Code 39 USD3 w/o Checksum = us3 */
public static final String BARCODETYPE_Code39USD3WOChecksum = "us3";
/** Code 39 3 of 9 linear with Checksum = 3O9 */
public static final String BARCODETYPE_Code393Of9LinearWithChecksum = "3O9";
/** Code 39 linear w/o Checksum = c39 */
public static final String BARCODETYPE_Code39LinearWOChecksum = "c39";
/** EAN 13 = E13 */
public static final String BARCODETYPE_EAN13 = "E13";
/** UPC-A = UPA */
public static final String BARCODETYPE_UPC_A = "UPA";
/** Code 39 with Checksum = 39C */
public static final String BARCODETYPE_Code39WithChecksum = "39C";
/** Code 39 w/o Checksum = 39c */
public static final String BARCODETYPE_Code39WOChecksum = "39c";
/** QR Code = QRC */
public static final String BARCODETYPE_QRCode = "QRC";
/** Set Barcode Type. /** Set Barcode Type.
@param BarcodeType @param BarcodeType
Type of barcode Type of barcode
@ -464,16 +466,16 @@ public class X_AD_PrintFormatItem extends PO implements I_AD_PrintFormatItem, I_
/** FieldAlignmentType AD_Reference_ID=253 */ /** FieldAlignmentType AD_Reference_ID=253 */
public static final int FIELDALIGNMENTTYPE_AD_Reference_ID=253; public static final int FIELDALIGNMENTTYPE_AD_Reference_ID=253;
/** Block = B */
public static final String FIELDALIGNMENTTYPE_Block = "B";
/** Center = C */
public static final String FIELDALIGNMENTTYPE_Center = "C";
/** Default = D */ /** Default = D */
public static final String FIELDALIGNMENTTYPE_Default = "D"; public static final String FIELDALIGNMENTTYPE_Default = "D";
/** Leading (left) = L */ /** Leading (left) = L */
public static final String FIELDALIGNMENTTYPE_LeadingLeft = "L"; public static final String FIELDALIGNMENTTYPE_LeadingLeft = "L";
/** Trailing (right) = T */ /** Trailing (right) = T */
public static final String FIELDALIGNMENTTYPE_TrailingRight = "T"; public static final String FIELDALIGNMENTTYPE_TrailingRight = "T";
/** Block = B */
public static final String FIELDALIGNMENTTYPE_Block = "B";
/** Center = C */
public static final String FIELDALIGNMENTTYPE_Center = "C";
/** Set Field Alignment. /** Set Field Alignment.
@param FieldAlignmentType @param FieldAlignmentType
Field Text Alignment Field Text Alignment
@ -982,6 +984,30 @@ public class X_AD_PrintFormatItem extends PO implements I_AD_PrintFormatItem, I_
return false; return false;
} }
/** Set Print Attributes.
@param IsPrintInstanceAttributes
Print each attributes as report column instead of printing the description of attribute set instance
*/
public void setIsPrintInstanceAttributes (boolean IsPrintInstanceAttributes)
{
set_Value (COLUMNNAME_IsPrintInstanceAttributes, Boolean.valueOf(IsPrintInstanceAttributes));
}
/** Get Print Attributes.
@return Print each attributes as report column instead of printing the description of attribute set instance
*/
public boolean isPrintInstanceAttributes ()
{
Object oo = get_Value(COLUMNNAME_IsPrintInstanceAttributes);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
/** Set Relative Position. /** Set Relative Position.
@param IsRelativePosition @param IsRelativePosition
The item is relative positioned (not absolute) The item is relative positioned (not absolute)
@ -1152,10 +1178,10 @@ public class X_AD_PrintFormatItem extends PO implements I_AD_PrintFormatItem, I_
/** LineAlignmentType AD_Reference_ID=254 */ /** LineAlignmentType AD_Reference_ID=254 */
public static final int LINEALIGNMENTTYPE_AD_Reference_ID=254; public static final int LINEALIGNMENTTYPE_AD_Reference_ID=254;
/** Leading (left) = L */
public static final String LINEALIGNMENTTYPE_LeadingLeft = "L";
/** Center = C */ /** Center = C */
public static final String LINEALIGNMENTTYPE_Center = "C"; public static final String LINEALIGNMENTTYPE_Center = "C";
/** Leading (left) = L */
public static final String LINEALIGNMENTTYPE_LeadingLeft = "L";
/** Trailing (right) = T */ /** Trailing (right) = T */
public static final String LINEALIGNMENTTYPE_TrailingRight = "T"; public static final String LINEALIGNMENTTYPE_TrailingRight = "T";
/** None = X */ /** None = X */
@ -1267,10 +1293,10 @@ public class X_AD_PrintFormatItem extends PO implements I_AD_PrintFormatItem, I_
public static final int PRINTAREATYPE_AD_Reference_ID=256; public static final int PRINTAREATYPE_AD_Reference_ID=256;
/** Content = C */ /** Content = C */
public static final String PRINTAREATYPE_Content = "C"; public static final String PRINTAREATYPE_Content = "C";
/** Header = H */
public static final String PRINTAREATYPE_Header = "H";
/** Footer = F */ /** Footer = F */
public static final String PRINTAREATYPE_Footer = "F"; public static final String PRINTAREATYPE_Footer = "F";
/** Header = H */
public static final String PRINTAREATYPE_Header = "H";
/** Set Area. /** Set Area.
@param PrintAreaType @param PrintAreaType
Print Area Print Area
@ -1293,18 +1319,18 @@ public class X_AD_PrintFormatItem extends PO implements I_AD_PrintFormatItem, I_
public static final int PRINTFORMATTYPE_AD_Reference_ID=255; public static final int PRINTFORMATTYPE_AD_Reference_ID=255;
/** Field = F */ /** Field = F */
public static final String PRINTFORMATTYPE_Field = "F"; public static final String PRINTFORMATTYPE_Field = "F";
/** Text = T */
public static final String PRINTFORMATTYPE_Text = "T";
/** Print Format = P */
public static final String PRINTFORMATTYPE_PrintFormat = "P";
/** Image = I */ /** Image = I */
public static final String PRINTFORMATTYPE_Image = "I"; public static final String PRINTFORMATTYPE_Image = "I";
/** Rectangle = R */
public static final String PRINTFORMATTYPE_Rectangle = "R";
/** Line = L */ /** Line = L */
public static final String PRINTFORMATTYPE_Line = "L"; public static final String PRINTFORMATTYPE_Line = "L";
/** Print Format = P */
public static final String PRINTFORMATTYPE_PrintFormat = "P";
/** Rectangle = R */
public static final String PRINTFORMATTYPE_Rectangle = "R";
/** Script = S */ /** Script = S */
public static final String PRINTFORMATTYPE_Script = "S"; public static final String PRINTFORMATTYPE_Script = "S";
/** Text = T */
public static final String PRINTFORMATTYPE_Text = "T";
/** Set Format Type. /** Set Format Type.
@param PrintFormatType @param PrintFormatType
Print Format Type Print Format Type
@ -1418,12 +1444,12 @@ public class X_AD_PrintFormatItem extends PO implements I_AD_PrintFormatItem, I_
public static final int SHAPETYPE_AD_Reference_ID=333; public static final int SHAPETYPE_AD_Reference_ID=333;
/** 3D Rectangle = 3 */ /** 3D Rectangle = 3 */
public static final String SHAPETYPE_3DRectangle = "3"; public static final String SHAPETYPE_3DRectangle = "3";
/** Normal Rectangle = N */
public static final String SHAPETYPE_NormalRectangle = "N";
/** Oval = O */ /** Oval = O */
public static final String SHAPETYPE_Oval = "O"; public static final String SHAPETYPE_Oval = "O";
/** Round Rectangle = R */ /** Round Rectangle = R */
public static final String SHAPETYPE_RoundRectangle = "R"; public static final String SHAPETYPE_RoundRectangle = "R";
/** Normal Rectangle = N */
public static final String SHAPETYPE_NormalRectangle = "N";
/** Set Shape Type. /** Set Shape Type.
@param ShapeType @param ShapeType
Type of the shape to be painted Type of the shape to be painted

View File

@ -91,6 +91,8 @@ import org.compiere.model.MRfQResponse;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import org.compiere.model.MTable; import org.compiere.model.MTable;
import org.compiere.model.PrintInfo; import org.compiere.model.PrintInfo;
import org.compiere.print.layout.InstanceAttributeColumn;
import org.compiere.print.layout.InstanceAttributeData;
import org.compiere.print.layout.LayoutEngine; import org.compiere.print.layout.LayoutEngine;
import org.compiere.print.layout.PrintDataEvaluatee; import org.compiere.print.layout.PrintDataEvaluatee;
import org.compiere.process.ProcessInfo; import org.compiere.process.ProcessInfo;
@ -627,6 +629,45 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
{ {
try try
{ {
//collect column to print
List<Object> columns = new ArrayList<>();
List<InstanceAttributeData> asiElements = new ArrayList<>();
int columnCount = 0;
for (int col = 0; col < m_printFormat.getItemCount(); col++)
{
MPrintFormatItem item = m_printFormat.getItem(col);
if (item.isPrinted())
{
if (item.isTypeField() && item.isPrintInstanceAttributes())
{
InstanceAttributeData asiElement = new InstanceAttributeData(item, columnCount);
asiElement.readAttributesData(m_printData);
asiElements.add(asiElement);
continue;
}
else
{
columns.add(item);
columnCount++;
}
}
}
if (asiElements.size() > 0)
{
int columnCreated = 0;
for(InstanceAttributeData data : asiElements)
{
List<InstanceAttributeColumn> instanceColumns = data.getColumns();
int index = data.getColumnIndex() + columnCreated;
for(InstanceAttributeColumn c : instanceColumns)
{
columns.add(index, c);
index++;
columnCreated++;
}
}
}
String cssPrefix = extension != null ? extension.getClassPrefix() : null; String cssPrefix = extension != null ? extension.getClassPrefix() : null;
if (cssPrefix != null && cssPrefix.trim().length() == 0) if (cssPrefix != null && cssPrefix.trim().length() == 0)
cssPrefix = null; cssPrefix = null;
@ -696,10 +737,14 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
mapCssInfo.clear(); mapCssInfo.clear();
MPrintFormatItem item = null; MPrintFormatItem item = null;
int printColIndex = -1; int printColIndex = -1;
for(int col = 0; col < m_printFormat.getItemCount(); col++) for(int col = 0; col < columns.size(); col++)
{ {
item = m_printFormat.getItem(col); Object colobj = columns.get(col);
if(item.isPrinted()) if (colobj instanceof MPrintFormatItem)
item = (MPrintFormatItem) colobj;
else if (colobj instanceof InstanceAttributeColumn)
item = ((InstanceAttributeColumn) colobj).getPrintFormatItem();
if(item != null)
{ {
printColIndex++; printColIndex++;
addCssInfo(item, printColIndex); addCssInfo(item, printColIndex);
@ -813,6 +858,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
int printColIndex = -1; int printColIndex = -1;
HashMap<Integer, th> suppressMap = new HashMap<>(); HashMap<Integer, th> suppressMap = new HashMap<>();
// for all rows (-1 = header row) // for all rows (-1 = header row)
for (int row = -1; row < m_printData.getRowCount(); row++) for (int row = -1; row < m_printData.getRowCount(); row++)
{ {
@ -838,10 +884,21 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
printColIndex = -1; printColIndex = -1;
// for all columns // for all columns
for (int col = 0; col < m_printFormat.getItemCount(); col++) for (int col = 0; col < columns.size(); col++)
{ {
MPrintFormatItem item = m_printFormat.getItem(col); Object colObj = columns.get(col);
if (item.isPrinted()) MPrintFormatItem item = null;
InstanceAttributeColumn instanceAttributeColumn = null;
if (colObj instanceof MPrintFormatItem)
{
item = (MPrintFormatItem) colObj;
}
else if (colObj instanceof InstanceAttributeColumn)
{
instanceAttributeColumn = (InstanceAttributeColumn) colObj;
item = instanceAttributeColumn.getPrintFormatItem();
}
if (item != null)
{ {
printColIndex++; printColIndex++;
// header row // header row
@ -849,8 +906,9 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
{ {
th th = new th(); th th = new th();
tr.addElement(th); tr.addElement(th);
th.addElement(Util.maskHTML(item.getPrintName(language))); String columnHeader = instanceAttributeColumn != null ? instanceAttributeColumn.getName() : item.getPrintName(language);
if (cssPrefix != null) th.addElement(Util.maskHTML(columnHeader));
if (cssPrefix != null && instanceAttributeColumn == null)
{ {
MColumn column = MColumn.get(getCtx(), item.getAD_Column_ID()); MColumn column = MColumn.get(getCtx(), item.getAD_Column_ID());
if (column != null && column.getAD_Column_ID() > 0) if (column != null && column.getAD_Column_ID() > 0)
@ -871,7 +929,8 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
{ {
td td = new td(); td td = new td();
tr.addElement(td); tr.addElement(td);
Object obj = m_printData.getNodeByPrintFormatItemId(item.getAD_PrintFormatItem_ID()); Object obj = instanceAttributeColumn != null ? instanceAttributeColumn.getPrintDataElement(row)
: m_printData.getNodeByPrintFormatItemId(item.getAD_PrintFormatItem_ID());
if (obj == null || !isDisplayPFItem(item)){ if (obj == null || !isDisplayPFItem(item)){
td.addElement("&nbsp;"); td.addElement("&nbsp;");
if (colSuppressRepeats != null && colSuppressRepeats[printColIndex]){ if (colSuppressRepeats != null && colSuppressRepeats[printColIndex]){
@ -1076,6 +1135,45 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
delimiter = '\t'; delimiter = '\t';
try try
{ {
//collect columns to be printed
ArrayList<Object> columns = new ArrayList<>();
List<InstanceAttributeData> asiElements = new ArrayList<>();
int columnCount = 0;
for (int col = 0; col < m_printFormat.getItemCount(); col++)
{
MPrintFormatItem item = m_printFormat.getItem(col);
if (item.isPrinted())
{
if (item.isTypeField() && item.isPrintInstanceAttributes())
{
InstanceAttributeData asiElement = new InstanceAttributeData(item, columnCount);
asiElement.readAttributesData(m_printData);
asiElements.add(asiElement);
continue;
}
else
{
columns.add(item);
columnCount++;
}
}
}
if (asiElements.size() > 0)
{
int columnCreated = 0;
for(InstanceAttributeData data : asiElements)
{
List<InstanceAttributeColumn> instanceColumns = data.getColumns();
int index = data.getColumnIndex() + columnCreated;
for(InstanceAttributeColumn c : instanceColumns)
{
columns.add(index, c);
index++;
columnCreated++;
}
}
}
Boolean [] colSuppressRepeats = m_layout == null || m_layout.colSuppressRepeats == null? LayoutEngine.getColSuppressRepeats(m_printFormat):m_layout.colSuppressRepeats; Boolean [] colSuppressRepeats = m_layout == null || m_layout.colSuppressRepeats == null? LayoutEngine.getColSuppressRepeats(m_printFormat):m_layout.colSuppressRepeats;
Object [] preValues = null; Object [] preValues = null;
if (colSuppressRepeats != null){ if (colSuppressRepeats != null){
@ -1092,10 +1190,21 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
// for all columns // for all columns
boolean first = true; // first column to print boolean first = true; // first column to print
for (int col = 0; col < m_printFormat.getItemCount(); col++) for (int col = 0; col < columns.size(); col++)
{ {
MPrintFormatItem item = m_printFormat.getItem(col); Object colObj = columns.get(col);
if (item.isPrinted()) MPrintFormatItem item = null;
InstanceAttributeColumn iaColumn = null;
if (colObj instanceof InstanceAttributeColumn)
{
iaColumn = (InstanceAttributeColumn) colObj;
item = iaColumn.getPrintFormatItem();
}
else if (colObj instanceof MPrintFormatItem)
{
item = (MPrintFormatItem)colObj;
}
if (item != null)
{ {
// column delimiter (comma or tab) // column delimiter (comma or tab)
if (first) if (first)
@ -1104,12 +1213,14 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
sb.append(delimiter); sb.append(delimiter);
// header row // header row
if (row == -1) if (row == -1)
createCSVvalue (sb, delimiter, {
m_printFormat.getItem(col).getPrintName(language)); String printName = iaColumn != null ? iaColumn.getName() : item.getPrintName(language);
createCSVvalue (sb, delimiter, printName);
}
else else
{ {
printColIndex++; printColIndex++;
Object obj = m_printData.getNodeByPrintFormatItemId(item.getAD_PrintFormatItem_ID()); Object obj = iaColumn != null ? iaColumn.getPrintDataElement(row) : m_printData.getNodeByPrintFormatItemId(item.getAD_PrintFormatItem_ID());
String data = ""; String data = "";
if (obj == null || !isDisplayPFItem(item)){ if (obj == null || !isDisplayPFItem(item)){
if (colSuppressRepeats != null && colSuppressRepeats[printColIndex]){ if (colSuppressRepeats != null && colSuppressRepeats[printColIndex]){

View File

@ -0,0 +1,84 @@
/***********************************************************************
* This file is part of iDempiere ERP Open Source *
* http://www.idempiere.org *
* *
* Copyright (C) Contributors *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
* *
* Contributors: *
* - hengsin *
**********************************************************************/
package org.compiere.print.layout;
import org.compiere.print.MPrintFormatItem;
import org.compiere.print.PrintDataElement;
import org.compiere.util.DisplayType;
/**
* @author hengsin
*
*/
public class InstanceAttributeColumn {
private String attributeName;
private InstanceAttributeData data;
/**
*
* @param attributeName
* @param data
*/
public InstanceAttributeColumn(String attributeName, InstanceAttributeData data) {
this.attributeName = attributeName;
this.data = data;
}
/**
*
* @return {@link MPrintFormatItem}
*/
public MPrintFormatItem getPrintFormatItem() {
return data.getPrintFormatItem();
}
/**
*
* @return name
*/
public String getName() {
return attributeName;
}
/**
*
* @param rowIndex
* @return attribute value
*/
public String getValue(int rowIndex) {
return data.getAttributeValue(rowIndex, attributeName);
}
/**
*
* @param rowIndex
* @return {@link PrintDataElement}
*/
public PrintDataElement getPrintDataElement(int rowIndex) {
return new PrintDataElement(data.getPrintFormatItem().getAD_PrintFormatItem_ID(), attributeName,
data.getAttributeValue(rowIndex, attributeName), DisplayType.Text, null);
}
}

View File

@ -0,0 +1,228 @@
/***********************************************************************
* This file is part of iDempiere ERP Open Source *
* http://www.idempiere.org *
* *
* Copyright (C) Contributors *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
* *
* Contributors: *
* - hengsin *
**********************************************************************/
package org.compiere.print.layout;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.adempiere.exceptions.DBException;
import org.compiere.model.X_AD_PrintFormatItem;
import org.compiere.print.MPrintFormatItem;
import org.compiere.print.PrintData;
import org.compiere.print.PrintDataElement;
import org.compiere.print.util.SerializableMatrix;
import org.compiere.util.DB;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Util;
import org.compiere.util.ValueNamePair;
/**
* @author hengsin
*
*/
public class InstanceAttributeData {
private MPrintFormatItem item;
private List<String> attributes;
private List<Map<String, String>> attributeRows;
private int columnIndex;
/**
*
* @param item
* @param columnIndex
*/
public InstanceAttributeData(MPrintFormatItem item, int columnIndex) {
this.item = item;
this.columnIndex = columnIndex;
}
/**
*
* @param rowIndex
* @param attributeName
* @return attribute value
*/
public String getAttributeValue(int rowIndex, String attributeName) {
if (attributeRows == null)
return null;
if (rowIndex >= attributeRows.size())
return null;
Map<String, String> valueMap = attributeRows.get(rowIndex);
return valueMap.get(attributeName);
}
/**
*
* @return {@link MPrintFormatItem}
*/
public MPrintFormatItem getPrintFormatItem() {
return item;
}
/**
*
* @return column index
*/
public int getColumnIndex() {
return columnIndex;
}
/**
*
* @return attribute columns
*/
public List<InstanceAttributeColumn> getColumns() {
List<InstanceAttributeColumn> list = new ArrayList<>();
for (String s : attributes) {
InstanceAttributeColumn col = new InstanceAttributeColumn(s, this);
list.add(col);
}
return list;
}
/**
*
* @param printData
*/
public void readAttributesData(PrintData printData) {
attributes = new ArrayList<>();
attributeRows = new ArrayList<>();
for (int i = 0; i < printData.getRowCount(); i++) {
printData.setRowIndex(i);
Map<String, String> attributeMap = new HashMap<>();
Object node = printData.getNodeByPrintFormatItem(item);
if (node instanceof PrintDataElement) {
PrintDataElement dataElement = (PrintDataElement) node;
Object value = dataElement.getValue();
if (value != null && value instanceof KeyNamePair) {
KeyNamePair knp = (KeyNamePair) value;
int asiId = knp.getKey();
if (asiId > 0) {
String sql = "SELECT b.Name, a.Value FROM M_AttributeInstance a JOIN M_Attribute b ON (a.M_Attribute_ID=b.M_Attribute_ID) "
+ "WHERE a.M_AttributeSetInstance_ID=?";
try (PreparedStatement stmt = DB.prepareStatement(sql, null)) {
stmt.setInt(1, asiId);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
String attribute = rs.getString(1);
String attributeValue = rs.getString(2);
if (Util.isEmpty(attributeValue))
continue;
if (!attributes.contains(attribute))
attributes.add(attribute);
attributeMap.put(attribute, attributeValue);
}
} catch (SQLException e) {
throw new DBException(e);
}
}
}
}
attributeRows.add(attributeMap);
}
}
/**
*
* @param elements
* @param tableProperties
* @param columnOffset
*/
public void updateTable(SerializableMatrix<Serializable> elements, TableProperties tableProperties,
int columnOffset) {
List<ValueNamePair> columnHeaderList = new ArrayList<>();
Collections.addAll(columnHeaderList, tableProperties.getColumnHeader());
List<Integer> columnMaxWidthList = new ArrayList<>();
for (int t : tableProperties.getColumnMaxWidth())
columnMaxWidthList.add(t);
List<Integer> columnMaxHeightList = new ArrayList<>();
for (int t : tableProperties.getColumnMaxHeight())
columnMaxHeightList.add(t);
List<String> columnJustificationList = new ArrayList<>();
Collections.addAll(columnJustificationList, tableProperties.getColumnJustification());
List<Boolean> fixedWidthList = new ArrayList<>();
for (boolean t : tableProperties.getFixedWidth())
fixedWidthList.add(t);
List<Boolean> colSuppressRepeatsList = new ArrayList<>();
for (boolean t : tableProperties.getColSuppressRepeats())
colSuppressRepeatsList.add(t);
int valueMaxWidth = item.getMaxWidth();
boolean valueFixedWidth = (valueMaxWidth != 0 && item.isFixedWidth());
boolean valueSuppressRepeats = item.isSuppressRepeats();
if (item.isSuppressNull()) {
if (valueMaxWidth == 0)
valueMaxWidth = -1; // indication suppress if Null
else
valueMaxWidth *= -1;
}
int valueMaxHeight = item.getMaxHeight();
if (item.isHeightOneLine())
valueMaxHeight = -1;
String valueJustification = item.getFieldAlignmentType();
if (valueJustification == null || valueJustification.equals(X_AD_PrintFormatItem.FIELDALIGNMENTTYPE_Default))
valueJustification = X_AD_PrintFormatItem.FIELDALIGNMENTTYPE_LeadingLeft;
int index = columnIndex + columnOffset;
for (String s : attributes) {
columnHeaderList.add(index, new ValueNamePair(s, s));
columnMaxWidthList.add(index, valueMaxWidth);
columnMaxHeightList.add(index, valueMaxHeight);
columnJustificationList.add(index, valueJustification);
fixedWidthList.add(index, valueFixedWidth);
colSuppressRepeatsList.add(index, valueSuppressRepeats);
index++;
}
tableProperties.setColumnHeader(columnHeaderList.toArray(new ValueNamePair[0]));
tableProperties.setColumnMaxWidth(columnMaxWidthList.stream().mapToInt(i -> i).toArray());
tableProperties.setColumnMaxHeight(columnMaxHeightList.stream().mapToInt(i -> i).toArray());
tableProperties.setColumnJustification(columnJustificationList.toArray(new String[0]));
boolean[] fixedWidth = new boolean[fixedWidthList.size()];
for (int i = 0; i < fixedWidthList.size(); i++)
fixedWidth[i] = fixedWidthList.get(i);
tableProperties.setFixedWidth(fixedWidth);
Boolean[] colSuppressRepeats = new Boolean[colSuppressRepeatsList.size()];
for (int i = 0; i < colSuppressRepeatsList.size(); i++)
colSuppressRepeats[i] = colSuppressRepeatsList.get(i);
tableProperties.setColSuppressRepeats(colSuppressRepeats);
for (int i = 0; i < elements.getRowCount(); i++) {
elements.setRowIndex(i);
List<Serializable> columns = elements.getRowData();
Map<String, String> attributeRow = attributeRows.get(i);
index = columnIndex + columnOffset;
for (String s : attributes) {
String value = attributeRow.get(s);
columns.add(index, value);
index++;
}
}
}
}

View File

@ -1589,12 +1589,25 @@ public class LayoutEngine implements Pageable, Printable, Doc
nextPages.x += xOffset; nextPages.x += xOffset;
nextPages.width -= xOffset; nextPages.width -= xOffset;
// Column count // Column count
List<Integer> instanceAttributeList = new ArrayList<>();
List<MPrintFormatItem> instanceAttributeItems = new ArrayList<>();
int columnCount = 0; int columnCount = 0;
for (int c = 0; c < format.getItemCount(); c++) for (int c = 0; c < format.getItemCount(); c++)
{ {
if (format.getItem(c).isPrinted()) if (format.getItem(c).isPrinted())
{
if (format.getItem(c).isTypeField())
{
if(format.getItem(c).isPrintInstanceAttributes())
{
instanceAttributeList.add(columnCount);
instanceAttributeItems.add(format.getItem(c));
continue;
}
}
columnCount++; columnCount++;
} }
}
// System.out.println("Cols=" + cols); // System.out.println("Cols=" + cols);
// Header & Column Setup // Header & Column Setup
@ -1612,6 +1625,8 @@ public class LayoutEngine implements Pageable, Printable, Doc
for (int c = 0; c < format.getItemCount(); c++) for (int c = 0; c < format.getItemCount(); c++)
{ {
MPrintFormatItem item = format.getItem(c); MPrintFormatItem item = format.getItem(c);
if (instanceAttributeItems.contains(item))
continue;
if (item.isPrinted()) if (item.isPrinted())
{ {
if (item.isNextLine() && item.getBelowColumn() != 0) if (item.isNextLine() && item.getBelowColumn() != 0)
@ -1737,6 +1752,8 @@ public class LayoutEngine implements Pageable, Printable, Doc
{ {
Serializable columnElement = null; Serializable columnElement = null;
MPrintFormatItem item = format.getItem(c); MPrintFormatItem item = format.getItem(c);
if (instanceAttributeItems.contains(item))
continue;
Serializable dataElement = null; Serializable dataElement = null;
if (item.isPrinted()) // Text Columns if (item.isPrinted()) // Text Columns
{ {
@ -1805,6 +1822,33 @@ public class LayoutEngine implements Pageable, Printable, Doc
// System.out.println("No PK " + printData); // System.out.println("No PK " + printData);
} // for all rows } // for all rows
//add asi attributes columns
List<InstanceAttributeData> asiElements = new ArrayList<>();
if (instanceAttributeList.size() > 0) {
for(int i = 0; i < instanceAttributeItems.size(); i ++) {
MPrintFormatItem item = instanceAttributeItems.get(i);
int columnIndex = instanceAttributeList.get(i);
InstanceAttributeData asiElement = new InstanceAttributeData(item, columnIndex);
asiElement.readAttributesData(printData);
asiElements.add(asiElement);
}
int columnOffset = 0;
for (InstanceAttributeData element : asiElements) {
TableProperties tableProperties = new TableProperties(columnHeader, columnMaxWidth, columnMaxHeight, fixedWidth, colSuppressRepeats,
columnJustification);
int currentCount = columnHeader.length;
element.updateTable(elements, tableProperties, columnOffset);
columnHeader = tableProperties.getColumnHeader();
columnMaxWidth = tableProperties.getColumnMaxWidth();
columnMaxHeight = tableProperties.getColumnMaxHeight();
fixedWidth = tableProperties.getFixedWidth();
colSuppressRepeats = tableProperties.getColSuppressRepeats();
columnJustification = tableProperties.getColumnJustification();
columnOffset += columnHeader.length - currentCount;
}
}
// //
TableElement table = new TableElement(columnHeader, TableElement table = new TableElement(columnHeader,
columnMaxWidth, columnMaxHeight, columnJustification, columnMaxWidth, columnMaxHeight, columnJustification,

View File

@ -0,0 +1,157 @@
/***********************************************************************
* This file is part of iDempiere ERP Open Source *
* http://www.idempiere.org *
* *
* Copyright (C) Contributors *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
* *
* Contributors: *
* - hengsin *
**********************************************************************/
package org.compiere.print.layout;
import org.compiere.util.ValueNamePair;
/**
* @author hengsin
*
*/
public class TableProperties {
private ValueNamePair[] columnHeader;
private int[] columnMaxWidth;
private int[] columnMaxHeight;
private boolean[] fixedWidth;
private Boolean[] colSuppressRepeats;
private String[] columnJustification;
/**
*
* @param columnHeader
* @param columnMaxWidth
* @param columnMaxHeight
* @param fixedWidth
* @param colSuppressRepeats
* @param columnJustification
*/
public TableProperties(ValueNamePair[] columnHeader, int[] columnMaxWidth, int[] columnMaxHeight,
boolean[] fixedWidth, Boolean[] colSuppressRepeats, String[] columnJustification) {
this.columnHeader = columnHeader;
this.columnMaxWidth = columnMaxWidth;
this.columnMaxHeight = columnMaxHeight;
this.fixedWidth = fixedWidth;
this.colSuppressRepeats = colSuppressRepeats;
this.columnJustification = columnJustification;
}
/**
*
* @return column headers
*/
public ValueNamePair[] getColumnHeader() {
return columnHeader;
}
/**
*
* @param columnHeader
*/
public void setColumnHeader(ValueNamePair[] columnHeader) {
this.columnHeader = columnHeader;
}
/**
*
* @return max width for columns
*/
public int[] getColumnMaxWidth() {
return columnMaxWidth;
}
/**
*
* @param columnMaxWidth
*/
public void setColumnMaxWidth(int[] columnMaxWidth) {
this.columnMaxWidth = columnMaxWidth;
}
/**
*
* @return max height for columns
*/
public int[] getColumnMaxHeight() {
return columnMaxHeight;
}
/**
*
* @param columnMaxHeight
*/
public void setColumnMaxHeight(int[] columnMaxHeight) {
this.columnMaxHeight = columnMaxHeight;
}
/**
*
* @return fixed width option for columns
*/
public boolean[] getFixedWidth() {
return fixedWidth;
}
/**
*
* @param fixedWidth
*/
public void setFixedWidth(boolean[] fixedWidth) {
this.fixedWidth = fixedWidth;
}
/**
*
* @return suppress repeating value setting for columns
*/
public Boolean[] getColSuppressRepeats() {
return colSuppressRepeats;
}
/**
*
* @param colSuppressRepeats
*/
public void setColSuppressRepeats(Boolean[] colSuppressRepeats) {
this.colSuppressRepeats = colSuppressRepeats;
}
/**
*
* @return justification setting for columns
*/
public String[] getColumnJustification() {
return columnJustification;
}
/**
*
* @param columnJustification
*/
public void setColumnJustification(String[] columnJustification) {
this.columnJustification = columnJustification;
}
}

View File

@ -149,7 +149,27 @@ public class EvaluationVisitor extends SimpleBooleanBaseVisitor<Object> {
} }
} }
//check string==bigdecimal or bigdecimal==string
if (left instanceof String && !(right instanceof String)) {
if (right instanceof BigDecimal) {
return left.equals(((BigDecimal)right).toPlainString());
} else {
return left.equals(right.toString());
}
} else if (right instanceof String && !(left instanceof String)) {
if (left instanceof BigDecimal) {
return ((BigDecimal)left).toPlainString().equals(right);
} else {
return left.toString().equals(right.toString());
}
}
try {
return left.compareTo(right) == 0; return left.compareTo(right) == 0;
} catch (Exception e) {
//fall back to string
return left.toString().equals(right.toString());
}
} }
private Boolean isIn(String left, String rightText) { private Boolean isIn(String left, String rightText) {

View File

@ -52,6 +52,7 @@ import org.adempiere.webui.event.ValueChangeListener;
import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.MColumn; import org.compiere.model.MColumn;
import org.compiere.model.MTable;
import org.compiere.model.X_AD_PrintFormatItem; import org.compiere.model.X_AD_PrintFormatItem;
import org.compiere.model.X_AD_PrintPaper; import org.compiere.model.X_AD_PrintPaper;
import org.compiere.print.MPrintColor; import org.compiere.print.MPrintColor;
@ -293,6 +294,7 @@ public class WPrintFormatEditor implements ValueChangeListener {
editorMap.put(MPrintFormatItem.COLUMNNAME_IsVarianceCalc, printFormatForm.editorIsVarianceCalc); editorMap.put(MPrintFormatItem.COLUMNNAME_IsVarianceCalc, printFormatForm.editorIsVarianceCalc);
editorMap.put(MPrintFormatItem.COLUMNNAME_IsRunningTotal, printFormatForm.editorIsRunningTotal); editorMap.put(MPrintFormatItem.COLUMNNAME_IsRunningTotal, printFormatForm.editorIsRunningTotal);
editorMap.put(MPrintFormatItem.COLUMNNAME_RunningTotalLines, printFormatForm.editorRunningTotalLines); editorMap.put(MPrintFormatItem.COLUMNNAME_RunningTotalLines, printFormatForm.editorRunningTotalLines);
editorMap.put(MPrintFormatItem.COLUMNNAME_IsPrintInstanceAttributes, printFormatForm.editorIsPrintInstanceAttributes);
} }
private void validateProperties(final MPrintFormatItem pfItem) { private void validateProperties(final MPrintFormatItem pfItem) {
@ -301,6 +303,13 @@ public class WPrintFormatEditor implements ValueChangeListener {
public String get_ValueAsString(String variableName) { public String get_ValueAsString(String variableName) {
String retString = null; String retString = null;
//ref column
String foreignColumn = "";
int f = variableName.indexOf('.');
if (f > 0) {
foreignColumn = variableName.substring(f+1, variableName.length());
variableName = variableName.substring(0, f);
}
if (pfItem.get_ColumnIndex(variableName) >= 0 ) { if (pfItem.get_ColumnIndex(variableName) >= 0 ) {
if (pfItem.get_Value(variableName) instanceof Boolean) { if (pfItem.get_Value(variableName) instanceof Boolean) {
@ -311,6 +320,23 @@ public class WPrintFormatEditor implements ValueChangeListener {
} }
} }
//check . foreign reference
if (!Util.isEmpty(retString) && !Util.isEmpty(foreignColumn) && variableName.endsWith("_ID")) {
int id = 0;
try {
id = Integer.parseInt(retString);
} catch (Exception e){}
if (id > 0) {
String foreignTable = variableName.substring(0, variableName.length()-3);
MTable table = MTable.get(Env.getCtx(), foreignTable);
if (table != null) {
retString = DB.getSQLValueString(null,
"SELECT " + foreignColumn + " FROM " + foreignTable + " WHERE "
+ foreignTable + "_ID = ?", id);
}
}
}
if (Util.isEmpty(retString)) { if (Util.isEmpty(retString)) {
MPrintFormat format = MPrintFormat.get(Env.getCtx(), MPrintFormat format = MPrintFormat.get(Env.getCtx(),
pfItem.getAD_PrintFormat_ID(), false); pfItem.getAD_PrintFormat_ID(), false);

View File

@ -134,6 +134,7 @@ public class WPrintFormatEditorForm extends Window
protected WEditor editorIsVarianceCalc = null; protected WEditor editorIsVarianceCalc = null;
protected WEditor editorIsRunningTotal = null; protected WEditor editorIsRunningTotal = null;
protected WEditor editorRunningTotalLines = null; protected WEditor editorRunningTotalLines = null;
protected WEditor editorIsPrintInstanceAttributes = null;
/** /**
* *
@ -702,6 +703,18 @@ public class WPrintFormatEditorForm extends Window
row.setGroup(group); row.setGroup(group);
rows.appendChild(row); rows.appendChild(row);
row = new Row();
row.appendChild(new Label(Msg.getElement(
Env.getCtx(),
MPrintFormatItem.COLUMNNAME_IsPrintInstanceAttributes)));
editorIsPrintInstanceAttributes = new WYesNoEditor(
MPrintFormatItem.COLUMNNAME_IsPrintInstanceAttributes, "", null,
false, false, true);
row.appendChild(editorIsPrintInstanceAttributes.getComponent());
editorIsPrintInstanceAttributes.addValueChangeListener(pfe);
row.setGroup(group);
rows.appendChild(row);
row = new Row(); row = new Row();
row.appendChild(new Label(Msg.getElement( row.appendChild(new Label(Msg.getElement(
Env.getCtx(), Env.getCtx(),