summaryrefslogtreecommitdiff
path: root/jimbrella/templates/admin/umbrellas.html
blob: 15b6f027ee9b61b533ee964c1c7b4cc9996812a8 (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html>
    <head>
        <title>JI Umbrella</title>
        <link rel="stylesheet" href="/static/jimbrella.css" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
    </head>
    <body>
        <h1>All Umbrellas</h1>
        <div id="container">
            {% include "admin/tabs.html" %}
            {% if mobile %}
            <div class="data-table-container">
                <table class="data">
                    {% for umb in umbrellas %}
                    {% if umb.status in ["lent", "overdue"] %}
                        <tr class="{{ umb.status }}">
                            <th rowspan=5>
                                {{ umb.serial }} <br />
                                {{ umb.status }} <br />
                                <a href="/admin/umbrellas?edit={{ umb.serial }}">Edit</a>
                            </th>
                            <td>{{ umb.tenant_name }}</td>
                        </tr>
                        <tr class="{{ umb.status }}"><td>{{ umb.tenant_id }}</td></tr>
                        <tr class="{{ umb.status }}"><td>{{ umb.tenant_phone }}</td></tr>
                        <tr class="{{ umb.status }}"><td>{{ umb.lent_at_str }}</td></tr>
                        <tr class="{{ umb.status }}"><td>
                            {{ umb.lent_time_ago_str }}
                            {% if umb.status in ["lent", "overdue"] %} ago {% endif %}
                        </td></tr>
                    {% else %}
                        <tr class="{{ umb.status }}">
                            <th colspan=2>{{ umb.serial }} <br /> {{ umb.status }}</th>
                        </tr>
                    {% endif %}
                    {% endfor %}
                </table>
            </div>
            {% else %}
            <div class="data-table-container">
                <table class="data">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Status</th>
                            <th>Tenant</th>
                            <th>ID</th>
                            <th>Phone</th>
                            <th colspan=2>Lent at</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% macro status_opt(umb, status) -%}
                        <option value="{{ status }}"
                        {% if umb.status == status %}
                            selected
                        {% endif %}>
                            {{ status }}
                        </option>
                        {%- endmacro %}

                        {% for umb in umbrellas %}
                        <tr class="{{ umb.status }}">
                        {% if umb.serial == edit %}
                        <form method="post" action="/admin/umbrellas/edit">
                            <input name="serial" type="number" value="{{ umb.serial }}" hidden/>
                            <td>{{ umb.serial }}</td>
                            <td>
                                <select name="status">
                                    {% for status in ["available", "lent", "overdue"] %}
                                        {{ status_opt(umb, status) }}
                                    {% endfor %}
                                </select>
                            </td>
                            <td><input name="tenant_name" value="{{ umb.tenant_name }}" class="db-edit" /></td>
                            <td><input name="tenant_id" type="number" value="{{ umb.tenant_id }}" class="db-edit" /></td>
                            <td><input name="tenant_phone" type="tel" value="{{ umb.tenant_phone }}" class="db-edit" /></td>
                            <td><input name="lent_at" type="datetime-local" value="{{ umb.lent_at_str }}"/></td>
                            <td>{{ umb.lent_time_ago_str }}
                                {% if umb.status in ["lent", "overdue"] %} ago {% endif %}
                            </td>
                            <td>
                                <input type="submit" value="Submit" />
                            </td>
                        </form>
                        {% else %}
                            <td>{{ umb.serial }}</td>
                            <td>{{ umb.status }}</td>
                            <td>{{ umb.tenant_name }}</td>
                            <td>{{ umb.tenant_id }}</td>
                            <td>{{ umb.tenant_phone }}</td>
                            <td>{{ umb.lent_at_str }}</td>
                            <td>{{ umb.lent_time_ago_str }}
                                {% if umb.status in ["lent", "overdue"] %} ago {% endif %}
                            </td>
                            <td>
                                <a href="/admin/umbrellas?edit={{ umb.serial }}">Edit</a>
                            </td>
                        {% endif %}
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
            {% endif %}
        </div>
    </body>
</html>