diff --git a/netforce_clinic/actions/clinic_print_labor_cost.xml b/netforce_clinic/actions/clinic_print_labor_cost.xml
new file mode 100644
index 0000000..fdd6673
--- /dev/null
+++ b/netforce_clinic/actions/clinic_print_labor_cost.xml
@@ -0,0 +1,9 @@
+
+ clinic_print_labor_cost
+ form_view
+ clinic.print.labor.cost
+ clinic_print_labor_cost
+ 1
+ account_menu
+
+
diff --git a/netforce_clinic/layouts/clinic_account_menu.xml b/netforce_clinic/layouts/clinic_account_menu.xml
index f48c160..3ee50a7 100644
--- a/netforce_clinic/layouts/clinic_account_menu.xml
+++ b/netforce_clinic/layouts/clinic_account_menu.xml
@@ -1,28 +1,28 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+ -
+
+
+
-
diff --git a/netforce_clinic/layouts/clinic_compute_labor_cost.xml b/netforce_clinic/layouts/clinic_compute_labor_cost.xml
index ea2d654..fe661f6 100644
--- a/netforce_clinic/layouts/clinic_compute_labor_cost.xml
+++ b/netforce_clinic/layouts/clinic_compute_labor_cost.xml
@@ -1,5 +1,4 @@
-
diff --git a/netforce_clinic/migrations/__init__.py b/netforce_clinic/migrations/__init__.py
index 3a2b12b..5406aaa 100644
--- a/netforce_clinic/migrations/__init__.py
+++ b/netforce_clinic/migrations/__init__.py
@@ -1,5 +1,6 @@
from . import clinic_setting
-from . import hdcase
+from . import print_labor_cost
+#from . import hdcase
#from . import remove_conv_bal
#from . import import_acc
#from . import update_labor_cost_line
diff --git a/netforce_clinic/migrations/clinic_setting.py b/netforce_clinic/migrations/clinic_setting.py
index 503d128..ff08c0b 100644
--- a/netforce_clinic/migrations/clinic_setting.py
+++ b/netforce_clinic/migrations/clinic_setting.py
@@ -9,25 +9,6 @@ class Migration(migration.Migration):
res=get_model("clinic.setting").search([])
if not res:
get_model("clinic.setting").create({})
-
- seq_names=[
- ('HDC-','Clinic HD Case'),
- ('VS-', 'Clinic Visit'),
- ('PS-', 'Clinic Personal'),
- ('PT-', 'Clinic Patient'),
- ('DT-', 'Clinic Doctor'),
- ('NS-', 'Clinic Nurse'),
- ]
- for prefix, seq_name in seq_names:
- seq_ids=get_model('sequence').search([['name','=',seq_name]])
- if not seq_ids:
- get_model("sequence").create({
- 'prefix': prefix,
- 'name': seq_name,
- 'type': 'other',
- })
- print("create seq %s successfully " % seq_name)
- # insert into clinic_personal(number,name,type, state,picture, active) select number, name,'doctor','temporary', picture, true from clinic_doctor;
return
Migration.register()
diff --git a/netforce_clinic/migrations/print_labor_cost.py b/netforce_clinic/migrations/print_labor_cost.py
new file mode 100644
index 0000000..b78c69d
--- /dev/null
+++ b/netforce_clinic/migrations/print_labor_cost.py
@@ -0,0 +1,37 @@
+import time
+
+from netforce.model import get_model
+from netforce import migration
+from netforce.access import set_active_user, get_active_user, set_active_company, get_active_company
+
+class Migration(migration.Migration):
+ _name="clinic.print.labor.cost"
+ _version="2.11.0"
+
+ def migrate(self):
+ user_id=get_active_user()
+ company_id=get_active_company()
+ set_active_company(1)
+ set_active_user(1)
+ date_from=get_model("clinic.report.labor.cost")._get_date_from()
+ date_to=get_model("clinic.report.labor.cost")._get_date_to()
+ yearnow=date_from.split("-")[0]
+ for period in get_model('clinic.period').search_browse([['name','=',yearnow]]):
+ for line in period.lines:
+ if line.state=='open':
+ period_id=line.id
+ date_from=line.date_start
+ date_to=line.date_stop
+ break
+ vals={
+ 'period_id': period_id,
+ 'date': time.strftime("%Y-%m-%d"),
+ 'date_from': date_from,
+ 'date_to': date_to,
+ }
+ get_model('clinic.print.labor.cost').create(vals)
+ set_active_company(company_id)
+ set_active_user(user_id)
+ return True
+
+Migration.register()
diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py
index 2cf0369..cb004e0 100644
--- a/netforce_clinic/models/__init__.py
+++ b/netforce_clinic/models/__init__.py
@@ -138,5 +138,5 @@ from . import province
from . import change_visit
from . import share_location
from . import report_cycle_setting
-#from . import district
-#from . import subdistrict
+from . import print_labor_cost
+from . import print_labor_cost_line
diff --git a/netforce_clinic/models/print_labor_cost.py b/netforce_clinic/models/print_labor_cost.py
new file mode 100644
index 0000000..9fe06c3
--- /dev/null
+++ b/netforce_clinic/models/print_labor_cost.py
@@ -0,0 +1,109 @@
+import time
+from calendar import monthrange
+
+from netforce.model import Model,fields,get_model
+
+class PrintLaborCost(Model):
+ _name="clinic.print.labor.cost"
+ _string="Print Report Labor Cost"
+
+ _fields={
+ "date": fields.Date("Month"),
+ "period_id": fields.Many2One("clinic.period.line","Period"),
+ "date_from": fields.Date("From", required=True),
+ "date_to": fields.Date("To", required=True),
+ "cycle_id": fields.Many2One("clinic.cycle","Cycle"),
+ "branch_id": fields.Many2One("clinic.branch","Branch"),
+ "department_id": fields.Many2One("clinic.department","Department"),
+ "staff_type": fields.Selection([['staff','Staff'],["doctor","Doctor"],["nurse","Nurse"]],"Type"),
+ 'lines': fields.One2Many("clinic.print.labor.cost.line","print_labor_cost_id","Lines"),
+ }
+
+ def reload(self,ids,context={}):
+ obj=self.browse(ids)[0]
+ context['defaults']={
+ 'date_from': obj.date_from,
+ 'date_to': obj.date_to,
+ 'cycle_id': obj.cycle_id.id,
+ 'branch_id': obj.branch_id.id,
+ 'department_id': obj.department_id.id,
+ 'staff_type': obj.staff_type,
+ }
+ cost_lines=get_model('clinic.report.labor.cost.summary').get_report_data(ids=[],context=context)['lines']
+ for line in obj.lines:
+ line.delete()
+ lines=[]
+ for cost_line in cost_lines:
+ staff_id=cost_line['staff_id']
+ lines.append(('create',{
+ 'staff_id': staff_id,
+ }))
+ obj.write({
+ 'lines': lines,
+ })
+ return
+
+ def do_print(self,ids,context={}):
+ data={}
+ return data
+
+ def _get_date_from(self,context={}):
+ year,month,day=time.strftime("%Y-%m-%d").split("-")
+ #return '%s-%s-01'%(year,month)
+ return '%s-%s-%s'%(year,month,day)
+
+ def _get_date_to(self,context={}):
+ year,month,day=time.strftime("%Y-%m-%d").split("-")
+ weekday, total_day=monthrange(int(year), int(month))
+ #return "%s-%s-%s"%(year,month,total_day)
+ return "%s-%s-%s"%(year,month,day)
+
+ def default_get(self,field_names=None,context={},**kw):
+ defaults=context.get("defaults",{})
+ date_from=defaults.get("date_from", self._get_date_from())
+ date_to=defaults.get("date_to", self._get_date_to())
+ print('defaults ', defaults)
+ yearnow=date_from.split("-")[0]
+ for period in get_model('clinic.period').search_browse([['name','=',yearnow]]):
+ for line in period.lines:
+ if line.state=='open':
+ period_id=line.id
+ date_from=line.date_start
+ date_to=line.date_stop
+ break
+ res={
+ 'period_id': period_id,
+ 'date': time.strftime("%Y-%m-%d"),
+ 'date_from': date_from,
+ 'date_to': date_to,
+ }
+ return res
+
+ def onchange_date(self,context={}):
+ data=context['data']
+ date=data['date']
+ year,month,day=date.split("-")
+ weekday, total_day=monthrange(int(year), int(month))
+ data['date_from']="%s-%s-01"%(year,month)
+ data['date_to']="%s-%s-%s"%(year,month,total_day)
+ return data
+
+ def onchange_branch(self,context={}):
+ data=context['data']
+ data['department_id']=None
+ return data
+
+ def onchange_from(self,context={}):
+ data=context['data']
+ data['date_to']=data['date_from']
+ return data
+
+ def onchange_period(self,context={}):
+ data=context['data']
+ period_id=data['period_id']
+ period=get_model('clinic.period.line').browse(period_id)
+ data['date_from']=period.date_start
+ data['date_to']=period.date_stop
+ return data
+
+PrintLaborCost.register()
diff --git a/netforce_clinic/models/print_labor_cost_line.py b/netforce_clinic/models/print_labor_cost_line.py
new file mode 100644
index 0000000..ccaf060
--- /dev/null
+++ b/netforce_clinic/models/print_labor_cost_line.py
@@ -0,0 +1,18 @@
+from netforce.model import Model,fields
+
+class PrintLaborCostLine(Model):
+ _name="clinic.print.labor.cost.line"
+ _string="Print Report Labor Cost Line"
+
+ _fields={
+ "print_labor_cost_id": fields.Many2One("clinic.print.labor.cost","Print Labor Cost",required=True,on_delete="cascade"),
+ 'staff_id': fields.Many2One("clinic.staff","Staff"),
+ 'print': fields.Boolean("Print"),
+ }
+
+ _defaults={
+ 'print': True,
+ }
+
+
+PrintLaborCostLine.register()
diff --git a/netforce_clinic/models/report_labor_cost_summary.py b/netforce_clinic/models/report_labor_cost_summary.py
index d34bc66..0848f3b 100644
--- a/netforce_clinic/models/report_labor_cost_summary.py
+++ b/netforce_clinic/models/report_labor_cost_summary.py
@@ -2,7 +2,7 @@ import time
from calendar import monthrange
from netforce.model import Model,fields,get_model
-from netforce.access import get_active_company
+from netforce.access import get_active_company, set_active_user, get_active_user, set_active_company
class ReportLaborCostSummary(Model):
_name="clinic.report.labor.cost.summary"
@@ -121,14 +121,14 @@ class ReportLaborCostSummary(Model):
return r
return "{0:,.0f}".format(r)
total_hdcase=0
+ print("----> ", dom)
for line in get_model("clinic.labor.cost.line").search_browse(dom):
lcost=line.labor_cost_id
citem=lcost.cycle_item_id
dpt=citem.department_id
- qty=line.qty or 0 #XXX
+ qty=line.qty or 0
total_hdcase+=qty
- #amt=line.pay_amount or 0 #XXX
- amt=line.amount or 0 #XXX
+ amt=line.amount or 0
staff=line.staff_id
categ_name=''
categ_id=None
@@ -313,6 +313,10 @@ class ReportLaborCostSummary(Model):
for tline in data['total_lines']:
data['total_lines_txt'][0]['item%s'%no]=tline['amt']
no+=1
+
+ #for nline in nlines:
+ #for sub_line in nline['sub_lines']:
+ #print(nline['staff_name'], sub_line)
return data
def onchange_date(self,context={}):
@@ -334,4 +338,6 @@ class ReportLaborCostSummary(Model):
data['department_id']=None
return data
+
+
ReportLaborCostSummary.register()