<% /****************************************************************************** * Copyright (c) 2000-2004 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 session="true" import="com.edeal.frontline.*,com.edeal.frontline.custom.*,org.w3c.dom.Node,java.util.*"%> <%@ page import="com.edeal.frontline.SelectionManager.GroupNode" %> <%@ page import="com.edeal.frontline.navigation.FlRequest" %> <%@page import="org.apache.commons.lang.StringUtils"%> <%@ page import="com.edeal.frontline.SelectionManager.ObjectNode" %> <%@ page import="com.edeal.frontline.SelectionManager.SubGroupNode" %> <%@ page import="com.edeal.frontline.FieldNotInitializedException" %> <%@ page import="com.edeal.frontline.AccessDeniedException" %> <%@ page import="com.edeal.frontline.Selection2Bean" %> <%@ page import="com.edeal.frontline.ObjectsBean" %> <%@page import="com.edeal.frontline.display.TargettingFieldInterfaceManager"%> <%@page import="com.edeal.frontline.display.TargettingFieldInterface"%> <%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %> <% // JSA class used to keep label code and translation class DisplayObjectName { public String label; public String labelCode; DisplayObjectName(String labelCode,String label) { this.label=label; this.labelCode=labelCode; } } // GGH replace the vector of table to a vector of this object "DisplayField" class DisplayField implements Comparable { public String fldID; public String fldDisplay; DisplayField(String fldID,String fldDisplay) { this.fldID=fldID; this.fldDisplay=fldDisplay; } public int compareTo(Object o) { DisplayField displayField = (DisplayField) o; return this.fldDisplay.toUpperCase().compareTo(displayField.fldDisplay.toUpperCase()); } } //Recuperation du context 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 lngID = FlLocale.getInstance(session).getLanguageID(); TargettingFieldInterfaceManager tfim=TargettingFieldInterfaceManager.factory(context); //si la langue dans fllocal est null alors français pas defaut if(lngID == null) { try { lngID = dico.getRefIdByCode("Lng", "Val", "fr_FR"); } catch (Exception ex) { } } //Recuperation des paramétres //je recupere le groupe id (id du critére parent) String paramGrpID = Utils.getRequestParameter(context, request, "GrpID"); //j'instancie un criteria bean parent try { paramGrpID = Criteria2.getCr2ParentID(); }catch (FieldNotInitializedException e){ paramGrpID = Utils.getRequestParameter(context, request, "GrpID"); Criteria2.setCr2ParentID(paramGrpID); } Criteria2Bean criteriaParent = null; if (paramGrpID == null) { criteriaParent = new Criteria2Bean(context); } else { criteriaParent = new Criteria2Bean(paramGrpID,context); } String SubGroup = null; boolean isSub = false; try { SubGroup = criteriaParent.getCr2SubGroup(); isSub= SubGroup != null && !"null".equals(SubGroup); }catch (FieldNotInitializedException ex){} //je recupere l'id du ciblage que je suis entrain de créer et sulequel je veux editer ce critére String paramSe2ID = null; try { paramSe2ID = Criteria2.getCr2Se2ID(); }catch (FieldNotInitializedException e){} if (paramSe2ID == null) { paramSe2ID = Utils.getRequestParameter(context, request, "se2ID"); Criteria2.setCr2Se2ID(paramSe2ID); } Selection2Bean selection2Bean = null; boolean condition_type = false; try { selection2Bean = new Selection2Bean(paramSe2ID,session); }catch (AccessDeniedException e){} if (selection2Bean != null) { try { int cond = selection2Bean.getSe2Condition(); condition_type = cond == 1; }catch (FieldNotInitializedException e){} } //si je suis en edition alors je recupere l'id du critére String id = null; try { id = Criteria2.getCr2ID(); }catch (FieldNotInitializedException e){} //on uilise le shéma xml pour recuperer la liste des objets à faire Vector VectObject = new Vector(); Vector VectObjectShadow = new Vector(); Vector objects = new Vector(); //ici on parse le xml et on construit la liste des objets String Model = flRequest.getRequestParameterOrAttribute("Se2Model"); if (StringUtils.isEmpty(Model)) { try { Model = selection2Bean.getSe2Model(); } catch (FieldNotInitializedException ex) { logger.error("criteria2/edit.jsp no model set !!!!",ex); } catch (NullPointerException npe) { logger.error("criteria2/edit.jsp selection2bean is null",npe); } } SelectionManager Selman= new SelectionManager(context,Model); Selman.parse(); SelectionManager.GroupNode groupNode = Selman.getResultGroup(); if(isSub){ SelectionManager.SubGroupNode subGR = Selman.getSubGroupById(SubGroup); objects = subGR.getVectObjects(); } else { objects = groupNode.getVectObjects(); } Vector subgroup = Selman.getResultSubGroup(); String label = null; try { label = Criteria2.getCr2TempName(); } catch (FieldNotInitializedException fnie) { } if (objects != null && objects.size()>0){ for (int i=0; i0){ for (int i=0; i0 && "Condition".equals(cond.elementAt(0))){ pattern = true; } String criteriaFieldName=null; if(paramCFldID != null && !pattern && ! "".equals(paramCFldID) && !"null".equals(paramCFldID)) { fld = dico.getFieldByID(paramCFldID); criteriaFieldName=fld.getFldSql(); try { fldType = dico.getRefCode("FldFltID", fld.getFldFltID()); } catch (FieldNotInitializedException ex) {}; try { isControledByRef = (fld.getFldTabID() != null); } catch (FieldNotInitializedException ex) {}; try { isControledByFob = (fld.getFldFobID() != null); } catch (FieldNotInitializedException ex) {}; try { hasCustomUi = tfim.hasCustomInterface(fld.getFldSql()); } catch (Exception e) {} if("BIT".equals(fldType)) { ctlOpe = new String[]{"=", "<>"}; isBoolean = true; } else if("DATE".equals(fldType) || "TIME".equals(fldType) || "TIMESTAMP".equals(fldType)) { ctlOpe = new String[]{"=", "<>", "<", ">", "<=", ">=", "exist"}; isDate = true; } else if("FLOAT|DOUBLE".equals(fldType) || "REAL".equals(fldType)) { ctlOpe = new String[]{"=", "<>", "<", ">", "<=", ">=", "in", "exist"}; isDecimal = true; isNumeric = true; } else if("INTEGER".equals(fldType) || "BIGINT".equals(fldType) || "SMALLINT".equals(fldType) || "DECIMAL|NUMERIC".equals(fldType) || "TINYINT".equals(fldType)) { ctlOpe = new String[]{"=", "<>", "<", ">", "<=", ">=", "in", "exist"}; isInteger = true; isNumeric = true; } else if("CHAR|VARCHAR|LONGVARCHAR|CLOB".equals(fldType)) { ctlOpe = new String[]{"=", "<>", "like", "in", "begin", "exist","<", ">", "<=", ">="}; isText = true; } if(fld.isFldMultival()) { ctlOpe = new String[]{"=", "contains", "exist"}; isMultipleValues = true; } else if(isControledByRef || isControledByFob) { ctlOpe = new String[]{"=", "<>", "in", "exist"}; } } //si Cr2IsTemplate a été coché alors je dois vider les choix. boolean isTemplate = false; try{ isTemplate = Criteria2.isCr2IsTemplate(); if(isTemplate && condition_type) { //je dois vider les choix normal Criteria2.setCr2Chx(null); }else { Criteria2.setCr2TempNameLabel(null); } }catch (FieldNotInitializedException e){} if (paramCFldID != null && !"null".equals(paramCFldID)){ for(int i = 0; i < ctlOpe.length; i++) { try { String opeID = dico.getRefIdByCode("Cr2Ope", ctlOpe[i]); String opeDisp = (String)dico.getRefDisp(session, "Cr2Ope", opeID); String operation = ""; if (!"".equals(opeDisp)){ operation=opeDisp; } isMultipleValues = isMultipleValues || (opeID.equals(paramCOpe) && "in".equals(ctlOpe[i])); if(opeID.equals(paramCOpe)) { isOpeSelected = true; isValueNeeded = !"exist".equals(ctlOpe[i]); } } catch (Exception ex) { } } } String sfwID = flRequest.getParameter("SfwID"); %> E-DEAL CRM
" ignoreList="true" showFooter="false">
<%if (id != null) { %> <% } %> "> "> <% if(condition_type) { %> <% } %> <% ObjectsBean objetBean =null; if (paramObject != null) { try{ objetBean = dico.getTable("sql",paramObject); } catch (FrontlineException ex) { IsAgraggate = true; } if (objetBean != null){ %> <% } } %> <% if (paramCFldID != null && !"null".equals(paramCFldID)){ %> <% } if(paramCOpe != null && !isValueNeeded) { %> <% } else if(isOpeSelected && trou) { %> <% } else if (isOpeSelected && ! trou) { %> <% } %> <% if(condition_type) { %> <% } %> <% if (objetBean != null){ Vector vectFields = dico.getTableFields("sql", paramObject, true, false); // let's get the object field Vector Champs = new Vector(); for (int i = 0; i < vectFields.size(); i++) { FieldBean fldBean = (FieldBean) vectFields.elementAt(i); String fldID = null; try { fldID = fldBean.getID(); } catch (FieldNotInitializedException ex) {} String fldSQL = null; try { fldSQL = fldBean.getFldSql(); } catch (FieldNotInitializedException ex) {} boolean horsCible = false; try { horsCible = fldBean.isFldCriteria(); } catch (FieldNotInitializedException ex) {} if (!horsCible) { String fldDisplay = null; try { fldDisplay = fldBean.getFldDisplay(); } catch (FieldNotInitializedException ex) { fldDisplay = ""; } try { fldDisplay = Utils.getMessage(session, fldBean .getFldDisplayLabel(), false, true, fldDisplay); } catch (FieldNotInitializedException fnie) { } if ("".equals(fldDisplay)){ fldDisplay = fldSQL; } //String[] Fields = {fldID,fldDisplay}; //Champs.addElement(Fields); Champs.addElement(new DisplayField(fldID, fldDisplay)); } } // sort the fields java.util.Collections.sort(Champs); // and then add the eventual "question types" //String[] FieldsStat = {"","------------------------"}; // liste des conditions types Vector questionsToAdd=new Vector(); if(!condition_type) { //Champs.addElement(FieldsStat); //questionsToAdd.addElement(new DisplayField("", "------------------------")); String[] fieldS = {"Se2ID", "Se2Name"}; String[][] queryS = {{"Se2Condition = 1", "Se2Model:SmdObjID = "+Utils.formatToSQL(context, paramObjectID)}}; logger.debug("Query: " + paramObjectID); Vector list = Selection2Bean.listSummary(session, fieldS, queryS); logger.debug("Query: " + list); if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { Hashtable row = (Hashtable) list.elementAt(i); String conditionID = (String) row.get("Se2ID"); String conditionName = (String) row.get("Se2Name"); //String[] Fields= {"Condition|"+conditionID,conditionName}; //Champs.addElement(Fields); questionsToAdd.addElement(new DisplayField("Condition|"+conditionID, conditionName)); } } if (!questionsToAdd.isEmpty()) { // sort them java.util.Collections.sort(questionsToAdd); Champs.addElement(new DisplayField("", "------------------------")); Champs.addAll(questionsToAdd); } } %> <% } %> <% if (paramCFldID != null && !"null".equals(paramCFldID)){ %> <% //on construit les inputs pour saisir les différentes valeurs. } if(paramCOpe != null && !isValueNeeded) { %> <% if(freeValue && isValueNeeded){ String cr2FldId = Criteria2.getCr2FldID(); String cr2FobId = Criteria2.getCr2FobID(); // If Actor fob field if(cr2FobId != null && !"".equals(cr2FobId)){ ObjectsBean objectsBean = new ObjectsBean(cr2FobId, session); if(objectsBean != null && "Actor".equals(objectsBean.getObjSql())){ if(Criteria2.getCr2Chx() != null){ Vector cr2ChxVector = Criteria2.getCr2Chx(); cr2ChxVector.clear(); Criteria2.getCr2Chx().add("$$ActID$$"); } else { Vector cr2ChxVector = new Vector(); cr2ChxVector.clear(); cr2ChxVector.add("$$ActID$$"); Criteria2.setCr2Chx(cr2ChxVector); } } } else if(cr2FldId != null){ FieldBean fldBean = new FieldBean(cr2FldId, session); // If a date type field if(fldBean != null && fldBean.isDate()){ if(Criteria2.getCr2Chx() != null){ Vector cr2ChxVector = Criteria2.getCr2Chx(); cr2ChxVector.clear(); Criteria2.getCr2Chx().add("$$CurrentDate$$"); } else { Vector cr2ChxVector = new Vector(); cr2ChxVector.clear(); cr2ChxVector.add("$$CurrentDate$$"); Criteria2.setCr2Chx(cr2ChxVector); } } } %> <% } else { %><%=Utils.formatToWeb((String)vectChx.firstElement(), true)%><%}%>" size="40" style="width: 100%"> <%} else { %> <%} %> <% } else if(isOpeSelected && trou) { %> <% } else if (isOpeSelected && ! trou){ %> <% } %>
  <% if(isControledByFob) { ObjectsBean ctlFob = dico.getTable("id", fld.getFldFobID()); if(isMultipleValues && ! freeValue) { %>
<fl:getMessage code="> <fl:getMessage code="> <%}}%>
onclick="doRefreshTemp();" onchange="doRefreshTemp()"> <% String paramCNot = null; try { paramCNot = Criteria2.isCr2Not() ? "1" : null; } catch (FieldNotInitializedException ex) { paramCNot = null; } %> > onclick="doRefreshFreeValue();" onchange="doRefreshFreeValue()">
")) %>" size="50" onFocus="this.blur();" style="width: 100%">
<% String htmlInput=null; if (hasCustomUi) { try { htmlInput=tfim.getHtmlForCriteriaEdit(session,flRequest,criteriaFieldName,selection2Bean,Criteria2); } catch (FrontlineException e) { logger.error("Exception in criteria edit:"+e.getMessage()); } } if (htmlInput!=null) { %> <%= htmlInput %> <% } else if(isControledByFob) { ObjectsBean ctlFob = dico.getTable("id", fld.getFldFobID()); %> <% if(freeValue){%> <% if(ctlFob != null && "Actor".equals(ctlFob.getObjSql())){ if(vectChx.isEmpty()){ Vector cr2ChxVec = new Vector(); cr2ChxVec.add("$$ActID$$"); Criteria2.setCr2Chx(cr2ChxVec); } } else { if(!vectChx.isEmpty() && "$$ActID$$".equals(vectChx.firstElement())){ vectChx.remove(0); } } %> <% } else { %><%=Utils.formatToWeb((String)vectChx.firstElement(), true)%><%}%>" size="40" style="width: 100%"> <% } else if(isMultipleValues) { %> <% } else { %> <% } %>
">
"> " style="width: 100%" readonly onfocus="this.blur();"> <fl:getMessage code="> <fl:getMessage code=">
<% } else if(isControledByRef) { if(freeValue){%> <% } else { %><%=Utils.formatToWeb((String)vectChx.firstElement(), true)%><%}%>" size="40" style="width: 100%"> <% } else { Vector vectRef = dico.getRefList(session, fld.getFldSql()); %> <% } } else if(isDate) { if(freeValue){ try{ Vector cr2ChxVector = Criteria2.getCr2Chx(); cr2ChxVector.clear(); cr2ChxVector.add("$$CurrentDate$$"); } catch (FieldNotInitializedException e){ Vector cr2ChxVector = new Vector(); cr2ChxVector.clear(); cr2ChxVector.add("$$CurrentDate$$"); Criteria2.setCr2Chx(cr2ChxVector); } %> <% } else { %><%=Utils.formatToWeb((String)vectChx.firstElement(), true)%><%}%>" size="40" style="width: 100%"> <% } else { String strDate = ""; String strTime = ""; String vectChxValue = null; if(!vectChx.isEmpty()){ vectChxValue = (String)vectChx.firstElement(); } java.util.Date date = null; if(vectChxValue != null && !"$$CurrentDate$$".equals(vectChxValue)){ date = Utils.formatDateFromWeb(session, vectChxValue); } strDate = Utils.formatToWebDate(session, date, true); String time = Utils.formatToWebTime(session, date, true); if(time != null && time.length()>5){ strTime = time.substring(0, 5); } %> ');"> ';return true;" onMouseOut="window.status=' '; return true"> ');"> <% } } else if(isNumeric || isText) { %> <% } else { %><%=Utils.formatToWeb((String)vectChx.firstElement(), true)%><%}%>" size="40" style="width: 100%"<% if(isNumeric && !isMultipleValues) { %> onBlur="ctrlNumField(this, '<%= isDecimal ? "float" : "integer" %>', '');"<% } %>> <% if(isMultipleValues) { %>
<% } } else if(isBoolean) { %> <% } %>

<% if(paramCOpe != null) { %>     <% } %>