Skip to content

Commit

Permalink
Merge branch 'master' into bndtools
Browse files Browse the repository at this point in the history
  • Loading branch information
hengsin committed Oct 8, 2024
2 parents ce7eaea + 04c3bb9 commit a53f4f6
Show file tree
Hide file tree
Showing 9 changed files with 383 additions and 5 deletions.
44 changes: 44 additions & 0 deletions migration/iD11/oracle/202410031525_IDEMPIERE-4297.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
-- IDEMPIERE-4297 organize dashboard
SELECT register_migration_script('202410031525_IDEMPIERE-4297.sql') FROM dual;

SET SQLBLANKLINES ON
SET DEFINE OFF

-- Oct 3, 2024, 3:31:34 PM CEST
UPDATE PA_DashboardContent SET ColumnNo=2,Updated=TO_TIMESTAMP('2024-10-03 15:31:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE PA_DashboardContent_ID=200005
;

-- Oct 3, 2024, 3:31:56 PM CEST
UPDATE PA_DashboardContent SET Line=1, ColumnNo=2,Updated=TO_TIMESTAMP('2024-10-03 15:31:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE PA_DashboardContent_ID=200002
;

-- Oct 3, 2024, 3:32:40 PM CEST
UPDATE PA_DashboardContent SET ColumnNo=4,Updated=TO_TIMESTAMP('2024-10-03 15:32:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE PA_DashboardContent_ID=50003
;

-- Oct 3, 2024, 3:32:54 PM CEST
UPDATE PA_DashboardContent SET Line=0, ColumnNo=1,Updated=TO_TIMESTAMP('2024-10-03 15:32:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE PA_DashboardContent_ID=50002
;

-- Oct 3, 2024, 3:33:54 PM CEST
UPDATE PA_DashboardContent SET Line=1, ColumnNo=1,Updated=TO_TIMESTAMP('2024-10-03 15:33:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE PA_DashboardContent_ID=200019
;

-- Oct 3, 2024, 3:34:26 PM CEST
UPDATE PA_DashboardContent SET Line=1, ColumnNo=0,Updated=TO_TIMESTAMP('2024-10-03 15:34:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE PA_DashboardContent_ID=200018
;

-- Oct 3, 2024, 3:34:57 PM CEST
UPDATE PA_DashboardContent SET Line=0, ColumnNo=3,Updated=TO_TIMESTAMP('2024-10-03 15:34:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE PA_DashboardContent_ID=50004
;

-- Oct 3, 2024, 3:55:12 PM CEST
UPDATE AD_StatusLine SET SQLStatement='SELECT
SUM(CASE WHEN EXTRACT(YEAR FROM Dateordered) = EXTRACT(YEAR FROM getdate()) THEN 1 ELSE 0 END) AS total_orders_current_year,
SUM(CASE WHEN EXTRACT(YEAR FROM Dateordered) = 2002 THEN 1 ELSE 0 END) AS total_orders_2002,
SUM(CASE WHEN EXTRACT(YEAR FROM Dateordered) = EXTRACT(YEAR FROM getdate()) THEN 1 ELSE 0 END) -
SUM(CASE WHEN EXTRACT(YEAR FROM Dateordered) = 2002 THEN 1 ELSE 0 END) AS difference
FROM c_order
WHERE issotrx=''Y'' AND ad_client_id= @#AD_Client_ID@',Updated=TO_TIMESTAMP('2024-10-03 15:55:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_StatusLine_ID=200024
;

18 changes: 18 additions & 0 deletions migration/iD11/oracle/202410071412_IDEMPIERE-6196.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- IDEMPIERE-6196_SysConfig
SELECT register_migration_script('202410071412_IDEMPIERE-6196.sql') FROM dual;

SET SQLBLANKLINES ON
SET DEFINE OFF

-- Oct 7, 2024, 2:12:19 PM CEST
UPDATE AD_Column SET SeqNoSelection=10,Updated=TO_TIMESTAMP('2024-10-07 14:12:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=10 WHERE AD_Column_ID=50195
;

-- Oct 7, 2024, 2:12:23 PM CEST
UPDATE AD_Column SET SeqNoSelection=20,Updated=TO_TIMESTAMP('2024-10-07 14:12:23','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=10 WHERE AD_Column_ID=50197
;

-- Oct 7, 2024, 2:12:27 PM CEST
UPDATE AD_Column SET SeqNoSelection=30,Updated=TO_TIMESTAMP('2024-10-07 14:12:27','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=10 WHERE AD_Column_ID=50196
;

41 changes: 41 additions & 0 deletions migration/iD11/postgresql/202410031525_IDEMPIERE-4297.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
-- IDEMPIERE-4297 organize dashboard
SELECT register_migration_script('202410031525_IDEMPIERE-4297.sql') FROM dual;

-- Oct 3, 2024, 3:31:34 PM CEST
UPDATE PA_DashboardContent SET ColumnNo=2,Updated=TO_TIMESTAMP('2024-10-03 15:31:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE PA_DashboardContent_ID=200005
;

-- Oct 3, 2024, 3:31:56 PM CEST
UPDATE PA_DashboardContent SET Line=1, ColumnNo=2,Updated=TO_TIMESTAMP('2024-10-03 15:31:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE PA_DashboardContent_ID=200002
;

-- Oct 3, 2024, 3:32:40 PM CEST
UPDATE PA_DashboardContent SET ColumnNo=4,Updated=TO_TIMESTAMP('2024-10-03 15:32:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE PA_DashboardContent_ID=50003
;

-- Oct 3, 2024, 3:32:54 PM CEST
UPDATE PA_DashboardContent SET Line=0, ColumnNo=1,Updated=TO_TIMESTAMP('2024-10-03 15:32:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE PA_DashboardContent_ID=50002
;

-- Oct 3, 2024, 3:33:54 PM CEST
UPDATE PA_DashboardContent SET Line=1, ColumnNo=1,Updated=TO_TIMESTAMP('2024-10-03 15:33:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE PA_DashboardContent_ID=200019
;

-- Oct 3, 2024, 3:34:26 PM CEST
UPDATE PA_DashboardContent SET Line=1, ColumnNo=0,Updated=TO_TIMESTAMP('2024-10-03 15:34:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE PA_DashboardContent_ID=200018
;

-- Oct 3, 2024, 3:34:57 PM CEST
UPDATE PA_DashboardContent SET Line=0, ColumnNo=3,Updated=TO_TIMESTAMP('2024-10-03 15:34:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE PA_DashboardContent_ID=50004
;

-- Oct 3, 2024, 3:55:12 PM CEST
UPDATE AD_StatusLine SET SQLStatement='SELECT
SUM(CASE WHEN EXTRACT(YEAR FROM Dateordered) = EXTRACT(YEAR FROM getdate()) THEN 1 ELSE 0 END) AS total_orders_current_year,
SUM(CASE WHEN EXTRACT(YEAR FROM Dateordered) = 2002 THEN 1 ELSE 0 END) AS total_orders_2002,
SUM(CASE WHEN EXTRACT(YEAR FROM Dateordered) = EXTRACT(YEAR FROM getdate()) THEN 1 ELSE 0 END) -
SUM(CASE WHEN EXTRACT(YEAR FROM Dateordered) = 2002 THEN 1 ELSE 0 END) AS difference
FROM c_order
WHERE issotrx=''Y'' AND ad_client_id= @#AD_Client_ID@',Updated=TO_TIMESTAMP('2024-10-03 15:55:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_StatusLine_ID=200024
;

15 changes: 15 additions & 0 deletions migration/iD11/postgresql/202410071412_IDEMPIERE-6196.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- IDEMPIERE-6196_SysConfig
SELECT register_migration_script('202410071412_IDEMPIERE-6196.sql') FROM dual;

-- Oct 7, 2024, 2:12:19 PM CEST
UPDATE AD_Column SET SeqNoSelection=10,Updated=TO_TIMESTAMP('2024-10-07 14:12:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=10 WHERE AD_Column_ID=50195
;

-- Oct 7, 2024, 2:12:23 PM CEST
UPDATE AD_Column SET SeqNoSelection=20,Updated=TO_TIMESTAMP('2024-10-07 14:12:23','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=10 WHERE AD_Column_ID=50197
;

-- Oct 7, 2024, 2:12:27 PM CEST
UPDATE AD_Column SET SeqNoSelection=30,Updated=TO_TIMESTAMP('2024-10-07 14:12:27','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=10 WHERE AD_Column_ID=50196
;

2 changes: 1 addition & 1 deletion org.adempiere.base/src/org/compiere/acct/Doc.java
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ else if (isPosted())
String AD_MessageValue = "PostingError-" + p_Status;
int AD_User_ID = p_po.getUpdatedBy();
MNote note = new MNote (getCtx(), AD_MessageValue, AD_User_ID,
getAD_Client_ID(), getAD_Org_ID(), p_po.get_TrxName());
getAD_Client_ID(), getAD_Org_ID(), null);
note.setRecord(p_po.get_Table_ID(), p_po.get_ID());
// Reference
note.setReference(toString()); // Document
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class ImageElement extends PrintElement
*/
public static ImageElement get (String imageURLString)
{
if (imageURLString == null)
return null;
Object key = imageURLString;
ImageElement image = (ImageElement)s_cache.get(key);
if (image == null)
Expand Down Expand Up @@ -216,6 +218,8 @@ public ImageElement(int record_ID, boolean isAttachment)
private URL getURL (String urlString)
{
URL url = null;
if (urlString == null)
return null;
// not a URL - may be a resource
if (urlString.indexOf("://") == -1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,37 @@
import java.awt.Color;
import java.awt.Font;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;

import javax.imageio.ImageIO;
import javax.imageio.ImageReader;

import org.adempiere.base.Core;
import org.adempiere.exceptions.AdempiereException;
import org.apache.ecs.MultiPartElement;
import org.apache.ecs.XhtmlDocument;
import org.apache.ecs.xhtml.*;
import org.compiere.model.MAttachment;
import org.compiere.model.MColumn;
import org.compiere.model.MImage;
import org.compiere.model.MQuery;
import org.compiere.model.MRole;
import org.compiere.model.MStyle;
Expand Down Expand Up @@ -73,6 +84,7 @@
import org.compiere.util.Util;
import org.osgi.service.component.annotations.Component;

import com.google.common.io.ByteStreams;
import com.google.common.net.MediaType;
import com.googlecode.htmlcompressor.compressor.HtmlCompressor;

Expand Down Expand Up @@ -631,7 +643,11 @@ else if (obj instanceof PrintDataElement)
if (item.isSuppressNull() && obj != null && suppressMap.containsKey(printColIndex))
suppressMap.remove(printColIndex);

if (pde.getColumnName().endsWith("_ID") && extension != null && !isExport)
if (item.isTypeImage())
{
printImageColumn(td, item, pde);
}
else if (pde.getColumnName().endsWith("_ID") && extension != null && !isExport)
{
boolean isZoom = false;
if (item.getColumnName().equals("Record_ID")) {
Expand Down Expand Up @@ -720,7 +736,9 @@ else if (obj instanceof PrintDataElement)
}
if (cssPrefix != null)
{
if (DisplayType.isNumeric(pde.getDisplayType()))
if (item.isTypeImage())
td.setClass(cssPrefix + "-image");
else if (DisplayType.isNumeric(pde.getDisplayType()))
td.setClass(cssPrefix + "-number");
else if (DisplayType.isDate(pde.getDisplayType()))
td.setClass(cssPrefix + "-date");
Expand All @@ -736,6 +754,116 @@ else if (obj instanceof PrintData)
log.log(Level.SEVERE, "Element not PrintData(Element) " + obj.getClass());
}

private static void printImageColumn(MultiPartElement td, MPrintFormatItem item, PrintDataElement pde) {
if (item.isImageField())
{
Object data = pde.getValue();
if (data != null)
{
if (pde.getDisplayType() == DisplayType.Image)
{
if (data instanceof Number number)
{
int id = number.intValue();
MImage image = MImage.get(id);
byte[] imageData = image.getBinaryData();
createDataURLImageElement(td, imageData, item);
}
}
else
{
String url = data.toString();
// not a URL - may be a resource
if (url.indexOf("://") == -1)
{
ClassLoader cl = HTMLReportRenderer.class.getClassLoader();
URL resource = cl.getResource(url);
if (resource != null)
createDataURLImageElement(td, resource, item);
resource = Core.getResourceFinder().getResource(url);
if (resource != null)
createDataURLImageElement(td, resource, item);
}
else
{
img image = new img(url);
td.addElementToRegistry(image);
applyHeightAndWidth(item, image);
}
}
}
}
else if (item.isImageIsAttached())
{
MAttachment attachment = MAttachment.get(Env.getCtx(), MPrintFormatItem.Table_ID, item.get_ID(), null, null);
if (attachment != null)
{
if (attachment.getEntryCount() != 1)
{
log.log(Level.WARNING, "Need just 1 Attachment Entry = " + attachment.getEntryCount());
return;
}
byte[] imageData = attachment.getEntryData(0);
createDataURLImageElement(td, imageData, item);
}
}
else if (!Util.isEmpty(item.getImageURL(), true))
{
img image = new img(item.getImageURL());
td.addElementToRegistry(image);
applyHeightAndWidth(item, image);
}
}

private static void applyHeightAndWidth(MPrintFormatItem item, img image) {
StringBuilder style = new StringBuilder();
if (item.getMaxHeight() > 0)
style.append("height:").append(item.getMaxHeight()).append("px;");
if (item.getMaxWidth() > 0)
style.append("width:").append(item.getMaxWidth()).append("px;");
if (style.length() > 0)
image.setStyle(style.toString());
}

private static void createDataURLImageElement(MultiPartElement td, URL url, MPrintFormatItem item) {
byte[] imageData = null;
try {
imageData = ByteStreams.toByteArray(url.openStream());
createDataURLImageElement(td, imageData, item);
} catch (IOException e) {
log.log(Level.WARNING, e.getLocalizedMessage(), e);
}
}

private static void createDataURLImageElement(MultiPartElement td, byte[] imageData, MPrintFormatItem item) {
String contentType = null;
Iterator<ImageReader> readers = null;
try {
readers = ImageIO.getImageReaders(ImageIO.createImageInputStream(new ByteArrayInputStream(imageData)));
} catch (IOException e) {
log.log(Level.WARNING, e.getLocalizedMessage(), e);
return;
}
while(readers.hasNext()) {
ImageReader reader = readers.next();
try {
contentType = reader.getFormatName();
if (!Util.isEmpty(contentType))
break;
} catch (IOException e) {
}
}
if (contentType != null) {
StringBuilder builder = new StringBuilder("data:")
.append(contentType)
.append(";base64,");
builder.append(Base64.getEncoder().encodeToString(imageData));
img image = new img(builder.toString());
td.addElementToRegistry(image);
applyHeightAndWidth(item, image);
}
}

/**
* Compress html content
* @param src
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.adempiere.webui.dashboard;

import org.adempiere.webui.panel.MenuTreePanel;
import org.adempiere.webui.util.ZKUpdateUtil;

/**
* Dashboard gadget: Menu Tree
Expand All @@ -37,6 +38,7 @@ public DPMenuTree()
super();

menuTreePanel = new MenuTreePanel(this);
ZKUpdateUtil.setHeight(this, "100%");
}

/**
Expand Down
Loading

0 comments on commit a53f4f6

Please sign in to comment.