Changes in Program Enrollment and Report for Student Contact Details (#8176)

* Added the student house name in the program enrollment

* added report for the student contact details

* Enabled tag in Student master and fix in student enrollment tool

* [Fix] School House and Report
This commit is contained in:
Manas Solanki 2017-03-29 16:07:31 +05:30 committed by Nabin Hait
parent 79731360ed
commit 8519b4bfe4
12 changed files with 391 additions and 7 deletions

View File

@ -1,5 +1,6 @@
{
"allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
"autoname": "PE.#####",
@ -107,19 +108,19 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "student_batch_name",
"fieldname": "school_house",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 1,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Student Batch Name",
"label": "School House",
"length": 0,
"no_copy": 0,
"options": "Student Batch Name",
"options": "School House",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -190,6 +191,36 @@
"set_only_once": 0,
"unique": 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": 1,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "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
},
{
"allow_on_submit": 0,
"bold": 0,
@ -369,19 +400,19 @@
"unique": 0
}
],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_field": "image",
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 1,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2017-02-20 13:19:29.456157",
"modified": "2017-03-29 15:30:03.359985",
"modified_by": "Administrator",
"module": "Schools",
"name": "Program Enrollment",

View File

@ -23,6 +23,16 @@ class ProgramEnrollmentTool(Document):
else:
students = frappe.db.sql("select student, student_name from \
`tabProgram Enrollment` where program = %s and academic_year = %s",(self.program, self.academic_year), as_dict=1)
student_list = [d.student for d in students]
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)
if students:
return students
else:

View File

@ -0,0 +1,8 @@
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.ui.form.on('School House', {
refresh: function(frm) {
}
});

View File

@ -0,0 +1,92 @@
{
"allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
"autoname": "field:house_name",
"beta": 0,
"creation": "2017-03-27 15:19:54.672995",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "Setup",
"editable_grid": 1,
"engine": "InnoDB",
"fields": [
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "house_name",
"fieldtype": "Data",
"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": "House Name",
"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": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
}
],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-03-29 15:33:15.757309",
"modified_by": "Administrator",
"module": "Schools",
"name": "School House",
"name_case": "",
"owner": "Administrator",
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Academics User",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
}
],
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 0,
"track_seen": 0
}

View File

@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
class SchoolHouse(Document):
pass

View File

@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
import frappe
import unittest
class TestSchoolHouse(unittest.TestCase):
pass

View File

@ -13,6 +13,92 @@
"editable_grid": 0,
"engine": "InnoDB",
"fields": [
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "section_break_1",
"fieldtype": "Section 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_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "1",
"fieldname": "enabled",
"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": "Enabled",
"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_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "section_break_3",
"fieldtype": "Section 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_on_submit": 0,
"bold": 0,
@ -992,7 +1078,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2017-03-15 17:50:09.677184",
"modified": "2017-03-29 12:57:26.293876",
"modified_by": "Administrator",
"module": "Schools",
"name": "Student",

View File

@ -0,0 +1,29 @@
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.query_reports["Student and Guardian Contact Details"] = {
"filters": [
{
"fieldname":"academic_year",
"label": __("Academic Year"),
"fieldtype": "Link",
"options": "Academic Year",
"reqd": 1,
},
{
"fieldname":"program",
"label": __("Program"),
"fieldtype": "Link",
"options": "Program",
"reqd": 1
},
{
"fieldname":"student_batch_name",
"label": __("Batch Name"),
"fieldtype": "Link",
"options": "Student Batch Name",
"reqd": 1
},
]
}

View File

@ -0,0 +1,26 @@
{
"add_total_row": 0,
"apply_user_permissions": 1,
"creation": "2017-03-27 17:47:16.831433",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"idx": 0,
"is_standard": "Yes",
"modified": "2017-03-27 18:34:08.867661",
"modified_by": "Administrator",
"module": "Schools",
"name": "Student and Guardian Contact Details",
"owner": "Administrator",
"ref_doctype": "Program Enrollment",
"report_name": "Student and Guardian Contact Details",
"report_type": "Script Report",
"roles": [
{
"role": "Instructor"
},
{
"role": "Academics User"
}
]
}

View File

@ -0,0 +1,82 @@
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe import _
def execute(filters=None):
columns, data = [], []
academic_year = filters.get("academic_year")
program = filters.get("program")
student_batch_name = filters.get("student_batch_name")
columns = get_columns()
program_enrollments = frappe.get_list("Program Enrollment", fields=["student", "student_name"],
filters={"academic_year": academic_year, "program": program, "student_batch_name": student_batch_name})
student_list = [d.student for d in program_enrollments]
if not student_list:
return columns, []
student_mobile_map = get_student_mobile_no(student_list)
guardian_map = get_guardian_map(student_list)
for d in program_enrollments:
row = [d.student, d.student_name, student_mobile_map.get(d.student)]
student_guardians = guardian_map.get(d.student)
if student_guardians:
for i in xrange(2):
if i < len(student_guardians):
g = student_guardians[i]
row += [g.guardian_name, g.relation, g.mobile_number]
data.append(row)
return columns, data
def get_columns():
columns = [
_("Student ID") + ":Link/Student:90",
_("Student Name") + "::150",
_("Student Mobile No.") + "::110",
_("Guardian1 Name") + "::150",
_("Relation with Guardian1") + "::80",
_("Guardian1 Mobile No") + "::125",
_("Guardian2 Name") + "::150",
_("Relation with Guardian2") + "::80",
_("Guardian2 Mobile No") + "::125",
]
return columns
def get_student_mobile_no(student_list):
student_mobile_map = frappe._dict()
student_mobile_no = frappe.db.sql('''
select name, student_mobile_number from `tabStudent` where name in (%s)''' %
', '.join(['%s']*len(student_list)), tuple(student_list), as_dict=1)
for s in student_mobile_no:
student_mobile_map[s.name] = s.student_mobile_number
return student_mobile_map
def get_guardian_map(student_list):
guardian_map = frappe._dict()
guardian_details = frappe.db.sql('''
select parent, guardian, guardian_name, relation from `tabStudent Guardian` where parent in (%s)''' %
', '.join(['%s']*len(student_list)), tuple(student_list), as_dict=1)
guardian_list = list(set([g.guardian for g in guardian_details]))
guardian_mobile_no = dict(frappe.db.sql("""select name, mobile_number from `tabGuardian`
where name in (%s)""" % ", ".join(['%s']*len(guardian_list)), tuple(guardian_list)))
for guardian in guardian_details:
guardian["mobile_number"] = guardian_mobile_no.get(guardian.guardian)
guardian_map.setdefault(guardian.parent, []).append(guardian)
return guardian_map