Edit C:\Users\Administrator\Desktop\Back\galaxie - Copy\siteweb\webform\webform-optimisation.jsp
<% /****************************************************************************** * Copyright (c) 2000-2009 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.util.Map.Entry,java.text.*,java.lang.reflect.*,com.edeal.frontline.navigation.*,com.edeal.frontline.helper.custom.*"%> <%@page session="true" import="com.edeal.frontline.Utils"%> <%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %> <%@ page import="com.edeal.frontline.helper.custom.FormHelper" %> <%@ page import="com.edeal.frontline.controller.actions.custom.LoadWebFormPvtAction" %> <jsp:useBean class="com.edeal.frontline.FormBean" id="Form" scope="request"/> <jsp:useBean class="com.edeal.frontline.PersonBean" id="Person" scope="request"/> <jsp:useBean class="com.edeal.frontline.FormResponseBean" id="FormResponse" scope="request"/> <% 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 languageID = dico.getRefIdByCode("Lna", "Te1", "fr_FR"); // String lngCode = dico.getRefCode("EntRefLngID_", languageID); // String countryID = dico.getRefIdByCode("Ctr", "Te1", "FR"); // FlLocale locale = FlLocale.getInstance(context, languageID, countryID); // String utk = flRequest.getRequestParameterOrAttribute("utk"); // if(utk != null) flRequest.setAttribute("utk", utk); // String eventCode = flRequest.getRequestParameterOrAttribute("event"); // if(eventCode != null) flRequest.setAttribute("event", eventCode); String utk = flRequest.getRequestParameterOrAttribute("utk"); if(utk != null) flRequest.setAttribute("utk", utk); String eventCode = flRequest.getRequestParameterOrAttribute("event"); if(eventCode != null) flRequest.setAttribute("event", eventCode); //////////////////////////////////// Bring the enterprise from an utk holder String entID = ""; String sqlQuery = "select PerEntID from Person where PerToken = " + Utils.formatToSQL(context, utk) + " AND PerID like '%"+utk+"%' "; java.sql.Connection con = null; java.sql.Statement stmt = null; java.sql.ResultSet rs = null; try { con = context.getConnection(); stmt = con.createStatement(); rs = stmt.executeQuery(sqlQuery); while (rs.next()) { entID = rs.getString("PerEntID"); } }catch(java.sql.SQLException e){ } finally { try { rs.close(); } catch (Exception e) { } try { stmt.close(); } catch (Exception e) { } try { con.close(); } catch (Exception e) { } } ///////////////////////////////////// String lngId = ""; try{ lngId = (new EnterpriseBean(entID, context)).getCustomProperty("EntRefLngID_").toString(); }catch(Exception e){ lngId = dico.getRefIdByCode("Lna", "Te1", "fr_FR"); } String ctrId = ""; try{ ctrId = (new EnterpriseBean(entID, context)).getEntCtrID(); }catch(Exception e){ ctrId = dico.getRefIdByCode("Ctr", "Te1", "FR"); } String languageID = lngId;//dico.getRefIdByCode("Lna", "Te1", "fr_FR"); String lngCode = dico.getRefCode("EntRefLngID_", languageID); String countryID = ctrId;//dico.getRefIdByCode("Ctr", "Te1", "FR"); FlLocale locale = FlLocale.getInstance(context, languageID, countryID); String init = flRequest.getRequestParameterOrAttribute("init"); String actID = (String)request.getSession().getAttribute("actorID"); String actcode = null; if(actID != null){ ActorBean actor = new ActorBean(actID, context); actcode = actor.getActCode(); } //http://u-project2.umanis.com/view.php?id=39749 : Export guide / localités et Millésime /* Date expireDt = null; String sExpireDt = ""; */ String millesime = ""; try{ /* expireDt = Form.getFrmAvailableToDt(); SimpleDateFormat sfd = new SimpleDateFormat("dd/MM/yyyy"); sExpireDt = sfd.format(expireDt); Calendar cal = Calendar.getInstance(); cal.setTime(expireDt); int year = cal.get(Calendar.YEAR); millesime = String.valueOf(year); */ millesime = String.valueOf((Integer)Form.getCustomProperty("FrmMillesime_")); }catch(Exception e){ logger.error(" The field 'FrmMillesime_' not initialized to get 'Millesime' :" + e.getMessage()); try { millesime = context.getContextParameter("Millesime"); } catch (Exception e2) { logger.error("Option 'Millesime' not found :" + e2.getMessage()); } } String enterprise = ""; String perEntID = null; try{ perEntID = Person.getPerEntID(); enterprise = new EnterpriseBean(perEntID,context).toString(); }catch(FrontlineException fe){} Boolean askForStatus = (Boolean)flRequest.getAttribute(LoadWebFormPvtAction._REQ_ATTRIB_ASKUSEREVTSTATUS); String pvtStatus = ""; try { pvtStatus = ((Integer)flRequest.getAttribute(LoadWebFormPvtAction._REQ_ATTRIB_PVTSTATUS)).toString(); } catch (Exception e) {} int iPvtStatus=Integer.MIN_VALUE; try { iPvtStatus=Integer.parseInt(pvtStatus); } catch (Exception e) {} Vector eventStatusList=(Vector)flRequest.getAttribute(LoadWebFormPvtAction._REQ_ATTRIB_EVTSTATUSLIST); String webIntro = ""; String webHeader = ""; //String webConclusion = ""; String webFooter = ""; String webTermsOfUse = ""; try { webIntro = FormHelper.makeHtmlCrLf(Form.getFrmWebIntro()); } catch (Exception e) {} try { webHeader = FormHelper.makeHtmlCrLf(Form.getFrmWebHeader()); } catch (Exception e) {} // try { webConclusion = Form.getFrmWebConclusion(); } catch (Exception e) {} try { webFooter = FormHelper.makeHtmlCrLf(Form.getFrmWebFooter()); } catch (Exception e) {} try { webTermsOfUse =FormHelper.makeHtmlCrLf(Form.getFrmWebTermsOfUse()); } catch (Exception e) {} // get the question and response LinkedHashMap<String,Vector<String>> mapQuestionResponse=(LinkedHashMap<String,Vector<String>>)flRequest.getAttribute(LoadWebFormPvtAction._REQ_ATTRIB_QUESTIONRESPONSEMAP); LinkedHashMap<String,Vector<String>> mapInitialQuestionResponse=(LinkedHashMap<String,Vector<String>>)flRequest.getAttribute(LoadWebFormPvtAction._REQ_ATTRIB_INIT_QUESTIONRESPONSEMAP); boolean fDoDisplayIntro=false; try { fDoDisplayIntro=(Boolean)flRequest.getAttribute(LoadWebFormPvtAction._REQ_ATTRIB_DISPLAYINTRO); } catch (Exception e) {} // get the link for navigation boolean hasNextQuestions=false; boolean hasPreviousQuestions=false; boolean canValidate= false; boolean canIntegrate = false; boolean isFormPaginated=false; int positionFirstQuestion=-1; int positionLastQuestion=-1; %> <html> <head> <script language="javascript"> function _tempSave(endPos) { var f = document.forms[0]; f.action = '<fl:webapp/>/save_partial_web_form.fl?fromToSave=0&toToSave=' + endPos; f.submit(); } function _save() { var f = document.forms[0]; f.action = '<fl:webapp/>/save_web_form.fl'; f.submit(); } function doSubmit(navigation) { f=document.forms[0]; if (navigation) { f.action+= '&' + navigation; } $("*[disabled]").removeAttr("disabled"); f.submit(); } </script> <script type="text/javascript"> <!-- function isDate(txtDate) { var currVal = txtDate; if(currVal == '') return false; var rxDatePattern = /^(\d{1,2})(\/)(\d{1,2})(\/)(\d{4})$/; //Declare Regex var dtArray = currVal.match(rxDatePattern); // is format OK? if (dtArray == null) return false; //Checks for dd/mm/yyyy format. dtMonth = dtArray[3]; dtDay= dtArray[1]; dtYear = dtArray[5]; if (dtMonth < 1 || dtMonth > 12) return false; else if (dtDay < 1 || dtDay> 31) return false; else if ((dtMonth==4 || dtMonth==6 || dtMonth==9 || dtMonth==11) && dtDay ==31) return false; else if (dtMonth == 2) { var isleap = (dtYear % 4 == 0 && (dtYear % 100 != 0 || dtYear % 400 == 0)); if (dtDay> 29 || (dtDay ==29 && !isleap)) return false; } return true; } function getDatefromString(str1){ // str1 format should be dd/mm/yyyy. Separator can be anything e.g. / or -. It wont effect var from = str1.split("/"); var date1 = new Date(from[2], from[1] - 1, from[0]); return date1; } function trim1(str) { return str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); } function isItValid(type,element){ if(type == 'java.lang.Double|java.lang.Double' || type == 'java.lang.Double'){ element.value = trim1(element.value); var element1 = document.getElementsByName(element.name)[0]; var element2 = document.getElementsByName(element.name)[1]; if(/^\+?([0-9]\d*)\.?(([0-9]\d*)*)$/.test(trim1(element1.value)) && !(type == 'java.lang.Double') && !trim1(element2.value)) return true; if(!trim1(element1.value) && (type == 'java.lang.Double')) return true; if(!(/^\+?([0-9]\d*)\.?(([0-9]\d*)*)$/.test(element.value))){ alert('<%=Utils.getMessage(context, lngCode, "LF37F", true,true, "please insert a valid price !")%>'); element.value = ''; element.focus(); return false; }else{ element.value = Number(element.value).toFixed(2); } }else if(type == 'java.util.Date|java.util.Date' || type == 'java.util.Date'){ element.value = trim1(element.value); if(!isDate(element.value+'/<%=millesime%>')){ alert('<%=Utils.getMessage(context, lngCode, "LF380", true,true, "please insert a valid Date dd/mm !")%>'); element.value = ''; element.focus(); return false; } }else if(type == 'java.lang.Integer'){ element.value = trim1(element.value); if(!(/^\+?(0|[1-9]\d*)$/.test(element.value))){ alert('<%=Utils.getMessage(context, lngCode, "LF381", true,true, "please insert a valid Integer !")%>'); element.value = ''; element.focus(); return false; } } return true; } function isIntervalValid(type,element){ if(type == 'java.lang.Double|java.lang.Double'){ var price1 = parseFloat(document.getElementsByName(element.name)[0].value); var price2 = parseFloat(document.getElementsByName(element.name)[1].value); price1 = (Math.round(price1*100)/100); price2 = (Math.round(price2*100)/100); if (price1>price2){ alert('<%=Utils.getMessage(context, lngCode, "LF382", true,true, "the second price should be bigger than the first one !")%>'); document.getElementsByName(element.name)[1].value = ''; document.getElementsByName(element.name)[1].focus(); return false; } }else if(type == 'java.util.Date|java.util.Date'){ var date1 = document.getElementsByName(element.name)[0].value; var date2 = document.getElementsByName(element.name)[1].value; date1 = getDatefromString(date1+'/<%=millesime%>'); date2 = getDatefromString(date2+'/<%=millesime%>'); if( date1 > date2){ alert('<%=Utils.getMessage(context, lngCode, "LF383", true,true, "End date should be greater than Start date !")%>'); document.getElementsByName(element.name)[1].value = ''; document.getElementsByName(element.name)[1].focus(); return false; } } return true; } function areTheyValid(type,element){ var element1 = document.getElementsByName(element.name)[0]; var element2 = document.getElementsByName(element.name)[1]; element1.value = trim1(element1.value); element2.value = trim1(element2.value); if(!element1.value && !element2.value) return true; if(isItValid(type,element1)) if(!element2.value){ if(type == 'java.util.Date|java.util.Date'){ element2.focus(); } }else{ if(isItValid(type,element2)) return isIntervalValid(type,element); } return false; } function clearDates(elementName){ document.getElementsByName(elementName)[0].value = ''; document.getElementsByName(elementName)[1].value = ''; } //--> </script> <link href="<fl:webapp/>/siteweb/webform/webform.css" type="text/css" rel="stylesheet"> <link media="print" href="<fl:webapp/>/siteweb/webform/webform_print.css" type="text/css" rel="stylesheet"> <title>Réponse au questionnaire</title> </head> <body onload=""> <div id="webform" class="webform"> <fl:form action="/save_web_form.fl" bean="Form"> <input type="hidden" name="FormID" value="<fl:getProperty name="Form" alt="" property="FrmID"/>"> <input type="hidden" name="PerID" value="<fl:getProperty name="Person" alt="" property="PerID"/>"> <input type="hidden" name="EventID" value="<fl:getProperty name="Form" alt="" property="FrmEventID"/>"> <input type="hidden" name="savemode" value="<%= (isFormPaginated?"partial":"full") %>"/> <p style="font-weight: bold;text-align: right;color: #333333;font: 12px "Lucida Grande", Helvetica, Sans-Serif;"> <br/> <%= Utils.getMessage(context, lngCode, "LF1DC", true,true,"N° Affilié") + " : " + Contrat_Helper.getAffiliateNumber(context, perEntID)%> </p> <div id="logo"><img id="logo_img" src="<fl:webapp/>/icons/logis.jpg" alt=""/></div> <div id="webform_title" class="webform_title"> <div id="div_web_form_title" ><%=Utils.getMessage(context, lngCode, "LF22E", true,true,"FEDERATION INTERNATIONALE DES LOGIS")%></div> <div id="div_web_form_title_subO" ><fl:getProperty name="Form" property="FrmLabel" alt=""/></div> </div> <br/> <br/> <% if (fDoDisplayIntro) { %> <div id="webform_intro" class="webform_container"> <%= webIntro %> </div> <% if (askForStatus) { %> <div id="webform_status" class="webform_container"> <ul class="webform_list"> <% if (eventStatusList != null && eventStatusList.size() > 0) { for (int i=0 ; i < eventStatusList.size() ; i++) { // evtCurrentStatus int statusPos = Integer.parseInt((String) ((Vector) eventStatusList.elementAt(i)).elementAt(0)); String statusLabel = (String) ((Vector) eventStatusList.elementAt(i)).elementAt(1); %> <li id="webform_status<%= Integer.toString(statusPos) %>" class="webform_status"> <label class="webform_answer"> <input type="radio" name="EventStatus" value="<%= Integer.toString(statusPos) %>" <%= (statusPos == iPvtStatus)? "checked" : "" %> ><%= statusLabel %> </label> </li> <% } } %> </ul> </div> <% } else { //if ( formEveStChMode != null && "AUTO".equals(dico.getRefCode("FrmEveStChMode" , formEveStChMode)) ) { %> <input type="hidden" name="EventStatus" value="<%= pvtStatus %>"> <% } boolean fHasBasicQuestion=false; try { fHasBasicQuestion=(Form.getFrmBasicQuestion0()!=null); } catch (Exception e) {} if (fHasBasicQuestion) { %> <div id="webform_basicquestions" class="webform_container"> <ul class="webform_list"> <% if (Form != null) { for (int i=0 ; i < 3 ; i++) { String basicQuestion = null; try { basicQuestion = (String) Form.getProperty("FrmBasicQuestion" + Integer.toString(i)); } catch (Exception e) { logger.debug("Error printing basic question number " + Integer.toString(i), e); } boolean bresponse = false; try { if (i == 0) bresponse = FormResponse.isFrpBasicResponse0(); if (i == 1) bresponse = FormResponse.isFrpBasicResponse1(); if (i == 2) bresponse = FormResponse.isFrpBasicResponse2(); } catch (Exception e) {} if (basicQuestion != null) { %> <li id="webform_basicquestion<%= Integer.toString(i) %>" class="webform_basicquestion"> <label class="webform_answer"> <input type="checkbox" name="BasicResponse<%= Integer.toString(i) %>" value="1" <%= bresponse ? "checked" : "" %>><%= basicQuestion %> </label> </li> <% } } } %> </ul> </div> <% } // if (fHasBasicQuestion) %> <% } // Display Intro %> <% if (mapQuestionResponse!=null && mapQuestionResponse.size()>0) { %> <div id="div_web_form_header"><%= webHeader %></div> <div id="div_web_form_header_sub"> <p class="p_web_form_header"> <%= Person.toString()%></p> <p class="p_web_form_header"> <%= Utils.getMessage(context, lngCode, "LF1DD", true,true,"Logis") + " : " + enterprise%></p> <%-- <p class="p_web_form_header"><%= Utils.getMessage(context, lngCode, "LF1DC", "N° Affilié") + " : " + Contrat_Helper.getAffiliateNumber(context, perEntID)%></p> --%> </div> <br/> <br/> <br/> <br/> <%-- <div id="div_web_form_header_sub2"> <p id="p_div_web_form_header_sub2"> <%=Utils.getMessage(context, lngCode, "LF22B", "A retourner impérativement à votre Association Logis")%> <br/><%=Utils.getMessage(context, lngCode, "LF22C", "AVANT LE")%> <%=sExpireDt %><br/> <%=Utils.getMessage(context, lngCode, "LF22D", "DERNIER DELAI")%> </p> </div> </div> </div> --%> <%-- <div id="webform_header" class="webform_container"> <div id="webform_header" class="webform_container"> <div id="div_web_form_header"><%= webHeader %></div> <div id="div_web_form_header_sub"> <p class="p_web_form_header"><%= Person.toString()%></p> <p class="p_web_form_header"><%= Utils.getMessage(context, lngCode, "LF1DD", "Logis") + " : " + enterprise%></p> <p class="p_web_form_header"><%= Utils.getMessage(context, lngCode, "LF1DC", "N° Affilié") + " : " + Contrat_Helper.getAffiliateNumber(context, perEntID)%></p> </div> <div id="div_web_form_header_sub2"> <p id="p_div_web_form_header_sub2"> <%=Utils.getMessage(context, lngCode, "LF22B", "A retourner impérativement à votre Association Logis")%><br/><%=Utils.getMessage(context, lngCode, "LF22C", "AVANT LE")%> <%=sExpireDt %><br/><%=Utils.getMessage(context, lngCode, "LF22D", "DERNIER DELAI")%> </p> </div> </div> </div> --%> <% // Variables servant au mode paginé Iterator<String> itQuestionResponse=mapQuestionResponse.keySet().iterator(); boolean fFirstQuestion=true; int lfqPosition=Integer.MIN_VALUE; int p=0; for (Entry<String, Vector<String>> entry : mapQuestionResponse.entrySet()) { String lfqID = entry.getKey(); LinkFormQuestionBean lfq=new LinkFormQuestionBean(lfqID,context); // Question or paragraph ? String questionID=null; try { questionID=lfq.getLfqFormQuestionID(); } catch (Exception e) {} String paragraph=null; try { paragraph=lfq.getLfqParagraph(); p++;} catch (Exception e) {} Vector<String> resps = entry.getValue(); //String responseID = mapQuestionResponse.get(lfqID); String responseID = null; if(resps != null && resps.size() > 0) responseID = resps.elementAt(0); // may be null try { lfqPosition=lfq.getLfqPosition(); } catch (Exception e) {} // removed from here if (paragraph != null) { if(p > 1){ %> </div> <% } %> <div class="div_webform_container" id="<%= "PARA" +p %>"> <p class="webform_paragraph" id="p_webform_paragraph"><%=Utils.getMessage(context, lngCode, paragraph, paragraph).replaceAll("::millesime::", millesime).replaceAll("::millesime\\+1::", (Integer.parseInt(millesime)+1)+"").replaceAll("::millesime-1::", (Integer.parseInt(millesime)-1)+"")%></p> <% } else { FormQuestionBean question = null; QuestionResponseBean questionResponse=null; try { question = new FormQuestionBean(questionID , context); if (responseID!=null) { questionResponse = new QuestionResponseBean(responseID,context); } } catch (Exception e) { } request.setAttribute("responses",resps); request.setAttribute("initialresponses",mapInitialQuestionResponse); request.setAttribute("isActorLogis",actcode != null && !"ano".equalsIgnoreCase(actcode)); request.setAttribute("curQuestion",question); // La question a poser request.setAttribute("curQrs",questionResponse); // La réponse éventuellement existente //request.setAttribute("curQrsPosition",curQrsPosition); // La position //request.setAttribute("curQrsRefValID",curQrsRefValID); %> <jsp:include page="webform_question.jsp"> <jsp:param name="lfqPos" value="<%= lfqPosition %>"/> <jsp:param name="lfqID" value="<%= lfqID %>"/> <jsp:param name="lngCode" value="<%=lngCode %>"/> <jsp:param name="countryID" value="<%=countryID %>"/> <jsp:param name="languageID" value="<%=languageID %>"/> <jsp:param name="millesime" value="<%=millesime %>"/> </jsp:include> <% if (fFirstQuestion) { positionFirstQuestion=lfqPosition-1; %> <input type="hidden" name="firstQuestionPos" value="<%= lfqPosition %>"> <% } // first question fFirstQuestion=false; }//N'est pas un paragraph } // while positionLastQuestion=lfqPosition; if(p >= 1){ %> </div> <%} %> <input type="hidden" name="lastQuestionPos" value="<%= lfqPosition %>"> <div id="webform_footer" class="webform_container"> <%= webFooter %> </div> <% } %> <%if(init == null || Utils.isEmpty(init) || !"ok".equalsIgnoreCase(init)){ %> <div id="webform_links" class="webform_container"> <% if (hasPreviousQuestions) { %> <a href="javascript:doSubmit('prev=<%= positionFirstQuestion %>')"><< précédent </a> <% } %> <% if(actcode != null && !"ano".equalsIgnoreCase(actcode)){ %> <a href="javascript:doSubmit('leavemode=seeyou&complete=false');"><%= Utils.getMessage(context, lngCode, "FF2B2", true,true,"J'enregistre et je finaliserai ma saisie plus tard (mon inscription n'est pas validée)") %></a> <br> <a href="javascript:doSubmit('leavemode=bye&complete=true&validate=true&integrate=false');"><%= Utils.getMessage(context, lngCode, "A2001", "Valider") %></a> <%-- <span>|</span> <a href="javascript:doSubmit('leavemode=bye&complete=true&validate=true&integrate=true');"><%= Utils.getMessage(context, lngCode, "LF175", "Intégrer") %></a> --%> <% }else if(actcode == null || "ano".equalsIgnoreCase(actcode)){ %> <a href="javascript:doSubmit('leavemode=seeyou&complete=false');"><%= Utils.getMessage(context, lngCode, "FF2B2", true,true,"J'enregistre et je finaliserai ma saisie plus tard (mon inscription n'est pas validée)") %></a> <br> <a href="javascript:doSubmit('leavemode=bye&complete=true&validate=false');"><%= Utils.getMessage(context, lngCode, "FF2B4", true,true,"J'ai terminé ma saisie et je valide mon inscription au guide") %></a> <% }if (hasNextQuestions) { %> <a href="javascript:doSubmit('next=<%= positionLastQuestion %>')"> suivant >></a> <% } %> </div> <% } %> <div id="webform_termsofuse" class="webform_container"> <%= webTermsOfUse %> </div> </fl:form> </div> </body> </html>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de