{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!--// $Id$ //-->
<h1>{$layout.pagetitle}</h1>
<table class="lmsbox">
    <colgroup>
        <col style="width: 96%;"/>
        <col style="width: 1%;"/>
        <col style="width: 1%;"/>
        <col style="width: 1%;"/>
        <col style="width: 1%;"/>
    </colgroup>
    <thead>
        <tr {tip text="Click on column name to change sorting order"}>
            <td class="nobr">
                <img src="img/voip.gif" alt="">
                <a class="bold" href="?m=voipaccountsearch&search&o=login{if $listdata.direction == "asc" && $listdata.order == "login"},desc{/if}">{trans("Login:")}</a>
                {if $listdata.order == "login"}
                <img src="img/{if $listdata.direction == "desc"}asc{else}desc{/if}_order.gif" alt="">
                {/if}
                <br>
                <img src="img/customer.gif" alt="">
                <a href="?m=voipaccountsearch&search&o=owner{if $listdata.direction == "asc" && $listdata.order == "owner"},desc{/if}">{trans("Owner:")}</a>
                {if $listdata.order == "owner"}
                <img src="img/{if $listdata.direction == "desc"}asc{else}desc{/if}_order.gif" alt="">
                {/if}
            </td>
            <td class="bold nobr">
                <a href="?m=voipaccountsearch&search&o=id{if $listdata.direction == "asc" && $listdata.order == "id"},desc{/if}">{trans("ID:")}</a>
                {if $listdata.order == "id"}
                <img src="img/{if $listdata.direction == "desc"}asc{else}desc{/if}_order.gif" alt="">
                {/if}
            </td>
            <td class="bold nobr">
                {trans("Phone number:")}
            </td>
            <td class="bold nobr">
                {trans("Password:")}
            </td>
            <td class="text-right bold nobr">
                {t a=$listdata.total}Total: $a{/t}
            </td>
        </tr>
        {if $listdata.total != 0}
        <tr>
            <td class="lms-ui-pagination" colspan="5">
                {include file="scroller.html" loop=$voipaccountlist adlink="&search=1"}
            </td>
        </tr>
        {/if}
    </thead>
    <tbody>
        {cycle values="light,lucid" print=false}
        {section name=voipaccountlist loop=$voipaccountlist start=$start max=$pagelimit}
        <tr class="highlight {cycle}" data-name="{$voipaccountlist[voipaccountlist].login}">
            <td onClick="return self.location.href = '?m=voipaccountinfo&id={$voipaccountlist[voipaccountlist].id}';">
                <a class="bold" name="{$voipaccountlist[voipaccountlist].id}">
                    <img src="img/voip.gif" alt=""> {$voipaccountlist[voipaccountlist].login}
                </a><br>
                <img src="img/customer.gif" alt="">
                <a href="?m=customerinfo&id={$voipaccountlist[voipaccountlist].ownerid}"
                   class="lms-ui-hint-rollover"
                   data-url="?m=customerinfoshort&id={$voipaccountlist[voipaccountlist].ownerid}"
                    >{$voipaccountlist[voipaccountlist].owner|truncate:60:"&hellip;"|replace:" ":"&nbsp;"}
                    ({$voipaccountlist[voipaccountlist].ownerid|string_format:"%04d"})
                </a>
            </td>
            <td onClick="return self.location.href = '?m=voipaccountinfo&id={$voipaccountlist[voipaccountlist].id}';">
                ({$voipaccountlist[voipaccountlist].id|string_format:"%04d"})
            </td>
            <td class="bold" onClick="return self.location.href = '?m=voipaccountinfo&id={$voipaccountlist[voipaccountlist].id}';">
                {$voipaccountlist[voipaccountlist].phone}
            </td>
            <td onClick="return self.location.href = '?m=voipaccountinfo&id={$voipaccountlist[voipaccountlist].id}';">
                {if ConfigHelper::checkPrivilege('hide_voip_passwords')}{'*'|str_repeat:8}{else}{$voipaccountlist[voipaccountlist].passwd}{/if}
            </td>
            <td class="text-right nobr" align="right">
                <a class="delete-voipaccount" href="?m=voipaccountdel&id={$voipaccountlist[voipaccountlist].id}"><img src="img/delete.gif" alt="{trans("Delete")}"></a>
                <a href="?m=voipaccountedit&id={$voipaccountlist[voipaccountlist].id}">
                    <img src="img/edit.gif" alt="{trans("Edit")}">
                </a>
                <a href="?m=voipaccountinfo&id={$voipaccountlist[voipaccountlist].id}">
                    <img src="img/info.gif" alt="{trans("Info")}">
                </a>
            </td>
        </tr>
        {sectionelse}
        <tr>
            <td class="empty-table" colspan="5">
                {trans("No such VoIP accounts matching search criteria.")}
            </td>
        </tr>
        {/section}
        <tr>
            {if $listdata.total != 0}
                <td class="lms-ui-pagination" colspan="4" style="border-top: 1px solid black;">
                {include file="scroller.html" loop=$voipaccountlist adlink="&search=1"}
                </td>
            {/if}
            <td class="text-right bold" style="border-top: 1px solid black; background-color: #CEBD9B;"{if $listdata.total == 0} colspan="5"{/if}>
                {trans("Total:")}
                {if $listdata.total}{$listdata.total}{else}0{/if}
            </td>
        </tr>
    </tbody>
</table>
    <script>
        $('.delete-voipaccount').click(function() {
            var name = $(this).closest('tr').attr('data-name');
            confirmDialog($t("Are you sure, you want to remove voip account '$a' from database?", name), this).done(function() {
                location.href = $(this).attr('href');
            });
            return false;
        });
    </script>
{/block}
