{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!--// $Id$ //-->
<h1>{$layout.pagetitle}</h1>

<form method="POST" action="?m={$layout.module}&page={$page}" id="choosefilter" name="choosefilter">
    <input type="submit" class="hiddenbtn">
</form>

<table class="lmsbox lms-ui-background-cycle">
    <colgroup>
        {block name="voipaccountlist-list-columns"}
        <col style="width: 96%;">
        <col style="width: 1%;" span="4">
        {assign var='number_of_table_columns' value='5'}
        {/block}
    </colgroup>
    <thead>
        {block name="voipaccountlist-list-header"}
        <tr {tip text="Click on column name to change sorting order"}>
            <th nowrap>
                <img src="img/voip.gif" alt="">
                <a href="?m=voipaccountlist&amp;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}
                / {trans("Location:")}
                <br>
                <img src="img/customer.gif" alt="">
                <a href="?m=voipaccountlist&amp;o=owner{if $listdata.direction == "asc" && $listdata.order == "owner"},desc{/if}">{trans("Customer:")}</a>
                {if $listdata.order == "owner"}
                <img src="img/{if $listdata.direction == "desc"}asc{else}desc{/if}_order.gif" alt="">
                {/if}
            </th>
            <th nowrap>
                <a href="?m=voipaccountlist&amp;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}
            </th>
            <th nowrap>
                {trans("Phone number:")}&nbsp;
            </th>
            <th nowrap>
                {trans("Password:")}
            </th>
            <th align="right" class="nobr">
                {button icon="add" label="New Account" href="?m=voipaccountadd"}
            </th>
        </tr>
        {/block}
        {block name="voipaccountlist-list-filters"}
            <tr>
                <th colspan="{$number_of_table_columns}">
                    {icon name="filter"}
                    <label>
                        {trans("Service provider")}
                        <select name="search[serviceproviderid]" form="choosefilter">
                            <option value=""{if empty($listdata.search.serviceproviderid)} selected{/if}>{trans("— all —")}</option>
                            {foreach $serviceproviders as $serviceprovider}
                                <option value="{$serviceprovider.id}"
                                    {if $listdata.search.serviceproviderid == $serviceprovider.id} selected{/if}>{$serviceprovider.name|escape}</option>
                            {/foreach}
                        </select>
                    </label>
                </th>
            </tr>
        {/block}
        {block name="voipaccountlist-list-header-pagination"}
        {if $listdata.total != 0}
        <tr>
            <th class="lms-ui-pagination" colspan="{$number_of_table_columns-1}">
                {include file="scroller.html" loop=$voipaccountlist}
            </th>
            <th></th>
        </tr>
        {/if}
        {/block}
    </thead>
    <tbody>
        {section name=voipaccountlist loop=$voipaccountlist start=$start max=$pagelimit}
        {block name="voipaccountlist-list-row"}
        <tr class="highlight" data-name="{$voipaccountlist[voipaccountlist].login}">
            <td onClick="return self.location.href = '?m=voipaccountinfo&amp;id={$voipaccountlist[voipaccountlist].id}';" nowrap>
                <img src="img/voip.gif" alt="">
                <strong>{$voipaccountlist[voipaccountlist].login}</strong>
		{if $voipaccountlist[voipaccountlist].location} / {$voipaccountlist[voipaccountlist].location}{if $voipaccountlist[voipaccountlist].borough_name} ({$voipaccountlist[voipaccountlist].state_name} / {$voipaccountlist[voipaccountlist].district_name} / {$_BOROUGHTYPES[$voipaccountlist[voipaccountlist].borough_type]} {$voipaccountlist[voipaccountlist].borough_name}){/if}{/if}
		<br>
                <img src="img/customer.gif" alt="">&nbsp;
                <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:40:"&hellip;":true|replace:" ":"&nbsp;"}
                    ({$voipaccountlist[voipaccountlist].ownerid|string_format:"%04d"})
                </a>
            </td>
            <td onClick="return self.location.href = '?m=voipaccountinfo&amp;id={$voipaccountlist[voipaccountlist].id}';" valign="top" nowrap>
                ({$voipaccountlist[voipaccountlist].id|string_format:"%04d"})
            </td>
            <td onClick="return self.location.href = '?m=voipaccountinfo&amp;id={$voipaccountlist[voipaccountlist].id}';" valign="top" nowrap>
                {foreach from=$voipaccountlist[voipaccountlist].phone item=$v name=account_phones}
                    {$v}{if not $smarty.foreach.account_phones.last}<br>{/if}
                {/foreach}
            </td>
            <td onClick="return self.location.href = '?m=voipaccountinfo&amp;id={$voipaccountlist[voipaccountlist].id}';" valign="top" nowrap>
                {if ConfigHelper::checkPrivilege('hide_voip_passwords')}{'*'|str_repeat:8}{else}{$voipaccountlist[voipaccountlist].passwd}{/if}
            </td>
            <td align="right" class="nobr">
					<a href="?m=voipaccountbillinglist&amp;id={$voipaccountlist[voipaccountlist].id}">
						<img src="img/sms.gif" alt="{trans("Edit")}" title="{trans("Billings")}">
					</a>
                    <a href="?m=voipaccountset&amp;id={$voipaccountlist[voipaccountlist].id}">
                        <img src="img/{if ! $voipaccountlist[voipaccountlist].access}no{/if}access.gif" alt="{if ! $voipaccountlist[voipaccountlist].access}{trans("Connect")}{else}{trans("Disconnect")}{/if}" title="{if ! $voipaccountlist[voipaccountlist].access}{trans("Connect")}{else}{trans("Disconnect")}{/if}">
                    </a>
                    <a class="delete-voipaccount" href="?m=voipaccountdel&id={$voipaccountlist[voipaccountlist].id}"><img src="img/delete.gif" alt="{trans("Delete")}" title="{trans("Delete")}"></a>
                    <a href="?m=voipaccountedit&amp;id={$voipaccountlist[voipaccountlist].id}">
                        <img src="img/edit.gif" alt="{trans("Edit")}" title="{trans("Edit")}">
                    </a>
                    <a href="?m=voipaccountinfo&amp;id={$voipaccountlist[voipaccountlist].id}">
                        <img src="img/info.gif" alt="{trans("Info")}" title="{trans("Info")}">
                    </a>
            </td>
        </tr>
        {if $voipaccountlist[voipaccountlist.index_next].ownerid == $voipaccountlist[voipaccountlist].ownerid && $listdata.order == "owner"}{cycle print=false}{/if}
        {/block}
        {sectionelse}
        {block name="voipaccountlist-list-empty-row"}
        <tr>
            <td class="empty-table" colspan="{$number_of_table_columns}">
                {trans("No such VoIP accounts in database.")}
            </td>
        </tr>
        {/block}
        {/section}
    </tbody>
    <tfoot>
        <tr>
            {if $listdata.total != 0}
            <td class="lms-ui-pagination" colspan="{$number_of_table_columns-1}" 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="{$number_of_table_columns}"{/if}>
                {trans("Total:")}
                {if $listdata.total}{$listdata.total}{else}0{/if}
            </td>
        </tr>
    </tfoot>
</table>
<script>

    $(function() {
        $('[form="choosefilter"]').change(function() {
            $("#choosefilter").submit();
        });

        $('.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}
{block name=extra_content}{/block}
