<?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, projectworkevent PWE " .
       "WHERE PTR.id = $ptr_id AND PWP.id = PTR.projectworkdaypersonnel_id " .
       "AND PWE.id = PWP.projectworkevent_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);

?>

