1. Arnaud Grausem
  2. thot

Commits

Arnaud Grausem  committed 3b90bdd

Adding proportion in all report types

  • Participants
  • Parent commits 4d89d9c
  • Branches default

Comments (0)

Files changed (7)

File media/css/report.css

View file
 
 th.task
 {
-    width: 270px;
+/*    width: auto;*/
 }
 
 th.hours
 {
-    width: 70px;
+    width: 50px;
+}
+
+th.percentage
+{
+    width: 50px;
+    text-align: center;
 }
 
 #report_view
     font-weight: bold;
 }
 
-td.total, th.total, td.hours
+th.percentage, td.percentage
+{
+    border-left: 1px solid #DDDDDD;
+    border-right: 1px solid #DDDDDD;
+}
+
+td.total, th.total, td.hours, td.percentage
 {
     text-align: right;
     padding-right: 20px;
+    padding-left: 20px;
 }
 
 td.day, th.day

File templates/report/includes/group_report.html

View file
 {% if detailed %}
 <th class="infos day">{% trans "Date" %}</th>
 <th class="infos comment">{% trans "Comment" %}</th>
+{% else %}
+<th class="percentage">{% trans "Proportion" %}</th>
 {% endif %}
 <th class="total">{% trans "Hours" %}</th>
 {% endblock %}
 
 {% block grouper %}
-<td colspan="{% if detailed %}4{% else %}2{% endif %}" class="user">{{ report.group }}</td>
+<td colspan="{% if detailed %}4{% else %}3{% endif %}" class="user">{{ report.group }}</td>
 {% endblock %}
 
 {% block activity %}
 <td class="comment">{{ activity.comment }}</td>
 <td class="hours">{{ activity.hours }}</td>
 {% else %}
+<td class="percentage">{{ activity.percentage|floatformat:2 }}</td>
 <td class="hours">{{ activity.by_task }}</td>
 {% endif %}
 {% endblock %}

File templates/report/includes/report.html

View file
         <tr class="total row">
             {% block user_total %}
             <td class="user">{% trans "Total" %}</td>
+            {% if not detailed %}
+            <td class="percentage total">100.00</td>
+            {% endif %} 
             <td class="user total" {% if detailed %}colspan="3"{% endif %}>{{ report.total }}</td>
             {% endblock %}
         </tr>
         <tr class="total row">
             {% block total %}
             <td class="user">{% trans "ALL TOTAL" %}</td>
-            <td class="user total" {% if detailed %}colspan="3"{% endif %}>{{ total|default_if_none:"0.0" }}</td>
+            <td class="user total" colspan="{% if detailed %}3{% else %}2{% endif %}">{{ total|default_if_none:"0.0" }}</td>
             {% endblock %}
         </tr>
         </tbody>

File templates/report/includes/task_report.html

View file
 {% if detailed %}
 <th class="infos day">{% trans "Date" %}</th>
 <th class="infos comment">{% trans "Comment" %}</th>
+{% else %}
+<th class="percentage">{% trans "Proportion" %}</th>
 {% endif %}
 <th id="total" class="hours">{% trans "Hours" %}</th>
 {% endblock %}
 
 {% block grouper %}
-<td colspan="{% if detailed %}5{% else %}3{% endif %}" class="user">{{ report.task }}</td>
+<td colspan="{% if detailed %}5{% else %}4{% endif %}" class="user">{{ report.task }}</td>
 {% endblock %}
 
 {% block activity %}
 <td class="comment">{{ activity.comment|default:"&nbsp;" }}</td>
 <td class="hours">{{ activity.hours }}</td>
 {% else %}
+<td class="percentage">{{ activity.percentage|floatformat:2 }}</td>
 <td class="hours">{{ activity.by_task }}</td>
 {% endif %}
 {% endblock %}
 
 {% block user_total %}
 <td colspan="2" class="user">{% trans "Total" %}</td>
-<td class="user total" {% if detailed %}colspan="3"{% endif %}>{{ report.total }}</td>
+<td class="user total" colspan="{% if detailed %}3{% else %}2{% endif %}">{{ report.total }}</td>
 {% endblock %}
 
 {% block total %}
 <td colspan="2" class="user">{% trans "ALL TOTAL" %}</td>
-<td class="user total" {% if detailed %}colspan="3"{% endif %}>{{ total }}</td>
+<td class="user total" colspan="{% if detailed %}3{% else %}2{% endif %}">{{ total }}</td>
 {% endblock %}
 

File templates/report/includes/user_report.html

View file
 {% if detailed %}
 <th class="infos day">{% trans "Date" %}</th>
 <th class="infos comment">{% trans "Comment" %}</th>
+{% else %}
+<th class="percentage">{% trans "Proportion" %}</th>
 {% endif %}
 <th class="total hours">{% trans "Hours" %}</th>
 {% endblock %}
 
 {% block grouper %}
-<td colspan="{% if detailed %}4{% else %}2{% endif %}" class="user">{{ report.user }}</td>
+<td colspan="{% if detailed %}4{% else %}3{% endif %}" class="user">{{ report.user }}</td>
 {% endblock %}
 
 {% block activity %}
 <td class="comment">{{ activity.comment|default:"&nbsp;" }}</td>
 <td class="hours">{{ activity.hours }}</td>
 {% else %}
+<td class="percentage">{{ activity.percentage|floatformat:2 }}</td>
 <td class="hours">{{ activity.by_task }}</td>
 {% endif %}
 {% endblock %}

File templates/timesheet/index.html

View file
     <li class="{% ifequal selected "daily" %}selected{% endifequal %}">
 	<a href="#" onclick="Dajaxice.timesheet.daily('Dajax.process')">{% trans "Daily" %}</a>
     </li>
-    {% comment %}
     {% if user.is_manager %}
     <li class="{% ifequal selected "task" %}selected{% endifequal %}">
 	<a href="#" onclick="Dajaxice.timesheet.editable_tasks('Dajax.process')">{% trans "Tasks" %}</a>
     </li>
     {% endif %}
-    <li class="{% ifequal selected "help" %}selected{% endifequal %}">
-	<a href="#" onclick="Dajaxice.timesheet.help('Dajax.process')">{% trans "Help" %}</a>
-    </li>
-    {% endcomment %}
 </ul>
 <div id="view">
 {% include timesheet_template %}	

File thot/report/forms.py

View file
     # BASE REPORT FORM FIELDS                                           #
     #####################################################################
     
-    begin_date = forms.DateField(label=_('Date range'))
-    end_date = forms.DateField(label=_('to'))
+    begin_date = forms.DateField(label=_('Date range'), 
+        initial=date.today()+relativedelta(months=-1))
+    end_date = forms.DateField(label=_('to'), initial=date.today())
     detailed = forms.BooleanField(label=_('Detailed report'), 
         initial=False, required=False)
-
-    def __init__(self, *args, **kwargs):
-        super(BaseReportForm, self).__init__(*args, **kwargs)
-        # defines begin date and end date initial data for the form
-        # dynamically for different instance of the form
-        today = date.today()
-        self.fields['begin_date'].initial = today+relativedelta(months=-1)
-        self.fields['end_date'].initial = today
     
     def report_data(self):
         """Returns basic report between two dates
             activities.query.group_by = ['task_id']
 
         for user in users:
+            # total of work time
+            try:
+                user_total = users_total.get(user__id=user.id).get('by_user')
+            except Activity.DoesNotExist:
+                user_total = Decimal('0.0')
+
+            # user activities
             if not detailed:
                 user_activities = activities.filter(user=user).values('task')\
                     .annotate(by_task=Sum('hours'))\
     
                 for activity in user_activities:
                     activity['task'] = Task.objects.get(id=activity['task'])
+                    activity['percentage'] = activity['by_task']/user_total*100
             else:
                 user_activities = activities.filter(user=user)\
                     .order_by('date')
 
-            try:
-                user_total = users_total.get(user__id=user.id).get('by_user')
-            except Activity.DoesNotExist:
-                user_total = Decimal('0.0')
 
             report = {
                 'user': user,
             activities.query.group_by = ['task_id']
 
         for group in groups:
+            # total of work time
+            try:
+                group_total = groups_total.get(group__id=group.id)\
+                    .get('by_group')
+            except Activity.DoesNotExist:
+                group_total = Decimal('0.0')
+
             if not detailed:
                 group_activities = activities.filter(group=group)\
                     .values('task').annotate(by_task=Sum('hours'))\
 
                 for activity in group_activities:
                     activity['task'] = Task.objects.get(id=activity['task'])
+                    activity['percentage'] = activity['by_task']/group_total*100
             else:
                 group_activities = activities.filter(group=group)\
                     .order_by('date')
 
-            try:
-                group_total = groups_total.get(group__id=group.id)\
-                    .get('by_group')
-            except Activity.DoesNotExist:
-                group_total = Decimal('0.0')
 
             report = {
                 'group': group,
             activities.query.group_by = ['user_id']
 
         for task in tasks:
+            try:
+                task_total = tasks_total.get(task__id=task.id).get('by_task')
+            except Activity.DoesNotExist:
+                task_total = Decimal('0.0')
+
             if not detailed:
                 task_activities = activities.filter(task=task)\
                     .values('user', 'group').annotate(by_task=Sum('hours'))\
                     activity['user'] = ActivityLogger.objects\
                         .get(id=activity['user'])
                     activity['group'] = Group.objects.get(id=activity['group'])
+                    activity['percentage'] = activity['by_task']/task_total*100
             
             else:
                 task_activities = activities.filter(task=task)\
                     .order_by('date')
 
-            try:
-                task_total = tasks_total.get(task__id=task.id).get('by_task')
-            except Activity.DoesNotExist:
-                task_total = Decimal('0.0')
 
             report = {
                 'task': task,