/* $Id:*/
/*============================================================================*
 |                 Copyright (c) 2014 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/enter-code.xml');

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/enter-code.xml',
'<View title="{message.XXAS_2FA_ENTERCODE_TITLE}" multiFactorAuthenticated="true" showSubmit="true" defaultFormHandler="xxas_com_2fa_pkg.enter_code_form_handler" submitLabel="{message.XXAS_RB_COM_GO}">

   <EditFields>
		
		<Hidden id="PHONE_NUMBER" />
		<Hidden id="BACKUP_CODE"  />
		<TextInput id="DESCRIPTION_MSG" label="{message.XXAS_2FA_ENTER_CODE_DES}" enabled="false"/>
		<TextInput id="ENTER_CODE_MSG" label="{message.XXAS_2FA_ENTER_CODE}" enabled="false"/>
		<TextInput id="DIGIT_CODE" label="{message.XXAS_2FA_DIGIT_CODE}" required="true"  />
		<Link label="{message.XXAS_2FA_GET_CODE_LINK}" value="#/two-step-troubleshoot" target="modal" hideIf="!model.BACKUP_CODE.value"/>
		<Link label="{message.XXAS_2FA_GET_CODE_LINK}" value="#/setup-2-step-verification" target="modal" hideIf="model.BACKUP_CODE.value" />
		
   </EditFields>

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