From f039bf200d5ce0e8bede639d174a706eca607635 Mon Sep 17 00:00:00 2001 From: Serghei MIHAI Date: Fri, 18 Jul 2014 11:09:39 +0200 Subject: [PATCH] agenda: display a summary of service activity Closes #2735 --- calebasse/agenda/appointments.py | 14 +++++- .../templates/agenda/agendas-therapeutes.html | 47 +++++++++++++++++-- calebasse/agenda/views.py | 10 +++-- calebasse/static/css/agenda.css | 52 +++++++++++++++++++++- calebasse/static/css/print.css | 10 ++++- 5 files changed, 123 insertions(+), 10 deletions(-) diff --git a/calebasse/agenda/appointments.py b/calebasse/agenda/appointments.py index 713cbb4..8580096 100644 --- a/calebasse/agenda/appointments.py +++ b/calebasse/agenda/appointments.py @@ -138,6 +138,7 @@ def get_daily_appointments(date, worker, service, time_tables, events, holidays) """ """ appointments = [] + activity = {'absences': []} timetables_set = IntervalSet((t.to_interval(date) for t in time_tables)) holidays_set = IntervalSet((h.to_interval(date) for h in holidays)) @@ -158,6 +159,13 @@ def get_daily_appointments(date, worker, service, time_tables, events, holidays) validation_states.pop('VALIDE') validation_states.pop('ACT_LOST') validation_states = vs + sorted(validation_states.items(), key=lambda tup: tup[0]) + + events.sort(key=lambda event: event.start_datetime) + + # get first and last events start times + if events: + activity['first_appointment'], activity['last_appointment'] = (e.start_datetime.time() for e in (events[0], events[-1])) + for event in events: appointment = Appointment() appointment.init_from_event(event, service, validation_states) @@ -173,10 +181,12 @@ def get_daily_appointments(date, worker, service, time_tables, events, holidays) label = u"Absence de groupe : %s" % holiday.holiday_type.name else: label = u"Absence indiv. : %s" % holiday.holiday_type.name + appointment.init_holiday_time(label, delta_minutes, time(interval.lower_bound.hour, interval.lower_bound.minute), description=holiday.comment) + activity['absences'].append(label) services = holiday.services.all() if service not in services: appointment.type = 'busy-elsewhere' @@ -195,14 +205,16 @@ def get_daily_appointments(date, worker, service, time_tables, events, holidays) end_time = interval_set.upper_bound() appointment = Appointment() appointment.init_start_stop(u"Arrivée", start_time) + activity['arrival'] = start_time appointment.weight = -1 appointments.append(appointment) appointment = Appointment() appointment.init_start_stop(u"Départ", end_time) + activity['departure'] = end_time appointment.weight = 1 appointments.append(appointment) - return sorted(appointments, key=lambda app: (app.begin_time, app.weight, app.event_id)) + return activity, sorted(appointments, key=lambda app: (app.begin_time, app.weight, app.event_id)) def get_daily_usage(date, ressource, service, occurrences): """ diff --git a/calebasse/agenda/templates/agenda/agendas-therapeutes.html b/calebasse/agenda/templates/agenda/agendas-therapeutes.html index c49d5ab..ff7b132 100644 --- a/calebasse/agenda/templates/agenda/agendas-therapeutes.html +++ b/calebasse/agenda/templates/agenda/agendas-therapeutes.html @@ -5,14 +5,43 @@ {% block appbar %}

Tous les agendas des intervenants du {{ service_name }} - {{ date|date:"DATE_FORMAT"|title }}

Retourner à l'agenda - {% endblock %} {% block agenda-content %} - - - +
+ +
+ {{ service_name }}: {{ date|date:"DATE_FORMAT"|title }} +

Activité du personnel

+ + + + + + + + +{% for worker_agenda in workers_agenda %} + + + + + + +{% endfor %} + +
NomArrivéePremier rendez-vousDernier rendez-vousDépartAbsences
{{ worker_agenda.worker.first_name}} {{ worker_agenda.worker.last_name }}{{ worker_agenda.activity.arrival }}{{ worker_agenda.activity.first_appointment }}{{ worker_agenda.activity.last_appointment }}{{ worker_agenda.activity.departure }}{% for absence in worker_agenda.activity.absences %} + {{ absence }}
+ {% endfor %} +
+
+
+ + + + + {% for worker_agenda in workers_agenda %} {% if worker_agenda.appointments %}
@@ -88,6 +117,7 @@ update_page_break(); $('button#print-button-therapeutes').click(function() { + $('div#activity').addClass('screen-only'); $.each($(".printable"), function(k, v) { if ($(v).is(':checked')) { $(v).parents('.worker-agenda').removeClass('screen-only'); @@ -99,6 +129,15 @@ window.print(); }); + $('button#print-button-therapeutes-activity').click(function() { + $('div#activity').removeClass('screen-only'); + $.each($('.content div:not(#activity)'), function(k, v) { + $(v).addClass('screen-only'); + }); + update_page_break(); + window.print(); + }); + $('#uncheck-all').on('click', function () { $('.printable').attr('checked', false); $('.printable').trigger('change'); diff --git a/calebasse/agenda/views.py b/calebasse/agenda/views.py index 05f8fe7..9f97d25 100644 --- a/calebasse/agenda/views.py +++ b/calebasse/agenda/views.py @@ -509,12 +509,14 @@ class AgendasTherapeutesView(AgendaHomepageView): events_workers[worker.id] = events_worker time_tables_workers[worker.id] = time_tables_worker holidays_workers[worker.id] = holidays_worker - daily_appointments = get_daily_appointments(context['date'], worker, self.service, + activity, daily_appointments = get_daily_appointments(context['date'], worker, self.service, time_tables_worker, events_worker, holidays_worker) if all(map(lambda x: x.holiday, daily_appointments)): continue + context['workers_agenda'].append({'worker': worker, 'appointments': daily_appointments, + 'activity': activity, 'has_events': True if events_worker else False}) for worker_agenda in context.get('workers_agenda', []): @@ -584,10 +586,12 @@ class AjaxWorkerTabView(TemplateView): 'exceptions', 'participants') events = [ e.today_occurrence(self.date) for e in events ] \ + [ e.today_occurrence(self.date) for e in eventswithact ] + activity, appointments = get_daily_appointments(context['date'], worker, + self.service, time_tables_worker, + events, holidays_worker) context['worker_agenda'] = {'worker': worker, - 'appointments': get_daily_appointments(context['date'], worker, self.service, - time_tables_worker, events, holidays_worker)} + 'appointments': appointments} if settings.RTF_TEMPLATES_DIRECTORY: context['mail'] = True diff --git a/calebasse/static/css/agenda.css b/calebasse/static/css/agenda.css index f8f5712..f4961ed 100644 --- a/calebasse/static/css/agenda.css +++ b/calebasse/static/css/agenda.css @@ -1,3 +1,7 @@ +br.clear { + clear: both; +} + td#dispos { vertical-align: top; } @@ -27,6 +31,21 @@ td#dispos h5 { display: block; } +.icon-print:before { + content: "\f02f"; + margin-right: 5px; +} + +.icon-check:before { + content: "\f046"; + margin-right: 5px; +} + +.icon-uncheck:before { + content: "\f096"; + margin-right: 5px; +} + #users .icon-toggle { float: right; display: none; @@ -222,7 +241,7 @@ ul.addresses { button.screen-only { margin: 1em 0; - float: right; + /* float: right; */ } h3 .icon-comment { @@ -231,4 +250,35 @@ h3 .icon-comment { .worker-agenda { margin-top: 2em; +} + +#activity { + float: right; + font-size: .8em; + margin-bottom: 2em; +} + +#activity h3 { + background: #eee; + border: 1px solid #aaa; + padding: 2px 5px; + margin:0; + border-bottom: 0; +} + +#activity table { + border-collapse: collapse; +} + +#activity .header { + display: none; +} + +#activity table td, #activity table th { + border: 1px solid #bbb; + padding: 2px 5px; +} + +#activity #print-button-therapeutes-activity { + float: right; } \ No newline at end of file diff --git a/calebasse/static/css/print.css b/calebasse/static/css/print.css index ae4ff1e..e594e29 100644 --- a/calebasse/static/css/print.css +++ b/calebasse/static/css/print.css @@ -43,7 +43,7 @@ div.worker-agenda table{ font-size: 70%; } -table#activity{ +table#activity, div#activity { font-size: 80%; } @@ -82,3 +82,11 @@ div.page-header { position: fixed; top: 0; } + +div#activity { + float: left; +} + +div#activity .header { + display: block; +} \ No newline at end of file -- 2.0.1