aboutsummaryrefslogtreecommitdiff
path: root/templates/income/update.html
blob: 855d5c4ba023c1e4bdf4ba0ad51dcb6dd8e17ef0 (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
110
111
112
113
114
115
116
117
118
119
120
121
122
{% extends "base.html" %}

{% block title %}
  Revenu {{ id }}
{% endblock title %}

{% block main %}

  <section class="g-Section">
    <p class="g-Paragraph">
      <a
        class="g-Link g-Media__Large"
        href="/incomes?page={{ query.page | default(value=1) }}"
      >
        Retour aux revenus
      </a>
    </p>

    {% if error %}
      <div class="g-Form__Error">{{ error }}</div>
    {% endif %}

    {% if not income %}

      Le revenu n’a pas été trouvé.

    {% else %}

      <form
        class="g-Form"
        action="/income/{{ income.id }}/update"
        method="POST"
      >
        <h1 class="g-H1">Modification</h1>

        <label class="g-Form__Label">
          Montant
          <input
            name="amount"
            type="number"
            class="g-Form__Input"
            value="{{ form.amount | default(value=income.amount) }}"
            required
          />
        </label>

        {% set user_id = form.user_id | default(value="" ~ income.user_id) %}

        <label class="g-Form__Label">
          Personne
          <select name="user_id" class="g-Form__Select" required>
            {% for user in users %}
              <option
                value="{{ user.id }}"
                {% if "" ~ user.id == user_id %} selected {% endif %}
              >
                {{ user.name }}
              </option>
            {% endfor %}
          </select>
        </label>

        {% set month_index = form.month | default(value="" ~ income.month) %}

        <label class="g-Form__Label">
          Mois
          <select name="month" class="g-Form__Select" required>
            {% for month in months %}
              <option
                value="{{ loop.index }}"
                {% if "" ~ loop.index == month_index %} selected {% endif %}
              >
                {{ month }}
              </option>
            {% endfor %}
          </select>
        </label>

        <label class="g-Form__Label">
          Année
          <input
            name="year"
            type="number"
            class="g-Form__Input"
            value="{{ form.year | default(value=income.year) }}"
            required
          />
        </label>

        <div>
          <input class="g-Button__Validate" type="submit" value="Modifier" />
        </div>
      </form>

      <form
        class="g-Form"
        action="/income/{{ income.id }}/delete"
        method="POST"
      >
        <h1 class="g-H1">Suppression</h1>

        {% if is_category_used %}
          <p>
            La catégorie ne peut pas être supprimée car elle est actuellement
            utilisée.
          </p>
        {% else %}
          <label class="g-Form__Label">
            Veuillez recopier le montant du revenu : « {{ income.amount }} ».
            <input name="remove-input" class="g-Form__Input" data-name="{{ income.amount }}" />
          </label>

          <div>
            <input id="remove-button" class="g-Button__Danger" type="submit" value="Supprimer" disabled />
          </div>
        {% endif %}
      </form>

    {% endif %}
  </section>

{% endblock main %}