--
-- $Id$
--

DEFINE thisfile = 'PLAT02.SQL'
DEFINE dbuser   = '^(PLAT|WOMA)'
DEFINE custid   = '^(PLAT|WOMA)'

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

------ payload begin ------

-- Enkele flexprops bij locatie, de keys t/m 1000 zijn vrij voor eigen gebruik (SEQUENCE alg_s_alg_kenmerk_key begint bij 1000, zie ALG_SEQ.SRC).
-- D'r zijn reeds 3 flexprops aangemaakt, zie plat_ini.
-- PLAT#41493: TB035 Cluster bevat niet het aantal percelen
INSERT INTO alg_kenmerk (alg_kenmerk_key, alg_kenmerk_niveau, alg_kenmerk_volgnr, alg_kenmerk_omschrijving, alg_kenmerk_kenmerktype, alg_kenmerk_toonbaar, alg_kenmerk_lengte)
VALUES (4, 'G', 100, 'Aantal percelen', 'N', 1, 9);


-- PLAT#36309:  MJOP-Export vanuit PLATO, Import in Tobias AX.
INSERT INTO fac_export_app	(fac_export_app_code, fac_export_app_flags, fac_export_app_oms, fac_export_app_timestamp,
                            fac_functie_key, fac_export_app_prefix,
                            fac_export_app_folder, fac_export_app_file_prefix, fac_export_app_postfix, fac_export_app_log_postfix)
SELECT 'MJOB_TOBIAS_AX', 2, 'Export van geaccordeerde MJOB taken naar Tobias-AX 2009', 'yyyymmdd_HHMM',
fac_functie_key, 'PLAT',
'../export/TobiasAX', 'tobiasax_', '.csv', '.log'
FROM fac_functie
WHERE fac_functie_code = 'WEB_FINMSU';

INSERT INTO fac_menu (fac_menu_volgnr, fac_menu_altlabel, fac_menu_alturl, fac_menu_altgroep, fac_functie_key, fac_menu_portal)
SELECT 1030, 'Tobias - MJOB Export (csv)', 'appl/exp/exp_export.asp?export_key=' || fac_export_app_key, 1 , f.fac_functie_key, 1
FROM fac_export_app, fac_functie f WHERE fac_export_app_code = 'MJOB_TOBIAS_AX' AND f.fac_functie_code = 'WEB_USER50';

-- Omdat Tobias-AX geen CSV kan inlezen, maar (alleen/wel) Excel, doen we geen export, maar een rapport.
-- Om insert hieronder te laten slagen, eerst dummy view aanmaken.
CREATE VIEW plat_v_rap_mjob_tobiasax (x) AS SELECT 'x' FROM DUAL;
INSERT INTO fac_usrrap (fac_usrrap_omschrijving, fac_usrrap_view_name, fac_usrrap_functie, fac_usrrap_info, fac_usrrap_count, fac_usrrap_ratio, fac_usrrap_pivot, fac_usrrap_graph, fac_usrrap_cond,  fac_functie_key, fac_usrrap_graph_type)
SELECT 'Export Tobias-AX', 'plat_v_rap_mjob_tobiasax', 0, 'Draai dit rapport uit, open via de Excel-knop het XLS-bestand en bewaar dan als XLSX.', 0, 0,  0, 0, 0, f.fac_functie_key, 0
FROM fac_functie f WHERE f.fac_functie_code = 'WEB_CTRUSE';

INSERT INTO fac_menu (fac_menu_volgnr, fac_menu_altlabel, fac_menu_alturl, fac_menu_altgroep, fac_functie_key, fac_menu_portal)
SELECT 1040, 'Tobias - MJOB Export', 'appl/fac/fac_report.asp?usrrap_key=' || fac_usrrap_key, 1 , f.fac_functie_key, 1
FROM fac_usrrap, fac_functie f WHERE fac_usrrap_view_name = 'plat_v_rap_mjob_tobiasax' AND f.fac_functie_code = 'WEB_CTRUSE';



--PLAT#41511: TB051 Plaats/Eigenaar nog verkeerde omschrijving
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Complex-Cluster' WHERE fac_locale_xsl_label = 'lcl_obj_position' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = ' ' WHERE fac_locale_xsl_label = 'lcl_obj_owner' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';

-- PLAT#51253: Plato release 2 bundeling / 2017.2 instellingen 
UPDATE fac_setting SET fac_setting_pvalue = '1' where fac_setting_name = 'mjb_enabled';
UPDATE fac_setting SET fac_setting_pvalue = to_char(to_char(sysdate,'YYYY')  + 1) where fac_setting_name = 'mjb_freeze_year';
UPDATE fac_setting SET fac_setting_pvalue = to_char(to_char(sysdate,'YYYY')  + 1) where fac_setting_name = 'mjb_start_year';
UPDATE fac_setting SET fac_setting_pvalue = '1' where fac_setting_name = 'mjb_operation_external';
-- Alle MJOB taken krijgen naast bitje 1 (starten oftewel inplannen kon dus al) nu ook bitje 2 (om te accorderen/freezen), 1+2=3 (ins_srtcontrole_options)
UPDATE ins_srtcontrole
SET ins_srtcontrole_options = 3
WHERE ctr_discipline_key IN (select ctr_discipline_key FROM ctr_discipline d, ctr_disc_params dp WHERE d.ins_discipline_verwijder IS NULL AND dp.ctr_ins_discipline_key = d.ins_discipline_key AND ctr_disc_params_ismjob = 1);

-- PLAT#41631: Rename van kostenplaats -> projectgroep
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Selecteer een projectgroep...' WHERE fac_locale_xsl_label = 'lcl_select_kostenplaats' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projectgroep gegevens' WHERE fac_locale_xsl_label = 'lcl_kpn_kpn_frame' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'U moet projectgroepen selecteren.' WHERE fac_locale_xsl_label = 'lcl_kpn_mandatory' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Verwijderen projectgroep' WHERE fac_locale_xsl_label = 'lcl_kpn_del_txt_kostenplaats' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Alleen beschikbaar met geldige projectgroep' WHERE fac_locale_xsl_label = 'lcl_select_account_disc' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projectgroep' WHERE fac_locale_xsl_label = 'lcl_account' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projectgroep' WHERE fac_locale_xsl_label = 'lcl_mld_kosten' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projectgroep' WHERE fac_locale_xsl_label = 'lcl_mld_inf_Kostenplaats' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projectgroep' WHERE fac_locale_xsl_label = 'lcl_prs_kosten' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Type projectgroep' WHERE fac_locale_xsl_label = 'lcl_prs_kosttype' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Afdelingen Projectgroep' WHERE fac_locale_xsl_label = 'lcl_prs_kosttype_prs' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Gebouwen Projectgroep' WHERE fac_locale_xsl_label = 'lcl_prs_kosttype_alg' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projecten Projectgroep' WHERE fac_locale_xsl_label = 'lcl_prs_kosttype_prj' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projectgroep code' WHERE fac_locale_xsl_label = 'lcl_prs_kostcode' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projectgroep: Inzage' WHERE fac_locale_xsl_label = 'lcl_prs_kosten_inzage' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projectgroep cluster' WHERE fac_locale_xsl_label = 'lcl_prs_kostenpl_group' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Externe projectgroep' WHERE fac_locale_xsl_label = 'lcl_prs_kpnextern' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Alle projectgroepen' WHERE fac_locale_xsl_label = 'lcl_prs_all_accounts' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projectgroep gewijzigd' WHERE fac_locale_xsl_label = 'lcl_prs_is_prskpu' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projectgroep' WHERE fac_locale_xsl_label = 'lcl_prs_dept_kosten' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projectgroepen' WHERE fac_locale_xsl_label = 'lcl_menu_fin_kostenplaatsen' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projectgroep clusters' WHERE fac_locale_xsl_label = 'lcl_menu_fin_kostenplaatsgroep' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projectgroep' WHERE fac_locale_xsl_label = 'lcl_shared_account' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'is budgethouder voor projectgroep' WHERE fac_locale_xsl_label = 'PRS_BUDGETHOUDER_VAN' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projectgroep verplicht' WHERE fac_locale_xsl_label = 'ins_discipline_kpnverplicht' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = '0;Standaard uit;1;Standaard aan;2;Projectgroep niet tonen' WHERE fac_locale_xsl_label = 'ins_srtdiscipline_kostenklantLOV' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projectgroep' WHERE fac_locale_xsl_label = 'prs_kostenplaats' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projectgroepen' WHERE fac_locale_xsl_label = 'prs_kostenplaats_m' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projectgroepen gewijzigd' WHERE fac_locale_xsl_label = 'lcl_noti_PRSKPU' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projectgroep' WHERE fac_locale_xsl_label = 'kostenplaats' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';
UPDATE fac_locale_xsl SET fac_locale_xsl_cust = 'Projectgroep clusters' WHERE fac_locale_xsl_label = 'lcl_kpn_groep_frame' AND fac_locale_xsl_lang = 'NL' AND fac_locale_xsl_module = 'ASP';


------ 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


--Plato algemeen
@plat.sql
