<?php

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

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

$textDate = date('D M j, Y', strtotime($date));

$dal = new DAL;

// Insert workday if it does not exist
if ($wo_id == 0) {
  $wo_id = hexdec(uniqid());
 
  $sql = "INSERT INTO workday (id, date, textdate) VALUES ($wo_id, '$date', '$textDate')";
  $result = $dal->query($sql);
}

echo json_encode ($wo_id);

?>
