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

     File:               CNT/cnt_edit_scope.asp (was: algins4cnt.asp/alg4cnt.asp)
     Description:        Afhankelijk van het type contract kan hier de bijbehorende scope worden aangepast
                         cnt_srtcontract_type                Scope
                         [1] Onderhoud/Maintenance           Objecten
                         [2] Huur/Rental                     Onroerend goed (ruimten/terreinen)
                         [3] Ondersteuning/Support           Plaats (locatie, gebouw, verdieping, ruimte, terrein) en/of objecten
                         [4] Algemeen/Generic                Geen
                         [5] Leverancier/Supplier            Plaats (locatie, gebouw, verdieping, ruimte, terrein)
                         [6] Mantel/Master                   Geen
     Parameters:         cnt_key   Contract key
     Context:
     Note:               Weet niet of status=2 wel afgehandeld moet worden als scope; dat was eerder niet zo.
*/ %>

<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="../Shared/selector.inc" -->
<!-- #include file="../Shared/plaatsselector.inc" -->
<!-- #include file="../Shared/afdelingselector.inc" -->
<!-- #include file="../Shared/persoonselector.inc" -->
<!-- #include file="../Shared/disciplineselector.inc" -->
<!-- #include file="../Shared/srtgroepselector.inc" -->
<!-- #include file="../Shared/srtdeelselector.inc" -->
<%
FCLTHeader.Requires({ plugins: ["jQuery"],
                           js: ["./cnt_edit_scope.js","../ins/bind.js"]
                    });

var cnt_key = getQParamInt("cnt_key");

var autfunction = ["WEB_CNTMAN", "WEB_INSMAN"];
if (S("cnt_contract_approval") == 1)
    autfunction = "WEB_CNTUSE";

// TODO: Hier zelf uitzoeken welke scope selectoren getoond worden afhankelijk van contracttype
// only_loc niet meer gebruiken
sql = "SELECT cdp.cnt_srtcontract_type, cdp.cnt_ins_discipline_key"
    + " FROM cnt_contract c"
    + ", cnt_disc_params cdp"
    + " WHERE c.ins_discipline_key = cdp.cnt_ins_discipline_key"
    + " AND c.cnt_contract_key = " + cnt_key;
oRs = Oracle.Execute(sql);
var cnt_srtcontract_type = oRs("cnt_srtcontract_type").value;
var disc_key = oRs("cnt_ins_discipline_key").value;
oRs.Close();

var authparams = user.checkAutorisation(autfunction, false, disc_key);

%>

<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script type="text/javascript">

      PRSreadlevel = "<%=authparams.PRSreadlevel%>";
<%    switch (cnt_srtcontract_type)
      {
        case 1: // object scope
%>              $(function ()
                  {
                    updateGroup("WEB_INSMAN");
                  });
<%              break;
        case 3: // object en/of plaats scope
%>              $(function ()
                  {
                    updateBld(<%=authparams.ALGwritelevel%>); // hieruit volgt ook updateFlr() en updateRoo()
                    updateGroup("WEB_INSMAN");
                  });
<%              break;
        case 5: // plaats scope
%>              $(function ()
                  {
                    updateBld(<%=authparams.ALGwritelevel%>); // hieruit volgt ook updateFlr() en updateRoo()
                  });
<%              break;
      }
%>
    </script>
  </head>

  <body class="editmode">
  <%    var buttons = [ {title: L("lcl_submit"), action: "cnt_submit()", icon: "fa-fclt-save" },
                      {title: L("lcl_cancel"), action: "cnt_cancel()", icon: "fa-fclt-cancel" } ];

  %>
  <% SUBFRAME_START();
  IFRAMER_HEADER(L("lcl_cnt_frame_algemeen"), buttons); %>

    <!-- <form name="u2" target="hidFrame" method="post"> -->
    <form id="u2" name="u2" action="cnt_edit_scope_save.asp" target="hidFrame" method="post" onSubmit="cnt_submit();">
      <input type="hidden" id="cnt_key" name="cnt_key" value="<%=cnt_key%>">
<%        // Objecten scope
          // TODO: Voor het cnt_srtcontract_type == 1 moet de object scope nog toegevoegd worden!!!
          if (cnt_srtcontract_type == 1)
          {
            SEARCH_BLOCK_START("", L("lcl_cnt_location_scope"));
              FCLTplaatsselector(authparams.ALGreadlevel, { locatiekey: -1,
                                                                gebouwkey: -1,
                                                                verdiepingkey: -1,
                                                                ruimtekey: -1,
                                                                startlevel: 2, // locatie
                                                                eindlevel: 5, // ruimte
                                                                terrein: true,
                                                                autlevel: authparams.ALGwritelevel,
                                                                onLocChange: "onPlaatsChange()",
                                                                onGebChange: "onPlaatsChange()",
                                                                onVerChange: "onPlaatsChange()",
                                                                onRuiChange: "onPlaatsChange()",
                                                                whenEmpty: L("lcl_search_generic"), // want filter
                                                                filtercode: "EXP"
                                                              });
            SEARCH_BLOCK_END();
            SEARCH_BLOCK_START("", L("lcl_cnt_verdeling"));

                      <!-- Organisatie -->
                   FCLTafdelingselector("sDept_key", // organisation
                                     "sgDept",
                                     { departmentKey: -1,
                                       label: L("lcl_prs_organisatie"),
                                       autlevel: authparams.PRSreadlevel, // Was voorheen niet aanwezig
                                       onChange: "onAfdelingChange",
                                       whenEmpty: L("lcl_search_generic")  // want filter
                                     }); %>
                    <!-- Persoon -->
<%                  FCLTpersoonselector("sName_key", // Persoon
                                       "sgPerson",
                                       { perslidKey: -1,
                                         label: L("lcl_search_pers"),
                                         autlevel: authparams.ALGwritelevel9,
                                         filtercode: "OBJP",
                                         urlAdd: [{urlParam: "afd_key", field: "sDept_key"}],
                                         extracode: "AK",
                                         extraParamField: "prsafd_key",
                                         onChange: "onPersoonChange",
                                         whenEmpty: L("lcl_search_generic") // want filter
                                       }); %>
<%          SEARCH_BLOCK_END();
            SIMPLE_BLOCK_START();
            SIMPLE_BLOCK_END();
            BLOCK_START("", L("lcl_cnt_object_scope"), { icon: "fa-crosshairs", wide: true });
%>
              </table>
              <div class="row">
                <div class="col-5">
                  <table style="width: 95%">
                    <!-- Objecten -->
<%
                      FCLTdisciplineselector("disc",
                                             "sgDisc",
                                             { label: L("lcl_discipline"),
                                               disc_key: -1,
                                               module: "INS",
                                               perslidKey: user_key,
                                               autfunctionKey: authparams.autfunctionkey,
                                               onChange: "onChangeDiscipline"
                                            });
                      FCLTsrtgroepselector("srtgroep",
                                           "sgSrtgroep",
                                           { label: L("lcl_obj_group"),
                                             srtgroep_key: -1,
                                             module: "INS",
                                             urlAdd: [{urlParam: "disc_key", field: "disc"}],
                                             autfunction: authparams.autfunction,
                                             onChange: "onChangeSrtgroep"
                                          });
                      FCLTsrtdeelselector("srtdeel",
                                          "sgSrtdeel",
                                          { label: L("lcl_obj_sort"),
                                            srtdeel_key: -1,
                                            module: "INS",
                                            urlAdd: [{urlParam: "srtgroep_key", field: "srtgroep"},
                                                     {urlParam: "disc_key", field: "disc"}],
                                            autfunction: authparams.autfunction,
                                            onChange: "onChangeSrtdeel"
                                          });
                      sql = "";
                      FCLTselector("objs",
                                   sql,
                                   { label: L("lcl_cnt_objects"),
                                     startmulti: true,
                                     size: 10,
                                     onDblClick: "showObjDetail(event);"
                                   }); %>
                  </table>
                </div>
                <div class="col-1 cnt-scope-buttons">
                  <span class="mover" onclick="addObj()"><%=I("fa-arrow-square-right")%></span>
                </div>
                <div class="col-1 cnt-scope-buttons">
                  <span class="mover" onclick="removeObj()"><%=I("fa-arrow-square-left")%></span><br><br>
                  <span class="mover" onclick="removeAllObj()"><%=I("fa-trash-alt")%></span>
                </div>
                <div class="col-5">
                  <table id="cntobjscope_list">
<%                // Works only for Objects now; query columns match shared/load_robjs.asp
                  var plaatsaanduiding = (S("prs_wpprefix_objectid") == 1
                                         ? " CASE"
                                           + " WHEN o.prs_werkplek_omschrijving IS NOT NULL"
                                           + " THEN ' ' || o.prs_werkplek_omschrijving"
                                           + " ELSE ''"
                                           + " END"
                                         : "''");
                  sql = "SELECT co.cnt_contract_object_key"
                      + "     , d.ins_deel_key"
                      + "     , d.ins_deel_omschrijving || " + plaatsaanduiding + " || ' (' || " + lcl.xsql('s.ins_srtdeel_omschrijving','s.ins_srtdeel_key') +" || ')' omschrijving"
                      + "     , COALESCE(d.ins_alg_locatie_key, -1) loc_key"
                      + "     , COALESCE(ao.alg_geb_ter_key, -1) gebter_key"
                      + "     , COALESCE(ao.alg_verdieping_key, -1) ver_key"
                      + "     , COALESCE(d.ins_alg_ruimte_key, -1) rui_key"
                      + "     , d.ins_srtdeel_key"
                      + " FROM ins_v_aanwezigdeel d"
                      + "    , ins_srtdeel s"
                      + "    , cnt_contract_object co"
                      + "    , ins_v_alg_onroerendgoed ao"
                      + "    , ins_v_alg_overzicht o"
                      + " WHERE d.ins_srtdeel_key = s.ins_srtdeel_key"
                      + "   AND d.ins_alg_ruimte_key = ao.alg_onrgoed_keys(+)" // (+) afdelings/persoons gebonden objecten hebben geen onrgoed link
                      + "   AND (d.ins_deel_vervaldatum IS NULL OR d.ins_deel_vervaldatum > TRUNC(SYSDATE))"
                      + "   AND co.cnt_ins_deel_key IS NOT NULL"
                      + "   AND co.cnt_ins_deel_key = d.ins_deel_key"
                      + "   AND co.cnt_contract_object_verwijder IS NULL"
                      + " AND d.ins_alg_ruimte_key = o.alg_onroerendgoed_keys(+)"
                      + " AND d.ins_alg_ruimte_type = o.alg_onroerendgoed_type(+)"
                      + " AND d.ins_alg_locatie_key = o.alg_locatie_key(+)"
                      + "   AND co.cnt_contract_key = " + cnt_key
                      + " ORDER BY 3";
                  oRs = Oracle.Execute(sql);
                  var j = 1;
                  while (!oRs.eof)
                  {
%>                  <tr id="row<%=j+1000%>" OnClick="javascript:selectObjRow(<%=j+1000%>);">
                      <td class="selectable" id="obj"><%/*note:this content is matched in itemExist, watch out! */ %>
                          <%=oRs("omschrijving").value%></td>
                      <td>
                        <input type="hidden" id="k<%=j%>" name="k<%=j%>" value="<%=oRs("cnt_contract_object_key").value%>">
                        <input type="hidden" id="kd<%=j%>" name="kd<%=j%>" value="<%=oRs("ins_deel_key").value%>">
                        <input type="hidden" id="ks<%=j%>" name="ks<%=j%>" value="<%=oRs("ins_srtdeel_key").value%>">
                      </td>
                    </tr>
<%                  j++;
                    oRs.MoveNext();
                  }
                  oRs.close(); %>
                  </table>
                  <input type="hidden" id="objcnt" name="objcnt" value="<%=j-1%>">
                </div>
              </div><%
            BLOCK_END();
        } %>
<% // Locatie/gebouw scope
          if (cnt_srtcontract_type == 3 || cnt_srtcontract_type == 5)
          {
            BLOCK_START("", L("lcl_cnt_location_scope"), { icon: "fa-map-marked", wide: true });
            %>
              </table>
              <div class="row">
                <div class="col-5">
                  <table style="width: 95%">
<%
                      var sql_my_loc = "   AND al.alg_locatie_key IN"
                                     + "     ( SELECT alg_locatie_key"
                                     + "         FROM fac_v_my_locations"
                                     + "        WHERE prs_perslid_key = " + user_key
                                     + "          AND niveau = " + authparams.ALGwritelevel
                                     + "     )";

                      var sql_filter = "   AND EXISTS"
                                     + "   ( SELECT ''"
                                     + "       FROM alg_v_aanweziggebouw ag"
                                     + "          , alg_srtgebouw sg"
                                     + "      WHERE ag.alg_srtgebouw_key = sg.alg_srtgebouw_key(+)"
                                     + "        AND (ag.alg_gebouw_vervaldatum IS NULL OR ag.alg_gebouw_vervaldatum > TRUNC (SYSDATE))"
                                     + "        AND ag.alg_locatie_key = al.alg_locatie_key"
                                     + "   )";
                      var sql = "SELECT al.alg_locatie_key"
                              + "     , al.alg_locatie_code || ' (' || al.alg_locatie_omschrijving || ')'"
                              + "  FROM alg_locatie al"
                              + " WHERE al.alg_locatie_verwijder IS NULL"
                              + "   AND (al.alg_locatie_vervaldatum > SYSDATE OR al.alg_locatie_vervaldatum IS NULL)"
                              + ((authparams.ALGwritelevel > -1) ? sql_my_loc : "")
                              + sql_filter
                              + " ORDER BY al.alg_locatie_upper";
                      FCLTselector("locs",
                                   sql,
                                   { label: L("lcl_location"),
                                     initKey: -1,
                                     initEmpty: true,
                                     multi: true,
                                     startmulti: false,
                                     size: 10,
                                     onChange: 'updateBld("' + authparams.ALGwritelevel + '");'
                                   }); %>

                    <!-- Gebouw/terrein -->
<%                        FCLTselector("blds",
                                       "", // sql: lege selectbox die onload wordt geladen
                                       { label: L("lcl_bld_terra"),
                                         initKey: -1,
                                         initEmpty: true,
                                         multi: true,
                                         startmulti: false,
                                         size: 10,
                                         onChange: 'updateFlr("' + authparams.ALGwritelevel + '");'
                                       });%>
                    <!-- Verdieping -->
<%                        FCLTselector("flrs",
                                       "", // sql: lege selectbox die onload wordt geladen
                                       { label: L("lcl_floor"),
                                         initKey: -1,
                                         initEmpty: true,
                                         multi: true,
                                         startmulti: false,
                                         size: 10,
                                         onChange: 'updateRoo("' + authparams.ALGwritelevel + '");'
                                       }); %>
                    <!-- Ruimte -->
<%                        FCLTselector("rooms",
                                       "", // sql: lege selectbox die onload wordt geladen
                                       { label: L("lcl_room"),
                                          initKey: -1,
                                         initEmpty: true,
                                         multi: true,
                                         startmulti: false,
                                         size: 10
                                       }); %>
                  </table>
                </div>
                <div class="col-1 cnt-scope-buttons">
                  <span class="mover" onclick="addLoc()"><%=I("fa-arrow-square-right")%></span>
                </div>
                <div class="col-1 cnt-scope-buttons">
                  <span class="mover" onclick="removeLoc()"><%=I("fa-arrow-square-left")%></span><br><br>
                  <span class="mover" onclick="removeAllLoc()"><%=I("fa-trash-alt")%></span>
                </div>

                <div class="col-5">
                  <table id="cntlocscope_list">
<%                // Works only for Objects now; query columns match shared/load_robjs.asp
                  sql = "SELECT cp.cnt_contract_plaats_key, "
                      + "       cp.cnt_alg_plaats_key, "
                      + "       l.alg_locatie_code || ' (' || l.alg_locatie_omschrijving || ')' plaats, "
                      + "       cp.cnt_alg_plaats_code, "
                      + "       cp.cnt_contract_plaats_gewicht "
                      + "  FROM cnt_contract_plaats cp, alg_v_aanweziglocatie l "
                      + " WHERE     cp.cnt_alg_plaats_code = 'L' "
                      + "       AND cp.cnt_alg_plaats_key = l.alg_locatie_key "
                      + "       AND cp.cnt_contract_plaats_verwijder IS NULL "
                      + "       AND cp.cnt_contract_key = " + cnt_key
                      + " UNION "
                      + "SELECT cnt_contract_plaats_key, "
                      + "       cnt_alg_plaats_key key, "
                      + "       l.alg_locatie_code || '-' || g.alg_gebouw_code || ' (' || g.alg_gebouw_naam || ')', "
                      + "       cnt_alg_plaats_code, "
                      + "       cnt_contract_plaats_gewicht gewicht "
                      + "  FROM cnt_contract_plaats, alg_locatie l, alg_v_aanweziggebouw g "
                      + " WHERE     cnt_alg_plaats_code = 'G' "
                      + "       AND cnt_alg_plaats_key = g.alg_gebouw_key "
                      + "       AND g.alg_locatie_key = l.alg_locatie_key "
                      + "       AND cnt_contract_plaats_verwijder IS NULL "
                      + "       AND cnt_contract_key = " + cnt_key
                      + " UNION "
                      + "SELECT cnt_contract_plaats_key, "
                      + "       cnt_alg_plaats_key key, "
                      + "       l.alg_locatie_code || '-' || t.alg_terreinsector_code || ' (' || t.alg_terreinsector_naam || ')', "
                      + "       cnt_alg_plaats_code, "
                      + "       cnt_contract_plaats_gewicht gewicht "
                      + "  FROM cnt_contract_plaats, alg_locatie l, alg_v_aanwezigterreinsector t "
                      + " WHERE     cnt_alg_plaats_code = 'T' "
                      + "       AND cnt_alg_plaats_key = t.alg_terreinsector_key "
                      + "       AND t.alg_locatie_key = l.alg_locatie_key "
                      + "       AND cnt_contract_plaats_verwijder IS NULL "
                      + "       AND cnt_contract_key = " + cnt_key
                      + " UNION "
                      + "SELECT cnt_contract_plaats_key, "
                      + "       cnt_alg_plaats_key key, "
                      + "       l.alg_locatie_code || '-' || v.alg_plaatsaanduiding || "
                      + "       DECODE (v.alg_plaatsomschrijving, '', '', ' (' || v.alg_plaatsomschrijving || ')'), "
                      + "       cnt_alg_plaats_code, "
                      + "       cnt_contract_plaats_gewicht gewicht "
                      + "  FROM cnt_contract_plaats, alg_locatie l, alg_v_allonrgoed_gegevens v "
                      + " WHERE     cnt_alg_plaats_code = 'V' "
                      + "       AND v.alg_type = 'V' "
                      + "       AND cnt_alg_plaats_key = v.alg_verdieping_key "
                      + "       AND v.alg_locatie_key = l.alg_locatie_key "
                      + "       AND cnt_contract_plaats_verwijder IS NULL "
                      + "       AND cnt_contract_key = " + cnt_key
                      + " UNION "
                      + "SELECT cnt_contract_plaats_key, "
                      + "       cnt_alg_plaats_key key, "
                      + "       l.alg_locatie_code || '-' || r.alg_plaatsaanduiding || "
                      + "       DECODE (r.alg_plaatsomschrijving, '', '', ' (' || r.alg_plaatsomschrijving || ')'), "
                      + "       cnt_alg_plaats_code, "
                      + "       cnt_contract_plaats_gewicht gewicht "
                      + "  FROM cnt_contract_plaats, alg_locatie l, alg_v_allonrgoed_gegevens r "
                      + " WHERE     cnt_alg_plaats_code = 'R' "
                      + "       AND r.alg_type = 'R' "
                      + "       AND cnt_alg_plaats_key = r.alg_ruimte_key "
                      + "       AND r.alg_locatie_key = l.alg_locatie_key "
                      + "       AND cnt_contract_plaats_verwijder IS NULL "
                      + "       AND cnt_contract_key = " + cnt_key
                      + " ORDER BY 3, 5 DESC";
                  oRs = Oracle.Execute(sql);
                  var j = 1;
                  while(!oRs.eof)
                  {
%>                  <tr id="row<%=j%>" OnClick="javascript:selectLocRow(<%=j%>);">
                      <td class="selectable" id="loc"><%/*note:this content is matched in itemExist, watch out!*/%>
                        <%=safe.html("" + oRs("plaats").value)%></td>
                      <td class="selectable">
                        <input type="text" class="fldshort float" maxlength="12" id="akn<%=j%>" name="akn<%=j%>" id="akn" onBlur="checkWeight(event);" value="<%=safe.editablefloat(oRs("cnt_contract_plaats_gewicht").value)%>">
                        <input type="hidden" id="ak<%=j%>" name="ak<%=j%>" value="<%=oRs("cnt_contract_plaats_key").value%>">
                        <input type="hidden" id="akd<%=j%>" name="akd<%=j%>" value="<%=oRs("cnt_alg_plaats_key").value%>">
                        <input type="hidden" id="aks<%=j%>" name="aks<%=j%>" value="<%=safe.htmlattr(oRs("plaats").value)%>">
                        <input type="hidden" id="akt<%=j%>" name="akt<%=j%>" value="<%=oRs("cnt_alg_plaats_code").value%>">
                      </td>
                    </tr>
<%                  j++;
                    oRs.MoveNext();
                  }
                  oRs.close(); %>
                  </table>
                  <input type="hidden" id="loccnt" name="loccnt" value="<%=j-1%>">
                </div>
              </div><%
            BLOCK_END();
} %>
<%       // Objectensoort scope
          if (cnt_srtcontract_type == 3)
          {
            BLOCK_START("", L("lcl_cnt_objectsrt_scope"), { icon: "fa-crosshairs", wide: true });
%>
              </table>
              <div class="row">
                <div class="col-5">
                  <table style="width: 95%">

<!-- Discipline -->
<%
                   sql = "SELECT ins_discipline_key"
                        + ", "+ lcl.xsqla('ins_discipline_omschrijving','ins_discipline_key')
                        + " FROM ins_v_aanwezigdiscipline"
                        + " WHERE ins_discipline_key IN"
                          + " (SELECT ins_discipline_key"
                          + " FROM fac_v_webgebruiker g"
                          + ", fac_functie f"
                          + " WHERE g.prs_perslid_key = " + user_key
                          + " AND f.fac_functie_key = g.fac_functie_key "
                          + " AND f.fac_functie_code = 'WEB_INSMAN'"
                          + " AND (g.fac_gebruiker_alg_level_read < 9 OR g.fac_gebruiker_prs_level_read < 9)" + ")"
                        + " ORDER BY "+ lcl.xsql('ins_discipline_omschrijving','ins_discipline_key') +" ASC";
                    FCLTselector("disc",
                                 sql,
                                 { label: L("lcl_discipline"),
                                   startmulti: true,
                                   size: 10,
                                   onChange: "updateGroup('WEB_INSMAN');"
                                 }); %>

                    <!-- Groep -->
<%                  FCLTselector("srtgroup",
                                 "", // sql: lege selectbox die onload wordt geladen
                                 { label: L("lcl_obj_group"),
                                   startmulti: true,
                                   size: 10,
                                   onChange: "updateSrtDeel('WEB_INSMAN');"
                                 }); %>

                    <!-- Objectsoort -->
<%                  FCLTselector("srtdeelmulti",
                                 "", // sql: lege selectbox die onload wordt geladen
                                 { label: L("lcl_obj_sort"),
                                   startmulti: true,
                                   size: 10
                                 }); %>
                  </table>
                </div>
                <div class="col-1 cnt-scope-buttons">
                  <span class="mover" onclick="addObjSort()"><%=I("fa-arrow-square-right")%></span>
                </div>
                <div class="col-1 cnt-scope-buttons">
                  <span class="mover" onclick="removeObjSort()"><%=I("fa-arrow-square-left")%></span><br><br>
                  <span class="mover" onclick="removeAllObjSort()"><%=I("fa-trash-alt")%></span>
                </div>
                <div class="col-5">
                  <table id="cntobjsortscope_list">
<%                  // Works only for Objects now; query columns match shared/load_robjs.asp
                    sql = "SELECT DISTINCT cos.cnt_contract_object_key"
                        + ", s.ins_srtdeel_key"
                        + ", "+ lcl.xsqla('s.ins_srtdeel_omschrijving','s.ins_srtdeel_key')
                        + " FROM ins_v_srtdeel_gegevens s"
                        + ", cnt_contract_object cos"
                        + ", ins_v_alg_onroerendgoed ao"
                        + " WHERE "
                        + " cos.cnt_ins_srtdeel_key = s.ins_srtdeel_key AND "
                        + " cos.cnt_ins_deel_key IS NULL AND "
                        + " cos.cnt_contract_object_verwijder IS NULL AND"
                        + " cos.cnt_contract_key = " + cnt_key
                        + " ORDER BY 3";
                    oRs = Oracle.Execute(sql);
                    var j = 1;
                    while (!oRs.eof)
                    {
%>                    <tr id="row<%=j+1000%>" OnClick="javascript:selectObjSortRow(<%=j + 1000%>);">
                        <td class="selectable" id="obsort"><%/*note:this content is matched in itemExist, watch out!*/%>
                          <%=oRs("ins_srtdeel_omschrijving").value%>
                        </td>
                        <td>
                         <input type="hidden" id="sk<%=j%>" name="sk<%=j%>" value="<%=oRs("cnt_contract_object_key").value%>">
                         <input type="hidden" id="skd<%=j%>" name="skd<%=j%>" value="<%=oRs("ins_srtdeel_key").value%>">
                         <input type="hidden" id="sks<%=j%>" name="sks<%=j%>" value="<%=oRs("ins_srtdeel_omschrijving").value%>">
                        </td>
                      </tr><%
                      j++;
                      oRs.MoveNext();
                    }
                    oRs.close(); %>
                  </table>
                  <input type="hidden" id="oscnt" name="oscnt" value="<%=j-1%>">
                </div>
              </div><%
            BLOCK_END();
} /* if (only_loc) */ %>
<%
IFACE.FORM_END(); %>
    </form>
    <iframe src="../Shared/empty.asp" frameborder="0" name="hidFrame" id="hidFrame" style="display:none"></iframe>
  <% SUBFRAME_END(); %>
  </body>
</html>
<% ASPPAGE_END(); %>
