<% /*
    $Revision$
    $Id$

    File:           model_approvals.asp
    Description:
    Parameters:
    Note:           Een approval is niet echt een data-entiteit

*/ %>

<!-- #include file="../fac/fac.inc" -->
<!-- #include file="../fac/fac_fiattering_list.inc" -->
<!-- #include file="../cnt/cnt.inc" -->
<%
// Fiatteringen
// fe = van mij (als budgethouder bv)
// fobo = - (ga maar naar invoices, orders etc?)

model_approvals =
{
    table: "approval",
    primary: "aanvraagnummer",
    records_name: "approvals",
    record_name: "approval",
    fields : { "id"           : {  dbs: "request_key",              typ: "key"      },
               "name"         : {  dbs: "aanvraagnummer",           typ: "varchar"  },
               "date"         : {  dbs: "datum",                    typ: "datetime" },
               "requestor"    : {  dbs: "prs_perslid_naam_full",    typ: "varchar"  },
               "amount"       : {  dbs: "bedrag",                   typ: "float",   "iscurrency": true    },
               "module"       : {  dbs: "module",                   typ: "varchar"  },
               "type"         : {  dbs: "type",                     typ: "varchar"  },
               //"status"       : {  dbs: "fiatstatus",               typ: "varchar"},
               "status"       : {  dbs: "statuskey",                typ: "key"      },
               "sortdate"     : {  dbs: "sortdate",                 typ: "date"     },
               "category"     : {  dbs: "categorie",                typ: "varchar"  },
               "approver"     : {  dbs: "fiatteur",                 typ: "varchar"  },
               "poparent"     : {  dbs: "bes_bestelling_parentkey", typ: "key"},
               "prefix"       : {  dbs: "prefix",                   typ: "varchar"  },
               "supplier"     : {  dbs: "uitvoerende",              typ: "varchar"  },
               "location"     : {  dbs: "locatie",                  typ: "varchar"  },
               "building"     : {  dbs: "gebouw",                   typ: "varchar"  },
               "terrain"      : {  dbs: "terrein",                  typ: "varchar"  }
             },

    REST_GET: function _GET(params)
        {
            var betreft = getQParamArray("betreft", ["BES", "CNT", "FIN", "MLDOF", "MLDOP"]); // Betreft module BES, CNT, FIN, MLDOF of MLDOP.
            var statussen = (params.filter.status||"o").split(",");
            var fparams = { betreft: params.filter.betreft?params.filter.betreft.split(","):[],
                            getopen: inArray("o", statussen),
                            getclosed: inArray("c", statussen),
                            getrejected: inArray("r", statussen)}
            var sql = fiattering_sql(fparams);
            var json = api2.sql2json (params, sql, model_approvals);
            return json;
        }
}
%>