<%@language = "javascript" %>

<!-- #include file="../scf/scaffolding.inc" -->
<!-- #include file="../api2/model_bes_srtdeel.inc" -->

<%
var srtdeel_key = getQParamInt("id", -1);
var scf_mode = getQParam("mode", "");
var catalogus = getQParamInt("catalog", -1);

var this_model = new model_bes_srtdeel(catalogus);
var scf_params = {
        "search": {
            "autosearch": false,
            "filters": [
                "name",
                "commoditynumber",
                "supplier",
                "catalog",
                "_enddate"
            ],
            "transit": [
                "supplier",
                "catalog"
            ]
        },
        "list": {
            "columns": [
                "catalog",
                "articlegroup",
                "commoditynumber",
                "supplier",
                "name",
                "unit",
                "actualprice",
                "expirationdate"
            ],
            "requires": {
                "js": [
                    "../mgt/bes_srtdeel.js"
                ]
            }
        },
        "edit": {
            "modal": false,
            "requires": {
                "js": [
                    "../mgt/bes_srtdeel.js"
                ]
            }
        },
        "layout": {
            "block": [
                {   "blockid": "besArtikel",
                    "label": L("lcl_bes_srtdeelblok"),
                    "icon": "fa-box-open",
                    "ishtmlsafe": true,
                    "hidden": false,
                    "buttons": [],
                    "fields": [
                        "commoditynumber",
                        "name",
                        "catalog",
                        "articlegroup",
                        //"sequence", // Wordt afhankelijk van bestelmode toegevoegd.
                        "unit",
                        "stockfactor",
                        "image",
                        "product",
                        "stockroomlocation",
                        "remark"
                    ]
                },
                {   "blockid": "besArtikelBestel",
                    "label": L("lcl_bes_srtdeelbestelblok"),
                    "icon": "fa-cart-shopping",
                    "ishtmlsafe": true,
                    "hidden": false,
                    "buttons": [],
                    "fields": [
                        "supplier",
                        "expirationdate",
                        "multiple",
                        "minimumorder",
                        "maximumorder",
                        "vat",
                        "editdays",
                        "canceldays",
                        "personalised",
                        "preview",
                        "minimumstock",
                        "maximumstock",
                        "maximumbestel",
                        "pacelistgroup",
                        "depositpct",
                        "objecttype"
                    ]
                },
                {
                    "blockid": "mldHidden",
                    "label": L("lcl_mld_hidden_fields"),
                    "hidden": true,
                    "fields": [
                        "created",
                        //"sequence", // Wordt afhankelijk van bestelmode toegevoegd.
                        "dimension",
                        "deviationpct",
                        "actualprice",
                        "_enddate"
                    ]
                }
            ]
        },
        "wrap": {
            "frames": [
                {
                    url: "../bes/bes_srtdeel_prijs_list.asp?ebedded=1&srtdeel_key={0}",
                    title: L("lcl_bes_prijsverloop"),
                    autfunction: "WEB_BESMSU"
                }
            ]
        }
    };


if (scf_mode == "list")
{
%>
    <script>
        var catalog = <%=catalogus%>;
    </script>
<%
}

this_model.hook_pre_search = function (fld)
{
    fld.supplier.foreignfiltercode = "BL";
}

var bestelmode = 0;
if (catalogus > 0)
{
  var sql = "SELECT bes_disc_params_bestelmode"
          + "  FROM bes_disc_params"
          + " WHERE bes_ins_discipline_key = " + catalogus;
  var oRs = Oracle.Execute(sql);
  bestelmode = oRs("bes_disc_params_bestelmode").Value;
  oRs.Close();
}

if (bestelmode == 3)
  scf_params.layout.block[0].fields.splice(4, 0, "sequence");
else
  scf_params.layout.block[2].fields.splice(1, 0, "sequence");

scaffolding(this_model, scf_params);
%>
<% ASPPAGE_END(); %>
