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

    File:               SuggestSrtcontrole.asp
    Description:        Suggereer taken
    Parameters:         k:            De eerste paar letters
                        filtcode:     Beperk de lijst met getoonde locaties TO BE DEFINED
                        intern_uitv:  Ben ik interne uitvoerder.

    Globals:
    Context:
    Note:
*/ %>

<%
JSON_Result = true;
%>

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

<%
var chars = getQParam("k", "");
var bAll = getQParamInt("SuggestAll", 0) == 1;
var ctrdisc_key_arr = getQParamIntArray("ctrdisc_key_arr", []);
var intern_uitv = getQParamInt("intern_uitv", 1) == 1;
var filtcode = getQParam("filtcode", "");

chars = chars.replace(/\*/g,"%");

var filt_params = { ctrdisc_key_arr: ctrdisc_key_arr,
                    intern_uitv: intern_uitv
                  };

var filtClause = getFiltClauseSrtcontrole(filtcode, filt_params);

var sql = "SELECT ins_srtcontrole_key"
        + filtClause.select
        + "     , cd.ins_discipline_omschrijving"
        + "  FROM ins_srtcontrole isc"
        + "     , ctr_disc_params cdp"
        + "     , ctr_discipline cd"
        + filtClause.from
        + "  WHERE (UPPER(" + lcl.xsql("ins_srtcontrole_omschrijving", "isc.ins_srtcontrole_key") + ") LIKE " + safe.quoted_sql_wild2(chars)
        + "      OR UPPER("+ lcl.xsql("ins_discipline_omschrijving", "cd.ins_discipline_key") + ") LIKE " + safe.quoted_sql_wild2(chars) + ")"
        + "    AND isc.ctr_discipline_key = cdp.ctr_ins_discipline_key"
        + "    AND cdp.ctr_ins_discipline_key = cd.ins_discipline_key"
        + filtClause.where
        + " ORDER BY UPPER(ins_srtcontrole_omschrijving)"


WriteResult2(sql, { bAll:    bAll,
                   fldName: "ins_srtcontrole_omschrijving",
                   fldKey:  "ins_srtcontrole_key",
                   fldDesc: "ins_discipline_omschrijving"
                  })
%>
<% ASPPAGE_END(); %>
