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

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

<html>
<%
  var sort  = getQParamInt("sort");
  var outlet_key  = getQParamInt("o_key");
  var wallplate_key  = getQParamInt("w_key");
  var wallplate = '';
  var room = '';
  var renter = '';
  var loccode = '';
%>
  <script type="text/javascript"><!--
    function loaded() {
    <%
    //    sql = "SELECT g2.ins_deel_upper wallplate"
    //        + ", o.alg_plaatsaanduiding ruimte"
    //        + ", wa.prs_afdeling_naam huurder_ruimte"
    //        + " FROM ins_deel g"
    //        + ", ins_deel g2"
    //        + ", ins_v_alg_overzicht o"
    //        + ", prs_v_werkplekafdeling_geg wa"
    //        + " WHERE g.ins_deel_key = " + outlet_key
    //        + " AND g.ins_deel_parent_key = g2.ins_deel_key"
    //        + " AND g.ins_deel_parent_key IS NOT NULL"
    //        + " AND g.ins_alg_ruimte_key = o.alg_onroerendgoed_keys"
    //        + " AND g.ins_alg_ruimte_type = o.alg_onroerendgoed_type"
    //        + " AND g.ins_alg_locatie_key = o.alg_locatie_key"
    //        + " AND g.ins_alg_ruimte_key = wa.alg_ruimte_key";
    //
        sql = " SELECT g_wallplate.ins_deel_omschrijving wallplate"            // 0
            + ", o.alg_plaatsaanduiding ruimte"                         // 1
            + ", wa.prs_afdeling_naam huurder_ruimte"                   // 2
            + ", o.alg_locatie_omschrijving"                           // 3
            + "   FROM ins_deel g_outlet,"                              // (assumes key is already validated)
            + "        ins_deel g_wallplate,"
            + "        (SELECT alg_r.alg_ruimte_key alg_onroerendgoed_keys, 'R' alg_onroerendgoed_type,"
            + "                   alg_l.alg_locatie_code"
            + "                || '-'"
            + "                || alg_g.alg_gebouw_code"
            + "                || '-'"
            + "                || alg_v.alg_verdieping_code"
            + "                || '-'"
            + "                || alg_r.alg_ruimte_nr alg_plaatsaanduiding,"
            + "                alg_g.alg_locatie_key,"
            + "                alg_l.alg_locatie_omschrijving"
            + "           FROM alg_ruimte alg_r, alg_verdieping alg_v, alg_gebouw alg_g, alg_locatie alg_l"
            + "          WHERE alg_r.alg_verdieping_key = alg_v.alg_verdieping_key"
            + "            AND alg_v.alg_gebouw_key = alg_g.alg_gebouw_key"
            + "            AND alg_g.alg_locatie_key = alg_l.alg_locatie_key"
            + "         UNION"
            + "         SELECT prs_w.prs_werkplek_key, 'W',"
            + "                   alg_l.alg_locatie_code"
            + "                || '-'"
            + "                || alg_g.alg_gebouw_code"
            + "                || '-'"
            + "                || alg_v.alg_verdieping_code"
            + "                || '-'"
            + "                || alg_r.alg_ruimte_nr"
            + "                || '/'"
            + "                || TO_CHAR (prs_w.prs_werkplek_volgnr),"
            + "                alg_g.alg_locatie_key,"
            + "                alg_l.alg_locatie_omschrijving"
            + "           FROM prs_werkplek prs_w,"
            + "                alg_ruimte alg_r,"
            + "                alg_verdieping alg_v,"
            + "                alg_gebouw alg_g,"
            + "                alg_locatie alg_l"
            + "          WHERE prs_w.prs_alg_ruimte_key = alg_r.alg_ruimte_key"
            + "            AND alg_r.alg_verdieping_key = alg_v.alg_verdieping_key"
            + "            AND alg_v.alg_gebouw_key = alg_g.alg_gebouw_key"
            + "            AND alg_g.alg_locatie_key = alg_l.alg_locatie_key) o,"
            + "        (SELECT prs_a.prs_afdeling_naam, prs_w.prs_alg_ruimte_key alg_ruimte_key"
            + "           FROM prs_perslidwerkplek prs_pw,"
            + "                prs_perslid prs_p,"
            + "                prs_afdeling prs_a,"
            + "                prs_werkplek prs_w"
            + "          WHERE prs_pw.prs_perslid_key = prs_p.prs_perslid_key"
            + "            AND prs_p.prs_afdeling_key = prs_a.prs_afdeling_key"
            + "            AND prs_pw.prs_werkplek_key = prs_w.prs_werkplek_key) wa"
            + "  WHERE g_outlet.ins_deel_parent_key = g_wallplate.ins_deel_key"
            + "    AND g_outlet.ins_deel_parent_key IS NOT NULL"
            + "    AND g_outlet.ins_alg_ruimte_key = o.alg_onroerendgoed_keys"
            + "    AND g_outlet.ins_alg_ruimte_type = o.alg_onroerendgoed_type"
            + "    AND g_outlet.ins_alg_locatie_key = o.alg_locatie_key"
            + "    AND g_outlet.ins_alg_ruimte_key = wa.alg_ruimte_key(+)"
            + "    AND g_outlet.ins_deel_key  = " + outlet_key;

        oRs = Oracle.Execute( sql );
        if (!oRs.eof) {
          wallplate = oRs(0).Value;
          room = oRs(1).Value;
          renter = oRs(2).Value;
          loccode = oRs(3).Value;
          oRs.MoveNext();
          if (!oRs.eof) renter = L("lcl_out_shared_use");
        }
        else renter = "";
        oRs.close();
    %>
    window.parent.document.forms.u2.wallplate.value = '<%=wallplate%>';
    window.parent.document.forms.u2.room.value = '<%=room%>';
    window.parent.document.forms.u2.loccode.value = '<%=loccode%>';
    window.parent.document.forms.u2.renter.value = '<%=renter%>';
    window.parent.loadKenmerk();
    window.parent.dec_cc();
    }
    -->
  </script>
  <body onLoad="javascript:loaded();">
<%  Response.Write("load_outlet.asp done " + outlet_key); %>
  </body>
</html>
