/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2013 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/setup-verification.xml');

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/setup-verification.xml',
'<View title="2FA-Verification" defaultFormHandler="xxas_com_2fa_pkg.setup_form_handler" showSubmit="true" submitLabel="{message.XXAS_RB_COM_NEXT}" >
  <EditFields>
    <Hidden id = "PERSON_ID"/>
    <Hidden id = "PHONE_ID"/>
    <TextInput id="DESCRIPTION_MSG1" label="{message.XXAS_2FA_VERF_DESC_MSG}" enabled="false"/>
    <TextInput id="DESCRIPTION_MSG2" label="{message.XXAS_2FA_VERF_DESC_MSG2}" enabled="false"/>
    <Poplist id="PHONE_TYPE" label="{message.XXAS_2FA_PHONE_TYPE}" listProvider="REST:2FA/GetPhoneType"   visible="true" value="W1" enabled="true" required="true" refreshOnChange="TRUE" valueSet="XXDUMMY" />
    <Poplist id="PHONE_TYPE_OLD" label="{message.XXAS_2FA_PHONE_TYPE}" listProvider="REST:2FA/GetPhoneType"   visible="FALSE" value="W1" valueSet="XXDUMMY" />
    
    <Poplist id="COUNTRY_CODE" label="{message.XXAS_2FA_COUNTRY_CODE}" visible="true" value="GB" enabled="true" required="true" listProvider="VALUE_SET_NAME:COUNTRY_PHONE_CODE"   valueSet="COUNTRY_PHONE_CODE" restAPI="XXDUMMY"/>
    <TextInput id="PHONE_NUMBER" enabled="true" label="{message.XXAS_EMP_PHONE_NUMBER}" required="true" placeholder="enter phone number" refreshOnChange="TRUE" visible="true"/>
    <TextInput id="PHONE_NUMBER_OLD" label="{message.XXAS_EMP_PHONE_NUMBER}"  visible="FALSE"/>
    <Flexfield  applicationId="800" descriptiveFlexfieldName="PER_PHONES"/>
    <Html id="NUMBER_PENDING_DESC" value="{message.XXAS_2FA_NUM_PEND_ERR_MSG}"  visible="false"/>
    <Html id="CHANGE_NUMBER_DESC" value="{message.XXAS_2FA_CHANGE_NUMBER_DESC}"  visible="false"/>
    <Poplist id="CHANGE_NUMBER" label="{message.XXAS_2FA_CHANGE_NUMBER}" visible="false"   enabled="true" style="radio"/>

  </EditFields>
</View>
' ); 
xxas_forms_pkg.update_forms_resource('/public/xxas/emp/view/setup-verification.xml');
END;
/
COMMIT;
EXIT;
/