# Copyright (c) 2019, Xhive LLC
# For license information, please see license.txt


import xhiveframework
from xhiveframework.model.document import Document


class AppointmentLetter(Document):
	pass


@xhiveframework.whitelist()
def get_appointment_letter_details(template):
	body = []
	intro = xhiveframework.get_list(
		"Appointment Letter Template",
		fields=["introduction", "closing_notes"],
		filters={"name": template},
	)[0]
	content = xhiveframework.get_all(
		"Appointment Letter content",
		fields=["title", "description"],
		filters={"parent": template},
		order_by="idx",
	)
	body.append(intro)
	body.append({"description": content})
	return body
