WTCA#52410 NACHTWERK-export (en rapportages) tbv. toegang huurders
svn path=/Customer/trunk/; revision=37942
This commit is contained in:
149
WTCA/wtca.sql
149
WTCA/wtca.sql
@@ -198,7 +198,7 @@ END;
|
||||
/
|
||||
|
||||
-- WTCA#52410: Controle-rapportage H- en UV-inrichting.
|
||||
CREATE OR REPLACE VIEW wtca_v_relatie_controle
|
||||
CREATE OR REPLACE VIEW wtca_v_rap_relatie_controle
|
||||
(
|
||||
fclt_f_controle,
|
||||
controle_ref
|
||||
@@ -278,13 +278,33 @@ AS
|
||||
AND a.prs_bedrijf_key = 61 -- Huurders
|
||||
AND a.prs_afdeling_parentkey IS NULL
|
||||
AND a.prs_afdeling_key = p.prs_afdeling_key
|
||||
AND p.prs_perslid_verwijder IS NULL
|
||||
AND p.prs_perslid_key = cp.prs_perslid_key
|
||||
AND cp.prs_contactpersoon_verwijder IS NULL
|
||||
AND cp.prs_bedrijf_key = b.prs_bedrijf_key
|
||||
AND b.prs_bedrijf_verwijder IS NULL
|
||||
AND UPPER (a.prs_afdeling_omschrijving) != TRIM (b.prs_bedrijf_naam_upper)
|
||||
UNION ALL
|
||||
SELECT '***H-account niet gelinkt aan H-relatie met RELUSE-rechten', a.prs_afdeling_naam || '-' || a.prs_afdeling_omschrijving || '/' || p.prs_perslid_naam
|
||||
FROM prs_afdeling a, prs_v_aanwezigperslid p
|
||||
WHERE a.prs_afdeling_verwijder IS NULL
|
||||
AND a.prs_bedrijf_key = 61 -- Huurders
|
||||
AND a.prs_afdeling_parentkey IS NULL
|
||||
AND a.prs_afdeling_key = p.prs_afdeling_key
|
||||
AND COALESCE (p.prs_perslid_oslogin, p.prs_perslid_oslogin2) IS NOT NULL
|
||||
AND NOT EXISTS
|
||||
(SELECT 1
|
||||
FROM prs_contactpersoon cp, prs_bedrijf b
|
||||
WHERE cp.prs_contactpersoon_verwijder IS NULL
|
||||
AND cp.prs_bedrijf_key = b.prs_bedrijf_key
|
||||
AND b.prs_bedrijf_verwijder IS NULL
|
||||
AND cp.prs_perslid_key = p.prs_perslid_key)
|
||||
AND EXISTS
|
||||
(SELECT 1
|
||||
FROM fac_gebruikersgroep gg, fac_groeprechten gr
|
||||
WHERE gg.fac_groep_key = gr.fac_groep_key
|
||||
AND gr.fac_functie_key IN (43, 462) -- RELMAN/RELUSE
|
||||
AND gg.prs_perslid_key = p.prs_perslid_key)
|
||||
UNION ALL
|
||||
SELECT 'UV-afdeling leeg', a.prs_afdeling_naam || '-' || a.prs_afdeling_omschrijving
|
||||
FROM prs_afdeling a
|
||||
WHERE a.prs_afdeling_verwijder IS NULL
|
||||
@@ -353,12 +373,51 @@ AS
|
||||
WHERE a.prs_afdeling_verwijder IS NULL
|
||||
AND a.prs_afdeling_parentkey = 341 -- UV
|
||||
AND a.prs_afdeling_key = p.prs_afdeling_key
|
||||
AND p.prs_perslid_verwijder IS NULL
|
||||
AND p.prs_perslid_key = cp.prs_perslid_key
|
||||
AND cp.prs_contactpersoon_verwijder IS NULL
|
||||
AND cp.prs_bedrijf_key = b.prs_bedrijf_key
|
||||
AND b.prs_bedrijf_verwijder IS NULL
|
||||
AND UPPER (a.prs_afdeling_omschrijving) != TRIM (b.prs_bedrijf_naam_upper);
|
||||
AND UPPER (a.prs_afdeling_omschrijving) != TRIM (b.prs_bedrijf_naam_upper)
|
||||
UNION ALL
|
||||
SELECT '***UV-account niet gelinkt aan UV-relatie met RELUSE-rechten', a.prs_afdeling_naam || '-' || a.prs_afdeling_omschrijving || '/' || p.prs_perslid_naam
|
||||
FROM prs_afdeling a, prs_v_aanwezigperslid p
|
||||
WHERE a.prs_afdeling_verwijder IS NULL
|
||||
AND a.prs_afdeling_parentkey = 341 -- UV
|
||||
AND a.prs_afdeling_key = p.prs_afdeling_key
|
||||
AND COALESCE (p.prs_perslid_oslogin, p.prs_perslid_oslogin2) IS NOT NULL
|
||||
AND NOT EXISTS
|
||||
(SELECT 1
|
||||
FROM prs_contactpersoon cp, prs_bedrijf b
|
||||
WHERE cp.prs_contactpersoon_verwijder IS NULL
|
||||
AND cp.prs_bedrijf_key = b.prs_bedrijf_key
|
||||
AND b.prs_bedrijf_verwijder IS NULL
|
||||
AND cp.prs_perslid_key = p.prs_perslid_key)
|
||||
AND EXISTS
|
||||
(SELECT 1
|
||||
FROM fac_gebruikersgroep gg, fac_groeprechten gr
|
||||
WHERE gg.fac_groep_key = gr.fac_groep_key
|
||||
AND gr.fac_functie_key IN (43, 462) -- RELMAN/RELUSE
|
||||
AND gg.prs_perslid_key = p.prs_perslid_key)
|
||||
UNION ALL
|
||||
SELECT '***UV-account niet gelinkt aan UV-relatie met ORDxxx-rechten', a.prs_afdeling_naam || '-' || a.prs_afdeling_omschrijving || '/' || p.prs_perslid_naam
|
||||
FROM prs_afdeling a, prs_v_aanwezigperslid p
|
||||
WHERE a.prs_afdeling_verwijder IS NULL
|
||||
AND a.prs_afdeling_parentkey = 341 -- UV
|
||||
AND a.prs_afdeling_key = p.prs_afdeling_key
|
||||
AND COALESCE (p.prs_perslid_oslogin, p.prs_perslid_oslogin2) IS NOT NULL
|
||||
AND NOT EXISTS
|
||||
(SELECT 1
|
||||
FROM prs_contactpersoon cp, prs_bedrijf b
|
||||
WHERE cp.prs_contactpersoon_verwijder IS NULL
|
||||
AND cp.prs_bedrijf_key = b.prs_bedrijf_key
|
||||
AND b.prs_bedrijf_verwijder IS NULL
|
||||
AND cp.prs_perslid_key = p.prs_perslid_key)
|
||||
AND EXISTS
|
||||
(SELECT 1
|
||||
FROM fac_gebruikersgroep gg, fac_groeprechten gr
|
||||
WHERE gg.fac_groep_key = gr.fac_groep_key
|
||||
AND gr.fac_functie_key IN (31, 32, 34, 35, 242) -- ORDBOF/ORDBO2/ORDSUP/ORDFIN/ORDAFR
|
||||
AND gg.prs_perslid_key = p.prs_perslid_key);
|
||||
|
||||
-- Dummy export NACHTWERK!
|
||||
-- WTCA#52410: Automatisch toevoegen/verwijderen H-relaties (incl. contactpersoon).
|
||||
@@ -406,7 +465,7 @@ AS
|
||||
CURSOR c_huurderrel_del
|
||||
IS
|
||||
SELECT DISTINCT '[' || b.prs_bedrijf_naam || '] ' aanduiding,
|
||||
b.prs_bedrijf_key, b.prs_bedrijf_naam
|
||||
b.prs_bedrijf_key, b.prs_bedrijf_naam, p.prs_perslid_key
|
||||
FROM prs_afdeling a, prs_perslid p, prs_contactpersoon cp, prs_bedrijf b
|
||||
WHERE a.prs_afdeling_verwijder IS NULL
|
||||
AND a.prs_bedrijf_key = 61 -- Huurders
|
||||
@@ -421,6 +480,7 @@ AS
|
||||
FROM prs_v_aanwezigperslid p
|
||||
WHERE p.prs_afdeling_key = a.prs_afdeling_key);
|
||||
|
||||
c_groep_cp NUMBER (10) := 381; -- Contactpersonenbeheer-groep
|
||||
v_errormsg VARCHAR2 (1000);
|
||||
oracle_err_num NUMBER;
|
||||
oracle_err_mes VARCHAR2 (200);
|
||||
@@ -498,6 +558,17 @@ BEGIN
|
||||
WHERE p.prs_srtperslid_key = sp.prs_srtperslid_key
|
||||
AND p.prs_perslid_key = rec.prs_perslid_key;
|
||||
|
||||
v_errormsg := 'Fout toekennen Contactpersonenbeheer-groep';
|
||||
|
||||
INSERT INTO fac_gebruikersgroep (fac_groep_key, prs_perslid_key)
|
||||
SELECT c_groep_cp, rec.prs_perslid_key
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS
|
||||
(SELECT 1
|
||||
FROM fac_gebruikersgroep
|
||||
WHERE fac_groep_key = c_groep_cp
|
||||
AND prs_perslid_key = rec.prs_perslid_key);
|
||||
|
||||
COMMIT;
|
||||
|
||||
v_count := v_count + 1;
|
||||
@@ -523,13 +594,21 @@ BEGIN
|
||||
|
||||
UPDATE prs_bedrijf
|
||||
SET prs_bedrijf_naam = SUBSTR ('VERVALLEN:' || prs_bedrijf_naam, 1, 60)
|
||||
WHERE prs_bedrijf_key = rec.prs_bedrijf_key;
|
||||
WHERE INSTR (prs_bedrijf_naam_upper, 'VERVALLEN') = 0
|
||||
AND prs_bedrijf_key = rec.prs_bedrijf_key;
|
||||
|
||||
v_errormsg := 'Fout toevoegen H-contactpersoon';
|
||||
v_errormsg := 'Fout verwijderen H-contactpersoon';
|
||||
|
||||
UPDATE prs_contactpersoon
|
||||
SET prs_contactpersoon_verwijder = SYSDATE
|
||||
WHERE prs_bedrijf_key = rec.prs_bedrijf_key;
|
||||
WHERE prs_contactpersoon_verwijder IS NULL
|
||||
AND prs_bedrijf_key = rec.prs_bedrijf_key;
|
||||
|
||||
v_errormsg := 'Fout afnemen Contactpersonenbeheer-groep';
|
||||
|
||||
DELETE FROM fac_gebruikersgroep
|
||||
WHERE fac_groep_key = c_groep_cp
|
||||
AND prs_perslid_key = rec.prs_perslid_key;
|
||||
|
||||
COMMIT;
|
||||
|
||||
@@ -556,7 +635,7 @@ EXCEPTION
|
||||
END wtca_select_nachtwerk;
|
||||
/
|
||||
|
||||
-- WTCA#52410: Toegang huurders.
|
||||
-- WTCA#52410: Toegang huurders en uitvoerenden.
|
||||
CREATE OR REPLACE VIEW wtca_v_rap_toegang_huurders
|
||||
(
|
||||
huurder,
|
||||
@@ -575,21 +654,24 @@ AS -- H-relaties
|
||||
DECODE (kl1.prs_kenmerklink_waarde, '81', 'Ja', '82', 'Nee', NULL) contract,
|
||||
DECODE (kl2.prs_kenmerklink_waarde, '1', 'Ja', 'Nee') access_main_entrance,
|
||||
DECODE (kl1.prs_kenmerklink_waarde, '81', DECODE (kl3.prs_kenmerklink_waarde, '1', 'Ja', 'Nee'), 'Nvt') key_pickup
|
||||
FROM (SELECT b.prs_bedrijf_key, b.prs_bedrijf_naam, cp.prs_perslid_key
|
||||
FROM prs_afdeling a, prs_v_aanwezigperslid p, prs_contactpersoon cp, prs_bedrijf b
|
||||
WHERE a.prs_afdeling_verwijder IS NULL
|
||||
AND a.prs_bedrijf_key = 61 -- Huurders
|
||||
AND a.prs_afdeling_parentkey IS NULL
|
||||
AND a.prs_afdeling_key = p.prs_afdeling_key
|
||||
AND p.prs_perslid_verwijder IS NULL
|
||||
AND COALESCE (p.prs_perslid_oslogin, p.prs_perslid_oslogin2) IS NOT NULL
|
||||
AND p.prs_perslid_key = cp.prs_perslid_key
|
||||
AND cp.prs_contactpersoon_verwijder IS NULL
|
||||
AND cp.prs_bedrijf_key = b.prs_bedrijf_key
|
||||
AND b.prs_bedrijf_verwijder IS NULL) x
|
||||
FROM ( SELECT b.prs_bedrijf_key, b.prs_bedrijf_naam,
|
||||
MIN (cp.prs_perslid_key) prs_perslid_key
|
||||
FROM prs_afdeling a, prs_v_aanwezigperslid p, prs_contactpersoon cp, prs_bedrijf b
|
||||
WHERE a.prs_afdeling_verwijder IS NULL
|
||||
AND a.prs_bedrijf_key = 61 -- Huurders
|
||||
AND a.prs_afdeling_parentkey IS NULL
|
||||
AND a.prs_afdeling_key = p.prs_afdeling_key
|
||||
AND p.prs_perslid_verwijder IS NULL
|
||||
AND COALESCE (p.prs_perslid_oslogin, p.prs_perslid_oslogin2) IS NOT NULL
|
||||
AND p.prs_perslid_key = cp.prs_perslid_key
|
||||
AND cp.prs_contactpersoon_verwijder IS NULL
|
||||
AND cp.prs_bedrijf_key = b.prs_bedrijf_key
|
||||
AND b.prs_bedrijf_verwijder IS NULL
|
||||
GROUP BY b.prs_bedrijf_key, b.prs_bedrijf_naam) x
|
||||
LEFT JOIN
|
||||
prs_contactpersoon cp
|
||||
ON x.prs_bedrijf_key = cp.prs_bedrijf_key
|
||||
AND cp.prs_contactpersoon_verwijder IS NULL
|
||||
LEFT JOIN
|
||||
prs_v_aanwezigkenmerklink kl1
|
||||
ON x.prs_perslid_key = kl1.prs_link_key
|
||||
@@ -614,20 +696,23 @@ AS -- H-relaties
|
||||
DECODE (kl1.prs_kenmerklink_waarde, '81', 'Ja', '82', 'Nee', NULL) contract,
|
||||
DECODE (kl2.prs_kenmerklink_waarde, '1', 'Ja', 'Nee') access_main_entrance,
|
||||
DECODE (kl1.prs_kenmerklink_waarde, '81', DECODE (kl3.prs_kenmerklink_waarde, '1', 'Ja', 'Nee'), 'Nvt') key_pickup
|
||||
FROM (SELECT b.prs_bedrijf_key, b.prs_bedrijf_naam, cp.prs_perslid_key
|
||||
FROM prs_afdeling a, prs_v_aanwezigperslid p, prs_contactpersoon cp, prs_bedrijf b
|
||||
WHERE a.prs_afdeling_verwijder IS NULL
|
||||
AND a.prs_afdeling_parentkey = 341 -- UV
|
||||
AND a.prs_afdeling_key = p.prs_afdeling_key
|
||||
AND p.prs_perslid_verwijder IS NULL
|
||||
AND COALESCE (p.prs_perslid_oslogin, p.prs_perslid_oslogin2) IS NOT NULL
|
||||
AND p.prs_perslid_key = cp.prs_perslid_key
|
||||
AND cp.prs_contactpersoon_verwijder IS NULL
|
||||
AND cp.prs_bedrijf_key = b.prs_bedrijf_key
|
||||
AND b.prs_bedrijf_verwijder IS NULL) x
|
||||
FROM ( SELECT b.prs_bedrijf_key, b.prs_bedrijf_naam,
|
||||
MIN (cp.prs_perslid_key) prs_perslid_key
|
||||
FROM prs_afdeling a, prs_v_aanwezigperslid p, prs_contactpersoon cp, prs_bedrijf b
|
||||
WHERE a.prs_afdeling_verwijder IS NULL
|
||||
AND a.prs_afdeling_parentkey = 341 -- UV
|
||||
AND a.prs_afdeling_key = p.prs_afdeling_key
|
||||
AND p.prs_perslid_verwijder IS NULL
|
||||
AND COALESCE (p.prs_perslid_oslogin, p.prs_perslid_oslogin2) IS NOT NULL
|
||||
AND p.prs_perslid_key = cp.prs_perslid_key
|
||||
AND cp.prs_contactpersoon_verwijder IS NULL
|
||||
AND cp.prs_bedrijf_key = b.prs_bedrijf_key
|
||||
AND b.prs_bedrijf_verwijder IS NULL
|
||||
GROUP BY b.prs_bedrijf_key, b.prs_bedrijf_naam) x
|
||||
LEFT JOIN
|
||||
prs_contactpersoon cp
|
||||
ON x.prs_bedrijf_key = cp.prs_bedrijf_key
|
||||
AND cp.prs_contactpersoon_verwijder IS NULL
|
||||
LEFT JOIN
|
||||
prs_v_aanwezigkenmerklink kl1
|
||||
ON x.prs_perslid_key = kl1.prs_link_key
|
||||
|
||||
Reference in New Issue
Block a user