Edit C:\galaxie\deploy\Tomcat6\webapps\galaxie\admin\referential\edit_mass_refvalues.jsp
<%@page import="com.edeal.frontline.controller.actions.GridEditAction"%> <%@page import="com.edeal.frontline.FlLocale"%><% /****************************************************************************** * Copyright (c) 2000-2011 e-Deal * * e-Deal S.A. * 41 rue Perrier * 92120 Montrouge * 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" contentType="text/html; charset=UTF-8"%> <%@page import="java.util.ArrayList"%> <%@ page import="com.edeal.frontline.navigation.FlRequest" %> <%@ page import="com.edeal.frontline.FlContext" %> <%@ page import="com.edeal.frontline.Utils" %> <%@ page import="com.edeal.frontline.FieldNotInitializedException" %> <%@ page import="java.util.Date" %> <%@ page import="java.text.SimpleDateFormat" %> <%@ page import="java.util.Vector" %> <%@ page import="java.util.Hashtable" %> <%@ page import="java.util.Set" %> <%@ page import="java.util.List" %> <%@ page import="com.edeal.frontline.BeansEditor" %> <%@ page import="com.edeal.frontline.TablesBean" %> <%@ page import="com.edeal.frontline.DataDictionary" %> <%@ page import="com.edeal.frontline.RefValuesBean" %> <%@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 tabID = flRequest.getRequestParameterOrAttribute("id"); String sfwID = flRequest.getRequestParameterOrAttribute("SfwID"); Vector vectLng = null; TablesBean table = null; try { // récuperations du couple Id, RefTe1 pour toutes les langues vectLng = dico.getRefList("Lna", "Te1"); table = new TablesBean(tabID, context); } catch (Exception e) {} Hashtable h = table.getColumnLabels(context, table.getID()); Set keysRef = h.keySet(); Vector vectRefValuesData = table.getRefValuesData(); //tableaux utilisés pour trier les champs String[] tabFields = {"TabT1", "TabT2", "TabT3", "TabN1", "TabN2", "TabN3", "TabD1", "TabD2", "TabD3"}; String[] refFields = {"RefTe1", "RefTe2", "RefTe3", "RefNu1", "RefNu2", "RefNu3", "RefDa1", "RefDa2", "RefDa3"}; String[] totalRefFields = {"RefID", "RefVal", "RefEnd", "RefPos","RefTe1", "RefTe2", "RefTe3", "RefNu1", "RefNu2", "RefNu3", "RefDa1", "RefDa2", "RefDa3"}; String[] relFields = {"RelTe1", "RelTe2", "RelTe3"}; //pour les champs de RefLocale ArrayList<String> fieldsLngUsing = new ArrayList<String>(); //pour les champs de RefValues ArrayList<String> fieldsList = new ArrayList<String>(); //pour les champs de Tables ArrayList<String> fieldsTabList = new ArrayList<String>(); int cmpFLU = 0; int cmpFL = 0; int cmpFTL = 0; //Stockage du nom des champs dans le même ordre pour //Tables, RefValues et RefLocale for(int t = 0 ; t<tabFields.length ; t ++){ if(keysRef.contains(tabFields[t])){ if(t<relFields.length){ fieldsLngUsing.add(cmpFLU++,relFields[t]); } fieldsTabList.add(cmpFTL++,tabFields[t]); fieldsList.add(cmpFL++,refFields[t]); } } //compteur pour différencier les <form> (id) et pouvoir les récupérer //si les inputs sont modifiés int cmpForms = 0; %> <script type="text/javascript" language="javascript" src="<fl:webapp/>/js/utils.js"></script> <script type="text/javascript" language="javascript" src="<fl:webapp/>/js/calendar.jsp"></script> <script type="text/javascript" language="javascript"> var refValuesIDsList = new Array(); var refLocaleIDsList = new Array(); var refVals2 = new Array(); var objJsList = new Array(); //pour vérifier si l'id est déjà stocké function notContains(array, val){ var cmpt =array.length; while(cmpt--){ if(array[cmpt]==val){ return false; } } return true; }; //pour stocker les forms où il y a eu une modification function saveRefValuesId(id){ var formid = id; if(notContains(refValuesIDsList, formid)){ refValuesIDsList.push(formid); } } function saveRefLocaleId(id){ var trid = id; if(notContains(refLocaleIDsList, trid)){ refLocaleIDsList.push(trid); } }; function createRefValObjs(){ var cmp = refValuesIDsList.length; if(cmp==0){ return; }else{ for ( i = 0 ; i < cmp ; i++){ var cmp2 = refValuesIDsList[i]; <% for(String field : totalRefFields){%> var <%= field.toLowerCase()%> = $('#'+cmp2+'_'+'<%= field%>').val(); <% }%> if (document.getElementById(cmp2+'_RefEnd').checked){ refend = 'true'; } var refvalues = new RefValuesJs(refid, new Fields('<%=tabID%>', refval, refte1, refte2, refte3, refnu1, refnu2, refnu3, refda1, refda2, refda3, refend, null, null, null, null, null, refpos)); objJsList.push(refvalues); } } return; }; function createRefLocObjs(){ var cmp = refLocaleIDsList.length; if(cmp==0){ return; }else{ for ( i = 0 ; i < cmp ; i++){ var cmp2 = refLocaleIDsList[i]; var relid = $('#'+cmp2+'_'+'RelID').val(); var relrefid = $('#'+cmp2+'_'+'RelRefID').val(); var rellngid = $('#'+cmp2+'_'+'RelLngID').val(); var relte1 = $('#'+cmp2+'_'+'RelTe1').val(); var relte2 = $('#'+cmp2+'_'+'RelTe2').val(); var relte3 = $('#'+cmp2+'_'+'RelTe3').val(); var refpos = $('#'+cmp2+'_'+'RefPos').val(); if(relte1!=''||relte2!=''||relte3!=''||refpos!=''){ var reflocale = new RefLocaleJs(relid, new Fields(null, null, null, null, null, null, null, null, null, null, null, null, relrefid, rellngid, relte1, relte2, relte3)); objJsList.push(reflocale); }; }; } }; function verifyRefVal(){ var refVals = new Array(); var cmp = <%=vectRefValuesData.size()%>; for ( i = 0 ; i < cmp ; i++){ var tmpRefVal = $('#'+i+'_'+'RefVal').val(); if(notContains(refVals, tmpRefVal)){ refVals.push(tmpRefVal); }else{ return false; } } return true; } function save(){ if(verifyRefVal()){ createRefValObjs(); createRefLocObjs(); var jsonstring = JSON.stringify(objJsList); $.ajax({ data: jsonstring, type: "POST", url: "<fl:webapp/>/save_mass_ref.fl", timeout: 20000, contentType: "application/json;charset=utf-8", dataType: 'json', async: false, success: analyse }); }else{ alert('<fl:getMessage code="L8112" alt="Les champs codes(RefVal) doivent être unique. Veuillez les vérifier." js="true"/>') } }; function analyse(jsonResponse){ if(jsonResponse==null||jsonResponse.error==''){ window.location.href = '<fl:webapp/>/referential.fl?RefTabID=<%=tabID %>&SfwID=<%=sfwID%>'; }else{ alert('<fl:getMessage code="L8110" alt="Erreur lors de l\\\'enregistrement :" js="true"/> ' + jsonResponse.error); } }; function refreshList(arrIndex){ window.setTimeout(refreshPage,10); } function refreshPage(){ window.refresh; } function editRefVal() { window.open("<fl:webapp/>/edit_refvalues.fl?tabID=" + "<%=tabID %>", "edit_refvalues", "width=1000,height=410,resizable=yes"); } </script> <div style="position: static; overflow:auto;"> <fl:bigTabs objectTitle="<%= Utils.getMessage(session, \"L6019\", false, true, \"Valeurs de référence\") %>" > <%for(int j = 0 ; j<vectRefValuesData.size(); j++){ Hashtable refValues = (Hashtable)vectRefValuesData.get(j); String refId = (String)refValues.get("RefID"); RefValuesBean refBean = new RefValuesBean(refId, context); Hashtable translations = refBean.getTranslations(); %> <form id="form_<%=cmpForms%>"> <div class="edealGrid"> <div id="grid-data" class="data" > <table width="100%"> <thead> <tr valign="top"> <th style="width: 6%"> </th> <th style="width: 8%"><fl:getMessage code="F2000" alt="Code"/></th> <% int cmp = 0; //boucle pour les champs utilisés for(String field : fieldsTabList){ //compteur pour le nombre de champs cmp++;%> <th style="width: <%=86/fieldsTabList.size()%>%"><%=(String)h.get(field)%></th> <%}%> <th style="width: 2%">Position</th> <th style="width: 2%">Désactivée</th> </tr> </thead> <tbody> <tr class="even bean"> <input id="<%=cmpForms%>_RefID" type="hidden" value="<%=refBean.getRefID()%>"> <td>Par défaut</input></td> <td><input id="<%=cmpForms%>_RefVal" class="input text chpsTextObligatoire" value="<%=refBean.getRefVal()%>" width="100%" onchange="javascript:saveRefValuesId('<%=cmpForms%>')"></input></td> <% for(int i = 0; i < cmp; i++){ String field = fieldsList.get(i); if(field.substring(3,5).equals("Da")){ Date date = (Date)refValues.get(field); String dateFormated = null; if(date!=null){ SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.SSS"); dateFormated = sdf.format(date); } %> <td nowrap> <input id="<%=cmpForms%>_<%=field%>" name="<%=field%>" type="hidden" value="<%=dateFormated!=null?dateFormated:""%>"> <div style="display: inline;"> <a href="javascript:openCalendar(document.forms[<%=cmpForms%>].Date$<%=field%>)" class="cal-icon"> <img src="/Head/icons/ico/clock_neutre.gif" class="icon"></a> <input name="Date$<%=field%>" value="<%=refValues.get(field)!=null?dateFormated.substring(0,10):""%>" style="width: 70px;" maxlength="10" size="10" class="input date" onchange="this.form.<%=field%>.value = this.form.Date$<%=field%>.value + ' ' + this.form.Time$<%=field%>.value;saveRefValuesId('<%=cmpForms%>');"> </div> <input name="Time$<%=field%>" value="<%=refValues.get(field)!=null?dateFormated.substring(11,16):""%>" maxlength="5" size="5" class="input time" onblur="this.form.<%=field%>.value = this.form.Date$<%=field%>.value + ' ' + this.form.Time$<%=field%>.value;" onchange="javascript:saveRefValuesId('<%=cmpForms%>')"> </td> <% }else{ %> <td><input id="<%=cmpForms%>_<%=field%>" value="<%=refValues.get(field)!=null?refValues.get(field):""%>" style="<%=(field.substring(3,5).equals("Te")?"min-width:150px;":"") %>width: 95%; <%=field.contains("N")||field.contains("D")?"text-align: right":""%>" onchange="javascript:saveRefValuesId('<%=cmpForms%>')"></input></td> <% } } %> <td><input id="<%=cmpForms%>_RefPos" value="<%=refBean.getRefPos()%>" style="width: 95%; text-align: right;" onchange="javascript:saveRefValuesId('<%=cmpForms%>')"></input></td> <td align="center"><input id="<%=cmpForms%>_RefEnd" type="checkbox" value="false" style="text-align: center" <%=refBean.isRefEnd() ?"checked=\"checked\"":"" %> onchange="javascript:saveRefValuesId('<%=cmpForms%>')"></input></td> </tr> <% int cmpColor = 1; for(Object keyLanguage : vectLng){ String languageID = (String)((Vector)keyLanguage).get(0); String relId = translations.get(languageID)!=null?(String)((Hashtable) translations.get(languageID)).get("RelID"):""; %> <tr id="<%=cmpForms%>_<%=languageID %>" class="<%=(cmpColor++%2==0?"even bean": "odd bean") %>"> <td> <%=((Vector)keyLanguage).get(1)%> </td> <input id="<%=cmpForms%>_<%=languageID %>_RelID" type="hidden" value="<%=relId%>"> <input id="<%=cmpForms%>_<%=languageID %>_RelRefID" type="hidden" value="<%=refBean.getRefID()%>"> <input id="<%=cmpForms%>_<%=languageID %>_RelLngID" type="hidden" value="<%=languageID%>"> <td></td> <%%> <% int comptrForLng = 0; for(int i = 0; i < cmp; i++){ if(comptrForLng<fieldsLngUsing.size()&&fieldsLngUsing.get(comptrForLng).substring(3).equals(fieldsList.get(i).substring(3))){ if(translations.get(languageID)!=null){ Hashtable htbl = (Hashtable) translations.get(languageID); String tmp = fieldsLngUsing.get(comptrForLng); String val = (String)htbl.get(tmp); %> <td><input id="<%=cmpForms%>_<%=languageID %>_<%=tmp %>" value="<%=val!=null?val:""%>" style="width: 95%;" onchange="javascript:saveRefLocaleId('<%=cmpForms%>_<%=languageID %>')"/></td> <% }else{ %> <td><input id="<%=cmpForms%>_<%=languageID%>_<%=fieldsLngUsing.get(comptrForLng)%>" value="" style="width: 95%;" onchange="javascript:saveRefLocaleId('<%=cmpForms%>_<%=languageID %>')"/></td> <% } comptrForLng++; }else{ %> <td></td> <% } } %> <td></td><td></td> </tr> <%} %> </tbody> </table> </div> </div> </form> <br/> <br/> <% cmpForms++; }%> </fl:bigTabs> </div>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de