<?php

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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "selectid") 
    $poc_id = $paramValue;  
  else if ($paramName == "values") 
    $values = $paramValue;  
}

$value =  explode (",", $values);

$dal = new DAL();

for ($i=0; $i<count($value); $i++) {

  list ($fw_id,$pr_id,$pf_id) = explode(":", $value[$i]);

  if ($pr_id == 0) {
    $sql = "DELETE FROM projectframework " .
           "WHERE id = $pf_id ";
    $result = $dal->query($sql)->id;
  }

  else {
    $sql = "INSERT INTO projectframework (project_id, framework_id) " .
             "VALUES ($pr_id, $fw_id) " ;
    $result = $dal->query($sql);
  }
}
    
echo json_encode($poc_id);

?>

