Rapport employés sans contrats
authorJean-Philippe Caissy <jpcaissy@piji.ca>
Tue, 21 Feb 2012 21:17:42 +0000 (15:17 -0600)
committerJean-Philippe Caissy <jpcaissy@piji.ca>
Tue, 21 Feb 2012 21:17:42 +0000 (15:17 -0600)
project/menu.py
project/rh/templates/rh/rapports/employes_sans_contrat.html [new file with mode: 0644]
project/rh/urls.py
project/rh/views.py

index 9428130..57399bd 100644 (file)
@@ -44,6 +44,7 @@ class CustomMenu(Menu):
                                children=[
                                    #items.MenuItem('Rapport des postes', reverse('rhr_postes')),
                                    items.MenuItem('Rapport des contrats', reverse('rhr_contrats')),
+                                   items.MenuItem(u'Rapport des employés sans contrat', reverse('rhr_employe_sans_contrat')),
                                    #items.MenuItem('Rapport de rémunération', reverse('rhr_remuneration')),
                                    items.MenuItem('Rapport des postes par service', reverse('rhr_postes_service')),
                                    items.MenuItem('Rapport des postes par implantation', reverse('rhr_postes_implantation')),
diff --git a/project/rh/templates/rh/rapports/employes_sans_contrat.html b/project/rh/templates/rh/rapports/employes_sans_contrat.html
new file mode 100644 (file)
index 0000000..fa1ae86
--- /dev/null
@@ -0,0 +1,42 @@
+{% extends 'rh/rapports/base.html' %}
+{% load adminmedia rapports i18n change_list %}
+
+{% block extrastyle %}
+<script type="text/javascript" src="/admin/jsi18n"></script>
+<script type="text/javascript" src="{{ STATIC_URL }}/admin/js/core.js"></script>
+{{ block.super }}
+{% endblock %}
+
+{% block nomrapport %}Rapport Contrats{% endblock %}
+
+{% block count_elements %}<h2>{{ count }} contrats pour {{ count_employe }} employés</h2>{% endblock %}
+
+{% block contentrapport %}
+
+<div id="changelist-filter">
+<h2>{% trans 'Filter' %}</h2>
+{% filter_region_contrat %}
+{% filter_implantation_contrat %}
+</div>
+
+<table id="result_list" class="results">
+<thead>
+<tr>
+    {% table_header headers %}
+</tr>
+</thead>
+{% spaceless %}{% for c in employes %}
+<tr class="{% cycle 'row1' 'row2' %}">
+    <td>{{ c.employe.id }}</td>
+    <td>{{ c.employe.nom }}</td>
+    <td>{{ c.employe.prenom }}</td>
+    <td>
+        {% for d in c.dossiers %}
+        {{ d }}
+        {% endfor %}
+    </td>
+</tr>
+{% endfor %}{% endspaceless %}
+</table>
+
+{% endblock %}
index 970fa8e..8d1654b 100644 (file)
@@ -5,6 +5,7 @@ from django.conf.urls.defaults import patterns, url
 urlpatterns = patterns(
     'project.rh.views',
     url(r'^admin/rh/rapports/postes$', 'rapports_poste', name='rhr_postes'),
+    url(r'^admin/rh/rapports/employes_sans_contrats$', 'rapports_employe_sans_contrat', name='rhr_employe_sans_contrat'),
     url(r'^admin/rh/rapports/contrats$', 'rapports_contrat', name='rhr_contrats'),
     url(r'^admin/rh/rapports/remuneration$', 'rapports_remuneration', name='rhr_remuneration'),
     url(r'^admin/rh/rapports/postes_par_service$', 'rapports_postes_service', name='rhr_postes_service'),
index 4c9d4da..31a7dc4 100644 (file)
@@ -289,6 +289,52 @@ def rapports_remuneration(request):
 
 @login_required
 @drh_or_admin_required
+def rapports_employe_sans_contrat(request):
+
+    lookup_params = dict(request.GET.items())
+    if 'ot' in lookup_params:
+        del lookup_params['ot']
+    if 'o' in lookup_params:
+        del lookup_params['o']
+
+    for key, value in lookup_params.items():
+        if not isinstance(key, str):
+            # 'key' will be used as a keyword argument later, so Python
+            # requires it to be a string.
+            del lookup_params[key]
+            lookup_params[smart_str(key)] = value
+
+    employes_query = rh.Employe.objects
+    if 'o' in request.GET:
+        employes_query = employes_query.order_by("%s%s" % ('-' if 'ot' in request.GET and request.GET['ot'] == "desc" else '', request.GET['o']))
+
+    employes = []
+    for e in employes_query.all():
+        dossiers = e.rh_dossiers.filter(Q(date_fin=None) | Q(date_fin__gt=date.today())).all()
+        for d in dossiers:
+            contrats = rh.Contrat.objects.filter(Q(dossier=d) & Q(date_fin__lt=date.today())).all()
+            if contrats:
+                employes.append({'employe': e, 'dossiers': dossiers})
+
+    headers = [
+        ("dossier__employe__id", u"# de l'employé"),
+        ("dossier__employe__nom", u"Nom"),
+        ("dossier__employe__prenom", u"Prénom"),
+        ("", u"Dossiers"),
+    ]
+    h = SortHeaders(request, headers, order_field_type="ot", order_field="o")
+
+    c = {
+        'title': u'Rapport des employés sans contrat',
+        'employes': employes,
+        'count': len(employes),
+        'headers': list(h.headers()),
+    }
+
+    return render_to_response('rh/rapports/employes_sans_contrat.html', c, RequestContext(request))
+
+@login_required
+@drh_or_admin_required
 def rapports_postes_modelisation(request):
     c = {}
     data = []