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

    File:               prs_dienstloc_list.asp
    Description:        Lijst van geleverde diensten door bedrijf berijf_key en/of op locatie locatie_key
    Parameters:         locatie_key (optioneel)
                        bedrijf_key (optioneel)
    Context:            Submit van prs_dienstloc_search.asp
    Note:

*/ %>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="../Shared/resultset_table_v2.inc" -->
<!-- #include file="../Shared/json2.js" -->

<%
var bedrijf_key = getQParamInt("bedrijf_key", -1);
var locatie_key = getQParamInt("locatie_key", -1);

FCLTHeader.Requires({plugins:["jQuery"],
                          js: []})

    function fnrowData(oRs)
      {
        var dienst_key        = oRs("prs_dienst_key").value;

        var data = {dienst_key:dienst_key};

        return JSON.stringify(data);
      }
%>
<html>
<head>
<% FCLTHeader.Generate(); %>
<script>
 function DienstLocEdit(row)
  {
    var prsData = eval('(' + row.getAttribute("ROWDATA") + ')');
    var url = "appl/prs/prs_dienst.asp?mode=viewUpdate&dienst_key="+prsData.dienst_key+"&bedrijf_key=<%=bedrijf_key%>";
    FcltMgr.openDetail(url, "");
  }
</script>
</head>

<body id="listbody">
<%
var autfunction = 'WEB_PRSMSU';
var authparams = user.checkAutorisation(autfunction);

var canAdd = (authparams.PRSwritelevel < 9);

  var sql = "SELECT prs_dienst_key, "
          + lcl.xsqla('prs_dienst_omschrijving', 'prs_dienst_key')
          + "  FROM prs_dienst "
          + " WHERE prs_dienst_key IN (SELECT dl.prs_dienst_key "
          + "                            FROM prs_bedrijfdienstlocatie dl "
          + "                           WHERE dl.prs_bedrijf_key = " + bedrijf_key + ") "

  var addButton = [];
  var addurl = "appl/prs/prs_dienst.asp?bedrijf_key=" + bedrijf_key;
  if (canAdd)
  {
      addButton.push({ icon: "page_refresh.png", title: L("lcl_refresh"), action: "FcltMgr.reload()" });
      addButton.push({ icon: "plus.png", title: L("lcl_add"), action: "FcltMgr.openDetail('" + addurl + "', '" + L("lcl_add") + "')" });
  }

    var rst = new ResultsetTable({ sql: sql,
                                   ID: "contacttable",
                                   noPrint:true,
                                   title: L("lcl_prs_companies_dienst_title"),
                                   rowData: fnrowData,
                                   keyColumn: "prs_dienst_key",
                                   buttons: addButton
                                 });

    rst.addColumn(new Column({caption: L("lcl_prs_companies_dienst"), content: "prs_dienst_omschrijving"}));
    rst.addAction({ action: "DienstLocEdit", caption: L("lcl_edit"), isDefault: true});
    rst.processResultset();
%>
</body>
</html>
