<% /****************************************************************************** * Copyright (c) 2000-2006 e-Deal * * e-Deal S.A. * 55 rue Brillat Savarin * 75013 Paris * France * * T: +33 (0)1 53 80 80 30 * F: +33 (0)1 73 01 69 77 * http://www.e-deal.com * * La diffusion de ce code source sous quelque forme que ce soit sans * l'autorisation de E-DEAL est interdite. * * Vous êtes autorisés à modifier ce code source uniquement pour votre usage * propre et sous réserve que les mentions de copyright demeurent intactes. * * Ce code est fourni en l'état. Aucune garantie d'aucune sorte, explicite ou * implicite n'est donnée. En aucun cas E-DEAL ne pourra être tenu pour * responsable des dommages pouvant résulter de l'utilisation de ce code * source. ******************************************************************************/ %><%@ page language="java" contentType="text/plain;charset=UTF-8"%><%@ page import="com.edeal.frontline.navigation.FlRequest" %><%@ page import="com.edeal.frontline.FlContext" %><%@ page import="java.util.Vector" %><%@ page import="java.lang.reflect.Method" %><%@ page import="com.edeal.frontline.FieldNotInitializedException" %><%@ page import="com.edeal.frontline.EventBean" %><%@ page import="com.edeal.frontline.Utils" %><%@ page import="com.edeal.frontline.LocationBean" %><%@ page import="com.edeal.frontline.FrontlineException" %><%@ page import="java.util.Hashtable" %><%@ page import="com.edeal.frontline.EnterpriseBean" %><%@ page import="com.edeal.frontline.DataDictionary" %><%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %><% final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(getClass()); FlRequest flRequest = new FlRequest(request); FlContext context = flRequest.getContext(); DataDictionary dico = context.getDataDictionary(); String PerLocID = flRequest.getParameter("PerLocID"); if (PerLocID == null) logger.error("ent_change_ajax.jsp : String PerLocID is null."); //logger.warn("ent_change_ajax.jsp : String PerLocID equals : " + PerLocID); String newEntID = flRequest.getParameter("newEntID"); if (newEntID == null) { newEntID = ""; } EnterpriseBean ent = new EnterpriseBean(newEntID, context); StringBuffer buf = new StringBuffer(); StringBuffer locAddr = null; String[] fields = { "LocID", "LocName", "LocAd1", "LocAd2", "LocAd3", "LocCity", "LocZip", "LocCtrID:Val", "LocAddressType:Val" }; String[][] query = { { "LocEntID = " + Utils.formatToSQL(context, newEntID) } }; Vector locs; try { locs = LocationBean.listSummary(context, fields, query); } catch (FrontlineException e) { locs = new Vector(); } if ("".equals(newEntID)) { buf.append("document.getElementById('PerLocFieldSet').style.display='none';"); buf.append("document.getElementById('PerLocTable').style.visibility='hidden';"); buf.append("var f = document.forms[0];"); //logger.warn("ent_change_ajax.jsp writes f_PerLocID_selectedIndex = 0;"); //buf.append("alert('f.PerLocID.selectedIndex = 0' will be inserted in buffer.);"); buf.append("if (f.PerLocID) { \n"); buf.append("f.PerLocID.selectedIndex = 0;"); buf.append("} \n"); } else { buf.append("document.getElementById('PerLocFieldSet').style.display='';"); buf.append("var f = document.forms[0];"); //logger.warn("ent_change_ajax.jsp writes f.PerLocID.options.length = 0;"); buf.append("if (f.PerLocID) { \n"); buf.append("f.PerLocID.options.length = 0;"); //logger.warn("ent_change_ajax.jsp writes f.PerLocID.options[0] = new Option...;"); if(locs.size() > 0){ buf.append("document.getElementById('PerLocDiv1').style.display='';"); buf.append("f.PerLocID.options[0] = new Option('" + Utils.getMessage(session, "L6490", true, "-Adresse principale-") + "', '');"); } else { buf.append("document.getElementById('PerLocDiv1').style.display='none';"); } buf.append("} \n"); Hashtable row; int selected = 0; for (int cnt = 0; cnt < locs.size(); ++cnt) { row = (Hashtable)locs.elementAt(cnt); String LocID = (String)row.get("LocID"); // If this Location is the same as the user's, save off the address info if (LocID.equalsIgnoreCase(PerLocID)) { selected = (cnt + 1); locAddr = new StringBuffer(); String tmpAdr = (String)row.get("LocAd1"); if (!Utils.isNullEmptyString(tmpAdr)) { locAddr.append(tmpAdr + "
"); } tmpAdr = (String)row.get("LocAd2"); if (!Utils.isNullEmptyString(tmpAdr)) { locAddr.append(tmpAdr + "
"); } tmpAdr = (String)row.get("LocAd3"); if (!Utils.isNullEmptyString(tmpAdr)) { locAddr.append(tmpAdr + "
"); } boolean haveIt = false; tmpAdr = (String)row.get("LocZip"); if (!Utils.isNullEmptyString(tmpAdr)) { locAddr.append(tmpAdr + " "); haveIt = true; } tmpAdr = (String)row.get("LocCity"); if (!Utils.isNullEmptyString(tmpAdr)) { locAddr.append(tmpAdr); haveIt = true; } if (haveIt) { locAddr.append("
"); } tmpAdr = (String)row.get("LocCtrID:Val"); if (!Utils.isNullEmptyString(tmpAdr)) { locAddr.append(tmpAdr); haveIt = true; } } buf.append("f.PerLocID.options[" + (cnt + 1)); buf.append("] = new Option('" + Utils.formatToJavascript((String)row.get("LocName")) + " (" + Utils.formatToJavascript((String)row.get("LocAddressType:Val")) + ")','" + LocID + "'); "); } buf.append("if (f.PerLocID) { \n"); buf.append("f.PerLocID.selectedIndex=" + selected + ";"); buf.append("} \n"); buf.append("document.getElementById('PerLocTable').style.visibility='visible';"); buf.append("document.getElementById('PerLocTable').style.display='table';"); } buf.append("var addr=document.getElementById(\"PerEnt.Address_value\");"); buf.append("addr.innerHTML=\""); if (locAddr != null) { buf.append(Utils.formatToJavascript(locAddr.toString())); } else { try { buf.append(ent.getEntAd1() + "
"); } catch (FrontlineException e) { } try { buf.append(ent.getEntAd2() + "
"); } catch (FrontlineException e) { } try { buf.append(ent.getEntAd3() + "
"); } catch (FrontlineException e) { } boolean haveIt = false; try { buf.append(ent.getEntZip() + " "); haveIt = true; } catch (FrontlineException e) { } try { buf.append(ent.getEntCity()); haveIt = true; } catch (FrontlineException e) { } if (haveIt) { buf.append("
"); } try { buf.append(dico.getRefDisp(session, "EntCtrID", ent.getEntCtrID())); } catch (FrontlineException e) { } } //logger.info(buf.toString()); buf.append("\";"); %><%= buf.toString() %>