<?php
	require("__include-common.php");
define("LOGINCHECK_SESSION_URL", "NO");		// URLをSESSION変数にセットしない。
	require("../account/__logincheck.php");
	if (is_write_permit() != True) {
		exit;
	}
	if ($_POST["todo"].'' == '') {
		exit;
	}
	$con = my_mysql_connect(_DB_SCHEMA);
	$sql = "select c_priority from m_todo";
	$sql .= " where id_account = " . $_SESSION['current_id'];
	$sql .= " and c_delete = 0 ";
	$sql .= " order by c_priority desc";
	$rs = my_mysql_query($sql);
	$row = mysql_num_rows($rs);
	if ($row == 0) {
		$my_priority = 0;
	}
	if (!($rec=mysql_fetch_array($rs))) {
		$my_priority = 0;
	} else {
		$my_priority = $rec['c_priority']+1;
	}
	$sql = "insert into m_todo (id_account, c_todo, c_color, c_priority, c_registtime)";
	$sql .= " values ('" . $_SESSION['current_id'] . "','" . str_for_mysql(form_str_adjust($_POST["todo"])) . "',";
	$sql .= "'" . $_POST["color"] . "',";
	$sql .= "'" . $my_priority . "','" . date("Y/m/d H:i:s") . "')";
	my_mysql_query($sql);
	$con = mysql_close($con);
?>
