{extends file="[shared]/frame.tpl"}

{block "content"}
   <div class="board-translations">
      <div class="container-fluid">
         <h3>{'statsTitle'|translate:'translations'}</h3>
         {$list_types = array_keys($stats)}
         {$pop = array_pop($list_types)}
         {$list_types = ['ID' => $list_types]}
         {foreach $languages as $key => $lang}
            <div class="panel panel-primary first">
               <div class="panel-heading">
                   <h3 class="panel-title" style="padding-bottom: 10px;">
                       {$lang}
                       <div class="col-md-1 pull-right"><a class="btn btn-default no-margin" href="javascript:nw('importTranslations', '', 'sourceLanguage={$sourceLanguage}&language={$key}')">Import</a></div>
                       <div class="col-md-1 pull-right"><a class="btn btn-default no-margin" href="javascript:nw('exportTranslations', '', 'sourceLanguage={$sourceLanguage}&language={$key}&{http_build_query($list_types)}')">Export</a></div>
                       <div class="col-md-2 pull-right"><a class="btn btn-default no-margin" href="javascript:nw('calculateTranslations', '', 'sourceLanguage={$sourceLanguage}&language={$key}')">Počet normostran</a></div>
                   </h3>
               </div>
               <div class="panel-body">
                   <div class="row bottom-space">
                       {foreach $stats as $listType => $entry}
                           {if $listType == 'translateBlocks'}
                               {continue}
                           {/if}
                           {$total = $entry.totals.total}
                           {$lang_total = "{$key}_total"}
                           {$lang_total = $entry.totals.$lang_total}
                           {if $listType == 'languageCheck'}
                               {$total = $lang_total}
                               {$lang_total = "{$key}_total_translated"}
                               {$lang_total = $entry.totals.$lang_total}
                           {/if}
                           {if $total == 0}{$percent = 0}{else}
                               {$percent = ($lang_total/$total)*100}
                           {/if}
                           {$class = 'badge-warning'}
                           {if $percent==100}{$class = 'badge-success'}{/if}
                           {$link_translate = "launch.php?s=main.php&l=&r=s:list.php|type:{$listType}|sourceLanguage={$sourceLanguage}|language={$key}"}
                           {$link_export = "javascript:nw('exportTranslations', '{$listType}', 'sourceLanguage={$sourceLanguage}&language={$key}')"}
                           {if $listType == 'languageCheck'}
                               {$link_translate = "launch.php?s=main.php&l=&r=s:languageCheck.php|language:{$key}"}
                           {/if}
                           <div class="col-lg-4 col-md-6 col-sm-6">
                               <div class="well">
                                   <div class="row">
                                       <div class="col-md-7">
                                           <label>{translate_type type=$entry.name}</label>
                                           <p>{'total'|translate:"orders"}: {$total}</p>
                                           <p>{'filter.translated'|translate:"translations"}: {$lang_total}
                                               <span class="no-margin badge {$class} badge-light pull-right">
                                                   {sprintf('%1.1F%%', $percent)}
                                               </span>
                                           </p>
                                       </div>
                                       <div class="col-md-5">
                                           <div>
                                               <a href="{$link_translate}" class="btn btn-default btn-block btn-sm" target="_blank">{translate_type type='translate'}</a>
                                           </div>
                                           {if $listType != 'languageCheck'}
                                           <div>
                                               <a href="{$link_export}" class="btn btn-default btn-block btn-sm">Export</a>
                                           </div>
                                           {/if}
                                       </div>
                                   </div>
                               </div>
                           </div>
                       {/foreach}
                   </div>
               </div>
            </div>
         {/foreach}
      </div>
   </div>
{/block}
