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

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

$dal = new DAL();

$sql = "SELECT id, date AS date " .
       "FROM workday WHERE date = '$date' LIMIT 1 ";
$result = $dal->query($sql);

if (count($result) == 0) {
  $sql = "SELECT 0 AS id, '$date' AS date LIMIT 1 " ;
  $result = $dal->query($sql);
}

echo json_encode($result);

?>

