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
|
if (r == true)
|
39
|
{
|
40
|
$.ajax({
|
41
|
url: '/api/occurrence/' + id + '/',
|
42
|
type: 'DELETE',
|
43
|
success: function(data) {
|
44
|
window.location.reload(true);
|
45
|
}
|
46
|
});
|
47
|
}
|
48
|
}
|
49
|
$(function() {
|
50
|
$('#tabs').tabs();
|
51
|
|
52
|
$('div.agenda > div').accordion({active: false, autoHeight: false});
|
53
|
|
54
|
$('.person-item').on('click', function() {
|
55
|
toggle_worker(this);
|
56
|
});
|
57
|
// select all anchors
|
58
|
$.each(extract_anchor(), function (i, anchor) {
|
59
|
$('#'+anchor.substr(1)).each(function (i, worker_selector) { toggle_worker(worker_selector); });
|
60
|
});
|
61
|
|
62
|
$('.textedit').on('keydown', function() {
|
63
|
$('button', this).removeAttr("disabled");
|
64
|
});
|
65
|
$('.textedit button').on('click', function() {
|
66
|
var textarea = $(this).prev();
|
67
|
var span = textarea.prev()
|
68
|
var btn = $(this)
|
69
|
$.ajax({
|
70
|
url: '/api/event/' + $(this).data("event-id") + '/?format=json',
|
71
|
type: 'PATCH',
|
72
|
contentType: 'application/json',
|
73
|
data: '{"description": "' + textarea.val() + '"}',
|
74
|
success: function(data) {
|
75
|
btn.attr('disabled', 'disabled');
|
76
|
span.html('Commentaire modifiée avec succès');
|
77
|
}
|
78
|
});
|
79
|
});
|
80
|
$('.appointment').on('click', function() {
|
81
|
$('.textedit span').html('');
|
82
|
});
|
83
|
|
84
|
|
85
|
|
86
|
/* Gestion du filtre sur les utilisateurs */
|
87
|
$('#filtre input').keyup(function() {
|
88
|
var filtre = $(this).val();
|
89
|
if (filtre) {
|
90
|
$('#users li').each(function() {
|
91
|
if ($(this).text().match(filtre)) {
|
92
|
$(this).show();
|
93
|
} else {
|
94
|
$(this).hide();
|
95
|
}
|
96
|
});
|
97
|
} else {
|
98
|
$('#users li').show();
|
99
|
}
|
100
|
|
101
|
});
|
102
|
$('#agenda-date').datepicker({
|
103
|
dateFormat: "DD d MM yy",
|
104
|
onClose: function(dateText, inst) {
|
105
|
console.log('close');
|
106
|
}
|
107
|
});
|
108
|
$('#agenda-date').on('change', function () {
|
109
|
window.location.href=replace_anchor('../' + $(this).datepicker('getDate').toISOString().substr(0,10), make_anchor());
|
110
|
});
|
111
|
$('.date').datepicker({showOn: 'button'});
|
112
|
$('#add-intervenant-btn').click(function() {
|
113
|
var text = $(this).prev().val();
|
114
|
$('#intervenants ul').append('<li><input type="checkbox" value="' + text + '" checked="checked">' + text + '</input></li>');
|
115
|
$(this).prev().val('').focus();
|
116
|
return false;
|
117
|
});
|
118
|
$('#newrdv').click(function() {
|
119
|
var participants = $('.person-item.active').map(function (i, v) { return $(v).data('worker-id'); });
|
120
|
var qs = $.param({participants: $.makeArray(participants) }, true);
|
121
|
var new_appointment_url = "{% url 'nouveau-rdv' service=service date=date %}?" + qs;
|
122
|
$('#rdv').load(new_appointment_url,
|
123
|
function () {
|
124
|
function onsuccess(response, status, xhr, form) {
|
125
|
var parse = $(response);
|
126
|
if ($('.errorlist', parse).length != 0) {
|
127
|
$('#rdv').html(response);
|
128
|
$('#rdv form').ajaxForm({
|
129
|
success: onsuccess,
|
130
|
});
|
131
|
$('#rdv .datepicker-date').datepicker({dateFormat: 'yy-m-d', showOn: 'button'});
|
132
|
console.log('error');
|
133
|
} else {
|
134
|
console.log('success');
|
135
|
window.location.reload(true);
|
136
|
}
|
137
|
}
|
138
|
$('#rdv .datepicker-date').datepicker({dateFormat: 'yy-m-d', showOn: 'button'});
|
139
|
$('form', this).ajaxForm({
|
140
|
success: onsuccess
|
141
|
});
|
142
|
$(this).dialog({title: 'Nouveau rendez-vous',
|
143
|
width: '800px',
|
144
|
buttons: [ { text: "Fermer",
|
145
|
click: function() { $(this).dialog("close"); } },
|
146
|
{ text: "Ajouter",
|
147
|
click: function() { $("#rdv form").submit(); } }]});
|
148
|
});
|
149
|
});
|
150
|
});
|
151
|
</script>
|
152
|
<style>
|
153
|
.person-item span { display: none; }
|
154
|
.person-item.active span { display: inline; }
|
155
|
#agenda-date { width: 20em; }
|
156
|
</style>
|
157
|
{% endblock %}
|
158
|
|
159
|
{% block title %}{{ block.super }} - Agenda {% endblock %}
|
160
|
|
161
|
{% block header %}
|
162
|
{{ block.super }}
|
163
|
<span>Agenda - {{ service_name }}</spam>
|
164
|
{% endblock %}
|
165
|
|
166
|
{% block appbar %}
|
167
|
<h2>Agenda</h2>
|
168
|
<a href="../..">Retourner à l'accueil</a>
|
169
|
<button>Nouvel événement (autre)</button>
|
170
|
<button id="newrdv">Nouveau rendez-vous patient</button>
|
171
|
{% endblock %}
|
172
|
|
173
|
{% block beforecontent %}
|
174
|
<div id="extra-top-links">
|
175
|
<a href="activite-du-service">Activité du service</a>
|
176
|
—
|
177
|
<a href="validation-des-actes">Validation des actes</a>
|
178
|
—
|
179
|
<a href="rendez-vous-periodiques">Rendez-vous périodiques</a>
|
180
|
</div>
|
181
|
|
182
|
|
183
|
<div id="users">
|
184
|
<div id="filtre">
|
185
|
<input type="text"/>
|
186
|
</div>
|
187
|
<dl>
|
188
|
{% for workers_type in workers_types %}
|
189
|
<dt>{{ workers_type.type }}</dt>
|
190
|
<dd><ul>
|
191
|
{% for worker in workers_type.workers %}
|
192
|
<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>
|
193
|
{% endfor %}
|
194
|
</ul></dd>
|
195
|
{% endfor %}
|
196
|
</dl>
|
197
|
</div>
|
198
|
{% endblock %}
|
199
|
|
200
|
{% block content %}
|
201
|
<div class="content">
|
202
|
<div id="datesel">
|
203
|
<a href="../{{ previous_month|date:"SHORT_DATE_FORMAT"}}">««</a>
|
204
|
<a href="../{{ previous_day|date:"SHORT_DATE_FORMAT"}}">«</a>
|
205
|
<!-- <span>Jeudi 5 juillet 2012</span> -->
|
206
|
<input id="agenda-date" value="{{ date|date:"DATE_FORMAT" }}"/>
|
207
|
<a href="../{{ next_day|date:"SHORT_DATE_FORMAT"}}">»</a>
|
208
|
<a href="../{{ next_month|date:"SHORT_DATE_FORMAT"}}">»»</a>
|
209
|
</div>
|
210
|
|
211
|
<table>
|
212
|
<tbody>
|
213
|
<tr>
|
214
|
<td id="dispos">
|
215
|
Disponibilités
|
216
|
<table>
|
217
|
{% for start_time, quaters in disponibility.items %}
|
218
|
<tr class="hour-mark">
|
219
|
<td rowspan="4">{{ start_time }}:00</td>
|
220
|
{% for quater in quaters|slice:":1" %}
|
221
|
{% for value in quater %}
|
222
|
<td class="worker-{{ value.id }} agenda {{ value.dispo }}" style="display: none; "></td>
|
223
|
{% endfor %}
|
224
|
{% endfor %}
|
225
|
</tr>
|
226
|
{% for quater in quaters|slice:"1:4" %}
|
227
|
<tr>
|
228
|
{% for value in quater %}
|
229
|
<td class="worker-{{ value.id }} agenda {{ value.dispo }}" style="display: none; "></td>
|
230
|
{% endfor %}
|
231
|
</tr>
|
232
|
{% endfor %}
|
233
|
{% endfor %}
|
234
|
</table>
|
235
|
</td>
|
236
|
|
237
|
<td id="agendas">
|
238
|
<div id="tabs">
|
239
|
<ul>
|
240
|
{% for worker_agenda in workers_agenda %}
|
241
|
<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>
|
242
|
{% endfor %}
|
243
|
</ul>
|
244
|
{% for worker_agenda in workers_agenda %}
|
245
|
<div id="tabs-worker-{{ worker_agenda.worker.id }}" class="tabs agenda worker-{{ worker_agenda.worker.id }}" style="display: none;">
|
246
|
<a class="print" href="#">Imprimer</a>
|
247
|
<div>
|
248
|
{% for appointment in worker_agenda.appointments %}
|
249
|
<h3 class="{{ appointment.type }} appointment">
|
250
|
<span class="hour">{{ appointment.begin_hour }}</span>
|
251
|
{% if appointment.title %} — {{ appointment.title }} {% endif %}
|
252
|
{% if appointment.length %} — {{ appointment.length }}m {% endif %}
|
253
|
{% if appointment.workers_initial %} —{{ appointment.workers_initial }} {% endif %}
|
254
|
{% if appointment.act_type %} — {{ appointment.act_type }} {% endif %}
|
255
|
{% if appointment.room %} — {{ appointment.room }} {% endif %}
|
256
|
<span class="right">
|
257
|
{% if appointment.service and appointment.service != service %}
|
258
|
<span class="box {{ appointment.service }}" title="{{ appointment.service }}"></span>
|
259
|
{% endif %}
|
260
|
{% if appointment.convocation_sent %}
|
261
|
<img title="Une convocation a été envoyée" src="{{ STATIC_URL }}images/emblem-mail.png">
|
262
|
{% endif %}
|
263
|
{% if appointment.description %}
|
264
|
<img title="Un commentaire existe" src="{{ STATIC_URL }}images/emblem-documents.png">
|
265
|
{% endif %}
|
266
|
{% if appointment.event_id %}
|
267
|
<button type="button"><img title="Editer un rendez-vous" src="{{ STATIC_URL }}images/accessories-text-editor.png"></button>
|
268
|
<button type="button" onclick="javascript:delete_appointment({{ appointment.occurrence_id }}, '{{ appointment.title }}')"><img title="Supprimer un rendez-vous" src="{{ STATIC_URL }}images/list-remove.png"></button>
|
269
|
{% endif %}
|
270
|
</span>
|
271
|
</h3>
|
272
|
|
273
|
<div>
|
274
|
{% if appointment.type == 'free' %}<button class='booking' data-hour="{{ appointment.begin_hour }}">Prendre un rendez-vous</button> {% endif %}
|
275
|
{% if appointment.event_id %}
|
276
|
<div class="tabs-worker-{{ worker_agenda.worker.id }} textedit">
|
277
|
<span></span>
|
278
|
<textarea>{{ appointment.description }}</textarea>
|
279
|
<button disabled="disabled" data-event-id="{{ appointment.event_id }}">✔</button>
|
280
|
</div>
|
281
|
{% endif %}
|
282
|
{% if appointment.patient_record_id %}
|
283
|
<a href="/{{ service }}/dossiers/{{ appointment.patient_record_id }}">Dossier patient</a> -
|
284
|
<a href="#">Prochains rendez-vous</a> -
|
285
|
<a href="#">Convoquer patient</a>
|
286
|
{% endif %}
|
287
|
</div>
|
288
|
{% endfor %}
|
289
|
</div>
|
290
|
</div>
|
291
|
{% endfor %}
|
292
|
|
293
|
</div>
|
294
|
|
295
|
</div>
|
296
|
</td>
|
297
|
</tr>
|
298
|
</tbody>
|
299
|
</table>
|
300
|
</div>
|
301
|
|
302
|
|
303
|
{% endblock %}
|
304
|
|
305
|
{% block dialogs %}
|
306
|
<div id="rdv" style="display: none;">
|
307
|
</div>
|
308
|
{% endblock %}
|