From dfcb424aee63b2a4af5b1c9430985602b1308ecc Mon Sep 17 00:00:00 2001
From: George Katsikas <giorgakis.katsikas@gmail.com>
Date: Wed, 14 Aug 2024 14:59:39 +0200
Subject: [PATCH] refactor worklog summary table

---
 .../finances/_worklog_summary_table.html      | 31 +++++++++++++++++++
 .../templates/finances/timesheets.html        | 24 +-------------
 2 files changed, 32 insertions(+), 23 deletions(-)
 create mode 100644 scipost_django/finances/templates/finances/_worklog_summary_table.html

diff --git a/scipost_django/finances/templates/finances/_worklog_summary_table.html b/scipost_django/finances/templates/finances/_worklog_summary_table.html
new file mode 100644
index 000000000..889d2e82b
--- /dev/null
+++ b/scipost_django/finances/templates/finances/_worklog_summary_table.html
@@ -0,0 +1,31 @@
+{% load scipost_extras %}
+
+<table class="table table-hover text-nowrap">
+  <thead class="table-light">
+    <tr>
+      <th>Employee</th>
+
+      {% for month in logs_filter_form.get_months %}<th colspan="2" scope="colgroup">{{ month|date:'N Y' }}</th>{% endfor %}
+
+    </tr>
+  </thead>
+  <tbody>
+
+    {% for user_data in logs_filter_form.filter_per_month %}
+      <tr>
+        <td>{{ user_data.user.contributor }}</td>
+
+        {% for _, total_time, monthly_salary in user_data.monthly_data %}
+          <td>{{ total_time|duration }}</td>
+          <td>€{{ monthly_salary|floatformat:0 }}</td>
+        {% endfor %}
+
+      </tr>
+    {% empty %}
+      <tr>
+        <td colspan="5">No logs found.</td>
+      </tr>
+    {% endfor %}
+
+  </tbody>
+</table>
diff --git a/scipost_django/finances/templates/finances/timesheets.html b/scipost_django/finances/templates/finances/timesheets.html
index 499ad4fc2..380f78ea4 100644
--- a/scipost_django/finances/templates/finances/timesheets.html
+++ b/scipost_django/finances/templates/finances/timesheets.html
@@ -32,29 +32,7 @@
       {% if form.is_bound and form.is_valid %}
         <h2 class="mb-2 mt-4">Team timesheets</h2>
         <h4 class="mb-1">{{ user_log.user.first_name }} {{ user_log.user.last_name }}</h4>
-        <table class="table table-hover text-nowrap">
-          <thead class="table-light">
-            <tr>
-              <th>Employee</th>
-              {% for month in form.get_months %}<th colspan="2" scope="colgroup">{{ month|date:'N Y' }}</th>{% endfor %}
-            </tr>
-          </thead>
-          <tbody>
-            {% for user_data in form.filter_per_month %}
-              <tr>
-                <td>{{ user_data.user.contributor }}</td>
-                {% for _, total_time, monthly_salary in user_data.monthly_data %}
-                  <td>{{ total_time|duration }}</td>
-                  <td>€{{ monthly_salary|floatformat:0 }}</td>
-                {% endfor %}
-              </tr>
-            {% empty %}
-              <tr>
-                <td colspan="5">No logs found.</td>
-              </tr>
-            {% endfor %}
-          </tbody>
-        </table>
+        {% include "finances/_worklog_summary_table.html" with logs_filter_form=form %}
       {% else %}
         <p class="text-danger">First submit the filter form to retrieve results.</p>
       {% endif %}
-- 
GitLab