Project

General

Profile

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

calebasse / calebasse / agenda / templates / agenda / index.html @ 4f9b8d87

1
{% extends "calebasse/base.html" %}
2
{% load url from future %}
3
{% block extrascripts %}
4
    <script>
5
      function replace_anchor(url, anchor) {
6
        var splitted = url.split('#');
7
       return splitted[0] + '#' + encodeURI(anchor);
8
      }
9
      function extract_anchor() {
10
        if (window.location.href.indexOf('#') == -1) {
11
          return "";
12
        }
13
        var splitted = window.location.href.split('#');
14
        return decodeURI(splitted[1]).split(',');
15
      }
16
      function make_anchor() {
17
        return $.makeArray($('.person-item.active').map(function (v, i) { return '_' + $(i).attr('id'); })).join(',');
18
      }
19
      function toggle_worker(worker_selector) {
20
        $(worker_selector).toggleClass('active');
21
        // update the anchor
22
        var anchor = make_anchor();
23
        var new_uri = replace_anchor(window.location.href, anchor);
24
        console.log(new_uri);
25
        window.location.href = new_uri;
26
        $('a[href^="../"]').each(function (i, a) {
27
          $(a).attr('href', replace_anchor($(a).attr('href'), anchor));
28
        });
29

    
30
        var $target = $($(worker_selector).data('target'));
31
        $target.toggle();
32
        if ($target.is(':visible')) {
33
          $target.click();
34
        }
35
      }
36
      function delete_appointment(id, title)  {
37
          var r=confirm("Etes-vous sûr de vouloir supprimer le rendez-vous "+ title + " ?");
38
      } 
39
  $(function() {
40
    $('#tabs').tabs();
41

    
42
    $('div.agenda > div').accordion({active: false, autoHeight: false});
43

    
44
    $('.person-item').on('click', function() {
45
      toggle_worker(this);
46
    });
47
    // select all anchors
48
    $.each(extract_anchor(), function (i, anchor) {
49
      $('#'+anchor.substr(1)).each(function (i, worker_selector) { toggle_worker(worker_selector); });
50
    });
51

    
52
    $('.textedit').on('keydown', function() {
53
        $('button', this).removeAttr("disabled");
54
    });
55
    $('.textedit button').on('click', function() {
56
        var textarea = $(this).prev();
57
        var span = textarea.prev()
58
        var btn = $(this)
59
        $.ajax({
60
            url: '/api/event/' + $(this).data("event-id") + '/?format=json',
61
            type: 'PATCH',
62
            contentType: 'application/json',
63
            data: '{"description": "' + textarea.val() + '"}',
64
            success: function(data) {
65
                btn.attr('disabled', 'disabled');
66
                span.html('Commentaire modifiée avec succès');
67
            }
68
        });
69
    });
70
    $('.appointment').on('click', function() {
71
        $('.textedit span').html('');
72
    });
73

    
74

    
75

    
76
    /* Gestion du filtre sur les utilisateurs */
77
		$('#filtre input').keyup(function() {
78
			var filtre = $(this).val();
79
      if (filtre) {
80
        $('#users li').each(function() {
81
          if ($(this).text().match(filtre)) {
82
            $(this).show();
83
          } else {
84
            $(this).hide();
85
          }
86
        });
87
      } else {
88
        $('#users li').show();
89
      }
90

    
91
		});
92
    $('#agenda-date').datepicker({
93
      dateFormat: "DD d MM yy",
94
      onClose: function(dateText, inst) {
95
        console.log('close');
96
      }
97
    });
98
    $('#agenda-date').on('change', function () {
99
      window.location.href=replace_anchor('../' + $(this).datepicker('getDate').toISOString().substr(0,10), make_anchor());
100
    });
101
		$('.date').datepicker({showOn: 'button'});
102
		$('#add-intervenant-btn').click(function() {
103
			var text = $(this).prev().val();
104
			$('#intervenants ul').append('<li><input type="checkbox" value="' + text + '" checked="checked">' + text + '</input></li>');
105
			$(this).prev().val('').focus();
106
			return false;
107
		});
108
    $('#newrdv').click(function() {
109
      var participants = $('.person-item.active').map(function (i, v) { return $(v).data('worker-id'); });
110
      var qs = $.param({participants: $.makeArray(participants) }, true);
111
      var new_appointment_url = "{% url 'nouveau-rdv' service=service date=date %}?" + qs;
112
      $('#rdv').load(new_appointment_url,
113
        function () {
114
          function onsuccess(response, status, xhr, form) {
115
            var parse = $(response);
116
            if ($('.errorlist', parse).length != 0) {
117
              $('#rdv').html(response);
118
              $('#rdv form').ajaxForm({
119
                success: onsuccess,
120
              });
121
              $('#rdv .datepicker-date').datepicker({dateFormat: 'yy-m-d', showOn: 'button'});
122
              console.log('error');
123
            } else {
124
              console.log('success');
125
              window.location.reload(true);
126
            }
127
          }
128
          $('#rdv .datepicker-date').datepicker({dateFormat: 'yy-m-d', showOn: 'button'});
129
          $('form', this).ajaxForm({
130
            success: onsuccess
131
          });
132
          $(this).dialog({title: 'Nouveau rendez-vous',
133
              width: '800px',
134
              buttons: [ { text: "Fermer",
135
                     click: function() { $(this).dialog("close"); } },
136
                   { text: "Ajouter",
137
                     click: function() { $("#rdv form").submit(); } }]});
138
      });
139
    });
140
	});
141
	</script>
142
  <style>
143
    .person-item span { display: none; }
144
    .person-item.active span { display: inline; }
145
    #agenda-date { width: 20em; }
146
  </style>
147
{% endblock %}
148

    
149
{% block title %}{{ block.super }} - Agenda {% endblock %}
150

    
151
{% block header %}
152
  {{ block.super }}
153
  <span>Agenda - {{ service_name }}</spam>
154
{% endblock %}
155

    
156
{% block appbar %}
157
    <h2>Agenda</h2>
158
    <a href="../..">Retourner à l'accueil</a>
159
    <button>Nouvel événement (autre)</button>
160
    <button id="newrdv">Nouveau rendez-vous patient</button>
161
{% endblock %}
162

    
163
{% block beforecontent %}
164
    <div id="extra-top-links">
165
     <a href="activite-du-service">Activité du service</a>
166
167
     <a href="validation-des-actes">Validation des actes</a>
168
169
     <a href="rendez-vous-periodiques">Rendez-vous périodiques</a>
170
    </div>
171

    
172

    
173
    <div id="users">
174
    <div id="filtre">
175
     <input type="text"/>
176
    </div>
177
    <dl>
178
     {% for workers_type in workers_types %}
179
     <dt>{{ workers_type.type }}</dt>
180
     <dd><ul>
181
       {% for worker in workers_type.workers %}
182
       <li id="selector-worker-{{worker.id}}" class="person-item" data-worker-id="{{worker.id}}" data-target=".worker-{{worker.id}}.agenda">{{ worker.display_name }} <span title="cliquer pour déselectionner">(-)</span></li>
183
       {% endfor %}
184
     </ul></dd>
185
     {% endfor %}
186
   </dl>
187
 </div>
188
{% endblock %}
189

    
190
{% block content %}
191
<div class="content">
192
   <div id="datesel">
193
     <a href="../{{ previous_month|date:"SHORT_DATE_FORMAT"}}">««</a>
194
     <a href="../{{ previous_day|date:"SHORT_DATE_FORMAT"}}">«</a>
195
   <!-- <span>Jeudi 5 juillet 2012</span> -->
196
   <input id="agenda-date" value="{{ date|date:"DATE_FORMAT" }}"/>
197
   <a href="../{{ next_day|date:"SHORT_DATE_FORMAT"}}">»</a>
198
   <a href="../{{ next_month|date:"SHORT_DATE_FORMAT"}}">»»</a>
199
   </div>
200

    
201
   <table>
202
    <tbody>
203
    <tr>
204
     <td id="dispos">
205
      Disponibilités
206
      <table>
207
        {% for start_time, quaters in disponibility.items %}
208
          <tr class="hour-mark">
209
              <td rowspan="4">{{ start_time }}:00</td>
210
              {% for quater in quaters|slice:":1" %}
211
                {% for value in quater %}
212
                <td class="worker-{{ value.id }} agenda {{ value.dispo }}" style="display: none; "></td>
213
                {% endfor %}
214
              {% endfor %}
215
          </tr>
216
          {% for quater in quaters|slice:"1:4" %}
217
            <tr>
218
              {% for value in quater %}
219
                <td class="worker-{{ value.id }} agenda {{ value.dispo }}" style="display: none; "></td>
220
              {% endfor %}
221
            </tr>
222
          {% endfor %}
223
        {% endfor %}
224
      </table>
225
     </td>
226

    
227
     <td id="agendas">
228
       <div id="tabs">
229
       <ul>
230
        {% for worker_agenda in workers_agenda %}
231
           <li><a href="#tabs-worker-{{ worker_agenda.worker.id }}" class="worker-{{ worker_agenda.worker.id }} agenda" style="display: none;">{{ worker_agenda.worker.display_name }}</a></li>
232
        {% endfor %}
233
       </ul>
234
       {% for worker_agenda in workers_agenda %}
235
       <div id="tabs-worker-{{ worker_agenda.worker.id }}" class="tabs agenda worker-{{ worker_agenda.worker.id }}" style="display: none;">
236
         <a class="print" href="#">Imprimer</a>
237
         <div>
238
           {% for appointment in worker_agenda.appointments %}
239
           <h3 class="{{ appointment.type }} appointment"><span class="hour">{{ appointment.begin_hour }}</span>
240
             {% if appointment.title %} — {{ appointment.title }}  {% endif %}
241
             {% if appointment.length %} — {{ appointment.length }}m {% endif %}
242
             {% if appointment.workers_initial %} —{{ appointment.workers_initial }} {% endif %}
243
             {% if appointment.act_type %} — {{ appointment.act_type }} {% endif %}
244
             {% if appointment.room %} — {{ appointment.room }} {% endif %}
245
             <span class="right">
246
                 {% if appointment.service and appointment.service != service %}
247
                 <span class="box {{ appointment.service }}" title="{{ appointment.service }}"></span>
248
                 {% endif %}
249
                 {% if appointment.convocation_sent %}
250
                 <img title="Une convocation a été envoyée" src="{{ STATIC_URL }}images/emblem-mail.png">
251
                 {% endif %}
252
                 {% if appointment.description %}
253
                 <img title="Un commentaire existe" src="{{ STATIC_URL }}images/emblem-documents.png">
254
                 {% endif %}
255
                 {% if appointment.event_id %}
256
                 <button type="button"><img title="Editer un rendez-vous" src="{{ STATIC_URL }}images/accessories-text-editor.png"></button>
257
                 <button type="button" onclick="javascript:delete_appointment({{ appointment.event_id }}, '{{ appointment.title }}')"><img title="Supprimer un rendez-vous" src="{{ STATIC_URL }}images/list-remove.png"></button>
258
                 {% endif %}
259
            </span>
260
           </h3>
261

    
262
           <div>
263
             {% if appointment.type == 'free' %}<button class='booking' data-hour="{{ appointment.begin_hour }}">Prendre un rendez-vous</button> {% endif %}
264
             {% if appointment.event_id %}
265
             <div class="tabs-worker-{{ worker_agenda.worker.id }} textedit">
266
                 <span></span>
267
                 <textarea>{{ appointment.description }}</textarea>
268
                 <button disabled="disabled" data-event-id="{{ appointment.event_id }}"></button>
269
             </div>
270
             {% endif %}
271
             {% if appointment.patient_record_id %}
272
             <a href="/{{ service }}/dossiers/{{ appointment.patient_record_id }}">Dossier patient</a> -
273
             <a href="#">Prochains rendez-vous</a> -
274
             <a href="#">Convoquer patient</a>
275
             {% endif %}
276
           </div>
277
           {% endfor %}
278
         </div>
279
       </div>
280
       {% endfor %}
281

    
282
       </div>
283

    
284
       </div>
285
     </td>
286
    </tr>
287
    </tbody>
288
   </table>
289
 </div>
290

    
291

    
292
{% endblock %}
293

    
294
{% block dialogs %}
295
  <div id="rdv" style="display: none;">
296
 </div>
297
{% endblock %}
(2-2/3)