diff --git a/base/src/org/adempiere/process/InitialClientSetup.java b/base/src/org/adempiere/process/InitialClientSetup.java index be0c1beed3..32f1fdb644 100644 --- a/base/src/org/adempiere/process/InitialClientSetup.java +++ b/base/src/org/adempiere/process/InitialClientSetup.java @@ -33,9 +33,9 @@ import java.io.File; import java.util.logging.Level; import org.adempiere.exceptions.AdempiereException; +import org.compiere.model.MCity; import org.compiere.model.MCurrency; import org.compiere.model.MSetup; -import org.compiere.model.X_C_City; import org.compiere.print.PrintUtil; import org.compiere.process.ProcessInfoParameter; import org.compiere.process.SvrProcess; @@ -168,9 +168,12 @@ public class InitialClientSetup extends SvrProcess throw new AdempiereException("@NotUnique@ " + p_NormalUserName); // City_ID overrides CityName if both used - if (p_CityName != null && p_CityName.length() > 0 && p_C_City_ID > 0) { - X_C_City city = new X_C_City(getCtx(), p_C_City_ID, null); - p_CityName = city.getName(); + if (p_C_City_ID > 0) { + MCity city = MCity.get(getCtx(), p_C_City_ID); + if (! city.getName().equals(p_CityName)) { + log.info("City name changed from " + p_CityName + " to " + city.getName()); + p_CityName = city.getName(); + } } // Validate existence and read permissions on CoA file @@ -187,8 +190,10 @@ public class InitialClientSetup extends SvrProcess // Process MSetup ms = new MSetup(Env.getCtx(), WINDOW_THIS_PROCESS); - if (! ms.createClient(p_ClientName, p_OrgName, p_AdminUserName, p_NormalUserName)) + if (! ms.createClient(p_ClientName, p_OrgName, p_AdminUserName, p_NormalUserName)) { + ms.rollback(); throw new AdempiereException("Create client failed"); + } addLog(ms.getInfo()); @@ -197,11 +202,16 @@ public class InitialClientSetup extends SvrProcess KeyNamePair currency_kp = new KeyNamePair(p_C_Currency_ID, currency.getDescription()); if (!ms.createAccounting(currency_kp, p_IsUseProductDimension, p_IsUseBPDimension, p_IsUseProjectDimension, p_IsUseCampaignDimension, p_IsUseSalesRegionDimension, - coaFile)) + coaFile)) { + ms.rollback(); throw new AdempiereException("@AccountSetupError@"); + } // Generate Entities - ms.createEntities(p_C_Country_ID, p_CityName, p_C_Region_ID, p_C_Currency_ID); + if (!ms.createEntities(p_C_Country_ID, p_CityName, p_C_Region_ID, p_C_Currency_ID)) { + ms.rollback(); + throw new AdempiereException("@AccountSetupError@"); + } addLog(ms.getInfo()); // Create Print Documents @@ -210,4 +220,4 @@ public class InitialClientSetup extends SvrProcess return "@OK@"; } // doIt -} // ASPGenerateLevel \ No newline at end of file +} // InitialClientSetup diff --git a/base/src/org/compiere/model/I_C_Country.java b/base/src/org/compiere/model/I_C_Country.java index 5eb1be99ff..7b2c37df33 100644 --- a/base/src/org/compiere/model/I_C_Country.java +++ b/base/src/org/compiere/model/I_C_Country.java @@ -1,429 +1,451 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2007 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.compiere.model; - -import java.math.BigDecimal; -import java.sql.Timestamp; -import org.compiere.util.KeyNamePair; - -/** Generated Interface for C_Country - * @author Adempiere (generated) - * @version Release 3.5.4a - */ -public interface I_C_Country -{ - - /** TableName=C_Country */ - public static final String Table_Name = "C_Country"; - - /** AD_Table_ID=170 */ - public static final int Table_ID = MTable.getTable_ID(Table_Name); - - KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name); - - /** AccessLevel = 6 - System - Client - */ - BigDecimal accessLevel = BigDecimal.valueOf(6); - - /** Load Meta Data */ - - /** Column name AD_Client_ID */ - public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID"; - - /** Get Client. - * Client/Tenant for this installation. - */ - public int getAD_Client_ID(); - - /** Column name AD_Language */ - public static final String COLUMNNAME_AD_Language = "AD_Language"; - - /** Set Language. - * Language for this entity - */ - public void setAD_Language (String AD_Language); - - /** Get Language. - * Language for this entity - */ - public String getAD_Language(); - - /** Column name AD_Org_ID */ - public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID"; - - /** Set Organization. - * Organizational entity within client - */ - public void setAD_Org_ID (int AD_Org_ID); - - /** Get Organization. - * Organizational entity within client - */ - public int getAD_Org_ID(); - - /** Column name C_Country_ID */ - public static final String COLUMNNAME_C_Country_ID = "C_Country_ID"; - - /** Set Country. - * Country - */ - public void setC_Country_ID (int C_Country_ID); - - /** Get Country. - * Country - */ - public int getC_Country_ID(); - - /** Column name C_Currency_ID */ - public static final String COLUMNNAME_C_Currency_ID = "C_Currency_ID"; - - /** Set Currency. - * The Currency for this record - */ - public void setC_Currency_ID (int C_Currency_ID); - - /** Get Currency. - * The Currency for this record - */ - public int getC_Currency_ID(); - - public I_C_Currency getC_Currency() throws RuntimeException; - - /** Column name CountryCode */ - public static final String COLUMNNAME_CountryCode = "CountryCode"; - - /** Set ISO Country Code. - * Upper-case two-letter alphanumeric ISO Country code according to ISO 3166-1 - http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html - */ - public void setCountryCode (String CountryCode); - - /** Get ISO Country Code. - * Upper-case two-letter alphanumeric ISO Country code according to ISO 3166-1 - http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html - */ - public String getCountryCode(); - - /** Column name Created */ - public static final String COLUMNNAME_Created = "Created"; - - /** Get Created. - * Date this record was created - */ - public Timestamp getCreated(); - - /** Column name CreatedBy */ - public static final String COLUMNNAME_CreatedBy = "CreatedBy"; - - /** Get Created By. - * User who created this records - */ - public int getCreatedBy(); - - /** Column name Description */ - public static final String COLUMNNAME_Description = "Description"; - - /** Set Description. - * Optional short description of the record - */ - public void setDescription (String Description); - - /** Get Description. - * Optional short description of the record - */ - public String getDescription(); - - /** Column name DisplaySequence */ - public static final String COLUMNNAME_DisplaySequence = "DisplaySequence"; - - /** Set Address Print Format. - * Format for printing this Address - */ - public void setDisplaySequence (String DisplaySequence); - - /** Get Address Print Format. - * Format for printing this Address - */ - public String getDisplaySequence(); - - /** Column name DisplaySequenceLocal */ - public static final String COLUMNNAME_DisplaySequenceLocal = "DisplaySequenceLocal"; - - /** Set Local Address Format. - * Format for printing this Address locally - */ - public void setDisplaySequenceLocal (String DisplaySequenceLocal); - - /** Get Local Address Format. - * Format for printing this Address locally - */ - public String getDisplaySequenceLocal(); - - /** Column name ExpressionBankAccountNo */ - public static final String COLUMNNAME_ExpressionBankAccountNo = "ExpressionBankAccountNo"; - - /** Set Bank Account No Format. - * Format of the Bank Account - */ - public void setExpressionBankAccountNo (String ExpressionBankAccountNo); - - /** Get Bank Account No Format. - * Format of the Bank Account - */ - public String getExpressionBankAccountNo(); - - /** Column name ExpressionBankRoutingNo */ - public static final String COLUMNNAME_ExpressionBankRoutingNo = "ExpressionBankRoutingNo"; - - /** Set Bank Routing No Format. - * Format of the Bank Routing Number - */ - public void setExpressionBankRoutingNo (String ExpressionBankRoutingNo); - - /** Get Bank Routing No Format. - * Format of the Bank Routing Number - */ - public String getExpressionBankRoutingNo(); - - /** Column name ExpressionPhone */ - public static final String COLUMNNAME_ExpressionPhone = "ExpressionPhone"; - - /** Set Phone Format. - * Format of the phone; - Can contain fixed format elements, Variables: "_lLoOaAcCa09" - */ - public void setExpressionPhone (String ExpressionPhone); - - /** Get Phone Format. - * Format of the phone; - Can contain fixed format elements, Variables: "_lLoOaAcCa09" - */ - public String getExpressionPhone(); - - /** Column name ExpressionPostal */ - public static final String COLUMNNAME_ExpressionPostal = "ExpressionPostal"; - - /** Set Postal Code Format. - * Format of the postal code; - Can contain fixed format elements, Variables: "_lLoOaAcCa09" - */ - public void setExpressionPostal (String ExpressionPostal); - - /** Get Postal Code Format. - * Format of the postal code; - Can contain fixed format elements, Variables: "_lLoOaAcCa09" - */ - public String getExpressionPostal(); - - /** Column name ExpressionPostal_Add */ - public static final String COLUMNNAME_ExpressionPostal_Add = "ExpressionPostal_Add"; - - /** Set Additional Postal Format. - * Format of the value; - Can contain fixed format elements, Variables: "_lLoOaAcCa09" - */ - public void setExpressionPostal_Add (String ExpressionPostal_Add); - - /** Get Additional Postal Format. - * Format of the value; - Can contain fixed format elements, Variables: "_lLoOaAcCa09" - */ - public String getExpressionPostal_Add(); - - /** Column name HasPostal_Add */ - public static final String COLUMNNAME_HasPostal_Add = "HasPostal_Add"; - - /** Set Additional Postal code. - * Has Additional Postal Code - */ - public void setHasPostal_Add (boolean HasPostal_Add); - - /** Get Additional Postal code. - * Has Additional Postal Code - */ - public boolean isHasPostal_Add(); - - /** Column name HasRegion */ - public static final String COLUMNNAME_HasRegion = "HasRegion"; - - /** Set Country has Region. - * Country contains Regions - */ - public void setHasRegion (boolean HasRegion); - - /** Get Country has Region. - * Country contains Regions - */ - public boolean isHasRegion(); - - /** Column name IsActive */ - public static final String COLUMNNAME_IsActive = "IsActive"; - - /** Set Active. - * The record is active in the system - */ - public void setIsActive (boolean IsActive); - - /** Get Active. - * The record is active in the system - */ - public boolean isActive(); - - /** Column name IsAddressLinesLocalReverse */ - public static final String COLUMNNAME_IsAddressLinesLocalReverse = "IsAddressLinesLocalReverse"; - - /** Set Reverse Local Address Lines. - * Print Local Address in reverse Order - */ - public void setIsAddressLinesLocalReverse (boolean IsAddressLinesLocalReverse); - - /** Get Reverse Local Address Lines. - * Print Local Address in reverse Order - */ - public boolean isAddressLinesLocalReverse(); - - /** Column name IsAddressLinesReverse */ - public static final String COLUMNNAME_IsAddressLinesReverse = "IsAddressLinesReverse"; - - /** Set Reverse Address Lines. - * Print Address in reverse Order - */ - public void setIsAddressLinesReverse (boolean IsAddressLinesReverse); - - /** Get Reverse Address Lines. - * Print Address in reverse Order - */ - public boolean isAddressLinesReverse(); - - /** Column name IsPostcodeLookup */ - public static final String COLUMNNAME_IsPostcodeLookup = "IsPostcodeLookup"; - - /** Set IsPostcodeLookup. - * Does this country have a post code web service - */ - public void setIsPostcodeLookup (boolean IsPostcodeLookup); - - /** Get IsPostcodeLookup. - * Does this country have a post code web service - */ - public boolean isPostcodeLookup(); - - /** Column name LookupClassName */ - public static final String COLUMNNAME_LookupClassName = "LookupClassName"; - - /** Set LookupClassName. - * The class name of the postcode lookup plugin - */ - public void setLookupClassName (String LookupClassName); - - /** Get LookupClassName. - * The class name of the postcode lookup plugin - */ - public String getLookupClassName(); - - /** Column name LookupClientID */ - public static final String COLUMNNAME_LookupClientID = "LookupClientID"; - - /** Set LookupClientID. - * The ClientID or Login submitted to the Lookup URL - */ - public void setLookupClientID (String LookupClientID); - - /** Get LookupClientID. - * The ClientID or Login submitted to the Lookup URL - */ - public String getLookupClientID(); - - /** Column name LookupPassword */ - public static final String COLUMNNAME_LookupPassword = "LookupPassword"; - - /** Set LookupPassword. - * The password submitted to the Lookup URL - */ - public void setLookupPassword (String LookupPassword); - - /** Get LookupPassword. - * The password submitted to the Lookup URL - */ - public String getLookupPassword(); - - /** Column name LookupUrl */ - public static final String COLUMNNAME_LookupUrl = "LookupUrl"; - - /** Set LookupUrl. - * The URL of the web service that the plugin connects to in order to retrieve postcode data - */ - public void setLookupUrl (String LookupUrl); - - /** Get LookupUrl. - * The URL of the web service that the plugin connects to in order to retrieve postcode data - */ - public String getLookupUrl(); - - /** Column name MediaSize */ - public static final String COLUMNNAME_MediaSize = "MediaSize"; - - /** Set Media Size. - * Java Media Size - */ - public void setMediaSize (String MediaSize); - - /** Get Media Size. - * Java Media Size - */ - public String getMediaSize(); - - /** Column name Name */ - public static final String COLUMNNAME_Name = "Name"; - - /** Set Name. - * Alphanumeric identifier of the entity - */ - public void setName (String Name); - - /** Get Name. - * Alphanumeric identifier of the entity - */ - public String getName(); - - /** Column name RegionName */ - public static final String COLUMNNAME_RegionName = "RegionName"; - - /** Set Region. - * Name of the Region - */ - public void setRegionName (String RegionName); - - /** Get Region. - * Name of the Region - */ - public String getRegionName(); - - /** Column name Updated */ - public static final String COLUMNNAME_Updated = "Updated"; - - /** Get Updated. - * Date this record was updated - */ - public Timestamp getUpdated(); - - /** Column name UpdatedBy */ - public static final String COLUMNNAME_UpdatedBy = "UpdatedBy"; - - /** Get Updated By. - * User who updated this records - */ - public int getUpdatedBy(); -} +/****************************************************************************** + * Product: Adempiere ERP & CRM Smart Business Solution * + * Copyright (C) 1999-2007 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.compiere.model; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import org.compiere.util.KeyNamePair; + +/** Generated Interface for C_Country + * @author Adempiere (generated) + * @version Release 3.5.4a + */ +public interface I_C_Country +{ + + /** TableName=C_Country */ + public static final String Table_Name = "C_Country"; + + /** AD_Table_ID=170 */ + public static final int Table_ID = MTable.getTable_ID(Table_Name); + + KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name); + + /** AccessLevel = 6 - System - Client + */ + BigDecimal accessLevel = BigDecimal.valueOf(6); + + /** Load Meta Data */ + + /** Column name AD_Client_ID */ + public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID"; + + /** Get Client. + * Client/Tenant for this installation. + */ + public int getAD_Client_ID(); + + /** Column name AD_Language */ + public static final String COLUMNNAME_AD_Language = "AD_Language"; + + /** Set Language. + * Language for this entity + */ + public void setAD_Language (String AD_Language); + + /** Get Language. + * Language for this entity + */ + public String getAD_Language(); + + /** Column name AD_Org_ID */ + public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID"; + + /** Set Organization. + * Organizational entity within client + */ + public void setAD_Org_ID (int AD_Org_ID); + + /** Get Organization. + * Organizational entity within client + */ + public int getAD_Org_ID(); + + /** Column name AllowCitiesOutOfList */ + public static final String COLUMNNAME_AllowCitiesOutOfList = "AllowCitiesOutOfList"; + + /** Set AllowCitiesOutOfList. + * A flag which tells if a country accept or not new cities + */ + public void setAllowCitiesOutOfList (boolean AllowCitiesOutOfList); + + /** Get AllowCitiesOutOfList. + * A flag which tells if a country accept or not new cities + */ + public boolean isAllowCitiesOutOfList(); + + /** Column name CaptureSequence */ + public static final String COLUMNNAME_CaptureSequence = "CaptureSequence"; + + /** Set CaptureSequence */ + public void setCaptureSequence (String CaptureSequence); + + /** Get CaptureSequence */ + public String getCaptureSequence(); + + /** Column name C_Country_ID */ + public static final String COLUMNNAME_C_Country_ID = "C_Country_ID"; + + /** Set Country. + * Country + */ + public void setC_Country_ID (int C_Country_ID); + + /** Get Country. + * Country + */ + public int getC_Country_ID(); + + /** Column name C_Currency_ID */ + public static final String COLUMNNAME_C_Currency_ID = "C_Currency_ID"; + + /** Set Currency. + * The Currency for this record + */ + public void setC_Currency_ID (int C_Currency_ID); + + /** Get Currency. + * The Currency for this record + */ + public int getC_Currency_ID(); + + public I_C_Currency getC_Currency() throws RuntimeException; + + /** Column name CountryCode */ + public static final String COLUMNNAME_CountryCode = "CountryCode"; + + /** Set ISO Country Code. + * Upper-case two-letter alphanumeric ISO Country code according to ISO 3166-1 - http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html + */ + public void setCountryCode (String CountryCode); + + /** Get ISO Country Code. + * Upper-case two-letter alphanumeric ISO Country code according to ISO 3166-1 - http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html + */ + public String getCountryCode(); + + /** Column name Created */ + public static final String COLUMNNAME_Created = "Created"; + + /** Get Created. + * Date this record was created + */ + public Timestamp getCreated(); + + /** Column name CreatedBy */ + public static final String COLUMNNAME_CreatedBy = "CreatedBy"; + + /** Get Created By. + * User who created this records + */ + public int getCreatedBy(); + + /** Column name Description */ + public static final String COLUMNNAME_Description = "Description"; + + /** Set Description. + * Optional short description of the record + */ + public void setDescription (String Description); + + /** Get Description. + * Optional short description of the record + */ + public String getDescription(); + + /** Column name DisplaySequence */ + public static final String COLUMNNAME_DisplaySequence = "DisplaySequence"; + + /** Set Address Print Format. + * Format for printing this Address + */ + public void setDisplaySequence (String DisplaySequence); + + /** Get Address Print Format. + * Format for printing this Address + */ + public String getDisplaySequence(); + + /** Column name DisplaySequenceLocal */ + public static final String COLUMNNAME_DisplaySequenceLocal = "DisplaySequenceLocal"; + + /** Set Local Address Format. + * Format for printing this Address locally + */ + public void setDisplaySequenceLocal (String DisplaySequenceLocal); + + /** Get Local Address Format. + * Format for printing this Address locally + */ + public String getDisplaySequenceLocal(); + + /** Column name ExpressionBankAccountNo */ + public static final String COLUMNNAME_ExpressionBankAccountNo = "ExpressionBankAccountNo"; + + /** Set Bank Account No Format. + * Format of the Bank Account + */ + public void setExpressionBankAccountNo (String ExpressionBankAccountNo); + + /** Get Bank Account No Format. + * Format of the Bank Account + */ + public String getExpressionBankAccountNo(); + + /** Column name ExpressionBankRoutingNo */ + public static final String COLUMNNAME_ExpressionBankRoutingNo = "ExpressionBankRoutingNo"; + + /** Set Bank Routing No Format. + * Format of the Bank Routing Number + */ + public void setExpressionBankRoutingNo (String ExpressionBankRoutingNo); + + /** Get Bank Routing No Format. + * Format of the Bank Routing Number + */ + public String getExpressionBankRoutingNo(); + + /** Column name ExpressionPhone */ + public static final String COLUMNNAME_ExpressionPhone = "ExpressionPhone"; + + /** Set Phone Format. + * Format of the phone; + Can contain fixed format elements, Variables: "_lLoOaAcCa09" + */ + public void setExpressionPhone (String ExpressionPhone); + + /** Get Phone Format. + * Format of the phone; + Can contain fixed format elements, Variables: "_lLoOaAcCa09" + */ + public String getExpressionPhone(); + + /** Column name ExpressionPostal */ + public static final String COLUMNNAME_ExpressionPostal = "ExpressionPostal"; + + /** Set Postal Code Format. + * Format of the postal code; + Can contain fixed format elements, Variables: "_lLoOaAcCa09" + */ + public void setExpressionPostal (String ExpressionPostal); + + /** Get Postal Code Format. + * Format of the postal code; + Can contain fixed format elements, Variables: "_lLoOaAcCa09" + */ + public String getExpressionPostal(); + + /** Column name ExpressionPostal_Add */ + public static final String COLUMNNAME_ExpressionPostal_Add = "ExpressionPostal_Add"; + + /** Set Additional Postal Format. + * Format of the value; + Can contain fixed format elements, Variables: "_lLoOaAcCa09" + */ + public void setExpressionPostal_Add (String ExpressionPostal_Add); + + /** Get Additional Postal Format. + * Format of the value; + Can contain fixed format elements, Variables: "_lLoOaAcCa09" + */ + public String getExpressionPostal_Add(); + + /** Column name HasPostal_Add */ + public static final String COLUMNNAME_HasPostal_Add = "HasPostal_Add"; + + /** Set Additional Postal code. + * Has Additional Postal Code + */ + public void setHasPostal_Add (boolean HasPostal_Add); + + /** Get Additional Postal code. + * Has Additional Postal Code + */ + public boolean isHasPostal_Add(); + + /** Column name HasRegion */ + public static final String COLUMNNAME_HasRegion = "HasRegion"; + + /** Set Country has Region. + * Country contains Regions + */ + public void setHasRegion (boolean HasRegion); + + /** Get Country has Region. + * Country contains Regions + */ + public boolean isHasRegion(); + + /** Column name IsActive */ + public static final String COLUMNNAME_IsActive = "IsActive"; + + /** Set Active. + * The record is active in the system + */ + public void setIsActive (boolean IsActive); + + /** Get Active. + * The record is active in the system + */ + public boolean isActive(); + + /** Column name IsAddressLinesLocalReverse */ + public static final String COLUMNNAME_IsAddressLinesLocalReverse = "IsAddressLinesLocalReverse"; + + /** Set Reverse Local Address Lines. + * Print Local Address in reverse Order + */ + public void setIsAddressLinesLocalReverse (boolean IsAddressLinesLocalReverse); + + /** Get Reverse Local Address Lines. + * Print Local Address in reverse Order + */ + public boolean isAddressLinesLocalReverse(); + + /** Column name IsAddressLinesReverse */ + public static final String COLUMNNAME_IsAddressLinesReverse = "IsAddressLinesReverse"; + + /** Set Reverse Address Lines. + * Print Address in reverse Order + */ + public void setIsAddressLinesReverse (boolean IsAddressLinesReverse); + + /** Get Reverse Address Lines. + * Print Address in reverse Order + */ + public boolean isAddressLinesReverse(); + + /** Column name IsPostcodeLookup */ + public static final String COLUMNNAME_IsPostcodeLookup = "IsPostcodeLookup"; + + /** Set IsPostcodeLookup. + * Does this country have a post code web service + */ + public void setIsPostcodeLookup (boolean IsPostcodeLookup); + + /** Get IsPostcodeLookup. + * Does this country have a post code web service + */ + public boolean isPostcodeLookup(); + + /** Column name LookupClassName */ + public static final String COLUMNNAME_LookupClassName = "LookupClassName"; + + /** Set LookupClassName. + * The class name of the postcode lookup plugin + */ + public void setLookupClassName (String LookupClassName); + + /** Get LookupClassName. + * The class name of the postcode lookup plugin + */ + public String getLookupClassName(); + + /** Column name LookupClientID */ + public static final String COLUMNNAME_LookupClientID = "LookupClientID"; + + /** Set LookupClientID. + * The ClientID or Login submitted to the Lookup URL + */ + public void setLookupClientID (String LookupClientID); + + /** Get LookupClientID. + * The ClientID or Login submitted to the Lookup URL + */ + public String getLookupClientID(); + + /** Column name LookupPassword */ + public static final String COLUMNNAME_LookupPassword = "LookupPassword"; + + /** Set LookupPassword. + * The password submitted to the Lookup URL + */ + public void setLookupPassword (String LookupPassword); + + /** Get LookupPassword. + * The password submitted to the Lookup URL + */ + public String getLookupPassword(); + + /** Column name LookupUrl */ + public static final String COLUMNNAME_LookupUrl = "LookupUrl"; + + /** Set LookupUrl. + * The URL of the web service that the plugin connects to in order to retrieve postcode data + */ + public void setLookupUrl (String LookupUrl); + + /** Get LookupUrl. + * The URL of the web service that the plugin connects to in order to retrieve postcode data + */ + public String getLookupUrl(); + + /** Column name MediaSize */ + public static final String COLUMNNAME_MediaSize = "MediaSize"; + + /** Set Media Size. + * Java Media Size + */ + public void setMediaSize (String MediaSize); + + /** Get Media Size. + * Java Media Size + */ + public String getMediaSize(); + + /** Column name Name */ + public static final String COLUMNNAME_Name = "Name"; + + /** Set Name. + * Alphanumeric identifier of the entity + */ + public void setName (String Name); + + /** Get Name. + * Alphanumeric identifier of the entity + */ + public String getName(); + + /** Column name RegionName */ + public static final String COLUMNNAME_RegionName = "RegionName"; + + /** Set Region. + * Name of the Region + */ + public void setRegionName (String RegionName); + + /** Get Region. + * Name of the Region + */ + public String getRegionName(); + + /** Column name Updated */ + public static final String COLUMNNAME_Updated = "Updated"; + + /** Get Updated. + * Date this record was updated + */ + public Timestamp getUpdated(); + + /** Column name UpdatedBy */ + public static final String COLUMNNAME_UpdatedBy = "UpdatedBy"; + + /** Get Updated By. + * User who updated this records + */ + public int getUpdatedBy(); +} diff --git a/base/src/org/compiere/model/MCity.java b/base/src/org/compiere/model/MCity.java new file mode 100644 index 0000000000..bfb4d80b34 --- /dev/null +++ b/base/src/org/compiere/model/MCity.java @@ -0,0 +1,132 @@ +/****************************************************************************** + * 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.compiere.model; + +import java.io.Serializable; +import java.sql.ResultSet; +import java.util.Comparator; +import java.util.Properties; + +import org.compiere.util.CCache; +import org.compiere.util.CLogger; + +/** + * Location City Model (Value Object) + * + * @author Mario Calderon / Carlos Ruiz + */ +public final class MCity extends X_C_City + implements Comparator, Serializable +{ + /** + * + */ + private static final long serialVersionUID = -8905525315954621942L; + + /** + * Get City (cached) + * @param ctx context + * @param C_City_ID ID + * @return City + */ + public static MCity get (Properties ctx, int C_City_ID) + { + Integer key = new Integer (C_City_ID); + MCity r = s_Cities.get(key); + if (r != null) + return r; + r = new MCity (ctx, C_City_ID, null); + if (r.getC_City_ID() == C_City_ID) + { + s_Cities.put(key, r); + return r; + } + return null; + } // get + + /** City Cache */ + private static CCache s_Cities = new CCache("C_City", 20);; + /** Static Logger */ + private static CLogger s_log = CLogger.getCLogger (MCity.class); + + /** Region Cache */ + + /************************************************************************** + * Create empty City + * @param ctx context + * @param C_City_ID id + * @param trxName transaction + */ + public MCity (Properties ctx, int C_City_ID, String trxName) + { + super (ctx, C_City_ID, trxName); + if (C_City_ID == 0) + { + } + } // MCity + + + /** + * Create City from current row in ResultSet + * @param ctx context + * @param rs result set + * @param trxName transaction + */ + public MCity (Properties ctx, ResultSet rs, String trxName) + { + super(ctx, rs, trxName); + } // MCity + + /** + * Parent Constructor + * @param Region Region + * @param CityName City Name + */ + public MCity (MRegion region, String cityName) + { + super (region.getCtx(), 0, region.get_TrxName()); + setC_Region_ID(region.getC_Region_ID()); + setName(cityName); + } // MCity + + /** + * Return Name + * @return Name + */ + public String toString() + { + return getName(); + } // toString + + /** + * Compare + * @param o1 object 1 + * @param o2 object 2 + * @return -1,0, 1 + */ + public int compare(Object o1, Object o2) + { + String s1 = o1.toString(); + if (s1 == null) + s1 = ""; + String s2 = o2.toString(); + if (s2 == null) + s2 = ""; + return s1.compareTo(s2); + } // compare + +} // MCity diff --git a/base/src/org/compiere/model/MLocation.java b/base/src/org/compiere/model/MLocation.java index 94152145ba..026ba3f568 100644 --- a/base/src/org/compiere/model/MLocation.java +++ b/base/src/org/compiere/model/MLocation.java @@ -27,6 +27,7 @@ import org.compiere.util.CCache; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; +import org.compiere.util.Msg; import org.compiere.util.Util; /** @@ -37,6 +38,7 @@ import org.compiere.util.Util; * * @author Michael Judd (Akuna Ltd) *
  • BF [ 2695078 ] Country is not translated on invoice + *
  • FR [2794312 ] Location AutoComplete - check if allow cities out of list */ public class MLocation extends X_C_Location implements Comparator { @@ -203,6 +205,10 @@ public class MLocation extends X_C_Location implements Comparator */ public MCountry getCountry() { + // Reset country if not match + if (m_c != null && m_c.get_ID() != getC_Country_ID()) + m_c = null; + // Load if (m_c == null) { if (getC_Country_ID() != 0) @@ -257,14 +263,17 @@ public class MLocation extends X_C_Location implements Comparator { m_r = region; if (region == null) + { super.setC_Region_ID(0); + } else { super.setC_Region_ID(m_r.getC_Region_ID()); + setRegionName(m_r.getName()); if (m_r.getC_Country_ID() != getC_Country_ID()) { log.info("Region(" + region + ") C_Country_ID=" + region.getC_Country_ID() - + " - From C_Country_ID=" + getC_Country_ID()); + + " - From C_Country_ID=" + getC_Country_ID()); setC_Country_ID(region.getC_Country_ID()); } } @@ -297,6 +306,10 @@ public class MLocation extends X_C_Location implements Comparator */ public MRegion getRegion() { + // Reset region if not match + if (m_r != null && m_r.get_ID() != getC_Region_ID()) + m_r = null; + // if (m_r == null && getC_Region_ID() != 0) m_r = MRegion.get(getCtx(), getC_Region_ID()); return m_r; @@ -594,9 +607,23 @@ public class MLocation extends X_C_Location implements Comparator if (!m_c.isHasRegion()) setC_Region_ID(0); } + if (getC_City_ID() <= 0 && getCity() != null && getCity().length() > 0) { + int city_id = DB.getSQLValue( + get_TrxName(), + "SELECT C_City_ID FROM C_City WHERE C_Country_ID=? AND COALESCE(C_Region_ID,0)=? AND Name=?", + new Object[] {getC_Country_ID(), getC_Region_ID(), getCity()}); + if (city_id > 0) + setC_City_ID(city_id); + } + + //check city + if (m_c != null && !m_c.isAllowCitiesOutOfList() && getC_City_ID()<=0) { + log.saveError("CityNotFound", Msg.translate(getCtx(), "CityNotFound")); + return false; + } return true; - } // geforeSave + } // beforeSave /** * After Save diff --git a/base/src/org/compiere/model/MSetup.java b/base/src/org/compiere/model/MSetup.java index d5290bb0d6..bc59591b1d 100644 --- a/base/src/org/compiere/model/MSetup.java +++ b/base/src/org/compiere/model/MSetup.java @@ -1319,4 +1319,14 @@ public final class MSetup { return m_info.toString(); } + + /** + * Rollback Internal Transaction + */ + public void rollback() { + try { + m_trx.rollback(); + m_trx.close(); + } catch (Exception e) {} + } } // MSetup diff --git a/base/src/org/compiere/model/X_C_Country.java b/base/src/org/compiere/model/X_C_Country.java index 02168f019c..b0d0f00c39 100644 --- a/base/src/org/compiere/model/X_C_Country.java +++ b/base/src/org/compiere/model/X_C_Country.java @@ -1,551 +1,589 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2007 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 * - *****************************************************************************/ -/** Generated Model - DO NOT CHANGE */ -package org.compiere.model; - -import java.sql.ResultSet; -import java.util.Properties; -import org.compiere.util.KeyNamePair; - -/** Generated Model for C_Country - * @author Adempiere (generated) - * @version Release 3.5.4a - $Id$ */ -public class X_C_Country extends PO implements I_C_Country, I_Persistent -{ - - /** - * - */ - private static final long serialVersionUID = 20090915L; - - /** Standard Constructor */ - public X_C_Country (Properties ctx, int C_Country_ID, String trxName) - { - super (ctx, C_Country_ID, trxName); - /** if (C_Country_ID == 0) - { - setC_Country_ID (0); - setCountryCode (null); - setDisplaySequence (null); -// @C@, @R@ @P@ - setHasPostal_Add (false); - setHasRegion (false); - setIsAddressLinesLocalReverse (false); - setIsAddressLinesReverse (false); - setName (null); - } */ - } - - /** Load Constructor */ - public X_C_Country (Properties ctx, ResultSet rs, String trxName) - { - super (ctx, rs, trxName); - } - - /** AccessLevel - * @return 6 - System - Client - */ - protected int get_AccessLevel() - { - return accessLevel.intValue(); - } - - /** Load Meta Data */ - protected POInfo initPO (Properties ctx) - { - POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName()); - return poi; - } - - public String toString() - { - StringBuffer sb = new StringBuffer ("X_C_Country[") - .append(get_ID()).append("]"); - return sb.toString(); - } - - /** AD_Language AD_Reference_ID=106 */ - public static final int AD_LANGUAGE_AD_Reference_ID=106; - /** Set Language. - @param AD_Language - Language for this entity - */ - public void setAD_Language (String AD_Language) - { - - set_Value (COLUMNNAME_AD_Language, AD_Language); - } - - /** Get Language. - @return Language for this entity - */ - public String getAD_Language () - { - return (String)get_Value(COLUMNNAME_AD_Language); - } - - /** Set Country. - @param C_Country_ID - Country - */ - public void setC_Country_ID (int C_Country_ID) - { - if (C_Country_ID < 1) - set_ValueNoCheck (COLUMNNAME_C_Country_ID, null); - else - set_ValueNoCheck (COLUMNNAME_C_Country_ID, Integer.valueOf(C_Country_ID)); - } - - /** Get Country. - @return Country - */ - public int getC_Country_ID () - { - Integer ii = (Integer)get_Value(COLUMNNAME_C_Country_ID); - if (ii == null) - return 0; - return ii.intValue(); - } - - public I_C_Currency getC_Currency() throws RuntimeException - { - return (I_C_Currency)MTable.get(getCtx(), I_C_Currency.Table_Name) - .getPO(getC_Currency_ID(), get_TrxName()); } - - /** Set Currency. - @param C_Currency_ID - The Currency for this record - */ - public void setC_Currency_ID (int C_Currency_ID) - { - if (C_Currency_ID < 1) - set_Value (COLUMNNAME_C_Currency_ID, null); - else - set_Value (COLUMNNAME_C_Currency_ID, Integer.valueOf(C_Currency_ID)); - } - - /** Get Currency. - @return The Currency for this record - */ - public int getC_Currency_ID () - { - Integer ii = (Integer)get_Value(COLUMNNAME_C_Currency_ID); - if (ii == null) - return 0; - return ii.intValue(); - } - - /** Set ISO Country Code. - @param CountryCode - Upper-case two-letter alphanumeric ISO Country code according to ISO 3166-1 - http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html - */ - public void setCountryCode (String CountryCode) - { - set_Value (COLUMNNAME_CountryCode, CountryCode); - } - - /** Get ISO Country Code. - @return Upper-case two-letter alphanumeric ISO Country code according to ISO 3166-1 - http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html - */ - public String getCountryCode () - { - return (String)get_Value(COLUMNNAME_CountryCode); - } - - /** Set Description. - @param Description - Optional short description of the record - */ - public void setDescription (String Description) - { - set_Value (COLUMNNAME_Description, Description); - } - - /** Get Description. - @return Optional short description of the record - */ - public String getDescription () - { - return (String)get_Value(COLUMNNAME_Description); - } - - /** Set Address Print Format. - @param DisplaySequence - Format for printing this Address - */ - public void setDisplaySequence (String DisplaySequence) - { - set_Value (COLUMNNAME_DisplaySequence, DisplaySequence); - } - - /** Get Address Print Format. - @return Format for printing this Address - */ - public String getDisplaySequence () - { - return (String)get_Value(COLUMNNAME_DisplaySequence); - } - - /** Set Local Address Format. - @param DisplaySequenceLocal - Format for printing this Address locally - */ - public void setDisplaySequenceLocal (String DisplaySequenceLocal) - { - set_Value (COLUMNNAME_DisplaySequenceLocal, DisplaySequenceLocal); - } - - /** Get Local Address Format. - @return Format for printing this Address locally - */ - public String getDisplaySequenceLocal () - { - return (String)get_Value(COLUMNNAME_DisplaySequenceLocal); - } - - /** Set Bank Account No Format. - @param ExpressionBankAccountNo - Format of the Bank Account - */ - public void setExpressionBankAccountNo (String ExpressionBankAccountNo) - { - set_Value (COLUMNNAME_ExpressionBankAccountNo, ExpressionBankAccountNo); - } - - /** Get Bank Account No Format. - @return Format of the Bank Account - */ - public String getExpressionBankAccountNo () - { - return (String)get_Value(COLUMNNAME_ExpressionBankAccountNo); - } - - /** Set Bank Routing No Format. - @param ExpressionBankRoutingNo - Format of the Bank Routing Number - */ - public void setExpressionBankRoutingNo (String ExpressionBankRoutingNo) - { - set_Value (COLUMNNAME_ExpressionBankRoutingNo, ExpressionBankRoutingNo); - } - - /** Get Bank Routing No Format. - @return Format of the Bank Routing Number - */ - public String getExpressionBankRoutingNo () - { - return (String)get_Value(COLUMNNAME_ExpressionBankRoutingNo); - } - - /** Set Phone Format. - @param ExpressionPhone - Format of the phone; Can contain fixed format elements, Variables: "_lLoOaAcCa09" - */ - public void setExpressionPhone (String ExpressionPhone) - { - set_Value (COLUMNNAME_ExpressionPhone, ExpressionPhone); - } - - /** Get Phone Format. - @return Format of the phone; Can contain fixed format elements, Variables: "_lLoOaAcCa09" - */ - public String getExpressionPhone () - { - return (String)get_Value(COLUMNNAME_ExpressionPhone); - } - - /** Set Postal Code Format. - @param ExpressionPostal - Format of the postal code; Can contain fixed format elements, Variables: "_lLoOaAcCa09" - */ - public void setExpressionPostal (String ExpressionPostal) - { - set_Value (COLUMNNAME_ExpressionPostal, ExpressionPostal); - } - - /** Get Postal Code Format. - @return Format of the postal code; Can contain fixed format elements, Variables: "_lLoOaAcCa09" - */ - public String getExpressionPostal () - { - return (String)get_Value(COLUMNNAME_ExpressionPostal); - } - - /** Set Additional Postal Format. - @param ExpressionPostal_Add - Format of the value; Can contain fixed format elements, Variables: "_lLoOaAcCa09" - */ - public void setExpressionPostal_Add (String ExpressionPostal_Add) - { - set_Value (COLUMNNAME_ExpressionPostal_Add, ExpressionPostal_Add); - } - - /** Get Additional Postal Format. - @return Format of the value; Can contain fixed format elements, Variables: "_lLoOaAcCa09" - */ - public String getExpressionPostal_Add () - { - return (String)get_Value(COLUMNNAME_ExpressionPostal_Add); - } - - /** Set Additional Postal code. - @param HasPostal_Add - Has Additional Postal Code - */ - public void setHasPostal_Add (boolean HasPostal_Add) - { - set_Value (COLUMNNAME_HasPostal_Add, Boolean.valueOf(HasPostal_Add)); - } - - /** Get Additional Postal code. - @return Has Additional Postal Code - */ - public boolean isHasPostal_Add () - { - Object oo = get_Value(COLUMNNAME_HasPostal_Add); - if (oo != null) - { - if (oo instanceof Boolean) - return ((Boolean)oo).booleanValue(); - return "Y".equals(oo); - } - return false; - } - - /** Set Country has Region. - @param HasRegion - Country contains Regions - */ - public void setHasRegion (boolean HasRegion) - { - set_Value (COLUMNNAME_HasRegion, Boolean.valueOf(HasRegion)); - } - - /** Get Country has Region. - @return Country contains Regions - */ - public boolean isHasRegion () - { - Object oo = get_Value(COLUMNNAME_HasRegion); - if (oo != null) - { - if (oo instanceof Boolean) - return ((Boolean)oo).booleanValue(); - return "Y".equals(oo); - } - return false; - } - - /** Set Reverse Local Address Lines. - @param IsAddressLinesLocalReverse - Print Local Address in reverse Order - */ - public void setIsAddressLinesLocalReverse (boolean IsAddressLinesLocalReverse) - { - set_Value (COLUMNNAME_IsAddressLinesLocalReverse, Boolean.valueOf(IsAddressLinesLocalReverse)); - } - - /** Get Reverse Local Address Lines. - @return Print Local Address in reverse Order - */ - public boolean isAddressLinesLocalReverse () - { - Object oo = get_Value(COLUMNNAME_IsAddressLinesLocalReverse); - if (oo != null) - { - if (oo instanceof Boolean) - return ((Boolean)oo).booleanValue(); - return "Y".equals(oo); - } - return false; - } - - /** Set Reverse Address Lines. - @param IsAddressLinesReverse - Print Address in reverse Order - */ - public void setIsAddressLinesReverse (boolean IsAddressLinesReverse) - { - set_Value (COLUMNNAME_IsAddressLinesReverse, Boolean.valueOf(IsAddressLinesReverse)); - } - - /** Get Reverse Address Lines. - @return Print Address in reverse Order - */ - public boolean isAddressLinesReverse () - { - Object oo = get_Value(COLUMNNAME_IsAddressLinesReverse); - if (oo != null) - { - if (oo instanceof Boolean) - return ((Boolean)oo).booleanValue(); - return "Y".equals(oo); - } - return false; - } - - /** Set IsPostcodeLookup. - @param IsPostcodeLookup - Does this country have a post code web service - */ - public void setIsPostcodeLookup (boolean IsPostcodeLookup) - { - set_Value (COLUMNNAME_IsPostcodeLookup, Boolean.valueOf(IsPostcodeLookup)); - } - - /** Get IsPostcodeLookup. - @return Does this country have a post code web service - */ - public boolean isPostcodeLookup () - { - Object oo = get_Value(COLUMNNAME_IsPostcodeLookup); - if (oo != null) - { - if (oo instanceof Boolean) - return ((Boolean)oo).booleanValue(); - return "Y".equals(oo); - } - return false; - } - - /** Set LookupClassName. - @param LookupClassName - The class name of the postcode lookup plugin - */ - public void setLookupClassName (String LookupClassName) - { - set_Value (COLUMNNAME_LookupClassName, LookupClassName); - } - - /** Get LookupClassName. - @return The class name of the postcode lookup plugin - */ - public String getLookupClassName () - { - return (String)get_Value(COLUMNNAME_LookupClassName); - } - - /** Set LookupClientID. - @param LookupClientID - The ClientID or Login submitted to the Lookup URL - */ - public void setLookupClientID (String LookupClientID) - { - set_Value (COLUMNNAME_LookupClientID, LookupClientID); - } - - /** Get LookupClientID. - @return The ClientID or Login submitted to the Lookup URL - */ - public String getLookupClientID () - { - return (String)get_Value(COLUMNNAME_LookupClientID); - } - - /** Set LookupPassword. - @param LookupPassword - The password submitted to the Lookup URL - */ - public void setLookupPassword (String LookupPassword) - { - set_Value (COLUMNNAME_LookupPassword, LookupPassword); - } - - /** Get LookupPassword. - @return The password submitted to the Lookup URL - */ - public String getLookupPassword () - { - return (String)get_Value(COLUMNNAME_LookupPassword); - } - - /** Set LookupUrl. - @param LookupUrl - The URL of the web service that the plugin connects to in order to retrieve postcode data - */ - public void setLookupUrl (String LookupUrl) - { - set_Value (COLUMNNAME_LookupUrl, LookupUrl); - } - - /** Get LookupUrl. - @return The URL of the web service that the plugin connects to in order to retrieve postcode data - */ - public String getLookupUrl () - { - return (String)get_Value(COLUMNNAME_LookupUrl); - } - - /** Set Media Size. - @param MediaSize - Java Media Size - */ - public void setMediaSize (String MediaSize) - { - set_Value (COLUMNNAME_MediaSize, MediaSize); - } - - /** Get Media Size. - @return Java Media Size - */ - public String getMediaSize () - { - return (String)get_Value(COLUMNNAME_MediaSize); - } - - /** Set Name. - @param Name - Alphanumeric identifier of the entity - */ - public void setName (String Name) - { - set_Value (COLUMNNAME_Name, Name); - } - - /** Get Name. - @return Alphanumeric identifier of the entity - */ - public String getName () - { - return (String)get_Value(COLUMNNAME_Name); - } - - /** Get Record ID/ColumnName - @return ID/ColumnName pair - */ - public KeyNamePair getKeyNamePair() - { - return new KeyNamePair(get_ID(), getName()); - } - - /** Set Region. - @param RegionName - Name of the Region - */ - public void setRegionName (String RegionName) - { - set_Value (COLUMNNAME_RegionName, RegionName); - } - - /** Get Region. - @return Name of the Region - */ - public String getRegionName () - { - return (String)get_Value(COLUMNNAME_RegionName); - } +/****************************************************************************** + * Product: Adempiere ERP & CRM Smart Business Solution * + * Copyright (C) 1999-2007 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 * + *****************************************************************************/ +/** Generated Model - DO NOT CHANGE */ +package org.compiere.model; + +import java.sql.ResultSet; +import java.util.Properties; +import org.compiere.util.KeyNamePair; + +/** Generated Model for C_Country + * @author Adempiere (generated) + * @version Release 3.5.4a - $Id$ */ +public class X_C_Country extends PO implements I_C_Country, I_Persistent +{ + + /** + * + */ + private static final long serialVersionUID = 20090915L; + + /** Standard Constructor */ + public X_C_Country (Properties ctx, int C_Country_ID, String trxName) + { + super (ctx, C_Country_ID, trxName); + /** if (C_Country_ID == 0) + { + setC_Country_ID (0); + setCountryCode (null); + setDisplaySequence (null); +// @C@, @R@ @P@ + setHasPostal_Add (false); + setHasRegion (false); + setIsAddressLinesLocalReverse (false); + setIsAddressLinesReverse (false); + setName (null); + } */ + } + + /** Load Constructor */ + public X_C_Country (Properties ctx, ResultSet rs, String trxName) + { + super (ctx, rs, trxName); + } + + /** AccessLevel + * @return 6 - System - Client + */ + protected int get_AccessLevel() + { + return accessLevel.intValue(); + } + + /** Load Meta Data */ + protected POInfo initPO (Properties ctx) + { + POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName()); + return poi; + } + + public String toString() + { + StringBuffer sb = new StringBuffer ("X_C_Country[") + .append(get_ID()).append("]"); + return sb.toString(); + } + + /** AD_Language AD_Reference_ID=106 */ + public static final int AD_LANGUAGE_AD_Reference_ID=106; + /** Set Language. + @param AD_Language + Language for this entity + */ + public void setAD_Language (String AD_Language) + { + + set_Value (COLUMNNAME_AD_Language, AD_Language); + } + + /** Get Language. + @return Language for this entity + */ + public String getAD_Language () + { + return (String)get_Value(COLUMNNAME_AD_Language); + } + + /** Set AllowCitiesOutOfList. + @param AllowCitiesOutOfList + A flag which tells if a country accept or not new cities + */ + public void setAllowCitiesOutOfList (boolean AllowCitiesOutOfList) + { + set_Value (COLUMNNAME_AllowCitiesOutOfList, Boolean.valueOf(AllowCitiesOutOfList)); + } + + /** Get AllowCitiesOutOfList. + @return A flag which tells if a country accept or not new cities + */ + public boolean isAllowCitiesOutOfList () + { + Object oo = get_Value(COLUMNNAME_AllowCitiesOutOfList); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + /** Set CaptureSequence. + @param CaptureSequence CaptureSequence */ + public void setCaptureSequence (String CaptureSequence) + { + set_Value (COLUMNNAME_CaptureSequence, CaptureSequence); + } + + /** Get CaptureSequence. + @return CaptureSequence */ + public String getCaptureSequence () + { + return (String)get_Value(COLUMNNAME_CaptureSequence); + } + + /** Set Country. + @param C_Country_ID + Country + */ + public void setC_Country_ID (int C_Country_ID) + { + if (C_Country_ID < 1) + set_ValueNoCheck (COLUMNNAME_C_Country_ID, null); + else + set_ValueNoCheck (COLUMNNAME_C_Country_ID, Integer.valueOf(C_Country_ID)); + } + + /** Get Country. + @return Country + */ + public int getC_Country_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_Country_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public I_C_Currency getC_Currency() throws RuntimeException + { + return (I_C_Currency)MTable.get(getCtx(), I_C_Currency.Table_Name) + .getPO(getC_Currency_ID(), get_TrxName()); } + + /** Set Currency. + @param C_Currency_ID + The Currency for this record + */ + public void setC_Currency_ID (int C_Currency_ID) + { + if (C_Currency_ID < 1) + set_Value (COLUMNNAME_C_Currency_ID, null); + else + set_Value (COLUMNNAME_C_Currency_ID, Integer.valueOf(C_Currency_ID)); + } + + /** Get Currency. + @return The Currency for this record + */ + public int getC_Currency_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_Currency_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set ISO Country Code. + @param CountryCode + Upper-case two-letter alphanumeric ISO Country code according to ISO 3166-1 - http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html + */ + public void setCountryCode (String CountryCode) + { + set_Value (COLUMNNAME_CountryCode, CountryCode); + } + + /** Get ISO Country Code. + @return Upper-case two-letter alphanumeric ISO Country code according to ISO 3166-1 - http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html + */ + public String getCountryCode () + { + return (String)get_Value(COLUMNNAME_CountryCode); + } + + /** Set Description. + @param Description + Optional short description of the record + */ + public void setDescription (String Description) + { + set_Value (COLUMNNAME_Description, Description); + } + + /** Get Description. + @return Optional short description of the record + */ + public String getDescription () + { + return (String)get_Value(COLUMNNAME_Description); + } + + /** Set Address Print Format. + @param DisplaySequence + Format for printing this Address + */ + public void setDisplaySequence (String DisplaySequence) + { + set_Value (COLUMNNAME_DisplaySequence, DisplaySequence); + } + + /** Get Address Print Format. + @return Format for printing this Address + */ + public String getDisplaySequence () + { + return (String)get_Value(COLUMNNAME_DisplaySequence); + } + + /** Set Local Address Format. + @param DisplaySequenceLocal + Format for printing this Address locally + */ + public void setDisplaySequenceLocal (String DisplaySequenceLocal) + { + set_Value (COLUMNNAME_DisplaySequenceLocal, DisplaySequenceLocal); + } + + /** Get Local Address Format. + @return Format for printing this Address locally + */ + public String getDisplaySequenceLocal () + { + return (String)get_Value(COLUMNNAME_DisplaySequenceLocal); + } + + /** Set Bank Account No Format. + @param ExpressionBankAccountNo + Format of the Bank Account + */ + public void setExpressionBankAccountNo (String ExpressionBankAccountNo) + { + set_Value (COLUMNNAME_ExpressionBankAccountNo, ExpressionBankAccountNo); + } + + /** Get Bank Account No Format. + @return Format of the Bank Account + */ + public String getExpressionBankAccountNo () + { + return (String)get_Value(COLUMNNAME_ExpressionBankAccountNo); + } + + /** Set Bank Routing No Format. + @param ExpressionBankRoutingNo + Format of the Bank Routing Number + */ + public void setExpressionBankRoutingNo (String ExpressionBankRoutingNo) + { + set_Value (COLUMNNAME_ExpressionBankRoutingNo, ExpressionBankRoutingNo); + } + + /** Get Bank Routing No Format. + @return Format of the Bank Routing Number + */ + public String getExpressionBankRoutingNo () + { + return (String)get_Value(COLUMNNAME_ExpressionBankRoutingNo); + } + + /** Set Phone Format. + @param ExpressionPhone + Format of the phone; Can contain fixed format elements, Variables: "_lLoOaAcCa09" + */ + public void setExpressionPhone (String ExpressionPhone) + { + set_Value (COLUMNNAME_ExpressionPhone, ExpressionPhone); + } + + /** Get Phone Format. + @return Format of the phone; Can contain fixed format elements, Variables: "_lLoOaAcCa09" + */ + public String getExpressionPhone () + { + return (String)get_Value(COLUMNNAME_ExpressionPhone); + } + + /** Set Postal Code Format. + @param ExpressionPostal + Format of the postal code; Can contain fixed format elements, Variables: "_lLoOaAcCa09" + */ + public void setExpressionPostal (String ExpressionPostal) + { + set_Value (COLUMNNAME_ExpressionPostal, ExpressionPostal); + } + + /** Get Postal Code Format. + @return Format of the postal code; Can contain fixed format elements, Variables: "_lLoOaAcCa09" + */ + public String getExpressionPostal () + { + return (String)get_Value(COLUMNNAME_ExpressionPostal); + } + + /** Set Additional Postal Format. + @param ExpressionPostal_Add + Format of the value; Can contain fixed format elements, Variables: "_lLoOaAcCa09" + */ + public void setExpressionPostal_Add (String ExpressionPostal_Add) + { + set_Value (COLUMNNAME_ExpressionPostal_Add, ExpressionPostal_Add); + } + + /** Get Additional Postal Format. + @return Format of the value; Can contain fixed format elements, Variables: "_lLoOaAcCa09" + */ + public String getExpressionPostal_Add () + { + return (String)get_Value(COLUMNNAME_ExpressionPostal_Add); + } + + /** Set Additional Postal code. + @param HasPostal_Add + Has Additional Postal Code + */ + public void setHasPostal_Add (boolean HasPostal_Add) + { + set_Value (COLUMNNAME_HasPostal_Add, Boolean.valueOf(HasPostal_Add)); + } + + /** Get Additional Postal code. + @return Has Additional Postal Code + */ + public boolean isHasPostal_Add () + { + Object oo = get_Value(COLUMNNAME_HasPostal_Add); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + /** Set Country has Region. + @param HasRegion + Country contains Regions + */ + public void setHasRegion (boolean HasRegion) + { + set_Value (COLUMNNAME_HasRegion, Boolean.valueOf(HasRegion)); + } + + /** Get Country has Region. + @return Country contains Regions + */ + public boolean isHasRegion () + { + Object oo = get_Value(COLUMNNAME_HasRegion); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + /** Set Reverse Local Address Lines. + @param IsAddressLinesLocalReverse + Print Local Address in reverse Order + */ + public void setIsAddressLinesLocalReverse (boolean IsAddressLinesLocalReverse) + { + set_Value (COLUMNNAME_IsAddressLinesLocalReverse, Boolean.valueOf(IsAddressLinesLocalReverse)); + } + + /** Get Reverse Local Address Lines. + @return Print Local Address in reverse Order + */ + public boolean isAddressLinesLocalReverse () + { + Object oo = get_Value(COLUMNNAME_IsAddressLinesLocalReverse); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + /** Set Reverse Address Lines. + @param IsAddressLinesReverse + Print Address in reverse Order + */ + public void setIsAddressLinesReverse (boolean IsAddressLinesReverse) + { + set_Value (COLUMNNAME_IsAddressLinesReverse, Boolean.valueOf(IsAddressLinesReverse)); + } + + /** Get Reverse Address Lines. + @return Print Address in reverse Order + */ + public boolean isAddressLinesReverse () + { + Object oo = get_Value(COLUMNNAME_IsAddressLinesReverse); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + /** Set IsPostcodeLookup. + @param IsPostcodeLookup + Does this country have a post code web service + */ + public void setIsPostcodeLookup (boolean IsPostcodeLookup) + { + set_Value (COLUMNNAME_IsPostcodeLookup, Boolean.valueOf(IsPostcodeLookup)); + } + + /** Get IsPostcodeLookup. + @return Does this country have a post code web service + */ + public boolean isPostcodeLookup () + { + Object oo = get_Value(COLUMNNAME_IsPostcodeLookup); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + /** Set LookupClassName. + @param LookupClassName + The class name of the postcode lookup plugin + */ + public void setLookupClassName (String LookupClassName) + { + set_Value (COLUMNNAME_LookupClassName, LookupClassName); + } + + /** Get LookupClassName. + @return The class name of the postcode lookup plugin + */ + public String getLookupClassName () + { + return (String)get_Value(COLUMNNAME_LookupClassName); + } + + /** Set LookupClientID. + @param LookupClientID + The ClientID or Login submitted to the Lookup URL + */ + public void setLookupClientID (String LookupClientID) + { + set_Value (COLUMNNAME_LookupClientID, LookupClientID); + } + + /** Get LookupClientID. + @return The ClientID or Login submitted to the Lookup URL + */ + public String getLookupClientID () + { + return (String)get_Value(COLUMNNAME_LookupClientID); + } + + /** Set LookupPassword. + @param LookupPassword + The password submitted to the Lookup URL + */ + public void setLookupPassword (String LookupPassword) + { + set_Value (COLUMNNAME_LookupPassword, LookupPassword); + } + + /** Get LookupPassword. + @return The password submitted to the Lookup URL + */ + public String getLookupPassword () + { + return (String)get_Value(COLUMNNAME_LookupPassword); + } + + /** Set LookupUrl. + @param LookupUrl + The URL of the web service that the plugin connects to in order to retrieve postcode data + */ + public void setLookupUrl (String LookupUrl) + { + set_Value (COLUMNNAME_LookupUrl, LookupUrl); + } + + /** Get LookupUrl. + @return The URL of the web service that the plugin connects to in order to retrieve postcode data + */ + public String getLookupUrl () + { + return (String)get_Value(COLUMNNAME_LookupUrl); + } + + /** Set Media Size. + @param MediaSize + Java Media Size + */ + public void setMediaSize (String MediaSize) + { + set_Value (COLUMNNAME_MediaSize, MediaSize); + } + + /** Get Media Size. + @return Java Media Size + */ + public String getMediaSize () + { + return (String)get_Value(COLUMNNAME_MediaSize); + } + + /** Set Name. + @param Name + Alphanumeric identifier of the entity + */ + public void setName (String Name) + { + set_Value (COLUMNNAME_Name, Name); + } + + /** Get Name. + @return Alphanumeric identifier of the entity + */ + public String getName () + { + return (String)get_Value(COLUMNNAME_Name); + } + + /** Get Record ID/ColumnName + @return ID/ColumnName pair + */ + public KeyNamePair getKeyNamePair() + { + return new KeyNamePair(get_ID(), getName()); + } + + /** Set Region. + @param RegionName + Name of the Region + */ + public void setRegionName (String RegionName) + { + set_Value (COLUMNNAME_RegionName, RegionName); + } + + /** Get Region. + @return Name of the Region + */ + public String getRegionName () + { + return (String)get_Value(COLUMNNAME_RegionName); + } } \ No newline at end of file diff --git a/client/src/org/compiere/apps/form/VSetup.java b/client/src/org/compiere/apps/form/VSetup.java index a4830b2752..7a0c3e496c 100644 --- a/client/src/org/compiere/apps/form/VSetup.java +++ b/client/src/org/compiere/apps/form/VSetup.java @@ -57,6 +57,7 @@ import org.compiere.util.Msg; * * @author Jorg Janke * @version $Id: VSetup.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ + * @deprecated */ public class VSetup extends CPanel implements FormPanel, ActionListener, Runnable diff --git a/client/src/org/compiere/grid/ed/AutoCompleter.java b/client/src/org/compiere/grid/ed/AutoCompleter.java new file mode 100644 index 0000000000..87dbb5473d --- /dev/null +++ b/client/src/org/compiere/grid/ed/AutoCompleter.java @@ -0,0 +1,290 @@ +package org.compiere.grid.ed; + +import java.awt.Color; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.MouseListener; + +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JList; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.KeyStroke; +import javax.swing.ListModel; +import javax.swing.Timer; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.JTextComponent; + +import org.compiere.util.CLogger; + +/** + * @author Santhosh Kumar T - santhosh@in.fiorano.com + *
  • Initial contribution - http://www.jroller.com/santhosh/date/20050620#file_path_autocompletion + * @author Teo Sarca , www.arhipac.ro + *
  • added timed triggering + *
  • refactored + * @author Cristina Ghita , www.arhipac.ro + *
  • refactored + */ +public abstract class AutoCompleter implements MouseListener +{ + + private static final long serialVersionUID = -5135462631871597277L; + private static final String AUTOCOMPLETER = "AUTOCOMPLETER"; //NOI18N + private static final int PopupDelayMillis = 500; + + protected final CLogger log = CLogger.getCLogger(getClass()); + + final JList listBox = new JList(); + final JTextComponent textBox; + final private JPopupMenu popup = new JPopupMenu(); + private boolean m_empty = false; + + private final Timer timer = new Timer(PopupDelayMillis, new ActionListener(){ + public void actionPerformed(ActionEvent e) + { + showPopup(); + } + }); + + public AutoCompleter(JTextComponent comp) + { + textBox = comp; + textBox.putClientProperty(AUTOCOMPLETER, this); + + JScrollPane scroll = new JScrollPane(listBox); + scroll.setBorder(null); + + listBox.setFocusable( false ); + listBox.addMouseListener(this); + scroll.getVerticalScrollBar().setFocusable( false ); + scroll.getHorizontalScrollBar().setFocusable( false ); + + popup.setBorder(BorderFactory.createLineBorder(Color.black)); + popup.add(scroll); + + if(textBox instanceof JTextField) + { + textBox.registerKeyboardAction(showAction, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), JComponent.WHEN_FOCUSED); + textBox.getDocument().addDocumentListener(documentListener); + } + + textBox.registerKeyboardAction(upAction, KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), JComponent.WHEN_FOCUSED); + textBox.registerKeyboardAction(hidePopupAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_FOCUSED); + popup.addPopupMenuListener(new PopupMenuListener() { + public void popupMenuWillBecomeVisible(PopupMenuEvent e) + { + } + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) + { + textBox.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)); + } + public void popupMenuCanceled(PopupMenuEvent e) + { + } + }); + listBox.setRequestFocusEnabled(false); + } + + public boolean isEmpty() + { + return m_empty; + } + + public void setEmpty(boolean empty) + { + m_empty = empty; + } + + private static final Action acceptAction = new AbstractAction() + { + private static final long serialVersionUID = -3950389799318995148L; + public void actionPerformed(ActionEvent e) + { + JComponent tf = (JComponent)e.getSource(); + AutoCompleter completer = (AutoCompleter)tf.getClientProperty(AUTOCOMPLETER); + completer.popup.setVisible(false); + if (completer.listBox.getSelectedValue() == null) + { + String txt = completer.textBox.getText(); + ListModel lm = completer.listBox.getModel(); + for (int index = 0; index < lm.getSize(); index++) + { + if (startsWithIgnoreCase(lm.getElementAt(index).toString(), txt)) + { + completer.acceptedListItem(lm.getElementAt(index)); + break; + } + } + } + else + { + completer.acceptedListItem(completer.listBox.getSelectedValue()); + } + } + }; + + private final DocumentListener documentListener = new DocumentListener() + { + public void insertUpdate(DocumentEvent e) + { + showPopupDelayed(); + } + public void removeUpdate(DocumentEvent e) + { + showPopupDelayed(); + } + public void changedUpdate(DocumentEvent e) + { + } + }; + + private void showPopupDelayed() + { + log.finest("showPopupDelayed.."); + timer.setRepeats(false); + timer.start(); + } + + private void showPopup() + { + log.finest("showPopup"); + popup.setVisible(false); + if (textBox.isEnabled() && updateListData() && listBox.getModel().getSize() != 0) + { + setEmpty(false); + if(!(textBox instanceof JTextField)) + { + textBox.getDocument().addDocumentListener(documentListener); + } + textBox.registerKeyboardAction(acceptAction, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), JComponent.WHEN_FOCUSED); + int size = listBox.getModel().getSize(); + listBox.setVisibleRowCount(size<10 ? size : 10); + + int x = 0; + try{ + int pos = Math.min(textBox.getCaret().getDot(), textBox.getCaret().getMark()); + x = textBox.getUI().modelToView(textBox, pos).x; + } catch(BadLocationException e){ + // this should never happen!!! + e.printStackTrace(); + } + popup.show(textBox, x, textBox.getHeight()); + } + else + { + popup.setVisible(false); + setEmpty(true); + } + textBox.requestFocus(); + } + + static Action showAction = new AbstractAction() + { + private static final long serialVersionUID = 8868536979000734628L; + public void actionPerformed(ActionEvent e) + { + JComponent tf = (JComponent)e.getSource(); + AutoCompleter completer = (AutoCompleter)tf.getClientProperty(AUTOCOMPLETER); + if(tf.isEnabled()) + { + if(completer.popup.isVisible()) + completer.selectNextPossibleValue(); + else + completer.showPopup(); + } + } + }; + + private static final Action upAction = new AbstractAction() + { + private static final long serialVersionUID = 2200136359410394434L; + + public void actionPerformed(ActionEvent e) + { + JComponent tf = (JComponent)e.getSource(); + AutoCompleter completer = (AutoCompleter)tf.getClientProperty(AUTOCOMPLETER); + if(tf.isEnabled()) + { + if(completer.popup.isVisible()) + completer.selectPreviousPossibleValue(); + } + } + }; + + private static final Action hidePopupAction = new AbstractAction() + { + private static final long serialVersionUID = -5683983067872135654L; + + public void actionPerformed(ActionEvent e) + { + JComponent tf = (JComponent)e.getSource(); + AutoCompleter completer = (AutoCompleter)tf.getClientProperty(AUTOCOMPLETER); + if(tf.isEnabled()) + completer.popup.setVisible(false); + } + }; + + /** + * Selects the next item in the list. It won't change the selection if the + * currently selected item is already the last item. + */ + protected void selectNextPossibleValue() + { + int si = listBox.getSelectedIndex(); + + if(si < listBox.getModel().getSize() - 1){ + listBox.setSelectedIndex(si + 1); + listBox.ensureIndexIsVisible(si + 1); + } + } + + /** + * Selects the previous item in the list. It won't change the selection if the + * currently selected item is already the first item. + */ + protected void selectPreviousPossibleValue() + { + int si = listBox.getSelectedIndex(); + + if(si > 0){ + listBox.setSelectedIndex(si - 1); + listBox.ensureIndexIsVisible(si - 1); + } + } + + /** + * Checks if str1 starts with str2 (ignores case, trim whitespaces, strip diacritics) + * @param str1 + * @param str2 + * @return true if str1 starts with str2 + */ + protected static boolean startsWithIgnoreCase(String str1, String str2) + { + String s1 = org.compiere.util.Util.stripDiacritics(str1.toUpperCase()).trim(); + String s2 = org.compiere.util.Util.stripDiacritics(str2.toUpperCase()).trim(); + return s1.startsWith(s2); + } + + + /** + * Update list model depending on the data in textfield + * @return + */ + protected abstract boolean updateListData(); + + /** + * User has selected some item in the list. Update textfield accordingly... + * @param selected + */ + protected abstract void acceptedListItem(Object selected); +} \ No newline at end of file diff --git a/client/src/org/compiere/grid/ed/CityAutoCompleter.java b/client/src/org/compiere/grid/ed/CityAutoCompleter.java new file mode 100644 index 0000000000..24ade1f54b --- /dev/null +++ b/client/src/org/compiere/grid/ed/CityAutoCompleter.java @@ -0,0 +1,242 @@ +/****************************************************************************** + * Product: Adempiere ERP & CRM Smart Business Solution * + * Copyright (C) 2009 SC ARHIPAC SERVICE SRL. 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. * + *****************************************************************************/ +package org.compiere.grid.ed; + +import java.awt.Color; +import java.awt.event.MouseEvent; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; + +import javax.swing.text.JTextComponent; + +import org.adempiere.exceptions.DBException; +import org.compiere.model.MSysConfig; +import org.compiere.util.DB; +import org.compiere.util.Env; + +/** + * + * @author Cristina Ghita , www.arhipac.ro + * + */ +public class CityAutoCompleter extends AutoCompleter +{ + public static final CityVO ITEM_More = new CityVO(-1, "...", -1, ""); + private final int m_maxRows = MSysConfig.getIntValue("LOCATION_MAX_CITY_ROWS", 7); + private CityVO m_city = null; + private final int m_windowNo; + private ArrayList list = new ArrayList(); + private ArrayList listShow = new ArrayList(); + + public CityAutoCompleter(JTextComponent comp, int windowNo) + { + super(comp); + this.m_windowNo = windowNo; + listBox.setVisibleRowCount(m_maxRows); + setCity(null); + } + + + @Override + protected void acceptedListItem(Object selected) + { + if (selected == null || selected == ITEM_More) + { + setCity(null); + return; + } + CityVO item = (CityVO) selected; + setCity(item); + Env.setContext(Env.getCtx(), m_windowNo, Env.TAB_INFO, "C_Region_ID", String.valueOf(item.C_Region_ID)); + textBox.setText(item.CityName); + } + + @Override + protected boolean updateListData() + { + String search = textBox.getText(); + if (m_city != null && m_city.CityName.compareTo(search) != 0) + { + setCity(null); + } + listShow.clear(); + boolean truncated = false; + search = search.toUpperCase(); + int i = 0; + for (CityVO vo : list) { + if (vo.CityName.toUpperCase().startsWith(search)) { + if (i > 0 && i == m_maxRows+1) + { + listShow.add(ITEM_More); + truncated = true; + break; + } + listShow.add(vo); + i++; + } + } + this.listBox.setListData(listShow.toArray()); + //if there is no city on the list return false, to not show the popup + if (listShow.isEmpty()) + { + return false; + } + else + { + CityVO city = (CityVO) listShow.get(0); + if (city.CityName.equalsIgnoreCase(search)) + { + m_city = city; + return true; + } + } + //if the list has only one item, but that item is not equals with m_city + //return false to not show any popup + if (!truncated && listShow.size() == 1 + && m_city != null && listShow.get(0).equals(this.m_city)) + { + log.finest("nothing to do 1"); + return false; + } + return true; + } + + public void fillList() + { + // Carlos Ruiz - globalqss - improve to avoid going to the database on every keystroke + list.clear(); + listShow.clear(); + ArrayList params = new ArrayList(); + final StringBuffer sql = new StringBuffer( + "SELECT cy.C_City_ID, cy.Name, cy.C_Region_ID, r.Name" + +" FROM C_City cy" + +" LEFT OUTER JOIN C_Region r ON (r.C_Region_ID=cy.C_Region_ID)" + +" WHERE cy.AD_Client_ID IN (0,?)"); + params.add(getAD_Client_ID()); + if (getC_Region_ID() > 0) + { + sql.append(" AND cy.C_Region_ID=?"); + params.add(getC_Region_ID()); + } + if (getC_Country_ID() > 0) + { + sql.append(" AND cy.C_Country_ID=?"); + params.add(getC_Country_ID()); + } + sql.append(" ORDER BY cy.Name, r.Name"); + PreparedStatement pstmt = null; + ResultSet rs = null; + try + { + pstmt = DB.prepareStatement(sql.toString(), null); + DB.setParameters(pstmt, params); + rs = pstmt.executeQuery(); + int i = 0; + while(rs.next()) + { + CityVO vo = new CityVO(rs.getInt(1), rs.getString(2), rs.getInt(3), rs.getString(4)); + list.add(vo); + if (i <= m_maxRows) { + listShow.add(vo); + } else if (i == m_maxRows + 1 && i > 0) { + listShow.add(ITEM_More); + } + i++; + } + } + catch (SQLException e) + { + throw new DBException(e, sql.toString()); + } + finally + { + DB.close(rs, pstmt); + rs = null; pstmt = null; + } + // + this.listBox.setListData(listShow.toArray()); + } + + private void setCity(CityVO vo) + { + m_city = vo; + log.finest("C_City_ID="+m_city); + if (m_city == null) { + textBox.setBackground(new Color(230, 230, 255)); + } else { + textBox.setBackground(Color.WHITE); + } + } + public int getC_City_ID() + { + return m_city != null ? m_city.C_City_ID : -1; + } + public int getAD_Client_ID() + { + return Env.getAD_Client_ID(Env.getCtx()); + } + public int getC_Country_ID() + { + return Env.getContextAsInt(Env.getCtx(), m_windowNo, Env.TAB_INFO, "C_Country_ID"); + } + public int getC_Region_ID() + { + return Env.getContextAsInt(Env.getCtx(), m_windowNo, Env.TAB_INFO, "C_Region_ID"); + } + + public CityVO getCity() + { + return m_city; + } + + public void mouseEntered(MouseEvent e) + { + // nothing to do + + } + + public void mouseExited(MouseEvent e) + { + // nothing to do + + } + + public void mousePressed(MouseEvent e) + { + // nothing to do + + } + + public void mouseReleased(MouseEvent e) + { + // nothing to do + + } + + public void mouseClicked(MouseEvent e) + { + if(e == null || listBox.getSelectedValue().equals(ITEM_More)) + { + setCity(null); + return; + } + + CityVO item = (CityVO)listBox.getSelectedValue(); + setCity(item); + Env.setContext(Env.getCtx(), m_windowNo, Env.TAB_INFO, "C_Region_ID", String.valueOf(item.C_Region_ID)); + textBox.setText(item.CityName); + } +} diff --git a/client/src/org/compiere/grid/ed/CityVO.java b/client/src/org/compiere/grid/ed/CityVO.java new file mode 100644 index 0000000000..af87a137b0 --- /dev/null +++ b/client/src/org/compiere/grid/ed/CityVO.java @@ -0,0 +1,84 @@ +/** + * + */ +package org.compiere.grid.ed; + + +/** + * @author Teo Sarca , www.arhipac.ro + * + */ +public class CityVO +{ + public final int C_City_ID; + public final String CityName; + public final int C_Region_ID; + public final String RegionName; + public CityVO(int city_ID, String cityName, int region_ID, String regionName) + { + super(); + C_City_ID = city_ID; + CityName = cityName; + C_Region_ID = region_ID; + RegionName = regionName; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + C_City_ID; + result = prime * result + C_Region_ID; + result = prime * result + ((CityName == null) ? 0 : CityName.hashCode()); + result = prime * result + ((RegionName == null) ? 0 : RegionName.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CityVO other = (CityVO) obj; + if (C_City_ID != other.C_City_ID) + return false; + if (C_Region_ID != other.C_Region_ID) + return false; + if (CityName == null) + { + if (other.CityName != null) + return false; + } + else if (!CityName.equals(other.CityName)) + return false; + if (RegionName == null) + { + if (other.RegionName != null) + return false; + } + else if (!RegionName.equals(other.RegionName)) + return false; + return true; + } + + @Override + public String toString() + { + StringBuffer sb = new StringBuffer(); + if (this.CityName != null) + { + sb.append(this.CityName); + } + if (this.RegionName != null) + { + sb.append(" (").append(this.RegionName).append(")"); + } + return sb.toString(); + } + +} \ No newline at end of file diff --git a/client/src/org/compiere/grid/ed/VLocationDialog.java b/client/src/org/compiere/grid/ed/VLocationDialog.java index a46194e7b3..60f3a78e81 100644 --- a/client/src/org/compiere/grid/ed/VLocationDialog.java +++ b/client/src/org/compiere/grid/ed/VLocationDialog.java @@ -35,6 +35,7 @@ import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.SwingConstants; +import org.compiere.apps.ADialog; import org.compiere.apps.AEnv; import org.compiere.apps.ConfirmPanel; import org.compiere.model.MCountry; @@ -63,22 +64,21 @@ import com.akunagroup.uk.postcode.Postcode; *
  • BF [ 1831060 ] Location dialog should use Address1, Address2 ... elements * @author Michael Judd, Akuna Ltd (UK) *
  • FR [ 1741222 ] - Webservice connector for address lookups + * @author Cristina Ghita, www.arhipac.ro + *
  • FR [ 2794312 ] Location AutoComplete */ public class VLocationDialog extends CDialog implements ActionListener { - - /** Lookup result */ - //private Object[][] data = null; - /** * */ - private static final long serialVersionUID = 6593340606631477392L; + private static final long serialVersionUID = 6952838437136830975L; + /** Lookup result header */ private Object[] header = null; - //private int m_WindowNo = 0; + private int m_WindowNo = 0; /** * Constructor @@ -108,6 +108,10 @@ public class VLocationDialog extends CDialog else setTitle(Msg.getMsg(Env.getCtx(), "LocationUpdate")); + // Reset TAB_INFO context + Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "C_Region_ID", null); + Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "C_Country_ID", null); + // Current Country MCountry.setDisplayLanguage(Env.getAD_Language(Env.getCtx())); fCountry = new CComboBox(MCountry.getCountries(Env.getCtx())); @@ -115,16 +119,21 @@ public class VLocationDialog extends CDialog m_origCountry_ID = m_location.getC_Country_ID(); // Current Region fRegion = new CComboBox(MRegion.getRegions(Env.getCtx(), m_origCountry_ID)); - if (m_location.getCountry().isHasRegion()) - lRegion.setText(m_location.getCountry().getRegionName()); // name for region + if (m_location.getCountry().isHasRegion()) { + if ( m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName) != null + && m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName).trim().length() > 0) + lRegion.setText(m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName)); + else + lRegion.setText(Msg.getMsg(Env.getCtx(), "Region")); + } fRegion.setSelectedItem(m_location.getRegion()); // + fOnline.setText(Msg.getMsg(Env.getCtx(), "Online")); initLocation(); fCountry.addActionListener(this); fOnline.addActionListener(this); + fRegion.addActionListener(this); AEnv.positionCenterWindow(frame, this); - - } // VLocationDialog private boolean m_change = false; @@ -156,7 +165,8 @@ public class VLocationDialog extends CDialog private CTextField fAddress2 = new CTextField(20); // length=60 private CTextField fAddress3 = new CTextField(20); // length=60 private CTextField fAddress4 = new CTextField(20); // length=60 - private CTextField fCity = new CTextField(15); // length=60 + private CTextField fCity = new CTextField(20); // length=60 + private CityAutoCompleter fCityAutoCompleter; private CComboBox fCountry; private CComboBox fRegion; private CTextField fPostal = new CTextField(5); // length=10 @@ -167,6 +177,18 @@ public class VLocationDialog extends CDialog private Insets labelInsets = new Insets(2,15,2,0); // top,left,bottom,right private Insets fieldInsets = new Insets(2,5,2,10); + private boolean isCityMandatory = false; + private boolean isRegionMandatory = false; + private boolean isAddress1Mandatory = false; + private boolean isAddress2Mandatory = false; + private boolean isAddress3Mandatory = false; + private boolean isAddress4Mandatory = false; + private boolean isPostalMandatory = false; + private boolean isPostalAddMandatory = false; + + private boolean inCountryAction; + private boolean inOKAction; + /** * Static component init * @throws Exception @@ -184,6 +206,8 @@ public class VLocationDialog extends CDialog southPanel.add(confirmPanel, BorderLayout.NORTH); // confirmPanel.addActionListener(this); + // + fCityAutoCompleter = new CityAutoCompleter(fCity, m_WindowNo); } // jbInit /** @@ -192,17 +216,41 @@ public class VLocationDialog extends CDialog private void initLocation() { MCountry country = m_location.getCountry(); - log.fine(country.getName() + ", Region=" + country.isHasRegion() + " " + country.getDisplaySequence() + log.fine(country.getName() + ", Region=" + country.isHasRegion() + " " + country.getCaptureSequence() + ", C_Location_ID=" + m_location.getC_Location_ID()); - // new Region - if (m_location.getC_Country_ID() != s_oldCountry_ID && country.isHasRegion()) + // new Country + if (country.getC_Country_ID() != s_oldCountry_ID) { - fRegion = new CComboBox(MRegion.getRegions(Env.getCtx(), country.getC_Country_ID())); - if (m_location.getRegion() != null) - fRegion.setSelectedItem(m_location.getRegion()); - lRegion.setText(country.getRegionName()); + fRegion.removeAllItems(); + if (country.isHasRegion()) { + for (MRegion region : MRegion.getRegions(Env.getCtx(), country.getC_Country_ID())) { + fRegion.addItem(region); + } + if ( m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName) != null + && m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName).trim().length() > 0) + lRegion.setText(m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName)); + else + lRegion.setText(Msg.getMsg(Env.getCtx(), "Region")); + } s_oldCountry_ID = m_location.getC_Country_ID(); } + + if (m_location.getC_Region_ID() > 0 && m_location.getC_Region().getC_Country_ID() == country.getC_Country_ID()) { + fRegion.setSelectedItem(m_location.getC_Region()); + } else { + fRegion.setSelectedItem(null); + m_location.setC_Region_ID(0); + } + + if (country.isHasRegion() && m_location.getC_Region_ID() > 0) + { + Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "C_Region_ID", String.valueOf(m_location.getC_Region_ID())); + } else { + Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "C_Region_ID", "0"); + } + Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "C_Country_ID", String.valueOf(country.get_ID())); + + fCityAutoCompleter.fillList(); gbc.anchor = GridBagConstraints.NORTHWEST; gbc.gridy = 0; // line @@ -212,43 +260,65 @@ public class VLocationDialog extends CDialog gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 0; gbc.weighty = 0; + + mainPanel.removeAll(); mainPanel.add(Box.createVerticalStrut(5), gbc); // top gap int line = 1; - addLine(line++, lAddress1, fAddress1); - addLine(line++, lAddress2, fAddress2); - addLine(line++, lAddress3, fAddress3); - addLine(line++, lAddress4, fAddress4); - // sequence of City Postal Region - @P@ @C@ - @C@, @R@ @P@ - String ds = country.getDisplaySequence(); + String ds = country.getCaptureSequence(); if (ds == null || ds.length() == 0) { - log.log(Level.SEVERE, "DisplaySequence empty - " + country); + log.log(Level.SEVERE, "CaptureSequence empty - " + country); ds = ""; // @C@, @P@ } + isCityMandatory = false; + isRegionMandatory = false; + isAddress1Mandatory = false; + isAddress2Mandatory = false; + isAddress3Mandatory = false; + isAddress4Mandatory = false; + isPostalMandatory = false; + isPostalAddMandatory = false; StringTokenizer st = new StringTokenizer(ds, "@", false); while (st.hasMoreTokens()) { String s = st.nextToken(); - if (s.startsWith("C")) + if (s.startsWith("CO")) { + // Country Last + addLine(line++, lCountry, fCountry); + // disable online if this country doesn't have post code lookup + if (m_location.getCountry().isPostcodeLookup()) { + addLine(line++, lOnline, fOnline); + } + } else if (s.startsWith("A1")) { + addLine(line++, lAddress1, fAddress1); + isAddress1Mandatory = s.endsWith("!"); + } else if (s.startsWith("A2")) { + addLine(line++, lAddress2, fAddress2); + isAddress2Mandatory = s.endsWith("!"); + } else if (s.startsWith("A3")) { + addLine(line++, lAddress3, fAddress3); + isAddress3Mandatory = s.endsWith("!"); + } else if (s.startsWith("A4")) { + addLine(line++, lAddress4, fAddress4); + isAddress4Mandatory = s.endsWith("!"); + } else if (s.startsWith("C")) { addLine(line++, lCity, fCity); - else if (s.startsWith("P")) + isCityMandatory = s.endsWith("!"); + } else if (s.startsWith("P")) { addLine(line++, lPostal, fPostal); - else if (s.startsWith("A")) + isPostalMandatory = s.endsWith("!"); + } else if (s.startsWith("A")) { addLine(line++, lPostalAdd, fPostalAdd); - else if (s.startsWith("R") && m_location.getCountry().isHasRegion()) + isPostalAddMandatory = s.endsWith("!"); + } else if (s.startsWith("R") && m_location.getCountry().isHasRegion()) { addLine(line++, lRegion, fRegion); + isRegionMandatory = s.endsWith("!"); + } } - - addLine(line++, lOnline, fOnline); - fOnline.setText(Msg.getMsg(Env.getCtx(), "Online")); - - // Country Last - addLine(line++, lCountry, fCountry); - // Fill it if (m_location.getC_Location_ID() != 0) { @@ -261,21 +331,16 @@ public class VLocationDialog extends CDialog fPostalAdd.setText(m_location.getPostal_Add()); if (m_location.getCountry().isHasRegion()) { - lRegion.setText(m_location.getCountry().getRegionName()); + if ( m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName) != null + && m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName).trim().length() > 0) + lRegion.setText(m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName)); + else + lRegion.setText(Msg.getMsg(Env.getCtx(), "Region")); fRegion.setSelectedItem(m_location.getRegion()); } - - // disable online if this country doesn't have post code lookup - if (m_location.getCountry().isPostcodeLookup()) { - fOnline.setEnabled(true); - fOnline.setVisible(true); - } - else { - fOnline.setEnabled(false); - fOnline.setVisible(false); - } - - fCountry.setSelectedItem(country); + + if (!fCountry.getSelectedItem().equals(country)) + fCountry.setSelectedItem(country); } // Update UI pack(); @@ -308,6 +373,15 @@ public class VLocationDialog extends CDialog } // addLine + @Override + public void dispose() + { + if (!m_change && m_location != null && !m_location.is_new()) + { + m_location = new MLocation(m_location.getCtx(), m_location.get_ID(), null); + } + super.dispose(); + } /** * ActionListener @@ -317,9 +391,32 @@ public class VLocationDialog extends CDialog { if (e.getActionCommand().equals(ConfirmPanel.A_OK)) { - action_OK(); - m_change = true; - dispose(); + inOKAction = true; + + if (m_location.getCountry().isHasRegion() && fRegion.getSelectedItem() == null) { + if (fCityAutoCompleter.getC_Region_ID() > 0 && fCityAutoCompleter.getC_Region_ID() != m_location.getC_Region_ID()) { + fRegion.setSelectedItem(MRegion.get(Env.getCtx(), fCityAutoCompleter.getC_Region_ID())); + m_location.setRegion(MRegion.get(Env.getCtx(), fCityAutoCompleter.getC_Region_ID())); + } + } + + String msg = validate_OK(); + if (msg != null) { + ADialog.error(0, this, "FillMandatory", Msg.parseTranslation(Env.getCtx(), msg)); + inOKAction = false; + return; + } + + if (action_OK()) + { + m_change = true; + dispose(); + } + else + { + ADialog.error(m_WindowNo, this, "CityNotFound"); + } + inOKAction = false; } else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) { @@ -330,34 +427,27 @@ public class VLocationDialog extends CDialog // Country Changed - display in new Format else if (e.getSource() == fCountry) { + inCountryAction = true; // Modifier for Mouse selection is 16 - for any key selection 0 MCountry c = (MCountry)fCountry.getSelectedItem(); m_location.setCountry(c); - - // refresh online button for new country - if (c.isPostcodeLookup()) { - fOnline.setEnabled(true); - fOnline.setVisible(true); - } - else { - fOnline.setEnabled(false); - fOnline.setVisible(false); - } - - // update the region name if regions are enabled for this country - if (c.isHasRegion()) - { - lRegion.setText(c.getRegionName()); - fRegion.setSelectedItem(m_location.getRegion()); - - // TODO: fix bug that occurs when the new region name is shorter than the old region name - } - - // refresh - mainPanel.removeAll(); - + initLocation(); - fCountry.requestFocus(); // allows to use Keybord selection + fCountry.requestFocus(); // allows to use Keyboard selection + inCountryAction = false; + } + // Region Changed + else if (e.getSource() == fRegion) + { + if (inCountryAction || inOKAction) + return; + MRegion r = (MRegion)fRegion.getSelectedItem(); + m_location.setRegion(r); + m_location.setC_City_ID(0); + m_location.setCity(null); + + initLocation(); + fRegion.requestFocus(); // allows to use Keyboard selection } else if (e.getSource() == fOnline) { @@ -371,16 +461,51 @@ public class VLocationDialog extends CDialog } } // actionPerformed + // LCO - address 1, region and city required + private String validate_OK() { + String fields = ""; + if (isAddress1Mandatory && fAddress1.getText().trim().length() == 0) { + fields = fields + " " + "@Address1@, "; + } + if (isAddress2Mandatory && fAddress2.getText().trim().length() == 0) { + fields = fields + " " + "@Address2@, "; + } + if (isAddress3Mandatory && fAddress3.getText().trim().length() == 0) { + fields = fields + " " + "@Address3@, "; + } + if (isAddress4Mandatory && fAddress4.getText().trim().length() == 0) { + fields = fields + " " + "@Address4@, "; + } + if (isCityMandatory && fCity.getText().trim().length() == 0) { + fields = fields + " " + "@C_City_ID@, "; + } + if (isRegionMandatory && fRegion.getSelectedItem() == null) { + fields = fields + " " + "@C_Region_ID@, "; + } + if (isPostalMandatory && fPostal.getText().trim().length() == 0) { + fields = fields + " " + "@Postal@, "; + } + if (isPostalAddMandatory && fPostalAdd.getText().trim().length() == 0) { + fields = fields + " " + "@PostalAdd@, "; + } + + if (fields.trim().length() > 0) + return fields.substring(0, fields.length() -2); + + return null; + } + /** * OK - check for changes (save them) & Exit */ - private void action_OK() + private boolean action_OK() { m_location.setAddress1(fAddress1.getText()); m_location.setAddress2(fAddress2.getText()); m_location.setAddress3(fAddress3.getText()); m_location.setAddress4(fAddress4.getText()); m_location.setCity(fCity.getText()); + m_location.setC_City_ID(fCityAutoCompleter.getC_City_ID()); m_location.setPostal(fPostal.getText()); m_location.setPostal_Add(fPostalAdd.getText()); // Country/Region @@ -394,7 +519,14 @@ public class VLocationDialog extends CDialog else m_location.setC_Region_ID(0); // Save changes - m_location.save(); + if(m_location.save()) + { + return true; + } + else + { + return false; + } } // actionOK /** @@ -452,111 +584,113 @@ public class VLocationDialog extends CDialog return ""; } - /** - * Fills the location field using the information retrieved from postcode - * servers. - * - * @param ctx - * Context - * @param pkeyData - * Lookup results - * @param windowNo - * Window No. - * @param tab - * Tab - * @param field - * Field - */ - private void fillLocation(HashMap postcodeData, MCountry country) { - // If it's not empty warn the user. - if (fAddress1 != null || fAddress2 != null - || fAddress3 != null - || fAddress4 != null || fCity != null) { - String warningMsg = "Existing address information will be overwritten. Proceed?"; - String warningTitle = "Warning"; - int response = JOptionPane.showConfirmDialog(null, warningMsg, - warningTitle, JOptionPane.YES_NO_OPTION); - if (response == JOptionPane.NO_OPTION) - return; - } - - - Set pcodeKeys = postcodeData.keySet(); - Iterator iterator = pcodeKeys.iterator(); - header = null; - - // Allocate the header array - header = new Object[pcodeKeys.size()]; - - String headerStr = null; - - // need to check how many records returned - // TODO - check number of records returns - size() method is incorrect - if (pcodeKeys.size() > 2) - { - // TODO: Implement ResultData Grid and get return (for premises level data) - System.out.println("Too many postcodes returned from Postcode Lookup - need to Implement ResultData"); - } else - { - for (int i = 0; (headerStr = (iterator.hasNext() ? iterator.next() : null)) != null - || iterator.hasNext(); i++) { - header[i] = headerStr; - Postcode values = (Postcode) postcodeData.get(headerStr); - - // Overwrite the values in location field. - fAddress1.setText(values.getStreet1()); - fAddress2.setText(values.getStreet2()); - fAddress3.setText(values.getStreet3()); - fAddress4.setText(values.getStreet4()); - fCity.setText(values.getCity()); - fPostal.setText(values.getPostcode()); - - // Do region lookup - if (country.isHasRegion()) - { - // get all regions for this country - MRegion[] regions = MRegion.getRegions(country.getCtx(), country.getC_Country_ID()); - - // If regions were loaded - if ( regions.length > 0) - { - // loop through regions array to attempt a region match - don't finish loop if region found - boolean found = false; - for (i = 0; i < regions.length && !found; i++) - { - - if (regions[i].getName().equals(values.getRegion()) ) - { - // found Region - fRegion.setSelectedItem(regions[i]); - log.fine("Found region: " + regions[i].getName()); - found = true; - } - } - if (!found) - { - // add new region - MRegion region = new MRegion(country, values.getRegion()); - if (region.save()) - { - log.fine("Added new region from web service: " + values.getRegion()); - // clears cache - Env.reset(false); - //reload regions to combo box - fRegion = new CComboBox(MRegion.getRegions(Env.getCtx(), country.getC_Country_ID())); - // select region - fRegion.setSelectedItem(values); - } else - log.severe("Error saving new region: " + region.getName()); - - } - } else - log.severe("Region lookup failed for Country: " + country.getName()); - - } - } - } - + /** + * Fills the location field using the information retrieved from postcode + * servers. + * + * @param ctx + * Context + * @param pkeyData + * Lookup results + * @param windowNo + * Window No. + * @param tab + * Tab + * @param field + * Field + */ + private void fillLocation(HashMap postcodeData, MCountry country) { + + // If it's not empty warn the user. + if (fAddress1 != null || fAddress2 != null + || fAddress3 != null + || fAddress4 != null || fCity != null) { + String warningMsg = "Existing address information will be overwritten. Proceed?"; + String warningTitle = "Warning"; + int response = JOptionPane.showConfirmDialog(null, warningMsg, + warningTitle, JOptionPane.YES_NO_OPTION); + if (response == JOptionPane.NO_OPTION) + return; } + + + Set pcodeKeys = postcodeData.keySet(); + Iterator iterator = pcodeKeys.iterator(); + header = null; + + // Allocate the header array + header = new Object[pcodeKeys.size()]; + + String headerStr = null; + + // need to check how many records returned + // TODO - check number of records returns - size() method is incorrect + if (pcodeKeys.size() > 2) + { + // TODO: Implement ResultData Grid and get return (for premises level data) + System.out.println("Too many postcodes returned from Postcode Lookup - need to Implement ResultData"); + } else + { + for (int i = 0; (headerStr = (iterator.hasNext() ? iterator.next() : null)) != null + || iterator.hasNext(); i++) { + header[i] = headerStr; + Postcode values = (Postcode) postcodeData.get(headerStr); + + // Overwrite the values in location field. + fAddress1.setText(values.getStreet1()); + fAddress2.setText(values.getStreet2()); + fAddress3.setText(values.getStreet3()); + fAddress4.setText(values.getStreet4()); + fCity.setText(values.getCity()); + fPostal.setText(values.getPostcode()); + + // Do region lookup + if (country.isHasRegion()) + { + // get all regions for this country + MRegion[] regions = MRegion.getRegions(country.getCtx(), country.getC_Country_ID()); + + // If regions were loaded + if ( regions.length > 0) + { + // loop through regions array to attempt a region match - don't finish loop if region found + boolean found = false; + for (i = 0; i < regions.length && !found; i++) + { + + if (regions[i].getName().equals(values.getRegion()) ) + { + // found Region + fRegion.setSelectedItem(regions[i]); + log.fine("Found region: " + regions[i].getName()); + found = true; + } + } + if (!found) + { + // add new region + MRegion region = new MRegion(country, values.getRegion()); + if (region.save()) + { + log.fine("Added new region from web service: " + values.getRegion()); + // clears cache + Env.reset(false); + //reload regions to combo box + fRegion = new CComboBox(MRegion.getRegions(Env.getCtx(), country.getC_Country_ID())); + // select region + fRegion.setSelectedItem(values); + } else + log.severe("Error saving new region: " + region.getName()); + + } + } else + log.severe("Region lookup failed for Country: " + country.getName()); + + } + } + } + + } + } // VLocationDialog diff --git a/migration/354a-trunk/oracle/580g_FR2794312.sql b/migration/354a-trunk/oracle/580g_FR2794312.sql new file mode 100644 index 0000000000..7d10d385b9 --- /dev/null +++ b/migration/354a-trunk/oracle/580g_FR2794312.sql @@ -0,0 +1,498 @@ +-- 22.05.2009 10:25:55 EEST +-- Location AutoComplete - http://sourceforge.net/tracker/?func=detail&aid=2794312&group_id=176962&atid=879335 +INSERT INTO AD_Element (UpdatedBy,AD_Element_ID,IsActive,CreatedBy,ColumnName,Name,Description,Updated,Created,AD_Client_ID,AD_Org_ID,PrintName,EntityType) VALUES (0,53838,'Y',0,'AllowCitiesOutOfList','AllowCitiesOutOfList','A flag which tells if a country accept or not new cities',TO_DATE('2009-05-22 10:25:53','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2009-05-22 10:25:53','YYYY-MM-DD HH24:MI:SS'),0,0,'Allow Cities Out Of List','D') +; + +-- 22.05.2009 10:25:55 EEST +INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Name,Description,Help,PrintName,PO_PrintName,PO_Name,PO_Description,PO_Help, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Element_ID, t.Name,t.Description,t.Help,t.PrintName,t.PO_PrintName,t.PO_Name,t.PO_Description,t.PO_Help, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=53838 AND EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Element_ID!=t.AD_Element_ID) +; + +-- 22.05.2009 10:28:40 EEST +INSERT INTO AD_Column (AD_Column_ID,IsParent,AD_Client_ID,AD_Org_ID,IsAutocomplete,AD_Table_ID,FieldLength,Created,CreatedBy,Updated,Version,DefaultValue,IsActive,Description,ColumnName,IsKey,AD_Reference_ID,IsTranslated,IsMandatory,IsIdentifier,SeqNo,IsSelectionColumn,IsSyncDatabase,AD_Element_ID,IsUpdateable,EntityType,Name,UpdatedBy,IsAlwaysUpdateable,IsEncrypted,IsAllowLogging) VALUES (57650,'N',0,0,'N',170,1,TO_DATE('2009-05-22 10:28:37','YYYY-MM-DD HH24:MI:SS'),0,TO_DATE('2009-05-22 10:28:37','YYYY-MM-DD HH24:MI:SS'),0,'Y','Y','A flag which tells if a country accept or not new cities','AllowCitiesOutOfList','N',20,'N','N','N',0,'N','N',53838,'Y','U','AllowCitiesOutOfList',0,'N','N','Y') +; + +-- 22.05.2009 10:28:40 EEST +INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=57650 AND EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Column_ID!=t.AD_Column_ID) +; + +-- 22.05.2009 10:28:41 EEST +INSERT INTO AD_Field (IsFieldOnly,DisplayLength,AD_Field_ID,IsEncrypted,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,UpdatedBy,IsActive,Created,IsSameLine,IsHeading,CreatedBy,AD_Client_ID,Updated,Description,AD_Org_ID,IsReadOnly,IsCentrallyMaintained,EntityType) VALUES ('N',1,57035,'N','AllowCitiesOutOfList',135,57650,'N',0,'Y',TO_DATE('2009-05-22 10:28:40','YYYY-MM-DD HH24:MI:SS'),'N','N',0,0,TO_DATE('2009-05-22 10:28:40','YYYY-MM-DD HH24:MI:SS'),'A flag which tells if a country accept or not new cities',0,'N','Y','U') +; + +-- 22.05.2009 10:28:41 EEST +INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=57035 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID) +; + +-- 22.05.2009 10:28:42 EEST +ALTER TABLE C_Country ADD AllowCitiesOutOfList CHAR(1) DEFAULT 'Y' CHECK (AllowCitiesOutOfList IN ('Y','N')) +; + +-- 22.05.2009 10:29:08 EEST +UPDATE AD_Column SET EntityType='D',Updated=TO_DATE('2009-05-22 10:29:08','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Column_ID=57650 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=70,IsDisplayed='Y' WHERE AD_Field_ID=342 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=80,IsDisplayed='Y' WHERE AD_Field_ID=343 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=90,IsDisplayed='Y' WHERE AD_Field_ID=345 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=100,IsDisplayed='Y' WHERE AD_Field_ID=10893 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=110,IsDisplayed='Y' WHERE AD_Field_ID=10892 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=120,IsDisplayed='Y' WHERE AD_Field_ID=10891 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=130,IsDisplayed='Y' WHERE AD_Field_ID=346 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=140,IsDisplayed='Y' WHERE AD_Field_ID=347 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=150,IsDisplayed='Y' WHERE AD_Field_ID=348 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=160,IsDisplayed='Y' WHERE AD_Field_ID=344 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=170,IsDisplayed='Y' WHERE AD_Field_ID=11184 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=180,IsDisplayed='Y' WHERE AD_Field_ID=10895 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=190,IsDisplayed='Y' WHERE AD_Field_ID=10894 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=200,IsDisplayed='Y' WHERE AD_Field_ID=5753 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=210,IsDisplayed='Y' WHERE AD_Field_ID=5752 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=220,IsDisplayed='Y' WHERE AD_Field_ID=51000 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=270,IsDisplayed='Y' WHERE AD_Field_ID=57035 +; + +-- 22.05.2009 10:32:17 EEST +INSERT INTO AD_Element (UpdatedBy,AD_Element_ID,IsActive,CreatedBy,ColumnName,Name,Updated,Created,AD_Client_ID,AD_Org_ID,PrintName,EntityType) VALUES (0,53839,'Y',0,'CaptureSequence','CaptureSequence',TO_DATE('2009-05-22 10:32:16','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2009-05-22 10:32:16','YYYY-MM-DD HH24:MI:SS'),0,0,'Capture Sequence','D') +; + +-- 22.05.2009 10:32:17 EEST +INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Name,Description,Help,PrintName,PO_PrintName,PO_Name,PO_Description,PO_Help, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Element_ID, t.Name,t.Description,t.Help,t.PrintName,t.PO_PrintName,t.PO_Name,t.PO_Description,t.PO_Help, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=53839 AND EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Element_ID!=t.AD_Element_ID) +; + +-- 22.05.2009 10:32:49 EEST +INSERT INTO AD_Column (AD_Column_ID,IsParent,AD_Client_ID,AD_Org_ID,IsAutocomplete,AD_Table_ID,FieldLength,Created,CreatedBy,Updated,Version,IsActive,ColumnName,IsKey,AD_Reference_ID,IsTranslated,IsMandatory,IsIdentifier,SeqNo,IsSelectionColumn,IsSyncDatabase,AD_Element_ID,IsUpdateable,EntityType,Name,UpdatedBy,IsAlwaysUpdateable,IsEncrypted,IsAllowLogging) VALUES (57651,'N',0,0,'N',170,20,TO_DATE('2009-05-22 10:32:48','YYYY-MM-DD HH24:MI:SS'),0,TO_DATE('2009-05-22 10:32:48','YYYY-MM-DD HH24:MI:SS'),1,'Y','CaptureSequence','N',10,'N','N','N',0,'N','N',53839,'Y','D','CaptureSequence',0,'N','N','Y') +; + +-- 22.05.2009 10:32:49 EEST +INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=57651 AND EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Column_ID!=t.AD_Column_ID) +; + +-- 22.05.2009 10:32:50 EEST +INSERT INTO AD_Field (IsFieldOnly,DisplayLength,AD_Field_ID,IsEncrypted,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,UpdatedBy,IsActive,Created,IsSameLine,IsHeading,CreatedBy,AD_Client_ID,Updated,AD_Org_ID,IsReadOnly,IsCentrallyMaintained,EntityType) VALUES ('N',20,57036,'N','CaptureSequence',135,57651,'N',0,'Y',TO_DATE('2009-05-22 10:32:49','YYYY-MM-DD HH24:MI:SS'),'N','N',0,0,TO_DATE('2009-05-22 10:32:49','YYYY-MM-DD HH24:MI:SS'),0,'N','Y','D') +; + +-- 22.05.2009 10:32:50 EEST +INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=57036 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID) +; + +-- 22.05.2009 10:32:51 EEST +ALTER TABLE C_Country ADD CaptureSequence NVARCHAR2(20) DEFAULT NULL +; + +-- 22.05.2009 10:33:44 EEST +UPDATE AD_Field SET SeqNo=280,IsDisplayed='Y' WHERE AD_Field_ID=57036 +; + +-- 22.05.2009 10:35:10 EEST +UPDATE AD_Field SET IsSameLine='Y',Updated=TO_DATE('2009-05-22 10:35:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=57035 +; + +-- 22.05.2009 10:35:47 EEST +UPDATE AD_Field SET IsSameLine='N',Updated=TO_DATE('2009-05-22 10:35:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=57035 +; + +-- 22.05.2009 10:36:41 EEST +UPDATE AD_Field SET SeqNo=230,IsDisplayed='Y' WHERE AD_Field_ID=57035 +; + +-- 22.05.2009 10:36:41 EEST +UPDATE AD_Field SET SeqNo=240,IsDisplayed='Y' WHERE AD_Field_ID=51003 +; + +-- 22.05.2009 10:36:41 EEST +UPDATE AD_Field SET SeqNo=250,IsDisplayed='Y' WHERE AD_Field_ID=51002 +; + +-- 22.05.2009 10:36:41 EEST +UPDATE AD_Field SET SeqNo=260,IsDisplayed='Y' WHERE AD_Field_ID=51004 +; + +-- 22.05.2009 10:36:41 EEST +UPDATE AD_Field SET SeqNo=270,IsDisplayed='Y' WHERE AD_Field_ID=51001 +; + +-- 22.05.2009 10:37:10 EEST +UPDATE AD_Field SET IsSameLine='Y', EntityType='D',Updated=TO_DATE('2009-05-22 10:37:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=57035 +; + + + +-- 27.05.2009 11:21:49 EEST +INSERT INTO AD_Message (MsgType,MsgText,CreatedBy,IsActive,Created,Updated,UpdatedBy,AD_Client_ID,AD_Org_ID,EntityType,Value,AD_Message_ID) VALUES ('E','The city does not exist and can not be created from here.',0,'Y',TO_DATE('2009-05-27 11:21:48','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2009-05-27 11:21:48','YYYY-MM-DD HH24:MI:SS'),0,0,0,'D','CityNotFound',53078) +; + +-- 27.05.2009 11:21:49 EEST +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=53078 AND EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Message_ID!=t.AD_Message_ID) +; + +-- 27.05.2009 11:22:10 EEST +UPDATE AD_Message_Trl SET IsTranslated='Y',MsgText='Orasul nu exista si nu paote fi creat de aici.',Updated=TO_DATE('2009-05-27 11:22:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=53078 AND AD_Language='ro_RO' +; + +-- 27.05.2009 11:22:16 EEST +UPDATE AD_Message_Trl SET MsgText='Orasul nu exista si nu poate fi creat de aici.',Updated=TO_DATE('2009-05-27 11:22:16','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=53078 AND AD_Language='ro_RO' +; + + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=110,IsDisplayed='Y' WHERE AD_Field_ID=57036 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=120,IsDisplayed='Y' WHERE AD_Field_ID=10892 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=130,IsDisplayed='Y' WHERE AD_Field_ID=10891 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=140,IsDisplayed='Y' WHERE AD_Field_ID=346 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=150,IsDisplayed='Y' WHERE AD_Field_ID=347 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=160,IsDisplayed='Y' WHERE AD_Field_ID=348 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=170,IsDisplayed='Y' WHERE AD_Field_ID=344 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=180,IsDisplayed='Y' WHERE AD_Field_ID=11184 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=190,IsDisplayed='Y' WHERE AD_Field_ID=10895 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=200,IsDisplayed='Y' WHERE AD_Field_ID=10894 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=210,IsDisplayed='Y' WHERE AD_Field_ID=5753 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=220,IsDisplayed='Y' WHERE AD_Field_ID=5752 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=230,IsDisplayed='Y' WHERE AD_Field_ID=51000 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=240,IsDisplayed='Y' WHERE AD_Field_ID=57035 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=250,IsDisplayed='Y' WHERE AD_Field_ID=51003 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=260,IsDisplayed='Y' WHERE AD_Field_ID=51002 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=270,IsDisplayed='Y' WHERE AD_Field_ID=51004 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=280,IsDisplayed='Y' WHERE AD_Field_ID=51001 +; + +-- Sep 17, 2009 9:37:05 PM COT +UPDATE AD_Element SET Name='Use Postcode Lookup', PrintName='Use Postcode Lookup',Updated=TO_DATE('2009-09-17 21:37:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=51000 +; + +-- Sep 17, 2009 9:37:05 PM COT +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=51000 +; + +-- Sep 17, 2009 9:37:05 PM COT +UPDATE AD_Column SET ColumnName='IsPostcodeLookup', Name='Use Postcode Lookup', Description='Does this country have a post code web service', Help='Enable the IsPostcodeLookup if you wish to configure a post code lookup web service' WHERE AD_Element_ID=51000 +; + +-- Sep 17, 2009 9:37:05 PM COT +UPDATE AD_Process_Para SET ColumnName='IsPostcodeLookup', Name='Use Postcode Lookup', Description='Does this country have a post code web service', Help='Enable the IsPostcodeLookup if you wish to configure a post code lookup web service', AD_Element_ID=51000 WHERE UPPER(ColumnName)='ISPOSTCODELOOKUP' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Sep 17, 2009 9:37:05 PM COT +UPDATE AD_Process_Para SET ColumnName='IsPostcodeLookup', Name='Use Postcode Lookup', Description='Does this country have a post code web service', Help='Enable the IsPostcodeLookup if you wish to configure a post code lookup web service' WHERE AD_Element_ID=51000 AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:05 PM COT +UPDATE AD_Field SET Name='Use Postcode Lookup', Description='Does this country have a post code web service', Help='Enable the IsPostcodeLookup if you wish to configure a post code lookup web service' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=51000) AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:06 PM COT +UPDATE AD_PrintFormatItem pi SET PrintName='Use Postcode Lookup', Name='Use Postcode Lookup' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=pi.AD_Column_ID AND c.AD_Element_ID=51000) +; + +-- Sep 17, 2009 9:37:19 PM COT +UPDATE AD_Element SET Name='Lookup ClassName', PrintName='Lookup ClassName',Updated=TO_DATE('2009-09-17 21:37:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=51001 +; + +-- Sep 17, 2009 9:37:19 PM COT +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=51001 +; + +-- Sep 17, 2009 9:37:19 PM COT +UPDATE AD_Column SET ColumnName='LookupClassName', Name='Lookup ClassName', Description='The class name of the postcode lookup plugin', Help='Enter the class name of the post code lookup plugin for your postcode web service provider' WHERE AD_Element_ID=51001 +; + +-- Sep 17, 2009 9:37:19 PM COT +UPDATE AD_Process_Para SET ColumnName='LookupClassName', Name='Lookup ClassName', Description='The class name of the postcode lookup plugin', Help='Enter the class name of the post code lookup plugin for your postcode web service provider', AD_Element_ID=51001 WHERE UPPER(ColumnName)='LOOKUPCLASSNAME' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Sep 17, 2009 9:37:19 PM COT +UPDATE AD_Process_Para SET ColumnName='LookupClassName', Name='Lookup ClassName', Description='The class name of the postcode lookup plugin', Help='Enter the class name of the post code lookup plugin for your postcode web service provider' WHERE AD_Element_ID=51001 AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:19 PM COT +UPDATE AD_Field SET Name='Lookup ClassName', Description='The class name of the postcode lookup plugin', Help='Enter the class name of the post code lookup plugin for your postcode web service provider' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=51001) AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:19 PM COT +UPDATE AD_PrintFormatItem pi SET PrintName='Lookup ClassName', Name='Lookup ClassName' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=pi.AD_Column_ID AND c.AD_Element_ID=51001) +; + +-- Sep 17, 2009 9:37:31 PM COT +UPDATE AD_Element SET Name='Lookup Client ID', PrintName='Lookup Client ID',Updated=TO_DATE('2009-09-17 21:37:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=51002 +; + +-- Sep 17, 2009 9:37:31 PM COT +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=51002 +; + +-- Sep 17, 2009 9:37:31 PM COT +UPDATE AD_Column SET ColumnName='LookupClientID', Name='Lookup Client ID', Description='The ClientID or Login submitted to the Lookup URL', Help='Enter the ClientID or Login for your account provided by the post code web service provider' WHERE AD_Element_ID=51002 +; + +-- Sep 17, 2009 9:37:31 PM COT +UPDATE AD_Process_Para SET ColumnName='LookupClientID', Name='Lookup Client ID', Description='The ClientID or Login submitted to the Lookup URL', Help='Enter the ClientID or Login for your account provided by the post code web service provider', AD_Element_ID=51002 WHERE UPPER(ColumnName)='LOOKUPCLIENTID' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Sep 17, 2009 9:37:31 PM COT +UPDATE AD_Process_Para SET ColumnName='LookupClientID', Name='Lookup Client ID', Description='The ClientID or Login submitted to the Lookup URL', Help='Enter the ClientID or Login for your account provided by the post code web service provider' WHERE AD_Element_ID=51002 AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:31 PM COT +UPDATE AD_Field SET Name='Lookup Client ID', Description='The ClientID or Login submitted to the Lookup URL', Help='Enter the ClientID or Login for your account provided by the post code web service provider' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=51002) AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:31 PM COT +UPDATE AD_PrintFormatItem pi SET PrintName='Lookup Client ID', Name='Lookup Client ID' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=pi.AD_Column_ID AND c.AD_Element_ID=51002) +; + +-- Sep 17, 2009 9:37:38 PM COT +UPDATE AD_Element SET Name='Lookup Password', PrintName='Lookup Password',Updated=TO_DATE('2009-09-17 21:37:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=51004 +; + +-- Sep 17, 2009 9:37:38 PM COT +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=51004 +; + +-- Sep 17, 2009 9:37:38 PM COT +UPDATE AD_Column SET ColumnName='LookupPassword', Name='Lookup Password', Description='The password submitted to the Lookup URL', Help='Enter the password for your account provided by the post code web service provider' WHERE AD_Element_ID=51004 +; + +-- Sep 17, 2009 9:37:38 PM COT +UPDATE AD_Process_Para SET ColumnName='LookupPassword', Name='Lookup Password', Description='The password submitted to the Lookup URL', Help='Enter the password for your account provided by the post code web service provider', AD_Element_ID=51004 WHERE UPPER(ColumnName)='LOOKUPPASSWORD' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Sep 17, 2009 9:37:38 PM COT +UPDATE AD_Process_Para SET ColumnName='LookupPassword', Name='Lookup Password', Description='The password submitted to the Lookup URL', Help='Enter the password for your account provided by the post code web service provider' WHERE AD_Element_ID=51004 AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:38 PM COT +UPDATE AD_Field SET Name='Lookup Password', Description='The password submitted to the Lookup URL', Help='Enter the password for your account provided by the post code web service provider' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=51004) AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:38 PM COT +UPDATE AD_PrintFormatItem pi SET PrintName='Lookup Password', Name='Lookup Password' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=pi.AD_Column_ID AND c.AD_Element_ID=51004) +; + +-- Sep 17, 2009 9:37:50 PM COT +UPDATE AD_Element SET Name='Lookup URL', PrintName='Lookup URL',Updated=TO_DATE('2009-09-17 21:37:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=51003 +; + +-- Sep 17, 2009 9:37:50 PM COT +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=51003 +; + +-- Sep 17, 2009 9:37:50 PM COT +UPDATE AD_Column SET ColumnName='LookupUrl', Name='Lookup URL', Description='The URL of the web service that the plugin connects to in order to retrieve postcode data', Help='Enter the URL of the web service that the plugin connects to in order to retrieve postcode data' WHERE AD_Element_ID=51003 +; + +-- Sep 17, 2009 9:37:50 PM COT +UPDATE AD_Process_Para SET ColumnName='LookupUrl', Name='Lookup URL', Description='The URL of the web service that the plugin connects to in order to retrieve postcode data', Help='Enter the URL of the web service that the plugin connects to in order to retrieve postcode data', AD_Element_ID=51003 WHERE UPPER(ColumnName)='LOOKUPURL' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Sep 17, 2009 9:37:50 PM COT +UPDATE AD_Process_Para SET ColumnName='LookupUrl', Name='Lookup URL', Description='The URL of the web service that the plugin connects to in order to retrieve postcode data', Help='Enter the URL of the web service that the plugin connects to in order to retrieve postcode data' WHERE AD_Element_ID=51003 AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:50 PM COT +UPDATE AD_Field SET Name='Lookup URL', Description='The URL of the web service that the plugin connects to in order to retrieve postcode data', Help='Enter the URL of the web service that the plugin connects to in order to retrieve postcode data' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=51003) AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:50 PM COT +UPDATE AD_PrintFormatItem pi SET PrintName='Lookup URL', Name='Lookup URL' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=pi.AD_Column_ID AND c.AD_Element_ID=51003) +; + +-- Sep 17, 2009 9:38:21 PM COT +UPDATE AD_Element SET Description='A flag which tells if a country accept or not new cities when capturing locations', Name='Allow Cities out of List', PrintName='Allow Cities out of List',Updated=TO_DATE('2009-09-17 21:38:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=53838 +; + +-- Sep 17, 2009 9:38:21 PM COT +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=53838 +; + +-- Sep 17, 2009 9:38:21 PM COT +UPDATE AD_Column SET ColumnName='AllowCitiesOutOfList', Name='Allow Cities out of List', Description='A flag which tells if a country accept or not new cities when capturing locations', Help=NULL WHERE AD_Element_ID=53838 +; + +-- Sep 17, 2009 9:38:21 PM COT +UPDATE AD_Process_Para SET ColumnName='AllowCitiesOutOfList', Name='Allow Cities out of List', Description='A flag which tells if a country accept or not new cities when capturing locations', Help=NULL, AD_Element_ID=53838 WHERE UPPER(ColumnName)='ALLOWCITIESOUTOFLIST' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Sep 17, 2009 9:38:21 PM COT +UPDATE AD_Process_Para SET ColumnName='AllowCitiesOutOfList', Name='Allow Cities out of List', Description='A flag which tells if a country accept or not new cities when capturing locations', Help=NULL WHERE AD_Element_ID=53838 AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:38:21 PM COT +UPDATE AD_Field SET Name='Allow Cities out of List', Description='A flag which tells if a country accept or not new cities when capturing locations', Help=NULL WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=53838) AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:38:21 PM COT +UPDATE AD_PrintFormatItem pi SET PrintName='Allow Cities out of List', Name='Allow Cities out of List' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=pi.AD_Column_ID AND c.AD_Element_ID=53838) +; + +-- Sep 17, 2009 9:45:01 PM COT +UPDATE AD_Element SET Help='The Capture Sequence defines the fields to be used when capturing an address on this country. The following notations are used: @CO@=Country, @C@=City, @P@=Postal, @A@=PostalAdd, @R@=Region, @A1@=Address 1 to @A4@=Address 4. Country is always mandatory, add a bang ! to make another field mandatory, for example @C!@ makes city mandatory, @A1!@ makes Address 1 mandatory.', Name='Capture Sequence',Updated=TO_DATE('2009-09-17 21:45:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=53839 +; + +-- Sep 17, 2009 9:45:01 PM COT +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=53839 +; + +-- Sep 17, 2009 9:45:01 PM COT +UPDATE AD_Column SET ColumnName='CaptureSequence', Name='Capture Sequence', Description=NULL, Help='The Capture Sequence defines the fields to be used when capturing an address on this country. The following notations are used: @CO@=Country, @C@=City, @P@=Postal, @A@=PostalAdd, @R@=Region, @A1@=Address 1 to @A4@=Address 4. Country is always mandatory, add a bang ! to make another field mandatory, for example @C!@ makes city mandatory, @A1!@ makes Address 1 mandatory.' WHERE AD_Element_ID=53839 +; + +-- Sep 17, 2009 9:45:01 PM COT +UPDATE AD_Process_Para SET ColumnName='CaptureSequence', Name='Capture Sequence', Description=NULL, Help='The Capture Sequence defines the fields to be used when capturing an address on this country. The following notations are used: @CO@=Country, @C@=City, @P@=Postal, @A@=PostalAdd, @R@=Region, @A1@=Address 1 to @A4@=Address 4. Country is always mandatory, add a bang ! to make another field mandatory, for example @C!@ makes city mandatory, @A1!@ makes Address 1 mandatory.', AD_Element_ID=53839 WHERE UPPER(ColumnName)='CAPTURESEQUENCE' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Sep 17, 2009 9:45:01 PM COT +UPDATE AD_Process_Para SET ColumnName='CaptureSequence', Name='Capture Sequence', Description=NULL, Help='The Capture Sequence defines the fields to be used when capturing an address on this country. The following notations are used: @CO@=Country, @C@=City, @P@=Postal, @A@=PostalAdd, @R@=Region, @A1@=Address 1 to @A4@=Address 4. Country is always mandatory, add a bang ! to make another field mandatory, for example @C!@ makes city mandatory, @A1!@ makes Address 1 mandatory.' WHERE AD_Element_ID=53839 AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:45:01 PM COT +UPDATE AD_Field SET Name='Capture Sequence', Description=NULL, Help='The Capture Sequence defines the fields to be used when capturing an address on this country. The following notations are used: @CO@=Country, @C@=City, @P@=Postal, @A@=PostalAdd, @R@=Region, @A1@=Address 1 to @A4@=Address 4. Country is always mandatory, add a bang ! to make another field mandatory, for example @C!@ makes city mandatory, @A1!@ makes Address 1 mandatory.' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=53839) AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:45:01 PM COT +UPDATE AD_PrintFormatItem pi SET PrintName='Capture Sequence', Name='Capture Sequence' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=pi.AD_Column_ID AND c.AD_Element_ID=53839) +; + +-- Sep 17, 2009 9:50:35 PM COT +UPDATE AD_Column SET FieldLength=60,Updated=TO_DATE('2009-09-17 21:50:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=57651 +; + +-- Sep 17, 2009 9:50:41 PM COT +ALTER TABLE C_Country MODIFY CaptureSequence NVARCHAR2(60) DEFAULT NULL +; + +-- Sep 17, 2009 9:51:38 PM COT +UPDATE AD_Field SET DisplayLength=40,Updated=TO_DATE('2009-09-17 21:51:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57036 +; + +update c_country set capturesequence = '@A1@ @A2@ @A3@ @A4@ ' || displaysequence || ' @CO@' +; + +-- Sep 17, 2009 9:56:09 PM COT +UPDATE C_Country SET CaptureSequence='@CO@ @R!@ @C!@ @A1!@ @A2@ @A3@ @A4@ @P@',Updated=TO_DATE('2009-09-17 21:56:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_Country_ID=156 +; + +-- Sep 17, 2009 9:57:12 PM COT +UPDATE C_Country SET HasRegion='Y', RegionName='Department',Updated=TO_DATE('2009-09-17 21:57:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_Country_ID=156 +; + +-- Sep 17, 2009 9:57:21 PM COT +UPDATE C_Country SET AllowCitiesOutOfList='Y',Updated=TO_DATE('2009-09-17 21:57:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_Country_ID=156 +; + +-- Sep 17, 2009 10:00:20 PM COT +UPDATE C_Country_Trl SET IsTranslated='Y',RegionName='Departamento',Updated=TO_DATE('2009-09-17 22:00:20','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_Country_ID=156 AND AD_Language LIKE 'es_%' +; + +-- 22-sep-2009 14:02:27 COT +-- FR [2794312] - Location AutoComplete +-- Deprecate form Initial Client Setup +UPDATE AD_Form SET IsActive='N',Updated=TO_DATE('2009-09-22 14:02:27','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Form_ID=102 +; + +-- 22-sep-2009 14:02:30 COT +UPDATE AD_Menu SET IsActive='N',Updated=TO_DATE('2009-09-22 14:02:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Menu_ID=225 +; + +-- 22-sep-2009 14:07:20 COT +-- FR [2794312] - Location AutoComplete +INSERT INTO AD_SysConfig (AD_Client_ID,AD_Org_ID,AD_SysConfig_ID,ConfigurationLevel,Created,CreatedBy,Description,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,50035,'S',TO_DATE('2009-09-22 14:07:19','YYYY-MM-DD HH24:MI:SS'),100,'Number of rows to show on city autocomplete feature on Location window','D','Y','LOCATION_MAX_CITY_ROWS',TO_DATE('2009-09-22 14:07:19','YYYY-MM-DD HH24:MI:SS'),100,'7') +; + diff --git a/migration/354a-trunk/postgresql/580g_FR2794312.sql b/migration/354a-trunk/postgresql/580g_FR2794312.sql new file mode 100644 index 0000000000..487a7e83fc --- /dev/null +++ b/migration/354a-trunk/postgresql/580g_FR2794312.sql @@ -0,0 +1,497 @@ +-- 22.05.2009 10:25:55 EEST +-- Location AutoComplete - http://sourceforge.net/tracker/?func=detail&aid=2794312&group_id=176962&atid=879335 +INSERT INTO AD_Element (UpdatedBy,AD_Element_ID,IsActive,CreatedBy,ColumnName,Name,Description,Updated,Created,AD_Client_ID,AD_Org_ID,PrintName,EntityType) VALUES (0,53838,'Y',0,'AllowCitiesOutOfList','AllowCitiesOutOfList','A flag which tells if a country accept or not new cities',TO_TIMESTAMP('2009-05-22 10:25:53','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2009-05-22 10:25:53','YYYY-MM-DD HH24:MI:SS'),0,0,'Allow Cities Out Of List','D') +; + +-- 22.05.2009 10:25:55 EEST +INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Name,Description,Help,PrintName,PO_PrintName,PO_Name,PO_Description,PO_Help, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Element_ID, t.Name,t.Description,t.Help,t.PrintName,t.PO_PrintName,t.PO_Name,t.PO_Description,t.PO_Help, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=53838 AND EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Element_ID!=t.AD_Element_ID) +; + +-- 22.05.2009 10:28:40 EEST +INSERT INTO AD_Column (AD_Column_ID,IsParent,AD_Client_ID,AD_Org_ID,IsAutocomplete,AD_Table_ID,FieldLength,Created,CreatedBy,Updated,Version,DefaultValue,IsActive,Description,ColumnName,IsKey,AD_Reference_ID,IsTranslated,IsMandatory,IsIdentifier,SeqNo,IsSelectionColumn,IsSyncDatabase,AD_Element_ID,IsUpdateable,EntityType,Name,UpdatedBy,IsAlwaysUpdateable,IsEncrypted,IsAllowLogging) VALUES (57650,'N',0,0,'N',170,1,TO_TIMESTAMP('2009-05-22 10:28:37','YYYY-MM-DD HH24:MI:SS'),0,TO_TIMESTAMP('2009-05-22 10:28:37','YYYY-MM-DD HH24:MI:SS'),0,'Y','Y','A flag which tells if a country accept or not new cities','AllowCitiesOutOfList','N',20,'N','N','N',0,'N','N',53838,'Y','U','AllowCitiesOutOfList',0,'N','N','Y') +; + +-- 22.05.2009 10:28:40 EEST +INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=57650 AND EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Column_ID!=t.AD_Column_ID) +; + +-- 22.05.2009 10:28:41 EEST +INSERT INTO AD_Field (IsFieldOnly,DisplayLength,AD_Field_ID,IsEncrypted,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,UpdatedBy,IsActive,Created,IsSameLine,IsHeading,CreatedBy,AD_Client_ID,Updated,Description,AD_Org_ID,IsReadOnly,IsCentrallyMaintained,EntityType) VALUES ('N',1,57035,'N','AllowCitiesOutOfList',135,57650,'N',0,'Y',TO_TIMESTAMP('2009-05-22 10:28:40','YYYY-MM-DD HH24:MI:SS'),'N','N',0,0,TO_TIMESTAMP('2009-05-22 10:28:40','YYYY-MM-DD HH24:MI:SS'),'A flag which tells if a country accept or not new cities',0,'N','Y','U') +; + +-- 22.05.2009 10:28:41 EEST +INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=57035 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID) +; + +-- 22.05.2009 10:28:42 EEST +ALTER TABLE C_Country ADD COLUMN AllowCitiesOutOfList CHAR(1) DEFAULT 'Y' CHECK (AllowCitiesOutOfList IN ('Y','N')) +; + +-- 22.05.2009 10:29:08 EEST +UPDATE AD_Column SET EntityType='D',Updated=TO_TIMESTAMP('2009-05-22 10:29:08','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Column_ID=57650 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=70,IsDisplayed='Y' WHERE AD_Field_ID=342 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=80,IsDisplayed='Y' WHERE AD_Field_ID=343 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=90,IsDisplayed='Y' WHERE AD_Field_ID=345 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=100,IsDisplayed='Y' WHERE AD_Field_ID=10893 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=110,IsDisplayed='Y' WHERE AD_Field_ID=10892 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=120,IsDisplayed='Y' WHERE AD_Field_ID=10891 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=130,IsDisplayed='Y' WHERE AD_Field_ID=346 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=140,IsDisplayed='Y' WHERE AD_Field_ID=347 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=150,IsDisplayed='Y' WHERE AD_Field_ID=348 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=160,IsDisplayed='Y' WHERE AD_Field_ID=344 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=170,IsDisplayed='Y' WHERE AD_Field_ID=11184 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=180,IsDisplayed='Y' WHERE AD_Field_ID=10895 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=190,IsDisplayed='Y' WHERE AD_Field_ID=10894 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=200,IsDisplayed='Y' WHERE AD_Field_ID=5753 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=210,IsDisplayed='Y' WHERE AD_Field_ID=5752 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=220,IsDisplayed='Y' WHERE AD_Field_ID=51000 +; + +-- 22.05.2009 10:30:52 EEST +UPDATE AD_Field SET SeqNo=270,IsDisplayed='Y' WHERE AD_Field_ID=57035 +; + +-- 22.05.2009 10:32:17 EEST +INSERT INTO AD_Element (UpdatedBy,AD_Element_ID,IsActive,CreatedBy,ColumnName,Name,Updated,Created,AD_Client_ID,AD_Org_ID,PrintName,EntityType) VALUES (0,53839,'Y',0,'CaptureSequence','CaptureSequence',TO_TIMESTAMP('2009-05-22 10:32:16','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2009-05-22 10:32:16','YYYY-MM-DD HH24:MI:SS'),0,0,'Capture Sequence','D') +; + +-- 22.05.2009 10:32:17 EEST +INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Name,Description,Help,PrintName,PO_PrintName,PO_Name,PO_Description,PO_Help, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Element_ID, t.Name,t.Description,t.Help,t.PrintName,t.PO_PrintName,t.PO_Name,t.PO_Description,t.PO_Help, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=53839 AND EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Element_ID!=t.AD_Element_ID) +; + +-- 22.05.2009 10:32:49 EEST +INSERT INTO AD_Column (AD_Column_ID,IsParent,AD_Client_ID,AD_Org_ID,IsAutocomplete,AD_Table_ID,FieldLength,Created,CreatedBy,Updated,Version,IsActive,ColumnName,IsKey,AD_Reference_ID,IsTranslated,IsMandatory,IsIdentifier,SeqNo,IsSelectionColumn,IsSyncDatabase,AD_Element_ID,IsUpdateable,EntityType,Name,UpdatedBy,IsAlwaysUpdateable,IsEncrypted,IsAllowLogging) VALUES (57651,'N',0,0,'N',170,20,TO_TIMESTAMP('2009-05-22 10:32:48','YYYY-MM-DD HH24:MI:SS'),0,TO_TIMESTAMP('2009-05-22 10:32:48','YYYY-MM-DD HH24:MI:SS'),1,'Y','CaptureSequence','N',10,'N','N','N',0,'N','N',53839,'Y','D','CaptureSequence',0,'N','N','Y') +; + +-- 22.05.2009 10:32:49 EEST +INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=57651 AND EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Column_ID!=t.AD_Column_ID) +; + +-- 22.05.2009 10:32:50 EEST +INSERT INTO AD_Field (IsFieldOnly,DisplayLength,AD_Field_ID,IsEncrypted,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,UpdatedBy,IsActive,Created,IsSameLine,IsHeading,CreatedBy,AD_Client_ID,Updated,AD_Org_ID,IsReadOnly,IsCentrallyMaintained,EntityType) VALUES ('N',20,57036,'N','CaptureSequence',135,57651,'N',0,'Y',TO_TIMESTAMP('2009-05-22 10:32:49','YYYY-MM-DD HH24:MI:SS'),'N','N',0,0,TO_TIMESTAMP('2009-05-22 10:32:49','YYYY-MM-DD HH24:MI:SS'),0,'N','Y','D') +; + +-- 22.05.2009 10:32:50 EEST +INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=57036 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID) +; + +-- 22.05.2009 10:32:51 EEST +ALTER TABLE C_Country ADD COLUMN CaptureSequence VARCHAR(20) DEFAULT NULL +; + +-- 22.05.2009 10:33:44 EEST +UPDATE AD_Field SET SeqNo=280,IsDisplayed='Y' WHERE AD_Field_ID=57036 +; + +-- 22.05.2009 10:35:10 EEST +UPDATE AD_Field SET IsSameLine='Y',Updated=TO_TIMESTAMP('2009-05-22 10:35:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=57035 +; + +-- 22.05.2009 10:35:47 EEST +UPDATE AD_Field SET IsSameLine='N',Updated=TO_TIMESTAMP('2009-05-22 10:35:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=57035 +; + +-- 22.05.2009 10:36:41 EEST +UPDATE AD_Field SET SeqNo=230,IsDisplayed='Y' WHERE AD_Field_ID=57035 +; + +-- 22.05.2009 10:36:41 EEST +UPDATE AD_Field SET SeqNo=240,IsDisplayed='Y' WHERE AD_Field_ID=51003 +; + +-- 22.05.2009 10:36:41 EEST +UPDATE AD_Field SET SeqNo=250,IsDisplayed='Y' WHERE AD_Field_ID=51002 +; + +-- 22.05.2009 10:36:41 EEST +UPDATE AD_Field SET SeqNo=260,IsDisplayed='Y' WHERE AD_Field_ID=51004 +; + +-- 22.05.2009 10:36:41 EEST +UPDATE AD_Field SET SeqNo=270,IsDisplayed='Y' WHERE AD_Field_ID=51001 +; + +-- 22.05.2009 10:37:10 EEST +UPDATE AD_Field SET IsSameLine='Y', EntityType='D',Updated=TO_TIMESTAMP('2009-05-22 10:37:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=57035 +; + + +-- 27.05.2009 11:21:49 EEST +INSERT INTO AD_Message (MsgType,MsgText,CreatedBy,IsActive,Created,Updated,UpdatedBy,AD_Client_ID,AD_Org_ID,EntityType,Value,AD_Message_ID) VALUES ('E','The city does not exist and can not be created from here.',0,'Y',TO_TIMESTAMP('2009-05-27 11:21:48','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2009-05-27 11:21:48','YYYY-MM-DD HH24:MI:SS'),0,0,0,'D','CityNotFound',53078) +; + +-- 27.05.2009 11:21:49 EEST +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=53078 AND EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Message_ID!=t.AD_Message_ID) +; + +-- 27.05.2009 11:22:10 EEST +UPDATE AD_Message_Trl SET IsTranslated='Y',MsgText='Orasul nu exista si nu paote fi creat de aici.',Updated=TO_TIMESTAMP('2009-05-27 11:22:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=53078 AND AD_Language='ro_RO' +; + +-- 27.05.2009 11:22:16 EEST +UPDATE AD_Message_Trl SET MsgText='Orasul nu exista si nu poate fi creat de aici.',Updated=TO_TIMESTAMP('2009-05-27 11:22:16','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=53078 AND AD_Language='ro_RO' +; + + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=110,IsDisplayed='Y' WHERE AD_Field_ID=57036 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=120,IsDisplayed='Y' WHERE AD_Field_ID=10892 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=130,IsDisplayed='Y' WHERE AD_Field_ID=10891 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=140,IsDisplayed='Y' WHERE AD_Field_ID=346 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=150,IsDisplayed='Y' WHERE AD_Field_ID=347 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=160,IsDisplayed='Y' WHERE AD_Field_ID=348 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=170,IsDisplayed='Y' WHERE AD_Field_ID=344 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=180,IsDisplayed='Y' WHERE AD_Field_ID=11184 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=190,IsDisplayed='Y' WHERE AD_Field_ID=10895 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=200,IsDisplayed='Y' WHERE AD_Field_ID=10894 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=210,IsDisplayed='Y' WHERE AD_Field_ID=5753 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=220,IsDisplayed='Y' WHERE AD_Field_ID=5752 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=230,IsDisplayed='Y' WHERE AD_Field_ID=51000 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=240,IsDisplayed='Y' WHERE AD_Field_ID=57035 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=250,IsDisplayed='Y' WHERE AD_Field_ID=51003 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=260,IsDisplayed='Y' WHERE AD_Field_ID=51002 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=270,IsDisplayed='Y' WHERE AD_Field_ID=51004 +; + +-- Sep 17, 2009 9:35:45 PM COT +UPDATE AD_Field SET SeqNo=280,IsDisplayed='Y' WHERE AD_Field_ID=51001 +; + +-- Sep 17, 2009 9:37:05 PM COT +UPDATE AD_Element SET Name='Use Postcode Lookup', PrintName='Use Postcode Lookup',Updated=TO_TIMESTAMP('2009-09-17 21:37:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=51000 +; + +-- Sep 17, 2009 9:37:05 PM COT +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=51000 +; + +-- Sep 17, 2009 9:37:05 PM COT +UPDATE AD_Column SET ColumnName='IsPostcodeLookup', Name='Use Postcode Lookup', Description='Does this country have a post code web service', Help='Enable the IsPostcodeLookup if you wish to configure a post code lookup web service' WHERE AD_Element_ID=51000 +; + +-- Sep 17, 2009 9:37:05 PM COT +UPDATE AD_Process_Para SET ColumnName='IsPostcodeLookup', Name='Use Postcode Lookup', Description='Does this country have a post code web service', Help='Enable the IsPostcodeLookup if you wish to configure a post code lookup web service', AD_Element_ID=51000 WHERE UPPER(ColumnName)='ISPOSTCODELOOKUP' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Sep 17, 2009 9:37:05 PM COT +UPDATE AD_Process_Para SET ColumnName='IsPostcodeLookup', Name='Use Postcode Lookup', Description='Does this country have a post code web service', Help='Enable the IsPostcodeLookup if you wish to configure a post code lookup web service' WHERE AD_Element_ID=51000 AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:05 PM COT +UPDATE AD_Field SET Name='Use Postcode Lookup', Description='Does this country have a post code web service', Help='Enable the IsPostcodeLookup if you wish to configure a post code lookup web service' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=51000) AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:06 PM COT +UPDATE AD_PrintFormatItem SET PrintName='Use Postcode Lookup', Name='Use Postcode Lookup' 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=51000) +; + +-- Sep 17, 2009 9:37:19 PM COT +UPDATE AD_Element SET Name='Lookup ClassName', PrintName='Lookup ClassName',Updated=TO_TIMESTAMP('2009-09-17 21:37:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=51001 +; + +-- Sep 17, 2009 9:37:19 PM COT +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=51001 +; + +-- Sep 17, 2009 9:37:19 PM COT +UPDATE AD_Column SET ColumnName='LookupClassName', Name='Lookup ClassName', Description='The class name of the postcode lookup plugin', Help='Enter the class name of the post code lookup plugin for your postcode web service provider' WHERE AD_Element_ID=51001 +; + +-- Sep 17, 2009 9:37:19 PM COT +UPDATE AD_Process_Para SET ColumnName='LookupClassName', Name='Lookup ClassName', Description='The class name of the postcode lookup plugin', Help='Enter the class name of the post code lookup plugin for your postcode web service provider', AD_Element_ID=51001 WHERE UPPER(ColumnName)='LOOKUPCLASSNAME' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Sep 17, 2009 9:37:19 PM COT +UPDATE AD_Process_Para SET ColumnName='LookupClassName', Name='Lookup ClassName', Description='The class name of the postcode lookup plugin', Help='Enter the class name of the post code lookup plugin for your postcode web service provider' WHERE AD_Element_ID=51001 AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:19 PM COT +UPDATE AD_Field SET Name='Lookup ClassName', Description='The class name of the postcode lookup plugin', Help='Enter the class name of the post code lookup plugin for your postcode web service provider' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=51001) AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:19 PM COT +UPDATE AD_PrintFormatItem SET PrintName='Lookup ClassName', Name='Lookup ClassName' 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=51001) +; + +-- Sep 17, 2009 9:37:31 PM COT +UPDATE AD_Element SET Name='Lookup Client ID', PrintName='Lookup Client ID',Updated=TO_TIMESTAMP('2009-09-17 21:37:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=51002 +; + +-- Sep 17, 2009 9:37:31 PM COT +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=51002 +; + +-- Sep 17, 2009 9:37:31 PM COT +UPDATE AD_Column SET ColumnName='LookupClientID', Name='Lookup Client ID', Description='The ClientID or Login submitted to the Lookup URL', Help='Enter the ClientID or Login for your account provided by the post code web service provider' WHERE AD_Element_ID=51002 +; + +-- Sep 17, 2009 9:37:31 PM COT +UPDATE AD_Process_Para SET ColumnName='LookupClientID', Name='Lookup Client ID', Description='The ClientID or Login submitted to the Lookup URL', Help='Enter the ClientID or Login for your account provided by the post code web service provider', AD_Element_ID=51002 WHERE UPPER(ColumnName)='LOOKUPCLIENTID' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Sep 17, 2009 9:37:31 PM COT +UPDATE AD_Process_Para SET ColumnName='LookupClientID', Name='Lookup Client ID', Description='The ClientID or Login submitted to the Lookup URL', Help='Enter the ClientID or Login for your account provided by the post code web service provider' WHERE AD_Element_ID=51002 AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:31 PM COT +UPDATE AD_Field SET Name='Lookup Client ID', Description='The ClientID or Login submitted to the Lookup URL', Help='Enter the ClientID or Login for your account provided by the post code web service provider' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=51002) AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:31 PM COT +UPDATE AD_PrintFormatItem SET PrintName='Lookup Client ID', Name='Lookup Client ID' 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=51002) +; + +-- Sep 17, 2009 9:37:38 PM COT +UPDATE AD_Element SET Name='Lookup Password', PrintName='Lookup Password',Updated=TO_TIMESTAMP('2009-09-17 21:37:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=51004 +; + +-- Sep 17, 2009 9:37:38 PM COT +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=51004 +; + +-- Sep 17, 2009 9:37:38 PM COT +UPDATE AD_Column SET ColumnName='LookupPassword', Name='Lookup Password', Description='The password submitted to the Lookup URL', Help='Enter the password for your account provided by the post code web service provider' WHERE AD_Element_ID=51004 +; + +-- Sep 17, 2009 9:37:38 PM COT +UPDATE AD_Process_Para SET ColumnName='LookupPassword', Name='Lookup Password', Description='The password submitted to the Lookup URL', Help='Enter the password for your account provided by the post code web service provider', AD_Element_ID=51004 WHERE UPPER(ColumnName)='LOOKUPPASSWORD' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Sep 17, 2009 9:37:38 PM COT +UPDATE AD_Process_Para SET ColumnName='LookupPassword', Name='Lookup Password', Description='The password submitted to the Lookup URL', Help='Enter the password for your account provided by the post code web service provider' WHERE AD_Element_ID=51004 AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:38 PM COT +UPDATE AD_Field SET Name='Lookup Password', Description='The password submitted to the Lookup URL', Help='Enter the password for your account provided by the post code web service provider' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=51004) AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:38 PM COT +UPDATE AD_PrintFormatItem SET PrintName='Lookup Password', Name='Lookup Password' 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=51004) +; + +-- Sep 17, 2009 9:37:50 PM COT +UPDATE AD_Element SET Name='Lookup URL', PrintName='Lookup URL',Updated=TO_TIMESTAMP('2009-09-17 21:37:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=51003 +; + +-- Sep 17, 2009 9:37:50 PM COT +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=51003 +; + +-- Sep 17, 2009 9:37:50 PM COT +UPDATE AD_Column SET ColumnName='LookupUrl', Name='Lookup URL', Description='The URL of the web service that the plugin connects to in order to retrieve postcode data', Help='Enter the URL of the web service that the plugin connects to in order to retrieve postcode data' WHERE AD_Element_ID=51003 +; + +-- Sep 17, 2009 9:37:50 PM COT +UPDATE AD_Process_Para SET ColumnName='LookupUrl', Name='Lookup URL', Description='The URL of the web service that the plugin connects to in order to retrieve postcode data', Help='Enter the URL of the web service that the plugin connects to in order to retrieve postcode data', AD_Element_ID=51003 WHERE UPPER(ColumnName)='LOOKUPURL' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Sep 17, 2009 9:37:50 PM COT +UPDATE AD_Process_Para SET ColumnName='LookupUrl', Name='Lookup URL', Description='The URL of the web service that the plugin connects to in order to retrieve postcode data', Help='Enter the URL of the web service that the plugin connects to in order to retrieve postcode data' WHERE AD_Element_ID=51003 AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:50 PM COT +UPDATE AD_Field SET Name='Lookup URL', Description='The URL of the web service that the plugin connects to in order to retrieve postcode data', Help='Enter the URL of the web service that the plugin connects to in order to retrieve postcode data' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=51003) AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:37:50 PM COT +UPDATE AD_PrintFormatItem SET PrintName='Lookup URL', Name='Lookup URL' 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=51003) +; + +-- Sep 17, 2009 9:38:21 PM COT +UPDATE AD_Element SET Description='A flag which tells if a country accept or not new cities when capturing locations', Name='Allow Cities out of List', PrintName='Allow Cities out of List',Updated=TO_TIMESTAMP('2009-09-17 21:38:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=53838 +; + +-- Sep 17, 2009 9:38:21 PM COT +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=53838 +; + +-- Sep 17, 2009 9:38:21 PM COT +UPDATE AD_Column SET ColumnName='AllowCitiesOutOfList', Name='Allow Cities out of List', Description='A flag which tells if a country accept or not new cities when capturing locations', Help=NULL WHERE AD_Element_ID=53838 +; + +-- Sep 17, 2009 9:38:21 PM COT +UPDATE AD_Process_Para SET ColumnName='AllowCitiesOutOfList', Name='Allow Cities out of List', Description='A flag which tells if a country accept or not new cities when capturing locations', Help=NULL, AD_Element_ID=53838 WHERE UPPER(ColumnName)='ALLOWCITIESOUTOFLIST' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Sep 17, 2009 9:38:21 PM COT +UPDATE AD_Process_Para SET ColumnName='AllowCitiesOutOfList', Name='Allow Cities out of List', Description='A flag which tells if a country accept or not new cities when capturing locations', Help=NULL WHERE AD_Element_ID=53838 AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:38:21 PM COT +UPDATE AD_Field SET Name='Allow Cities out of List', Description='A flag which tells if a country accept or not new cities when capturing locations', Help=NULL WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=53838) AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:38:21 PM COT +UPDATE AD_PrintFormatItem SET PrintName='Allow Cities out of List', Name='Allow Cities out of List' 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=53838) +; + +-- Sep 17, 2009 9:45:01 PM COT +UPDATE AD_Element SET Help='The Capture Sequence defines the fields to be used when capturing an address on this country. The following notations are used: @CO@=Country, @C@=City, @P@=Postal, @A@=PostalAdd, @R@=Region, @A1@=Address 1 to @A4@=Address 4. Country is always mandatory, add a bang ! to make another field mandatory, for example @C!@ makes city mandatory, @A1!@ makes Address 1 mandatory.', Name='Capture Sequence',Updated=TO_TIMESTAMP('2009-09-17 21:45:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=53839 +; + +-- Sep 17, 2009 9:45:01 PM COT +UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=53839 +; + +-- Sep 17, 2009 9:45:01 PM COT +UPDATE AD_Column SET ColumnName='CaptureSequence', Name='Capture Sequence', Description=NULL, Help='The Capture Sequence defines the fields to be used when capturing an address on this country. The following notations are used: @CO@=Country, @C@=City, @P@=Postal, @A@=PostalAdd, @R@=Region, @A1@=Address 1 to @A4@=Address 4. Country is always mandatory, add a bang ! to make another field mandatory, for example @C!@ makes city mandatory, @A1!@ makes Address 1 mandatory.' WHERE AD_Element_ID=53839 +; + +-- Sep 17, 2009 9:45:01 PM COT +UPDATE AD_Process_Para SET ColumnName='CaptureSequence', Name='Capture Sequence', Description=NULL, Help='The Capture Sequence defines the fields to be used when capturing an address on this country. The following notations are used: @CO@=Country, @C@=City, @P@=Postal, @A@=PostalAdd, @R@=Region, @A1@=Address 1 to @A4@=Address 4. Country is always mandatory, add a bang ! to make another field mandatory, for example @C!@ makes city mandatory, @A1!@ makes Address 1 mandatory.', AD_Element_ID=53839 WHERE UPPER(ColumnName)='CAPTURESEQUENCE' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Sep 17, 2009 9:45:01 PM COT +UPDATE AD_Process_Para SET ColumnName='CaptureSequence', Name='Capture Sequence', Description=NULL, Help='The Capture Sequence defines the fields to be used when capturing an address on this country. The following notations are used: @CO@=Country, @C@=City, @P@=Postal, @A@=PostalAdd, @R@=Region, @A1@=Address 1 to @A4@=Address 4. Country is always mandatory, add a bang ! to make another field mandatory, for example @C!@ makes city mandatory, @A1!@ makes Address 1 mandatory.' WHERE AD_Element_ID=53839 AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:45:01 PM COT +UPDATE AD_Field SET Name='Capture Sequence', Description=NULL, Help='The Capture Sequence defines the fields to be used when capturing an address on this country. The following notations are used: @CO@=Country, @C@=City, @P@=Postal, @A@=PostalAdd, @R@=Region, @A1@=Address 1 to @A4@=Address 4. Country is always mandatory, add a bang ! to make another field mandatory, for example @C!@ makes city mandatory, @A1!@ makes Address 1 mandatory.' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=53839) AND IsCentrallyMaintained='Y' +; + +-- Sep 17, 2009 9:45:01 PM COT +UPDATE AD_PrintFormatItem SET PrintName='Capture Sequence', Name='Capture Sequence' 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=53839) +; + +-- Sep 17, 2009 9:50:35 PM COT +UPDATE AD_Column SET FieldLength=60,Updated=TO_TIMESTAMP('2009-09-17 21:50:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=57651 +; + +-- Sep 17, 2009 9:50:41 PM COT +insert into t_alter_column values('c_country','CaptureSequence','VARCHAR(60)',null,'NULL') +; + +-- Sep 17, 2009 9:51:38 PM COT +UPDATE AD_Field SET DisplayLength=40,Updated=TO_TIMESTAMP('2009-09-17 21:51:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57036 +; + +update c_country set capturesequence = '@A1@ @A2@ @A3@ @A4@ ' || displaysequence || ' @CO@' +; + +-- Sep 17, 2009 9:56:09 PM COT +UPDATE C_Country SET CaptureSequence='@CO@ @R!@ @C!@ @A1!@ @A2@ @A3@ @A4@ @P@',Updated=TO_TIMESTAMP('2009-09-17 21:56:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_Country_ID=156 +; + +-- Sep 17, 2009 9:57:12 PM COT +UPDATE C_Country SET HasRegion='Y', RegionName='Department',Updated=TO_TIMESTAMP('2009-09-17 21:57:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_Country_ID=156 +; + +-- Sep 17, 2009 9:57:17 PM COT +UPDATE C_Country SET AllowCitiesOutOfList='Y',Updated=TO_TIMESTAMP('2009-09-17 21:57:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_Country_ID=156 +; + +-- Sep 17, 2009 10:00:20 PM COT +UPDATE C_Country_Trl SET IsTranslated='Y',RegionName='Departamento',Updated=TO_TIMESTAMP('2009-09-17 22:00:20','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_Country_ID=156 AND AD_Language LIKE 'es_%' +; + +-- 22-sep-2009 14:02:27 COT +-- FR [2794312] - Location AutoComplete +-- Deprecate form Initial Client Setup +UPDATE AD_Form SET IsActive='N',Updated=TO_TIMESTAMP('2009-09-22 14:02:27','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Form_ID=102 +; + +-- 22-sep-2009 14:02:30 COT +UPDATE AD_Menu SET IsActive='N',Updated=TO_TIMESTAMP('2009-09-22 14:02:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Menu_ID=225 +; + +-- 22-sep-2009 14:07:20 COT +-- FR [2794312] - Location AutoComplete +INSERT INTO AD_SysConfig (AD_Client_ID,AD_Org_ID,AD_SysConfig_ID,ConfigurationLevel,Created,CreatedBy,Description,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,50035,'S',TO_TIMESTAMP('2009-09-22 14:07:19','YYYY-MM-DD HH24:MI:SS'),100,'Number of rows to show on city autocomplete feature on Location window','D','Y','LOCATION_MAX_CITY_ROWS',TO_TIMESTAMP('2009-09-22 14:07:19','YYYY-MM-DD HH24:MI:SS'),100,'7') +; + diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/AutoComplete.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/AutoComplete.java index f49cf39289..45c574c1a4 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/AutoComplete.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/AutoComplete.java @@ -1,154 +1,154 @@ -/****************************************************************************** - * Product: Posterita Ajax UI * - * Copyright (C) 2007 Posterita Ltd. 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 * - * Posterita Ltd., 3, Draper Avenue, Quatre Bornes, Mauritius * - * or via info@posterita.org or http://www.posterita.org/ * - *****************************************************************************/ - -package org.adempiere.webui.component; - -import java.util.Arrays; -import java.util.Iterator; - -import org.zkoss.zk.ui.event.InputEvent; -import org.zkoss.zul.Comboitem; - -/** - * Auto-complete with combobox. - * Based on ZK's Auto-complete - * - * @author Niraj Sohun - * Aug 20, 2007 - */ - -public class AutoComplete extends Combobox -{ - /** - * - */ - private static final long serialVersionUID = 2642639623099513816L; - - /** comboItems All menu labels */ - private String[] comboItems; - - /** strDescription Description of menu items */ - private String[] strDescription; - - /** - * Set menu labels - * - * @param vals Menu labels - */ - - public void setDict(String[] vals) - { - comboItems = vals; - - if (comboItems != null) - { - Arrays.sort(comboItems); - } - } - - /** - * Set description of menu items - * - * @param vals Description of menu items - */ - - public void setDescription(String[] vals) - { - strDescription = vals; - } - - /** - * Constructor - */ - - public AutoComplete() - { - if (comboItems != null) - refresh(""); - } - - public AutoComplete(String value) - { - super.setValue(value); - } - - public void setValue(String value) - { - super.setValue(value); - refresh(value); - } - - /** - * Event handler responsible to reducing number of items - * Method is invoked each time something is typed in the combobox - * - * @param evt The event - */ - - public void onChanging(InputEvent evt) - { - if (!evt.isChangingBySelectBack()) - { - refresh(evt.getValue()); - } - } - - /** - * Refresh comboitem based on the specified value. - */ - private void refresh(String val) - { - if ((val == null) || (val.trim().length() == 0)) { - super.getChildren().clear(); - return; - } - - String compare = val.toLowerCase().trim(); - - Iterator it = getItems().iterator(); - for (int i = 0; i < comboItems.length; i++) - { - boolean match = false; - if (compare.length() < 3) - { - match = comboItems[i].toLowerCase().startsWith(compare); - } - else - { - match = comboItems[i].toLowerCase().contains(compare); - } - if (match) - { - Comboitem comboitem = null; - if (it != null && it.hasNext()) { - comboitem = ((Comboitem)it.next()); - } else { - it = null; - comboitem = new Comboitem(); - super.appendChild(comboitem); - } - - comboitem.setLabel(comboItems[i]); - comboitem.setDescription(strDescription[i]); - } - } - while (it != null && it.hasNext()) { - it.next(); - it.remove(); - } - } -} +/****************************************************************************** + * Product: Posterita Ajax UI * + * Copyright (C) 2007 Posterita Ltd. 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 * + * Posterita Ltd., 3, Draper Avenue, Quatre Bornes, Mauritius * + * or via info@posterita.org or http://www.posterita.org/ * + *****************************************************************************/ + +package org.adempiere.webui.component; + +import java.util.Arrays; +import java.util.Iterator; + +import org.zkoss.zk.ui.event.InputEvent; +import org.zkoss.zul.Comboitem; + +/** + * Auto-complete with combobox. + * Based on ZK's Auto-complete + * + * @author Niraj Sohun + * Aug 20, 2007 + */ + +public class AutoComplete extends Combobox +{ + /** + * + */ + private static final long serialVersionUID = 2642639623099513816L; + + /** comboItems All menu labels */ + private String[] comboItems; + + /** strDescription Description of menu items */ + private String[] strDescription; + + /** + * Set menu labels + * + * @param vals Menu labels + */ + + public void setDict(String[] vals) + { + comboItems = vals; + + if (comboItems != null) + { + Arrays.sort(comboItems); + } + } + + /** + * Set description of menu items + * + * @param vals Description of menu items + */ + + public void setDescription(String[] vals) + { + strDescription = vals; + } + + /** + * Constructor + */ + + public AutoComplete() + { + if (comboItems != null) + refresh(""); + } + + public AutoComplete(String value) + { + super.setValue(value); + } + + public void setValue(String value) + { + super.setValue(value); + refresh(value); + } + + /** + * Event handler responsible to reducing number of items + * Method is invoked each time something is typed in the combobox + * + * @param evt The event + */ + + public void onChanging(InputEvent evt) + { + if (!evt.isChangingBySelectBack()) + { + refresh(evt.getValue()); + } + } + + /** + * Refresh comboitem based on the specified value. + */ + private void refresh(String val) + { + if (comboItems == null || val == null) { + super.getChildren().clear(); + return; + } + + String compare = val.toLowerCase().trim(); + + Iterator it = getItems().iterator(); + for (int i = 0; i < comboItems.length; i++) + { + boolean match = false; + if (compare.length() < 3) + { + match = comboItems[i].toLowerCase().startsWith(compare); + } + else + { + match = comboItems[i].toLowerCase().contains(compare); + } + if (match) + { + Comboitem comboitem = null; + if (it != null && it.hasNext()) { + comboitem = ((Comboitem)it.next()); + } else { + it = null; + comboitem = new Comboitem(); + super.appendChild(comboitem); + } + + comboitem.setLabel(comboItems[i]); + comboitem.setDescription(strDescription[i]); + } + } + while (it != null && it.hasNext()) { + it.next(); + it.remove(); + } + } +} diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WAutoCompleterCity.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WAutoCompleterCity.java new file mode 100644 index 0000000000..6c3a4d2f57 --- /dev/null +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WAutoCompleterCity.java @@ -0,0 +1,245 @@ +/****************************************************************************** + * Product: Adempiere ERP & CRM Smart Business Solution * + * Copyright (C) 2009 SC ARHIPAC SERVICE SRL. 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. * + *****************************************************************************/ +package org.adempiere.webui.window; + + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; + +import org.adempiere.exceptions.DBException; +import org.adempiere.webui.component.AutoComplete; +import org.compiere.grid.ed.CityVO; +import org.compiere.model.MSysConfig; +import org.compiere.util.DB; +import org.compiere.util.Env; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zk.ui.event.EventListener; +import org.zkoss.zk.ui.event.Events; +import org.zkoss.zk.ui.event.InputEvent; +import org.zkoss.zul.Timer; + + + +/** + * @author Cristina Ghita - www.arhipac.ro + * + */ +public class WAutoCompleterCity extends AutoComplete implements EventListener +{ + /** + * + */ + private static final long serialVersionUID = 318310285903469314L; + + private static final int PopupDelayMillis = 500; + + private final Timer timer = new Timer(PopupDelayMillis); + + private CityVO m_city = null; + + private ArrayList m_cities = new ArrayList(); + + private ArrayList m_citiesShow = new ArrayList(); + + private final int m_maxRows = MSysConfig.getIntValue("LOCATION_MAX_CITY_ROWS", 7); + + public static final CityVO ITEM_More = new CityVO(-1, "...", -1, ""); + + private final int m_windowNo; + + public WAutoCompleterCity(int m_windowNo) + { + super(); + this.m_windowNo = m_windowNo; + this.addEventListener(Events.ON_SELECT, this); + } + + private void showPopupDelayed() + { + timer.setRepeats(false); + timer.start(); + } + + @Override + public void onChanging(InputEvent evt) + { + showPopupDelayed(); + refreshData(evt.getValue()); + super.onChanging(evt); + } + + public void refreshData(String val) + { + String search = val; + if (m_city != null && m_city.CityName.compareTo(search) != 0) + { + setCity(null); + } + m_citiesShow.clear(); + this.removeAllItems(); + this.setDict(null); + this.setDescription(null); + boolean truncated = false; + search = search.toUpperCase(); + int i = 0; + for (CityVO vo : m_cities) { + if (vo.CityName.toUpperCase().startsWith(search)) { + if (i > 0 && i == m_maxRows+1) + { + m_citiesShow.add(ITEM_More); + truncated = true; + break; + } + m_citiesShow.add(vo); + i++; + } + } + //if there is no city on the list return false, to not show the popup + if (m_citiesShow.isEmpty()) + { + return; + } + else + { + CityVO city = (CityVO) m_citiesShow.get(0); + if (city.CityName.equalsIgnoreCase(search)) + { + m_city = city; + return; + } + } + //if the list has only one item, but that item is not equals with m_city + //return false to not show any popup + if (!truncated && m_citiesShow.size() == 1 + && m_city != null && m_citiesShow.get(0).equals(this.m_city)) + { + return; + } + + String[] cityValues = new String[m_citiesShow.size()]; + String[] cityDesc = new String[m_citiesShow.size()]; + i = 0; + for (CityVO vo : m_citiesShow) { + cityValues[i] = vo.CityName; + cityDesc[i] = vo.RegionName; + i++; + } + // + this.removeAllItems(); + this.setDict(cityValues); + this.setDescription(cityDesc); + } + + public void fillList() + { + // Carlos Ruiz - globalqss - improve to avoid going to the database on every keystroke + m_cities.clear(); + m_citiesShow.clear(); + ArrayList params = new ArrayList(); + final StringBuffer sql = new StringBuffer( + "SELECT cy.C_City_ID, cy.Name, cy.C_Region_ID, r.Name" + +" FROM C_City cy" + +" LEFT OUTER JOIN C_Region r ON (r.C_Region_ID=cy.C_Region_ID)" + +" WHERE cy.AD_Client_ID IN (0,?)"); + params.add(getAD_Client_ID()); + if (getC_Region_ID() > 0) + { + sql.append(" AND cy.C_Region_ID=?"); + params.add(getC_Region_ID()); + } + if (getC_Country_ID() > 0) + { + sql.append(" AND cy.C_Country_ID=?"); + params.add(getC_Country_ID()); + } + sql.append(" ORDER BY cy.Name, r.Name"); + PreparedStatement pstmt = null; + ResultSet rs = null; + try + { + pstmt = DB.prepareStatement(sql.toString(), null); + DB.setParameters(pstmt, params); + rs = pstmt.executeQuery(); + int i = 0; + while(rs.next()) + { + CityVO vo = new CityVO(rs.getInt(1), rs.getString(2), rs.getInt(3), rs.getString(4)); + m_cities.add(vo); + if (i <= m_maxRows) { + m_citiesShow.add(vo); + } else if (i == m_maxRows + 1 && i > 0) { + m_citiesShow.add(ITEM_More); + } + i++; + } + } + catch (SQLException e) + { + throw new DBException(e, sql.toString()); + } + finally + { + DB.close(rs, pstmt); + rs = null; pstmt = null; + } + refreshData(""); + } + + private void setCity(CityVO vo) + { + m_city = vo; + } + public int getC_City_ID() + { + return m_city != null ? m_city.C_City_ID : -1; + } + public int getAD_Client_ID() + { + return Env.getAD_Client_ID(Env.getCtx()); + } + public int getC_Country_ID() + { + return Env.getContextAsInt(Env.getCtx(), m_windowNo, Env.TAB_INFO, "C_Country_ID"); + } + public int getC_Region_ID() + { + return Env.getContextAsInt(Env.getCtx(), m_windowNo, Env.TAB_INFO, "C_Region_ID"); + } + + + public void onEvent(Event event) throws Exception + { + System.out.println("Event: " + event.getName()); + event.toString(); + int index = this.getSelectedIndex(); + System.out.println("Index = " +index ); + if (index>=0) + { + CityVO city = (CityVO) m_citiesShow.get(index); + + if(event == null || city.equals(ITEM_More)) + { + setCity(null); + return; + } + + setCity(city); + Env.setContext(Env.getCtx(), m_windowNo, Env.TAB_INFO, "C_Region_ID", String.valueOf(city.C_Region_ID)); + this.setText(city.CityName); + } + } + +} diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java index 055a7a6729..655a936f8e 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java @@ -1,425 +1,602 @@ -/****************************************************************************** - * 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 * - *****************************************************************************/ - -/** - * 2007, Modified by Posterita Ltd. - */ - -package org.adempiere.webui.window; - -import java.util.Iterator; -import java.util.List; -import java.util.StringTokenizer; -import java.util.logging.Level; - -import org.adempiere.webui.component.Button; -import org.adempiere.webui.component.Grid; -import org.adempiere.webui.component.GridFactory; -import org.adempiere.webui.component.Label; -import org.adempiere.webui.component.ListItem; -import org.adempiere.webui.component.Listbox; -import org.adempiere.webui.component.Panel; -import org.adempiere.webui.component.Row; -import org.adempiere.webui.component.Textbox; -import org.adempiere.webui.component.Window; -import org.compiere.model.MCountry; -import org.compiere.model.MLocation; -import org.compiere.model.MRegion; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.zkoss.zk.ui.event.Event; -import org.zkoss.zk.ui.event.EventListener; -import org.zkoss.zk.ui.event.Events; - -/** - * @author Sendy Yagambrum - * @date July 16, 2007 - * Location Dialog Box - * This class is based upon VLocationDialog, written by Jorg Janke - * - **/ -public class WLocationDialog extends Window implements EventListener -{ - /** - * - */ - private static final long serialVersionUID = 7510181548669317310L; - private static final String LABEL_STYLE = "white-space: nowrap;"; - /** Logger */ - private static CLogger log = CLogger.getCLogger(WLocationDialog.class); - private Label lblAddress1; - private Label lblAddress2; - private Label lblAddress3; - private Label lblAddress4; - private Label lblCity; - private Label lblZip; - private Label lblRegion; - private Label lblPostal; - private Label lblPostalAdd; - private Label lblCountry; - - private Textbox txtAddress1; - private Textbox txtAddress2; - private Textbox txtAddress3; - private Textbox txtAddress4; - private Textbox txtCity; - private Textbox txtPostal; - private Textbox txtPostalAdd; - private Listbox lstRegion; - private Listbox lstCountry; - - private Button btnOk; - private Button btnCancel; - private Grid mainPanel; - - private boolean m_change = false; - private MLocation m_location; - private int m_origCountry_ID; - private int s_oldCountry_ID = 0; - - public WLocationDialog(String title, MLocation location) - { - m_location = location; - if (m_location == null) - m_location = new MLocation (Env.getCtx(), 0, null); - // Overwrite title - if (m_location.getC_Location_ID() == 0) - setTitle(Msg.getMsg(Env.getCtx(), "LocationNew")); - else - setTitle(Msg.getMsg(Env.getCtx(), "LocationUpdate")); - - initComponents(); - init(); -// Current Country - MCountry.setDisplayLanguage(Env.getAD_Language(Env.getCtx())); - for (MCountry country:MCountry.getCountries(Env.getCtx())) - { - lstCountry.appendItem(country.getName(), country); - } - setCountry(); - lstCountry.addEventListener(Events.ON_SELECT,this); - m_origCountry_ID = m_location.getC_Country_ID(); - // Current Region - for (MRegion region : MRegion.getRegions(Env.getCtx(), m_origCountry_ID)) - { - lstRegion.appendItem(region.getName(),region); - } - if (m_location.getCountry().isHasRegion() && - m_location.getCountry().getRegionName() != null && - m_location.getCountry().getRegionName().trim().length() > 0) - lblRegion.setValue(m_location.getCountry().getRegionName()); // name for region - - setRegion(); - initLocation(); - // - this.setWidth("290px"); - this.setClosable(true); - this.setBorder("normal"); - this.setAttribute("mode","modal"); - } - - private void initComponents() - { - lblAddress1 = new Label(Msg.getElement(Env.getCtx(), "Address1")); - lblAddress1.setStyle(LABEL_STYLE); - lblAddress2 = new Label(Msg.getElement(Env.getCtx(), "Address2")); - lblAddress2.setStyle(LABEL_STYLE); - lblAddress3 = new Label(Msg.getElement(Env.getCtx(), "Address3")); - lblAddress3.setStyle(LABEL_STYLE); - lblAddress4 = new Label(Msg.getElement(Env.getCtx(), "Address4")); - lblAddress4.setStyle(LABEL_STYLE); - lblCity = new Label(Msg.getMsg(Env.getCtx(), "City")); - lblCity.setStyle(LABEL_STYLE); - lblZip = new Label(Msg.getMsg(Env.getCtx(), "Postal")); - lblZip.setStyle(LABEL_STYLE); - lblRegion = new Label(Msg.getMsg(Env.getCtx(), "Region")); - lblRegion.setStyle(LABEL_STYLE); - lblPostal = new Label(Msg.getMsg(Env.getCtx(), "Postal")); - lblPostal.setStyle(LABEL_STYLE); - lblPostalAdd = new Label(Msg.getMsg(Env.getCtx(), "PostalAdd")); - lblPostalAdd.setStyle(LABEL_STYLE); - lblCountry = new Label(Msg.getMsg(Env.getCtx(), "Country")); - lblCountry.setStyle(LABEL_STYLE); - - txtAddress1 = new Textbox(); - txtAddress1.setCols(20); - txtAddress2 = new Textbox(); - txtAddress2.setCols(20); - txtAddress3 = new Textbox(); - txtAddress3.setCols(20); - txtAddress4 = new Textbox(); - txtAddress4.setCols(20); - txtCity = new Textbox(); - txtCity.setCols(20); - txtPostal = new Textbox(); - txtPostal.setCols(20); - txtPostalAdd = new Textbox(); - txtPostalAdd.setCols(20); - - lstRegion = new Listbox(); - lstRegion.setMold("select"); - lstRegion.setWidth("154px"); - lstRegion.setRows(0); - - lstCountry = new Listbox(); - lstCountry.setMold("select"); - lstCountry.setWidth("154px"); - lstCountry.setRows(0); - - btnOk = new Button(); - btnOk.setImage("/images/Ok16.png"); - btnOk.addEventListener(Events.ON_CLICK,this); - btnCancel = new Button(); - btnCancel.setImage("/images/Cancel16.png"); - btnCancel.addEventListener(Events.ON_CLICK,this); - - mainPanel = GridFactory.newGridLayout(); - mainPanel.setStyle("padding:5px"); - } - - private void init() - { - Row pnlAddress1 = new Row(); - pnlAddress1.appendChild(lblAddress1.rightAlign()); - pnlAddress1.appendChild(txtAddress1); - - Row pnlAddress2 = new Row(); - pnlAddress2.appendChild(lblAddress2.rightAlign()); - pnlAddress2.appendChild(txtAddress2); - - Row pnlAddress3 = new Row(); - pnlAddress3.appendChild(lblAddress3.rightAlign()); - pnlAddress3.appendChild(txtAddress3); - - Row pnlAddress4 = new Row(); - pnlAddress4.appendChild(lblAddress4.rightAlign()); - pnlAddress4.appendChild(txtAddress4); - - Row pnlCity = new Row(); - pnlCity.appendChild(lblCity.rightAlign()); - pnlCity.appendChild(txtCity); - - Row pnlPostal = new Row(); - pnlPostal.appendChild(lblPostal.rightAlign()); - pnlPostal.appendChild(txtPostal); - - Row pnlPostalAdd = new Row(); - pnlPostalAdd.appendChild(lblPostalAdd.rightAlign()); - pnlPostalAdd.appendChild(txtPostalAdd); - - Row pnlRegion = new Row(); - pnlRegion.appendChild(lblRegion.rightAlign()); - pnlRegion.appendChild(lstRegion); - - Row pnlCountry = new Row(); - pnlCountry.appendChild(lblCountry.rightAlign()); - pnlCountry.appendChild(lstCountry); - - Panel pnlButton = new Panel(); - pnlButton.appendChild(btnOk); - pnlButton.appendChild(btnCancel); - pnlButton.setWidth("100%"); - pnlButton.setStyle("text-align:right"); - - this.appendChild(mainPanel); - this.appendChild(pnlButton); - } - /** - * Dynamically add fields to the Location dialog box - * @param panel panel to add - * - */ - private void addComponents(Row row) - { - if (mainPanel.getRows() != null) - mainPanel.getRows().appendChild(row); - else - mainPanel.newRows().appendChild(row); - } - - private void initLocation() - { - if (mainPanel.getRows() != null) - mainPanel.getRows().getChildren().clear(); - - MCountry country = m_location.getCountry(); - log.fine(country.getName() + ", Region=" + country.isHasRegion() + " " + country.getDisplaySequence() - + ", C_Location_ID=" + m_location.getC_Location_ID()); - // new Region - if (m_location.getC_Country_ID() != s_oldCountry_ID && country.isHasRegion()) - { - lstRegion.getChildren().clear(); - for (MRegion region : MRegion.getRegions(Env.getCtx(), country.getC_Country_ID())) - { - lstRegion.appendItem(region.getName(),region); - } - if (m_location.getRegion() != null) - { - setRegion(); - } - s_oldCountry_ID = m_location.getC_Country_ID(); - } - addComponents((Row)txtAddress1.getParent()); - addComponents((Row)txtAddress2.getParent()); - addComponents((Row)txtAddress3.getParent()); - addComponents((Row)txtAddress4.getParent()); -// sequence of City Postal Region - @P@ @C@ - @C@, @R@ @P@ - String ds = country.getDisplaySequence(); - if (ds == null || ds.length() == 0) - { - log.log(Level.SEVERE, "DisplaySequence empty - " + country); - ds = ""; // @C@, @P@ - } - StringTokenizer st = new StringTokenizer(ds, "@", false); - while (st.hasMoreTokens()) - { - String s = st.nextToken(); - if (s.startsWith("C")) - addComponents((Row)txtCity.getParent()); - else if (s.startsWith("P")) - addComponents((Row)txtPostal.getParent()); - else if (s.startsWith("A")) - addComponents((Row)txtPostalAdd.getParent()); - else if (s.startsWith("R") && m_location.getCountry().isHasRegion()) - addComponents((Row)lstRegion.getParent()); - } - // Country Last - addComponents((Row)lstCountry.getParent()); - -// Fill it - if (m_location.getC_Location_ID() != 0) - { - txtAddress1.setText(m_location.getAddress1()); - txtAddress2.setText(m_location.getAddress2()); - txtAddress3.setText(m_location.getAddress3()); - txtAddress4.setText(m_location.getAddress4()); - txtCity.setText(m_location.getCity()); - txtPostal.setText(m_location.getPostal()); - txtPostalAdd.setText(m_location.getPostal_Add()); - if (m_location.getCountry().isHasRegion()) - { - if (m_location.getCountry().getRegionName() != null - && m_location.getCountry().getRegionName().trim().length() > 0) - lblRegion.setValue(m_location.getCountry().getRegionName()); - else - lblRegion.setValue(Msg.getMsg(Env.getCtx(), "Region")); - - setRegion(); - } - setCountry(); - } - } - private void setCountry() - { - List listCountry = lstCountry.getChildren(); - Iterator iter = listCountry.iterator(); - while (iter.hasNext()) - { - ListItem listitem = (ListItem)iter.next(); - if (m_location.getCountry().equals(listitem.getValue())) - { - lstCountry.setSelectedItem(listitem); - } - } - } - private void setRegion() - { - if (m_location.getRegion() != null) - { - List listState = lstRegion.getChildren(); - Iterator iter = listState.iterator(); - while (iter.hasNext()) - { - ListItem listitem = (ListItem)iter.next(); - if (m_location.getRegion().equals(listitem.getValue())) - { - lstRegion.setSelectedItem(listitem); - } - } - } - else - { - lstRegion.setSelectedItem(null); - } - } - /** - * Get result - * @return true, if changed - */ - public boolean isChanged() - { - return m_change; - } // getChange - /** - * Get edited Value (MLocation) - * @return location - */ - public MLocation getValue() - { - return m_location; - } - - public void onEvent(Event event) throws Exception - { - if (btnOk.equals(event.getTarget())) - { - action_OK(); - m_change = true; - this.detach(); - } - else if (btnCancel.equals(event.getTarget())) - { - m_change = false; - this.detach(); - } - - // Country Changed - display in new Format - else if (lstCountry.equals(event.getTarget())) - { - MCountry c = (MCountry)lstCountry.getSelectedItem().getValue(); - m_location.setCountry(c); - // refrseh - initLocation(); - } - } - /** - * OK - check for changes (save them) & Exit - */ - private void action_OK() - { - m_location.setAddress1(txtAddress1.getValue()); - m_location.setAddress2(txtAddress2.getValue()); - m_location.setAddress3(txtAddress3.getValue()); - m_location.setAddress4(txtAddress4.getValue()); - m_location.setCity(txtCity.getValue()); - m_location.setPostal(txtPostal.getValue()); - // Country/Region - MCountry c = (MCountry)lstCountry.getSelectedItem().getValue(); - m_location.setCountry(c); - if (m_location.getCountry().isHasRegion()) - { - MRegion r = (MRegion)lstRegion.getSelectedItem().getValue(); - m_location.setRegion(r); - } - else - m_location.setC_Region_ID(0); - // Save chnages - m_location.save(); - - } // actionOK -} +/****************************************************************************** + * 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 * + *****************************************************************************/ + +/** + * 2007, Modified by Posterita Ltd. + */ + +package org.adempiere.webui.window; + +import java.util.Iterator; +import java.util.List; +import java.util.StringTokenizer; +import java.util.logging.Level; + +import org.adempiere.webui.component.Button; +import org.adempiere.webui.component.Grid; +import org.adempiere.webui.component.GridFactory; +import org.adempiere.webui.component.Label; +import org.adempiere.webui.component.ListItem; +import org.adempiere.webui.component.Listbox; +import org.adempiere.webui.component.Panel; +import org.adempiere.webui.component.Row; +import org.adempiere.webui.component.Textbox; +import org.adempiere.webui.component.Window; +import org.compiere.model.MCountry; +import org.compiere.model.MLocation; +import org.compiere.model.MRegion; +import org.compiere.util.CLogger; +import org.compiere.util.Env; +import org.compiere.util.Msg; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zk.ui.event.EventListener; +import org.zkoss.zk.ui.event.Events; + +/** + * @author Sendy Yagambrum + * @date July 16, 2007 + * Location Dialog Box + * This class is based upon VLocationDialog, written by Jorg Janke + * @author Cristina Ghita, www.arhipac.ro + *
  • FR [ 2794312 ] Location AutoComplete + * + * @TODO: Implement fOnline button present in swing client + * + **/ +public class WLocationDialog extends Window implements EventListener +{ + /** + * + */ + private static final long serialVersionUID = 6892969005447776082L; + private static final String LABEL_STYLE = "white-space: nowrap;"; + /** Logger */ + private static CLogger log = CLogger.getCLogger(WLocationDialog.class); + private Label lblAddress1; + private Label lblAddress2; + private Label lblAddress3; + private Label lblAddress4; + private Label lblCity; + private Label lblZip; + private Label lblRegion; + private Label lblPostal; + private Label lblPostalAdd; + private Label lblCountry; + + private Textbox txtAddress1; + private Textbox txtAddress2; + private Textbox txtAddress3; + private Textbox txtAddress4; + private WAutoCompleterCity txtCity; + private Textbox txtPostal; + private Textbox txtPostalAdd; + private Listbox lstRegion; + private Listbox lstCountry; + + private Button btnOk; + private Button btnCancel; + private Grid mainPanel; + + private boolean m_change = false; + private MLocation m_location; + private int m_origCountry_ID; + private int s_oldCountry_ID = 0; + + private int m_WindowNo = 0; + + private boolean isCityMandatory = false; + private boolean isRegionMandatory = false; + private boolean isAddress1Mandatory = false; + private boolean isAddress2Mandatory = false; + private boolean isAddress3Mandatory = false; + private boolean isAddress4Mandatory = false; + private boolean isPostalMandatory = false; + private boolean isPostalAddMandatory = false; + + private boolean inCountryAction; + private boolean inOKAction; + + public WLocationDialog(String title, MLocation location) + { + m_location = location; + if (m_location == null) + m_location = new MLocation (Env.getCtx(), 0, null); + // Overwrite title + if (m_location.getC_Location_ID() == 0) + setTitle(Msg.getMsg(Env.getCtx(), "LocationNew")); + else + setTitle(Msg.getMsg(Env.getCtx(), "LocationUpdate")); + // + // Reset TAB_INFO context + Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "C_Region_ID", null); + Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "C_Country_ID", null); + // + initComponents(); + init(); + // Current Country + MCountry.setDisplayLanguage(Env.getAD_Language(Env.getCtx())); + for (MCountry country:MCountry.getCountries(Env.getCtx())) + { + lstCountry.appendItem(country.getName(), country); + } + setCountry(); + lstCountry.addEventListener(Events.ON_SELECT,this); + lstRegion.addEventListener(Events.ON_SELECT,this); + m_origCountry_ID = m_location.getC_Country_ID(); + // Current Region + lstRegion.appendItem("", null); + for (MRegion region : MRegion.getRegions(Env.getCtx(), m_origCountry_ID)) + { + lstRegion.appendItem(region.getName(),region); + } + if (m_location.getCountry().isHasRegion()) { + if (m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName) != null + && m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName).trim().length() > 0) + lblRegion.setValue(m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName)); + else + lblRegion.setValue(Msg.getMsg(Env.getCtx(), "Region")); + } + + setRegion(); + initLocation(); + // + this.setWidth("290px"); + this.setClosable(true); + this.setBorder("normal"); + this.setAttribute("mode","modal"); + } + + private void initComponents() + { + lblAddress1 = new Label(Msg.getElement(Env.getCtx(), "Address1")); + lblAddress1.setStyle(LABEL_STYLE); + lblAddress2 = new Label(Msg.getElement(Env.getCtx(), "Address2")); + lblAddress2.setStyle(LABEL_STYLE); + lblAddress3 = new Label(Msg.getElement(Env.getCtx(), "Address3")); + lblAddress3.setStyle(LABEL_STYLE); + lblAddress4 = new Label(Msg.getElement(Env.getCtx(), "Address4")); + lblAddress4.setStyle(LABEL_STYLE); + lblCity = new Label(Msg.getMsg(Env.getCtx(), "City")); + lblCity.setStyle(LABEL_STYLE); + lblZip = new Label(Msg.getMsg(Env.getCtx(), "Postal")); + lblZip.setStyle(LABEL_STYLE); + lblRegion = new Label(Msg.getMsg(Env.getCtx(), "Region")); + lblRegion.setStyle(LABEL_STYLE); + lblPostal = new Label(Msg.getMsg(Env.getCtx(), "Postal")); + lblPostal.setStyle(LABEL_STYLE); + lblPostalAdd = new Label(Msg.getMsg(Env.getCtx(), "PostalAdd")); + lblPostalAdd.setStyle(LABEL_STYLE); + lblCountry = new Label(Msg.getMsg(Env.getCtx(), "Country")); + lblCountry.setStyle(LABEL_STYLE); + + txtAddress1 = new Textbox(); + txtAddress1.setCols(20); + txtAddress2 = new Textbox(); + txtAddress2.setCols(20); + txtAddress3 = new Textbox(); + txtAddress3.setCols(20); + txtAddress4 = new Textbox(); + txtAddress4.setCols(20); + + //autocomplete City + txtCity = new WAutoCompleterCity(m_WindowNo); + txtCity.setCols(20); + txtCity.setAutodrop(true); + txtCity.setAutocomplete(true); + txtCity.addEventListener(Events.ON_CHANGING, this); + //txtCity + + txtPostal = new Textbox(); + txtPostal.setCols(20); + txtPostalAdd = new Textbox(); + txtPostalAdd.setCols(20); + + lstRegion = new Listbox(); + lstRegion.setMold("select"); + lstRegion.setWidth("154px"); + lstRegion.setRows(0); + + lstCountry = new Listbox(); + lstCountry.setMold("select"); + lstCountry.setWidth("154px"); + lstCountry.setRows(0); + + btnOk = new Button(); + btnOk.setImage("/images/Ok16.png"); + btnOk.addEventListener(Events.ON_CLICK,this); + btnCancel = new Button(); + btnCancel.setImage("/images/Cancel16.png"); + btnCancel.addEventListener(Events.ON_CLICK,this); + + mainPanel = GridFactory.newGridLayout(); + mainPanel.setStyle("padding:5px"); + } + + private void init() + { + Row pnlAddress1 = new Row(); + pnlAddress1.appendChild(lblAddress1.rightAlign()); + pnlAddress1.appendChild(txtAddress1); + + Row pnlAddress2 = new Row(); + pnlAddress2.appendChild(lblAddress2.rightAlign()); + pnlAddress2.appendChild(txtAddress2); + + Row pnlAddress3 = new Row(); + pnlAddress3.appendChild(lblAddress3.rightAlign()); + pnlAddress3.appendChild(txtAddress3); + + Row pnlAddress4 = new Row(); + pnlAddress4.appendChild(lblAddress4.rightAlign()); + pnlAddress4.appendChild(txtAddress4); + + Row pnlCity = new Row(); + pnlCity.appendChild(lblCity.rightAlign()); + pnlCity.appendChild(txtCity); + + Row pnlPostal = new Row(); + pnlPostal.appendChild(lblPostal.rightAlign()); + pnlPostal.appendChild(txtPostal); + + Row pnlPostalAdd = new Row(); + pnlPostalAdd.appendChild(lblPostalAdd.rightAlign()); + pnlPostalAdd.appendChild(txtPostalAdd); + + Row pnlRegion = new Row(); + pnlRegion.appendChild(lblRegion.rightAlign()); + pnlRegion.appendChild(lstRegion); + + Row pnlCountry = new Row(); + pnlCountry.appendChild(lblCountry.rightAlign()); + pnlCountry.appendChild(lstCountry); + + Panel pnlButton = new Panel(); + pnlButton.appendChild(btnOk); + pnlButton.appendChild(btnCancel); + pnlButton.setWidth("100%"); + pnlButton.setStyle("text-align:right"); + + this.appendChild(mainPanel); + this.appendChild(pnlButton); + } + /** + * Dynamically add fields to the Location dialog box + * @param panel panel to add + * + */ + private void addComponents(Row row) + { + if (mainPanel.getRows() != null) + mainPanel.getRows().appendChild(row); + else + mainPanel.newRows().appendChild(row); + } + + private void initLocation() + { + if (mainPanel.getRows() != null) + mainPanel.getRows().getChildren().clear(); + + MCountry country = m_location.getCountry(); + log.fine(country.getName() + ", Region=" + country.isHasRegion() + " " + country.getCaptureSequence() + + ", C_Location_ID=" + m_location.getC_Location_ID()); + // new Country + if (m_location.getC_Country_ID() != s_oldCountry_ID) + { + lstRegion.getChildren().clear(); + if (country.isHasRegion()) { + lstRegion.appendItem("", null); + for (MRegion region : MRegion.getRegions(Env.getCtx(), country.getC_Country_ID())) + { + lstRegion.appendItem(region.getName(),region); + } + if (m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName) != null + && m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName).trim().length() > 0) + lblRegion.setValue(m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName)); + else + lblRegion.setValue(Msg.getMsg(Env.getCtx(), "Region")); + } + s_oldCountry_ID = m_location.getC_Country_ID(); + } + + if (m_location.getC_Region_ID() > 0 && m_location.getC_Region().getC_Country_ID() == country.getC_Country_ID()) { + setRegion(); + } else { + lstRegion.setSelectedItem(null); + m_location.setC_Region_ID(0); + } + + if (country.isHasRegion() && m_location.getC_Region_ID() > 0) + { + Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "C_Region_ID", String.valueOf(m_location.getC_Region_ID())); + } else { + Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "C_Region_ID", "0"); + } + Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "C_Country_ID", String.valueOf(country.get_ID())); + + txtCity.fillList(); + + // sequence of City Postal Region - @P@ @C@ - @C@, @R@ @P@ + String ds = country.getCaptureSequence(); + if (ds == null || ds.length() == 0) + { + log.log(Level.SEVERE, "CaptureSequence empty - " + country); + ds = ""; // @C@, @P@ + } + isCityMandatory = false; + isRegionMandatory = false; + isAddress1Mandatory = false; + isAddress2Mandatory = false; + isAddress3Mandatory = false; + isAddress4Mandatory = false; + isPostalMandatory = false; + isPostalAddMandatory = false; + StringTokenizer st = new StringTokenizer(ds, "@", false); + while (st.hasMoreTokens()) + { + String s = st.nextToken(); + if (s.startsWith("CO")) { + // Country Last + addComponents((Row)lstCountry.getParent()); + // TODO: Add Online + // if (m_location.getCountry().isPostcodeLookup()) { + // addLine(line++, lOnline, fOnline); + // } + } else if (s.startsWith("A1")) { + addComponents((Row)txtAddress1.getParent()); + isAddress1Mandatory = s.endsWith("!"); + } else if (s.startsWith("A2")) { + addComponents((Row)txtAddress2.getParent()); + isAddress2Mandatory = s.endsWith("!"); + } else if (s.startsWith("A3")) { + addComponents((Row)txtAddress3.getParent()); + isAddress3Mandatory = s.endsWith("!"); + } else if (s.startsWith("A4")) { + addComponents((Row)txtAddress4.getParent()); + isAddress4Mandatory = s.endsWith("!"); + } else if (s.startsWith("C")) { + addComponents((Row)txtCity.getParent()); + isCityMandatory = s.endsWith("!"); + } else if (s.startsWith("P")) { + addComponents((Row)txtPostal.getParent()); + isPostalMandatory = s.endsWith("!"); + } else if (s.startsWith("A")) { + addComponents((Row)txtPostalAdd.getParent()); + isPostalAddMandatory = s.endsWith("!"); + } else if (s.startsWith("R") && m_location.getCountry().isHasRegion()) { + addComponents((Row)lstRegion.getParent()); + isRegionMandatory = s.endsWith("!"); + } + } + + // Fill it + if (m_location.getC_Location_ID() != 0) + { + txtAddress1.setText(m_location.getAddress1()); + txtAddress2.setText(m_location.getAddress2()); + txtAddress3.setText(m_location.getAddress3()); + txtAddress4.setText(m_location.getAddress4()); + txtCity.setText(m_location.getCity()); + txtPostal.setText(m_location.getPostal()); + txtPostalAdd.setText(m_location.getPostal_Add()); + if (m_location.getCountry().isHasRegion()) + { + if (m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName) != null + && m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName).trim().length() > 0) + lblRegion.setValue(m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName)); + else + lblRegion.setValue(Msg.getMsg(Env.getCtx(), "Region")); + + setRegion(); + } + setCountry(); + } + } + private void setCountry() + { + List listCountry = lstCountry.getChildren(); + Iterator iter = listCountry.iterator(); + while (iter.hasNext()) + { + ListItem listitem = (ListItem)iter.next(); + if (m_location.getCountry().equals(listitem.getValue())) + { + lstCountry.setSelectedItem(listitem); + } + } + } + + private void setRegion() + { + if (m_location.getRegion() != null) + { + List listState = lstRegion.getChildren(); + Iterator iter = listState.iterator(); + while (iter.hasNext()) + { + ListItem listitem = (ListItem)iter.next(); + if (m_location.getRegion().equals(listitem.getValue())) + { + lstRegion.setSelectedItem(listitem); + } + } + } + else + { + lstRegion.setSelectedItem(null); + } + } + /** + * Get result + * @return true, if changed + */ + public boolean isChanged() + { + return m_change; + } // getChange + /** + * Get edited Value (MLocation) + * @return location + */ + public MLocation getValue() + { + return m_location; + } + + public void onEvent(Event event) throws Exception + { + if (btnOk.equals(event.getTarget())) + { + inOKAction = true; + + if (m_location.getCountry().isHasRegion() && lstRegion.getSelectedItem() == null) { + if (txtCity.getC_Region_ID() > 0 && txtCity.getC_Region_ID() != m_location.getC_Region_ID()) { + m_location.setRegion(MRegion.get(Env.getCtx(), txtCity.getC_Region_ID())); + setRegion(); + } + } + + String msg = validate_OK(); + if (msg != null) { + FDialog.error(0, this, "FillMandatory", Msg.parseTranslation(Env.getCtx(), msg)); + inOKAction = false; + return; + } + + if(action_OK()) + { + m_change = true; + inOKAction = false; + this.dispose(); + } + else + { + FDialog.error(0, this, "CityNotFound"); + } + inOKAction = false; + } + else if (btnCancel.equals(event.getTarget())) + { + m_change = false; + this.dispose(); + } + // Country Changed - display in new Format + else if (lstCountry.equals(event.getTarget())) + { + inCountryAction = true; + MCountry c = (MCountry)lstCountry.getSelectedItem().getValue(); + m_location.setCountry(c); + m_location.setC_City_ID(0); + m_location.setCity(null); + // refresh + initLocation(); + inCountryAction = false; + } + // Region Changed + else if (lstRegion.equals(event.getTarget())) + { + if (inCountryAction || inOKAction) + return; + MRegion r = (MRegion)lstRegion.getSelectedItem().getValue(); + m_location.setRegion(r); + m_location.setC_City_ID(0); + m_location.setCity(null); + // refresh + initLocation(); + } + } + + + // LCO - address 1, region and city required + private String validate_OK() { + String fields = ""; + if (isAddress1Mandatory && txtAddress1.getText().trim().length() == 0) { + fields = fields + " " + "@Address1@, "; + } + if (isAddress2Mandatory && txtAddress2.getText().trim().length() == 0) { + fields = fields + " " + "@Address2@, "; + } + if (isAddress3Mandatory && txtAddress3.getText().trim().length() == 0) { + fields = fields + " " + "@Address3@, "; + } + if (isAddress4Mandatory && txtAddress4.getText().trim().length() == 0) { + fields = fields + " " + "@Address4@, "; + } + if (isCityMandatory && txtCity.getValue().trim().length() == 0) { + fields = fields + " " + "@C_City_ID@, "; + } + if (isRegionMandatory && lstRegion.getSelectedItem() == null) { + fields = fields + " " + "@C_Region_ID@, "; + } + if (isPostalMandatory && txtPostal.getText().trim().length() == 0) { + fields = fields + " " + "@Postal@, "; + } + if (isPostalAddMandatory && txtPostalAdd.getText().trim().length() == 0) { + fields = fields + " " + "@PostalAdd@, "; + } + + if (fields.trim().length() > 0) + return fields.substring(0, fields.length() -2); + + return null; + } + + /** + * OK - check for changes (save them) & Exit + */ + private boolean action_OK() + { + m_location.setAddress1(txtAddress1.getValue()); + m_location.setAddress2(txtAddress2.getValue()); + m_location.setAddress3(txtAddress3.getValue()); + m_location.setAddress4(txtAddress4.getValue()); + m_location.setC_City_ID(txtCity.getC_City_ID()); + m_location.setCity(txtCity.getValue()); + m_location.setPostal(txtPostal.getValue()); + // Country/Region + MCountry country = (MCountry)lstCountry.getSelectedItem().getValue(); + m_location.setCountry(country); + if (country.isHasRegion()) + { + MRegion r = (MRegion)lstRegion.getSelectedItem().getValue(); + m_location.setRegion(r); + } + else + { + m_location.setC_Region_ID(0); + } + // Save chnages + if(m_location.save()) + { + return true; + } + else + { + return false; + } + } // actionOK + + @Override + public void dispose() + { + if (!m_change && m_location != null && !m_location.is_new()) + { + m_location = new MLocation(m_location.getCtx(), m_location.get_ID(), null); + } + super.dispose(); + } +}