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

    File:        alg_srtruimte_search_list.asp
    Description: Vangt de parameters van alg_srtruimte_search op en verwerkt die tot een lijst
    Parameters:
    Context:     Vanuit alg_srtruimte_search.asp
    Note:
*/ %>

<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/resultset_table_v2.inc" -->

<%
var searchtext = getQParam("searchtext", null);
//var fkdmodule = getQParamSafe("fkdmodule", -1);

var outputmode = getQParamInt("outputmode", 0); //  0 = screen, 1 = print, 2 = excel etc
var showall = getQParamInt("showall", 0) == 1;

var authparams = user.checkAutorisation("WEB_ALGMSU");

%>
<html>
  <head>
<%
FCLTHeader.Generate({outputmode: outputmode});
%>

<script>
    function fkd_edit(row)
    {
        var srtruimte_key = row.getAttribute("ROWKEY");
        var url = "appl/alg/alg_srtruimte.asp?alg_srtruimte_key="+srtruimte_key;
        FcltMgr.openDetail(url, "<%=L("lcl_alg_srtruimte_details")%>", {callback: FcltMgr.reload } );
    }
</script>
  </head>

  <body>
<%

    var sql = "SELECT sr.alg_srtruimte_key"
            + "     , sr.alg_srtruimte_omschrijving"
            + "     , sr.alg_srtruimte_prijs"
            + "     , sr.alg_srtruimte_prijs2"
            + "     , sr.alg_srtruimte_prijs3"
            + "     , sr.alg_srtruimte_prijs4"
            + "     , sr.alg_srtruimte_prijs5"
            + "     , sr.alg_srtruimte_code"
            + "     , CASE  WHEN sr.prs_bevat_werkplek = 1"
                        + " THEN " + safe.quoted_sql(L("lcl_yes"))
                        + " ELSE " + safe.quoted_sql(L("lcl_no"))
                        + " END bevat_werkplek"
            + "     , CASE  WHEN sr.prs_verhuurbaar = 1"
                        + " THEN " + safe.quoted_sql(L("lcl_yes"))
                        + " ELSE " + safe.quoted_sql(L("lcl_no"))
                        + " END verhuurbaar"
            + "     , sr.alg_srtruimte_t_uitvoertijd.tijdsduur tijdsduur"
            + "     , sr.alg_srtruimte_t_uitvoertijd.eenheid   eenheid"
            + "  FROM alg_srtruimte sr"
            + " WHERE sr.alg_srtruimte_verwijder IS NULL"
            + (searchtext
              ? "  AND sr.alg_srtruimte_upper LIKE " + safe.quoted_sql_wild("%" + searchtext + "%")
              : ""
              )
            + " ORDER BY sr.alg_srtruimte_omschrijving";

    function fnUitvoertijdKolom(oRs)
    {
        var tmp = "";
        if (oRs("tijdsduur").Value)
          tmp = oRs("tijdsduur").Value + " " + (oRs("eenheid").Value == "U" ? L("lcl_mld_hours") : L("lcl_mld_days"))

        return tmp;
    }

    buttons = {};
    //if (canAdd)
    {
      var addurl = "appl/alg/alg_srtruimte.asp?mode=edit";
      buttons = [{ icon: "plus.png", title: L("lcl_add"), action: "FcltMgr.openDetail('" + addurl + "', '" + L("lcl_add") + "', {callback: FcltMgr.reload })" }]
    }

    var rst = new ResultsetTable({ sql: sql,
                                   keyColumn: "alg_srtruimte_key",
                                   ID: "algsrtruimtetable",
                                   showAll: showall,
                                   outputmode: outputmode,
                                   title: L("lcl_menu_alg_ruimtefuncties"),
                                   buttons: buttons
                                 });

    rst.addColumn(new Column({caption: "Key",                       content: "alg_srtruimte_key"}));
    rst.addColumn(new Column({caption: L("lcl_descr"),              content: "alg_srtruimte_omschrijving"}));
    rst.addColumn(new Column({caption: L("lcl_alg_alg_tarief"),     content: "alg_srtruimte_prijs",  datatype: "currency"}));
    rst.addColumn(new Column({caption: L("lcl_alg_alg_tariefA"),    content: "alg_srtruimte_prijs2", datatype: "currency"}));
    rst.addColumn(new Column({caption: L("lcl_alg_alg_tariefB"),    content: "alg_srtruimte_prijs3", datatype: "currency"}));
    rst.addColumn(new Column({caption: L("lcl_alg_alg_tariefC"),    content: "alg_srtruimte_prijs4", datatype: "currency"}));
    rst.addColumn(new Column({caption: L("lcl_alg_alg_tariefD"),    content: "alg_srtruimte_prijs5", datatype: "currency"}));
    rst.addColumn(new Column({caption: L("lcl_alg_srtruimte_code"), content: "alg_srtruimte_code"}));
    rst.addColumn(new Column({caption: L("lcl_prs_has_workplace"),  content: "bevat_werkplek"}));
    rst.addColumn(new Column({caption: L("lcl_prs_rentable"),       content: "verhuurbaar"}));
    rst.addColumn(new Column({caption: L("lcl_mld_stduitvoertijd"), content: fnUitvoertijdKolom}));

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

    var cnt = rst.processResultset();

%>
  </body>
</html>
