<?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 == "crew") {
  $sql = "UPDATE projectteamrole SET note='$value' " .
         "WHERE id = $id " ;
 $result = $dal->query($sql);
}

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

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

else if ($type == "billfrom") {
  $billable = ($value ==  "true") ? 1 : 0;
  $sql = "UPDATE personneltravel SET billable=$billable " .
         "WHERE id = $id " ;
  $result = $dal->query($sql);
}
else if ($type == "billto") {
  $billable = ($value ==  "true") ? 1 : 0;
  $sql = "UPDATE personneltravel SET billable=$billable " .
         "WHERE id = $id " ;
  $result = $dal->query($sql);
}
else if ($type == "durrole") {
  $sql = "UPDATE projectteamrole SET duration=$value " .
         "WHERE id = $id " ;
  $result = $dal->query($sql);
}
else if ($type == "durfrom") {
  $sql = "UPDATE personneltravel SET duration=$value " .
         "WHERE id = $id " ;
  $result = $dal->query($sql);
}
else if ($type == "durto") {
  $sql = "UPDATE personneltravel SET duration=$value " .
         "WHERE id = $id " ;
  $result = $dal->query($sql);
 }

echo json_encode($result);

?>

