239 lines
7.4 KiB
C++
239 lines
7.4 KiB
C++
<% /*
|
|
$Revision$
|
|
$Id$
|
|
|
|
File: model_bgt_budget.inc
|
|
|
|
Description: Model voor bgt_budget
|
|
|
|
Context:
|
|
|
|
Notes:
|
|
*/
|
|
%>
|
|
<!-- #include file="../bgt/bgt_tools.inc" -->
|
|
<!-- #include file="../api2/model_bgt_budgetmutatie.inc" -->
|
|
<%
|
|
var v_checkauth = getQParamInt("id", 0) > 0;
|
|
|
|
function model_bgt_budget()
|
|
{
|
|
this.records_name = "budgets";
|
|
this.record_name = "budget";
|
|
this.table = "bgt_budget";
|
|
this.primary = "bgt_budget_key";
|
|
this.autfunction = "WEB_BGTUSE";
|
|
this.record_title = L("bgt_budget");
|
|
this.records_title = L("bgt_budget_m");
|
|
|
|
this.fields = {
|
|
"id": {
|
|
"dbs": "bgt_budget_key",
|
|
"label": L("lcl_key"),
|
|
"typ": "key",
|
|
"hidden_fld": true,
|
|
"required": true,
|
|
"filter": "exact",
|
|
"seq": "bgt_s_bgt_budget_key"
|
|
},
|
|
"budgetdiscipline": {
|
|
"dbs": "ins_discipline_key",
|
|
"label": L("bgt_discipline_omschrijving"),
|
|
"typ": "key",
|
|
"required": true,
|
|
"insertonly": true,
|
|
"foreign": bgt_budgetdiscipline_foreign(v_checkauth),
|
|
"showtransit": true
|
|
},
|
|
"budgetproject": {
|
|
"dbs": "bgt_project_key",
|
|
"label": L("bgt_project_omschrijving"),
|
|
"typ": "key",
|
|
"required": true,
|
|
"insertonly": true,
|
|
"foreign": bgt_budgetproject_foreign(),
|
|
"showtransit": true
|
|
},
|
|
"budgetcostcategory": {
|
|
"dbs": "bgt_kostenrubriek_key",
|
|
"label": L("bgt_kostenrubriek_oms"),
|
|
"typ": "key",
|
|
"required": true,
|
|
"insertonly": true,
|
|
"foreign": bgt_budgetcostcategory_foreign(),
|
|
"showtransit": true
|
|
},
|
|
"costtypegroup": {
|
|
"dbs": "prs_kostensoortgrp_key",
|
|
"label": L("prs_kostensoortgrp_key"),
|
|
"typ": "key",
|
|
"required": false,
|
|
"insertonly": true,
|
|
"foreign": bgt_costtypegroup_foreign(),
|
|
"showtransit": true,
|
|
"LOVinit": "",
|
|
"filter": "exact"
|
|
},
|
|
"costtype": {
|
|
"dbs": "prs_kostensoort_key",
|
|
"label": L("prs_kostensoort_key"),
|
|
"typ": "key",
|
|
"required": false,
|
|
"insertonly": true,
|
|
"foreign": bgt_costtype_foreign(),
|
|
"showtransit": true
|
|
},
|
|
"amountoriginal": {
|
|
"dbs": "bgt_budget_bedrag_origineel",
|
|
"sql": "(BGT.getBudgetOpDatum(bgt_budget.bgt_budget_key, 0, NULL))",
|
|
"label": L("bgt_budget_origineel"),
|
|
"typ": "float",
|
|
"iscurrency": true,
|
|
"total": true
|
|
},
|
|
"amountmutation": {
|
|
"dbs": "bgt_budget_bedrag_mutatie",
|
|
"sql": "(BGT.getBudgetMutaties(bgt_budget.bgt_budget_key, 0, NULL, NULL))",
|
|
"label": L("bgt_budget_mutaties"),
|
|
"typ": "float",
|
|
"iscurrency": true,
|
|
"total": true
|
|
},
|
|
"amount": {
|
|
"dbs": "bgt_budget_bedrag",
|
|
"label": L("bgt_budget_bedrag"),
|
|
"typ": "float",
|
|
"iscurrency": true,
|
|
"total": true,
|
|
"required": true
|
|
},
|
|
"vat": {
|
|
"dbs": "bgt_budget_btwbedrag",
|
|
"label": L("bgt_budget_btwbedrag"),
|
|
"typ": "float",
|
|
"iscurrency": true,
|
|
"total": true,
|
|
"required": true
|
|
},
|
|
"amountincl": {
|
|
"dbs": "bgt_budget_bedrag_incl",
|
|
"sql": "bgt_budget_bedrag + bgt_budget_btwbedrag",
|
|
"label": L("lcl_fin_total_sum"),
|
|
"typ": "float",
|
|
"readonly": true,
|
|
"sqlshow": true,
|
|
"iscurrency": true,
|
|
"total": true,
|
|
"defaultvalue": "0",
|
|
"clone": false
|
|
},
|
|
"contingency": {
|
|
"dbs": "bgt_budget_isreserve",
|
|
"label": L("bgt_budget_isreserve"),
|
|
"typ": "check0",
|
|
"defaultvalue": 0
|
|
},
|
|
"account": {
|
|
"dbs": "prs_kostenplaats_key",
|
|
"label": L("bgt_budget_account"),
|
|
"typ": "key",
|
|
"foreign": bgt_account_foreign(),
|
|
"emptyoption": null
|
|
},
|
|
"begin": {
|
|
"dbs": "bgt_budget_begin",
|
|
"label": L("bgt_budget_begin"),
|
|
"typ": "date",
|
|
"required": false
|
|
},
|
|
"end": {
|
|
"dbs": "bgt_budget_eind",
|
|
"label": L("bgt_budget_eind"),
|
|
"typ": "date",
|
|
"required": false
|
|
},
|
|
"costgroup": {
|
|
"dbs": "prs_kostenplaatsgrp_key",
|
|
"label": L("bgt_budget_accountgrp"),
|
|
"typ": "key",
|
|
"foreign": {
|
|
"tbl": "prs_kostenplaatsgrp",
|
|
"key": "prs_kostenplaatsgrp_key",
|
|
"desc": "prs_kostenplaatsgrp_oms"
|
|
},
|
|
"hidden_fld": true
|
|
}
|
|
};
|
|
|
|
this.edit = {
|
|
// "modal": true
|
|
};
|
|
|
|
this.list = {
|
|
"columns": [
|
|
"budgetcostcategory",
|
|
"costtypegroup",
|
|
"costtype",
|
|
"amount",
|
|
"vat"
|
|
]
|
|
};
|
|
|
|
|
|
this.hook_pre_edit = function (obj, fld)
|
|
{
|
|
var btw_data = {};
|
|
if (obj.id > -1)
|
|
{
|
|
fld.amount.readonly = true;
|
|
fld.vat.readonly = true;
|
|
|
|
var sql = "SELECT s.prs_kostensoort_btw"
|
|
+ " , f.fin_btwtabelwaarde_perc"
|
|
+ " FROM bgt_budget b"
|
|
+ " , prs_kostensoort s"
|
|
+ " , fin_btwtabelwaarde f"
|
|
+ " WHERE s.fin_btwtabelwaarde_key = f.fin_btwtabelwaarde_key"
|
|
+ " AND b.prs_kostensoort_key = s.prs_kostensoort_key"
|
|
+ " AND b.bgt_budget_key = " + obj.id;
|
|
var oRs = Oracle.Execute(sql);
|
|
if (!oRs.eof)
|
|
{
|
|
btw_data.btw_inc = oRs("prs_kostensoort_btw").Value;
|
|
btw_data.btw_val = oRs("fin_btwtabelwaarde_perc").Value;
|
|
}
|
|
oRs.Close();
|
|
}
|
|
else
|
|
{
|
|
// Een nieuw budget heeft nog geen origineel- en mutatie-bedrag.
|
|
delete fld.amountoriginal;
|
|
delete fld.amountmutation;
|
|
}
|
|
%>
|
|
<script type="text/javascript">
|
|
var cur_mode = "budget_edit"; // Laat alleen de kostensoorten zien waaraan nog geen budget gekoppeld is.
|
|
var btw_data = <%=JSON.stringify(btw_data)%>;
|
|
<% if (obj.budgetdiscipline) { %> var budgetdiscipline = "<%=obj.budgetdiscipline.id%>"; <% } %>
|
|
<% if (obj.budgetproject) { %> var budgetproject = "<%=obj.budgetproject.id%>"; <% } %>
|
|
</script>
|
|
<%
|
|
}
|
|
|
|
this.hook_pre_post = function(params, obj)
|
|
{
|
|
// Wordt alleen gebruikt bij toevoegen.
|
|
}
|
|
|
|
|
|
this.hook_pre_put = function(params, obj, key)
|
|
{ // Zoek bij wijzigen van kostenplaats de kostenplaatsgrp_key op
|
|
}
|
|
|
|
|
|
this.REST_GET = generic_REST_GET(this);
|
|
this.REST_POST = generic_REST_POST(this);
|
|
this.REST_PUT = generic_REST_PUT(this);
|
|
this.REST_DELETE = generic_REST_DELETE(this);
|
|
}
|
|
%> |