aboutsummaryrefslogtreecommitdiff
path: root/budget/templates/list_bills.html
blob: 7e96ca73c2a0844ea5b3f53c8cc8971561ed6d59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{% extends "layout.html" %}

{% block js %}
$(document).ready(function(){

    // display the form when clicking on the "add bill" button
    $('#add_bill_button').click(function(){
        $('#add_bill').show(200);
        $(this).hide();
        $('#hide_bill_form').show();
        return false;
    });

    // and provide a mechanism to hide it back
    $('#hide_bill_form').click(function(){
        $('#add_bill').hide(200);
        $(this).hide();
        $('#add_bill_button').show();
        return false;
    });

    // ask for confirmation before removing an user
    $('a.remove').each(function(){
        $(this).hide();
        $(this).click(function(){
            return confirm("are you sure?");
        });
    });

    // display the remove button on mouse over (and hide them per default)
    $('.members li').hover(function(){
        $(this).children('a.remove').show();
    }, function(){
        $(this).children('a.remove').hide();
    });
});
{% endblock %}

{% block top_menu %}
<ul>
    <li><a href="{{ url_for("exit") }}">logout</a></li>
</ul>
{% endblock %}

{% block content %}
<div id="leftmenu" class="span-6">
    <ul class="members">
    {% set balance = project.get_balance() %}
    {% for member in project.active_members %}
    <li class="{{ loop.cycle("even", "odd") }}">
    <span class="balance {% if balance[member] > 0 %}positive{% elif balance[member] < 0 %}negative{% endif %}">{{ balance[member] }}</span>
    {{ member.name }}
    <a class="remove" href="{{ url_for("remove_member", project_id=project.id, member_id=member.id) }}">delete</a></li>
    {% endfor %}
    </ul>
    <form action="{{ url_for("add_member", project_id=project.id) }}" method="post">
        {{ forms.add_member(member_form) }}
    </form>
</div>
<div id="content" class="uniForm span-18 last">
    <a id="add_bill_button" class="awesome large green button fright" href="{{ url_for('add_bill', project_id=project.id) }}">Add a bill</a>

    <a id="hide_bill_form" class="awesome button fright" style="display: none;" href="#">Hide form</a>

<form id="add_bill" action="{{ url_for('add_bill', project_id=project.id) }}" method="post" style="width: 400px; display: none">{{ forms.add_bill(bill_form) }}</form>

    {% if bills.count() > 0 %}
    <table class="list_bills">
        <thead><tr><th>When?</th><th>Who paid?</th><th>For what?</th><th>Owers</th><th>How much?</th><th>Actions</th></tr></thead>
    <tbody>
    {% for bill in bills %}
    <tr class="{{ loop.cycle("odd", "even") }}">
            <td>{{ bill.date }}</td>
            <td>{{ bill.payer }}</td>
            <td>{{ bill.what }}</td>
            <td>{% for ower in bill.owers %}{{ ower.name }} {% endfor %}</td>
            <td>{{ bill.amount }} ({{ bill.pay_each() }} each)</td>
            <td><a href="{{ url_for("edit_bill", bill_id=bill.id, project_id=project.id) }}">edit</a>
                <a href="{{ url_for("delete_bill", bill_id=bill.id, project_id=project.id) }}">delete</a></td>
    </tr>
    {% endfor %}
    </tbody>
    </table>

    {% else %}
    <p>Nothing to list yet. You probably want to <a href="{{ url_for("add_bill", project_id=project.id) }}">add a bill</a> ?</p>
    {% endif %}
</div>
{% endblock %}