<?php

require_once($_SERVER['DOCUMENT_ROOT'] . '/sys/db.php');
 
foreach ($_POST as $paramName => $paramValue) {
}

$dal = new DAL();

$sql = "SELECT PTR.id as ptr_id, PTR.start_time, PTR.end_time, PTR.break_dur " .    "FROM projectteamrole PTR, projectworkdaypersonnel PWP, " .
       "projectworkday PW " .
       "WHERE PWP.id = PTR.projectworkdaypersonnel_id " .
       "AND PW.id = PWP.projectworkday_id AND PW.fieldwork_day = 0 "; 
$projectteamrole = $dal->query($sql);

foreach ($projectteamrole as $ptr) { 

  $or_id = hexdec(uniqid());

  $sql = "INSERT INTO officerole " .
         "(id, projecteamrole_id, start_time, end_time, break_dur) " .
         "VALUES " .
         "($or_id, $ptr->ptr_id, '$ptr->start_time', '$ptr->end_time', " .
         "'$ptr->break_dur') ";

  $result = $dal->query($sql);
}         

echo json_encode($result);

?>

