<?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"];
$id_client = $_GET["id_client"];

//===================== client  =============
$query_bl3 = "SELECT cat_client FROM pm_client where id = ".$id_client;
$result_bl3 = @$db->query($query_bl3);


if($result_b3l !== false){
	$row_bl3 = $result_bl3->fetch();																		
	$cat_client = $row_bl3["cat_client"];
}

if($cat_client == 1){
	$id_depot = 1;
}else{
	$id_depot = 3;
}

//===================== New STOCK =============
$query_bl = "SELECT qte FROM pm_depot_stock_pf where id_produits  = ".$id." AND id_depot = ".$id_depot;

$result_bl = @$db->query($query_bl);


if($result_bl !== false){
	$row_bl = $result_bl->fetch();																		
	$qte_bl = $row_bl["qte"];
}
//=============================================

	if(isset($qte_bl)){
        $data = array(
            "id"     => $id,
            "qte_en_stock"     => $qte_bl,
            "qte_en_stock_new"     => $qte_bl,
            // "dev1"     => $query_fabri_1,
            // "dev2"     => $query_fabri,
        );
        echo json_encode($data);
    }



?>