<?php

$result = sql_select_field($config["table_prefix"] . "cron", '(MAX(id)+1) as max');
$row = sql_fetch_assoc($result)['max'];
$date = date("Y-m-d H:i:s");
$sql_query = 'INSERT INTO ' . $config['table_prefix'] . 'cron ';
$sql_query .= <<<EOT
(`id`, `description`, `period`, `last_start_time`, `last_stop_time`, `disabled`, `one_time`, `command`, `thread_name`, `log`, `max_exec_time`, `check_enabled`, `check_cond`, `check_text`, `check_last_status`, `last_notify`, `error_count`, `calc_id`)
VALUES ("$row", "Напоминания 3", "* * * * *", "$date", "$date", "0", "0", "form_tips_line_after_update_value(); echo 'Done';", "main", "", "0", "0", "", "", "0", "0000-00-00 00:00:00", "0", "0");
EOT;
run_query($sql_query);

$res = sql_fetch_assoc(sql_query('SELECT TABLE_NAME FROM information_schema.tables WHERE TABLE_SCHEMA="' .
    $config['dbname'] . '" AND TABLE_NAME="' . $config['table_prefix'] . 'tips_postpone"'));
if (!$res) {
    run_query("CREATE TABLE " . $config["table_prefix"] . "tips_postpone (`id` INT(11) AUTO_INCREMENT, `table_id` INT(11), `line_id` INT(11), `field_int_name` VARCHAR(11), PRIMARY KEY (`id`))");
}
