<?php
$sql_query = 'UPDATE ' . $config['table_prefix'] . 'calc_template SET ';
$sql_query .= <<<'EOT'
calculate_tpl = 'global $thread{$send_tpl}, $sended;\r\nif (!$thread{$send_tpl}) {\r\n    $thread{$send_tpl} = send_template({$send_tpl}, \'id = \' . $line[\'id\']);\r\n    $sended = 1;\r\n} else {\r\n    form_msg_template($thread{$send_tpl}, \'id = \' . $line[\'id\']);\r\n    $sended++;\r\n}\r\nif (!isset($_REQUEST[\'sel\']) || $sended == count($_REQUEST[\'sel\'])) {\r\n    if (!isset($_REQUEST[\'sel\'])) {\r\n        send_all_msg($thread{$send_tpl});\r\n    }\r\n    $_SESSION[$ses_id][\'send_mode\'] = \'msg\';\r\n    $_SESSION[$ses_id][\'send_complit\'] = 1;\r\n}',
params = '{\r\n    \"title\": \"Отправить шаблон мессенджера\",\r\n    \"help\": \"tpl_send_msg\",\r\n    \"parameters\": {\r\n        \"send_tpl\": {\r\n            \"type\": \"Template\",\r\n            \"name\": \"send_tpl\",\r\n            \"description\": \"Шаблон мессенджера\",\r\n            \"tpl_type\": \"msg\",\r\n            \"help\": \"tpl_send_msg_template\"\r\n        }\r\n    }\r\n}'
WHERE id = 125
EOT;
run_query($sql_query);