<%@language="javascript"%>
<% /*
     $Revision$
     $Id$

    File:           bes_srtprod_prijs_list.asp
    Description:    Toont alle prijzen van een artikel
    Parameters:     srtprod_key
    Context:        embedded in bes_srtprod frame
    Noot:

*/ %>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="../Shared/resultset_table_v2.inc" -->
<%
FCLTHeader.Requires({ js: ["jquery-ui.js"] });

var srtprod_key = getQParamInt("srtprod_key");
var outputmode = getQParamInt("outputmode", 0);
var showall = getQParamInt("showall", 0) == 1;

var authparams = user.checkAutorisation("WEB_BESMSU");
%>

<html>
  <head>
<%  FCLTHeader.Generate({outputmode: outputmode}); %>
    <script>
        function bes_edit(row)
        {
          var srtprod_prijs_key = row.getAttribute("ROWKEY");
          var url = "./bes_srtprod_prijs.asp?srtprod_key=<%=srtprod_key%>&srtprod_prijs_key="+srtprod_prijs_key;
          FcltMgr.openModalDetail(url, '<%=L("lcl_bes_prijsedit")%>', {callback: FcltMgr.reload } );
        }
    </script>
  </head>

  <body>
<%
    var sql = " SELECT b.bes_srtprod_prijs_key,"
            + "        b.bes_srtprod_prijs_inkprijs,"
            + "        b.bes_srtprod_prijs_prijs,"
            + "        b.bes_srtprod_prijs_prio,"
            + "        b.bes_srtprod_prijs_vervaldatum"
            + "   FROM bes_srtprod_prijs b"
            + "  WHERE b.bes_srtprod_key = " + srtprod_key
            + "  ORDER BY bes_srtprod_prijs_vervaldatum";

    // TODO: gebruiken en actuele prijs highlighten?
    function fnrowClass(oRs)
    {
        // if laatste?
        return "expired2"; // Te laat
    }

    addButton = {};
    //if (canAdd)
    {
      var addurl = "./bes_srtprod_prijs.asp?srtprod_key=" + srtprod_key;
      addButton = [{ icon: "plus.png", title: L("lcl_bes_prijsadd"), action: "FcltMgr.openModalDetail('" + addurl + "', '" + L("lcl_bes_prijsadd") + "', {callback: FcltMgr.reload })" }]
    }

    var rst = new ResultsetTable({ sql: sql,
                                   keyColumn: "bes_srtprod_prijs_key",   //dummy
                                   ID: "besprijstable",
                                   showAll: showall,
                                   outputmode: outputmode,
                                   //rowData: fnrowData,
                                   //rowClass: fnrowClass,
                                   title: L("lcl_bes_prijsverloop"),
                                   buttons: addButton
                                 });

    rst.addColumn(new Column({caption: L("lcl_bes_srtdeel_prijs_prijs"),       content: "bes_srtprod_prijs_prijs",       datatype: "currency"}));
    rst.addColumn(new Column({caption: L("lcl_bes_srtdeel_prijs_inkprijs"),    content: "bes_srtprod_prijs_inkprijs",    datatype: "currency"}));
    rst.addColumn(new Column({caption: L("lcl_bes_srtdeel_prijs_vervaldatum"), content: "bes_srtprod_prijs_vervaldatum", datatype: "date"}));

    rst.addAction({ action: "bes_edit", caption: L("lcl_edit"), isDefault: true});

    var cnt = rst.processResultset();
%>
  </body>
</html>
