$sql="SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,";
$sql.=" f.facnumber, f.datef, f.paye, f.fk_statut as statut, f.rowid as facid,";
$sql.=" f.facnumber, f.datef, f.paye, f.type, f.fk_statut as statut, f.rowid as facid,";
$sql.=" d.rowid, d.total_ht as total_ht, d.qty";// We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used