<?php

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

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

$dal = new DAL();

$sql = "SELECT PWP.id " .
       "FROM projectteamrole PTR, projectworkdaypersonnel PWP, projectworkday PW " .
       "WHERE PTR.id = $ptr_id AND PWP.id = PTR.projectworkdaypersonnel_id " .
       "AND PW.id = PWP.projectworkday_id LIMIT 1";
$pwp_id = $dal->query($sql)->id;
 
$ptr_id = hexdec(uniqid());
  
$sql = "INSERT INTO projectteamrole " . 
       "(id, projectworkdaypersonnel_id, teamrole_id) " .
       "VALUES ($ptr_id, $pwp_id, 2) ";
$return = $dal->query($sql);
    
echo json_encode($result);

?>

