FR [2794312] Location AutoComplete

https://sourceforge.net/tracker/index.php?func=detail&aid=2794312&group_id=176962&atid=879335
FR [2780543] FR - Implement automplete to WLocationDialog
https://sourceforge.net/tracker/index.php?func=detail&aid=2780543&group_id=176962&atid=955896
And also it covers some flaws in InitialClientSetup raised because of the
new flag C_Country.AllowCitiesOutOfList
Thanks to Carlos for supplying the patch.
This commit is contained in:
tspc 2009-09-24 10:59:05 +00:00
parent a96bb62a67
commit 45446b44bd
16 changed files with 4158 additions and 1751 deletions

View File

@ -33,9 +33,9 @@ import java.io.File;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.AdempiereException;
import org.compiere.model.MCity;
import org.compiere.model.MCurrency; import org.compiere.model.MCurrency;
import org.compiere.model.MSetup; import org.compiere.model.MSetup;
import org.compiere.model.X_C_City;
import org.compiere.print.PrintUtil; import org.compiere.print.PrintUtil;
import org.compiere.process.ProcessInfoParameter; import org.compiere.process.ProcessInfoParameter;
import org.compiere.process.SvrProcess; import org.compiere.process.SvrProcess;
@ -168,9 +168,12 @@ public class InitialClientSetup extends SvrProcess
throw new AdempiereException("@NotUnique@ " + p_NormalUserName); throw new AdempiereException("@NotUnique@ " + p_NormalUserName);
// City_ID overrides CityName if both used // City_ID overrides CityName if both used
if (p_CityName != null && p_CityName.length() > 0 && p_C_City_ID > 0) { if (p_C_City_ID > 0) {
X_C_City city = new X_C_City(getCtx(), p_C_City_ID, null); MCity city = MCity.get(getCtx(), p_C_City_ID);
p_CityName = city.getName(); 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 // Validate existence and read permissions on CoA file
@ -187,8 +190,10 @@ public class InitialClientSetup extends SvrProcess
// Process // Process
MSetup ms = new MSetup(Env.getCtx(), WINDOW_THIS_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"); throw new AdempiereException("Create client failed");
}
addLog(ms.getInfo()); addLog(ms.getInfo());
@ -197,11 +202,16 @@ public class InitialClientSetup extends SvrProcess
KeyNamePair currency_kp = new KeyNamePair(p_C_Currency_ID, currency.getDescription()); KeyNamePair currency_kp = new KeyNamePair(p_C_Currency_ID, currency.getDescription());
if (!ms.createAccounting(currency_kp, if (!ms.createAccounting(currency_kp,
p_IsUseProductDimension, p_IsUseBPDimension, p_IsUseProjectDimension, p_IsUseCampaignDimension, p_IsUseSalesRegionDimension, p_IsUseProductDimension, p_IsUseBPDimension, p_IsUseProjectDimension, p_IsUseCampaignDimension, p_IsUseSalesRegionDimension,
coaFile)) coaFile)) {
ms.rollback();
throw new AdempiereException("@AccountSetupError@"); throw new AdempiereException("@AccountSetupError@");
}
// Generate Entities // 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()); addLog(ms.getInfo());
// Create Print Documents // Create Print Documents
@ -210,4 +220,4 @@ public class InitialClientSetup extends SvrProcess
return "@OK@"; return "@OK@";
} // doIt } // doIt
} // ASPGenerateLevel } // InitialClientSetup

View File

@ -75,6 +75,28 @@ public interface I_C_Country
*/ */
public int getAD_Org_ID(); 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 */ /** Column name C_Country_ID */
public static final String COLUMNNAME_C_Country_ID = "C_Country_ID"; public static final String COLUMNNAME_C_Country_ID = "C_Country_ID";

View File

@ -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<Integer,MCity> s_Cities = new CCache<Integer,MCity>("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

View File

@ -27,6 +27,7 @@ import org.compiere.util.CCache;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util; import org.compiere.util.Util;
/** /**
@ -37,6 +38,7 @@ import org.compiere.util.Util;
* *
* @author Michael Judd (Akuna Ltd) * @author Michael Judd (Akuna Ltd)
* <li>BF [ 2695078 ] Country is not translated on invoice * <li>BF [ 2695078 ] Country is not translated on invoice
* <li>FR [2794312 ] Location AutoComplete - check if allow cities out of list
*/ */
public class MLocation extends X_C_Location implements Comparator 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() 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 (m_c == null)
{ {
if (getC_Country_ID() != 0) if (getC_Country_ID() != 0)
@ -257,14 +263,17 @@ public class MLocation extends X_C_Location implements Comparator
{ {
m_r = region; m_r = region;
if (region == null) if (region == null)
{
super.setC_Region_ID(0); super.setC_Region_ID(0);
}
else else
{ {
super.setC_Region_ID(m_r.getC_Region_ID()); super.setC_Region_ID(m_r.getC_Region_ID());
setRegionName(m_r.getName());
if (m_r.getC_Country_ID() != getC_Country_ID()) if (m_r.getC_Country_ID() != getC_Country_ID())
{ {
log.info("Region(" + region + ") C_Country_ID=" + region.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()); setC_Country_ID(region.getC_Country_ID());
} }
} }
@ -297,6 +306,10 @@ public class MLocation extends X_C_Location implements Comparator
*/ */
public MRegion getRegion() 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) if (m_r == null && getC_Region_ID() != 0)
m_r = MRegion.get(getCtx(), getC_Region_ID()); m_r = MRegion.get(getCtx(), getC_Region_ID());
return m_r; return m_r;
@ -594,9 +607,23 @@ public class MLocation extends X_C_Location implements Comparator
if (!m_c.isHasRegion()) if (!m_c.isHasRegion())
setC_Region_ID(0); 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; return true;
} // geforeSave } // beforeSave
/** /**
* After Save * After Save

View File

@ -1319,4 +1319,14 @@ public final class MSetup
{ {
return m_info.toString(); return m_info.toString();
} }
/**
* Rollback Internal Transaction
*/
public void rollback() {
try {
m_trx.rollback();
m_trx.close();
} catch (Exception e) {}
}
} // MSetup } // MSetup

View File

@ -98,6 +98,44 @@ public class X_C_Country extends PO implements I_C_Country, I_Persistent
return (String)get_Value(COLUMNNAME_AD_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. /** Set Country.
@param C_Country_ID @param C_Country_ID
Country Country

View File

@ -57,6 +57,7 @@ import org.compiere.util.Msg;
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: VSetup.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ * @version $Id: VSetup.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
* @deprecated
*/ */
public class VSetup extends CPanel public class VSetup extends CPanel
implements FormPanel, ActionListener, Runnable implements FormPanel, ActionListener, Runnable

View File

@ -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
* <li>Initial contribution - http://www.jroller.com/santhosh/date/20050620#file_path_autocompletion
* @author Teo Sarca , www.arhipac.ro
* <li>added timed triggering
* <li>refactored
* @author Cristina Ghita , www.arhipac.ro
* <li>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);
}

View File

@ -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<CityVO> list = new ArrayList<CityVO>();
private ArrayList<CityVO> listShow = new ArrayList<CityVO>();
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<Object> params = new ArrayList<Object>();
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);
}
}

View File

@ -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();
}
}

View File

@ -35,6 +35,7 @@ import javax.swing.JLabel;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import org.compiere.apps.ADialog;
import org.compiere.apps.AEnv; import org.compiere.apps.AEnv;
import org.compiere.apps.ConfirmPanel; import org.compiere.apps.ConfirmPanel;
import org.compiere.model.MCountry; import org.compiere.model.MCountry;
@ -63,22 +64,21 @@ import com.akunagroup.uk.postcode.Postcode;
* <li>BF [ 1831060 ] Location dialog should use Address1, Address2 ... elements * <li>BF [ 1831060 ] Location dialog should use Address1, Address2 ... elements
* @author Michael Judd, Akuna Ltd (UK) * @author Michael Judd, Akuna Ltd (UK)
* <li>FR [ 1741222 ] - Webservice connector for address lookups * <li>FR [ 1741222 ] - Webservice connector for address lookups
* @author Cristina Ghita, www.arhipac.ro
* <li>FR [ 2794312 ] Location AutoComplete
*/ */
public class VLocationDialog extends CDialog public class VLocationDialog extends CDialog
implements ActionListener implements ActionListener
{ {
/** Lookup result */
//private Object[][] data = null;
/** /**
* *
*/ */
private static final long serialVersionUID = 6593340606631477392L; private static final long serialVersionUID = 6952838437136830975L;
/** Lookup result header */ /** Lookup result header */
private Object[] header = null; private Object[] header = null;
//private int m_WindowNo = 0; private int m_WindowNo = 0;
/** /**
* Constructor * Constructor
@ -108,6 +108,10 @@ public class VLocationDialog extends CDialog
else else
setTitle(Msg.getMsg(Env.getCtx(), "LocationUpdate")); 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 // Current Country
MCountry.setDisplayLanguage(Env.getAD_Language(Env.getCtx())); MCountry.setDisplayLanguage(Env.getAD_Language(Env.getCtx()));
fCountry = new CComboBox(MCountry.getCountries(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(); m_origCountry_ID = m_location.getC_Country_ID();
// Current Region // Current Region
fRegion = new CComboBox(MRegion.getRegions(Env.getCtx(), m_origCountry_ID)); fRegion = new CComboBox(MRegion.getRegions(Env.getCtx(), m_origCountry_ID));
if (m_location.getCountry().isHasRegion()) if (m_location.getCountry().isHasRegion()) {
lRegion.setText(m_location.getCountry().getRegionName()); // name for 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"));
}
fRegion.setSelectedItem(m_location.getRegion()); fRegion.setSelectedItem(m_location.getRegion());
// //
fOnline.setText(Msg.getMsg(Env.getCtx(), "Online"));
initLocation(); initLocation();
fCountry.addActionListener(this); fCountry.addActionListener(this);
fOnline.addActionListener(this); fOnline.addActionListener(this);
fRegion.addActionListener(this);
AEnv.positionCenterWindow(frame, this); AEnv.positionCenterWindow(frame, this);
} // VLocationDialog } // VLocationDialog
private boolean m_change = false; private boolean m_change = false;
@ -156,7 +165,8 @@ public class VLocationDialog extends CDialog
private CTextField fAddress2 = new CTextField(20); // length=60 private CTextField fAddress2 = new CTextField(20); // length=60
private CTextField fAddress3 = new CTextField(20); // length=60 private CTextField fAddress3 = new CTextField(20); // length=60
private CTextField fAddress4 = 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 fCountry;
private CComboBox fRegion; private CComboBox fRegion;
private CTextField fPostal = new CTextField(5); // length=10 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 labelInsets = new Insets(2,15,2,0); // top,left,bottom,right
private Insets fieldInsets = new Insets(2,5,2,10); 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 * Static component init
* @throws Exception * @throws Exception
@ -184,6 +206,8 @@ public class VLocationDialog extends CDialog
southPanel.add(confirmPanel, BorderLayout.NORTH); southPanel.add(confirmPanel, BorderLayout.NORTH);
// //
confirmPanel.addActionListener(this); confirmPanel.addActionListener(this);
//
fCityAutoCompleter = new CityAutoCompleter(fCity, m_WindowNo);
} // jbInit } // jbInit
/** /**
@ -192,18 +216,42 @@ public class VLocationDialog extends CDialog
private void initLocation() private void initLocation()
{ {
MCountry country = m_location.getCountry(); 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()); + ", C_Location_ID=" + m_location.getC_Location_ID());
// new Region // new Country
if (m_location.getC_Country_ID() != s_oldCountry_ID && country.isHasRegion()) if (country.getC_Country_ID() != s_oldCountry_ID)
{ {
fRegion = new CComboBox(MRegion.getRegions(Env.getCtx(), country.getC_Country_ID())); fRegion.removeAllItems();
if (m_location.getRegion() != null) if (country.isHasRegion()) {
fRegion.setSelectedItem(m_location.getRegion()); for (MRegion region : MRegion.getRegions(Env.getCtx(), country.getC_Country_ID())) {
lRegion.setText(country.getRegionName()); 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(); 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.anchor = GridBagConstraints.NORTHWEST;
gbc.gridy = 0; // line gbc.gridy = 0; // line
gbc.gridx = 0; gbc.gridx = 0;
@ -213,42 +261,64 @@ public class VLocationDialog extends CDialog
gbc.weightx = 0; gbc.weightx = 0;
gbc.weighty = 0; gbc.weighty = 0;
mainPanel.removeAll();
mainPanel.add(Box.createVerticalStrut(5), gbc); // top gap mainPanel.add(Box.createVerticalStrut(5), gbc); // top gap
int line = 1; 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@ // sequence of City Postal Region - @P@ @C@ - @C@, @R@ @P@
String ds = country.getDisplaySequence(); String ds = country.getCaptureSequence();
if (ds == null || ds.length() == 0) if (ds == null || ds.length() == 0)
{ {
log.log(Level.SEVERE, "DisplaySequence empty - " + country); log.log(Level.SEVERE, "CaptureSequence empty - " + country);
ds = ""; // @C@, @P@ 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); StringTokenizer st = new StringTokenizer(ds, "@", false);
while (st.hasMoreTokens()) while (st.hasMoreTokens())
{ {
String s = st.nextToken(); 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); addLine(line++, lCity, fCity);
else if (s.startsWith("P")) isCityMandatory = s.endsWith("!");
} else if (s.startsWith("P")) {
addLine(line++, lPostal, fPostal); addLine(line++, lPostal, fPostal);
else if (s.startsWith("A")) isPostalMandatory = s.endsWith("!");
} else if (s.startsWith("A")) {
addLine(line++, lPostalAdd, fPostalAdd); 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); 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 // Fill it
if (m_location.getC_Location_ID() != 0) if (m_location.getC_Location_ID() != 0)
{ {
@ -261,21 +331,16 @@ public class VLocationDialog extends CDialog
fPostalAdd.setText(m_location.getPostal_Add()); fPostalAdd.setText(m_location.getPostal_Add());
if (m_location.getCountry().isHasRegion()) 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()); fRegion.setSelectedItem(m_location.getRegion());
} }
// disable online if this country doesn't have post code lookup if (!fCountry.getSelectedItem().equals(country))
if (m_location.getCountry().isPostcodeLookup()) { fCountry.setSelectedItem(country);
fOnline.setEnabled(true);
fOnline.setVisible(true);
}
else {
fOnline.setEnabled(false);
fOnline.setVisible(false);
}
fCountry.setSelectedItem(country);
} }
// Update UI // Update UI
pack(); pack();
@ -308,6 +373,15 @@ public class VLocationDialog extends CDialog
} // addLine } // 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 * ActionListener
@ -317,9 +391,32 @@ public class VLocationDialog extends CDialog
{ {
if (e.getActionCommand().equals(ConfirmPanel.A_OK)) if (e.getActionCommand().equals(ConfirmPanel.A_OK))
{ {
action_OK(); inOKAction = true;
m_change = true;
dispose(); 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)) else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL))
{ {
@ -330,34 +427,27 @@ public class VLocationDialog extends CDialog
// Country Changed - display in new Format // Country Changed - display in new Format
else if (e.getSource() == fCountry) else if (e.getSource() == fCountry)
{ {
inCountryAction = true;
// Modifier for Mouse selection is 16 - for any key selection 0 // Modifier for Mouse selection is 16 - for any key selection 0
MCountry c = (MCountry)fCountry.getSelectedItem(); MCountry c = (MCountry)fCountry.getSelectedItem();
m_location.setCountry(c); m_location.setCountry(c);
// refresh online button for new country initLocation();
if (c.isPostcodeLookup()) { fCountry.requestFocus(); // allows to use Keyboard selection
fOnline.setEnabled(true); inCountryAction = false;
fOnline.setVisible(true); }
} // Region Changed
else { else if (e.getSource() == fRegion)
fOnline.setEnabled(false); {
fOnline.setVisible(false); if (inCountryAction || inOKAction)
} return;
MRegion r = (MRegion)fRegion.getSelectedItem();
// update the region name if regions are enabled for this country m_location.setRegion(r);
if (c.isHasRegion()) m_location.setC_City_ID(0);
{ m_location.setCity(null);
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(); initLocation();
fCountry.requestFocus(); // allows to use Keybord selection fRegion.requestFocus(); // allows to use Keyboard selection
} }
else if (e.getSource() == fOnline) else if (e.getSource() == fOnline)
{ {
@ -371,16 +461,51 @@ public class VLocationDialog extends CDialog
} }
} // actionPerformed } // 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 * OK - check for changes (save them) & Exit
*/ */
private void action_OK() private boolean action_OK()
{ {
m_location.setAddress1(fAddress1.getText()); m_location.setAddress1(fAddress1.getText());
m_location.setAddress2(fAddress2.getText()); m_location.setAddress2(fAddress2.getText());
m_location.setAddress3(fAddress3.getText()); m_location.setAddress3(fAddress3.getText());
m_location.setAddress4(fAddress4.getText()); m_location.setAddress4(fAddress4.getText());
m_location.setCity(fCity.getText()); m_location.setCity(fCity.getText());
m_location.setC_City_ID(fCityAutoCompleter.getC_City_ID());
m_location.setPostal(fPostal.getText()); m_location.setPostal(fPostal.getText());
m_location.setPostal_Add(fPostalAdd.getText()); m_location.setPostal_Add(fPostalAdd.getText());
// Country/Region // Country/Region
@ -394,7 +519,14 @@ public class VLocationDialog extends CDialog
else else
m_location.setC_Region_ID(0); m_location.setC_Region_ID(0);
// Save changes // Save changes
m_location.save(); if(m_location.save())
{
return true;
}
else
{
return false;
}
} // actionOK } // actionOK
/** /**
@ -452,111 +584,113 @@ public class VLocationDialog extends CDialog
return ""; 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<String, Object> postcodeData, MCountry country) {
// If it's not empty warn the user. /**
if (fAddress1 != null || fAddress2 != null * Fills the location field using the information retrieved from postcode
|| fAddress3 != null * servers.
|| fAddress4 != null || fCity != null) { *
String warningMsg = "Existing address information will be overwritten. Proceed?"; * @param ctx
String warningTitle = "Warning"; * Context
int response = JOptionPane.showConfirmDialog(null, warningMsg, * @param pkeyData
warningTitle, JOptionPane.YES_NO_OPTION); * Lookup results
if (response == JOptionPane.NO_OPTION) * @param windowNo
return; * Window No.
} * @param tab
* Tab
* @param field
Set<String> pcodeKeys = postcodeData.keySet(); * Field
Iterator<String> iterator = pcodeKeys.iterator(); */
header = null; private void fillLocation(HashMap<String, Object> postcodeData, MCountry country) {
// 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());
}
}
}
// 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<String> pcodeKeys = postcodeData.keySet();
Iterator<String> 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 } // VLocationDialog

View File

@ -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')
;

View File

@ -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')
;

View File

@ -112,7 +112,7 @@ public class AutoComplete extends Combobox
*/ */
private void refresh(String val) private void refresh(String val)
{ {
if ((val == null) || (val.trim().length() == 0)) { if (comboItems == null || val == null) {
super.getChildren().clear(); super.getChildren().clear();
return; return;
} }

View File

@ -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<CityVO> m_cities = new ArrayList<CityVO>();
private ArrayList<CityVO> m_citiesShow = new ArrayList<CityVO>();
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<Object> params = new ArrayList<Object>();
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);
}
}
}

View File

@ -51,375 +51,552 @@ import org.zkoss.zk.ui.event.Events;
* @date July 16, 2007 * @date July 16, 2007
* Location Dialog Box * Location Dialog Box
* This class is based upon VLocationDialog, written by Jorg Janke * This class is based upon VLocationDialog, written by Jorg Janke
* @author Cristina Ghita, www.arhipac.ro
* <li>FR [ 2794312 ] Location AutoComplete
*
* @TODO: Implement fOnline button present in swing client
* *
**/ **/
public class WLocationDialog extends Window implements EventListener public class WLocationDialog extends Window implements EventListener
{ {
/** /**
* *
*/ */
private static final long serialVersionUID = 7510181548669317310L; private static final long serialVersionUID = 6892969005447776082L;
private static final String LABEL_STYLE = "white-space: nowrap;"; private static final String LABEL_STYLE = "white-space: nowrap;";
/** Logger */ /** Logger */
private static CLogger log = CLogger.getCLogger(WLocationDialog.class); private static CLogger log = CLogger.getCLogger(WLocationDialog.class);
private Label lblAddress1; private Label lblAddress1;
private Label lblAddress2; private Label lblAddress2;
private Label lblAddress3; private Label lblAddress3;
private Label lblAddress4; private Label lblAddress4;
private Label lblCity; private Label lblCity;
private Label lblZip; private Label lblZip;
private Label lblRegion; private Label lblRegion;
private Label lblPostal; private Label lblPostal;
private Label lblPostalAdd; private Label lblPostalAdd;
private Label lblCountry; private Label lblCountry;
private Textbox txtAddress1; private Textbox txtAddress1;
private Textbox txtAddress2; private Textbox txtAddress2;
private Textbox txtAddress3; private Textbox txtAddress3;
private Textbox txtAddress4; private Textbox txtAddress4;
private Textbox txtCity; private WAutoCompleterCity txtCity;
private Textbox txtPostal; private Textbox txtPostal;
private Textbox txtPostalAdd; private Textbox txtPostalAdd;
private Listbox lstRegion; private Listbox lstRegion;
private Listbox lstCountry; private Listbox lstCountry;
private Button btnOk; private Button btnOk;
private Button btnCancel; private Button btnCancel;
private Grid mainPanel; private Grid mainPanel;
private boolean m_change = false; private boolean m_change = false;
private MLocation m_location; private MLocation m_location;
private int m_origCountry_ID; private int m_origCountry_ID;
private int s_oldCountry_ID = 0; private int s_oldCountry_ID = 0;
public WLocationDialog(String title, MLocation location) private int m_WindowNo = 0;
{
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(); private boolean isCityMandatory = false;
init(); private boolean isRegionMandatory = false;
// Current Country private boolean isAddress1Mandatory = false;
MCountry.setDisplayLanguage(Env.getAD_Language(Env.getCtx())); private boolean isAddress2Mandatory = false;
for (MCountry country:MCountry.getCountries(Env.getCtx())) private boolean isAddress3Mandatory = false;
{ private boolean isAddress4Mandatory = false;
lstCountry.appendItem(country.getName(), country); private boolean isPostalMandatory = false;
} private boolean isPostalAddMandatory = false;
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(); private boolean inCountryAction;
initLocation(); private boolean inOKAction;
//
this.setWidth("290px");
this.setClosable(true);
this.setBorder("normal");
this.setAttribute("mode","modal");
}
private void initComponents() public WLocationDialog(String title, MLocation location)
{ {
lblAddress1 = new Label(Msg.getElement(Env.getCtx(), "Address1")); m_location = location;
lblAddress1.setStyle(LABEL_STYLE); if (m_location == null)
lblAddress2 = new Label(Msg.getElement(Env.getCtx(), "Address2")); m_location = new MLocation (Env.getCtx(), 0, null);
lblAddress2.setStyle(LABEL_STYLE); // Overwrite title
lblAddress3 = new Label(Msg.getElement(Env.getCtx(), "Address3")); if (m_location.getC_Location_ID() == 0)
lblAddress3.setStyle(LABEL_STYLE); setTitle(Msg.getMsg(Env.getCtx(), "LocationNew"));
lblAddress4 = new Label(Msg.getElement(Env.getCtx(), "Address4")); else
lblAddress4.setStyle(LABEL_STYLE); setTitle(Msg.getMsg(Env.getCtx(), "LocationUpdate"));
lblCity = new Label(Msg.getMsg(Env.getCtx(), "City")); //
lblCity.setStyle(LABEL_STYLE); // Reset TAB_INFO context
lblZip = new Label(Msg.getMsg(Env.getCtx(), "Postal")); Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "C_Region_ID", null);
lblZip.setStyle(LABEL_STYLE); Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "C_Country_ID", null);
lblRegion = new Label(Msg.getMsg(Env.getCtx(), "Region")); //
lblRegion.setStyle(LABEL_STYLE); initComponents();
lblPostal = new Label(Msg.getMsg(Env.getCtx(), "Postal")); init();
lblPostal.setStyle(LABEL_STYLE); // Current Country
lblPostalAdd = new Label(Msg.getMsg(Env.getCtx(), "PostalAdd")); MCountry.setDisplayLanguage(Env.getAD_Language(Env.getCtx()));
lblPostalAdd.setStyle(LABEL_STYLE); for (MCountry country:MCountry.getCountries(Env.getCtx()))
lblCountry = new Label(Msg.getMsg(Env.getCtx(), "Country")); {
lblCountry.setStyle(LABEL_STYLE); 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"));
}
txtAddress1 = new Textbox(); setRegion();
txtAddress1.setCols(20); initLocation();
txtAddress2 = new Textbox(); //
txtAddress2.setCols(20); this.setWidth("290px");
txtAddress3 = new Textbox(); this.setClosable(true);
txtAddress3.setCols(20); this.setBorder("normal");
txtAddress4 = new Textbox(); this.setAttribute("mode","modal");
txtAddress4.setCols(20); }
txtCity = new Textbox();
txtCity.setCols(20);
txtPostal = new Textbox();
txtPostal.setCols(20);
txtPostalAdd = new Textbox();
txtPostalAdd.setCols(20);
lstRegion = new Listbox(); private void initComponents()
lstRegion.setMold("select"); {
lstRegion.setWidth("154px"); lblAddress1 = new Label(Msg.getElement(Env.getCtx(), "Address1"));
lstRegion.setRows(0); 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);
lstCountry = new Listbox(); txtAddress1 = new Textbox();
lstCountry.setMold("select"); txtAddress1.setCols(20);
lstCountry.setWidth("154px"); txtAddress2 = new Textbox();
lstCountry.setRows(0); txtAddress2.setCols(20);
txtAddress3 = new Textbox();
txtAddress3.setCols(20);
txtAddress4 = new Textbox();
txtAddress4.setCols(20);
btnOk = new Button(); //autocomplete City
btnOk.setImage("/images/Ok16.png"); txtCity = new WAutoCompleterCity(m_WindowNo);
btnOk.addEventListener(Events.ON_CLICK,this); txtCity.setCols(20);
btnCancel = new Button(); txtCity.setAutodrop(true);
btnCancel.setImage("/images/Cancel16.png"); txtCity.setAutocomplete(true);
btnCancel.addEventListener(Events.ON_CLICK,this); txtCity.addEventListener(Events.ON_CHANGING, this);
//txtCity
mainPanel = GridFactory.newGridLayout(); txtPostal = new Textbox();
mainPanel.setStyle("padding:5px"); txtPostal.setCols(20);
} txtPostalAdd = new Textbox();
txtPostalAdd.setCols(20);
private void init() lstRegion = new Listbox();
{ lstRegion.setMold("select");
Row pnlAddress1 = new Row(); lstRegion.setWidth("154px");
pnlAddress1.appendChild(lblAddress1.rightAlign()); lstRegion.setRows(0);
pnlAddress1.appendChild(txtAddress1);
Row pnlAddress2 = new Row(); lstCountry = new Listbox();
pnlAddress2.appendChild(lblAddress2.rightAlign()); lstCountry.setMold("select");
pnlAddress2.appendChild(txtAddress2); lstCountry.setWidth("154px");
lstCountry.setRows(0);
Row pnlAddress3 = new Row(); btnOk = new Button();
pnlAddress3.appendChild(lblAddress3.rightAlign()); btnOk.setImage("/images/Ok16.png");
pnlAddress3.appendChild(txtAddress3); btnOk.addEventListener(Events.ON_CLICK,this);
btnCancel = new Button();
btnCancel.setImage("/images/Cancel16.png");
btnCancel.addEventListener(Events.ON_CLICK,this);
Row pnlAddress4 = new Row(); mainPanel = GridFactory.newGridLayout();
pnlAddress4.appendChild(lblAddress4.rightAlign()); mainPanel.setStyle("padding:5px");
pnlAddress4.appendChild(txtAddress4); }
Row pnlCity = new Row(); private void init()
pnlCity.appendChild(lblCity.rightAlign()); {
pnlCity.appendChild(txtCity); Row pnlAddress1 = new Row();
pnlAddress1.appendChild(lblAddress1.rightAlign());
pnlAddress1.appendChild(txtAddress1);
Row pnlPostal = new Row(); Row pnlAddress2 = new Row();
pnlPostal.appendChild(lblPostal.rightAlign()); pnlAddress2.appendChild(lblAddress2.rightAlign());
pnlPostal.appendChild(txtPostal); pnlAddress2.appendChild(txtAddress2);
Row pnlPostalAdd = new Row(); Row pnlAddress3 = new Row();
pnlPostalAdd.appendChild(lblPostalAdd.rightAlign()); pnlAddress3.appendChild(lblAddress3.rightAlign());
pnlPostalAdd.appendChild(txtPostalAdd); pnlAddress3.appendChild(txtAddress3);
Row pnlRegion = new Row(); Row pnlAddress4 = new Row();
pnlRegion.appendChild(lblRegion.rightAlign()); pnlAddress4.appendChild(lblAddress4.rightAlign());
pnlRegion.appendChild(lstRegion); pnlAddress4.appendChild(txtAddress4);
Row pnlCountry = new Row(); Row pnlCity = new Row();
pnlCountry.appendChild(lblCountry.rightAlign()); pnlCity.appendChild(lblCity.rightAlign());
pnlCountry.appendChild(lstCountry); pnlCity.appendChild(txtCity);
Panel pnlButton = new Panel(); Row pnlPostal = new Row();
pnlButton.appendChild(btnOk); pnlPostal.appendChild(lblPostal.rightAlign());
pnlButton.appendChild(btnCancel); pnlPostal.appendChild(txtPostal);
pnlButton.setWidth("100%");
pnlButton.setStyle("text-align:right");
this.appendChild(mainPanel); Row pnlPostalAdd = new Row();
this.appendChild(pnlButton); pnlPostalAdd.appendChild(lblPostalAdd.rightAlign());
} pnlPostalAdd.appendChild(txtPostalAdd);
/**
* 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() Row pnlRegion = new Row();
{ pnlRegion.appendChild(lblRegion.rightAlign());
if (mainPanel.getRows() != null) pnlRegion.appendChild(lstRegion);
mainPanel.getRows().getChildren().clear();
MCountry country = m_location.getCountry(); Row pnlCountry = new Row();
log.fine(country.getName() + ", Region=" + country.isHasRegion() + " " + country.getDisplaySequence() pnlCountry.appendChild(lblCountry.rightAlign());
+ ", C_Location_ID=" + m_location.getC_Location_ID()); pnlCountry.appendChild(lstCountry);
// 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 Panel pnlButton = new Panel();
if (m_location.getC_Location_ID() != 0) pnlButton.appendChild(btnOk);
{ pnlButton.appendChild(btnCancel);
txtAddress1.setText(m_location.getAddress1()); pnlButton.setWidth("100%");
txtAddress2.setText(m_location.getAddress2()); pnlButton.setStyle("text-align:right");
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(); this.appendChild(mainPanel);
} this.appendChild(pnlButton);
setCountry(); }
} /**
} * Dynamically add fields to the Location dialog box
private void setCountry() * @param panel panel to add
{ *
List listCountry = lstCountry.getChildren(); */
Iterator iter = listCountry.iterator(); private void addComponents(Row row)
while (iter.hasNext()) {
{ if (mainPanel.getRows() != null)
ListItem listitem = (ListItem)iter.next(); mainPanel.getRows().appendChild(row);
if (m_location.getCountry().equals(listitem.getValue())) else
{ mainPanel.newRows().appendChild(row);
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 private void initLocation()
{ {
if (btnOk.equals(event.getTarget())) if (mainPanel.getRows() != null)
{ mainPanel.getRows().getChildren().clear();
action_OK();
m_change = true;
this.detach();
}
else if (btnCancel.equals(event.getTarget()))
{
m_change = false;
this.detach();
}
// Country Changed - display in new Format MCountry country = m_location.getCountry();
else if (lstCountry.equals(event.getTarget())) log.fine(country.getName() + ", Region=" + country.isHasRegion() + " " + country.getCaptureSequence()
{ + ", C_Location_ID=" + m_location.getC_Location_ID());
MCountry c = (MCountry)lstCountry.getSelectedItem().getValue(); // new Country
m_location.setCountry(c); if (m_location.getC_Country_ID() != s_oldCountry_ID)
// refrseh {
initLocation(); lstRegion.getChildren().clear();
} if (country.isHasRegion()) {
} lstRegion.appendItem("", null);
/** for (MRegion region : MRegion.getRegions(Env.getCtx(), country.getC_Country_ID()))
* OK - check for changes (save them) & Exit {
*/ lstRegion.appendItem(region.getName(),region);
private void action_OK() }
{ if (m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName) != null
m_location.setAddress1(txtAddress1.getValue()); && m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName).trim().length() > 0)
m_location.setAddress2(txtAddress2.getValue()); lblRegion.setValue(m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName));
m_location.setAddress3(txtAddress3.getValue()); else
m_location.setAddress4(txtAddress4.getValue()); lblRegion.setValue(Msg.getMsg(Env.getCtx(), "Region"));
m_location.setCity(txtCity.getValue()); }
m_location.setPostal(txtPostal.getValue()); s_oldCountry_ID = m_location.getC_Country_ID();
// 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 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();
}
} }