<% /*
    $Revision$
    $Id$

    File:           model_faq_discipline.inc

    Description:    Model voor kennisbankitems disciplines

    Context:

    Notes:          Nu nog geen faq_disc_params.
                    Als de tabel faq_disc_params wordt toegevoegd moet in scafflding_show
                    '&& module != "facq"' in de regel 'if (module != "mrk" && module != "cht" && module != "faq")'
                    verwijderd worden.
                    Dan moet model_faq_discipline() ook aangepast worden zodat de disc_params
                    met ins_tab_discipline wordt gejoind en er als het ware 1 tabel van maakt.
*/
%>
<!-- #include file="../mgt/mgt.inc"-->
<%

function model_faq_discipline(disc_key, params)
{
  this.records_name = "knowledgedisciplines";
  this.record_name = "knowledgediscipline";
  this.table = "ins_tab_discipline";
  this.primary = "ins_discipline_key";
  this.soft_delete = "ins_discipline_verwijder";
  this.autfunction = "WEB_FAQMGT";
  this.record_title = L("faq_discipline");
  this.records_title = L("faq_discipline_m");

  this.fields = {
      "id": {
          "dbs": "ins_discipline_key",
          "label": L("lcl_key"),
          "typ": "key",
          "required": true,
          "seq": "ins_s_ins_discipline_key"
      },
      "module": {
          "dbs": "ins_discipline_module",
          "label": L("faq_discipline_module"),
          "typ": "varchar",
          "hidden_fld": true,
          "defaultvalue": "FAQ"
      },
      "name": {
          "dbs": "ins_discipline_omschrijving",
          "label": L("faq_discipline_omschrijving"),
          "typ": "varchar",
          "translate": true,
          "required": true
      },
        "symbolname": {
            "dbs": "ins_discipline_image",
            "typ": "icon",
            "module": "FAQ",
            "label": L("lcl_symbol_name")
        },
        "externnr": {
            "dbs": "ins_discipline_externnr",
            "typ": "varchar",
            "label": L("extern_nr")
        },
        "externsyncdate": {
            "dbs": "ins_discipline_externsyncdate",
            "typ": "datetime",
            "label": L("extern_syncdate"),
            "hidden_fld": true,
            "readonly": !(user.has("WEB_FACTAB") || user.has("WEB_FACXNR"))
        }
  };

    this.hook_post_post = function (params, obj, key)
    {
        var org_disc_key = getQParamInt("id", -1);
        var clone_auth = getQParamInt("clone_auth", 0) == 1;
        if (clone_auth)
        {   // Ook de autorisatie van de oude discipline kopieren
            mgt.clone_authorization(key, org_disc_key);
        }
    }

  this.REST_GET    = generic_REST_GET(this,  // Let op: de originele _model
                                         { "GET": {
                                                   wheres: [ "ins_tab_discipline.ins_discipline_module = 'FAQ'"
                                                           ]
                                                  }
                                         }
                                     )

  this.REST_POST   = generic_REST_POST(this);
  this.REST_PUT    = generic_REST_PUT(this);
  this.REST_DELETE = generic_REST_DELETE(this, {});
}
%>