<?php

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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "selectid")
    $ve_id = $paramValue;
}

$dal = new DAL();

$sql = "SELECT WO.id, WO.name AS text, " .
       "(CASE WHEN VW.vehicle_id IS NULL THEN 0 " .
         "ELSE VW.id END) AS setid, " .
       "(CASE WHEN VW.vehicle_id IS NULL THEN 0 " .
         "ELSE VW.vehicle_id END) AS selid " .
       "FROM washoption WO " .
       "LEFT JOIN vehiclewash VW " .
       "ON (VW.vehicle_id = $ve_id AND VW.washoption_id = WO.id) " .
       "ORDER BY WO.id " ;
$result = $dal->query($sql);

echo json_encode($result);

?>

