<?php

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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "scopeid") 
    $pwo_id = $paramValue;  
  else if ($paramName == "id") 
    $pwo_id = $paramValue;  
  else if ($paramName == "seloperationname") 
    $op_name_id = $paramValue;  
  else if ($paramName == "operationtype_id") 
    $operationtype_id = $paramValue;  
  else if ($paramName == "operationstarttime") 
    $starttime = $paramValue;  
  else if ($paramName == "op_duration") 
    $op_duration = $paramValue;  
  else if ($paramName == "operation_note") 
    $note = $paramValue;  
}

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

if ("null" == $op_name_id)
  $op_name_id = $op_id;

$dal = new DAL();

$sql = "SELECT name FROM operation ". 
       "WHERE id = $op_name_id LIMIT 1";
$op_name = $dal->query($sql)->name;


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

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

?>

