Project

General

Profile

Download (4.08 KB) Statistics
| Branch: | Tag: | Revision:

calebasse / calebasse / personnes / templates / personnes / group_holiday_update.html @ a69db8e6

1
{% extends "personnes/simple-form.html" %}
2

    
3
{% block appbar %}
4
<h2>Absences de groupe</h2>
5
  <a href="..">Retour à la gestion des absences</a>
6
{% endblock %}
7

    
8

    
9
{% block content %}
10
    <form method="post">
11
      <div id="form-content">
12
        {% csrf_token %}
13
        {% with formset=form %}
14
        {{ formset.management_form }}
15
        <p>Le format des dates est jj/mm/aaaa.</p>
16
        <table class="inline">
17
          <thead>
18
            <tr>
19
              <td><label class="required">Date de début</label></td>
20
              <td><label class="required">Date de fin</label></td>
21
              <td><label>Heure de début</label></td>
22
              <td><label>Heure de fin</label></td>
23
              <td><label class="required">Type d'absence</label></td>
24
              <td><label>Commentaire</label></td>
25
              <td><label>Tous les services</label></td>
26
              <td><label>Supprimer</label></td>
27
            </tr>
28
          </thead>
29
          <tbody id="timetables">
30
          {% for form in formset %}
31
            {% if form.non_field_errors %}
32
            <tr><td colspan="4">{{ form.non_field_errors }}</td></tr>
33
            {% endif %}
34
            <tr class="timetable">
35
              <td id="start-{{ forloop.counter0 }}" class="datepicker" data-before-selector="#end-{{ forloop.counter0 }}" data-number-of-months="3">{{ form.start_date }}</td>
36
              <td id="end-{{ forloop.counter0 }}" class="datepicker" data-after-selector="#start-{{ forloop.counter0 }}" data-number-of-months="3">{{ form.end_date }}</td>
37
              <td class="timepicker">{{ form.start_time }}</td>
38
              <td class="timepicker">{{ form.end_time }}</td>
39
              <td>{{ form.holiday_type }} {{ form.holiday_type.errors }}</td>
40
              <td>{{ form.comment }}{{ form.comment.errors }}</td>
41
              <td>{{ form.for_all_services }}</td>
42
              <td class="delete">{% if form.id.value != None %}{{ form.DELETE }}{% endif %}
43
                {% for field in form %}
44
                {% if field.is_hidden %}
45
                {{field}}
46
                {% endif %}
47
                {% endfor %}
48
              </td>
49
            </tr>
50
          {% endfor %}
51
          </tbody>
52
        </table>
53
        {% endwith %}
54
      </div>
55
      {% block buttons %}
56
      <button class="enable-on-change">Modifier</button>
57
      <button id="add-form">Ajouter une ligne</button>
58
      {% endblock %}
59
    </form>
60
<p><a href="..">{% block back-link %}Retour à la gestion des absences{% endblock %}</a></p>
61
{% endblock %}
62

    
63
{% block page-end %}
64
{{ block.super }}
65
<script>
66
  $(function () {
67
    var completions = [];
68
    for (var i = 8*60; i < 21*60; i += 15) {
69
      var completion = ''
70
      var hour = Math.floor(i/60);
71
      var minute = i % 60;
72
      var c = function (v) {
73
        if (v < 10) {
74
          return '0'+v;
75
        }
76
        return v;
77
      }
78
      completions.push(''+c(hour)+':'+c(minute));
79
    }
80
    $('.timepicker input').autocomplete({delay:0, source: completions, minLength: 0});
81
    function addForm() {
82
      var count = $('.timetable').length
83
      var new_row = $('.timetable:first').clone(false).get(0);
84
      $('input', new_row).val('');
85
      $('input, select', new_row).each(function (i, v) {
86
        v.name = v.name.replace('-0-', '-' + count + '-');
87
      });
88
      $('.delete input[type="checkbox"]', new_row).remove();
89
      $('.hasDatepicker', new_row).removeClass('hasDatepicker');
90
      $('*', new_row).each(function (i, v) {
91
        if (v.id) {
92
          v.id = v.id.replace('-0', '-' + count);
93
          if ($(v).data('before-selector')) {
94
            var old_value = $(v).data('before-selector');
95
            $(v).data('before-selector', old_value.replace('-0', '-' + count));
96
          }
97
          if ($(v).data('after-selector')) {
98
            var old_value = $(v).data('after-selector');
99
            $(v).data('after-selector', old_value.replace('-0', '-' + count));
100
          }
101
        }
102
      });
103

    
104
      $(new_row).appendTo($('#timetables'));
105
      $('#id_timetable_set-TOTAL_FORMS').val(count+1);
106
      window.calebasse_dialogs();
107
      return false;
108
    }
109
    $('#add-form').click(addForm);
110
  });
111
</script>
112
{% endblock %}
(4-4/16)