<?php

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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "id")
    $id = $paramValue;
  elseif ($paramName == "value") 
    $value = $paramValue;  
  elseif ($paramName == "type") 
    $type = $paramValue;  
}

$dal = new DAL();

if ($type == "noteproject") {
  $sql = "UPDATE projectteamrole SET note='$value' " .
         "WHERE id = $id " ;
  $result = $dal->query($sql);
}

else if ($type == "notetravel") {
  $sql = "UPDATE personneltravel SET note='$value' " .
         "WHERE id = $id " ;
  $result = $dal->query($sql);
}

else if ($type == "ratproject") {
  $sql = "UPDATE projectteamrole SET rationale='$value' " .
         "WHERE id = $id " ;
  $result = $dal->query($sql);
}

else if ($type == "rattravel") {
  $sql = "UPDATE personneltravel SET rationale='$value' " .
         "WHERE id = $id " ;
  $result = $dal->query($sql);
}

else if ($type == "billproject") {
  $billable = ($value ==  "true") ? 1 : 0;
  $sql = "UPDATE projectteamrole SET billable=$billable " .
         "WHERE id = $id " ;
  $result = $dal->query($sql);
}

else if ($type == "billtravel") {
  $billable = ($value ==  "true") ? 1 : 0;
  $sql = "UPDATE personneltravel SET billable=$billable " .
         "WHERE id = $id " ;
  $result = $dal->query($sql);
}

else if ($type == "durproject") {
  $sql = "UPDATE projectteamrole SET moduration=$value " .
         "WHERE id = $id " ;
  $result = $dal->query($sql);
}

else if ($type == "durtravel") {
  $sql = "UPDATE personneltravel SET moduration=$value " .
         "WHERE id = $id " ;
  $result = $dal->query($sql);
}

echo json_encode($result);

?>

