diff --git a/APPL/MGT/ctr_scenario.asp b/APPL/MGT/ctr_scenario.asp index 8c386421ab..ecf1e27cd6 100644 --- a/APPL/MGT/ctr_scenario.asp +++ b/APPL/MGT/ctr_scenario.asp @@ -29,10 +29,11 @@ scaffolding(this_model, "name" ] }, - "edit":{ + "show": { "modal": true, requires: { js: ["./ctr_scenario.js"] }, - buttons: [{ title: L("lcl_mjb_inst_scen"), action: "institute_scenario", icon: "plus.png" }] + buttons: [{ title: L("lcl_mjb_inst_scen"), action: "institute_scenario", icon: "plus.png" }, + { title: L("lcl_mjb_copy_current"), action: "copy_current", icon: "delete.png" }] } }); %> diff --git a/APPL/MGT/ctr_scenario.js b/APPL/MGT/ctr_scenario.js index b42122972b..7e9e12af4c 100644 --- a/APPL/MGT/ctr_scenario.js +++ b/APPL/MGT/ctr_scenario.js @@ -18,3 +18,19 @@ function institute_scenario(key, table) } ); } + +function copy_current(key, table) +{ + FcltMgr.confirm( L("lcl_mjb_copy_current") + "?", + { autoconfirm: false }, + function() { + var data = { scen_key: key, + totalcopy: 1 }; + protectRequest.dataToken(data); + $.post("../mjb/mjb_incl_scen_save.asp" + , data + , FcltCallbackClose + , "json"); + } + ); +} diff --git a/APPL/MJB/mjb_incl_scen_save.asp b/APPL/MJB/mjb_incl_scen_save.asp index 66e1be0969..5ff9ed3755 100644 --- a/APPL/MJB/mjb_incl_scen_save.asp +++ b/APPL/MJB/mjb_incl_scen_save.asp @@ -25,10 +25,27 @@ var JSON_Result = true; <% protectRequest.validateToken(); -var ins_key_arr = getFParamIntArray("ins_keys"); -var srtcont_key_arr = getFParamIntArray("srtcont_keys"); var scen_key = getFParamInt("scen_key"); +var totalcopy = getFParamInt("totalcopy", 0) == 1; +if (totalcopy) +{ // 1 Willekeurig object en controle ophalen om straks 1 maal de rechten te checken en in 1 keer een copie te maken van alle controles. + var sql = "SELECT ins_deel_key" + + " , ins_srtcontrole_key" + + " FROM ins_v_defined_inspect di" + + " ORDER BY ins_deel_key DESC" + var oRs = Oracle.Execute(sql); + var ins_key_arr = [oRs("ins_deel_key").Value]; + var srtcont_key_arr = [oRs("ins_srtcontrole_key").Value]; + oRs.Close(); +} +else +{ + var ins_key_arr = getFParamIntArray("ins_keys"); + var srtcont_key_arr = getFParamIntArray("srtcont_keys"); +} + + var sql = "SELECT isc.ctr_discipline_key" + " FROM ins_srtcontrole isc" + " WHERE isc.ins_srtcontrole_key = " + srtcont_key_arr[0]; @@ -90,6 +107,7 @@ result.scen_key = scen_key; for (var i = 0; i < ingesloten.length; i++) { // Toevoegen van de taak voor het object aan het (nieuwe) scenario. + // Als totalcopy dan wordt de for lus 1 maal doorlopen en worden alle controles in 1 keer aangemaakt. sql = "INSERT INTO ins_srtcontroledl_xcp (ins_srtcontroledl_xcp_key" + " , ins_deel_key" + " , ins_srtcontrole_key" @@ -110,8 +128,8 @@ for (var i = 0; i < ingesloten.length; i++) + " , ins_srtcontroledl_xcp_aanteh" + " , ins_scenario_key)" + " SELECT ins_s_srtcontroledl_xcp_key.nextval" - + " , " + ingesloten[i].ins_key - + " , " + ingesloten[i].srtcont_key + + " , ins_deel_key" + + " , ins_srtcontrole_key" + " , ins_srtcontroledl_xcp_periode" + " , ins_srtcontroledl_xcp_eenheid" + " , ins_srtcontroledl_xcp_bits" @@ -129,9 +147,13 @@ for (var i = 0; i < ingesloten.length; i++) + " , ins_srtcontroledl_xcp_aanteh" + " , " + scen_key + " FROM ins_v_defined_inspect_xcp" - + " WHERE ins_deel_key = " + ingesloten[i].ins_key - + " AND ins_srtcontrole_key = " + ingesloten[i].srtcont_key - + " AND ins_scenario_key IS NULL"; + + " WHERE ins_srtcontrole_periode > 0" + + (!totalcopy + ? " AND ins_deel_key = " + ingesloten[i].ins_key + + " AND ins_srtcontrole_key = " + ingesloten[i].srtcont_key + : "") + + " AND ins_scenario_key IS NULL" + + " AND ctr_ismjob = 1" var err = Oracle.Execute(sql, true); if (err.friendlyMsg) @@ -161,8 +183,10 @@ for (var i = 0; i < ingesloten.length; i++) + " , " + scen_key + " FROM ins_v_defined_inspect_xcp xcp" + " WHERE xcp.ins_srtcontrole_periode > 0" - + " AND xcp.ins_deel_key = " + ingesloten[i].ins_key - + " AND xcp.ins_srtcontrole_key = " + ingesloten[i].srtcont_key + + (!totalcopy + ? " AND xcp.ins_deel_key = " + ingesloten[i].ins_key + + " AND xcp.ins_srtcontrole_key = " + ingesloten[i].srtcont_key + : "") + " AND xcp.ins_scenario_key IS NULL" + " AND xcp.ctr_ismjob = 1"