From 11c871bfe36dae61bd8e40e52df1ef474600c089 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Tue, 12 Dec 2017 10:52:13 +0100
Subject: [PATCH] subject edit page contains info about vouchers

---
 .../includes/subject_vouchers_box.html        | 48 +++++++++++++++++++
 smash/web/templates/subjects/edit.html        |  5 ++
 2 files changed, 53 insertions(+)
 create mode 100644 smash/web/templates/includes/subject_vouchers_box.html

diff --git a/smash/web/templates/includes/subject_vouchers_box.html b/smash/web/templates/includes/subject_vouchers_box.html
new file mode 100644
index 00000000..36638b10
--- /dev/null
+++ b/smash/web/templates/includes/subject_vouchers_box.html
@@ -0,0 +1,48 @@
+<div class="row">
+    <div class="col-lg-12">
+        <div class="box box-success">
+            <div class="box-header with-border">
+                <h3>Vouchers <a title="add a new voucher"
+                                id="add-voucher"
+                                href="{% url 'web.views.voucher_add' %}?study_subject_id={{ subject.id }}"
+                                class="text-primary"
+                ><i class="fa fa-plus-circle text-success"></i></a></h3>
+            </div>
+            <div class="box-body">
+                <table class="table table-bordered table-striped">
+                    <thead>
+                    <tr>
+
+                        <th class="text-center">Number</th>
+                        <th class="text-center">Type</th>
+                        <th class="text-center">Issue date</th>
+                        <th class="text-center">Expiry date</th>
+                        <th class="text-center">Status</th>
+                        <th class="text-center">Use date</th>
+                        <th class="text-center">Partner</th>
+                        <th class="text-center">Feedback</th>
+                        <th class="text-center">Edit</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    {% for voucher in subject.vouchers.all %}
+                        <tr>
+                            <td>{{ voucher.number }}</td>
+                            <td>{{ voucher.voucher_type }}</td>
+                            <td>{{ voucher.issue_date }}</td>
+                            <td>{{ voucher.expiry_date }}</td>
+                            <td>{{ voucher.status }}</td>
+                            <td>{{ voucher.use_date }}</td>
+                            <td>{{ voucher.usage_partner.first_name }} {{ voucher.usage_partner.last_name }}</td>
+                            <td>{{ voucher.feedback }}</td>
+                            <td><a href="{% url 'web.views.voucher_edit' voucher.id %}"><i class="fa fa-edit"></i></a>
+                            </td>
+                        </tr>
+                    {% endfor %}
+                    </tbody>
+                </table>
+            </div>
+        </div>
+
+    </div>
+</div>
diff --git a/smash/web/templates/subjects/edit.html b/smash/web/templates/subjects/edit.html
index 1dedffbc..669f8630 100644
--- a/smash/web/templates/subjects/edit.html
+++ b/smash/web/templates/subjects/edit.html
@@ -109,11 +109,16 @@
             </div><!-- /.col-md-12 -->
         </div><!-- /.row -->
 
+        {% if study_subject.study.columns.vouchers %}
+            {% include 'includes/subject_vouchers_box.html' with subject=study_subject %}
+        {% endif %}
+
         {% include 'includes/mail_templates_box.html' with instance_id=study_subject.id %}
 
         {% include 'includes/contact_attempts_box.html' with subject=study_subject contact_attempts=contact_attempts %}
 
 
+
         <div class="modal modal-danger fade" id="confirm-dead-resigned-mark-dialog" tabindex="-1" role="dialog">
             <div class="modal-dialog" role="document">
                 <div class="modal-content">
-- 
GitLab