<DOCTYPE html>

<head>
<meta http-equiv = "content-type" charset = utf-8" > 

<meta name = "description" content = "task_add" >

<meta name = "keywords" content = "task_add">

<title>php1</title>

<link rel="stylesheet" type="text/css" href="style.css">
</head>
<?php
$a=0;
include_once('tables_in.php');
$main=new tables_in();
$a=$main->check_values($_POST);
if($a==0)
  $main->add_task($_POST);
?>
<html style="height:100%;">

<body style="background-color: #AAAAAA; min-height:100%;">
<div style="background-color:#FFFFFF; margin-left:10%; margin-right:10%; padding:3%; height:100%;">                                                       
<a href="calender.php"> Вернуться к списку </a>
<form action = "<?php $_PHP_SELF ?>" method="post">
<table style="border: solid-black 1px;">
<th>Новая задача</th>
<tr>
<td><label for="theme"> Тема: </label></td>
<td><input type="text" name ="theme" id="theme" value="<?php if (isset($_POST['theme'])) { echo $_POST['theme']; } ?>"></td>
</tr>
<tr>
<td><label for="type"> Тип:</label></td>
<td><input type="text" name ="type" id="type" value="<?php if (isset($_POST['type'])) { echo $_POST['type']; } ?>"></td>
</tr>
<tr>
<td><label for="place"> Место:</label></td>
<td><input type="text" name ="place" id="place" value="<?php if (isset($_POST['place'])) { echo $_POST['place']; } ?>"></td>
</tr>
<tr>
<td><label for="date_start"> Дата начала:</label></td>
<td><input type="date" name ="date_start" id="date_start" value="<?php if (isset($_POST['date_start'])) { echo $_POST['date_start']; } ?>"></td>
</tr>
<tr>
<td><label for="time_start"> Время начала:</label></td>
<td><input type="time" name ="time_start" id="time_start" value="<?php if (isset($_POST['time_start']))  echo $_POST['time_start']; else echo('00:00');  ?>"></td>
</tr>
<tr>
<td><label for="date_end"> Дата начала:</label></td>
<td><input type="date" name ="date_end" id="date_end" value="<?php if (isset($_POST['date_end'])) { echo $_POST['date_end']; } ?>"></td>
</tr>
<tr>
<td><label for="time_end"> Время начала:</label></td>
<td><input type="time" name ="time_end" id="time_end" value="<?php if (isset($_POST['time_end'])) { echo $_POST['time_end']; } else echo('00:00'); ?>"></td>
</tr>
<tr>
<tr>
<td><label for="comment"> Комментарий:</label></td>
<td><textarea rows="4" name ="comment" id="comment" value="<?php if (isset($_POST['comment'])) { echo $_POST['comment']; } ?>"></textarea></td>
</tr>
</tr>
<tr>
<td text-align:center colspan="2"><input type="submit" value="Send" name="send"></td>
<tr><td>
<?php
if($a==1)
  echo('Ошибка ввода');
if($a==2)
  echo('Заполните все поля');
if($a==3)
  echo('Неверный формат даты');
if($a==4)
  echo('Время занято');
?>
</tr></td>
                                                                               
</tr>
</table>
</form>
</div>
</body>

</html>