Project

General

Profile

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

calebasse / calebasse / personnes / templates / personnes / worker_schedule_update.html @ 27d50e46

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

    
3
{% block extrascripts %}
4
{{ block.super }}
5
<script>
6
  $(function () {
7
    $('td.service ul').checkboxwidget({allCaption: "Tous"});
8
    $('td.periodicity').each(function (i, e) {
9
      var $divmenu = $('> div', e).divmenu();
10
      var $inputs = $('input, select', $divmenu);
11
      var f = function () {
12
        $('div .eo-divmenu-element', e).each(function (i, v) {
13
          if ($('select, input', v).val()) {
14
            console.log(i);
15
            $divmenu.divmenu('select', i);
16
          }
17
        });
18
      };
19
      f();
20
      $divmenu.on('change', 'select', function () {
21
        f();
22
      });
23
      var timeout;
24
      $divmenu.on('mouseenter', function () {
25
        $divmenu.divmenu('open');
26
      });
27
      $divmenu.on('mouseleave', function (e) {
28
        if ((typeof e.fromElement != 'undefined' && !e.fromElement.length) ||
29
          (typeof e.fromElement == 'undefined' && e.target.tagName != 'SELECT')) {
30
          $divmenu.divmenu('close');
31
        }
32
      });
33
      $inputs.focusin(function () {
34
        clearTimeout(timeout);
35
        $divmenu.divmenu('open');
36
      });
37
      $inputs.focusout(function () {
38
        timeout = setTimeout(function () {
39
          $divmenu.divmenu('close');
40
        }, 300);
41
      });
42
    });
43
  });
44
</script>
45
<style>
46
</style>
47
{% endblock %}
48

    
49
{% block appbar %}
50
<h2>Horaire du {{weekday}} de <span class="lastname">{{object.last_name}}</span> {{object.first_name}}</h2>
51
  <a href="..">Retour à la page de <span class="lastname">{{object.last_name}}</span> {{object.first_name}}</a>
52
{% endblock %}
53

    
54

    
55
{% block content %}
56
    <form method="post">
57
      <div id="form-content">
58
        {% csrf_token %}
59
        {% with formset=form %}
60
        {{ formset.management_form }}
61
        <p>Le format des dates est jj/mm/aaaa.</p>
62
        <table id="schedules" class="inline">
63
          <thead>
64
            <tr>
65
              <td><label class="required">Services</label></td>
66
              <td><label class="required">Heure de début</label></td>
67
              <td><label class="required">Heure de fin</label></td>
68
              <td><label class="required">Date de début</label></td>
69
              <td><label>Date de fin</label></td>
70
              <td><label>Périodicité</label></td>
71
              <td><label>Supprimer</label></td>
72
            </tr>
73
          </thead>
74
          <tbody id="timetables">
75
          {% for form in formset %}
76
            {% if form.non_field_errors %}
77
            <tr>
78
              <td colspan="6">
79
                <p class="error">{{ form.non_field_errors }}</p>
80
              </td>
81
             {% endif %}
82
            <tr class="timetable">
83
              <td class="service">{{ form.services }}{{ form.services.errors }}</td>
84
              <td class="timepicker">{{ form.start_time }}{{ form.start_time.errors }}</td>
85
              <td class="timepicker">{{ form.end_time }}{{ form.end_time.errors }}</td>
86
              <td id="start-{{ forloop.counter0 }}" class="datepicker" data-before-selector="#end-{{ forloop.counter0 }}" data-number-of-months="3">{{ form.start_date }}{{ form.start_date.errors }}</td>
87
              <td id="end-{{ forloop.counter0 }}" class="datepicker" data-after-selector="#start-{{ forloop.counter0 }}" data-number-of-months="3">{{ form.end_date }}{{ form.end_date.errors }}</td>
88
              <td>{{ form.periodicity }}{{ form.periodicity.errors }}</td>
89
              <td>{% if form.id.value %}{{ form.DELETE }}{% endif %}
90
                {% for field in form %}
91
                {% if field.is_hidden %}
92
                {{field}}
93
                {% endif %}
94
                {% endfor %}
95
              </td>
96
            </tr>
97
          {% endfor %}
98
          </tbody>
99
        </table>
100
        {% endwith %}
101
      </div>
102
      {% block buttons %}
103
      <button class="enable-on-change">Modifier</button>
104
      <button id="add-form">Ajouter une ligne</button>
105
      {% endblock %}
106
<!--      <a href="..">{% block back-link %}Retour{% endblock %}</a>-->
107
    </form>
108
{% endblock %}
109

    
110
{% block page-end %}
111
{{ block.super }}
112
<script>
113
  $(function () {
114
    var completions = [];
115
    for (var i = 8*60; i < 21*60; i += 15) {
116
      var completion = ''
117
      var hour = Math.floor(i/60);
118
      var minute = i % 60;
119
      var c = function (v) {
120
        if (v < 10) {
121
          return '0'+v;
122
        }
123
        return v;
124
      }
125
      completions.push(''+c(hour)+':'+c(minute));
126
    }
127
    $('.timepicker input').autocomplete({delay:0, source: completions, minLength: 0});
128
    function addForm() {
129
      var count = $('.timetable').length
130
      var new_row = $('.timetable:first').clone(false).get(0);
131
      $('input', new_row).val('');
132
      $('input, select', new_row).each(function (i, v) {
133
        v.name = v.name.replace('-0-', '-' + count + '-');
134
      });
135
      $('.delete input[type="checkbox"]', new_row).remove();
136
      $('*', new_row).each(function (i, v) {
137
        if (v.id) {
138
          v.id = v.id.replace('-0', '-' + count);
139
          if ($(v).data('before-selector')) {
140
            var old_value = $(v).data('before-selector');
141
            $(v).data('before-selector', old_value.replace('-0', '-' + count));
142
          }
143
          if ($(v).data('after-selector')) {
144
            var old_value = $(v).data('after-selector');
145
            $(v).data('after-selector', old_value.replace('-0', '-' + count));
146
          }
147
        }
148
      });
149

    
150
      $(new_row).appendTo($('#timetables'));
151
      $('#id_timetable_set-TOTAL_FORMS').val(count+1);
152
      window.calebasse_dialogs();
153
      return false;
154
    }
155
    $('#add-form').click(addForm);
156
  });
157
</script>
158
{% endblock %}
(11-11/13)