---
# ====== Page: Global Page ===================================
id: 0
identification: 
  name: Global Page

regions: 
- # ====== Region: Hotel Selector ==============================
  id: 50883646658802747
  identification: 
    name: Hotel Selector
    type: Static Content

  layout: 
    sequence: 10
    parent-region: No Parent
    slot: REGION_POSITION_01
    start-new-layout: false
    start-new-row: true
    column: Automatic
    new-column: true
    column-span: Automatic

  appearance: 
    template: Blank with Attributes
    template-options: 
    - '#DEFAULT#'
    render-components: Above Content

  accessibility: 
    use-landmark: true
    landmark-type: Template Default

  advanced: 
    region-display-selector: false
    exclude-title-from-translation: false

  customization: 
    customizable: Not Customizable By End Users

  attributes: 
    settings: 
      output-as: HTML
      expand-shortcuts: false

page-items: 
- # ====== Page Item: P0_ALERT_MESSAGE =========================
  id: 38067706131765342
  identification: 
    name: P0_ALERT_MESSAGE
    type: Hidden

  settings: 
    value-protected: true

  layout: 
    sequence: 30
    region: No Parent
    slot: BODY

  advanced: 
    warn-on-unsaved-changes: Page Default

  source: 
    type: Null
    used: Always, replacing any existing value in session state

  session-state: 
    data-type: VARCHAR2
    storage: Per Session (Persistent)

  security: 
    session-state-protection: Unrestricted
    store-value-encrypted-in-session-state: true
    restricted-characters: All characters can be saved.

- # ====== Page Item: P0_HOTEL_ID ==============================
  id: 50882989782802741
  identification: 
    name: P0_HOTEL_ID
    type: Select List

  label: 
    label: Hotel Name
    alignment: Left

  settings: 
    page-action-on-selection: None

  multiple-values: 
    type: No

  layout: 
    sequence: 10
    region: Hotel Selector # 50883646658802747
    slot: BODY
    alignment: Left
    start-new-layout: false
    start-new-row: true
    column: Automatic
    new-column: true
    column-span: Automatic
    label-column-span: Page Template Default

  appearance: 
    template: Optional - Floating
    template-options: 
    - '#DEFAULT#'
    - t-Form-fieldContainer--stretchInputs
    - t-Form-fieldContainer--large
    - t-Form-fieldContainer--noPadding
    - t-Form-fieldContainer--normalDisplay
    height: 1

  validation: 
    value-required: false

  list-of-values: 
    type: SQL Query
    sql-query: |
      SELECT DISPLAY_VALUE, RETURN_VALUE
      FROM (
          SELECT NVL(h.HOTEL_NAME, 'Name') AS DISPLAY_VALUE,
                 RAWTOHEX(h.ID) AS RETURN_VALUE,
                 2 AS SORT_ORDER
          FROM UR_HOTELS h
          WHERE NVL(h.ASSOCIATION_END_DATE, SYSDATE) >= SYSDATE
            AND (
                  UR_UTILS.is_privileged_user(:APP_USER) = 'Y'
               OR UR_UTILS.is_internal_user(:APP_USER)   = 'Y'
               OR EXISTS (
                      SELECT 1
                      FROM UR_USER_HOTELS_ACCESS u
                      JOIN ur_users uu ON u.USER_ID = uu.USER_ID
                      WHERE u.HOTEL_ID = h.ID
                        AND upper(uu.USER_NAME) = upper(:APP_USER)
                        AND u.ACTIVE = 'Y'
                        AND SYSDATE BETWEEN NVL(u.START_DATE, SYSDATE) AND NVL(u.END_DATE, SYSDATE)
                  )
                )
      
          UNION ALL
      
          SELECT '-- Show all data --' AS DISPLAY_VALUE,
                 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' AS RETURN_VALUE,
                 1 AS SORT_ORDER
          FROM DUAL
          WHERE UR_UTILS.is_privileged_user(:APP_USER) = 'Y'
             OR UR_UTILS.is_internal_user(:APP_USER)   = 'Y'
             OR EXISTS (
                  SELECT 1
                  FROM UR_USER_HOTELS_ACCESS u
                  JOIN ur_users uu ON u.USER_ID = uu.USER_ID
                  JOIN UR_HOTELS h ON u.HOTEL_ID = h.ID
                  WHERE upper(uu.USER_NAME) = upper(:APP_USER)
                    AND u.ACTIVE = 'Y'
                    AND NVL(h.ASSOCIATION_END_DATE, SYSDATE) >= SYSDATE
                    AND SYSDATE BETWEEN NVL(u.START_DATE, SYSDATE) AND NVL(u.END_DATE, SYSDATE)
               )
      )
      ORDER BY SORT_ORDER, DISPLAY_VALUE
      
    display-extra-values: false
    display-null-value: false

  advanced: 
    warn-on-unsaved-changes: Page Default

  source: 
    type: Null
    used: Only when current value in session state is null

  default: 
    type: Static
    static-value: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

  session-state: 
    storage: Per Session (Persistent)

  quick-picks: 
    show-quick-picks: false

  server-side-condition: 
    type: Expression
    language: PL/SQL
    pl/sql-expression: |
      INSTR(':1026:17:1023:9:19:1075:1001:29:1010:28:1601:33:1006:24:15:1002:1011:167:27:', ':'||:APP_PAGE_ID||':') > 0
      -- removinge strategy page 1050 from the global hotel

  security: 
    session-state-protection: Unrestricted
    store-value-encrypted-in-session-state: true
    restricted-characters: All characters can be saved.

- # ====== Page Item: P0_USERNAME ==============================
  id: 53906779199499342
  identification: 
    name: P0_USERNAME
    type: Hidden

  settings: 
    value-protected: false

  layout: 
    sequence: 40
    region: No Parent
    slot: BODY

  advanced: 
    warn-on-unsaved-changes: Page Default

  source: 
    type: Null
    used: Always, replacing any existing value in session state

  default: 
    type: Static
    static-value: '&APP_USER.'

  session-state: 
    data-type: VARCHAR2
    storage: Per Session (Persistent)

  security: 
    session-state-protection: Unrestricted
    store-value-encrypted-in-session-state: true
    restricted-characters: All characters can be saved.

dynamic-actions: 
- # ====== Dynamic Action: Page load ===========================
  id: 35089826126576855
  identification: 
    name: Page load

  execution: 
    sequence: 20
    event-scope: Static

  when: 
    event: Page Load

  actions: 
  - # ====== Action: Initialize Bug Reporter =====================
    id: 71280932196660
    identification: 
      name: Initialize Bug Reporter
      action: Execute JavaScript Code

    settings: 
      code: |
        BugReporter.init({
          apexProcessName: 'AJX_BUG_REPORTER_LOG'
        });
        
        const headerBg = getComputedStyle(document.documentElement).getPropertyValue('--ut-header-background-color').trim();
        const applyColor = () => document.querySelectorAll('.bug-reporter-btn').forEach(b => b.style.setProperty('background-color', headerBg, 'important'));
        applyColor();
        
        const btn = [...document.querySelectorAll('.bug-reporter-btn')].find(b => !b.closest('.ui-dialog, [role="dialog"], .t-Dialog-page, .bug-reporter-modal'));
        
        if (btn) {
          const checkDialog = () => {
            const selectors = ['.t-Dialog-page', '.ui-dialog', '.ui-dialog-content', '.ui-widget-overlay', '.t-DialogRegion', '.apex-modal', '.apex-page-dialog'];
            let hasDialog = false;
            
            for (const selector of selectors) {
              for (const el of document.querySelectorAll(selector)) {
                if (el.closest('.bug-reporter') || el.classList.contains('bug-reporter-overlay') || el.classList.contains('bug-reporter-modal')) continue;
                
                if (selector === '.ui-dialog-content' || selector === '.ui-dialog') {
                  const dlg = el.closest('.ui-dialog');
                  if (dlg) {
                    const aria = dlg.getAttribute('aria-describedby') || '';
                    const content = dlg.querySelector('.ui-dialog-content');
                    const cId = content ? content.id : '';
                    const cls = dlg.className || '';
                    
                    if (aria.includes('PopupLov') || cId.includes('PopupLov') || cls.includes('popup')) continue;
                  }
                }
                
                const style = getComputedStyle(el);
                if (style.display !== 'none' && style.visibility !== 'hidden') {
                  hasDialog = true;
                  break;
                }
              }
              if (hasDialog) break;
            }
            
            if (document.body.classList.contains('apex-dialog-open') || document.body.classList.contains('modal-open')) hasDialog = true;
            
            btn.style.setProperty('display', hasDialog ? 'none' : 'flex', 'important');
          };
        
          checkDialog();
          new MutationObserver(() => { checkDialog(); applyColor(); }).observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['class', 'style'] });
          $(document).on('apexafterclosedialog apexafterclosecanceldialog apexbeforedialog dialogopen dialogclose', () => setTimeout(() => { checkDialog(); applyColor(); }, 50));
        }
        

    execution: 
      sequence: 10
      event: Page load # 35089826126576855
      fire-when-event-result-is: True
      fire-on-initialization: false

    server-side-condition: 
      type: Expression
      language: PL/SQL
      pl/sql-expression: ":APP_USER != 'nobody'"

- # ====== Dynamic Action: Changed =============================
  id: 38067791380765343
  identification: 
    name: Changed

  execution: 
    sequence: 10
    event-scope: Static
    type: Immediate

  when: 
    event: Change
    selection-type: Item(s)
    item(s): 
    - P0_ALERT_MESSAGE

  actions: 
  - # ====== Action: Execute JavaScript Code =====================
    id: 38067961197765344
    identification: 
      action: Execute JavaScript Code

    settings: 
      code: |
        var messagesJson = $v("P0_ALERT_MESSAGE");  // get the string from hidden page item
        
        if (messagesJson) {
          try {
            // Try parsing the string
            var parsed = JSON.parse(messagesJson);
        
            // Check if parsed result is array or object
            if (Array.isArray(parsed)) {
              // It's an array - pass as is
              showAlertToastr(parsed);
            } else if (parsed && typeof parsed === 'object') {
              // Single object - pass it wrapped in array for consistency 
              showAlertToastr([parsed]);
            } else {
              // Parsed to something else (string/number) — just pass original string
              showAlertToastr(messagesJson);
            }
          } catch (e) {
            // Parsing failed — probably plain text, pass as is
            showAlertToastr(messagesJson);
          }
        }

    execution: 
      sequence: 10
      event: Changed # 38067791380765343
      fire-when-event-result-is: True
      fire-on-initialization: false

- # ====== Dynamic Action: Connect Hotel ID  ===================
  id: 50883126612802742
  identification: 
    name: 'Connect Hotel ID '

  execution: 
    sequence: 30
    event-scope: Static
    type: Immediate

  when: 
    event: Change
    selection-type: Item(s)
    item(s): 
    - P0_HOTEL_ID

  actions: 
  - # ====== Action: Execute Server-side Code ====================
    id: 50883247172802743
    identification: 
      action: Execute Server-side Code

    settings: 
      language: PE.PROPERTY.SOURCE_SNIPPET_LANG.LOV.PLSQL.D
      pl/sql-code: |
        :G_HOTEL_ID := :P0_HOTEL_ID;
        
      items-to-submit: 
      - P0_HOTEL_ID

    execution: 
      sequence: 10
      event: 'Connect Hotel ID ' # 50883126612802742
      fire-when-event-result-is: True
      fire-on-initialization: false
      stop-execution-on-error: true
      wait-for-result: true

