<?php $this->layout('main', ['title' => __('Remote Relays'), 'manual' => true]) ?>

<div class="card">
    <div class="card-header bg-primary-dark">
        <h2 class="card-title"><?=__('Remote Relays')?></h2>
    </div>
    <div class="card-body alert-info d-flex align-items-center" role="alert">
        <div class="flex-shrink-0 mr-2">
            <i class="material-icons" aria-hidden="true">info</i>
        </div>
        <div class="flex-fill">
            <p class="card-text">
                <?=__('Remote relays let you work with broadcasting software outside this server. Any relay you include here will be included in your station\'s statistics. You can also broadcast from this server to remote relays.')?>
            </p>
        </div>
    </div>
    <div class="card-actions">
        <a class="btn btn-outline-primary" role="button" href="<?=$router->fromHere('stations:remotes:add')?>">
            <i class="material-icons" aria-hidden="true">add</i>
            <?=__('Add Remote Relay')?>
        </a>
    </div>
    <table class="table table-responsive-md table-striped mb-0">
        <colgroup>
            <col width="25%">
            <col width="45%">
            <col width="30%">
        </colgroup>
        <thead>
        <tr>
            <th><?=__('Actions')?></th>
            <th><?=__('Remote Relay')?></th>
            <th><?=__('AutoDJ')?></th>
        </tr>
        </thead>
        <tbody>
        <?php foreach ($remotes as $row): ?>
            <?php /** @var App\Entity\StationRemote $row */ ?>
            <tr class="align-middle">
                <td>
                    <?php if ($row->isEditable()): ?>
                        <div class="btn-group btn-group-sm">
                            <a class="btn btn-sm btn-primary" href="<?=$router->fromHere('stations:remotes:edit',
                                ['id' => $row->getId()])?>"><?=__('Edit')?></a>
                            <a class="btn btn-sm btn-danger" data-confirm-title="<?=$this->e(__('Delete remote relay "%s"?',
                                $row->getUrl()))?>" href="<?=$router->fromHere('stations:remotes:delete',
                                ['id' => $row->getId(), 'csrf' => $csrf])?>"><?=__('Delete')?></a>
                        </div>
                    <?php endif; ?>
                </td>
                <td>
                    <h5 class="m-0">
                        <a href="<?=$this->e($row->getUrl())?>" target="_blank"><?=$this->e($row->getDisplayName())?></a>
                    </h5>
                </td>
                <td>
                    <?php if ($row->getEnableAutodj()): ?>
                        <?=__('Enabled')?> - <?=(int)$row->getAutodjBitrate()?>kbps <?=strtoupper($this->e($row->getAutodjFormat()))?>
                    <?php else: ?>
                        <?=__('Disabled')?>
                    <?php endif; ?>
                </td>
            </tr>
        <?php endforeach; ?>
        </tbody>
    </table>
</div>
