<%inherit file="base.html"/>
<%namespace name="search_box" file="search_box.html"/>
<%block name="title">Bank Account List</%block>
<% import time %>
<style type="text/css">
    .bank {
        margin-bottom: 0.5em;
    }
    .bank .ui-widget-header {
        padding: 0.3em;
        margin: 0;
        font-size: 1.2em;
        overflow: auto;
    }
    .bank .ui-widget-content {
        margin-left: 1em;
        padding: 0;
    }
    .account:first-child {
        border: 0;
    }
    .account {
        border: collapse;
        padding: 0.5em;
        overflow: auto;
        border-top: 1px solid #aaa;
    }
    .account .text {
        float: left;
    }
    .account .type {
        opacity: 0.5;
        font-weight: bold;
    }

    .actions {
        font-size: 12px;
    }
    .actions {
        float: right;
    }
    .actions label {
        font-size: 0.9em;
    }
</style>
<script>
    $(function() {
        $('.actions a.download').button({ icons: {primary:'ui-icon-disk'} })
        $('.actions a.delete').button({ icons: {primary:'ui-icon-trash'}, text: false }).click(function() {
            url = $(this).attr('href');
            if( confirm('Really delete?') ) {
                document.location = url;
            }
            return false;
        });
        $('.actions a.add').button({ icons: {primary:'ui-icon-plusthick'} })
    });
</script>
    <div class="ui-widget-content ui-corner-bottom">
    % for a in accounts:
        <% name = a.long_description() %>
        <% today = time.strftime('%Y-%m-%d_%H_%M_%S') %>
        <% url = "/download/%s/%s_%s.ofx" % (a.local_id(),name,today) %>
        <% type = str(a.__class__) %>
        <div class="account">
            <div class="text">
            <span class="name">
                ${name}
            </span><br/>
            <span class="type">
                ${type}
            </span>
            </div>
            <div class="actions">
                <label>Statements:</label>
                <a href="${url}?days=10" class="download">10 days</a>
                <a href="${url}?days=30" class="download">30 days</a>
                <a href="${url}?days=60" class="download">60 days</a>
                <a href="${url}?days=90" class="download">90 days</a>
                &nbsp;&nbsp;
                <a href="/delete_account?id=${a.local_id()}" class="delete">Delete</a>
            </div>
        </div>
    % endfor
    </div>
% if not accounts:
${search_box.form(error='No financial institution have been configured yet')}
% else:
<div class="actions">
    <a href="/search" class="add">Add account</a>
</div>
% endif
