FSN#39055 BCS/2000 functionaliteit in FACILITOR - customization

svn path=/Website/trunk/; revision=33765
This commit is contained in:
Erik Groener
2017-05-10 08:31:44 +00:00
parent 4bbce877d8
commit 1024184e5c
6 changed files with 227 additions and 35 deletions

View File

@@ -71,7 +71,8 @@ function model_bgt_budgetmutatie()
"label": L("bgt_budgetmutatie_door"),
"typ": "key",
"foreign": "PRS_PERSLID",
"required": true
"required": true,
"defaultvalue": user_key
},
"budgetfrom": {
"dbs": "bgt_budget_key_van",
@@ -81,8 +82,7 @@ function model_bgt_budgetmutatie()
"tbl": "(" + budgetnaam_sql + ")",
"key": "bgt_budget_key",
"desc": "bgt_budget_naam"
},
"required": true
}
},
"budgetto": {
"dbs": "bgt_budget_key_naar",
@@ -92,26 +92,35 @@ function model_bgt_budgetmutatie()
"tbl": "(" + budgetnaam_sql + ")",
"key": "bgt_budget_key",
"desc": "bgt_budget_naam"
},
"required": true
}
},
"amountfrom": {
"dbs": "bgt_budget_bedrag_van",
"label": L("bgt_budgetmutatie_bedrag"),
"typ": "float",
"iscurrency": true,
"total": true,
"required": true,
"hidden": true,
"hidden_fld": true
},
},
"vatfrom": {
"dbs": "bgt_budget_btwbedrag_van",
"label": L("bgt_budgetmutatie_btwbedrag"),
"typ": "float",
"iscurrency": true,
"hidden": true,
"hidden_fld": true
},
"amountto": {
"dbs": "bgt_budget_bedrag_naar",
"label": L("bgt_budgetmutatie_bedrag"),
"typ": "float",
"iscurrency": true,
"total": true,
"required": true
"iscurrency": true
},
"vatto": {
"dbs": "bgt_budget_btwbedrag_naar",
"label": L("bgt_budgetmutatie_btwbedrag"),
"typ": "float",
"iscurrency": true
},
"amountdifference": {
"dbs": "bgt_budget_bedrag_verschil",
@@ -138,6 +147,7 @@ function model_bgt_budgetmutatie()
]
};
this.hook_pre_edit = function (obj, fld)
{
fld.amountto.label = L("bgt_budgetmutatie_bedrag");
@@ -160,11 +170,25 @@ function model_bgt_budgetmutatie()
this.hook_pre_post = function (params, jsondata)
{
if (jsondata.budgetfrom == jsondata.budgetto)
abort_with_warning("'Van budget' en 'Naar budget' zijn hetzelfde.");
abort_with_warning(L("bgt_budgetmutatie_err1").format(L("bgt_budgetmutatie_van"), L("bgt_budgetmutatie_naar")));
if ((!jsondata.amountto || jsondata.amountto == 0) && (!jsondata.vatto || jsondata.vatto == 0))
abort_with_warning(L("bgt_budgetmutatie_err2").format(L("bgt_budgetmutatie_bedrag"), L("bgt_budgetmutatie_btwbedrag")));
}
this.REST_GET = generic_REST_GET(this);
var budget_key = getQParamInt("budgetcommon", -1);
if (budget_key > -1)
{
this.REST_GET = generic_REST_GET(this, {
"GET": {
"wheres": ["bgt_budget_key_van = {0} or bgt_budget_key_naar = {0}".format(budget_key)]
}
});
}
else
{
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);

View File

@@ -50,7 +50,7 @@ function model_prs_kostensoort()
"multiedit": true
},
"name": {
"dbs": "prs_kostensoort_opmerking",
"dbs": "prs_kostensoort_oms",
"label": L("prs_kostensoort_opmerking"),
"typ": "varchar",
"required": true, /* proberen */
@@ -58,11 +58,11 @@ function model_prs_kostensoort()
"filter": "like",
"multiedit": true
},
"code": {
"dbs": "prs_kostensoort_oms",
"remark": {
"dbs": "prs_kostensoort_opmerking",
"label": L("prs_kostensoort_oms"),
"typ": "varchar",
"required": true,
"required": (S("bgt_enabled") ? false : true),
"filter": "like"
},
"altcode": {
@@ -84,12 +84,22 @@ function model_prs_kostensoort()
"typ": "check",
"multiedit": true
},
"vat": {
"inclvat": {
"dbs": "prs_kostensoort_btw",
"label": L("prs_kostensoort_btw"),
"typ": "check",
"multiedit": true
},
"vat": {
"dbs": "fin_btwtabelwaarde_key",
"label": L("lcl_btw_percentage"),
"typ": "key",
"foreign": {
"tbl": "fin_btwtabelwaarde",
"key": "fin_btwtabelwaarde_key",
"desc": "fin_btwtabelwaarde_oms"
}
},
"costcentre": {
"dbs": "prs_kostenplaats_key",
"label": L("prs_kostenplaats_key"),
@@ -114,6 +124,7 @@ function model_prs_kostensoort()
if (S("bgt_enabled")) // alleen voor budgetcontrole
{
delete this.fields.charge;
this.includes["budget"] = {
"model": new model_bgt_budget(),
"joinfield": "costtype",
@@ -122,6 +133,20 @@ function model_prs_kostensoort()
this.print = { xmlnode: "budget", where: "kostensoort"};
}
else
{
delete this.fields.vat;
}
// this.hook_pre_edit = function(obj, fld)
// {
if (!S("bgt_enabled"))
{
// verwijder het btw-percentage veld.
// btw-waarde zichtbaar
// als inc_btw = 1 dan weer niet, en btw-waarde = leeg (tenminste bij opslaan
}
// }
this.REST_GET = generic_REST_GET(this);

65
APPL/BGT/bgt_budget.asp Normal file
View File

@@ -0,0 +1,65 @@
<%@language = "javascript" %>
<% /*
$Revision$
$Id$
File: bgt_budget.asp
Description: aanroep van model_bgt_budget
Context:
Notes:
*/
%>
<!-- #include file="../scf/scaffolding.inc" -->
<!-- #include file="../api2/model_bgt_budget.inc" -->
<%
var this_model = new model_bgt_budget();
scaffolding(this_model,
{
"search": {
"autosearch": true,
"filters": [
"budgetdiscipline",
"budgetproject",
"budgetcostcategory",
"costtypegroup",
"costtype"
],
"requires": {
"js": ["../bgt/bgt_budget.js"]
}
},
"list": {
"columns": [
"budgetproject",
"budgetcostcategory",
"costtypegroup",
"costtype",
"amount",
"vat"
],
"orderby": [
"budgetproject",
"budgetcostcategory",
"costtypegroup",
"costtype"
]
},
"edit": {
"requires": {
"js": ["../bgt/bgt_budget.js"]
}
// ,
// "modal": true
}
,
"wrap": {
"no_default_frames": true,
"frames": [ { url: "./bgt_budgetmutatie.asp?mode=list&budgetcommon={0}" } ]
// "frames": [ { url: "./bgt_budget.asp?mode=list&model=mutations&budget={0}" } ] // bij toevoegen wordt bgt_budget.asp aangeroepen!!
}
});
%>

View File

@@ -9,6 +9,8 @@ function init_budget()
$("#budgetcostcategory").change(function() {change_rubriek(); });
$("#costtypegroup").change(function() {change_groep(); });
$("#costtype").change(function() {change_soort(); });
$("#amount").change(function() {change_amount(); });
$("#account").change(function() {change_account(); });
var init_niveau = "";
var init_key = -1;
@@ -26,11 +28,25 @@ function init_budget()
parent_key: -1,
init_key: init_key
},
re_init);
re_init_soort);
}
init_niveau = "";
init_key = -1;
if ($("#account").val() != -1) { init_niveau = "KP"; init_key = $("#account").val(); }
if (init_key > 0)
{
$.getJSON( "../bgt/get_bgt_info_ajax.asp",
{ req_info: "initsearch",
niveau: init_niveau,
parent_key: -1,
init_key: init_key
},
re_init_plaats);
}
}
function re_init(data)
function re_init_soort(data)
{
fill_rubriekselector("D", -1 , data.parents.D);
fill_rubriekselector("P", data.parents.D, data.parents.P);
@@ -39,6 +55,12 @@ function re_init(data)
fill_rubriekselector("S", data.parents.G, data.parents.S);
}
function re_init_plaats(data)
{
var init_key = ($("#account").val() != -1 ? $("#account").val() : -1);
fill_plaatsselector("KP", data.parents.P, init_key);
}
function change_discipline()
{
var discipline_key = $("#budgetdiscipline").val();
@@ -53,6 +75,7 @@ function change_project()
process_info({niveau:"G",lov:[]});
process_info({niveau:"S",lov:[]});
fill_rubriekselector("R", project_key);
fill_plaatsselector("KP", project_key);
}
function change_rubriek()
{
@@ -70,6 +93,36 @@ function change_soort()
var soort_key = $("#costtype").val();
if ($("#contingency").length)
$("#contingency").prop("disabled", (soort_key > 0 ? false: true) );
if ($("#costtype option:selected").attr("incl_btw") == "1")
{
$("#vat").val(null);
$("#vat").closest("tr").hide();
}
else
{
$("#vat").closest("tr").show();
}
}
function change_amount()
{
// bereken btwbedrag (vat) adhv btw-percentage bij kostensoort.
var btw_incl = $("#costtype option:selected").attr("incl_btw") == "1";
var btw_perc = $("#costtype option:selected").attr("perc_btw");
if (btw_perc && !isNaN(parseFloat(btw_perc)) && !btw_incl)
{
var perc = 1 + (parseFloat(btw_perc) / 100);
var amount = $("#amount").val();
$("#vat").val(amount * perc);
}
}
function change_account()
{
// Vul de prs_kostenplaatsgrp_key
var costgrp_key = $("#account option:selected").attr("par_key");
$("#costgroup").val(costgrp_key);
}
function fill_rubriekselector(niveau, parent_key, init_key)
@@ -83,28 +136,50 @@ function fill_rubriekselector(niveau, parent_key, init_key)
process_info);
}
function fill_plaatsselector(niveau, parent_key, init_key)
{
$.getJSON( "../bgt/get_bgt_info_ajax.asp",
{ req_info: "plaatssearch",
niveau: niveau,
parent_key: parent_key,
init_key: init_key
},
process_info);
}
function process_info(data)
{
var select;
switch(data.niveau)
{
case "D": select = $("#budgetdiscipline"); break;
case "P": select = $("#budgetproject"); break;
case "R": select = $("#budgetcostcategory"); break;
case "G": select = $("#costtypegroup"); break;
case "S": select = $("#costtype"); break;
case "D": select = $("#budgetdiscipline"); break;
case "P": select = $("#budgetproject"); break;
case "R": select = $("#budgetcostcategory"); break;
case "G": select = $("#costtypegroup"); break;
case "S": select = $("#costtype"); break;
case "KP": select = $("#account"); break;
}
var add_data = "";
var sel_key = -1;
var new_lov = '<option value="-1" ></option>';
if (data.lov.length > 0)
{
for (i=0; i<data.lov.length;i++)
for (i=0; i < data.lov.length;i++)
{
var opt = data.lov[i];
new_lov += '<option value="' + opt.key + '"' + (opt.sel?"selected":"") + '>'+ safe.html(opt.oms) + '</option>';
if (opt.sel) sel_key = opt.key;
if (data.niveau == "KP")
{
add_data = ' par_key="' + opt.atr.par_key + '"';
}
else
{
add_data = ' incl_btw="' + opt.atr.btw_inc + '"'
+ ' perc_btw="' + opt.atr.btw_val + '"';
}
new_lov += '<option value="' + opt.key + '"' + (opt.sel?" selected":"") + add_data + '>'+ opt.oms + '</option>';
if (opt.sel)
sel_key = opt.key;
}
select.prop("disabled", false);
}

View File

@@ -24,7 +24,8 @@ scaffolding(this_model,
"filters": [
"mutationdate",
"budgetfrom",
"budgetto"
"budgetto",
"budgetcommon"
]
},
"list": {
@@ -34,6 +35,7 @@ scaffolding(this_model,
"budgetfrom",
"budgetto",
"amountto",
"vatto",
"amountdifference"
],
"orderby": [

View File

@@ -34,12 +34,13 @@ scaffolding(this_model,
"code",
"refcode"
]
}
/*
,
},
"edit":{
"xxxmodal": true
"requires": {
"js": [
"../mgt/prs_kostensoort.js"
]
}
}
*/
});
%>