<?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_idfrom, type AS from_type, start_time AS from_start_time, " .
       "LPAD(PT.duration, 5, '0') AS from_duration, mileage AS from_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 (count($result) == 0)
  $result = (object)array("tr_idfrom"=>"$tr_id", "from_type"=>"Day",
    "from_start_time"=>"07:30", "from_duration"=>"00.50", "from_mileage"=>"0.00");

echo json_encode($result);

?>

