<?php
    global $dbcon;
    include "../db/headerApi.php";
    include "../db/connection_main.php";

    $json = file_get_contents('php://input');
    $data = json_decode($json);

    $sql = "SELECT portal
              FROM apps.xxyty_sso_reports_access
             WHERE portal IN ('HR_ITINV', 'ADMIN_ITINV', 'SUPERADMIN_ITINV')
               AND NVL(attribute1, 'N') = 'Y'
               AND emp_id = :emp_id";
                
    $sqlarr = oci_parse($dbcon , $sql);
    oci_bind_by_name($sqlarr, ':emp_id', $data->emp_id);
    $r = oci_execute($sqlarr);

    if (!$r) {
            $e = oci_error($sqlarr);
            print json_encode($e['message']);
    }
    $rows = [];
    oci_fetch_all($sqlarr, $rows, null, null, OCI_FETCHSTATEMENT_BY_ROW);

    print json_encode($rows);
?>