Project

General

Profile

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

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

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

    
3
{% block appbar %}
4
<h2>Absences de <span class="lastname">{{object.last_name}}</span> {{object.first_name}}</h2>
5
  <a href="..">Retour à la page de <span class="lastname">{{object.last_name}}</span> {{object.first_name}}</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>Supprimer</label></td>
26
            </tr>
27
          </thead>
28
          <tbody id="timetables">
29
          {% for form in formset %}
30
            <tr class="timetable">
31
              <td id="start-{{ forloop.counter0 }}" class="datepicker" data-before-selector="#end-{{ forloop.counter0 }}" data-number-of-months="3">{{ form.start_date }}</td>
32
              <td id="end-{{ forloop.counter0 }}" class="datepicker" data-after-selector="#start-{{ forloop.counter0 }}" data-number-of-months="3">{{ form.end_date }}</td>
33
              <td class="timepicker">{{ form.start_time }}</td>
34
              <td class="timepicker">{{ form.end_time }}</td>
35
              <td>{{ form.holiday_type }} {{ form.holiday_type.errors }}</td>
36
              <td>{{ form.comment }}{{ form.comment.errors }}</td>
37
              <td>{% if form.id.value %}{{ form.DELETE }}{% endif %}
38
                {% for field in form %}
39
                {% if field.is_hidden %}
40
                {{field}}
41
                {% endif %}
42
                {% endfor %}
43
              </td>
44
            </tr>
45
          {% endfor %}
46
          </tbody>
47
        </table>
48
        {% endwith %}
49
      </div>
50
      {% block buttons %}
51
      <button class="enable-on-change">Modifier</button>
52
      <button id="add-form">Ajouter une ligne</button>
53
      {% endblock %}
54
    </form>
55
    <p><a href="..">{% block back-link %}Retour à la page de <span class="lastname">{{object.last_name}}</span> {{object.first_name}}{% endblock %}</a></p>
56
{% endblock %}
57

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

    
98
      $(new_row).appendTo($('#timetables'));
99
      $('#id_timetable_set-TOTAL_FORMS').val(count+1);
100
      window.calebasse_dialogs();
101
      return false;
102
    }
103
    $('#add-form').click(addForm);
104
  });
105
</script>
106
{% endblock %}
(13-13/16)