FSN#36298: 1. Scenario’s (per complex moeten verschillende scenario’s gemaakt moeten kunnen.

svn path=/Website/trunk/; revision=34695
This commit is contained in:
Maykel Geerdink
2017-07-20 14:48:35 +00:00
parent f2d3e72054
commit 059140d6ee
9 changed files with 182 additions and 325 deletions

View File

@@ -607,61 +607,9 @@ ins = {checkAutLevel:
+ " ELSE 0"
+ " END invoerAfterNext"
+ " FROM ("
// De view ins_v_defined_inspect_xcp levert de volgende regels op
// Alle Active Situatie (AS) soort controle's die geen uitzondering (XCP) record hebben maar wel een scenario.
+ " SELECT idsc.ins_deelsrtcontrole_key"
+ " , idsc.ins_deelsrtcontrole_datum"
+ " , idsc.ins_deelsrtcontrole_status"
+ " , NULL vervaldatum"
+ " , isc.ins_srtcontrole_mode isc_mode"
+ " , isc.ctr_discipline_key"
+ " , isc.ins_srtcontrole_options options"
+ " , isc.ins_srtcontrole_eenheid eenheid"
+ " , idsc.ins_deelsrtcontrole_plandatum plandatum"
+ " , CASE"
+ " WHEN 1 = " + (hasInspect? 0 : 1) // lastinspect IS NULL
+ " THEN (SELECT d.ins_deel_aanmaak FROM ins_deel d WHERE d.ins_deel_key = " + pins_deel_key + ")"
+ " WHEN idsc.ins_deelsrtcontrole_status IN (0, 2)"
+ " THEN ins_deelsrtcontrole_datum_org"
+ " ELSE fac.nextcyclusdate(CASE"
+ " WHEN isc.ins_srtcontrole_mode = 0"
+ " THEN idsc.ins_deelsrtcontrole_datum_org" // Moment modus (0). Uitgaan van eigenlijke/orginele inspectiedatum.
+ " ELSE idsc.ins_deelsrtcontrole_datum" // Interval modus (1). Uitgaan van werkelijke inspectiedatum.
+ " END"
+ " , isc.ins_srtcontrole_mode"
+ " , isc.ins_srtcontrole_eenheid"
+ " , isc.ins_srtcontrole_periode"
+ " , isc.ins_srtcontrole_bits"
+ " , 1)"
+ " END inspectie_next"
+ " FROM ins_srtcontrole isc"
+ " , ins_deelsrtcontrole idsc"
+ " WHERE isc.ins_srtcontrole_key = idsc.ins_srtcontrole_key(+)" // Er kan nog voor de eerste keer geinspecteerd moeten worden.
+ " AND isc.ins_srtcontrole_key = " + params.srtcont_key
+ " AND idsc.ins_deel_key(+) = " + pins_deel_key
+ (params.scen_key && params.scen_key > 0
? " AND idsc.ins_scenario_key(+) = " + params.scen_key
: " AND idsc.ins_scenario_key(+) IS NULL")
+ (params.deelsrtcont_key > 0
? " AND idsc.ins_deelsrtcontrole_key = " + params.deelsrtcont_key
: " AND (idsc.ins_deelsrtcontrole_key IS NULL OR"
+ " idsc.ins_deelsrtcontrole_key = (SELECT MAX(idsc2.ins_deelsrtcontrole_key)"
+ " FROM ins_deelsrtcontrole idsc2"
+ " WHERE idsc2.ins_deel_key = " + pins_deel_key
+ " AND idsc2.ins_srtcontrole_key = " + params.srtcont_key
+ " AND idsc2.ins_scenario_key IS NULL))")
+ " AND NOT EXISTS"
+ " (SELECT xcp.ins_srtcontroledl_xcp_key"
+ " FROM ins_srtcontroledl_xcp xcp"
+ " WHERE xcp.ins_srtcontrole_key = " + params.srtcont_key
+ " AND xcp.ins_deel_key = " + pins_deel_key
+ " AND xcp.ins_scenario_key IS NULL)"
+ " AND EXISTS"
+ " (SELECT xcp.ins_srtcontroledl_xcp_key"
+ " FROM ins_srtcontroledl_xcp xcp"
+ " WHERE xcp.ins_srtcontrole_key = " + params.srtcont_key
+ " AND xcp.ins_deel_key = " + pins_deel_key
+ " AND xcp.ins_scenario_key IS NOT NULL)"
+ " UNION ALL"
// en
// Alle Active Situatie (AS) soort controle's die:
// a) geen uitzondering (XCP) record hebben en geen scenario.
// b) een uitzondering (XCP) record hebben.
@@ -670,10 +618,10 @@ ins = {checkAutLevel:
+ " , idsc.ins_deelsrtcontrole_datum"
+ " , idsc.ins_deelsrtcontrole_status"
+ " , xcp.ins_srtcontroledl_xcp_eind vervaldatum"
+ " , isc.ins_srtcontrole_mode isc_mode"
+ " , isc.ctr_discipline_key"
+ " , isc.ins_srtcontrole_options options"
+ " , COALESCE (xcp.ins_srtcontroledl_xcp_eenheid, isc.ins_srtcontrole_eenheid) eenheid"
+ " , xcp.ins_srtcontrole_mode isc_mode"
+ " , xcp.ctr_discipline_key"
+ " , xcp.ins_srtcontrole_options options"
+ " , xcp.ins_srtcontrole_eenheid eenheid"
+ " , idsc.ins_deelsrtcontrole_plandatum plandatum"
+ " , CASE"
+ " WHEN 1 = " + (hasInspect? 0 : 1) // lastinspect IS NULL
@@ -681,23 +629,21 @@ ins = {checkAutLevel:
+ " WHEN idsc.ins_deelsrtcontrole_status IN (0, 2)"
+ " THEN ins_deelsrtcontrole_datum_org"
+ " ELSE fac.nextcyclusdate(CASE"
+ " WHEN isc.ins_srtcontrole_mode = 0"
+ " WHEN xcp.ins_srtcontrole_mode = 0"
+ " THEN idsc.ins_deelsrtcontrole_datum_org" // Moment modus (0). Uitgaan van eigenlijke/orginele inspectiedatum.
+ " ELSE idsc.ins_deelsrtcontrole_datum" // Interval modus (1). Uitgaan van werkelijke inspectiedatum.
+ " END"
+ " , isc.ins_srtcontrole_mode"
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_eenheid, isc.ins_srtcontrole_eenheid)"
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_periode, isc.ins_srtcontrole_periode)"
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_bits, isc.ins_srtcontrole_bits)"
+ " , xcp.ins_srtcontrole_mode"
+ " , xcp.ins_srtcontrole_eenheid"
+ " , xcp.ins_srtcontrole_periode"
+ " , xcp.ins_srtcontrole_bits"
+ " , 1)"
+ " END inspectie_next"
+ " FROM ins_srtcontrole isc"
+ " , ins_deelsrtcontrole idsc"
+ " , ins_srtcontroledl_xcp xcp"
+ " WHERE isc.ins_srtcontrole_key = idsc.ins_srtcontrole_key(+)" // Er kan nog voor de eerste keer geinspecteerd moeten worden.
+ " AND isc.ins_srtcontrole_key = xcp.ins_srtcontrole_key(+)"
+ " AND isc.ins_srtcontrole_key = " + params.srtcont_key
+ " AND xcp.ins_deel_key(+) = " + pins_deel_key
+ " FROM ins_deelsrtcontrole idsc"
+ " , ins_v_defined_inspect_xcp xcp"
+ " WHERE xcp.ins_srtcontrole_key = idsc.ins_srtcontrole_key(+)" // Er kan nog voor de eerste keer geinspecteerd moeten worden.
+ " AND xcp.ins_srtcontrole_key = " + params.srtcont_key
+ " AND xcp.ins_deel_key = " + pins_deel_key
+ " AND idsc.ins_deel_key(+) = " + pins_deel_key
+ (params.scen_key && params.scen_key > 0
? " AND idsc.ins_scenario_key(+) = " + params.scen_key
@@ -708,10 +654,13 @@ ins = {checkAutLevel:
? " AND idsc.ins_deelsrtcontrole_key = " + params.deelsrtcont_key
: " AND (idsc.ins_deelsrtcontrole_key IS NULL OR"
+ " idsc.ins_deelsrtcontrole_key = (SELECT MAX(idsc2.ins_deelsrtcontrole_key)"
+ " FROM ins_deelsrtcontrole idsc2"
+ " WHERE idsc2.ins_deel_key = " + pins_deel_key
+ " AND idsc2.ins_srtcontrole_key = " + params.srtcont_key
+ " AND idsc2.ins_scenario_key IS NULL))")
+ " FROM ins_deelsrtcontrole idsc2"
+ " WHERE idsc2.ins_deel_key = " + pins_deel_key
+ " AND idsc2.ins_srtcontrole_key = " + params.srtcont_key
+ (params.scen_key && params.scen_key > 0
? " AND idsc2.ins_scenario_key = " + params.scen_key
: " AND idsc2.ins_scenario_key IS NULL")
+ " ))")
+ " ) insp"
+ " ORDER BY insp.ins_deelsrtcontrole_datum DESC";
var oRs = Oracle.Execute(sql);
@@ -788,13 +737,10 @@ ins = {checkAutLevel:
// Zijn er soort controles waar de user lees of schrijf rechten op heeft?
// Eerst lezen.
var bsql = "SELECT COUNT(*) aantal"
+ " FROM (SELECT di.ins_srtcontrole_key"
+ " FROM ins_v_defined_inspect di"
+ " , ins_srtcontroledl_xcp xcp"
+ " WHERE di.ins_srtcontrole_key = xcp.ins_srtcontrole_key(+)"
+ " AND di.ins_deel_key = xcp.ins_deel_key(+)"
+ " AND di.ins_deel_key = " + pins_deel_key
+ " AND di.ctr_discipline_key IN (SELECT w.ins_discipline_key" // Alleen van de disciplines waar ik schrijf rechten op heb meetellen.
+ " FROM (SELECT xcp.ins_srtcontrole_key"
+ " FROM ins_v_defined_inspect_xcp xcp"
+ " WHERE xcp.ins_deel_key = " + pins_deel_key
+ " AND xcp.ctr_discipline_key IN (SELECT w.ins_discipline_key" // Alleen van de disciplines waar ik schrijf rechten op heb meetellen.
+ " FROM fac_v_webgebruiker w"
+ " , fac_functie f"
+ " WHERE w.fac_functie_key = f.fac_functie_key "
@@ -802,8 +748,8 @@ ins = {checkAutLevel:
+ " AND w.fac_gebruiker_prs_level_read < 9"
+ " AND w.fac_gebruiker_alg_level_read < 9"
+ " AND w.prs_perslid_key = " + user_key + ")"
+ " GROUP BY di.ins_srtcontrole_key"
+ " , di.ins_deel_key)";
+ " GROUP BY xcp.ins_srtcontrole_key"
+ " , xcp.ins_deel_key)";
var boRs = Oracle.Execute(bsql);
var add = boRs("aantal").Value > 0;
iresult.hasAnyReadXcp = boRs("aantal").Value > 0 && iresult.canRead("WEB_INSMAN"); // Enige rechten om exceptions (xcp) waarden te lezen.
@@ -811,13 +757,10 @@ ins = {checkAutLevel:
// Nu schrijven.
var bsql = "SELECT COUNT(*) aantal"
+ " FROM (SELECT di.ins_srtcontrole_key"
+ " FROM ins_v_defined_inspect di"
+ " , ins_srtcontroledl_xcp xcp"
+ " WHERE di.ins_srtcontrole_key = xcp.ins_srtcontrole_key(+)"
+ " AND di.ins_deel_key = xcp.ins_deel_key(+)"
+ " AND di.ins_deel_key = " + pins_deel_key
+ " AND di.ctr_discipline_key IN (SELECT w.ins_discipline_key" // Alleen van de disciplines waar ik schrijf rechten op heb meetellen.
+ " FROM (SELECT xcp.ins_srtcontrole_key"
+ " FROM ins_v_defined_inspect_xcp xcp"
+ " WHERE xcp.ins_deel_key = " + pins_deel_key
+ " AND xcp.ctr_discipline_key IN (SELECT w.ins_discipline_key" // Alleen van de disciplines waar ik schrijf rechten op heb meetellen.
+ " FROM fac_v_webgebruiker w"
+ " , fac_functie f"
+ " WHERE w.fac_functie_key = f.fac_functie_key "
@@ -825,8 +768,8 @@ ins = {checkAutLevel:
+ " AND w.fac_gebruiker_prs_level_write < 9"
+ " AND w.fac_gebruiker_alg_level_write < 9"
+ " AND w.prs_perslid_key = " + user_key + ")"
+ " GROUP BY di.ins_srtcontrole_key"
+ " , di.ins_deel_key)";
+ " GROUP BY xcp.ins_srtcontrole_key"
+ " , xcp.ins_deel_key)";
var boRs = Oracle.Execute(bsql);
var add = boRs("aantal").Value > 0;
iresult.hasAnyWriteXcp = boRs("aantal").Value > 0 && iresult.canWrite("WEB_INSMAN"); // Enige rechten om exceptions (xcp) waarden te schrijven.

View File

@@ -177,29 +177,26 @@ if (ins_key_arr.length == 1)
var eersteinspectie;
var info = "";
sql = "SELECT *"
+ " FROM (SELECT DISTINCT COALESCE (xcp.ins_srtcontroledl_xcp_eenheid, di.ins_srtcontrole_eenheid) eenheid"
+ " , di.ins_srtcontrole_info info"
+ " , di.ins_srtcontrole_mode scmode"
+ " , di.ctr_controle_type sctype"
+ " , di.ins_deel_aanmaak"
+ " FROM (SELECT DISTINCT xcp.ins_srtcontrole_eenheid eenheid"
+ " , xcp.ins_srtcontrole_info info"
+ " , xcp.ins_srtcontrole_mode scmode"
+ " , xcp.ctr_controle_type sctype"
+ " , xcp.ins_deel_aanmaak"
+ " , xcp.ins_srtcontroledl_xcp_startdat startdatum"
+ " , (SELECT COUNT (idsc.ins_deelsrtcontrole_key)"
+ " FROM ins_deelsrtcontrole idsc1"
+ " WHERE idsc1.ins_deel_key = di.ins_deel_key"
+ " AND idsc1.ins_srtcontrole_key = di.ins_srtcontrole_key"
+ " WHERE idsc1.ins_deel_key = xcp.ins_deel_key"
+ " AND idsc1.ins_srtcontrole_key = xcp.ins_srtcontrole_key"
+ " AND idsc1.ins_scenario_key IS NULL) aantal"
+ " FROM ins_v_defined_inspect di"
+ " , ins_srtcontroledl_xcp xcp"
+ " FROM ins_v_defined_inspect_xcp xcp"
+ " , ins_deelsrtcontrole idsc"
+ " WHERE di.ins_srtcontrole_key = xcp.ins_srtcontrole_key(+)"
+ " AND di.ins_deel_key = xcp.ins_deel_key(+)"
+ " AND di.ins_srtcontrole_key = idsc.ins_srtcontrole_key(+)" // Er kan nog voor de eerste keer geinspecteerd moeten worden.
+ " WHERE xcp.ins_srtcontrole_key = idsc.ins_srtcontrole_key(+)" // Er kan nog voor de eerste keer geinspecteerd moeten worden.
+ " AND idsc.ins_scenario_key(+) IS NULL"
+ " AND xcp.ins_scenario_key(+) IS NULL"
+ " AND di.ins_deel_key IN (" + ingesloten.join(",") + ")"
+ " AND xcp.ins_scenario_key IS NULL"
+ " AND xcp.ins_deel_key IN (" + ingesloten.join(",") + ")"
+ " AND idsc.ins_deel_key(+) IN (" + ingesloten.join(",") + ")"
+ " AND COALESCE (xcp.ins_srtcontroledl_xcp_periode, di.ins_srtcontrole_periode) > 0"
+ " AND di.ins_srtcontrole_key IN (" + ingeslotensc.join(",") + ")"
+ " AND xcp.ins_srtcontrole_periode > 0"
+ " AND xcp.ins_srtcontrole_key IN (" + ingeslotensc.join(",") + ")"
+ " )";
var oRs = Oracle.Execute(sql);
eenheid = oRs("eenheid").Value;

View File

@@ -322,16 +322,13 @@ var authparams = user.checkAutorisation("WEB_INSUSE");
var addurl_editxcp = "../ins/ins_xcp.asp?ins_key=" + ins_key + "&urole=bo";
// Zijn er inactieve soort controles (periode = 0) die ook gelden voor het object. Dan de "Toevoegen" knop tonen.
var bsql = "SELECT COUNT(*) aantal"
+ " FROM (SELECT di.ins_srtcontrole_key"
+ " FROM ins_v_defined_inspect di"
+ " , ins_srtcontroledl_xcp xcp"
+ " WHERE di.ins_srtcontrole_key = xcp.ins_srtcontrole_key(+)"
+ " AND di.ins_deel_key = xcp.ins_deel_key(+)"
+ " AND di.ins_deel_key = " + ins_key
+ " AND COALESCE (xcp.ins_srtcontroledl_xcp_periode, di.ins_srtcontrole_periode) <= 0" // Inactieve soort controles tonen.
+ " FROM (SELECT xcp.ins_srtcontrole_key"
+ " FROM ins_v_defined_inspect_xcp xcp"
+ " WHERE xcp.ins_deel_key = " + ins_key
+ " AND xcp.ins_srtcontrole_periode <= 0" // Inactieve soort controles tonen.
+ " AND xcp.ins_srtcontroledl_xcp_periode IS NULL" // Soort controles die niet overruled zijn tonen.
+ " AND xcp.ins_scenario_key IS NULL"
+ " AND di.ctr_discipline_key IN (SELECT w.ins_discipline_key" // Alleen van de disciplines waar ik schrijf rechten op heb meetellen.
+ " AND xcp.ctr_discipline_key IN (SELECT w.ins_discipline_key" // Alleen van de disciplines waar ik schrijf rechten op heb meetellen.
+ " FROM fac_v_webgebruiker w"
+ " , fac_functie f"
+ " WHERE w.fac_functie_key = f.fac_functie_key "
@@ -339,8 +336,8 @@ var authparams = user.checkAutorisation("WEB_INSUSE");
+ " AND w.fac_gebruiker_prs_level_write < 9"
+ " AND w.fac_gebruiker_alg_level_write < 9"
+ " AND w.prs_perslid_key = " + user_key + ")"
+ " GROUP BY di.ins_srtcontrole_key"
+ " , di.ins_deel_key)";
+ " GROUP BY xcp.ins_srtcontrole_key"
+ " , xcp.ins_deel_key)";
var boRs = Oracle.Execute(bsql);
var add = boRs("aantal").Value > 0;
boRs.close();

View File

@@ -74,7 +74,7 @@ for (var i = 0; i < ins_key_arr.length; i++)
{
var dlsrtcont_key = -1;
var sql = "SELECT *"
+ " FROM (SELECT di.ins_srtcontrole_key"
+ " FROM (SELECT xcp.ins_srtcontrole_key"
+ " , idsc.ins_deelsrtcontrole_key"
+ " , (SELECT MAX (idsc2.ins_deelsrtcontrole_datum)"
+ " FROM ins_deelsrtcontrole idsc2"
@@ -84,25 +84,22 @@ for (var i = 0; i < ins_key_arr.length; i++)
? " AND idsc2.ins_scenario_key = " + scen_key_arr[i]
: " AND idsc2.ins_scenario_key IS NULL")
+ " ) ins_deelsrtcontrole_datum"
+ " , COALESCE (xcp.ins_srtcontroledl_xcp_eenheid, di.ins_srtcontrole_eenheid) eenheid"
+ " , di.ins_srtcontrole_mode"
+ " , xcp.ins_srtcontrole_eenheid eenheid"
+ " , xcp.ins_srtcontrole_mode"
+ " , idsc.ins_deelsrtcontrole_status"
+ " , di.ins_deel_aanmaak"
+ " , di.ctr_discipline_key"
+ " , di.ins_srtcontrole_options options"
+ " , xcp.ins_deel_aanmaak"
+ " , xcp.ctr_discipline_key"
+ " , xcp.ins_srtcontrole_options options"
+ " , cd.ins_discipline_omschrijving"
+ " FROM ins_v_defined_inspect di"
+ " , ins_srtcontroledl_xcp xcp"
+ " FROM ins_v_defined_inspect_xcp xcp"
+ " , ins_deelsrtcontrole idsc"
+ " , ctr_v_aanwezigdiscipline cd"
+ " WHERE di.ins_srtcontrole_key = xcp.ins_srtcontrole_key(+)"
+ " AND di.ins_deel_key = xcp.ins_deel_key(+)"
+ " AND di.ins_srtcontrole_key = idsc.ins_srtcontrole_key(+)" // Er kan nog voor de eerste keer geinspecteerd moeten worden.
+ " AND di.ctr_discipline_key = cd.ins_discipline_key"
+ " AND di.ins_deel_key = " + ins_key_arr[i]
+ " WHERE xcp.ins_srtcontrole_key = idsc.ins_srtcontrole_key(+)" // Er kan nog voor de eerste keer geinspecteerd moeten worden.
+ " AND xcp.ctr_discipline_key = cd.ins_discipline_key"
+ " AND xcp.ins_deel_key = " + ins_key_arr[i]
+ " AND idsc.ins_deel_key(+) = " + ins_key_arr[i]
+ " AND COALESCE (xcp.ins_srtcontroledl_xcp_periode, di.ins_srtcontrole_periode) > 0"
+ " AND di.ins_srtcontrole_key = " + srtcont_key_arr[i]
+ " AND xcp.ins_srtcontrole_periode > 0"
+ " AND xcp.ins_srtcontrole_key = " + srtcont_key_arr[i]
+ (deelsrtcont_key > 0
? " AND idsc.ins_deelsrtcontrole_key = " + deelsrtcont_key
: "")

View File

@@ -78,21 +78,18 @@ user.auth_required_or_abort(this_ins.canInspShow);
var info = "";
sql = "SELECT *"
+ " FROM (SELECT DISTINCT COALESCE (xcp.ins_srtcontroledl_xcp_eenheid, di.ins_srtcontrole_eenheid) eenheid"
+ " , di.ins_srtcontrole_info info"
+ " , di.ins_srtcontrole_mode scmode"
+ " , di.ctr_controle_type sctype"
+ " FROM (SELECT DISTINCT xcp.ins_srtcontrole_eenheid eenheid"
+ " , xcp.ins_srtcontrole_info info"
+ " , xcp.ins_srtcontrole_mode scmode"
+ " , xcp.ctr_controle_type sctype"
+ " , xcp.ins_srtcontroledl_xcp_eind vervaldatum"
+ " , di.ctr_discipline_key"
+ " FROM ins_v_defined_inspect di"
+ " , ins_srtcontroledl_xcp xcp"
+ " , xcp.ctr_discipline_key"
+ " FROM ins_v_defined_inspect_xcp xcp"
+ " , ins_deelsrtcontrole idsc"
+ " WHERE di.ins_srtcontrole_key = xcp.ins_srtcontrole_key(+)"
+ " AND di.ins_deel_key = xcp.ins_deel_key(+)"
+ " AND di.ins_srtcontrole_key = idsc.ins_srtcontrole_key" // Er kan nog voor de eerste keer geinspecteerd moeten worden.
+ " AND idsc.ins_deel_key = di.ins_deel_key"
+ " AND COALESCE (xcp.ins_srtcontroledl_xcp_periode, di.ins_srtcontrole_periode) > 0"
+ " AND di.ins_deel_key IN (" + ins_key + ")"
+ " WHERE xcp.ins_srtcontrole_key = idsc.ins_srtcontrole_key" // Er kan nog voor de eerste keer geinspecteerd moeten worden.
+ " AND idsc.ins_deel_key = xcp.ins_deel_key"
+ " AND xcp.ins_srtcontrole_periode > 0"
+ " AND xcp.ins_deel_key IN (" + ins_key + ")"
+ " AND idsc.ins_deelsrtcontrole_key = " + deelsrtcont_key
+ " )";
var oRs = Oracle.Execute(sql);

View File

@@ -593,185 +593,72 @@ if (srtcont_key > 0)
var sql = "SELECT *"
+ " FROM ("
// De view ins_v_defined_inspect_xcp levert de volgende regels op
// Alle Active Situatie (AS) soort controle's die geen uitzondering (XCP) record hebben maar wel een scenario.
+ (!isScenario
? " SELECT di.ins_srtcontrole_key"
+ " , " + lcl.xsqla('di.ins_srtcontrole_omschrijving', 'di.ins_srtcontrole_key')
+ " , di.ins_srtcontrole_mode modus"
+ " , di.ins_deel_aantal aantal_std"
+ " , null aantal_xcp"
+ " , di.ins_srtdeel_eenheid aanteh_std"
+ " , null aanteh_xcp"
+ " , di.ins_srtcontrole_eenheid eenheid_std"
+ " , -1 eenheid_xcp"
+ " , di.ins_srtcontrole_periode periode_std"
+ " , null periode_xcp"
+ " , di.ins_srtcontrole_bits bits_std"
+ " , null bits_xcp"
+ " , di.ins_srtcontrole_groep groep_std"
+ " , null groep_xcp"
+ " , di.ins_srtcontrole_kosten kosten_std1"
+ " , null kosten_xcp1"
+ " , di.ins_srtcontrole_kosten2 kosten_std2"
+ " , null kosten_xcp2"
+ " , di.ins_srtcontrole_kosten3 kosten_std3"
+ " , null kosten_xcp3"
+ " , di.ins_srtcontrole_uren uren_std"
+ " , null uren_xcp"
+ " , di.ins_srtcontrole_materiaal materiaal_std"
+ " , null materiaal_xcp"
+ " , di.ins_srtcontrole_percentage perc_std"
+ " , null perc_xcp"
+ " , di.ins_srtcontrole_opmerking opmerk_std"
+ " , null opmerk_xcp"
+ " , -1 xcp_key"
+ " , null startdate_xcp"
+ " , null start_xcp_dag"
+ " , null start_xcp_maand"
+ " , null start_xcp_jaar"
+ " , di.ins_srtcontrole_eind eind_std"
+ " , TO_CHAR(di.ins_srtcontrole_eind, 'DD') eind_std_dag"
+ " , TO_CHAR(di.ins_srtcontrole_eind, 'MM') eind_std_maand"
+ " , TO_CHAR(di.ins_srtcontrole_eind, 'YYYY') eind_std_jaar"
+ " , null eind_xcp"
+ " , null eind_xcp_dag"
+ " , null eind_xcp_maand"
+ " , null eind_xcp_jaar"
+ " , TO_CHAR(ins.nextcyclusdate (di.ins_deel_key, di.ins_srtcontrole_key, null, 1), 'DD') nextdate_dag"
+ " , TO_CHAR(ins.nextcyclusdate (di.ins_deel_key, di.ins_srtcontrole_key, null, 1), 'MM') nextdate_maand"
+ " , TO_CHAR(ins.nextcyclusdate (di.ins_deel_key, di.ins_srtcontrole_key, null, 1), 'YYYY') nextdate_jaar"
+ " , di.ctr_ismjob ismjob"
+ " , CASE"
+ " WHEN (SELECT COUNT(sdc.ins_deelsrtcontrole_key)"
+ " FROM ins_deelsrtcontrole sdc"
+ " WHERE sdc.ins_deel_key = di.ins_deel_key"
+ " AND sdc.ins_srtcontrole_key = di.ins_srtcontrole_key"
+ " AND sdc.ins_deelsrtcontrole_status = 6"
+ " AND sdc.ins_scenario_key IS NULL) > 0"
+ " THEN 1"
+ " ELSE 0"
+ " END hascontroles"
+ " FROM ins_v_defined_inspect di"
+ " WHERE di.ins_deel_key = " + ins_key
// De xcp_periode overruled de standaard periode. De xcp_periode kan/mag NULL zijn maar de standaard periode niet.
// Mogelijke waarden van de standaard periode en xcp periode:
// ins_srtcontrole_periode ins_srtcontroledl_xcp_periode uitleg
// 0 NULL een inactieve soort controle die ook geldt voor het object
// 1..n NULL een actieve soort controle geldt ook voor het object.
// 0 1 een standaard niet actieve controle is voor het object actief gemaakt.
// 1..n 0 een standaard actieve controle is voor het object inactief gemaakt.
+ (add
? " AND di.ins_srtcontrole_periode <= 0" // Inactieve soort controles tonen.
: " AND di.ins_srtcontrole_periode > 0") // Actieve soort controles tonen.
+ (srtcont_key > 0
? " AND di.ins_srtcontrole_key = " + srtcont_key
: "")
+ " AND di.ctr_discipline_key IN (SELECT w.ins_discipline_key"
+ " FROM fac_v_webgebruiker w"
+ " , fac_functie f"
+ " WHERE w.fac_functie_key = f.fac_functie_key "
+ " AND f.fac_functie_code = 'WEB_CTRUSE'"
+ " AND w.fac_gebruiker_prs_level_write < 9"
+ " AND w.fac_gebruiker_alg_level_write < 9"
+ " AND w.prs_perslid_key = " + user_key + ")"
+ " AND NOT EXISTS (SELECT xcp.ins_srtcontroledl_xcp_key" // Geen uitzondering (XCP) record.
+ " FROM ins_srtcontroledl_xcp xcp"
+ " WHERE xcp.ins_srtcontrole_key = di.ins_srtcontrole_key"
+ " AND xcp.ins_deel_key = di.ins_deel_key"
+ " AND xcp.ins_scenario_key IS NULL)"
+ " AND EXISTS (SELECT xcp.ins_srtcontroledl_xcp_key" // Wel een scenario aanwezig
+ " FROM ins_srtcontroledl_xcp xcp"
+ " WHERE xcp.ins_srtcontrole_key = di.ins_srtcontrole_key"
+ " AND xcp.ins_deel_key = di.ins_deel_key"
+ " AND xcp.ins_scenario_key IS NOT NULL)"
+ " GROUP BY di.ins_srtcontrole_key"
+ " , di.ins_srtcontrole_omschrijving"
+ " , di.ins_srtcontrole_mode"
+ " , di.ins_deel_aantal"
+ " , di.ins_srtdeel_eenheid"
+ " , di.ins_srtcontrole_periode"
+ " , di.ins_srtcontrole_eenheid"
+ " , di.ins_srtcontrole_bits"
+ " , di.ins_srtcontrole_groep"
+ " , di.ins_srtcontrole_kosten"
+ " , di.ins_srtcontrole_kosten2"
+ " , di.ins_srtcontrole_kosten3"
+ " , di.ins_srtcontrole_uren"
+ " , di.ins_srtcontrole_materiaal"
+ " , di.ins_srtcontrole_percentage"
+ " , di.ins_srtcontrole_opmerking"
+ " , di.ins_srtcontrole_eind"
+ " , di.ins_deel_key"
+ " , di.ctr_ismjob"
+ " HAVING COUNT(*) = " + cntdeel // Als multi dan alleen de inspecties die voor *alle* objecten gelden
+ " UNION"
: "")
// en
// Alle soort controles van de scenario's.
// en
// Alle Active Situatie (AS) soort controle's die:
// a) geen uitzondering (XCP) record hebben en geen scenario.
// b) een uitzondering (XCP) record hebben.
+ " SELECT di.ins_srtcontrole_key"
+ " , " + lcl.xsqla('di.ins_srtcontrole_omschrijving', 'di.ins_srtcontrole_key')
+ " , di.ins_srtcontrole_mode modus"
+ " , di.ins_deel_aantal aantal_std"
+ " SELECT xcp.ins_srtcontrole_key"
+ " , " + lcl.xsqla('xcp.ins_srtcontrole_omschrijving', 'xcp.ins_srtcontrole_key')
+ " , xcp.ins_srtcontrole_mode modus"
+ " , xcp.ins_deel_aantal aantal_std"
+ " , xcp.ins_srtcontroledl_xcp_aantal aantal_xcp"
+ " , di.ins_srtdeel_eenheid aanteh_std"
+ " , xcp.ins_srtdeel_eenheid aanteh_std"
+ " , xcp.ins_srtcontroledl_xcp_aanteh aanteh_xcp"
+ " , di.ins_srtcontrole_eenheid eenheid_std"
+ " , xcp.ins_srtcontrole_eenheid eenheid_std"
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_eenheid, -1) eenheid_xcp"
+ " , di.ins_srtcontrole_periode periode_std"
+ " , xcp.ins_srtcontrole_periode periode_std"
+ " , xcp.ins_srtcontroledl_xcp_periode periode_xcp"
+ " , di.ins_srtcontrole_bits bits_std"
+ " , xcp.ins_srtcontrole_bits bits_std"
+ " , xcp.ins_srtcontroledl_xcp_bits bits_xcp"
+ " , di.ins_srtcontrole_groep groep_std"
+ " , xcp.ins_srtcontrole_groep groep_std"
+ " , xcp.ins_srtcontroledl_xcp_groep groep_xcp"
+ " , di.ins_srtcontrole_kosten kosten_std1"
+ " , xcp.ins_srtcontrole_kosten kosten_std1"
+ " , xcp.ins_srtcontroledl_xcp_kosten kosten_xcp1"
+ " , di.ins_srtcontrole_kosten2 kosten_std2"
+ " , xcp.ins_srtcontrole_kosten2 kosten_std2"
+ " , xcp.ins_srtcontroledl_xcp_kosten2 kosten_xcp2"
+ " , di.ins_srtcontrole_kosten3 kosten_std3"
+ " , xcp.ins_srtcontrole_kosten3 kosten_std3"
+ " , xcp.ins_srtcontroledl_xcp_kosten3 kosten_xcp3"
+ " , di.ins_srtcontrole_uren uren_std"
+ " , xcp.ins_srtcontrole_uren uren_std"
+ " , xcp.ins_srtcontroledl_xcp_uren uren_xcp"
+ " , di.ins_srtcontrole_materiaal materiaal_std"
+ " , xcp.ins_srtcontrole_materiaal materiaal_std"
+ " , xcp.ins_srtcontroledl_xcp_materia materiaal_xcp"
+ " , di.ins_srtcontrole_percentage perc_std"
+ " , xcp.ins_srtcontrole_percentage perc_std"
+ " , xcp.ins_srtcontroledl_xcp_perc perc_xcp"
+ " , di.ins_srtcontrole_opmerking opmerk_std"
+ " , xcp.ins_srtcontrole_opmerking opmerk_std"
+ " , xcp.ins_srtcontroledl_xcp_opmerk opmerk_xcp"
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_key, -1) xcp_key"
+ " , xcp.ins_srtcontroledl_xcp_startdat startdate_xcp"
+ " , TO_CHAR(xcp.ins_srtcontroledl_xcp_startdat, 'DD') start_xcp_dag"
+ " , TO_CHAR(xcp.ins_srtcontroledl_xcp_startdat, 'MM') start_xcp_maand"
+ " , TO_CHAR(xcp.ins_srtcontroledl_xcp_startdat, 'YYYY') start_xcp_jaar"
+ " , di.ins_srtcontrole_eind eind_std"
+ " , TO_CHAR(di.ins_srtcontrole_eind, 'DD') eind_std_dag"
+ " , TO_CHAR(di.ins_srtcontrole_eind, 'MM') eind_std_maand"
+ " , TO_CHAR(di.ins_srtcontrole_eind, 'YYYY') eind_std_jaar"
+ " , xcp.ins_srtcontrole_eind eind_std"
+ " , TO_CHAR(xcp.ins_srtcontrole_eind, 'DD') eind_std_dag"
+ " , TO_CHAR(xcp.ins_srtcontrole_eind, 'MM') eind_std_maand"
+ " , TO_CHAR(xcp.ins_srtcontrole_eind, 'YYYY') eind_std_jaar"
+ " , xcp.ins_srtcontroledl_xcp_eind eind_xcp"
+ " , TO_CHAR(xcp.ins_srtcontroledl_xcp_eind, 'DD') eind_xcp_dag"
+ " , TO_CHAR(xcp.ins_srtcontroledl_xcp_eind, 'MM') eind_xcp_maand"
+ " , TO_CHAR(xcp.ins_srtcontroledl_xcp_eind, 'YYYY') eind_xcp_jaar"
+ " , TO_CHAR(ins.nextcyclusdate (di.ins_deel_key, di.ins_srtcontrole_key, " + (isScenario? scen_key : "null") + ", 1), 'DD') nextdate_dag"
+ " , TO_CHAR(ins.nextcyclusdate (di.ins_deel_key, di.ins_srtcontrole_key, " + (isScenario? scen_key : "null") + ", 1), 'MM') nextdate_maand"
+ " , TO_CHAR(ins.nextcyclusdate (di.ins_deel_key, di.ins_srtcontrole_key, " + (isScenario? scen_key : "null") + ", 1), 'YYYY') nextdate_jaar"
+ " , di.ctr_ismjob ismjob"
+ " , TO_CHAR(ins.nextcyclusdate (xcp.ins_deel_key, xcp.ins_srtcontrole_key, " + (isScenario? scen_key : "null") + ", 1), 'DD') nextdate_dag"
+ " , TO_CHAR(ins.nextcyclusdate (xcp.ins_deel_key, xcp.ins_srtcontrole_key, " + (isScenario? scen_key : "null") + ", 1), 'MM') nextdate_maand"
+ " , TO_CHAR(ins.nextcyclusdate (xcp.ins_deel_key, xcp.ins_srtcontrole_key, " + (isScenario? scen_key : "null") + ", 1), 'YYYY') nextdate_jaar"
+ " , xcp.ctr_ismjob ismjob"
+ " , CASE"
+ " WHEN (SELECT COUNT(sdc.ins_deelsrtcontrole_key)"
+ " FROM ins_deelsrtcontrole sdc"
+ " WHERE sdc.ins_deel_key = di.ins_deel_key"
+ " AND sdc.ins_srtcontrole_key = di.ins_srtcontrole_key"
+ " WHERE sdc.ins_deel_key = xcp.ins_deel_key"
+ " AND sdc.ins_srtcontrole_key = xcp.ins_srtcontrole_key"
+ " AND sdc.ins_deelsrtcontrole_status = 6"
+ " AND sdc.ins_scenario_key IS NULL) > 0"
+ " THEN 1"
+ " ELSE 0"
+ " END hascontroles"
+ " FROM ins_v_defined_inspect di"
+ " , ins_srtcontroledl_xcp xcp"
+ " WHERE di.ins_srtcontrole_key = xcp.ins_srtcontrole_key(+)"
+ " AND di.ins_deel_key = xcp.ins_deel_key(+)"
+ " AND di.ins_deel_key = " + ins_key
+ " FROM ins_v_defined_inspect_xcp xcp"
+ " WHERE xcp.ins_deel_key = " + ins_key
// De xcp_periode overruled de standaard periode. De xcp_periode kan/mag NULL zijn maar de standaard periode niet.
// Mogelijke waarden van de standaard periode en xcp periode:
// ins_srtcontrole_periode ins_srtcontroledl_xcp_periode uitleg
@@ -780,14 +667,14 @@ if (srtcont_key > 0)
// 0 1 een standaard niet actieve controle is voor het object actief gemaakt.
// 1..n 0 een standaard actieve controle is voor het object inactief gemaakt.
+ (add
? " AND COALESCE (xcp.ins_srtcontroledl_xcp_periode, di.ins_srtcontrole_periode) <= 0" // Inactieve soort controles tonen.
? " AND xcp.ins_srtcontrole_periode <= 0" // Inactieve soort controles tonen.
+ " AND xcp.ins_srtcontroledl_xcp_periode IS NULL" // Soort controles die niet overruled zijn tonen.
: " AND (COALESCE (xcp.ins_srtcontroledl_xcp_periode, di.ins_srtcontrole_periode) > 0" // Actieve soort controles tonen.
: " AND (xcp.ins_srtcontrole_periode > 0" // Actieve soort controles tonen.
+ " OR ins_srtcontroledl_xcp_periode = 0)") // Soort controles die inactief zijn gemaakt tonen.
+ (srtcont_key > 0
? " AND di.ins_srtcontrole_key = " + srtcont_key
? " AND xcp.ins_srtcontrole_key = " + srtcont_key
: "")
+ " AND di.ctr_discipline_key IN (SELECT w.ins_discipline_key"
+ " AND xcp.ctr_discipline_key IN (SELECT w.ins_discipline_key"
+ " FROM fac_v_webgebruiker w"
+ " , fac_functie f"
+ " WHERE w.fac_functie_key = f.fac_functie_key "
@@ -798,26 +685,26 @@ if (srtcont_key > 0)
+ (isScenario
? " AND xcp.ins_scenario_key = " + scen_key
: " AND xcp.ins_scenario_key IS NULL")
+ " GROUP BY di.ins_srtcontrole_key"
+ " , di.ins_srtcontrole_omschrijving"
+ " , di.ins_srtcontrole_mode"
+ " , di.ins_deel_aantal"
+ " GROUP BY xcp.ins_srtcontrole_key"
+ " , xcp.ins_srtcontrole_omschrijving"
+ " , xcp.ins_srtcontrole_mode"
+ " , xcp.ins_deel_aantal"
+ " , xcp.ins_srtcontroledl_xcp_aantal"
+ " , di.ins_srtdeel_eenheid"
+ " , xcp.ins_srtdeel_eenheid"
+ " , xcp.ins_srtcontroledl_xcp_aanteh"
+ " , di.ins_srtcontrole_periode"
+ " , di.ins_srtcontrole_eenheid"
+ " , di.ins_srtcontrole_bits"
+ " , di.ins_srtcontrole_groep"
+ " , di.ins_srtcontrole_kosten"
+ " , di.ins_srtcontrole_kosten2"
+ " , di.ins_srtcontrole_kosten3"
+ " , di.ins_srtcontrole_uren"
+ " , di.ins_srtcontrole_materiaal"
+ " , di.ins_srtcontrole_percentage"
+ " , di.ins_srtcontrole_opmerking"
+ " , di.ins_srtcontrole_eind"
+ " , di.ins_deel_key"
+ " , xcp.ins_srtcontrole_periode"
+ " , xcp.ins_srtcontrole_eenheid"
+ " , xcp.ins_srtcontrole_bits"
+ " , xcp.ins_srtcontrole_groep"
+ " , xcp.ins_srtcontrole_kosten"
+ " , xcp.ins_srtcontrole_kosten2"
+ " , xcp.ins_srtcontrole_kosten3"
+ " , xcp.ins_srtcontrole_uren"
+ " , xcp.ins_srtcontrole_materiaal"
+ " , xcp.ins_srtcontrole_percentage"
+ " , xcp.ins_srtcontrole_opmerking"
+ " , xcp.ins_srtcontrole_eind"
+ " , xcp.ins_deel_key"
+ " , xcp.ins_srtcontroledl_xcp_key"
+ " , xcp.ins_srtcontroledl_xcp_periode"
+ " , xcp.ins_srtcontroledl_xcp_eenheid"
@@ -832,7 +719,7 @@ if (srtcont_key > 0)
+ " , xcp.ins_srtcontroledl_xcp_opmerk"
+ " , xcp.ins_srtcontroledl_xcp_startdat"
+ " , xcp.ins_srtcontroledl_xcp_eind"
+ " , di.ctr_ismjob"
+ " , xcp.ctr_ismjob"
+ " HAVING COUNT(*) = " + cntdeel + ")" // Als multi dan alleen de inspecties die voor *alle* objecten gelden
+ " ORDER BY ins_srtcontrole_omschrijving";
FCLTselector("sel_srtcontrole",

38
APPL/MGT/ctr_scenario.asp Normal file
View File

@@ -0,0 +1,38 @@
<%@language = "javascript" %>
<% /*
$Revision$
$Id$
File: ctr_scenario.asp
Description: fac_management aanroep van model_ctr_scenario
Context:
Notes:
*/
%>
<!-- #include file="../scf/scaffolding.inc" -->
<!-- #include file="../api2/model_ctr_scenario.inc" -->
<%
var this_model = new model_ctr_scenario();
scaffolding(this_model,
{
"search": {
"autosearch": true
},
"list": {
"columns": [
"id",
"name"
]
},
"edit":{
"modal": true,
requires: { js: ["./ctr_scenario.js"] },
buttons: [{ title: L("lcl_mjb_inst_scen"), action: "institute_scenario", icon: "plus.png" }]
}
});
%>

View File

@@ -17,8 +17,6 @@ var JSON_Result = true;
%>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="../Shared/selector.inc" -->
<!-- #include file="../Shared/json2.js" -->
<!-- #include file="../shared/save2db.inc" -->
<!-- #include file="../ins/ins.inc" -->
@@ -41,8 +39,9 @@ while (!oRs.eof)
var ins_key = oRs("ins_deel_key").Value;
var srtcont_key = oRs("ins_srtcontrole_key").Value;
// Rechten controleren.
var this_ins = ins.func_enabled_deel(ins_key, {srtcont_key: srtcont_key});
if (this_ins.canChangeXcp) // Mag ik de AS xcp waarde wijzigen?
//var this_ins = ins.func_enabled_deel(ins_key, {srtcont_key: srtcont_key});
//if (this_ins.canChangeXcp) // Mag ik de AS xcp waarde wijzigen?
if (true) // Doorvoeren mag vooralsnog altijd.
{
ingesloten.push({ins_key: ins_key, srtcont_key: srtcont_key});

View File

@@ -386,12 +386,14 @@ var transitParam = buildTransitParam(["disc", "srtgroep", "srtdeel", "srtcontrol
+ " , el.ctr_controle_type"
+ " , el.ins_scenario_key"
+ " , el.hasscenario" // Heeft de periodieke taak ook <20><>n of meerdere scenario's.
+ " , COALESCE((SELECT MAX(1)" // Heeft de periodieke taak ook de meegegeven scenario 'scenario'.
+ " FROM ins_srtcontroledl_xcp xcp2"
+ " WHERE xcp2.ins_deel_key = el.ins_deel_key"
+ " AND xcp2.ins_srtcontrole_key = el.ins_srtcontrole_key"
+ " AND xcp2.ins_scenario_key = " + scenario
+ " AND xcp2.ins_scenario_key IS NOT NULL), 0) hasscenario2"
+ (scenario > 0
? " , COALESCE((SELECT MAX(1)" // Heeft de periodieke taak ook de meegegeven scenario 'scenario'.
+ " FROM ins_srtcontroledl_xcp xcp2"
+ " WHERE xcp2.ins_deel_key = el.ins_deel_key"
+ " AND xcp2.ins_srtcontrole_key = el.ins_srtcontrole_key"
+ " AND xcp2.ins_scenario_key = " + scenario
+ " AND xcp2.ins_scenario_key IS NOT NULL), 0)"
: " , 0") + " hasscenario2"
+ " , (SELECT LISTAGG(isc.ins_scenario_omschrijving, ', ') WITHIN GROUP (ORDER BY isc.ins_scenario_omschrijving)"
+ " FROM ins_srtcontroledl_xcp xcp"
+ " , ins_scenario isc"
@@ -418,7 +420,7 @@ var transitParam = buildTransitParam(["disc", "srtgroep", "srtdeel", "srtcontrol
+ " AND w.fac_gebruiker_prs_level_read < 9"
+ " AND w.fac_gebruiker_alg_level_read < 9"
+ " AND w.prs_perslid_key = " + user_key
+ " AND el.ctr_discipline_key = w.ins_discipline_key)"
+ " AND w.ins_discipline_key = el.ctr_discipline_key)"
// Vroeg filteren is *heel* goed voor performance
+ (dist_key > 0
? " AND el.ins_alg_locatie_key IN (SELECT alg_locatie_key FROM alg_locatie WHERE alg_district_key = " + dist_key + ")"
@@ -1000,10 +1002,10 @@ var transitParam = buildTransitParam(["disc", "srtgroep", "srtdeel", "srtcontrol
doneclik[deel_key + ":" + srtcont_key] = 1;
var scen_key = oRs("ins_scenario_key").Value? oRs("ins_scenario_key").Value : -1;
// INSUSE read rechten heb je al nodig om dit overzicht te zien.
// Inspecties in de status gestart(2) of gereedgemeld(5) mogen niet drag en drop zijn. Planningsdatum is daarvan niet aan te passen.
return "<span" + (hasWriteCTRUSE? " class='" + (oRs("canBePlanned").Value == 1? "details draggable" : "") + "'" : "") + ">{0}</span>".format(safe.curr(v, true))
return "<span" + (hasWriteCTRUSE? " class='" + (oRs("canBePlanned").Value == 1 && (scenario < 0 || scen_key > 0 || oRs("hasscenario2").Value == 1)? "details draggable" : "") + "'" : "") + ">{0}</span>".format(safe.curr(v, true))
/* experimenteel inline schuiven
var fnprev = "moveplan(event, {0}, {1}, {2}-1)".format(deel_key, srtcont_key, jaar);
var fnnext = "moveplan(event, {0}, {1}, {2}+1)".format(deel_key, srtcont_key, jaar);