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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "sumid")
    $lw_id = $paramValue;
  else if ($paramName == "id")
    $we_id = $paramValue;
  else if ($paramName == "start_time")
    $start_time = $paramValue;
}

$result= [0, "Ok"];

if ($we_id == 0) {
  $dal = new DAL();

  $sql = "SELECT start_time FROM weather " .
       "WHERE loginworkday_id = $lw_id AND start_time = '$start_time' LIMIT 1";
  $log_time = $dal->query($sql)->start_time;

  if (count($log_time) > 0) {
    $result = [1, "Duplicate: $log_time"];
  }
}
  
  echo json_encode($result);

?>

