diff --git a/APPL/INS/ins.inc b/APPL/INS/ins.inc index e11aca4822..1b8098bd2d 100644 --- a/APPL/INS/ins.inc +++ b/APPL/INS/ins.inc @@ -1151,12 +1151,7 @@ ins = {checkAutLevel: + (inspDone ? " SELECT 1 rn" // Afgehandelde inspecties. + " , di.ins_deel_key" - + " , (SELECT MAX(idsc.ins_deelsrtcontrole_datum)" - + " FROM ins_deelsrtcontrole idsc" - + " WHERE idsc.ins_srtcontrole_key = di.ins_srtcontrole_key" - + " AND idsc.ins_deelsrtcontrole_status IN (5, 6)" - + " AND idsc.ins_deel_key = di.ins_deel_key" - + " AND idsc.ins_scenario_key = 1) inspectie_date" + + " , dsc.ins_deelsrtcontrole_datum inspectie_date" + " , di.ins_srtcontroledl_xcp_startdat" + " , NULL nonext" + " , di.ins_srtcontrole_eenheid inspectie_eenheid" @@ -1168,11 +1163,7 @@ ins = {checkAutLevel: + " , NULL ins_deelsrtcontrole_key" + " , (SELECT idsc.ins_deelsrtcontrole_plandatum" + " FROM ins_deelsrtcontrole idsc" - + " WHERE idsc.ins_deelsrtcontrole_key = (SELECT MAX(idsc2.ins_deelsrtcontrole_key)" - + " FROM ins_deelsrtcontrole idsc2" - + " WHERE idsc2.ins_deel_key = di.ins_deel_key" - + " AND idsc2.ins_srtcontrole_key = di.ins_srtcontrole_key" - + " AND idsc2.ins_scenario_key = 1))" // Afgehandelde inspecties. + + " WHERE idsc.ins_deelsrtcontrole_key = dsc.ins_deelsrtcontrole_key)" // Afgehandelde inspecties. + " ins_deelsrtcontrole_plandatum" // Er moet naar de laatste UITGEVOERDE (afgeronde(6)) inspectie gekeken worden om te bepalen of de laatste inspectie een SUCCESS was. + " , di.ctr_controle_type" @@ -1183,12 +1174,7 @@ ins = {checkAutLevel: + " FROM ins_deelsrtcontrole idsc" + " , ins_controlemode cm" + " WHERE idsc.ins_controlemode_key = cm.ins_controlemode_key" - + " AND idsc.ins_deelsrtcontrole_key = (SELECT MAX(idsc2.ins_deelsrtcontrole_key)" - + " FROM ins_deelsrtcontrole idsc2" - + " WHERE idsc2.ins_deel_key = di.ins_deel_key" - + " AND idsc2.ins_srtcontrole_key = di.ins_srtcontrole_key" - + " AND idsc2.ins_deelsrtcontrole_status IN (5, 6)" - + " AND idsc2.ins_scenario_key = 1))" + + " AND idsc.ins_deelsrtcontrole_key = dsc.ins_deelsrtcontrole_key)" + " ins_controlemode_success" + " , di.ctr_discipline_key ctr_disc_key" + " , (SELECT ins_discipline_omschrijving" @@ -1196,7 +1182,10 @@ ins = {checkAutLevel: + " WHERE ins_discipline_key = di.ctr_discipline_key) ctr_disc_oms" : "") + " FROM ins_v_defined_inspect_xcp di" - + " WHERE EXISTS (" + lastinspect + ")" + + " , ins_deelsrtcontrole dsc" // Alle inspecties meenemen als het vinkbokje "Afgehandeld" (inspDone) is aangevinkt. + + " WHERE di.ins_deel_key = dsc.ins_deel_key" + + " AND di.ins_srtcontrole_key = dsc.ins_srtcontrole_key" + + " AND di.ins_scenario_key = dsc.ins_scenario_key" + " AND di.ins_scenario_key = 1" + (srtcontrole > -1 ? " AND di.ins_srtcontrole_key = " + srtcontrole @@ -2240,7 +2229,7 @@ ins = {checkAutLevel: + (koppel_key?" case when xx.ins_deel_key = ins_deelkoppeling_van_key THEN 1 ELSE 0 END,":"") + (outputmode == 2 // excel moet objecten met gelijke kenmerken bij elkaar hebben ? " ins_srtdeel_upper, plaats, soort, ins_deel_omschrijving" - : (mobile? " plaats, ins_deel_omschrijving, soort" : " ins_deel_omschrijving, plaats, ins_disc_oms, ins_groep_oms, soort")); + : (mobile? " plaats, ins_deel_omschrijving, soort" : " ins_deel_omschrijving, inspectie_date, plaats, ins_disc_oms, ins_groep_oms, soort")); return sql; },