<% /*
     $Revision$
     $Id$

    File:        imp_list_rap.inc
    Description: Definieert de serverside functie imp_list_rap() die een rapportage lijst van een importfunctie toont die
                 voldoen aan de gegeven parameters/criteria, binnen de readautorisaties van de user.
    Parameters:  -
    Context:     -

    Note:        -

*/ %>
<!-- #include file="../Shared/resultset_table_v2.inc" -->
<!-- #include file="imp.inc" -->

<%
FCLTHeader.Requires({ plugins:["suggest", "jQuery"],
                      js: ["./imp_list.js"]
                    });

function imp_list_rap(params)
{
  var import_key = params.import_key; // Importfunctie key
  var rapfilter_arr = params.rapfilter_arr;

  // Heb ik rechten om rapportage te zien
  var this_imp = imp.func_enabled_import(import_key);
  user.auth_required_or_abort(this_imp.canReadAny);
%>

  <html>
    <head>
<%
      FCLTHeader.Generate({ outputmode: params.outputmode });
%>
    </head>

    <body id="listbody">
<%
      var sql = "SELECT imp_log_datum"
              + ", imp_log_status"
              + ", imp_log_omschrijving"
              + ", imp_log_hint"
              + " FROM imp_log"
              + " WHERE fac_import_key = " + import_key;

      if (rapfilter_arr.length)
      {
        for (i = 0; i < rapfilter_arr.length; i++)
        {
          rapfilter_arr[i] = safe.quoted_sql(rapfilter_arr[i]);
        }
        sql += " AND imp_log_status IN (" + rapfilter_arr.join(",") + ")";
      }
      if (params.searchtext)
      {
        sql += " AND (   UPPER(imp_log_omschrijving) LIKE " + safe.quoted_sql_wild("%" + params.searchtext + "%")
             + "      OR UPPER(imp_log_hint) LIKE " + safe.quoted_sql_wild("%" + params.searchtext + "%")
             + "     )";
      }

      sql += " ORDER BY imp_log_status"
           + ", imp_log_key"
           + ", imp_log_omschrijving"
           + ", imp_log_hint";

      /**********************************
       * Callback functies ResultsetTable
       *********************************/

      var rst = new ResultsetTable({ keyColumn: "imp_log_datum",
                                     sql: sql,
                                     ID: "impraptable",
                                     filterParams: params,
                                     outputmode: params.outputmode,
                                     title: L("lcl_imp_import_rapportage"),
                                     showAll: params.showall
                                    });

      rst.addColumn(new Column({caption: L("lcl_imp_rap_datum"), content: "imp_log_datum", datatype: "datetime", nowrap: true}));
      rst.addColumn(new Column({caption: L("lcl_imp_rap_status"), content: "imp_log_status"}));
      rst.addColumn(new Column({caption: L("lcl_imp_rap_omschrijving"), content: "imp_log_omschrijving"}));
      rst.addColumn(new Column({caption: L("lcl_imp_rap_hint"), content: "imp_log_hint"}));

      var cnt = rst.processResultset();
}
%>