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

<!--#include file="../Shared/common.inc"-->
<!--#include file="../Shared/resultset_table_v2.inc" -->
<!--#include file="../mld/mld.inc" -->
<%
FCLTHeader.Requires({ plugins:[],
                      js: ["../mld/mld_list.js", "jquery-ui.js"]});

var mld_key = getQParamInt("mld_key");
var urole = getQParamSafe("urole");

var this_mld = mld.func_enabled_melding(mld_key); // Wat heb ik zoal aan rechten op deze specifieke melding
user.auth_required_or_abort(this_mld.canReadAny);

%>
<html>
    <head>
<%
   FCLTHeader.Generate();
%>
      <script type="text/javascript">
        // Text strings used by mld_list.js
        var urole = "<%=urole%>";
        var mld_key = "<%=mld_key%>";

        function mld_continue()
        {
          FcltMgr.openDetail("appl/mld/mld_melding.asp?urole=fo&mld_key=" + mld_key + "&mld_continue=1",  L("lcl_mld_continuation_mld"));
        }

      </script>
    </head>
<body id="listbody">
<%
  function fncolStatus(oRs)
  {
    return mld.getmldstatustext(oRs("mld_melding_status").Value, oRs("mld_melding_conceptstatus").Value);
  }

  // Workflow Details for Root call of a workflow sequence
  // Or follow-up calls for this one
 sql= "SELECT mld_melding_key"
    + ",      mld_melding_datum"
    + ",      mld_melding_onderwerp"
    + ",      mld_melding_omschrijving"
    + ", CASE "
      + " WHEN sd.ins_srtdiscipline_prefix IS NULL"
      + " THEN ''"
      + " ELSE sd.ins_srtdiscipline_prefix || '-'"
      + " END"
      + " || "+ lcl.xsqla('di.ins_discipline_omschrijving', 'di.ins_discipline_key')
    + ", " + lcl.xsqla('stdm.mld_stdmelding_omschrijving','stdm.mld_stdmelding_key')
    + ",      "+mld.gettrackdate_sql('MLDAFM')+" mld_melding_afgemeld"
    + ",      mld_melding_opmerking"
    + ",      m.mld_melding_status"
    + ", " + lcl.xsql('di2.ins_discipline_omschrijving', 'di2.ins_discipline_key')+" behandelteam"
    + ",      m.mld_melding_conceptstatus"
    + "  FROM mld_melding m"
    + ",      mld_stdmelding stdm"
    + ",      mld_discipline di"   // vakgroep
    + ",      mld_discipline di2"  // behandelteam
    + ",      ins_srtdiscipline sd"
    + " WHERE mld_melding_start_key=" + mld_key
    + "   AND di.ins_srtdiscipline_key = sd.ins_srtdiscipline_key"
    + "   AND m.mld_stdmelding_key = stdm.mld_stdmelding_key"
    + "   AND di.ins_discipline_key = stdm.mld_ins_discipline_key"
    + "   AND di2.ins_discipline_key(+) = m.mld_ins_discipline_key"
    + "   AND m.mld_melding_key <> "+ mld_key                 // do not show ourselves
    + " ORDER BY 1";

    buttons = [];

    buttons.push({ icon: "fa-columns",  title: L("lcl_scf_columns"), action: "openColumns()"});

    if (this_mld.canContinue)
        buttons.push({ title: L("lcl_add"), icon: "fa-plus", action:"mld_continue()", tooltip: L("lcl_continue_hint") });

    var rst = new ResultsetTable({ sql:sql,
                                   tabs_code: "workflowinfo-" + urole,
                                   keyColumn: "mld_melding_key",
                                   ID: "workflowtable",
                                   buttons: buttons,
                                   title: L("lcl_mld_frame_workflow")
                                 });

    rst.addColumn(new Column({caption: L("lcl_mld_date"), content: "mld_melding_datum", datatype:"date"}));
    rst.addColumn(new Column({caption: L("lcl_mld_number"), content: "mld_melding_key"}));
    rst.addColumn(new Column({caption: L("lcl_vakgroup"), content: "ins_discipline_omschrijving"}));
    rst.addColumn(new Column({caption: L("lcl_mld_complain"), content: "mld_stdmelding_omschrijving", combine: true}));
    rst.addColumn(new Column({caption: L("lcl_mld_subject"), content: "mld_melding_onderwerp"}));
    rst.addColumn(new Column({caption: L("lcl_txt"), content: "mld_melding_omschrijving", combine: true}))
    rst.addColumn(new Column({caption: L("lcl_status"), content: fncolStatus, colName: "mld_melding_status"}));
    rst.addColumn(new Column({caption: L("mld_processing_group"), content: "behandelteam", showDefault: false}));
    rst.addColumn(new Column({caption: L("lcl_mld_st_closed"), content: "mld_melding_afgemeld", datatype: "date"}));
    rst.addColumn(new Column({caption: L("lcl_mld_inf_Opmerking"), content: "mld_melding_opmerking"}));

    rst.addAction({action: "mld_edit", caption: L("lcl_edit"), isDefault: true});

    var cnt = rst.processResultset();
%>
</body>
</html>
<% ASPPAGE_END(); %>
