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

try 
{
    session_start();
    echo $_POST["FirstName"];
    echo $_POST["LastName"];
    echo $_POST["PWD"];

    $sap = Login();
    $employees = $sap->getService("EmployeesInfo");
    $result = $employees->queryBuilder()
    ->select('EmployeeID,FirstName,LastName')
    ->where(new Equal("FirstName", $_POST["FirstName"]))
    ->where(new Equal("LastName", $_POST["LastName"]))
    ->where(new Equal("U_pwd", $_POST["PWD"]))
    ->findAll();
    
    $Employee = array_values(((array) $result)["value"]);

    $count =  count($Employee);

    if($count == 1) {
        $_SESSION["FirstName"] = $_POST["FirstName"];        
        $_SESSION["LastName"] = $_POST["LastName"];
        $_SESSION["PWD"]=$_POST["PWD"];
        $_SESSION["EmployeeID"] = array_values((array) array_values((array) $Employee)[0])[0];
        header("Location: ../EntreeStock.php");
    }
    else {

        $_SESSION["errorMessage"] = "Login invalide";        
        header("Location: ../Login.php");
    }
        
} catch (Exception $e) {
    echo $e->getMessage();    
    $_SESSION['messageError']=$e->getMessage();
    header("Location: ../Login.php");
}
?>


--B1_BpsItemsSortieB1SLQuery