<% /****************************************************************************** * 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.*,java.util.*,java.text.*,java.lang.reflect.*,com.edeal.frontline.navigation.*"%> <%@ page import="java.util.LinkedHashMap" %> <%@ page import="com.edeal.frontline.helper.custom.EventHelper" %> <%@ page import="com.edeal.frontline.helper.EventBaseHelper.StatusType" %> <%@ page import="com.edeal.frontline.helper.EventBaseHelper.EventCategory" %> <%@ page import="java.util.Iterator" %> <%@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(); // GET ACTOR NAME String actID = (String)session.getAttribute("actorID"); String actCompleteName = "........."; try { ObjectsBean objBean = dico.getTable("sql", "Actor"); actCompleteName = objBean.toString(session, actID); } catch (FrontlineException fe) { } //GET PARAMETERS String lsePositionStr = flRequest.getRequestParameterOrAttribute("lsePosition"); String perID = flRequest.getRequestParameterOrAttribute("perID"); String scriptID = flRequest.getRequestParameterOrAttribute("scriptID"); String preview = flRequest.getRequestParameterOrAttribute("preview"); if (preview == null) { preview = "0"; } int lsePosition = new Integer(lsePositionStr).intValue(); //GET OBJECTS FROM SESSION PersonBean person = (PersonBean)session.getAttribute("srpPerson"); ScriptBean script = (ScriptBean)session.getAttribute("srpScript"); Vector scriptElements = (Vector)session.getAttribute("srpScriptElements"); Vector scriptPages = (Vector)session.getAttribute("ScriptPages"); Vector scriptPagesID = (Vector)session.getAttribute("ScriptPagesID"); Vector linkScriptElements = (Vector)session.getAttribute("srpLinkScriptElements"); Hashtable objections = (Hashtable)session.getAttribute("Objections"); Hashtable responses = (Hashtable)session.getAttribute("ScriptResponses"); if (script == null || scriptElements == null || scriptElements.size() == 0 || !scriptID.equals(script.getScrID())) { throw new FrontlineException("scriptresponse edit_body info missing"); } // pour la replication de session en cluster if (person != null) { person.setSession(session); } if (script != null) { script.setSession(session); } for (int i = 0; i < scriptElements.size(); i++) { if (scriptElements.elementAt(i) != null) { ((ScriptElementBean)scriptElements.elementAt(i)).setSession(session); } } for (int i = 0; i < linkScriptElements.size(); i++) { if (linkScriptElements.elementAt(i) != null) { ((LinkScriptElementBean)linkScriptElements.elementAt(i)).setSession(session); } } // recuperation des éléments et des LinkScriptElement de la page String pageID = (String)scriptPagesID.elementAt(lsePosition); ScriptPageBean scp = (ScriptPageBean)scriptPages.elementAt(lsePosition); Vector pagesElements = new Vector(); Vector pagesLinkScriptElements = new Vector(); Vector displayedElementsID = new Vector(); for (int i = 0; i < linkScriptElements.size(); i ++) { LinkScriptElementBean currLse = (LinkScriptElementBean)linkScriptElements.elementAt(i); try { String lsePageID = currLse.getLsePageID(); String lseElementID = currLse.getLseScriptElementID(); if (pageID.equals(lsePageID)) { pagesLinkScriptElements.addElement(currLse); pagesElements.addElement((ScriptElementBean)scriptElements.elementAt(i)); } } catch (FieldNotInitializedException fnie) { } } //GET DISPLAY INFO String scriptLabel = "???"; String scriptNumber = "???"; String scriptEventID = script.getScrEventID(); String scrParStatusRule = null; try { scrParStatusRule = script.getScrParStatusRule(); } catch (FieldNotInitializedException e) { } String scrParStatus = null; try { scrParStatus = script.getScrParStatus(); } catch (FieldNotInitializedException e) { } scriptLabel = script.getScrLabel(); DecimalFormat df = FlLocale.getInstance(session).getDecimalFormat("0000"); scriptNumber = df.format((long) (script.getScrSeqNum())); String perCompleteName = (person == null) ? Utils.getMessage(session, "L620E", "") : person.toString(); //IF THIS IS THE LAST SCRIPT ELEMENT, WE'LL BE SHOWING THE EVENT STATUS CHOICES LinkedHashMap statusParIDAndDisplay = new LinkedHashMap(); boolean askForParStatus = false; if (lsePosition == scriptPages.size() - 1) { String[][] queryPvt = {{"PvtEventID = " + Utils.formatToSQL(context, scriptEventID) , "PvtPersonID = " + Utils.formatToSQL(context, perID)}}; String[] fieldsPvt = {"PvtID"}; Vector listPvt = PersonEventBean.listSummary(session, fieldsPvt, queryPvt); //On regarde si on doit poser la question de l'état pour l'evenement if (scrParStatusRule == null || "NONE".equals(dico.getRefCode("ScrParStatusRule" , scrParStatusRule)) ) { if (listPvt == null || listPvt.size() == 0) { askForParStatus = true; } } else if ( "MANU".equals(dico.getRefCode("ScrParStatusRule" , scrParStatusRule)) ) { askForParStatus = true; } if (askForParStatus) { statusParIDAndDisplay = EventHelper.getListStatusByEvent(context, StatusType.PARTICIPATION, scriptEventID); } } boolean hasNotes = "true".equals(flRequest.getRequestParameterOrAttribute("hasNotes")); %> <%= scriptLabel %>
"> <%-- DISPLAY NAVIGATION BAR --%>
    <% if (lsePosition != scriptPages.size() -1) { %> <% } else { %> <% } %>  
<%-- HEADER --%>
<% //IF THIS IS NOT A PREVIEW, SHOW A LINK TO THE PERSON if (perID != null) { %> <%= perCompleteName %> <% } else { %> <%= perCompleteName %> <% } %>
<%= scriptLabel %> (<%= scriptNumber %>)
<%-- END OF HEADER --%> <%-- Current element index --%> <%-- HIDDEN FORM FIELDS --%> <%-- Next element requested index --%> <% for (int eltIndex = 0; eltIndex < pagesElements.size(); eltIndex++) { ScriptElementBean scriptElement = (ScriptElementBean)pagesElements.elementAt(eltIndex); LinkScriptElementBean linkScriptElement = (LinkScriptElementBean)pagesLinkScriptElements.elementAt(eltIndex); Vector scriptElementResponses = (Vector)responses.get(linkScriptElement.getID()); if (scriptElementResponses == null) { scriptElementResponses = new Vector(); } else { for (int i = 0; i < scriptElementResponses.size(); i++) { if (scriptElementResponses.elementAt(i) != null) { ((ScriptElementResponseBean)scriptElementResponses.elementAt(i)).setSession(session); } } } if (scriptElement != null) { String qLabel = null; try { qLabel = scriptElement.getSceLabel(); } catch (FieldNotInitializedException fnie) { } String qDescription = null; try { qDescription = Utils.formatToWeb(scriptElement.getSceDescription(), false); } catch (FieldNotInitializedException fnie) { } // remplacement de $$actor$$ et $$person$$ if (qDescription != null) { qDescription = Utils.replace(qDescription, "$$person$$", perCompleteName); qDescription = Utils.replace(qDescription, "$$actor$$", actCompleteName); } /* String qComment = null; try { qComment = Utils.formatToWeb((String)scriptElement.getCustomProperty("SceComment_"), false); } catch (FieldNotInitializedException fnie) { } // remplacement de $$actor$$ et $$person$$ if (qComment != null) { qComment = Utils.replace(qComment, "$$person$$", perCompleteName); qComment = Utils.replace(qComment, "$$actor$$", actCompleteName); } */ //IMAGE String picID = null; try { picID = scriptElement.getSceImage(); } catch (FieldNotInitializedException ex) { } %> <%-- DISPLAY SCRIPT ELEMENT LABEL --%> <%-- DISPLAY SCRIPT ELEMENT IMAGE IF ANY --%> <% if (picID != null) { %> <% } %> <%-- DISPLAY SCRIPT ELEMENT DESCRIPTION --%> <%-- DISPLAY SCRIPT ELEMENT ANSWERS --%> <% if (scriptElement.getSceHasAnswers() == 1) { String qType = null; try { qType = scriptElement.getSceType(); } catch (FieldNotInitializedException fnie) { } //if text libre if ( qType == null || qType.equals(dico.getRefIdByCode("SceType" , "FRE")) ) { int inputSize = 0; try { inputSize = scriptElement.getSceInputSize(); } catch (FieldNotInitializedException fnie) { } String value = ""; if (scriptElementResponses.size() > 0) { try { value = ((ScriptElementResponseBean)scriptElementResponses.elementAt(0)).getSerText(); } catch (FieldNotInitializedException e) {} } if (inputSize == -1) { %> <%----%> <% } else { %> <%----%> <% } } else { //Pas Texte libre, c-a-d REF ou LST boolean isREF = false; boolean isLST = false; if ( qType.equals(dico.getRefIdByCode("SceType" , "REF")) ) { isREF = true; } if ( qType.equals(dico.getRefIdByCode("SceType" , "LST")) ) { isLST = true; } boolean isCombo = true; boolean isRadio = false; boolean isCheck = false; String dispType = null; try { dispType = scriptElement.getSceDispType(); } catch (FieldNotInitializedException fnie) { } if (dispType != null && dispType.equals(dico.getRefIdByCode("SceDispType", "RADIO"))) { isCombo = false; isRadio = true; } if (dispType != null && dispType.equals(dico.getRefIdByCode("SceDispType", "CHECK"))) { isCombo = false; isCheck = true; } int complementaryText = 0; try { complementaryText = scriptElement.getSceAssociatedText(); } catch (FieldNotInitializedException fnie) { } int nbColumn = 1; try { nbColumn = scriptElement.getSceColumnsNb(); } catch (FieldNotInitializedException fnie) { } int hasOther = 0; try { hasOther = scriptElement.getSceHasOther(); } catch (FieldNotInitializedException fnie) { } String refTableID = null; try { refTableID = scriptElement.getSceRefTable(); } catch (FieldNotInitializedException fnie) { } Vector possibleResponses = new Vector(); Vector recordedResponses = new Vector(); //in this vector we will store the responses from scriptElementResponses that we have Hashtable complementaryTexts = new Hashtable(); //in this hashtable we will store the complementary texts that we have if ( isLST ) { for (int j=0 ; j < 15 ; j++) { String lstAnswer = null; try { Method getter = Class.forName("com.edeal.frontline.ScriptElementBean").getMethod("getSceLstAnswer" + j , null); lstAnswer = (String) getter.invoke(scriptElement , null); } catch (Exception e) { } if (lstAnswer != null) { Vector oneResponse = new Vector(); oneResponse.add(Integer.toString(j)); oneResponse.add(lstAnswer); possibleResponses.add(oneResponse); } } for (int k = 0 ; k < scriptElementResponses.size() ; k++) { try { String choice = new Integer(((ScriptElementResponseBean)scriptElementResponses.elementAt(k)).getSerPosition()).toString(); recordedResponses.addElement(choice); complementaryTexts.put(choice, ((ScriptElementResponseBean)scriptElementResponses.elementAt(k)).getSerMoreText()); } catch (FieldNotInitializedException e) {} } } else { try { possibleResponses = dico.getRefList(session, refTableID , "Te1"); } catch (FrontlineException fe) { logger.error("DBG: dico.getRefList a lancé une exception : " + fe.getMessage()); } for (int k = 0 ; k < scriptElementResponses.size() ; k++) { try { String choice = ((ScriptElementResponseBean)scriptElementResponses.elementAt(k)).getSerRefValID(); recordedResponses.addElement(choice); complementaryTexts.put(choice, ((ScriptElementResponseBean)scriptElementResponses.elementAt(k)).getSerMoreText()); } catch (FieldNotInitializedException e) {} } } if (isCombo) { %> <%----%> <% } else { // pas combo , c-a-d checkbox ou radio String tagType = "checkbox"; if (isRadio) { tagType = "radio"; } %> <%----%> <%-- OBJECTIONS / ARGUMENTS --%> <% if (scriptElement != null && scriptElement.getID() != null) { Vector linksList = (Vector)objections.get(scriptElement.getID()); //if there are links to objections if (linksList != null && linksList.size() > 0) { %> <% }//end of if there are links to objections }//end of if there is a script element %><%-- END OF OBJECTIONS / ARGUMENTS --%><% }//end of if (texte libre) }//end of if (scriptElement.getSceHasAnswers() == 1) } } %>
 
<%= qLabel == null ? " " : qLabel %>
 
<fl:getMessage code=">
 
<%= qDescription == null ? " " : qDescription %>
">
<% if (complementaryText > 0) { String compText = null; if (responseChoice != null) { compText = (String)complementaryTexts.get(responseChoice); } %> " size="<%= Integer.toString(complementaryText) %>"> <% } %>
<% int nbResByColumn = possibleResponses.size() / nbColumn; if ( nbColumn * nbResByColumn < possibleResponses.size() ) nbResByColumn++; int cptPossibleResponse = 0; for (int j=0 ; j < possibleResponses.size() ; j++) { String responseChoice = (String) ((Vector) possibleResponses.elementAt(j)).elementAt(0); String responseLabel = (String) ((Vector) possibleResponses.elementAt(j)).elementAt(1); if (cptPossibleResponse % nbResByColumn == 0) { if (cptPossibleResponse > 0) { %> <% } %>
" value="<%= responseChoice %>"<%= recordedResponses.contains(responseChoice) ? " checked" : ""%> ><%= responseLabel %> <% } else { %>
" value="<%= responseChoice %>"<%= recordedResponses.contains(responseChoice) ? " checked" : ""%> ><%= responseLabel %> <% } if ( (complementaryText > 0) || (hasOther > 0 && j == possibleResponses.size() - 1) ) { String compText = (String)complementaryTexts.get(responseChoice); %> " size="<%= complementaryText > 0 ? Integer.toString(complementaryText) : Integer.toString(hasOther) %>"> <% } cptPossibleResponse++; } %>
<%}%>
 
<% //for each objection for (int i=0 ; i < linksList.size() ; i++) { Hashtable curLink = (Hashtable) linksList.elementAt(i); String curLsoObjectionID = (String) curLink.get("LsoObjectionID"); String obaObjection = (String) curLink.get("LsoObjectionID:ObaObjection"); %><%--<%= obaObjection %>
<% --%> <%= obaObjection %>
<% } %>
<%-- IF THIS IS THE LAST ELEMENT, WE MAY WANT TO SHOW THE EVENT STATUS SECTION --%> <% if (lsePosition == scriptElements.size() - 1) { %> <%-- EVENT STATUS SECTION --%> <% if (askForParStatus) { %> <% } %>
<% if (statusParIDAndDisplay != null && !statusParIDAndDisplay.isEmpty()) { Iterator iter = statusParIDAndDisplay.keySet().iterator(); while (iter.hasNext()) { String currStatusID = iter.next(); String currStatusDisplay = statusParIDAndDisplay.get(currStatusID); %> ><%= currStatusDisplay %> <% } } } else if ( scrParStatusRule != null && "AUTO".equals(dico.getRefCode("ScrParStatusRule" , scrParStatusRule)) ) { %>
">
<%-- END OF EVENT STATUS SECTION --%> <% } %>
<%-- PROGRESS BAR --%>
<%-- END OF PROGRESS BAR --%>

<% if (pagesElements == null || pagesElements.size() == 0) { %><% } %>

<%if (hasNotes){%>
<%}%>