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

try 
{

    $sap = Login();
    $DocEntry = "";
    if (!empty($_GET['DocEntry'])) { $DocEntry = $_GET['DocEntry'] ; }
 
    if( $DocEntry == "") {

        //HISTORIQUE
        $HistoriqueLines_result = $sap->getService("view.svc/B1_GetDetailPatientHistoryB1SLQuery")->queryBuilder()
        ->select('Type, U_ItemCode, U_Description, U_Qte, U_Instructions')
        ->where(new Equal("DocEntry", intval($DocEntry) ))->findAll();        

    } else {

        //HISTORIQUE
        $HistoriqueLines_result = $sap->getService("view.svc/B1_GetDetailPatientHistoryB1SLQuery")->queryBuilder()
        ->select('Type, U_ItemCode, U_Description, U_Qte, U_Instructions')
        ->where(new Equal("DocEntry", intval($DocEntry) ))->findAll();        
    }

    $Historique = json_decode(json_encode($HistoriqueLines_result), TRUE);
    echo json_encode($Historique['value']);

 

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