diff --git a/lms/lms/doctype/lms_certificate/lms_certificate.py b/lms/lms/doctype/lms_certificate/lms_certificate.py index 66fd33392..1ffe1f108 100644 --- a/lms/lms/doctype/lms_certificate/lms_certificate.py +++ b/lms/lms/doctype/lms_certificate/lms_certificate.py @@ -6,12 +6,41 @@ from frappe.model.document import Document from frappe.utils import add_years, nowdate from lms.lms.utils import is_certified +from frappe.email.doctype.email_template.email_template import get_email_template class LMSCertificate(Document): def validate(self): self.validate_duplicate_certificate() + def after_insert(self): + self.send_mail() + + def send_mail(self): + subject = _("Congratulations on getting certified!") + template = "certification" + custom_template = frappe.db.get_single_value("LMS Settings", "certification_template") + + args = { + "student_name": self.member_name, + "course_name": self.course, + "course_title": frappe.db.get_value("LMS Course", self.course, "title"), + "certificate_name": self.name, + } + + if custom_template: + email_template = get_email_template(custom_template, args) + subject = email_template.get("subject") + content = email_template.get("message") + frappe.sendmail( + recipients=self.member, + subject=subject, + template=template if not custom_template else None, + content=content if custom_template else None, + args=args, + header=[subject, "green"], + ) + def validate_duplicate_certificate(self): certificates = frappe.get_all( "LMS Certificate", diff --git a/lms/lms/doctype/lms_settings/lms_settings.json b/lms/lms/doctype/lms_settings/lms_settings.json index abfbb361f..2791f044f 100644 --- a/lms/lms/doctype/lms_settings/lms_settings.json +++ b/lms/lms/doctype/lms_settings/lms_settings.json @@ -10,6 +10,7 @@ "is_onboarding_complete", "column_break_zdel", "livecode_url", + "certification_template", "course_settings_section", "search_placeholder", "column_break_iqxy", @@ -186,7 +187,7 @@ { "fieldname": "section_break_szgq", "fieldtype": "Section Break", - "label": "Class Settings" + "label": "Batch Settings" }, { "fieldname": "signup_settings_tab", @@ -316,12 +317,18 @@ "fieldname": "show_dashboard", "fieldtype": "Check", "label": "Dashboard" + }, + { + "fieldname": "certification_template", + "fieldtype": "Link", + "label": "Certificate Email Template", + "options": "Email Template" } ], "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2023-10-30 16:42:58.994359", + "modified": "2023-11-01 22:38:38.380325", "modified_by": "Administrator", "module": "LMS", "name": "LMS Settings", diff --git a/lms/lms/print_format/certificate/certificate.json b/lms/lms/print_format/certificate/certificate.json index 47b27f518..a23e79080 100644 --- a/lms/lms/print_format/certificate/certificate.json +++ b/lms/lms/print_format/certificate/certificate.json @@ -2,7 +2,7 @@ "absolute_value": 0, "align_labels_right": 0, "creation": "2023-08-09 17:02:21.430320", - "css": ".outer-border {\n font-family: \"Inter\" sans-serif;\n font-size: 16px;\n border-radius: 0.5rem;\n border: 1px solid #E2E6E9;\n padding: 1rem;\n}\n\n.inner-border {\n border: 10px solid #0089FF;\n border-radius: 8px;\n text-align: center;\n padding: 6rem 4rem;\n background-color: #FFFFFF;\n}\n\n.certificate-logo {\n height: 1.5rem;\n margin-bottom: 4rem;\n}\n\n.certificate-name {\n font-size: 2rem;\n font-weight: 500;\n color: #192734;\n margin-bottom: 0.5rem;\n}\n\n.certificate-footer {\n margin: 4rem auto 0;\n width: 70%;\n text-align: center;\n}\n\n.certificate-footer-item {\n color: #192734;\n}\n\n.cursive-font {\n font-family: cursive;\n font-weight: 600;\n}\n\n.certificate-divider {\n margin: 0.5rem 0;\n}\n\n.certificate-expiry {\n margin-left: 2rem;\n}", + "css": ".outer-border {\n font-family: \"Inter\" sans-serif;\n font-size: 16px;\n border-radius: 0.5rem;\n border: 1px solid #E2E6E9;\n padding: 1rem;\n}\n\n.inner-border {\n border: 8px solid #0089FF;\n border-radius: 8px;\n text-align: center;\n padding: 6rem 4rem;\n background-color: #FFFFFF;\n}\n\n.certificate-logo {\n height: 1.5rem;\n margin-bottom: 4rem;\n}\n\n.certificate-name {\n font-size: 2rem;\n font-weight: 500;\n color: #192734;\n margin-bottom: 0.5rem;\n}\n\n.certificate-footer {\n margin: 4rem auto 0;\n width: 70%;\n text-align: center;\n}\n\n.certificate-footer-item {\n color: #192734;\n}\n\n.cursive-font {\n font-family: cursive;\n font-weight: 600;\n}\n\n.certificate-divider {\n margin: 0.5rem 0;\n}\n\n.certificate-expiry {\n margin-left: 2rem;\n}", "custom_format": 1, "disabled": 0, "doc_type": "LMS Certificate", @@ -10,19 +10,20 @@ "doctype": "Print Format", "font_size": 14, "format_data": "{\"header\":\"
{{ doc.name }}
\\n\n \n {{ _(\"Course Instructor\") }} \n | \n {% endif %}\n \n {% if certificate.expiry_date %}\n \n \n \n | \n \n {{ _(\"Expiry Date\") }} \n | \n {% endif %}\n \n
\n \n {{ _(\"Course Instructor\") }} \n | \n {% endif %}\n \n {% if certificate.expiry_date %}\n \n \n \n | \n \n {{ _(\"Expiry Date\") }} \n | \n {% endif %}\n \n
+ {{ _("Dear ") }} {{ student_name }}, +
++ {{ _("I am delighted to inform you that you have successfully earned your certification for the {0} course. Congratulations!").format(frappe.bold(course_title)) }} +
++ {{ _("With this certification, you can now showcase your updated skills and share your achievement with your colleagues and on LinkedIn. To access your certificate, please click on the link provided below.") }} +
++ {{ _("Once again, congratulations on this significant accomplishment.")}} +
++ {{ _("Best Regards") }} +
\ No newline at end of file diff --git a/lms/www/courses/certificate.html b/lms/www/courses/certificate.html index e6f47e821..2a3af3d3d 100644 --- a/lms/www/courses/certificate.html +++ b/lms/www/courses/certificate.html @@ -13,12 +13,11 @@