From 171157f1b3783a16fbd5781a96304dcbacb7c2e2 Mon Sep 17 00:00:00 2001 From: Manas Solanki Date: Fri, 5 Jan 2018 12:42:39 +0530 Subject: [PATCH] Fix + Enhancement in Program Enrollment Tool (#12291) * Fix + Enhancement in Program Enrollment Tool * updated the docs --- .../admission/program-enrollment-tool.md | 13 +- .../program_enrollment_tool.js | 17 +- .../program_enrollment_tool.json | 205 +++++++++++++++++- .../program_enrollment_tool.py | 43 ++-- .../program_enrollment_tool_student.json | 33 ++- .../student_applicant/student_applicant.json | 33 ++- 6 files changed, 307 insertions(+), 37 deletions(-) diff --git a/erpnext/docs/user/manual/en/education/admission/program-enrollment-tool.md b/erpnext/docs/user/manual/en/education/admission/program-enrollment-tool.md index 53d9d9c84d1..97a26c73ceb 100644 --- a/erpnext/docs/user/manual/en/education/admission/program-enrollment-tool.md +++ b/erpnext/docs/user/manual/en/education/admission/program-enrollment-tool.md @@ -1,16 +1,21 @@ # Program Enrollment Tool -The Program Enrollment tool allows the bulk enrollment of the **Student Applicants** in a Program. +The Program Enrollment tool allows the bulk enrollment of the new and old students in a Program. If you are enrolling a new student, you can fetch the students from the **Student Applicant** or if you are promoting the older students you can fetch them from the **Program Enrollment** itself +> Note: Academic Term is optional in the Program Enrollment Tool -You can create the the Program Enrollment for : +You can create the Program Enrollment for : -1. **Student Applicants** >> List of Student Applicants will be fetched for the selected **Program** and **Academic year**. +1. **Student Applicants**: List of Student Applicants will be fetched for the selected **Program**, **Academic year** and **Academic Term** (if provided). Student Applicant Enrollment -2. **Program Enrollment** >> You can bulk update the **Program** for the students from one academic year to another in the same **Program** or a new **Program**. +2. **Program Enrollment**: List of students already enrolled in selected **Program** for the given **Academic Year**, **Academic Term** (if provided) and **Student Batch** will be fetched and can be used to enroll students from one academic year/term to another in the same **Program** or a new **Program**. Student Applicant Enrollment +**New Student Batch**: This can be selected for the entire students fetched in the table. Priority will be given to the Batch selected in the table (for individual students). + +For promoting the students, the new academic year, academic term and program can also be selected for the enrollment of the fetched students list. + {next} \ No newline at end of file diff --git a/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.js b/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.js index bf6f3e0938c..4f8ce6d19c0 100644 --- a/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.js +++ b/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.js @@ -1,11 +1,19 @@ // Copyright (c) 2016, Frappe and contributors // For license information, please see license.txt -cur_frm.add_fetch("student", "title", "student_name"); -cur_frm.add_fetch("student_applicant", "title", "student_name"); frappe.ui.form.on("Program Enrollment Tool", { + setup: function(frm) { + frm.add_fetch("student", "title", "student_name"); + frm.add_fetch("student_applicant", "title", "student_name"); + }, + "refresh": function(frm) { frm.disable_save(); + frm.fields_dict.enroll_students.$input.addClass(' btn btn-primary'); + frappe.realtime.on("program_enrollment_tool", function(data) { + frappe.hide_msgprint(true); + frappe.show_progress(__("Enrolling students"), data.progress[0], data.progress[1]); + }); }, "get_students": function(frm) { @@ -18,7 +26,7 @@ frappe.ui.form.on("Program Enrollment Tool", { frm.set_value("students", r.message); } } - }) + }); }, "enroll_students": function(frm) { @@ -27,7 +35,8 @@ frappe.ui.form.on("Program Enrollment Tool", { doc:frm.doc, callback: function(r) { frm.set_value("students", []); + frappe.hide_msgprint(true); } - }) + }); } }); diff --git a/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.json b/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.json index 71071cdbdc3..d611a6f2706 100644 --- a/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.json +++ b/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.json @@ -29,7 +29,7 @@ "label": "Get Students From", "length": 0, "no_copy": 0, - "options": "\nStudent Applicants\nProgram Enrollments", + "options": "\nStudent Applicant\nProgram Enrollment", "permlevel": 0, "precision": "", "print_hide": 0, @@ -73,6 +73,67 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "depends_on": "eval:doc.get_students_from==\"Program Enrollment\"", + "fieldname": "student_batch", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Student Batch", + "length": 0, + "no_copy": 0, + "options": "Student Batch Name", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "column_break_3", + "fieldtype": "Column Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -110,8 +171,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "get_students", - "fieldtype": "Button", + "fieldname": "academic_term", + "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -119,9 +180,10 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Get Students", + "label": "Academic Term", "length": 0, "no_copy": 0, + "options": "Academic Term", "permlevel": 0, "precision": "", "print_hide": 0, @@ -163,6 +225,36 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "get_students", + "fieldtype": "Button", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Get Students", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -209,6 +301,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, + "label": "Enrollment Details", "length": 0, "no_copy": 0, "permlevel": 0, @@ -229,7 +322,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "depends_on": "eval:doc.get_students_from==\"Program Enrollments\"", + "depends_on": "eval:doc.get_students_from==\"Program Enrollment\"", "fieldname": "new_program", "fieldtype": "Link", "hidden": 0, @@ -261,8 +354,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "depends_on": "eval:doc.get_students_from==\"Program Enrollments\"", - "fieldname": "new_academic_year", + "fieldname": "new_student_batch", "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, @@ -271,10 +363,10 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "New Academic Year", + "label": "New Student Batch", "length": 0, "no_copy": 0, - "options": "Academic Year", + "options": "Student Batch Name", "permlevel": 0, "precision": "", "print_hide": 0, @@ -316,6 +408,99 @@ "search_index": 0, "set_only_once": 0, "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "column_break_12", + "fieldtype": "Column Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "depends_on": "eval:doc.get_students_from==\"Program Enrollment\"", + "fieldname": "new_academic_year", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "New Academic Year", + "length": 0, + "no_copy": 0, + "options": "Academic Year", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "depends_on": "eval:doc.get_students_from==\"Program Enrollment\"", + "fieldname": "new_academic_term", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "New Academic Term", + "length": 0, + "no_copy": 0, + "options": "Academic Term", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 } ], "has_web_view": 0, @@ -328,7 +513,7 @@ "issingle": 1, "istable": 0, "max_attachments": 0, - "modified": "2017-12-27 09:35:45.002469", + "modified": "2018-01-02 11:59:40.230689", "modified_by": "Administrator", "module": "Education", "name": "Program Enrollment Tool", diff --git a/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.py b/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.py index d989d9f1d29..824a29582e9 100644 --- a/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.py +++ b/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.py @@ -17,21 +17,26 @@ class ProgramEnrollmentTool(Document): elif not self.academic_year: frappe.throw(_("Mandatory field - Academic Year")) else: - if self.get_students_from == "Student Applicants": - students = frappe.db.sql("select name as student_applicant, title as student_name from \ - `tabStudent Applicant` where program = %s and academic_year = %s",(self.program, self.academic_year), as_dict=1) - else: - students = frappe.db.sql("select student, student_name, student_batch_name from \ - `tabProgram Enrollment` where program = %s and academic_year = %s",(self.program, self.academic_year), as_dict=1) + condition = 'and academic_term=%(academic_term)s' if self.academic_term else " " + if self.get_students_from == "Student Applicant": + students = frappe.db.sql('''select name as student_applicant, title as student_name from `tabStudent Applicant` + where application_status="Approved" and program=%(program)s and academic_year=%(academic_year)s {0}''' + .format(condition), self.as_dict(), as_dict=1) + elif self.get_students_from == "Program Enrollment": + condition2 = 'and student_batch_name=%(student_batch)s' if self.student_batch else " " + students = frappe.db.sql('''select student, student_name, student_batch_name from `tabProgram Enrollment` + where program=%(program)s and academic_year=%(academic_year)s {0} {1}''' + .format(condition, condition2), self.as_dict(), as_dict=1) + student_list = [d.student for d in students] + if student_list: + inactive_students = frappe.db.sql(''' + select name as student, title as student_name from `tabStudent` where name in (%s) and enabled = 0''' % + ', '.join(['%s']*len(student_list)), tuple(student_list), as_dict=1) - inactive_students = frappe.db.sql(''' - select name as student, title as student_name from `tabStudent` where name in (%s) and enabled = 0''' % - ', '.join(['%s']*len(student_list)), tuple(student_list), as_dict=1) - - for student in students: - if student.student in [d.student for d in inactive_students]: - students.remove(student) + for student in students: + if student.student in [d.student for d in inactive_students]: + students.remove(student) if students: return students @@ -39,18 +44,22 @@ class ProgramEnrollmentTool(Document): frappe.throw(_("No students Found")) def enroll_students(self): - for stud in self.students: + total = len(self.students) + for i, stud in enumerate(self.students): + frappe.publish_realtime("program_enrollment_tool", dict(progress=[i+1, total]), user=frappe.session.user) if stud.student: prog_enrollment = frappe.new_doc("Program Enrollment") prog_enrollment.student = stud.student prog_enrollment.student_name = stud.student_name - prog_enrollment.student_batch_name = stud.student_batch_name prog_enrollment.program = self.new_program prog_enrollment.academic_year = self.new_academic_year + prog_enrollment.academic_term = self.new_academic_term + prog_enrollment.student_batch_name = stud.student_batch_name if stud.student_batch_name else self.new_student_batch prog_enrollment.save() elif stud.student_applicant: prog_enrollment = enroll_student(stud.student_applicant) prog_enrollment.academic_year = self.academic_year + prog_enrollment.academic_term = self.academic_term + prog_enrollment.student_batch_name = stud.student_batch_name if stud.student_batch_name else self.new_student_batch prog_enrollment.save() - frappe.msgprint("Students have been enrolled.") - \ No newline at end of file + frappe.msgprint("{0} Students have been enrolled.".format(total)) diff --git a/erpnext/education/doctype/program_enrollment_tool_student/program_enrollment_tool_student.json b/erpnext/education/doctype/program_enrollment_tool_student/program_enrollment_tool_student.json index 0dbe1b87a9f..9be292b65ea 100644 --- a/erpnext/education/doctype/program_enrollment_tool_student/program_enrollment_tool_student.json +++ b/erpnext/education/doctype/program_enrollment_tool_student/program_enrollment_tool_student.json @@ -133,6 +133,37 @@ "search_index": 0, "set_only_once": 0, "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "student_batch_name", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Student Batch Name", + "length": 0, + "no_copy": 0, + "options": "Student Batch Name", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 } ], "has_web_view": 0, @@ -145,7 +176,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2017-11-10 19:09:59.530615", + "modified": "2018-01-02 12:03:53.890741", "modified_by": "Administrator", "module": "Education", "name": "Program Enrollment Tool Student", diff --git a/erpnext/education/doctype/student_applicant/student_applicant.json b/erpnext/education/doctype/student_applicant/student_applicant.json index 9c8423494b3..1140984a83b 100644 --- a/erpnext/education/doctype/student_applicant/student_applicant.json +++ b/erpnext/education/doctype/student_applicant/student_applicant.json @@ -320,6 +320,37 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "academic_term", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Academic Term", + "length": 0, + "no_copy": 0, + "options": "Academic Term", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -1058,7 +1089,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2017-11-10 19:08:55.049625", + "modified": "2018-01-02 11:47:14.944338", "modified_by": "Administrator", "module": "Education", "name": "Student Applicant",