{*<!--

+---------------------------------------------------------------------------+
| Revive Adserver                                                           |
| http://www.revive-adserver.com                                            |
|                                                                           |
| Copyright: See the COPYRIGHT.txt file.                                    |
| License: GPLv2 or later, see the LICENSE.txt file.                        |
+---------------------------------------------------------------------------+

-->*}


<div class='tableWrapper'>
    <div class='tableHeader'>
        <ul class='tableActions'>
            <li>
            	{if $entityUrl != 'affiliate-channels.php' || $affiliateId != -1}
	            <a href='channel-edit.php?{$entityId}' class='inlineIcon iconTargetingChannelAdd'>{t str=AddNewChannel}</a>
                {else}
	            <span class='inlineIcon iconTargetingChannelAddDisabled'>{t str=AddNewChannel}</span>
                {/if}
            </li>
            <li class='inactive activeIfSelected'>
                <a id='deleteSelection' href='#' class='inlineIcon iconDelete'>{t str=Delete}</a>

                {literal}
                <script type='text/javascript'>
                <!--

                $('#deleteSelection').click(function(event) {
					event.preventDefault();

					if (!$(this).parents('li').hasClass('inactive')) {
						var ids = [];
						$(this).parents('.tableWrapper').find('.toggleSelection input:checked').each(function() {
							ids.push(this.value);
						});

						if (!tablePreferences.warningBeforeDelete || confirm("{/literal}{t str=ConfirmDeleteChannels}{literal}")) {
							window.location = 'channel-delete.php?{/literal}{$entityId}&{rv_add_session_token}{literal}&channelid=' + ids.join(',');
						}
					}
                });

                //-->
                </script>
                {/literal}
            </li>
        </ul>

        <div class='clear'></div>
        <div class='corner left'></div>
        <div class='corner right'></div>
    </div>

    <table cellspacing='0' summary=''>
        <thead>
            <tr>
                <th class='first toggleAll'>
                    <input type='checkbox' />
                </th>
                <th>
                    {t str=Name}
                </th>
                {if $entityUrl != 'affiliate-channels.php'}
                <th>
                    {t str=Owner}
                </th>
                {/if}
                <th>
                    {t str=Description}
                </th>
                <th class='last alignRight'>&nbsp;

                </th>
            </tr>
        </thead>

{if !$from|@count}
        <tbody>
            <tr class='odd'>
                <td colspan='{if $entityUrl != 'affiliate-channels.php'}5{else}4{/if}'>&nbsp;</td>
            </tr>
            <tr class='even'>
                <td colspan='{if $entityUrl != 'affiliate-channels.php'}5{else}4{/if}' class="hasPanel">
                    <div class='tableMessage'>
                        <div class='panel'>
                            {if $entityUrl != 'affiliate-channels.php' || $affiliateId != -1}
                                {t str=NoChannels}
                            {else}
                                {t str=NoChannelsAddWebsite}
                            {/if}

                            <div class='corner top-left'></div>
                            <div class='corner top-right'></div>
                            <div class='corner bottom-left'></div>
                            <div class='corner bottom-right'></div>
                        </div>
                    </div>

                    &nbsp;
                </td>
            </tr>
            <tr class='odd'>
                <td colspan='{if $entityUrl != 'affiliate-channels.php'}5{else}4{/if}'>&nbsp;</td>
            </tr>
        </tbody>

{else}
        <tbody>
    {cycle name=bgcolor values="even,odd" assign=bgColor reset=1}
    {foreach key=channelId item=channel from=$from}
        {cycle name=bgcolor assign=bgColor}
            <tr class='{$bgColor}'>
              <td class='toggleSelection'>
                  <input type='checkbox' value='{$channelId}' />
                </td>
                <td>
                    <a href='channel-edit.php?{$entityId}&channelid={$channelId}' class='inlineIcon iconTargetingChannel'>{$channel.name|escape:html}</a>
                    {ox_entity_id type="Channel" id=$channelId}
                </td>
                {if $entityUrl != 'affiliate-channels.php'}
                <td>
                  {$channel.owner|escape:html|default:'&nbsp;'}
                </td>
                {/if}
                <td>
                  {$channel.description|escape:html|default:'&nbsp;'}
                </td>
                <td class='alignRight'>
                    <ul class='rowActions'>
                        <li>
                            <a href='channel-acl.php?{$entityId}&channelid={$channelId}' class='inlineIcon iconTargetingChannelAcl'>{t str=EditChannelLimitations}</a>
                        </li>
                    </ul>
                </td>
            </tr>
    {/foreach}
       </tbody>
{/if}
    </table>
</div>
