<?php

require_once('../../autoload.php');
header('Content-Type: application/json');

$listexport = array();

$conn = get_dbconnection();

if($conn)
{
  $afcnid=$_GET['afcnid'];
  $sql = "select b.desc_id,b.description_{$_SESSION['lang']} from annexe_afcn as a, description_afcn as b, export_afcn as l where a.id = '{$afcnid}' and l.ann_id = a.ann_id and l.desc_id = b.desc_id";
  if($query=pg_query($conn,$sql))
  {
    $counter = 0;
    while($row = pg_fetch_row($query))
    {
      $exportype = new stdClass();
      $exportype->type = "option";
      $exportype->value = $row[0];
      $exportype->label = $row[1];
      $listexport[] =$exportype;
    }
  }
}
else{
  echo "Could not connect";
}


$myJSON = json_encode($listexport);

echo $myJSON;
?>
