From 317e2d6a5122bb0a3a93d8164ef66d0e3288e8c1 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Tue, 10 Mar 2015 08:46:14 +0700 Subject: [PATCH] improve report --- .../models/report_labor_cost_detail.py | 10 ++++++++++ .../templates/report_labor_cost_detail.hbs | 18 ++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/netforce_clinic/models/report_labor_cost_detail.py b/netforce_clinic/models/report_labor_cost_detail.py index dc04859..2102eb7 100644 --- a/netforce_clinic/models/report_labor_cost_detail.py +++ b/netforce_clinic/models/report_labor_cost_detail.py @@ -126,13 +126,22 @@ class ReportLaborCostDetail(Model): dates[date][dpt.name]['qty']+=qty lines=[] dpts=get_model("clinic.department").search_read([],['name']) + department_name="" + if department_id: + department_name=get_model("clinic.department").browse(department_id).name or "" # link to sub detail + show_count=0 for dpt in dpts: + show_link=True + if dpt['name']!=department_name and department_name!='': + show_link=False + show_count+=1 dpt.update({ 'staff_id': staff_id, 'staff_type': staff_type, 'date_from': date_from, 'date_to': date_to, + 'show_link': show_link, }) dpts=sorted(dpts, key=lambda b: b['name']) no=1 @@ -209,6 +218,7 @@ class ReportLaborCostDetail(Model): 'comp_span': comp_span, #qty, amt 'lines': lines, 'dpt_lines': dpt_lines, + 'show_all': show_count <=1 and True or False, } return data diff --git a/netforce_clinic/templates/report_labor_cost_detail.hbs b/netforce_clinic/templates/report_labor_cost_detail.hbs index 3895a5f..381e4a7 100644 --- a/netforce_clinic/templates/report_labor_cost_detail.hbs +++ b/netforce_clinic/templates/report_labor_cost_detail.hbs @@ -7,7 +7,11 @@ - {{comp_name}} + {{#if show_all}} + {{comp_name}} + {{else}} + {{comp_name}} + {{/if}} @@ -16,10 +20,20 @@ วันที่ {{#each dpts}} + {{#if show_link}} {{name}} + {{else}} + {{name}} + {{/if}} {{/each}} - รวม + + {{#if show_all}} + รวม + {{else}} + รวม + {{/if}} +