AAIT#37411 Contract factuurschema bewerken via scaffolding
svn path=/Website/trunk/; revision=31516
This commit is contained in:
@@ -40,12 +40,16 @@ function model_cnt_factuurschema()
|
||||
"accountingperiod": {
|
||||
"dbs": "cnt_factuurschema_boekmaand",
|
||||
"typ": "varchar",
|
||||
"track": true,
|
||||
"label": L("lcl_fin_divide_period")
|
||||
"required": true,
|
||||
"label": L("lcl_fin_divide_period"),
|
||||
"friendlyname": true // accountingperiod hernoemen naar "name" is me te verwarrend
|
||||
|
||||
},
|
||||
"amount": {
|
||||
"dbs": "cnt_factuurschema_bedrag",
|
||||
"typ": "float"
|
||||
"typ": "float",
|
||||
"required": true,
|
||||
"label": L("lcl_cnt_period_sum")
|
||||
},
|
||||
"description": {
|
||||
"dbs": "cnt_factuurschema_opmerking",
|
||||
|
||||
@@ -20,16 +20,94 @@
|
||||
<%
|
||||
var this_model = model_contracts;
|
||||
|
||||
var sqltotal = "SELECT SUM (fin_factuur_totaal)"
|
||||
+ " FROM fin_factuur f"
|
||||
+ " WHERE f.fin_factuur_boekmaand = cnt_factuurschema.cnt_factuurschema_boekmaand"
|
||||
+ " AND f.cnt_contract_key = cnt_factuurschema.cnt_contract_key"
|
||||
|
||||
this_model.includes.schedule.model.fields["fintotal"] =
|
||||
{ dbs: "fintotal",
|
||||
label: L("lcl_mld_invoiced"),
|
||||
sql: "(" + sqltotal + ")",
|
||||
typ: 'float'
|
||||
}
|
||||
|
||||
if (mode == "edit" && getQParamInt("id", -1) < 0)
|
||||
{
|
||||
var cnt_key = getQParamInt("cnt_contract_key");
|
||||
var sql = "SELECT 'x'"
|
||||
+ " FROM cnt_factuurschema"
|
||||
+ " WHERE cnt_contract_key =" + cnt_key ;
|
||||
var oRs = Oracle.Execute( sql );
|
||||
var hasFactuurschema = !oRs.EOF;
|
||||
oRs.close();
|
||||
|
||||
if (!hasFactuurschema)
|
||||
{
|
||||
var sql = "SELECT cnt_contract_kosten"
|
||||
+ " , 1+TRUNC(MONTHS_BETWEEN(cnt_contract_looptijd_tot, cnt_contract_looptijd_van)) maanden"
|
||||
+ " , cnt_contract_looptijd_tot"
|
||||
+ " , cnt_contract_kosten"
|
||||
+ " FROM cnt_contract"
|
||||
+ " WHERE cnt_contract_key = " + cnt_key;
|
||||
var oRs = Oracle.Execute(sql);
|
||||
var kosten = oRs("cnt_contract_kosten").Value;
|
||||
var maanden = oRs("maanden").Value;
|
||||
oRs.Close()
|
||||
var maandbedrag = (kosten/maanden).toFixed(2);
|
||||
|
||||
this_model.includes.schedule.model.fields["amount"].defaultvalue = maandbedrag;
|
||||
|
||||
this_model.includes.schedule.model.fields["tekst"] =
|
||||
{
|
||||
label: "U kunt ook automatisch {0} maanden laten genereren:".format(maanden),
|
||||
typ: "label"
|
||||
}
|
||||
this_model.includes.schedule.model.fields["generate"] =
|
||||
{
|
||||
label: L("lcl_cnt_genschema"),
|
||||
typ: 'check0'
|
||||
}
|
||||
this_model.includes.schedule.model["edit"] = {
|
||||
"requires": {
|
||||
js: ["./cnt_factuurschema.js"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var org_save = scaffolding_save;
|
||||
scaffolding_save = function(model, scf_params)
|
||||
{
|
||||
if (getFParam("generate", "off") == "on")
|
||||
{
|
||||
protectRequest.validateToken();
|
||||
var cnt_key = getQParamInt( "cnt_contract_key" );
|
||||
var amount = getFParamFloat("amount");
|
||||
var description = getFParam("description");
|
||||
var sql = "BEGIN"
|
||||
+ " cnt.generatefactuurschema({0}, {1});".format(cnt_key, amount)
|
||||
+ "END;";
|
||||
var err = Oracle.Execute(sql, true);
|
||||
if (err.friendlyMsg)
|
||||
abort_with_warning(err.friendlyMsg);
|
||||
var result = { success: true };
|
||||
Response.ContentType = "application/json";
|
||||
Response.Write(JSON.stringify(result));
|
||||
}
|
||||
else
|
||||
org_save(model, scf_params);
|
||||
}
|
||||
|
||||
scaffolding(this_model,
|
||||
{ "included": {
|
||||
"schedule" : {
|
||||
"list": {
|
||||
"columns": [
|
||||
"id",
|
||||
"cnt_contract_key",
|
||||
"accountingperiod",
|
||||
"amount",
|
||||
"description"
|
||||
"description",
|
||||
"fintotal"
|
||||
],
|
||||
"orderby": [,
|
||||
"cnt_contract_key",
|
||||
@@ -37,7 +115,10 @@ scaffolding(this_model,
|
||||
]
|
||||
},
|
||||
"edit": {
|
||||
"modal": true
|
||||
"modal": true,
|
||||
"requires": {
|
||||
js: ["./cnt_factuurschema.js"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
14
APPL/CNT/cnt_factuurschema.js
Normal file
14
APPL/CNT/cnt_factuurschema.js
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
$Revision$
|
||||
$Id$
|
||||
|
||||
File: cnt_factuurschema.js
|
||||
*/
|
||||
|
||||
$(function () {
|
||||
$("#generate").change(function ()
|
||||
{
|
||||
$("#accountingperiod").prop("disabled", $(this).prop("checked"));
|
||||
$("#accountingperiod").toggleClass("required", !$(this).prop("checked"));
|
||||
})
|
||||
});
|
||||
@@ -551,22 +551,23 @@ function scf_LABELTR(fld, field, params)
|
||||
{
|
||||
if (field.label || field.labelvalue)
|
||||
{
|
||||
var labelname = (field.label ? field.label : (field.labelvalue ? "" : field.label));
|
||||
var labelvalue = (field.label ? (field.labelvalue ? field.labelvalue : "") : field.labelvalue);
|
||||
Response.Write('<div id="label_'+fld+'"><tr><td>'+field.label+'</td><td>'+labelvalue+'</td></tr></div>');
|
||||
if (field.labelvalue)
|
||||
Response.Write('<tr><td>'+field.label+'</td><td>'+field.labelvalue+'</td></tr>');
|
||||
else
|
||||
Response.Write('<tr><td colspan="2">'+field.label+'</td></tr>');
|
||||
}
|
||||
}
|
||||
|
||||
function scf_BUTTONTR(fld, field, params)
|
||||
{
|
||||
Response.Write('<div id="tr_'+fld+'"><tr><td class="label">'
|
||||
{ // JGL: <div><tr> is ongeldige html. Durf het niet aan te passen
|
||||
Response.Write('<div id="tr_'+fld+'"><tr><td class="label">'
|
||||
+'<label for="'+fld+'">'+(field.label?field.label+':':'')+'</label>'
|
||||
+'</td><td><button id="'+fld+'" name="'+fld+'">'+field.defaultvalue+'</button></td></tr></div>');
|
||||
}
|
||||
|
||||
function scf_DIV(fld, field, params)
|
||||
{
|
||||
Response.Write('<div id="'+fld+'" name="'+fld+'">'+field.defaultvalue+'</div>');
|
||||
Response.Write('<div id="'+fld+'" name="'+fld+'">'+field.defaultvalue+'</div>');
|
||||
}
|
||||
|
||||
function scf_GROUP_START(model, fld, val, params)
|
||||
|
||||
@@ -134,7 +134,7 @@ function scaffolding_list(model, scf_params)
|
||||
<%
|
||||
// doe maar niet. Headers zijn dan de deur te vroeg uit
|
||||
// en we kunnen geen 500-status meer doen? busyLoading(); // via ResultsetTable is te laat (na REST_GET) dus maar zelf
|
||||
buttons = [];
|
||||
buttons = scf_params.list.buttons || [];
|
||||
if (!nobuttons)
|
||||
buttons.push({ icon: "fa-refresh", title: L("lcl_refresh"), action: "FcltMgr.reload()", id: "btn_scf_refresh" });
|
||||
if (model["REST_POST"] && authparams.PRSwritelevel < 9 && authparams.ALGwritelevel < 9)
|
||||
|
||||
Reference in New Issue
Block a user