/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2016 Applaud Solutions UK Ltd                |
 |                             All rights reserved                            |
 *===========================================================================*/

SET VERIFY OFF
SET FEEDBACK OFF
SET SCAN OFF
WHENEVER OSERROR  EXIT FAILURE ROLLBACK
WHENEVER SQLERROR EXIT FAILURE ROLLBACK



DECLARE 

  e_dir_exists EXCEPTION;
  PRAGMA EXCEPTION_INIT(e_dir_exists, -31003);

  e_does_not_exists EXCEPTION;
  PRAGMA EXCEPTION_INIT(e_does_not_exists , -31001);

  result boolean;
  
BEGIN

  BEGIN

    result := DBMS_XDB.createfolder('/public/xxas/');
    result := DBMS_XDB.createfolder('/public/xxas/emp/');
    result := DBMS_XDB.createfolder('/public/xxas/emp/view/');

  EXCEPTION
    WHEN e_dir_exists THEN
      NULL;
  END;

  
  BEGIN

    DBMS_XDB.DeleteResource('/public/xxas/emp/view/generalsettings.xml');

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/generalsettings.xml',
'<View defaultFormHandler="xxas_general_page_pkg.save_general_settings_form" title="General settings">

  <EditFields>
    <Container id="GENERAL_GRP" label="General">
      <Hidden id="AUTOSETUP_ID"/>
      <TextInput id="GUEST_HOME_PAGE" label="Guest Home Page" enabled="true" required="true"/>
      <TextInput id="AUTHENTICATED_HOME_PAGE" label="Authenticated Home Page" enabled="true" required="true"/>
      <!--TextInput id="SHOW_SEARCH" label="Show search" enabled="true"/-->
      <Poplist id="SHOW_SEARCH" label="Show search" listProvider="LOOKUP_TYPE:XXAS_GLOBAL_SEARCH" />
      <Combolist id="EMP_REG_VIEWS_MENU" label="Applaud Registered Views Menu" enabled="true" listProvider="VALUE_SET_NAME:Applaud Registered Views Menu" longlist="true" required="true"/>      
    </Container>
    <Container id="CLOUD_GRP" label="Applaud Cloud">    
      <TextInput id="TENANT_ID" label="Tenant Id"/>
      <TextInput id="CLOUD_API_KEY" label="Applaud Cloud API key"/>
      <TextInput id="PUSH_NOTIFICATION_API_KEY" label="Push Notification API Key" enabled="true"/>
    </Container>
    <Container id="BRANDING_GRP" label="Branding">      
      <TextInput id="BRANDING_LOGO" label="Branding logo" enabled="true"/>
      <TextInput id="FAV_ICON" label="Fav Icon" enabled="true"/>
      <TextInput id="STYLE_SHEET" label="Theme Id" enabled="true"/>
      <Poplist id="FLASH_THEME" label="Flash Theme" enabled="true" listProvider="VALUE_SET_NAME:XXAS_COLOR_THEMES"/>
    </Container>
    <Container id="TRACKING_GRP" label="Tracking">
      <TextInput id="GOOGLE_ANALYTICS_CODE" label="Google Analytics Tracking Code" enabled="true"/>
      <!--TextInput id="AUDIT_ENABLED" label="Auditing" enabled="true"/-->
      <Poplist id="AUDIT_ENABLED" label="Auditing" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" positiveBooleanValue="Y"/>
    </Container>
    <Container id="SUPPORT_GRP" label="Support">      
      <!--TextInput id="SEND_DIAG_TO_APPLAUD" label="Send Diagnostics to Applaud" enabled="true"/-->
      <Poplist id="SEND_DIAG_TO_APPLAUD" label="Send Diagnostics to Applaud" listProvider="LOOKUP_TYPE:YES_NO"  showAsBoolean="true" positiveBooleanValue="Y"/>
      <Combolist id="SUPPORT_ROLE" label="Support Role" enabled="true" listProvider="VALUE_SET_NAME:XXAS_Support_Roles" longlist="true" required="true"/>
    </Container>      
    <Container id="AUTHENTICATION_GRP" label="Authentication">            
      <TextInput id="SSO_LOGIN_URL" label="SSO Login URL" enabled="true"/>
      <TextInput id="CUSTOM_AUTH_CLASS" label="Custom authentication class" enabled="true"/>
      <!--TextInput id="TWO_FACTOR" label="Use two-factor" enabled="true"/-->
      <Poplist id="TWO_FACTOR" label="Use two-factor" listProvider="LOOKUP_TYPE:YES_NO"  showAsBoolean="true" positiveBooleanValue="Y"/>
    </Container>      
  </EditFields>

</View>' ); 
xxas_forms_pkg.update_forms_resource('/public/xxas/emp/view/generalsettings.xml');
END;
/
COMMIT;
EXIT;
