<?php

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

if (isset($_REQUEST["id"])) {
  $tr_id = $_REQUEST["id"];
}  
  
$dal = new DAL();

$sql = "SELECT TR.id AS tr_idto, type AS to_type, startime AS to_startime, " .
       "LPAD(PT.duration, 5, '0') AS to_duration, mileage AS to_mileage " .
       "FROM travel TR, personneltravel PT " .
       "WHERE TR.id = $tr_id AND TR.id = PT.travel_id " .
       "AND PT.travelrole_id = 1 LIMIT 1 ";
$result = $dal->query($sql);

if (NULL == $result)
  $result = (object)array("tr_idto"=>"$tr_id", "to_type"=>"Day", 
        "to_startime"=>"07:30", "to_duration"=>"00.50", "to_mileage"=>"0.00");

echo json_encode($result);

?>

