<?php

$result = sql_select_array($config["table_prefix"] . 'calc_template', 'id = 115');
if ($result['id']) {
	return;
}

$sql_query = 'INSERT INTO `' . $config["table_prefix"] . 'calc_template`';
$sql_query .= <<<'EOT'
(`id`, `name`, `calculate_tpl`, `params`, `type`, `tpl_name`, `javascript_tpl`, `tpl_category`, `calc_types`, `calc_num`) VALUES
(115, 'Дата: Перевод в текст', "$temp_date = strtotime($line['{$source}']);
$line['{$receiver}'] = data2str($temp_date);", '{
    "title": "Дата: Перевод в текст",
    "help": "date_to_text",
    "parameters": {
        "source": {
            "type": "Field",
            "name": "source",
            "description": "Поле-источник",
            "help": "source_field",
            "type_field": 2
        },
        "receiver": {
            "type": "Field",
            "name": "receiver",
            "description": "Поле-получатель",
            "help": "receiver_field",
            "type_field": 3
        }
    },
    "events": [
        {
            "type": 3,
            "field": "source"
        }
    ]
}', '', 'date_to_text.tpl', '', '1', '[1]', '12');
EOT;
run_query($sql_query);
