<?php

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

$child = ""; 
foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "delid")
    $tr_id = $paramValue;
  else if ($paramName == "listid")
    $pw_id = $paramValue;
}

$dal = new DAL();

$sql = "DELETE FROM personneltravel WHERE travel_id = $tr_id ";
$result = $dal->query($sql);

$sql = "DELETE FROM travel WHERE id = $tr_id ";
$result = $dal->query($sql);

$sql = "SELECT TR.id, CONCAT (VE.name, ' (', VE.seating, ') ', VE.descr) text, 3 added " .
       "FROM (travel TR, vehicle VE, projectworkdaypersonnel PP) " .
       "LEFT JOIN personneltravel PT ON PT.travel_id = TR.id " .
       "WHERE PP.projectworkday_id = $pw_id AND PT.projectworkdaypersonnel_id = PP.id " .
       "AND TR.destination = 'from' AND VE.id = TR.vehicle_id " .
       "GROUP BY TR.id " ;
      
$result = $dal->query($sql);

echo json_encode($result);

?>

