<?php

require_once($_SERVER['DOCUMENT_ROOT'] . '/sys/db.php');

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "selid")
    $pr_id = $paramValue;
}
  
$dal = new DAL();

$sql = "SELECT FR.id, description AS text, " .
       "(CASE WHEN PF.project_id IS NULL THEN 0 " .
         "ELSE PF.project_id END) AS selid " .
       "FROM framework FR " .
       "LEFT JOIN projectframework PF " .
       "ON (PF.framework_id = FR.id AND PF.project_id = $pr_id) " .
       "WHERE FR.active = 1 ORDER BY FR.id ";
$result = $dal->query($sql);

echo json_encode($result);
?>

