From 78657a8d75a77724b40c22c01166b5131e88d199 Mon Sep 17 00:00:00 2001 From: Phuoc CAO Date: Fri, 14 Sep 2018 15:14:25 +0200 Subject: [PATCH] ajout de planning.pt --- mondumas/models/agenda.py | 19 ++---- mondumas/routes.py | 1 + mondumas/templates/agenda/agenda.pt | 7 +- mondumas/templates/agenda/planning.pt | 41 +++++------- mondumas/templates/home.pt | 5 ++ mondumas/templates/layouts/global_layout.pt | 8 ++- mondumas/views/agenda.py | 74 ++++++++++++++++++--- 7 files changed, 102 insertions(+), 53 deletions(-) diff --git a/mondumas/models/agenda.py b/mondumas/models/agenda.py index 0e4236f..ec082d4 100644 --- a/mondumas/models/agenda.py +++ b/mondumas/models/agenda.py @@ -20,9 +20,9 @@ def execute_query(request, query, params): mark_changed(request.dbsession) transaction.commit() -def get_agendas(request): - """ lire la liste des personnes ayant un agenda""" - query = "SELECT * FROM p_users WHERE agenda <> 0 AND actif <> 0 ORDER BY nom;" +def get_users_agenda(request): + """ lire la liste des users ayant un agenda""" + query = "SELECT * FROM p_users WHERE cd_uti <> 'N' and agenda <> 0 AND actif <> 0 ORDER BY nom;" results = request.dbsession.execute(query).fetchall() return results @@ -77,18 +77,9 @@ def get_rendez_vous(request, itc): datedeb = d.strftime('%Y-%m-01') # lire les rdv de l'ITC - query = """ - (SELECT CONCAT(l.societe,"-OS-",l.no_id) as nodossier, l.rdv_debut, l.rdv_fin, e.c_nom FROM ordres_lig l - INNER JOIN ordres e ON l.societe=e.societe AND l.no_id=e.no_id - WHERE l.datevi >= :datedeb AND l.liste=:itc ORDER BY l.datevi, l.heurevi) - UNION - (SELECT CONCAT(l.societe,"-DD-",l.no_id) as nodossier, l.rdv_debut, l.rdv_fin, e.c_nom FROM dem_lig l + query = """SELECT CONCAT(l.societe,"-DD-",l.no_id) as nodossier, l.rdv_debut, l.rdv_fin, e.c_nom FROM dem_lig l INNER JOIN dem_devis e ON l.societe=e.societe AND l.no_id=e.no_id - WHERE l.datevi >= :datedeb AND l.liste=:itc ORDER BY l.datevi, l.heurevi) - UNION - (SELECT CONCAT(l.societe,"-RD-",l.no_id) as nodossier, l.rdv_debut, l.rdv_fin, e.c_nom FROM rdvous_lig l - INNER JOIN rdvous e ON l.societe=e.societe AND l.no_id=e.no_id - WHERE l.datevi >= :datedeb AND l.liste=:itc ORDER BY l.datevi, l.heurevi); + WHERE l.datevi >= :datedeb AND l.liste=:itc ORDER BY l.datevi, l.heurevi """ results = request.dbsession.execute(query, {'datedeb': datedeb, 'itc': itc}).fetchall() return results diff --git a/mondumas/routes.py b/mondumas/routes.py index a0c7ede..f4322fe 100644 --- a/mondumas/routes.py +++ b/mondumas/routes.py @@ -2,6 +2,7 @@ def includeme(config): config.add_static_view('static', 'static', cache_max_age=3600) config.add_route('home', '/') config.add_route('agenda', '/agenda') + config.add_route('planning', '/planning') config.add_route('changer_mdp', '/changer_mdp') config.add_route('dossier_view', '/dossier_view/{nodossier}') config.add_route('rdv_edit','/rdv_edit/{nodossier}/{nolig}') diff --git a/mondumas/templates/agenda/agenda.pt b/mondumas/templates/agenda/agenda.pt index cef67fd..8f38cf0 100644 --- a/mondumas/templates/agenda/agenda.pt +++ b/mondumas/templates/agenda/agenda.pt @@ -18,8 +18,10 @@

- RDV Peinture RDV Menuiserie  - RDV Plomberiee RDV Polynet  + RDV Peinture  + RDV Menuiserie  + RDV Plomberie  + RDV Plomberie 

@@ -43,6 +45,7 @@ $(document).ready(function() { right: 'today' }, defaultView: 'agendaWeek', + height: 'auto', minTime: "07:00:00", maxTime: "21:00:00", events:${fullcalendar_events}, diff --git a/mondumas/templates/agenda/planning.pt b/mondumas/templates/agenda/planning.pt index 8ad4078..c7a3d9a 100644 --- a/mondumas/templates/agenda/planning.pt +++ b/mondumas/templates/agenda/planning.pt @@ -8,23 +8,13 @@ Retour -
-
- -
-
- -
-
-

- RDV Peinture RDV Menuiserie  - RDV Plomberiee RDV Polynet  -

+

+ RDV Peinture  + RDV Menuiserie  + RDV Plomberie  + RDV Plomberie  +

@@ -39,15 +29,20 @@ - - + + + diff --git a/mondumas/views/agenda.py b/mondumas/views/agenda.py index b747191..89a53a5 100644 --- a/mondumas/views/agenda.py +++ b/mondumas/views/agenda.py @@ -99,7 +99,7 @@ def agenda(request): logged_in = request.authenticated_userid # liste des users avec agenda - agendas = get_agendas(request) + agendas = get_users_agenda(request) # le user a-t-il un agenda ? agenda = 'JMD' @@ -117,35 +117,87 @@ def agenda(request): # construire la liste des events events = [] for row in rows: - event_url = 'dossier_view/%s' % (row.nodossier) - event_title = row.c_nom - # déterminer la couleur de l'event selon la societe societe = row.nodossier[0:2] if societe == "PE": - color = "#d9534f" # rouge danger + color = "LightYellow" elif societe == "PL": - color = "#5cb85c" # vert success + color = "LightGreen" elif societe == "PO": - color = "#5bc0de" # bleu info + color = "LightBlue" else: - color = "#f0ad4e" # orange warning + color = "Gold" json_event = { - 'title': event_title, + 'title': row.c_nom, 'start': row.rdv_debut.strftime('%Y-%m-%d %H:%M:%S'), 'end': row.rdv_fin.strftime('%Y-%m-%d %H:%M:%S'), 'allDay': False, 'color': color, - 'url': event_url, + 'textColor': 'Black', + 'url': 'dossier_view/%s' % (row.nodossier), } events.append(json_event) return { - 'page_title': 'Planning', + 'page_title': 'Agenda', 'fullcalendar_events': json.dumps(events), 'agendas': agendas, 'agenda': agenda, } +@view_config(route_name='planning', renderer='../templates/agenda/planning.pt', permission='view') +def planning(request): + logged_in = request.authenticated_userid + + # construire la liste des ressources + # {"id":"a","title":"Auditorium A"} + ressources = [] + # liste des users avec agenda + users = get_users_agenda(request) + for row in users: + json_ressources = { + 'id': row.CD_UTI, + 'title': row.NOM + } + ressources.append(json_ressources) + + # construire la liste des events + events = [] + for user in users: + rows = get_rendez_vous(request, user.CD_UTI) + for row in rows: + event_url = 'dossier_view/%s' % (row.nodossier) + event_title = row.c_nom + + # déterminer la couleur de l'event selon la societe + societe = row.nodossier[0:2] + if societe == "PE": + color = "LightYellow" + elif societe == "PL": + color = "LightGreen" + elif societe == "PO": + color = "LightBlue" + else: + color = "Gold" + + json_event = { + 'resourceId': user.CD_UTI, + 'title': event_title, + 'start': row.rdv_debut.strftime('%Y-%m-%d %H:%M:%S'), + 'end': row.rdv_fin.strftime('%Y-%m-%d %H:%M:%S'), + 'allDay': False, + 'color': color, + 'textColor': 'Black', + 'url': event_url, + } + events.append(json_event) + + + return { + 'page_title': 'Planning', + 'fullcalendar_events': json.dumps(events), + 'fullcalendar_ressources': json.dumps(ressources), + } +