--
-- $Id$
--
-- Aanpassingen om DB49 (accp) naar de DB49a te brengen
-- Merk op dat de recreate er nog bij komt die de DB-version bijwerkt
--
-- MOET OOK ZIJN/WORDEN OPGENOMEN IN DB48to49.src !!!

DEFINE thisfile = 'DB49to49a.sql'
DEFINE dbuser   = '*'

SET ECHO ON
SET DEFINE ON
COLUMN fcltlogfile NEW_VALUE fcltlogfile NOPRINT;
COLUMN fcltcusterr NEW_VALUE fcltcusterr NOPRINT;
WHENEVER SQLERROR CONTINUE;
SELECT adm.getscriptspoolfile('&thisfile') AS fcltlogfile FROM DUAL;
SPOOL &fcltlogfile
WHENEVER SQLERROR EXIT;
SELECT adm.checkscriptcust('&dbuser') AS fcltcusterr FROM DUAL;
WHENEVER SQLERROR CONTINUE;
PROMPT &fcltcusterr
SET DEFINE OFF

------ payload begin ------
-- /////////////////////////////////////////////////////////////////////////////////////////// AAXX#81521
ALTER TABLE res_rsv_ruimte
    ADD res_rsv_ruimte_visibility NUMBER (4) DEFAULT 1 NOT NULL;

ALTER TABLE exc_import
    ADD visibility NUMBER (4) DEFAULT 1;

ALTER TABLE exc_import
    ADD CONSTRAINT exc_c_visibility CHECK
            (modifier = 'D' OR visibility IS NOT NULL);

-- /////////////////////////////////////////////////////////////////////////////////////////// SCHG#85790
ALTER TABLE fac_imp_cnt
    MODIFY (cnt_soort VARCHAR2(60));

-- /////////////////////////////////////////////////////////////////////////////////////////// FCLT#81526
UPDATE fac_import_app
   SET fac_import_app_csv = 1
 WHERE fac_import_app_code = 'TAAK_MJOB';

/////////////////////////////////////////////////////////////////////////////////////////// BAUS#80301
-- Autorisatie en module van het menuitem "Taakkenmerken" aanpassen van "WEB_INSMG" en "INS" naar "WEB_CTTMGT" en "CTR".
UPDATE fac_menuitems
   SET fac_menuitems_module = 'CTR',
       fac_functie_key = (SELECT fac_functie_key
                            FROM fac_functie
                           WHERE fac_functie_code = 'WEB_CTRMGT')
 WHERE fac_menuitems_label = 'lcl_menu_ins_taakkenmerken';


-- Aanmaken van het default menuitem "Taakkenmerken":
INSERT INTO fac_menu(fac_menuitems_key,
                     fac_menu_volgnr,
                     fac_menu_altlabel,
                     fac_menu_alturl,
                     fac_menu_altgroep,
                     fac_menu_image,
                     fac_menu_level,
                     fac_menu_info)
    SELECT fac_menuitems_key,
             (SELECT fm.fac_menu_volgnr
                FROM fac_menu fm
               WHERE fm.fac_menu_altlabel = 'lcl_menu_ins_kenmerken')
           + 1,
           fac_menuitems_label,
           fac_menuitems_url,
           fac_menuitems_groep,
           fac_menuitems_image,
           CASE
               WHEN fac_menuitems_groep IN (0, 1, 2) THEN 2
               WHEN fac_menuitems_groep IN (3, 7) THEN 1
               ELSE 0
           END
               fac_menu_level,
           fac_menuitems_oms
      FROM fac_menuitems i
     WHERE fac_menuitems_label = 'lcl_menu_ins_taakkenmerken'
       AND i.fac_menuitems_key NOT IN
               (SELECT m.fac_menuitems_key
                  FROM fac_menu m
                 WHERE m.fac_menuitems_key IS NOT NULL);

------ payload end   ------

SET DEFINE OFF
BEGIN adm.systrackscriptId ('$Id$', 1); END;
/

COMMIT;
SET ECHO OFF
SPOOL OFF
SET DEFINE ON
PROMPT Logfile of this upgrade is: &fcltlogfile