<% /*
     $Revision$
     $Id$
*/ %>

<!-- #include file="./Suggest/referentieFilter.inc" -->

<%
// De volgende functies maken de filtertabel met de geselecteerde filterwaarden van het scherm als header van de uitdraai

// NOTE: Hij levert HTML-safe op!
function getRSFilterValueByKey(pTable, pKeys, pLabel)
{ // Levert de filterwaarde(n) op van een multi-selectable selectbox als een HTML tabelregel string
  // Input: pTable: selectie tabel
  //        pKeys:  geselecteerde keys waarvan de omschrijving uit de tabel gehaald wordt
  //        pLabel: label van de opgehaalde waarden
  // Voorbeeld getRSFilterValueByKey("INS_TAB_DISCIPLINE", "7, 4, 25", "Productgroep")
  //           return: <tr>
  //                     <td align="right"><b>Productgroep:&nbsp;</b></td>
  //                     <td align="left">A- Vergader en verblijf<br>A-Archief<br>A-BHV (bedr hulp verlening)</td>
  //                   </tr>
  var firstItem = true;
  var lSep = "<br>";

  var filterValue = '<tr><td class="headerlabel">' + pLabel + ':</td><td class="headerdescr">';

  var sql = getSQLByKey(pTable, pKeys);
  var oRs = Oracle.Execute(sql);
  if (oRs.eof) return "";
  while (!oRs.eof)
  {
    filterValue += (!firstItem? lSep : "") + safe.html(oRs(0).value);
    firstItem = false;
    oRs.MoveNext();
  }
  oRs.close();
  filterValue += "</td></tr>";

  return filterValue;
}

function getRSFilterValueByValue(pValue, pLabel, pshowTime)
{ // // Levert de filterwaarde op als een HTML tabelregel string
  // Input: pValue: filterwaarde
  //        pLabel: label van de filter waarden
  // Voorbeeld getRSFilterValueByValue("001", "Locatie")
  //           return: <tr>
  //                     <td align="right"><b>Locatie:&nbsp;</b></td>
  //                     <td align="left">001</td>
  //                   </tr>
  var lvalue = "";
  switch(typeof pValue)
  {
    // Plaatsgegevens
    case "undefined":  { lvalue = lvalue;
                         break;
                       }
    case "number":     { if (!isNaN(pValue)) // Reason: to avoid printing string 'NaN' for invalid/empty number fields
                           lvalue = "" + pValue;
                         break;
                       }
    case "date":       { lvalue = "" + (pshowTime? toDateTimeString(pValue) : toDateString(pValue));
                         break;
                       }
    case "object":     { if (pValue instanceof Date)
                           lvalue = "" + (pshowTime? toDateTimeString(pValue) : toDateString(pValue));
                         if (pValue instanceof String)
                           lvalue = "" + pValue;
                         if (pValue instanceof Array)
                           lvalue = "" + pValue.join(", ");
                         break;
                       }
    default:           { lvalue = "" + pValue;
                         break;
                       }
  }

  var filterValue = '';
  if (lvalue != "")
  {
    filterValue = '<tr><td class="headerlabel">' + pLabel + ':</td><td class="headerdescr">'
                + safe.html(lvalue)
                + '</td></tr>';
  }

  return filterValue;
}

function getSQLByKey (pTable, pKeys)
{ // Get SQL-Query for printing selection criteria:
  // SAMPLE  getSQLByKey ('INS_TAB_DISCIPLINE', '7, 4, 25')
  //         returns: "SELECT lcl.x(ins_discipline_omschrijving...) "+
  //                  "FROM ins_tab_discipline "+
  //                  "WHERE ins_discipline_key IN ( 7, 4, 25) "+
  //                  "ORDER BY upper(lcl.x(ins_discipline_omschrijving...))"
  //
  var sql = '';
  if ((typeof(pKeys) != 'undefined' ) && (pKeys != ''))
    var lKeys = "" + pKeys;
  else
    var lKeys = "-1";

  switch(pTable)
  {
    case "INS_TAB_DISCIPLINE": {
      sql = "SELECT " + lcl.xsqla('ins_discipline_omschrijving', 'ins_discipline_key')
          + " FROM ins_tab_discipline"
          + " WHERE ins_discipline_key IN (" + lKeys + ")"
          + " ORDER BY UPPER("+lcl.xsql('ins_discipline_omschrijving', 'ins_discipline_key')+")";
      break;
    }
    //
    case "INS_SRTDISCIPLINE": {
      sql = "SELECT " + lcl.xsqla('ins_srtdiscipline_omschrijving', 'ins_srtdiscipline_key')
          + " FROM ins_srtdiscipline"
          + " WHERE ins_srtdiscipline_key IN (" + lKeys + ")"
          + " ORDER BY UPPER("+lcl.xsql('ins_srtdiscipline_omschrijving', 'ins_srtdiscipline_key')+")";
      break;
    }
    //
    case "INS_SRTGROEP": {
      sql = "SELECT " + lcl.xsqla('ins_srtgroep_omschrijving', 'ins_srtgroep_key')
          + " FROM ins_srtgroep "
          + " WHERE ins_srtgroep_key IN (" + lKeys + ")"
          + " ORDER BY UPPER("+lcl.xsql('ins_srtgroep_omschrijving', 'ins_srtgroep_key')+")";
      break;
    }
    //
    case "INS_SRTDEEL": {
      sql = "SELECT " + lcl.xsqla('ins_srtdeel_omschrijving', 'ins_srtdeel_key')
          + " FROM ins_srtdeel"
          + " WHERE ins_srtdeel_key IN (" + lKeys + ")"
          + " ORDER BY UPPER(" + lcl.xsql('ins_srtdeel_omschrijving', 'ins_srtdeel_key')+")";
      break;
    }
    //
    case "INS_SRTCONTROLE": {
      sql = "SELECT " + lcl.xsqla('ins_srtcontrole_omschrijving', 'ins_srtcontrole_key')
          + " FROM ins_srtcontrole"
          + " WHERE ins_srtcontrole_key IN (" + lKeys + ")"
          + " ORDER BY UPPER(" + lcl.xsql('ins_srtcontrole_omschrijving', 'ins_srtcontrole_key')+")";
      break;
    }
    //
    case "BES_SRTGROEP": {
      sql = "SELECT " + lcl.xsqla('bes_srtgroep_omschrijving', 'bes_srtgroep_key')
          + " FROM bes_srtgroep "
          + " WHERE bes_srtgroep_key IN (" + lKeys + ")"
          + " ORDER BY UPPER("+lcl.xsql('bes_srtgroep_omschrijving', 'bes_srtgroep_key')+")";
      break;
    }
    //
    case "BES_SRTDEEL": {
      sql = "SELECT " + lcl.xsqla('bes_srtdeel_omschrijving', 'bes_srtdeel_key')
          + " FROM bes_srtdeel"
          + " WHERE bes_srtdeel_key IN (" + lKeys + ")"
          + " ORDER BY UPPER(" + lcl.xsql('bes_srtdeel_omschrijving', 'bes_srtdeel_key')+")";
      break;
    }
    //
    case "ALG_REGIO": {
      sql = "SELECT alg_regio_omschrijving"
          + " FROM alg_regio "
          + " WHERE alg_regio_key IN (" + lKeys + ")"
          + " ORDER BY alg_regio_upper";
      break;
    }
    //
    case "ALG_DISTRICT": {
      sql = "SELECT alg_district_omschrijving"
          + " FROM alg_district "
          + " WHERE alg_district_key IN (" + lKeys + ")"
          + " ORDER BY alg_district_upper";
      break;
    }
    //
    case "ALG_LOCATIE": {
      sql = "SELECT alg_locatie_omschrijving"
          + " FROM alg_locatie "
          + " WHERE alg_locatie_key IN (" + lKeys + ")"
          + " ORDER BY alg_locatie_upper";
      break;
    }
    //
    case "ALG_GEBOUW":
    case "ALG_TERREIN": {
      sql  = "SELECT g.alg_gebouw_omschrijving, alg_gebouw_upper"
           + " FROM  alg_gebouw g"
           + " WHERE alg_gebouw_key IN (" + lKeys + ")"
           + " UNION ALL"
           + " SELECT alg_terreinsector_naam, alg_terreinsector_upper"
           + " FROM  alg_terreinsector "
           + " WHERE alg_terreinsector_key IN (" + lKeys + ")"
           + " ORDER BY 2";
      break;
    }
    //
    case "ALG_SRTTERREINSECTOR": {
      sql = "SELECT " + lcl.xsqla('alg_srtterreinsec_omschrijving', 'alg_srtterreinsec_key')
          + " FROM alg_srtterreinsector "
          + " WHERE alg_srtterreinsector_key IN (" + lKeys + ")"
          + " ORDER BY UPPER("+lcl.xsql('alg_srtterreinsec_omschrijving', 'alg_srtterreinsec_key')+")";
      break;
    }
    //
    case "ALG_SRTGEBOUW": {
      sql = "SELECT " + lcl.xsqla('alg_srtgebouw_omschrijving', 'alg_srtgebouw_key')
          + " FROM alg_srtgebouw "
          + " WHERE alg_srtgebouw_key IN (" + lKeys + ")"
          + " ORDER BY UPPER("+lcl.xsql('alg_srtgebouw_omschrijving', 'alg_srtgebouw_key')+")";
      break;
    }
    //
    case "ALG_VERDIEPING": {
      sql = "SELECT alg_verdieping_code ||'-'|| alg_verdieping_omschrijving"
          + " FROM alG_verdieping "
          + " WHERE alg_verdieping_key IN (" + lKeys + ")"
          + " ORDER BY alg_verdieping_volgnr";
      break;
    }
    //
    case "ALG_RUIMTE": {
      sql = "SELECT alg_ruimte_nr ||"
          + " ' ('|| alg_ruimte_omschrijving ||')'"
          + " FROM alg_ruimte WHERE alg_ruimte_key IN (" + lKeys + ")"
          + " ORDER BY 1";
      break;
    }
    //
    case "ALG_SRTRUIMTE": {
      sql = "SELECT " + lcl.xsqla('alg_srtruimte_omschrijving', 'alg_srtruimte_key')
          + " FROM alg_srtruimte "
          + " WHERE alg_srtruimte_key IN (" + lKeys + ")"
          + " ORDER BY UPPER("+lcl.xsql('alg_srtruimte_omschrijving', 'alg_srtruimte_key')+")";
      break;
    }
    //
    case "PRS_KOSTENPLAATS": {
        sql = "SELECT " + S("prs_kpn_string")
            + " FROM prs_kostenplaats k"
            + " WHERE k.prs_kostenplaats_key IN (" + lKeys + ")"
            + " ORDER BY UPPER(k.prs_kostenplaats_omschrijving)";
      break;
    }
    //
    case "PRS_KOSTENPLAATSGRP": {
        sql = "SELECT ksg.prs_kostenplaatsgrp_oms"
            + " FROM prs_kostenplaatsgrp ksg"
            + " WHERE ksg.prs_kostenplaatsgrp_key IN (" + lKeys + ")"
            + " ORDER BY UPPER(ksg.prs_kostenplaatsgrp_oms)";
      break;
    }
    //
    case "PRS_KOSTENSOORT": {
        sql = "SELECT ks.prs_kostensoort_oms || '-' || " + lcl.xsql("ks.prs_kostensoort_opmerking", "ks.prs_kostensoort_key") + " kostensoort"
            + " FROM prs_kostensoort ks"
            + " WHERE ks.prs_kostensoort_key IN (" + lKeys + ")"
            + " ORDER BY UPPER(ks.prs_kostensoort_oms)";
      break;
    }
    case "PRS_KOSTENSOORTGRP": {
        sql = "SELECT " + lcl.xsqla('prs_kostensoortgrp_oms', 'prs_kostensoortgrp_key')
            + " FROM prs_kostensoortgrp"
            + " WHERE prs_kostensoortgrp_key IN (" + lKeys + ")"
            + " ORDER BY UPPER("+lcl.xsql('prs_kostensoortgrp_oms', 'prs_kostensoortgrp_key')+")";
      break;
    }
    //
    case "PRS_WERKPLEK": {
        sql = "SELECT prs_werkplek_omschrijving"
            + " FROM prs_werkplek"
            + " WHERE prs_werkplek_key IN (" + lKeys + ")"
            + " ORDER BY prs_werkplek_volgnr";
      break;
    }
    //
    case "PRS_BEDRIJF": {
      sql = "SELECT prs_bedrijf_naam"
          + " FROM prs_bedrijf"
          + " WHERE prs_bedrijf_key IN (" + lKeys + ")"
          + " ORDER BY prs_bedrijf_naam_upper";
      break;
    }
    //
    case "MLD_STDMELDING": {
      sql = "SELECT " + lcl.xsqla('mld_stdmelding_omschrijving','mld_stdmelding_key')
          + " FROM mld_stdmelding"
          + " WHERE mld_stdmelding_key IN (" + lKeys + ")"
          + " ORDER BY UPPER("+lcl.xsql('mld_stdmelding_omschrijving','mld_stdmelding_key')+")";
      break;
    }
    //
    case "MLD_V_UITVOERENDE": {
      sql = "SELECT naam"
          + " FROM mld_v_uitvoerende"
          + " WHERE mld_uitvoerende_key IN (" + lKeys + ")"
          + " ORDER BY upper(naam)";
      break;
    }
    //
    case "MLD_TYPEOPDR": {
      sql = "SELECT " + lcl.xsqla('mld_typeopdr_omschrijving', 'mld_typeopdr_key')
          + "  FROM mld_typeopdr"
          + " WHERE mld_typeopdr_key IN (" + lKeys + ")"
          + " ORDER BY UPPER("+ lcl.xsql('mld_typeopdr_omschrijving', 'mld_typeopdr_key')+")";
      break;
    }
    //
    case "PRS_AFDELING": {
      sql = "SELECT " + S("prs_dep_string")
          + " FROM prs_v_afdeling d "
          + " WHERE d.prs_afdeling_key IN (" + lKeys + ")"
          + " ORDER BY prs_afdeling_upper";
      break;
    }
    //
    case "PRS_DIENST": {
      sql = "SELECT " + lcl.xsql('prs_dienst_omschrijving', 'prs_dienst_key')
          + " FROM prs_dienst d "
          + " WHERE d.prs_dienst_key IN (" + lKeys + ")"
          + " ORDER BY UPPER(" + lcl.xsql('prs_dienst_omschrijving', 'prs_dienst_key') + ")";
      break;
    }
    //
    case "PRS_PERSLID": {
        sql = "SELECT " + S("prs_pers_string")
            + " FROM prs_perslid p "
            + " WHERE prs_perslid_key IN (" + lKeys + ")"
            + " ORDER BY prs_perslid_upper";
      break;
    }
    //
    case "PRS_SRTPERSLID": {
        sql = "SELECT " + lcl.xsqla('prs_srtperslid_omschrijving', 'prs_srtperslid_key')
            + " FROM prs_srtperslid p"
            + " WHERE prs_srtperslid_key IN (" + lKeys + ")"
            + " ORDER BY UPPER("+lcl.xsql('prs_srtperslid_omschrijving', 'prs_srtperslid_key')+")";
      break;
    }
    //
    case "RES_ARTIKEL": {
        sql = "SELECT " + lcl.xsqla('res_artikel_omschrijving', 'res_artikel_key')
            + " FROM res_artikel a"
            + " WHERE res_artikel_key IN (" + lKeys + ")"
            + " ORDER BY UPPER("+lcl.xsqla('res_artikel_omschrijving', 'res_artikel_key')+")";
      break;
    }
    //
    case "PRJ_VERHUISAANVRAAG": {
        sql = "SELECT mld_melding_key || '-' || "+lcl.xsql('stdm.mld_stdmelding_omschrijving','stdm.mld_stdmelding_key')+" prj_verhuisaanvraag_oms "
            + " FROM mld_melding m, mld_stdmelding stdm"
            + " WHERE stdm.mld_stdmelding_key = m.mld_stdmelding_key"
            + " AND mld_melding_key IN (" + lKeys + ")"
            + " ORDER BY 1";
      break;
    }
    //
    case "FAC_PROFIEL": {
        sql = "SELECT fac_profiel_omschrijving"
            + "  FROM fac_profiel"
            + " WHERE fac_profiel_key IN (" + lKeys + ")"
            + " ORDER BY 1";
      break;
    }
    //
    case "FAC_USRDATA": {
        sql = "SELECT " + lcl.xsqla('fac_usrdata_omschr', 'fac_usrdata_key')
            + " FROM fac_usrdata "
            + " WHERE fac_usrdata_key IN (" + lKeys + ")"
            + " ORDER BY fac_usrdata_volgnr, UPPER("+lcl.xsql('fac_usrdata_omschr', 'fac_usrdata_key')+")";
      break;
    }
    //
    case "FIN_FACTUUR_VOOR": {  // TODO vereist vertaling (beetje krom zo?)

        var sql_fac = "(SELECT 'mld_opdr_key' id, 'Opdrachten' label FROM DUAL"
                    + " UNION ALL"
                    + " SELECT 'bes_bestelopdr_key', 'Bestellingen' FROM DUAL"
                    + " UNION ALL"
                    + " SELECT 'cnt_contract_key', 'Contracten' FROM DUAL)";

        sql = " SELECT label"
            + " FROM " + sql_fac
            + " WHERE id IN (" + lKeys + ")"
            + " ORDER BY 1";

      break;
    }
    //
    case "CNT_CONTRACT_NUMMER": {
      sql = "SELECT c.cnt_contract_nummer || ' - ' || b.prs_bedrijf_naam"
          + " FROM cnt_contract c"
          + ", prs_bedrijf b"
          + " WHERE c.cnt_prs_bedrijf_key = b.prs_bedrijf_key"
          + " AND cnt_contract_key IN (" + lKeys + ")";
      break;
    }
    //
    case "CNT_CONTRACT": {
      sql = "SELECT cnt_contract_nummer_intern || '-' || cnt_contract_omschrijving"
          + " FROM cnt_contract c"
          + " WHERE cnt_contract_key IN (" + lKeys + ")"
          + " ORDER BY 1";
      break;
    }
    //
    case "MLD_STDMELDINGGROEP": {
      sql = "SELECT " + lcl.xsqla('mld_stdmeldinggroep_naam', 'mld_stdmeldinggroep_key')
          + "  FROM mld_stdmeldinggroep"
          + " WHERE mld_stdmeldinggroep_key IN (" + lKeys + ")"
          + " ORDER BY 1";
      break;
    }
    //
    case "MLD_BEHANDELGROEP": {
      sql = "SELECT " + lcl.xsqla('mld_behandelgroep_naam', 'mld_behandelgroep_key')
          + "  FROM mld_behandelgroep"
          + " WHERE mld_behandelgroep_key IN (" + lKeys + ")"
          + " ORDER BY 1";
      break;
    }
    //
    default: {
      sql = "SELECT '?' FROM prs_perslid WHERE prs_perslid_key = -1";
      sql = "SELECT '?' FROM dual";
      break;
    }
    //
  }

  return sql;
}

function getRSFilterPlace(lparams)
{
  var lfilterPlace = {content: "", count: 0};
  if (lparams.reg_key && lparams.reg_key > 0)
  {
    lfilterPlace.content += getRSFilterValueByKey("ALG_REGIO", lparams.reg_key, L("lcl_region"));
    lfilterPlace.count++;
  }
  if (lparams.dist_key && lparams.dist_key > 0)
  {
    lfilterPlace.content += getRSFilterValueByKey("ALG_DISTRICT", lparams.dist_key, L("lcl_district"));
    lfilterPlace.count++;
  }
  if (lparams.loc_key && lparams.loc_key > 0)
  {
    lfilterPlace.content += getRSFilterValueByKey("ALG_LOCATIE", lparams.loc_key, L("lcl_location"));
    lfilterPlace.count++;
  }
  if (lparams.bld_key && lparams.bld_key > 0)
  {
    lfilterPlace.content += getRSFilterValueByKey("ALG_GEBOUW", lparams.bld_key, L("lcl_building"));
    lfilterPlace.count++;
  }
  if (lparams.terr_key && lparams.terr_key > 0)
  {
    lfilterPlace.content += getRSFilterValueByKey("ALG_TERREIN", lparams.terr_key, L("lcl_terra"));
    lfilterPlace.count++;
  }
  if (lparams.flr_key && lparams.flr_key > 0)
  {
    lfilterPlace.content += getRSFilterValueByKey("ALG_VERDIEPING", lparams.flr_key, L("lcl_floor"));
    lfilterPlace.count++;
  }
  if (lparams.room_key && lparams.room_key > 0)
  {
    lfilterPlace.content += getRSFilterValueByKey("ALG_RUIMTE", lparams.room_key, L("lcl_room"));
    lfilterPlace.count++;
  }
  if (lparams.wpl_key && lparams.wpl_key > 0)
  {
    lfilterPlace.content += getRSFilterValueByKey("PRS_WERKPLEK", lparams.wpl_key, L("lcl_workplace"));
    lfilterPlace.count++;
  }

  return lfilterPlace;
}

function getRSFilterBesStatus(lparams, lStatusSep)
{
  var lfilterStatus = "";
  if (lparams.besstafg) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_bes_afgewezen");
  if (lparams.besstnew) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_bes_new");
  if (lparams.besstfia) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_bes_gefiatteerd");
  if (lparams.besstacc) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_bes_geaccepteerd");
  if (lparams.besstbes) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_bes_besteld");
  if (lparams.besstlev) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_bes_geleverd");
  if (lparams.besstver) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_bes_verwerkt");
  if (lparams.besstmix) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_bes_mixed");

  lfilterStatus = getRSFilterValueByValue(lfilterStatus, L("lcl_bes_RFOs_status"));
  return lfilterStatus;
}

function getRSFilterBesOpdrStatus(lparams, lStatusSep)
{
  var lfilterStatus = "";
  if (lparams.besopdrstafg) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_bes_ord_afgewezen");
  if (lparams.besopdrstnew) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_bes_ord_new");
  if (lparams.besopdrstbeh) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_bes_ord_inbehandeling");
  if (lparams.besopdrstbes) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_bes_ord_inbestelling");
  if (lparams.besopdrstbev) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_bes_ord_bevestigd");
  if (lparams.besopdrstlev) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_bes_ord_geleverd");
  if (lparams.besopdrstver) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_bes_ord_verwerkt");

  lfilterStatus = getRSFilterValueByValue(lfilterStatus, L("lcl_bes_orders_status"));
  return lfilterStatus;
}

function getRSFilterBezOpdrStatus(lparams, lStatusSep)
{
  var lfilterStatus = "";
  if (lparams.bezExpect) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_vis_expected");
  if (lparams.bezInside) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_vis_inside");
  if (lparams.bezDepart) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_vis_departed")
  if (lparams.bezClosed) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_vis_processed");

  lfilterStatus = getRSFilterValueByValue(lfilterStatus, L("lcl_bes_Bes_status"));
  return lfilterStatus;
}

function getRSFilterCntStatus(lparams, lStatusSep)
{
  var lfilterStatus = "";
  if (lparams.cntAct) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_cnt_topical");
  if (lparams.cntRap) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_cnt_warn");
  if (lparams.cntOpz) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_cnt_cancel");
  if (lparams.cntVerl) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_cnt_past");

  lfilterStatus = getRSFilterValueByValue(lfilterStatus, L("lcl_cnt_status"));
  return lfilterStatus;
}

function getRSFilterInsStatus(lparams, lStatusSep)
{
  var lfilterStatus = "";
  if (lparams.insLentOut) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_obj_lent_out");
  if (lparams.insAvail) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_obj_available");

  lfilterStatus = getRSFilterValueByValue(lfilterStatus, L("lcl_mld_status"));
  return lfilterStatus;
}

function getRSFilterFinStatus(lparams, lStatusSep)
{
  var lfilterStatus = "";
  if (lparams.finstatus == 1) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + fin.getfinstatustext(1);
  if (lparams.finstatus == 2) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + fin.getfinstatustext(2);
  if (lparams.finstatus == 3) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + fin.getfinstatustext(3);
  if (lparams.finstatus == 6) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + fin.getfinstatustext(6);
  if (lparams.finstatus == 7) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + fin.getfinstatustext(7);

  lfilterStatus = getRSFilterValueByValue(lfilterStatus, L("lcl_fin_status"));
  return lfilterStatus;
}

function getRSFilterFinBron(lparams, lStatusSep)
{
  var lfilterStatus = "";
  if (lparams.fin_bron_key == 0) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + fin.getfinbrontext(0);
  if (lparams.fin_bron_key == 1) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + fin.getfinbrontext(1);
  if (lparams.fin_bron_key == 2) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + fin.getfinbrontext(2);

  lfilterStatus = getRSFilterValueByValue(lfilterStatus, L("lcl_fin_invoice_source"));
  return lfilterStatus;
}

function getRSFilterMldStatus(lparams, lStatusSep)
{
  var lfilterStatus = "";
  if (lparams.mldstpen || (lparams.mldstatus_arr && lparams.mldstatus_arr.join(",").indexOf("0") > -1)) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_mld_pending");
  if (lparams.mldstrej || (lparams.mldstatus_arr && lparams.mldstatus_arr.join(",").indexOf("1") > -1)) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_mld_afgewezen");
  if (lparams.mldstnew || (lparams.mldstatus_arr && lparams.mldstatus_arr.join(",").indexOf("2") > -1)) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_mld_afgewezen");
  if (lparams.mldsting || (lparams.mldstatus_arr && lparams.mldstatus_arr.join(",").indexOf("3") > -1)) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_mld_ingezien");
  if (lparams.mldstacc || (lparams.mldstatus_arr && lparams.mldstatus_arr.join(",").indexOf("4") > -1)) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_mld_geaccepteerd");
  if (lparams.mldstafm || (lparams.mldstatus_arr && lparams.mldstatus_arr.join(",").indexOf("5") > -1)) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_mld_afgemeld");
  if (lparams.mldstver || (lparams.mldstatus_arr && lparams.mldstatus_arr.join(",").indexOf("6") > -1)) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_mld_verwerkt");
  if (lparams.mldstuit || (lparams.mldstatus_arr && lparams.mldstatus_arr.join(",").indexOf("7") > -1)) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_mld_uitgegeven");
  if (lparams.mldnieto || (lparams.mldstatus_arr && lparams.mldstatus_arr.join(",").indexOf("99") > -1)) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_mld_not_solved");

  lfilterStatus = getRSFilterValueByValue(lfilterStatus, L("lcl_mld_mldstatus"));
  return lfilterStatus;
}

function getRSFilterMldOpdrStatus(lparams, lStatusSep)
{
  var lfilterStatus = "";
  if (lparams.mldopdrstrej || (lparams.opdrstatus_arr && lparams.opdrstatus_arr.join(",").indexOf("1")) > -1) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_mld_ord_afgewzen");
  if (lparams.mldopdrstnak || (lparams.opdrstatus_arr && lparams.opdrstatus_arr.join(",").indexOf("2")) > -1) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_mld_ord_niet_akkoord");
  if (lparams.mldopdrsttfi || (lparams.opdrstatus_arr && lparams.opdrstatus_arr.join(",").indexOf("3")) > -1) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_mld_ord_ter_fiattering");
  if (lparams.mldopdrstfia || (lparams.opdrstatus_arr && lparams.opdrstatus_arr.join(",").indexOf("4")) > -1) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_mld_ord_gefiatteerd");
  if (lparams.mldopdrstuit || (lparams.opdrstatus_arr && lparams.opdrstatus_arr.join(",").indexOf("5")) > -1) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_mld_ord_uitgegeven");
  if (lparams.mldopdrstafm || (lparams.opdrstatus_arr && lparams.opdrstatus_arr.join(",").indexOf("6")) > -1) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_mld_ord_afgemeld");
  if (lparams.mldopdrstver || (lparams.opdrstatus_arr && lparams.opdrstatus_arr.join(",").indexOf("7")) > -1) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_mld_ord_verwerkt");
  if (lparams.mldopdrstacp || (lparams.opdrstatus_arr && lparams.opdrstatus_arr.join(",").indexOf("8")) > -1) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_mld_ord_geaccepteerd");
  if (lparams.mldopdrstafr || (lparams.opdrstatus_arr && lparams.opdrstatus_arr.join(",").indexOf("9")) > -1) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + L("lcl_mld_ord_afgerond");

  lfilterStatus = getRSFilterValueByValue(lfilterStatus, L("lcl_mld_opdr_status"));
  return lfilterStatus;
}

function getRSFilterResStatus(lparams, lStatusSep)
{
  var lfilterStatus = "";
  if (lparams.resstatus == 1) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + res.getfostatustext(1);
  if (lparams.resstatus == 2) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + res.getfostatustext(2);
  if (lparams.resstatus == 3) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + res.getfostatustext(3);
  if (lparams.resstatus == 4) lfilterStatus += (lfilterStatus == ""? "" : lStatusSep) + res.getfostatustext(4);

  lfilterStatus = getRSFilterValueByValue(lfilterStatus, L("lcl_status_FO"));
  return lfilterStatus;
}

function getRSFilterDisGroupItem(lparams)
{
  var lfilterDisGroupItem = {content: "", count: 0};
  if (lparams.catalogus_key)
  {
    lfilterDisGroupItem.content += getRSFilterValueByKey("INS_TAB_DISCIPLINE", lparams.catalogus_key, L("lcl_bes_Catalogus"));
    lfilterDisGroupItem.count++;
  }
  if (lparams.besgroep_key)
  {
    lfilterDisGroupItem.content += getRSFilterValueByKey("BES_SRTGROEP", lparams.besgroep_key, L("lcl_bes_srtgroup"));
    lfilterDisGroupItem.count++;
  }
  if (lparams.item_key)
  {
    lfilterDisGroupItem.content += getRSFilterValueByKey("BES_SRTDEEL", lparams.item_key, L("lcl_bes_srtdeel"));
    lfilterDisGroupItem.count++;
  }

  return lfilterDisGroupItem;
}

function getRSFilterDisGroupObjsrt(lparams)
{
  var lfilterDisGroupObjsrt = {content: "", count: 0};
  if (lparams.disc_key)
  {
    lfilterDisGroupObjsrt.content += getRSFilterValueByKey("INS_TAB_DISCIPLINE", lparams.disc_key, L("lcl_discipline"));
    lfilterDisGroupObjsrt.count++;
  }
  if (lparams.insgroup_key)
  {
    lfilterDisGroupObjsrt.content += getRSFilterValueByKey("INS_SRTGROEP", lparams.insgroup_key, L("lcl_obj_group"));
    lfilterDisGroupObjsrt.count++;
  }
  if (lparams.objsrt_key_arr)
  {
    lfilterDisGroupObjsrt.content += getRSFilterValueByKey("INS_SRTDEEL", lparams.objsrt_key_arr, L("lcl_obj_sort"));
    lfilterDisGroupObjsrt.count++;
  }

  return lfilterDisGroupObjsrt;
}

function getRSFilterFaqLevel(pValue)
{
  var lfilterFaqLevel = "";
  if (pValue > 0) lfilterFaqLevel = L("lcl_faq_level" + pValue)

  lfilterFaqLevel = getRSFilterValueByValue(lfilterFaqLevel, L("lcl_faq_level"));
  return lfilterFaqLevel;
}

function getRSFilterKsgrpKs(lparams)
{
  var lfilterKsgrpKs = {content: "", count: 0};
  if (lparams.ksgrp_key)
  {
    lfilterKsgrpKs.content += getRSFilterValueByKey("PRS_KOSTENSOORTGRP", lparams.ksgrp_key, L("lcl_cnt_kostensoortgroep"));
    lfilterKsgrpKs.count++;
  }
  if (lparams.ks_key)
  {
    lfilterKsgrpKs.content += getRSFilterValueByKey("PRS_KOSTENSOORT", lparams.ks_key, L("lcl_cnt_kostensoort"));
    lfilterKsgrpKs.count++;
  }

  return lfilterKsgrpKs;
}

function getRSFilterSumOverBelow(lparams)
{
  var lfilterSumOverBelow = {content: "", count: 0};
  if (lparams.sumover)
  {
    lfilterSumOverBelow.content += getRSFilterValueByValue(safe.curr(lparams.sumover), L("lcl_fin_bedrag_boven") + " " + S("currency_pref"));
    lfilterSumOverBelow.count++;
  }
  if (lparams.sumbelow)
  {
    lfilterSumOverBelow.content += getRSFilterValueByValue(safe.curr(lparams.sumbelow), L("lcl_fin_bedrag_onder") + " " + S("currency_pref"));
    lfilterSumOverBelow.count++;
  }

  return lfilterSumOverBelow;
}

function getRSFilterShownMld(lparams)
{
  var lshownmld = "";
  var first = true;
  var lSep = ", ";

  if (lparams.chkAcceptEx)
  {
    lshownmld = L("lcl_mld_accept_time_exceed");
    first = false;
  }
  if (lparams.chkRunEx)
  {
    lshownmld += (!first? lSep : "") + L("lcl_mld_run_time_exceed");
    first = false;
  }
  if (lparams.chkSpoed)
  {
    lshownmld += (!first? lSep : "") + L("lcl_mld_spoed");
    first = false;
  }

  return lshownmld;
}

function getRSFilterShownFac(lparams)
{
  var lshownfac = "";
  var first = true;
  var lSep = ", ";

  if (lparams.getopen)
  {
    lshownfac = L("lcl_bes_chek1");
    first = false;
  }
  if (lparams.getclosed)
  {
    lshownfac += (!first? lSep : "") + L("lcl_fac_gefiatteerd");
    first = false;
  }
  if (lparams.getrejected)
  {
    lshownfac += (!first? lSep : "") + L("lcl_fac_afgewezen");
    first = false;
  }

  return lshownfac;
}

function getRSFilterShownRes(lparams)
{
  var lshownres = "";
  var first = true;
  var lSep = ", ";

  if (lparams.roomcat)
  {
    lshownres = L("lcl_show_rooms");
    first = false;
  }
  if (lparams.objcat)
  {
    lshownres += (!first? lSep : "") + L("lcl_reserved_object");
    first = false;
  }
  if (lparams.artcat)
  {
    lshownres += (!first? lSep : "") + L("lcl_reserved_cons");
    first = false;
  }
  if (lparams.res_actual)
  {
    lshownres += (!first? lSep : "") + L("lcl_res_shown_actual");
    first = false;
  }
  if (lparams.res_deleted)
  {
    lshownres += (!first? lSep : "") + L("lcl_res_shown_deleted");
    first = false;
  }
  if (lparams.res_open)
  {
    lshownres += (!first? lSep : "") + L("lcl_open_reservations");
    first = false;
  }
  if (lparams.res_closed)
  {
    lshownres += (!first? lSep : "") + L("lcl_closed_reservations");
    first = false;
  }
  if (lparams.res_notapproved)
  {
    lshownres += (!first? lSep : "") + L("lcl_res_notapproved");
    first = false;
  }
  if (lparams.res_approved)
  {
    lshownres += (!first? lSep : "") + L("lcl_res_approved");
    first = false;
  }
  if (lparams.dayschedule)
  {
    lshownres += (!first? lSep : "") + L("lcl_res_dayschedule");
    first = false;
  }

  return lshownres;
}

function getRSFilterSrtdisDiscStdmld(lparams)
{
  var lfilterSrtdisDiscStdmld = {content: "", count: 0};
  if (lparams.srtdisc_key)
  {
    lfilterSrtdisDiscStdmld.content += getRSFilterValueByKey("INS_SRTDISCIPLINE", lparams.srtdisc_key, L("lcl_vakgroup_type"));
    lfilterSrtdisDiscStdmld.count++;
  }
  if (lparams.disc_key_arr)
  {
    lfilterSrtdisDiscStdmld.content += lfilterValue = getRSFilterValueByKey("INS_TAB_DISCIPLINE", lparams.disc_key_arr, L("lcl_vakgroup"));
    lfilterSrtdisDiscStdmld.count++;
  }
  if (lparams.stdm_key_arr)
  {
    lfilterSrtdisDiscStdmld.content += lfilterValue = getRSFilterValueByKey("MLD_STDMELDING", lparams.stdm_key_arr, L("lcl_complain"));
    lfilterSrtdisDiscStdmld.count++;
  }

  return lfilterSrtdisDiscStdmld;
}

function getRSFilterDates(lparams)
{
  var lfilterDates = {content: "", count: 0};
  if (lparams.datetimefrom)
  {
    lfilterDates.content += getRSFilterValueByValue(lparams.datetimefrom, "<nobr>" + L("lcl_period_from") + "</nobr>", true);
    lfilterDates.count++;
  }
  if (lparams.datetimeto)
  {
    lfilterDates.content += getRSFilterValueByValue(lparams.datetimeto, "<nobr>" + L("lcl_period_to") + "</nobr>", true);
    lfilterDates.count++;
  }
  if (lparams.datefrom)
  {
    lfilterDates.content += getRSFilterValueByValue(lparams.datefrom, "<nobr>" + L("lcl_period_from") + "</nobr>");
    lfilterDates.count++;
  }
  if (lparams.dateto)
  {
    lfilterDates.content += getRSFilterValueByValue(lparams.dateto, "<nobr>" + L("lcl_period_to") + "</nobr>");
    lfilterDates.count++;
  }

  return lfilterDates;
}

function getGroupBesDescription(key)
{
  var ldescr = "";
  switch(key)
  {
    // Bepaal omschrijving
    case 0:     { ldescr = L("lcl_bes_RFOs");
                  break;
                }
    case 1:     { ldescr = L("lcl_shared_order");
                  break;
                }
    case 2:     { ldescr = L("lcl_bes_RFOs") + " - " + L("lcl_dep_name_level1");
                  break;
                }
    case 3:     { ldescr = L("lcl_bes_RFOs") + " - " + L("lcl_bes_Catalogus");
                  break;
                }
    case 4:     { ldescr = L("lcl_bes_RFOs") + " - " + L("lcl_bes_srtgroup");
                  break;
                }
    case 5:     { ldescr = L("lcl_bes_RFOs") + " - " + L("lcl_bes_srtdeel");
                  break;
                }
    case 6:     { ldescr = L("lcl_shared_order") + " - " + L("lcl_bes_Supplier");
                  break;
                }
    case 7:     { ldescr = L("lcl_bes_RFOs") + " - " + L("lcl_dep_name_level2");
                  break;
                }
    case 8:     { ldescr = L("lcl_bes_RFOs") + " - " + L("lcl_bes_ordernr");
                  break;
                }
    case 10:    { ldescr = L("lcl_district");
                  break;
                }
    case 11:    { ldescr = L("lcl_mi_location");
                  break;
                }
    default:    { ldescr = "";
                  break;
                }
  }

  return ldescr;
}

function getGroup2BesDescription(key)
{
  var ldescr = "";
  switch(key)
  {
    // Bepaal omschrijving
    case 8:     { ldescr = L("lcl_bes_RFOs") + " - " + L("lcl_bes_ordernr");
                  break;
                }
    case 10:    { ldescr = L("lcl_district");
                  break;
                }
    case 11:    { ldescr = L("lcl_mi_location");
                  break;
                }
    default:    { ldescr = "";
                  break;
                }
  }

  return ldescr;
}

function getRSFilterBezGroup(key)
{
  var ldescr = "";
  switch(key)
  {
    // Bepaal omschrijving
    case 1:     { ldescr = L("lcl_district");
                  break;
                }
    case 2:     { ldescr = L("lcl_location");
                  break;
                }
    case 3:     { ldescr = L("lcl_building");
                  break;
                }
    case 4:     { ldescr = L("lcl_month");
                  break;
                }
    case 5:     { ldescr = L("lcl_week");
                  break;
                }
    case 6:     { ldescr = L("lcl_day");
                  break;
                }
    default:    { ldescr = "";
                  break;
                }
  }

  return ldescr;
}

function getRSFilterMldGroup(key)
{
  var ldescr = "";
  switch(key)
  {
    // Bepaal omschrijving
    case 1:     { ldescr = L("lcl_complains");
                  break;
                }
    case 2:     { ldescr = L("lcl_orders");
                  break;
                }
    case 3:     { ldescr = L("lcl_complain") + ' ' + L("lcl_status");
                  break;
                }
    case 4:     { ldescr = L("lcl_vakgroup_type");
                  break;
                }
    case 5:     { ldescr = L("lcl_vakgroup_type") + ' + ' + L("lcl_vakgroup");
                  break;
                }
    case 6:     { ldescr = L("lcl_vakgroup_type") + ' + ' + L("lcl_vakgroup") + ' + ' + L("lcl_complain");
                  break;
                }
    case 7:     { ldescr = L("lcl_mld_kosten");
                  break;
                }
    case 8:     { ldescr = L("lcl_district");
                  break;
                }
    case 9:     { ldescr = L("lcl_location");
                  break;
                }
    case 10:    { ldescr = L("lcl_mld_opdrachtstatus");
                  break;
                }
    case 11:    { ldescr = L("lcl_handler");
                  break;
                }
    case 12:    { ldescr = L("lcl_charge_type");
                  break;
                }
    case 13:    { ldescr = L("lcl_district") + ' + ' + L("lcl_vakgroup_type") + ' + ' + L("lcl_vakgroup");
                  break;
                }
    case 14:    { ldescr = L("lcl_location") + ' + ' + L("lcl_vakgroup_type") + ' + ' + L("lcl_vakgroup");
                  break;
                }
    case 15:    { ldescr = L("lcl_charge_type_group");
                  break;
                }
    case 16:    { ldescr = L("lcl_orders") + ' + ' + L("lcl_opdr_kosten");
                  break;
                }
    case 17:    { ldescr = L("lcl_mld_typeopdr");
                  break;
                }
    case 18:    { ldescr = L("lcl_mld_meldinggroep");
                  break;
                }
    case 19:    { ldescr = L("lcl_vakgroup_type") + ' + ' + L("lcl_mld_meldinggroep");
                  break;
                }
    case 20:    { ldescr = L("lcl_mld_meldinggroep");
                  break;
                }
    case 21:    { ldescr = L("lcl_mld_meldbron");
                  break;
                }
    case 22:    { ldescr = L("lcl_mld_urg");
                  break;
                }
    default:    { ldescr = "";
                  break;
                }
  }

  return ldescr;
}

function getRSFilterBesGroup(lparams)
{
  var ldescr = "";
  var lfilterBesGroup = {content: "", count: 0};
  if (lparams.groupbes != null)
  {
    switch(lparams.groupbes)
    {
      // Bepaal omschrijving
      case 0:     { ldescr = L("lcl_bes_RFOs");
                    break;
                  }
      case 1:     { ldescr = L("lcl_shared_order");
                    break;
                  }
      case 2:     { ldescr = L("lcl_bes_RFOs") + " - " + L("lcl_dep_name_level1");
                    break;
                  }
      case 3:     { ldescr = L("lcl_bes_RFOs") + " - " + L("lcl_bes_Catalogus");
                    break;
                  }
      case 4:     { ldescr = L("lcl_bes_RFOs") + " - " + L("lcl_bes_srtgroup");
                    break;
                  }
      case 5:     { ldescr = L("lcl_bes_RFOs") + " - " + L("lcl_bes_srtdeel");
                    break;
                  }
      case 6:     { ldescr = L("lcl_shared_order") + " - " + L("lcl_bes_Supplier");
                    break;
                  }
      case 7:     { ldescr = L("lcl_bes_RFOs") + " - " + L("lcl_dep_name_level2");
                    break;
                  }
      case 8:     { ldescr = L("lcl_bes_RFOs") + " - " + L("lcl_bes_ordernr");
                    break;
                  }
      case 10:    { ldescr = L("lcl_district");
                    break;
                  }
      case 11:    { ldescr = L("lcl_mi_location");
                    break;
                  }
      default:    { ldescr = "";
                    break;
                  }
    }
    lfilterBesGroup.content += getRSFilterValueByValue(ldescr, L("lcl_bes_group"));
    lfilterBesGroup.count++;
  }
  if (lparams.groupbes2 != null)
  {
    switch(lparams.groupbes2)
    {
      // Bepaal omschrijving
      case 8:     { ldescr = L("lcl_bes_RFOs") + " - " + L("lcl_bes_ordernr");
                    break;
                  }
      case 10:    { ldescr = L("lcl_district");
                    break;
                  }
      case 11:    { ldescr = L("lcl_mi_location");
                    break;
                  }
      default:    { ldescr = "";
                    break;
                  }
    }
    lfilterBesGroup.content += getRSFilterValueByValue(ldescr, L("lcl_bes_group2"));
    lfilterBesGroup.count++;
  }

  return lfilterBesGroup;
}

function getDepartmentDescription(key)
{
  var ldescr = "";
  var sql = "SELECT d.niveau"
          + " FROM prs_v_afdeling d "
          + " WHERE d.prs_afdeling_key = " + key;
  var oRs = Oracle.Execute(sql);
  switch(oRs("niveau").Value)
  {
    // Bepaal omschrijving
    case 1:     { ldescr = L("lcl_dep_name_level1");
                  break;
                }
    case 2:     { ldescr = L("lcl_dep_name_level2");
                  break;
                }
    case 3:     { ldescr = L("lcl_dep_name_level3");
                  break;
                }
    case 4:     { ldescr = L("lcl_dep_name_level4");
                  break;
                }
    case 5:     { ldescr = L("lcl_dep_name_level5");
                  break;
                }
    default:    { ldescr = "";
                  break;
                }
  }

  return ldescr;
}

function getFinTypeDescription(key)
{
  var ldescr = "";
  switch(key)
  {
    // Bepaal omschrijving
    case "B":                      { ldescr = L("lcl_fin_bestellingen");
                                     break;
                                   }
    case "C":                      { ldescr = L("lcl_fin_contracten");
                                     break;
                                   }
    case "O":                      { ldescr = L("lcl_fin_opdrachten");
                                     break;
                                   }
    default:                       { ldescr = "";
                                     break;
                                   }
  }

  return ldescr;
}

function getMjobGroupDescription(key)
{
  var ldescr = "";
  switch(key)
  {
    // Bepaal omschrijving
    case 1:     { ldescr = L("lcl_district");
                  break;
                }
    case 2:     { ldescr = L("lcl_building");
                  break;
                }
    case 3:     { ldescr = L("lcl_discipline");
                  break;
                }
    case 4:     { ldescr = L("lcl_obj_group");
                  break;
                }
    case 5:     { ldescr = L("lcl_obj_sort");
                  break;
                }
    case 6:     { ldescr = L("lcl_ins_object");
                  break;
                }
    case 7:     { ldescr = L("lcl_ins_controle_srt");
                  break;
                }
    default:    { ldescr = "";
                  break;
                }
  }

  return ldescr;
}

function getSortoutDescription(key)
{
  var ldescr = "";
  switch(key)
  {
    // Bepaal omschrijving
    case 1:     { ldescr = L("lcl_location") + ", " + L("lcl_time");
                  break;
                }
    case 5:     { ldescr = L("lcl_time");
                  break;
                }
    case 2:     { ldescr = L("lcl_place");
                  break;
                }
    case 3:     { ldescr = L("lcl_reservation");
                  break;
                }
    case 4:     { ldescr = L("lcl_host");
                  break;
                }
    default:    { ldescr = "";
                  break;
                }
  }

  return ldescr;
}

function getGroupResDescription(key)
{
  var ldescr = "";
  switch(key)
  {
    // Bepaal omschrijving
    case 1:     { ldescr = L("lcl_res_group");
                  break;
                }
    case 5:     { ldescr = L("lcl_district");
                  break;
                }
    case 6:     { ldescr = L("lcl_mi_location");
                  break;
                }
    case 10:    { ldescr = L("lcl_building");
                  break;
                }
    case 7:     { ldescr = L("lcl_res_article");
                  break;
                }
    case 8:     { ldescr = L("lcl_res_art_number");
                  break;
                }
    case 12:    { ldescr = L("lcl_charge_type");
                  break;
                }
    case 13:    { ldescr = L("lcl_charge_type_group");
                  break;
                }
    case 9:     { ldescr = L("lcl_account");
                  break;
                }
    case 11:    { ldescr = L("lcl_activity");
                  break;
                }
    case 14:    { ldescr = L("lcl_room");
                  break;
                }
    case 15:    { ldescr = L("lcl_res_roomcat");
                  break;
                }
    case 16:    { ldescr = L("lcl_month");
                  break;
                }
    default:    { ldescr = "";
                  break;
                }
  }

  return ldescr;
}

function getReportDates(lparam, lparams)
{
  var lfilterDates = {content: "", count: 0};
  var lparam_middlepart = lparam.substr(13, lparam.length - 17);
  lfilterDates.content += getRSFilterValueByValue(lparams[lparam], "<nobr>" + lparam.substr(13, 1).toUpperCase() + lparam.substr(14) + "</nobr>", true);
  lfilterDates.count++;
  if (lparams["fclt_f_end_" + lparam_middlepart + " " + L("lcl_to")])
  {
    lfilterDates.content += getRSFilterValueByValue(lparams["fclt_f_end_" + lparam_middlepart + " " + L("lcl_to")], lparam_middlepart + " " + L("lcl_to"));
    lfilterDates.count++;
  }

  return lfilterDates;
}

function getRSFilterColumns(lparams)
{
  var askFilterBesGroup = true;
  var askFilterBezGroup = true;
  var askFilterBesOpdrStatus = true;
  var askFilterBezOpdrStatus = true;
  var askFilterBesStatus = true;
  var askFilterKsgrpKs = true;
  var askFilterCntStatus = true;
  var askFilterDates = true;
  var askFilterDisGroupItem = true;
  var askFilterDisGroupObjsrt = true;
  var askFilterInsStatus = true;
  var askFilterMldOpdrStatus = true;
  var askFilterMldStatus = true;
  var askFilterPlace = true;
  var askFilterResType = true;
  var askFilterShownFac = true;
  var askFilterShownMld = true;
  var askFilterShownRes = true;
  var askFilterSrtdisDiscStdmld = true;
  var askFilterSumOverBelow = true;
  var lfilterBesGroup = {content: "", count: 0};
  var lfilterDates = {content: "", count: 0};
  var lfilterReportDates = {content: "", count: 0};
  var lfilterColumnRight = {content: "", count: 0}
  var lfilterColumnLeft = {content: "", count: 0}
  var lfilterKsgrpKs = {content: "", count: 0}
  var lfilterPlace = {content: "", count: 0};
  var lfilterDisGroupItem = {content: "", count: 0};
  var lfilterDisGroupObjsrt = {content: "", count: 0};
  var lfilterSrtdisDiscStdmld = {content: "", count: 0};
  var lfilterSumOverBelow = {content: "", count: 0};
  var lcount;
  var lfilterValue;
  var lStatusSep = " | ";

  for (lparam in lparams)
  {
    lcount = 1;
    lfilterValue = "";
    if (lparams[lparam] != null) // lparams[lparam] moet een waarde hebben. De waarde 0 of false mag ook
    {
      switch(lparam)
      {
        // ALG gegevens
        case "reg_key":
        case "dist_key":
        case "loc_key":
        case "bld_key":
        case "terr_key":
        case "flr_key":
        case "room_key":
        case "wpl_key":         { if (askFilterPlace)
                                  {
                                    lfilterPlace = getRSFilterPlace(lparams); // Alle plaats gegevens ophalen en onder elkaar weergeven
                                    lfilterValue = lfilterPlace.content;
                                    lcount = lfilterPlace.count;
                                    askFilterPlace = false;
                                  }
                                  else
                                  {
                                    lfilterValue = "";
                                    lcount = 0;
                                  }
                                  break;
                                }
        case "bld_func":        { lfilterValue = getRSFilterValueByKey("ALG_SRTGEBOUW", lparams[lparam], L("lcl_estate_gebouw_srtgebouw"));
                                  break;
                                }
        case "verantw_key":     { lfilterValue = getRSFilterValueByKey("PRS_PERSLID", lparams[lparam], L("lcl_alg_verantw"));
                                  break;
                                }
        // BES gegevens
        case "rfo_key":         { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_bes_key"));
                                  break;
                                }
        case "opdr_key":        { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_ord_order_num"));
                                  break;
                                }
        case "item":            { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_bes_srtdeel"));
                                  break;
                                }
        case "catalogus_key":   // Catalogus, Groep en Item gegevens
        case "besgroep_key":
        case "item_key":        { if (askFilterDisGroupItem)
                                  {
                                    lfilterDisGroupItem = getRSFilterDisGroupItem(lparams); // Catalogus, Groep en Item gegevens ophalen en onder elkaar weergeven
                                    lfilterValue = lfilterDisGroupItem.content;
                                    lcount = lfilterDisGroupItem.count;
                                    askFilterDisGroupItem = false;
                                  }
                                  else
                                  {
                                    lfilterValue = "";
                                    lcount = 0;
                                  }
                                  break;
                                }
        case "besstafg":        // Bestelaanvraagstatus gegevens
        case "besstnew":
        case "besstfia":
        case "besstacc":
        case "besstbes":
        case "besstlev":
        case "besstver":
        case "besstmix":        { if (askFilterBesStatus)
                                  {
                                    lfilterValue = getRSFilterBesStatus(lparams, lStatusSep); // Alle Status gegevens ophalen
                                    askFilterBesStatus = false;
                                  }
                                  else
                                  {
                                    lfilterValue = "";
                                    lcount = 0;
                                  }
                                  break;
                                }
        case "besopdrstafg":    // Bestelopdrachtstatus gegevens
        case "besopdrstnew":
        case "besopdrstbeh":
        case "besopdrstbes":
        case "besopdrstbev":
        case "besopdrstlev":
        case "besopdrstver":    { if (askFilterBesOpdrStatus)
                                  {
                                    lfilterValue = getRSFilterBesOpdrStatus(lparams, lStatusSep); // Alle Status gegevens ophalen
                                    askFilterBesOpdrStatus = false;
                                  }
                                  else
                                  {
                                    lfilterValue = "";
                                    lcount = 0;
                                  }
                                  break;
                                }
        case "groupbes":        // Bestelling groupering gegevens
        case "groupbes2":       { if (askFilterBesGroup)
                                  {
                                    lfilterBesGroup = getRSFilterBesGroup(lparams); // Beide grouperingen gegevens ophalen en onder elkaar weergeven
                                    lfilterValue = lfilterBesGroup.content;
                                    lcount = lfilterBesGroup.count;
                                    askFilterBesGroup = false;
                                  }
                                  else
                                  {
                                    lfilterValue = "";
                                    lcount = 0;
                                  }
                                  break;
                                }
        // BEZ gegevens
        case "bez_key":         { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_vis_appointment_no"));
                                  break;
                                }
        case "afspr_key":       { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_vis_appointment_no"));
                                  break;
                                }
        case "bezPark":         { lfilterValue = getRSFilterValueByValue(L("lcl_Yes"), L("lcl_park"));
                                  break;
                                }
        case "bezExpect":       // Bezoekersstatus gegevens
        case "bezInside":
        case "bezDepart":
        case "bezClosed":       { if (askFilterBezOpdrStatus)
                                  {
                                    lfilterValue = getRSFilterBezOpdrStatus(lparams, lStatusSep); // Alle Status gegevens ophalen
                                    askFilterBezOpdrStatus = false;
                                  }
                                  else
                                  {
                                    lfilterValue = "";
                                    lcount = 0;
                                  }
                                  break;
                                }
        case "groupbez":        { lfilterValue = getRSFilterValueByValue(getRSFilterBezGroup(lparams.groupbez), L("lcl_BEZ_group"));
                                  break;
                                }
        // CNT gegevens
        case "cnt_key":         { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_cnt_intern_nr"));
                                  break;
                                }
        case "contract":        { lfilterValue = getRSFilterValueByKey("CNT_CONTRACT_NUMMER", lparams[lparam], L("lcl_cnt_contractnr"));
                                  break;
                                }
        case "contractnr":      { lfilterValue = getRSFilterValueByKey("CNT_CONTRACT_NUMMER", lparams[lparam], L("lcl_cnt_intern_nr"));
                                  break;
                                }
        case "cntsrt_key":      { lfilterValue = getRSFilterValueByKey("INS_TAB_DISCIPLINE", lparams[lparam], L("lcl_cnt_srttype"));
                                  break;
                                }
        case "objectsrt_key":   { lfilterValue = getRSFilterValueByKey("INS_SRTDEEL", lparams[lparam], L("lcl_obj_sort"));
                                  break;
                                }
        case "discript":        { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_cnt_beschrijv"));
                                  break;
                                }
        case "dienst_key":      { lfilterValue = getRSFilterValueByKey("PRS_DIENST", lparams[lparam], L("lcl_prs_companies_dienst"));
                                  break;
                                }
        case "uitvoerder_key":  { lfilterValue = getRSFilterValueByKey("PRS_BEDRIJF", lparams[lparam], L("lcl_cnt_contractant"));
                                  break;
                                }
        case "cnt_persoon_key": { lfilterValue = getRSFilterValueByKey("PRS_PERSLID", lparams[lparam], L("lcl_cnt_name"));
                                  break;
                                }
        case "eigenaar_key":    { lfilterValue = getRSFilterValueByKey("PRS_AFDELING", lparams[lparam], L("lcl_cnt_owner"));
                                  break;
                                }
        case "beheerder_key":   { lfilterValue = getRSFilterValueByKey("PRS_PERSLID", lparams[lparam], L("lcl_cnt_beheerder"));
                                  break;
                                }
        case "mantel_key":      { lfilterValue = getRSFilterValueByKey("CNT_CONTRACT", lparams[lparam], L("lcl_cnt_mantel"));
                                  break;
                                }
        case "ksgrp_key":       // Kostensoortgroep en kostensoort gegevens
        case "ks_key":          { if (askFilterKsgrpKs)
                                  {
                                    lfilterKsgrpKs = getRSFilterKsgrpKs(lparams); // Catalogus, Groep en Item gegevens ophalen en onder elkaar weergeven
                                    lfilterValue = lfilterKsgrpKs.content;
                                    lcount = lfilterKsgrpKs.count;
                                    askFilterKsgrpKs = false;
                                  }
                                  else
                                  {
                                    lfilterValue = "";
                                    lcount = 0;
                                  }
                                  break;
                                }
        case "cntAct":          // Contractstatus gegevens
        case "cntRap":
        case "cntOpz":
        case "cntVerl":         { if (askFilterCntStatus)
                                  {
                                    lfilterValue = getRSFilterCntStatus(lparams, lStatusSep); // Alle Status gegevens ophalen
                                    askFilterCntStatus = false;
                                  }
                                  else
                                  {
                                    lfilterValue = "";
                                    lcount = 0;
                                  }
                                  break;
                                }
        // FAC gegevens
        case "getopen":
        case "getclosed":
        case "getrejected":     { if (askFilterShownFac)
                                  {
                                    lfilterValue = getRSFilterValueByValue(getRSFilterShownFac(lparams), L("lcl_status"));
                                    askFilterShownFac = false;
                                  }
                                  else
                                  {
                                    lfilterValue = "";
                                    lcount = 0;
                                  }
                                  break;
                                }
        case "profiel_key":     { lfilterValue = getRSFilterValueByKey("FAC_PROFIEL", lparams[lparam], L("lcl_prs_profile"));
                                  break;
                                }
        // Factuur gegevens
        // FIN gegevens
        case "fin_key":         { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_fin_number"));
                                  break;
                                }
        case "fin_type":        { lfilterValue = getRSFilterValueByValue(getFinTypeDescription(lparams[lparam]), L("lcl_fin_factuur_type"));
                                  break;
                                }
        case "findate":         { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_fin_date"));
                                  break;
                                }
        case "debtor":          { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_fin_debtor"));
                                  break;
                                }
        case "fin_bron_key":    { lfilterValue = getRSFilterFinBron(lparams, lStatusSep);
                                  break;
                                }
        case "finstatus":       { lfilterValue = getRSFilterFinStatus(lparams, lStatusSep);
                                  break;
                                }
        case "sumover":
        case "sumbelow":        { if (askFilterSumOverBelow)
                                  {
                                    lfilterSumOverBelow = getRSFilterSumOverBelow(lparams); // Factuurbedrag boven en factuurbedrag onder gegevens ophalen en onder elkaar weergeven
                                    lfilterValue = lfilterSumOverBelow.content;
                                    lcount = lfilterSumOverBelow.count;
                                    askFilterSumOverBelow = false;
                                  }
                                  else
                                  {
                                    lfilterValue = "";
                                    lcount = 0;
                                  }
                                  break;
                                }
        case "finnum":          { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_fin_number"));
                                  break;
                                }
        case "goedkeur_key":    { lfilterValue = getRSFilterValueByKey("PRS_PERSLID", lparams[lparam], L("lcl_fin_goedkeurder"));
                                  break;
                                }
        case "goedkeur":        { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_fin_goedkeurder"));
                                  break;
                                }
        case "debiteur_nr":     { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_fin_debtor_nr"));
                                  break;
                                }
        // FAC gegevens
        case "getopen":
        case "getclosed":
        case "getrejected":     { if (askFilterShownFac)
                                  {
                                    lfilterValue = getRSFilterValueByValue(getRSFilterShownFac(lparams), L("lcl_status"));
                                    askFilterShownFac = false;
                                  }
                                  else
                                  {
                                    lfilterValue = "";
                                    lcount = 0;
                                  }
                                  break;
                                }
        // Kennisbank gegevens
        // FAQ gegevens
        case "fac_faq_lang":   { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_faq_lang"));
                                  break;
                                }
        case "fac_faq_level":   { lfilterValue = getRSFilterFaqLevel(lparams[lparam]);
                                  break;
                                }
        // Object (ins_deel) gegevens
        // INS gegevens
        case "disc_key":        // Discipline, Groep en Objectsoort
        case "insgroup_key":
        case "objsrt_key_arr":  { if (askFilterDisGroupObjsrt)
                                  {
                                    lfilterDisGroupObjsrt = getRSFilterDisGroupObjsrt(lparams); // Discipline, Groep en Objectsoort gegevens ophalen en onder elkaar weergeven
                                    lfilterValue = lfilterDisGroupObjsrt.content;
                                    lcount = lfilterDisGroupObjsrt.count;
                                    askFilterDisGroupObjsrt = false;
                                  }
                                  else
                                  {
                                    lfilterValue = "";
                                    lcount = 0;
                                  }
                                  break;
                                }
        case "deel":            { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_obj_identification"));
                                  break;
                                }
        case "disc_key_str":    { lfilterValue = getRSFilterValueByKey("INS_TAB_DISCIPLINE", lparams[lparam], L("lcl_vakgroup"));
                                  break;
                                }
        case "srtdeel_key":     { lfilterValue = getRSFilterValueByKey("INS_SRTDEEL", lparams[lparam], L("lcl_obj_sort"));
                                  break;
                                }
        case "insObjIncl":      { if (lparams.insObjIncl) lfilterValue = getRSFilterValueByValue(L("lcl_Yes"), L("lcl_subobjects_incl"));
                                  break;
                                }
        case "expObjIncl":      { if (lparams.expObjIncl) lfilterValue = getRSFilterValueByValue(L("lcl_Yes"), L("lcl_expobjects_incl"));
                                  break;
                                }
        case "insLentOut":      // Uitgeleende en beschikbare objecten (status)
        case "insAvail":        { if (askFilterInsStatus)
                                  {
                                    lfilterValue = getRSFilterInsStatus(lparams, lStatusSep); // Alle Status gegevens ophalen
                                    askFilterInsStatus = false;
                                  }
                                  else
                                  {
                                    lfilterValue = "";
                                    lcount = 0;
                                  }
                                  break;
                                }
        case "mjbgroup":        { lfilterValue = getRSFilterValueByValue(getMjobGroupDescription(lparams[lparam]), L("lcl_mjb_group"));
                                  break;
                                }
        case "mjbtoyear":       { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_mjb_uptoyear"));
                                  break;
                                }
        case "mjbsrtcontr":    { lfilterValue = getRSFilterValueByKey("INS_SRTCONTROLE", lparams[lparam], L("lcl_ins_controle_srt"));
                                  break;
                                }
        case "mjbinfl_pct":     { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_mjb_inflation"));
                                  break;
                                }
        case "mjbfreq":         { lfilterValue = getRSFilterValueByValue(lparams[lparam] + " " + L("lcl_ins_controle_period_rearyear"), L("lcl_mjb_frequency"));
                                  break;
                                }
        case "mjbincbtw":       { if (lparams.mjbincbtw)
                                    lfilterValue = getRSFilterValueByValue(L("lcl_Yes"), L("lcl_mjb_inclbtw"));
                                  break;
                                }
        // MLD gegevens
        case "srtdisc_key":     // Discipline, Groep en Objectsoort
        case "disc_key_arr":
        case "stdm_key_arr":    { if (askFilterSrtdisDiscStdmld)
                                  {
                                    lfilterSrtdisDiscStdmld = getRSFilterSrtdisDiscStdmld(lparams); // Soort Melding (srtdiscipline), Productgroep (discipline) en Melding (srtmelding) gegevens ophalen en onder elkaar weergeven
                                    lfilterValue = lfilterSrtdisDiscStdmld.content;
                                    lcount = lfilterSrtdisDiscStdmld.count;
                                    askFilterSrtdisDiscStdmld = false;
                                  }
                                  else
                                  {
                                    lfilterValue = "";
                                    lcount = 0;
                                  }
                                  break;
                                }
        case "mld_key":         { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_call_number"));
                                  break;
                                }
        case "opdrnr":          { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_mld_order_nr"));
                                  break;
                                }
        case "opdr_key":        { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_shared_order"));
                                  break;
                                }
        case "mld_result":      { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_mld_result"));
                                  break;
                                }
        case "opdrtype_key":    { lfilterValue = getRSFilterValueByKey("MLD_TYPEOPDR", lparams[lparam], L("lcl_mld_typeopdr"));
                                  break;
                                }
        case "meldinggrp_key":  { lfilterValue = getRSFilterValueByKey("MLD_STDMELDINGGROEP", lparams[lparam], L("lcl_mld_meldinggroep"));
                                  break;
                                }
        case "behandelgrp_key":  { lfilterValue = getRSFilterValueByKey("MLD_BEHANDELGROEP", lparams[lparam], L("lcl_mld_behandelgroep"));
                                  break;
                                }
                                // Melding/Opdracht groupering gegevens
        case "groepering_key":  { lfilterValue = getRSFilterValueByValue(getRSFilterMldGroup(lparams.groepering_key), L("lcl_BEZ_group"));
                                  break;
                                }
        case "ref_key":         { lreferenceName = getReferenceNameReferentie(lparams[lparam], lparams["ref_type"])
                                  lfilterValue = getRSFilterValueByValue(lreferenceName, L("lcl_reference"));
                                  break;
                                }
        case "mldstpen":        // Meldingstatus gegevens
        case "mldstnew":
        case "mldsting":
        case "mldstacc":
        case "mldstuit":
        case "mldstrej":
        case "mldstafm":
        case "mldstver":
        case "mldstatus_arr":   { if (askFilterMldStatus)
                                  {
                                    lfilterValue = getRSFilterMldStatus(lparams, lStatusSep); // Alle Status gegevens ophalen
                                    askFilterMldStatus = false;
                                  }
                                  else
                                  {
                                    lfilterValue = "";
                                    lcount = 0;
                                  }
                                  break;
                                }
        case "mldopdrstrej":    // Opdrachtstatus gegevens
        case "mldopdrstnak":
        case "mldopdrsttfi":
        case "mldopdrstfia":
        case "mldopdrstuit":
        case "mldopdrstafm":
        case "mldopdrstver":
        case "opdrstatus_arr":  { if (askFilterMldOpdrStatus)
                                  {
                                    lfilterValue = getRSFilterMldOpdrStatus(lparams, lStatusSep); // Alle Opdracht Status gegevens ophalen
                                    askFilterMldOpdrStatus = false;
                                  }
                                  else
                                  {
                                    lfilterValue = "";
                                    lcount = 0;
                                  }
                                  break;
                                }
        case "chkAcceptEx":
        case "chkRunEx":
        case "chkSpoed":        { if (askFilterShownMld)
                                  {
                                    lfilterValue = getRSFilterValueByValue(getRSFilterShownMld(lparams), "<nobr>" + L("lcl_mld_shown_mld") + "</nobr>");
                                    askFilterShownMld = false;
                                  }
                                  else
                                  {
                                    lfilterValue = "";
                                    lcount = 0;
                                  }
                                  break;
                                }
        // PRJ gegevens
        case "verhuisaanvraag": { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_prj_verhuisaanvraag"));
                                  break;
                                }
        case "scenario":        { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_prj_scenario"));
                                  break;
                                }
        // PRS gegevens
        case "dep_key":         { lfilterValue = getRSFilterValueByKey("PRS_AFDELING", lparams[lparam], getDepartmentDescription(lparams[lparam]));
                                  break;
                                }
        case "dept":
        case "org_key":         { lfilterValue = getRSFilterValueByKey("PRS_AFDELING", lparams[lparam], L("lcl_prs_organisatie"));
                                  break;
                                }
        case "bedrijf_key":
        case "company_key":     { lfilterValue = getRSFilterValueByKey("PRS_BEDRIJF", lparams[lparam], L("lcl_prs_company"));
                                  break;
                                }
        case "supplier_key":    { lfilterValue = getRSFilterValueByKey("PRS_BEDRIJF", lparams[lparam], L("lcl_prs_companies_leverancier"));
                                  break;
                                }
        case "comp_key":        { lfilterValue = getRSFilterValueByKey("PRS_BEDRIJF", lparams[lparam], L("lcl_company"));
                                  break;
                                }
        case "kp":              { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_prs_kosten"));
                                  break;
                                }
        case "kp_key":          { lfilterValue = getRSFilterValueByKey("PRS_KOSTENPLAATS", lparams[lparam], L("lcl_cnt_kostenplaats"));
                                  break;
                                }
        case "prs_kstpl":
        case "kstpl_key":       { lfilterValue = getRSFilterValueByKey("PRS_KOSTENPLAATS", lparams[lparam], L("lcl_prs_dept_kosten"));
                                  break;
                                }
        case "behandel_key":    { lfilterValue = getRSFilterValueByKey("PRS_PERSLID", lparams[lparam], L("lcl_mld_behandelaar"));
                                  break;
                                }
        case "caller_key":      { lfilterValue = getRSFilterValueByKey("PRS_PERSLID", lparams[lparam], L("lcl_caller"));
                                  break;
                                }
        case "host_key":        { lfilterValue = getRSFilterValueByKey("PRS_PERSLID", lparams[lparam], L("lcl_host"));
                                  break;
                                }
        case "requestor_key":   { lfilterValue = getRSFilterValueByKey("PRS_PERSLID", lparams[lparam], L("lcl_res_requestor"));
                                  break;
                                }
        case "personfor_key":   { lfilterValue = getRSFilterValueByKey("PRS_PERSLID", lparams[lparam], L("lcl_bes_order_for"));
                                  break;
                                }
        case "persoon_key":     { lfilterValue = getRSFilterValueByKey("PRS_PERSLID", lparams[lparam], L("lcl_obj_bind_p"));
                                  break;
                                }
        case "budh_key":        { lfilterValue = getRSFilterValueByKey("PRS_PERSLID", lparams[lparam], L("lcl_prs_budgethouder"));
                                  break;
                                }
        case "handler_key":     { lfilterValue = getRSFilterValueByKey("MLD_V_UITVOERENDE", lparams[lparam], L("lcl_handler"));
                                  break;
                                }
        case "contact_key":     { lfilterValue = getRSFilterValueByKey("PRS_PERSLID", lparams[lparam], L("lcl_contact_pers"));
                                  break;
                                }
        case "prsLogin":        { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_prs_person_login"));
                                  break;
                                }
        case "deptName":         { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_prs_dept_name"));
                                  break;
                                }
        case "deptDesc":         { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_prs_dept_desc"));
                                  break;
                                }
        case "prsName":         { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_prs_person_name"));
                                  break;
                                }
        case "prsNR":           { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_prs_person_nr"));
                                  break;
                                }
        case "bdr_key":         { lfilterValue = getRSFilterValueByKey("PRS_BEDRIJF", lparams[lparam], L("lcl_prs_dept_company"));
                                  break;
                                }
        case "func":            { lfilterValue = getRSFilterValueByKey("PRS_SRTPERSLID", lparams[lparam], L("lcl_prs_person_function"));
                                  break;
                                }
        // RES gegevens
        case "res_key":         { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_res_number"));
                                  break;
                                }
        case "room_key_arr":    { lfilterValue = getRSFilterValueByKey("INS_TAB_DISCIPLINE", lparams[lparam], L("lcl_res_roomcat"));
                                  break;
                                }
        case "obj_key_arr":     { lfilterValue = getRSFilterValueByKey("INS_TAB_DISCIPLINE", lparams[lparam], L("lcl_res_objcat"));
                                  break;
                                }
        case "art_key_arr":     { lfilterValue = getRSFilterValueByKey("INS_TAB_DISCIPLINE", lparams[lparam], L("lcl_res_artcat"));
                                  break;
                                }
        case "article_arr":     { lfilterValue = getRSFilterValueByKey("INS_TAB_DISCIPLINE", lparams[lparam], L("lcl_res_art"));
                                  break;
                                }
        case "artgroup":        { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_res_art_group"));
                                  break;
                                }
        case "resstatus":       { lfilterValue = getRSFilterResStatus(lparams, lStatusSep);
                                  break;
                                }
        case "roomcat":
        case "objcat":
        case "artcat":
        case "res_actual":
        case "res_deleted":
        case "res_open":
        case "res_closed":
        case "res_approved":
        case "res_notapproved":
        case "dayschedule":     { if (askFilterShownRes)
                                  {
                                    lfilterValue = getRSFilterValueByValue(getRSFilterShownRes(lparams), "<nobr>" + (lparam == "dayschedule"? L("lcl_res_list") : L("lcl_res_shown_res")) + "</nobr>");
                                    askFilterShownRes = false;
                                  }
                                  else
                                  {
                                    lfilterValue = "";
                                    lcount = 0;
                                  }
                                  break;
                                }
        case "sortout":         { lfilterValue = getRSFilterValueByValue(getSortoutDescription(lparams[lparam]), L("lcl_res_sort"));
                                  break;
                                }
        case "groupres":        { lfilterValue = getRSFilterValueByValue(getGroupResDescription(lparams[lparam]), L("lcl_res_group"));
                                  break;
                                }
        // Diverse gegevens
        case "descr":
        case "omschr":          { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_descr"));
                                  break;
                                }
        case "search":
        case "searchtekst":
        case "searchtext":      { lfilterValue = getRSFilterValueByValue(lparams[lparam], L("lcl_search_diff_fields"));
                                  break;
                                }
        // Datum gegevens
        case "datetimefrom":
        case "datetimeto":
        case "datefrom":
        case "dateto":          { if (askFilterDates)
                                  {
                                    lfilterDates = getRSFilterDates(lparams); // Alle datum gegevens ophalen en onder elkaar weergeven
                                    lfilterValue = lfilterDates.content;
                                    lcount = lfilterDates.count;
                                    askFilterDates = false;
                                  }
                                  else
                                  {
                                    lfilterValue = "";
                                    lcount = 0;
                                  }
                                  break;
                                }
        default:                { lcount = 0;
                                  break;
                                }
      }
      // Als er niets gevonden is kan het misschien nog een rapportage zijn.
      if (lcount == 0)
      { // Voor de rapportages weten we dat de parameters met "fclt_f_" beginnen. We kunnen dan gemakkelijk alles in één keer pakken.
        // De filternaam zit dan in de parameternaam.
        lcount = 1;
        switch(lparam.substr(0, 7))
        {
          case "fclt_f_":         { if (lparam.substr(0, 12) == "fclt_f_start")
                                    {
                                      lfilterReportDates = getReportDates(lparam, lparams); // Alle datum gegevens ophalen en onder elkaar weergeven
                                      lfilterValue = lfilterReportDates.content;
                                      lcount = lfilterReportDates.count;
                                    }
                                    else if (lparam.substr(0, 10) == "fclt_f_end")
                                      lcount = 0; // De "fclt_f_start") zorgt ook voor de einddatum zodat ze beide gegroepeerd worden.
                                    else
                                      lfilterValue = getRSFilterValueByValue(lparams[lparam], lparam.substr(7, 1).toUpperCase() + lparam.substr(8));
                                    break;
                                  }
          default:                { lcount = 0;
                                    break;
                                  }
        }
      }
    }
    if (lcount > 0 && lfilterValue != "")
    {
      if (lfilterColumnLeft.count <= lfilterColumnRight.count)
      {
        lfilterColumnLeft.content += lfilterValue;
        lfilterColumnLeft.count += lcount;
      }
      else
      {
        lfilterColumnRight.content += lfilterValue;
        lfilterColumnRight.count += lcount;
      }
    }
  }

  return {filterColumnLeft: lfilterColumnLeft.content, filterColumnRight: lfilterColumnRight.content};
}

function getRSFilterTable(lparams)
{
  var filterColumns = getRSFilterColumns(lparams)

  var lResult = "";
  if ((filterColumns.filterColumnLeft != null) || (filterColumns.filterColumnRight != null))
  {
    lResult += "<div id='rsFilterTable'>";
    lResult += "<table id='prsearchtable' BORDER=0 WIDTH='100%'>";
    lResult += "<tr>";
    lResult += "  <td class='prsearchkolom1'>";
    lResult += "    <!-- Left filter elements -->";
    lResult += "    <table>";
    lResult +=        filterColumns.filterColumnLeft;
    lResult += "    </table>";
    lResult += "  </td>";
    lResult += "  <td class='prsearchkolom2'>";
    lResult += "    <!-- Right filter elements -->";
    lResult += "    <table>";
    lResult +=        filterColumns.filterColumnRight;
    lResult += "    </table>";
    lResult += "  </td>";
    lResult += "</tr>";
    lResult += "</table>";
    lResult += "</div>";
  }
  return lResult;
}
%>