hg merge release-3.1 (merge release3.1 into development)

This commit is contained in:
Carlos Ruiz 2016-09-03 20:54:17 +02:00
commit 2f05d731c1
33 changed files with 331 additions and 190 deletions

View File

@ -0,0 +1,10 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Jun 6, 2016 10:53:34 AM SGT
-- IDEMPIERE-2668 Exclude Locators for Demand Operations
UPDATE AD_Field SET IsMandatory='Y',Updated=TO_DATE('2016-06-06 10:53:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200649
;
SELECT register_migration_script('201606061100_IDEMPIERE-2668.sql') FROM dual
;

View File

@ -0,0 +1,10 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
-- Aug 15, 2016 10:12:48 AM BRT
UPDATE AD_Column SET IsAllowCopy='N',Updated=TO_DATE('2016-08-15 10:12:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3075
;
SELECT register_migration_script('20160815103455_IDEMPIERE-3158.sql') FROM dual
;

View File

@ -0,0 +1,27 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-3171 Can't add record on POS Terminal, IDEMPIERE-170
-- Sep 3, 2016 2:31:03 PM GMT+01:00
UPDATE AD_Field SET IsDisplayed='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsDisplayedGrid='N', IsToolbarButton=NULL,Updated=TO_DATE('2016-09-03 14:31:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10802
;
-- Sep 3, 2016 2:31:33 PM GMT+01:00
UPDATE AD_Column SET IsMandatory='N',Updated=TO_DATE('2016-09-03 14:31:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=12750
;
-- Sep 3, 2016 2:31:40 PM GMT+01:00
UPDATE AD_Field SET DefaultValue='-1', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2016-09-03 14:31:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10802
;
-- Sep 3, 2016 2:39:09 PM GMT+01:00
ALTER TABLE C_POS MODIFY C_CashBook_ID NUMBER(10) DEFAULT NULL
;
-- Sep 3, 2016 2:39:09 PM GMT+01:00
ALTER TABLE C_POS MODIFY C_CashBook_ID NULL
;
SELECT register_migration_script('201609031532_IDEMPIERE-3171.sql') FROM dual
;

View File

@ -0,0 +1,11 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-3173 Columns that must not be copied
-- Sep 3, 2016 2:45:57 PM GMT+01:00
UPDATE AD_Column SET IsAllowCopy='N',Updated=TO_DATE('2016-09-03 14:45:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2925
;
SELECT register_migration_script('201609031546_IDEMPIERE-3173.sql') FROM dual
;

View File

@ -0,0 +1,15 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-2676 Incorrect context variables - onNavigate Callout
-- Sep 3, 2016 3:07:56 PM GMT+01:00
UPDATE AD_Column SET Callout='org.compiere.model.CalloutOrder.priceListReadOnly', IsUpdateable='N',Updated=TO_DATE('2016-09-03 15:07:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2161
;
-- Sep 3, 2016 3:08:09 PM GMT+01:00
UPDATE AD_Column SET Callout='org.compiere.model.CalloutOrder.priceListReadOnly', IsUpdateable='N',Updated=TO_DATE('2016-09-03 15:08:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3484
;
SELECT register_migration_script('201609031608_IDEMPIERE-2676.sql') FROM dual
;

View File

@ -0,0 +1,7 @@
-- Jun 6, 2016 10:53:34 AM SGT
-- IDEMPIERE-2668 Exclude Locators for Demand Operations
UPDATE AD_Field SET IsMandatory='Y',Updated=TO_TIMESTAMP('2016-06-06 10:53:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200649
;
SELECT register_migration_script('201606061100_IDEMPIERE-2668.sql') FROM dual
;

View File

@ -0,0 +1,7 @@
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
-- Aug 15, 2016 10:12:48 AM BRT
UPDATE AD_Column SET IsAllowCopy='N',Updated=TO_TIMESTAMP('2016-08-15 10:12:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3075
;
SELECT register_migration_script('20160815103455_IDEMPIERE-3158.sql') FROM dual
;

View File

@ -0,0 +1,24 @@
-- IDEMPIERE-3171 Can't add record on POS Terminal, IDEMPIERE-170
-- Sep 3, 2016 2:31:03 PM GMT+01:00
UPDATE AD_Field SET IsDisplayed='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsDisplayedGrid='N', IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2016-09-03 14:31:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10802
;
-- Sep 3, 2016 2:31:33 PM GMT+01:00
UPDATE AD_Column SET IsMandatory='N',Updated=TO_TIMESTAMP('2016-09-03 14:31:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=12750
;
-- Sep 3, 2016 2:31:40 PM GMT+01:00
UPDATE AD_Field SET DefaultValue='-1', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2016-09-03 14:31:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10802
;
-- Sep 3, 2016 2:39:09 PM GMT+01:00
INSERT INTO t_alter_column values('c_pos','C_CashBook_ID','NUMERIC(10)',null,'NULL')
;
-- Sep 3, 2016 2:39:09 PM GMT+01:00
INSERT INTO t_alter_column values('c_pos','C_CashBook_ID',null,'NULL',null)
;
SELECT register_migration_script('201609031532_IDEMPIERE-3171.sql') FROM dual
;

View File

@ -0,0 +1,8 @@
-- IDEMPIERE-3173 Columns that must not be copied
-- Sep 3, 2016 2:45:57 PM GMT+01:00
UPDATE AD_Column SET IsAllowCopy='N',Updated=TO_TIMESTAMP('2016-09-03 14:45:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2925
;
SELECT register_migration_script('201609031546_IDEMPIERE-3173.sql') FROM dual
;

View File

@ -0,0 +1,12 @@
-- IDEMPIERE-2676 Incorrect context variables - onNavigate Callout
-- Sep 3, 2016 3:07:56 PM GMT+01:00
UPDATE AD_Column SET Callout='org.compiere.model.CalloutOrder.priceListReadOnly', IsUpdateable='N',Updated=TO_TIMESTAMP('2016-09-03 15:07:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2161
;
-- Sep 3, 2016 3:08:09 PM GMT+01:00
UPDATE AD_Column SET Callout='org.compiere.model.CalloutOrder.priceListReadOnly', IsUpdateable='N',Updated=TO_TIMESTAMP('2016-09-03 15:08:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3484
;
SELECT register_migration_script('201609031608_IDEMPIERE-2676.sql') FROM dual
;

View File

@ -160,14 +160,10 @@ public class CalloutInventory extends CalloutEngine
private BigDecimal setQtyBook (int M_AttributeSetInstance_ID, int M_Product_ID, int M_Locator_ID) throws Exception { private BigDecimal setQtyBook (int M_AttributeSetInstance_ID, int M_Product_ID, int M_Locator_ID) throws Exception {
// Set QtyBook from first storage location // Set QtyBook from first storage location
BigDecimal bd = null; BigDecimal bd = null;
String sql = "SELECT QtyOnHand FROM M_StorageOnHand " String sql = "SELECT SUM(QtyOnHand) FROM M_StorageOnHand "
+ "WHERE M_Product_ID=?" // 1 + "WHERE M_Product_ID=?" // 1
+ " AND M_Locator_ID=?" // 2 + " AND M_Locator_ID=?" // 2
+ " AND M_AttributeSetInstance_ID=?"; + " AND M_AttributeSetInstance_ID=?"; //3
if (M_AttributeSetInstance_ID == 0)
sql = "SELECT SUM(QtyOnHand) FROM M_StorageOnHand "
+ "WHERE M_Product_ID=?" // 1
+ " AND M_Locator_ID=?"; // 2
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
try try
@ -175,8 +171,7 @@ public class CalloutInventory extends CalloutEngine
pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, M_Product_ID); pstmt.setInt(1, M_Product_ID);
pstmt.setInt(2, M_Locator_ID); pstmt.setInt(2, M_Locator_ID);
if (M_AttributeSetInstance_ID != 0) pstmt.setInt(3, M_AttributeSetInstance_ID);
pstmt.setInt(3, M_AttributeSetInstance_ID);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {

View File

@ -661,9 +661,10 @@ public class CalloutOrder extends CalloutEngine
* @param mTab Grid Tab * @param mTab Grid Tab
* @param mField Grid Field * @param mField Grid Field
* @param value New Value * @param value New Value
* @param readonly Read Only - do not set tab fields, just context
* @return null or error message * @return null or error message
*/ */
public String priceList (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) public String priceListFill (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value, boolean readonly)
{ {
Integer M_PriceList_ID = (Integer) mTab.getValue("M_PriceList_ID"); Integer M_PriceList_ID = (Integer) mTab.getValue("M_PriceList_ID");
if (M_PriceList_ID == null || M_PriceList_ID.intValue()== 0) if (M_PriceList_ID == null || M_PriceList_ID.intValue()== 0)
@ -695,12 +696,16 @@ public class CalloutOrder extends CalloutEngine
if (rs.next()) if (rs.next())
{ {
// Tax Included // Tax Included
mTab.setValue("IsTaxIncluded", new Boolean("Y".equals(rs.getString(1)))); if (!readonly) {
mTab.setValue("IsTaxIncluded", new Boolean("Y".equals(rs.getString(1))));
}
// Price Limit Enforce // Price Limit Enforce
Env.setContext(ctx, WindowNo, "EnforcePriceLimit", rs.getString(2)); Env.setContext(ctx, WindowNo, "EnforcePriceLimit", rs.getString(2));
// Currency // Currency
Integer ii = new Integer(rs.getInt(3)); if (!readonly) {
mTab.setValue("C_Currency_ID", ii); Integer ii = new Integer(rs.getInt(3));
mTab.setValue("C_Currency_ID", ii);
}
// PriceList Version // PriceList Version
Env.setContext(ctx, WindowNo, "M_PriceList_Version_ID", rs.getInt(5)); Env.setContext(ctx, WindowNo, "M_PriceList_Version_ID", rs.getInt(5));
} }
@ -718,8 +723,18 @@ public class CalloutOrder extends CalloutEngine
if (steps) log.warning("fini"); if (steps) log.warning("fini");
return ""; return "";
} // priceListFill
public String priceList (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
return priceListFill (ctx, WindowNo, mTab, mField, value, false);
} // priceList } // priceList
/* IDEMPIERE-2676 - this is same callout priceList but not setting any variable, just reading and setting context, called on navigate */
public String priceListReadOnly (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
return priceListFill (ctx, WindowNo, mTab, mField, value, true);
} // priceListReadOnly
/** /**
* Set Payment Term. * Set Payment Term.

View File

@ -525,7 +525,7 @@ public class ImportInvoice extends SvrProcess
imp.setName (imp.getBPartnerValue ()); imp.setName (imp.getBPartnerValue ());
} }
// BPartner // BPartner
MBPartner bp = MBPartner.get (getCtx(), imp.getBPartnerValue()); MBPartner bp = MBPartner.get (getCtx(), imp.getBPartnerValue(), get_TrxName());
if (bp == null) if (bp == null)
{ {
bp = new MBPartner (getCtx (), -1, get_TrxName()); bp = new MBPartner (getCtx (), -1, get_TrxName());

View File

@ -525,7 +525,7 @@ public class ImportOrder extends SvrProcess
imp.setName (imp.getBPartnerValue ()); imp.setName (imp.getBPartnerValue ());
} }
// BPartner // BPartner
MBPartner bp = MBPartner.get (getCtx(), imp.getBPartnerValue()); MBPartner bp = MBPartner.get (getCtx(), imp.getBPartnerValue(), get_TrxName());
if (bp == null) if (bp == null)
{ {
bp = new MBPartner (getCtx (), -1, get_TrxName()); bp = new MBPartner (getCtx (), -1, get_TrxName());

View File

@ -16,18 +16,12 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.process; package org.compiere.process;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.model.MInventory; import org.compiere.model.MInventory;
import org.compiere.model.MInventoryLine;
import org.compiere.model.MInventoryLineMA; import org.compiere.model.MInventoryLineMA;
import org.compiere.model.MStorageOnHand;
import org.compiere.util.AdempiereSystemError; import org.compiere.util.AdempiereSystemError;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env;
/** /**
* Update existing Inventory Count List with current Book value * Update existing Inventory Count List with current Book value
@ -92,7 +86,7 @@ public class InventoryCountUpdate extends SvrProcess
// ASI // ASI
sql = new StringBuilder("UPDATE M_InventoryLine l ") sql = new StringBuilder("UPDATE M_InventoryLine l ")
.append("SET (QtyBook,QtyCount) = ") .append("SET (QtyBook,QtyCount) = ")
.append("(SELECT QtyOnHand,QtyOnHand FROM M_StorageOnHand s ") .append("(SELECT SUM(QtyOnHand),SUM(QtyOnHand) FROM M_StorageOnHand s ")
.append("WHERE s.M_Product_ID=l.M_Product_ID AND s.M_Locator_ID=l.M_Locator_ID") .append("WHERE s.M_Product_ID=l.M_Product_ID AND s.M_Locator_ID=l.M_Locator_ID")
.append(" AND s.M_AttributeSetInstance_ID=l.M_AttributeSetInstance_ID),") .append(" AND s.M_AttributeSetInstance_ID=l.M_AttributeSetInstance_ID),")
.append(" Updated=SysDate,") .append(" Updated=SysDate,")
@ -105,9 +99,6 @@ public class InventoryCountUpdate extends SvrProcess
int no = DB.executeUpdate(sql.toString(), get_TrxName()); int no = DB.executeUpdate(sql.toString(), get_TrxName());
if (log.isLoggable(Level.INFO)) log.info("Update with ASI=" + no); if (log.isLoggable(Level.INFO)) log.info("Update with ASI=" + no);
// No ASI
int noMA = updateWithMA();
// Set Count to Zero // Set Count to Zero
if (p_InventoryCountSetZero) if (p_InventoryCountSetZero)
{ {
@ -119,71 +110,11 @@ public class InventoryCountUpdate extends SvrProcess
} }
if (multiple > 0){ if (multiple > 0){
StringBuilder msgreturn = new StringBuilder("@M_InventoryLine_ID@ - #").append((no + noMA)).append(" --> @InventoryProductMultiple@"); StringBuilder msgreturn = new StringBuilder("@M_InventoryLine_ID@ - #").append(no).append(" --> @InventoryProductMultiple@");
return msgreturn.toString(); return msgreturn.toString();
} }
StringBuilder msgreturn = new StringBuilder("@M_InventoryLine_ID@ - #").append(no); StringBuilder msgreturn = new StringBuilder("@M_InventoryLine_ID@ - #").append(no);
return msgreturn.toString(); return msgreturn.toString();
} // doIt } // doIt
/**
* Update Inventory Lines With Material Allocation
* @return no updated
*/
private int updateWithMA()
{
int no = 0;
//
String sql = "SELECT * FROM M_InventoryLine WHERE M_Inventory_ID=? AND M_AttributeSetInstance_ID=0";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, p_M_Inventory_ID);
rs = pstmt.executeQuery ();
while (rs.next ())
{
MInventoryLine il = new MInventoryLine (getCtx(), rs, get_TrxName());
BigDecimal onHand = Env.ZERO;
MStorageOnHand[] storages = MStorageOnHand.getAll(getCtx(), il.getM_Product_ID(), il.getM_Locator_ID(), get_TrxName());
MInventoryLineMA ma = null;
for (int i = 0; i < storages.length; i++)
{
MStorageOnHand storage = storages[i];
if (storage.getQtyOnHand().signum() == 0)
continue;
onHand = onHand.add(storage.getQtyOnHand());
// No ASI
if (storage.getM_AttributeSetInstance_ID() == 0
&& storages.length == 1)
continue;
// Save ASI
ma = new MInventoryLineMA (il,
storage.getM_AttributeSetInstance_ID(), storage.getQtyOnHand(),storage.getDateMaterialPolicy(),true);
if (!ma.save())
;
}
il.setQtyBook(onHand);
il.setQtyCount(onHand);
if (il.save())
no++;
}
}
catch (Exception e)
{
log.log (Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//
if (log.isLoggable(Level.INFO)) log.info("#" + no);
return no;
} // updateWithMA
} // InventoryCountUpdate } // InventoryCountUpdate

View File

@ -1464,30 +1464,33 @@ public class GridTabCSVImporter implements IGridTabImporter
systemAccess = true; systemAccess = true;
} }
} }
int thisClientId = Env.getAD_Client_ID(Env.getCtx());
String trxName = (trx!=null?trx.getTrxName():null); String trxName = (trx!=null?trx.getTrxName():null);
StringBuilder postSelect = new StringBuilder(" FROM ") StringBuilder postSelect = new StringBuilder(" FROM ")
.append(foreignTable).append(" WHERE ") .append(foreignTable).append(" WHERE ")
.append(foreignColumn).append("=? AND IsActive='Y' AND AD_Client_ID"); .append(foreignColumn).append("=? AND IsActive='Y' AND AD_Client_ID=?");
if (systemAccess) {
postSelect.append(" IN (0,?)");
} else {
postSelect.append("=?");
}
StringBuilder selectCount = new StringBuilder("SELECT COUNT(*)").append(postSelect); StringBuilder selectCount = new StringBuilder("SELECT COUNT(*)").append(postSelect);
int count = DB.getSQLValueEx(trxName, selectCount.toString(), value, Env.getAD_Client_ID(Env.getCtx())); StringBuilder selectId = new StringBuilder("SELECT ").append(foreignTable).append("_ID").append(postSelect);
int count = DB.getSQLValueEx(trxName, selectCount.toString(), value, thisClientId);
if (count == 1) { // single value found, OK if (count == 1) { // single value found, OK
StringBuilder selectId = new StringBuilder("SELECT ").append(foreignTable).append("_ID").append(postSelect); return DB.getSQLValueEx(trxName, selectId.toString(), value, thisClientId);
id = DB.getSQLValueEx(trxName, selectId.toString(), value, Env.getAD_Client_ID(Env.getCtx()));
} else if (count > 1) { // multiple values found, error ForeignMultipleResolved } else if (count > 1) { // multiple values found, error ForeignMultipleResolved
id = -2; return -2;
} else if (count == 0) { // no values found, error ForeignNotResolved } else if (count == 0) { // no values found, error ForeignNotResolved
id = -3; if (systemAccess && thisClientId != 0) {
// not found in client, try with System
count = DB.getSQLValueEx(trxName, selectCount.toString(), value, 0 /* System */);
if (count == 1) { // single value found, OK
return DB.getSQLValueEx(trxName, selectId.toString(), value, 0 /* System */);
} else if (count > 1) { // multiple values found, error ForeignMultipleResolved
return -2;
}
}
} }
return -3; // no values found, error ForeignNotResolved
return id;
} }
//Copy from GridTable //Copy from GridTable

View File

@ -3543,6 +3543,7 @@ public class GridTable extends AbstractTableModel
private void openResultSet() { private void openResultSet() {
//postgresql need trx to use cursor based resultset //postgresql need trx to use cursor based resultset
//https://jdbc.postgresql.org/documentation/head/query.html#query-with-cursor
String trxName = m_virtual ? Trx.createTrxName("Loader") : null; String trxName = m_virtual ? Trx.createTrxName("Loader") : null;
trx = trxName != null ? Trx.get(trxName, true) : null; trx = trxName != null ? Trx.get(trxName, true) : null;
// open Statement (closed by Loader.close) // open Statement (closed by Loader.close)

View File

@ -47,7 +47,7 @@ public class MBPartner extends X_C_BPartner
/** /**
* *
*/ */
private static final long serialVersionUID = -5503105554864289337L; private static final long serialVersionUID = -803727877324075871L;
/** /**
* Get Empty Template Business Partner * Get Empty Template Business Partner
@ -110,12 +110,23 @@ public class MBPartner extends X_C_BPartner
* @param Value value * @param Value value
* @return BPartner or null * @return BPartner or null
*/ */
public static MBPartner get (Properties ctx, String Value) public static MBPartner get (Properties ctx, String Value) {
return get(ctx,Value,null);
}
/**
* Get BPartner with Value in a transaction
* @param ctx context
* @param Value value
* @param trxName transaction
* @return BPartner or null
*/
public static MBPartner get (Properties ctx, String Value, String trxName)
{ {
if (Value == null || Value.length() == 0) if (Value == null || Value.length() == 0)
return null; return null;
final String whereClause = "Value=? AND AD_Client_ID=?"; final String whereClause = "Value=? AND AD_Client_ID=?";
MBPartner retValue = new Query(ctx, I_C_BPartner.Table_Name, whereClause, null) MBPartner retValue = new Query(ctx, I_C_BPartner.Table_Name, whereClause, trxName)
.setParameters(Value,Env.getAD_Client_ID(ctx)) .setParameters(Value,Env.getAD_Client_ID(ctx))
.firstOnly(); .firstOnly();
return retValue; return retValue;
@ -128,9 +139,22 @@ public class MBPartner extends X_C_BPartner
* @return BPartner or null * @return BPartner or null
*/ */
public static MBPartner get (Properties ctx, int C_BPartner_ID) public static MBPartner get (Properties ctx, int C_BPartner_ID)
{
return get(ctx,C_BPartner_ID,null);
}
/**
* Get BPartner with Value in a transaction
* @param ctx context
* @param Value value
* @param trxName transaction
* @return BPartner or null
*/
public static MBPartner get (Properties ctx, int C_BPartner_ID, String trxName)
{ {
final String whereClause = "C_BPartner_ID=? AND AD_Client_ID=?"; final String whereClause = "C_BPartner_ID=? AND AD_Client_ID=?";
MBPartner retValue = new Query(ctx,I_C_BPartner.Table_Name,whereClause,null) MBPartner retValue = new Query(ctx,I_C_BPartner.Table_Name,whereClause,trxName)
.setParameters(C_BPartner_ID,Env.getAD_Client_ID(ctx)) .setParameters(C_BPartner_ID,Env.getAD_Client_ID(ctx))
.firstOnly(); .firstOnly();
return retValue; return retValue;

View File

@ -144,6 +144,11 @@ public class MField extends X_AD_Field
if (getAD_Column().getColumnName().equals("AD_Org_ID")) // AD_Org_ID can be copied if (getAD_Column().getColumnName().equals("AD_Org_ID")) // AD_Org_ID can be copied
setIsAllowCopy("Y"); setIsAllowCopy("Y");
} }
if (getAD_Reference_ID() <= 0) {
setAD_Reference_Value_ID(0);
setAD_Val_Rule_ID(0);
setIsToolbarButton(null);
}
return true; return true;
} // beforeSave } // beforeSave

View File

@ -120,15 +120,17 @@ public class MPOS extends X_C_POS
protected boolean beforeSave (boolean newRecord) protected boolean beforeSave (boolean newRecord)
{ {
// Org Consistency // Org Consistency
if (newRecord if (newRecord || is_ValueChanged("C_BankAccount_ID"))
|| is_ValueChanged("C_CashBook_ID") || is_ValueChanged("M_Warehouse_ID"))
{ {
MCashBook cb = MCashBook.get(getCtx(), getC_CashBook_ID(), get_TrxName()); MBankAccount cb = MBankAccount.get(getCtx(), getC_BankAccount_ID());
if (cb.getAD_Org_ID() != getAD_Org_ID()) if (cb.getAD_Org_ID() != getAD_Org_ID())
{ {
log.saveError("Error", Msg.parseTranslation(getCtx(), "@AD_Org_ID@: @C_CashBook_ID@")); log.saveError("Error", Msg.parseTranslation(getCtx(), "@AD_Org_ID@: @C_BankAccount_ID@"));
return false; return false;
} }
}
if (newRecord || is_ValueChanged("M_Warehouse_ID"))
{
MWarehouse wh = MWarehouse.get(getCtx(), getM_Warehouse_ID(), get_TrxName()); MWarehouse wh = MWarehouse.get(getCtx(), getM_Warehouse_ID(), get_TrxName());
if (wh.getAD_Org_ID() != getAD_Org_ID()) if (wh.getAD_Org_ID() != getAD_Org_ID())
{ {

View File

@ -71,6 +71,7 @@ public class MPeriodControl extends X_C_PeriodControl
{ {
this (period.getCtx(), period.getAD_Client_ID(), period.getC_Period_ID(), this (period.getCtx(), period.getAD_Client_ID(), period.getC_Period_ID(),
DocBaseType, period.get_TrxName()); DocBaseType, period.get_TrxName());
setClientOrg(period);
} // MPeriodControl } // MPeriodControl
/** /**

View File

@ -456,7 +456,7 @@ public class MStorageOnHand extends X_M_StorageOnHand
* @param ctx context * @param ctx context
* @param M_Warehouse_ID ignore if M_Locator_ID > 0 * @param M_Warehouse_ID ignore if M_Locator_ID > 0
* @param M_Product_ID product * @param M_Product_ID product
* @param M_AttributeSetInstance_ID instance id, 0 to retrieve all instance * @param M_AttributeSetInstance_ID instance id, 0 to retrieve storages that don't have asi, -1 to retrieve all instance
* @param minGuaranteeDate optional minimum guarantee date if all attribute instances * @param minGuaranteeDate optional minimum guarantee date if all attribute instances
* @param FiFo first in-first-out * @param FiFo first in-first-out
* @param M_Locator_ID optional locator id * @param M_Locator_ID optional locator id
@ -476,7 +476,7 @@ public class MStorageOnHand extends X_M_StorageOnHand
* @param ctx context * @param ctx context
* @param M_Warehouse_ID ignore if M_Locator_ID > 0 * @param M_Warehouse_ID ignore if M_Locator_ID > 0
* @param M_Product_ID product * @param M_Product_ID product
* @param M_AttributeSetInstance_ID instance id, 0 to retrieve all instance * @param M_AttributeSetInstance_ID instance id, 0 to retrieve storages that don't have asi, -1 to retrieve all instance
* @param minGuaranteeDate optional minimum guarantee date if all attribute instances * @param minGuaranteeDate optional minimum guarantee date if all attribute instances
* @param FiFo first in-first-out * @param FiFo first in-first-out
* @param M_Locator_ID optional locator id * @param M_Locator_ID optional locator id
@ -492,79 +492,66 @@ public class MStorageOnHand extends X_M_StorageOnHand
if ((M_Warehouse_ID == 0 && M_Locator_ID == 0) || M_Product_ID == 0) if ((M_Warehouse_ID == 0 && M_Locator_ID == 0) || M_Product_ID == 0)
return new MStorageOnHand[0]; return new MStorageOnHand[0];
boolean allAttributeInstances = false;
if (M_AttributeSetInstance_ID == 0)
allAttributeInstances = true;
ArrayList<MStorageOnHand> list = new ArrayList<MStorageOnHand>(); ArrayList<MStorageOnHand> list = new ArrayList<MStorageOnHand>();
// Specific Attribute Set Instance
String sql = "SELECT s.M_Product_ID,s.M_Locator_ID,s.M_AttributeSetInstance_ID," String sql = "SELECT s.M_Product_ID,s.M_Locator_ID,s.M_AttributeSetInstance_ID,"
+ "s.AD_Client_ID,s.AD_Org_ID,s.IsActive,s.Created,s.CreatedBy,s.Updated,s.UpdatedBy," + "s.AD_Client_ID,s.AD_Org_ID,s.IsActive,s.Created,s.CreatedBy,s.Updated,s.UpdatedBy,"
+ "s.QtyOnHand,s.DateLastInventory,s.DateMaterialPolicy " + "s.QtyOnHand,s.DateLastInventory,s.M_StorageOnHand_UU,s.DateMaterialPolicy "
+ "FROM M_StorageOnHand s" + "FROM M_StorageOnHand s"
+ " INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID) "; + " INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID)"
+ " LEFT OUTER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) ";
if (M_Locator_ID > 0) if (M_Locator_ID > 0)
sql += "WHERE l.M_Locator_ID = ?"; sql += "WHERE l.M_Locator_ID = ?";
else else
sql += "WHERE l.M_Warehouse_ID=?"; sql += "WHERE l.M_Warehouse_ID=?";
sql += " AND s.M_Product_ID=?" sql += " AND s.M_Product_ID=? "
+ " AND COALESCE(s.M_AttributeSetInstance_ID,0)=? "
+ " AND s.QtyOnHand < 0 "; + " AND s.QtyOnHand < 0 ";
sql += "ORDER BY l.PriorityNo DESC, DateMaterialPolicy ";
if (!FiFo) if (minGuaranteeDate != null)
sql += " DESC";
// All Attribute Set Instances
if (allAttributeInstances)
{ {
sql = "SELECT s.M_Product_ID,s.M_Locator_ID,s.M_AttributeSetInstance_ID," sql += "AND (asi.GuaranteeDate IS NULL OR asi.GuaranteeDate>?) ";
+ "s.AD_Client_ID,s.AD_Org_ID,s.IsActive,s.Created,s.CreatedBy,s.Updated,s.UpdatedBy," }
+ "s.QtyOnHand,s.DateLastInventory,s.M_StorageOnHand_UU,s.DateMaterialPolicy "
+ "FROM M_StorageOnHand s" if (M_AttributeSetInstance_ID > 0)
+ " INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID)" {
+ " LEFT OUTER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) "; sql += "AND s.M_AttributeSetInstance_ID=? ";
if (M_Locator_ID > 0) }
sql += "WHERE l.M_Locator_ID = ?"; else if (M_AttributeSetInstance_ID == 0)
else {
sql += "WHERE l.M_Warehouse_ID=?"; sql += "AND (s.M_AttributeSetInstance_ID=0 OR s.M_AttributeSetInstance_ID IS NULL) ";
sql += " AND s.M_Product_ID=? " }
+ " AND s.QtyOnHand < 0 ";
MProduct product = MProduct.get(Env.getCtx(), M_Product_ID);
if (minGuaranteeDate != null)
{ if(product.isUseGuaranteeDateForMPolicy()){
sql += "AND (asi.GuaranteeDate IS NULL OR asi.GuaranteeDate>?) "; sql += "ORDER BY l.PriorityNo DESC, " +
} "asi.GuaranteeDate";
if (!FiFo)
MProduct product = MProduct.get(Env.getCtx(), M_Product_ID); sql += " DESC";
}
if(product.isUseGuaranteeDateForMPolicy()){ else
sql += "ORDER BY l.PriorityNo DESC, " + {
"asi.GuaranteeDate"; sql += "ORDER BY l.PriorityNo DESC, l.M_Locator_ID, s.DateMaterialPolicy";
if (!FiFo) if (!FiFo)
sql += " DESC"; sql += " DESC";
} }
else
{ sql += ", s.QtyOnHand DESC";
sql += "ORDER BY l.PriorityNo DESC, l.M_Locator_ID, s.DateMaterialPolicy";
if (!FiFo)
sql += " DESC";
}
sql += ", s.QtyOnHand DESC";
}
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
try try
{ {
int index = 0;
pstmt = DB.prepareStatement(sql, trxName); pstmt = DB.prepareStatement(sql, trxName);
pstmt.setInt(1, M_Locator_ID > 0 ? M_Locator_ID : M_Warehouse_ID); pstmt.setInt(++index, M_Locator_ID > 0 ? M_Locator_ID : M_Warehouse_ID);
pstmt.setInt(2, M_Product_ID); pstmt.setInt(++index, M_Product_ID);
if (!allAttributeInstances) if (minGuaranteeDate != null)
{ {
pstmt.setInt(3, M_AttributeSetInstance_ID); pstmt.setTimestamp(++index, minGuaranteeDate);
} }
else if (minGuaranteeDate != null) if (M_AttributeSetInstance_ID > 0)
{ {
pstmt.setTimestamp(3, minGuaranteeDate); pstmt.setInt(++index, M_AttributeSetInstance_ID);
} }
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())

View File

@ -173,7 +173,7 @@ public class MUser extends X_AD_User
{ {
if (name == null || name.length() == 0 || password == null || password.length() == 0) if (name == null || name.length() == 0 || password == null || password.length() == 0)
{ {
s_log.warning ("Invalid Name/Password = " + name + "/" + password); s_log.warning ("Invalid Name/Password = " + name);
return null; return null;
} }
boolean hash_password = MSysConfig.getBooleanValue(MSysConfig.USER_PASSWORD_HASH, false); boolean hash_password = MSysConfig.getBooleanValue(MSysConfig.USER_PASSWORD_HASH, false);
@ -198,7 +198,7 @@ public class MUser extends X_AD_User
List<MUser> users = new Query(ctx, MUser.Table_Name, where.toString(), null) List<MUser> users = new Query(ctx, MUser.Table_Name, where.toString(), null)
.setParameters(name) .setParameters(name)
.setOrderBy(MUser.COLUMNNAME_AD_User_ID) .setOrderBy("AD_Client_ID, AD_User_ID") // prefer first user on System
.list(); .list();
if (users.size() == 0) { if (users.size() == 0) {
@ -223,6 +223,7 @@ public class MUser extends X_AD_User
if (valid){ if (valid){
retValue=user; retValue=user;
break;
} }
} }

View File

@ -134,6 +134,11 @@ public class MUserDefField extends X_AD_UserDef_Field
return false; return false;
} }
} }
if (getAD_Reference_ID() <= 0) {
setAD_Reference_Value_ID(0);
setAD_Val_Rule_ID(0);
setIsToolbarButton(null);
}
return true; return true;
} }

View File

@ -390,6 +390,15 @@ public final class Env
ctx.setProperty(WindowNo+"|"+context, String.valueOf(value)); ctx.setProperty(WindowNo+"|"+context, String.valueOf(value));
} // setContext } // setContext
public static void setContext (Properties ctx, int WindowNo, int TabNo, String context, int value)
{
if (ctx == null || context == null)
return;
if (log.isLoggable(Level.FINER)) log.finer("Context("+WindowNo+") " + context + "==" + value);
//
ctx.setProperty(WindowNo+"|"+TabNo+"|"+context, String.valueOf(value));
} // setContext
/** /**
* Set Context for Window to Y/N Value * Set Context for Window to Y/N Value
* @param ctx context * @param ctx context

View File

@ -194,9 +194,9 @@ public class Evaluator
secondEval = secondEval.replace('\'', ' ').replace('"', ' ').trim(); // strip ' and " secondEval = secondEval.replace('\'', ' ').replace('"', ' ').trim(); // strip ' and "
// Handling of ID compare (null => 0) // Handling of ID compare (null => 0)
if (first.indexOf("_ID") != -1 && firstEval.length() == 0) if (first.trim().endsWith("_ID") && firstEval.length() == 0)
firstEval = "0"; firstEval = "0";
if (second.indexOf("_ID") != -1 && secondEval.length() == 0) if (second.trim().endsWith("_ID") && secondEval.length() == 0)
secondEval = "0"; secondEval = "0";
// Logical Comparison // Logical Comparison

View File

@ -489,7 +489,7 @@ public abstract class AbstractElementHandler implements ElementHandler {
if (element.properties.containsKey(uuidColumn)) { if (element.properties.containsKey(uuidColumn)) {
uuid = element.properties.get(uuidColumn).contents.toString(); uuid = element.properties.get(uuidColumn).contents.toString();
} }
return (uuid != null && uuid.trim().length() == 36); return (uuid != null && uuid.trim().length() <= 36);
} }
protected String getUUIDKey(PIPOContext ctx, Element element) { protected String getUUIDKey(PIPOContext ctx, Element element) {
@ -497,7 +497,7 @@ public abstract class AbstractElementHandler implements ElementHandler {
String uuidColumn = PO.getUUIDColumnName(tableName); String uuidColumn = PO.getUUIDColumnName(tableName);
if (element.properties.containsKey(uuidColumn)) { if (element.properties.containsKey(uuidColumn)) {
String uuid = element.properties.get(uuidColumn).contents.toString(); String uuid = element.properties.get(uuidColumn).contents.toString();
if (uuid != null && uuid.trim().length() == 36) if (uuid != null && uuid.trim().length() <= 36)
return uuid.trim(); return uuid.trim();
} }
return null; return null;

View File

@ -82,7 +82,7 @@ public class POFinder {
String idColumn = tableName + "_ID"; String idColumn = tableName + "_ID";
if (element.properties.containsKey(uuidColumn)) { if (element.properties.containsKey(uuidColumn)) {
String uuid = element.properties.get(uuidColumn).contents.toString(); String uuid = element.properties.get(uuidColumn).contents.toString();
if (uuid != null && uuid.trim().length() == 36) { if (uuid != null && uuid.trim().length() <= 36) {
uuid = uuid.trim(); uuid = uuid.trim();
String targetUUID = Env.getAD_Client_ID(ctx.ctx) > 0 ? getTargetUUID(ctx.ctx, tableName, uuid, ctx.trx.getTrxName()) : uuid; String targetUUID = Env.getAD_Client_ID(ctx.ctx) > 0 ? getTargetUUID(ctx.ctx, tableName, uuid, ctx.trx.getTrxName()) : uuid;
Query query = new Query(ctx.ctx, tableName, uuidColumn+"=?", getTrxName(ctx)); Query query = new Query(ctx.ctx, tableName, uuidColumn+"=?", getTrxName(ctx));

View File

@ -164,7 +164,7 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
} }
else else
{ {
pageSize = MSysConfig.getIntValue(MSysConfig.ZK_PAGING_SIZE, DEFAULT_PAGE_SIZE); pageSize = MSysConfig.getIntValue(MSysConfig.ZK_PAGING_SIZE, DEFAULT_PAGE_SIZE, Env.getAD_Client_ID(Env.getCtx()));
String limit = Library.getProperty(CustomGridDataLoader.GRID_DATA_LOADER_LIMIT); String limit = Library.getProperty(CustomGridDataLoader.GRID_DATA_LOADER_LIMIT);
if (limit == null || !(limit.equals(Integer.toString(pageSize)))) { if (limit == null || !(limit.equals(Integer.toString(pageSize)))) {
Library.setProperty(CustomGridDataLoader.GRID_DATA_LOADER_LIMIT, Integer.toString(pageSize)); Library.setProperty(CustomGridDataLoader.GRID_DATA_LOADER_LIMIT, Integer.toString(pageSize));
@ -197,7 +197,7 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
public void setDetailPaneMode(boolean detailPaneMode) { public void setDetailPaneMode(boolean detailPaneMode) {
if (this.detailPaneMode != detailPaneMode) { if (this.detailPaneMode != detailPaneMode) {
this.detailPaneMode = detailPaneMode; this.detailPaneMode = detailPaneMode;
pageSize = detailPaneMode ? DEFAULT_DETAIL_PAGE_SIZE : MSysConfig.getIntValue(MSysConfig.ZK_PAGING_SIZE, 20); pageSize = detailPaneMode ? DEFAULT_DETAIL_PAGE_SIZE : MSysConfig.getIntValue(MSysConfig.ZK_PAGING_SIZE, 20, Env.getAD_Client_ID(Env.getCtx()));
updatePaging(); updatePaging();
} }
} }

View File

@ -54,7 +54,7 @@ import org.zkoss.zul.South;
*/ */
public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup,EventListener<Event>{ public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup,EventListener<Event>{
/** /**
* *
*/ */
private static final long serialVersionUID = 1849434312706721390L; private static final long serialVersionUID = 1849434312706721390L;
@ -319,7 +319,7 @@ public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup
public MNote getMNote(MBroadcastMessage mbMessage) { public MNote getMNote(MBroadcastMessage mbMessage) {
MNote note =null; MNote note =null;
if(!mbMessage.getBroadcastType().equals(MBroadcastMessage.BROADCASTTYPE_Immediate)){ if(!mbMessage.getBroadcastType().equals(MBroadcastMessage.BROADCASTTYPE_Immediate)){
String sql = "SELECT * FROM AD_Note WHERE AD_BroadcastMessage_ID = ? AND AD_User_ID = ? AND AD_Client_ID = ?"; String sql = "SELECT * FROM AD_Note WHERE AD_BroadcastMessage_ID = ? AND AD_User_ID = ? AND AD_Client_ID in (?, 0)";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs=null; ResultSet rs=null;
try { try {

View File

@ -841,9 +841,13 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
isHasNextPage = false; isHasNextPage = false;
if (log.isLoggable(Level.FINER)) if (log.isLoggable(Level.FINER))
log.finer(dataSql); log.finer(dataSql);
Trx trx = null;
try try
{ {
m_pstmt = DB.prepareStatement(dataSql, null); //https://jdbc.postgresql.org/documentation/head/query.html#query-with-cursor
String trxName = Trx.createTrxName("InfoPanelLoad:");
trx = Trx.get(trxName, true);
m_pstmt = DB.prepareStatement(dataSql, trxName);
setParameters (m_pstmt, false); // no count setParameters (m_pstmt, false); // no count
if (log.isLoggable(Level.FINE)) if (log.isLoggable(Level.FINE))
log.fine("Start query - " + (System.currentTimeMillis()-startTime) + "ms"); log.fine("Start query - " + (System.currentTimeMillis()-startTime) + "ms");
@ -890,6 +894,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
finally finally
{ {
DB.close(m_rs, m_pstmt); DB.close(m_rs, m_pstmt);
trx.close();
} }
if (end > cacheEnd || end <= 0) if (end > cacheEnd || end <= 0)

View File

@ -472,8 +472,16 @@ public final class WAccountDialog extends Window
statusBar.setStatusDB(""); statusBar.setStatusDB("");
// Initial value // Initial value
if (m_mAccount.C_ValidCombination_ID != 0) if (m_mAccount.C_ValidCombination_ID != 0) {
m_mTab.navigate(0); m_mTab.navigate(0);
if (f_Account_ID.getValue() instanceof Integer) {
Env.setContext(Env.getCtx(), m_WindowNo, "Account_ID", (Integer)f_Account_ID.getValue());
Env.setContext(Env.getCtx(), m_WindowNo, 0, "Account_ID", (Integer)f_Account_ID.getValue());
if (f_SubAcct_ID != null) {
f_SubAcct_ID.dynamicDisplay();
}
}
}
log.config("fini"); log.config("fini");
return true; return true;
@ -1213,7 +1221,9 @@ public final class WAccountDialog extends Window
Object newValue = evt.getNewValue(); Object newValue = evt.getNewValue();
if (newValue instanceof Integer) { if (newValue instanceof Integer) {
Env.setContext(Env.getCtx(), m_WindowNo, "Account_ID", ((Integer)newValue).intValue()); Env.setContext(Env.getCtx(), m_WindowNo, "Account_ID", ((Integer)newValue).intValue());
Env.setContext(Env.getCtx(), m_WindowNo, 0, "Account_ID", ((Integer)newValue).intValue());
if (f_SubAcct_ID != null) { if (f_SubAcct_ID != null) {
f_SubAcct_ID.setValue(null);
f_SubAcct_ID.dynamicDisplay(); f_SubAcct_ID.dynamicDisplay();
} }
} }

View File

@ -201,6 +201,7 @@ public class WImageDialog extends Window implements EventListener<Event>
confirmPanel.addActionListener(Events.ON_CLICK, this); confirmPanel.addActionListener(Events.ON_CLICK, this);
addEventListener(Events.ON_UPLOAD, this); addEventListener(Events.ON_UPLOAD, this);
addEventListener("onSave", this);
} // init } // init
public void onEvent(Event e) throws Exception { public void onEvent(Event e) throws Exception {
@ -211,19 +212,8 @@ public class WImageDialog extends Window implements EventListener<Event>
} }
else if (e.getTarget().getId().equals(ConfirmPanel.A_OK)) else if (e.getTarget().getId().equals(ConfirmPanel.A_OK))
{ {
if (image.getContent() != null) Clients.showBusy(this, Msg.getMsg(Env.getCtx(), "Processing"));
{ Events.echoEvent("onSave", this, null);
if (!Util.isEmpty(fileNameTextbox.getValue()))
m_mImage.setName(fileNameTextbox.getValue());
m_mImage.saveEx();
}
else if (m_mImage != null && m_mImage.getAD_Image_ID() > 0)
{
m_mImage.setBinaryData(null);
m_mImage.setName("-");
m_mImage.saveEx();
}
detach();
} }
else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
{ {
@ -240,10 +230,12 @@ public class WImageDialog extends Window implements EventListener<Event>
{ {
captureDiv.setVisible(true); captureDiv.setVisible(true);
cancelCaptureButton.setVisible(true); cancelCaptureButton.setVisible(true);
cancelCaptureButton.setEnabled(true);
mainLayout.setVisible(false); mainLayout.setVisible(false);
String script = "var wgt = zk.Widget.$('#"+captureDiv.getUuid()+"');"; String script = "var wgt = zk.Widget.$('#"+captureDiv.getUuid()+"');";
script = script + "var cancelBtn=zk.Widget.$('#"+cancelCaptureButton.getUuid()+"');";
script = script + "jq(wgt).photobooth(); "; script = script + "jq(wgt).photobooth(); ";
script = script + "jq(wgt).bind( 'image', function( event, dataUrl ){ zAu.send(new zk.Event(wgt, 'onCaptureImage', dataUrl, {toServer:true})); });"; script = script + "jq(wgt).bind( 'image', function( event, dataUrl ){ cancelBtn.setVisible(false);zAu.send(new zk.Event(wgt, 'onCaptureImage', dataUrl, {toServer:true})); });";
Clients.evalJavaScript(script); Clients.evalJavaScript(script);
} }
else if (e.getName().equals("onCaptureImage")) else if (e.getName().equals("onCaptureImage"))
@ -279,6 +271,30 @@ public class WImageDialog extends Window implements EventListener<Event>
script = script + "jq(wgt).data( 'photobooth').destroy(); "; script = script + "jq(wgt).data( 'photobooth').destroy(); ";
Clients.evalJavaScript(script); Clients.evalJavaScript(script);
} }
else if (e.getName().equals("onSave"))
{
try {
onSave();
} finally {
Clients.clearBusy(this);
}
}
}
private void onSave() {
if (image.getContent() != null)
{
if (!Util.isEmpty(fileNameTextbox.getValue()))
m_mImage.setName(fileNameTextbox.getValue());
m_mImage.saveEx();
}
else if (m_mImage != null && m_mImage.getAD_Image_ID() > 0)
{
m_mImage.setBinaryData(null);
m_mImage.setName("-");
m_mImage.saveEx();
}
detach();
} }
/** /**