<?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_produits where id = ".$id;
$result = @$db->query($query);
if($result !== false){
	$row = $result->fetch();
	
	$prix_ht = $row["prix_ht"];
	$fodec = $row["fodec"];
	$tva = $row["tva"];
	$famille = $row["famille"];
	$code_barre = $row["code_barre"];
	$desingnation = $row["desingnation"];
	$code_produit = $row["code_produit"];
	$remise = $row["remise"];
	$coulissage = $row["coulissage"];
	$remarque = $row["remarque"];
	$fournisseur = $row["fournisseur"];
	$unite = $row["unite"];

//====== get unite =======
$query_unite = "SELECT * from pm_unite where id = ".$unite;
$result_unite = @$db->query($query_unite);
if($result_unite !== false){
	$row_unite = $result_unite->fetch();
	$unite = $row_unite["name"];
}
	
	
	if(isset($coulissage)){
        $data = array(
            "prix_ht"     => $prix_ht,
            "fodec"  => $fodec,
            "tva"   => $tva,
            "famille"   => $famille,
            "code_barre"   => $code_barre,
            "desingnation"   => $desingnation,
            "code_produit"   => $code_produit,
            "remise"   => $remise,
            "coulissage"   => $coulissage,
            "remarque"   => $remarque,
            "fournisseur"   => $fournisseur,
            "unite"      => $unite
        );
        echo json_encode($data);
    }
}	




?>