[minor] Program Enrollment Tool (#15013)

* Make academic term field mandatory

* Add disabled field to Student Group

* Mandatory check in Education Settings for Academic Term

* Fix as per review
diff --git a/erpnext/demo/user/education.py b/erpnext/demo/user/education.py
index 8c82f87..e4bb9ff 100644
--- a/erpnext/demo/user/education.py
+++ b/erpnext/demo/user/education.py
@@ -51,12 +51,12 @@
 		
 def assign_student_group(student, student_name, program, courses, batch):
 	course_list = [d["course"] for d in courses]
-	for d in frappe.get_list("Student Group", fields=("name"), filters={"program": program, "course":("in", course_list)}):
+	for d in frappe.get_list("Student Group", fields=("name"), filters={"program": program, "course":("in", course_list), "disabled": 0}):
 		student_group = frappe.get_doc("Student Group", d.name)
 		student_group.append("students", {"student": student, "student_name": student_name,
 			"group_roll_number":len(student_group.students)+1, "active":1})
 		student_group.save()
-	student_batch = frappe.get_list("Student Group", fields=("name"), filters={"program": program, "group_based_on":"Batch", "batch":batch})[0]
+	student_batch = frappe.get_list("Student Group", fields=("name"), filters={"program": program, "group_based_on":"Batch", "batch":batch, "disabled": 0})[0]
 	student_batch_doc = frappe.get_doc("Student Group", student_batch.name)
 	student_batch_doc.append("students", {"student": student, "student_name": student_name,
 		"group_roll_number":len(student_batch_doc.students)+1, "active":1})
@@ -65,7 +65,7 @@
 
 def mark_student_attendance(current_date):
 	status = ["Present", "Absent"]
-	for d in frappe.db.get_list("Student Group", filters={"group_based_on": "Batch"}):
+	for d in frappe.db.get_list("Student Group", filters={"group_based_on": "Batch", "disabled": 0}):
 		students = get_student_group_students(d.name)
 		for stud in students:
 			make_attendance_records(stud.student, stud.student_name, status[weighted_choice([9,4])], None, d.name, current_date)
@@ -77,7 +77,7 @@
 
 def make_assessment_plan(date):
 	for d in range(1,4):
-		random_group = get_random("Student Group", {"group_based_on": "Course"}, True)
+		random_group = get_random("Student Group", {"group_based_on": "Course", "disabled": 0}, True)
 		doc = frappe.new_doc("Assessment Plan")
 		doc.student_group = random_group.name
 		doc.course = random_group.course
diff --git a/erpnext/education/doctype/education_settings/education_settings.json b/erpnext/education/doctype/education_settings/education_settings.json
index a0b8e99..c1eaa11 100644
--- a/erpnext/education/doctype/education_settings/education_settings.json
+++ b/erpnext/education/doctype/education_settings/education_settings.json
@@ -201,6 +201,38 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "default": "0", 
+   "description": "If enabled, field Academic Term will be Mandatory in Program Enrollment Tool.", 
+   "fieldname": "academic_term_reqd", 
+   "fieldtype": "Check", 
+   "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": "Make Academic Term Mandatory", 
+   "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, 
    "fieldname": "section_break_7", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -267,7 +299,7 @@
  "issingle": 1, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2017-11-28 15:45:30.324324", 
+ "modified": "2018-07-26 04:43:35.406690", 
  "modified_by": "Administrator", 
  "module": "Education", 
  "name": "Education Settings", 
diff --git a/erpnext/education/doctype/fee_schedule/fee_schedule.js b/erpnext/education/doctype/fee_schedule/fee_schedule.js
index c4fff77..1338331 100644
--- a/erpnext/education/doctype/fee_schedule/fee_schedule.js
+++ b/erpnext/education/doctype/fee_schedule/fee_schedule.js
@@ -31,7 +31,8 @@
 			return {
 				"program": frm.doc.program,
 				"academic_term": frm.doc.academic_term,
-				"academic_year": frm.doc.academic_year
+				"academic_year": frm.doc.academic_year,
+				"disabled": 0
 			};
 		});
 		frappe.realtime.on("fee_schedule_progress", function(data) {
diff --git a/erpnext/education/doctype/program_enrollment/program_enrollment.json b/erpnext/education/doctype/program_enrollment/program_enrollment.json
index 00b1373..7e0701c 100644
--- a/erpnext/education/doctype/program_enrollment/program_enrollment.json
+++ b/erpnext/education/doctype/program_enrollment/program_enrollment.json
@@ -671,7 +671,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2017-12-27 10:59:36.838548", 
+ "modified": "2018-07-26 04:44:03.781418", 
  "modified_by": "Administrator", 
  "module": "Education", 
  "name": "Program Enrollment", 
diff --git a/erpnext/education/doctype/program_enrollment/program_enrollment.py b/erpnext/education/doctype/program_enrollment/program_enrollment.py
index 0f9bb96..455ad9c 100644
--- a/erpnext/education/doctype/program_enrollment/program_enrollment.py
+++ b/erpnext/education/doctype/program_enrollment/program_enrollment.py
@@ -86,7 +86,6 @@
 					"program": filters['program']
 				})
 
-
 @frappe.whitelist()
 def get_students(doctype, txt, searchfield, start, page_len, filters):
 	if not filters.get("academic_term"):
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 2e54a2f..06d7598 100644
--- a/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.js
+++ b/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.js
@@ -5,6 +5,9 @@
 	setup: function(frm) {
 		frm.add_fetch("student", "title", "student_name");
 		frm.add_fetch("student_applicant", "title", "student_name");
+		if(frm.doc.__onload && frm.doc.__onload.academic_term_reqd) {
+			frm.toggle_reqd("academic_term", true);
+		}
 	},
 
 	"refresh": function(frm) {
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 d611a6f..35ad98d 100644
--- a/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.json
+++ b/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.json
@@ -513,7 +513,7 @@
  "issingle": 1, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-01-02 11:59:40.230689", 
+ "modified": "2018-07-26 04:44:13.232146", 
  "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 ca5b49c..6223331 100644
--- a/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.py
+++ b/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.py
@@ -7,8 +7,13 @@
 from frappe import _
 from frappe.model.document import Document
 from erpnext.education.api import enroll_student
+from frappe.utils import cint
 
 class ProgramEnrollmentTool(Document):
+	def onload(self):
+		academic_term_reqd = cint(frappe.db.get_single_value('Education Settings', 'academic_term_reqd'))
+		self.set_onload("academic_term_reqd", academic_term_reqd)
+
 	def get_students(self):
 		students = []
 		if not self.get_students_from:
diff --git a/erpnext/education/doctype/student_attendance_tool/student_attendance_tool.js b/erpnext/education/doctype/student_attendance_tool/student_attendance_tool.js
index df6d132..cc9607d 100644
--- a/erpnext/education/doctype/student_attendance_tool/student_attendance_tool.js
+++ b/erpnext/education/doctype/student_attendance_tool/student_attendance_tool.js
@@ -7,7 +7,8 @@
 		frm.set_query("student_group", function() {
 			return {
 				"filters": {
-					"group_based_on": frm.doc.group_based_on
+					"group_based_on": frm.doc.group_based_on,
+					"disabled": 0
 				}
 			};
 		});
diff --git a/erpnext/education/doctype/student_group/student_group.json b/erpnext/education/doctype/student_group/student_group.json
index 37a611b..0af1565 100644
--- a/erpnext/education/doctype/student_group/student_group.json
+++ b/erpnext/education/doctype/student_group/student_group.json
@@ -298,6 +298,37 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
+   "default": "0", 
+   "fieldname": "disabled", 
+   "fieldtype": "Check", 
+   "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": "Disabled", 
+   "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, 
    "collapsible_depends_on": "", 
    "columns": 0, 
    "depends_on": "eval:!doc.__islocal", 
@@ -459,7 +490,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2017-11-10 19:09:37.370864", 
+ "modified": "2018-07-26 04:17:10.836912", 
  "modified_by": "Administrator", 
  "module": "Education", 
  "name": "Student Group", 
diff --git a/erpnext/education/report/student_and_guardian_contact_details/student_and_guardian_contact_details.py b/erpnext/education/report/student_and_guardian_contact_details/student_and_guardian_contact_details.py
index 641b783..4d2e510 100644
--- a/erpnext/education/report/student_and_guardian_contact_details/student_and_guardian_contact_details.py
+++ b/erpnext/education/report/student_and_guardian_contact_details/student_and_guardian_contact_details.py
@@ -99,7 +99,7 @@
 
 def get_student_roll_no(academic_year, program, batch):
 	student_group = frappe.get_all("Student Group",
-		filters={"academic_year":academic_year, "program":program, "batch":batch})
+		filters={"academic_year":academic_year, "program":program, "batch":batch, "disabled": 0})
 	if student_group:
 		roll_no_dict = dict(frappe.db.sql('''select student, group_roll_number from `tabStudent Group Student` where parent=%s''',
 			(student_group[0].name)))