<?php

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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "id") 
    $pwo_id = $paramValue;  
  else if ($paramName == "name_id") 
    $op_id = $paramValue;  
  else if ($paramName == "name_id_text") 
    $name = $paramValue;  
  else if ($paramName == "operationtype_id") 
    $operationtype_id = $paramValue;  
  else if ($paramName == "starttime") 
    $starttime = $paramValue;  
  else if ($paramName == "breakduration") 
    $breakduration = $paramValue;  
  else if ($paramName == "stoptime") 
    $stoptime = $paramValue;  
  else if ($paramName == "duration") 
    $duration = $paramValue;  
  else if ($paramName == "note") 
    $note = $paramValue;  
}

$duration = str_replace(":", ".", $op_duration);

$dal = new DAL();

$sql = "UPDATE operation ". 
       "SET operationtype_id='$operationtype_id' " .
       "WHERE id = $op_id ";
$result = $dal->query($sql);

$sql = "UPDATE projectworkdayoperation ". 
       "SET starttime='$starttime', breakduration='$breakduration', " .
       "duration='$duration', stoptime='$stoptime', note='$note' " .
       "WHERE id = $pwo_id " ;
$result = $dal->query($sql);
    
echo json_encode($pwo_id);

?>

