<?php 
include "functions.php";
use SAPb1\Filters\Equal;
use SAPb1\Filters\InArray;

try 
{
    session_start();
   
    // $Groupe = $_GET["Groupe"];
    //$_SESSION['codeClientGet']=null;
   
    if(isset($_POST['codeClientGet'])){
      $_SESSION['codeClientGet']=$_POST['codeClientGet'];
    }
    $sap = Login();
    $ItemsList = $sap->getService("Projects");
    $ItemsList->headers(['Prefer' => 'odata.maxpagesize=777740']);
    $Items_result = $ItemsList->queryBuilder()
    ->select('Code,Name')
    ->where(new Equal("Active", "tYES" ))
    ->where(new Equal("U_CLIENT",$_SESSION['codeClientGet']))
    ->findAll();
    // echo $_SESSION['codeClientGet'];
    // header('Content-Type: application/json');
    // echo json_encode($Items_result);

    $Items = json_decode(json_encode($Items_result), TRUE);
    echo json_encode($Items['value']);
    // $Items = json_decode(json_encode($Items_result), true);

    //     $response = array();
    //     $response['value'] = $Items;

    //     header('Content-Type: application/json');

} catch (Exception $e) {
    echo $e->getMessage();    
}