<?
function panel_view_sv($rec_sv)
{
;
  ?><div id="panel_view_pp">
      <?
      if (isset($rec_sv) && isset($rec_sv['sign_id'])) {
        $script_name1 =  signature()->save_DTW_data_to_js($rec_sv['standart_sign'], $rec_sv['sign_id'] . '_first', 'sample1') ;
        $script_name2 =  signature()->save_DTW_data_to_js($rec_sv['second_sign'], $rec_sv['sign_key'] . '_second', 'sample2') ;
        
        $st_time_sign = number_format($rec_sv['standart_sign_time_sign'] / 1000, 3);// signature()->get_signature_time_by_str_sign($rec_sv['standart_sign']);
        $time_sign = number_format($rec_sv['second_sign_time_sign'] / 1000, 3);//signature()->get_signature_time_by_str_sign($rec_sv['second_sign']);
        
        $diff_time_percent = false;
        
        if ($st_time_sign > 0) {
            $diff_time_percent = (1 - $time_sign / $st_time_sign) * 100;
        }
        
        ?>
            <script type="text/javascript" src="/tmp/<?echo $script_name1?>"></script>
            <script type="text/javascript" src="/tmp/<?echo $script_name2?>"></script>
            <script type="text/javascript" src="/<?echo _CLASS_?>/ext/aspmo_signature/signature_renderer.js" ></script>
            <table>
            <tr>
                <td>Подписи:
                    <br />
                    <button onclick="$j('#canvas1').signatureRender(sample1);$j('#canvas2').signatureRender(sample2);">Обновить</button>
                </td>
                <td class="left">
                    <div class="sign-title">Эталонная подпись</div>
                    <canvas id="canvas1" style="border: medium; border-color: #DBDBDB; border-style: solid;" width="600" height="400"> &nbsp; </canvas>
                    <script type="text/javascript">
                        $j(document).ready(function(){$j('#canvas1').signatureRender(sample1);});
                        $j('#canvas1').signatureTooltip( <? echo json_encode(unserialize($rec_sv['standart_sign']), JSON_FORCE_OBJECT ); ?>);
                    </script>
                </td>
                <td class="left">
                    <div class="sign-title">Текущая подпись</div>
                    <canvas id="canvas2" style="border: medium; border-color: #DBDBDB; border-style: solid;" width="600" height="400"> &nbsp; </canvas>
                    <script type="text/javascript">
                        $j(document).ready(function(){$j('#canvas2').signatureRender(sample2);});
                        $j('#canvas2').signatureTooltip( <? echo json_encode(unserialize($rec_sv['second_sign']), JSON_FORCE_OBJECT ); ?>);
                    </script>
                </td>
            </tr>
            </table>
            <div id="panel_personal_norma">
                <h2>Результаты сравнения</h2>
                <table>
                    <tbody>
                        <tr>
                            <th></th>
                            <th><strong>Отклонение по форме</strong></th>
                            <th colspan="2"><strong>Отклонение по времени</strong></th>
                        </tr>
                        <tr>
                            <td>Критерии</td>
                            <td<?if ($rec_sv['DTW_sign_result'] > $GLOBALS['LS_sv_DTW_result']) {?> style="background-color: red"<?}?>>MAX <? echo $GLOBALS['LS_sv_DTW_result']; ?></td>
                            <td<?if ($st_time_sign > 0 && $diff_time_percent > $GLOBALS['LS_sv_TimePercentUpper']) {?> style="background-color: red"<?}?>>Не быстрее <? echo $GLOBALS['LS_sv_TimePercentUpper']; ?>%</td>
                            <td<?if ($st_time_sign > 0 && $diff_time_percent < -$GLOBALS['LS_sv_TimePercentLower']) {?> style="background-color: red"<?}?>>Не медленне <? echo $GLOBALS['LS_sv_TimePercentLower']; ?>%</td>
                        </tr>
                        <tr>
                            <td>Эталонная подпись</td>
                            <td><? echo number_format(0, 2); ?></td>
                            <td colspan="2"><? echo $st_time_sign; ?> сек.</td>
                        </tr>
                        <tr>
                            <td>Текущая подпись</td>
                            <td<?if ($rec_sv['second_DTW_mp_Cost'] > $GLOBALS['LS_sv_DTW_result']) {?> style="background-color: red"<?}?>><? echo number_format($rec_sv['second_DTW_mp_Cost'], 2); ?></td>
                            <td colspan="2"<?if ($st_time_sign > 0 && ($diff_time_percent < -$GLOBALS['LS_sv_TimePercentLower'] || $diff_time_percent < -$GLOBALS['LS_sv_TimePercentLower'])) {?> style="background-color: red"<?}?>><? echo $time_sign; ?> сек.</td>
                        </tr>
                    </tbody>
                </table>
            </div>
                     <? } else { ?>
        <div class="red">Эталонная подпись не назначена</div>
        <?}
   ?>
    <h2>Исходные данные</h2>
    <textarea style="width:100%;height:100px;"><?echo $rec_sv['standart_sign']?></textarea><br><textarea  style="width:100%;height:100px;"><?echo $rec_sv['second_sign']?></textarea><?
    
  ?></div><?
}

?>