<%@page import="com.edeal.frontline.ProductBean"%> <%@page import="com.edeal.frontline.DataDictionary"%> <%@page import="com.edeal.frontline.FieldNotInitializedException"%> <%@page import="com.edeal.frontline.FrontlineException"%> <%@page import="com.edeal.frontline.AccessDeniedException"%> <%@page import="com.edeal.frontline.OpportunityBean"%> <% /****************************************************************************** * Copyright (c) 2000-2006 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" contentType="text/plain;charset=UTF-8"%><%@ page import="com.edeal.frontline.FlContext" %><%@ page import="com.edeal.frontline.navigation.FlRequest" %><%@ page import="java.util.Vector" %><%@ page import="java.util.Hashtable" %><%@ page import="java.text.DecimalFormat" %><%@ page import="com.edeal.frontline.FlLocale" %><%@ page import="com.edeal.frontline.Utils" %><% 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(); boolean listOnly; try { listOnly = Boolean.valueOf(flRequest.getParameter("listOnly")).booleanValue(); } catch (Exception e) { listOnly = true; } DecimalFormat unitPriceFormat = FlLocale.getInstance(session).getDecimalFormat("#,##0.##"); DecimalFormat moneyFormat = FlLocale.getInstance(session).getDecimalFormat("#,##0.##"); DecimalFormat intFormat = FlLocale.getInstance(session).getDecimalFormat("#,##0;- #,##0"); DecimalFormat doubleFormat = FlLocale.getInstance(session).getDecimalFormat("#,##0.##;- #,##0.##"); double totalGross = 0; double totalPrice = 0; double Remise = 0; double totalDiscountM = 0; double totalTVA = 0; double totalTPF = 0; double totalHT = 0; double netApayer = 0; boolean presenceArt = false; Vector prods = (Vector)flRequest.getAttribute("products"); String oppID = (String)flRequest.getAttribute("pOppID"); OpportunityBean opp = new OpportunityBean(oppID, context); double acompte = 0; try{ acompte = (Double)opp.getCustomProperty("OppAcompte_"); }catch(FieldNotInitializedException fe){ } StringBuffer tableBuf = new StringBuffer(); // Construct our table tableBuf.append("
"); tableBuf.append(""); if (prods.size() == 0) { tableBuf.append(""); } else { String height = null; try{ height = flRequest.getContext().getContextParameter("Devis.Thumbnail.Height"); } catch (FrontlineException fex) { height = "50"; } String width = null; try{ width = flRequest.getContext().getContextParameter("Devis.Thumbnail.Width"); } catch (FrontlineException fex) { width = "80"; } tableBuf.append(""); if (!listOnly) { tableBuf.append(""); } tableBuf.append(""); // Product rows boolean doColor = false; for (int cnt = 0; cnt < prods.size(); ++cnt) { Hashtable row = (Hashtable)prods.elementAt(cnt); presenceArt = true; // récup image du produit String imgPrdID = null; imgPrdID = (String)row.get("ProPrdID:PrdPicID"); Double ProPrice = (Double) row.get("ProPrice"); if (ProPrice != null ) { totalPrice += ProPrice.doubleValue(); } Integer ProQuantity = (Integer) row.get("ProQuantity"); Double ProUnitPrice = (Double)row.get("ProUnitPrice"); Double ProMontantHTrem_ = (Double)row.get("ProMontantHTrem_"); Double ProMontantTva_ = (Double)row.get("ProMontantTva_"); Double ProMontantTpf_ = (Double)row.get("ProMontantTpf_"); Double ProUnitHTrem_ = (Double)row.get("ProUnitHTrem_"); try { totalGross += ProQuantity.intValue() * ProUnitPrice.doubleValue(); } catch (NullPointerException e) { } String ProRemise_ =(String)row.get("ProRemise_:Val"); String ProPrdTva_ =(String)row.get("ProPrdTva_:Val"); String ProPrdTva_RefV = (String)row.get("ProPrdTva_"); String codeTVA = ProPrdTva_RefV != null ? dico.getRefCode("ProPrdTva_", ProPrdTva_RefV) : ""; String ProPrdTaxeParafiscale_ =(String)row.get("ProPrdTaxeParafiscale_:Val"); // on additionne les montants de remise de chaque produit if (ProRemise_ != null && ProUnitHTrem_ != null) { Remise = ( ProUnitPrice.doubleValue() - ProUnitHTrem_.doubleValue() ) * ProQuantity ; totalDiscountM += Remise; } // on additionne les montants TVA de chaque produit if (ProMontantTva_ != null ) { totalTVA += ProMontantTva_.doubleValue(); } // on additionne les montants TVA de chaque produit if (ProMontantTpf_ != null ) { totalTPF += ProMontantTpf_.doubleValue(); } // on additionne les montants HT de chaque produit if (ProMontantHTrem_ != null ) { totalHT += ProMontantHTrem_.doubleValue(); } netApayer = totalPrice-acompte; String PrdCode = (String)row.get("ProPrdID:PrdCode"); String PrdDesignation = (String)row.get("ProDesignation"); String prdid = (String)row.get("ProPrdID"); try{ String prdnamelng_ = (String)ProductBean.lookup(context, "PrdNamelng_", prdid); PrdDesignation = (String)dico.getRefDisp(session, "Rd_", "Te1", prdnamelng_); }catch(Exception e){ logger.warn(e.getMessage()); } tableBuf.append(""); if (!listOnly) { tableBuf.append(""); } if (imgPrdID != null) { tableBuf.append(""); } else { tableBuf.append(""); } tableBuf.append(""); doColor = !doColor; } // Total - headers tableBuf.append(""); tableBuf.append(""); if (!listOnly) { tableBuf.append(""); } else { tableBuf.append(""); } tableBuf.append(""); tableBuf.append(""); if (!listOnly) { tableBuf.append(""); } tableBuf.append("
"); tableBuf.append(Utils.getMessage(session, "L0001", true, "Aucune entrée disponible")); tableBuf.append("
 "); tableBuf.append(Utils.getMessage(session, "F600A", true, "Image")); tableBuf.append(""); tableBuf.append(Utils.getMessage(session, "F2000", true, "Code")); tableBuf.append(""); tableBuf.append(Utils.getMessage(session, "F203F", true, "Désignation")); tableBuf.append(""); tableBuf.append(Utils.getMessage(session, "F3023", true, "P. U. HT")); tableBuf.append(""); tableBuf.append(Utils.getMessage(session, "LF18A", true, "Quantité facturée")); tableBuf.append(""); tableBuf.append(Utils.getMessage(session, "F3025", true, "Remise sur P.U")); tableBuf.append(""); tableBuf.append(Utils.getMessage(session, "FF132", true, "P. U. HT Après Remise")); tableBuf.append(""); tableBuf.append(Utils.getMessage(session, "FF134", true, "Montant HT")); tableBuf.append(""); tableBuf.append(Utils.getMessage(session, "FF130", true, "TVA à appliquer")); tableBuf.append(""); tableBuf.append(Utils.getMessage(session, "FF140", true, "Montant TVA")); tableBuf.append(""); tableBuf.append(Utils.getMessage(session, "FF1F0", true, "TPF à appliquer")); tableBuf.append(""); tableBuf.append(Utils.getMessage(session, "FF1F1", true, "Montant TPF")); tableBuf.append(""); tableBuf.append(Utils.getMessage(session, "F3026", true, "Prix net")); tableBuf.append(""); tableBuf.append(Utils.getMessage(session, "", true, "Code TVA")); tableBuf.append("
 "); tableBuf.append(""); tableBuf.append("\"\""); tableBuf.append(""); tableBuf.append(""); if (listOnly) { tableBuf.append(""); } tableBuf.append(PrdCode == null ? " " : Utils.formatToJavascript(PrdCode)); if (listOnly) { tableBuf.append(""); } tableBuf.append(""); tableBuf.append(PrdDesignation == null ? " " : Utils.formatToJavascript(PrdDesignation)); tableBuf.append(""); tableBuf.append(ProUnitPrice == null ? " " : unitPriceFormat.format(ProUnitPrice.doubleValue()) + " €"); tableBuf.append(""); tableBuf.append(ProQuantity == null ? " " : intFormat.format(ProQuantity.intValue())); tableBuf.append(""); tableBuf.append(ProRemise_ == null ? " " : Utils.formatToJavascript(ProRemise_)); tableBuf.append(""); tableBuf.append( ProUnitHTrem_== null ? " " : unitPriceFormat.format(ProUnitHTrem_.doubleValue()) + " €"); tableBuf.append(""); tableBuf.append( ProMontantHTrem_ == null ? " " : unitPriceFormat.format(ProMontantHTrem_.doubleValue()) + " €"); tableBuf.append(""); tableBuf.append(ProPrdTva_ == null ? " " : Utils.formatToJavascript(ProPrdTva_)); tableBuf.append(""); tableBuf.append(ProMontantTva_ == null ? " " : unitPriceFormat.format(ProMontantTva_.doubleValue()) + " €"); tableBuf.append(""); tableBuf.append(ProPrdTaxeParafiscale_ == null ? " " : Utils.formatToJavascript(ProPrdTaxeParafiscale_)); tableBuf.append(""); tableBuf.append(ProMontantTpf_ == null ? " " : unitPriceFormat.format(ProMontantTpf_.doubleValue()) + " €"); tableBuf.append(""); tableBuf.append(ProPrice == null ? " " : moneyFormat.format(ProPrice.doubleValue()) + " €"); tableBuf.append(""); tableBuf.append(ProPrdTva_ == null ? " " : Utils.formatToJavascript(codeTVA)); tableBuf.append("
 
  "); tableBuf.append(Utils.getMessage(session, "FF13D", true, "Acompte")); tableBuf.append(""); tableBuf.append(Utils.getMessage(session, "L3041", true, "Remise totale")); tableBuf.append(""); tableBuf.append(Utils.getMessage(session, "LF18B", true, "Total HT")); tableBuf.append(""); tableBuf.append(Utils.getMessage(session, "LF18C", true, "Total TVA")); tableBuf.append(""); tableBuf.append(Utils.getMessage(session, "LF18E", true, "Total TPF")); tableBuf.append(""); tableBuf.append(Utils.getMessage(session, "LF18D", true, "Total TTC")); tableBuf.append(""); tableBuf.append(Utils.getMessage(session, "FF13E", true, "NET à Payer")); tableBuf.append("
"); } else { tableBuf.append(""); } tableBuf.append(Utils.getMessage(session, "F1058", true, "Total") + " : "); tableBuf.append(""); tableBuf.append(moneyFormat.format(acompte) + " €"); tableBuf.append(""); tableBuf.append(moneyFormat.format(totalDiscountM) + " €"); tableBuf.append(""); tableBuf.append(moneyFormat.format(totalHT) + " €"); tableBuf.append(""); tableBuf.append(moneyFormat.format(totalTVA) + " €"); tableBuf.append(""); tableBuf.append(moneyFormat.format(totalTPF) + " €"); tableBuf.append(""); tableBuf.append(moneyFormat.format(totalPrice) + " €"); tableBuf.append(""); tableBuf.append(moneyFormat.format(netApayer) + " €"); tableBuf.append("
"); try{ opp.setCustomProperty("OppNetApayer_", netApayer); opp.setCustomProperty("OppTotalHT_", totalHT); opp.setCustomProperty("OppTotalTVA_", totalTVA); opp.setCustomProperty("OppTotalTTC_", totalPrice); opp.setCustomProperty("OppTotalTPF_", totalTPF); opp.save(); }catch(AccessDeniedException ae){ }catch(FrontlineException fe){ } %>var f = document.getElementById('ProdOppTable'); f.innerHTML = '<%= tableBuf.toString() %>'; <% if(presenceArt) {%> document.forms[0].presenceArticles.value ='true'; <%}%> try { document.forms[0].total.value = '<%= moneyFormat.format(totalPrice) %>'; document.forms[0].totalHT.value = '<%= moneyFormat.format(totalHT) %>'; document.forms[0].totalTVA.value = '<%= moneyFormat.format(totalTVA) %>'; document.forms[0].totalTPF.value = '<%= moneyFormat.format(totalTPF) %>'; } catch (error) { }