<?php
ini_set('display_errors', 0);

require_once("../../common/lib.php");
require_once("../../common/define.php");

if(!isset($_SESSION['user'])){
    header("Location: login.php");
    exit();
}

$id = $_GET["id"];

$query = "SELECT * from pm_be where fournisseur <> ".$id;
$result = @$db->query($query);
$cont = 0 ;
$outp = array();
if($result !== false){
	// $outp = $result->fetch();
	foreach($result as $row){
		
		$outp[$cont]["id"] = $row["id"];
		
		$cont++;	
	} 

}

//======== Facture  d'achat

$query_payer = "SELECT ref_be from pm_facture_achat where fournisseur = ".$id;	
// echo $query_payer;
$result_payer = @$db->query($query_payer);
if($result_payer !== false){
	foreach($result_payer as $row_payer){
		if($row_payer["ref_be"]){
			$be = explode(",", $row_payer["ref_be"]);
			foreach ($be as &$value) {
				// echo ">>>".$value;
				$outp[$cont]["id"]  = $value;
				$cont++;
			}
		}
	} 
}	

	
	echo json_encode($outp);




?>