package org.apache.jsp.sales.productOpportunity; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*; import com.edeal.frontline.ProductBean; import com.edeal.frontline.DataDictionary; import com.edeal.frontline.FieldNotInitializedException; import com.edeal.frontline.FrontlineException; import com.edeal.frontline.AccessDeniedException; import com.edeal.frontline.OpportunityBean; import com.edeal.frontline.FlContext; import com.edeal.frontline.navigation.FlRequest; import java.util.Vector; import java.util.Hashtable; import java.text.DecimalFormat; import com.edeal.frontline.FlLocale; import com.edeal.frontline.Utils; public final class prodOppsTable_005fajax_jsp extends org.apache.jasper.runtime.HttpJspBase implements org.apache.jasper.runtime.JspSourceDependent { private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory(); private static java.util.List _jspx_dependants; private javax.el.ExpressionFactory _el_expressionfactory; private org.apache.AnnotationProcessor _jsp_annotationprocessor; public Object getDependants() { return _jspx_dependants; } public void _jspInit() { _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory(); _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName()); } public void _jspDestroy() { } public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("text/plain;charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); /****************************************************************************** * 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. ******************************************************************************/ 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){ } out.write("var f = document.getElementById('ProdOppTable');\n"); out.write("f.innerHTML = '"); out.print( tableBuf.toString() ); out.write("';\n"); out.write("\t"); if(presenceArt) { out.write("\n"); out.write("\tdocument.forms[0].presenceArticles.value ='true';\n"); out.write("\t"); } out.write("\n"); out.write("try {\n"); out.write("\tdocument.forms[0].total.value = '"); out.print( moneyFormat.format(totalPrice) ); out.write("';\n"); out.write("\tdocument.forms[0].totalHT.value = '"); out.print( moneyFormat.format(totalHT) ); out.write("';\n"); out.write("\tdocument.forms[0].totalTVA.value = '"); out.print( moneyFormat.format(totalTVA) ); out.write("';\n"); out.write("\tdocument.forms[0].totalTPF.value = '"); out.print( moneyFormat.format(totalTPF) ); out.write("';\n"); out.write("} catch (error) {\n"); out.write("}\n"); } catch (Throwable t) { if (!(t instanceof SkipPageException)){ out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) {} if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); else log(t.getMessage(), t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } } }