/* $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/candidateprofile.xml');

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/candidateprofile.xml',
'<View title="Candidate profile" showSubmit="false" submitLabel="Save Profile" autosave="true" autosaveTimeout="3000" autosaveMessage="{message.XXAS_COM_CHNG_SAVE}" defaultFormHandler="xxas_applicant_pkg.update_profile">

  <CreateFields>
  
    <Container id="BASIC" label="Basic Details" layout="FORM">
      <Hidden id="PERSON_ID"/>
      <Poplist id="TITLE" label="{message.XXAS_RB_EMP_EXP_JT}" required="false" listProvider="LOOKUP_TYPE:TITLE"/>
      <TextInput id="FIRST_NAME" label="First Name" required="true"/>
      <TextInput id="LAST_NAME" label="Last Name" required="true"/>
      <TextInput id="EMAIL_ADDRESS" label="Email" enabled="false"/>          
    </Container>
  
    <Container id="ADDRESS" label="Address" layout="FORM">
      <Flexfield applicationId="800" descriptiveFlexfieldName="Address Structure"/>
    </Container>
    
    <Container id="PHONE_NUMBERS_GRP" label="Phone Numbers" layout="TABULAR">
      <MultiRow id="PHONE_NUMBERS" createAllowed="false" xdbUri="/public/xxas/emp/view/applicantphonenumbers.xml"/>
    </Container>	

    <Container id="DOCUMENTS_GRP" label="Resume &amp; Supporting Documents" layout="TABULAR">
      <File id="CV_DOCUMENT_ID" label="Resume" buttonText="Upload your Resume" fileInfoProvider="xxas_applicant_pkg.get_document_info"/>
      <!--Poplist id="XXX_NO_RESUME" label="I don''t have a Resume" showAsBoolean="true" positiveBooleanValue="Y" listProvider="LOOKUP_TYPE:YES_NO" description="Tick this to type in previous employers, education, qualifications and schools manually" hideIf="model.DOCUMENTS_GRP.CV_DOCUMENT_ID.value !== false &amp;&amp; !!model.DOCUMENTS_GRP.CV_DOCUMENT_ID.value"/-->
      <File id="COV_LET_DOCUMENT_ID" label="Covering Letter" buttonText="Upload a Covering Letter" fileInfoProvider="xxas_applicant_pkg.get_document_info"/>
      <!--MultiRow id="DOCUMENTS" createAllowed="true" xdbUri="/public/xxas/emp/view/applicantdocs.xml"/-->
    </Container>	
    
   <Container id="PREVIOUS_EMPLOYERS_GRP" label="Previous Employers" layout="TABULAR">
      <MultiRow id="PREVIOUS_EMPLOYERS" createAllowed="true" includeEmptyRow="true"  xdbUri="/public/xxas/emp/view/candidatepreviousemployers.xml"/>
    </Container>
    
    <Container id="FURTHER_EDUCATION_GRP" label="Further Education and Qualifications" layout="TABULAR">
      <MultiRow id="FURTHER_EDUCATION" createAllowed="true" includeEmptyRow="true"  xdbUri="/public/xxas/emp/view/candidatefurthered.xml"/>
    </Container>

    <Container id="SCHOOL_GRP" label="School" layout="TABULAR">
      <MultiRow id="SCHOOL" createAllowed="true" includeEmptyRow="true" xdbUri="/public/xxas/emp/view/candidateschool.xml"/>
    </Container>

    <Container id="ACCOUNT_INFORMATION" label="Account Information" layout="FORM">         
      <TextInput id="USERNAME" label="Email Address" enabled="false"/>
      <Link label="Change your password" value="#/change-password"/>
    </Container>
    
    <Container id="ADDITIONAL_DETAILS" label="Additional Details" layout="FORM">
      <Poplist id="SEX" label="Gender" listProvider="LOOKUP_TYPE:SEX"/>
      <Flexfield applicationId="800" descriptiveFlexfieldName="Person Developer DF" descriptiveFlexContextCode="GB"/>
      <Flexfield applicationId="800" descriptiveFlexfieldName="PER_PEOPLE"/>
    </Container>

    <Container id="ACCOUNT_PRIVACY" label="Account Privacy" layout="FORM">  
      <Poplist id="ALLOW_ACCESS" label="Find Me" description="Allow our recruiters to match your profile to vacancies" visible="false" showAsBoolean="true" positiveBooleanValue="Y" listProvider="LOOKUP_TYPE:YES_NO"/>
      <Poplist id="RECEIVE_INFO_MAIL" label="Important Updates" description="General email and important updates" visible="false" showAsBoolean="true" positiveBooleanValue="Y" listProvider="LOOKUP_TYPE:YES_NO"/>      
      <Poplist id="MATCHING_JOBS" label="Job Alerts" description="Receive emails of jobs that match my saved searches"  showAsBoolean="true" positiveBooleanValue="Y" value="Y" listProvider="LOOKUP_TYPE:YES_NO"/>
      <Poplist id="MATCHING_JOB_FREQ" label="Frequency of Alerts" visible="false" value="1" listProvider="LOOKUP_TYPE:IRC_MESSAGE_FREQ" hideIf="model.ACCOUNT_PRIVACY.MATCHING_JOBS.value != &apos;Y&apos;"/>
    </Container>
    
  </CreateFields>

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