<%@page import="java.io.ByteArrayInputStream"%> <%@page import="java.io.InputStream"%> <%@page import="org.apache.commons.io.IOUtils"%> <%@page import="java.io.StringWriter"%> <%@page import="javax.mail.internet.MimeUtility"%> <%@page import="com.edeal.frontline.EventBean"%> <%@page import="com.edeal.frontline.OpportunityBean"%> <%@page import="com.edeal.frontline.PersonEventBean"%> <%@page import="com.edeal.frontline.helper.InteractionBaseHelper"%> <%@page import="com.edeal.frontline.helper.InteractionBaseHelper.ContextObjectInformation"%> <%@page import="java.util.HashMap"%> <%@page import="com.edeal.frontline.ObjectsBean"%> <%@page import="com.edeal.frontline.AttachmentBean"%> <% /****************************************************************************** * Copyright (c) 2000-2013 E-DEAL * * E-DEAL S.A. * 41, rue Périer * 92120 Montrouge * France * * T: +33 (0)1 73 03 29 80 * 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"%> <%@ page import="com.edeal.frontline.MessagesBean" %> <%@ page import="com.edeal.frontline.FrontlineException" %> <%@ 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.util.Vector" %> <%@ page import="java.util.Iterator" %> <%@ page import="java.util.Hashtable" %> <%@ page import="com.edeal.frontline.SalesInvestBean" %> <%@ page import="com.edeal.frontline.FlLocale" %> <%@ page import="com.edeal.frontline.DataDictionary" %> <%@ page import="com.edeal.frontline.grid.functions.InteractionSyntaxActions" %> <%@ page import="com.edeal.frontline.helper.ContextHelper" %> <%@ taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %> <% EventBean event = (EventBean) request.getAttribute("event"); EventBean eventFromPersonEvent = (EventBean) request.getAttribute("eventFromPersonEvent"); OpportunityBean opportunity = (OpportunityBean) request.getAttribute("opportunity"); PersonEventBean personEvent = (PersonEventBean) request.getAttribute("personEvent"); 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(); InteractionBaseHelper ibh = new InteractionBaseHelper(Interaction); HashMap contextObjectInformation = ibh.getContextObjectInformation(); String typeInterID = ""; String typeInteraction = ""; String titreFen = ""; String codetitreFen = ""; Vector reservationsIDs = null; String resaIDs = ""; Vector todosIDs = null; String tdIDs = ""; Vector correspondancesIDs = null; String corrIDs = ""; try{ reservationsIDs = (Vector)Interaction.getCustomProperty("IntReserv_"); resaIDs = Utils.implodeList(reservationsIDs, ";"); } catch (FieldNotInitializedException e){ } try{ typeInterID = (String)Interaction.getCustomProperty("IntType_"); }catch(FieldNotInitializedException e){ typeInterID = ""; } if(typeInterID.equals(dico.getRefIdByCode("IntType_", "ACT"))){ titreFen = "Todo"; codetitreFen ="FF072"; typeInteraction = "TODO"; try{ correspondancesIDs = (Vector)Interaction.getCustomProperty("IntCorr_"); corrIDs = Utils.implodeList(correspondancesIDs, ";"); } catch (FieldNotInitializedException e){ } } else if (typeInterID.equals(dico.getRefIdByCode("IntType_", "COR"))){ titreFen = "Correspondance"; codetitreFen ="FF09A"; typeInteraction = "CORR"; try{ todosIDs = (Vector)Interaction.getCustomProperty("IntTodo_"); tdIDs = Utils.implodeList(todosIDs, ";"); } catch (FieldNotInitializedException e){ } } else { titreFen = "Interaction"; codetitreFen ="L30B2"; } String id = null; try { id = Interaction.getID(); } catch (FieldNotInitializedException fnie) { } FlLocale locale = FlLocale.getInstance(session); boolean has5columns = Interaction.hasPlaceDisplay() || Interaction.hasOperationDisplay(); Date today = new Date(); long retard = 0; Date dateInt = null; try { dateInt = Interaction.getIntDate(); retard = (today.getTime() - dateInt.getTime()) / 86400000; } catch (FieldNotInitializedException ex) { } long dureeH = 0; long dureeM = 0; Date begHour = null; Date endHour = null; try { begHour = Interaction.getIntTimeBeg(); } catch (FieldNotInitializedException ex) { } try { endHour = Interaction.getIntTimeEnd(); } catch (FieldNotInitializedException ex) { } long dureeMin = 0; if(begHour != null && endHour != null) { dureeMin = (endHour.getTime() - begHour.getTime()) / 60000; dureeH = dureeMin / 60; dureeM = dureeMin % 60; } String statusId = null; try { statusId = Interaction.getIntStiID(); } catch (FieldNotInitializedException ex) { } String status = ""; try { status = dico.getRefCode("IntStiID", statusId); } catch (FrontlineException ex) { logger.error("Error occurred during int status recovering with int status id '"+statusId+"'",ex); } //category code String catCode = null; try{ catCode = (String) dico.getRefDisp("Acv", "Te2", Interaction.getIntAtvID()); } catch (FrontlineException e){ } //category code String subCatCode = null; try{ subCatCode = (String) dico.getRefCode("Acv", null, Interaction.getIntAtvID()); } catch (FrontlineException e){ } boolean isIntExceptionalCostActive = SalesInvestBean.isIntExceptionalCostActive(context); String activite = null; try { activite = Interaction.getIntAtvID(); } catch (FieldNotInitializedException fnie) { } String cpgID = null; try { cpgID = Interaction.getIntCpgID(); } catch (FieldNotInitializedException fnie) { } String intPlace = null; try { intPlace = Interaction.getIntPlace(); } catch (FieldNotInitializedException fnie) { } Vector corresList = null; try { corresList = Interaction.getIntCorID(); } catch (FieldNotInitializedException fnie) { } String intReport = null; try { intReport = Interaction.getIntReport(); } catch (FieldNotInitializedException fnie) { } intReport = intReport == null ? "" : intReport; boolean isGeoLocalized = true; try { Interaction.getIntGeoCodeStatusID(); } catch (FieldNotInitializedException e) { isGeoLocalized = false; } String solicitationID = null; try { solicitationID = (String) Interaction.getCustomProperty("IntSolicitation_"); } catch (FieldNotInitializedException e) { } String sentmailID = null; String msgContent = ""; String startingFlag = "Content-Transfer-Encoding: "; int startingFlaglength = 0; MessagesBean msgBean = null; boolean decode = false; try { sentmailID = (String) Interaction.getIntMsgID(); if(sentmailID != null) { msgBean = new MessagesBean( sentmailID , context); msgContent = msgBean.getMsgBody(); int indexDeb = -1; indexDeb = msgContent.indexOf(startingFlag+"7bit");//BASE64 QUOTED-PRINTABLE 8BIT 7BIT BINARY x-token if(indexDeb>=0){ startingFlaglength = startingFlag.length() + "7bit".length(); }else{ indexDeb = msgContent.indexOf(startingFlag+"8bit"); if(indexDeb>=0){ startingFlaglength = startingFlag.length() + "8bit".length(); }else{ decode = true; indexDeb = msgContent.indexOf(startingFlag+"quoted-printable"); if(indexDeb>=0){ startingFlaglength = startingFlag.length() + "quoted-printable".length(); }else{ decode = false; indexDeb = msgContent.indexOf(startingFlag+"binary"); if(indexDeb>=0){ startingFlaglength = startingFlag.length() + "binary".length(); }else{ indexDeb = msgContent.indexOf(startingFlag+"base64"); if(indexDeb>=0){ startingFlaglength = startingFlag.length() + "base64".length(); }else{ indexDeb = msgContent.indexOf(startingFlag+"x-token"); if(indexDeb<0) throw new Exception("");//We can not translate the MessageBody ! else{ startingFlaglength = startingFlag.length() + "x-token".length(); } } } } } } indexDeb = indexDeb + startingFlaglength; msgContent = msgContent.substring(indexDeb); int indexFin = msgContent.indexOf("------"); msgContent = msgContent.substring(0 , indexFin); if(decode){ String msgContent2 = msgBean.getMsgBody(); msgContent = msgContent2.substring(msgContent2.indexOf(msgContent)+msgContent.length()+"------".length()); indexDeb = msgContent.indexOf(startingFlag+"quoted-printable"); startingFlaglength = startingFlag.length() + "quoted-printable".length(); indexDeb = indexDeb + startingFlaglength; msgContent = msgContent.substring(indexDeb); indexFin = msgContent.indexOf("------"); msgContent = msgContent.substring(0 , indexFin); try{ //msgContent = MimeUtility.decodeText(msgContent); InputStream inst = new ByteArrayInputStream(msgContent.getBytes()); inst.close(); inst = MimeUtility.decode(inst, "quoted-printable"); StringWriter writer = new StringWriter(); IOUtils.copy(inst, writer, "UTF-8"); msgContent = writer.toString(); }catch(Exception ee){ logger.error(ee.getMessage()); ee.printStackTrace(); } } } } catch (Exception e) { //logger.error(e.getMessage()); //e.printStackTrace(); try{ msgContent = msgBean.getMsgBody(); msgContent = e.getMessage() + "
" + msgContent; }catch(Exception e2){ //logger.error(e2.getMessage()); //e2.printStackTrace(); } } /* 0041739: Relance de correspondance http://u-project2.umanis.com/view.php?id=41739 */ String intParentID; try{ intParentID = Interaction.getIntParentID(); }catch(FieldNotInitializedException fne){ intParentID = null; } %> ">
<%} else { if(typeInteraction.equals("CORR")){%> <%}%> <% } %> <%---------------------- Tester s'il faut afficher la liste des correspondants en dehors du cas d'une TODO------------------------%> <% String correspondents = ""; if(typeInteraction.equals("CORR")){ correspondents = InteractionSyntaxActions.getIntCorrespondentHtml(session,context,id); %> "/> "/> <% if (solicitationID != null) { %> "/> <%} %> <%} %> <%---------------------- Seulement si c'est une TODO------------------------%> <% if(typeInteraction.equals("TODO")){%> "/> <%}%> <%---------------------- Seulement si c'est une TODO------------------------%>
<% if (Interaction.hasTimePeriodDisplay()) { String begHourS = Utils.formatToWebTime(session, begHour, true); String endHourS = Utils.formatToWebTime(session, endHour, true); boolean isMorning = false; boolean isAfternoon = false; boolean isAllDay = false; if ("08:30:00".equals(begHourS) && "12:00:00".equals(endHourS)) { isMorning = true; } else if ("14:00:00".equals(begHourS) && "17:30:00".equals(endHourS)) { isAfternoon = true; } else if ("08:30:00".equals(begHourS) && "17:30:00".equals(endHourS)) { isAllDay = true; } if (isMorning) { %> <% } else if (isAfternoon) { %> <% } else if (isAllDay) { %> <% } %>
<%=correspondents%>
"/> "/> "/> <% if(intParentID!=null){ %> "/> <% } %>
<% if(sentmailID != null) { %>
" nbPix="32"> <%=msgContent %>
<%} %> " nbPix="32"> <%---------------------- Seulement si c'est une TODO------------------------%> <% if(typeInteraction.equals("TODO")){%> " /> <%}%> <%---------------------- Seulement si c'est une Correspondance------------------------%> <% if(typeInteraction.equals("CORR")){%> " /> <%}%> " > <%---------------------- Seulement si c'est une Correspondance------------------------%> <% if(typeInteraction.equals("CORR")){%> " /> <%}%> <%---------------------- Seulement si c'est une Correspondance------------------------%> <% if(typeInteraction.equals("CORR")){ String TabIntAssociees = null; try { TabIntAssociees = context.getContextParameter("Sales.Interaction.Renvoi.TabIntAssociees"); } catch (Exception e) { } if(TabIntAssociees!=null && "true".equalsIgnoreCase(TabIntAssociees)){ %> " /> <%}}%>