<?php
// ini_set('display_errors', 1);

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

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

$id = $_GET["id"];

$query = "SELECT SUM(total_ttc) as total from pm_facture_avoir where ref_bl = ".$id;
// echo $query;
$result = @$db->query($query);
$outp = array();
$cont = 0;
if($result !== false){
	foreach($result as $row){
		$outp["total_ttc"] = $row["total"] ;
		
	} 
}	

	echo json_encode($outp);