{config_load file="$language.conf" section="view_mailbeezstats"}

{if $block_history > 0}
    <h2>{#title_blocked#}</h2>
    <table class="table table-striped table-bordered table-condensed" id="email_rate_analytics">

        <thead>
        <tr>
            <th data-priority="1">{#header_module#}</th>
            <th data-priority="1">{#header_blockedby#}</th>
            <th data-priority="1">{#header_date#}</th>
        </tr>
        </thead>
        <tbody>
        {foreach from=$block_history item=block_item}
            <tr>

                <td>{$block_item.module}
                    <div class="engagement_badge blocked"> {#engagement_blocked#}</div>
                </td>

                <td>
                    {if $block_item.date_block && $block_item.source == 0}
                    {mh_lng key='TEXT_CFG_BLOCK_SOURCE_0'}
                    {elseif $block_item.source == 1}
                    {mh_lng key='TEXT_CFG_BLOCK_SOURCE_1'}
                    {elseif $block_item.source == 2}
                    {mh_lng key='TEXT_CFG_BLOCK_SOURCE_2'}
                    {elseif $block_item.source == 3}
                    {mh_lng key='TEXT_CFG_BLOCK_SOURCE_3'}
                    {elseif $block_item.source == 4}
                    {mh_lng key='TEXT_CFG_BLOCK_SOURCE_4'}
                    {/if}
                </td>
                <td><abbr class="timeago" title="{$block_item.date_block}">{$block_item.date_block}</abbr></td>
            </tr>
        {/foreach}
        </tbody>
    </table>
{/if}

{if $msg_history > 0 }
    <h2>{#title_history#}</h2>
    <!--<table data-role="table" data-mode="reflow" class="ui-responsive table-stroke" style="width: 100%">-->
    <table class="table table-striped table-bordered table-condensed" id="email_rate_analytics">

        <thead>
        <tr>
            <th data-priority="1">{#header_archive#}</th>
            <!--<th data-priority="1">{#header_mode#}</th>-->
            <th data-priority="1">{#header_module#}</th>
            <th data-priority="1">{#header_date#}</th>
            <th data-priority="1">{#header_language#}</th>
            <th data-priority="1">{#header_channel#}</th>
            <th data-priority="1">{#header_engagements#}</th>
        </tr>
        </thead>
        <tbody>

        {foreach from=$msg_history item=msg_item}
            <tr style="{if $msg_item.simulation > 0}opacity: 0.5; {/if}"
                {if $email_archive}onclick="return openCeeboxPopup('{$msg_item.view_archive_url}');"{/if}>
                <!--<th>1<img src="{$module_path}icon_36.png" style="padding: 20px;"></th>-->
                <td>

                    {if $email_archive}
                        <a href="#" onclick="return openCeeboxPopup('{$msg_item.view_archive_url}');"><img
                                    src="{$module_path}zoom.png" hspace="0" vspace="0" width="16" height="16"
                                    style="float:left; margin:0px;padding: 0px;margin-top: 4px;"></a>
                    {else}
                        <a href="#popupDialog" data-rel="popup" data-inline="true" data-transition="pop"
                           data-position-to="window"><img src="{$module_path}zoom.png" hspace="0" vspace="0" width="16"
                                                          height="16"
                                                          style="float:left; margin:0px;padding: 0px;margin-top: 4px;"></a>
                        <div data-role="popup" id="popupDialog" data-overlay-theme="a" data-theme="c"
                             data-dismissible="false" style="max-width:400px;" class="ui-corner-all">
                            <div data-role="content" data-theme="d" class="ui-corner ui-content">
                                <h3 class="ui-title">{#popup_archive_title#}</h3>

                                <p>{#popup_archive_text#}</p>
                                <a href="#" data-role="button" data-inline="true" data-rel="back"
                                   data-theme="c">{#popup_archive_button_cancel#}</a>
                                <a href="{#popup_archive_url#}" target="_blank" data-role="button" data-inline="true"
                                   data-transition="flow" data-theme="b">{#popup_archive_button_readmore#}</a>
                            </div>
                        </div>
                    {/if}

                </td>
                <td>
                    <div style="float:left; margin-right: 5px;">
                        {if $msg_item.mode == 'SIM'}
                            <div class="mode_badge simulation"><abbr title="Simulation">S</abbr></div>
                        {elseif $msg_item.mode == 'PROD'}
                            <div class="mode_badge production"><abbr title="Production">P</abbr></div>
                        {/if}
                    </div>

                    <div style="overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          width: 70%;
          float:left;">
                        <abbr title="{$msg_item.module}">{$msg_item.module}</abbr>
                    </div>
                    / {$msg_item.iteration}
                </td>
                <td><abbr class="timeago" title="{$msg_item.date_sent}">{$message.date_sent}</abbr></td>
                <td>{$msg_item.language_id}</td>
                <td>{if $msg_item.channel == 'DEFAULT'} email {else}{$msg_item.channel}{/if}</td>
                <td>
                    {if $msg_item.engagement_bounced > 0}
                        <div class="engagement_badge bounced"> {$msg_item.engagement_bounced} {#engagement_bounced#}</div>
                    {/if}
                    {if $msg_item.engagement_opened > 0}
                        <div class="engagement_badge opened"> {#engagement_opened#}</div>
                    {/if}
                    {if $msg_item.engagement_clicked > 0}
                        <div class="engagement_badge clicked"> {#engagement_clicked#}</div>
                    {/if}
                    {if $msg_item.engagement_ordered > 0}
                        <div class="engagement_badge ordered"> {#engagement_ordered#}</div>
                    {/if}
                </td>
            </tr>
        {/foreach}
        </tbody>
    </table>
{else}
    <p>
        {#no_history#}
    </p>
{/if}