<?php
$sql_query = 'UPDATE ' . $config['table_prefix'] . 'calc_template SET ';
$sql_query .= <<<'EOT'
`calculate_tpl` = '{if $open_form == 1}\r\nforeach ($_SESSION[\'back_urls\'] as $back_url => $url) {\r\n    if (strpos($url, \"view_line2.php?table=$table_id\") && strpos($url, \"&line=$ID\")) break;\r\n}\r\nheader(\"Location: view_line2.php?table={$sub_table.subTable}&line=new&{$sub_table.link_field_id}=$ID&back_url=$back_url&save_close\");\r\nexit;\r\n{else}\r\necho \"<script>window.open(\'view_line2.php?table={$sub_table.subTable}&line=new&{$sub_table.link_field_id}=$ID\')</script>\";\r\n{/if}'
WHERE `id` = 126;
EOT;
run_query($sql_query);