Merge 62bf3c7d8f22

This commit is contained in:
Heng Sin Low 2013-06-20 12:09:06 +08:00
commit 1993840bdc
16 changed files with 390 additions and 49 deletions

View File

@ -258,7 +258,20 @@ public class InvoiceNGL extends SvrProcess
continue;
MInvoice invoice = new MInvoice(getCtx(), gl.getC_Invoice_ID(), null);
if (invoice.getC_Currency_ID() == as.getC_Currency_ID())
continue;
continue;
//
if (AD_Org_ID == 0) // invoice org id
AD_Org_ID = gl.getAD_Org_ID();
// Change in Org
if (AD_Org_ID != gl.getAD_Org_ID())
{
createBalancing (asDefaultAccts, journal, drTotal, crTotal, AD_Org_ID, (i+1) * 10);
//
AD_Org_ID = gl.getAD_Org_ID();
drTotal = Env.ZERO;
crTotal = Env.ZERO;
journal = null;
}
//
if (journal == null)
{
@ -288,19 +301,6 @@ public class InvoiceNGL extends SvrProcess
line.setAmtSourceCr (cr);
line.setAmtAcctCr (cr);
line.saveEx();
//
if (AD_Org_ID == 0) // invoice org id
AD_Org_ID = gl.getAD_Org_ID();
// Change in Org
if (AD_Org_ID != gl.getAD_Org_ID())
{
createBalancing (asDefaultAccts, journal, drTotal, crTotal, AD_Org_ID, (i+1) * 10);
//
AD_Org_ID = gl.getAD_Org_ID();
drTotal = Env.ZERO;
crTotal = Env.ZERO;
journal = null;
}
}
createBalancing (asDefaultAccts, journal, drTotal, crTotal, AD_Org_ID, (list.size()+1) * 10);

View File

@ -634,10 +634,11 @@ public class MLookupFactory
}
StringBuilder embedSQL = new StringBuilder("SELECT ");
boolean translated = false;
// Translated
if (IsTranslated && !Env.isBaseLanguage(language, TableName))
{
translated = true;
if (isValueDisplayed)
embedSQL.append(TableNameAlias).append(".Value||'-'||");
embedSQL.append(TableName).append("_Trl.").append(DisplayColumn);
@ -660,16 +661,19 @@ public class MLookupFactory
}
embedSQL.append(" WHERE ");
int Column_ID = MColumn.getColumn_ID(BaseTable, BaseColumn);
MColumn column = MColumn.get(Env.getCtx(), Column_ID);
// If is not virtual column - teo_sarca [ 1739530 ]
if (! BaseColumn.trim().startsWith("("))
if (!column.isVirtualColumn())
{
embedSQL.append(BaseTable).append(".").append(BaseColumn);
embedSQL.append("=").append(TableNameAlias).append(".").append(KeyColumn);
} else if (translated) {
embedSQL.append(TableNameAlias).append(".").append(BaseColumn).append("=").append(column.getColumnSQL());
} else {
embedSQL.append(BaseColumn).append("=").append(column.getColumnSQL());
}
else
{
embedSQL.append(BaseColumn);
}
embedSQL.append("=").append(TableNameAlias).append(".").append(KeyColumn);
return embedSQL.toString();
} // getLookup_TableEmbed
@ -772,7 +776,14 @@ public class MLookupFactory
return lInfo;
} // getLookup_TableDir
private static StringBuilder getDisplayColumn(Language language, String TableName, ArrayList<LookupDisplayColumn> list) {
private static StringBuilder getDisplayColumn(Language language,
String tableName, ArrayList<LookupDisplayColumn> list) {
return getDisplayColumn(language, tableName, list, null);
}
private static StringBuilder getDisplayColumn(Language language,
String TableName, ArrayList<LookupDisplayColumn> list,
String baseTable) {
StringBuilder displayColumn = new StringBuilder();
int size = list.size();
// Get Display Column
@ -787,7 +798,8 @@ public class MLookupFactory
displayColumn.append("NVL(");
// translated
if (ldc.IsTranslated && !Env.isBaseLanguage(language, TableName) && !ldc.IsVirtual)
if (ldc.IsTranslated && !Env.isBaseLanguage(language, TableName) && !ldc.IsVirtual
&& baseTable != null && !(TableName+"_Trl").equalsIgnoreCase(baseTable))
{
displayColumn.append(TableName).append("_Trl.").append(ldc.ColumnName);
}
@ -886,11 +898,12 @@ public class MLookupFactory
//
StringBuilder embedSQL = new StringBuilder("SELECT ");
StringBuilder displayColumn = getDisplayColumn(language, TableName, list);
StringBuilder displayColumn = getDisplayColumn(language, TableName, list, BaseTable);
embedSQL.append(displayColumn.toString());
embedSQL.append(" FROM ").append(TableName);
// Translation
if (isTranslated && !Env.isBaseLanguage(language, TableName))
if ( isTranslated && !Env.isBaseLanguage(language, TableName)
&& !(TableName+"_Trl").equalsIgnoreCase(BaseTable)) // IDEMPIERE-1070
{
embedSQL.append(" INNER JOIN ").append(TableName).append("_TRL ON (")
.append(TableName).append(".").append(KeyColumn)

View File

@ -424,6 +424,7 @@ public class MMatchPO extends X_M_MatchPO
matchInv.setM_AttributeSetInstance_ID(mpo.getM_AttributeSetInstance_ID());
matchInv.setQty(mpo.getQty());
matchInv.setDateTrx(dateTrx);
matchInv.setProcessed(true);
if (!matchInv.save())
{
if (savepoint != null)

View File

@ -54,7 +54,7 @@ public class MSequence extends X_AD_Sequence
/**
*
*/
private static final long serialVersionUID = -631878634759124313L;
private static final long serialVersionUID = 7331047665037991960L;
/** Log Level for Next ID Call */
private static final Level LOGLEVEL = Level.ALL;
@ -323,7 +323,7 @@ public class MSequence extends X_AD_Sequence
return getDocumentNoFromSeq(seq, trxName, po);
} // getDocumentNo
private static String getDocumentNoFromSeq(MSequence seq, String trxName, PO po) {
public static String getDocumentNoFromSeq(MSequence seq, String trxName, PO po) {
// Check AdempiereSys
boolean adempiereSys = false;
if (Ini.isClient())

View File

@ -406,6 +406,7 @@ public class DataEngine
.append(lookupSQL).append(" AS ").append(ColumnName).append(",");
groupByColumns.add(m_synonym+display);
groupByColumns.add(lookupSQL);
orderName = m_synonym + display;
//
TableReference tr = getTableReference(AD_Reference_Value_ID);
String foreignColumnName = tr.KeyColumn;

View File

@ -30,6 +30,7 @@ import org.compiere.model.POInfo;
/**
* Template for DocAction
*
* Instead of modifying DocumentEngine, you could simply extend DocOptions interface and use customizeValidActions
* @author Jorg Janke
* @version $Id: DocActionTemplate.java,v 1.3 2006/07/30 00:54:44 jjanke Exp $
*/
@ -427,5 +428,5 @@ public class DocActionTemplate extends PO implements DocAction
{
return false;
}
} // DocActionTemplate

View File

@ -36,13 +36,23 @@ Export-Package: .,
net.sf.jasperreports.components.headertoolbar,
net.sf.jasperreports.components.headertoolbar.actions,
net.sf.jasperreports.components.headertoolbar.htmlv2,
net.sf.jasperreports.components.headertoolbar.htmlv2.resources,
net.sf.jasperreports.components.headertoolbar.resources,
net.sf.jasperreports.components.headertoolbar.resources.images,
net.sf.jasperreports.components.headertoolbar.resources.images.format,
net.sf.jasperreports.components.headertoolbar.resources.images.jive,
net.sf.jasperreports.components.headertoolbar.resources.images.style,
net.sf.jasperreports.components.iconlabel,
net.sf.jasperreports.components.list,
net.sf.jasperreports.components.map,
net.sf.jasperreports.components.map.fill,
net.sf.jasperreports.components.map.resources,
net.sf.jasperreports.components.map.resources.templates,
net.sf.jasperreports.components.map.type,
net.sf.jasperreports.components.sort,
net.sf.jasperreports.components.sort.actions,
net.sf.jasperreports.components.sort.resources,
net.sf.jasperreports.components.sort.resources.images,
net.sf.jasperreports.components.spiderchart,
net.sf.jasperreports.components.spiderchart.type,
net.sf.jasperreports.components.table,
@ -83,18 +93,29 @@ Export-Package: .,
net.sf.jasperreports.engine.data,
net.sf.jasperreports.engine.design,
net.sf.jasperreports.engine.design.events,
net.sf.jasperreports.engine.dtds,
net.sf.jasperreports.engine.export,
net.sf.jasperreports.engine.export.data,
net.sf.jasperreports.engine.export.draw,
net.sf.jasperreports.engine.export.legacy,
net.sf.jasperreports.engine.export.oasis,
net.sf.jasperreports.engine.export.ooxml,
net.sf.jasperreports.engine.export.ooxml.docx,
net.sf.jasperreports.engine.export.ooxml.docx._rels,
net.sf.jasperreports.engine.export.ooxml.pptx._rels,
net.sf.jasperreports.engine.export.ooxml.pptx.ppt.slideLayouts,
net.sf.jasperreports.engine.export.ooxml.pptx.ppt.slideLayouts._rels,
net.sf.jasperreports.engine.export.ooxml.pptx.ppt.slideMasters,
net.sf.jasperreports.engine.export.ooxml.pptx.ppt.slideMasters._rels,
net.sf.jasperreports.engine.export.ooxml.pptx.ppt.theme,
net.sf.jasperreports.engine.export.ooxml.type,
net.sf.jasperreports.engine.export.ooxml.xlsx._rels,
net.sf.jasperreports.engine.export.tabulator,
net.sf.jasperreports.engine.export.type,
net.sf.jasperreports.engine.export.zip,
net.sf.jasperreports.engine.fill,
net.sf.jasperreports.engine.fonts,
net.sf.jasperreports.engine.images,
net.sf.jasperreports.engine.print,
net.sf.jasperreports.engine.query,
net.sf.jasperreports.engine.scriptlets,
@ -106,6 +127,8 @@ Export-Package: .,
net.sf.jasperreports.engine.xml,
net.sf.jasperreports.expressions,
net.sf.jasperreports.extensions,
net.sf.jasperreports.fonts,
net.sf.jasperreports.fonts.dejavu,
net.sf.jasperreports.functions,
net.sf.jasperreports.functions.annotations,
net.sf.jasperreports.governors,
@ -128,6 +151,9 @@ Export-Package: .,
net.sf.jasperreports.web.commands,
net.sf.jasperreports.web.listeners,
net.sf.jasperreports.web.servlets,
net.sf.jasperreports.web.servlets.resources,
net.sf.jasperreports.web.servlets.resources.templates,
net.sf.jasperreports.web.servlets.resources.viewer,
net.sf.jasperreports.web.util,
org.apache.bcel,
org.apache.bcel.classfile,

View File

@ -414,15 +414,18 @@ public class ReportStarter implements ProcessCall, ClientProcess
String jasperName = data.getJasperName();
String name = jasperReport.getName();
File reportDir = data.getReportDir();
String resourcePath = reportDir.getAbsolutePath();
String reportdir = reportPath.substring(0, reportPath.lastIndexOf("/"));
if (!resourcePath.endsWith("/") && !resourcePath.endsWith("\\"));
{
resourcePath = resourcePath + "/";
reportdir = reportdir + "/";
}
params.put("SUBREPORT_DIR", resourcePath);
params.put("RESOURCE_DIR", resourcePath);
params.put("REPORT_DIR", reportdir);
if (jasperReport != null && pi.getTable_ID() > 0 && Record_ID <= 0 && pi.getRecord_IDs() != null && pi.getRecord_IDs().length > 0)
{
try

View File

@ -4,7 +4,8 @@ echo Adempiere Full Database Export $Revision: 1.3 $
# $Id: DBExportFull.sh,v 1.3 2005/01/22 21:59:15 jjanke Exp $
echo Saving database $1@$ADEMPIERE_DB_NAME to $IDEMPIERE_HOME/data/ExpDatFull.dmp
DATE=`date +%Y%m%d_%H%M%S`
echo Saving database $1@$ADEMPIERE_DB_NAME to $IDEMPIERE_HOME/data/ExpDatFull_$DATE.dmp
if [ $# -eq 0 ]
then
@ -27,8 +28,8 @@ sqlplus $1@$ADEMPIERE_DB_SERVER/$ADEMPIERE_DB_NAME @$IDEMPIERE_HOME/utils/$ADEMP
chgrp dba $IDEMPIERE_HOME/data
chmod 770 $IDEMPIERE_HOME/data
expdp $1@$ADEMPIERE_DB_SERVER:$ADEMPIERE_DB_PORT/$ADEMPIERE_DB_NAME DIRECTORY=ADEMPIERE_DATA_PUMP_DIR DUMPFILE=ExpDatFull.dmp LOGFILE=ExpDatFull.log EXCLUDE=STATISTICS FULL=Y
expdp $1@$ADEMPIERE_DB_SERVER:$ADEMPIERE_DB_PORT/$ADEMPIERE_DB_NAME DIRECTORY=ADEMPIERE_DATA_PUMP_DIR DUMPFILE=ExpDatFull_$DATE.dmp LOGFILE=ExpDatFull_$DATE.log EXCLUDE=STATISTICS FULL=Y
cd $IDEMPIERE_HOME/data
jar cvfM ExpDatFull.jar ExpDatFull.dmp ExpDatFull.log
jar cvfM ExpDatFull.jar ExpDatFull_$DATE.dmp ExpDatFull_$DATE.log

View File

@ -4,7 +4,8 @@ echo Adempiere Database Export $Revision: 1.5 $
# $Id: DBExport.sh,v 1.5 2005/12/20 07:12:17 jjanke Exp $
echo Saving database $1@$ADEMPIERE_DB_NAME to $IDEMPIERE_HOME/data/ExpDat.dmp
DATE=`date +%Y%m%d_%H%M%S`
echo Saving database $1@$ADEMPIERE_DB_NAME to $IDEMPIERE_HOME/data/ExpDat_$DATE.dmp
if [ $# -eq 0 ]
then
@ -31,7 +32,7 @@ chgrp dba $IDEMPIERE_HOME/data
chmod 770 $IDEMPIERE_HOME/data
# Export
expdp $1/$2@$ADEMPIERE_DB_SERVER:$ADEMPIERE_DB_PORT/$ADEMPIERE_DB_NAME DIRECTORY=ADEMPIERE_DATA_PUMP_DIR DUMPFILE=ExpDat.dmp LOGFILE=ExpDat.log EXCLUDE=STATISTICS SCHEMAS=$1
expdp $1/$2@$ADEMPIERE_DB_SERVER:$ADEMPIERE_DB_PORT/$ADEMPIERE_DB_NAME DIRECTORY=ADEMPIERE_DATA_PUMP_DIR DUMPFILE=ExpDat_$DATE.dmp LOGFILE=ExpDat_$DATE.log EXCLUDE=STATISTICS SCHEMAS=$1
cd $IDEMPIERE_HOME/data
jar cvfM ExpDat.jar ExpDat.dmp ExpDat.log
jar cvfM ExpDat.jar ExpDat_$DATE.dmp ExpDat_$DATE.log

View File

@ -1,8 +1,8 @@
@Echo Adempiere Full Database Export $Revision: 1.6 $
@Rem $Id: DBExportFull.bat,v 1.6 2005/04/27 17:45:01 jjanke Exp $
@Echo Saving database %1@%ADEMPIERE_DB_NAME% to %IDEMPIERE_HOME%\data\ExpDatFull.dmp
@set Date=%date:~6,4%%date:~3,2%%date:~0,2%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%
@Echo Saving database %1@%ADEMPIERE_DB_NAME% to %IDEMPIERE_HOME%\data\ExpDatFull_%Date%.dmp
@if (%IDEMPIERE_HOME%) == () goto environment
@if (%ADEMPIERE_DB_NAME%) == () goto environment
@ -16,10 +16,10 @@
@echo -------------------------------------
@sqlplus %1@%ADEMPIERE_DB_SERVER%:%ADEMPIERE_DB_PORT%/%ADEMPIERE_DB_NAME% @%IDEMPIERE_HOME%\utils\%ADEMPIERE_DB_PATH%\CreateDataPumpDir.sql %IDEMPIERE_HOME%\data
@expdp %1@%ADEMPIERE_DB_SERVER%:%ADEMPIERE_DB_PORT%/%ADEMPIERE_DB_NAME% DIRECTORY=ADEMPIERE_DATA_PUMP_DIR DUMPFILE=ExpDatFull.dmp LOGFILE=ExpDatFull.log EXCLUDE=STATISTICS FULL=Y
@expdp %1@%ADEMPIERE_DB_SERVER%:%ADEMPIERE_DB_PORT%/%ADEMPIERE_DB_NAME% DIRECTORY=ADEMPIERE_DATA_PUMP_DIR DUMPFILE=ExpDatFull_%Date%.dmp LOGFILE=ExpDatFull_%Date%.log EXCLUDE=STATISTICS FULL=Y
@cd %IDEMPIERE_HOME%\data
@jar cvfM data\ExpDatFull.jar ExpDatFull.dmp ExpDatFull.log
@jar cvfM data\ExpDatFull.jar ExpDatFull_%Date%.dmp ExpDatFull_%Date%.log
@goto end

View File

@ -2,7 +2,8 @@
@Rem $Id: DBExport.bat,v 1.8 2005/04/27 17:45:01 jjanke Exp $
@Rem
@Echo Saving database %1@%ADEMPIERE_DB_NAME% to %IDEMPIERE_HOME%\data\ExpDat.dmp
@set Date=%date:~6,4%%date:~3,2%%date:~0,2%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%
@Echo Saving database %1@%ADEMPIERE_DB_NAME% to %IDEMPIERE_HOME%\data\ExpDat_%Date%.dmp
@if (%IDEMPIERE_HOME%) == () goto environment
@if (%ADEMPIERE_DB_NAME%) == () goto environment
@ -20,11 +21,10 @@
@sqlplus %3@%ADEMPIERE_DB_SERVER%:%ADEMPIERE_DB_PORT%/%ADEMPIERE_DB_NAME% @%IDEMPIERE_HOME%\utils\%ADEMPIERE_DB_PATH%\CreateDataPumpDir.sql %IDEMPIERE_HOME%\data
@Rem The Export
@expdp %1/%2@%ADEMPIERE_DB_SERVER%:%ADEMPIERE_DB_PORT%/%ADEMPIERE_DB_NAME% DIRECTORY=ADEMPIERE_DATA_PUMP_DIR DUMPFILE=ExpDat.dmp LOGFILE=ExpDat.log EXCLUDE=STATISTICS SCHEMAS=%1
@expdp %1/%2@%ADEMPIERE_DB_SERVER%:%ADEMPIERE_DB_PORT%/%ADEMPIERE_DB_NAME% DIRECTORY=ADEMPIERE_DATA_PUMP_DIR DUMPFILE=ExpDat_%Date%.dmp LOGFILE=ExpDat_%Date%.log EXCLUDE=STATISTICS SCHEMAS=%1
@cd %IDEMPIERE_HOME%\Data
@copy ExpDat.jar ExpDatOld.jar
@jar cvfM ExpDat.jar ExpDat.dmp ExpDat.log
@jar cvfM ExpDat.jar ExpDat_%Date%.dmp ExpDat_%Date%.log
@goto end

View File

@ -103,7 +103,7 @@ public class DefaultEditorFactory implements IEditorFactory {
}
/** Text */
else if (displayType == DisplayType.Text || displayType == DisplayType.Memo || displayType == DisplayType.TextLong)
else if (displayType == DisplayType.Text || displayType == DisplayType.Memo || displayType == DisplayType.TextLong || displayType == DisplayType.ID)
{
editor = new WStringEditor(gridField, tableEditor);
}
@ -127,8 +127,7 @@ public class DefaultEditorFactory implements IEditorFactory {
/** Table Direct */
else if (displayType == DisplayType.TableDir ||
displayType == DisplayType.Table || displayType == DisplayType.List
|| displayType == DisplayType.ID )
displayType == DisplayType.Table || displayType == DisplayType.List)
{
editor = new WTableDirEditor(gridField);
}

View File

@ -0,0 +1,285 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. 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., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.adempiere.webui.process;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.window.SimplePDFViewer;
import org.compiere.model.MBPartner;
import org.compiere.model.MClient;
import org.compiere.model.MDunningLevel;
import org.compiere.model.MDunningRun;
import org.compiere.model.MDunningRunEntry;
import org.compiere.model.MMailText;
import org.compiere.model.MQuery;
import org.compiere.model.MUser;
import org.compiere.model.MUserMail;
import org.compiere.model.PrintInfo;
import org.compiere.print.MPrintFormat;
import org.compiere.print.ReportEngine;
import org.compiere.process.ProcessInfoParameter;
import org.compiere.process.SvrProcess;
import org.compiere.util.AdempiereUserError;
import org.compiere.util.EMail;
/**
* Dunning Letter Print
*
* @author Jorg Janke
* @version $Id: DunningPrint.java,v 1.2 2006/07/30 00:51:02 jjanke Exp $
*
* FR 2872010 - Dunning Run for a complete Dunning (not just level) - Developer: Carlos Ruiz - globalqss - Sponsor: Metas
*/
public class DunningPrint extends SvrProcess
{
/** Mail PDF */
private boolean p_EMailPDF = false;
/** Mail Template */
private int p_R_MailText_ID = 0;
/** Dunning Run */
private int p_C_DunningRun_ID = 0;
/** Print only Outstanding */
private boolean p_IsOnlyIfBPBalance = true;
/** Print only unprocessed lines */
private boolean p_PrintUnprocessedOnly = true;
/**
* Prepare - e.g., get Parameters.
*/
protected void prepare()
{
ProcessInfoParameter[] para = getParameter();
for (int i = 0; i < para.length; i++)
{
String name = para[i].getParameterName();
if (para[i].getParameter() == null)
;
else if (name.equals("EMailPDF"))
p_EMailPDF = "Y".equals(para[i].getParameter());
else if (name.equals("R_MailText_ID"))
p_R_MailText_ID = para[i].getParameterAsInt();
else if (name.equals("C_DunningRun_ID"))
p_C_DunningRun_ID = para[i].getParameterAsInt();
else if (name.equals("IsOnlyIfBPBalance"))
p_IsOnlyIfBPBalance = "Y".equals(para[i].getParameter());
else if (name.equals("PrintUnprocessedOnly"))
p_PrintUnprocessedOnly = "Y".equals(para[i].getParameter());
else
log.log(Level.SEVERE, "Unknown Parameter: " + name);
}
} // prepare
/**
* Process
* @return info
* @throws Exception
*/
protected String doIt () throws Exception
{
if (log.isLoggable(Level.INFO)) log.info("C_DunningRun_ID=" + p_C_DunningRun_ID + ",R_MailText_ID=" + p_R_MailText_ID
+ ", EmailPDF=" + p_EMailPDF + ",IsOnlyIfBPBalance=" + p_IsOnlyIfBPBalance
+ ",PrintUnprocessedOnly=" + p_PrintUnprocessedOnly);
// Need to have Template
if (p_EMailPDF && p_R_MailText_ID == 0)
throw new AdempiereUserError ("@NotFound@: @R_MailText_ID@");
// String subject = "";
MMailText mText = null;
if (p_EMailPDF)
{
mText = new MMailText (getCtx(), p_R_MailText_ID, get_TrxName());
if (p_EMailPDF && mText.get_ID() == 0)
throw new AdempiereUserError ("@NotFound@: @R_MailText_ID@ - " + p_R_MailText_ID);
// subject = mText.getMailHeader();
}
//
MDunningRun run = new MDunningRun (getCtx(), p_C_DunningRun_ID, get_TrxName());
if (run.get_ID() == 0)
throw new AdempiereUserError ("@NotFound@: @C_DunningRun_ID@ - " + p_C_DunningRun_ID);
MClient client = MClient.get(getCtx());
int count = 0;
int errors = 0;
MDunningRunEntry[] entries = run.getEntries(false);
List<File> pdfList = new ArrayList<File>();
for (int i = 0; i < entries.length; i++)
{
MDunningRunEntry entry = entries[i];
// Print Format on Dunning Level
MDunningLevel level = new MDunningLevel (getCtx(), entry.getC_DunningLevel_ID(), get_TrxName());
MPrintFormat format = null;
if (level.getDunning_PrintFormat_ID() > 0)
format = MPrintFormat.get (getCtx(), level.getDunning_PrintFormat_ID(), false);
if (p_IsOnlyIfBPBalance && entry.getAmt().signum() <= 0)
continue;
if (p_PrintUnprocessedOnly && entry.isProcessed())
continue;
// To BPartner
MBPartner bp = new MBPartner (getCtx(), entry.getC_BPartner_ID(), get_TrxName());
if (bp.get_ID() == 0)
{
StringBuilder msglog = new StringBuilder("@NotFound@: @C_BPartner_ID@ ").append(entry.getC_BPartner_ID());
addLog (entry.get_ID(), null, null,msglog.toString() );
errors++;
continue;
}
// To User
MUser to = new MUser (getCtx(), entry.getAD_User_ID(), get_TrxName());
if (p_EMailPDF)
{
if (to.get_ID() == 0)
{
StringBuilder msglog = new StringBuilder("@NotFound@: @AD_User_ID@ - ").append(bp.getName());
addLog (entry.get_ID(), null, null,msglog.toString());
errors++;
continue;
}
else if (to.getEMail() == null || to.getEMail().length() == 0)
{
StringBuilder msglog = new StringBuilder("@NotFound@: @EMail@ - ").append(to.getName());
addLog (entry.get_ID(), null, null, msglog.toString());
errors++;
continue;
}
}
// query
MQuery query = new MQuery("C_Dunning_Header_v");
query.addRestriction("C_DunningRunEntry_ID", MQuery.EQUAL,
new Integer(entry.getC_DunningRunEntry_ID()));
// Engine
PrintInfo info = new PrintInfo(
bp.getName(),
MDunningRunEntry.Table_ID,
entry.getC_DunningRunEntry_ID(),
entry.getC_BPartner_ID());
StringBuilder msginfo = new StringBuilder().append(bp.getName()).append(", Amt=").append(entry.getAmt());
info.setDescription(msginfo.toString());
ReportEngine re = null;
if (format != null)
re = new ReportEngine(getCtx(), format, query, info);
boolean printed = false;
if (p_EMailPDF)
{
EMail email = client.createEMail(to.getEMail(), null, null);
if (!email.isValid())
{
StringBuilder msglog = new StringBuilder(
"@RequestActionEMailError@ Invalid EMail: ").append(to);
addLog (entry.get_ID(), null, null,msglog.toString() );
errors++;
continue;
}
mText.setUser(to); // variable context
mText.setBPartner(bp);
mText.setPO(entry);
String message = mText.getMailText(true);
if (mText.isHtml())
email.setMessageHTML(mText.getMailHeader(), message);
else
{
email.setSubject (mText.getMailHeader());
email.setMessageText (message);
}
//
if (re != null) {
File attachment = re.getPDF(File.createTempFile("Dunning", ".pdf"));
StringBuilder msglog = new StringBuilder().append(to.toString()).append(" - ").append(attachment);
if (log.isLoggable(Level.FINE)) log.fine(msglog.toString());
email.addAttachment(attachment);
}
//
String msg = email.send();
MUserMail um = new MUserMail(mText, entry.getAD_User_ID(), email);
um.saveEx();
if (msg.equals(EMail.SENT_OK))
{
StringBuilder msglog = new StringBuilder()
.append(bp.getName()).append(" @RequestActionEMailOK@");
addLog (entry.get_ID(), null, null,msglog.toString());
count++;
printed = true;
}
else
{
StringBuilder msglog = new StringBuilder().append(bp.getName()).append(" @RequestActionEMailError@ ").append(msg);
addLog (entry.get_ID(), null, null,msglog.toString() );
errors++;
}
}
else
{
if (re != null) {
pdfList.add(re.getPDF());
count++;
printed = true;
}
}
if (printed)
{
entry.setProcessed (true);
entry.save ();
}
} // for all dunning letters
if (errors==0) {
run.setProcessed(true);
run.saveEx();
}
if (p_EMailPDF){
StringBuilder msgreturn = new StringBuilder("@Sent@=").append(count).append(" - @Errors@=").append(errors);
return msgreturn.toString();
}
if (pdfList.size() > 1) {
try {
File outFile = File.createTempFile("DunningPrint", ".pdf");
AEnv.mergePdf(pdfList, outFile);
Window win = new SimplePDFViewer(this.getName(), new FileInputStream(outFile));
win.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
SessionManager.getAppDesktop().showWindow(win, "center");
} catch (Exception e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
} else if (pdfList.size() > 0) {
try {
Window win = new SimplePDFViewer(this.getName(), new FileInputStream(pdfList.get(0)));
win.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
SessionManager.getAppDesktop().showWindow(win, "center");
} catch (Exception e)
{
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
}
StringBuilder msgreturn = new StringBuilder("@Printed@=").append(count);
return msgreturn.toString();
} // doIt
} // DunningPrint

View File

@ -102,6 +102,7 @@ import org.zkoss.zul.Comboitem;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Div;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Space;
import org.zkoss.zul.Tab;
@ -119,7 +120,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
/**
*
*/
private static final long serialVersionUID = 2452116093966974927L;
private static final long serialVersionUID = -5019862772740854656L;
// values and label for history combo
private static final String HISTORY_DAY_ALL = "All";
@ -471,11 +472,19 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
listhead.appendChild(lstHRightBracket);
advancedPanel.appendChild(listhead);
advancedPanel.setVflex(true);
Borderlayout layout = new Borderlayout();
layout.setHflex("1");
layout.setVflex("1");
winAdvanced.appendChild(layout);
North north =new North();
layout.appendChild(north);
north.appendChild(toolBar);
toolBar.setVflex("0");
Center center = new Center();
layout.appendChild(center);

View File

@ -30,7 +30,8 @@ bin.includes = META-INF/,\
WEB-INF/lib/atmosphere-runtime-1.0.4.jar,\
OSGI-INF/defaultcreatefromfactory.xml,\
OSGI-INF/defaultformfactory.xml,\
OSGI-INF/feedbackservice.xml
OSGI-INF/feedbackservice.xml,\
sessiontimeout.zul
src.includes = WEB-INF/classes/,\
WEB-INF/tld/,\
WEB-INF/web.xml,\