@using SharpConnector.Models;
@using SharpConnector.Constants;

@model Record<Recipient>

@using (Html.BeginForm("RemoveRecipient", "AddressBook", FormMethod.Post))
{
    <div id="btn_wrapper">
        <div class="left">
            <input type="button" value="Back" onclick="navigateTo('@Url.Action("Index", "Home")');" />
        </div>
        <div id="title">
            <h3 class="text-center">Fax Recipients</h3>
        </div>
        <div class="right">
            <input type="submit" value="Remove" id="btn_remove" />
        </div>
    </div>

    <div class="inner_wrapper stretch_to_bottom">
        @if (Model != null && Model.Pagination != null)
        {
            <table id="pagination" class="pagination" align="center" valign="top" cellspacing="0" cellpadding="0" border="0">
                <tr>
                    <td align="left">
                        Showing <span id="startIndex">@Model.Pagination.StartIndex</span> to <span id="endIndex">@Model.Pagination.EndIndex</span> of <span id="totalRecords">@Model.Pagination.Total</span> records
                    </td>
                    <td width="33">
                        <button type="button" id="btn-left" class="btn-pagination disabled" onclick="navigateTo('@Url.Action("Recipients", "AddressBook")?page=@(Model.Pagination.Page - 1)');"></button>
                    </td>
                    <td align="center" width="112">
                        <font size="3">
                            <span id="currentPage">@Model.Pagination.Page</span>/<span id="totalPage">@Model.Pagination.TotalPage</span> page
                        </font>
                    </td>
                    <td width="33">
                        <button type="button" id="btn-right" class="btn-pagination" onclick="navigateTo('@Url.Action("Recipients", "AddressBook")?page=@(Model.Pagination.Page + 1)');"></button>
                    </td>
                </tr>
            </table>
        }

        <table id="table_recipients" class="tbl_content" align="center" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" border="1">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Company</th>
                    <th>Fax No.</th>
                    <th>&nbsp;</th>
                </tr>
            </thead>
            <tbody>
                @if (Model != null && Model.Records != null && Model.Records.Count > 0)
                {
                    for (var i = 0; i < Model.Records.Count; i++)
                    {
                        var c = Model.Records[i];

                        <tr id="c-@c.Id">
                            <td width="33%">@c.Name</td>
                            <td width="33%">@c.Company</td>
                            <td width="33%">@c.Address</td>
                            <td align="center">
                                <input name="contacts" type="checkbox" value="@c.Id" />
                            </td>
                        </tr>
                    }
                }
                else
                {
                    <tr>
                        <td colspan="4"><div class="no-records">@Msg.NoRecords</div></td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
}
