// Copyright (c) 2018, Xhive LLC
// For license information, please see license.txt
xhiveframework.ui.form.on("Attendance Request", {
	refresh(frm) {
		frm.trigger("show_attendance_warnings");
	},

	show_attendance_warnings(frm) {
		if (!frm.is_new() && frm.doc.docstatus === 0) {
			frm.dashboard.clear_headline();

			frm.call("get_attendance_warnings").then((r) => {
				if (r.message?.length) {
					frm.dashboard.reset();
					frm.dashboard.add_section(
						xhiveframework.render_template("attendance_warnings", {
							warnings: r.message || [],
						}),
						__("Attendance Warnings")
					);
					frm.dashboard.show();
				}
			})
		}
	}
});
