<?php

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

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

$sql = "SELECT FR.id AS rowid, description AS text, " .
       "(CASE WHEN PF.project_id IS NULL THEN 0 " .
         "ELSE PF.id END) AS setid, " .
       "(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.project_id = $pr_id AND PF.framework_id = FR.id) " .
       "WHERE FR.active = 1 ORDER BY FR.id ";
$result = $dal->query($sql);

echo json_encode($result);
?>

