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

try 
{
    session_start();

    
    if(isset($_POST['ClientS'])){
        $_SESSION['ClientS']=$_POST['ClientS'];
    }
    if(isset($_POST['ProjectS'])){
        $_SESSION['ProjectS']=$_POST['ProjectS'];
    }

    // $Groupe = $_GET["Groupe"];

    $sap = Login();
    $ItemsList = $sap->getService("view.svc/B1_BpsItemsSortieB1SLQuery");
    $ItemsList->headers(['Prefer' => 'odata.maxpagesize=777740']);
    $Items_result = $ItemsList->queryBuilder()
    
    ->select('itemcode,dscription')
    ->where(new Equal('u_cardcode', $_SESSION['ClientS']))
    ->where(new Equal('u_codeproject',$_SESSION['ProjectS']))
    ->findAll();

    header('Content-Type: application/json');
    // echo $Items_result;
    echo json_encode($Items_result);
} catch (Exception $e) {
    echo $e->getMessage();    
}

?>