Edit C:\Users\Administrator\Desktop\Back\galaxie - Copy\siteweb\webform\test.jsp
<%@page import="com.itextpdf.text.log.SysoLogger"%> <%@ page session="true"%> <%@ page import="com.edeal.frontline.*"%> <%@ page import="com.edeal.frontline.helper.custom.*"%> <%@ page import="java.lang.reflect.*"%> <%@ page import="java.util.*,java.text.*"%> <%@ page import="com.edeal.frontline.grid.GridData"%> <%@ page import="com.edeal.frontline.navigation.FlRequest"%> <%@ page import="com.edeal.frontline.custom.*"%> <%@ page import="com.edeal.frontline.services.addressnormalisation.*"%> <%@ page import="com.edeal.frontline.helper.ContextHelper"%> <%@ taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl"%> <%@ page import="java.io.File"%> <%@ page import="java.io.FileInputStream"%> <%@ page import="java.io.FileOutputStream"%> <%@ page import="java.io.InputStream"%> <%@ page import="java.io.StringReader"%> <%@ page import="java.io.StringWriter"%> <%@ page import="javax.xml.parsers.*"%> <%@ page import="org.w3c.dom.*"%> <%@ page import="org.xml.sax.*"%> <%@ page import="javax.xml.parsers.DocumentBuilderFactory"%> <%@ page import="javax.xml.transform.Result"%> <%@ page import="javax.xml.transform.Source"%> <%@ page import="javax.xml.transform.Transformer"%> <%@ page import="javax.xml.transform.TransformerFactory"%> <%@ page import="javax.xml.transform.dom.DOMSource"%> <%@ page import="javax.xml.transform.stream.StreamResult"%> <%@ page import="org.apache.commons.io.FileUtils"%> <%@ page import="java.net.URL"%> <%@ page import="com.edeal.frontline.fusion.Fusion"%> <%@ page import="com.edeal.frontline.fusion.parameters.impl.FusionParameterWordImpl"%> <% 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 entID = "0000FF00007aa2d8"; //int nb = Contrat_Helper.getNbEnseignes(context, entID); /* Vector vec = Contrat_Helper.getPrdCodesFromContract(context, entID); String q = FormHelper.formatLfqQueryToSQL(context,vec); Vector prds = OpportunityHelper.getDefaultCotProductList(context, "2015", entID, "L"); Vector<String> vecprds = OpportunityHelper.getCotPrdCodes(context, entID); logger.info("Les enseignes : " + vec); logger.info(" Produits : " + prds); logger.info("les enseignes sql query : " + q); logger.info("Codes de produits : " + vecprds); */ /* Vector<Vector<Object>> values = dico.getRefList(session, "Mls", "Nu1"); logger.info("Codes : " + values); if (values != null) { for (Vector<Object> val : values) { String refID = (String)val.firstElement(); logger.info("refID : " + refID); Double refDisp = (Double)val.elementAt(1); logger.info("refDisp : " + refDisp.toString()); } } */ //FormHelper.updateFormQuestion(context); //String formID = "00012d000068d2f9"; //String frpID = "0000000000918439"; //FormHelper.mergeEnvies(context, entID, formID, frpID); //FormHelper.mergeFermeturesYear(context, "0000FF00007aa2d8", "0000000000920c9c", "00012d000068cf54", "2015"); //FormHelper.mergeFermeturesHebdo(context, "0000FF00007aa2d8", "0000000000920c9c", "00012d000068cf54", "2015"); //FormHelper.mergePrices(context, "0000FF00007aa2d8", "0000000000920c9c", "00012d000068cf54","2015"); //FormHelper.generateCotDevis(context, "0000FF00007b247a", "0000FF00007aa2d8", "00012d000068cf54", "0000000000920c9c"); //String attid = (String)EnterpriseBean.lookup(context, "EntPhotoID_:Po_Apercu:AttID", "0000FF00007aa2d8"); //logger.info("attachment :: " + attid); //logger.info("count :: " + PersonEventHelper.getListPersonEventForEvent(context, "00012d000068d2f7")); //String ctID = com.edeal.frontline.helper.custom.Contrat_Helper.getActifAdhContractID(context,"0000FF00007a9fcd"); //int numCt = (Integer)Contrat_Bean.lookup(context, "Ct_NumContrat", ctID); //out.print(numCt); //document id=00000000009a1e9e /* Vector<Hashtable> list = null; String model = null; String docid = null; String lngId = "00012d00000009dc"; String docObjID = "00000000009af3e0"; String entId = "0000FF00007a9fcd"; EnterpriseBean enttt; String version = (new SimpleDateFormat("dd-MM-yyyy-HH-mm-ss") .format(new Date())); String xmlfilename = "resultat" + version + ".xml"; String pdffilename = "resultat" + version + ".pdf"; try { AttachmentBean attach = new AttachmentBean((new DocumentBean( docObjID, context)).getDocAttID(), context);//QuestionnaireGuide2003 String requrl = request.getRequestURL().toString(); String cntname = context.getContextName(); String url = requrl.substring(0, requrl.indexOf(cntname) + cntname.length() + 1) + "download?id="; FileUtils.copyURLToFile(new URL(url + attach.getAttID()), new File("source.xml")); try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory .newInstance(); InputStream inputStream = new FileInputStream(new File( "source.xml")); org.w3c.dom.Document doc = documentBuilderFactory .newDocumentBuilder().parse(inputStream); StringWriter stw = new StringWriter(); Transformer serializer = TransformerFactory.newInstance() .newTransformer(); serializer.transform(new DOMSource(doc), new StreamResult( stw)); model = stw.toString(); } catch (Exception e) { e.printStackTrace(); } String res = Fusion.doFusion(request.getSession(), context, model, entId, lngId, new FusionParameterWordImpl()); //////passage Autre : //////WWDernierDelaiWW :21 Juillet 2014 res = res.replaceAll("WWDernierDelaiWW", "21 Juillet 2014"); try { enttt = new EnterpriseBean(entId, context); String cvcv = enttt.getCustomProperty("EntCotisationMil_").toString(); res = res.replaceAll("WWEntCotisationMil_WW", cvcv); } catch (Exception e) { e.printStackTrace(); } //////passage Autre : Fin /////passage Localité : /////LL_Pays_LL => ,LL_Region_LL try { enttt = new EnterpriseBean(entId, context); String locid = enttt.getCustomProperty("EntLocalityID_").toString(); Localite_Bean locb = new Localite_Bean(locid,context); String depid = locb.getLo_Dep(); String regVal = (String)dico.getRefDisp(session, "Dp_", "Te2", depid); String regid = dico.getRefIdByCode("Rg_", "Te2", regVal); String region = (String)dico.getRefDisp(session, "Rg_", "Te1",regid); String paysVal = (String)dico.getRefDisp(session, "Rg_", "Te2", regid); String paysid = dico.getRefIdByCode("Ctr", "Te2", paysVal); String pays = (String)dico.getRefDisp(session, "Ctr", "Te1", paysid); res = res.replaceAll("LL_Pays_LL", pays); res = res.replaceAll("LL_Region_LL", region); } catch (Exception e) { e.printStackTrace(); } /////passage Localité : Fin //////passage du personne : //////Params : XXPerCivID:ValXX,XXPerNameXX,XXPerFstNameXX String perFstName = ""; String perName = ""; String perCiv = ""; try { String perId = EnterpriseHelper.getEntExploitant(context, entId); PersonBean person = new PersonBean(perId, context); perFstName = person.getPerFstName(); perName = person.getPerName(); perCiv = (String) dico.getRefDisp("Civ", "Te1", person.getPerCivID()); } catch (Exception e) { e.printStackTrace(); } res = res.replaceAll("XXPerFstNameXX", perFstName); res = res.replaceAll("XXPerNameXX", perName); res = res.replaceAll("XXPerCivID:ValXX", perCiv); //////passage du personne : Fin //////passage du contrat : //////Params : YYCt_NombreChambresYY int ct_NombreChambres = 0; try { //String ctID = Contrat_Helper.getAffiliateNumber(context, entId); String ctID = (new EnterpriseHelper(new EnterpriseBean( entId, context))) .getCtrPrincipal(new EnterpriseBean(entId, context)); //out.print(ctID); Contrat_Bean contrat = new Contrat_Bean(ctID, context); ct_NombreChambres = contrat.getCt_NombreChambres(); } catch (Exception e) { e.printStackTrace(); } res = res.replaceAll("YYCt_NombreChambresYY", "" + ct_NombreChambres); //////passage du contrat : Fin //////passage des langues : /////[LL_DE_LL] Allemand /////[LL_US_LL] Anglais /////[LL_ES_LL] Espagnol /////[LL_FR_LL] Français /////[LL_IT_LL] Italien /////[LL_NL_LL] Néerlandais /////[LL_CT_LL] Catalan /////[LL_PG_LL] Portugais ///// [_] non parlé ///// [V] parlé ///// table mvaentspoklngid_, customproperty EntSpokLngID_ ///// try { enttt = new EnterpriseBean(entId, context); Vector<String> lng = (Vector<String>)enttt.getCustomProperty("EntSpokLngID_"); String langFRID = dico.getRefIdByCode("Lna", "Te1", "fr_FR"); String langDEID = dico.getRefIdByCode("Lna", "Te1", "de_DE"); String langUSID = dico.getRefIdByCode("Lna", "Te1", "en_US"); String langCTID = dico.getRefIdByCode("Lna", "Te1", "ct_CT"); String langESID = dico.getRefIdByCode("Lna", "Te1", "es_ES"); String langITID = dico.getRefIdByCode("Lna", "Te1", "it_IT"); String langNLID = dico.getRefIdByCode("Lna", "Te1", "nl_NL"); String langPGID = dico.getRefIdByCode("Lna", "Te1", "pg_PG"); if(lng.contains(langFRID)){ res = res.replaceAll("LL_FR_LL", "X"); }else{ res = res.replaceAll("LL_FR_LL", "_"); } if(lng.contains(langDEID)){ res = res.replaceAll("LL_DE_LL", "X"); }else{ res = res.replaceAll("LL_DE_LL", "_"); } if(lng.contains(langUSID)){ res = res.replaceAll("LL_US_LL", "X"); }else{ res = res.replaceAll("LL_US_LL", "_"); } if(lng.contains(langCTID)){ res = res.replaceAll("LL_CT_LL", "X"); }else{ res = res.replaceAll("LL_CT_LL", "_"); } if(lng.contains(langESID)){ res = res.replaceAll("LL_ES_LL", "X"); }else{ res = res.replaceAll("LL_ES_LL", "_"); } if(lng.contains(langITID)){ res = res.replaceAll("LL_IT_LL", "X"); }else{ res = res.replaceAll("LL_IT_LL", "_"); } if(lng.contains(langNLID)){ res = res.replaceAll("LL_NL_LL", "X"); }else{ res = res.replaceAll("LL_NL_LL", "_"); } if(lng.contains(langPGID)){ res = res.replaceAll("LL_PG_LL", "X"); }else{ res = res.replaceAll("LL_PG_LL", "_"); } //out.print(lng); //res = res.replaceAll("WWEntCotisationMil_WW", cvcv); } catch (Exception e) { e.printStackTrace(); } //////passage des langues : Fin byte[] bytestab = Fusion.word2pdfNew(context, res); FileOutputStream fos = new FileOutputStream("resultat.pdf"); fos.write(bytestab); fos.close(); DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance(); DocumentBuilder builder; try { builder = factory.newDocumentBuilder(); Document document = builder.parse(new InputSource( new StringReader(res))); TransformerFactory tranFactory = TransformerFactory .newInstance(); Transformer aTransformer = tranFactory.newTransformer(); Source src = new DOMSource(document); Result dest = new StreamResult(new File("resultat.xml")); aTransformer.transform(src, dest); } catch (Exception e) { e.printStackTrace(); } AttachmentBean attXmlRes = new AttachmentBean(context); attXmlRes.setAttFile(java.nio.file.Files .readAllBytes(java.nio.file.Paths.get("resultat.xml"))); attXmlRes.setAttContentType("application/octet-stream"); attXmlRes.setAttFileName("resultat.xml"); attXmlRes.setAttDesc("resultat.xml"); // Sauvegarde try { attXmlRes.save(); attXmlRes.saveBinary(); out.print("<a href='download?id=" + attXmlRes.getAttID() + "'>telecharger le fichier XML</a>"); //out.print(res); } catch (FrontlineException ex) { logger.error( "Impossible de sauvegarder le Fichier Attaché", ex); } catch (AccessDeniedException ade) { logger.error("Impossible d'accéder à l'objet Attachment", ade); } AttachmentBean attpdfRes = new AttachmentBean(context); attpdfRes.setAttFile(java.nio.file.Files .readAllBytes(java.nio.file.Paths.get("resultat.pdf"))); attpdfRes.setAttContentType("application/octet-stream"); attpdfRes.setAttFileName("resultat.pdf"); attpdfRes.setAttDesc("resultat.pdf"); // Sauvegarde try { attpdfRes.save(); attpdfRes.saveBinary(); out.print("<br/><a href='download?id=" + attpdfRes.getAttID() + "'>telecharger le fichier PDF</a>"); //out.print(res); } catch (FrontlineException ex) { logger.error( "Impossible de sauvegarder le Fichier Attaché", ex); } catch (AccessDeniedException ade) { logger.error("Impossible d'accéder à l'objet Attachment", ade); } } catch (Exception e) { logger.error("ERREUR lors de la fusion", e); } */ /* String formID = "00012d000068cf54"; String pvtID = "00000000009f7181"; PersonEventBean pvt = new PersonEventBean(pvtID, context); String perID = pvt.getPvtPersonID(); PersonBean per = new PersonBean(perID,context); String entID = per.getPerEntID(); String frpID = pvt.getPvtFrpID(); String nom = EnterpriseBean.class.getName(); Class cl = Class.forName(nom); Class[] types = new Class[]{String.class, com.edeal.frontline.FlContext.class}; Constructor ct = cl.getConstructor(types); Object obj = ct.newInstance(new Object[]{entID, context} ); Vector lfqs = FormHelper.getLfqsEnabledList(context, formID, "Enterprise"); if(lfqs != null && lfqs.size() >0){ for(int p=0; p<lfqs.size(); p++){ Hashtable row = (Hashtable)lfqs.elementAt(p); String lfqCode = (String)row.get("LfqCode_"); Vector<String> codes = Utils.explodeList(lfqCode, "|"); for(int i=0; i<codes.size(); i++){ lfqCode = codes.get(i); FieldBean fldbean = dico.getFieldByName(lfqCode); boolean isREF = false; try { String refType = fldbean.getFldTabID(); isREF = refType != null; }catch (FieldNotInitializedException e){} boolean isStd = false; try { isStd = fldbean.isFldStd(); }catch (FieldNotInitializedException e){} boolean isMva = false; try { isMva = fldbean.isFldMultival(); }catch (FieldNotInitializedException e){} String strType = com.edeal.frontline.dataimport.BeanOutSource.getJavaType(dico.getRefCode("FldFltID", fldbean.getFldFltID())); Class clType = null; Object cValue = null; try{ if(isMva) { clType = Class.forName("java.util.Vector"); cValue = new Vector(); } else if("java.lang.Boolean".equalsIgnoreCase(strType)) { clType = boolean.class; cValue = new Boolean(false); } else if("java.lang.Float".equalsIgnoreCase(strType)) { clType = float.class; cValue = new Float(0); } else if("java.lang.Double".equalsIgnoreCase(strType)) { clType = double.class; cValue = new Double(0); } else if("java.lang.Integer".equalsIgnoreCase(strType)) { clType = int.class; cValue = new Integer(0); } else if("java.lang.Long".equalsIgnoreCase(strType)) { clType = long.class; cValue = new Integer(0); } else if("java.lang.Short".equalsIgnoreCase(strType)) { clType = short.class; cValue = new Integer(0); } else { clType = Class.forName(strType); } }catch(ClassNotFoundException e){ logger.warn(e.getMessage()); } String sqlQuery = "select LfqID,QrsID,QrsRefValID,QrsText from LinkFormQuestion " + " inner join QuestionResponse on (QrsLfqID = LfqID and QrsFrpID = " + Utils.formatToSQL(context, frpID)+ ") " + " where LfqFormID = " + Utils.formatToSQL(context, formID) + " AND LfqName_ = " + Utils.formatToSQL(context, "Enterprise") + " AND LfqCode_ = " + Utils.formatToSQL(context, lfqCode) + " order by LfqPosition,QrsInstance"; logger.info("query:" + sqlQuery); 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); if(isMva){ Vector<String> values = new Vector<String>(); while (rs.next()) { values.add(rs.getString("QrsRefValID")); } cValue = values; }else if(isREF){ while (rs.next()) { cValue = rs.getString("QrsRefValID"); } }else{ while (rs.next()) { cValue = rs.getString("QrsText"); } } try { Class[] type = {clType}; Object[] params = {(Object)cValue}; if(isStd) { //obj.getClass().getMethod("set" + (String) lfqCode,new Class[]{clType}).invoke(obj, params); Method m0 = obj.getClass().getMethod("get" + (String) lfqCode); Object typeParam; try{ typeParam = m0.invoke(obj); }catch(Exception e){ typeParam = new String(); } //pour exécuter le setProperty Class[] getMethodParams = new Class[]{Object.class}; Method m = obj.getClass().getMethod("set" + (String) lfqCode,getMethodParams); m.invoke(obj, new Object[]{lfqCode, typeParam.getClass().cast(cValue)}); } else { //pour avoir le type du property, on exécute getproperty et voir le type du resultat Class[] getMethodParams0 = new Class[]{String.class}; Method m0 = obj.getClass().getMethod("getCustomProperty",getMethodParams0); Object typeParam; try{ typeParam = m0.invoke(obj, new Object[]{lfqCode}); }catch(Exception e){ typeParam = new String(); } //pour exécuter le setProperty Class[] getMethodParams = new Class[]{String.class,Object.class}; Method m = obj.getClass().getMethod("setCustomProperty",getMethodParams); m.invoke(obj, new Object[]{lfqCode, typeParam.getClass().cast(cValue)}); } } catch (Exception ex) { logger.error("STACK TRACE",ex); } }catch (java.sql.SQLException e){ logger.error("SQL Error in getting question and response", e); } finally { try { rs.close(); } catch (Exception e) { } try { stmt.close(); } catch (Exception e) { } try { con.close(); } catch (Exception e) { } } } } } //pour enregistrer save() Method m1 = obj.getClass().getMethod("save"); m1.invoke(obj); */ // r�cup�ration du contrat associ� � la commande s'il est renseign� (Cas des affili�s) /* String idType="STACI"; org.json.JSONArray jsonArr = new org.json.JSONArray(); Vector vectorSubCategoryDisplay = null; Vector vectorSubCategoryCode = null; String catCode = null; Vector <String> resultFamIDs = new Vector<String>(); try { //DataDictionary dico = context.getDataDictionary(); catCode = idType; vectorSubCategoryDisplay = dico.getRefList("Pf_", "Te1"); vectorSubCategoryCode = dico.getRefList("Pf_", "Te2"); } catch (FrontlineException fe) { } if ((vectorSubCategoryDisplay != null) && (vectorSubCategoryDisplay.size() > 0) && (vectorSubCategoryCode != null) && (vectorSubCategoryCode.size() > 0)) { for (int j = 0; j < vectorSubCategoryDisplay.size(); j++) { Vector vSubCategoryDisplay = (Vector)vectorSubCategoryDisplay.elementAt(j); try { Vector vSubCategoryCode = (Vector)vectorSubCategoryCode.elementAt(j); String subCatID = (String)vSubCategoryDisplay.elementAt(0); String subCatParent = (String)vSubCategoryCode.elementAt(1); if (subCatParent.contains(catCode)) { resultFamIDs.addElement(subCatID); } } catch (Exception e) { logger.debug("La sous-cat�gorie est vide", e); } } } //00012d000f5eb959 Stroungnfvb String idOpp = ""; String contratID = null; OpportunityBean opp = new OpportunityBean(idOpp,context); try { contratID = (String) opp.getCustomProperty("OppAffiliationCtID_"); } catch (FieldNotInitializedException ex) { } Vector <ProductOpportunityBean> productsList = new Vector<ProductOpportunityBean>(); try { productsList = (Vector) opp.getProductOpportunities(); } catch (FieldNotInitializedException fnie) { logger.error("STACK TRACE", fnie); } String oppEntID = null; try{ oppEntID = opp.getOppEntID(); }catch(FieldNotInitializedException fe){ } // Date du jour : Date dateDuJour = new Date(); // lid de l'utilisateur connect� String actID = (String)request.getSession().getAttribute("actorID"); //out.print(productsList + " " + actID + " " + oppEntID + " " +resultFamIDs ); // Dans le cas o� l'on a valid� un devis avec des enseignes, il faut Activer le champ boolean "NotifierSTACI" du contrat associ� au devis if(contratID != null){ // Il faut dans ce cas ajouter les produits de la famille "Enseigne" � la table Contrat-Produit if (productsList != null && productsList.size() > 0) { //Evo on ram�ne la liste des familles STACI Vector <String> famIDs = new Vector<String>(); famIDs = resultFamIDs;//getfamillesStaci(context, "STACI"); // Etat enseigne Ouvert String ouvID = null; // les codes Ref des Distributeurs try { ouvID = dico.getRefIdByCode("Ent", "Te1", "OUV"); } catch (FrontlineException e) { ouvID = ""; } // Statut enseigne Valide String ValID = null; // les codes Ref des Distributeurs try { ValID = dico.getRefIdByCode("Ls_", "Te1", "VA"); } catch (FrontlineException e) { ValID = ""; } for (int i = 0; i < productsList.size(); i++) { if(productsList.get(i) != null) { ProductOpportunityBean proOpp = productsList.get(i); // si le produit est une enseigne, il faut l'ajouter dans contrat-produit // On r�cup�re le produit contenu dans l a ligne de produit int qte = proOpp.getProQuantity(); ProductBean pro = new ProductBean(proOpp.getProPrdID(), context); // r�cup�ration de la famille du produit si elle est renseign�e String prdFamID = null; try { prdFamID = (String) pro.getCustomProperty("PrdFamilleProduit_"); } catch (FieldNotInitializedException ex) { logger.error("STACK TRACE", ex); } Boolean crerLigneStaciCtr = false; if(prdFamID != null && famIDs != null && !famIDs.isEmpty()){ for(int j=0; j < famIDs.size(); j++) { if(prdFamID.equalsIgnoreCase(famIDs.elementAt(j))){ crerLigneStaciCtr = true; } } } if(crerLigneStaciCtr){ // le produit est une enseigne -> il faut l'ins�rer dans Contrat-Produit ContratProduit_Bean conpro = new ContratProduit_Bean(context); conpro.setCr_Commande_(idOpp); // la commande associ�e conpro.setCr_Contrat(contratID); // le contrat conpro.setCr_Produit(pro.getID()); // l'enseigne conpro.setCr_Etat(ouvID); // Ouvert conpro.setCr_Statut(ValID);//Valide oppEntID = opp.getOppEntID(); if(oppEntID != null) conpro.setCr_Tiers(oppEntID);//ajout de cr_tiers conpro.setCr_Quantity(qte); try{ conpro.setCr_DateDebut((Date)opp.getCustomProperty("OppDatComm_")); } catch (FieldNotInitializedException e) { conpro.setCr_DateDebut(dateDuJour); // date du jour si la date de commande n'est pas fournie } conpro.setCr_CrDt(dateDuJour); conpro.setCr_CreID(actID); try { conpro.save(); } catch (FrontlineException ex) { logger.error("STACK TRACE", ex); } catch (AccessDeniedException ade) { logger.error("STACK TRACE", ade); } } } } } } */ %>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de