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

    File:               cnt_show_note2.asp
    Description:        Nieuwe notities versie.
                        Betere layout, altijd een invulveld
    Parameters:         cnt_key (altijd verplicht hier)

*/

var cnt_key = getQParamInt("cnt_key"); // Altijd verplicht cnt_key.
var LOCKED_USER_OK = { "xmlnode" : "contract", "key": cnt_key };
%>

<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="../Shared/status.inc"-->
<!-- #include file="./cnt.inc" -->
<!-- #include file="../Shared/resultset_table_v2.inc" -->
<!-- #include file="../Shared/discx3d.inc" -->
<!-- #include file="../Shared/notes.inc" -->
<%
FCLTHeader.Requires({js: ["notes.js"]});

var outputmode = getQParamInt("outputmode", 0);

var this_cnt = cnt.func_enabled_contract(cnt_key); // Wat mag ik zoal op dit contract.
user.auth_required_or_abort(this_cnt.canReadNotes);

var cnt_info = cnt.cnt_contract_info(cnt_key);
// Afgehandeld:  1=Gesloten.
var afgehandeld = cnt_info.contract_status == 1;

var kenmerk_key = -1;
if (cnt_key > 0)
{
  // Als ik canReadNotes heb dan heb ik canUSEread en/of canMANread rechten.
  // Wat mag ik op  basis van mijn autorisatie (potentieel) zien, bepaal mijn rolcode-masker
  var myreadrolcode = 0 + (this_cnt.canMANread ? 1 : 0)
                        + (this_cnt.canUSEread ? 2 : 0);

  // Is er een bijlage kenmerk?
  var sql = "SELECT k.cnt_kenmerk_key"
          + "  FROM cnt_srtkenmerk t"
          + "     , cnt_kenmerk k"
          + "     , cnt_contract c"
          + " WHERE (c.ins_discipline_key = k.cnt_srtcontract_key OR k.cnt_srtcontract_key IS NULL)"
          + "   AND k.cnt_kenmerk_niveau IN ('C', 'S')"
          + "   AND k.cnt_srtkenmerk_key = t.cnt_srtkenmerk_key"
          + "    AND k.cnt_kenmerk_verwijder IS NULL"
          + "   AND t.cnt_srtkenmerk_verwijder IS NULL"
          + "   AND c.cnt_contract_key = " + cnt_key
          + "   AND BITAND(k.cnt_kenmerk_rolcode, " + myreadrolcode + ") > 0 "
          + "   AND (k.cnt_kenmerk_verplicht IS NULL"
          + "     OR k.cnt_kenmerk_verplicht = 0)"
          + "   AND t.cnt_srtkenmerk_kenmerktype = 'M'"
          + "   AND cnt_kenmerk_toonbaar IS NULL"
          + " ORDER BY cnt_kenmerk_volgnummer"
          + "     , k.cnt_kenmerk_niveau";

  var oRs = Oracle.Execute(sql);
  if (!oRs.eof)
  {
    kenmerk_key = oRs("cnt_kenmerk_key").Value;
  }
  oRs.Close();

  var upload_url = protectQS.create("../Shared/BijlagenForm.asp?module=CNT&multi=1&key=" + cnt_key + "&kenmerk_key=" + kenmerk_key);
}

notes.show_note2("CNT", cnt_key, kenmerk_key, this_cnt, afgehandeld, upload_url);

%>
<% ASPPAGE_END(); %>
