<?php
session_start();
$lo_id = $_SESSION['login'];

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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "id")
    $ow_id = $paramValue;
  elseif ($paramName == "teamrole_id")
    $teamrole_id = $paramValue;
  elseif ($paramName == "startime") 
    $startime = $paramValue;  
  elseif ($paramName == "stoptime") 
    $stoptime = $paramValue;  
  elseif ($paramName == "breakdur") 
    $breakdur = $paramValue;  
  elseif ($paramName == "duration") 
    $duration = $paramValue;  
  elseif ($paramName == "billable") 
    $billable = $paramValue;  
  elseif ($paramName == "billrationale") 
    $billrationale = $paramValue;  
  elseif ($paramName == "note") 
    $note = $paramValue;  
}

$textDate = date('D M j, Y', strtotime($date));

$dal = new DAL;

// Get the personnel id for the login id
//$sql = "SELECT personnel_id FROM login WHERE id = $lo_id LIMIT 1";
//$pe_id = $dal->query($sql)->personnel_id;

if ($ow_id > 0) {

  $sql = "UPDATE officeworkrole SET teamrole_id=$teamrole_id, " .
         "duration='$duration', billable=$billable, " .
         "billrationale='$billrationale', note='$note' " .
         "WHERE id = $ow_id "; 
  $result = $dal->query($sql);
}

echo json_encode ($ow_id);

?>
