Project

General

Profile

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

calebasse / calebasse / agenda / templates / agenda / index.html @ 41dfa4b8

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() {
37
    $('#tabs').tabs();
38

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

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

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

    
69

    
70
    /* Gestion du filtre sur les utilisateurs */
71
		$('#filtre input').keyup(function() {
72
			var filtre = $(this).val();
73
      if (filtre) {
74
        $('#users li').each(function() {
75
          if ($(this).text().match(filtre)) {
76
            $(this).show();
77
          } else {
78
            $(this).hide();
79
          }
80
        });
81
      } else {
82
        $('#users li').show();
83
      }
84

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

    
143
{% block title %}{{ block.super }} - Agenda {% endblock %}
144

    
145
{% block header %}
146
  {{ block.super }}
147
  <span>Agenda - {{ service_name }}</spam>
148
{% endblock %}
149

    
150
{% block appbar %}
151
    <h2>Agenda</h2>
152
    <a href="../..">Retourner à l'accueil</a>
153
    <button>Nouvel événement (autre)</button>
154
    <button id="newrdv">Nouveau rendez-vous patient</button>
155
{% endblock %}
156

    
157
{% block beforecontent %}
158
    <div id="extra-top-links">
159
     <a href="activite-du-service">Activité du service</a>
160
161
     <a href="validation-des-actes">Validation des actes</a>
162
163
     <a href="rendez-vous-periodiques">Rendez-vous périodiques</a>
164
    </div>
165

    
166

    
167
    <div id="users">
168
    <div id="filtre">
169
     <input type="text"/>
170
    </div>
171
    <dl>
172
     {% for workers_type in workers_types %}
173
     <dt>{{ workers_type.type }}</dt>
174
     <dd><ul>
175
       {% for worker in workers_type.workers %}
176
       <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>
177
       {% endfor %}
178
     </ul></dd>
179
     {% endfor %}
180
   </dl>
181
 </div>
182
{% endblock %}
183

    
184
{% block content %}
185
<div class="content">
186
   <div id="datesel">
187
     <a href="../{{ previous_month|date:"SHORT_DATE_FORMAT"}}">««</a>
188
     <a href="../{{ previous_day|date:"SHORT_DATE_FORMAT"}}">«</a>
189
   <!-- <span>Jeudi 5 juillet 2012</span> -->
190
   <input id="agenda-date" value="{{ date|date:"DATE_FORMAT" }}"/>
191
   <a href="../{{ next_day|date:"SHORT_DATE_FORMAT"}}">»</a>
192
   <a href="../{{ next_month|date:"SHORT_DATE_FORMAT"}}">»»</a>
193
   </div>
194

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

    
221
     <td id="agendas">
222
       <div id="tabs">
223
       <ul>
224
        {% for worker_agenda in workers_agenda %}
225
           <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>
226
        {% endfor %}
227
       </ul>
228
       {% for worker_agenda in workers_agenda %}
229
       <div id="tabs-worker-{{ worker_agenda.worker.id }}" class="tabs agenda worker-{{ worker_agenda.worker.id }}" style="display: none;">
230
         <a class="print" href="#">Imprimer</a>
231
         <div>
232
           {% for appointment in worker_agenda.appointments %}
233
           <h3 class="{{ appointment.type }} appointment"><span class="hour">{{ appointment.begin_hour }}</span>
234
             {% if appointment.title %} — {{ appointment.title }}  {% endif %}
235
             {% if appointment.length %} — {{ appointment.length }}m {% endif %}
236
             {% if appointment.workers_initial %} —{{ appointment.workers_initial }} {% endif %}
237
             {% if appointment.act_type %} — {{ appointment.act_type }} {% endif %}
238
             {% if appointment.room %} — {{ appointment.room }} {% endif %}
239
             <span class="right">
240
                 {% if appointment.service and appointment.service != service %}
241
                 <span class="box {{ appointment.service }}" title="{{ appointment.service }}"></span>
242
                 {% endif %}
243
                 {% if appointment.convocation_sent %}
244
                 <img title="Une convocation a été envoyée" src="{{ STATIC_URL }}images/emblem-mail.png">
245
                 {% endif %}
246
                 {% if appointment.description %}
247
                 <img title="Un commentaire existe" src="{{ STATIC_URL }}images/emblem-documents.png">
248
                 {% endif %}
249
            </span>
250
           </h3>
251

    
252
           <div>
253
             {% if appointment.type == 'free' %}<button class='booking' data-hour="{{ appointment.begin_hour }}">Prendre un rendez-vous</button> {% endif %}
254
             {% if appointment.event_id %}
255
             <div class="tabs-worker-{{ worker_agenda.worker.id }} textedit">
256
                 <span></span>
257
                 <textarea>{{ appointment.description }}</textarea>
258
                 <button disabled="disabled" data-event-id="{{ appointment.event_id }}"></button>
259
             </div>
260
             {% endif %}
261
             {% if appointment.patient_record_id %}
262
             <a href="/{{ service }}/dossiers/{{ appointment.patient_record_id }}">Dossier patient</a> -
263
             <a href="#">Prochains rendez-vous</a> -
264
             <a href="#">Convoquer patient</a>
265
             {% endif %}
266
           </div>
267
           {% endfor %}
268
         </div>
269
       </div>
270
       {% endfor %}
271

    
272
       </div>
273

    
274
       </div>
275
     </td>
276
    </tr>
277
    </tbody>
278
   </table>
279
 </div>
280

    
281

    
282
{% endblock %}
283

    
284
{% block dialogs %}
285
  <div id="rdv" style="display: none;">
286
 </div>
287
{% endblock %}
(2-2/3)