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

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/signup.xml',
'<View sendBasicAuth="true" postToHref="/OA_HTML/applaud/auth/signup" formHelp="{message.XXAS_SIGNUP_HELP}" title="Signup" clientAutosave="false">

  <CreateFields>
    <Poplist id="CURRENT_OR_PAST_EMP_FLAG" label="Are you a past employee?" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" positiveBooleanValue="Y"/>
    <TextInput id="NATIONAL_IDENTIFIER" label="{message.XXAS_SIGNUP_NI_NUMBER}" emptyValue="Your 9 digit code" required="true" description="To help us find you on the system" hideIf="!model.CURRENT_OR_PAST_EMP_FLAG.value || model.CURRENT_OR_PAST_EMP_FLAG.value === &apos;N&apos;"/>
    <TextInput id="FIRST_NAME" label="{message.XXAS_SIGN_UP_FIRST_NAME}" emptyValue="Enter your first name" required="true"/>
    <TextInput id="LAST_NAME" label="{message.XXAS_SIGN_UP_LAST_NAME}" emptyValue="Enter your last name" required="true"/>
    <Email id="EMAIL_ADDRESS" label="{message.XXAS_SIGNIN_EMAIL}" emptyValue="{message.XXAS_FORGOT_UNAME_PROMPT}" required="true"/>
    <Password id="PASSWORD" label="{message.XXAS_SIGNIN_PASSWORD}" emptyValue="{message.XXAS_SIGNIN_PASSWORD_PROMPT}" required="true" description="{message.XXAS_SIGNIN_PW_DESC}"/>
    <Submit label="{message.XXAS_SIGNUP}" color="balanced"/>
  </CreateFields>

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