diff --git a/lms/lms/doctype/lms_batch/lms_batch.py b/lms/lms/doctype/lms_batch/lms_batch.py
index 5213f93e..b21f24ab 100644
--- a/lms/lms/doctype/lms_batch/lms_batch.py
+++ b/lms/lms/doctype/lms_batch/lms_batch.py
@@ -335,3 +335,14 @@ def get_timetable_details(timetable):
timetable = sorted(timetable, key=lambda k: k["date"])
return timetable
+
+
+@frappe.whitelist()
+def send_email_to_students(batch, subject, message):
+ frappe.only_for("Moderator")
+ students = frappe.get_all("Batch Student", {"parent": batch}, pluck="student")
+ frappe.sendmail(
+ recipients=students,
+ subject=subject,
+ message=message,
+ )
diff --git a/lms/public/css/style.css b/lms/public/css/style.css
index 48e7a357..c62f3de4 100644
--- a/lms/public/css/style.css
+++ b/lms/public/css/style.css
@@ -2469,4 +2469,8 @@ select {
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
transform: rotate(180deg);
+}
+
+.modal-body .ql-container {
+ max-height: unset !important;
}
\ No newline at end of file
diff --git a/lms/www/batches/batch.html b/lms/www/batches/batch.html
index 92700499..22798514 100644
--- a/lms/www/batches/batch.html
+++ b/lms/www/batches/batch.html
@@ -75,6 +75,11 @@
+
+
+
{% if batch_info.custom_component %}
diff --git a/lms/www/batches/batch.js b/lms/www/batches/batch.js
index 8dfc84a9..1f4cd60d 100644
--- a/lms/www/batches/batch.js
+++ b/lms/www/batches/batch.js
@@ -63,6 +63,10 @@ frappe.ready(() => {
$(document).on("click", ".slot", (e) => {
mark_active_slot(e);
});
+
+ $(".btn-email").click((e) => {
+ email_to_students();
+ });
});
const create_live_class = (e) => {
@@ -765,3 +769,47 @@ const get_background_color = (doctype) => {
if (doctype == "LMS Assignment") return "var(--orange-400)";
if (doctype == "LMS Live Class") return "var(--purple-400)";
};
+
+const email_to_students = () => {
+ this.email_dialog = new frappe.ui.Dialog({
+ title: __("Email to Students"),
+ fields: [
+ {
+ fieldtype: "Data",
+ fieldname: "subject",
+ label: __("Subject"),
+ reqd: 1,
+ },
+ {
+ fieldtype: "Text Editor",
+ fieldname: "message",
+ label: __("Message"),
+ reqd: 1,
+ max_height: 100,
+ min_lines: 5,
+ },
+ ],
+ primary_action: (values) => {
+ send_email(values);
+ },
+ });
+ this.email_dialog.show();
+};
+
+const send_email = (values) => {
+ frappe.call({
+ method: "lms.lms.doctype.lms_batch.lms_batch.send_email_to_students",
+ args: {
+ batch: $(".class-details").data("batch"),
+ subject: values.subject,
+ message: values.message,
+ },
+ callback: (r) => {
+ this.email_dialog.hide();
+ frappe.show_alert({
+ message: __("Email sent successfully"),
+ indicator: "green",
+ });
+ },
+ });
+};