Project

General

Profile

« Previous | Next » 

Revision feffc421

Added by Serghei Mihai over 10 years ago

dossiers: display anap quotations and filter by them

Closes #5011

View differences:

calebasse/dossiers/templates/dossiers/index.html
51 51
  </div>
52 52
    <br>
53 53
  <div>
54
    <a href="quotations">Page des quotations</a><br/>
54
    <a href="quotations">Quotations et déficiences</a><br/>
55 55
    <a href="waiting-queue">Liste d'attente</a>
56 56
  </div>
57 57
</div>
calebasse/dossiers/templates/dossiers/quotations.html
2 2
{% load url from future %}
3 3

  
4 4
{% block appbar %}
5
    <h2>Dossiers</h2>
6
    <a href=".">Retourner aux dossiers</a>
7
    <button id='print-button'>Imprimer</button>
5
<h2>Dossiers</h2>
6
<a href=".">Retourner aux dossiers</a>
7
<button id='print-button'>Imprimer</button>
8 8
{% endblock %}
9 9

  
10 10
{% block content %}
11 11
<div id="sidebar">
12 12
  <div>
13 13
    <form>
14
    <h3>Rechercher dans les dossiers</h3>
15
    <label>Sans quotations <input name="without_quotations" type="checkbox"
16
    {% if request.GET.without_quotations == 'on' %}checked="checked"{% endif %}/></label>
17

  
18
    <h3>Avec au moins un acte (optionnel)</h3>
19
    Après (jj/mm/aaaa)
20
    <label><input name="date_actes_start" type="text" value="{{ request.GET.date_actes_start }}"></label>
21
    Avant (jj/mm/aaaa)
22
    <label><input name="date_actes_end" type="text" value="{{ request.GET.date_actes_end }}"></label>
23
    {% if request.GET %}
24
    <div class="search-reset">
25
    <button id="search">Rechercher</button>
26
    <button id="reset" class="icon-remove-sign" title="Réinitialiser"></button>
27
    </div>
28
    {% else %}
29
    <button id="search">Rechercher</button>
30
    {% endif %}
31
    <p id="search-results" style="display: none; "></p>
14
      <h3>Rechercher dans les dossiers</h3>
15
      <div>
16
        <label>sans quotations
17
          <input name="without_quotations" type="checkbox"
18
                 {% if request.GET.without_quotations == 'on' %}checked="checked"{% endif %}/></label>
19
      </div>
20
      <div>
21
        <label>sans quotations ANAP
22
          <input name="without_anap_quotations" type="checkbox"
23
                 {% if request.GET.without_anap_quotations == 'on' %}checked="checked"{% endif %}/></label>
24
      </div>
25
      <h3>Avec au moins un acte (optionnel)</h3>
26
      Après (jj/mm/aaaa)
27
      <label><input name="date_actes_start" type="text" value="{{ request.GET.date_actes_start }}"></label>
28
      Avant (jj/mm/aaaa)
29
      <label><input name="date_actes_end" type="text" value="{{ request.GET.date_actes_end }}"></label>
30
      {% if request.GET %}
31
      <div class="search-reset">
32
        <button id="search">Rechercher</button>
33
        <button id="reset" class="icon-remove-sign" title="Réinitialiser"></button>
34
      </div>
35
      {% else %}
36
      <button id="search">Rechercher</button>
37
      {% endif %}
38
      <p id="search-results" style="display: none; "></p>
32 39
  </div>
33 40
  <div id="filtre">
34 41
    <h3>Filtres sur l'état</h3>
35 42
    {{ search_form.states }}
36 43
    <button id="btn_all_state">Tous</button>
37 44
    <button id="btn_none_state">Aucun</button>
38
    </form>
45
  </form>
39 46
  </div>
40 47
</div>
41 48
<div class="content">
......
49 56
        <th rowspan="2">Mises 1</th>
50 57
        <th rowspan="2">Mises 2</th>
51 58
        <th rowspan="2">Mises 3</th>
59
        <th rowspan="2">ANAP</th>
52 60
      </tr>
53 61
      <tr>
54 62
        <th>papier</th>
......
59 67

  
60 68
      {% for patient_record in patient_records %}
61 69
      <tr style="display: table-row;" class="pr-line {{ patient_record.state_class }}" data-link="{{ patient_record.object.id }}/view">
62
          <td>{{ patient_record.object.paper_id|default_if_none:"" }}</td>
63
          <td>{{ patient_record.object.id }}</td>
64
          <td><span class="lastname">{{ patient_record.object.last_name }}</span></td>
65
          <td>{{ patient_record.object.first_name }}</td>
66
          <td class="{{ patient_record.state_class }}">{{ patient_record.state }}</td>
67
          <td>{% for mise in patient_record.object.mises_1.all %}{{ mise }}<br/>{% endfor %}</td>
68
          <td>{% for mise in patient_record.object.mises_2.all %}{{ mise }}<br/>{% endfor %}</td>
69
          <td>{% for mise in patient_record.object.mises_3.all %}{{ mise }}<br/>{% endfor %}</td>
70
        <td>{{ patient_record.object.paper_id|default_if_none:"" }}</td>
71
        <td>{{ patient_record.object.id }}</td>
72
        <td><span class="lastname">{{ patient_record.object.last_name }}</span></td>
73
        <td>{{ patient_record.object.first_name }}</td>
74
        <td class="{{ patient_record.state_class }}">{{ patient_record.state }}</td>
75
        <td>{% for mise in patient_record.object.mises_1.all %}{{ mise }}<br/>{% endfor %}</td>
76
        <td>{% for mise in patient_record.object.mises_2.all %}{{ mise }}<br/>{% endfor %}</td>
77
        <td>{% for mise in patient_record.object.mises_3.all %}{{ mise }}<br/>{% endfor %}</td>
78
        <td>{% if patient_record.anap %}<span class="icon-ok"></span>{% endif %}</td>
70 79
      </tr>
71 80
      {% endfor %}
72 81

  
73 82
    </tbody>
74 83
  </table>
75 84

  
76
{% if request.GET %}
77
<div class="pagination">
85
  {% if request.GET %}
86
  <div class="pagination">
78 87
    <span class="step-links">
79
        {% if paginate_patient_records.has_previous %}
80
            <a href="?{{ query }}&page={{ paginate_patient_records.previous_page_number }}">««</a>
81
        {% endif %}
88
      {% if paginate_patient_records.has_previous %}
89
      <a href="?{{ query }}&page={{ paginate_patient_records.previous_page_number }}">««</a>
90
      {% endif %}
82 91

  
83
        <span class="current">
84
            page {{ paginate_patient_records.number }} de {{ paginate_patient_records.paginator.num_pages }}
85
        </span>
92
      <span class="current">
93
        page {{ paginate_patient_records.number }} de {{ paginate_patient_records.paginator.num_pages }}
94
      </span>
86 95

  
87
        {% if paginate_patient_records.has_next %}
88
            <a href="?{{ query }}&page={{ paginate_patient_records.next_page_number }}">»»</a>
89
        {% endif %}
96
      {% if paginate_patient_records.has_next %}
97
      <a href="?{{ query }}&page={{ paginate_patient_records.next_page_number }}">»»</a>
98
      {% endif %}
90 99
    </span>
91
</div>
92
{% endif %}
100
  </div>
101
  {% endif %}
93 102

  
94 103

  
95 104

  
calebasse/dossiers/views.py
840 840
            current_state = patient_record.get_current_state() or patient_record.get_state()
841 841
            state = current_state.status.name
842 842
            state_class = current_state.status.type.lower()
843
            deficiencies = [getattr(patient_record, field) \
844
                            for field in self.deficience_fields]
845
            anap = reduce(lambda f1, f2: f1 or f2, deficiencies)
843 846
            patient_records.append(
844 847
                    {
845 848
                        'object': patient_record,
846 849
                        'state': state,
847
                        'state_class': state_class
850
                        'state_class': state_class,
851
                        'anap': anap
848 852
                        }
849 853
                    )
850 854
        return patient_records
......
852 856
    def get_queryset(self):
853 857
        form = forms.QuotationsForm(data=self.request.GET or None)
854 858
        qs = super(PatientRecordsQuotationsView, self).get_queryset()
859
        self.deficience_fields = [field for field in self.model._meta.get_all_field_names() if field.startswith('deficiency_')]
860

  
855 861
        without_quotations = self.request.GET.get('without_quotations')
862
        without_anap_quotations = self.request.GET.get('without_anap_quotations')
856 863
        if without_quotations:
857
            qs = qs.filter(mises_1=None).filter(mises_2=None).filter(mises_3=None)
864
            qs = qs.filter(mises_1__isnull=True).filter(mises_2__isnull=True).filter(mises_3__isnull=True)
865

  
866
        if without_anap_quotations:
867
            for field in self.deficience_fields:
868
                anap_field = {field: 0}
869
                qs = qs.filter(**anap_field)
870

  
858 871
        states = self.request.GET.getlist('states')
859 872
        qs = qs.filter(last_state__status__id__in=states)
860 873

  

Also available in: Unified diff