<%@language = "javascript" %> <% /* $Revision$ $Id$ File: bes_assmon_search_list.asp Description: Vangt de parameters van bes_assmon_search op en verwerkt die tot een lijst Parameters: urole Context: Vanuit bes_assmon_search.asp Note: */ %> <% var searchtext = getQParam("searchtext", null); var disc_key = getQParamInt("disc", -1); var srtgroep_keys = getQParamIntArray("srtgroep", []); var lev_keys = getQParamIntArray("lev_keys", []); var bes_peildat1 = getQParamDate("bes_peildat1", null); var bes_peildat2 = getQParamDate("bes_peildat2", null); var matchonly = getQParam("matchonly", "off") == "on"; // *iemand* moet hem leveren var pctkolom = getQParam("pctkolom", "off") == "on"; var outputmode = getQParamInt("outputmode", 0); // 0 = screen, 1 = print, 2 = excel etc var showall = getQParamInt("showall", 0) == 1; var authparams = user.checkAutorisation("WEB_BESMSU"); %>
<% FCLTHeader.Generate({outputmode: outputmode}); %>
<% var lev_sql = // horizontaal "SELECT prs_bedrijf_key," + " prs_bedrijf_naam" + " FROM prs_bedrijf bedr" + " WHERE" if (lev_keys.length) lev_sql += " bedr.prs_bedrijf_key IN (" + lev_keys.join(",") + ")" else lev_sql += " bedr.prs_bedrijf_key IN (SELECT prs_bedrijf_key FROM bes_srtdeel)" lev_sql += " ORDER BY bedr.prs_bedrijf_naam_upper"; var lRs = Oracle.Execute(lev_sql); var leveranciers = {}; while (!lRs.Eof) { //leveranciers.push({ key: oRs("prs_bedrijf_key").Value, naam: oRs("prs_bedrijf_naam").Value }); leveranciers[lRs("prs_bedrijf_key").Value] = lRs("prs_bedrijf_naam").Value; lRs.MoveNext(); } var sql = "SELECT bes_srtprod_key," // vertikaal + " bes_srtgroep_omschrijving," + " bes_srtprod_omschrijving," + " bes.getsrtprodprijs (bes_srtprod_key, "+bes_peildat1.toSQL()+") pprijs"; if (bes_peildat2) { sql += ", bes.getsrtprodprijs (bes_srtprod_key, "+bes_peildat2.toSQL()+") pprijs2"; } for (lev_key in leveranciers) { sql += ", MAX (DECODE (prs_bedrijf_key, " + lev_key + ", prijs, NULL)) Lev" + lev_key; if (bes_peildat2) sql += ", MAX (DECODE (prs_bedrijf_key, " + lev_key + ", prijs2, NULL)) Lev2_" + lev_key; sql += ", MAX (DECODE (prs_bedrijf_key, " + lev_key + ", bes_srtdeel_omschrijving, NULL)) Oms" + lev_key; sql += ", MAX (DECODE (prs_bedrijf_key, " + lev_key + ", bes_srtdeel_key, NULL)) deel" + lev_key; } sql += " FROM (SELECT bsp.bes_srtprod_key," + " bsp.bes_srtprod_omschrijving," + " bsg.bes_srtgroep_omschrijving," + " bsd.bes_srtdeel_omschrijving," + " bes.getsrtdeelprijs (bsd.bes_srtdeel_key, "+bes_peildat1.toSQL()+") prijs," if (bes_peildat2) { sql += " bes.getsrtdeelprijs (bsd.bes_srtdeel_key, "+bes_peildat2.toSQL()+") prijs2,"; } sql += " bsd.bes_srtdeel_key," + " bsd.prs_bedrijf_key" + " FROM bes_srtprod bsp, bes_srtdeel bsd, bes_srtgroep bsg" + " WHERE bsp.bes_srtprod_key = bsd.bes_srtprod_key" + (srtgroep_keys.length>1 || srtgroep_keys[0]>-1 ? " AND bsg.bes_srtgroep_key IN (" + srtgroep_keys.join(",") + ")" : "") + (disc_key>0 ? " AND bsg.ins_discipline_key = " + disc_key : "") + (searchtext?" AND (UPPER(bsp.bes_srtprod_nr) LIKE " + safe.quoted_sql_wild(searchtext + "%") + " OR " + " UPPER(bsp.bes_srtprod_omschrijving) LIKE " + safe.quoted_sql_wild("%"+searchtext + "%") + ")" :"") + " AND bsg.bes_srtgroep_key = bsp.bes_srtgroep_key" + (matchonly&&lev_keys.length?" AND bsd.prs_bedrijf_key IN ("+lev_keys.join(",")+")":"") // *iemand* moet hem leveren + " )" + " GROUP BY bes_srtprod_key," + " bes_srtprod_omschrijving," + " bes_srtgroep_omschrijving" + " ORDER BY bes_srtgroep_omschrijving, " + " bes_srtprod_omschrijving," + " bes_srtprod_key"; /* SELECT bes_srtprod_key, MAX (DECODE (prs_bedrijf_key, 46741, prijs, NULL)) Lev46741, MAX (DECODE (prs_bedrijf_key, 456, prijs, NULL)) Lev456, MAX (DECODE (prs_bedrijf_key, 789, prijs, NULL)) Lev789 FROM (SELECT bsp.bes_srtprod_key, bsd.prs_bedrijf_key, bes.getsrtdeelprijs (bsd.bes_srtdeel_key, NULL) prijs FROM bes_srtprod bsp, bes_srtdeel bsd WHERE bsp.bes_srtprod_key = bsd.bes_srtprod_key) GROUP BY bes_srtprod_key; */ function displaypercent(val1, val2) { if ( val1 && val2 && val1 != val2 ) { var diff = 100*(val2 - val1) / val1; var stl = diff<0?"besprijsdown":"besprijsup"; return ""+(diff>0?"+":"")+safe.displayfloat(diff)+""; } else return "-"; } function fnPrijsverschilP(oRs) { return displaypercent(oRs("pprijs").value, oRs("pprijs2").value); } function fnfnPrijsverschilL(lev_key) { return function (oRs) { var pkol1 = "lev" + lev_key; var pkol2 = "lev2_" + lev_key; return displaypercent(oRs(pkol1).value, oRs(pkol2).value); } } function fnfnLevPrijs(lev_key) { return function (oRs) { if (oRs("deel" + lev_key).Value == null) return ""; // wordt niet geleverd var html = "" + (safe.curr(oRs("lev" + lev_key).Value)||"---") // klikbare streepjes als wel geleverd maar geen prijs + ""; return html; } } function fnfnLevPrijs2(lev_key) { return function (oRs) { var p2 = oRs("lev2_" + lev_key).Value; var stl = ""; if (!pctkolom && p2 != null) { var p1 = oRs("lev" + lev_key).Value; if (p1 != null) { diff = p2 - p1; if (Math.abs(diff) > 0.005) var stl = "class='"+(diff<0?"besprijsdown":"besprijsup") + "'"; } } var html = "" + safe.curr(p2) + ""; return html; } } var rst = new ResultsetTable({ sql: sql, keyColumn: "bes_srtprod_key", ID: "assortimenttable", showAll: showall, outputmode: outputmode, //rowData: fnrowData, //rowClass: fnrowClass, title: L("lcl_bes_assortiment_list") }); rst.addColumn(new Column({caption: L("lcl_bes_srtgroup"), content: "bes_srtgroep_omschrijving"})); rst.addColumn(new Column({caption: L("lcl_bes_srtprod"), content: "bes_srtprod_omschrijving"})); rst.addColumn(new Column({caption: L("lcl_bes_srtprod_prijs_prijs")+(bes_peildat2?L("lcl_bes_peildatum1_suf"):""), content: "pprijs", datatype: "currency"})); if (bes_peildat2) { rst.addColumn(new Column({caption: L("lcl_bes_srtprod_prijs_prijs")+L("lcl_bes_peildatum2_suf"), content: "pprijs2", datatype: "currency"})); if (pctkolom) { rst.addColumn(new Column({caption: L("lcl_bes_verschil_percentage"), content: fnPrijsverschilP, datatype: "currency"})); } } for (lev_key in leveranciers) { rst.addColumn(new Column({caption: safe.html(leveranciers[lev_key])+(bes_peildat2?L("lcl_bes_peildatum1_suf"):""), datatype: "currency", content: fnfnLevPrijs(lev_key), tooltip: "oms" + lev_key })); if (bes_peildat2) { rst.addColumn(new Column({caption: safe.html(leveranciers[lev_key])+L("lcl_bes_peildatum2_suf"), datatype: "currency", content: fnfnLevPrijs2(lev_key), tooltip: "oms" + lev_key })); if (pctkolom) { rst.addColumn(new Column({caption: L("lcl_bes_verschil_percentage"), content: fnfnPrijsverschilL(lev_key), datatype: "currency"})); } } } rst.addAction({ action: "prd_edit", caption: L("lcl_edit"), isDefault: true}); var cnt = rst.processResultset(); %>