diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml
index 6b6c8da..6710fdd 100644
--- a/netforce_clinic/layouts/clinic_menu.xml
+++ b/netforce_clinic/layouts/clinic_menu.xml
@@ -35,15 +35,11 @@
- -
-
-
-
+
+ -
-
- -
-
+
-
diff --git a/netforce_clinic/models/report_hd_case_summary.py b/netforce_clinic/models/report_hd_case_summary.py
index e7bc58e..8a89807 100644
--- a/netforce_clinic/models/report_hd_case_summary.py
+++ b/netforce_clinic/models/report_hd_case_summary.py
@@ -4,6 +4,7 @@ from datetime import datetime
from calendar import monthrange
from netforce.model import Model, fields, get_model
from netforce.database import get_connection
+from netforce.access import get_active_company
from . import utils
@@ -22,8 +23,8 @@ class ReportHDCaseSummary(Model):
def get_report_data(self,ids,context={}):
db=get_connection()
- for item in get_model("company").search_browse([]):
- company_name=item.name
+ company_id=get_active_company()
+ company=get_model("company").browse(company_id)
date=datetime.now().strftime("%Y-%m-%d")
if ids:
@@ -85,7 +86,7 @@ class ReportHDCaseSummary(Model):
weekday, crr_total_day=monthrange(prev_year, crr_month)
time_start='%s-%s-01 00:00:00'%(year,str(crr_month).zfill(2))
time_stop='%s-%s-%s 23:59:59'%(year,str(crr_month).zfill(2),crr_total_day)
- new_patients=db.query("select id, name, note from clinic_patient where active=true and create_time >=%s and create_time <=%s",time_start,time_stop)
+ new_patients=db.query("select id, name, note from clinic_patient where active=true and create_time >=%s and create_time <=%s and company_id=%s",time_start,time_stop,company_id)
items['topic3']={
'month': month_str,
'amount': len(new_patients) or 0.0,
@@ -97,7 +98,7 @@ class ReportHDCaseSummary(Model):
# number for patient who resign for this month
time_start='%s-%s-01 00:00:00'%(year,str(crr_month).zfill(2))
time_stop='%s-%s-%s 23:59:59'%(year,str(crr_month).zfill(2),crr_total_day)
- resign_patients=db.query("select id, name, note from clinic_patient where active=false and write_time >=%s and write_time <=%s",time_start,time_stop)
+ resign_patients=db.query("select id, name, note from clinic_patient where active=false and write_time >=%s and write_time <=%s and company_id=%s",time_start,time_stop,company_id)
items['topic4']={
'month': month_str,
'amount': len(resign_patients) or 0.0,
@@ -109,7 +110,7 @@ class ReportHDCaseSummary(Model):
dom=[]
weekday, crr_total_day=monthrange(year, crr_month)
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
- npatients=db.query("select id, name, note from clinic_patient where active=true and reg_date <=%s",time_stop)
+ npatients=db.query("select id, name, note from clinic_patient where active=true and reg_date <=%s and company_id=%s",time_stop,company_id)
items['topic5']={
'month': next_month_str,
'amount': len(npatients),
@@ -181,7 +182,8 @@ class ReportHDCaseSummary(Model):
'lines': lines,
'new_patient_lines': new_patient_lines,
'resign_patient_lines': resign_patient_lines,
- 'company_name': company_name,
+ 'company_name': company.name or "",
+ 'parent_company_name': company.parent_id.name or "",
}
return data
diff --git a/netforce_clinic/templates/report_hd_case_summary.hbs b/netforce_clinic/templates/report_hd_case_summary.hbs
index 4ab98d0..08e880f 100644
--- a/netforce_clinic/templates/report_hd_case_summary.hbs
+++ b/netforce_clinic/templates/report_hd_case_summary.hbs
@@ -3,7 +3,7 @@
ใบสรุปการทำ Hemodialysis
- ศูนย์ไตเทียมราชวัตร {{company_name}}
+ {{parent_company_name}} {{company_name}}
ประจำเดือน {{month}} {{year}}